qdash-sdk 1.10.5b1287__tar.gz
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.
- qdash_sdk-1.10.5b1287/.gitignore +258 -0
- qdash_sdk-1.10.5b1287/PKG-INFO +60 -0
- qdash_sdk-1.10.5b1287/README.md +51 -0
- qdash_sdk-1.10.5b1287/hatch_build.py +32 -0
- qdash_sdk-1.10.5b1287/pyproject.toml +49 -0
- qdash_sdk-1.10.5b1287/src/qdash/sdk/__init__.py +40 -0
- qdash_sdk-1.10.5b1287/src/qdash/sdk/_calibration.py +149 -0
- qdash_sdk-1.10.5b1287/src/qdash/sdk/_pipelines.py +113 -0
- qdash_sdk-1.10.5b1287/src/qdash/sdk/_runs.py +32 -0
- qdash_sdk-1.10.5b1287/src/qdash/sdk/_session.py +92 -0
- qdash_sdk-1.10.5b1287/src/qdash/sdk/_workflows.py +152 -0
- qdash_sdk-1.10.5b1287/src/qdash/sdk/calibration.py +42 -0
- qdash_sdk-1.10.5b1287/src/qdash/sdk/pipeline.py +178 -0
- qdash_sdk-1.10.5b1287/src/qdash/sdk/py.typed +0 -0
- qdash_sdk-1.10.5b1287/src/qdash/sdk/sweep.py +75 -0
- qdash_sdk-1.10.5b1287/tests/test_sdk_calibration.py +276 -0
- qdash_sdk-1.10.5b1287/tests/test_sdk_distributions.py +258 -0
- qdash_sdk-1.10.5b1287/tests/test_sdk_pipeline.py +217 -0
- qdash_sdk-1.10.5b1287/tests/test_sdk_session.py +283 -0
- qdash_sdk-1.10.5b1287/tests/test_sdk_workflows.py +224 -0
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
# Created by https://www.toptal.com/developers/gitignore/api/python,react
|
|
2
|
+
# Edit at https://www.toptal.com/developers/gitignore?templates=python,react
|
|
3
|
+
|
|
4
|
+
### Python ###
|
|
5
|
+
# Byte-compiled / optimized / DLL files
|
|
6
|
+
__pycache__/
|
|
7
|
+
*.py[cod]
|
|
8
|
+
*$py.class
|
|
9
|
+
|
|
10
|
+
# C extensions
|
|
11
|
+
*.so
|
|
12
|
+
|
|
13
|
+
# Distribution / packaging
|
|
14
|
+
.Python
|
|
15
|
+
build/
|
|
16
|
+
develop-eggs/
|
|
17
|
+
dist/
|
|
18
|
+
downloads/
|
|
19
|
+
eggs/
|
|
20
|
+
.eggs/
|
|
21
|
+
# lib/
|
|
22
|
+
lib64/
|
|
23
|
+
parts/
|
|
24
|
+
sdist/
|
|
25
|
+
var/
|
|
26
|
+
wheels/
|
|
27
|
+
share/python-wheels/
|
|
28
|
+
*.egg-info/
|
|
29
|
+
.installed.cfg
|
|
30
|
+
*.egg
|
|
31
|
+
MANIFEST
|
|
32
|
+
|
|
33
|
+
# PyInstaller
|
|
34
|
+
# Usually these files are written by a python script from a template
|
|
35
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
36
|
+
*.manifest
|
|
37
|
+
*.spec
|
|
38
|
+
|
|
39
|
+
# Installer logs
|
|
40
|
+
pip-log.txt
|
|
41
|
+
pip-delete-this-directory.txt
|
|
42
|
+
|
|
43
|
+
# Unit test / coverage reports
|
|
44
|
+
htmlcov/
|
|
45
|
+
.tox/
|
|
46
|
+
.nox/
|
|
47
|
+
.coverage
|
|
48
|
+
.coverage.*
|
|
49
|
+
.cache
|
|
50
|
+
nosetests.xml
|
|
51
|
+
coverage.xml
|
|
52
|
+
*.cover
|
|
53
|
+
*.py,cover
|
|
54
|
+
.hypothesis/
|
|
55
|
+
.pytest_cache/
|
|
56
|
+
cover/
|
|
57
|
+
|
|
58
|
+
# Translations
|
|
59
|
+
*.mo
|
|
60
|
+
*.pot
|
|
61
|
+
|
|
62
|
+
# Django stuff:
|
|
63
|
+
*.log
|
|
64
|
+
local_settings.py
|
|
65
|
+
db.sqlite3
|
|
66
|
+
db.sqlite3-journal
|
|
67
|
+
|
|
68
|
+
# Flask stuff:
|
|
69
|
+
instance/
|
|
70
|
+
.webassets-cache
|
|
71
|
+
|
|
72
|
+
# Scrapy stuff:
|
|
73
|
+
.scrapy
|
|
74
|
+
|
|
75
|
+
# Sphinx documentation
|
|
76
|
+
docs/_build/
|
|
77
|
+
|
|
78
|
+
# PyBuilder
|
|
79
|
+
.pybuilder/
|
|
80
|
+
target/
|
|
81
|
+
|
|
82
|
+
# Jupyter Notebook
|
|
83
|
+
.ipynb_checkpoints
|
|
84
|
+
|
|
85
|
+
# IPython
|
|
86
|
+
profile_default/
|
|
87
|
+
ipython_config.py
|
|
88
|
+
|
|
89
|
+
# pyenv
|
|
90
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
91
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
92
|
+
# .python-version
|
|
93
|
+
|
|
94
|
+
# pipenv
|
|
95
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
96
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
97
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
98
|
+
# install all needed dependencies.
|
|
99
|
+
#Pipfile.lock
|
|
100
|
+
|
|
101
|
+
# poetry
|
|
102
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
103
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
104
|
+
# commonly ignored for libraries.
|
|
105
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
106
|
+
#poetry.lock
|
|
107
|
+
|
|
108
|
+
# pdm
|
|
109
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
110
|
+
#pdm.lock
|
|
111
|
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
|
112
|
+
# in version control.
|
|
113
|
+
# https://pdm.fming.dev/#use-with-ide
|
|
114
|
+
.pdm.toml
|
|
115
|
+
|
|
116
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
117
|
+
__pypackages__/
|
|
118
|
+
|
|
119
|
+
# Celery stuff
|
|
120
|
+
celerybeat-schedule
|
|
121
|
+
celerybeat.pid
|
|
122
|
+
|
|
123
|
+
# SageMath parsed files
|
|
124
|
+
*.sage.py
|
|
125
|
+
|
|
126
|
+
# Environments
|
|
127
|
+
*.env
|
|
128
|
+
.venv
|
|
129
|
+
env/
|
|
130
|
+
venv/
|
|
131
|
+
ENV/
|
|
132
|
+
env.bak/
|
|
133
|
+
venv.bak/
|
|
134
|
+
|
|
135
|
+
# Spyder project settings
|
|
136
|
+
.spyderproject
|
|
137
|
+
.spyproject
|
|
138
|
+
|
|
139
|
+
# Rope project settings
|
|
140
|
+
.ropeproject
|
|
141
|
+
|
|
142
|
+
# mkdocs documentation
|
|
143
|
+
/site
|
|
144
|
+
|
|
145
|
+
# mypy
|
|
146
|
+
.mypy_cache/
|
|
147
|
+
.dmypy.json
|
|
148
|
+
dmypy.json
|
|
149
|
+
|
|
150
|
+
# Pyre type checker
|
|
151
|
+
.pyre/
|
|
152
|
+
|
|
153
|
+
# pytype static type analyzer
|
|
154
|
+
.pytype/
|
|
155
|
+
|
|
156
|
+
# Cython debug symbols
|
|
157
|
+
cython_debug/
|
|
158
|
+
|
|
159
|
+
# PyCharm
|
|
160
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
161
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
162
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
163
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
164
|
+
#.idea/
|
|
165
|
+
|
|
166
|
+
### Python Patch ###
|
|
167
|
+
# Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration
|
|
168
|
+
poetry.toml
|
|
169
|
+
|
|
170
|
+
# ruff
|
|
171
|
+
.ruff_cache/
|
|
172
|
+
|
|
173
|
+
# LSP config files
|
|
174
|
+
pyrightconfig.json
|
|
175
|
+
|
|
176
|
+
### react ###
|
|
177
|
+
.DS_*
|
|
178
|
+
logs
|
|
179
|
+
**/*.backup.*
|
|
180
|
+
**/*.back.*
|
|
181
|
+
|
|
182
|
+
node_modules
|
|
183
|
+
bower_components
|
|
184
|
+
|
|
185
|
+
*.sublime*
|
|
186
|
+
|
|
187
|
+
psd
|
|
188
|
+
thumb
|
|
189
|
+
sketch
|
|
190
|
+
|
|
191
|
+
# End of https://www.toptal.com/developers/gitignore/api/python,react
|
|
192
|
+
|
|
193
|
+
.env
|
|
194
|
+
compose.override.yaml
|
|
195
|
+
|
|
196
|
+
# Databases
|
|
197
|
+
*.db
|
|
198
|
+
memo_store.toml
|
|
199
|
+
prefect.db-shm
|
|
200
|
+
prefect.db-wal
|
|
201
|
+
.next
|
|
202
|
+
next-env.d.ts
|
|
203
|
+
# tailwind.config.js
|
|
204
|
+
postgres_data/
|
|
205
|
+
mongo_data/*
|
|
206
|
+
!mongo_data/.gitkeep
|
|
207
|
+
!mongo_data/data/
|
|
208
|
+
mongo_data/data/*
|
|
209
|
+
!mongo_data/data/.gitkeep
|
|
210
|
+
!mongo_data/data/db/
|
|
211
|
+
mongo_data/data/db/*
|
|
212
|
+
!mongo_data/data/db/.gitkeep
|
|
213
|
+
calib_data/*
|
|
214
|
+
!calib_data/.gitkeep
|
|
215
|
+
src/qdash/workflow/user_flows/*/
|
|
216
|
+
*.env
|
|
217
|
+
docker_node_modules/
|
|
218
|
+
.venv/src/
|
|
219
|
+
log/
|
|
220
|
+
.pnpm-store/
|
|
221
|
+
qpu_data/
|
|
222
|
+
docs/.vitepress/cache/
|
|
223
|
+
ui/.vite/
|
|
224
|
+
ui/tsconfig.tsbuildinfo
|
|
225
|
+
src/qdash/workflow/images/*
|
|
226
|
+
src/qdash/workflow/.system_note.json
|
|
227
|
+
src/qdash/workflow/*.json
|
|
228
|
+
src/qdash/workflow/.calibration/*.json
|
|
229
|
+
src/qdash/workflow/.classifier/*/*
|
|
230
|
+
# Ignore all files in config directory except committed configs
|
|
231
|
+
config/qubex/*
|
|
232
|
+
!config/qubex/qubex.example/
|
|
233
|
+
config/qubex-config/*
|
|
234
|
+
config/task-knowledge/
|
|
235
|
+
config/quelware-client/*
|
|
236
|
+
src/tools/schedule/*
|
|
237
|
+
.serena/
|
|
238
|
+
.mcp.json
|
|
239
|
+
.tmp/*
|
|
240
|
+
/.claude/settings.local.json
|
|
241
|
+
# Isolated pi agent dir of `task pi-local` (generated models.json, sessions).
|
|
242
|
+
/.pi-local/
|
|
243
|
+
docs/internal/*
|
|
244
|
+
docs/papers/*
|
|
245
|
+
config/qubex-config
|
|
246
|
+
# Local pi extension checkouts mounted into the Agent Runtime during development.
|
|
247
|
+
# The directory itself is tracked (.gitkeep) so the compose bind mount always exists.
|
|
248
|
+
agent-runtime/extensions/*
|
|
249
|
+
!agent-runtime/extensions/.gitkeep
|
|
250
|
+
scripts/estimate_qubit_frequency
|
|
251
|
+
scripts/estimate-resonator-frequency
|
|
252
|
+
.direnv
|
|
253
|
+
tmp
|
|
254
|
+
/notes
|
|
255
|
+
|
|
256
|
+
# Compiled pi package tests and release tarballs.
|
|
257
|
+
packages/*/.test-dist/
|
|
258
|
+
*.tgz
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: qdash-sdk
|
|
3
|
+
Version: 1.10.5b1287
|
|
4
|
+
Summary: Python SDK for defining and running QDash calibrations
|
|
5
|
+
Author-email: OQTOPUS Team <oqtopus-team@googlegroups.com>
|
|
6
|
+
Requires-Python: <3.13,>=3.11
|
|
7
|
+
Requires-Dist: qdash-client==1.10.5b1287
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
|
|
10
|
+
# qdash-sdk
|
|
11
|
+
|
|
12
|
+
`qdash-sdk` provides `qdash.sdk`: the `QDash` session, which validates and starts calibrations
|
|
13
|
+
on a chip and lists and runs the workflows registered in a project, and the calibration
|
|
14
|
+
definitions, built on
|
|
15
|
+
[`qdash-client`](../../clients/python/README.md). Installing it installs the matching
|
|
16
|
+
`qdash-client` release:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
pip install qdash-sdk
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
```python
|
|
23
|
+
from qdash.sdk import QDash
|
|
24
|
+
|
|
25
|
+
with QDash.from_env() as qdash:
|
|
26
|
+
# A registered workflow runs code saved in QDash on the chip it was saved for.
|
|
27
|
+
for summary in qdash.workflows.list():
|
|
28
|
+
print(summary.name, summary.chip_id)
|
|
29
|
+
workflow = qdash.workflows.get("coherence_check")
|
|
30
|
+
result = workflow.run(parameters={"qids": ["0", "1"]}).wait()
|
|
31
|
+
print(result.status)
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
The [Python client guide](../../docs/reference/clients/python.md) covers configuration,
|
|
35
|
+
`chip.calibrate(targets, steps)`, which runs steps defined in Python on the chip you name,
|
|
36
|
+
registered workflows and the pipeline API.
|
|
37
|
+
|
|
38
|
+
## Develop the Package
|
|
39
|
+
|
|
40
|
+
Install the workspace and run the SDK checks from the repository root:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
uv sync --all-groups --all-packages
|
|
44
|
+
task test-sdk
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
`src/qdash/sdk/` holds the SDK sources; API requests, models, configuration, and errors stay in
|
|
48
|
+
`qdash-client`. `tests/test_sdk_distributions.py` builds both wheels and checks that each one
|
|
49
|
+
installs only its own namespace.
|
|
50
|
+
|
|
51
|
+
## Version and Publication
|
|
52
|
+
|
|
53
|
+
`qdash-sdk` has no version of its own. hatch-vcs derives it the same way as `qdash-client`,
|
|
54
|
+
and `hatch_build.py` pins the dependency to that version: a build of `X.Y.Z` or `X.Y.ZbN`
|
|
55
|
+
requires `qdash-client==X.Y.Z` or `qdash-client==X.Y.ZbN`. Development builds require any
|
|
56
|
+
`qdash-client`.
|
|
57
|
+
|
|
58
|
+
`.github/workflows/publish-qdash-client.yml` publishes both packages from one release record:
|
|
59
|
+
`qdash-client` first, then `qdash-sdk`. See
|
|
60
|
+
[Python SDK architecture](../../docs/developer-guide/architecture/python-sdk.md#packaging-and-release).
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# qdash-sdk
|
|
2
|
+
|
|
3
|
+
`qdash-sdk` provides `qdash.sdk`: the `QDash` session, which validates and starts calibrations
|
|
4
|
+
on a chip and lists and runs the workflows registered in a project, and the calibration
|
|
5
|
+
definitions, built on
|
|
6
|
+
[`qdash-client`](../../clients/python/README.md). Installing it installs the matching
|
|
7
|
+
`qdash-client` release:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pip install qdash-sdk
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
```python
|
|
14
|
+
from qdash.sdk import QDash
|
|
15
|
+
|
|
16
|
+
with QDash.from_env() as qdash:
|
|
17
|
+
# A registered workflow runs code saved in QDash on the chip it was saved for.
|
|
18
|
+
for summary in qdash.workflows.list():
|
|
19
|
+
print(summary.name, summary.chip_id)
|
|
20
|
+
workflow = qdash.workflows.get("coherence_check")
|
|
21
|
+
result = workflow.run(parameters={"qids": ["0", "1"]}).wait()
|
|
22
|
+
print(result.status)
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
The [Python client guide](../../docs/reference/clients/python.md) covers configuration,
|
|
26
|
+
`chip.calibrate(targets, steps)`, which runs steps defined in Python on the chip you name,
|
|
27
|
+
registered workflows and the pipeline API.
|
|
28
|
+
|
|
29
|
+
## Develop the Package
|
|
30
|
+
|
|
31
|
+
Install the workspace and run the SDK checks from the repository root:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
uv sync --all-groups --all-packages
|
|
35
|
+
task test-sdk
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
`src/qdash/sdk/` holds the SDK sources; API requests, models, configuration, and errors stay in
|
|
39
|
+
`qdash-client`. `tests/test_sdk_distributions.py` builds both wheels and checks that each one
|
|
40
|
+
installs only its own namespace.
|
|
41
|
+
|
|
42
|
+
## Version and Publication
|
|
43
|
+
|
|
44
|
+
`qdash-sdk` has no version of its own. hatch-vcs derives it the same way as `qdash-client`,
|
|
45
|
+
and `hatch_build.py` pins the dependency to that version: a build of `X.Y.Z` or `X.Y.ZbN`
|
|
46
|
+
requires `qdash-client==X.Y.Z` or `qdash-client==X.Y.ZbN`. Development builds require any
|
|
47
|
+
`qdash-client`.
|
|
48
|
+
|
|
49
|
+
`.github/workflows/publish-qdash-client.yml` publishes both packages from one release record:
|
|
50
|
+
`qdash-client` first, then `qdash-sdk`. See
|
|
51
|
+
[Python SDK architecture](../../docs/developer-guide/architecture/python-sdk.md#packaging-and-release).
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"""Pin qdash-sdk's qdash-client dependency to the version being built.
|
|
2
|
+
|
|
3
|
+
The release pipeline publishes qdash-client and qdash-sdk from one release record with
|
|
4
|
+
one version, X.Y.Z for a QDash tag or X.Y.ZbN for a develop beta, so a release build
|
|
5
|
+
requires exactly that qdash-client. Development versions from hatch-vcs change on every
|
|
6
|
+
commit and the 0.0.0 fallback names no release, so those builds depend on any
|
|
7
|
+
qdash-client; this also keeps the workspace lock independent of the commit.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
|
|
12
|
+
import re
|
|
13
|
+
from typing import Any
|
|
14
|
+
|
|
15
|
+
from hatchling.metadata.plugin.interface import MetadataHookInterface
|
|
16
|
+
|
|
17
|
+
# The PEP 440 versions .github/scripts/client-release.mjs publishes.
|
|
18
|
+
RELEASE_VERSION = re.compile(r"(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(b[1-9]\d*)?")
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def client_requirement(version: str) -> str:
|
|
22
|
+
"""Return the qdash-client requirement for a qdash-sdk build of ``version``."""
|
|
23
|
+
if RELEASE_VERSION.fullmatch(version) and version != "0.0.0":
|
|
24
|
+
return f"qdash-client=={version}"
|
|
25
|
+
return "qdash-client"
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class CustomMetadataHook(MetadataHookInterface):
|
|
29
|
+
"""Hatchling metadata hook selected by ``[tool.hatch.metadata.hooks.custom]``."""
|
|
30
|
+
|
|
31
|
+
def update(self, metadata: dict[str, Any]) -> None:
|
|
32
|
+
metadata["dependencies"] = [client_requirement(metadata["version"])]
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "qdash-sdk"
|
|
3
|
+
description = "Python SDK for defining and running QDash calibrations"
|
|
4
|
+
authors = [
|
|
5
|
+
{name = "OQTOPUS Team", email = "oqtopus-team@googlegroups.com"}
|
|
6
|
+
]
|
|
7
|
+
readme = "README.md"
|
|
8
|
+
requires-python = ">=3.11,<3.13"
|
|
9
|
+
# hatch_build.py sets the dependencies: qdash-client pinned to this package's version.
|
|
10
|
+
dynamic = ["version", "dependencies"]
|
|
11
|
+
|
|
12
|
+
[dependency-groups]
|
|
13
|
+
dev = [
|
|
14
|
+
"mypy==2.3.0",
|
|
15
|
+
"pytest==9.0.3",
|
|
16
|
+
"pytest-asyncio==1.3.0",
|
|
17
|
+
"ruff==0.15.14",
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
[build-system]
|
|
21
|
+
requires = ["hatchling", "hatch-vcs"]
|
|
22
|
+
build-backend = "hatchling.build"
|
|
23
|
+
|
|
24
|
+
# Keep the version source identical to clients/python so both packages of one build
|
|
25
|
+
# carry the same version.
|
|
26
|
+
[tool.hatch.version]
|
|
27
|
+
source = "vcs"
|
|
28
|
+
tag-pattern = "^v(?P<version>\\d+\\.\\d+\\.\\d+)$"
|
|
29
|
+
fallback-version = "0.0.0"
|
|
30
|
+
|
|
31
|
+
[tool.hatch.version.raw-options]
|
|
32
|
+
root = "../.."
|
|
33
|
+
version_scheme = "no-guess-dev"
|
|
34
|
+
local_scheme = "no-local-version"
|
|
35
|
+
|
|
36
|
+
[tool.hatch.version.raw-options.scm.git]
|
|
37
|
+
describe_command = "git describe --dirty --tags --long --match v[0-9]*"
|
|
38
|
+
|
|
39
|
+
[tool.hatch.metadata.hooks.custom]
|
|
40
|
+
|
|
41
|
+
[tool.hatch.build]
|
|
42
|
+
exclude = [
|
|
43
|
+
"**/__pycache__",
|
|
44
|
+
"**/*.pyc",
|
|
45
|
+
]
|
|
46
|
+
|
|
47
|
+
[tool.hatch.build.targets.wheel]
|
|
48
|
+
only-include = ["src/qdash/sdk"]
|
|
49
|
+
sources = ["src"]
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"""QDash SDK: define calibrations in Python and run them through the QDash API.
|
|
2
|
+
|
|
3
|
+
The SDK is distributed as ``qdash-sdk``, which depends on ``qdash-client`` and reuses its
|
|
4
|
+
configuration, authentication, transport and errors. ``QDash.chip(chip_id)`` validates and
|
|
5
|
+
starts calibrations defined with :mod:`qdash.sdk.calibration`; ``QDash.workflows`` lists,
|
|
6
|
+
inspects and runs the workflows registered in the project; ``QDash.pipelines`` and
|
|
7
|
+
:mod:`qdash.sdk.pipeline` work with whole pipeline specs.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from qdash.client.services.errors import (
|
|
11
|
+
QDashApiError,
|
|
12
|
+
QDashAuthError,
|
|
13
|
+
QDashConfigError,
|
|
14
|
+
QDashNotFoundError,
|
|
15
|
+
QDashTransportError,
|
|
16
|
+
QDashValidationError,
|
|
17
|
+
)
|
|
18
|
+
from qdash.sdk._calibration import CalibrationRun, Chip
|
|
19
|
+
from qdash.sdk._pipelines import PipelineRun, Pipelines
|
|
20
|
+
from qdash.sdk._runs import RunResult
|
|
21
|
+
from qdash.sdk._session import QDash
|
|
22
|
+
from qdash.sdk._workflows import Workflow, WorkflowRun, Workflows
|
|
23
|
+
|
|
24
|
+
__all__ = [
|
|
25
|
+
"CalibrationRun",
|
|
26
|
+
"Chip",
|
|
27
|
+
"PipelineRun",
|
|
28
|
+
"Pipelines",
|
|
29
|
+
"QDash",
|
|
30
|
+
"QDashApiError",
|
|
31
|
+
"QDashAuthError",
|
|
32
|
+
"QDashConfigError",
|
|
33
|
+
"QDashNotFoundError",
|
|
34
|
+
"QDashTransportError",
|
|
35
|
+
"QDashValidationError",
|
|
36
|
+
"RunResult",
|
|
37
|
+
"Workflow",
|
|
38
|
+
"WorkflowRun",
|
|
39
|
+
"Workflows",
|
|
40
|
+
]
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"""Calibration on one chip: ``Chip.validate_calibration``, ``Chip.calibrate`` and the run.
|
|
2
|
+
|
|
3
|
+
These are a front door over :class:`~qdash.sdk.Pipelines`: ``targets`` and ``steps`` become a
|
|
4
|
+
:class:`~qdash.sdk.pipeline.Pipeline`, and validation, dispatch and waiting are the pipeline
|
|
5
|
+
operations' own.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
from typing import TYPE_CHECKING, Any
|
|
11
|
+
|
|
12
|
+
from qdash.sdk._runs import RunResult
|
|
13
|
+
from qdash.sdk.pipeline import Pipeline
|
|
14
|
+
|
|
15
|
+
if TYPE_CHECKING:
|
|
16
|
+
from collections.abc import Mapping, Sequence
|
|
17
|
+
|
|
18
|
+
from pydantic import BaseModel
|
|
19
|
+
|
|
20
|
+
from qdash.client.services.models import (
|
|
21
|
+
ExecutePipelineResponse,
|
|
22
|
+
PipelineTargets,
|
|
23
|
+
ValidatePipelineResponse,
|
|
24
|
+
)
|
|
25
|
+
from qdash.sdk._pipelines import PipelineRun, Pipelines
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class CalibrationRun:
|
|
29
|
+
"""A dispatched calibration, returned by :meth:`Chip.calibrate`.
|
|
30
|
+
|
|
31
|
+
``execution_id`` is the execution the server created for the first step; ``response`` is
|
|
32
|
+
the dispatch response as the API returned it.
|
|
33
|
+
"""
|
|
34
|
+
|
|
35
|
+
def __init__(self, run: PipelineRun) -> None:
|
|
36
|
+
self._run = run
|
|
37
|
+
|
|
38
|
+
@property
|
|
39
|
+
def execution_id(self) -> str:
|
|
40
|
+
return self._run.execution_id
|
|
41
|
+
|
|
42
|
+
@property
|
|
43
|
+
def response(self) -> ExecutePipelineResponse:
|
|
44
|
+
return self._run.response
|
|
45
|
+
|
|
46
|
+
def __repr__(self) -> str:
|
|
47
|
+
return f"CalibrationRun(execution_id={self.execution_id!r})"
|
|
48
|
+
|
|
49
|
+
def get(self) -> RunResult:
|
|
50
|
+
"""The run's current state; raises ``QDashNotFoundError`` before it exists."""
|
|
51
|
+
return RunResult(self.execution_id, self._run.get())
|
|
52
|
+
|
|
53
|
+
def wait(
|
|
54
|
+
self,
|
|
55
|
+
*,
|
|
56
|
+
timeout_seconds: float = 3600.0,
|
|
57
|
+
poll_interval_seconds: float = 5.0,
|
|
58
|
+
) -> RunResult:
|
|
59
|
+
"""Poll until the whole calibration ends and return its result.
|
|
60
|
+
|
|
61
|
+
A failed or cancelled calibration is returned, not raised; check ``result.status``.
|
|
62
|
+
Raises ``TimeoutError`` when the run has not ended within ``timeout_seconds``; the
|
|
63
|
+
run itself keeps going. Same polling as :meth:`PipelineRun.wait`.
|
|
64
|
+
"""
|
|
65
|
+
detail = self._run.wait(
|
|
66
|
+
timeout_seconds=timeout_seconds, poll_interval_seconds=poll_interval_seconds
|
|
67
|
+
)
|
|
68
|
+
return RunResult(self.execution_id, detail)
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
class Chip:
|
|
72
|
+
"""Calibration on one chip, reached as ``QDash.chip(chip_id)``.
|
|
73
|
+
|
|
74
|
+
Holds the session's client, project and the chip ID; creating it sends no request.
|
|
75
|
+
"""
|
|
76
|
+
|
|
77
|
+
def __init__(self, pipelines: Pipelines, chip_id: str) -> None:
|
|
78
|
+
if not isinstance(chip_id, str) or not chip_id:
|
|
79
|
+
raise ValueError("chip_id must be a non-empty string")
|
|
80
|
+
self._pipelines = pipelines
|
|
81
|
+
self._chip_id = chip_id
|
|
82
|
+
|
|
83
|
+
@property
|
|
84
|
+
def chip_id(self) -> str:
|
|
85
|
+
return self._chip_id
|
|
86
|
+
|
|
87
|
+
def __repr__(self) -> str:
|
|
88
|
+
return f"Chip({self._chip_id!r})"
|
|
89
|
+
|
|
90
|
+
def validate_calibration(
|
|
91
|
+
self,
|
|
92
|
+
targets: PipelineTargets | Mapping[str, Any],
|
|
93
|
+
steps: Sequence[BaseModel | Mapping[str, Any]],
|
|
94
|
+
*,
|
|
95
|
+
name: str | None = None,
|
|
96
|
+
default_run_parameters: Mapping[str, Any] | None = None,
|
|
97
|
+
tags: Sequence[str] | None = None,
|
|
98
|
+
backend_name: str | None = None,
|
|
99
|
+
) -> ValidatePipelineResponse:
|
|
100
|
+
"""Check a calibration on this chip without running it.
|
|
101
|
+
|
|
102
|
+
Takes the same arguments as :meth:`calibrate`. The server reports every problem,
|
|
103
|
+
including preflight checks that read calibration data, in the response; ``valid`` is
|
|
104
|
+
false when there is any. Nothing is dispatched.
|
|
105
|
+
"""
|
|
106
|
+
pipeline = _pipeline(targets, steps, name, default_run_parameters, tags)
|
|
107
|
+
return self._pipelines.validate(pipeline, chip_id=self._chip_id, backend_name=backend_name)
|
|
108
|
+
|
|
109
|
+
def calibrate(
|
|
110
|
+
self,
|
|
111
|
+
targets: PipelineTargets | Mapping[str, Any],
|
|
112
|
+
steps: Sequence[BaseModel | Mapping[str, Any]],
|
|
113
|
+
*,
|
|
114
|
+
name: str | None = None,
|
|
115
|
+
default_run_parameters: Mapping[str, Any] | None = None,
|
|
116
|
+
tags: Sequence[str] | None = None,
|
|
117
|
+
backend_name: str | None = None,
|
|
118
|
+
) -> CalibrationRun:
|
|
119
|
+
"""Start a calibration of ``targets`` on this chip: ``steps`` run in order.
|
|
120
|
+
|
|
121
|
+
Dispatches one calibration pipeline execution, which measures on the hardware.
|
|
122
|
+
``name`` is the execution's display name, ``default_run_parameters`` the run
|
|
123
|
+
parameters every task call starts from, and ``tags`` the execution's tags; the
|
|
124
|
+
server's defaults apply to any left out. The server validates the calibration
|
|
125
|
+
before dispatch and rejects one with problems with ``QDashValidationError``; calling
|
|
126
|
+
:meth:`validate_calibration` first is optional. Requires a project on the session.
|
|
127
|
+
Returns once the run is dispatched; call :meth:`CalibrationRun.wait` to follow it.
|
|
128
|
+
"""
|
|
129
|
+
pipeline = _pipeline(targets, steps, name, default_run_parameters, tags)
|
|
130
|
+
run = self._pipelines.execute(pipeline, chip_id=self._chip_id, backend_name=backend_name)
|
|
131
|
+
return CalibrationRun(run)
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
def _pipeline(
|
|
135
|
+
targets: PipelineTargets | Mapping[str, Any],
|
|
136
|
+
steps: Sequence[BaseModel | Mapping[str, Any]],
|
|
137
|
+
name: str | None,
|
|
138
|
+
default_run_parameters: Mapping[str, Any] | None,
|
|
139
|
+
tags: Sequence[str] | None,
|
|
140
|
+
) -> Pipeline:
|
|
141
|
+
# Only the options given are set, so the spec leaves the rest to the server's defaults.
|
|
142
|
+
options: dict[str, Any] = {}
|
|
143
|
+
if name is not None:
|
|
144
|
+
options["name"] = name
|
|
145
|
+
if default_run_parameters is not None:
|
|
146
|
+
options["default_run_parameters"] = default_run_parameters
|
|
147
|
+
if tags is not None:
|
|
148
|
+
options["tags"] = tags
|
|
149
|
+
return Pipeline(targets=targets, steps=steps, **options)
|