semi_cr.core.lab.utils.qharbor_tools package¶
Stable user API for QHarbor experiment announcement and publication.
- class semi_cr.core.lab.utils.qharbor_tools.Artifact(name: str, data: Any, media_type: str = 'application/octet-stream', metadata: Mapping[str, Any]=<factory>)[source]¶
Bases:
objectPortable data ready for publication by a remote backend.
- data: Any¶
- class semi_cr.core.lab.utils.qharbor_tools.AuthenticationBackend[source]¶
Bases:
ABCAbstract authentication provider injected into
Experiment.- name = 'authentication'¶
- status() AuthenticationStatus[source]¶
Return current authentication state without opening a login prompt.
- login() AuthenticationStatus[source]¶
Run interactive login and verify that it completed.
- login_with_token(credentials: TokenCredentials) AuthenticationStatus[source]¶
Authenticate without an interactive prompt and verify the result.
- exception semi_cr.core.lab.utils.qharbor_tools.AuthenticationError(message: str, *, operation: str | None = None, dataset_uuid: str | None = None, backend_name: str | None = None, run_reference: RunReference | None = None, artifact_name: str | None = None, retryable: bool = False)[source]¶
Bases:
QHarborToolsErrorAuthentication was required or failed.
- add_note()¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception semi_cr.core.lab.utils.qharbor_tools.AuthenticationFailedError(message: str, *, operation: str | None = None, dataset_uuid: str | None = None, backend_name: str | None = None, run_reference: RunReference | None = None, artifact_name: str | None = None, retryable: bool = False)[source]¶
Bases:
AuthenticationErrorAn interactive or token login did not establish a session.
- add_note()¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception semi_cr.core.lab.utils.qharbor_tools.AuthenticationRequiredError(message: str, *, operation: str | None = None, dataset_uuid: str | None = None, backend_name: str | None = None, run_reference: RunReference | None = None, artifact_name: str | None = None, retryable: bool = False)[source]¶
Bases:
AuthenticationErrorA remote operation requires the user to authenticate.
- add_note()¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- class semi_cr.core.lab.utils.qharbor_tools.AuthenticationStatus(provider: str, authenticated: bool, supported: bool = True, principal_id: str | None = None, server_url: str | None = None, scopes: tuple[str, ...] | Sequence[str] = ())[source]¶
Bases:
objectPortable authentication state returned to framework users.
- classmethod unsupported(provider: str) AuthenticationStatus[source]¶
Return an unauthenticated status for a backend without login support.
- exception semi_cr.core.lab.utils.qharbor_tools.AuthenticationUnsupportedError(message: str, *, operation: str | None = None, dataset_uuid: str | None = None, backend_name: str | None = None, run_reference: RunReference | None = None, artifact_name: str | None = None, retryable: bool = False)[source]¶
Bases:
AuthenticationErrorThe configured remote backend has no authentication provider.
- add_note()¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception semi_cr.core.lab.utils.qharbor_tools.BackendCloseError(message: str, *, operation: str | None = None, dataset_uuid: str | None = None, backend_name: str | None = None, run_reference: RunReference | None = None, artifact_name: str | None = None, retryable: bool = False)[source]¶
Bases:
BackendErrorA measurement backend could not release its resources.
- add_note()¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- class semi_cr.core.lab.utils.qharbor_tools.BackendContext(experiment_name: str, subject_id: str, dataset_uuid: str)[source]¶
Bases:
objectExperiment information supplied when preparing a local backend.
- exception semi_cr.core.lab.utils.qharbor_tools.BackendError(message: str, *, operation: str | None = None, dataset_uuid: str | None = None, backend_name: str | None = None, run_reference: RunReference | None = None, artifact_name: str | None = None, retryable: bool = False)[source]¶
Bases:
QHarborToolsErrorBase class for measurement-backend failures.
- add_note()¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception semi_cr.core.lab.utils.qharbor_tools.BackendExportError(message: str, *, operation: str | None = None, dataset_uuid: str | None = None, backend_name: str | None = None, run_reference: RunReference | None = None, artifact_name: str | None = None, retryable: bool = False)[source]¶
Bases:
BackendErrorA measurement backend could not export a run.
- add_note()¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception semi_cr.core.lab.utils.qharbor_tools.BackendLoadError(message: str, *, operation: str | None = None, dataset_uuid: str | None = None, backend_name: str | None = None, run_reference: RunReference | None = None, artifact_name: str | None = None, retryable: bool = False)[source]¶
Bases:
BackendErrorA measurement backend could not reload a run.
- add_note()¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception semi_cr.core.lab.utils.qharbor_tools.BackendPreparationError(message: str, *, operation: str | None = None, dataset_uuid: str | None = None, backend_name: str | None = None, run_reference: RunReference | None = None, artifact_name: str | None = None, retryable: bool = False)[source]¶
Bases:
BackendErrorA measurement backend could not be prepared.
- add_note()¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception semi_cr.core.lab.utils.qharbor_tools.BackendSaveError(message: str, *, operation: str | None = None, dataset_uuid: str | None = None, backend_name: str | None = None, run_reference: RunReference | None = None, artifact_name: str | None = None, retryable: bool = False)[source]¶
Bases:
BackendErrorA measurement backend could not persist a run.
- add_note()¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception semi_cr.core.lab.utils.qharbor_tools.ConfigurationError(message: str, *, operation: str | None = None, dataset_uuid: str | None = None, backend_name: str | None = None, run_reference: RunReference | None = None, artifact_name: str | None = None, retryable: bool = False)[source]¶
Bases:
QHarborToolsError,ValueErrorThe supplied framework configuration or data is invalid.
- add_note()¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- class semi_cr.core.lab.utils.qharbor_tools.DatasetConfig(name: str, description: str, scope: str, subject_id: str, platform: str, project_id: str, component: str, step: str, sub_step: str, protocol_name: str, equipment: str, team: str = 'Spin Qubit', extra_attributes: Mapping[str, Any]=<factory>)[source]¶
Bases:
objectMetadata used to announce a QHarbor dataset.
- class semi_cr.core.lab.utils.qharbor_tools.Experiment(config: ExperimentConfig, *, measurement_backend: MeasurementBackend | None = None, remote_backend: RemoteBackend | None = None, authentication_backend: AuthenticationBackend | None = None, login_policy: LoginPolicy | str = LoginPolicy.ON_DEMAND)[source]¶
Bases:
objectStable facade over remote publication and optional local persistence.
- classmethod open(uuid: str, *, measurement_backend: MeasurementBackend | None = None, remote_backend: RemoteBackend | None = None, authentication_backend: AuthenticationBackend | None = None, login_policy: LoginPolicy | str = LoginPolicy.ON_DEMAND) Self[source]¶
Open an existing remote experiment, optionally attaching storage.
- property dataset: RemoteDataset¶
Return the announced or opened remote dataset.
- authentication_status() AuthenticationStatus[source]¶
Return login state without opening an interactive prompt.
- login() AuthenticationStatus[source]¶
Authenticate interactively, serializing concurrent login attempts.
- login_with_token(credentials: TokenCredentials) AuthenticationStatus[source]¶
Authenticate with secret-safe token credentials.
- logout() AuthenticationStatus[source]¶
End the shared remote session; repeated calls are safe.
- announce() RemoteDataset[source]¶
Create the configured remote dataset once and return its reference.
- refresh() RemoteDataset[source]¶
Reload metadata and filenames from the remote service.
- update_metadata(metadata: Mapping[str, Any]) RemoteDataset[source]¶
Merge metadata into the remote dataset attributes.
- publish(*, name: str, data: Any, metadata: Mapping[str, Any] | None = None, media_type: str = 'application/octet-stream') PublicationReceipt[source]¶
Publish existing data directly, without a measurement backend.
- save(*, schema: MeasurementSchema, results: Mapping[str, Any], metadata: Mapping[str, Any] | None = None, publish: Sequence[str] | None = None) MeasurementReceipt[source]¶
Persist one backend run, export it, and publish its artifacts.
- retry_publish(recovery: RunReference | PublishError, *, publish: Sequence[str] | None = None) MeasurementReceipt[source]¶
Republish a preserved backend run without creating a new local run.
- attach_backend(backend: MeasurementBackend) Self[source]¶
Attach local measurement storage to a remote-only experiment.
- class semi_cr.core.lab.utils.qharbor_tools.ExperimentConfig(user: UserConfig, dataset: DatasetConfig)[source]¶
Bases:
objectConfiguration for a new remote experiment.
- user: UserConfig¶
- dataset: DatasetConfig¶
- class semi_cr.core.lab.utils.qharbor_tools.LoginPolicy(*values)[source]¶
Bases:
StrEnumControl whether a remote operation may start interactive login.
- ON_DEMAND = 'on_demand'¶
- EXPLICIT = 'explicit'¶
- __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.utils.qharbor_tools.MeasurementBackend[source]¶
Bases:
ABCAbstract local measurement storage and export backend.
- name = 'measurement'¶
- prepare(context: BackendContext) None[source]¶
Prepare the backend for an experiment.
- save(request: SaveRequest) StoredRun[source]¶
Persist one run and normalize dependency failures.
- load(run: RunReference) StoredRun[source]¶
Reload a run and normalize dependency failures.
- exception semi_cr.core.lab.utils.qharbor_tools.MeasurementBackendRequiredError(message: str, *, operation: str | None = None, dataset_uuid: str | None = None, backend_name: str | None = None, run_reference: RunReference | None = None, artifact_name: str | None = None, retryable: bool = False)[source]¶
Bases:
QHarborToolsErrorAn operation requires an attached measurement backend.
- add_note()¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- class semi_cr.core.lab.utils.qharbor_tools.MeasurementReceipt(dataset_uuid: str, run_reference: RunReference, publications: tuple[Publication, ...], metadata: Mapping[str, Any] = <factory>)[source]¶
Bases:
objectResult of local persistence followed by remote publication.
- run_reference: RunReference¶
- publications: tuple[Publication, ...]¶
- class semi_cr.core.lab.utils.qharbor_tools.MeasurementSchema(name: str, parameters: tuple[ParameterSpec, ...] | Sequence[ParameterSpec])[source]¶
Bases:
objectBackend-independent description of one saved measurement.
- parameters: tuple[ParameterSpec, ...] | Sequence[ParameterSpec]¶
- class semi_cr.core.lab.utils.qharbor_tools.ParameterSpec(name: str, label: str | None = None, unit: str = '', setpoints: tuple[str, ...] = (), paramtype: str = 'numeric')[source]¶
Bases:
objectA backend-independent measurement parameter definition.
- class semi_cr.core.lab.utils.qharbor_tools.Publication(dataset_uuid: str, filename: str, metadata: Mapping[str, Any]=<factory>)[source]¶
Bases:
objectOne artifact successfully published to a remote dataset.
- exception semi_cr.core.lab.utils.qharbor_tools.PublicationConflictError(message: str, *, completed_publications: Sequence[Publication] = (), pending_artifacts: Sequence[Artifact] = (), **context: Any)[source]¶
Bases:
PublishErrorA remote filename already refers to different content.
- add_note()¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- class semi_cr.core.lab.utils.qharbor_tools.PublicationReceipt(dataset_uuid: str, publications: tuple[Publication, ...])[source]¶
Bases:
objectResult of a direct remote publication.
- publications: tuple[Publication, ...]¶
- exception semi_cr.core.lab.utils.qharbor_tools.PublishError(message: str, *, completed_publications: Sequence[Publication] = (), pending_artifacts: Sequence[Artifact] = (), **context: Any)[source]¶
Bases:
QHarborToolsErrorOne or more artifacts could not be published.
- add_note()¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception semi_cr.core.lab.utils.qharbor_tools.QHarborToolsError(message: str, *, operation: str | None = None, dataset_uuid: str | None = None, backend_name: str | None = None, run_reference: RunReference | None = None, artifact_name: str | None = None, retryable: bool = False)[source]¶
Bases:
ExceptionBase class for failures raised by the public framework API.
- add_note()¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception semi_cr.core.lab.utils.qharbor_tools.RemoteAccessError(message: str, *, operation: str | None = None, dataset_uuid: str | None = None, backend_name: str | None = None, run_reference: RunReference | None = None, artifact_name: str | None = None, retryable: bool = False)[source]¶
Bases:
QHarborToolsErrorA remote dataset operation failed.
- add_note()¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- class semi_cr.core.lab.utils.qharbor_tools.RemoteBackend[source]¶
Bases:
ABCAbstract remote dataset service used by
Experiment.- name = 'remote'¶
- announce(request: AnnouncementRequest) RemoteDataset[source]¶
Create a remote dataset and normalize dependency failures.
- open(uuid: str) RemoteDataset[source]¶
Open a remote dataset and normalize dependency failures.
- update_metadata(dataset: RemoteDataset, metadata: Mapping[str, Any]) RemoteDataset[source]¶
Update remote dataset metadata.
- publish(dataset: RemoteDataset, artifact: Artifact) Publication[source]¶
Publish one artifact.
- class semi_cr.core.lab.utils.qharbor_tools.RemoteDataset(uuid: str, name: str, description: str = '', attributes: Mapping[str, Any]=<factory>, files: tuple[str, ...]=())[source]¶
Bases:
objectStable public representation of a remote dataset.
- exception semi_cr.core.lab.utils.qharbor_tools.RemoteDatasetNotFoundError(message: str, *, operation: str | None = None, dataset_uuid: str | None = None, backend_name: str | None = None, run_reference: RunReference | None = None, artifact_name: str | None = None, retryable: bool = False)[source]¶
Bases:
RemoteAccessErrorThe requested remote dataset does not exist or is inaccessible.
- add_note()¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- class semi_cr.core.lab.utils.qharbor_tools.RunReference(backend: str, run_id: str, locator: str | None = None, metadata: Mapping[str, Any]=<factory>)[source]¶
Bases:
objectSerializable identity of a run stored by a measurement backend.
- class semi_cr.core.lab.utils.qharbor_tools.SaveRequest(experiment_name: str, subject_id: str, schema: Any, results: Mapping[str, Any], metadata: Mapping[str, Any])[source]¶
Bases:
objectValidated results supplied to a measurement backend.
- schema: Any¶
- class semi_cr.core.lab.utils.qharbor_tools.StoredRun(reference: RunReference, native_handle: Any = None)[source]¶
Bases:
objectBackend run plus an optional native handle kept out of public receipts.
- reference: RunReference¶
- class semi_cr.core.lab.utils.qharbor_tools.TokenCredentials(token: str, server_url: str)[source]¶
Bases:
objectSecret-safe token credentials for non-interactive authentication.
- class semi_cr.core.lab.utils.qharbor_tools.UserConfig(initials: str, name: str)[source]¶
Bases:
objectUser identity recorded in QHarbor metadata.
Subpackages¶
Submodules¶
semi_cr.core.lab.utils.qharbor_tools.api module¶
Long-lived user API for announcing and publishing experiment data.
- class semi_cr.core.lab.utils.qharbor_tools.api.Experiment(config: ExperimentConfig, *, measurement_backend: MeasurementBackend | None = None, remote_backend: RemoteBackend | None = None, authentication_backend: AuthenticationBackend | None = None, login_policy: LoginPolicy | str = LoginPolicy.ON_DEMAND)[source]¶
Bases:
objectStable facade over remote publication and optional local persistence.
- classmethod open(uuid: str, *, measurement_backend: MeasurementBackend | None = None, remote_backend: RemoteBackend | None = None, authentication_backend: AuthenticationBackend | None = None, login_policy: LoginPolicy | str = LoginPolicy.ON_DEMAND) Self[source]¶
Open an existing remote experiment, optionally attaching storage.
- property dataset: RemoteDataset¶
Return the announced or opened remote dataset.
- authentication_status() AuthenticationStatus[source]¶
Return login state without opening an interactive prompt.
- login() AuthenticationStatus[source]¶
Authenticate interactively, serializing concurrent login attempts.
- login_with_token(credentials: TokenCredentials) AuthenticationStatus[source]¶
Authenticate with secret-safe token credentials.
- logout() AuthenticationStatus[source]¶
End the shared remote session; repeated calls are safe.
- announce() RemoteDataset[source]¶
Create the configured remote dataset once and return its reference.
- refresh() RemoteDataset[source]¶
Reload metadata and filenames from the remote service.
- update_metadata(metadata: Mapping[str, Any]) RemoteDataset[source]¶
Merge metadata into the remote dataset attributes.
- publish(*, name: str, data: Any, metadata: Mapping[str, Any] | None = None, media_type: str = 'application/octet-stream') PublicationReceipt[source]¶
Publish existing data directly, without a measurement backend.
- save(*, schema: MeasurementSchema, results: Mapping[str, Any], metadata: Mapping[str, Any] | None = None, publish: Sequence[str] | None = None) MeasurementReceipt[source]¶
Persist one backend run, export it, and publish its artifacts.
- retry_publish(recovery: RunReference | PublishError, *, publish: Sequence[str] | None = None) MeasurementReceipt[source]¶
Republish a preserved backend run without creating a new local run.
- attach_backend(backend: MeasurementBackend) Self[source]¶
Attach local measurement storage to a remote-only experiment.
semi_cr.core.lab.utils.qharbor_tools.authentication module¶
Authentication contracts and dependency-independent public models.
- class semi_cr.core.lab.utils.qharbor_tools.authentication.LoginPolicy(*values)[source]¶
Bases:
StrEnumControl whether a remote operation may start interactive login.
- ON_DEMAND = 'on_demand'¶
- EXPLICIT = 'explicit'¶
- __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.utils.qharbor_tools.authentication.AuthenticationStatus(provider: str, authenticated: bool, supported: bool = True, principal_id: str | None = None, server_url: str | None = None, scopes: tuple[str, ...] | Sequence[str] = ())[source]¶
Bases:
objectPortable authentication state returned to framework users.
- classmethod unsupported(provider: str) AuthenticationStatus[source]¶
Return an unauthenticated status for a backend without login support.
- class semi_cr.core.lab.utils.qharbor_tools.authentication.TokenCredentials(token: str, server_url: str)[source]¶
Bases:
objectSecret-safe token credentials for non-interactive authentication.
- class semi_cr.core.lab.utils.qharbor_tools.authentication.AuthenticationBackend[source]¶
Bases:
ABCAbstract authentication provider injected into
Experiment.- name = 'authentication'¶
- status() AuthenticationStatus[source]¶
Return current authentication state without opening a login prompt.
- login() AuthenticationStatus[source]¶
Run interactive login and verify that it completed.
- login_with_token(credentials: TokenCredentials) AuthenticationStatus[source]¶
Authenticate without an interactive prompt and verify the result.
semi_cr.core.lab.utils.qharbor_tools.backend module¶
Abstract backend contracts and dependency-error normalization.
- class semi_cr.core.lab.utils.qharbor_tools.backend.RemoteBackend[source]¶
Bases:
ABCAbstract remote dataset service used by
Experiment.- name = 'remote'¶
- announce(request: AnnouncementRequest) RemoteDataset[source]¶
Create a remote dataset and normalize dependency failures.
- open(uuid: str) RemoteDataset[source]¶
Open a remote dataset and normalize dependency failures.
- update_metadata(dataset: RemoteDataset, metadata: Mapping[str, Any]) RemoteDataset[source]¶
Update remote dataset metadata.
- publish(dataset: RemoteDataset, artifact: Artifact) Publication[source]¶
Publish one artifact.
- class semi_cr.core.lab.utils.qharbor_tools.backend.MeasurementBackend[source]¶
Bases:
ABCAbstract local measurement storage and export backend.
- name = 'measurement'¶
- prepare(context: BackendContext) None[source]¶
Prepare the backend for an experiment.
- save(request: SaveRequest) StoredRun[source]¶
Persist one run and normalize dependency failures.
- load(run: RunReference) StoredRun[source]¶
Reload a run and normalize dependency failures.
semi_cr.core.lab.utils.qharbor_tools.data_utils module¶
Compatibility helpers for notebooks written before the framework API.
New code should use qharbor_tools.Experiment directly. Imports of
QDrive, QCoDeS, and Plottr remain inside the functions that need them so this
module can be imported without optional measurement dependencies.
- class semi_cr.core.lab.utils.qharbor_tools.data_utils.LegacyRawDataset(backend: RemoteBackend, remote: RemoteDataset)[source]¶
Bases:
objectSmall QDrive-like bridge used by existing notebooks.
It exposes the attributes and item-assignment behavior used by existing callers while delegating all remote work to
RemoteBackend.- refresh() LegacyRawDataset[source]¶
- semi_cr.core.lab.utils.qharbor_tools.data_utils.load_yaml_file(path: str | Path) dict[str, Any][source]¶
Load a YAML mapping from disk.
- semi_cr.core.lab.utils.qharbor_tools.data_utils.conversion_to_float_parameters(params: Mapping[str, Any]) dict[str, Any][source]¶
Convert known station values to floats without mutating input.
- semi_cr.core.lab.utils.qharbor_tools.data_utils.init_local_database(db_path: Path, SAMPLE_NAME: str, show_plottr: bool = False) Path[source]¶
Initialize the legacy per-sample QCoDeS database and return its path.
- semi_cr.core.lab.utils.qharbor_tools.data_utils.create_raw_dataset(config: Mapping[str, Any], *, remote_backend: RemoteBackend | None = None) LegacyRawDataset[source]¶
Create a remote dataset from the historical nested configuration.
- semi_cr.core.lab.utils.qharbor_tools.data_utils.get_or_create_dataset(config: Mapping[str, Any], *, remote_backend: RemoteBackend | None = None) LegacyRawDataset[source]¶
Open the configured UUID or announce a new dataset.
- semi_cr.core.lab.utils.qharbor_tools.data_utils.make_raw_dataset(scope_name: str, experimentName: str, equipment: str, protocolName: str, user_initials: str, user_name: str, platform: str, chip_id: str, project_id: str, component: str, step: str, sub_step: str, description: str = '', *, remote_backend: RemoteBackend | None = None) LegacyRawDataset[source]¶
Announce a dataset using the historical flat argument list.
- semi_cr.core.lab.utils.qharbor_tools.data_utils.make_tier2_qharbor_raw_dataset(experimentName: str, description: str, attributes: Mapping[str, Any], scope_name: str = 'Test will be deleted', *, remote_backend: RemoteBackend | None = None) LegacyRawDataset[source]¶
Announce a tier-2 dataset through the remote backend contract.
- semi_cr.core.lab.utils.qharbor_tools.data_utils.add_user_attributes(attributes: dict[str, Any], user_initials: str, user_name: str) dict[str, Any][source]¶
Add standard user attributes to a mutable metadata mapping.
- semi_cr.core.lab.utils.qharbor_tools.data_utils.add_chip_attributes(attributes: dict[str, Any], chip_id: str, project_id: str, component: str) dict[str, Any][source]¶
Add standard chip attributes to a mutable metadata mapping.
- semi_cr.core.lab.utils.qharbor_tools.data_utils.start_live_plotting(station_name: str) Path[source]¶
Initialize the historical station database and return its path.
- semi_cr.core.lab.utils.qharbor_tools.data_utils.get_measured_subject_ids(raw_dataset: LegacyRawDataset) list[str][source]¶
Extract unique subject IDs from published HDF5 filenames.
semi_cr.core.lab.utils.qharbor_tools.errors module¶
Stable exceptions exposed by qharbor_tools.
- exception semi_cr.core.lab.utils.qharbor_tools.errors.QHarborToolsError(message: str, *, operation: str | None = None, dataset_uuid: str | None = None, backend_name: str | None = None, run_reference: RunReference | None = None, artifact_name: str | None = None, retryable: bool = False)[source]¶
Bases:
ExceptionBase class for failures raised by the public framework API.
- add_note()¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception semi_cr.core.lab.utils.qharbor_tools.errors.ConfigurationError(message: str, *, operation: str | None = None, dataset_uuid: str | None = None, backend_name: str | None = None, run_reference: RunReference | None = None, artifact_name: str | None = None, retryable: bool = False)[source]¶
Bases:
QHarborToolsError,ValueErrorThe supplied framework configuration or data is invalid.
- add_note()¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception semi_cr.core.lab.utils.qharbor_tools.errors.AuthenticationError(message: str, *, operation: str | None = None, dataset_uuid: str | None = None, backend_name: str | None = None, run_reference: RunReference | None = None, artifact_name: str | None = None, retryable: bool = False)[source]¶
Bases:
QHarborToolsErrorAuthentication was required or failed.
- add_note()¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception semi_cr.core.lab.utils.qharbor_tools.errors.AuthenticationRequiredError(message: str, *, operation: str | None = None, dataset_uuid: str | None = None, backend_name: str | None = None, run_reference: RunReference | None = None, artifact_name: str | None = None, retryable: bool = False)[source]¶
Bases:
AuthenticationErrorA remote operation requires the user to authenticate.
- add_note()¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception semi_cr.core.lab.utils.qharbor_tools.errors.AuthenticationFailedError(message: str, *, operation: str | None = None, dataset_uuid: str | None = None, backend_name: str | None = None, run_reference: RunReference | None = None, artifact_name: str | None = None, retryable: bool = False)[source]¶
Bases:
AuthenticationErrorAn interactive or token login did not establish a session.
- add_note()¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception semi_cr.core.lab.utils.qharbor_tools.errors.AuthenticationUnsupportedError(message: str, *, operation: str | None = None, dataset_uuid: str | None = None, backend_name: str | None = None, run_reference: RunReference | None = None, artifact_name: str | None = None, retryable: bool = False)[source]¶
Bases:
AuthenticationErrorThe configured remote backend has no authentication provider.
- add_note()¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception semi_cr.core.lab.utils.qharbor_tools.errors.RemoteAccessError(message: str, *, operation: str | None = None, dataset_uuid: str | None = None, backend_name: str | None = None, run_reference: RunReference | None = None, artifact_name: str | None = None, retryable: bool = False)[source]¶
Bases:
QHarborToolsErrorA remote dataset operation failed.
- add_note()¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception semi_cr.core.lab.utils.qharbor_tools.errors.RemoteDatasetNotFoundError(message: str, *, operation: str | None = None, dataset_uuid: str | None = None, backend_name: str | None = None, run_reference: RunReference | None = None, artifact_name: str | None = None, retryable: bool = False)[source]¶
Bases:
RemoteAccessErrorThe requested remote dataset does not exist or is inaccessible.
- add_note()¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception semi_cr.core.lab.utils.qharbor_tools.errors.MeasurementBackendRequiredError(message: str, *, operation: str | None = None, dataset_uuid: str | None = None, backend_name: str | None = None, run_reference: RunReference | None = None, artifact_name: str | None = None, retryable: bool = False)[source]¶
Bases:
QHarborToolsErrorAn operation requires an attached measurement backend.
- add_note()¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception semi_cr.core.lab.utils.qharbor_tools.errors.BackendError(message: str, *, operation: str | None = None, dataset_uuid: str | None = None, backend_name: str | None = None, run_reference: RunReference | None = None, artifact_name: str | None = None, retryable: bool = False)[source]¶
Bases:
QHarborToolsErrorBase class for measurement-backend failures.
- add_note()¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception semi_cr.core.lab.utils.qharbor_tools.errors.BackendPreparationError(message: str, *, operation: str | None = None, dataset_uuid: str | None = None, backend_name: str | None = None, run_reference: RunReference | None = None, artifact_name: str | None = None, retryable: bool = False)[source]¶
Bases:
BackendErrorA measurement backend could not be prepared.
- add_note()¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception semi_cr.core.lab.utils.qharbor_tools.errors.BackendSaveError(message: str, *, operation: str | None = None, dataset_uuid: str | None = None, backend_name: str | None = None, run_reference: RunReference | None = None, artifact_name: str | None = None, retryable: bool = False)[source]¶
Bases:
BackendErrorA measurement backend could not persist a run.
- add_note()¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception semi_cr.core.lab.utils.qharbor_tools.errors.BackendLoadError(message: str, *, operation: str | None = None, dataset_uuid: str | None = None, backend_name: str | None = None, run_reference: RunReference | None = None, artifact_name: str | None = None, retryable: bool = False)[source]¶
Bases:
BackendErrorA measurement backend could not reload a run.
- add_note()¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception semi_cr.core.lab.utils.qharbor_tools.errors.BackendExportError(message: str, *, operation: str | None = None, dataset_uuid: str | None = None, backend_name: str | None = None, run_reference: RunReference | None = None, artifact_name: str | None = None, retryable: bool = False)[source]¶
Bases:
BackendErrorA measurement backend could not export a run.
- add_note()¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception semi_cr.core.lab.utils.qharbor_tools.errors.BackendCloseError(message: str, *, operation: str | None = None, dataset_uuid: str | None = None, backend_name: str | None = None, run_reference: RunReference | None = None, artifact_name: str | None = None, retryable: bool = False)[source]¶
Bases:
BackendErrorA measurement backend could not release its resources.
- add_note()¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception semi_cr.core.lab.utils.qharbor_tools.errors.PublishError(message: str, *, completed_publications: Sequence[Publication] = (), pending_artifacts: Sequence[Artifact] = (), **context: Any)[source]¶
Bases:
QHarborToolsErrorOne or more artifacts could not be published.
- add_note()¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception semi_cr.core.lab.utils.qharbor_tools.errors.PublicationConflictError(message: str, *, completed_publications: Sequence[Publication] = (), pending_artifacts: Sequence[Artifact] = (), **context: Any)[source]¶
Bases:
PublishErrorA remote filename already refers to different content.
- add_note()¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
semi_cr.core.lab.utils.qharbor_tools.models module¶
Dependency-independent models used by the qharbor tools framework.
- semi_cr.core.lab.utils.qharbor_tools.models.require_text(value: str, field_name: str) str[source]¶
Return a stripped non-empty string or raise a configuration error.
- semi_cr.core.lab.utils.qharbor_tools.models.frozen_mapping(value: Mapping[str, Any] | None = None) Mapping[str, Any][source]¶
Copy a mapping so receipts and references cannot change unexpectedly.
- class semi_cr.core.lab.utils.qharbor_tools.models.UserConfig(initials: str, name: str)[source]¶
Bases:
objectUser identity recorded in QHarbor metadata.
- class semi_cr.core.lab.utils.qharbor_tools.models.DatasetConfig(name: str, description: str, scope: str, subject_id: str, platform: str, project_id: str, component: str, step: str, sub_step: str, protocol_name: str, equipment: str, team: str = 'Spin Qubit', extra_attributes: Mapping[str, Any]=<factory>)[source]¶
Bases:
objectMetadata used to announce a QHarbor dataset.
- class semi_cr.core.lab.utils.qharbor_tools.models.ExperimentConfig(user: UserConfig, dataset: DatasetConfig)[source]¶
Bases:
objectConfiguration for a new remote experiment.
- user: UserConfig¶
- dataset: DatasetConfig¶
- class semi_cr.core.lab.utils.qharbor_tools.models.AnnouncementRequest(name: str, description: str, scope: str, attributes: Mapping[str, Any])[source]¶
Bases:
objectDependency-independent request passed to a remote backend.
- class semi_cr.core.lab.utils.qharbor_tools.models.RemoteDataset(uuid: str, name: str, description: str = '', attributes: Mapping[str, Any]=<factory>, files: tuple[str, ...]=())[source]¶
Bases:
objectStable public representation of a remote dataset.
- class semi_cr.core.lab.utils.qharbor_tools.models.Artifact(name: str, data: Any, media_type: str = 'application/octet-stream', metadata: Mapping[str, Any]=<factory>)[source]¶
Bases:
objectPortable data ready for publication by a remote backend.
- data: Any¶
- class semi_cr.core.lab.utils.qharbor_tools.models.RunReference(backend: str, run_id: str, locator: str | None = None, metadata: Mapping[str, Any]=<factory>)[source]¶
Bases:
objectSerializable identity of a run stored by a measurement backend.
- class semi_cr.core.lab.utils.qharbor_tools.models.StoredRun(reference: RunReference, native_handle: Any = None)[source]¶
Bases:
objectBackend run plus an optional native handle kept out of public receipts.
- reference: RunReference¶
- class semi_cr.core.lab.utils.qharbor_tools.models.BackendContext(experiment_name: str, subject_id: str, dataset_uuid: str)[source]¶
Bases:
objectExperiment information supplied when preparing a local backend.
semi_cr.core.lab.utils.qharbor_tools.receipts module¶
Stable receipts returned by qharbor tools operations.
- class semi_cr.core.lab.utils.qharbor_tools.receipts.Publication(dataset_uuid: str, filename: str, metadata: Mapping[str, Any]=<factory>)[source]¶
Bases:
objectOne artifact successfully published to a remote dataset.
- class semi_cr.core.lab.utils.qharbor_tools.receipts.PublicationReceipt(dataset_uuid: str, publications: tuple[Publication, ...])[source]¶
Bases:
objectResult of a direct remote publication.
- publications: tuple[Publication, ...]¶
- class semi_cr.core.lab.utils.qharbor_tools.receipts.MeasurementReceipt(dataset_uuid: str, run_reference: RunReference, publications: tuple[Publication, ...], metadata: Mapping[str, Any] = <factory>)[source]¶
Bases:
objectResult of local persistence followed by remote publication.
- run_reference: RunReference¶
- publications: tuple[Publication, ...]¶
semi_cr.core.lab.utils.qharbor_tools.schemas module¶
Measurement schemas shared by all local measurement backends.
- class semi_cr.core.lab.utils.qharbor_tools.schemas.ParameterSpec(name: str, label: str | None = None, unit: str = '', setpoints: tuple[str, ...] = (), paramtype: str = 'numeric')[source]¶
Bases:
objectA backend-independent measurement parameter definition.
- class semi_cr.core.lab.utils.qharbor_tools.schemas.MeasurementSchema(name: str, parameters: tuple[ParameterSpec, ...] | Sequence[ParameterSpec])[source]¶
Bases:
objectBackend-independent description of one saved measurement.
- parameters: tuple[ParameterSpec, ...] | Sequence[ParameterSpec]¶