continuous-labs 0.1.3__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 (90) hide show
  1. continuous_labs-0.1.3/LICENSE +21 -0
  2. continuous_labs-0.1.3/PKG-INFO +562 -0
  3. continuous_labs-0.1.3/README-PYPI.md +547 -0
  4. continuous_labs-0.1.3/README.md +547 -0
  5. continuous_labs-0.1.3/pyproject.toml +54 -0
  6. continuous_labs-0.1.3/setup.cfg +4 -0
  7. continuous_labs-0.1.3/src/continuous/__init__.py +17 -0
  8. continuous_labs-0.1.3/src/continuous/_hooks/__init__.py +5 -0
  9. continuous_labs-0.1.3/src/continuous/_hooks/registration.py +13 -0
  10. continuous_labs-0.1.3/src/continuous/_hooks/sdkhooks.py +76 -0
  11. continuous_labs-0.1.3/src/continuous/_hooks/types.py +124 -0
  12. continuous_labs-0.1.3/src/continuous/_version.py +15 -0
  13. continuous_labs-0.1.3/src/continuous/basesdk.py +396 -0
  14. continuous_labs-0.1.3/src/continuous/errors/__init__.py +39 -0
  15. continuous_labs-0.1.3/src/continuous/errors/continuousdefaulterror.py +40 -0
  16. continuous_labs-0.1.3/src/continuous/errors/continuouserror.py +30 -0
  17. continuous_labs-0.1.3/src/continuous/errors/error.py +27 -0
  18. continuous_labs-0.1.3/src/continuous/errors/no_response_error.py +17 -0
  19. continuous_labs-0.1.3/src/continuous/errors/responsevalidationerror.py +27 -0
  20. continuous_labs-0.1.3/src/continuous/httpclient.py +125 -0
  21. continuous_labs-0.1.3/src/continuous/models/__init__.py +294 -0
  22. continuous_labs-0.1.3/src/continuous/models/build_simulatorop.py +84 -0
  23. continuous_labs-0.1.3/src/continuous/models/buildsimulatorrequest.py +81 -0
  24. continuous_labs-0.1.3/src/continuous/models/buildworldrequest.py +38 -0
  25. continuous_labs-0.1.3/src/continuous/models/cancel_simulator_buildop.py +18 -0
  26. continuous_labs-0.1.3/src/continuous/models/cancel_world_buildop.py +18 -0
  27. continuous_labs-0.1.3/src/continuous/models/createdsimulation.py +83 -0
  28. continuous_labs-0.1.3/src/continuous/models/createsimulationrequest.py +38 -0
  29. continuous_labs-0.1.3/src/continuous/models/delete_simulationop.py +18 -0
  30. continuous_labs-0.1.3/src/continuous/models/delete_simulatorop.py +18 -0
  31. continuous_labs-0.1.3/src/continuous/models/delete_worldop.py +18 -0
  32. continuous_labs-0.1.3/src/continuous/models/fork_simulationop.py +25 -0
  33. continuous_labs-0.1.3/src/continuous/models/forksimulationrequest.py +38 -0
  34. continuous_labs-0.1.3/src/continuous/models/get_simulationop.py +18 -0
  35. continuous_labs-0.1.3/src/continuous/models/get_simulatorop.py +18 -0
  36. continuous_labs-0.1.3/src/continuous/models/get_worldop.py +18 -0
  37. continuous_labs-0.1.3/src/continuous/models/list_simulation_stepsop.py +52 -0
  38. continuous_labs-0.1.3/src/continuous/models/list_simulationsop.py +69 -0
  39. continuous_labs-0.1.3/src/continuous/models/list_simulatorsop.py +70 -0
  40. continuous_labs-0.1.3/src/continuous/models/list_worldsop.py +45 -0
  41. continuous_labs-0.1.3/src/continuous/models/listsimulationsresponse.py +37 -0
  42. continuous_labs-0.1.3/src/continuous/models/listsimulationstepsresponse.py +37 -0
  43. continuous_labs-0.1.3/src/continuous/models/listsimulatorsresponse.py +37 -0
  44. continuous_labs-0.1.3/src/continuous/models/listworldsresponse.py +37 -0
  45. continuous_labs-0.1.3/src/continuous/models/mint_simulation_tokenop.py +28 -0
  46. continuous_labs-0.1.3/src/continuous/models/mintsimulationtokenrequest.py +15 -0
  47. continuous_labs-0.1.3/src/continuous/models/resourceerror.py +20 -0
  48. continuous_labs-0.1.3/src/continuous/models/security.py +42 -0
  49. continuous_labs-0.1.3/src/continuous/models/simulation.py +73 -0
  50. continuous_labs-0.1.3/src/continuous/models/simulationtoken.py +21 -0
  51. continuous_labs-0.1.3/src/continuous/models/simulator.py +83 -0
  52. continuous_labs-0.1.3/src/continuous/models/start_simulationop.py +18 -0
  53. continuous_labs-0.1.3/src/continuous/models/start_worldop.py +18 -0
  54. continuous_labs-0.1.3/src/continuous/models/step.py +20 -0
  55. continuous_labs-0.1.3/src/continuous/models/stop_simulationop.py +18 -0
  56. continuous_labs-0.1.3/src/continuous/models/stop_worldop.py +18 -0
  57. continuous_labs-0.1.3/src/continuous/models/world.py +76 -0
  58. continuous_labs-0.1.3/src/continuous/models/worldsimulation.py +20 -0
  59. continuous_labs-0.1.3/src/continuous/py.typed +1 -0
  60. continuous_labs-0.1.3/src/continuous/sdk.py +189 -0
  61. continuous_labs-0.1.3/src/continuous/sdkconfiguration.py +49 -0
  62. continuous_labs-0.1.3/src/continuous/simulations.py +1915 -0
  63. continuous_labs-0.1.3/src/continuous/simulators.py +1057 -0
  64. continuous_labs-0.1.3/src/continuous/types/__init__.py +24 -0
  65. continuous_labs-0.1.3/src/continuous/types/base64fileinput.py +43 -0
  66. continuous_labs-0.1.3/src/continuous/types/basemodel.py +77 -0
  67. continuous_labs-0.1.3/src/continuous/utils/__init__.py +180 -0
  68. continuous_labs-0.1.3/src/continuous/utils/annotations.py +79 -0
  69. continuous_labs-0.1.3/src/continuous/utils/datetimes.py +37 -0
  70. continuous_labs-0.1.3/src/continuous/utils/dynamic_imports.py +54 -0
  71. continuous_labs-0.1.3/src/continuous/utils/enums.py +134 -0
  72. continuous_labs-0.1.3/src/continuous/utils/eventstreaming.py +326 -0
  73. continuous_labs-0.1.3/src/continuous/utils/forms.py +239 -0
  74. continuous_labs-0.1.3/src/continuous/utils/headers.py +136 -0
  75. continuous_labs-0.1.3/src/continuous/utils/logger.py +27 -0
  76. continuous_labs-0.1.3/src/continuous/utils/metadata.py +119 -0
  77. continuous_labs-0.1.3/src/continuous/utils/queryparams.py +217 -0
  78. continuous_labs-0.1.3/src/continuous/utils/requestbodies.py +67 -0
  79. continuous_labs-0.1.3/src/continuous/utils/retries.py +372 -0
  80. continuous_labs-0.1.3/src/continuous/utils/security.py +215 -0
  81. continuous_labs-0.1.3/src/continuous/utils/serializers.py +306 -0
  82. continuous_labs-0.1.3/src/continuous/utils/unmarshal_json_response.py +38 -0
  83. continuous_labs-0.1.3/src/continuous/utils/url.py +155 -0
  84. continuous_labs-0.1.3/src/continuous/utils/values.py +139 -0
  85. continuous_labs-0.1.3/src/continuous/worlds.py +1425 -0
  86. continuous_labs-0.1.3/src/continuous_labs.egg-info/PKG-INFO +562 -0
  87. continuous_labs-0.1.3/src/continuous_labs.egg-info/SOURCES.txt +88 -0
  88. continuous_labs-0.1.3/src/continuous_labs.egg-info/dependency_links.txt +1 -0
  89. continuous_labs-0.1.3/src/continuous_labs.egg-info/requires.txt +3 -0
  90. continuous_labs-0.1.3/src/continuous_labs.egg-info/top_level.txt +1 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Continuous Labs, Inc.
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,562 @@
1
+ Metadata-Version: 2.4
2
+ Name: continuous-labs
3
+ Version: 0.1.3
4
+ Summary: Python SDK for the Continuous Simulation API.
5
+ Author: Continuous Labs
6
+ License: MIT
7
+ Project-URL: repository, https://github.com/continuous-labs-ai/continuous-python
8
+ Requires-Python: >=3.10
9
+ Description-Content-Type: text/markdown
10
+ License-File: LICENSE
11
+ Requires-Dist: httpcore>=1.0.9
12
+ Requires-Dist: httpx>=0.28.1
13
+ Requires-Dist: pydantic>=2.11.2
14
+ Dynamic: license-file
15
+
16
+ # continuous
17
+
18
+ Python SDK for the Continuous Simulation API.
19
+
20
+ Speakeasy generates this SDK from the public OpenAPI contract in [continuous-labs-ai/continuous](https://github.com/continuous-labs-ai/continuous/blob/main/openapi/simulation.yaml). Report API problems there and SDK packaging problems here.
21
+
22
+ <!-- Start Summary [summary] -->
23
+ ## Summary
24
+
25
+ Continuous Simulation API: The Continuous Simulation API builds reusable Simulators and runs isolated Simulations and Worlds. This document describes the stable v1 public contract.
26
+ <!-- End Summary [summary] -->
27
+
28
+ <!-- Start Table of Contents [toc] -->
29
+ ## Table of Contents
30
+ <!-- $toc-max-depth=2 -->
31
+ * [continuous](https://github.com/continuous-labs-ai/continuous-python/blob/master/#continuous)
32
+ * [SDK Installation](https://github.com/continuous-labs-ai/continuous-python/blob/master/#sdk-installation)
33
+ * [IDE Support](https://github.com/continuous-labs-ai/continuous-python/blob/master/#ide-support)
34
+ * [SDK Example Usage](https://github.com/continuous-labs-ai/continuous-python/blob/master/#sdk-example-usage)
35
+ * [Authentication](https://github.com/continuous-labs-ai/continuous-python/blob/master/#authentication)
36
+ * [Available Resources and Operations](https://github.com/continuous-labs-ai/continuous-python/blob/master/#available-resources-and-operations)
37
+ * [File uploads](https://github.com/continuous-labs-ai/continuous-python/blob/master/#file-uploads)
38
+ * [Retries](https://github.com/continuous-labs-ai/continuous-python/blob/master/#retries)
39
+ * [Error Handling](https://github.com/continuous-labs-ai/continuous-python/blob/master/#error-handling)
40
+ * [Server Selection](https://github.com/continuous-labs-ai/continuous-python/blob/master/#server-selection)
41
+ * [Custom HTTP Client](https://github.com/continuous-labs-ai/continuous-python/blob/master/#custom-http-client)
42
+ * [Resource Management](https://github.com/continuous-labs-ai/continuous-python/blob/master/#resource-management)
43
+ * [Debugging](https://github.com/continuous-labs-ai/continuous-python/blob/master/#debugging)
44
+ * [Development](https://github.com/continuous-labs-ai/continuous-python/blob/master/#development)
45
+ * [Maturity](https://github.com/continuous-labs-ai/continuous-python/blob/master/#maturity)
46
+ * [Contributions](https://github.com/continuous-labs-ai/continuous-python/blob/master/#contributions)
47
+
48
+ <!-- End Table of Contents [toc] -->
49
+
50
+ <!-- Start SDK Installation [installation] -->
51
+ ## SDK Installation
52
+
53
+ > [!NOTE]
54
+ > **Python version upgrade policy**
55
+ >
56
+ > Once a Python version reaches its [official end of life date](https://devguide.python.org/versions/), a 3-month grace period is provided for users to upgrade. Following this grace period, the minimum python version supported in the SDK will be updated.
57
+
58
+ The SDK can be installed with *uv*, *pip*, or *poetry* package managers.
59
+
60
+ ### uv
61
+
62
+ *uv* is a fast Python package installer and resolver, designed as a drop-in replacement for pip and pip-tools. It's recommended for its speed and modern Python tooling capabilities.
63
+
64
+ ```bash
65
+ uv add continuous-labs
66
+ ```
67
+
68
+ ### PIP
69
+
70
+ *PIP* is the default package installer for Python, enabling easy installation and management of packages from PyPI via the command line.
71
+
72
+ ```bash
73
+ pip install continuous-labs
74
+ ```
75
+
76
+ ### Poetry
77
+
78
+ *Poetry* is a modern tool that simplifies dependency management and package publishing by using a single `pyproject.toml` file to handle project metadata and dependencies.
79
+
80
+ ```bash
81
+ poetry add continuous-labs
82
+ ```
83
+
84
+ ### Shell and script usage with `uv`
85
+
86
+ You can use this SDK in a Python shell with [uv](https://docs.astral.sh/uv/) and the `uvx` command that comes with it like so:
87
+
88
+ ```shell
89
+ uvx --from continuous-labs python
90
+ ```
91
+
92
+ It's also possible to write a standalone Python script without needing to set up a whole project like so:
93
+
94
+ ```python
95
+ #!/usr/bin/env -S uv run --script
96
+ # /// script
97
+ # requires-python = ">=3.10"
98
+ # dependencies = [
99
+ # "continuous-labs",
100
+ # ]
101
+ # ///
102
+
103
+ from continuous import Continuous
104
+
105
+ sdk = Continuous(
106
+ # SDK arguments
107
+ )
108
+
109
+ # Rest of script here...
110
+ ```
111
+
112
+ Once that is saved to a file, you can run it with `uv run script.py` where
113
+ `script.py` can be replaced with the actual file name.
114
+ <!-- End SDK Installation [installation] -->
115
+
116
+ <!-- Start IDE Support [idesupport] -->
117
+ ## IDE Support
118
+
119
+ ### PyCharm
120
+
121
+ Generally, the SDK will work well with most IDEs out of the box. However, when using PyCharm, you can enjoy much better integration with Pydantic by installing an additional plugin.
122
+
123
+ - [PyCharm Pydantic Plugin](https://docs.pydantic.dev/latest/integrations/pycharm/)
124
+ <!-- End IDE Support [idesupport] -->
125
+
126
+ <!-- Start SDK Example Usage [usage] -->
127
+ ## SDK Example Usage
128
+
129
+ ### Example
130
+
131
+ ```python
132
+ # Synchronous Example
133
+ from continuous import Continuous
134
+ import os
135
+
136
+
137
+ with Continuous(
138
+ api_key_auth=os.getenv("CONTINUOUS_API_KEY_AUTH", ""),
139
+ ) as c_client:
140
+
141
+ res = c_client.simulations.list_simulations(limit=50)
142
+
143
+ # Handle response
144
+ print(res)
145
+ ```
146
+
147
+ </br>
148
+
149
+ The same SDK client can also be used to make asynchronous requests by importing asyncio.
150
+
151
+ ```python
152
+ # Asynchronous Example
153
+ import asyncio
154
+ from continuous import Continuous
155
+ import os
156
+
157
+ async def main():
158
+
159
+ async with Continuous(
160
+ api_key_auth=os.getenv("CONTINUOUS_API_KEY_AUTH", ""),
161
+ ) as c_client:
162
+
163
+ res = await c_client.simulations.list_simulations_async(limit=50)
164
+
165
+ # Handle response
166
+ print(res)
167
+
168
+ asyncio.run(main())
169
+ ```
170
+ <!-- End SDK Example Usage [usage] -->
171
+
172
+ <!-- Start Authentication [security] -->
173
+ ## Authentication
174
+
175
+ ### Per-Client Security Schemes
176
+
177
+ This SDK supports the following security scheme globally:
178
+
179
+ | Name | Type | Scheme | Environment Variable |
180
+ | -------------- | ---- | ----------- | ------------------------- |
181
+ | `api_key_auth` | http | HTTP Bearer | `CONTINUOUS_API_KEY_AUTH` |
182
+
183
+ To authenticate with the API the `api_key_auth` parameter must be set when initializing the SDK client instance. For example:
184
+ ```python
185
+ from continuous import Continuous
186
+ import os
187
+
188
+
189
+ with Continuous(
190
+ api_key_auth=os.getenv("CONTINUOUS_API_KEY_AUTH", ""),
191
+ ) as c_client:
192
+
193
+ res = c_client.simulations.list_simulations(limit=50)
194
+
195
+ # Handle response
196
+ print(res)
197
+
198
+ ```
199
+ <!-- End Authentication [security] -->
200
+
201
+ <!-- Start Available Resources and Operations [operations] -->
202
+ ## Available Resources and Operations
203
+
204
+ <details open>
205
+ <summary>Available methods</summary>
206
+
207
+ ### [Simulations](https://github.com/continuous-labs-ai/continuous-python/blob/master/docs/sdks/simulations/README.md)
208
+
209
+ * [list_simulations](https://github.com/continuous-labs-ai/continuous-python/blob/master/docs/sdks/simulations/README.md#list_simulations) - List Simulations
210
+ * [create_simulation](https://github.com/continuous-labs-ai/continuous-python/blob/master/docs/sdks/simulations/README.md#create_simulation) - Create Simulation
211
+ * [delete_simulation](https://github.com/continuous-labs-ai/continuous-python/blob/master/docs/sdks/simulations/README.md#delete_simulation) - Delete Simulation
212
+ * [get_simulation](https://github.com/continuous-labs-ai/continuous-python/blob/master/docs/sdks/simulations/README.md#get_simulation) - Get Simulation
213
+ * [fork_simulation](https://github.com/continuous-labs-ai/continuous-python/blob/master/docs/sdks/simulations/README.md#fork_simulation) - Fork Simulation
214
+ * [start_simulation](https://github.com/continuous-labs-ai/continuous-python/blob/master/docs/sdks/simulations/README.md#start_simulation) - Start Simulation
215
+ * [list_simulation_steps](https://github.com/continuous-labs-ai/continuous-python/blob/master/docs/sdks/simulations/README.md#list_simulation_steps) - List Simulation Steps
216
+ * [stop_simulation](https://github.com/continuous-labs-ai/continuous-python/blob/master/docs/sdks/simulations/README.md#stop_simulation) - Stop Simulation
217
+ * [mint_simulation_token](https://github.com/continuous-labs-ai/continuous-python/blob/master/docs/sdks/simulations/README.md#mint_simulation_token) - Mint Simulation Token
218
+
219
+ ### [Simulators](https://github.com/continuous-labs-ai/continuous-python/blob/master/docs/sdks/simulators/README.md)
220
+
221
+ * [list_simulators](https://github.com/continuous-labs-ai/continuous-python/blob/master/docs/sdks/simulators/README.md#list_simulators) - List Simulators
222
+ * [build_simulator](https://github.com/continuous-labs-ai/continuous-python/blob/master/docs/sdks/simulators/README.md#build_simulator) - Build Simulator
223
+ * [delete_simulator](https://github.com/continuous-labs-ai/continuous-python/blob/master/docs/sdks/simulators/README.md#delete_simulator) - Delete Simulator
224
+ * [get_simulator](https://github.com/continuous-labs-ai/continuous-python/blob/master/docs/sdks/simulators/README.md#get_simulator) - Get Simulator
225
+ * [cancel_simulator_build](https://github.com/continuous-labs-ai/continuous-python/blob/master/docs/sdks/simulators/README.md#cancel_simulator_build) - Cancel Simulator Build
226
+
227
+ ### [Worlds](https://github.com/continuous-labs-ai/continuous-python/blob/master/docs/sdks/worlds/README.md)
228
+
229
+ * [list_worlds](https://github.com/continuous-labs-ai/continuous-python/blob/master/docs/sdks/worlds/README.md#list_worlds) - List Worlds
230
+ * [build_world](https://github.com/continuous-labs-ai/continuous-python/blob/master/docs/sdks/worlds/README.md#build_world) - Build World
231
+ * [delete_world](https://github.com/continuous-labs-ai/continuous-python/blob/master/docs/sdks/worlds/README.md#delete_world) - Delete World
232
+ * [get_world](https://github.com/continuous-labs-ai/continuous-python/blob/master/docs/sdks/worlds/README.md#get_world) - Get World
233
+ * [cancel_world_build](https://github.com/continuous-labs-ai/continuous-python/blob/master/docs/sdks/worlds/README.md#cancel_world_build) - Cancel World Build
234
+ * [start_world](https://github.com/continuous-labs-ai/continuous-python/blob/master/docs/sdks/worlds/README.md#start_world) - Start World
235
+ * [stop_world](https://github.com/continuous-labs-ai/continuous-python/blob/master/docs/sdks/worlds/README.md#stop_world) - Stop World
236
+
237
+ </details>
238
+ <!-- End Available Resources and Operations [operations] -->
239
+
240
+ <!-- Start File uploads [file-upload] -->
241
+ ## File uploads
242
+
243
+ Certain SDK methods accept file objects as part of a request body or multi-part request. It is possible and typically recommended to upload files as a stream rather than reading the entire contents into memory. This avoids excessive memory consumption and potentially crashing with out-of-memory errors when working with very large files. The following example demonstrates how to attach a file stream to a request.
244
+
245
+ > [!TIP]
246
+ >
247
+ > For endpoints that handle file uploads bytes arrays can also be used. However, using streams is recommended for large files.
248
+ >
249
+
250
+ ```python
251
+ from continuous import Continuous
252
+ import os
253
+
254
+
255
+ with Continuous(
256
+ api_key_auth=os.getenv("CONTINUOUS_API_KEY_AUTH", ""),
257
+ ) as c_client:
258
+
259
+ res = c_client.simulators.build_simulator(request={
260
+ "filter_": [],
261
+ "instructions": "Return stable example data for every operation.",
262
+ "name": "billing-api",
263
+ "spec_kind": "openapi",
264
+ })
265
+
266
+ # Handle response
267
+ print(res)
268
+
269
+ ```
270
+ <!-- End File uploads [file-upload] -->
271
+
272
+ <!-- Start Retries [retries] -->
273
+ ## Retries
274
+
275
+ Some of the endpoints in this SDK support retries. If you use the SDK without any configuration, it will fall back to the default retry strategy provided by the API. However, the default retry strategy can be overridden on a per-operation basis, or across the entire SDK.
276
+
277
+ To change the default retry strategy for a single API call, simply provide a `RetryConfig` object to the call:
278
+ ```python
279
+ from continuous import Continuous
280
+ from continuous.utils import BackoffStrategy, RetryConfig
281
+ import os
282
+
283
+
284
+ with Continuous(
285
+ api_key_auth=os.getenv("CONTINUOUS_API_KEY_AUTH", ""),
286
+ ) as c_client:
287
+
288
+ res = c_client.simulations.list_simulations(limit=50,
289
+ RetryConfig("backoff", BackoffStrategy(1, 50, 1.1, 100), False))
290
+
291
+ # Handle response
292
+ print(res)
293
+
294
+ ```
295
+
296
+ If you'd like to override the default retry strategy for all operations that support retries, you can use the `retry_config` optional parameter when initializing the SDK:
297
+ ```python
298
+ from continuous import Continuous
299
+ from continuous.utils import BackoffStrategy, RetryConfig
300
+ import os
301
+
302
+
303
+ with Continuous(
304
+ retry_config=RetryConfig("backoff", BackoffStrategy(1, 50, 1.1, 100), False),
305
+ api_key_auth=os.getenv("CONTINUOUS_API_KEY_AUTH", ""),
306
+ ) as c_client:
307
+
308
+ res = c_client.simulations.list_simulations(limit=50)
309
+
310
+ # Handle response
311
+ print(res)
312
+
313
+ ```
314
+ <!-- End Retries [retries] -->
315
+
316
+ <!-- Start Error Handling [errors] -->
317
+ ## Error Handling
318
+
319
+ [`ContinuousError`](https://github.com/continuous-labs-ai/continuous-python/blob/master/./src/continuous/errors/continuouserror.py) is the base class for all HTTP error responses. It has the following properties:
320
+
321
+ | Property | Type | Description |
322
+ | ------------------ | ---------------- | --------------------------------------------------------------------------------------- |
323
+ | `err.message` | `str` | Error message |
324
+ | `err.status_code` | `int` | HTTP response status code eg `404` |
325
+ | `err.headers` | `httpx.Headers` | HTTP response headers |
326
+ | `err.body` | `str` | HTTP body. Can be empty string if no body is returned. |
327
+ | `err.raw_response` | `httpx.Response` | Raw HTTP response |
328
+ | `err.data` | | Optional. Some errors may contain structured data. [See Error Classes](https://github.com/continuous-labs-ai/continuous-python/blob/master/#error-classes). |
329
+
330
+ ### Example
331
+ ```python
332
+ from continuous import Continuous, errors
333
+ import os
334
+
335
+
336
+ with Continuous(
337
+ api_key_auth=os.getenv("CONTINUOUS_API_KEY_AUTH", ""),
338
+ ) as c_client:
339
+ res = None
340
+ try:
341
+
342
+ res = c_client.simulations.list_simulations(limit=50)
343
+
344
+ # Handle response
345
+ print(res)
346
+
347
+
348
+ except errors.ContinuousError as e:
349
+ # The base class for HTTP error responses
350
+ print(e.message)
351
+ print(e.status_code)
352
+ print(e.body)
353
+ print(e.headers)
354
+ print(e.raw_response)
355
+
356
+ # Depending on the method different errors may be thrown
357
+ if isinstance(e, errors.Error):
358
+ print(e.data.code) # str
359
+ print(e.data.detail) # str
360
+ ```
361
+
362
+ ### Error Classes
363
+ **Primary errors:**
364
+ * [`ContinuousError`](https://github.com/continuous-labs-ai/continuous-python/blob/master/./src/continuous/errors/continuouserror.py): The base class for HTTP error responses.
365
+ * [`Error`](https://github.com/continuous-labs-ai/continuous-python/blob/master/./src/continuous/errors/error.py): Bad Request.
366
+
367
+ <details><summary>Less common errors (5)</summary>
368
+
369
+ <br />
370
+
371
+ **Network errors:**
372
+ * [`httpx.RequestError`](https://www.python-httpx.org/exceptions/#httpx.RequestError): Base class for request errors.
373
+ * [`httpx.ConnectError`](https://www.python-httpx.org/exceptions/#httpx.ConnectError): HTTP client was unable to make a request to a server.
374
+ * [`httpx.TimeoutException`](https://www.python-httpx.org/exceptions/#httpx.TimeoutException): HTTP request timed out.
375
+
376
+
377
+ **Inherit from [`ContinuousError`](https://github.com/continuous-labs-ai/continuous-python/blob/master/./src/continuous/errors/continuouserror.py)**:
378
+ * [`ResponseValidationError`](https://github.com/continuous-labs-ai/continuous-python/blob/master/./src/continuous/errors/responsevalidationerror.py): Type mismatch between the response data and the expected Pydantic model. Provides access to the Pydantic validation error via the `cause` attribute.
379
+
380
+ </details>
381
+ <!-- End Error Handling [errors] -->
382
+
383
+ <!-- Start Server Selection [server] -->
384
+ ## Server Selection
385
+
386
+ ### Override Server URL Per-Client
387
+
388
+ The default server can be overridden globally by passing a URL to the `server_url: str` optional parameter when initializing the SDK client instance. For example:
389
+ ```python
390
+ from continuous import Continuous
391
+ import os
392
+
393
+
394
+ with Continuous(
395
+ server_url="https://api.continuouslabs.ai",
396
+ api_key_auth=os.getenv("CONTINUOUS_API_KEY_AUTH", ""),
397
+ ) as c_client:
398
+
399
+ res = c_client.simulations.list_simulations(limit=50)
400
+
401
+ # Handle response
402
+ print(res)
403
+
404
+ ```
405
+ <!-- End Server Selection [server] -->
406
+
407
+ <!-- Start Custom HTTP Client [http-client] -->
408
+ ## Custom HTTP Client
409
+
410
+ The Python SDK makes API calls using the [httpx](https://www.python-httpx.org/) HTTP library. In order to provide a convenient way to configure timeouts, cookies, proxies, custom headers, and other low-level configuration, you can initialize the SDK client with your own HTTP client instance.
411
+ Depending on whether you are using the sync or async version of the SDK, you can pass an instance of `HttpClient` or `AsyncHttpClient` respectively, which are Protocol's ensuring that the client has the necessary methods to make API calls.
412
+ This allows you to wrap the client with your own custom logic, such as adding custom headers, logging, or error handling, or you can just pass an instance of `httpx.Client` or `httpx.AsyncClient` directly.
413
+
414
+ For example, you could specify a header for every request that this sdk makes as follows:
415
+ ```python
416
+ from continuous import Continuous
417
+ import httpx
418
+
419
+ http_client = httpx.Client(headers={"x-custom-header": "someValue"})
420
+ s = Continuous(client=http_client)
421
+ ```
422
+
423
+ or you could wrap the client with your own custom logic:
424
+ ```python
425
+ from continuous import Continuous
426
+ from continuous.httpclient import AsyncHttpClient
427
+ import httpx
428
+
429
+ class CustomClient(AsyncHttpClient):
430
+ client: AsyncHttpClient
431
+
432
+ def __init__(self, client: AsyncHttpClient):
433
+ self.client = client
434
+
435
+ async def send(
436
+ self,
437
+ request: httpx.Request,
438
+ *,
439
+ stream: bool = False,
440
+ auth: Union[
441
+ httpx._types.AuthTypes, httpx._client.UseClientDefault, None
442
+ ] = httpx.USE_CLIENT_DEFAULT,
443
+ follow_redirects: Union[
444
+ bool, httpx._client.UseClientDefault
445
+ ] = httpx.USE_CLIENT_DEFAULT,
446
+ ) -> httpx.Response:
447
+ request.headers["Client-Level-Header"] = "added by client"
448
+
449
+ return await self.client.send(
450
+ request, stream=stream, auth=auth, follow_redirects=follow_redirects
451
+ )
452
+
453
+ def build_request(
454
+ self,
455
+ method: str,
456
+ url: httpx._types.URLTypes,
457
+ *,
458
+ content: Optional[httpx._types.RequestContent] = None,
459
+ data: Optional[httpx._types.RequestData] = None,
460
+ files: Optional[httpx._types.RequestFiles] = None,
461
+ json: Optional[Any] = None,
462
+ params: Optional[httpx._types.QueryParamTypes] = None,
463
+ headers: Optional[httpx._types.HeaderTypes] = None,
464
+ cookies: Optional[httpx._types.CookieTypes] = None,
465
+ timeout: Union[
466
+ httpx._types.TimeoutTypes, httpx._client.UseClientDefault
467
+ ] = httpx.USE_CLIENT_DEFAULT,
468
+ extensions: Optional[httpx._types.RequestExtensions] = None,
469
+ ) -> httpx.Request:
470
+ return self.client.build_request(
471
+ method,
472
+ url,
473
+ content=content,
474
+ data=data,
475
+ files=files,
476
+ json=json,
477
+ params=params,
478
+ headers=headers,
479
+ cookies=cookies,
480
+ timeout=timeout,
481
+ extensions=extensions,
482
+ )
483
+
484
+ s = Continuous(async_client=CustomClient(httpx.AsyncClient()))
485
+ ```
486
+ ### httpx2 (Pydantic's httpx fork)
487
+
488
+ [httpx2](https://httpx2.pydantic.dev/) is Pydantic's maintained fork of `httpx`. To run this SDK on httpx2, call `alias_httpx()` at your program's entry point, before importing the SDK, so every `import httpx` — including the ones inside the SDK — resolves to `httpx2`:
489
+ ```python
490
+ import httpx2
491
+
492
+ httpx2.alias_httpx()
493
+
494
+ from continuous import Continuous
495
+
496
+ s = Continuous()
497
+ ```
498
+
499
+ An SDK can also be generated against httpx2 directly, so it depends on the fork instead of `httpx`, by setting `python.httpClientLibrary: httpx2` in `gen.yaml`.
500
+ <!-- End Custom HTTP Client [http-client] -->
501
+
502
+ <!-- Start Resource Management [resource-management] -->
503
+ ## Resource Management
504
+
505
+ The `Continuous` class implements the context manager protocol and registers a finalizer function to close the underlying sync and async HTTPX clients it uses under the hood. This will close HTTP connections, release memory and free up other resources held by the SDK. In short-lived Python programs and notebooks that make a few SDK method calls, resource management may not be a concern. However, in longer-lived programs, it is beneficial to create a single SDK instance via a [context manager][context-manager] and reuse it across the application.
506
+
507
+ [context-manager]: https://docs.python.org/3/reference/datamodel.html#context-managers
508
+
509
+ ```python
510
+ from continuous import Continuous
511
+ import os
512
+ def main():
513
+
514
+ with Continuous(
515
+ api_key_auth=os.getenv("CONTINUOUS_API_KEY_AUTH", ""),
516
+ ) as c_client:
517
+ # Rest of application here...
518
+
519
+
520
+ # Or when using async:
521
+ async def amain():
522
+
523
+ async with Continuous(
524
+ api_key_auth=os.getenv("CONTINUOUS_API_KEY_AUTH", ""),
525
+ ) as c_client:
526
+ # Rest of application here...
527
+ ```
528
+ <!-- End Resource Management [resource-management] -->
529
+
530
+ <!-- Start Debugging [debug] -->
531
+ ## Debugging
532
+
533
+ You can setup your SDK to emit debug logs for SDK requests and responses.
534
+
535
+ You can pass your own logger class directly into your SDK.
536
+ ```python
537
+ from continuous import Continuous
538
+ import logging
539
+
540
+ logging.basicConfig(level=logging.DEBUG)
541
+ s = Continuous(debug_logger=logging.getLogger("continuous"))
542
+ ```
543
+
544
+ You can also enable a default debug logger by setting an environment variable `CONTINUOUS_DEBUG` to true.
545
+ <!-- End Debugging [debug] -->
546
+
547
+ <!-- Placeholder for Future Speakeasy SDK Sections -->
548
+
549
+ # Development
550
+
551
+ ## Maturity
552
+
553
+ This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage
554
+ to a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally
555
+ looking for the latest version.
556
+
557
+ ## Contributions
558
+
559
+ While we value open-source contributions to this SDK, this library is generated programmatically. Any manual changes added to internal files will be overwritten on the next generation.
560
+ We look forward to hearing your feedback. Feel free to open a PR or an issue with a proof of concept and we'll do our best to include it in a future release.
561
+
562
+ ### SDK Created by [Speakeasy](https://www.speakeasy.com/?utm_source=continuous-simulation&utm_campaign=python)