cloudsprite 0.11.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.
Files changed (76) hide show
  1. cloudsprite-0.11.0/LICENSE +21 -0
  2. cloudsprite-0.11.0/MANIFEST.in +8 -0
  3. cloudsprite-0.11.0/PKG-INFO +358 -0
  4. cloudsprite-0.11.0/README.md +300 -0
  5. cloudsprite-0.11.0/pyproject.toml +148 -0
  6. cloudsprite-0.11.0/setup.cfg +4 -0
  7. cloudsprite-0.11.0/src/cloudsprite/__init__.py +451 -0
  8. cloudsprite-0.11.0/src/cloudsprite/_antenna.py +83 -0
  9. cloudsprite-0.11.0/src/cloudsprite/_auth.py +295 -0
  10. cloudsprite-0.11.0/src/cloudsprite/_client.py +502 -0
  11. cloudsprite-0.11.0/src/cloudsprite/_config.py +203 -0
  12. cloudsprite-0.11.0/src/cloudsprite/_consent.py +104 -0
  13. cloudsprite-0.11.0/src/cloudsprite/_context.py +945 -0
  14. cloudsprite-0.11.0/src/cloudsprite/_exceptions.py +136 -0
  15. cloudsprite-0.11.0/src/cloudsprite/_figure_models.py +158 -0
  16. cloudsprite-0.11.0/src/cloudsprite/_figure_validation.py +168 -0
  17. cloudsprite-0.11.0/src/cloudsprite/_filter_foster.py +165 -0
  18. cloudsprite-0.11.0/src/cloudsprite/_filter_synthesis.py +400 -0
  19. cloudsprite-0.11.0/src/cloudsprite/_filtering.py +134 -0
  20. cloudsprite-0.11.0/src/cloudsprite/_impedance_matching.py +262 -0
  21. cloudsprite-0.11.0/src/cloudsprite/_interpolation.py +47 -0
  22. cloudsprite-0.11.0/src/cloudsprite/_lineage.py +775 -0
  23. cloudsprite-0.11.0/src/cloudsprite/_link_budget.py +99 -0
  24. cloudsprite-0.11.0/src/cloudsprite/_logging.py +53 -0
  25. cloudsprite-0.11.0/src/cloudsprite/_mixed_mode.py +49 -0
  26. cloudsprite-0.11.0/src/cloudsprite/_monte_carlo.py +193 -0
  27. cloudsprite-0.11.0/src/cloudsprite/_noise_figure.py +44 -0
  28. cloudsprite-0.11.0/src/cloudsprite/_pagination.py +130 -0
  29. cloudsprite-0.11.0/src/cloudsprite/_parsers.py +75 -0
  30. cloudsprite-0.11.0/src/cloudsprite/_publish.py +162 -0
  31. cloudsprite-0.11.0/src/cloudsprite/_redact.py +179 -0
  32. cloudsprite-0.11.0/src/cloudsprite/_response.py +63 -0
  33. cloudsprite-0.11.0/src/cloudsprite/_resultset.py +65 -0
  34. cloudsprite-0.11.0/src/cloudsprite/_rf_network.py +111 -0
  35. cloudsprite-0.11.0/src/cloudsprite/_run_config.py +46 -0
  36. cloudsprite-0.11.0/src/cloudsprite/_script_runner.py +217 -0
  37. cloudsprite-0.11.0/src/cloudsprite/_script_workspace.py +271 -0
  38. cloudsprite-0.11.0/src/cloudsprite/_sparameter_metrics.py +75 -0
  39. cloudsprite-0.11.0/src/cloudsprite/_tdr.py +283 -0
  40. cloudsprite-0.11.0/src/cloudsprite/_trace.py +112 -0
  41. cloudsprite-0.11.0/src/cloudsprite/_version.py +23 -0
  42. cloudsprite-0.11.0/src/cloudsprite/_visualizer.py +380 -0
  43. cloudsprite-0.11.0/src/cloudsprite/_visualizer_cli.py +412 -0
  44. cloudsprite-0.11.0/src/cloudsprite/_visualizer_preview.py +864 -0
  45. cloudsprite-0.11.0/src/cloudsprite/_work_context.py +116 -0
  46. cloudsprite-0.11.0/src/cloudsprite/_ws.py +577 -0
  47. cloudsprite-0.11.0/src/cloudsprite/cli.py +300 -0
  48. cloudsprite-0.11.0/src/cloudsprite/py.typed +0 -0
  49. cloudsprite-0.11.0/src/cloudsprite/resources/__init__.py +1 -0
  50. cloudsprite-0.11.0/src/cloudsprite/resources/_base.py +293 -0
  51. cloudsprite-0.11.0/src/cloudsprite/resources/_models.py +50 -0
  52. cloudsprite-0.11.0/src/cloudsprite/resources/cloudscripts.py +173 -0
  53. cloudsprite-0.11.0/src/cloudsprite/resources/datasets.py +431 -0
  54. cloudsprite-0.11.0/src/cloudsprite/resources/figures.py +282 -0
  55. cloudsprite-0.11.0/src/cloudsprite/resources/instruments.py +295 -0
  56. cloudsprite-0.11.0/src/cloudsprite/resources/notebooks.py +183 -0
  57. cloudsprite-0.11.0/src/cloudsprite/resources/orbs.py +99 -0
  58. cloudsprite-0.11.0/src/cloudsprite/resources/parameters.py +77 -0
  59. cloudsprite-0.11.0/src/cloudsprite/resources/projects.py +182 -0
  60. cloudsprite-0.11.0/src/cloudsprite/resources/related.py +125 -0
  61. cloudsprite-0.11.0/src/cloudsprite/resources/reports.py +992 -0
  62. cloudsprite-0.11.0/src/cloudsprite/resources/search.py +245 -0
  63. cloudsprite-0.11.0/src/cloudsprite/resources/shares.py +229 -0
  64. cloudsprite-0.11.0/src/cloudsprite/resources/sprites.py +15 -0
  65. cloudsprite-0.11.0/src/cloudsprite/resources/tags.py +107 -0
  66. cloudsprite-0.11.0/src/cloudsprite/resources/teams.py +86 -0
  67. cloudsprite-0.11.0/src/cloudsprite/resources/traces.py +147 -0
  68. cloudsprite-0.11.0/src/cloudsprite/resources/usage.py +152 -0
  69. cloudsprite-0.11.0/src/cloudsprite/resources/visualizer_templates.py +466 -0
  70. cloudsprite-0.11.0/src/cloudsprite/resources/workflows.py +59 -0
  71. cloudsprite-0.11.0/src/cloudsprite.egg-info/PKG-INFO +358 -0
  72. cloudsprite-0.11.0/src/cloudsprite.egg-info/SOURCES.txt +74 -0
  73. cloudsprite-0.11.0/src/cloudsprite.egg-info/dependency_links.txt +1 -0
  74. cloudsprite-0.11.0/src/cloudsprite.egg-info/entry_points.txt +3 -0
  75. cloudsprite-0.11.0/src/cloudsprite.egg-info/requires.txt +35 -0
  76. cloudsprite-0.11.0/src/cloudsprite.egg-info/top_level.txt +1 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 CloudSprite
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,8 @@
1
+ # The sdist carries the package source and metadata only. Tests, fixtures,
2
+ # docs, demos and scripts stay in the repository.
3
+ prune tests
4
+ prune docs
5
+ prune demos
6
+ prune examples
7
+ prune pressure_test
8
+ prune scripts
@@ -0,0 +1,358 @@
1
+ Metadata-Version: 2.4
2
+ Name: cloudsprite
3
+ Version: 0.11.0
4
+ Summary: CloudSprite Python SDK — programmatic access to RF & T&M data
5
+ Author-email: CloudSprite <support@cloudsprite.io>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://cloudsprite.io
8
+ Project-URL: Documentation, https://docs.cloudsprite.io/platform/python-sdk/
9
+ Project-URL: SDK reference, https://docs.cloudsprite.io/sdk-reference/
10
+ Project-URL: Changelog, https://docs.cloudsprite.io/platform/release-notes/
11
+ Project-URL: Support, https://docs.cloudsprite.io/
12
+ Keywords: rf,test-and-measurement,vna,s-parameters,touchstone,cloudsprite,sdk
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Intended Audience :: Science/Research
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Programming Language :: Python :: 3 :: Only
22
+ Classifier: Topic :: Scientific/Engineering
23
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
24
+ Classifier: Typing :: Typed
25
+ Requires-Python: >=3.11
26
+ Description-Content-Type: text/markdown
27
+ License-File: LICENSE
28
+ Requires-Dist: requests<3,>=2.28
29
+ Requires-Dist: numpy<3,>=1.24
30
+ Requires-Dist: scipy<2,>=1.10
31
+ Provides-Extra: plotly
32
+ Requires-Dist: plotly<7,>=5; extra == "plotly"
33
+ Provides-Extra: rf
34
+ Requires-Dist: scikit-rf<2,>=0.30; extra == "rf"
35
+ Provides-Extra: ws
36
+ Requires-Dist: aiohttp<4,>=3.9; extra == "ws"
37
+ Provides-Extra: pandas
38
+ Requires-Dist: pandas<3,>=2.0; extra == "pandas"
39
+ Provides-Extra: all
40
+ Requires-Dist: plotly<7,>=5; extra == "all"
41
+ Requires-Dist: scikit-rf<2,>=0.30; extra == "all"
42
+ Requires-Dist: aiohttp<4,>=3.9; extra == "all"
43
+ Requires-Dist: pandas<3,>=2.0; extra == "all"
44
+ Provides-Extra: dev
45
+ Requires-Dist: plotly<7,>=5; extra == "dev"
46
+ Requires-Dist: pytest<9,>=7.0; extra == "dev"
47
+ Requires-Dist: pytest-cov<7,>=4.0; extra == "dev"
48
+ Requires-Dist: responses<1,>=0.23; extra == "dev"
49
+ Requires-Dist: black<26,>=24.0; extra == "dev"
50
+ Requires-Dist: isort<7,>=5.12; extra == "dev"
51
+ Requires-Dist: ruff<1,>=0.4; extra == "dev"
52
+ Requires-Dist: mypy<2,>=1.8; extra == "dev"
53
+ Requires-Dist: types-requests<3,>=2.31; extra == "dev"
54
+ Requires-Dist: scikit-rf<2,>=0.30; extra == "dev"
55
+ Requires-Dist: aiohttp<4,>=3.9; extra == "dev"
56
+ Requires-Dist: pandas<3,>=2.0; extra == "dev"
57
+ Dynamic: license-file
58
+
59
+ # cloudsprite
60
+
61
+ CloudSprite Python SDK — programmatic access to RF and T&M data.
62
+
63
+ ## Install
64
+
65
+ ```bash
66
+ pip install cloudsprite
67
+ # or
68
+ uv add cloudsprite
69
+ ```
70
+
71
+ Python 3.11 or newer. The core install covers connect, query and publish. Optional extras:
72
+
73
+ ```bash
74
+ pip install "cloudsprite[rf]" # scikit-rf: Touchstone parsing, Trace.to_network()
75
+ pip install "cloudsprite[pandas]" # ResultSet.to_dataframe()
76
+ pip install "cloudsprite[ws]" # aiohttp: WebSocket instrument control
77
+ pip install "cloudsprite[plotly]" # go.Figure input for saved figure publishing
78
+ pip install "cloudsprite[all]" # every extra
79
+ ```
80
+
81
+ Figure dicts work without the Plotly extra.
82
+
83
+ **This is a beta (0.x).** The API may change between minor versions; changes are listed in the
84
+ [changelog](https://docs.cloudsprite.io/platform/release-notes/). Pin a version (`cloudsprite==0.11.*`)
85
+ if you need a stable surface.
86
+
87
+ ## Setup
88
+
89
+ ```bash
90
+ cloudsprite init
91
+ ```
92
+
93
+ Paste the API key (input is hidden). The CLI authenticates it, lists orgs and
94
+ teams, and writes slugs to `~/.cloudsprite/config`. Production API host is the
95
+ default — do not type a base URL. Override only if you need to: `cloudsprite init --base-url http://localhost:8000`.
96
+
97
+ Or set the key directly:
98
+
99
+ ```bash
100
+ export CLOUDSPRITE_API_KEY=csk_your_key
101
+ ```
102
+
103
+ `cs.connect()` then applies `org` / `team` from the config file. A unique org
104
+ is selected automatically. `Client(org="acme", team="rf-lab")` sets the same
105
+ defaults at construction.
106
+
107
+ ## Quickstart
108
+
109
+ ```python
110
+ import cloudsprite as cs
111
+
112
+ cs.connect(api_key="csk_your_key")
113
+ cs.set_org("acme")
114
+ cs.set_team("rf-lab")
115
+
116
+ # Fetch traces
117
+ s21 = cs.projects["cable-qual"].datasets["sweep-25c"].traces["S21"]
118
+
119
+ # Compute
120
+ result = s21 * 0.5
121
+ result.name = "filtered"
122
+
123
+ # Publish
124
+ cs.set_project("cable-qual")
125
+ cs.cloudscript(__file__)
126
+ cs.publish(traces=[result], name="filtered-results")
127
+ ```
128
+
129
+ ## Run a CloudScript on your computer
130
+
131
+ A CloudScript run started from CloudSprite stops after **30 minutes**. A script that needs longer
132
+ runs on your computer with this SDK instead. It is the same script, unchanged: the cloud runner
133
+ and your machine both execute it with `import cloudsprite as cs`.
134
+
135
+ **1. Install the SDK.** See [Install](#install).
136
+
137
+ **2. Sign in.** Run `cloudsprite init` (writes `~/.cloudsprite/config`), or set
138
+ `CLOUDSPRITE_API_KEY`. See [Setup](#setup).
139
+
140
+ **3. Get the script.** Copy its code from the script's page in CloudSprite, or, if it was
141
+ imported from a Git repository, clone that repository at the version you want to run.
142
+
143
+ **4. Provide the run settings.** A cloud run writes its config to `cs_run_config.json` in the
144
+ script's working directory, and `cs.run_config()` reads that file. Create the same file (a JSON
145
+ object) in the directory you run from. With no file, `cs.run_config()` returns `{}`.
146
+
147
+ ```json
148
+ {"correlation_threshold": 0.9}
149
+ ```
150
+
151
+ ```python
152
+ config = cs.run_config()
153
+ threshold = float(config.get("correlation_threshold", 0.95))
154
+ ```
155
+
156
+ `cs.run_config()` reads the current directory, so call it before `os.chdir`. It raises
157
+ `ValidationError` if the file is not a JSON object.
158
+
159
+ **5. Run it with Python**, from that directory:
160
+
161
+ ```bash
162
+ python my_script.py
163
+ ```
164
+
165
+ A cloud run starts a repository script from the repository root, with the root on `sys.path`.
166
+ If the script imports modules from the repository root, run from the root with
167
+ `PYTHONPATH=. python path/to/my_script.py`.
168
+
169
+ A cloud run sets the project for you. Locally, call `cs.set_project("cable-qual")` in the script
170
+ or set `CLOUDSPRITE_PROJECT`. `CLOUDSPRITE_ORG` and `CLOUDSPRITE_TEAM` set the org and team the
171
+ same way.
172
+
173
+ **Results.** `cs.publish(...)` and the other SDK calls write to CloudSprite exactly as in a cloud
174
+ run, using your API key: the published datasets appear in the project. Call
175
+ `cs.cloudscript(__file__)` to track the run (source is attached only with your consent), and
176
+ `cs.cloudscript(__file__, install_hooks=True)` to also report the run on exit; see
177
+ [What the SDK sends](#what-the-sdk-sends-lineage--run-reporting) for what leaves your machine. The
178
+ 30-minute limit does not apply to local runs.
179
+
180
+ ## Query Patterns
181
+
182
+ ```python
183
+ # All datasets in a project
184
+ cs.projects["cable-qual"].datasets
185
+
186
+ # Glob matching
187
+ cs.projects["cable-qual"].datasets["sweep-*"]
188
+
189
+ # Filter by parameter
190
+ cs.projects["cable-qual"].datasets.filter(cs.params.temp > 25)
191
+
192
+ # Traces live on a dataset (not on the collection)
193
+ ds = cs.projects["cable-qual"].datasets["sweep-25c"]
194
+ s21 = ds.traces["S21"]
195
+ ```
196
+
197
+ > Collection-level fan-out (e.g. `datasets.traces["S21"]` across many datasets)
198
+ > is planned; use per-dataset access today.
199
+
200
+ ## Exports, share links, usage and related datasets
201
+
202
+ ```python
203
+ # Export a report (html page, or md = zip of markdown + assets) and download it
204
+ report = cs.reports.get("CQ-RPT-1")
205
+ path = report.export("html").wait(timeout=300).download("./out/")
206
+ # wait() raises ExportInputsChangedError / ExportPermissionDeniedError / ExportError / ExportTimeoutError
207
+
208
+ # Share link: the URL is returned once, on create or regenerate
209
+ link = cs.shares.create(ds, allow_download=False)
210
+ print(link.share_url)
211
+ link.regenerate() # new URL; the old one stops working
212
+ link.revoke()
213
+
214
+ # What uses a dataset, and which datasets resemble it
215
+ usage = ds.usage()
216
+ print(usage.counts) # reports, notebooks, figures, workflows, scripts, derived, derived_from
217
+ for item in ds.related(limit=5, scope="team"):
218
+ print(item.dataset.title, round(item.score, 2), item.reasons[0].text)
219
+ ```
220
+
221
+ ## scikit-rf Integration
222
+
223
+ Requires `pip install cloudsprite[rf]`.
224
+
225
+ ```python
226
+ s21 = cs.projects["cable-qual"].datasets["cal-data"].traces["S21"]
227
+ network = s21.to_trace().to_network() # → skrf.Network
228
+ ```
229
+
230
+ ## Visualizer templates
231
+
232
+ A visualizer template is one HTML file with a JSON manifest (CloudSprite Template Standard 0.1) that
233
+ draws a dataset inside a sandbox. Build it locally, test it, then publish it to your team:
234
+
235
+ ```bash
236
+ cloudsprite visualizer validate overlay.html # offline checks, then the API reviewer; exit 1 on a block
237
+ cloudsprite visualizer preview overlay.html --dataset <id> # http://127.0.0.1:8765, sandboxed, real cs runtime
238
+ cloudsprite visualizer publish overlay.html --bump patch --readme README.md
239
+ ```
240
+
241
+ `preview` uses sample data unless you pass `--dataset <id>` or `--data file.json`
242
+ (`{"channels": [{"label": "S21", "x": [...], "y": [...], "xUnit": "Hz", "yUnit": "dB"}]}`); reload the
243
+ page after editing the file. The template runs in a `sandbox="allow-scripts"` iframe with no network
244
+ access, the same isolation the app applies. The runtime and engine libraries load from the
245
+ user-content origin of the environment your `base_url` points at. `publish` creates a team template or saves a strictly higher semver version; `--bump`
246
+ rewrites the manifest version after a successful publish. Listing a template for your whole
247
+ organisation is requested in the app.
248
+
249
+ The same calls are available to scripts:
250
+
251
+ ```python
252
+ templates = cs.visualizer_templates
253
+ report = templates.validate(source) # report["can_publish"], report["findings"]
254
+ templates.publish(source, readme=readme) # new template, or a strictly higher semver version
255
+ templates.deprecate(template_id, "use 2.x", version="1.0.0")
256
+ ```
257
+
258
+ ## Advanced: Client
259
+
260
+ The module API (`cs.connect`, `cs.projects`, …) is a thin convenience layer over a
261
+ process-default `Client`. Prefer an explicit `Client` for libraries, multi-tenant
262
+ scripts, tests, and notebooks that need isolation:
263
+
264
+ ```python
265
+ from cloudsprite import Client
266
+
267
+ # Construction is cold — no network I/O. Auth runs on first API call
268
+ # (or call client.connect() explicitly).
269
+ with Client(api_key="csk_your_key", team="rf-lab") as cs:
270
+ for p in cs.projects:
271
+ print(p.name)
272
+ cs.set_project("cable-qual")
273
+ cs.publish(traces=[result], name="filtered-results")
274
+ # .close() shuts the publish thread pool; further calls raise.
275
+
276
+ # Two clients never share team/project state, caches, or lineage:
277
+ lab = Client(api_key="csk_lab_key", team="rf-lab")
278
+ prod = Client(api_key="csk_prod_key", team="production")
279
+ ```
280
+
281
+ Threading: instance isolation is guaranteed; concurrent `set_team` / `set_project`
282
+ on one client is unsupported. Prefer one `Client` per thread or logical session.
283
+
284
+ ## What the SDK sends (lineage / run reporting)
285
+
286
+ `cs.cloudscript()` is **opt-in** — nothing is sent until you call it. When active, the following may leave your machine:
287
+
288
+ | Channel | What is sent | Default | Disable |
289
+ |-|-|-|-|
290
+ | CloudScript source | Full file contents as a DataFile on each `publish()` | **Off until you say yes once** (see below) | `upload_source=False`, `CLOUDSPRITE_UPLOAD_SOURCE=0` or `CLOUDSPRITE_NO_SOURCE_UPLOAD=1` |
291
+ | Git state | HEAD sha, with optional `-dirty` suffix | On | `include_git=False` or `CLOUDSPRITE_NO_GIT_STATE=1` |
292
+ | Error text | Exception type + message only (no traceback frames, no absolute paths) | On | `include_error=False` or `CLOUDSPRITE_NO_ERROR_MESSAGE=1` |
293
+ | Run report | Dataset I/O ids, content hash, sdk version, seed, status, `purpose`, `params` (secrets redacted), the active work context → `POST /api/script-runs/` | Via hooks or `cs.report_run()` | Do not call `cloudscript` / `report_run` |
294
+ | Script arguments | `sys.argv[1:]` of a script run, secret flags and values redacted (never environment variables) | On | `include_argv=False` or `CLOUDSPRITE_NO_ARGV=1` |
295
+
296
+ **Source upload is opt-in.** The first time a `publish()` would attach your script's source and you are
297
+ at a terminal, the SDK asks once: `Upload this script's source to CloudSprite for run lineage? [y/N]`. Your
298
+ answer is saved in `~/.cloudsprite/config` under `[privacy]` (`upload_source = true` or `false`) and
299
+ never asked again on that machine; edit that line to change it. Without a saved answer, and with no
300
+ terminal (CI, notebooks, pipes), nothing is uploaded and a one-line notice says how to enable it.
301
+ Settings override the saved answer: `cs.cloudscript(__file__, upload_source=True)` (or `False`) for one script,
302
+ `CLOUDSPRITE_UPLOAD_SOURCE=1` (or `0`) for an environment. `CLOUDSPRITE_NO_SOURCE_UPLOAD=1` and
303
+ `CLOUDSPRITE_NO_TELEMETRY=1` force it off. Scripts that CloudSprite itself runs in the cloud always attach their
304
+ source, since it already lives on the server.
305
+
306
+ `cs.sprite()` and `cs.track_script()` remain as aliases of `cs.cloudscript()` (same callable, no deprecation warning).
307
+
308
+ **Not sent:** git remote URL, OS username, full tracebacks, or source lines from stack frames.
309
+
310
+ **Process hooks** (`sys.excepthook` + `atexit`) are **off by default**. Pass `install_hooks=True` for automatic failure capture and exit-time reporting; notebooks/REPLs should call `cs.report_run()` instead.
311
+
312
+ Blanket kill-switch:
313
+
314
+ ```bash
315
+ export CLOUDSPRITE_NO_TELEMETRY=1
316
+ ```
317
+
318
+ That disables source upload, git state, error text and argv (explicit kwargs still win).
319
+
320
+ ```python
321
+ # Typical CloudScript with automatic run report on exit
322
+ cs.cloudscript(__file__, install_hooks=True)
323
+
324
+ # Minimal: track I/O + hash, no source upload, no git, no error text
325
+ cs.cloudscript(__file__, upload_source=False, include_git=False, include_error=False)
326
+ ```
327
+
328
+ ### Work context
329
+
330
+ Say which engineering activity (and attempt) a run or dataset belongs to, and why:
331
+
332
+ ```python
333
+ cs.cloudscript(__file__, purpose="re-run S21 sweep after fixture change", params={"temp_c": 25})
334
+
335
+ with cs.work_context(activity="<activity-uuid>", attempt="<attempt-uuid>"):
336
+ cs.publish(traces=[s21], name="s21-sweep") # dataset stamped with the activity/attempt
337
+ ```
338
+
339
+ Every API request inside the block carries `X-CloudSprite-Work-Context`; the run report names the
340
+ same activity. `CLOUDSPRITE_ACTIVITY=<activity-uuid>` sets a process-wide default. Server runs
341
+ inherit their context from the run, so nothing is sent there.
342
+
343
+ ## Known limitations
344
+
345
+ - Lineage metadata fields on the dataset (`is_computed`, `input_datasets`, `script_hash`, etc.) are not
346
+ stored by the API yet, so `publish()` does not send them. The script source is attached as a data
347
+ file when you call `cs.cloudscript()`.
348
+ - Collection-level trace fan-out (`datasets.traces["S21"]` across many datasets) is not available; use
349
+ per-dataset access.
350
+
351
+ ## Support and security
352
+
353
+ Questions and bug reports: support@cloudsprite.io. Report security issues to security@cloudsprite.io
354
+ rather than in a public forum.
355
+
356
+ ## License
357
+
358
+ MIT.
@@ -0,0 +1,300 @@
1
+ # cloudsprite
2
+
3
+ CloudSprite Python SDK — programmatic access to RF and T&M data.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ pip install cloudsprite
9
+ # or
10
+ uv add cloudsprite
11
+ ```
12
+
13
+ Python 3.11 or newer. The core install covers connect, query and publish. Optional extras:
14
+
15
+ ```bash
16
+ pip install "cloudsprite[rf]" # scikit-rf: Touchstone parsing, Trace.to_network()
17
+ pip install "cloudsprite[pandas]" # ResultSet.to_dataframe()
18
+ pip install "cloudsprite[ws]" # aiohttp: WebSocket instrument control
19
+ pip install "cloudsprite[plotly]" # go.Figure input for saved figure publishing
20
+ pip install "cloudsprite[all]" # every extra
21
+ ```
22
+
23
+ Figure dicts work without the Plotly extra.
24
+
25
+ **This is a beta (0.x).** The API may change between minor versions; changes are listed in the
26
+ [changelog](https://docs.cloudsprite.io/platform/release-notes/). Pin a version (`cloudsprite==0.11.*`)
27
+ if you need a stable surface.
28
+
29
+ ## Setup
30
+
31
+ ```bash
32
+ cloudsprite init
33
+ ```
34
+
35
+ Paste the API key (input is hidden). The CLI authenticates it, lists orgs and
36
+ teams, and writes slugs to `~/.cloudsprite/config`. Production API host is the
37
+ default — do not type a base URL. Override only if you need to: `cloudsprite init --base-url http://localhost:8000`.
38
+
39
+ Or set the key directly:
40
+
41
+ ```bash
42
+ export CLOUDSPRITE_API_KEY=csk_your_key
43
+ ```
44
+
45
+ `cs.connect()` then applies `org` / `team` from the config file. A unique org
46
+ is selected automatically. `Client(org="acme", team="rf-lab")` sets the same
47
+ defaults at construction.
48
+
49
+ ## Quickstart
50
+
51
+ ```python
52
+ import cloudsprite as cs
53
+
54
+ cs.connect(api_key="csk_your_key")
55
+ cs.set_org("acme")
56
+ cs.set_team("rf-lab")
57
+
58
+ # Fetch traces
59
+ s21 = cs.projects["cable-qual"].datasets["sweep-25c"].traces["S21"]
60
+
61
+ # Compute
62
+ result = s21 * 0.5
63
+ result.name = "filtered"
64
+
65
+ # Publish
66
+ cs.set_project("cable-qual")
67
+ cs.cloudscript(__file__)
68
+ cs.publish(traces=[result], name="filtered-results")
69
+ ```
70
+
71
+ ## Run a CloudScript on your computer
72
+
73
+ A CloudScript run started from CloudSprite stops after **30 minutes**. A script that needs longer
74
+ runs on your computer with this SDK instead. It is the same script, unchanged: the cloud runner
75
+ and your machine both execute it with `import cloudsprite as cs`.
76
+
77
+ **1. Install the SDK.** See [Install](#install).
78
+
79
+ **2. Sign in.** Run `cloudsprite init` (writes `~/.cloudsprite/config`), or set
80
+ `CLOUDSPRITE_API_KEY`. See [Setup](#setup).
81
+
82
+ **3. Get the script.** Copy its code from the script's page in CloudSprite, or, if it was
83
+ imported from a Git repository, clone that repository at the version you want to run.
84
+
85
+ **4. Provide the run settings.** A cloud run writes its config to `cs_run_config.json` in the
86
+ script's working directory, and `cs.run_config()` reads that file. Create the same file (a JSON
87
+ object) in the directory you run from. With no file, `cs.run_config()` returns `{}`.
88
+
89
+ ```json
90
+ {"correlation_threshold": 0.9}
91
+ ```
92
+
93
+ ```python
94
+ config = cs.run_config()
95
+ threshold = float(config.get("correlation_threshold", 0.95))
96
+ ```
97
+
98
+ `cs.run_config()` reads the current directory, so call it before `os.chdir`. It raises
99
+ `ValidationError` if the file is not a JSON object.
100
+
101
+ **5. Run it with Python**, from that directory:
102
+
103
+ ```bash
104
+ python my_script.py
105
+ ```
106
+
107
+ A cloud run starts a repository script from the repository root, with the root on `sys.path`.
108
+ If the script imports modules from the repository root, run from the root with
109
+ `PYTHONPATH=. python path/to/my_script.py`.
110
+
111
+ A cloud run sets the project for you. Locally, call `cs.set_project("cable-qual")` in the script
112
+ or set `CLOUDSPRITE_PROJECT`. `CLOUDSPRITE_ORG` and `CLOUDSPRITE_TEAM` set the org and team the
113
+ same way.
114
+
115
+ **Results.** `cs.publish(...)` and the other SDK calls write to CloudSprite exactly as in a cloud
116
+ run, using your API key: the published datasets appear in the project. Call
117
+ `cs.cloudscript(__file__)` to track the run (source is attached only with your consent), and
118
+ `cs.cloudscript(__file__, install_hooks=True)` to also report the run on exit; see
119
+ [What the SDK sends](#what-the-sdk-sends-lineage--run-reporting) for what leaves your machine. The
120
+ 30-minute limit does not apply to local runs.
121
+
122
+ ## Query Patterns
123
+
124
+ ```python
125
+ # All datasets in a project
126
+ cs.projects["cable-qual"].datasets
127
+
128
+ # Glob matching
129
+ cs.projects["cable-qual"].datasets["sweep-*"]
130
+
131
+ # Filter by parameter
132
+ cs.projects["cable-qual"].datasets.filter(cs.params.temp > 25)
133
+
134
+ # Traces live on a dataset (not on the collection)
135
+ ds = cs.projects["cable-qual"].datasets["sweep-25c"]
136
+ s21 = ds.traces["S21"]
137
+ ```
138
+
139
+ > Collection-level fan-out (e.g. `datasets.traces["S21"]` across many datasets)
140
+ > is planned; use per-dataset access today.
141
+
142
+ ## Exports, share links, usage and related datasets
143
+
144
+ ```python
145
+ # Export a report (html page, or md = zip of markdown + assets) and download it
146
+ report = cs.reports.get("CQ-RPT-1")
147
+ path = report.export("html").wait(timeout=300).download("./out/")
148
+ # wait() raises ExportInputsChangedError / ExportPermissionDeniedError / ExportError / ExportTimeoutError
149
+
150
+ # Share link: the URL is returned once, on create or regenerate
151
+ link = cs.shares.create(ds, allow_download=False)
152
+ print(link.share_url)
153
+ link.regenerate() # new URL; the old one stops working
154
+ link.revoke()
155
+
156
+ # What uses a dataset, and which datasets resemble it
157
+ usage = ds.usage()
158
+ print(usage.counts) # reports, notebooks, figures, workflows, scripts, derived, derived_from
159
+ for item in ds.related(limit=5, scope="team"):
160
+ print(item.dataset.title, round(item.score, 2), item.reasons[0].text)
161
+ ```
162
+
163
+ ## scikit-rf Integration
164
+
165
+ Requires `pip install cloudsprite[rf]`.
166
+
167
+ ```python
168
+ s21 = cs.projects["cable-qual"].datasets["cal-data"].traces["S21"]
169
+ network = s21.to_trace().to_network() # → skrf.Network
170
+ ```
171
+
172
+ ## Visualizer templates
173
+
174
+ A visualizer template is one HTML file with a JSON manifest (CloudSprite Template Standard 0.1) that
175
+ draws a dataset inside a sandbox. Build it locally, test it, then publish it to your team:
176
+
177
+ ```bash
178
+ cloudsprite visualizer validate overlay.html # offline checks, then the API reviewer; exit 1 on a block
179
+ cloudsprite visualizer preview overlay.html --dataset <id> # http://127.0.0.1:8765, sandboxed, real cs runtime
180
+ cloudsprite visualizer publish overlay.html --bump patch --readme README.md
181
+ ```
182
+
183
+ `preview` uses sample data unless you pass `--dataset <id>` or `--data file.json`
184
+ (`{"channels": [{"label": "S21", "x": [...], "y": [...], "xUnit": "Hz", "yUnit": "dB"}]}`); reload the
185
+ page after editing the file. The template runs in a `sandbox="allow-scripts"` iframe with no network
186
+ access, the same isolation the app applies. The runtime and engine libraries load from the
187
+ user-content origin of the environment your `base_url` points at. `publish` creates a team template or saves a strictly higher semver version; `--bump`
188
+ rewrites the manifest version after a successful publish. Listing a template for your whole
189
+ organisation is requested in the app.
190
+
191
+ The same calls are available to scripts:
192
+
193
+ ```python
194
+ templates = cs.visualizer_templates
195
+ report = templates.validate(source) # report["can_publish"], report["findings"]
196
+ templates.publish(source, readme=readme) # new template, or a strictly higher semver version
197
+ templates.deprecate(template_id, "use 2.x", version="1.0.0")
198
+ ```
199
+
200
+ ## Advanced: Client
201
+
202
+ The module API (`cs.connect`, `cs.projects`, …) is a thin convenience layer over a
203
+ process-default `Client`. Prefer an explicit `Client` for libraries, multi-tenant
204
+ scripts, tests, and notebooks that need isolation:
205
+
206
+ ```python
207
+ from cloudsprite import Client
208
+
209
+ # Construction is cold — no network I/O. Auth runs on first API call
210
+ # (or call client.connect() explicitly).
211
+ with Client(api_key="csk_your_key", team="rf-lab") as cs:
212
+ for p in cs.projects:
213
+ print(p.name)
214
+ cs.set_project("cable-qual")
215
+ cs.publish(traces=[result], name="filtered-results")
216
+ # .close() shuts the publish thread pool; further calls raise.
217
+
218
+ # Two clients never share team/project state, caches, or lineage:
219
+ lab = Client(api_key="csk_lab_key", team="rf-lab")
220
+ prod = Client(api_key="csk_prod_key", team="production")
221
+ ```
222
+
223
+ Threading: instance isolation is guaranteed; concurrent `set_team` / `set_project`
224
+ on one client is unsupported. Prefer one `Client` per thread or logical session.
225
+
226
+ ## What the SDK sends (lineage / run reporting)
227
+
228
+ `cs.cloudscript()` is **opt-in** — nothing is sent until you call it. When active, the following may leave your machine:
229
+
230
+ | Channel | What is sent | Default | Disable |
231
+ |-|-|-|-|
232
+ | CloudScript source | Full file contents as a DataFile on each `publish()` | **Off until you say yes once** (see below) | `upload_source=False`, `CLOUDSPRITE_UPLOAD_SOURCE=0` or `CLOUDSPRITE_NO_SOURCE_UPLOAD=1` |
233
+ | Git state | HEAD sha, with optional `-dirty` suffix | On | `include_git=False` or `CLOUDSPRITE_NO_GIT_STATE=1` |
234
+ | Error text | Exception type + message only (no traceback frames, no absolute paths) | On | `include_error=False` or `CLOUDSPRITE_NO_ERROR_MESSAGE=1` |
235
+ | Run report | Dataset I/O ids, content hash, sdk version, seed, status, `purpose`, `params` (secrets redacted), the active work context → `POST /api/script-runs/` | Via hooks or `cs.report_run()` | Do not call `cloudscript` / `report_run` |
236
+ | Script arguments | `sys.argv[1:]` of a script run, secret flags and values redacted (never environment variables) | On | `include_argv=False` or `CLOUDSPRITE_NO_ARGV=1` |
237
+
238
+ **Source upload is opt-in.** The first time a `publish()` would attach your script's source and you are
239
+ at a terminal, the SDK asks once: `Upload this script's source to CloudSprite for run lineage? [y/N]`. Your
240
+ answer is saved in `~/.cloudsprite/config` under `[privacy]` (`upload_source = true` or `false`) and
241
+ never asked again on that machine; edit that line to change it. Without a saved answer, and with no
242
+ terminal (CI, notebooks, pipes), nothing is uploaded and a one-line notice says how to enable it.
243
+ Settings override the saved answer: `cs.cloudscript(__file__, upload_source=True)` (or `False`) for one script,
244
+ `CLOUDSPRITE_UPLOAD_SOURCE=1` (or `0`) for an environment. `CLOUDSPRITE_NO_SOURCE_UPLOAD=1` and
245
+ `CLOUDSPRITE_NO_TELEMETRY=1` force it off. Scripts that CloudSprite itself runs in the cloud always attach their
246
+ source, since it already lives on the server.
247
+
248
+ `cs.sprite()` and `cs.track_script()` remain as aliases of `cs.cloudscript()` (same callable, no deprecation warning).
249
+
250
+ **Not sent:** git remote URL, OS username, full tracebacks, or source lines from stack frames.
251
+
252
+ **Process hooks** (`sys.excepthook` + `atexit`) are **off by default**. Pass `install_hooks=True` for automatic failure capture and exit-time reporting; notebooks/REPLs should call `cs.report_run()` instead.
253
+
254
+ Blanket kill-switch:
255
+
256
+ ```bash
257
+ export CLOUDSPRITE_NO_TELEMETRY=1
258
+ ```
259
+
260
+ That disables source upload, git state, error text and argv (explicit kwargs still win).
261
+
262
+ ```python
263
+ # Typical CloudScript with automatic run report on exit
264
+ cs.cloudscript(__file__, install_hooks=True)
265
+
266
+ # Minimal: track I/O + hash, no source upload, no git, no error text
267
+ cs.cloudscript(__file__, upload_source=False, include_git=False, include_error=False)
268
+ ```
269
+
270
+ ### Work context
271
+
272
+ Say which engineering activity (and attempt) a run or dataset belongs to, and why:
273
+
274
+ ```python
275
+ cs.cloudscript(__file__, purpose="re-run S21 sweep after fixture change", params={"temp_c": 25})
276
+
277
+ with cs.work_context(activity="<activity-uuid>", attempt="<attempt-uuid>"):
278
+ cs.publish(traces=[s21], name="s21-sweep") # dataset stamped with the activity/attempt
279
+ ```
280
+
281
+ Every API request inside the block carries `X-CloudSprite-Work-Context`; the run report names the
282
+ same activity. `CLOUDSPRITE_ACTIVITY=<activity-uuid>` sets a process-wide default. Server runs
283
+ inherit their context from the run, so nothing is sent there.
284
+
285
+ ## Known limitations
286
+
287
+ - Lineage metadata fields on the dataset (`is_computed`, `input_datasets`, `script_hash`, etc.) are not
288
+ stored by the API yet, so `publish()` does not send them. The script source is attached as a data
289
+ file when you call `cs.cloudscript()`.
290
+ - Collection-level trace fan-out (`datasets.traces["S21"]` across many datasets) is not available; use
291
+ per-dataset access.
292
+
293
+ ## Support and security
294
+
295
+ Questions and bug reports: support@cloudsprite.io. Report security issues to security@cloudsprite.io
296
+ rather than in a public forum.
297
+
298
+ ## License
299
+
300
+ MIT.