qdash-client 0.1.0__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.
@@ -0,0 +1,24 @@
1
+ # Required
2
+ QDASH_BASE_URL=https://example.qdash/api
3
+
4
+ # Recommended authentication mode
5
+ QDASH_API_TOKEN=
6
+
7
+ # Optional headers
8
+ QDASH_PROJECT_ID=
9
+ QDASH_CF_ACCESS_CLIENT_ID=
10
+ QDASH_CF_ACCESS_CLIENT_SECRET=
11
+
12
+ # Optional request settings
13
+ QDASH_TIMEOUT_SECONDS=30
14
+ QDASH_RETRY_MAX_ATTEMPTS=3
15
+ QDASH_RETRY_BACKOFF_SECONDS=0.2
16
+ QDASH_RETRY_MAX_BACKOFF_SECONDS=5.0
17
+ QDASH_VERIFY_TLS=true
18
+ QDASH_PROXY=
19
+ QDASH_USER_AGENT=
20
+
21
+ # Optional legacy username/password authentication mode
22
+ QDASH_USERNAME=
23
+ QDASH_PASSWORD_ENV=QDASH_PASSWORD
24
+ QDASH_PASSWORD=
@@ -0,0 +1,246 @@
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
+ !postgres_data/.gitkeep
206
+ mongo_data/*
207
+ !mongo_data/.gitkeep
208
+ !mongo_data/data/
209
+ mongo_data/data/*
210
+ !mongo_data/data/.gitkeep
211
+ !mongo_data/data/db/
212
+ mongo_data/data/db/*
213
+ !mongo_data/data/db/.gitkeep
214
+ calib_data/*
215
+ !calib_data/.gitkeep
216
+ src/qdash/workflow/user_flows/*/
217
+ *.env
218
+ docker_node_modules/
219
+ .venv/src/
220
+ log/
221
+ .pnpm-store/
222
+ qpu_data/
223
+ docs/.vitepress/cache/
224
+ ui/.vite/
225
+ ui/tsconfig.tsbuildinfo
226
+ src/qdash/workflow/images/*
227
+ src/qdash/workflow/.system_note.json
228
+ src/qdash/workflow/*.json
229
+ src/qdash/workflow/.calibration/*.json
230
+ src/qdash/workflow/.classifier/*/*
231
+ # Ignore all files in config directory except committed configs
232
+ config/qubex/*
233
+ !config/qubex/qubex.example/
234
+ config/qubex-config/*
235
+ config/task-knowledge/
236
+ src/tools/schedule/*
237
+ .serena/
238
+ .mcp.json
239
+ .tmp/*
240
+ /.claude/settings.local.json
241
+ docs/internal/*
242
+ docs/papers/*
243
+ config/qubex-config
244
+ scripts/estimate_qubit_frequency
245
+ scripts/estimate-resonator-frequency
246
+ .direnv
@@ -0,0 +1,288 @@
1
+ Metadata-Version: 2.4
2
+ Name: qdash-client
3
+ Version: 0.1.0
4
+ Summary: Python client for the QDash API
5
+ Author-email: OQTOPUS Team <oqtopus-team@googlegroups.com>
6
+ Requires-Python: <3.13,>=3.11
7
+ Requires-Dist: httpx>=0.27.0
8
+ Requires-Dist: pydantic>=2.8.0
9
+ Description-Content-Type: text/markdown
10
+
11
+ # qdash.client README
12
+
13
+ `qdash.client` is a Python client for calling the QDash API.
14
+
15
+ - `services`: domain logic such as authentication, retries, and response normalization
16
+ - `rest`: low-level HTTP communication
17
+
18
+ This package follows the same approach as `oqtopus-client`, separating the transport layer from the service layer.
19
+ For user-facing examples, see `docs/user-guide/qdash-client.md`.
20
+
21
+ ## Installation
22
+
23
+ Install the lightweight client package when only programmatic API access is needed.
24
+
25
+ ```bash
26
+ pip install qdash-client
27
+ ```
28
+
29
+ For development against this repository:
30
+
31
+ ```bash
32
+ pip install ./src/qdash/client
33
+ ```
34
+
35
+ The distribution name is `qdash-client`, but the Python import path is `qdash.client`.
36
+
37
+ ## Publishing
38
+
39
+ `qdash-client` is published from this repository with PyPI Trusted Publishing. Configure the
40
+ `qdash-client` project on PyPI to trust this GitHub repository and the
41
+ `.github/workflows/publish-qdash-client.yml` workflow.
42
+
43
+ Release tags use the `qdash-client-v<version>` format and must match the version in
44
+ `pyproject.toml`.
45
+
46
+ ```bash
47
+ git tag qdash-client-v0.1.0
48
+ git push origin qdash-client-v0.1.0
49
+ ```
50
+
51
+ ## Minimal Quick Start
52
+
53
+ This is a minimal example using `/chips`, `/metrics/config`, and `/task-results/timeseries`.
54
+
55
+ ```python
56
+ from qdash.client import QDashClient
57
+
58
+ client = QDashClient()
59
+ try:
60
+ chips = client.list_chips()
61
+ print(chips.total)
62
+ print([chip.chip_id for chip in chips.chips])
63
+
64
+ metrics_config = client.get_metrics_config()
65
+ print(metrics_config.keys())
66
+
67
+ series = client.get_task_results_timeseries(
68
+ chip_id="chip-001",
69
+ parameter="t1",
70
+ start_at="2026-06-01T00:00:00Z",
71
+ end_at="2026-06-02T00:00:00Z",
72
+ )
73
+ print(series.data)
74
+ finally:
75
+ client.close()
76
+ ```
77
+
78
+ ## 1. Public API
79
+
80
+ In most cases, you will use the following:
81
+
82
+ - `QDashClient`
83
+ - `QDashConfig`
84
+ - Exception classes such as `QDashApiError`
85
+
86
+ ```python
87
+ from qdash.client import QDashClient, QDashConfig
88
+ ```
89
+
90
+ ## 2. Configuration
91
+
92
+ ### 2.1 From Environment Variables
93
+
94
+ ```python
95
+ from qdash.client import QDashConfig, QDashClient
96
+
97
+ config = QDashConfig.from_env()
98
+ client = QDashClient(config)
99
+ ```
100
+
101
+ Main environment variables:
102
+
103
+ - `QDASH_BASE_URL`
104
+ - `QDASH_API_TOKEN`
105
+ - `QDASH_PROJECT_ID`
106
+ - `QDASH_CF_ACCESS_CLIENT_ID`
107
+ - `QDASH_CF_ACCESS_CLIENT_SECRET`
108
+ - `QDASH_TIMEOUT_SECONDS`
109
+ - `QDASH_RETRY_MAX_ATTEMPTS`
110
+ - `QDASH_RETRY_BACKOFF_SECONDS`
111
+ - `QDASH_RETRY_MAX_BACKOFF_SECONDS`
112
+ - `QDASH_VERIFY_TLS`
113
+ - `QDASH_PROXY`
114
+ - `QDASH_USER_AGENT`
115
+
116
+ For legacy username/password authentication, set:
117
+
118
+ - `QDASH_USERNAME`
119
+ - `QDASH_PASSWORD_ENV`
120
+ - the environment variable named by `QDASH_PASSWORD_ENV` (defaults to `QDASH_PASSWORD`)
121
+
122
+ ### 2.2 From a Configuration File
123
+
124
+ ```python
125
+ from qdash.client import QDashConfig, QDashClient
126
+
127
+ config = QDashConfig.from_file(section="default")
128
+ client = QDashClient(config)
129
+ ```
130
+
131
+ If `path` is omitted:
132
+
133
+ 1. If `XDG_CONFIG_HOME` is set: `$XDG_CONFIG_HOME/qdash/config.ini`
134
+ 2. Otherwise: `~/.config/qdash/config.ini`
135
+
136
+ Example configuration:
137
+
138
+ ```ini
139
+ [default]
140
+ base_url = https://example.qdash/api
141
+ api_token = your-token
142
+ project_id = your-project-id
143
+ cf_access_client_id = your-cf-client-id
144
+ cf_access_client_secret = your-cf-client-secret
145
+ timeout_seconds = 30
146
+ retry_max_attempts = 3
147
+ retry_backoff_seconds = 0.2
148
+ retry_max_backoff_seconds = 5.0
149
+ ```
150
+
151
+ For legacy username/password authentication from a config file, use `username` and `password_env`
152
+ instead of `api_token`.
153
+
154
+ ### 2.3 Automatic Loading
155
+
156
+ ```python
157
+ from qdash.client import QDashClient
158
+
159
+ # Loads config.ini by default
160
+ client = QDashClient()
161
+ ```
162
+
163
+ ## 3. Usage (Synchronous API)
164
+
165
+ ### 3.1 List Chips
166
+
167
+ ```python
168
+ from qdash.client import QDashClient
169
+
170
+ client = QDashClient()
171
+ try:
172
+ chips = client.list_chips()
173
+ print([chip.chip_id for chip in chips.chips])
174
+ finally:
175
+ client.close()
176
+ ```
177
+
178
+ ### 3.2 Time-Series Metrics
179
+
180
+ ```python
181
+ from qdash.client import QDashClient
182
+
183
+ client = QDashClient()
184
+ try:
185
+ series = client.get_task_results_timeseries(
186
+ chip_id="chip-001",
187
+ parameter="t1",
188
+ tag="calibration",
189
+ start_at="2026-06-01T00:00:00Z",
190
+ end_at="2026-06-08T00:00:00Z",
191
+ qid="Q00",
192
+ )
193
+ print(series.data)
194
+ finally:
195
+ client.close()
196
+ ```
197
+
198
+ ### 3.3 Metrics Configuration
199
+
200
+ ```python
201
+ from qdash.client import QDashClient
202
+
203
+ client = QDashClient()
204
+ try:
205
+ config = client.get_metrics_config()
206
+ print(config.get("qubit_metrics", {}).keys())
207
+ print(config.get("coupling_metrics", {}).keys())
208
+ finally:
209
+ client.close()
210
+ ```
211
+
212
+ ## 4. Usage (Asynchronous API)
213
+
214
+ ```python
215
+ import asyncio
216
+ from qdash.client import QDashClient
217
+
218
+ async def main() -> None:
219
+ client = QDashClient()
220
+ try:
221
+ chips = await client.list_chips_async()
222
+ print([chip.chip_id for chip in chips.chips])
223
+
224
+ metrics_config = await client.get_metrics_config_async()
225
+ print(metrics_config.get("qubit_metrics", {}).keys())
226
+
227
+ series = await client.get_task_results_timeseries_async(
228
+ chip_id="chip-001",
229
+ parameter="t1",
230
+ start_at="2026-06-01T00:00:00Z",
231
+ end_at="2026-06-02T00:00:00Z",
232
+ )
233
+ print(series.data)
234
+ finally:
235
+ client.close()
236
+
237
+ asyncio.run(main())
238
+ ```
239
+
240
+ ## 5. Error Handling
241
+
242
+ Main exceptions:
243
+
244
+ - `QDashApiError` (base class)
245
+ - `QDashAuthError` (missing or invalid authentication)
246
+ - `QDashNotFoundError` (404)
247
+ - `QDashValidationError` (422)
248
+ - `QDashTransportError` (transport errors, timeouts, or other HTTP statuses)
249
+
250
+ ```python
251
+ from qdash.client import QDashClient, QDashApiError
252
+
253
+ client = QDashClient()
254
+ try:
255
+ print(client.list_chips().chips)
256
+ except QDashApiError as exc:
257
+ print(exc.status_code, exc)
258
+ finally:
259
+ client.close()
260
+ ```
261
+
262
+ ## 6. Exporter Helper Functionality
263
+
264
+ `QDashClient` provides helper methods for exporters.
265
+
266
+ - `normalize_chip_metrics(chip_id, payload)`
267
+
268
+ This method converts a QDash API response into a list of
269
+ `NormalizedMetricRecord` objects that are easier for exporters to consume.
270
+
271
+ ## 7. Using the Low-Level REST Client Directly
272
+
273
+ In most cases, using `QDashClient` is recommended.
274
+
275
+ If you need direct access to the low-level API, you can use `qdash.client.rest`.
276
+
277
+ ```python
278
+ from qdash.client.rest import ApiClient, Configuration
279
+
280
+ cfg = Configuration(host="https://example.qdash/api")
281
+ rest_client = ApiClient(cfg)
282
+
283
+ try:
284
+ resp = rest_client.request("GET", "/chips")
285
+ print(resp.status_code, resp.data)
286
+ finally:
287
+ rest_client.close()
288
+ ```