diff --git a/src/acquisition/flusurv/api.py b/src/acquisition/flusurv/api.py index dd602766a..735800eb6 100644 --- a/src/acquisition/flusurv/api.py +++ b/src/acquisition/flusurv/api.py @@ -323,7 +323,16 @@ def _group_by_epiweek(self, data): def _groupid_to_name(self, ageid, sexid, raceid, fluid): if ((ageid, sexid, raceid, fluid).count(0) < 3): - raise ValueError("Expect at least three of four group ids to be 0") + warn( + "We expect an obs to represent only a single demographic group at " + + "a time. This obs represents multiple, with demographic IDs " + + f"ageid {ageid}, sexid {sexid}, raceid {raceid}, fluid {fluid}. " + + "Skip it." + ) + # This obs will be added to the processed data, but won't be + # inserted into the DB, since the column name is not in + # constants.EXPECTED_GROUPS. + group = "_".join((str(ageid), str(sexid), str(raceid), str(fluid))) if (ageid, sexid, raceid, fluid).count(0) == 4: group = "overall" # In all cases, if id is not available as a key in the dict, use the diff --git a/tests/acquisition/flusurv/test_flusurv.py b/tests/acquisition/flusurv/test_flusurv.py index 18eb1aa33..c9c4a75fd 100644 --- a/tests/acquisition/flusurv/test_flusurv.py +++ b/tests/acquisition/flusurv/test_flusurv.py @@ -379,7 +379,7 @@ def test_groupids_to_name(self): with self.assertRaisesRegex(ValueError, "Ageid cannot be 6"): api_fetcher._groupid_to_name(6, 0, 0, 0) - with self.assertRaisesRegex(ValueError, "Expect at least three of four group ids to be 0"): + with self.assertWarnsRegex(Warning, "We expect an obs to represent only a single demographic group at a time"): api_fetcher._groupid_to_name(1, 1, 0, 0) api_fetcher._groupid_to_name(0, 1, 1, 0) api_fetcher._groupid_to_name(1, 1, 1, 1)