hugr

Client API for HUGR in Nexus.

N.B. Nexus support for HUGR is experimental, and any HUGRs programs uploaded to Nexus before stability is achieved might not work in the future.

qnexus.client.hugr.cost(
programs: HUGRRef | list[HUGRRef],
n_shots: int | list[int],
project: ProjectRef | None = None,
system_name: Literal['Helios-1'] = 'Helios-1',
) float[source]

Estimate the cost (in HQC) of running Hugr programs for n_shots number of shots on a Quantinuum Helios system.

NB: This will execute a costing job on a dedicated cost estimation device.

Once run, the cost will be visible also in the Nexus web portal as part of the job.

qnexus.client.hugr.cost_confidence(
programs: HUGRRef | list[HUGRRef],
n_shots: int | list[int],
project: ProjectRef | None = None,
system_name: Literal['Helios-1'] = 'Helios-1',
) list[tuple[float, float]][source]

Estimate the cost (in HQC) of running Hugr programs for n_shots number of shots on a Quantinuum Helios system.

Returns a list of tuples of (cost, confidence) for each job item.

NB: This will execute a costing job on a dedicated cost estimation device.

Once run, the cost will be visible also in the Nexus web portal as part of the job.

Examples

>>> import qnexus as qnx
>>> costs = qnx.hugr.cost_confidence(
...     programs=[hugr_ref],
...     n_shots=100,
...     project=project_ref,
... )
>>> for hqc_cost, confidence in costs:
...     print(f"Cost: {hqc_cost}, Confidence: {confidence}")
qnexus.client.hugr.get(
*,
id: UUID | str | None = None,
name: str | None = None,
name_like: str | None = None,
creator_email: list[str] | None = None,
project: ProjectRef | None = None,
properties: OrderedDict[str, bool | int | float | str] | None = None,
created_before: datetime | None = None,
created_after: datetime | None = datetime.datetime(2023, 1, 1, 0, 0),
modified_before: datetime | None = None,
modified_after: datetime | None = None,
sort_filters: list[SortFilterEnum] | None = None,
page_number: int | None = None,
page_size: int | None = None,
scope: ScopeFilterEnum = ScopeFilterEnum.USER,
) HUGRRef[source]

Get a single HUGR using filters. Throws an exception if the filters do not match exactly one object.

Examples

>>> import qnexus as qnx
>>> hugr_ref = qnx.hugr.get(name="my_hugr", project=project_ref)
qnexus.client.hugr.get_all(
*,
name_like: str | None = None,
name_exact: list[str] | None = None,
creator_email: list[str] | None = None,
project: ProjectRef | None = None,
properties: OrderedDict[str, bool | int | float | str] | None = None,
created_before: datetime | None = None,
created_after: datetime | None = datetime.datetime(2023, 1, 1, 0, 0),
modified_before: datetime | None = None,
modified_after: datetime | None = None,
sort_filters: list[SortFilterEnum] | None = None,
page_number: int | None = None,
page_size: int | None = None,
scope: ScopeFilterEnum = ScopeFilterEnum.USER,
) NexusIterator[HUGRRef][source]

Get a NexusIterator over HUGRs with optional filters.

Examples

>>> import qnexus as qnx
>>> all_hugrs = qnx.hugr.get_all(project=project_ref)
>>> all_hugrs.df()
qnexus.client.hugr.update(
ref: HUGRRef,
name: str | None = None,
description: str | None = None,
properties: OrderedDict[str, bool | int | float | str] | None = None,
) HUGRRef[source]

Update the annotations on a HUGRRef.

Examples

>>> import qnexus as qnx
>>> updated = qnx.hugr.update(hugr_ref, name="renamed_hugr")
qnexus.client.hugr.upload(
hugr_package: Package | PackagePointer | Hugr[Module],
name: str,
project: ProjectRef | None = None,
description: str | None = None,
properties: OrderedDict[str, bool | int | float | str] | None = None,
) HUGRRef[source]

Upload a HUGR to Nexus.

N.B. HUGR support in Nexus is subject to change. Until full support is achieved any programs uploaded may not work in the future.

Examples

>>> import qnexus as qnx
>>> hugr_ref = qnx.hugr.upload(
...     hugr_package=my_package,
...     name="my_hugr_program",
...     project=project_ref,
... )