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: ~uuid.UUID = 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: ~uuid.UUID = None, _platform: IPlatform = None, parent_id: ~uuid.UUID = 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)

Bases: IItem

Interface for all entities in the system.

platform_id: UUID = None

ID of the platform

parent_id: UUID = 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: Optional[dict] = None) NoReturn

Shortcut to update the tags with the given dictionary.

Parameters:

tags – New tags

post_creation(platform: IPlatform) None

Post creation hook for object.

Returns:

None

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

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: Union[str, UUID], platform: IPlatform = None, **kwargs) IEntity

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)

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()

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: ~uuid.UUID = 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: ~uuid.UUID = None, _platform: IPlatform = None, parent_id: ~uuid.UUID = 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: Union[str, PathLike], save_platform: bool = False, platform_args: Optional[Dict] = None)

Write a id file.

Parameters:
  • filename – Filename to create

  • save_platform – Save platform to the file as well

  • platform_args – Platform Args

Returns:

None