Logo
2.1.9
  • 1. Unit Parsing
  • 2. Serialization (with Graphs!)
  • 3. API Reference
    • 3.1. gemd package
      • 3.1.1. Subpackages
        • 3.1.1.1. gemd.builders package
        • 3.1.1.2. gemd.demo package
        • 3.1.1.3. gemd.entity package
        • 3.1.1.4. gemd.enumeration package
        • 3.1.1.5. gemd.json package
        • 3.1.1.6. gemd.units package
        • 3.1.1.7. gemd.util package
      • 3.1.2. Module contents
GEMD-python
  • »
  • 3. gemd »
  • 3.1. gemd package »
  • 3.1.1.3. gemd.entity package »
  • gemd.entity.link_by_uid module
  • View page source

gemd.entity.link_by_uid module

A unique id that stands in for a data object.

class gemd.entity.link_by_uid.LinkByUID(scope, id)

Bases: DictSerializable

Link object, which replaces pointers to other entities before serialization and writing.

Parameters
  • scope (str) – The scope of the unique identifier. Scopes are case-insensitive.

  • id (str) – The unique identifier.

as_dict() → Dict[str, Any]

Convert the object to a dictionary.

Returns

A dictionary representation of the object, where the keys are its fields.

Return type

dict

static build(d: Mapping[str, Any]) → DictSerializableType

Build an object from a JSON dictionary.

This differs from from_dict in that the values themselves may also be dictionaries corresponding to serialized DictSerializable objects.

Parameters

d (dict) – The object as a serialized dictionary.

Returns

The deserialized object.

Return type

DictSerializable

dump() → Dict[str, Any]

Convert the object to a JSON dictionary, so that every entry is serialized.

Uses the json encoder client, so objects with uids are converted to LinkByUID dictionaries.

Returns

A string representation of the object as a dictionary.

Return type

str

classmethod from_dict(d: Mapping[str, Any]) → DictSerializableType

Reconstitute the object from a dictionary.

Parameters

d (dict) – The object as a dictionary of key-value pairs that correspond to the object’s fields.

Returns

The deserialized object.

Return type

DictSerializable

classmethod from_entity(entity: BaseEntityType, *, scope=None)

Create LinkByUID from in-memory object.

  • If there exists an id with scope (default ‘auto’), the LinkByUID object will be built with that scope.

  • If there is no id with scope, an arbitrary scope-id pair will be chosen.

  • If the object has no uids, the object will be mutated to include a uid (UUID4) with the chosen scope and the LinkByUID object will be built with that scope and id.

Parameters
  • entity (BaseEntity) – The entity to substitute with a LinkByUID

  • scope (str, optional) – The desired scope of the id.

Returns

A link object that references entity through its scope and id.

Return type

LinkByUID

skip = {}
typ = 'link_by_uid'
Previous Next

© Copyright 2020, Citrine Informatics.

Built with Sphinx using a theme provided by Read the Docs.