idmtools.entities.iplatform module

class idmtools.entities.iplatform.IPlatform(*args, **kwargs)

Bases: idmtools.core.interfaces.iitem.IItem, idmtools.core.cache_enabled.CacheEnabled

Interface defining a platform. A platform needs to implement basic operation such as:

  • Creating experiment

  • Creating simulation

  • Commissioning

  • File handling

platform_type_map: Dict[Type, idmtools.core.enums.ItemType] = None

Maps the platform types to idmtools types

supported_types: Set[idmtools.core.enums.ItemType]
static get_caller()

Trace the stack and find the caller.

Returns

The direct caller.

validate_inputs_types() → NoReturn

Validate user inputs and case attributes with the correct data types.

Returns

None

get_item(item_id: Union[str, uuid.UUID], item_type: idmtools.core.enums.ItemType = None, force: bool = False, raw: bool = False, **kwargs) → Optional[Union[idmtools.entities.experiment.Experiment, idmtools.entities.suite.Suite, idmtools.entities.simulation.Simulation, idmtools.entities.iworkflow_item.IWorkflowItem, idmtools.assets.asset_collection.AssetCollection]]

Retrieve an object from the platform. This function is cached; force allows you to force the refresh of the cache. If no object_type is passed, the function will try all the types (experiment, suite, simulation).

Parameters
  • item_id – The ID of the object to retrieve.

  • item_type – The type of the object to be retrieved.

  • force – If True, force the object fetching from the platform.

  • raw – Return either an idmtools object or a platform object.

Returns

The object found on the platform or None.

Raises

ValueError – If the item type is not supported

get_children(item_id: uuid.UUID, item_type: idmtools.core.enums.ItemType, force: bool = False, raw: bool = False, item: Any = None, **kwargs) → Any

Retrieve the children of a given object.

Parameters
  • item_id – The ID of the object for which we want the children.

  • force – If True, force the object fetching from the platform.

  • raw – Return either an idmtools object or a platform object.

  • item_type – Pass the type of the object for quicker retrieval.

  • item – optional platform or idm item to use instead of loading

Returns

The children of the object or None.

get_children_by_object(parent: idmtools.core.interfaces.ientity.IEntity) → List[idmtools.core.interfaces.ientity.IEntity]

Returns a list of children for an entity

Parameters

parent – Parent object

Returns

List of children

get_parent_by_object(child: idmtools.core.interfaces.ientity.IEntity)idmtools.core.interfaces.ientity.IEntity

Parent of object

Parameters

child – Child object to find parent for

Returns

Returns parent object

get_parent(item_id: uuid.UUID, item_type: idmtools.core.enums.ItemType = None, force: bool = False, raw: bool = False, **kwargs)

Retrieve the parent of a given object.

Parameters
  • item_id – The ID of the object for which we want the parent.

  • force – If True, force the object fetching from the platform.

  • raw – Return either an idmtools object or a platform object.

  • item_type – Pass the type of the object for quicker retrieval.

Returns

The parent of the object or None.

get_cache_key(force, item_id, item_type, kwargs, raw, prefix='p')
create_items(items: Union[List[idmtools.core.interfaces.ientity.IEntity], idmtools.core.interfaces.ientity.IEntity]) → List[idmtools.core.interfaces.ientity.IEntity]

Create items (simulations, experiments, or suites) on the platform. The function will batch the items based on type and call the self._create_batch for creation :param items: The list of items to create.

Returns

List of item IDs created.

run_items(items: Union[idmtools.core.interfaces.ientity.IEntity, List[idmtools.core.interfaces.ientity.IEntity]], **kwargs)

Run items on the platform. :param items:

Returns:

flatten_item(item: idmtools.core.interfaces.ientity.IEntity) → List[idmtools.core.interfaces.ientity.IEntity]

Flatten an item: resolve the children until getting to the leaves. For example, for an experiment, will return all the simulations. For a suite, will return all the simulations contained in the suites experiments.

Parameters

item – Which item to flatten

Returns

List of leaves

