@oqtopus-team/qdash-sdk 0.0.0-stage → 1.10.5-beta.1289
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +44 -2
- package/dist/index.d.ts +257 -0
- package/dist/index.js +386 -0
- package/dist/index.js.map +1 -0
- package/package.json +45 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2024 The University of Osaka
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,45 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @oqtopus-team/qdash-sdk
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
`@oqtopus-team/qdash-sdk` validates and starts QDash calibrations on a chip and lists and runs
|
|
4
|
+
the workflows registered in a project. It is built on
|
|
5
|
+
[`@oqtopus-team/qdash-client`](https://www.npmjs.com/package/@oqtopus-team/qdash-client), which
|
|
6
|
+
stays the lower-level API for every other route. Installing the SDK installs the client of the
|
|
7
|
+
same release:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @oqtopus-team/qdash-sdk
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
The package is ESM only and requires Node.js 20 or later.
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { QDash, customOneQubit, qubitTargets } from "@oqtopus-team/qdash-sdk";
|
|
17
|
+
|
|
18
|
+
const qdash = QDash.fromEnv(); // or new QDash(client, { projectId: "your-project-id" })
|
|
19
|
+
const chip = qdash.chip("64Qv3");
|
|
20
|
+
const steps = [customOneQubit({ step_name: "t1", tasks: [{ name: "CheckT1" }] })];
|
|
21
|
+
|
|
22
|
+
const check = await chip.validateCalibration(qubitTargets(["0", "1"]), steps); // nothing runs
|
|
23
|
+
const run = await chip.calibrate(qubitTargets(["0", "1"]), steps); // measures
|
|
24
|
+
const result = await run.wait({ timeoutSeconds: 3600 });
|
|
25
|
+
console.log(run.executionId, result.status);
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
`result.status` is the whole pipeline run's status. A timeout throws `QDashTimeoutError` and
|
|
29
|
+
leaves the run going. `qdash.workflows.list()`, `get(name)` and `run(name, { parameters })` reach
|
|
30
|
+
the project's registered workflows. The SDK sends requests through the given `QDashClient`, and
|
|
31
|
+
its error classes are the client's own, so `instanceof` works with either import. A session
|
|
32
|
+
without a project uses the client's configuration as it is: when no project is configured
|
|
33
|
+
there, QDash applies the user's default project.
|
|
34
|
+
|
|
35
|
+
The [TypeScript client reference](https://oqtopus-team.github.io/qdash/reference/clients/typescript#run-a-calibration)
|
|
36
|
+
covers configuration and every call.
|
|
37
|
+
|
|
38
|
+
## Develop the Package
|
|
39
|
+
|
|
40
|
+
Install from the repository root; the SDK builds against the client in the same checkout:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
bun install --frozen-lockfile
|
|
44
|
+
task test-sdk-ts
|
|
45
|
+
```
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
import { QDashClient, QDashClientOptions } from '@oqtopus-team/qdash-client';
|
|
2
|
+
export { QDashApiError, QDashAuthError, QDashConfigError, QDashNotFoundError, QDashTimeoutError, QDashTransportError, QDashValidationError } from '@oqtopus-team/qdash-client';
|
|
3
|
+
import { PipelineTargets, CalibrationPipelineSpecStepsItem, CalibrationPipelineSpec, CustomOneQubitStep, ExecutionResponseDetail, ExecutePipelineResponse, PipelineCatalogResponse, ValidatePipelineResponse, FlowSummary, GetFlowResponse, ExecuteFlowResponse } from '@oqtopus-team/qdash-client/models';
|
|
4
|
+
export { CalibrationPipelineSpec, CalibrationPipelineSpecStepsItem, CustomOneQubitStep, ExecuteFlowResponse, ExecutePipelineResponse, ExecutionResponseDetail, FlowSummary, GetFlowResponse, PipelineCatalogResponse, PipelineProblem, PipelineTargets, TaskCall, ValidatePipelineResponse } from '@oqtopus-team/qdash-client/models';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Small builders for the generated pipeline spec types.
|
|
8
|
+
*
|
|
9
|
+
* Targets, steps and task calls are the API's own generated types
|
|
10
|
+
* (`PipelineTargets`, `CustomOneQubitStep`, `TaskCall`, ...), written in the
|
|
11
|
+
* spec's JSON form with its snake_case keys; object literals of those types are
|
|
12
|
+
* always accepted. These helpers only fill in what is tedious to write: the
|
|
13
|
+
* target shape, a step's `type` and sweep declarations. They send nothing, and
|
|
14
|
+
* leave every rule beyond the obvious shape to the server's validate route.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/** Explicit target qubits by the IDs QDash lists: `{ qids: [...] }`. */
|
|
18
|
+
declare function qubitTargets(qids: readonly string[]): PipelineTargets;
|
|
19
|
+
/** Every qubit of the given MUXes: `{ mux_ids: [...], exclude_qids?: [...] }`. */
|
|
20
|
+
declare function muxTargets(muxIds: readonly number[], options?: {
|
|
21
|
+
excludeQids?: readonly string[];
|
|
22
|
+
}): PipelineTargets;
|
|
23
|
+
/** A `CustomOneQubit` step: its task calls, in order, on every candidate qubit. */
|
|
24
|
+
declare function customOneQubit(step: Omit<CustomOneQubitStep, "type">): CustomOneQubitStep;
|
|
25
|
+
/** Top-level spec fields a calibration may set; the server defaults the rest. */
|
|
26
|
+
interface CalibrationOptions {
|
|
27
|
+
/** The execution's display name. */
|
|
28
|
+
name?: string;
|
|
29
|
+
/** Run parameters every task call starts from, e.g. shots or interval. */
|
|
30
|
+
defaultRunParameters?: Record<string, unknown>;
|
|
31
|
+
tags?: string[];
|
|
32
|
+
/** Defaults to the configured backend. */
|
|
33
|
+
backendName?: string;
|
|
34
|
+
}
|
|
35
|
+
/** The spec version 2 object for `targets` and `steps`, with only the options given. */
|
|
36
|
+
declare function calibrationSpec(targets: PipelineTargets, steps: readonly CalibrationPipelineSpecStepsItem[], options?: CalibrationOptions): CalibrationPipelineSpec;
|
|
37
|
+
/** A swept run parameter in the spec's wire format; the worker expands it. */
|
|
38
|
+
interface SweepDeclaration {
|
|
39
|
+
value: number[];
|
|
40
|
+
value_type: "list" | "np.linspace" | "np.logspace" | "np.arange" | "range";
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Sweep declarations, constructor for constructor as `qdash.workflow.sweep` and
|
|
44
|
+
* the Python SDK write them. Nothing is expanded locally.
|
|
45
|
+
*/
|
|
46
|
+
declare const sweep: {
|
|
47
|
+
/** Explicit points: `{ value: [p0, p1, ...], value_type: "list" }`. */
|
|
48
|
+
readonly values: (...points: number[]) => SweepDeclaration;
|
|
49
|
+
/** `numpy.linspace(start, stop, num)`. */
|
|
50
|
+
readonly linspace: (start: number, stop: number, num: number) => SweepDeclaration;
|
|
51
|
+
/** `numpy.logspace(start, stop, num)`; `start` and `stop` are base-10 exponents. */
|
|
52
|
+
readonly logspace: (start: number, stop: number, num: number) => SweepDeclaration;
|
|
53
|
+
/** `numpy.arange(start, stop, step)`. */
|
|
54
|
+
readonly arange: (start: number, stop: number, step: number) => SweepDeclaration;
|
|
55
|
+
/** Python `range(start, stop, step)`. */
|
|
56
|
+
readonly range: (start: number, stop: number, step: number) => SweepDeclaration;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
/** How long `wait()` polls `GET /executions/{id}`; the run is never cancelled. */
|
|
60
|
+
interface WaitOptions {
|
|
61
|
+
/** Give up after this many seconds with `QDashTimeoutError` (default 3600). */
|
|
62
|
+
timeoutSeconds?: number;
|
|
63
|
+
/** Seconds between reads (default 5). */
|
|
64
|
+
pollIntervalSeconds?: number;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* The state of a run when it was read.
|
|
68
|
+
*
|
|
69
|
+
* `status` is the whole run's: `detail.pipeline.status`, which stays `running`
|
|
70
|
+
* until the last step ends even when the first step's execution has completed.
|
|
71
|
+
* A run without pipeline progress keeps `detail.status`. `detail` is the
|
|
72
|
+
* execution detail as the API returned it.
|
|
73
|
+
*/
|
|
74
|
+
interface RunResult {
|
|
75
|
+
readonly executionId: string;
|
|
76
|
+
readonly status: string;
|
|
77
|
+
readonly detail: ExecutionResponseDetail;
|
|
78
|
+
}
|
|
79
|
+
/** The whole pipeline run's status, or the execution's own without pipeline progress. */
|
|
80
|
+
declare function runStatus(detail: ExecutionResponseDetail): string;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* A spec the pipeline routes accept: a typed version 2 spec, or any JSON object
|
|
84
|
+
* (for example a stored version 1 spec), sent unchanged.
|
|
85
|
+
*/
|
|
86
|
+
type PipelineSpecInput = CalibrationPipelineSpec | Record<string, unknown>;
|
|
87
|
+
interface PipelineTarget {
|
|
88
|
+
chipId: string;
|
|
89
|
+
/** Defaults to the configured backend. */
|
|
90
|
+
backendName?: string;
|
|
91
|
+
}
|
|
92
|
+
/** A dispatched pipeline execution, returned by `Pipelines.execute`. */
|
|
93
|
+
declare class PipelineRun {
|
|
94
|
+
private readonly client;
|
|
95
|
+
/** The dispatch response as the API returned it. */
|
|
96
|
+
readonly response: ExecutePipelineResponse;
|
|
97
|
+
constructor(client: QDashClient, response: ExecutePipelineResponse);
|
|
98
|
+
/** The execution the server created for the first step. */
|
|
99
|
+
get executionId(): string;
|
|
100
|
+
/** The current execution detail; `QDashNotFoundError` before it exists. */
|
|
101
|
+
get(): Promise<ExecutionResponseDetail>;
|
|
102
|
+
/**
|
|
103
|
+
* Poll until the whole pipeline run ends and return the raw execution detail.
|
|
104
|
+
* Its outcome is `detail.pipeline.status`, or `detail.status` without pipeline
|
|
105
|
+
* progress. A failed or cancelled run is returned, not thrown.
|
|
106
|
+
*/
|
|
107
|
+
wait(options?: WaitOptions): Promise<ExecutionResponseDetail>;
|
|
108
|
+
}
|
|
109
|
+
/** Calibration pipeline routes, reached as `qdash.pipelines`. */
|
|
110
|
+
declare class Pipelines {
|
|
111
|
+
private readonly client;
|
|
112
|
+
constructor(client: QDashClient);
|
|
113
|
+
/** Step types, task names by type and the spec schema the server accepts. */
|
|
114
|
+
catalog(options?: {
|
|
115
|
+
backendName?: string;
|
|
116
|
+
}): Promise<PipelineCatalogResponse>;
|
|
117
|
+
/**
|
|
118
|
+
* Check a spec against the project, chip and backend without running it. The
|
|
119
|
+
* server reports every problem, including preflight checks that read
|
|
120
|
+
* calibration data, as data; `valid` is false when there is any.
|
|
121
|
+
*/
|
|
122
|
+
validate(spec: PipelineSpecInput, target: PipelineTarget): Promise<ValidatePipelineResponse>;
|
|
123
|
+
/**
|
|
124
|
+
* Dispatch a spec as one execution, which measures on the hardware. The server
|
|
125
|
+
* validates it again and answers 422 (`QDashValidationError`) with the same
|
|
126
|
+
* problems. The run belongs to the session's project, or to the server's
|
|
127
|
+
* default project for the user when none is configured. Returns once
|
|
128
|
+
* dispatched; nothing waits.
|
|
129
|
+
*/
|
|
130
|
+
execute(spec: PipelineSpecInput, target: PipelineTarget): Promise<PipelineRun>;
|
|
131
|
+
}
|
|
132
|
+
/** A dispatched calibration, returned by `Chip.calibrate`. */
|
|
133
|
+
declare class CalibrationRun {
|
|
134
|
+
private readonly run;
|
|
135
|
+
constructor(run: PipelineRun);
|
|
136
|
+
get executionId(): string;
|
|
137
|
+
get response(): ExecutePipelineResponse;
|
|
138
|
+
/** The run's current state; `QDashNotFoundError` before it exists. */
|
|
139
|
+
get(): Promise<RunResult>;
|
|
140
|
+
/** Poll until the whole calibration ends; see `PipelineRun.wait`. */
|
|
141
|
+
wait(options?: WaitOptions): Promise<RunResult>;
|
|
142
|
+
}
|
|
143
|
+
/** Calibration on one chip, reached as `qdash.chip(chipId)`; creating it sends nothing. */
|
|
144
|
+
declare class Chip {
|
|
145
|
+
private readonly pipelines;
|
|
146
|
+
readonly chipId: string;
|
|
147
|
+
constructor(pipelines: Pipelines, chipId: string);
|
|
148
|
+
/**
|
|
149
|
+
* Check a calibration of `targets` on this chip without running it. Takes the
|
|
150
|
+
* same arguments as `calibrate`; nothing is dispatched.
|
|
151
|
+
*/
|
|
152
|
+
validateCalibration(targets: PipelineTargets, steps: readonly CalibrationPipelineSpecStepsItem[], options?: CalibrationOptions): Promise<ValidatePipelineResponse>;
|
|
153
|
+
/**
|
|
154
|
+
* Start a calibration of `targets` on this chip: `steps` run in order as one
|
|
155
|
+
* pipeline execution. Does not call `validateCalibration` first; the server
|
|
156
|
+
* validates before dispatch.
|
|
157
|
+
*/
|
|
158
|
+
calibrate(targets: PipelineTargets, steps: readonly CalibrationPipelineSpecStepsItem[], options?: CalibrationOptions): Promise<CalibrationRun>;
|
|
159
|
+
private target;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Registered workflows of a project: flows saved to QDash, from the UI or
|
|
164
|
+
* `QDashClient.saveFlow`, with a deployment and a target chip. These reach the
|
|
165
|
+
* server's `/flows` routes; nothing is uploaded, registered or run locally.
|
|
166
|
+
*/
|
|
167
|
+
|
|
168
|
+
interface WorkflowRunOptions {
|
|
169
|
+
/** Override the saved `default_parameters` for this run only. */
|
|
170
|
+
parameters?: Record<string, unknown>;
|
|
171
|
+
}
|
|
172
|
+
/** A dispatched workflow run. */
|
|
173
|
+
declare class WorkflowRun {
|
|
174
|
+
private readonly client;
|
|
175
|
+
readonly name: string;
|
|
176
|
+
/** The dispatch response as the API returned it, including `flow_run_id`. */
|
|
177
|
+
readonly response: ExecuteFlowResponse;
|
|
178
|
+
constructor(client: QDashClient, name: string,
|
|
179
|
+
/** The dispatch response as the API returned it, including `flow_run_id`. */
|
|
180
|
+
response: ExecuteFlowResponse);
|
|
181
|
+
get executionId(): string;
|
|
182
|
+
/** The run's current state; `QDashNotFoundError` before it exists. */
|
|
183
|
+
get(): Promise<RunResult>;
|
|
184
|
+
/** Poll until the whole run ends; a failed or cancelled run is returned. */
|
|
185
|
+
wait(options?: WaitOptions): Promise<RunResult>;
|
|
186
|
+
}
|
|
187
|
+
/** A registered workflow as `Workflows.get` read it. */
|
|
188
|
+
declare class Workflow {
|
|
189
|
+
private readonly workflows;
|
|
190
|
+
/** The response as the API returned it, including the source `code`. */
|
|
191
|
+
readonly detail: GetFlowResponse;
|
|
192
|
+
constructor(workflows: Workflows,
|
|
193
|
+
/** The response as the API returned it, including the source `code`. */
|
|
194
|
+
detail: GetFlowResponse);
|
|
195
|
+
get name(): string;
|
|
196
|
+
/** The chip the workflow was saved for. */
|
|
197
|
+
get chipId(): string;
|
|
198
|
+
get description(): string;
|
|
199
|
+
/** The saved parameters a run starts from, not every parameter the flow accepts. */
|
|
200
|
+
get defaultParameters(): Record<string, unknown>;
|
|
201
|
+
/** The same as `qdash.workflows.run(this.name, options)`. */
|
|
202
|
+
run(options?: WorkflowRunOptions): Promise<WorkflowRun>;
|
|
203
|
+
}
|
|
204
|
+
/** The project's registered workflows, reached as `qdash.workflows`. */
|
|
205
|
+
declare class Workflows {
|
|
206
|
+
private readonly client;
|
|
207
|
+
constructor(client: QDashClient);
|
|
208
|
+
/** Summaries of the workflows registered in the session's project. */
|
|
209
|
+
list(): Promise<FlowSummary[]>;
|
|
210
|
+
/** The registered workflow `name`; `QDashNotFoundError` when there is none. */
|
|
211
|
+
get(name: string): Promise<Workflow>;
|
|
212
|
+
/**
|
|
213
|
+
* Dispatch the registered workflow `name`. The server merges `parameters` over
|
|
214
|
+
* the saved defaults and runs on the saved `chip_id` unless the merged
|
|
215
|
+
* parameters carry one. Returns once dispatched.
|
|
216
|
+
*/
|
|
217
|
+
run(name: string, options?: WorkflowRunOptions): Promise<WorkflowRun>;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
interface QDashSessionOptions {
|
|
221
|
+
/**
|
|
222
|
+
* Send this project as `X-Project-Id` on every request of the session. The
|
|
223
|
+
* given client and its configuration are not changed. Without it the session
|
|
224
|
+
* uses the client's configured project, or none, in which case the server
|
|
225
|
+
* applies the user's default project.
|
|
226
|
+
*/
|
|
227
|
+
projectId?: string;
|
|
228
|
+
}
|
|
229
|
+
interface QDashFactoryOptions extends QDashSessionOptions {
|
|
230
|
+
/** Options of the `QDashClient` the session creates, such as a custom `fetch`. */
|
|
231
|
+
clientOptions?: QDashClientOptions;
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Entry point of the QDash SDK: one configured `QDashClient` and the domain
|
|
235
|
+
* operations on it. Creating a session, a chip or a workflow handle sends no
|
|
236
|
+
* request, and the session holds nothing to close.
|
|
237
|
+
*/
|
|
238
|
+
declare class QDash {
|
|
239
|
+
/** The underlying client, for routes the SDK does not wrap. */
|
|
240
|
+
readonly client: QDashClient;
|
|
241
|
+
readonly pipelines: Pipelines;
|
|
242
|
+
readonly workflows: Workflows;
|
|
243
|
+
constructor(client: QDashClient, options?: QDashSessionOptions);
|
|
244
|
+
/** A session configured from `QDASH_*` environment variables. */
|
|
245
|
+
static fromEnv(options?: QDashFactoryOptions & {
|
|
246
|
+
env?: Record<string, string | undefined>;
|
|
247
|
+
}): QDash;
|
|
248
|
+
/** A session configured from a profile of the client's config file. */
|
|
249
|
+
static fromProfile(profile?: string, path?: string, options?: QDashFactoryOptions): Promise<QDash>;
|
|
250
|
+
private static owning;
|
|
251
|
+
/** The project sent as `X-Project-Id`, or undefined for the server's default. */
|
|
252
|
+
get projectId(): string | undefined;
|
|
253
|
+
/** Calibration on `chipId` through this session; sends no request. */
|
|
254
|
+
chip(chipId: string): Chip;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
export { type CalibrationOptions, CalibrationRun, Chip, PipelineRun, type PipelineSpecInput, type PipelineTarget, Pipelines, QDash, type QDashFactoryOptions, type QDashSessionOptions, type RunResult, type SweepDeclaration, type WaitOptions, Workflow, WorkflowRun, type WorkflowRunOptions, Workflows, calibrationSpec, customOneQubit, muxTargets, qubitTargets, runStatus, sweep };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
// src/session.ts
|
|
2
|
+
import {
|
|
3
|
+
QDashClient,
|
|
4
|
+
QDashConfig,
|
|
5
|
+
QDashConfigError
|
|
6
|
+
} from "@oqtopus-team/qdash-client";
|
|
7
|
+
|
|
8
|
+
// src/definitions.ts
|
|
9
|
+
function qubitTargets(qids) {
|
|
10
|
+
if (typeof qids === "string" || !Array.isArray(qids)) {
|
|
11
|
+
throw new TypeError('qubitTargets takes a list of qubit IDs, e.g. qubitTargets(["0", "1"])');
|
|
12
|
+
}
|
|
13
|
+
return { qids: [...qids] };
|
|
14
|
+
}
|
|
15
|
+
function muxTargets(muxIds, options = {}) {
|
|
16
|
+
for (const [name, value] of [
|
|
17
|
+
["muxIds", muxIds],
|
|
18
|
+
["excludeQids", options.excludeQids ?? []]
|
|
19
|
+
]) {
|
|
20
|
+
if (!Array.isArray(value)) throw new TypeError(`muxTargets ${name} must be a list`);
|
|
21
|
+
}
|
|
22
|
+
const excluded = [...options.excludeQids ?? []];
|
|
23
|
+
return excluded.length > 0 ? { mux_ids: [...muxIds], exclude_qids: excluded } : { mux_ids: [...muxIds] };
|
|
24
|
+
}
|
|
25
|
+
function customOneQubit(step) {
|
|
26
|
+
return { type: "CustomOneQubit", ...step };
|
|
27
|
+
}
|
|
28
|
+
function calibrationSpec(targets, steps, options = {}) {
|
|
29
|
+
return {
|
|
30
|
+
spec_version: 2,
|
|
31
|
+
...options.name !== void 0 ? { name: options.name } : {},
|
|
32
|
+
targets,
|
|
33
|
+
steps: [...steps],
|
|
34
|
+
...options.defaultRunParameters !== void 0 ? { default_run_parameters: options.defaultRunParameters } : {},
|
|
35
|
+
...options.tags !== void 0 ? { tags: options.tags } : {}
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function number(constructor, name, value) {
|
|
39
|
+
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
40
|
+
throw new TypeError(`sweep.${constructor} ${name} must be a finite number, got ${String(value)}`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function count(constructor, num) {
|
|
44
|
+
if (typeof num !== "number" || !Number.isInteger(num) || num < 1) {
|
|
45
|
+
throw new RangeError(`sweep.${constructor} num must be a positive integer, got ${String(num)}`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
var sweep = {
|
|
49
|
+
/** Explicit points: `{ value: [p0, p1, ...], value_type: "list" }`. */
|
|
50
|
+
values(...points) {
|
|
51
|
+
if (points.length === 0) throw new RangeError("sweep.values needs at least one point");
|
|
52
|
+
points.forEach((point, index) => number("values", `points[${index}]`, point));
|
|
53
|
+
return { value: points, value_type: "list" };
|
|
54
|
+
},
|
|
55
|
+
/** `numpy.linspace(start, stop, num)`. */
|
|
56
|
+
linspace(start, stop, num) {
|
|
57
|
+
number("linspace", "start", start);
|
|
58
|
+
number("linspace", "stop", stop);
|
|
59
|
+
count("linspace", num);
|
|
60
|
+
return { value: [start, stop, num], value_type: "np.linspace" };
|
|
61
|
+
},
|
|
62
|
+
/** `numpy.logspace(start, stop, num)`; `start` and `stop` are base-10 exponents. */
|
|
63
|
+
logspace(start, stop, num) {
|
|
64
|
+
number("logspace", "start", start);
|
|
65
|
+
number("logspace", "stop", stop);
|
|
66
|
+
count("logspace", num);
|
|
67
|
+
return { value: [start, stop, num], value_type: "np.logspace" };
|
|
68
|
+
},
|
|
69
|
+
/** `numpy.arange(start, stop, step)`. */
|
|
70
|
+
arange(start, stop, step) {
|
|
71
|
+
number("arange", "start", start);
|
|
72
|
+
number("arange", "stop", stop);
|
|
73
|
+
number("arange", "step", step);
|
|
74
|
+
if (step === 0) throw new RangeError("sweep.arange step must not be zero");
|
|
75
|
+
return { value: [start, stop, step], value_type: "np.arange" };
|
|
76
|
+
},
|
|
77
|
+
/** Python `range(start, stop, step)`. */
|
|
78
|
+
range(start, stop, step) {
|
|
79
|
+
for (const [name, value] of [
|
|
80
|
+
["start", start],
|
|
81
|
+
["stop", stop],
|
|
82
|
+
["step", step]
|
|
83
|
+
]) {
|
|
84
|
+
if (!Number.isInteger(value)) {
|
|
85
|
+
throw new TypeError(`sweep.range ${name} must be an integer, got ${String(value)}`);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
if (step === 0) throw new RangeError("sweep.range step must not be zero");
|
|
89
|
+
return { value: [start, stop, step], value_type: "range" };
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
// src/runs.ts
|
|
94
|
+
function runStatus(detail) {
|
|
95
|
+
return detail.pipeline ? detail.pipeline.status : detail.status;
|
|
96
|
+
}
|
|
97
|
+
function runResult(executionId, detail) {
|
|
98
|
+
return Object.freeze({ executionId, status: runStatus(detail), detail });
|
|
99
|
+
}
|
|
100
|
+
function waitForRun(client, executionId, options) {
|
|
101
|
+
return client.waitForExecution(executionId, {
|
|
102
|
+
timeoutSeconds: options.timeoutSeconds ?? 3600,
|
|
103
|
+
pollIntervalSeconds: options.pollIntervalSeconds ?? 5,
|
|
104
|
+
wholePipeline: true,
|
|
105
|
+
notFoundAsPending: true
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// src/pipelines.ts
|
|
110
|
+
function request(spec, target) {
|
|
111
|
+
return {
|
|
112
|
+
chip_id: target.chipId,
|
|
113
|
+
// The request types `spec` as a plain JSON object so the server, not a 422 from
|
|
114
|
+
// request parsing, reports problems; a typed spec is such an object.
|
|
115
|
+
spec,
|
|
116
|
+
...target.backendName ? { backend_name: target.backendName } : {}
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
var PipelineRun = class {
|
|
120
|
+
constructor(client, response) {
|
|
121
|
+
this.client = client;
|
|
122
|
+
this.response = response;
|
|
123
|
+
}
|
|
124
|
+
client;
|
|
125
|
+
/** The dispatch response as the API returned it. */
|
|
126
|
+
response;
|
|
127
|
+
/** The execution the server created for the first step. */
|
|
128
|
+
get executionId() {
|
|
129
|
+
return this.response.execution_id;
|
|
130
|
+
}
|
|
131
|
+
/** The current execution detail; `QDashNotFoundError` before it exists. */
|
|
132
|
+
get() {
|
|
133
|
+
return this.client.getExecution(this.executionId);
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Poll until the whole pipeline run ends and return the raw execution detail.
|
|
137
|
+
* Its outcome is `detail.pipeline.status`, or `detail.status` without pipeline
|
|
138
|
+
* progress. A failed or cancelled run is returned, not thrown.
|
|
139
|
+
*/
|
|
140
|
+
wait(options = {}) {
|
|
141
|
+
return waitForRun(this.client, this.executionId, options);
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
var Pipelines = class {
|
|
145
|
+
constructor(client) {
|
|
146
|
+
this.client = client;
|
|
147
|
+
}
|
|
148
|
+
client;
|
|
149
|
+
/** Step types, task names by type and the spec schema the server accepts. */
|
|
150
|
+
catalog(options = {}) {
|
|
151
|
+
return this.client.api.getCalibrationPipelineCatalog(
|
|
152
|
+
options.backendName ? { backend_name: options.backendName } : void 0
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Check a spec against the project, chip and backend without running it. The
|
|
157
|
+
* server reports every problem, including preflight checks that read
|
|
158
|
+
* calibration data, as data; `valid` is false when there is any.
|
|
159
|
+
*/
|
|
160
|
+
validate(spec, target) {
|
|
161
|
+
return this.client.api.validateCalibrationPipeline(request(spec, target));
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Dispatch a spec as one execution, which measures on the hardware. The server
|
|
165
|
+
* validates it again and answers 422 (`QDashValidationError`) with the same
|
|
166
|
+
* problems. The run belongs to the session's project, or to the server's
|
|
167
|
+
* default project for the user when none is configured. Returns once
|
|
168
|
+
* dispatched; nothing waits.
|
|
169
|
+
*/
|
|
170
|
+
async execute(spec, target) {
|
|
171
|
+
const response = await this.client.api.executeCalibrationPipeline(request(spec, target));
|
|
172
|
+
return new PipelineRun(this.client, response);
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
var CalibrationRun = class {
|
|
176
|
+
constructor(run) {
|
|
177
|
+
this.run = run;
|
|
178
|
+
}
|
|
179
|
+
run;
|
|
180
|
+
get executionId() {
|
|
181
|
+
return this.run.executionId;
|
|
182
|
+
}
|
|
183
|
+
get response() {
|
|
184
|
+
return this.run.response;
|
|
185
|
+
}
|
|
186
|
+
/** The run's current state; `QDashNotFoundError` before it exists. */
|
|
187
|
+
async get() {
|
|
188
|
+
return runResult(this.executionId, await this.run.get());
|
|
189
|
+
}
|
|
190
|
+
/** Poll until the whole calibration ends; see `PipelineRun.wait`. */
|
|
191
|
+
async wait(options = {}) {
|
|
192
|
+
return runResult(this.executionId, await this.run.wait(options));
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
var Chip = class {
|
|
196
|
+
constructor(pipelines, chipId) {
|
|
197
|
+
this.pipelines = pipelines;
|
|
198
|
+
if (typeof chipId !== "string" || !chipId) {
|
|
199
|
+
throw new TypeError("chipId must be a non-empty string");
|
|
200
|
+
}
|
|
201
|
+
this.chipId = chipId;
|
|
202
|
+
}
|
|
203
|
+
pipelines;
|
|
204
|
+
chipId;
|
|
205
|
+
/**
|
|
206
|
+
* Check a calibration of `targets` on this chip without running it. Takes the
|
|
207
|
+
* same arguments as `calibrate`; nothing is dispatched.
|
|
208
|
+
*/
|
|
209
|
+
validateCalibration(targets, steps, options = {}) {
|
|
210
|
+
return this.pipelines.validate(calibrationSpec(targets, steps, options), this.target(options));
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Start a calibration of `targets` on this chip: `steps` run in order as one
|
|
214
|
+
* pipeline execution. Does not call `validateCalibration` first; the server
|
|
215
|
+
* validates before dispatch.
|
|
216
|
+
*/
|
|
217
|
+
async calibrate(targets, steps, options = {}) {
|
|
218
|
+
const run = await this.pipelines.execute(
|
|
219
|
+
calibrationSpec(targets, steps, options),
|
|
220
|
+
this.target(options)
|
|
221
|
+
);
|
|
222
|
+
return new CalibrationRun(run);
|
|
223
|
+
}
|
|
224
|
+
target(options) {
|
|
225
|
+
return { chipId: this.chipId, ...options.backendName ? { backendName: options.backendName } : {} };
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
// src/workflows.ts
|
|
230
|
+
var NAME = /^[A-Za-z0-9_]+$/;
|
|
231
|
+
function checkedName(name) {
|
|
232
|
+
if (typeof name !== "string" || !NAME.test(name)) {
|
|
233
|
+
throw new TypeError(`workflow name must be letters, digits and underscores, got ${JSON.stringify(name)}`);
|
|
234
|
+
}
|
|
235
|
+
return name;
|
|
236
|
+
}
|
|
237
|
+
var WorkflowRun = class {
|
|
238
|
+
constructor(client, name, response) {
|
|
239
|
+
this.client = client;
|
|
240
|
+
this.name = name;
|
|
241
|
+
this.response = response;
|
|
242
|
+
}
|
|
243
|
+
client;
|
|
244
|
+
name;
|
|
245
|
+
response;
|
|
246
|
+
get executionId() {
|
|
247
|
+
return this.response.execution_id;
|
|
248
|
+
}
|
|
249
|
+
/** The run's current state; `QDashNotFoundError` before it exists. */
|
|
250
|
+
async get() {
|
|
251
|
+
return runResult(this.executionId, await this.client.getExecution(this.executionId));
|
|
252
|
+
}
|
|
253
|
+
/** Poll until the whole run ends; a failed or cancelled run is returned. */
|
|
254
|
+
async wait(options = {}) {
|
|
255
|
+
return runResult(this.executionId, await waitForRun(this.client, this.executionId, options));
|
|
256
|
+
}
|
|
257
|
+
};
|
|
258
|
+
var Workflow = class {
|
|
259
|
+
constructor(workflows, detail) {
|
|
260
|
+
this.workflows = workflows;
|
|
261
|
+
this.detail = detail;
|
|
262
|
+
}
|
|
263
|
+
workflows;
|
|
264
|
+
detail;
|
|
265
|
+
get name() {
|
|
266
|
+
return this.detail.name;
|
|
267
|
+
}
|
|
268
|
+
/** The chip the workflow was saved for. */
|
|
269
|
+
get chipId() {
|
|
270
|
+
return this.detail.chip_id;
|
|
271
|
+
}
|
|
272
|
+
get description() {
|
|
273
|
+
return this.detail.description;
|
|
274
|
+
}
|
|
275
|
+
/** The saved parameters a run starts from, not every parameter the flow accepts. */
|
|
276
|
+
get defaultParameters() {
|
|
277
|
+
return { ...this.detail.default_parameters };
|
|
278
|
+
}
|
|
279
|
+
/** The same as `qdash.workflows.run(this.name, options)`. */
|
|
280
|
+
run(options = {}) {
|
|
281
|
+
return this.workflows.run(this.name, options);
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
var Workflows = class {
|
|
285
|
+
constructor(client) {
|
|
286
|
+
this.client = client;
|
|
287
|
+
}
|
|
288
|
+
client;
|
|
289
|
+
/** Summaries of the workflows registered in the session's project. */
|
|
290
|
+
async list() {
|
|
291
|
+
return (await this.client.listFlows()).flows;
|
|
292
|
+
}
|
|
293
|
+
/** The registered workflow `name`; `QDashNotFoundError` when there is none. */
|
|
294
|
+
async get(name) {
|
|
295
|
+
return new Workflow(this, await this.client.getFlow(checkedName(name)));
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Dispatch the registered workflow `name`. The server merges `parameters` over
|
|
299
|
+
* the saved defaults and runs on the saved `chip_id` unless the merged
|
|
300
|
+
* parameters carry one. Returns once dispatched.
|
|
301
|
+
*/
|
|
302
|
+
async run(name, options = {}) {
|
|
303
|
+
const checked = checkedName(name);
|
|
304
|
+
const response = await this.client.executeFlow(checked, { ...options.parameters ?? {} });
|
|
305
|
+
return new WorkflowRun(this.client, checked, response);
|
|
306
|
+
}
|
|
307
|
+
};
|
|
308
|
+
|
|
309
|
+
// src/session.ts
|
|
310
|
+
function checkedProject(projectId) {
|
|
311
|
+
if (projectId !== void 0 && (typeof projectId !== "string" || !projectId)) {
|
|
312
|
+
throw new QDashConfigError("projectId must be a non-empty string");
|
|
313
|
+
}
|
|
314
|
+
return projectId;
|
|
315
|
+
}
|
|
316
|
+
var QDash = class _QDash {
|
|
317
|
+
/** The underlying client, for routes the SDK does not wrap. */
|
|
318
|
+
client;
|
|
319
|
+
pipelines;
|
|
320
|
+
workflows;
|
|
321
|
+
constructor(client, options = {}) {
|
|
322
|
+
const projectId = checkedProject(options.projectId);
|
|
323
|
+
this.client = projectId !== void 0 ? client.withProject(projectId) : client;
|
|
324
|
+
this.pipelines = new Pipelines(this.client);
|
|
325
|
+
this.workflows = new Workflows(this.client);
|
|
326
|
+
}
|
|
327
|
+
/** A session configured from `QDASH_*` environment variables. */
|
|
328
|
+
static fromEnv(options = {}) {
|
|
329
|
+
const env = options.env ?? process.env;
|
|
330
|
+
return _QDash.owning(QDashConfig.fromEnv(env), options, env);
|
|
331
|
+
}
|
|
332
|
+
/** A session configured from a profile of the client's config file. */
|
|
333
|
+
static async fromProfile(profile = "default", path, options = {}) {
|
|
334
|
+
const config = path ? await QDashConfig.fromFile(profile, path) : await QDashConfig.fromFile(profile);
|
|
335
|
+
return _QDash.owning(config, options);
|
|
336
|
+
}
|
|
337
|
+
static owning(config, options, env) {
|
|
338
|
+
const projectId = checkedProject(options.projectId);
|
|
339
|
+
const scoped = projectId !== void 0 ? new QDashConfig({ ...config, projectId }) : config;
|
|
340
|
+
const clientOptions = env ? { ...options.clientOptions, env } : options.clientOptions ?? {};
|
|
341
|
+
return new _QDash(new QDashClient(scoped, clientOptions));
|
|
342
|
+
}
|
|
343
|
+
/** The project sent as `X-Project-Id`, or undefined for the server's default. */
|
|
344
|
+
get projectId() {
|
|
345
|
+
return this.client.config.projectId;
|
|
346
|
+
}
|
|
347
|
+
/** Calibration on `chipId` through this session; sends no request. */
|
|
348
|
+
chip(chipId) {
|
|
349
|
+
return new Chip(this.pipelines, chipId);
|
|
350
|
+
}
|
|
351
|
+
};
|
|
352
|
+
|
|
353
|
+
// src/index.ts
|
|
354
|
+
import {
|
|
355
|
+
QDashApiError,
|
|
356
|
+
QDashAuthError,
|
|
357
|
+
QDashConfigError as QDashConfigError2,
|
|
358
|
+
QDashNotFoundError,
|
|
359
|
+
QDashTimeoutError,
|
|
360
|
+
QDashTransportError,
|
|
361
|
+
QDashValidationError
|
|
362
|
+
} from "@oqtopus-team/qdash-client";
|
|
363
|
+
export {
|
|
364
|
+
CalibrationRun,
|
|
365
|
+
Chip,
|
|
366
|
+
PipelineRun,
|
|
367
|
+
Pipelines,
|
|
368
|
+
QDash,
|
|
369
|
+
QDashApiError,
|
|
370
|
+
QDashAuthError,
|
|
371
|
+
QDashConfigError2 as QDashConfigError,
|
|
372
|
+
QDashNotFoundError,
|
|
373
|
+
QDashTimeoutError,
|
|
374
|
+
QDashTransportError,
|
|
375
|
+
QDashValidationError,
|
|
376
|
+
Workflow,
|
|
377
|
+
WorkflowRun,
|
|
378
|
+
Workflows,
|
|
379
|
+
calibrationSpec,
|
|
380
|
+
customOneQubit,
|
|
381
|
+
muxTargets,
|
|
382
|
+
qubitTargets,
|
|
383
|
+
runStatus,
|
|
384
|
+
sweep
|
|
385
|
+
};
|
|
386
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/session.ts","../src/definitions.ts","../src/runs.ts","../src/pipelines.ts","../src/workflows.ts","../src/index.ts"],"sourcesContent":["import {\n QDashClient,\n QDashConfig,\n QDashConfigError,\n type QDashClientOptions,\n} from \"@oqtopus-team/qdash-client\";\n\nimport { Chip, Pipelines } from \"./pipelines.js\";\nimport { Workflows } from \"./workflows.js\";\n\nexport interface QDashSessionOptions {\n /**\n * Send this project as `X-Project-Id` on every request of the session. The\n * given client and its configuration are not changed. Without it the session\n * uses the client's configured project, or none, in which case the server\n * applies the user's default project.\n */\n projectId?: string;\n}\n\nexport interface QDashFactoryOptions extends QDashSessionOptions {\n /** Options of the `QDashClient` the session creates, such as a custom `fetch`. */\n clientOptions?: QDashClientOptions;\n}\n\nfunction checkedProject(projectId: string | undefined): string | undefined {\n if (projectId !== undefined && (typeof projectId !== \"string\" || !projectId)) {\n throw new QDashConfigError(\"projectId must be a non-empty string\");\n }\n return projectId;\n}\n\n/**\n * Entry point of the QDash SDK: one configured `QDashClient` and the domain\n * operations on it. Creating a session, a chip or a workflow handle sends no\n * request, and the session holds nothing to close.\n */\nexport class QDash {\n /** The underlying client, for routes the SDK does not wrap. */\n readonly client: QDashClient;\n readonly pipelines: Pipelines;\n readonly workflows: Workflows;\n\n constructor(client: QDashClient, options: QDashSessionOptions = {}) {\n const projectId = checkedProject(options.projectId);\n this.client = projectId !== undefined ? client.withProject(projectId) : client;\n this.pipelines = new Pipelines(this.client);\n this.workflows = new Workflows(this.client);\n }\n\n /** A session configured from `QDASH_*` environment variables. */\n static fromEnv(\n options: QDashFactoryOptions & { env?: Record<string, string | undefined> } = {},\n ): QDash {\n const env = options.env ?? process.env;\n return QDash.owning(QDashConfig.fromEnv(env), options, env);\n }\n\n /** A session configured from a profile of the client's config file. */\n static async fromProfile(\n profile = \"default\",\n path?: string,\n options: QDashFactoryOptions = {},\n ): Promise<QDash> {\n const config = path\n ? await QDashConfig.fromFile(profile, path)\n : await QDashConfig.fromFile(profile);\n return QDash.owning(config, options);\n }\n\n private static owning(\n config: QDashConfig,\n options: QDashFactoryOptions,\n env?: Record<string, string | undefined>,\n ): QDash {\n const projectId = checkedProject(options.projectId);\n const scoped = projectId !== undefined ? new QDashConfig({ ...config, projectId }) : config;\n const clientOptions = env ? { ...options.clientOptions, env } : (options.clientOptions ?? {});\n return new QDash(new QDashClient(scoped, clientOptions));\n }\n\n /** The project sent as `X-Project-Id`, or undefined for the server's default. */\n get projectId(): string | undefined {\n return this.client.config.projectId;\n }\n\n /** Calibration on `chipId` through this session; sends no request. */\n chip(chipId: string): Chip {\n return new Chip(this.pipelines, chipId);\n }\n}\n","/**\n * Small builders for the generated pipeline spec types.\n *\n * Targets, steps and task calls are the API's own generated types\n * (`PipelineTargets`, `CustomOneQubitStep`, `TaskCall`, ...), written in the\n * spec's JSON form with its snake_case keys; object literals of those types are\n * always accepted. These helpers only fill in what is tedious to write: the\n * target shape, a step's `type` and sweep declarations. They send nothing, and\n * leave every rule beyond the obvious shape to the server's validate route.\n */\nimport type {\n CalibrationPipelineSpec,\n CalibrationPipelineSpecStepsItem,\n CustomOneQubitStep,\n PipelineTargets,\n} from \"@oqtopus-team/qdash-client/models\";\n\n/** Explicit target qubits by the IDs QDash lists: `{ qids: [...] }`. */\nexport function qubitTargets(qids: readonly string[]): PipelineTargets {\n if (typeof qids === \"string\" || !Array.isArray(qids)) {\n throw new TypeError('qubitTargets takes a list of qubit IDs, e.g. qubitTargets([\"0\", \"1\"])');\n }\n return { qids: [...qids] };\n}\n\n/** Every qubit of the given MUXes: `{ mux_ids: [...], exclude_qids?: [...] }`. */\nexport function muxTargets(\n muxIds: readonly number[],\n options: { excludeQids?: readonly string[] } = {},\n): PipelineTargets {\n for (const [name, value] of [\n [\"muxIds\", muxIds],\n [\"excludeQids\", options.excludeQids ?? []],\n ] as const) {\n if (!Array.isArray(value)) throw new TypeError(`muxTargets ${name} must be a list`);\n }\n const excluded = [...(options.excludeQids ?? [])];\n return excluded.length > 0 ? { mux_ids: [...muxIds], exclude_qids: excluded } : { mux_ids: [...muxIds] };\n}\n\n/** A `CustomOneQubit` step: its task calls, in order, on every candidate qubit. */\nexport function customOneQubit(step: Omit<CustomOneQubitStep, \"type\">): CustomOneQubitStep {\n return { type: \"CustomOneQubit\", ...step };\n}\n\n/** Top-level spec fields a calibration may set; the server defaults the rest. */\nexport interface CalibrationOptions {\n /** The execution's display name. */\n name?: string;\n /** Run parameters every task call starts from, e.g. shots or interval. */\n defaultRunParameters?: Record<string, unknown>;\n tags?: string[];\n /** Defaults to the configured backend. */\n backendName?: string;\n}\n\n/** The spec version 2 object for `targets` and `steps`, with only the options given. */\nexport function calibrationSpec(\n targets: PipelineTargets,\n steps: readonly CalibrationPipelineSpecStepsItem[],\n options: CalibrationOptions = {},\n): CalibrationPipelineSpec {\n return {\n spec_version: 2,\n ...(options.name !== undefined ? { name: options.name } : {}),\n targets,\n steps: [...steps],\n ...(options.defaultRunParameters !== undefined\n ? { default_run_parameters: options.defaultRunParameters }\n : {}),\n ...(options.tags !== undefined ? { tags: options.tags } : {}),\n };\n}\n\n/** A swept run parameter in the spec's wire format; the worker expands it. */\nexport interface SweepDeclaration {\n value: number[];\n value_type: \"list\" | \"np.linspace\" | \"np.logspace\" | \"np.arange\" | \"range\";\n}\n\nfunction number(constructor: string, name: string, value: unknown): void {\n if (typeof value !== \"number\" || !Number.isFinite(value)) {\n throw new TypeError(`sweep.${constructor} ${name} must be a finite number, got ${String(value)}`);\n }\n}\n\nfunction count(constructor: string, num: unknown): void {\n if (typeof num !== \"number\" || !Number.isInteger(num) || num < 1) {\n throw new RangeError(`sweep.${constructor} num must be a positive integer, got ${String(num)}`);\n }\n}\n\n/**\n * Sweep declarations, constructor for constructor as `qdash.workflow.sweep` and\n * the Python SDK write them. Nothing is expanded locally.\n */\nexport const sweep = {\n /** Explicit points: `{ value: [p0, p1, ...], value_type: \"list\" }`. */\n values(...points: number[]): SweepDeclaration {\n if (points.length === 0) throw new RangeError(\"sweep.values needs at least one point\");\n points.forEach((point, index) => number(\"values\", `points[${index}]`, point));\n return { value: points, value_type: \"list\" };\n },\n /** `numpy.linspace(start, stop, num)`. */\n linspace(start: number, stop: number, num: number): SweepDeclaration {\n number(\"linspace\", \"start\", start);\n number(\"linspace\", \"stop\", stop);\n count(\"linspace\", num);\n return { value: [start, stop, num], value_type: \"np.linspace\" };\n },\n /** `numpy.logspace(start, stop, num)`; `start` and `stop` are base-10 exponents. */\n logspace(start: number, stop: number, num: number): SweepDeclaration {\n number(\"logspace\", \"start\", start);\n number(\"logspace\", \"stop\", stop);\n count(\"logspace\", num);\n return { value: [start, stop, num], value_type: \"np.logspace\" };\n },\n /** `numpy.arange(start, stop, step)`. */\n arange(start: number, stop: number, step: number): SweepDeclaration {\n number(\"arange\", \"start\", start);\n number(\"arange\", \"stop\", stop);\n number(\"arange\", \"step\", step);\n if (step === 0) throw new RangeError(\"sweep.arange step must not be zero\");\n return { value: [start, stop, step], value_type: \"np.arange\" };\n },\n /** Python `range(start, stop, step)`. */\n range(start: number, stop: number, step: number): SweepDeclaration {\n for (const [name, value] of [\n [\"start\", start],\n [\"stop\", stop],\n [\"step\", step],\n ] as const) {\n if (!Number.isInteger(value)) {\n throw new TypeError(`sweep.range ${name} must be an integer, got ${String(value)}`);\n }\n }\n if (step === 0) throw new RangeError(\"sweep.range step must not be zero\");\n return { value: [start, stop, step], value_type: \"range\" };\n },\n} as const;\n","import type { QDashClient } from \"@oqtopus-team/qdash-client\";\nimport type { ExecutionResponseDetail } from \"@oqtopus-team/qdash-client/models\";\n\n/** How long `wait()` polls `GET /executions/{id}`; the run is never cancelled. */\nexport interface WaitOptions {\n /** Give up after this many seconds with `QDashTimeoutError` (default 3600). */\n timeoutSeconds?: number;\n /** Seconds between reads (default 5). */\n pollIntervalSeconds?: number;\n}\n\n/**\n * The state of a run when it was read.\n *\n * `status` is the whole run's: `detail.pipeline.status`, which stays `running`\n * until the last step ends even when the first step's execution has completed.\n * A run without pipeline progress keeps `detail.status`. `detail` is the\n * execution detail as the API returned it.\n */\nexport interface RunResult {\n readonly executionId: string;\n readonly status: string;\n readonly detail: ExecutionResponseDetail;\n}\n\n/** The whole pipeline run's status, or the execution's own without pipeline progress. */\nexport function runStatus(detail: ExecutionResponseDetail): string {\n return detail.pipeline ? detail.pipeline.status : detail.status;\n}\n\nexport function runResult(executionId: string, detail: ExecutionResponseDetail): RunResult {\n return Object.freeze({ executionId, status: runStatus(detail), detail });\n}\n\n/**\n * Poll until the whole run ends. An execution not listed yet (404) is read again;\n * a failed or cancelled run is returned; `QDashTimeoutError` leaves the run going.\n */\nexport function waitForRun(\n client: QDashClient,\n executionId: string,\n options: WaitOptions,\n): Promise<ExecutionResponseDetail> {\n return client.waitForExecution(executionId, {\n timeoutSeconds: options.timeoutSeconds ?? 3600,\n pollIntervalSeconds: options.pollIntervalSeconds ?? 5,\n wholePipeline: true,\n notFoundAsPending: true,\n });\n}\n","import type { QDashClient } from \"@oqtopus-team/qdash-client\";\nimport type {\n CalibrationPipelineSpec,\n CalibrationPipelineSpecStepsItem,\n ExecutePipelineResponse,\n ExecutionResponseDetail,\n PipelineCatalogResponse,\n PipelineTargets,\n ValidatePipelineResponse,\n} from \"@oqtopus-team/qdash-client/models\";\n\nimport { calibrationSpec, type CalibrationOptions } from \"./definitions.js\";\nimport { runResult, waitForRun, type RunResult, type WaitOptions } from \"./runs.js\";\n\n/**\n * A spec the pipeline routes accept: a typed version 2 spec, or any JSON object\n * (for example a stored version 1 spec), sent unchanged.\n */\nexport type PipelineSpecInput = CalibrationPipelineSpec | Record<string, unknown>;\n\nexport interface PipelineTarget {\n chipId: string;\n /** Defaults to the configured backend. */\n backendName?: string;\n}\n\nfunction request(spec: PipelineSpecInput, target: PipelineTarget) {\n return {\n chip_id: target.chipId,\n // The request types `spec` as a plain JSON object so the server, not a 422 from\n // request parsing, reports problems; a typed spec is such an object.\n spec: spec as Record<string, unknown>,\n ...(target.backendName ? { backend_name: target.backendName } : {}),\n };\n}\n\n/** A dispatched pipeline execution, returned by `Pipelines.execute`. */\nexport class PipelineRun {\n /** The dispatch response as the API returned it. */\n readonly response: ExecutePipelineResponse;\n\n constructor(\n private readonly client: QDashClient,\n response: ExecutePipelineResponse,\n ) {\n this.response = response;\n }\n\n /** The execution the server created for the first step. */\n get executionId(): string {\n return this.response.execution_id;\n }\n\n /** The current execution detail; `QDashNotFoundError` before it exists. */\n get(): Promise<ExecutionResponseDetail> {\n return this.client.getExecution(this.executionId);\n }\n\n /**\n * Poll until the whole pipeline run ends and return the raw execution detail.\n * Its outcome is `detail.pipeline.status`, or `detail.status` without pipeline\n * progress. A failed or cancelled run is returned, not thrown.\n */\n wait(options: WaitOptions = {}): Promise<ExecutionResponseDetail> {\n return waitForRun(this.client, this.executionId, options);\n }\n}\n\n/** Calibration pipeline routes, reached as `qdash.pipelines`. */\nexport class Pipelines {\n constructor(private readonly client: QDashClient) {}\n\n /** Step types, task names by type and the spec schema the server accepts. */\n catalog(options: { backendName?: string } = {}): Promise<PipelineCatalogResponse> {\n return this.client.api.getCalibrationPipelineCatalog(\n options.backendName ? { backend_name: options.backendName } : undefined,\n );\n }\n\n /**\n * Check a spec against the project, chip and backend without running it. The\n * server reports every problem, including preflight checks that read\n * calibration data, as data; `valid` is false when there is any.\n */\n validate(spec: PipelineSpecInput, target: PipelineTarget): Promise<ValidatePipelineResponse> {\n return this.client.api.validateCalibrationPipeline(request(spec, target));\n }\n\n /**\n * Dispatch a spec as one execution, which measures on the hardware. The server\n * validates it again and answers 422 (`QDashValidationError`) with the same\n * problems. The run belongs to the session's project, or to the server's\n * default project for the user when none is configured. Returns once\n * dispatched; nothing waits.\n */\n async execute(spec: PipelineSpecInput, target: PipelineTarget): Promise<PipelineRun> {\n const response = await this.client.api.executeCalibrationPipeline(request(spec, target));\n return new PipelineRun(this.client, response);\n }\n}\n\n/** A dispatched calibration, returned by `Chip.calibrate`. */\nexport class CalibrationRun {\n constructor(private readonly run: PipelineRun) {}\n\n get executionId(): string {\n return this.run.executionId;\n }\n\n get response(): ExecutePipelineResponse {\n return this.run.response;\n }\n\n /** The run's current state; `QDashNotFoundError` before it exists. */\n async get(): Promise<RunResult> {\n return runResult(this.executionId, await this.run.get());\n }\n\n /** Poll until the whole calibration ends; see `PipelineRun.wait`. */\n async wait(options: WaitOptions = {}): Promise<RunResult> {\n return runResult(this.executionId, await this.run.wait(options));\n }\n}\n\n/** Calibration on one chip, reached as `qdash.chip(chipId)`; creating it sends nothing. */\nexport class Chip {\n readonly chipId: string;\n\n constructor(\n private readonly pipelines: Pipelines,\n chipId: string,\n ) {\n if (typeof chipId !== \"string\" || !chipId) {\n throw new TypeError(\"chipId must be a non-empty string\");\n }\n this.chipId = chipId;\n }\n\n /**\n * Check a calibration of `targets` on this chip without running it. Takes the\n * same arguments as `calibrate`; nothing is dispatched.\n */\n validateCalibration(\n targets: PipelineTargets,\n steps: readonly CalibrationPipelineSpecStepsItem[],\n options: CalibrationOptions = {},\n ): Promise<ValidatePipelineResponse> {\n return this.pipelines.validate(calibrationSpec(targets, steps, options), this.target(options));\n }\n\n /**\n * Start a calibration of `targets` on this chip: `steps` run in order as one\n * pipeline execution. Does not call `validateCalibration` first; the server\n * validates before dispatch.\n */\n async calibrate(\n targets: PipelineTargets,\n steps: readonly CalibrationPipelineSpecStepsItem[],\n options: CalibrationOptions = {},\n ): Promise<CalibrationRun> {\n const run = await this.pipelines.execute(\n calibrationSpec(targets, steps, options),\n this.target(options),\n );\n return new CalibrationRun(run);\n }\n\n private target(options: CalibrationOptions): PipelineTarget {\n return { chipId: this.chipId, ...(options.backendName ? { backendName: options.backendName } : {}) };\n }\n}\n","/**\n * Registered workflows of a project: flows saved to QDash, from the UI or\n * `QDashClient.saveFlow`, with a deployment and a target chip. These reach the\n * server's `/flows` routes; nothing is uploaded, registered or run locally.\n */\nimport type { QDashClient } from \"@oqtopus-team/qdash-client\";\nimport type { ExecuteFlowResponse, FlowSummary, GetFlowResponse } from \"@oqtopus-team/qdash-client/models\";\n\nimport { runResult, waitForRun, type RunResult, type WaitOptions } from \"./runs.js\";\n\n// The names the server accepts when a flow is saved; anything else is rejected\n// before it becomes part of a request path.\nconst NAME = /^[A-Za-z0-9_]+$/;\n\nfunction checkedName(name: string): string {\n if (typeof name !== \"string\" || !NAME.test(name)) {\n throw new TypeError(`workflow name must be letters, digits and underscores, got ${JSON.stringify(name)}`);\n }\n return name;\n}\n\nexport interface WorkflowRunOptions {\n /** Override the saved `default_parameters` for this run only. */\n parameters?: Record<string, unknown>;\n}\n\n/** A dispatched workflow run. */\nexport class WorkflowRun {\n constructor(\n private readonly client: QDashClient,\n readonly name: string,\n /** The dispatch response as the API returned it, including `flow_run_id`. */\n readonly response: ExecuteFlowResponse,\n ) {}\n\n get executionId(): string {\n return this.response.execution_id;\n }\n\n /** The run's current state; `QDashNotFoundError` before it exists. */\n async get(): Promise<RunResult> {\n return runResult(this.executionId, await this.client.getExecution(this.executionId));\n }\n\n /** Poll until the whole run ends; a failed or cancelled run is returned. */\n async wait(options: WaitOptions = {}): Promise<RunResult> {\n return runResult(this.executionId, await waitForRun(this.client, this.executionId, options));\n }\n}\n\n/** A registered workflow as `Workflows.get` read it. */\nexport class Workflow {\n constructor(\n private readonly workflows: Workflows,\n /** The response as the API returned it, including the source `code`. */\n readonly detail: GetFlowResponse,\n ) {}\n\n get name(): string {\n return this.detail.name;\n }\n\n /** The chip the workflow was saved for. */\n get chipId(): string {\n return this.detail.chip_id;\n }\n\n get description(): string {\n return this.detail.description;\n }\n\n /** The saved parameters a run starts from, not every parameter the flow accepts. */\n get defaultParameters(): Record<string, unknown> {\n return { ...this.detail.default_parameters };\n }\n\n /** The same as `qdash.workflows.run(this.name, options)`. */\n run(options: WorkflowRunOptions = {}): Promise<WorkflowRun> {\n return this.workflows.run(this.name, options);\n }\n}\n\n/** The project's registered workflows, reached as `qdash.workflows`. */\nexport class Workflows {\n constructor(private readonly client: QDashClient) {}\n\n /** Summaries of the workflows registered in the session's project. */\n async list(): Promise<FlowSummary[]> {\n return (await this.client.listFlows()).flows;\n }\n\n /** The registered workflow `name`; `QDashNotFoundError` when there is none. */\n async get(name: string): Promise<Workflow> {\n return new Workflow(this, await this.client.getFlow(checkedName(name)));\n }\n\n /**\n * Dispatch the registered workflow `name`. The server merges `parameters` over\n * the saved defaults and runs on the saved `chip_id` unless the merged\n * parameters carry one. Returns once dispatched.\n */\n async run(name: string, options: WorkflowRunOptions = {}): Promise<WorkflowRun> {\n const checked = checkedName(name);\n const response = await this.client.executeFlow(checked, { ...(options.parameters ?? {}) });\n return new WorkflowRun(this.client, checked, response);\n }\n}\n","/**\n * `@oqtopus-team/qdash-sdk`: validate and start calibrations and registered\n * workflows through the QDash API, modelled on the Python `qdash.sdk`.\n *\n * `new QDash(client)` or `QDash.fromEnv()` wrap a `QDashClient` from\n * `@oqtopus-team/qdash-client` and reuse its configuration, authentication,\n * project, transport and errors; the error classes below are the client's own.\n * `qdash.chip(chipId)` validates (`validateCalibration`) or dispatches\n * (`calibrate`) a calibration; `qdash.workflows` lists, reads and runs the\n * project's registered workflows; `qdash.pipelines` works with whole specs.\n */\nexport { QDash } from \"./session.js\";\nexport type { QDashFactoryOptions, QDashSessionOptions } from \"./session.js\";\nexport { CalibrationRun, Chip, PipelineRun, Pipelines } from \"./pipelines.js\";\nexport type { PipelineSpecInput, PipelineTarget } from \"./pipelines.js\";\nexport { Workflow, WorkflowRun, Workflows } from \"./workflows.js\";\nexport type { WorkflowRunOptions } from \"./workflows.js\";\nexport { runStatus } from \"./runs.js\";\nexport type { RunResult, WaitOptions } from \"./runs.js\";\nexport { calibrationSpec, customOneQubit, muxTargets, qubitTargets, sweep } from \"./definitions.js\";\nexport type { CalibrationOptions, SweepDeclaration } from \"./definitions.js\";\nexport {\n QDashApiError,\n QDashAuthError,\n QDashConfigError,\n QDashNotFoundError,\n QDashTimeoutError,\n QDashTransportError,\n QDashValidationError,\n} from \"@oqtopus-team/qdash-client\";\nexport type {\n CalibrationPipelineSpec,\n CalibrationPipelineSpecStepsItem,\n CustomOneQubitStep,\n ExecuteFlowResponse,\n ExecutePipelineResponse,\n ExecutionResponseDetail,\n FlowSummary,\n GetFlowResponse,\n PipelineCatalogResponse,\n PipelineProblem,\n PipelineTargets,\n TaskCall,\n ValidatePipelineResponse,\n} from \"@oqtopus-team/qdash-client/models\";\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAEK;;;ACaA,SAAS,aAAa,MAA0C;AACrE,MAAI,OAAO,SAAS,YAAY,CAAC,MAAM,QAAQ,IAAI,GAAG;AACpD,UAAM,IAAI,UAAU,uEAAuE;AAAA,EAC7F;AACA,SAAO,EAAE,MAAM,CAAC,GAAG,IAAI,EAAE;AAC3B;AAGO,SAAS,WACd,QACA,UAA+C,CAAC,GAC/B;AACjB,aAAW,CAAC,MAAM,KAAK,KAAK;AAAA,IAC1B,CAAC,UAAU,MAAM;AAAA,IACjB,CAAC,eAAe,QAAQ,eAAe,CAAC,CAAC;AAAA,EAC3C,GAAY;AACV,QAAI,CAAC,MAAM,QAAQ,KAAK,EAAG,OAAM,IAAI,UAAU,cAAc,IAAI,iBAAiB;AAAA,EACpF;AACA,QAAM,WAAW,CAAC,GAAI,QAAQ,eAAe,CAAC,CAAE;AA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,WAAO,OAAM,OAAO,YAAY,QAAQ,GAAG,GAAG,SAAS,GAAG;AAAA,EAC5D;AAAA;AAAA,EAGA,aAAa,YACX,UAAU,WACV,MACA,UAA+B,CAAC,GAChB;AAChB,UAAM,SAAS,OACX,MAAM,YAAY,SAAS,SAAS,IAAI,IACxC,MAAM,YAAY,SAAS,OAAO;AACtC,WAAO,OAAM,OAAO,QAAQ,OAAO;AAAA,EACrC;AAAA,EAEA,OAAe,OACb,QACA,SACA,KACO;AACP,UAAM,YAAY,eAAe,QAAQ,SAAS;AAClD,UAAM,SAAS,cAAc,SAAY,IAAI,YAAY,EAAE,GAAG,QAAQ,UAAU,CAAC,IAAI;AACrF,UAAM,gBAAgB,MAAM,EAAE,GAAG,QAAQ,eAAe,IAAI,IAAK,QAAQ,iBAAiB,CAAC;AAC3F,WAAO,IAAI,OAAM,IAAI,YAAY,QAAQ,aAAa,CAAC;AAAA,EACzD;AAAA;AAAA,EAGA,IAAI,YAAgC;AAClC,WAAO,KAAK,OAAO,OAAO;AAAA,EAC5B;AAAA;AAAA,EAGA,KAAK,QAAsB;AACzB,WAAO,IAAI,KAAK,KAAK,WAAW,MAAM;AAAA,EACxC;AACF;;;AKrEA;AAAA,EACE;AAAA,EACA;AAAA,EACA,oBAAAA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;","names":["QDashConfigError"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,47 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oqtopus-team/qdash-sdk",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
6
|
-
|
|
3
|
+
"version": "1.10.5-beta.1289",
|
|
4
|
+
"packageManager": "bun@1.4.0",
|
|
5
|
+
"description": "TypeScript SDK for QDash calibrations and registered workflows, built on @oqtopus-team/qdash-client",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"license": "Apache-2.0",
|
|
8
|
+
"author": "OQTOPUS Team <oqtopus-team@googlegroups.com>",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/oqtopus-team/qdash.git",
|
|
12
|
+
"directory": "sdks/typescript"
|
|
13
|
+
},
|
|
14
|
+
"homepage": "https://oqtopus-team.github.io/qdash/",
|
|
15
|
+
"bugs": "https://github.com/oqtopus-team/qdash/issues",
|
|
16
|
+
"engines": {
|
|
17
|
+
"node": ">=20.0.0"
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist",
|
|
21
|
+
"README.md",
|
|
22
|
+
"LICENSE"
|
|
23
|
+
],
|
|
24
|
+
"main": "./dist/index.js",
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"exports": {
|
|
27
|
+
".": {
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
29
|
+
"import": "./dist/index.js"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"scripts": {
|
|
33
|
+
"build": "tsup src/index.ts --format esm --dts --sourcemap --clean --out-dir dist --external @oqtopus-team/qdash-client",
|
|
34
|
+
"check": "tsc --noEmit && vitest run",
|
|
35
|
+
"prepack": "bun run build",
|
|
36
|
+
"test": "vitest run"
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@oqtopus-team/qdash-client": "1.10.5-beta.1289"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@types/node": "^24.0.0",
|
|
43
|
+
"tsup": "^8.5.0",
|
|
44
|
+
"typescript": "^5.8.0",
|
|
45
|
+
"vitest": "^4.1.11"
|
|
46
|
+
}
|
|
47
|
+
}
|