idmtools_models.json_configured_task module

idmtools json configured task.

Copyright 2021, Bill & Melinda Gates Foundation. All rights reserved.

class idmtools_models.json_configured_task.JSONConfiguredTask(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[Simulation, IWorkflowItem], IPlatform], ~typing.NoReturn]] = <factory>, _ITask__post_creation_hooks: ~typing.List[~typing.Callable[[~typing.Union[Simulation, IWorkflowItem], IPlatform], ~typing.NoReturn]] = <factory>, common_assets: ~idmtools.assets.asset_collection.AssetCollection = <factory>, transient_assets: ~idmtools.assets.asset_collection.AssetCollection = <factory>, parameters: dict = <factory>, envelope: str = None, config_file_name: str = 'config.json', is_config_common: bool = False, configfile_argument: str = None, command_line_argument_no_filename: bool = False)

Bases: ITask

Defines an extensible simple task that implements functionality through optional supplied use hooks.

parameters: dict
envelope: str = None
config_file_name: str = 'config.json'
is_config_common: bool = False
configfile_argument: str = None
command_line_argument_no_filename: bool = False
gather_common_assets() AssetCollection

Gather assets common across an Experiment(Set of Simulations).

Returns:

Common AssetCollection

gather_transient_assets() AssetCollection

Gather assets that are unique to this simulation/worktiem.

Returns:

Simulation/workitem level AssetCollection

set_parameter(key: Union[str, int, float], value: Union[str, int, float, Dict[Union[str, int, float], Any]])

Update a parameter. The type hinting encourages JSON supported types.

Parameters:
  • key – Config

  • value

Returns:

Tags to be defined on the simulation/workitem

get_parameter(key: Union[str, int, float]) Union[str, int, float, Dict[Union[str, int, float], Any]]

Returns a parameter value.

Parameters:

key – Key of parameter

Returns:

Value of parameter

Raises:

KeyError

update_parameters(values: Dict[Union[str, int, float], Union[str, int, float, Dict[Union[str, int, float], Any]]])

Perform bulk update from another dictionary.

Parameters:

values – Values to update as dictionaryy

Returns:

Values

reload_from_simulation(simulation: Simulation, config_file_name: Optional[str] = None, envelope: Optional[str] = None, **kwargs)

Reload from Simulation.

To do this, the process is

  1. First check for a configfile name from arguments, then tags, or the default name

  2. Load the json config file

  3. Check if we got an envelope argument from parameters or the simulation tags, or on the task object

Parameters:
  • simulation – Simulation object with metadata to load info from

  • config_file_name – Optional name of config file

  • envelope – Optional name of envelope

Returns:

Populates the config with config from object

pre_creation(parent: Union[Simulation, WorkflowItem], platform: IPlatform)

Pre-creation. For JSONConfiguredTask, we finalize our configuration file and command line here.

Parameters:
  • parent – Parent of task

  • platform – Platform task is being created on

Returns:

None

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

Performs a callback with a parameter and a value. Most likely users want to use set_parameter_partial instead of this method.

Parameters:
  • simulation – Simulation object

  • param – Param name

  • value – Value to set

Returns:

Tags to add to simulation

classmethod set_parameter_partial(parameter: str)

Callback to be used when sweeping with a json configured model.

Parameters:

parameter – Param name

Returns:

Partial setting a specific parameter

Notes

  • TODO Reference some examples code here

__init__(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[Simulation, IWorkflowItem], IPlatform], ~typing.NoReturn]] = <factory>, _ITask__post_creation_hooks: ~typing.List[~typing.Callable[[~typing.Union[Simulation, IWorkflowItem], IPlatform], ~typing.NoReturn]] = <factory>, common_assets: ~idmtools.assets.asset_collection.AssetCollection = <factory>, transient_assets: ~idmtools.assets.asset_collection.AssetCollection = <factory>, parameters: dict = <factory>, envelope: str = None, config_file_name: str = 'config.json', is_config_common: bool = False, configfile_argument: str = None, command_line_argument_no_filename: bool = False) None
class idmtools_models.json_configured_task.JSONConfiguredTaskSpecification

Bases: TaskSpecification

JSONConfiguredTaskSpecification defines the plugin specs for JSONConfiguredTask.

get(configuration: dict) JSONConfiguredTask

Get instance of JSONConfiguredTask with configuration specified.

Parameters:

configuration – Configuration for configuration

Returns:

JSONConfiguredTask with configuration

get_description() str

Get description for plugin.

Returns:

Description of plugin

get_example_urls() List[str]

Get list of urls with examples for JSONConfiguredTask.

Returns:

List of urls that point to examples relating to JSONConfiguredTask

get_type() Type[JSONConfiguredTask]

Get task type provided by plugin.

Returns:

JSONConfiguredTask

get_version() str

Returns the version of the plugin.

Returns:

Plugin Version