Skip to content

Commit

Permalink
Merge pull request #1742 from materialsproject/dev
Browse files Browse the repository at this point in the history
convert bools and skip non-str
  • Loading branch information
tschaume committed Apr 8, 2024
2 parents f0d7f38 + 2b6957c commit 9085132
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ["ubuntu-latest", "macos-latest"]
os: ["ubuntu-latest"]
python-version: ["3.10", "3.11"]
steps:
- uses: actions/checkout@v3
Expand Down
26 changes: 18 additions & 8 deletions mpcontribs-client/mpcontribs/client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ def _response_hook(resp, *args, **kwargs):
resp.count = 0


def _chunk_by_size(items, max_size=0.95*MAX_BYTES):
def _chunk_by_size(items, max_size=0.95 * MAX_BYTES):
buffer, buffer_size = [], 0

for idx, item in enumerate(items):
Expand Down Expand Up @@ -1732,10 +1732,10 @@ def get_all_ids(
raise MPContribsClientError(f"`op` has to be one of {ops}")

unique_identifiers = self.get_unique_identifiers_flags()
data_id_fields = {
k: v for k, v in data_id_fields.items()
if k in unique_identifiers and isinstance(v, str)
} if data_id_fields else {}
data_id_fields = data_id_fields or {}
for k, v in data_id_fields.items():
if k in unique_identifiers and isinstance(v, str):
data_id_fields[k] = v

ret = {}
query = query or {}
Expand Down Expand Up @@ -2163,9 +2163,19 @@ def submit_contributions(
):
continue

contribs[project_name].append(
{k: deepcopy(contrib[k]) for k in fields if k in contrib}
)
contrib_copy = {}
for k in fields:
if k in contrib:
flat = {}
for kk, vv in flatten(contrib[k], reducer="dot").items():
if isinstance(vv, bool):
flat[kk] = "Yes" if vv else "No"
elif isinstance(vv, str):
flat[kk] = vv

contrib_copy[k] = deepcopy(unflatten(flat, splitter="dot"))

contribs[project_name].append(contrib_copy)

for component in COMPONENTS:
elements = contrib.get(component, [])
Expand Down

0 comments on commit 9085132

Please sign in to comment.