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: 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[[Simulation | IWorkflowItem, IPlatform], ~typing.NoReturn]] = <factory>, _ITask__post_creation_hooks: ~typing.List[~typing.Callable[[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)[source]#

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

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

Returns:

Common AssetCollection

gather_transient_assets() AssetCollection[source]#

Gather assets that are unique to this simulation/worktiem.

Returns:

Simulation/workitem level AssetCollection

set_parameter(key: str | int | float, value: str | int | float | Dict[str | int | float, Any])[source]#

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: str | int | float) str | int | float | Dict[str | int | float, Any][source]#

Returns a parameter value.

Parameters:

key – Key of parameter

Returns:

Value of parameter

Raises:

KeyError

update_parameters(values: Dict[str | int | float, str | int | float | Dict[str | int | float, Any]])[source]#

Perform bulk update from another dictionary.

Parameters:

values – Values to update as dictionaryy

Returns:

Values

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

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

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

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

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: 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[[Simulation | IWorkflowItem, IPlatform], ~typing.NoReturn]] = <factory>, _ITask__post_creation_hooks: ~typing.List[~typing.Callable[[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[source]#

Bases: TaskSpecification

JSONConfiguredTaskSpecification defines the plugin specs for JSONConfiguredTask.

get(configuration: dict) JSONConfiguredTask[source]#

Get instance of JSONConfiguredTask with configuration specified.

Parameters:

configuration – Configuration for configuration

Returns:

JSONConfiguredTask with configuration

get_description() str[source]#

Get description for plugin.

Returns:

Description of plugin

get_example_urls() List[str][source]#

Get list of urls with examples for JSONConfiguredTask.

Returns:

List of urls that point to examples relating to JSONConfiguredTask

get_type() Type[JSONConfiguredTask][source]#

Get task type provided by plugin.

Returns:

JSONConfiguredTask

get_version() str[source]#

Returns the version of the plugin.

Returns:

Plugin Version