idmtools.entities.iplatform_ops.iplatform_simulation_operations module

IPlatformSimulationOperations defines simulation item operations interface.

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

class idmtools.entities.iplatform_ops.iplatform_simulation_operations.IPlatformSimulationOperations(platform: IPlatform, platform_type: Type)

Bases: CacheEnabled, ABC

IPlatformSimulationOperations defines simulation item operations interface.

platform: IPlatform
platform_type: Type
abstract get(simulation_id: UUID, **kwargs) Any

Returns the platform representation of an Simulation.

Parameters:
  • simulation_id – Item id of Simulations

  • **kwargs

Returns:

Platform Representation of an simulation

pre_create(simulation: Simulation, **kwargs) NoReturn

Run the platform/simulation post creation events.

Parameters:
  • simulation – simulation to run post-creation events

  • **kwargs – Optional arguments mainly for extensibility

Returns:

NoReturn

post_create(simulation: Simulation, **kwargs) NoReturn

Run the platform/simulation post creation events.

Parameters:
  • simulation – simulation to run post-creation events

  • **kwargs – Optional arguments mainly for extensibility

Returns:

NoReturn

create(simulation: Simulation, do_pre: bool = True, do_post: bool = True, **kwargs) Any

Creates an simulation from an IDMTools simulation object.

Also performs pre-creation and post-creation locally and on platform.

Parameters:
  • simulation – Simulation to create

  • do_pre – Perform Pre creation events for item

  • do_post – Perform Post creation events for item

  • **kwargs – Optional arguments mainly for extensibility

Returns:

Created platform item and the UUID of said item

abstract platform_create(simulation: Simulation, **kwargs) Any

Creates an simulation on Platform from an IDMTools Simulation Object.

Parameters:
  • simulation – Simulation to create

  • **kwargs – Optional arguments mainly for extensibility

Returns:

Created platform item and the UUID of said item

batch_create(sims: List[Simulation], display_progress: bool = True, **kwargs) List[Simulation]

Provides a method to batch create simulations.

Parameters:
  • sims – List of simulations to create

  • display_progress – Show progress bar

  • **kwargs

Returns:

List of tuples containing the create object and id of item that was created

abstract get_parent(simulation: Any, **kwargs) Any

Returns the parent of item. If the platform doesn’t support parents, you should throw a TopLevelItem error.

Parameters:
  • simulation

  • **kwargs

Returns:

Parent of simulation

Raises:

TopLevelItem

to_entity(simulation: Any, load_task: bool = False, parent: Optional[Experiment] = None, **kwargs) Simulation

Converts the platform representation of simulation to idmtools representation.

Parameters:
  • simulation – Platform simulation object

  • load_task – Load Task Object as well. Can take much longer and have more data on platform

  • parent – Optional parent object

Returns:

IDMTools simulation object

pre_run_item(simulation: Simulation, **kwargs)

Trigger right before commissioning experiment on platform.

This ensures that the item is created. It also ensures that the children(simulations) have also been created.

Parameters:

simulation – Experiment to commission

Returns:

None

post_run_item(simulation: Simulation, **kwargs)

Trigger right after commissioning experiment on platform.

Parameters:

simulation – Experiment just commissioned

Returns:

None

run_item(simulation: Simulation, **kwargs)

Called during commissioning of an item. This should create the remote resource.

Parameters:

simulation

Returns:

None

abstract platform_run_item(simulation: Simulation, **kwargs)

Called during commissioning of an item. This should create the remote resource but not upload assets.

Parameters:

simulation – Simulation to run

Returns:

None

abstract send_assets(simulation: Any, **kwargs)

Send simulations assets to server.

Parameters:
  • simulation – Simulation to upload assets for

  • **kwargs – Keyword arguments for the op

Returns:

None

abstract refresh_status(simulation: Simulation, **kwargs)

Refresh status for simulation object.

Parameters:

simulation – Experiment to get status for

Returns:

None

abstract get_assets(simulation: Simulation, files: List[str], **kwargs) Dict[str, bytearray]

Get files from simulation.

Parameters:
  • simulation – Simulation to fetch files from

  • files – Files to get

  • **kwargs

Returns:

Dictionary containing filename and content

abstract list_assets(simulation: Simulation, **kwargs) List[Asset]

List available assets for a simulation.

Parameters:

simulation – Simulation of assets Assets

Returns:

List of filenames

__init__(platform: IPlatform, platform_type: Type) None