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

Portable data ready for publication by a remote backend.

name: str
data: Any
media_type: str
metadata: Mapping[str, Any]
class semi_cr.core.lab.utils.qharbor_tools.AuthenticationBackend[source]

Bases: ABC

Abstract 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.

logout() → None[source]

End the provider session.

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

Authentication 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: AuthenticationError

An 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: AuthenticationError

A 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: object

Portable authentication state returned to framework users.

provider: str
authenticated: bool
supported: bool
principal_id: str | None
server_url: str | None
scopes: tuple[str, ...] | Sequence[str]
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: AuthenticationError

The 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: BackendError

A 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: object

Experiment information supplied when preparing a local backend.

experiment_name: str
subject_id: str
dataset_uuid: str
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: QHarborToolsError

Base 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: BackendError

A 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: BackendError

A 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: BackendError

A 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: BackendError

A 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, ValueError

The 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: object

Metadata used to announce a QHarbor dataset.

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
extra_attributes: Mapping[str, Any]
attributes(user: UserConfig) → dict[str, Any][source]

Return QHarbor attribute names expected by current data workflows.

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

Stable 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.

property metadata: Mapping[str, Any]

Return the current remote dataset attributes.

property files: tuple[str, ...]

Return filenames known when the remote dataset was last refreshed.

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.

close() → None[source]

Close attached backends; repeated calls are safe.

class semi_cr.core.lab.utils.qharbor_tools.ExperimentConfig(user: UserConfig, dataset: DatasetConfig)[source]

Bases: object

Configuration for a new remote experiment.

user: UserConfig
dataset: DatasetConfig
class semi_cr.core.lab.utils.qharbor_tools.LoginPolicy(*values)[source]

Bases: StrEnum

Control 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: ABC

Abstract 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.

export(run: StoredRun, *, variables: Sequence[str] | None = None) → list[Artifact][source]

Export a run as portable artifacts.

close() → None[source]

Release resources 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: QHarborToolsError

An 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: object

Result of local persistence followed by remote publication.

dataset_uuid: str
run_reference: RunReference
publications: tuple[Publication, ...]
metadata: Mapping[str, Any]
class semi_cr.core.lab.utils.qharbor_tools.MeasurementSchema(name: str, parameters: tuple[ParameterSpec, ...] | Sequence[ParameterSpec])[source]

Bases: object

Backend-independent description of one saved measurement.

name: str
parameters: tuple[ParameterSpec, ...] | Sequence[ParameterSpec]
property parameter_names: tuple[str, ...]

Return parameter names in registration order.

validate_results(results: Mapping[str, Any]) → None[source]

Validate keys and array shapes before a backend has side effects.

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

A backend-independent measurement parameter definition.

name: str
label: str | None
unit: str
setpoints: tuple[str, ...]
paramtype: str
class semi_cr.core.lab.utils.qharbor_tools.Publication(dataset_uuid: str, filename: str, metadata: Mapping[str, Any]=<factory>)[source]

Bases: object

One artifact successfully published to a remote dataset.

dataset_uuid: str
filename: str
metadata: Mapping[str, Any]
exception semi_cr.core.lab.utils.qharbor_tools.PublicationConflictError(message: str, *, completed_publications: Sequence[Publication] = (), pending_artifacts: Sequence[Artifact] = (), **context: Any)[source]

Bases: PublishError

A 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: object

Result of a direct remote publication.

dataset_uuid: str
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: QHarborToolsError

One 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: Exception

Base 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: QHarborToolsError

A 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: ABC

Abstract 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.

close() → None[source]

Release remote resources.

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

Stable public representation of a remote dataset.

uuid: str
name: str
description: str
attributes: Mapping[str, Any]
files: tuple[str, ...]
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: RemoteAccessError

The 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: object

Serializable identity of a run stored by a measurement backend.

backend: str
run_id: str
locator: str | None
metadata: Mapping[str, Any]
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: object

Validated results supplied to a measurement backend.

experiment_name: str
subject_id: str
schema: Any
results: Mapping[str, Any]
metadata: Mapping[str, Any]
class semi_cr.core.lab.utils.qharbor_tools.StoredRun(reference: RunReference, native_handle: Any = None)[source]

Bases: object

Backend run plus an optional native handle kept out of public receipts.

reference: RunReference
native_handle: Any
class semi_cr.core.lab.utils.qharbor_tools.TokenCredentials(token: str, server_url: str)[source]

Bases: object

Secret-safe token credentials for non-interactive authentication.

token: str
server_url: str
class semi_cr.core.lab.utils.qharbor_tools.UserConfig(initials: str, name: str)[source]

Bases: object

User identity recorded in QHarbor metadata.

initials: str
name: str

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

Stable 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.

property metadata: Mapping[str, Any]

Return the current remote dataset attributes.

property files: tuple[str, ...]

Return filenames known when the remote dataset was last refreshed.

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.

close() → None[source]

Close attached backends; repeated calls are safe.

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

