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: ObservationDefinition

Data 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

model_config

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

validation_rules

The list of validation rules for the observation.

default_validation_rules

The list of default validation rules for the observation.

created_timestamp

Time when this object was created locally.

dut_label

DUT label of the device the observation is about.

source

How the observation was made, e.g. experiment analysis or manual specification.

tags

Human-readable tags of the observation.

dut_field

Name of the property the observation is about.

value

Value of the observation.

unit

SI unit of the value.

uncertainty

Uncertainty of the observation value.

invalid

Flag indicating if the observation is invalid.

Methods

create

Create a local observation from the given parameters.

from_setting

Creates a local observation from a setting.

pretty_value

Scientifically formatted value with uncertainty.

save

Save the observation to the DB.

stash

Stash the observation.

tag

Add provided tags to the observation.

validate

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)

  • source (dict[str, Any])

  • tags (list[str])

  • validation_rules (list[Callable[[ObservationDefinition], None]])

  • default_validation_rules (list[Callable[[ObservationDefinition], None]])

  • created_timestamp (datetime)

validation_rules: list[ValidationRuleType]#

The list of validation rules for the observation.

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

tag(tags)#

Add provided tags to the observation.

Parameters:

tags (list[str])

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:

LocalObservation

pretty_value()#

Scientifically formatted value with uncertainty.

Return type:

str

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:

    source is given using run_id, sequence_id or configurator.

  • attr:

    uncertainty is None.

  • attr:

    invalid is False.

  • attr:

    tags is 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 of setting in a settings tree. The dut_field of an observation should match the path of the corresponding setting in the EXA settings tree. If not given, setting.parameter.name must 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:

LocalObservation

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)

  • tags (list[str] | None)

  • run_id (UUID | None)

  • sequence_id (UUID | None)

  • configurator (str | None)

  • validation_rules (list[Callable[[ObservationDefinition], None]] | None)

Return type:

LocalObservation

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

Inheritance diagram of exa.core.observation.observation.LocalObservation