Skip to content

Commit

Permalink
🐛 gbd-risk: Add missing percentages (#3262)
Browse files Browse the repository at this point in the history
* 🐛 Add missing percentages for gbd-risk
  • Loading branch information
Marigold authored Sep 10, 2024
1 parent c827ff1 commit bcf0c24
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
18 changes: 11 additions & 7 deletions etl/grapher_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,13 +458,17 @@ def cleanup_ghost_variables(engine: Engine, dataset_id: int, upserted_variable_i
if rows:
rows = pd.DataFrame(rows, columns=["chartId", "variableId"])

# show a warning
log.warning(
"Variables used in charts will not be deleted automatically",
rows=rows,
variables=variable_ids_to_delete,
)
return False
# raise an error if on staging server
if config.ENV == "staging":
raise ValueError(f"Variables used in charts will not be deleted automatically:\n{rows}")
else:
# otherwise show a warning
log.warning(
"Variables used in charts will not be deleted automatically",
rows=rows,
variables=variable_ids_to_delete,
)
return False

# then variables themselves with related data in other tables
con.execute(
Expand Down
3 changes: 2 additions & 1 deletion etl/steps/data/garden/ihme_gbd/2024-05-20/gbd_risk.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def run(dest_dir: str) -> None:
ds_meadow = paths.load_dataset("gbd_risk")

# Read table from meadow dataset.
tb = ds_meadow["gbd_risk"].reset_index()
tb = ds_meadow.read_table("gbd_risk", reset_index=True)
ds_regions = paths.load_dataset("regions")
#
# Process data.
Expand All @@ -39,6 +39,7 @@ def run(dest_dir: str) -> None:
index_cols=["country", "year", "metric", "measure", "rei", "cause", "age"],
regions=REGIONS,
age_group_mapping=AGE_GROUPS_RANGES,
run_percent=False,
)

# Format the tables
Expand Down
2 changes: 1 addition & 1 deletion etl/steps/data/garden/ihme_gbd/2024-05-20/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def add_regional_aggregates(
assert tb_percent["value"].max() <= 100 or tb_percent.shape[0] == 0
assert tb_percent["value"].min() >= 0 or tb_percent.shape[0] == 0
# Combine all the metrics back together
tb_out = pr.concat([tb_out, tb_percent], ignore_index=True)
tb_out = pr.concat([tb_out, tb_percent], ignore_index=True)
assert tb_out.age.m.origins
tb_out = tb_out.drop(columns="population")
return tb_out
Expand Down

0 comments on commit bcf0c24

Please sign in to comment.