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:
ABCBase class for materials, processes, and measurements.
BaseElement‘s are thin wrappers for GEMD entities. OneBaseElementcontains a template, spec, and run for the same kind of entity (Material,Process, orMeasurement) 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
TEMPLATEas follows:TEMPLATE: ClassVar[Template] = Template(name=__name__), replacingTemplatewith one ofMaterialTemplate,ProcessTemplate, orMeasurementTemplate.2. Instantiate
_ATTRSas follows:_ATTRS: ClassVar[AttrsDict] = _validate_temp_keys(TEMPLATE)3. Add conditions, parameters, and/or properties using
define_attribute(_ATTRS, ...)from theqf_gemd.base.attributesmodule.4. Call
finalize_template(_ATTRS, TEMPLATE), found in theqf_gemd.base.attributesmodule, to add attributes toTEMPLATE.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
tupleof hierarchicalstrs. 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
strs.tags: tuple[str]
tuples representing tags to remove. which: {‘spec’, ‘run’, ‘both’}, default ‘spec’ Whether to remove from the spec, run, or both.
- get_tags_dict()
Get a
dictrepresenting the hierarchical tags.
- update_filelinks(*filelinks: FileLink, replace_all: bool = False, which: Literal['spec', 'run', 'both'] = 'spec') None
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_filelinks(*filelinks: FileLink, which: Literal['spec', 'run', 'both'] = 'spec') None
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_filelinks_dict()
Get string representations of the file links.
- filelinks_dict: FileLinksDict
Strings representing the file links of the spec and run.