vivarium.artifact.entity_key

Entity Key

Provides the EntityKey class and is_entity_key() helper for working with artifact entity keys formatted as "type.name.measure" or "type.measure".

vivarium.artifact.entity_key.is_entity_key(key)[source]

Check whether a string is a valid artifact entity key.

A valid entity key has the format "type.name.measure" or "type.measure" - that is, 2 or 3 non-empty dot-separated elements with no leading, trailing, or consecutive dots.

Return type:

bool

Parameters:

key (str) – The string to check.

Returns:

True if the string matches the entity key format, False otherwise.

class vivarium.artifact.entity_key.EntityKey(key)[source]

A convenience wrapper that translates artifact keys.

This class provides several representations of the artifact keys that are useful when working with the pandas and tables HDF interfaces.

Parameters:

key (str)

property type: str

The type of the entity represented by the key.

property name: str

The name of the entity represented by the key.

property measure: str

The measure associated with the data represented by the key.

property group_prefix: str

The HDF group prefix for the key.

property group_name: str

The HDF group name for the key.

property group: str

The full path to the group for this key.

property path: str

The full HDF path associated with this key.

with_measure(measure)[source]

Replace this key’s measure with the provided one.

Return type:

EntityKey

Parameters:

measure (str) – The measure to replace this key’s measure with.

Returns:

A new EntityKey with the updated measure.