Base Element

class openmsimodel.entity.base.base_element.BaseElement(name: str, *, template: ClassVar[PropertyTemplate | ParameterTemplate | ConditionTemplate | MaterialTemplate | ProcessTemplate | MeasurementTemplate] = None, notes: str | None = None)

Bases: ABC

Base class for materials, processes, and measurements.

BaseElement ‘s are thin wrappers for GEMD entities. One BaseElement contains a template, spec, and run for the same kind of entity (Material, Process, or Measurement) and helps to create, update, link, and output these.

Note that name is the GEMD name given to the spec and run. The template name is the name of the subclass.

To subclass:

1. Instantiate TEMPLATE as follows: TEMPLATE: ClassVar[Template] = Template(name=__name__), replacing Template with one of MaterialTemplate, ProcessTemplate, or MeasurementTemplate.

2. Instantiate _ATTRS as follows: _ATTRS: ClassVar[AttrsDict] = _validate_temp_keys(TEMPLATE)

3. Add conditions, parameters, and/or properties using define_attribute(_ATTRS, ...) from the qf_gemd.base.attributes module.

4. Call finalize_template(_ATTRS, TEMPLATE), found in the qf_gemd.base.attributes module, to add attributes to TEMPLATE.

  1. Follow any additional subclass directions.

abstract property spec: MaterialSpec | ProcessSpec | MeasurementSpec | IngredientSpec

The underlying GEMD spec.

abstract property run: MaterialRun | ProcessRun | MeasurementRun | IngredientRun

The underlying GEMD run.

update_tags(*tags: tuple[str, ...], replace_all: bool = False, which: Literal['spec', 'run', 'both'] = 'spec') None

Change or add hierarchical tags.

Each tag is represented by a tuple of hierarchical str s. For example, ('Quantum Design', 'MPMS3'), in that order, describes the make and model of a particular measurement instrument.

When replace_all is False, any existing tags that are exactly the same as a new tag will not be duplicated. However, a tag that is the “child” of an existing tag will not override the “parent” tag. For example, it is possible to have all of the following at once: ('Quantum Design', 'DynaCool'), ('Quantum Design', 'DynaCool', '1'), and ('Quantum Design', 'DynaCool', '3').

Internally, tag strings will be concatenated with '::' as recommended by the GEMD specification.

tags: tuple[str]

tuples representing tags to add. Each tuple should contain the components of a tag from most general to most specific.

replace_all: bool, default False

If True, remove any existing tags before adding new ones.

which: {‘spec’, ‘run’, ‘both’}, default ‘spec’

Whether to update the spec, run, or both.

remove_tags(*tags: tuple[str, ...], which: Literal['spec', 'run', 'both'] = 'spec') None

Remove tags.

See update_tags for tag format details. Tags are removed by exact comparison of the underlying hierarchcal str s.

tags: tuple[str] tuple s representing tags to remove. which: {‘spec’, ‘run’, ‘both’}, default ‘spec’ Whether to remove from the spec, run, or both.

get_tags_dict()

Get a dict representing the hierarchical tags.

Change or add file links.

filelinks: FileLink The file links to change or add. replace_all: bool, default False If True, remove any existing file links before adding new ones. which: {‘spec’, ‘run’, ‘both’}, default ‘spec’ Whether to update the spec, run, or both.

Remove file links.

filelinks: tuple[str]

The file links to remove by comparison of the underlying url and filename.

which: {‘spec’, ‘run’, ‘both’}, default ‘spec’

Whether to remove from the spec, run, or both.

Get string representations of the file links.

filelinks_dict: FileLinksDict

Strings representing the file links of the spec and run.