LocalObservation#
Module: exa.core.observation.observation
- class LocalObservation(*, dut_field, value, unit, uncertainty=None, invalid=False, dut_label, source, tags=[], validation_rules=[], default_validation_rules=[DUTFieldValidationRule()], created_timestamp=<factory>)#
Bases:
ObservationDefinitionData object representing a locally generated observation that can be later saved to database.
The responsibility of the class is to hold the data of the observation in order to defer the saving to the database and use the observations in subsequent parts.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
Attributes
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
The list of validation rules for the observation.
The list of default validation rules for the observation.
Time when this object was created locally.
dut_labelDUT label of the device the observation is about.
sourceHow the observation was made, e.g. experiment analysis or manual specification.
tagsHuman-readable tags of the observation.
dut_fieldName of the property the observation is about.
valueValue of the observation.
unitSI unit of the value.
uncertaintyUncertainty of the observation value.
invalidFlag indicating if the observation is invalid.
Methods
Create a local observation from the given parameters.
Creates a local observation from a setting.
Scientifically formatted value with uncertainty.
Save the observation to the DB.
Stash the observation.
Add provided tags to the observation.
Validate the observation using the validation rules of the observation.
- Parameters:
dut_field (str)
value (Annotated[bool | str | int | float | complex | ndarray, PlainValidator(func=~exa.common.data.value.validate_value, json_schema_input_type=~typing.Any), PlainSerializer(func=~exa.common.data.value.serialize_value, return_type=PydanticUndefined, when_used=always), WithJsonSchema(json_schema={}, mode=None)])
unit (str)
uncertainty (Annotated[int | float | complex | ndarray, PlainValidator(func=~exa.common.data.value.validate_value, json_schema_input_type=~typing.Any), PlainSerializer(func=~exa.common.data.value.serialize_value, return_type=PydanticUndefined, when_used=always), WithJsonSchema(json_schema={}, mode=None)] | None)
invalid (bool)
dut_label (str)
validation_rules (list[Callable[[ObservationDefinition], None]])
default_validation_rules (list[Callable[[ObservationDefinition], None]])
created_timestamp (datetime)
- default_validation_rules: list[ValidationRuleType]#
The list of default validation rules for the observation.
- created_timestamp: datetime#
Time when this object was created locally. Not to be confused with the timestamp assigned when saving to database.
- validate()#
Validate the observation using the validation rules of the observation.
- Return type:
None
- save(storage=None)#
Save the observation to the DB.
- Parameters:
storage (StorageInterface | None) – If given, overrides the default (ambient) storage backend.
- Returns:
The saved observation or None in case the saving did not succeed.
- Return type:
ObservationData | None
- stash(observation_stash)#
Stash the observation.
- Parameters:
observation_stash (_ObservationStash) – The stash where the observation is added.
- Returns:
Self.
- Return type:
- classmethod from_setting(setting, *, dut_field='', run_id=None, sequence_id=None, configurator=None)#
Creates a local observation from a setting.
Observations have several attributes that Settings are lacking. They are handled as follows:
- attr:
sourceis given usingrun_id,sequence_idorconfigurator.
- attr:
uncertaintyis None.
- attr:
invalidis False.
- attr:
tagsis empty.
- Parameters:
setting (Setting) – Setting to be converted into an observation.
dut_field (str) – If given, will override
setting.parameter.name, which is arbitrary and does not have to match the path ofsettingin a settings tree. Thedut_fieldof an observation should match the path of the corresponding setting in the EXA settings tree. If not given,setting.parameter.namemust include a QPU component.run_id (UUID | None) – If given, the run ID of the experiment that generated
setting.sequence_id (UUID | None) – If given, the ID of the sequence that generated
setting.configurator (str | None) – If given, the configuration source for
setting.
- Return type:
- classmethod create(dut_field, value, unit, *, uncertainty=None, invalid=False, tags=None, run_id=None, sequence_id=None, configurator=None, validation_rules=None)#
Create a local observation from the given parameters.
- Parameters:
dut_field (str)
value (Annotated[bool | str | int | float | complex | ndarray, PlainValidator(func=~exa.common.data.value.validate_value, json_schema_input_type=~typing.Any), PlainSerializer(func=~exa.common.data.value.serialize_value, return_type=PydanticUndefined, when_used=always), WithJsonSchema(json_schema={}, mode=None)])
unit (str)
uncertainty (Annotated[int | float | complex | ndarray, PlainValidator(func=~exa.common.data.value.validate_value, json_schema_input_type=~typing.Any), PlainSerializer(func=~exa.common.data.value.serialize_value, return_type=PydanticUndefined, when_used=always), WithJsonSchema(json_schema={}, mode=None)] | None)
invalid (bool)
run_id (UUID | None)
sequence_id (UUID | None)
configurator (str | None)
validation_rules (list[Callable[[ObservationDefinition], None]] | None)
- Return type:
- model_config: ClassVar[ConfigDict] = {'extra': 'ignore', 'ser_json_inf_nan': 'constants', 'validate_assignment': True, 'validate_default': True}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
Inheritance
