semi_cr.core.lab.station package¶
Subpackages¶
- semi_cr.core.lab.station.context package
ContextStateInfrastructureContextRuntimeBindingRuntimeBindingRegistryStaticStationContextStationContextStationContext.stationStationContext.staticStationContext.bindingsStationContext.resolve_runtime()StationContext.instrumentsStationContext.devicesStationContext.chipsStationContext.pcbsStationContext.connectorsStationContext.graphStationContext.modulesStationContext.has_runtimeStationContext.stateStationContext.loadedStationContext.connectedStationContext.partially_connectedStationContext.connected_instrument_namesStationContext.has_connectionsStationContext.load()StationContext.connect()StationContext.disconnect()
- Submodules
- semi_cr.core.lab.station.context.bindings module
- semi_cr.core.lab.station.context.config module
- semi_cr.core.lab.station.context.graph module
- semi_cr.core.lab.station.context.models module
- semi_cr.core.lab.station.context.runtime module
StationContextStationContext.stationStationContext.staticStationContext.bindingsStationContext.resolve_runtime()StationContext.instrumentsStationContext.devicesStationContext.chipsStationContext.pcbsStationContext.connectorsStationContext.graphStationContext.modulesStationContext.has_runtimeStationContext.stateStationContext.loadedStationContext.connectedStationContext.partially_connectedStationContext.connected_instrument_namesStationContext.has_connectionsStationContext.load()StationContext.connect()StationContext.disconnect()
- semi_cr.core.lab.station.context.static module
- semi_cr.core.lab.station.graphing package
- Submodules
- semi_cr.core.lab.station.graphing.context module
- semi_cr.core.lab.station.graphing.ids module
safe_id_part()lab_node_id()terminal_node_id()connector_node_id()connector_connection_node_id()chip_node_id()device_node_id()pin_node_id()pad_node_id()instrument_node_id()instrument_module_node_id()instrument_connection_node_id()terminal_id()qcodes_node_id()local_device_name()qualified_device_name()resolve_terminal_id()
- semi_cr.core.lab.station.graphing.models module
NodeEdgeGraphRelationGraphRelation.CONTAINSGraphRelation.DEPENDENCYGraphRelation.CONNECTIONGraphRelation.REPRESENTSGraphRelation.INTERNAL_CONNECTIONGraphRelation.PHYSICALGraphRelation.DEVICEGraphRelation.__new_member__()GraphRelation.encode()GraphRelation.replace()GraphRelation.split()GraphRelation.rsplit()GraphRelation.join()GraphRelation.capitalize()GraphRelation.casefold()GraphRelation.title()GraphRelation.center()GraphRelation.count()GraphRelation.expandtabs()GraphRelation.find()GraphRelation.partition()GraphRelation.index()GraphRelation.ljust()GraphRelation.lower()GraphRelation.lstrip()GraphRelation.rfind()GraphRelation.rindex()GraphRelation.rjust()GraphRelation.rstrip()GraphRelation.rpartition()GraphRelation.splitlines()GraphRelation.strip()GraphRelation.swapcase()GraphRelation.translate()GraphRelation.upper()GraphRelation.startswith()GraphRelation.endswith()GraphRelation.removeprefix()GraphRelation.removesuffix()GraphRelation.isascii()GraphRelation.islower()GraphRelation.isupper()GraphRelation.istitle()GraphRelation.isspace()GraphRelation.isdecimal()GraphRelation.isdigit()GraphRelation.isnumeric()GraphRelation.isalpha()GraphRelation.isalnum()GraphRelation.isidentifier()GraphRelation.isprintable()GraphRelation.zfill()GraphRelation.format()GraphRelation.format_map()GraphRelation.maketrans()GraphRelation.__dir__()
- semi_cr.core.lab.station.graphing.operations module
- semi_cr.core.lab.station.graphing.overlay module
- semi_cr.core.lab.station.graphing.parsing module
- semi_cr.core.lab.station.graphing.resolver module
- semi_cr.core.lab.station.graphing.runtime_builder module
- semi_cr.core.lab.station.graphing.static_builder module
- semi_cr.core.lab.station.graphing.validation module
- semi_cr.core.lab.station.graphing.view module
- semi_cr.core.lab.station.routing_v1 package
- Submodules
- semi_cr.core.lab.station.routing_v1.attachment module
- semi_cr.core.lab.station.routing_v1.configurable module
- semi_cr.core.lab.station.routing_v1.conversions module
- semi_cr.core.lab.station.routing_v1.dc module
- semi_cr.core.lab.station.routing_v1.errors module
- semi_cr.core.lab.station.routing_v1.graph module
- semi_cr.core.lab.station.routing_v1.integration module
- semi_cr.core.lab.station.routing_v1.matching module
CapabilityCapability.VOLTAGE_SOURCECapability.VOLTAGE_METERCapability.CURRENT_SOURCECapability.CURRENT_METERCapability.RF_SOURCECapability.IQ_RECEIVERCapability.DIGITAL_TRIGGERCapability.__new_member__()Capability.encode()Capability.replace()Capability.split()Capability.rsplit()Capability.join()Capability.capitalize()Capability.casefold()Capability.title()Capability.center()Capability.count()Capability.expandtabs()Capability.find()Capability.partition()Capability.index()Capability.ljust()Capability.lower()Capability.lstrip()Capability.rfind()Capability.rindex()Capability.rjust()Capability.rstrip()Capability.rpartition()Capability.splitlines()Capability.strip()Capability.swapcase()Capability.translate()Capability.upper()Capability.startswith()Capability.endswith()Capability.removeprefix()Capability.removesuffix()Capability.isascii()Capability.islower()Capability.isupper()Capability.istitle()Capability.isspace()Capability.isdecimal()Capability.isdigit()Capability.isnumeric()Capability.isalpha()Capability.isalnum()Capability.isidentifier()Capability.isprintable()Capability.zfill()Capability.format()Capability.format_map()Capability.maketrans()Capability.__dir__()
requested_capability()
- semi_cr.core.lab.station.routing_v1.models module
- semi_cr.core.lab.station.routing_v1.profiles module
- semi_cr.core.lab.station.routing_v1.quantities module
RoutedVoltageRoutedCurrentCurrentFromTransimpedanceVoltageRoutedRFDriveRoutedIQReceiverRoutedRFFrequencyRoutedPulseAmplitudeRFFrequencyControllerRFPowerControllerOPXRFFrequencyControllerVNARFFrequencyControllerVNARFPowerControllerfind_route_endpoint()make_rf_frequency_controller()find_rf_frequency_controller()make_rf_power_controller()find_rf_power_controller()RoutedRFPower
- semi_cr.core.lab.station.routing_v1.queries module
node_supports_role()node_matches_filters()find_device_pin_node()find_pin_node()electrical_net_for_pin()find_pin_route_to_role()find_route()represented_objects_for_node()objects_on_electrical_net()objects_reachable_from_device()find_instruments()find_instruments_for_device()resolve_synchronization_config()objects_in_pin_route_with_attr()
- semi_cr.core.lab.station.routing_v1.resolution module
- semi_cr.core.lab.station.routing_v1.validation module
ValidationSeverityValidationSeverity.ERRORValidationSeverity.WARNINGValidationSeverity.__new_member__()ValidationSeverity.encode()ValidationSeverity.replace()ValidationSeverity.split()ValidationSeverity.rsplit()ValidationSeverity.join()ValidationSeverity.capitalize()ValidationSeverity.casefold()ValidationSeverity.title()ValidationSeverity.center()ValidationSeverity.count()ValidationSeverity.expandtabs()ValidationSeverity.find()ValidationSeverity.partition()ValidationSeverity.index()ValidationSeverity.ljust()ValidationSeverity.lower()ValidationSeverity.lstrip()ValidationSeverity.rfind()ValidationSeverity.rindex()ValidationSeverity.rjust()ValidationSeverity.rstrip()ValidationSeverity.rpartition()ValidationSeverity.splitlines()ValidationSeverity.strip()ValidationSeverity.swapcase()ValidationSeverity.translate()ValidationSeverity.upper()ValidationSeverity.startswith()ValidationSeverity.endswith()ValidationSeverity.removeprefix()ValidationSeverity.removesuffix()ValidationSeverity.isascii()ValidationSeverity.islower()ValidationSeverity.isupper()ValidationSeverity.istitle()ValidationSeverity.isspace()ValidationSeverity.isdecimal()ValidationSeverity.isdigit()ValidationSeverity.isnumeric()ValidationSeverity.isalpha()ValidationSeverity.isalnum()ValidationSeverity.isidentifier()ValidationSeverity.isprintable()ValidationSeverity.zfill()ValidationSeverity.format()ValidationSeverity.format_map()ValidationSeverity.maketrans()ValidationSeverity.__dir__()
ValidationIssueRoutingValidationReportvalidate_routing_graph()
Submodules¶
semi_cr.core.lab.station.base module¶
- class semi_cr.core.lab.station.base.GraphRelation(*values)[source]¶
Bases:
StrEnum- CONTAINS = 'contains'¶
- DEPENDENCY = 'dependency'¶
- CONNECTION = 'connection'¶
- REPRESENTS = 'represents'¶
- INTERNAL_CONNECTION = 'internal_connection'¶
- PHYSICAL = 'physical'¶
- DEVICE = 'device'¶
- __new_member__(*values)¶
values must already be of type str
- encode(encoding='utf-8', errors='strict')¶
Encode the string using the codec registered for encoding.
- encoding
The encoding in which to encode the string.
- errors
The error handling scheme to use for encoding errors. The default is ‘strict’ meaning that encoding errors raise a UnicodeEncodeError. Other possible values are ‘ignore’, ‘replace’ and ‘xmlcharrefreplace’ as well as any other name registered with codecs.register_error that can handle UnicodeEncodeErrors.
- replace(old, new, count=-1, /)¶
Return a copy with all occurrences of substring old replaced by new.
- count
Maximum number of occurrences to replace. -1 (the default value) means replace all occurrences.
If the optional argument count is given, only the first count occurrences are replaced.
- split(sep=None, maxsplit=-1)¶
Return a list of the substrings in the string, using sep as the separator string.
- sep
The separator used to split the string.
When set to None (the default value), will split on any whitespace character (including n r t f and spaces) and will discard empty strings from the result.
- maxsplit
Maximum number of splits. -1 (the default value) means no limit.
Splitting starts at the front of the string and works to the end.
Note, str.split() is mainly useful for data that has been intentionally delimited. With natural text that includes punctuation, consider using the regular expression module.
- rsplit(sep=None, maxsplit=-1)¶
Return a list of the substrings in the string, using sep as the separator string.
- sep
The separator used to split the string.
When set to None (the default value), will split on any whitespace character (including n r t f and spaces) and will discard empty strings from the result.
- maxsplit
Maximum number of splits. -1 (the default value) means no limit.
Splitting starts at the end of the string and works to the front.
- join(iterable, /)¶
Concatenate any number of strings.
The string whose method is called is inserted in between each given string. The result is returned as a new string.
Example: ‘.’.join([‘ab’, ‘pq’, ‘rs’]) -> ‘ab.pq.rs’
- capitalize()¶
Return a capitalized version of the string.
More specifically, make the first character have upper case and the rest lower case.
- casefold()¶
Return a version of the string suitable for caseless comparisons.
- title()¶
Return a version of the string where each word is titlecased.
More specifically, words start with uppercased characters and all remaining cased characters have lower case.
- center(width, fillchar=' ', /)¶
Return a centered string of length width.
Padding is done using the specified fill character (default is a space).
- count(sub[, start[, end]]) int¶
Return the number of non-overlapping occurrences of substring sub in string S[start:end]. Optional arguments start and end are interpreted as in slice notation.
- expandtabs(tabsize=8)¶
Return a copy where all tab characters are expanded using spaces.
If tabsize is not given, a tab size of 8 characters is assumed.
- find(sub[, start[, end]]) int¶
Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.
Return -1 on failure.
- partition(sep, /)¶
Partition the string into three parts using the given separator.
This will search for the separator in the string. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.
If the separator is not found, returns a 3-tuple containing the original string and two empty strings.
- index(sub[, start[, end]]) int¶
Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.
Raises ValueError when the substring is not found.
- ljust(width, fillchar=' ', /)¶
Return a left-justified string of length width.
Padding is done using the specified fill character (default is a space).
- lower()¶
Return a copy of the string converted to lowercase.
- lstrip(chars=None, /)¶
Return a copy of the string with leading whitespace removed.
If chars is given and not None, remove characters in chars instead.
- rfind(sub[, start[, end]]) int¶
Return the highest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.
Return -1 on failure.
- rindex(sub[, start[, end]]) int¶
Return the highest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.
Raises ValueError when the substring is not found.
- rjust(width, fillchar=' ', /)¶
Return a right-justified string of length width.
Padding is done using the specified fill character (default is a space).
- rstrip(chars=None, /)¶
Return a copy of the string with trailing whitespace removed.
If chars is given and not None, remove characters in chars instead.
- rpartition(sep, /)¶
Partition the string into three parts using the given separator.
This will search for the separator in the string, starting at the end. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.
If the separator is not found, returns a 3-tuple containing two empty strings and the original string.
- splitlines(keepends=False)¶
Return a list of the lines in the string, breaking at line boundaries.
Line breaks are not included in the resulting list unless keepends is given and true.
- strip(chars=None, /)¶
Return a copy of the string with leading and trailing whitespace removed.
If chars is given and not None, remove characters in chars instead.
- swapcase()¶
Convert uppercase characters to lowercase and lowercase characters to uppercase.
- translate(table, /)¶
Replace each character in the string using the given translation table.
- table
Translation table, which must be a mapping of Unicode ordinals to Unicode ordinals, strings, or None.
The table must implement lookup/indexing via __getitem__, for instance a dictionary or list. If this operation raises LookupError, the character is left untouched. Characters mapped to None are deleted.
- upper()¶
Return a copy of the string converted to uppercase.
- startswith(prefix[, start[, end]]) bool¶
Return True if S starts with the specified prefix, False otherwise. With optional start, test S beginning at that position. With optional end, stop comparing S at that position. prefix can also be a tuple of strings to try.
- endswith(suffix[, start[, end]]) bool¶
Return True if S ends with the specified suffix, False otherwise. With optional start, test S beginning at that position. With optional end, stop comparing S at that position. suffix can also be a tuple of strings to try.
- removeprefix(prefix, /)¶
Return a str with the given prefix string removed if present.
If the string starts with the prefix string, return string[len(prefix):]. Otherwise, return a copy of the original string.
- removesuffix(suffix, /)¶
Return a str with the given suffix string removed if present.
If the string ends with the suffix string and that suffix is not empty, return string[:-len(suffix)]. Otherwise, return a copy of the original string.
- isascii()¶
Return True if all characters in the string are ASCII, False otherwise.
ASCII characters have code points in the range U+0000-U+007F. Empty string is ASCII too.
- islower()¶
Return True if the string is a lowercase string, False otherwise.
A string is lowercase if all cased characters in the string are lowercase and there is at least one cased character in the string.
- isupper()¶
Return True if the string is an uppercase string, False otherwise.
A string is uppercase if all cased characters in the string are uppercase and there is at least one cased character in the string.
- istitle()¶
Return True if the string is a title-cased string, False otherwise.
In a title-cased string, upper- and title-case characters may only follow uncased characters and lowercase characters only cased ones.
- isspace()¶
Return True if the string is a whitespace string, False otherwise.
A string is whitespace if all characters in the string are whitespace and there is at least one character in the string.
- isdecimal()¶
Return True if the string is a decimal string, False otherwise.
A string is a decimal string if all characters in the string are decimal and there is at least one character in the string.
- isdigit()¶
Return True if the string is a digit string, False otherwise.
A string is a digit string if all characters in the string are digits and there is at least one character in the string.
- isnumeric()¶
Return True if the string is a numeric string, False otherwise.
A string is numeric if all characters in the string are numeric and there is at least one character in the string.
- isalpha()¶
Return True if the string is an alphabetic string, False otherwise.
A string is alphabetic if all characters in the string are alphabetic and there is at least one character in the string.
- isalnum()¶
Return True if the string is an alpha-numeric string, False otherwise.
A string is alpha-numeric if all characters in the string are alpha-numeric and there is at least one character in the string.
- isidentifier()¶
Return True if the string is a valid Python identifier, False otherwise.
Call keyword.iskeyword(s) to test whether string s is a reserved identifier, such as “def” or “class”.
- isprintable()¶
Return True if the string is printable, False otherwise.
A string is printable if all of its characters are considered printable in repr() or if it is empty.
- zfill(width, /)¶
Pad a numeric string with zeros on the left, to fill a field of the given width.
The string is never truncated.
- format(*args, **kwargs) str¶
Return a formatted version of S, using substitutions from args and kwargs. The substitutions are identified by braces (‘{’ and ‘}’).
- format_map(mapping) str¶
Return a formatted version of S, using substitutions from mapping. The substitutions are identified by braces (‘{’ and ‘}’).
- static maketrans()¶
Return a translation table usable for str.translate().
If there is only one argument, it must be a dictionary mapping Unicode ordinals (integers) or characters to Unicode ordinals, strings or None. Character keys will be then converted to ordinals. If there are two arguments, they must be strings of equal length, and in the resulting dictionary, each character in x will be mapped to the character at the same position in y. If there is a third argument, it must be a string, whose characters will be mapped to None in the result.
- __dir__()¶
Returns public methods and other interesting attributes.
- class semi_cr.core.lab.station.base.InstrumentSpec(name: str, type: str, init: dict[str, ~typing.Any]=<factory>)[source]¶
Bases:
objectStatic description of an instrument.
Does not represent an active connection and does not contain a QCoDeS Instrument instance.
- semi_cr.core.lab.station.base.static_instrument_node_id(spec: InstrumentSpec) str[source]¶
- class semi_cr.core.lab.station.base.ConfigBundle(files: str | Path | tuple[str | Path, ...] | None = None)[source]¶
Bases:
objectA container class for QCoDes configuration that has been loaded from one or more yaml files. Instantiate a ConfigBundle with or without files, and add more using import_yaml.
Jens has a suspicion that we can avoid some complexity by encapsulating the configuration merging logic properly in here and having it here only. I believe now the ConfigBundle does that properly.
- dict() Mapping[str, Any][source]¶
Allows the retrieval the YaML configuration as a big honkin’ dict.
- get_items() list[QCoDeSInstrumentSpec][source]¶
The QCoDes-style configuration we use kind of puts everything into one big instruments hierarchy. We can get an adequate approximation of ‘what is in this station’ by simply iterating over all these so-called instruments.
- load() Mapping[str, Any][source]¶
Loads a dict of paths to configuration files into a merged dict. A
Maintaining parity by initializing self.config to the empty dict. Would be nice if the ConfigBundle would maintain state.
DEPRECATED: Get rid of this method and self.config in order to maintain atomicity. :return:
- import_yaml(yamlfile: str | Path | tuple[str | Path, ...]) None[source]¶
Takes a reference to a file or a tuple of such references and augments the current set of configurations with it.
- merge(other: ConfigBundle) ConfigBundle[source]¶
- dump_yaml(stream) None[source]¶
Dumps a YaML structure from the current ConfigBundle contents into a provided stream.
- get_yaml() str[source]¶
- Returns:
a string containing a YaML document containing the current state of the ConfigBundle.
- classmethod combine(*bundles: ConfigBundle) ConfigBundle[source]¶
semi_cr.core.lab.station.context_old module¶
- class semi_cr.core.lab.station.context_old.StaticTerminalRef(instrument: str, module: str | None, terminal: str)[source]¶
Bases:
object
- class semi_cr.core.lab.station.context_old.InfrastructureContext(wiring_config: semi_cr.core.lab.station.base.ConfigBundle, electronics_config: semi_cr.core.lab.station.base.ConfigBundle)[source]¶
Bases:
object- wiring_config: ConfigBundle¶
- electronics_config: ConfigBundle¶
- config: ConfigBundle¶
- graph: MultiDiGraph¶
- semi_cr.core.lab.station.context_old.build_instrument_specs(config: dict[str, Any]) dict[str, InstrumentSpec][source]¶
- class semi_cr.core.lab.station.context_old.StaticStationContext(device: ConfigContext, infrastructure: InfrastructureContext)[source]¶
Bases:
objectDescription of the complete station without talking to hardware.
- device: ConfigContext¶
- infrastructure: InfrastructureContext¶
- config: ConfigBundle¶
- instruments: dict[str, InstrumentSpec]¶
- graph: MultiDiGraph¶
- class semi_cr.core.lab.station.context_old.RuntimeBinding(static_id: str, runtime_id: str, runtime_object: Any)[source]¶
Bases:
object
- class semi_cr.core.lab.station.context_old.RuntimeBindingRegistry[source]¶
Bases:
object- get_binding(static_id: str) RuntimeBinding[source]¶
- semi_cr.core.lab.station.context_old.normalize_qcodes_config(config: dict[str, Any]) dict[str, Any][source]¶
- class semi_cr.core.lab.station.context_old.ContextState(*values)[source]¶
Bases:
Enum- CREATED = 1¶
- LOADED = 2¶
- PARTIALLY_CONNECTED = 3¶
- CONNECTED = 4¶
- classmethod __contains__(value)¶
Return True if value is in cls.
value is in cls if: 1) value is a member of cls, or 2) value is the value of one of the cls’s members.
- classmethod __getitem__(name)¶
Return the member matching name.
- classmethod __iter__()¶
Return members in definition order.
- classmethod __len__()¶
Return the number of members (no aliases)
- class semi_cr.core.lab.station.context_old.StationContext(station: LabStation, static: StaticStationContext)[source]¶
Bases:
objectRuntime realization of a StaticStationContext.
Construction is intentionally side-effect free.
Lifecycle:
context = StationContext(station, static)
context.load() context.connect()
…
context.disconnect()
- station: LabStation¶
- static: StaticStationContext¶
- property bindings: RuntimeBindingRegistry¶
- resolve_runtime(static_id: str) Any[source]¶
Resolve a static object ID to its runtime realization.
Runtime resolution is available once bindings have been created, including while the context is being connected.
- property instruments: dict[str, Instrument]¶
- property graph: MultiDiGraph¶
- property state: ContextState¶
- property has_connections: bool¶
True when at least one instrument owned by this context is currently connected.
- load() None[source]¶
Load the static configuration into the QCoDeS station.
This does not connect to physical instruments.
- connect(instruments: str | Iterable[str] | None = None) None[source]¶
Connect one, several, or all configured instruments.
- Parameters:
instruments – QCoDeS instrument config name, iterable of config names, or None to connect all configured instruments.
Examples
context.connect() context.connect(“qdac_1”) context.connect([“qdac_1”, “smu”])
- disconnect(instruments: str | Iterable[str] | None = None) None[source]¶
Disconnect one, several, or all runtime instruments instantiated by this context.
QCoDeS configuration remains loaded.
- Parameters:
instruments – Config name, iterable of config names, or None to disconnect all instruments owned by this context.
Examples
context.disconnect() context.disconnect(“qdac_1”) context.disconnect([“qdac_1”, “smu”])
semi_cr.core.lab.station.metadata module¶
- class semi_cr.core.lab.station.metadata.LabStation(cfg_file: str | pathlib.Path)[source]¶
Bases:
Station- __getitem__(key: str) Metadatable¶
Shortcut to components dictionary.
- add_component(component: MetadatableWithName, name: str | None = None, update_snapshot: bool = True) str¶
Record one component as part of this Station.
- Parameters:
component – Components to add to the Station.
name – Name of the component.
update_snapshot – Immediately update the snapshot of each component as it is added to the Station.
- Returns:
- The name assigned this component, which may have been changed
to make it unique among previously added components.
- Return type:
- close_all_registered_instruments() None¶
Closes all instruments that are registered to this Station object by calling the
base.Instrument.close()-method on each one. The instruments will be removed from the station and from the QCoDeS monitor.
- close_and_remove_instrument(instrument: Instrument | str) None¶
Safely close instrument and remove from station and monitor list.
- config: StationConfig | None = None¶
A user dict representing the YAML file that the station was loaded from
- delegate_attr_dicts: ClassVar[list[str]] = ['components']¶
A list of names (strings) of dictionaries which are (or will be) attributes of
self, whose keys should be treated as attributes ofself.
- delegate_attr_objects: ClassVar[list[str]] = []¶
A list of names (strings) of objects which are (or will be) attributes of
self, whose attributes should be passed through toself.
- get_component(full_name: str) MetadatableWithName¶
Get a (sub)component with a given name from this Station. The name may be of a component that is a sub-component of another component, e.g. a parameter on an instrument, an instrument module or an top-level instrument.
- Parameters:
full_name – Name of the component.
- Returns:
The component with the given name.
- Raises:
KeyError – If a component with the given name is not part of this station.
- load_all_instruments(only_names: Iterable[str] | None = None, only_types: Iterable[str] | None = None) tuple[str, ...]¶
Load all instruments specified in the loaded YAML station configuration.
Optionally, the instruments to be loaded can be filtered by their names or types, use
only_namesandonly_typesarguments for that. It is an error to supply bothonly_namesandonly_types.- Parameters:
only_names – List of instrument names to load from the config. If left as None, then all instruments are loaded.
only_types – List of instrument types e.g. the class names of the instruments to load. If left as None, then all instruments are loaded.
- Returns:
The names of the loaded instruments
- load_config(config: str | IO) None¶
Loads a configuration from a supplied string or file/stream handle. The string or file/stream is expected to be YAML formatted
Loading of a configuration will update the snapshot of the station and make the instruments described in the config file available for instantiation with the
load_instrument()method.Additionally the shortcut methods
load_<instrument_name>will be updated.
- load_config_file(filename: str | None = None) None¶
Loads a configuration from a YAML file. If filename is not specified the default file name from the qcodes configuration will be used.
Loading of a configuration will update the snapshot of the station and make the instruments described in the config file available for instantiation with the
load_instrument()method.Additionally the shortcut methods
load_<instrument_name>will be updated.
- load_config_files(*filenames: str) None¶
Loads configuration from multiple YAML files after merging them into one. If filenames are not specified the default file name from the qcodes configuration will be used.
Loading of configuration will update the snapshot of the station and make the instruments described in the config files available for instantiation with the
load_instrument()method.Additionally the shortcut methods
load_<instrument_name>will be updated.
- load_instrument(identifier: str, revive_instance: bool = False, update_snapshot: bool = True, **kwargs: Any) Instrument¶
Creates an
Instrumentinstance as described by the loaded configuration file.- Parameters:
identifier – The identifying string that is looked up in the yaml configuration file, which identifies the instrument to be added.
revive_instance – If
True, try to return an instrument with the specified name instead of closing it and creating a new one.update_snapshot – Immediately update the snapshot of the instrument as it is added to the Station.
**kwargs – Additional keyword arguments that get passed on to the
__init__-method of the instrument to be added.
- load_metadata(metadata: Mapping[str, Any]) None¶
Load metadata into this classes metadata dictionary.
- Parameters:
metadata – Metadata to load.
- omit_delegate_attrs: ClassVar[list[str]] = []¶
A list of attribute names (strings) to not delegate to any other dictionary or object.
- remove_component(name: str) MetadatableWithName | None¶
Remove a component with a given name from this Station.
- Parameters:
name – Name of the component.
- Returns:
The component that has been removed (this behavior is the same as for Python dictionaries).
- Raises:
KeyError – If a component with the given name is not part of this station.
- snapshot(update: bool | None = False) 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 – Passed to snapshot_base.
- Returns:
Base snapshot.
- snapshot_base(update: bool | None = True, params_to_skip_update: Sequence[str] | None = None) dict[Any, Any]¶
State of the station as a JSON-compatible dictionary (everything that the custom JSON encoder class
NumpyJSONEncodersupports).Note: If the station contains an instrument that has already been closed, not only will it not be snapshotted, it will also be removed from the station during the execution of this function.
- Parameters:
update – If
True, update the state by querying the all the children: f.ex. instruments, parameters, components, etc. If None only update if the state is known to be invalid. IfFalse, just use the latest values in memory and never update the state.params_to_skip_update – Not used.
- Returns:
Base snapshot.
- Return type:
semi_cr.core.lab.station.nodes module¶
- class semi_cr.core.lab.station.nodes.BetterDelegateParameter(name: str, *, source: Parameter | None, **kwargs: Unpack[ParameterKWArgs[ParameterDataTypeVar, InstrumentTypeVar_co]])[source]¶
Bases:
DelegateParameter- validate(value: Any | None) None[source]¶
Validate the supplied value. If it has a source parameter, validate the value as well with the source validator.
- Parameters:
value – value to validate
- Raises:
TypeError – If the value is of the wrong type.
ValueError – If the value is outside the bounds specified by the validator.
- __getitem__(keys: Any) SweepFixedValues¶
Slice a Parameter to get a SweepValues object to iterate over during a sweep
- add_validator(vals: Validator) None¶
Add a validator for the parameter. The parameter is validated against all validators in reverse order of how they are added.
- Parameters:
vals – Validator to add to the parameter.
- property depends_on: ParameterSet¶
- extra_validator(vals: Validator) Generator[None, None, None]¶
Contextmanager to to temporarily add a validator to the parameter within the given context. The validator is removed from the parameter when the context ends.
- property full_name: str¶
Name of the parameter including the name of the instrument and submodule that the parameter may be bound to. The names are separated by underscores, like this:
instrument_submodule_parameter.
- get_ramp_values(value: NumberType | Sized, step: NumberType | None = None) Sequence[NumberType | Sized]¶
Return values to sweep from current value to target value. This method can be overridden to have a custom sweep behaviour. It can even be overridden by a generator.
- Parameters:
value – target value
step – maximum step size
- Returns:
List of stepped values, including target value.
- get_raw() Any¶
get_rawis called to perform the actual data acquisition from the instrument. This method should either be overwritten to perform the desired operation or alternatively forParametera suitable method is automatically generated ifget_cmdis supplied to the parameter constructor. The method is automatically wrapped to provide agetmethod on the parameter instance.
- global_on_set_callback = None¶
- property has_control_of: ParameterSet¶
- increment(value: ParameterDataTypeVar) None¶
Increment the parameter with a value
- Parameters:
value – Value to be added to the parameter.
- property instrument: InstrumentTypeVar_co¶
Return the first instrument that this parameter is bound to. E.g if this is bound to a channel it will return the channel and not the instrument that the channel is bound too. Use
root_instrument()to get the real instrument.
- property inter_delay: float¶
Delay time between consecutive set operations. The actual time will not be shorter than this, but may be longer if the underlying set call takes longer.
Typically used in conjunction with step to create an effective ramp rate, but can also be used without a step to enforce a delay between sets.
- Getter:
Returns the current inter_delay.
- Setter:
Sets the value of the inter_delay.
- Raises:
TypeError – If delay is not int nor float
ValueError – If delay is negative
- property is_controlled_by: ParameterSet¶
- property label: str¶
Label of the data used for plots etc. Read from source if not explicitly overwritten. Set to None to disable overwrite.
- load_metadata(metadata: Mapping[str, Any]) None¶
Load metadata into this classes metadata dictionary.
- Parameters:
metadata – Metadata to load.
- property name: str¶
Name of the parameter. This is identical to
short_name().
- property param_spec: ParamSpecBase¶
- property post_delay: float¶
Delay time after start of set operation, for each set. The actual time will not be shorter than this, but may be longer if the underlying set call takes longer.
Typically used in conjunction with step to create an effective ramp rate, but can also be used without a step to enforce a delay after every set. One might think of post_delay as how long a set operation is supposed to take. For example, there might be an instrument that needs extra time after setting a parameter although the command for setting the parameter returns quickly.
- Getter:
Returns the current post_delay.
- Setter:
Sets the value of the post_delay.
- Raises:
TypeError – If delay is not int nor float
ValueError – If delay is negative
- property raw_value: Any¶
Note that this property will be deprecated soon. Use
cache.raw_valueinstead.Represents the cached raw value of the parameter.
- Getter:
Returns the cached raw value of the parameter.
- property register_name: str¶
Name that will be used to register this parameter in a dataset By default, this returns
full_nameor the value of theregister_nameargument if it was passed at initialization.
- remove_validator() Validator | None¶
Remove the last validator added to the parameter and return it. Returns None if there are no validators associated with the parameter.
- Returns:
The last validator added to the parameter or None if there are no validators associated with the parameter.
- restore_at_exit(allow_changes: bool = True) _SetParamContext¶
Use a context manager to restore the value of a parameter after a
withblock.By default, the parameter value may be changed inside the block, but this can be prevented with
allow_changes=False. This can be useful, for example, for debugging a complex measurement that unintentionally modifies a parameter.Example
>>> p = Parameter("p", set_cmd=None, get_cmd=None) >>> p.set(2) >>> with p.restore_at_exit(): ... p.set(3) ... print(f"value inside with block: {p.get()}") # prints 3 >>> print(f"value after with block: {p.get()}") # prints 2 >>> with p.restore_at_exit(allow_changes=False): ... p.set(5) # raises an exception
- property root_instrument: InstrumentBase | None¶
Return the fundamental instrument that this parameter belongs too. E.g if the parameter is bound to a channel this will return the fundamental instrument that that channel belongs to. Use
instrument()to get the channel.
- set_raw(value: Any) None¶
set_rawis called to perform the actual setting of a parameter on the instrument. This method should either be overwritten to perform the desired operation or alternatively forParametera suitable method is automatically generated ifset_cmdis supplied to the parameter constructor. The method is automatically wrapped to provide asetmethod on the parameter instance.
- set_to(value: ParameterDataTypeVar, allow_changes: bool = False) _SetParamContext¶
Use a context manager to temporarily set a parameter to a value. By default, the parameter value cannot be changed inside the context. This may be overridden with
allow_changes=True.Examples
>>> from qcodes.parameters import Parameter >>> p = Parameter("p", set_cmd=None, get_cmd=None) >>> p.set(2) >>> with p.set_to(3): ... print(f"p value in with block {p.get()}") # prints 3 ... p.set(5) # raises an exception >>> print(f"p value outside with block {p.get()}") # prints 2 >>> with p.set_to(3, allow_changes=True): ... p.set(5) # now this works >>> print(f"value after second block: {p.get()}") # still prints 2
- property short_name: str¶
Short name of the parameter. This is without the name of the instrument or submodule that the parameter may be bound to. For full name refer to
full_name().
- snapshot(update: bool | None = False) 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 – Passed to snapshot_base.
- Returns:
Base snapshot.
- snapshot_base(update: bool | None = True, params_to_skip_update: Sequence[str] | None = None) dict[Any, Any]¶
State of the parameter as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).If the parameter has been initiated with
snapshot_value=False, the snapshot will NOT include thevalueandraw_valueof the parameter.- Parameters:
update – If True, update the state by calling
parameter.get()unlesssnapshot_getof the parameter isFalse. IfupdateisNone, use the current value from thecacheunless the cache is invalid. IfFalse, never callparameter.get().params_to_skip_update – No effect but may be passed from superclass
- Returns:
base snapshot
- property source: Parameter | None¶
The source parameter that this
DelegateParameteris bound to orNoneif thisDelegateParameteris unbound.- Getter:
Returns the current source.
- Setter:
Sets the source.
- property step: int | float | integer | floating | None¶
Stepsize that this Parameter uses during set operation. Stepsize must be a positive number or None. If step is a positive number, this is the maximum value change allowed in one hardware call, so a single set can result in many calls to the hardware if the starting value is far from the target. All but the final change will attempt to change by +/- step exactly. If step is None stepping will not be used.
- Getter:
Returns the current stepsize.
- Setter:
Sets the value of the step.
- Raises:
TypeError – if step is set to not numeric or None
ValueError – if step is set to negative
TypeError – if step is set to not integer or None for an integer parameter
TypeError – if step is set to not a number on None
- sweep(start: float, stop: float, step: float | None = None, num: int | None = None) SweepFixedValues¶
Create a collection of parameter values to be iterated over. Requires start and stop and (step or num) The sign of step is not relevant.
- Parameters:
start – The starting value of the sequence.
stop – The end value of the sequence.
step – Spacing between values.
num – Number of values to generate.
- Returns:
Collection of parameter values to be iterated over.
- Return type:
SweepFixedValues
Examples
>>> sweep(0, 10, num=5) [0.0, 2.5, 5.0, 7.5, 10.0] >>> sweep(5, 10, step=1) [5.0, 6.0, 7.0, 8.0, 9.0, 10.0] >>> sweep(15, 10.5, step=1.5) >[15.0, 13.5, 12.0, 10.5]
- property underlying_instrument: InstrumentBase | None¶
Returns an instance of the underlying hardware instrument that this parameter communicates with, per this parameter’s implementation.
This is useful in the case where a parameter does not belongs to an instrument instance that represents a real hardware instrument but actually uses a real hardware instrument in its implementation (e.g. via calls to one or more parameters of that real hardware instrument). This is also useful when a parameter does belong to an instrument instance but that instance does not represent the real hardware instrument that the parameter interacts with: hence
root_instrumentof the parameter cannot be thehardware_instrument, howeverunderlying_instrumentcan be implemented to return thehardware_instrument.By default it returns the
root_instrumentof the parameter.
- property unit: str¶
The unit of measure. Read from source if not explicitly overwritten. Set to None to disable overwrite.
- property validators: tuple[Validator, ...]¶
Tuple of all validators associated with the parameter. Note that this includes validators of the source parameter if source parameter is set and has any validators.
- Getter:
All validators associated with the parameter.
- property vals: Validator | None¶
The first validator of the parameter. None if no validators are set for this parameter.
- Getter:
Returns the first validator or None if no validators.
- Setter:
Sets the first validator. Set to None to remove the first validator.
- Raises:
RuntimeError – If removing the first validator when more than one validator is set.
- get_parser¶
- set_parser¶
- cache¶
- get_latest¶
- get¶
- set¶
- metadata¶
- class semi_cr.core.lab.station.nodes.NoneParameter(**kwargs: Any)[source]¶
Bases:
Parameter- __getitem__(keys: Any) SweepFixedValues¶
Slice a Parameter to get a SweepValues object to iterate over during a sweep
- add_validator(vals: Validator) None¶
Add a validator for the parameter. The parameter is validated against all validators in reverse order of how they are added.
- Parameters:
vals – Validator to add to the parameter.
- property depends_on: ParameterSet¶
- extra_validator(vals: Validator) Generator[None, None, None]¶
Contextmanager to to temporarily add a validator to the parameter within the given context. The validator is removed from the parameter when the context ends.
- property full_name: str¶
Name of the parameter including the name of the instrument and submodule that the parameter may be bound to. The names are separated by underscores, like this:
instrument_submodule_parameter.
- get_ramp_values(value: NumberType | Sized, step: NumberType | None = None) Sequence[NumberType | Sized]¶
Return values to sweep from current value to target value. This method can be overridden to have a custom sweep behaviour. It can even be overridden by a generator.
- Parameters:
value – target value
step – maximum step size
- Returns:
List of stepped values, including target value.
- get_raw() Any¶
get_rawis called to perform the actual data acquisition from the instrument. This method should either be overwritten to perform the desired operation or alternatively forParametera suitable method is automatically generated ifget_cmdis supplied to the parameter constructor. The method is automatically wrapped to provide agetmethod on the parameter instance.
- global_on_set_callback = None¶
- property has_control_of: ParameterSet¶
- increment(value: ParameterDataTypeVar) None¶
Increment the parameter with a value
- Parameters:
value – Value to be added to the parameter.
- property instrument: InstrumentTypeVar_co¶
Return the first instrument that this parameter is bound to. E.g if this is bound to a channel it will return the channel and not the instrument that the channel is bound too. Use
root_instrument()to get the real instrument.
- property inter_delay: float¶
Delay time between consecutive set operations. The actual time will not be shorter than this, but may be longer if the underlying set call takes longer.
Typically used in conjunction with step to create an effective ramp rate, but can also be used without a step to enforce a delay between sets.
- Getter:
Returns the current inter_delay.
- Setter:
Sets the value of the inter_delay.
- Raises:
TypeError – If delay is not int nor float
ValueError – If delay is negative
- property is_controlled_by: ParameterSet¶
- load_metadata(metadata: Mapping[str, Any]) None¶
Load metadata into this classes metadata dictionary.
- Parameters:
metadata – Metadata to load.
- property name: str¶
Name of the parameter. This is identical to
short_name().
- property param_spec: ParamSpecBase¶
- property post_delay: float¶
Delay time after start of set operation, for each set. The actual time will not be shorter than this, but may be longer if the underlying set call takes longer.
Typically used in conjunction with step to create an effective ramp rate, but can also be used without a step to enforce a delay after every set. One might think of post_delay as how long a set operation is supposed to take. For example, there might be an instrument that needs extra time after setting a parameter although the command for setting the parameter returns quickly.
- Getter:
Returns the current post_delay.
- Setter:
Sets the value of the post_delay.
- Raises:
TypeError – If delay is not int nor float
ValueError – If delay is negative
- property raw_value: Any¶
Note that this property will be deprecated soon. Use
cache.raw_valueinstead.Represents the cached raw value of the parameter.
- Getter:
Returns the cached raw value of the parameter.
- property register_name: str¶
Name that will be used to register this parameter in a dataset By default, this returns
full_nameor the value of theregister_nameargument if it was passed at initialization.
- remove_validator() Validator | None¶
Remove the last validator added to the parameter and return it. Returns None if there are no validators associated with the parameter.
- Returns:
The last validator added to the parameter or None if there are no validators associated with the parameter.
- restore_at_exit(allow_changes: bool = True) _SetParamContext¶
Use a context manager to restore the value of a parameter after a
withblock.By default, the parameter value may be changed inside the block, but this can be prevented with
allow_changes=False. This can be useful, for example, for debugging a complex measurement that unintentionally modifies a parameter.Example
>>> p = Parameter("p", set_cmd=None, get_cmd=None) >>> p.set(2) >>> with p.restore_at_exit(): ... p.set(3) ... print(f"value inside with block: {p.get()}") # prints 3 >>> print(f"value after with block: {p.get()}") # prints 2 >>> with p.restore_at_exit(allow_changes=False): ... p.set(5) # raises an exception
- property root_instrument: InstrumentBase | None¶
Return the fundamental instrument that this parameter belongs too. E.g if the parameter is bound to a channel this will return the fundamental instrument that that channel belongs to. Use
instrument()to get the channel.
- set_raw(value: Any) None¶
set_rawis called to perform the actual setting of a parameter on the instrument. This method should either be overwritten to perform the desired operation or alternatively forParametera suitable method is automatically generated ifset_cmdis supplied to the parameter constructor. The method is automatically wrapped to provide asetmethod on the parameter instance.
- set_to(value: ParameterDataTypeVar, allow_changes: bool = False) _SetParamContext¶
Use a context manager to temporarily set a parameter to a value. By default, the parameter value cannot be changed inside the context. This may be overridden with
allow_changes=True.Examples
>>> from qcodes.parameters import Parameter >>> p = Parameter("p", set_cmd=None, get_cmd=None) >>> p.set(2) >>> with p.set_to(3): ... print(f"p value in with block {p.get()}") # prints 3 ... p.set(5) # raises an exception >>> print(f"p value outside with block {p.get()}") # prints 2 >>> with p.set_to(3, allow_changes=True): ... p.set(5) # now this works >>> print(f"value after second block: {p.get()}") # still prints 2
- property short_name: str¶
Short name of the parameter. This is without the name of the instrument or submodule that the parameter may be bound to. For full name refer to
full_name().
- snapshot(update: bool | None = False) 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 – Passed to snapshot_base.
- Returns:
Base snapshot.
- snapshot_base(update: bool | None = True, params_to_skip_update: Sequence[str] | None = None) dict[Any, Any]¶
State of the parameter as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).If the parameter has been initiated with
snapshot_value=False, the snapshot will NOT include thevalueandraw_valueof the parameter.- Parameters:
update – If True, update the state by calling
parameter.get()unlesssnapshot_getof the parameter isFalse. IfupdateisNone, use the current value from thecacheunless the cache is invalid. IfFalse, never callparameter.get().params_to_skip_update – No effect but may be passed from superclass
- Returns:
base snapshot
- property step: int | float | integer | floating | None¶
Stepsize that this Parameter uses during set operation. Stepsize must be a positive number or None. If step is a positive number, this is the maximum value change allowed in one hardware call, so a single set can result in many calls to the hardware if the starting value is far from the target. All but the final change will attempt to change by +/- step exactly. If step is None stepping will not be used.
- Getter:
Returns the current stepsize.
- Setter:
Sets the value of the step.
- Raises:
TypeError – if step is set to not numeric or None
ValueError – if step is set to negative
TypeError – if step is set to not integer or None for an integer parameter
TypeError – if step is set to not a number on None
- sweep(start: float, stop: float, step: float | None = None, num: int | None = None) SweepFixedValues¶
Create a collection of parameter values to be iterated over. Requires start and stop and (step or num) The sign of step is not relevant.
- Parameters:
start – The starting value of the sequence.
stop – The end value of the sequence.
step – Spacing between values.
num – Number of values to generate.
- Returns:
Collection of parameter values to be iterated over.
- Return type:
SweepFixedValues
Examples
>>> sweep(0, 10, num=5) [0.0, 2.5, 5.0, 7.5, 10.0] >>> sweep(5, 10, step=1) [5.0, 6.0, 7.0, 8.0, 9.0, 10.0] >>> sweep(15, 10.5, step=1.5) >[15.0, 13.5, 12.0, 10.5]
- property underlying_instrument: InstrumentBase | None¶
Returns an instance of the underlying hardware instrument that this parameter communicates with, per this parameter’s implementation.
This is useful in the case where a parameter does not belongs to an instrument instance that represents a real hardware instrument but actually uses a real hardware instrument in its implementation (e.g. via calls to one or more parameters of that real hardware instrument). This is also useful when a parameter does belong to an instrument instance but that instance does not represent the real hardware instrument that the parameter interacts with: hence
root_instrumentof the parameter cannot be thehardware_instrument, howeverunderlying_instrumentcan be implemented to return thehardware_instrument.By default it returns the
root_instrumentof the parameter.
- validate(value: ParameterDataTypeVar) None¶
Validate the value supplied.
- Parameters:
value – value to validate
- Raises:
TypeError – If the value is of the wrong type.
ValueError – If the value is outside the bounds specified by the validator.
- property validators: tuple[Validator, ...]¶
Tuple of all validators associated with the parameter.
- Getter:
All validators associated with the parameter.
- property vals: Validator | None¶
The first validator of the parameter. None if no validators are set for this parameter.
- Getter:
Returns the first validator or None if no validators.
- Setter:
Sets the first validator. Set to None to remove the first validator.
- Raises:
RuntimeError – If removing the first validator when more than one validator is set.
- get_parser¶
- set_parser¶
- cache¶
- get_latest¶
- get¶
- set¶
- metadata¶
- class semi_cr.core.lab.station.nodes.Node(name: str = 'Node', parameters: Iterable[Parameter] = ())[source]¶
Bases:
ABC
- class semi_cr.core.lab.station.nodes.Edge(*values)[source]¶
Bases:
Enum- Active = 1¶
- Inactive = 2¶
- Disabled = 3¶
- classmethod __contains__(value)¶
Return True if value is in cls.
value is in cls if: 1) value is a member of cls, or 2) value is the value of one of the cls’s members.
- classmethod __getitem__(name)¶
Return the member matching name.
- classmethod __iter__()¶
Return members in definition order.
- classmethod __len__()¶
Return the number of members (no aliases)
- class semi_cr.core.lab.station.nodes.SingleSourceNode(name: str = 'SingleSourceNode')[source]¶
Bases:
Node
- class semi_cr.core.lab.station.nodes.ForwardingNode(name: str = 'SingleSourceNode')[source]¶
Bases:
SingleSourceNode
- class semi_cr.core.lab.station.nodes.MultiSourceForwardingNode(name: str = 'MultiSourceForwardingNode')[source]¶
Bases:
Node
- class semi_cr.core.lab.station.nodes.CompositeParameter(name: str, **kwargs: Any)[source]¶
Bases:
Parameter- get_raw() Any[source]¶
get_rawis called to perform the actual data acquisition from the instrument. This method should either be overwritten to perform the desired operation or alternatively forParametera suitable method is automatically generated ifget_cmdis supplied to the parameter constructor. The method is automatically wrapped to provide agetmethod on the parameter instance.
- __getitem__(keys: Any) SweepFixedValues¶
Slice a Parameter to get a SweepValues object to iterate over during a sweep
- add_validator(vals: Validator) None¶
Add a validator for the parameter. The parameter is validated against all validators in reverse order of how they are added.
- Parameters:
vals – Validator to add to the parameter.
- property depends_on: ParameterSet¶
- extra_validator(vals: Validator) Generator[None, None, None]¶
Contextmanager to to temporarily add a validator to the parameter within the given context. The validator is removed from the parameter when the context ends.
- property full_name: str¶
Name of the parameter including the name of the instrument and submodule that the parameter may be bound to. The names are separated by underscores, like this:
instrument_submodule_parameter.
- get_ramp_values(value: NumberType | Sized, step: NumberType | None = None) Sequence[NumberType | Sized]¶
Return values to sweep from current value to target value. This method can be overridden to have a custom sweep behaviour. It can even be overridden by a generator.
- Parameters:
value – target value
step – maximum step size
- Returns:
List of stepped values, including target value.
- global_on_set_callback = None¶
- property has_control_of: ParameterSet¶
- increment(value: ParameterDataTypeVar) None¶
Increment the parameter with a value
- Parameters:
value – Value to be added to the parameter.
- property instrument: InstrumentTypeVar_co¶
Return the first instrument that this parameter is bound to. E.g if this is bound to a channel it will return the channel and not the instrument that the channel is bound too. Use
root_instrument()to get the real instrument.
- property inter_delay: float¶
Delay time between consecutive set operations. The actual time will not be shorter than this, but may be longer if the underlying set call takes longer.
Typically used in conjunction with step to create an effective ramp rate, but can also be used without a step to enforce a delay between sets.
- Getter:
Returns the current inter_delay.
- Setter:
Sets the value of the inter_delay.
- Raises:
TypeError – If delay is not int nor float
ValueError – If delay is negative
- property is_controlled_by: ParameterSet¶
- load_metadata(metadata: Mapping[str, Any]) None¶
Load metadata into this classes metadata dictionary.
- Parameters:
metadata – Metadata to load.
- property name: str¶
Name of the parameter. This is identical to
short_name().
- property param_spec: ParamSpecBase¶
- property post_delay: float¶
Delay time after start of set operation, for each set. The actual time will not be shorter than this, but may be longer if the underlying set call takes longer.
Typically used in conjunction with step to create an effective ramp rate, but can also be used without a step to enforce a delay after every set. One might think of post_delay as how long a set operation is supposed to take. For example, there might be an instrument that needs extra time after setting a parameter although the command for setting the parameter returns quickly.
- Getter:
Returns the current post_delay.
- Setter:
Sets the value of the post_delay.
- Raises:
TypeError – If delay is not int nor float
ValueError – If delay is negative
- property raw_value: Any¶
Note that this property will be deprecated soon. Use
cache.raw_valueinstead.Represents the cached raw value of the parameter.
- Getter:
Returns the cached raw value of the parameter.
- property register_name: str¶
Name that will be used to register this parameter in a dataset By default, this returns
full_nameor the value of theregister_nameargument if it was passed at initialization.
- remove_validator() Validator | None¶
Remove the last validator added to the parameter and return it. Returns None if there are no validators associated with the parameter.
- Returns:
The last validator added to the parameter or None if there are no validators associated with the parameter.
- restore_at_exit(allow_changes: bool = True) _SetParamContext¶
Use a context manager to restore the value of a parameter after a
withblock.By default, the parameter value may be changed inside the block, but this can be prevented with
allow_changes=False. This can be useful, for example, for debugging a complex measurement that unintentionally modifies a parameter.Example
>>> p = Parameter("p", set_cmd=None, get_cmd=None) >>> p.set(2) >>> with p.restore_at_exit(): ... p.set(3) ... print(f"value inside with block: {p.get()}") # prints 3 >>> print(f"value after with block: {p.get()}") # prints 2 >>> with p.restore_at_exit(allow_changes=False): ... p.set(5) # raises an exception
- property root_instrument: InstrumentBase | None¶
Return the fundamental instrument that this parameter belongs too. E.g if the parameter is bound to a channel this will return the fundamental instrument that that channel belongs to. Use
instrument()to get the channel.
- set_raw(value: Any) None¶
set_rawis called to perform the actual setting of a parameter on the instrument. This method should either be overwritten to perform the desired operation or alternatively forParametera suitable method is automatically generated ifset_cmdis supplied to the parameter constructor. The method is automatically wrapped to provide asetmethod on the parameter instance.
- set_to(value: ParameterDataTypeVar, allow_changes: bool = False) _SetParamContext¶
Use a context manager to temporarily set a parameter to a value. By default, the parameter value cannot be changed inside the context. This may be overridden with
allow_changes=True.Examples
>>> from qcodes.parameters import Parameter >>> p = Parameter("p", set_cmd=None, get_cmd=None) >>> p.set(2) >>> with p.set_to(3): ... print(f"p value in with block {p.get()}") # prints 3 ... p.set(5) # raises an exception >>> print(f"p value outside with block {p.get()}") # prints 2 >>> with p.set_to(3, allow_changes=True): ... p.set(5) # now this works >>> print(f"value after second block: {p.get()}") # still prints 2
- property short_name: str¶
Short name of the parameter. This is without the name of the instrument or submodule that the parameter may be bound to. For full name refer to
full_name().
- snapshot(update: bool | None = False) 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 – Passed to snapshot_base.
- Returns:
Base snapshot.
- snapshot_base(update: bool | None = True, params_to_skip_update: Sequence[str] | None = None) dict[Any, Any]¶
State of the parameter as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).If the parameter has been initiated with
snapshot_value=False, the snapshot will NOT include thevalueandraw_valueof the parameter.- Parameters:
update – If True, update the state by calling
parameter.get()unlesssnapshot_getof the parameter isFalse. IfupdateisNone, use the current value from thecacheunless the cache is invalid. IfFalse, never callparameter.get().params_to_skip_update – No effect but may be passed from superclass
- Returns:
base snapshot
- property step: int | float | integer | floating | None¶
Stepsize that this Parameter uses during set operation. Stepsize must be a positive number or None. If step is a positive number, this is the maximum value change allowed in one hardware call, so a single set can result in many calls to the hardware if the starting value is far from the target. All but the final change will attempt to change by +/- step exactly. If step is None stepping will not be used.
- Getter:
Returns the current stepsize.
- Setter:
Sets the value of the step.
- Raises:
TypeError – if step is set to not numeric or None
ValueError – if step is set to negative
TypeError – if step is set to not integer or None for an integer parameter
TypeError – if step is set to not a number on None
- sweep(start: float, stop: float, step: float | None = None, num: int | None = None) SweepFixedValues¶
Create a collection of parameter values to be iterated over. Requires start and stop and (step or num) The sign of step is not relevant.
- Parameters:
start – The starting value of the sequence.
stop – The end value of the sequence.
step – Spacing between values.
num – Number of values to generate.
- Returns:
Collection of parameter values to be iterated over.
- Return type:
SweepFixedValues
Examples
>>> sweep(0, 10, num=5) [0.0, 2.5, 5.0, 7.5, 10.0] >>> sweep(5, 10, step=1) [5.0, 6.0, 7.0, 8.0, 9.0, 10.0] >>> sweep(15, 10.5, step=1.5) >[15.0, 13.5, 12.0, 10.5]
- property underlying_instrument: InstrumentBase | None¶
Returns an instance of the underlying hardware instrument that this parameter communicates with, per this parameter’s implementation.
This is useful in the case where a parameter does not belongs to an instrument instance that represents a real hardware instrument but actually uses a real hardware instrument in its implementation (e.g. via calls to one or more parameters of that real hardware instrument). This is also useful when a parameter does belong to an instrument instance but that instance does not represent the real hardware instrument that the parameter interacts with: hence
root_instrumentof the parameter cannot be thehardware_instrument, howeverunderlying_instrumentcan be implemented to return thehardware_instrument.By default it returns the
root_instrumentof the parameter.
- validate(value: ParameterDataTypeVar) None¶
Validate the value supplied.
- Parameters:
value – value to validate
- Raises:
TypeError – If the value is of the wrong type.
ValueError – If the value is outside the bounds specified by the validator.
- property validators: tuple[Validator, ...]¶
Tuple of all validators associated with the parameter.
- Getter:
All validators associated with the parameter.
- property vals: Validator | None¶
The first validator of the parameter. None if no validators are set for this parameter.
- Getter:
Returns the first validator or None if no validators.
- Setter:
Sets the first validator. Set to None to remove the first validator.
- Raises:
RuntimeError – If removing the first validator when more than one validator is set.
- get_parser¶
- set_parser¶
- cache¶
- get_latest¶
- get¶
- set¶
- metadata¶
- class semi_cr.core.lab.station.nodes.SeriesResistanceParameter(name: str, **kwargs: Any)[source]¶
Bases:
CompositeParameter- get_raw() float[source]¶
get_rawis called to perform the actual data acquisition from the instrument. This method should either be overwritten to perform the desired operation or alternatively forParametera suitable method is automatically generated ifget_cmdis supplied to the parameter constructor. The method is automatically wrapped to provide agetmethod on the parameter instance.
- __getitem__(keys: Any) SweepFixedValues¶
Slice a Parameter to get a SweepValues object to iterate over during a sweep
- add_validator(vals: Validator) None¶
Add a validator for the parameter. The parameter is validated against all validators in reverse order of how they are added.
- Parameters:
vals – Validator to add to the parameter.
- property depends_on: ParameterSet¶
- extra_validator(vals: Validator) Generator[None, None, None]¶
Contextmanager to to temporarily add a validator to the parameter within the given context. The validator is removed from the parameter when the context ends.
- property full_name: str¶
Name of the parameter including the name of the instrument and submodule that the parameter may be bound to. The names are separated by underscores, like this:
instrument_submodule_parameter.
- get_ramp_values(value: NumberType | Sized, step: NumberType | None = None) Sequence[NumberType | Sized]¶
Return values to sweep from current value to target value. This method can be overridden to have a custom sweep behaviour. It can even be overridden by a generator.
- Parameters:
value – target value
step – maximum step size
- Returns:
List of stepped values, including target value.
- global_on_set_callback = None¶
- property has_control_of: ParameterSet¶
- increment(value: ParameterDataTypeVar) None¶
Increment the parameter with a value
- Parameters:
value – Value to be added to the parameter.
- property instrument: InstrumentTypeVar_co¶
Return the first instrument that this parameter is bound to. E.g if this is bound to a channel it will return the channel and not the instrument that the channel is bound too. Use
root_instrument()to get the real instrument.
- property inter_delay: float¶
Delay time between consecutive set operations. The actual time will not be shorter than this, but may be longer if the underlying set call takes longer.
Typically used in conjunction with step to create an effective ramp rate, but can also be used without a step to enforce a delay between sets.
- Getter:
Returns the current inter_delay.
- Setter:
Sets the value of the inter_delay.
- Raises:
TypeError – If delay is not int nor float
ValueError – If delay is negative
- property is_controlled_by: ParameterSet¶
- load_metadata(metadata: Mapping[str, Any]) None¶
Load metadata into this classes metadata dictionary.
- Parameters:
metadata – Metadata to load.
- property name: str¶
Name of the parameter. This is identical to
short_name().
- property param_spec: ParamSpecBase¶
- property post_delay: float¶
Delay time after start of set operation, for each set. The actual time will not be shorter than this, but may be longer if the underlying set call takes longer.
Typically used in conjunction with step to create an effective ramp rate, but can also be used without a step to enforce a delay after every set. One might think of post_delay as how long a set operation is supposed to take. For example, there might be an instrument that needs extra time after setting a parameter although the command for setting the parameter returns quickly.
- Getter:
Returns the current post_delay.
- Setter:
Sets the value of the post_delay.
- Raises:
TypeError – If delay is not int nor float
ValueError – If delay is negative
- property raw_value: Any¶
Note that this property will be deprecated soon. Use
cache.raw_valueinstead.Represents the cached raw value of the parameter.
- Getter:
Returns the cached raw value of the parameter.
- property register_name: str¶
Name that will be used to register this parameter in a dataset By default, this returns
full_nameor the value of theregister_nameargument if it was passed at initialization.
- remove_validator() Validator | None¶
Remove the last validator added to the parameter and return it. Returns None if there are no validators associated with the parameter.
- Returns:
The last validator added to the parameter or None if there are no validators associated with the parameter.
- restore_at_exit(allow_changes: bool = True) _SetParamContext¶
Use a context manager to restore the value of a parameter after a
withblock.By default, the parameter value may be changed inside the block, but this can be prevented with
allow_changes=False. This can be useful, for example, for debugging a complex measurement that unintentionally modifies a parameter.Example
>>> p = Parameter("p", set_cmd=None, get_cmd=None) >>> p.set(2) >>> with p.restore_at_exit(): ... p.set(3) ... print(f"value inside with block: {p.get()}") # prints 3 >>> print(f"value after with block: {p.get()}") # prints 2 >>> with p.restore_at_exit(allow_changes=False): ... p.set(5) # raises an exception
- property root_instrument: InstrumentBase | None¶
Return the fundamental instrument that this parameter belongs too. E.g if the parameter is bound to a channel this will return the fundamental instrument that that channel belongs to. Use
instrument()to get the channel.
- set_raw(value: Any) None¶
set_rawis called to perform the actual setting of a parameter on the instrument. This method should either be overwritten to perform the desired operation or alternatively forParametera suitable method is automatically generated ifset_cmdis supplied to the parameter constructor. The method is automatically wrapped to provide asetmethod on the parameter instance.
- set_to(value: ParameterDataTypeVar, allow_changes: bool = False) _SetParamContext¶
Use a context manager to temporarily set a parameter to a value. By default, the parameter value cannot be changed inside the context. This may be overridden with
allow_changes=True.Examples
>>> from qcodes.parameters import Parameter >>> p = Parameter("p", set_cmd=None, get_cmd=None) >>> p.set(2) >>> with p.set_to(3): ... print(f"p value in with block {p.get()}") # prints 3 ... p.set(5) # raises an exception >>> print(f"p value outside with block {p.get()}") # prints 2 >>> with p.set_to(3, allow_changes=True): ... p.set(5) # now this works >>> print(f"value after second block: {p.get()}") # still prints 2
- property short_name: str¶
Short name of the parameter. This is without the name of the instrument or submodule that the parameter may be bound to. For full name refer to
full_name().
- snapshot(update: bool | None = False) 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 – Passed to snapshot_base.
- Returns:
Base snapshot.
- snapshot_base(update: bool | None = True, params_to_skip_update: Sequence[str] | None = None) dict[Any, Any]¶
State of the parameter as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).If the parameter has been initiated with
snapshot_value=False, the snapshot will NOT include thevalueandraw_valueof the parameter.- Parameters:
update – If True, update the state by calling
parameter.get()unlesssnapshot_getof the parameter isFalse. IfupdateisNone, use the current value from thecacheunless the cache is invalid. IfFalse, never callparameter.get().params_to_skip_update – No effect but may be passed from superclass
- Returns:
base snapshot
- property step: int | float | integer | floating | None¶
Stepsize that this Parameter uses during set operation. Stepsize must be a positive number or None. If step is a positive number, this is the maximum value change allowed in one hardware call, so a single set can result in many calls to the hardware if the starting value is far from the target. All but the final change will attempt to change by +/- step exactly. If step is None stepping will not be used.
- Getter:
Returns the current stepsize.
- Setter:
Sets the value of the step.
- Raises:
TypeError – if step is set to not numeric or None
ValueError – if step is set to negative
TypeError – if step is set to not integer or None for an integer parameter
TypeError – if step is set to not a number on None
- sweep(start: float, stop: float, step: float | None = None, num: int | None = None) SweepFixedValues¶
Create a collection of parameter values to be iterated over. Requires start and stop and (step or num) The sign of step is not relevant.
- Parameters:
start – The starting value of the sequence.
stop – The end value of the sequence.
step – Spacing between values.
num – Number of values to generate.
- Returns:
Collection of parameter values to be iterated over.
- Return type:
SweepFixedValues
Examples
>>> sweep(0, 10, num=5) [0.0, 2.5, 5.0, 7.5, 10.0] >>> sweep(5, 10, step=1) [5.0, 6.0, 7.0, 8.0, 9.0, 10.0] >>> sweep(15, 10.5, step=1.5) >[15.0, 13.5, 12.0, 10.5]
- property underlying_instrument: InstrumentBase | None¶
Returns an instance of the underlying hardware instrument that this parameter communicates with, per this parameter’s implementation.
This is useful in the case where a parameter does not belongs to an instrument instance that represents a real hardware instrument but actually uses a real hardware instrument in its implementation (e.g. via calls to one or more parameters of that real hardware instrument). This is also useful when a parameter does belong to an instrument instance but that instance does not represent the real hardware instrument that the parameter interacts with: hence
root_instrumentof the parameter cannot be thehardware_instrument, howeverunderlying_instrumentcan be implemented to return thehardware_instrument.By default it returns the
root_instrumentof the parameter.
- validate(value: ParameterDataTypeVar) None¶
Validate the value supplied.
- Parameters:
value – value to validate
- Raises:
TypeError – If the value is of the wrong type.
ValueError – If the value is outside the bounds specified by the validator.
- property validators: tuple[Validator, ...]¶
Tuple of all validators associated with the parameter.
- Getter:
All validators associated with the parameter.
- property vals: Validator | None¶
The first validator of the parameter. None if no validators are set for this parameter.
- Getter:
Returns the first validator or None if no validators.
- Setter:
Sets the first validator. Set to None to remove the first validator.
- Raises:
RuntimeError – If removing the first validator when more than one validator is set.
- get_parser¶
- set_parser¶
- cache¶
- get_latest¶
- get¶
- set¶
- metadata¶
semi_cr.core.lab.station.runtime module¶
semi_cr.core.lab.station.snapshot module¶
- class semi_cr.core.lab.station.snapshot.ParameterSnapshot(*, value: Any = None, unit: str | None = None, label: str | None = None)[source]¶
Bases:
BaseModelCreate 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.
- value: Any¶
- __copy__() Self¶
Returns a shallow copy of the model.
- classmethod __get_pydantic_json_schema__(core_schema: CoreSchema, handler: GetJsonSchemaHandler, /) JsonSchemaValue¶
Hook into generating the model’s JSON schema.
- Parameters:
core_schema – A pydantic-core CoreSchema. You can ignore this argument and call the handler with a new CoreSchema, wrap this CoreSchema ({‘type’: ‘nullable’, ‘schema’: current_schema}), or just call the handler with the original schema.
handler – Call into Pydantic’s internal JSON schema generation. This will raise a pydantic.errors.PydanticInvalidForJsonSchema if JSON schema generation fails. Since this gets called by BaseModel.model_json_schema you can override the schema_generator argument to that function to change JSON schema generation globally for a type.
- Returns:
A JSON schema, as a Python object.
- __pretty__(fmt: Callable[[Any], Any], **kwargs: Any) Generator[Any, None, None]¶
Used by devtools (https://python-devtools.helpmanual.io/) to pretty print objects.
- classmethod __pydantic_init_subclass__(**kwargs: Any) None¶
This is intended to behave just like __init_subclass__, but is called by ModelMetaclass only after the class is actually fully initialized. In particular, attributes like model_fields will be present when this is called.
This is necessary because __init_subclass__ will always be called by type.__new__, and it would require a prohibitively large refactor to the ModelMetaclass to ensure that type.__new__ was called in such a manner that the class would already be sufficiently initialized.
This will receive the same kwargs that would be passed to the standard __init_subclass__, namely, any kwargs passed to the class definition that aren’t used internally by pydantic.
- Parameters:
**kwargs – Any keyword arguments passed to the class definition that aren’t used internally by pydantic.
- __rich_repr__() RichReprResult¶
Used by Rich (https://rich.readthedocs.io/en/stable/pretty.html) to pretty print objects.
- copy(*, include: AbstractSetIntStr | MappingIntStrAny | None = None, exclude: AbstractSetIntStr | MappingIntStrAny | None = None, update: Dict[str, Any] | None = None, deep: bool = False) Self¶
Returns a copy of the model.
- !!! warning “Deprecated”
This method is now deprecated; use model_copy instead.
If you need include or exclude, use:
`python {test="skip" lint="skip"} data = self.model_dump(include=include, exclude=exclude, round_trip=True) data = {**data, **(update or {})} copied = self.model_validate(data) `- Parameters:
include – Optional set or mapping specifying which fields to include in the copied model.
exclude – Optional set or mapping specifying which fields to exclude in the copied model.
update – Optional dictionary of field-value pairs to override field values in the copied model.
deep – If True, the values of fields that are Pydantic models will be deep-copied.
- Returns:
A copy of the model with included, excluded and updated fields as specified.
- dict(*, include: set[int] | set[str] | Mapping[int, set[int] | set[str] | Mapping[int, IncEx | bool] | Mapping[str, IncEx | bool] | bool] | Mapping[str, set[int] | set[str] | Mapping[int, IncEx | bool] | Mapping[str, IncEx | bool] | bool] | None = None, exclude: set[int] | set[str] | Mapping[int, set[int] | set[str] | Mapping[int, IncEx | bool] | Mapping[str, IncEx | bool] | bool] | Mapping[str, set[int] | set[str] | Mapping[int, IncEx | bool] | Mapping[str, IncEx | bool] | bool] | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) Dict[str, Any]¶
- json(*, include: set[int] | set[str] | Mapping[int, set[int] | set[str] | Mapping[int, IncEx | bool] | Mapping[str, IncEx | bool] | bool] | Mapping[str, set[int] | set[str] | Mapping[int, IncEx | bool] | Mapping[str, IncEx | bool] | bool] | None = None, exclude: set[int] | set[str] | Mapping[int, set[int] | set[str] | Mapping[int, IncEx | bool] | Mapping[str, IncEx | bool] | bool] | Mapping[str, set[int] | set[str] | Mapping[int, IncEx | bool] | Mapping[str, IncEx | bool] | bool] | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Callable[[Any], Any] | None = PydanticUndefined, models_as_dict: bool = PydanticUndefined, **dumps_kwargs: Any) str¶
- model_computed_fields = {}¶
- model_config = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- classmethod model_construct(_fields_set: set[str] | None = None, **values: Any) Self¶
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed.
- !!! note
model_construct() generally respects the model_config.extra setting on the provided model. That is, if model_config.extra == ‘allow’, then all extra passed values are added to the model instance’s __dict__ and __pydantic_extra__ fields. If model_config.extra == ‘ignore’ (the default), then all extra passed values are ignored. Because no validation is performed with a call to model_construct(), having model_config.extra == ‘forbid’ does not result in an error if extra values are passed, but they will be ignored.
- Parameters:
_fields_set – A set of field names that were originally explicitly set during instantiation. If provided, this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute. Otherwise, the field names from the values argument will be used.
values – Trusted or pre-validated data dictionary.
- Returns:
A new instance of the Model class with validated data.
- model_copy(*, update: Mapping[str, Any] | None = None, deep: bool = False) Self¶
- !!! abstract “Usage Documentation”
[model_copy](../concepts/serialization.md#model_copy)
Returns a copy of the model.
- !!! note
The underlying instance’s [__dict__][object.__dict__] attribute is copied. This might have unexpected side effects if you store anything in it, on top of the model fields (e.g. the value of [cached properties][functools.cached_property]).
- Parameters:
update – Values to change/add in the new model. Note: the data is not validated before creating the new model. You should trust this data.
deep – Set to True to make a deep copy of the model.
- Returns:
New model instance.
- model_dump(*, mode: Literal['json', 'python'] | str = 'python', include: set[int] | set[str] | Mapping[int, set[int] | set[str] | Mapping[int, IncEx | bool] | Mapping[str, IncEx | bool] | bool] | Mapping[str, set[int] | set[str] | Mapping[int, IncEx | bool] | Mapping[str, IncEx | bool] | bool] | None = None, exclude: set[int] | set[str] | Mapping[int, set[int] | set[str] | Mapping[int, IncEx | bool] | Mapping[str, IncEx | bool] | bool] | Mapping[str, set[int] | set[str] | Mapping[int, IncEx | bool] | Mapping[str, IncEx | bool] | bool] | None = None, context: Any | None = None, by_alias: bool | None = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, fallback: Callable[[Any], Any] | None = None, serialize_as_any: bool = False) dict[str, Any]¶
- !!! abstract “Usage Documentation”
[model_dump](../concepts/serialization.md#modelmodel_dump)
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
- Parameters:
mode – The mode in which to_python should run. If mode is ‘json’, the output will only contain JSON serializable types. If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include – A set of fields to include in the output.
exclude – A set of fields to exclude from the output.
context – Additional context to pass to the serializer.
by_alias – Whether to use the field’s alias in the dictionary key if defined.
exclude_unset – Whether to exclude fields that have not been explicitly set.
exclude_defaults – Whether to exclude fields that are set to their default value.
exclude_none – Whether to exclude fields that have a value of None.
round_trip – If True, dumped values should be valid as input for non-idempotent types such as Json[T].
warnings – How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors, “error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
fallback – A function to call when an unknown value is encountered. If not provided, a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.
serialize_as_any – Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A dictionary representation of the model.
- model_dump_json(*, indent: int | None = None, include: set[int] | set[str] | Mapping[int, set[int] | set[str] | Mapping[int, IncEx | bool] | Mapping[str, IncEx | bool] | bool] | Mapping[str, set[int] | set[str] | Mapping[int, IncEx | bool] | Mapping[str, IncEx | bool] | bool] | None = None, exclude: set[int] | set[str] | Mapping[int, set[int] | set[str] | Mapping[int, IncEx | bool] | Mapping[str, IncEx | bool] | bool] | Mapping[str, set[int] | set[str] | Mapping[int, IncEx | bool] | Mapping[str, IncEx | bool] | bool] | None = None, context: Any | None = None, by_alias: bool | None = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, fallback: Callable[[Any], Any] | None = None, serialize_as_any: bool = False) str¶
- !!! abstract “Usage Documentation”
[model_dump_json](../concepts/serialization.md#modelmodel_dump_json)
Generates a JSON representation of the model using Pydantic’s to_json method.
- Parameters:
indent – Indentation to use in the JSON output. If None is passed, the output will be compact.
include – Field(s) to include in the JSON output.
exclude – Field(s) to exclude from the JSON output.
context – Additional context to pass to the serializer.
by_alias – Whether to serialize using field aliases.
exclude_unset – Whether to exclude fields that have not been explicitly set.
exclude_defaults – Whether to exclude fields that are set to their default value.
exclude_none – Whether to exclude fields that have a value of None.
round_trip – If True, dumped values should be valid as input for non-idempotent types such as Json[T].
warnings – How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors, “error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
fallback – A function to call when an unknown value is encountered. If not provided, a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.
serialize_as_any – Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A JSON string representation of the model.
- property model_extra: dict[str, Any] | None¶
Get extra fields set during validation.
- Returns:
A dictionary of extra fields, or None if config.extra is not set to “allow”.
- model_fields = {'label': FieldInfo(annotation=Union[str, NoneType], required=False, default=None), 'unit': FieldInfo(annotation=Union[str, NoneType], required=False, default=None), 'value': FieldInfo(annotation=Any, required=False, default=None)}¶
- property model_fields_set: set[str]¶
Returns the set of fields that have been explicitly set on this model instance.
- Returns:
- A set of strings representing the fields that have been set,
i.e. that were not filled from defaults.
- classmethod model_json_schema(by_alias: bool = True, ref_template: str = '#/$defs/{model}', schema_generator: type[GenerateJsonSchema] = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: Literal['validation', 'serialization']='validation') dict[str, Any]¶
Generates a JSON schema for a model class.
- Parameters:
by_alias – Whether to use attribute aliases or not.
ref_template – The reference template.
schema_generator – To override the logic used to generate the JSON schema, as a subclass of GenerateJsonSchema with your desired modifications
mode – The mode in which to generate the schema.
- Returns:
The JSON schema for the given model class.
- classmethod model_parametrized_name(params: tuple[type[Any], ...]) str¶
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
- Parameters:
params – Tuple of types of the class. Given a generic class Model with 2 type variables and a concrete model Model[str, int], the value (str, int) would be passed to params.
- Returns:
String representing the new class where params are passed to cls as type variables.
- Raises:
TypeError – Raised when trying to generate concrete names for non-generic models.
- model_post_init(context: Any, /) None¶
Override this method to perform additional initialization after __init__ and model_construct. This is useful if you want to do some validation that requires the entire model to be initialized.
- classmethod model_rebuild(*, force: bool = False, raise_errors: bool = True, _parent_namespace_depth: int = 2, _types_namespace: MappingNamespace | None = None) bool | None¶
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.
- Parameters:
force – Whether to force the rebuilding of the model schema, defaults to False.
raise_errors – Whether to raise errors, defaults to True.
_parent_namespace_depth – The depth level of the parent namespace, defaults to 2.
_types_namespace – The types namespace, defaults to None.
- Returns:
Returns None if the schema is already “complete” and rebuilding was not required. If rebuilding _was_ required, returns True if rebuilding was successful, otherwise False.
- classmethod model_validate(obj: Any, *, strict: bool | None = None, from_attributes: bool | None = None, context: Any | None = None, by_alias: bool | None = None, by_name: bool | None = None) Self¶
Validate a pydantic model instance.
- Parameters:
obj – The object to validate.
strict – Whether to enforce types strictly.
from_attributes – Whether to extract data from object attributes.
context – Additional context to pass to the validator.
by_alias – Whether to use the field’s alias when validating against the provided input data.
by_name – Whether to use the field’s name when validating against the provided input data.
- Raises:
ValidationError – If the object could not be validated.
- Returns:
The validated model instance.
- classmethod model_validate_json(json_data: str | bytes | bytearray, *, strict: bool | None = None, context: Any | None = None, by_alias: bool | None = None, by_name: bool | None = None) Self¶
- !!! abstract “Usage Documentation”
[JSON Parsing](../concepts/json.md#json-parsing)
Validate the given JSON data against the Pydantic model.
- Parameters:
json_data – The JSON data to validate.
strict – Whether to enforce types strictly.
context – Extra variables to pass to the validator.
by_alias – Whether to use the field’s alias when validating against the provided input data.
by_name – Whether to use the field’s name when validating against the provided input data.
- Returns:
The validated Pydantic model.
- Raises:
ValidationError – If json_data is not a JSON string or the object could not be validated.
- classmethod model_validate_strings(obj: Any, *, strict: bool | None = None, context: Any | None = None, by_alias: bool | None = None, by_name: bool | None = None) Self¶
Validate the given object with string data against the Pydantic model.
- Parameters:
obj – The object containing string data to validate.
strict – Whether to enforce types strictly.
context – Extra variables to pass to the validator.
by_alias – Whether to use the field’s alias when validating against the provided input data.
by_name – Whether to use the field’s name when validating against the provided input data.
- Returns:
The validated Pydantic model.
- classmethod parse_file(path: str | Path, *, content_type: str | None = None, encoding: str = 'utf8', proto: DeprecatedParseProtocol | None = None, allow_pickle: bool = False) Self¶
- classmethod parse_raw(b: str | bytes, *, content_type: str | None = None, encoding: str = 'utf8', proto: DeprecatedParseProtocol | None = None, allow_pickle: bool = False) Self¶
- class semi_cr.core.lab.station.snapshot.ComponentSnapshot(*, name: str, class_name: str | None = None, label: str | None = None, parameters: dict[str, ~semi_cr.core.lab.station.snapshot.ParameterSnapshot]=<factory>, submodules: dict[str, ~semi_cr.core.lab.station.snapshot.ComponentSnapshot]=<factory>)[source]¶
Bases:
BaseModelCreate 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.
- parameters: dict[str, ParameterSnapshot]¶
- __copy__() Self¶
Returns a shallow copy of the model.
- classmethod __get_pydantic_json_schema__(core_schema: CoreSchema, handler: GetJsonSchemaHandler, /) JsonSchemaValue¶
Hook into generating the model’s JSON schema.
- Parameters:
core_schema – A pydantic-core CoreSchema. You can ignore this argument and call the handler with a new CoreSchema, wrap this CoreSchema ({‘type’: ‘nullable’, ‘schema’: current_schema}), or just call the handler with the original schema.
handler – Call into Pydantic’s internal JSON schema generation. This will raise a pydantic.errors.PydanticInvalidForJsonSchema if JSON schema generation fails. Since this gets called by BaseModel.model_json_schema you can override the schema_generator argument to that function to change JSON schema generation globally for a type.
- Returns:
A JSON schema, as a Python object.
- __pretty__(fmt: Callable[[Any], Any], **kwargs: Any) Generator[Any, None, None]¶
Used by devtools (https://python-devtools.helpmanual.io/) to pretty print objects.
- classmethod __pydantic_init_subclass__(**kwargs: Any) None¶
This is intended to behave just like __init_subclass__, but is called by ModelMetaclass only after the class is actually fully initialized. In particular, attributes like model_fields will be present when this is called.
This is necessary because __init_subclass__ will always be called by type.__new__, and it would require a prohibitively large refactor to the ModelMetaclass to ensure that type.__new__ was called in such a manner that the class would already be sufficiently initialized.
This will receive the same kwargs that would be passed to the standard __init_subclass__, namely, any kwargs passed to the class definition that aren’t used internally by pydantic.
- Parameters:
**kwargs – Any keyword arguments passed to the class definition that aren’t used internally by pydantic.
- __rich_repr__() RichReprResult¶
Used by Rich (https://rich.readthedocs.io/en/stable/pretty.html) to pretty print objects.
- copy(*, include: AbstractSetIntStr | MappingIntStrAny | None = None, exclude: AbstractSetIntStr | MappingIntStrAny | None = None, update: Dict[str, Any] | None = None, deep: bool = False) Self¶
Returns a copy of the model.
- !!! warning “Deprecated”
This method is now deprecated; use model_copy instead.
If you need include or exclude, use:
`python {test="skip" lint="skip"} data = self.model_dump(include=include, exclude=exclude, round_trip=True) data = {**data, **(update or {})} copied = self.model_validate(data) `- Parameters:
include – Optional set or mapping specifying which fields to include in the copied model.
exclude – Optional set or mapping specifying which fields to exclude in the copied model.
update – Optional dictionary of field-value pairs to override field values in the copied model.
deep – If True, the values of fields that are Pydantic models will be deep-copied.
- Returns:
A copy of the model with included, excluded and updated fields as specified.
- dict(*, include: set[int] | set[str] | Mapping[int, set[int] | set[str] | Mapping[int, IncEx | bool] | Mapping[str, IncEx | bool] | bool] | Mapping[str, set[int] | set[str] | Mapping[int, IncEx | bool] | Mapping[str, IncEx | bool] | bool] | None = None, exclude: set[int] | set[str] | Mapping[int, set[int] | set[str] | Mapping[int, IncEx | bool] | Mapping[str, IncEx | bool] | bool] | Mapping[str, set[int] | set[str] | Mapping[int, IncEx | bool] | Mapping[str, IncEx | bool] | bool] | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) Dict[str, Any]¶
- json(*, include: set[int] | set[str] | Mapping[int, set[int] | set[str] | Mapping[int, IncEx | bool] | Mapping[str, IncEx | bool] | bool] | Mapping[str, set[int] | set[str] | Mapping[int, IncEx | bool] | Mapping[str, IncEx | bool] | bool] | None = None, exclude: set[int] | set[str] | Mapping[int, set[int] | set[str] | Mapping[int, IncEx | bool] | Mapping[str, IncEx | bool] | bool] | Mapping[str, set[int] | set[str] | Mapping[int, IncEx | bool] | Mapping[str, IncEx | bool] | bool] | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Callable[[Any], Any] | None = PydanticUndefined, models_as_dict: bool = PydanticUndefined, **dumps_kwargs: Any) str¶
- model_computed_fields = {}¶
- model_config = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- classmethod model_construct(_fields_set: set[str] | None = None, **values: Any) Self¶
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed.
- !!! note
model_construct() generally respects the model_config.extra setting on the provided model. That is, if model_config.extra == ‘allow’, then all extra passed values are added to the model instance’s __dict__ and __pydantic_extra__ fields. If model_config.extra == ‘ignore’ (the default), then all extra passed values are ignored. Because no validation is performed with a call to model_construct(), having model_config.extra == ‘forbid’ does not result in an error if extra values are passed, but they will be ignored.
- Parameters:
_fields_set – A set of field names that were originally explicitly set during instantiation. If provided, this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute. Otherwise, the field names from the values argument will be used.
values – Trusted or pre-validated data dictionary.
- Returns:
A new instance of the Model class with validated data.
- model_copy(*, update: Mapping[str, Any] | None = None, deep: bool = False) Self¶
- !!! abstract “Usage Documentation”
[model_copy](../concepts/serialization.md#model_copy)
Returns a copy of the model.
- !!! note
The underlying instance’s [__dict__][object.__dict__] attribute is copied. This might have unexpected side effects if you store anything in it, on top of the model fields (e.g. the value of [cached properties][functools.cached_property]).
- Parameters:
update – Values to change/add in the new model. Note: the data is not validated before creating the new model. You should trust this data.
deep – Set to True to make a deep copy of the model.
- Returns:
New model instance.
- model_dump(*, mode: Literal['json', 'python'] | str = 'python', include: set[int] | set[str] | Mapping[int, set[int] | set[str] | Mapping[int, IncEx | bool] | Mapping[str, IncEx | bool] | bool] | Mapping[str, set[int] | set[str] | Mapping[int, IncEx | bool] | Mapping[str, IncEx | bool] | bool] | None = None, exclude: set[int] | set[str] | Mapping[int, set[int] | set[str] | Mapping[int, IncEx | bool] | Mapping[str, IncEx | bool] | bool] | Mapping[str, set[int] | set[str] | Mapping[int, IncEx | bool] | Mapping[str, IncEx | bool] | bool] | None = None, context: Any | None = None, by_alias: bool | None = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, fallback: Callable[[Any], Any] | None = None, serialize_as_any: bool = False) dict[str, Any]¶
- !!! abstract “Usage Documentation”
[model_dump](../concepts/serialization.md#modelmodel_dump)
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
- Parameters:
mode – The mode in which to_python should run. If mode is ‘json’, the output will only contain JSON serializable types. If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include – A set of fields to include in the output.
exclude – A set of fields to exclude from the output.
context – Additional context to pass to the serializer.
by_alias – Whether to use the field’s alias in the dictionary key if defined.
exclude_unset – Whether to exclude fields that have not been explicitly set.
exclude_defaults – Whether to exclude fields that are set to their default value.
exclude_none – Whether to exclude fields that have a value of None.
round_trip – If True, dumped values should be valid as input for non-idempotent types such as Json[T].
warnings – How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors, “error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
fallback – A function to call when an unknown value is encountered. If not provided, a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.
serialize_as_any – Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A dictionary representation of the model.
- model_dump_json(*, indent: int | None = None, include: set[int] | set[str] | Mapping[int, set[int] | set[str] | Mapping[int, IncEx | bool] | Mapping[str, IncEx | bool] | bool] | Mapping[str, set[int] | set[str] | Mapping[int, IncEx | bool] | Mapping[str, IncEx | bool] | bool] | None = None, exclude: set[int] | set[str] | Mapping[int, set[int] | set[str] | Mapping[int, IncEx | bool] | Mapping[str, IncEx | bool] | bool] | Mapping[str, set[int] | set[str] | Mapping[int, IncEx | bool] | Mapping[str, IncEx | bool] | bool] | None = None, context: Any | None = None, by_alias: bool | None = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, fallback: Callable[[Any], Any] | None = None, serialize_as_any: bool = False) str¶
- !!! abstract “Usage Documentation”
[model_dump_json](../concepts/serialization.md#modelmodel_dump_json)
Generates a JSON representation of the model using Pydantic’s to_json method.
- Parameters:
indent – Indentation to use in the JSON output. If None is passed, the output will be compact.
include – Field(s) to include in the JSON output.
exclude – Field(s) to exclude from the JSON output.
context – Additional context to pass to the serializer.
by_alias – Whether to serialize using field aliases.
exclude_unset – Whether to exclude fields that have not been explicitly set.
exclude_defaults – Whether to exclude fields that are set to their default value.
exclude_none – Whether to exclude fields that have a value of None.
round_trip – If True, dumped values should be valid as input for non-idempotent types such as Json[T].
warnings – How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors, “error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
fallback – A function to call when an unknown value is encountered. If not provided, a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.
serialize_as_any – Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A JSON string representation of the model.
- property model_extra: dict[str, Any] | None¶
Get extra fields set during validation.
- Returns:
A dictionary of extra fields, or None if config.extra is not set to “allow”.
- model_fields = {'class_name': FieldInfo(annotation=Union[str, NoneType], required=False, default=None), 'label': FieldInfo(annotation=Union[str, NoneType], required=False, default=None), 'name': FieldInfo(annotation=str, required=True), 'parameters': FieldInfo(annotation=dict[str, ParameterSnapshot], required=False, default_factory=dict), 'submodules': FieldInfo(annotation=dict[str, ComponentSnapshot], required=False, default_factory=dict)}¶
- property model_fields_set: set[str]¶
Returns the set of fields that have been explicitly set on this model instance.
- Returns:
- A set of strings representing the fields that have been set,
i.e. that were not filled from defaults.
- classmethod model_json_schema(by_alias: bool = True, ref_template: str = '#/$defs/{model}', schema_generator: type[GenerateJsonSchema] = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: Literal['validation', 'serialization']='validation') dict[str, Any]¶
Generates a JSON schema for a model class.
- Parameters:
by_alias – Whether to use attribute aliases or not.
ref_template – The reference template.
schema_generator – To override the logic used to generate the JSON schema, as a subclass of GenerateJsonSchema with your desired modifications
mode – The mode in which to generate the schema.
- Returns:
The JSON schema for the given model class.
- classmethod model_parametrized_name(params: tuple[type[Any], ...]) str¶
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
- Parameters:
params – Tuple of types of the class. Given a generic class Model with 2 type variables and a concrete model Model[str, int], the value (str, int) would be passed to params.
- Returns:
String representing the new class where params are passed to cls as type variables.
- Raises:
TypeError – Raised when trying to generate concrete names for non-generic models.
- model_post_init(context: Any, /) None¶
Override this method to perform additional initialization after __init__ and model_construct. This is useful if you want to do some validation that requires the entire model to be initialized.
- classmethod model_rebuild(*, force: bool = False, raise_errors: bool = True, _parent_namespace_depth: int = 2, _types_namespace: MappingNamespace | None = None) bool | None¶
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.
- Parameters:
force – Whether to force the rebuilding of the model schema, defaults to False.
raise_errors – Whether to raise errors, defaults to True.
_parent_namespace_depth – The depth level of the parent namespace, defaults to 2.
_types_namespace – The types namespace, defaults to None.
- Returns:
Returns None if the schema is already “complete” and rebuilding was not required. If rebuilding _was_ required, returns True if rebuilding was successful, otherwise False.
- classmethod model_validate(obj: Any, *, strict: bool | None = None, from_attributes: bool | None = None, context: Any | None = None, by_alias: bool | None = None, by_name: bool | None = None) Self¶
Validate a pydantic model instance.
- Parameters:
obj – The object to validate.
strict – Whether to enforce types strictly.
from_attributes – Whether to extract data from object attributes.
context – Additional context to pass to the validator.
by_alias – Whether to use the field’s alias when validating against the provided input data.
by_name – Whether to use the field’s name when validating against the provided input data.
- Raises:
ValidationError – If the object could not be validated.
- Returns:
The validated model instance.
- classmethod model_validate_json(json_data: str | bytes | bytearray, *, strict: bool | None = None, context: Any | None = None, by_alias: bool | None = None, by_name: bool | None = None) Self¶
- !!! abstract “Usage Documentation”
[JSON Parsing](../concepts/json.md#json-parsing)
Validate the given JSON data against the Pydantic model.
- Parameters:
json_data – The JSON data to validate.
strict – Whether to enforce types strictly.
context – Extra variables to pass to the validator.
by_alias – Whether to use the field’s alias when validating against the provided input data.
by_name – Whether to use the field’s name when validating against the provided input data.
- Returns:
The validated Pydantic model.
- Raises:
ValidationError – If json_data is not a JSON string or the object could not be validated.
- classmethod model_validate_strings(obj: Any, *, strict: bool | None = None, context: Any | None = None, by_alias: bool | None = None, by_name: bool | None = None) Self¶
Validate the given object with string data against the Pydantic model.
- Parameters:
obj – The object containing string data to validate.
strict – Whether to enforce types strictly.
context – Extra variables to pass to the validator.
by_alias – Whether to use the field’s alias when validating against the provided input data.
by_name – Whether to use the field’s name when validating against the provided input data.
- Returns:
The validated Pydantic model.
- classmethod parse_file(path: str | Path, *, content_type: str | None = None, encoding: str = 'utf8', proto: DeprecatedParseProtocol | None = None, allow_pickle: bool = False) Self¶
- classmethod parse_raw(b: str | bytes, *, content_type: str | None = None, encoding: str = 'utf8', proto: DeprecatedParseProtocol | None = None, allow_pickle: bool = False) Self¶
- class semi_cr.core.lab.station.snapshot.StationSnapshot(*, timestamp: datetime = <factory>, instruments: dict[str, ~semi_cr.core.lab.station.snapshot.ComponentSnapshot]=<factory>, config: dict[str, ~typing.Any]=<factory>, metadata: dict[str, ~typing.Any]=<factory>)[source]¶
Bases:
BaseModelCreate 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.
- timestamp: datetime¶
- instruments: dict[str, ComponentSnapshot]¶
- __copy__() Self¶
Returns a shallow copy of the model.
- classmethod __get_pydantic_json_schema__(core_schema: CoreSchema, handler: GetJsonSchemaHandler, /) JsonSchemaValue¶
Hook into generating the model’s JSON schema.
- Parameters:
core_schema – A pydantic-core CoreSchema. You can ignore this argument and call the handler with a new CoreSchema, wrap this CoreSchema ({‘type’: ‘nullable’, ‘schema’: current_schema}), or just call the handler with the original schema.
handler – Call into Pydantic’s internal JSON schema generation. This will raise a pydantic.errors.PydanticInvalidForJsonSchema if JSON schema generation fails. Since this gets called by BaseModel.model_json_schema you can override the schema_generator argument to that function to change JSON schema generation globally for a type.
- Returns:
A JSON schema, as a Python object.
- __pretty__(fmt: Callable[[Any], Any], **kwargs: Any) Generator[Any, None, None]¶
Used by devtools (https://python-devtools.helpmanual.io/) to pretty print objects.
- classmethod __pydantic_init_subclass__(**kwargs: Any) None¶
This is intended to behave just like __init_subclass__, but is called by ModelMetaclass only after the class is actually fully initialized. In particular, attributes like model_fields will be present when this is called.
This is necessary because __init_subclass__ will always be called by type.__new__, and it would require a prohibitively large refactor to the ModelMetaclass to ensure that type.__new__ was called in such a manner that the class would already be sufficiently initialized.
This will receive the same kwargs that would be passed to the standard __init_subclass__, namely, any kwargs passed to the class definition that aren’t used internally by pydantic.
- Parameters:
**kwargs – Any keyword arguments passed to the class definition that aren’t used internally by pydantic.
- __rich_repr__() RichReprResult¶
Used by Rich (https://rich.readthedocs.io/en/stable/pretty.html) to pretty print objects.
- copy(*, include: AbstractSetIntStr | MappingIntStrAny | None = None, exclude: AbstractSetIntStr | MappingIntStrAny | None = None, update: Dict[str, Any] | None = None, deep: bool = False) Self¶
Returns a copy of the model.
- !!! warning “Deprecated”
This method is now deprecated; use model_copy instead.
If you need include or exclude, use:
`python {test="skip" lint="skip"} data = self.model_dump(include=include, exclude=exclude, round_trip=True) data = {**data, **(update or {})} copied = self.model_validate(data) `- Parameters:
include – Optional set or mapping specifying which fields to include in the copied model.
exclude – Optional set or mapping specifying which fields to exclude in the copied model.
update – Optional dictionary of field-value pairs to override field values in the copied model.
deep – If True, the values of fields that are Pydantic models will be deep-copied.
- Returns:
A copy of the model with included, excluded and updated fields as specified.
- dict(*, include: set[int] | set[str] | Mapping[int, set[int] | set[str] | Mapping[int, IncEx | bool] | Mapping[str, IncEx | bool] | bool] | Mapping[str, set[int] | set[str] | Mapping[int, IncEx | bool] | Mapping[str, IncEx | bool] | bool] | None = None, exclude: set[int] | set[str] | Mapping[int, set[int] | set[str] | Mapping[int, IncEx | bool] | Mapping[str, IncEx | bool] | bool] | Mapping[str, set[int] | set[str] | Mapping[int, IncEx | bool] | Mapping[str, IncEx | bool] | bool] | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) Dict[str, Any]¶
- json(*, include: set[int] | set[str] | Mapping[int, set[int] | set[str] | Mapping[int, IncEx | bool] | Mapping[str, IncEx | bool] | bool] | Mapping[str, set[int] | set[str] | Mapping[int, IncEx | bool] | Mapping[str, IncEx | bool] | bool] | None = None, exclude: set[int] | set[str] | Mapping[int, set[int] | set[str] | Mapping[int, IncEx | bool] | Mapping[str, IncEx | bool] | bool] | Mapping[str, set[int] | set[str] | Mapping[int, IncEx | bool] | Mapping[str, IncEx | bool] | bool] | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Callable[[Any], Any] | None = PydanticUndefined, models_as_dict: bool = PydanticUndefined, **dumps_kwargs: Any) str¶
- model_computed_fields = {}¶
- model_config = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- classmethod model_construct(_fields_set: set[str] | None = None, **values: Any) Self¶
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed.
- !!! note
model_construct() generally respects the model_config.extra setting on the provided model. That is, if model_config.extra == ‘allow’, then all extra passed values are added to the model instance’s __dict__ and __pydantic_extra__ fields. If model_config.extra == ‘ignore’ (the default), then all extra passed values are ignored. Because no validation is performed with a call to model_construct(), having model_config.extra == ‘forbid’ does not result in an error if extra values are passed, but they will be ignored.
- Parameters:
_fields_set – A set of field names that were originally explicitly set during instantiation. If provided, this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute. Otherwise, the field names from the values argument will be used.
values – Trusted or pre-validated data dictionary.
- Returns:
A new instance of the Model class with validated data.
- model_copy(*, update: Mapping[str, Any] | None = None, deep: bool = False) Self¶
- !!! abstract “Usage Documentation”
[model_copy](../concepts/serialization.md#model_copy)
Returns a copy of the model.
- !!! note
The underlying instance’s [__dict__][object.__dict__] attribute is copied. This might have unexpected side effects if you store anything in it, on top of the model fields (e.g. the value of [cached properties][functools.cached_property]).
- Parameters:
update – Values to change/add in the new model. Note: the data is not validated before creating the new model. You should trust this data.
deep – Set to True to make a deep copy of the model.
- Returns:
New model instance.
- model_dump(*, mode: Literal['json', 'python'] | str = 'python', include: set[int] | set[str] | Mapping[int, set[int] | set[str] | Mapping[int, IncEx | bool] | Mapping[str, IncEx | bool] | bool] | Mapping[str, set[int] | set[str] | Mapping[int, IncEx | bool] | Mapping[str, IncEx | bool] | bool] | None = None, exclude: set[int] | set[str] | Mapping[int, set[int] | set[str] | Mapping[int, IncEx | bool] | Mapping[str, IncEx | bool] | bool] | Mapping[str, set[int] | set[str] | Mapping[int, IncEx | bool] | Mapping[str, IncEx | bool] | bool] | None = None, context: Any | None = None, by_alias: bool | None = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, fallback: Callable[[Any], Any] | None = None, serialize_as_any: bool = False) dict[str, Any]¶
- !!! abstract “Usage Documentation”
[model_dump](../concepts/serialization.md#modelmodel_dump)
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
- Parameters:
mode – The mode in which to_python should run. If mode is ‘json’, the output will only contain JSON serializable types. If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include – A set of fields to include in the output.
exclude – A set of fields to exclude from the output.
context – Additional context to pass to the serializer.
by_alias – Whether to use the field’s alias in the dictionary key if defined.
exclude_unset – Whether to exclude fields that have not been explicitly set.
exclude_defaults – Whether to exclude fields that are set to their default value.
exclude_none – Whether to exclude fields that have a value of None.
round_trip – If True, dumped values should be valid as input for non-idempotent types such as Json[T].
warnings – How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors, “error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
fallback – A function to call when an unknown value is encountered. If not provided, a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.
serialize_as_any – Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A dictionary representation of the model.
- model_dump_json(*, indent: int | None = None, include: set[int] | set[str] | Mapping[int, set[int] | set[str] | Mapping[int, IncEx | bool] | Mapping[str, IncEx | bool] | bool] | Mapping[str, set[int] | set[str] | Mapping[int, IncEx | bool] | Mapping[str, IncEx | bool] | bool] | None = None, exclude: set[int] | set[str] | Mapping[int, set[int] | set[str] | Mapping[int, IncEx | bool] | Mapping[str, IncEx | bool] | bool] | Mapping[str, set[int] | set[str] | Mapping[int, IncEx | bool] | Mapping[str, IncEx | bool] | bool] | None = None, context: Any | None = None, by_alias: bool | None = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, fallback: Callable[[Any], Any] | None = None, serialize_as_any: bool = False) str¶
- !!! abstract “Usage Documentation”
[model_dump_json](../concepts/serialization.md#modelmodel_dump_json)
Generates a JSON representation of the model using Pydantic’s to_json method.
- Parameters:
indent – Indentation to use in the JSON output. If None is passed, the output will be compact.
include – Field(s) to include in the JSON output.
exclude – Field(s) to exclude from the JSON output.
context – Additional context to pass to the serializer.
by_alias – Whether to serialize using field aliases.
exclude_unset – Whether to exclude fields that have not been explicitly set.
exclude_defaults – Whether to exclude fields that are set to their default value.
exclude_none – Whether to exclude fields that have a value of None.
round_trip – If True, dumped values should be valid as input for non-idempotent types such as Json[T].
warnings – How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors, “error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
fallback – A function to call when an unknown value is encountered. If not provided, a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.
serialize_as_any – Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A JSON string representation of the model.
- property model_extra: dict[str, Any] | None¶
Get extra fields set during validation.
- Returns:
A dictionary of extra fields, or None if config.extra is not set to “allow”.
- model_fields = {'config': FieldInfo(annotation=dict[str, Any], required=False, default_factory=dict), 'instruments': FieldInfo(annotation=dict[str, ComponentSnapshot], required=False, default_factory=dict), 'metadata': FieldInfo(annotation=dict[str, Any], required=False, default_factory=dict), 'timestamp': FieldInfo(annotation=datetime, required=False, default_factory=now)}¶
- property model_fields_set: set[str]¶
Returns the set of fields that have been explicitly set on this model instance.
- Returns:
- A set of strings representing the fields that have been set,
i.e. that were not filled from defaults.
- classmethod model_json_schema(by_alias: bool = True, ref_template: str = '#/$defs/{model}', schema_generator: type[GenerateJsonSchema] = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: Literal['validation', 'serialization']='validation') dict[str, Any]¶
Generates a JSON schema for a model class.
- Parameters:
by_alias – Whether to use attribute aliases or not.
ref_template – The reference template.
schema_generator – To override the logic used to generate the JSON schema, as a subclass of GenerateJsonSchema with your desired modifications
mode – The mode in which to generate the schema.
- Returns:
The JSON schema for the given model class.
- classmethod model_parametrized_name(params: tuple[type[Any], ...]) str¶
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
- Parameters:
params – Tuple of types of the class. Given a generic class Model with 2 type variables and a concrete model Model[str, int], the value (str, int) would be passed to params.
- Returns:
String representing the new class where params are passed to cls as type variables.
- Raises:
TypeError – Raised when trying to generate concrete names for non-generic models.
- model_post_init(context: Any, /) None¶
Override this method to perform additional initialization after __init__ and model_construct. This is useful if you want to do some validation that requires the entire model to be initialized.
- classmethod model_rebuild(*, force: bool = False, raise_errors: bool = True, _parent_namespace_depth: int = 2, _types_namespace: MappingNamespace | None = None) bool | None¶
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.
- Parameters:
force – Whether to force the rebuilding of the model schema, defaults to False.
raise_errors – Whether to raise errors, defaults to True.
_parent_namespace_depth – The depth level of the parent namespace, defaults to 2.
_types_namespace – The types namespace, defaults to None.
- Returns:
Returns None if the schema is already “complete” and rebuilding was not required. If rebuilding _was_ required, returns True if rebuilding was successful, otherwise False.
- classmethod model_validate(obj: Any, *, strict: bool | None = None, from_attributes: bool | None = None, context: Any | None = None, by_alias: bool | None = None, by_name: bool | None = None) Self¶
Validate a pydantic model instance.
- Parameters:
obj – The object to validate.
strict – Whether to enforce types strictly.
from_attributes – Whether to extract data from object attributes.
context – Additional context to pass to the validator.
by_alias – Whether to use the field’s alias when validating against the provided input data.
by_name – Whether to use the field’s name when validating against the provided input data.
- Raises:
ValidationError – If the object could not be validated.
- Returns:
The validated model instance.
- classmethod model_validate_json(json_data: str | bytes | bytearray, *, strict: bool | None = None, context: Any | None = None, by_alias: bool | None = None, by_name: bool | None = None) Self¶
- !!! abstract “Usage Documentation”
[JSON Parsing](../concepts/json.md#json-parsing)
Validate the given JSON data against the Pydantic model.
- Parameters:
json_data – The JSON data to validate.
strict – Whether to enforce types strictly.
context – Extra variables to pass to the validator.
by_alias – Whether to use the field’s alias when validating against the provided input data.
by_name – Whether to use the field’s name when validating against the provided input data.
- Returns:
The validated Pydantic model.
- Raises:
ValidationError – If json_data is not a JSON string or the object could not be validated.
- classmethod model_validate_strings(obj: Any, *, strict: bool | None = None, context: Any | None = None, by_alias: bool | None = None, by_name: bool | None = None) Self¶
Validate the given object with string data against the Pydantic model.
- Parameters:
obj – The object containing string data to validate.
strict – Whether to enforce types strictly.
context – Extra variables to pass to the validator.
by_alias – Whether to use the field’s alias when validating against the provided input data.
by_name – Whether to use the field’s name when validating against the provided input data.
- Returns:
The validated Pydantic model.
- classmethod parse_file(path: str | Path, *, content_type: str | None = None, encoding: str = 'utf8', proto: DeprecatedParseProtocol | None = None, allow_pickle: bool = False) Self¶
- classmethod parse_raw(b: str | bytes, *, content_type: str | None = None, encoding: str = 'utf8', proto: DeprecatedParseProtocol | None = None, allow_pickle: bool = False) Self¶
- semi_cr.core.lab.station.snapshot.component_from_qcodes_snapshot(name: str, snapshot: dict[str, Any]) ComponentSnapshot[source]¶
- semi_cr.core.lab.station.snapshot.station_snapshot_from_qcodes(station) StationSnapshot[source]¶