cloudsprite 0.11.0__py3-none-any.whl

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 (70) hide show
  1. cloudsprite/__init__.py +451 -0
  2. cloudsprite/_antenna.py +83 -0
  3. cloudsprite/_auth.py +295 -0
  4. cloudsprite/_client.py +502 -0
  5. cloudsprite/_config.py +203 -0
  6. cloudsprite/_consent.py +104 -0
  7. cloudsprite/_context.py +945 -0
  8. cloudsprite/_exceptions.py +136 -0
  9. cloudsprite/_figure_models.py +158 -0
  10. cloudsprite/_figure_validation.py +168 -0
  11. cloudsprite/_filter_foster.py +165 -0
  12. cloudsprite/_filter_synthesis.py +400 -0
  13. cloudsprite/_filtering.py +134 -0
  14. cloudsprite/_impedance_matching.py +262 -0
  15. cloudsprite/_interpolation.py +47 -0
  16. cloudsprite/_lineage.py +775 -0
  17. cloudsprite/_link_budget.py +99 -0
  18. cloudsprite/_logging.py +53 -0
  19. cloudsprite/_mixed_mode.py +49 -0
  20. cloudsprite/_monte_carlo.py +193 -0
  21. cloudsprite/_noise_figure.py +44 -0
  22. cloudsprite/_pagination.py +130 -0
  23. cloudsprite/_parsers.py +75 -0
  24. cloudsprite/_publish.py +162 -0
  25. cloudsprite/_redact.py +179 -0
  26. cloudsprite/_response.py +63 -0
  27. cloudsprite/_resultset.py +65 -0
  28. cloudsprite/_rf_network.py +111 -0
  29. cloudsprite/_run_config.py +46 -0
  30. cloudsprite/_script_runner.py +217 -0
  31. cloudsprite/_script_workspace.py +271 -0
  32. cloudsprite/_sparameter_metrics.py +75 -0
  33. cloudsprite/_tdr.py +283 -0
  34. cloudsprite/_trace.py +112 -0
  35. cloudsprite/_version.py +23 -0
  36. cloudsprite/_visualizer.py +380 -0
  37. cloudsprite/_visualizer_cli.py +412 -0
  38. cloudsprite/_visualizer_preview.py +864 -0
  39. cloudsprite/_work_context.py +116 -0
  40. cloudsprite/_ws.py +577 -0
  41. cloudsprite/cli.py +300 -0
  42. cloudsprite/py.typed +0 -0
  43. cloudsprite/resources/__init__.py +1 -0
  44. cloudsprite/resources/_base.py +293 -0
  45. cloudsprite/resources/_models.py +50 -0
  46. cloudsprite/resources/cloudscripts.py +173 -0
  47. cloudsprite/resources/datasets.py +431 -0
  48. cloudsprite/resources/figures.py +282 -0
  49. cloudsprite/resources/instruments.py +295 -0
  50. cloudsprite/resources/notebooks.py +183 -0
  51. cloudsprite/resources/orbs.py +99 -0
  52. cloudsprite/resources/parameters.py +77 -0
  53. cloudsprite/resources/projects.py +182 -0
  54. cloudsprite/resources/related.py +125 -0
  55. cloudsprite/resources/reports.py +992 -0
  56. cloudsprite/resources/search.py +245 -0
  57. cloudsprite/resources/shares.py +229 -0
  58. cloudsprite/resources/sprites.py +15 -0
  59. cloudsprite/resources/tags.py +107 -0
  60. cloudsprite/resources/teams.py +86 -0
  61. cloudsprite/resources/traces.py +147 -0
  62. cloudsprite/resources/usage.py +152 -0
  63. cloudsprite/resources/visualizer_templates.py +466 -0
  64. cloudsprite/resources/workflows.py +59 -0
  65. cloudsprite-0.11.0.dist-info/METADATA +358 -0
  66. cloudsprite-0.11.0.dist-info/RECORD +70 -0
  67. cloudsprite-0.11.0.dist-info/WHEEL +5 -0
  68. cloudsprite-0.11.0.dist-info/entry_points.txt +3 -0
  69. cloudsprite-0.11.0.dist-info/licenses/LICENSE +21 -0
  70. cloudsprite-0.11.0.dist-info/top_level.txt +1 -0
