hiv_workflow.lib.utils.runtime module

hiv_workflow.lib.utils.runtime.add_post_channel_config_as_asset(task: idmtools.entities.itask.ITask, channels: List[hiv_workflow.lib.analysis.channel.Channel], reference_data: hiv_workflow.lib.analysis.population_obs.PopulationObs, site_info: dict)None

Construct a post_channel_config.json file to configure the EMOD post-processor for HIV analyzer input and ensure it is added to Task assets

Parameters
  • task – Task object to add file as an asset to

  • channels – list of Channels, model data channels to post-process

  • reference_data – reference data from an ingest form for determining which provinces/ages/etc to post-process model results at.

  • site_info – information related to scaling of simulations back to reference population

Returns

None

hiv_workflow.lib.utils.runtime.compute_num_cores(max_memory_mb: int)int

Computes the number of cores to request for a simulation based on an assumption of one core per 8GB of requested memory for EMOD.

Parameters

max_memory_mb – simulation max memory, in MB

Returns

Number of cores to request

hiv_workflow.lib.utils.runtime.set_python_processing(task: idmtools.entities.itask.ITask, pre: str = None, mid: str = None, post: str = None)idmtools.entities.itask.ITask

Adds EMOD python pre/in/post processing file(s) to the given task as assets and makes sure embedded python is turned off if none are given (it currently defaults to on).

Parameters
  • task – the Task object to potentially add pre/in/post processing files to

  • pre – Defines the pre-processor to use. If ‘standard’, use the in-code standard processor, if a path, the path to a custom pre-processor, if None, no pre-processor will be used.

  • mid – Defines the in-processor to use. If ‘standard’, use the in-code standard processor, if a path, the path to a custom in-processor, if None, no in-processor will be used.

  • post – Defines the post-processor to use. If ‘standard’, use the in-code standard processor, if a path, the path to a custom post-processor, if None, no post-processor will be used.

Returns

The provided task object, modified

hiv_workflow.lib.utils.runtime.add_ingest_form_to_assets(task: idmtools.entities.itask.ITask, path: str)idmtools.entities.itask.ITask

Simply adds the ingest form specified as an asset to the provided task for logging purposes

Parameters
  • task – the Task object to add the ingest form to

  • path – path of the ingest form to add

Returns

The provided task object, modified

hiv_workflow.lib.utils.runtime.map_sample_to_model_input(simulation: idmtools.entities.simulation.Simulation, sample: dict, config_builder: Callable = None, campaign_builder: Callable = None, demographics_builder: Callable = None, random_run_number: bool = True)dict

This method builds config, campaign, and/or demographics objects and sets them on the provide simulation object. It consumes a sample, which is a dict of parameter key/values that are used as overrides to the default behavior of the provided builders.

Parameters
  • simulation – simulation object to add built config/campaign/demographics objects to

  • sample – dict of parameter names/values overrides to use during config/campaign/demographics building

  • config_builder – reference to a function that builds an EMOD config object. None means do not build a config object.

  • campaign_builder – reference to a function that builds an EMOD campaign object. None means do not build a campaign object.

  • demographics_builder – reference to a function that builds an EMOD demographics object. None means do not build a demographics object.

  • random_run_number – if True, run numbers will be randomly assigned, otherwise any pre-existing run number will be used

Returns

A dict of simulation tag names/values

hiv_workflow.lib.utils.runtime.constrain_sample(sample: dict, custom_sample_constrainer: Callable)dict

Calls the provided constraint function on the given sample. Its purpose is to ensure various logical properties in the sample.

Parameters
  • sample – sample to check for logical constraints

  • custom_sample_constrainer – function that accepts a sample and modifies it based on internal constraint logic

Returns

The provide sample, modified

hiv_workflow.lib.utils.runtime.initialize_EMODTask(executable_path: str, schema_path: str, config_builder: Callable = None, campaign_builder: Callable = None, demographics_builder: Callable = None, demographics_paths: List[str] = None, python_processing_setter: Callable = None, channels: List[hiv_workflow.lib.analysis.channel.Channel] = None, reference: hiv_workflow.lib.analysis.population_obs.PopulationObs = None, site_info: dict = None)emodpy.emod_task.EMODTask

Creates an EMODTask object with specified executable, builders, etc set on it.

Parameters
  • executable_path – path to where the model binary is/will be

  • schema_path – path to schema matching model binary

  • config_builder – reference to a function that builds an EMOD config object. None means do not build a config object.

  • campaign_builder – reference to a function that builds an EMOD campaign object. None means do not build a campaign object.

  • demographics_builder – reference to a function that builds an EMOD demographics object. None means do not build a demographics object. Mutually exclusive with demographics_paths.

  • demographics_paths – list of paths to demographics files to use. Mutually exclusive with demographics_builder.

  • python_processing_setter – reference to a function that sets EMOD python pre/in/post processing on an EMODTask object and adds any appropriate assets.

  • channels – list of channels for configuring HIV post-processing for analysis

  • reference – reference data object for configuring HIV post-processing for analysis

  • site_info – information related to scaling of simulations back to reference population, for configuring HIV post-procesing for analysis

Returns

A configured EMODTask object

hiv_workflow.lib.utils.runtime.load_model(model_name: str, model_root: str = 'models') → module

Loads a model directory by name

Parameters
  • model_name – name of model (directory) to load

  • model_root – directory containing model to load

Returns

The loaded model

hiv_workflow.lib.utils.runtime.available_algorithms() → List[str]
Returns

A list of calibration algorithms available for use by name

hiv_workflow.lib.utils.runtime.load_algorithm(algorithm_name: str, algorithm_root: str = 'hiv_workflow.lib.calibration.algorithms') → module

Loads a calibration algorithm binding code by name relative to a code path

Parameters
  • algorithm_name – the name of the algorithm to load binding code for.

  • algorithm_root – the path to a module containing algorithm bindings to load

Returns

The module of binding code for the specified calibration algorithm

hiv_workflow.lib.utils.runtime.detect_duplicate_items_in(items: Iterable) → List

Simple function that detects and returns the duplicates in an provide iterable.

Parameters

items – a collection of items to search for duplicates

Returns

A list of duplicated items from the provided list