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')[source]#

Add embedded Python scripts from a given path.

emodpy.emod_task.default_ep4_fn(task, ep4_path=None)[source]#
class emodpy.emod_task.EMODTask(command: 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[[~idmtools.entities.simulation.Simulation | ~idmtools.entities.iworkflow_item.IWorkflowItem, ~idmtools.entities.iplatform.IPlatform], ~typing.NoReturn]] = <factory>, _ITask__post_creation_hooks: ~typing.List[~typing.Callable[[~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: str | None = 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, py_path_list: list = <factory>, is_linux: bool = False, implicit_configs: list = <factory>, sif_filename: str | None = None)[source]#

Bases: 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: DemographicsFiles#

Common Demographics

migrations: MigrationFiles#

Common Migrations

reporters: Reporters#

Common Reports

climate: ClimateFiles#

Common Climate

config: dict#

Represents config.jon

config_file_name: str = 'config.json'#
campaign: EMODCampaign#

Campaign configuration

simulation_demographics: DemographicsFiles#

Simulation level demographics such as overlays

simulation_migrations: MigrationFiles#

Simulation level migrations

use_embedded_python: bool = True#

Add –python-script-path to command line

py_path_list: list#
is_linux: bool = False#
implicit_configs: list#
sif_filename: str = None#
sif_path = None#
create_campaign_from_callback(builder, params=None)[source]#
Parameters:

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

create_demog_from_callback(builder, from_sweep=False, params=None)[source]#
handle_implicit_configs()[source]#

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) EMODTask[source]#

Create a task from emod-api Defaults

Parameters:
  • 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.

Returns:

EMODTask

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)[source]#

Load custom EMOD files when creating EMODTask.

Parameters:
  • 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[source]#

Load files in the experiment/base_simulation.

Parameters:
  • 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: Simulation | IWorkflowItem, platform: IPlatform)[source]#

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

set_command_line() NoReturn[source]#

Build and set the command line object.

Returns:

add_py_path(path_to_add) NoReturn[source]#

Add path to list of python paths prepended to sys.path in embedded interpreter

Returns:

set_sif(path_to_sif, platform=None) NoReturn[source]#

Set the Singularity Image File.

Returns:

gather_common_assets() AssetCollection[source]#

Gather Experiment Level Assets Returns:

gather_transient_assets() AssetCollection[source]#

Gather assets that are per simulation Returns:

copy_simulation(base_simulation: Simulation) Simulation[source]#

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

Returns:

set_parameter(name: str, value: any) dict[source]#

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

Parameters:
  • name – Name of parameter to set

  • value – Value to set

Returns:

Tags to set

static set_parameter_sweep_callback(simulation: Simulation, param: str, value: Any) Dict[str, Any][source]#

Convenience callback for sweeps

Parameters:
  • simulation – Simulation we are updating

  • param – Parameter

  • value – Value

Returns:

Tags to set on simulation

classmethod set_parameter_partial(parameter: str)[source]#

Convenience callback for sweeps

Parameters:

parameter – Parameter to set

Returns:

get_parameter(name: str, default: Any | None = None)[source]#

Get a parameter in the simulation.

Parameters:
  • name – The name of the parameter.

  • default – Optional, the default value.

Returns:

The value of the parameter.

update_parameters(params)[source]#

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

Parameters:

params – A dictionary with new values.

Returns:

None

reload_from_simulation(simulation: Simulation)[source]#

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

classmethod get_file_from_comps(exp_id, filename)[source]#

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)[source]#

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

Parameters:
  • exp_id – ID of experiment.

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

Returns:

None.

classmethod handle_experiment_completion(experiment)[source]#

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

Parameters:

parameter – experiment reference

Returns:

class emodpy.emod_task.EMODTaskSpecification[source]#

Bases: TaskSpecification

get(configuration: dict) EMODTask[source]#

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

Returns:

EMODTask for configuration

get_description() str[source]#

Defines a description of the plugin

Returns:

Plugin description

get_example_urls() List[str][source]#

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

Returns:

List of urls to examples

get_type() Type[EMODTask][source]#

Returns the Task type defined by specification

Returns:

get_version() str[source]#

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

Returns:

Version