idmtools.entities.itask module¶
Defines our ITask interface.
Copyright 2021, Bill & Melinda Gates Foundation. All rights reserved.
- class idmtools.entities.itask.ITask(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>)¶
Bases:
object
ITask represents a task to be ran on a remote system.
A Task should provide all the files and command needed to run remotely.
- platform_requirements: Set[idmtools.entities.platform_requirements.PlatformRequirements]¶
- common_assets: idmtools.assets.asset_collection.AssetCollection¶
Common(Experiment-level) assets
- transient_assets: idmtools.assets.asset_collection.AssetCollection¶
Transient(Simulation-level) assets
- property command¶
The Command to run
- property metadata_fields¶
Collect all metadata fields.
Returns: set of metadata filed names
- add_pre_creation_hook(hook: Callable[[Union[Simulation, IWorkflowItem], IPlatform], NoReturn])¶
Called before a simulation is created on a platform. Each hook receives either a Simulation or WorkflowTask.
- Parameters:
hook – Function to call on event
- Returns:
None
- add_post_creation_hook(hook: Callable[[Union[Simulation, IWorkflowItem], IPlatform], NoReturn])¶
Called after a simulation has been created on a platform. Each hook receives either a Simulation or WorkflowTask.
- Parameters:
hook – Function to call on event
- Returns:
None
- add_platform_requirement(requirement: Union[idmtools.entities.platform_requirements.PlatformRequirements, str]) NoReturn ¶
Adds a platform requirements to a task.
- Parameters:
requirement – Requirement to add task
- Returns:
None
- pre_creation(parent: Union[Simulation, IWorkflowItem], platform: IPlatform)¶
Optional Hook called at the time of creation of task. Can be used to setup simulation and experiment level hooks.
- Parameters:
parent – Parent of Item
platform – Platform executing the task. Useful for querying platform before execution
- Returns:
None
- post_creation(parent: Union[Simulation, IWorkflowItem], platform: IPlatform)¶
Optional Hook called at the after creation task. Can be used to setup simulation and experiment level hooks.
- Parameters:
parent – Parent of Item
platform – Platform executing the task. Useful for querying platform before execution
- Returns:
None
- abstract gather_common_assets() idmtools.assets.asset_collection.AssetCollection ¶
Function called at runtime to gather all assets in the collection.
- abstract gather_transient_assets() idmtools.assets.asset_collection.AssetCollection ¶
Function called at runtime to gather all assets in the collection.
- gather_all_assets() idmtools.assets.asset_collection.AssetCollection ¶
Collect all common and transient assets.
Returns: new AssetCollection
- copy_simulation(base_simulation: Simulation) Simulation ¶
Called when copying a simulation for batching. Override you your task has specific concerns when copying simulations.
- reload_from_simulation(simulation: Simulation)¶
Optional hook that is called when loading simulations from a platform.
- to_simulation()¶
Convert task to simulation.
Returns: new simulation
- pre_getstate()¶
Return default values for
pickle_ignore_fields()
.Call before pickling.
Returns: dict
- post_setstate()¶
Post load from pickle.
- property pickle_ignore_fields¶
Pickle ignore fields.
- Returns:
List of fields to ignore
- __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>) None ¶