refresh_status(item: idmtools.core.interfaces.ientity.IEntity) → NoReturn

Populate the platform item and specified item with its status.

Parameters

item – The item to check status for.

get_files(item: idmtools.core.interfaces.ientity.IEntity, files: Union[Set[str], List[str]], output: str = None, **kwargs) → Union[Dict[str, Dict[str, bytearray]], Dict[str, bytearray]]

Get files for a platform entity

Parameters
  • item – Item to fetch files for

  • files – List of file names to get

  • output – save files to

  • **kwargs – Platform arguments

Returns

For simulations, this returns a dictionary with filename as key and values being binary data from file or a dict.

For experiments, this returns a dictionary with key as sim id and then the values as a dict of the simulations described above

get_files_by_id(item_id: uuid.UUID, item_type: idmtools.core.enums.ItemType, files: Union[Set[str], List[str]], output: str = None) → Union[Dict[str, Dict[str, bytearray]], Dict[str, bytearray]]

Get files by item id (UUID) :param item_id: COMPS Item, say, Simulation Id or WorkItem Id :param item_type: Item Type :param files: List of files to retrieve :param output: save files to

Returns: dict with key/value: file_name/file_content

are_requirements_met(requirements: Union[idmtools.entities.platform_requirements.PlatformRequirements, Set[idmtools.entities.platform_requirements.PlatformRequirements]]) → bool

Does the platform support the list of requirements

Parameters

requirements – Requirements should be a list of PlatformRequirements or a single PlatformRequirements

Returns

True if all the requirements are supported

is_task_supported(task: idmtools.entities.itask.ITask) → bool

Is a task supported on this platform. This depends on the task properly setting its requirements. See idmtools.entities.itask.ITask.platform_requirements and idmtools.entities.platform_requirements.PlatformRequirements

Parameters

task – Task to check support of

Returns

True if the task is supported, False otherwise.

wait_till_done(item: idmtools.core.interfaces.irunnable_entity.IRunnableEntity, timeout: int = 86400, refresh_interval: int = 5, progress: bool = True)

Wait for the experiment to be done.

Parameters
  • item – Experiment/Workitem to wait on

  • refresh_interval – How long to wait between polling.

  • timeout – How long to wait before failing.

  • progress – Should we display progress

See also

idmtools.entities.iplatform.IPlatform.wait_till_done_progress() idmtools.entities.iplatform.IPlatform.__wait_until_done_progress_callback() idmtools.entities.iplatform.IPlatform.__wait_till_callback()

wait_till_done_progress(item: idmtools.core.interfaces.irunnable_entity.IRunnableEntity, timeout: int = 86400, refresh_interval: int = 5, wait_progress_desc: str = None)

Wait on an item to complete with progress bar

Parameters
  • item – Item to monitor

  • timeout – Timeout on waiting

  • refresh_interval – How often to refresh

  • wait_progress_desc – Wait Progress Description

Returns

None

See also

idmtools.entities.iplatform.IPlatform.__wait_until_done_progress_callback() idmtools.entities.iplatform.IPlatform.wait_till_done() idmtools.entities.iplatform.IPlatform.__wait_till_callback()

Retrieve all related objects :param item: SSMTWorkItem :param relation_type: Depends or Create

Returns: dict with key the object type

is_regather_assets_on_modify() → bool

Return default behaviour for platform when rerunning experiment and gathering assets

Returns

True or false

is_windows_platform(item: idmtools.core.interfaces.ientity.IEntity = None) → bool

Returns is the target platform is a windows system

property common_asset_path
join_path(*args) → str

Join path using platform rules

Parameters

*args – List of paths to join

Returns

Joined path as string

id_from_file(filename: str)

Load just the id portion of a id file

Parameters

filename – Filename

Returns:

get_item_from_id_file(id_filename: Union[os.PathLike, str], item_type: Optional[idmtools.core.enums.ItemType] = None)idmtools.core.interfaces.ientity.IEntity

Load an item from an id file. This ignores the platform in the file :param id_filename: Filename to load :param item_type: Optional item type

Returns: