Skip to content

Commit 9085132

Browse files
authored
Merge pull request #1742 from materialsproject/dev
convert bools and skip non-str
2 parents f0d7f38 + 2b6957c commit 9085132

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

.github/workflows/testing.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
runs-on: ${{ matrix.os }}
2121
strategy:
2222
matrix:
23-
os: ["ubuntu-latest", "macos-latest"]
23+
os: ["ubuntu-latest"]
2424
python-version: ["3.10", "3.11"]
2525
steps:
2626
- uses: actions/checkout@v3

mpcontribs-client/mpcontribs/client/__init__.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ def _response_hook(resp, *args, **kwargs):
288288
resp.count = 0
289289

290290

291-
def _chunk_by_size(items, max_size=0.95*MAX_BYTES):
291+
def _chunk_by_size(items, max_size=0.95 * MAX_BYTES):
292292
buffer, buffer_size = [], 0
293293

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

17341734
unique_identifiers = self.get_unique_identifiers_flags()
1735-
data_id_fields = {
1736-
k: v for k, v in data_id_fields.items()
1737-
if k in unique_identifiers and isinstance(v, str)
1738-
} if data_id_fields else {}
1735+
data_id_fields = data_id_fields or {}
1736+
for k, v in data_id_fields.items():
1737+
if k in unique_identifiers and isinstance(v, str):
1738+
data_id_fields[k] = v
17391739

17401740
ret = {}
17411741
query = query or {}
@@ -2163,9 +2163,19 @@ def submit_contributions(
21632163
):
21642164
continue
21652165

2166-
contribs[project_name].append(
2167-
{k: deepcopy(contrib[k]) for k in fields if k in contrib}
2168-
)
2166+
contrib_copy = {}
2167+
for k in fields:
2168+
if k in contrib:
2169+
flat = {}
2170+
for kk, vv in flatten(contrib[k], reducer="dot").items():
2171+
if isinstance(vv, bool):
2172+
flat[kk] = "Yes" if vv else "No"
2173+
elif isinstance(vv, str):
2174+
flat[kk] = vv
2175+
2176+
contrib_copy[k] = deepcopy(unflatten(flat, splitter="dot"))
2177+
2178+
contribs[project_name].append(contrib_copy)
21692179

21702180
for component in COMPONENTS:
21712181
elements = contrib.get(component, [])

0 commit comments

Comments
 (0)