idmtools.core.interfaces.iitem module

IItem is the base of all items that have ids such as AssetCollections, Experiments, etc.

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

class idmtools.core.interfaces.iitem.IItem(_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>)

Bases: object

IItem represents items that have identifiable ids.

In addition, IItem facilities pre and post creation hooks through the __pre_creation_hooks, __post_creation_hooks, add_pre_creation_hook, add_post_creation_hook

property uid

UID Of the object.

If not id is set, uses the hash of the object.

Returns:

ID

property id

Alias for uid.

Returns:

UID of object

Notes

What is relation to uid?

property metadata: Dict[str, Any]

Identify the metadata from the fields.

Returns:

Metadata dict

property pickle_ignore_fields

Get list of fields that will be ignored when pickling.

Returns:

Set of fields that are ignored when pickling the item

property metadata_fields

Get list of fields that have metadata.

Returns:

Set of fields that have metadata

display() str

Display as string representation.

Returns:

String of item

pre_creation(platform: IPlatform) None

Called before the actual creation of the entity.

Parameters:

platform – Platform item is being created on

Returns:

None

post_creation(platform: IPlatform) None

Called after the actual creation of the entity.

Parameters:

platform – Platform item was created on

Returns:

None

add_pre_creation_hook(hook: Callable[[IItem, IPlatform], None])

Adds a hook function to be called before an item is created.

Parameters:

hook – Hook function. This should have two arguments, the item and the platform

Returns:

None

add_post_creation_hook(hook: Callable[[IItem, IPlatform], None])

Adds a hook function to be called after an item is created.

Parameters:

hook – Hook function. This should have two arguments, the item and the platform

Returns:

None

post_setstate()

Function called after restoring the state if additional initialization is required.

pre_getstate()

Function called before picking and return default values for “pickle-ignore” fields.

__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>) None