Saver and Uploader¶
The saver model takes results from a Cascade-AT model and saves them in the correct format to the IHME file system and also uploads them to the epi databases.
The results of a Cascade-AT model need to be saved to the IHME epi databases. This module wrangles the draw files from a completed model and uploads summaries to the epi databases for visualization in EpiViz.
Eventually, this module should be replaced by something like save_results_at
.
-
exception
cascade_at.saver.results_handler.
ResultsError
[source]¶ Raised when there is an error with uploading or validating the results.
-
class
cascade_at.saver.results_handler.
ResultsHandler
[source]¶ -
self.
draw_keys
¶ The keys of the draw data frames
-
self.
summary_cols
¶ The columns that need to be present in all summary files
-
summarize_results
(df)[source]¶ Summarizes results from either mean or draw cols to get mean, upper, and lower cols.
- Parameters
df (
DataFrame
) – A data frame with draw columns or just a mean column- Return type
DataFrame
-
save_draw_files
(df, model_version_id, directory, add_summaries)[source]¶ Saves a data frame by location and sex in .csv files. This currently saves the summaries, but when we get save_results working it will save draws and then summaries as part of that.
- Parameters
df (
DataFrame
) –- Data frame with the following columns:
[‘location_id’, ‘year_id’, ‘age_group_id’, ‘sex_id’, ‘measure_id’, ‘mean’ OR ‘draw’]
model_version_id (
int
) – The model version to attach to the datadirectory (
Path
) – Path to save the files toadd_summaries (
bool
) – Save an additional file with summaries to upload
- Return type
None
-
save_summary_files
(df, model_version_id, directory)[source]¶ Saves a data frame with summaries by location and sex in summary.csv files.
- Parameters
df (
DataFrame
) –- Data frame with the following columns:
[‘location_id’, ‘year_id’, ‘age_group_id’, ‘sex_id’, ‘measure_id’, ‘mean’, ‘lower’, and ‘upper’]
model_version_id (
int
) – The model version to attach to the datadirectory (
Path
) – Path to save the files to
- Return type
None
-
static
upload_summaries
(directory, conn_def, table)[source]¶ Uploads results from a directory to the model_estimate_final table in the Epi database specified by the conn_def argument.
In the future, this will probably be replaced by save_results_dismod but we don’t have draws to work with so we’re just uploading summaries for now directly.
- Parameters
directory (
Path
) – Directory where files are savedconn_def (
str
) – Connection to a database to be used with db_tools.ezfuncstable (
str
) – which table to upload to
- Return type
None
-