cloudsprite/_tdr.py ADDED
@@ -0,0 +1,283 @@
1
+ """PNA-style low-pass step TDR from S11 or SDD11, backed by scikit-rf.
2
+
3
+ Mimics Keysight PNA option 010 / S9x010 defaults (Keysight AN 5989-5723):
4
+
5
+ * harmonic grid (Set Freq Low Pass: f_k = k * f_stop / N)
6
+ * DC from a 3-point real-part fit (Legacy), forced real
7
+ * Kaiser-Bessel window, beta=6 (Normal)
8
+ * inverse chirp-Z onto a dense time grid over the display window
9
+ (this is the PNA interpolator; a short IFFT looks jagged)
10
+ * open-circuit renormalization so an ideal open has late-time rho = 1
11
+ """
12
+
13
+ from __future__ import annotations
14
+
15
+ from dataclasses import dataclass
16
+ from typing import TYPE_CHECKING, Any, Literal
17
+
18
+ import numpy as np
19
+ from numpy.typing import NDArray
20
+
21
+ from cloudsprite._exceptions import ValidationError
22
+ from cloudsprite._mixed_mode import single_ended_to_sdd11
23
+ from cloudsprite._rf_network import NetworkInput, _network
24
+ from cloudsprite._trace import Trace
25
+
26
+ if TYPE_CHECKING:
27
+ from skrf import Frequency, Network
28
+
29
+ DEFAULT_WINDOW = "kaiser"
30
+ DEFAULT_KAISER_BETA = 6.0
31
+ DEFAULT_DC: Literal["three_point", "linear"] = "three_point"
32
+ DEFAULT_TRANSFORM: Literal["czt", "ifft"] = "czt"
33
+ # Time samples across [0, t_max]. 20001 / 20 ns = 1 ps, PNA-smooth.
34
+ DEFAULT_NPOINTS = 20001
35
+ DEFAULT_T_MAX_S = 20e-9
36
+ # rho == 1 is an open; clip just short so Z stays finite.
37
+ _RHO_CLIP = 0.9995
38
+ # PNA "already on a harmonic grid" tolerance, Hz.
39
+ _HARMONIC_ATOL_HZ = 0.5
40
+ # Lead-in so the impulse's left lobe is integrated before t=0.
41
+ _T_PRE_S = 2e-9
42
+
43
+
44
+ @dataclass(frozen=True)
45
+ class TdrStep:
46
+ """Low-pass step TDR response on ``[0, t_max_s]``.
47
+
48
+ Attributes:
49
+ time_s: Time axis in seconds, shape (N,), starting at 0.
50
+ rho: Step reflection coefficient (dimensionless), shape (N,).
51
+ impedance_ohm: ``z0 * (1 + rho) / (1 - rho)`` in ohms, shape (N,), with rho
52
+ clipped to +/-0.9995 so an open stays finite. A differential (SDD11)
53
+ response is the differential impedance.
54
+ z0_ohm: Reference impedance of the transformed reflection (e.g. 50 for
55
+ S11, 100 for SDD11 of a 50/50 pair).
56
+ parameter: ``"s11"`` or ``"sdd11"``, the parameter that was transformed.
57
+ """
58
+
59
+ time_s: NDArray[np.float64]
60
+ rho: NDArray[np.float64]
61
+ impedance_ohm: NDArray[np.float64]
62
+ z0_ohm: float
63
+ parameter: str
64
+
65
+ def to_traces(self, name: str = "TDR") -> list[Trace]:
66
+ """Impedance and rho as ``Trace`` objects, ready for ``cs.publish``.
67
+
68
+ Args:
69
+ name: Prefix for the trace names (``"<name> impedance"``, ``"<name> rho"``).
70
+
71
+ Returns:
72
+ Two traces with x = time (s): impedance (ohm) and rho (unitless).
73
+ Publish both with one call::
74
+
75
+ cs.publish(cs.tdr_step("dut.s2p", parameter="sdd11").to_traces("SDD11 TDR"),
76
+ name="DUT differential TDR")
77
+ """
78
+ return [
79
+ Trace(f"{name} impedance", self.time_s.copy(), self.impedance_ohm.copy(), "s", "ohm"),
80
+ Trace(f"{name} rho", self.time_s.copy(), self.rho.copy(), "s", ""),
81
+ ]
82
+
83
+
84
+ def _window_spec(name: str, kaiser_beta: float) -> Any:
85
+ """Map a window name to an skrf / scipy.get_window spec."""
86
+ key = str(name).strip().lower()
87
+ if key in {"none", "off", ""}:
88
+ return None
89
+ if key in {"kaiser", "kb", "normal"}:
90
+ return ("kaiser", float(kaiser_beta))
91
+ if key in {"minimum", "min", "rect", "rectangular"}:
92
+ return ("kaiser", 0.0)
93
+ if key in {"maximum", "max"}:
94
+ return ("kaiser", 13.0)
95
+ return name
96
+
97
+
98
+ def _to_harmonic_grid(net: Network) -> Network:
99
+ """Interpolate onto f_k = k * f_stop / N (PNA Set Freq Low Pass)."""
100
+ import skrf
101
+
102
+ f = np.asarray(net.f, dtype=float)
103
+ n = len(f)
104
+ if n < 2:
105
+ raise ValidationError("TDR needs at least two frequency points.")
106
+ f_stop = float(f[-1])
107
+ if f[0] <= 0 or f_stop <= 0:
108
+ raise ValidationError("TDR needs a positive start frequency; drop any 0 Hz point (DC is extrapolated).")
109
+ df = f_stop / n
110
+ if f[0] > df + _HARMONIC_ATOL_HZ:
111
+ raise ValidationError(
112
+ f"Sweep must start at or below f_stop / N = {df:.6g} Hz to resample onto the harmonic grid "
113
+ f"(starts at {f[0]:.6g} Hz); extrapolating below the measured band is not done."
114
+ )
115
+ if np.allclose(f, df * np.arange(1, n + 1), rtol=0.0, atol=_HARMONIC_ATOL_HZ):
116
+ return net.copy()
117
+ return net.interpolate(skrf.Frequency(df, f_stop, n, unit="Hz"), kind="linear", coords="cart")
118
+
119
+
120
+ def _dc_three_point(net: Network) -> NDArray[np.complex128]:
121
+ """PNA Legacy-style DC: polynomial through the first three Re{S} samples.
122
+
123
+ Im{S(0)} is forced to 0 (hermitian). Each entry is clipped to [-1, 1].
124
+ """
125
+ nports = net.nports
126
+ s0 = np.zeros((nports, nports), dtype=complex)
127
+ k = min(3, len(net))
128
+ f = np.asarray(net.f[:k], dtype=float)
129
+ for i in range(nports):
130
+ for j in range(nports):
131
+ re = np.real(net.s[:k, i, j])
132
+ val = float(re[0]) if k == 1 else float(np.polyval(np.polyfit(f, re, deg=k - 1), 0.0))
133
+ s0[i, j] = np.clip(val, -1.0, 1.0)
134
+ return s0
135
+
136
+
137
+ def _time_grid(t_max_s: float, npoints: int) -> tuple[NDArray[np.float64], NDArray[np.bool_]]:
138
+ """Even grid from -t_pre to t_max; return (full_t, keep_mask for t>=0)."""
139
+ dt = t_max_s / (npoints - 1)
140
+ n_pre = int(np.ceil(_T_PRE_S / dt))
141
+ t = np.arange(-n_pre, npoints, dtype=float) * dt
142
+ return t, t >= 0.0
143
+
144
+
145
+ def _czt_impulse(s_pos: NDArray[Any], f: NDArray[Any], t: NDArray[Any]) -> NDArray[np.float64]:
146
+ """Hermitian inverse FT of a one-sided spectrum via chirp-Z.
147
+
148
+ s_pos[k] lives at f[k] = k * df. Negative frequencies are implied by
149
+ conjugate symmetry, which is the PNA low-pass assumption.
150
+ """
151
+ from scipy.signal import CZT
152
+
153
+ s = np.asarray(s_pos, dtype=complex).ravel()
154
+ f = np.asarray(f, dtype=float).ravel()
155
+ t = np.asarray(t, dtype=float).ravel()
156
+ df = float(f[1] - f[0])
157
+ dt = float(t[1] - t[0])
158
+ # CZT[m] = sum_k s[k] * a^{-k} * w^{m k} with a, w chosen so
159
+ # that this equals sum_k s[k] exp(+j 2 pi k df t_m).
160
+ a = np.exp(-2j * np.pi * df * float(t[0]))
161
+ w = np.exp(+2j * np.pi * df * dt)
162
+ onesided = CZT(len(s), m=len(t), w=w, a=a)(s)
163
+ # Two-sided: df * (S0 + 2 Re sum_{k>=1} Sk e^{j 2 pi f_k t})
164
+ return np.asarray(df * (2.0 * np.real(onesided) - float(np.real(s[0]))), dtype=np.float64)
165
+
166
+
167
+ def _lowpass_step(
168
+ s11: Network, *, window: Any, npoints: int, t_max_s: float, transform: str
169
+ ) -> tuple[NDArray[np.float64], NDArray[np.float64]]:
170
+ """Return (t_seconds, rho) on [0, t_max] with `npoints` samples."""
171
+ from scipy.integrate import cumulative_trapezoid
172
+
173
+ if transform == "czt":
174
+ wnet = s11.copy() if window is None else s11.windowed(window=window, normalize=False, center_to_dc=True)
175
+ t, keep = _time_grid(t_max_s, npoints)
176
+ impulse = _czt_impulse(wnet.s[:, 0, 0], wnet.f, t)
177
+ step = cumulative_trapezoid(impulse, t, initial=0.0)
178
+ return t[keep][:npoints], np.real(step[keep][:npoints])
179
+ t, rho = s11.step_response(window=window, n=npoints)
180
+ keep = (t >= 0) & (t <= t_max_s)
181
+ return np.asarray(t)[keep], np.real(np.asarray(rho)[keep])
182
+
183
+
184
+ def _open_step_scale(frequency: Frequency, window: Any, npoints: int, *, t_max_s: float, transform: str) -> float:
185
+ """Late-time step height of an ideal open after the same transform."""
186
+ import skrf
187
+
188
+ ones = skrf.Network(frequency=frequency, s=np.ones((len(frequency), 1, 1), dtype=complex), z0=50.0)
189
+ _t, step = _lowpass_step(ones, window=window, npoints=npoints, t_max_s=t_max_s, transform=transform)
190
+ if step.size == 0:
191
+ return 1.0
192
+ scale = float(np.mean(step[-max(8, step.size // 20) :]))
193
+ return 1.0 if abs(scale) < 1e-12 else scale
194
+
195
+
196
+ def tdr_step(
197
+ network: NetworkInput,
198
+ *,
199
+ parameter: Literal["s11", "sdd11"] = "s11",
200
+ positive_port: int = 0,
201
+ negative_port: int = 1,
202
+ window: str = DEFAULT_WINDOW,
203
+ kaiser_beta: float = DEFAULT_KAISER_BETA,
204
+ dc: Literal["three_point", "linear"] = DEFAULT_DC,
205
+ transform: Literal["czt", "ifft"] = DEFAULT_TRANSFORM,
206
+ t_max_s: float = DEFAULT_T_MAX_S,
207
+ npoints: int = DEFAULT_NPOINTS,
208
+ renormalize: bool = True,
209
+ ) -> TdrStep:
210
+ """PNA-style low-pass step TDR of S11 or SDD11.
211
+
212
+ Args:
213
+ network: scikit-rf Network or local Touchstone path. A one-port is the
214
+ reflection itself (S11 or an existing SDD11). With two or more ports,
215
+ ``parameter="s11"`` uses port 1; ``parameter="sdd11"`` converts the
216
+ single-ended pair (``positive_port``, ``negative_port``, zero-based,
217
+ default ports 1 and 2) to SDD11 first. The sweep must start above 0 Hz.
218
+ parameter: ``"s11"`` or ``"sdd11"``; labels the result for a one-port.
219
+ positive_port: Zero-based positive leg for the SDD11 conversion.
220
+ negative_port: Zero-based negative leg for the SDD11 conversion.
221
+ window: ``"kaiser"`` (PNA Normal, ``kaiser_beta``), ``"minimum"``,
222
+ ``"maximum"``, ``"none"``, or any ``scipy.signal.get_window`` name.
223
+ kaiser_beta: Kaiser beta for ``window="kaiser"`` (PNA Normal is 6).
224
+ dc: ``"three_point"`` (PNA Legacy 3-point real fit) or ``"linear"``
225
+ (scikit-rf linear extrapolation) for the missing DC point.
226
+ transform: ``"czt"`` (PNA-style dense chirp-Z, default) or ``"ifft"``
227
+ (scikit-rf step_response, jagged on short sweeps).
228
+ t_max_s: Display window end in seconds (> 0).
229
+ npoints: Time samples across ``[0, t_max_s]`` (>= 2).
230
+ renormalize: Scale so an ideal open settles at rho = 1.
231
+
232
+ Returns:
233
+ TdrStep with time (s), rho and impedance (ohm). Input is unchanged. The sweep
234
+ is linearly resampled onto the PNA harmonic grid ``k * f_stop / N`` first.
235
+ Out of scope: band-pass/impulse mode, gating and time-to-frequency inverse.
236
+ Requires ``pip install cloudsprite[rf]``.
237
+
238
+ Raises:
239
+ ValidationError: Bad option, port pair or frequency sweep.
240
+ ImportError: Install with ``pip install cloudsprite[rf]``.
241
+
242
+ Example:
243
+ >>> step = cs.tdr_step("dut.s2p", parameter="sdd11")
244
+ >>> cs.publish(step.to_traces("SDD11 TDR"), name="DUT differential TDR")
245
+ """
246
+ if parameter not in ("s11", "sdd11"):
247
+ raise ValidationError(f"parameter must be 's11' or 'sdd11', got {parameter!r}.")
248
+ dc_key = str(dc).strip().lower()
249
+ if dc_key not in {"three_point", "3point", "legacy", "linear", "skrf"}:
250
+ raise ValidationError(f"dc must be 'three_point' or 'linear', got {dc!r}.")
251
+ kind = str(transform).strip().lower()
252
+ if kind not in {"czt", "ifft"}:
253
+ raise ValidationError(f"transform must be 'czt' or 'ifft', got {transform!r}.")
254
+ if npoints < 2:
255
+ raise ValidationError("npoints must be >= 2.")
256
+ if not np.isfinite(t_max_s) or t_max_s <= 0:
257
+ raise ValidationError("t_max_s must be positive and finite.")
258
+
259
+ net = _network(network)
260
+ if net.nports == 1:
261
+ refl = net
262
+ elif parameter == "sdd11":
263
+ refl = single_ended_to_sdd11(net, positive_port, negative_port)
264
+ else:
265
+ refl = net.s11
266
+ z0 = float(np.real(np.asarray(refl.z0)[0, 0]))
267
+ if z0 <= 0:
268
+ raise ValidationError("Reference impedance must be positive.")
269
+
270
+ grid = _to_harmonic_grid(refl)
271
+ if dc_key in {"three_point", "3point", "legacy"}:
272
+ filled = grid.extrapolate_to_dc(kind="linear", dc_sparam=_dc_three_point(grid))
273
+ else:
274
+ filled = grid.extrapolate_to_dc(kind="linear")
275
+
276
+ win = _window_spec(window, kaiser_beta)
277
+ t, rho = _lowpass_step(filled, window=win, npoints=npoints, t_max_s=t_max_s, transform=kind)
278
+ if renormalize:
279
+ rho = rho / _open_step_scale(filled.frequency, win, npoints, t_max_s=t_max_s, transform=kind)
280
+ rho = np.real(np.asarray(rho, dtype=float))
281
+ clipped = np.clip(rho, -_RHO_CLIP, _RHO_CLIP)
282
+ z = z0 * (1 + clipped) / (1 - clipped)
283
+ return TdrStep(np.asarray(t, dtype=np.float64), rho, z, z0, parameter)
cloudsprite/_trace.py ADDED
@@ -0,0 +1,112 @@
1
+ """Trace object: numpy arrays, operator overloading, scikit-rf conversion."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from collections.abc import Callable
6
+ from typing import Any
7
+
8
+ import numpy as np
9
+
10
+
11
+ class Trace:
12
+ """A trace with x/y data, units, and arithmetic support."""
13
+
14
+ def __init__(
15
+ self,
16
+ name: str,
17
+ x: np.ndarray,
18
+ y: np.ndarray,
19
+ x_unit: str = "",
20
+ y_unit: str = "",
21
+ dataset: Any = None,
22
+ ) -> None:
23
+ self.name = name
24
+ self.x = np.asarray(x)
25
+ self.y = np.asarray(y)
26
+ self.x_unit = x_unit
27
+ self.y_unit = y_unit
28
+ self.dataset = dataset
29
+
30
+ def _arithmetic(self, other: Any, op: Callable[[Any, Any], Any]) -> Trace:
31
+ if isinstance(other, (int, float)):
32
+ return Trace(
33
+ name=self.name,
34
+ x=self.x.copy(),
35
+ y=op(self.y, other),
36
+ x_unit=self.x_unit,
37
+ y_unit=self.y_unit,
38
+ dataset=self.dataset,
39
+ )
40
+ # Duck-type: accept anything with .x, .y, and .name (e.g. TraceRef from
41
+ # resources/traces.py). We only need those three attributes for
42
+ # align_traces and result construction.
43
+ if hasattr(other, "x") and hasattr(other, "y") and hasattr(other, "name"):
44
+ from cloudsprite._interpolation import align_traces
45
+
46
+ y1, y2, x_common = align_traces(self, other)
47
+ return Trace(
48
+ name=self.name,
49
+ x=x_common,
50
+ y=op(y1, y2),
51
+ x_unit=self.x_unit,
52
+ y_unit=self.y_unit,
53
+ dataset=self.dataset,
54
+ )
55
+ return NotImplemented # type: ignore[no-any-return]
56
+
57
+ def __add__(self, other: Any) -> Trace:
58
+ result = self._arithmetic(other, np.add)
59
+ return result
60
+
61
+ def __sub__(self, other: Any) -> Trace:
62
+ result = self._arithmetic(other, np.subtract)
63
+ return result
64
+
65
+ def __mul__(self, other: Any) -> Trace:
66
+ result = self._arithmetic(other, np.multiply)
67
+ return result
68
+
69
+ def __truediv__(self, other: Any) -> Trace:
70
+ result = self._arithmetic(other, np.divide)
71
+ return result
72
+
73
+ def __radd__(self, other: Any) -> Trace:
74
+ return self.__add__(other)
75
+
76
+ def __rmul__(self, other: Any) -> Trace:
77
+ return self.__mul__(other)
78
+
79
+ def to_network(self) -> Any:
80
+ """Convert trace to a scikit-rf Network object.
81
+
82
+ Requires the optional ``rf`` extra::
83
+
84
+ pip install cloudsprite[rf]
85
+
86
+ Requires y_unit == "dB" (magnitude). Raises ValidationError otherwise
87
+ because the dB-to-linear conversion (10^(y/20)) would produce
88
+ incorrect results for other units (linear, phase, etc.).
89
+ """
90
+ try:
91
+ import skrf
92
+ except ImportError as exc:
93
+ raise ImportError(
94
+ "scikit-rf is required for Trace.to_network(). " "Install it with: pip install cloudsprite[rf]"
95
+ ) from exc
96
+
97
+ from cloudsprite._exceptions import ValidationError
98
+
99
+ if self.y_unit != "dB":
100
+ raise ValidationError(
101
+ f"to_network() requires y_unit='dB', got y_unit={self.y_unit!r} on trace '{self.name}'. "
102
+ f"Convert your trace to dB magnitude before calling to_network()."
103
+ )
104
+
105
+ freq = skrf.Frequency.from_f(self.x, unit="Hz")
106
+ s_linear = 10 ** (self.y / 20.0)
107
+ s = s_linear.reshape(-1, 1, 1)
108
+ return skrf.Network(frequency=freq, s=s, name=self.name)
109
+
110
+ def __repr__(self) -> str:
111
+ pts = len(self.x) if self.x is not None else 0
112
+ return f"Trace('{self.name}', {pts} points)"
@@ -0,0 +1,23 @@
1
+ """Single source for the installed package version.
2
+
3
+ Three call sites resolved this independently (package ``__version__``, lineage
4
+ run reports, and the ``source_type=sdk`` dataset stamp), each repeating the
5
+ ``PackageNotFoundError`` fallback. They must agree — the version is reported to
6
+ the API — so it lives here.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ from importlib.metadata import PackageNotFoundError
12
+ from importlib.metadata import version as _pkg_version
13
+
14
+ # Reported when running from a source tree with no installed dist metadata.
15
+ UNKNOWN_VERSION = "0.0.0+unknown"
16
+
17
+
18
+ def sdk_version() -> str:
19
+ """The installed ``cloudsprite`` version, or ``UNKNOWN_VERSION``."""
20
+ try:
21
+ return _pkg_version("cloudsprite")
22
+ except PackageNotFoundError:
23
+ return UNKNOWN_VERSION