ObservationStash#
Module: exa.core.observation.observation_stash
- class ObservationStash(local_observations, db_observations, compare_db_and_local_time=None)#
Bases:
objectClass for saving local observations in the runtime instead of the DB.
- Parameters:
local_observations (Mapping[str, Sequence[LocalObservation]]) – Dictionary mapping lists of local observations to their dut field path (The full one which includes the component name). Duplicates are removed.
db_observations (Mapping[str, Sequence[ObservationData]]) – Dictionary mapping lists of db observations to their dut field path (The full one which includes the component name). Duplicates are removed. The DB observations will be returned by
get_latest_observation()in case there is no local observation for thatdut_fieldfound.compare_db_and_local_time (bool | None) – Allow comparing local and database timestamps when fetching latest observations. If disabled, local observations will always have priority to database observations, and a warning will be shown in case a database observation may be more recent. Setting the flag explicitly to ´False´ Suppresses the warning. Disabled by default.
Methods
Copies the observation stash.
Create an observation stash containing latest observations from the DB filtered using
set_id.Create an observation stash containing latest observations from the DB filtered using
tags.Get the DB observations stored in the stash.
Gives the latest observation for the specified name (i.e. DUT field path).
Get the latest local or DB observations stored in the stash.
Get the local observations stored in the stash.
Merge the local observations from self to another stash.
Tag observations in the stash.
Saves the local observations to the DB.
Change the value of an observation in the stash by adding a new LocalObservation.
Adds local observations to the stash.
- static from_tags(tags=())#
Create an observation stash containing latest observations from the DB filtered using
tags.Only contains observations for the
dut_idof the station.- Parameters:
tags (Iterable[Iterable[str]]) – Observation tags to choose which observations to load. Outer iterable is a short-circuit OR, inner is AND. Example:
[['awesome', 'monday'], ['base']]means “For every observation (dut_field) we need, first try to load the latest such observation that is tagged with both'awesome'AND'monday'. If one with these tags cannot be found, try finding one tagged with'base'” instead. Iftagsis empty, no observations will be loaded.- Returns:
observation stash containing the requested observations
- Return type:
- static from_observation_set(set_id)#
Create an observation stash containing latest observations from the DB filtered using
set_id.Only contains observations for the
dut_idof the station.- Parameters:
set_id (UUID) – The observation set ID for which to load observations.
- Returns:
observation stash containing the requested observations
- Return type:
- copy()#
Copies the observation stash.
- Return type:
- stash(observations)#
Adds local observations to the stash.
Only observations not yet found in self are added.
- Parameters:
observations (LocalObservation | list[LocalObservation]) – A list of observations or a singular observation to be added.
- Return type:
None
- get_latest_observation(dut_field, tags=None, set_ids=None)#
Gives the latest observation for the specified name (i.e. DUT field path).
By default, any local observations added to the stash are considered more recent than database observations stored in the stash when initialising it. This can be altered using the compare_local_and_db_time flag when initializing the ObservationStash
- get_local_observations(components=None, observations=None, tags=None)#
Get the local observations stored in the stash.
- Parameters:
components (list[str] | None) – Components for which to get the observations. If not provided, will get for all components.
observations (list[str] | None) – Observation parameter names for which to get the observations. If not provided, will get for all observation parameters.
tags (list[str] | None) – If provided, will get only the observations containing these tags.
- Return type:
- get_db_observations(components=None, observations=None, tags=None, set_ids=None)#
Get the DB observations stored in the stash.
- Parameters:
components (list[str] | None) – Components for which to get the observations. If not provided, will get for all components.
observations (list[str] | None) – Observation parameter names for which to get the observations. If not provided, will get for all observation parameters.
tags (list[str] | None) – If provided, will get only the observations containing these tags.
set_ids (list[UUID] | None) – If provided, will get only the observations associated with the given set ids. Can not be used together with tags.
- Return type:
- get_latest_observations(components=None, observations=None, tags=None)#
Get the latest local or DB observations stored in the stash.
- Parameters:
components (list[str] | None) – Components for which to get the latest observations. If not provided, will get for all components.
observations (list[str] | None) – Observation parameter names for which to get the latest observations. If not provided, will get for all observation parameters.
tags (list[str] | None) – If provided, will get only the latest observations containing these tags.
- Return type:
- modify_tags(tags_to_add=None, tags_to_remove=None, components=None, observations=None, tags=None)#
Tag observations in the stash.
- Parameters:
components (list[str] | None) – Components for which to add/remove tags. If not provided, will apply to all components.
observations (list[str] | None) – Observations for which to add/remove tags. If not provided, will apply to all observations.
tags (list[str] | None) – Tags for which to add/remove more tags.
- Return type:
None
- merge_to(other, components=None, observations=None, tags=None, only_latest=False)#
Merge the local observations from self to another stash.
- Parameters:
other (ObservationStash) – The stash into which to merge the local observations.
components (list[str] | None) – Components for which to merge the observations. If not provided, will merge for all components.
observations (list[str] | None) – Observation parameter names for which to merge the observations. If not provided, will merge for all observation parameters.
tags (list[str] | None) – If provided, will merge only the observations containing these tags.
only_latest (bool) – Option to merge only the latest observation per dut field.
- Return type:
None
- save(components=None, observations=None, tags=None, new_tags=None, only_latest=False, convert_to_db_observations=False, storage=None)#
Saves the local observations to the DB.
- Parameters:
components (list[str] | None) – Components for which to save the observations. If not provided, will save for all components.
observations (list[str] | None) – Observation parameter names for which to save the observations. If not provided, will save for all observation parameters.
tags (list[str] | None) – If provided, will save only the observations containing these tags.
new_tags (list[str] | None) – Optionally tag the observations with these tags when saving.
only_latest (bool) – Option to save only the latest observation per dut field.
convert_to_db_observations (bool) – If set
True, moves the saved observations as DB observations, so that they cannot be saved again from this same stash.storage (StorageInterface | None) – If given, overrides the default (ambient) storage backend for this call.
- Returns:
The saved observations as in a list of DB observations.
- Return type:
- set_observation_value(dut_field, value)#
Change the value of an observation in the stash by adding a new LocalObservation.
- Parameters:
dut_field (str) – The full DUT field path of the observation, including the component name.
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)]) – The new value for the observation.
- Return type:
None
Inheritance
