Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/allow 0 count #89

Merged
merged 7 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/mds/agg_mds/adapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -1596,7 +1596,7 @@ def gather_metadata(
except ValueError as exc:
logger.error(f"Exception occurred: {exc}. Returning no results")
except RetryError:
logger.error(f"Multiple retrys failed. Returning no results")
logger.error("Multiple retries failed. Returning no results")
return {}


Expand Down
2 changes: 1 addition & 1 deletion src/mds/agg_mds/mds.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def pull_mds(baseURL: str, guid_type: str, batchSize: int = 1000) -> dict:
raise
except httpx.HTTPError as exc:
logger.error(
f"An HTTP error {exc.response.status_code if exc.response is not None else ''} occurred while requesting {exc.request.url}. Aborting futher pulls"
f"An HTTP error {exc.response.status_code if exc.response is not None else ''} occurred while requesting {exc.request.url}. Aborting further pulls"
)
break
return results
5 changes: 4 additions & 1 deletion src/mds/populate.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,10 @@ async def main(commons_config: Commons) -> None:
await populate_metadata(name, common, results, use_temp_index=True)

if mdsCount == 0:
raise ValueError("Could not obtain any metadata from any adapters.")
logger.info(
"Could not obtain any metadata from any adapters. Existing indexes are left in place."
)
return

# populate global information index
await populate_info(commons_config, use_temp_index=True)
Expand Down
65 changes: 32 additions & 33 deletions tests/test_populate.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,43 +456,42 @@ def wipe_return_value(mock: AsyncMock):
respx.get(
"http://testfail/ok//mds/metadata?data=True&_guid_type=discovery_metadata&limit=1000&offset=0"
).mock(return_value=httpx.Response(status_code=500))
with pytest.raises(Exception):
await main(
Commons(
configuration=Config(
settings=Settings(),
schema={
"_subjects_count": FieldDefinition(type="integer"),
"year_awarded": FieldDefinition(type="integer"),
await main(
Commons(
configuration=Config(
settings=Settings(),
schema={
"_subjects_count": FieldDefinition(type="integer"),
"year_awarded": FieldDefinition(type="integer"),
},
),
gen3_commons={
"my_commons": MDSInstance(
mds_url="http://testfail/ok/",
commons_url="test",
columns_to_fields={
"authz": "path:authz",
"tags": "path:tags",
"_subjects_count": "path:subjects_count",
"dbgap_accession_number": "path:study_id",
"study_description": "path:study_description_summary",
"number_of_datafiles": "path:data_files_count",
"investigator": "path:contributor",
},
),
gen3_commons={
"my_commons": MDSInstance(
mds_url="http://testfail/ok/",
commons_url="test",
columns_to_fields={
"authz": "path:authz",
"tags": "path:tags",
"_subjects_count": "path:subjects_count",
"dbgap_accession_number": "path:study_id",
"study_description": "path:study_description_summary",
"number_of_datafiles": "path:data_files_count",
"investigator": "path:contributor",
},
),
},
adapter_commons={
"adapter_commons": AdapterMDSInstance(
mds_url="",
commons_url="",
adapter="icpsr",
),
},
)
},
adapter_commons={
"adapter_commons": AdapterMDSInstance(
mds_url="",
commons_url="",
adapter="icpsr",
),
},
)
)

# check that the get_all_metadata return value has not been changed
# since drop_all should not be called if an exception has been raised
# check that the get_all_metadata return value has not been changed
# since drop_all should not be called if an exception has been raised or no data has been pulled
es = await datastore.init("test", 9200)
assert (await es.get_all_metadata()) == existing_metadata

Expand Down
Loading