Skip to content

Commit

Permalink
Merge pull request #15 from OCHA-DAP/hotfix/extra-dims-handle-nonetype
Browse files Browse the repository at this point in the history
Fix for cases where there are no extra dims in config
  • Loading branch information
isatotun authored Nov 18, 2024
2 parents e621481 + 39b406d commit dacb088
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def parse_pipeline_config(dataset, test, update, mode):
end_date = config["end_date"]
sel_iso3s = None
forecast = config["forecast"]
extra_dims = parse_extra_dims(config.get("extra_dims"))
extra_dims = parse_extra_dims(config)
if not end_date:
end_date = date.today() - timedelta(days=1)
if update:
Expand Down
17 changes: 10 additions & 7 deletions src/utils/general_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,16 @@ def parse_date(filename):
return pd.to_datetime(res[0])


def parse_extra_dims(extra_dims):
def parse_extra_dims(config):
parsed_extra_dims = {}
for extra_dim in extra_dims:
dim = next(iter(extra_dim))
if extra_dim[dim] == "str":
parsed_extra_dims[dim] = VARCHAR
else:
parsed_extra_dims[dim] = Integer

if "extra_dims" in config.keys():
extra_dims = config.get("extra_dims")
for extra_dim in extra_dims:
dim = next(iter(extra_dim))
if extra_dim[dim] == "str":
parsed_extra_dims[dim] = VARCHAR
else:
parsed_extra_dims[dim] = Integer

return parsed_extra_dims

0 comments on commit dacb088

Please sign in to comment.