idmtools.core.interfaces.ientity module#

IEntity definition. IEntity is the base of most of our Remote server entitiies like Experiment, Simulation, WorkItems, and Suites.

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

class idmtools.core.interfaces.ientity.IEntity(_uid: str = None, _IItem__pre_creation_hooks: ~typing.List[~typing.Callable[[IItem, IPlatform], None]] = <factory>, _IItem__post_creation_hooks: ~typing.List[~typing.Callable[[IItem, IPlatform], None]] = <factory>, platform_id: str = None, _platform: IPlatform = None, parent_id: str = None, _parent: IEntity = None, status: ~idmtools.core.enums.EntityStatus = None, tags: ~typing.Dict[str, ~typing.Any] = <factory>, item_type: ~idmtools.core.enums.ItemType = None, _platform_object: ~typing.Any = None)[source]#

Bases: IItem

Interface for all entities in the system.

platform_id: str = None#

ID of the platform

parent_id: str = None#

Parent id

status: EntityStatus = None#

Status of item

tags: Dict[str, Any]#

Tags for item

item_type: ItemType = None#

Item Type(Experiment, Suite, Asset, etc)

update_tags(tags: dict | None = None) NoReturn[source]#

Shortcut to update the tags with the given dictionary.

Parameters:

tags – New tags

post_creation(platform: IPlatform) None[source]#

Post creation hook for object.

Returns:

None

classmethod from_id_file(filename: PathLike | str, platform: IPlatform = None, **kwargs) IEntity[source]#

Load from a file that container the id.

Parameters:
  • filename – Filename to load

  • platform – Platform object to load id from. This can be loaded from file if saved there.

  • **kwargs – Platform extra arguments

Returns:

Entity loaded from id file

Raises:

EnvironmentError if item type is None.

classmethod from_id(item_id: str, platform: IPlatform = None, **kwargs) IEntity[source]#

Load an item from an id.

Parameters:
  • item_id – Id of item

  • platform – Platform. If not supplied, we check the current context

  • **kwargs – Optional platform args

Returns:

IEntity of object

property parent#

Return parent object for item.

Returns:

Parent entity if set

property platform: IPlatform#

Get objects platform object.

Returns:

Platform

get_platform_object(force: bool = False, platform: IPlatform = None, **kwargs)[source]#

Get the platform representation of an object.

Parameters:
  • force – Force reload of platform object

  • platform – Allow passing platform object to fetch

  • **kwargs – Optional args used for specific platform behaviour

Returns:

Platform Object

property done#

Returns if a item is done.

For an item to be done, it should be in either failed or succeeded state.

Returns:

True if status is succeeded or failed

property succeeded#

Returns if an item has succeeded.

Returns:

True if status is SUCCEEDED

property failed#

Returns is a item has failed.

Returns:

True if status is failed

static get_current_platform_or_error()[source]#

Try to fetch the current platform from context. If no platform is set, error.

Returns:

Platform if set

Raises:

NoPlatformException if no platform is set on the current context

__init__(_uid: str = None, _IItem__pre_creation_hooks: ~typing.List[~typing.Callable[[IItem, IPlatform], None]] = <factory>, _IItem__post_creation_hooks: ~typing.List[~typing.Callable[[IItem, IPlatform], None]] = <factory>, platform_id: str = None, _platform: IPlatform = None, parent_id: str = None, _parent: IEntity = None, status: ~idmtools.core.enums.EntityStatus = None, tags: ~typing.Dict[str, ~typing.Any] = <factory>, item_type: ~idmtools.core.enums.ItemType = None, _platform_object: ~typing.Any = None) None#
to_id_file(filename: str | PathLike, save_platform: bool = False, platform_args: Dict | None = None)[source]#

Write a id file.

Parameters:
  • filename – Filename to create

  • save_platform – Save platform to the file as well

  • platform_args – Platform Args

Returns:

None