Application Context

Each model run needs to have an object that determines the file structure, connections to the IHME databases, etc.

This context can be modified for a local environment, but that’s not currently implemented in an intuitive or user-friendly way. When we want to enable local runs of an entire cascade, this configuration is what we need to do design work on.

Configuration

There is an additional repository that stores application information for the IHME configuration.

cascade_at.context.configuration.application_config()[source]

Returns a configuration dictionary based on the configuration that is installed into the environment.

Returns

This is a mapping type.

Return type

ConfigParser.SectionProxy

Context

Based on the configuration above, and a model version ID from the epi database, we define a context object that keeps track of database connections and file structures.

class cascade_at.context.model_context.Context(model_version_id, make=False, configure_application=True, root_directory=None)[source]

Bases: object

Context for running a model.

Parameters
  • model_version_id (int) – The model version ID for this context. If you’re not configuring the application, doesn’t matter what this is.

  • make (bool) – Whether or not the make the directory tree for the model.

  • configure_application (bool) – Configure the production application. If False, this can be used for testing on a local machine.

update_status(status)[source]

Updates status in the database.

db_folder(location_id, sex_id)[source]
db_file(location_id, sex_id)[source]

Gets the database file for a given location and sex.

Parameters
  • location_id (int) – Location ID for the database (parent).

  • sex_id (int) – Sex ID for the database, as the reference.

Return type

Path

db_index_file_pattern(location_id, sex_id)[source]

Gets the database file pattern for databases with indices. Used in sample simulate when it’s done in parallel.

Parameters
  • location_id (int) – Location ID for the database (parent).

  • sex_id (int) – Sex ID for the database, as the reference.

Returns

Return type

String representing the absolute path to the index database.

write_inputs(inputs=None, settings=None)[source]

Write the inputs objects to disk.

read_inputs()[source]

Read the inputs from disk.

Return type

(<class ‘cascade_at.inputs.measurement_inputs.MeasurementInputs’>, <class ‘cascade_at.model.grid_alchemy.Alchemy’>, <class ‘cascade_at.settings.settings_config.SettingsConfig’>)

It also provides methods to read in the three things that are always needed to construct models: