emodpy.emod_task module

emodpy.emod_task.dev_mode = False

Note that these 3 functions could be member functions of EMODTask but Python modules are already pretty good at being ‘static classes’.

emodpy.emod_task.add_ep4_from_path(task, ep4_path='EP4')

Add embedded Python scripts from a given path.

emodpy.emod_task.default_ep4_fn(task, ep4_path=None)
class emodpy.emod_task.EMODTask(command: typing.Union[str, idmtools.entities.command_line.CommandLine] = <property object>, platform_requirements: typing.Set[idmtools.entities.platform_requirements.PlatformRequirements] = <factory>, _ITask__pre_creation_hooks: typing.List[typing.Callable[[typing.Union[idmtools.entities.simulation.Simulation, idmtools.entities.iworkflow_item.IWorkflowItem], idmtools.entities.iplatform.IPlatform], typing.NoReturn]] = <factory>, _ITask__post_creation_hooks: typing.List[typing.Callable[[typing.Union[idmtools.entities.simulation.Simulation, idmtools.entities.iworkflow_item.IWorkflowItem], idmtools.entities.iplatform.IPlatform], typing.NoReturn]] = <factory>, common_assets: idmtools.assets.asset_collection.AssetCollection = <factory>, transient_assets: idmtools.assets.asset_collection.AssetCollection = <factory>, eradication_path: typing.Optional[str] = None, demographics: emodpy.emod_file.DemographicsFiles = <factory>, migrations: emodpy.emod_file.MigrationFiles = <factory>, reporters: emodpy.reporters.base.Reporters = <factory>, climate: emodpy.emod_file.ClimateFiles = <factory>, config: dict = <factory>, config_file_name: str = 'config.json', campaign: emodpy.emod_campaign.EMODCampaign = <factory>, simulation_demographics: emodpy.emod_file.DemographicsFiles = <factory>, simulation_migrations: emodpy.emod_file.MigrationFiles = <factory>, use_embedded_python: bool = True, is_linux: bool = False, implicit_configs: list = <factory>, sif_filename: typing.Optional[str] = None)

Bases: idmtools.entities.itask.ITask

EMODTask allows easy running and configuration of EMOD Experiments and Simulations

eradication_path: str = None

Eradication path. Can also be set through config file

demographics: emodpy.emod_file.DemographicsFiles

Common Demographics

migrations: emodpy.emod_file.MigrationFiles

Common Migrations

reporters: emodpy.reporters.base.Reporters

Common Reports

climate: emodpy.emod_file.ClimateFiles

Common Climate

config: dict

Represents config.jon

config_file_name: str = 'config.json'
campaign: emodpy.emod_campaign.EMODCampaign

Campaign configuration

simulation_demographics: emodpy.emod_file.DemographicsFiles

Simulation level demographics such as overlays

simulation_migrations: emodpy.emod_file.MigrationFiles

Simulation level migrations

use_embedded_python: bool = True

Add –python-script-path to command line

is_linux: bool = False
implicit_configs: list
sif_filename: str = None
sif_path = None
create_campaign_from_callback(builder, params=None)

write_campaign (str) – if not None, the path to write the campaign to

create_demog_from_callback(builder, from_sweep=False, params=None)

Execute the implicit config functions created by the demographics builder.

classmethod from_default2(eradication_path, schema_path, param_custom_cb=None, config_path='config.json', campaign_builder=None, ep4_custom_cb=<function default_ep4_fn>, demog_builder=None, plugin_report=None, serial_pop_files=None, write_default_config=None, ep4_path=None, **kwargs) emodpy.emod_task.EMODTask

Create a task from emod-api Defaults

  • eradication_path – Path to Eradication binary.

  • schema_path – Path to schema.json.

  • param_custom_cb – Function that sets parameters for config.

  • campaign_builder – Function that builds the campaign.

  • ep4_custom_cb – Function that sets EP4 assets. There are 4 options for specificying EP4 scripts: 1) Set ep4_custom_cb=None. This just says “don’t even attempt to use EP4 scripts”. Not the default. 2) All defaults. This uses the built-in ep4 scripts (inside emodpy module) which does some standard pre- and post-processing. You can’t edit these scripts. 3) Set the (new) ep4_path to your local path where your custom scripts are. Leave out ep4_custom_cb so it uses the default function (but with your path). 4) Power mode where you set ep4_custom_cb to your own function which gives you all the power. Probably don’t need this.

  • demog_builder – Function that builds the demographics configuration and optional migration configuration.

  • plugin_report – Custom reports file.

  • serial_pop_files – Input “.dtk” serialized population files.

  • config_path – Optional filename for the generated config.json, if you don’t like that name.

  • write_default_config – Set to true if you want to have the default_config.json written locally for inspection.

  • ep4_path – See ep4_custom_cb section.



