qcodes.metadatable

Classes:

Metadatable([metadata])

MetadatableWithName([metadata])

Add short_name and full_name properties to Metadatable.

Functions:

normalize_snapshot_update(update)

Normalize the update argument of snapshot/snapshot_base into one of the canonical SnapshotUpdate string values.

class qcodes.metadatable.Metadatable(metadata: Mapping[str, Any] | None = None)[source]

Bases: object

Methods:

load_metadata(metadata)

Load metadata into this classes metadata dictionary.

snapshot()

Decorate a snapshot dictionary with metadata.

snapshot_base([update, params_to_skip_update])

Override this with the primary information for a subclass.

load_metadata(metadata: Mapping[str, Any]) None[source]

Load metadata into this classes metadata dictionary.

Parameters:

metadata – Metadata to load.

final snapshot(update: Literal['All', 'Only_invalid', 'Never'] = 'Only_invalid') dict[str, Any][source]
final snapshot(update: bool | None = 'Only_invalid') dict[str, Any]

Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override snapshot_base().

Parameters:

update

What to do about the values stored in the snapshot; passed to snapshot_base() after being normalized to a SnapshotUpdate value.

  • "All": force an update of every value.

  • "Only_invalid" (the default): only update values whose cache is invalid, using the latest cached value otherwise.

  • "Never": never update, always use the latest values in memory.

The legacy True / None / False values are deprecated aliases for "All" / "Only_invalid" / "Never" and are still accepted for backwards compatibility (no warning is raised).

Returns:

Base snapshot.

snapshot_base(update: bool | SnapshotUpdate | None = 'Only_invalid', params_to_skip_update: Sequence[str] | None = None) dict[str, Any][source]

Override this with the primary information for a subclass.

class qcodes.metadatable.MetadatableWithName(metadata: Mapping[str, Any] | None = None)[source]

Bases: Metadatable

Add short_name and full_name properties to Metadatable. This is used as a base class for all components in QCoDeS that are members of a station to ensure that they have a name and consistent interface.

Methods:

load_metadata(metadata)

Load metadata into this classes metadata dictionary.

snapshot([update])

Decorate a snapshot dictionary with metadata.

snapshot_base([update, params_to_skip_update])

Override this with the primary information for a subclass.

Attributes:

short_name

Name excluding name of any parent that this object is bound to.

full_name

Name including name of any parent that this object is bound to separated by '_'.

load_metadata(metadata: Mapping[str, Any]) None

Load metadata into this classes metadata dictionary.

Parameters:

metadata – Metadata to load.

snapshot(update: bool | Literal['All', 'Only_invalid', 'Never'] | None = 'Only_invalid') dict[str, Any]

Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override snapshot_base().

Parameters:

update

What to do about the values stored in the snapshot; passed to snapshot_base() after being normalized to a SnapshotUpdate value.

  • "All": force an update of every value.

  • "Only_invalid" (the default): only update values whose cache is invalid, using the latest cached value otherwise.

  • "Never": never update, always use the latest values in memory.

The legacy True / None / False values are deprecated aliases for "All" / "Only_invalid" / "Never" and are still accepted for backwards compatibility (no warning is raised).

Returns:

Base snapshot.

snapshot_base(update: bool | SnapshotUpdate | None = 'Only_invalid', params_to_skip_update: Sequence[str] | None = None) dict[str, Any]

Override this with the primary information for a subclass.

abstract property short_name: str

Name excluding name of any parent that this object is bound to.

abstract property full_name: str

Name including name of any parent that this object is bound to separated by ‘_’.

qcodes.metadatable.normalize_snapshot_update(update: bool | Literal['All', 'Only_invalid', 'Never'] | None) Literal['All', 'Only_invalid', 'Never'][source]

Normalize the update argument of snapshot/snapshot_base into one of the canonical SnapshotUpdate string values.

The legacy values True, None and False are mapped to "All", "Only_invalid" and "Never" respectively, and the canonical string values are returned unchanged. This is the single place where the update argument is interpreted; all internal code should work with the returned SnapshotUpdate value rather than with the legacy bool/None representation.

Parameters:

update – The update argument as passed to snapshot/ snapshot_base.

Returns:

The equivalent canonical SnapshotUpdate value.

Raises:

ValueError – If update is a string that is not a valid SnapshotUpdate value.