Control 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: object

Portable authentication state returned to framework users.

provider: str
authenticated: bool
supported: bool
principal_id: str | None
server_url: str | None
scopes: tuple[str, ...] | Sequence[str]
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: object

Secret-safe token credentials for non-interactive authentication.

token: str
server_url: str
class semi_cr.core.lab.utils.qharbor_tools.authentication.AuthenticationBackend[source]

Bases: ABC

Abstract 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.

logout() → None[source]

End the provider session.

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

Abstract 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.

close() → None[source]

Release remote resources.

class semi_cr.core.lab.utils.qharbor_tools.backend.MeasurementBackend[source]

Bases: ABC

Abstract 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.

export(run: StoredRun, *, variables: Sequence[str] | None = None) → list[Artifact][source]

Export a run as portable artifacts.

close() → None[source]

Release resources 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: object

Small 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.

property uuid: str
property name: str
property description: str
property attributes: Mapping[str, Any]
property files: tuple[str, ...]
refresh() → LegacyRawDataset[source]
close() → None[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.data_utils.check_user_exists() → bool[source]

Return whether the default QDrive authentication session is active.

semi_cr.core.lab.utils.qharbor_tools.data_utils.show_plottr_inspectr(db_path: Path) → Popen[bytes][source]

Launch Plottr Inspectr for a QCoDeS database.

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

Base 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, ValueError

The 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: QHarborToolsError

Authentication 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: AuthenticationError

A 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: AuthenticationError

An 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: AuthenticationError

The 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: QHarborToolsError

A 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: RemoteAccessError

The 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: QHarborToolsError

An 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: QHarborToolsError

Base 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: BackendError

A 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: BackendError

A 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: BackendError

A 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: BackendError

A 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: BackendError

A 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: QHarborToolsError

One 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: PublishError

A 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: object

User identity recorded in QHarbor metadata.

initials: str
name: str
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: object

Metadata used to announce a QHarbor dataset.

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
extra_attributes: Mapping[str, Any]
attributes(user: UserConfig) → dict[str, Any][source]

Return QHarbor attribute names expected by current data workflows.

class semi_cr.core.lab.utils.qharbor_tools.models.ExperimentConfig(user: UserConfig, dataset: DatasetConfig)[source]

Bases: object

Configuration 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: object

Dependency-independent request passed to a remote backend.

name: str
description: str
scope: str
attributes: Mapping[str, Any]
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: object

Stable public representation of a remote dataset.

uuid: str
name: str
description: str
attributes: Mapping[str, Any]
files: tuple[str, ...]
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: object

Portable data ready for publication by a remote backend.

name: str
data: Any
media_type: str
metadata: Mapping[str, 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: object

Serializable identity of a run stored by a measurement backend.

backend: str
run_id: str
locator: str | None
metadata: Mapping[str, Any]
class semi_cr.core.lab.utils.qharbor_tools.models.StoredRun(reference: RunReference, native_handle: Any = None)[source]

Bases: object

Backend run plus an optional native handle kept out of public receipts.

reference: RunReference
native_handle: Any
class semi_cr.core.lab.utils.qharbor_tools.models.BackendContext(experiment_name: str, subject_id: str, dataset_uuid: str)[source]

Bases: object

Experiment information supplied when preparing a local backend.

experiment_name: str
subject_id: str
dataset_uuid: str
class semi_cr.core.lab.utils.qharbor_tools.models.SaveRequest(experiment_name: str, subject_id: str, schema: Any, results: Mapping[str, Any], metadata: Mapping[str, Any])[source]

Bases: object

Validated results supplied to a measurement backend.

experiment_name: str
subject_id: str
schema: Any
results: Mapping[str, Any]
metadata: Mapping[str, Any]

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

One artifact successfully published to a remote dataset.

dataset_uuid: str
filename: str
metadata: Mapping[str, Any]
class semi_cr.core.lab.utils.qharbor_tools.receipts.PublicationReceipt(dataset_uuid: str, publications: tuple[Publication, ...])[source]

Bases: object

Result of a direct remote publication.

dataset_uuid: str
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: object

Result of local persistence followed by remote publication.

dataset_uuid: str
run_reference: RunReference
publications: tuple[Publication, ...]
metadata: Mapping[str, Any]

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

A backend-independent measurement parameter definition.

name: str
label: str | None
unit: str
setpoints: tuple[str, ...]
paramtype: str
class semi_cr.core.lab.utils.qharbor_tools.schemas.MeasurementSchema(name: str, parameters: tuple[ParameterSpec, ...] | Sequence[ParameterSpec])[source]

Bases: object

Backend-independent description of one saved measurement.

name: str
parameters: tuple[ParameterSpec, ...] | Sequence[ParameterSpec]
property parameter_names: tuple[str, ...]

Return parameter names in registration order.

validate_results(results: Mapping[str, Any]) → None[source]

Validate keys and array shapes before a backend has side effects.