classmethod from_files(eradication_path=None, config_path=None, campaign_path=None, demographics_paths=None, ep4_path=None, custom_reports_path=None, asset_path=None, **kwargs)

Load custom EMOD files when creating EMODTask.

  • asset_path – If an asset path is passed, the climate, dlls, and migrations will be searched there

  • eradication_path – The eradication.exe path.

  • config_path – The custom configuration file.

  • campaign_path – The custom campaign file.

  • demographics_paths – The custom demographics files (single file or a list).

  • custom_reports_path – Custom reports file

Returns: An initialized experiment

load_files(config_path=None, campaign_path=None, custom_reports_path=None, demographics_paths=None, asset_path=None) NoReturn

Load files in the experiment/base_simulation.

  • asset_path – Path to find assets

  • config_path – Configuration file path

  • campaign_path – Campaign file path

  • demographics_paths – Demographics file path

  • custom_reports_path – Path for the custom reports file

pre_creation(parent: Union[idmtools.entities.simulation.Simulation, idmtools.entities.iworkflow_item.IWorkflowItem], platform: idmtools.entities.iplatform.IPlatform)

Call before a task is executed. This ensures our configuration is properly done

set_command_line() NoReturn

Build and set the command line object.


set_sif(path_to_sif, platform=None) NoReturn

Set the Singularity Image File.


gather_common_assets() idmtools.assets.asset_collection.AssetCollection

Gather Experiment Level Assets Returns:

gather_transient_assets() idmtools.assets.asset_collection.AssetCollection

Gather assets that are per simulation Returns:

copy_simulation(base_simulation: idmtools.entities.simulation.Simulation) idmtools.entities.simulation.Simulation

Called when making copies of a simulation.

Here we deep copy parts of the simulation to ensure we don’t accidentally update objects :param base_simulation: Base Simulation


set_parameter(name: str, value: any) dict

Set a value in the EMOD config.json file. This will be deprecated in the future in favour of emod_api.config.

  • name – Name of parameter to set

  • value – Value to set


Tags to set

static set_parameter_sweep_callback(simulation: idmtools.entities.simulation.Simulation, param: str, value: Any) Dict[str, Any]

Convenience callback for sweeps

  • simulation – Simulation we are updating

  • param – Parameter

  • value – Value


Tags to set on simulation

classmethod set_parameter_partial(parameter: str)

Convenience callback for sweeps


parameter – Parameter to set


get_parameter(name: str, default: Optional[Any] = None)

Get a parameter in the simulation.

  • name – The name of the parameter.

  • default – Optional, the default value.


The value of the parameter.


Bulk update the configuration parameter values. This will be deprecated in the future in favour of emod_api.config.


params – A dictionary with new values.



reload_from_simulation(simulation: idmtools.entities.simulation.Simulation)

Optional hook that is called when loading simulations from a platform.

classmethod get_file_from_comps(exp_id, filename)

Get file or files from COMPS. Retrieve all files named <filename> in experiment <exp_id> and put them in a local directory called exp_id. On linux, this is under “latest_experiment”. This function will eventually be added to pyCOMPS.

classmethod cache_experiment_metadata_in_sql(exp_id, optional_data_files=None)

Create local sqlite database of experiment metadata, plus optional data from post-proc file. Tags will be column names.

  • exp_id – ID of experiment.

  • optional_data_files – List of filenames (not path) of downloaded files containing single value post-processed on server.



classmethod handle_experiment_completion(experiment)

Handle experiment completion in consistent way, pull down stderr on failure.


parameter – experiment reference


class emodpy.emod_task.EMODTaskSpecification

Bases: idmtools.registry.task_specification.TaskSpecification

get(configuration: dict) emodpy.emod_task.EMODTask

Return an EMODTask object using provided configuration :param configuration: Configuration for Task


EMODTask for configuration

get_description() str

Defines a description of the plugin


Plugin description

get_example_urls() List[str]

Return a list of examples. This is used by the examples cli command to allow users to quickly load examples locally


List of urls to examples

get_type() Type[emodpy.emod_task.EMODTask]

Returns the Task type defined by specification


get_version() str

Return the version string for EMODTask. This should be the module version so return that