deeptable 0.1.0a1__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 (80) hide show
  1. deeptable-0.1.0a1/.gitignore +15 -0
  2. deeptable-0.1.0a1/.release-please-manifest.json +3 -0
  3. deeptable-0.1.0a1/CHANGELOG.md +16 -0
  4. deeptable-0.1.0a1/CONTRIBUTING.md +128 -0
  5. deeptable-0.1.0a1/LICENSE +7 -0
  6. deeptable-0.1.0a1/PKG-INFO +495 -0
  7. deeptable-0.1.0a1/README.md +460 -0
  8. deeptable-0.1.0a1/SECURITY.md +27 -0
  9. deeptable-0.1.0a1/api.md +35 -0
  10. deeptable-0.1.0a1/bin/check-release-environment +21 -0
  11. deeptable-0.1.0a1/bin/publish-pypi +7 -0
  12. deeptable-0.1.0a1/examples/.keep +4 -0
  13. deeptable-0.1.0a1/pyproject.toml +255 -0
  14. deeptable-0.1.0a1/release-please-config.json +66 -0
  15. deeptable-0.1.0a1/requirements-dev.lock +110 -0
  16. deeptable-0.1.0a1/src/deeptable/__init__.py +102 -0
  17. deeptable-0.1.0a1/src/deeptable/_base_client.py +2124 -0
  18. deeptable-0.1.0a1/src/deeptable/_client.py +488 -0
  19. deeptable-0.1.0a1/src/deeptable/_compat.py +219 -0
  20. deeptable-0.1.0a1/src/deeptable/_constants.py +14 -0
  21. deeptable-0.1.0a1/src/deeptable/_exceptions.py +108 -0
  22. deeptable-0.1.0a1/src/deeptable/_files.py +123 -0
  23. deeptable-0.1.0a1/src/deeptable/_models.py +872 -0
  24. deeptable-0.1.0a1/src/deeptable/_qs.py +150 -0
  25. deeptable-0.1.0a1/src/deeptable/_resource.py +43 -0
  26. deeptable-0.1.0a1/src/deeptable/_response.py +830 -0
  27. deeptable-0.1.0a1/src/deeptable/_streaming.py +333 -0
  28. deeptable-0.1.0a1/src/deeptable/_types.py +270 -0
  29. deeptable-0.1.0a1/src/deeptable/_utils/__init__.py +64 -0
  30. deeptable-0.1.0a1/src/deeptable/_utils/_compat.py +45 -0
  31. deeptable-0.1.0a1/src/deeptable/_utils/_datetime_parse.py +136 -0
  32. deeptable-0.1.0a1/src/deeptable/_utils/_logs.py +25 -0
  33. deeptable-0.1.0a1/src/deeptable/_utils/_proxy.py +65 -0
  34. deeptable-0.1.0a1/src/deeptable/_utils/_reflection.py +42 -0
  35. deeptable-0.1.0a1/src/deeptable/_utils/_resources_proxy.py +24 -0
  36. deeptable-0.1.0a1/src/deeptable/_utils/_streams.py +12 -0
  37. deeptable-0.1.0a1/src/deeptable/_utils/_sync.py +58 -0
  38. deeptable-0.1.0a1/src/deeptable/_utils/_transform.py +457 -0
  39. deeptable-0.1.0a1/src/deeptable/_utils/_typing.py +156 -0
  40. deeptable-0.1.0a1/src/deeptable/_utils/_utils.py +421 -0
  41. deeptable-0.1.0a1/src/deeptable/_version.py +4 -0
  42. deeptable-0.1.0a1/src/deeptable/lib/.keep +4 -0
  43. deeptable-0.1.0a1/src/deeptable/pagination.py +63 -0
  44. deeptable-0.1.0a1/src/deeptable/py.typed +0 -0
  45. deeptable-0.1.0a1/src/deeptable/resources/__init__.py +33 -0
  46. deeptable-0.1.0a1/src/deeptable/resources/files.py +470 -0
  47. deeptable-0.1.0a1/src/deeptable/resources/structured_sheets/__init__.py +33 -0
  48. deeptable-0.1.0a1/src/deeptable/resources/structured_sheets/exports.py +184 -0
  49. deeptable-0.1.0a1/src/deeptable/resources/structured_sheets/structured_sheets.py +514 -0
  50. deeptable-0.1.0a1/src/deeptable/types/__init__.py +10 -0
  51. deeptable-0.1.0a1/src/deeptable/types/file.py +34 -0
  52. deeptable-0.1.0a1/src/deeptable/types/file_list_params.py +16 -0
  53. deeptable-0.1.0a1/src/deeptable/types/file_upload_params.py +14 -0
  54. deeptable-0.1.0a1/src/deeptable/types/structured_sheet_create_params.py +18 -0
  55. deeptable-0.1.0a1/src/deeptable/types/structured_sheet_list_params.py +16 -0
  56. deeptable-0.1.0a1/src/deeptable/types/structured_sheet_response.py +53 -0
  57. deeptable-0.1.0a1/src/deeptable/types/structured_sheets/__init__.py +3 -0
  58. deeptable-0.1.0a1/tests/__init__.py +1 -0
  59. deeptable-0.1.0a1/tests/api_resources/__init__.py +1 -0
  60. deeptable-0.1.0a1/tests/api_resources/structured_sheets/__init__.py +1 -0
  61. deeptable-0.1.0a1/tests/api_resources/structured_sheets/test_exports.py +144 -0
  62. deeptable-0.1.0a1/tests/api_resources/test_files.py +335 -0
  63. deeptable-0.1.0a1/tests/api_resources/test_structured_sheets.py +353 -0
  64. deeptable-0.1.0a1/tests/conftest.py +84 -0
  65. deeptable-0.1.0a1/tests/sample_file.txt +1 -0
  66. deeptable-0.1.0a1/tests/test_client.py +1916 -0
  67. deeptable-0.1.0a1/tests/test_deepcopy.py +58 -0
  68. deeptable-0.1.0a1/tests/test_extract_files.py +64 -0
  69. deeptable-0.1.0a1/tests/test_files.py +51 -0
  70. deeptable-0.1.0a1/tests/test_models.py +963 -0
  71. deeptable-0.1.0a1/tests/test_qs.py +78 -0
  72. deeptable-0.1.0a1/tests/test_required_args.py +111 -0
  73. deeptable-0.1.0a1/tests/test_response.py +277 -0
  74. deeptable-0.1.0a1/tests/test_streaming.py +248 -0
  75. deeptable-0.1.0a1/tests/test_transform.py +460 -0
  76. deeptable-0.1.0a1/tests/test_utils/test_datetime_parse.py +110 -0
  77. deeptable-0.1.0a1/tests/test_utils/test_proxy.py +34 -0
  78. deeptable-0.1.0a1/tests/test_utils/test_typing.py +73 -0
  79. deeptable-0.1.0a1/tests/utils.py +167 -0
  80. deeptable-0.1.0a1/uv.lock +1829 -0
@@ -0,0 +1,15 @@
1
+ .prism.log
2
+ _dev
3
+
4
+ __pycache__
5
+ .mypy_cache
6
+
7
+ dist
8
+
9
+ .venv
10
+ .idea
11
+
12
+ .env
13
+ .envrc
14
+ codegen.log
15
+ Brewfile.lock.json
@@ -0,0 +1,3 @@
1
+ {
2
+ ".": "0.1.0-alpha.1"
3
+ }
@@ -0,0 +1,16 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0-alpha.1 (2026-01-23)
4
+
5
+ Full Changelog: [v0.0.1...v0.1.0-alpha.1](https://github.com/deeptable-com/deeptable-python/compare/v0.0.1...v0.1.0-alpha.1)
6
+
7
+ ### Features
8
+
9
+ * **api:** change casing for DeepTable class ([470c907](https://github.com/deeptable-com/deeptable-python/commit/470c907140848a8475722b79d3056b6aa6684aec))
10
+ * **api:** change pagination scheme ([3613ac5](https://github.com/deeptable-com/deeptable-python/commit/3613ac5a3692365d28dd464a638d8df5fc9f79bc))
11
+
12
+
13
+ ### Chores
14
+
15
+ * update SDK settings ([fe8f650](https://github.com/deeptable-com/deeptable-python/commit/fe8f650bea07ecca7253054825864b61f5db7647))
16
+ * update SDK settings ([46bd257](https://github.com/deeptable-com/deeptable-python/commit/46bd257650a90cefc9452e4be91319a5cb92e0fa))
@@ -0,0 +1,128 @@
1
+ ## Setting up the environment
2
+
3
+ ### With `uv`
4
+
5
+ We use [uv](https://docs.astral.sh/uv/) to manage dependencies because it will automatically provision a Python environment with the expected Python version. To set it up, run:
6
+
7
+ ```sh
8
+ $ ./scripts/bootstrap
9
+ ```
10
+
11
+ Or [install uv manually](https://docs.astral.sh/uv/getting-started/installation/) and run:
12
+
13
+ ```sh
14
+ $ uv sync --all-extras
15
+ ```
16
+
17
+ You can then run scripts using `uv run python script.py` or by manually activating the virtual environment:
18
+
19
+ ```sh
20
+ # manually activate - https://docs.python.org/3/library/venv.html#how-venvs-work
21
+ $ source .venv/bin/activate
22
+
23
+ # now you can omit the `uv run` prefix
24
+ $ python script.py
25
+ ```
26
+
27
+ ### Without `uv`
28
+
29
+ Alternatively if you don't want to install `uv`, you can stick with the standard `pip` setup by ensuring you have the Python version specified in `.python-version`, create a virtual environment however you desire and then install dependencies using this command:
30
+
31
+ ```sh
32
+ $ pip install -r requirements-dev.lock
33
+ ```
34
+
35
+ ## Modifying/Adding code
36
+
37
+ Most of the SDK is generated code. Modifications to code will be persisted between generations, but may
38
+ result in merge conflicts between manual patches and changes from the generator. The generator will never
39
+ modify the contents of the `src/deeptable/lib/` and `examples/` directories.
40
+
41
+ ## Adding and running examples
42
+
43
+ All files in the `examples/` directory are not modified by the generator and can be freely edited or added to.
44
+
45
+ ```py
46
+ # add an example to examples/<your-example>.py
47
+
48
+ #!/usr/bin/env -S uv run python
49
+
50
+ ```
51
+
52
+ ```sh
53
+ $ chmod +x examples/<your-example>.py
54
+ # run the example against your api
55
+ $ ./examples/<your-example>.py
56
+ ```
57
+
58
+ ## Using the repository from source
59
+
60
+ If you’d like to use the repository from source, you can either install from git or link to a cloned repository:
61
+
62
+ To install via git:
63
+
64
+ ```sh
65
+ $ pip install git+ssh://git@github.com/deeptable-com/deeptable-python.git
66
+ ```
67
+
68
+ Alternatively, you can build from source and install the wheel file:
69
+
70
+ Building this package will create two files in the `dist/` directory, a `.tar.gz` containing the source files and a `.whl` that can be used to install the package efficiently.
71
+
72
+ To create a distributable version of the library, all you have to do is run this command:
73
+
74
+ ```sh
75
+ $ uv build
76
+ # or
77
+ $ python -m build
78
+ ```
79
+
80
+ Then to install:
81
+
82
+ ```sh
83
+ $ pip install ./path-to-wheel-file.whl
84
+ ```
85
+
86
+ ## Running tests
87
+
88
+ Most tests require you to [set up a mock server](https://github.com/stoplightio/prism) against the OpenAPI spec to run the tests.
89
+
90
+ ```sh
91
+ # you will need npm installed
92
+ $ npx prism mock path/to/your/openapi.yml
93
+ ```
94
+
95
+ ```sh
96
+ $ ./scripts/test
97
+ ```
98
+
99
+ ## Linting and formatting
100
+
101
+ This repository uses [ruff](https://github.com/astral-sh/ruff) and
102
+ [black](https://github.com/psf/black) to format the code in the repository.
103
+
104
+ To lint:
105
+
106
+ ```sh
107
+ $ ./scripts/lint
108
+ ```
109
+
110
+ To format and fix all ruff issues automatically:
111
+
112
+ ```sh
113
+ $ ./scripts/format
114
+ ```
115
+
116
+ ## Publishing and releases
117
+
118
+ Changes made to this repository via the automated release PR pipeline should publish to PyPI automatically. If
119
+ the changes aren't made through the automated pipeline, you may want to make releases manually.
120
+
121
+ ### Publish with a GitHub workflow
122
+
123
+ You can release to package managers by using [the `Publish PyPI` GitHub action](https://www.github.com/deeptable-com/deeptable-python/actions/workflows/publish-pypi.yml). This requires a setup organization or repository secret to be set up.
124
+
125
+ ### Publish manually
126
+
127
+ If you need to manually release a package, you can run the `bin/publish-pypi` script with a `PYPI_TOKEN` set on
128
+ the environment.
@@ -0,0 +1,7 @@
1
+ Copyright 2026 deeptable
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,495 @@
1
+ Metadata-Version: 2.3
2
+ Name: deeptable
3
+ Version: 0.1.0a1
4
+ Summary: The official Python library for the deeptable API
5
+ Project-URL: Homepage, https://github.com/deeptable-com/deeptable-python
6
+ Project-URL: Repository, https://github.com/deeptable-com/deeptable-python
7
+ Author-email: DeepTable <support@deeptable.com>
8
+ License: MIT
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Operating System :: MacOS
12
+ Classifier: Operating System :: Microsoft :: Windows
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Operating System :: POSIX
15
+ Classifier: Operating System :: POSIX :: Linux
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
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.14
22
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
23
+ Classifier: Typing :: Typed
24
+ Requires-Python: >=3.9
25
+ Requires-Dist: anyio<5,>=3.5.0
26
+ Requires-Dist: distro<2,>=1.7.0
27
+ Requires-Dist: httpx<1,>=0.23.0
28
+ Requires-Dist: pydantic<3,>=1.9.0
29
+ Requires-Dist: sniffio
30
+ Requires-Dist: typing-extensions<5,>=4.10
31
+ Provides-Extra: aiohttp
32
+ Requires-Dist: aiohttp; extra == 'aiohttp'
33
+ Requires-Dist: httpx-aiohttp>=0.1.9; extra == 'aiohttp'
34
+ Description-Content-Type: text/markdown
35
+
36
+ # DeepTable Python API library
37
+
38
+ <!-- prettier-ignore -->
39
+ [![PyPI version](https://img.shields.io/pypi/v/deeptable.svg?label=pypi%20(stable))](https://pypi.org/project/deeptable/)
40
+
41
+ The DeepTable Python library provides convenient access to the DeepTable REST API from any Python 3.9+
42
+ application. The library includes type definitions for all request params and response fields,
43
+ and offers both synchronous and asynchronous clients powered by [httpx](https://github.com/encode/httpx).
44
+
45
+ It is generated with [Stainless](https://www.stainless.com/).
46
+
47
+ ## Documentation
48
+
49
+ The REST API documentation can be found on [docs.deeptable.com](https://docs.deeptable.com). The full API of this library can be found in [api.md](https://github.com/deeptable-com/deeptable-python/tree/main/api.md).
50
+
51
+ ## Installation
52
+
53
+ ```sh
54
+ # install from PyPI
55
+ pip install --pre deeptable
56
+ ```
57
+
58
+ ## Usage
59
+
60
+ The full API of this library can be found in [api.md](https://github.com/deeptable-com/deeptable-python/tree/main/api.md).
61
+
62
+ ```python
63
+ import os
64
+ from deeptable import DeepTable
65
+
66
+ client = DeepTable(
67
+ api_key=os.environ.get("DEEPTABLE_API_KEY"), # This is the default and can be omitted
68
+ )
69
+
70
+ structured_sheet_response = client.structured_sheets.create(
71
+ file_id="file_01h45ytscbebyvny4gc8cr8ma2",
72
+ )
73
+ print(structured_sheet_response.id)
74
+ ```
75
+
76
+ While you can provide an `api_key` keyword argument,
77
+ we recommend using [python-dotenv](https://pypi.org/project/python-dotenv/)
78
+ to add `DEEPTABLE_API_KEY="My API Key"` to your `.env` file
79
+ so that your API Key is not stored in source control.
80
+
81
+ ## Async usage
82
+
83
+ Simply import `AsyncDeepTable` instead of `DeepTable` and use `await` with each API call:
84
+
85
+ ```python
86
+ import os
87
+ import asyncio
88
+ from deeptable import AsyncDeepTable
89
+
90
+ client = AsyncDeepTable(
91
+ api_key=os.environ.get("DEEPTABLE_API_KEY"), # This is the default and can be omitted
92
+ )
93
+
94
+
95
+ async def main() -> None:
96
+ structured_sheet_response = await client.structured_sheets.create(
97
+ file_id="file_01h45ytscbebyvny4gc8cr8ma2",
98
+ )
99
+ print(structured_sheet_response.id)
100
+
101
+
102
+ asyncio.run(main())
103
+ ```
104
+
105
+ Functionality between the synchronous and asynchronous clients is otherwise identical.
106
+
107
+ ### With aiohttp
108
+
109
+ By default, the async client uses `httpx` for HTTP requests. However, for improved concurrency performance you may also use `aiohttp` as the HTTP backend.
110
+
111
+ You can enable this by installing `aiohttp`:
112
+
113
+ ```sh
114
+ # install from PyPI
115
+ pip install --pre deeptable[aiohttp]
116
+ ```
117
+
118
+ Then you can enable it by instantiating the client with `http_client=DefaultAioHttpClient()`:
119
+
120
+ ```python
121
+ import os
122
+ import asyncio
123
+ from deeptable import DefaultAioHttpClient
124
+ from deeptable import AsyncDeepTable
125
+
126
+
127
+ async def main() -> None:
128
+ async with AsyncDeepTable(
129
+ api_key=os.environ.get("DEEPTABLE_API_KEY"), # This is the default and can be omitted
130
+ http_client=DefaultAioHttpClient(),
131
+ ) as client:
132
+ structured_sheet_response = await client.structured_sheets.create(
133
+ file_id="file_01h45ytscbebyvny4gc8cr8ma2",
134
+ )
135
+ print(structured_sheet_response.id)
136
+
137
+
138
+ asyncio.run(main())
139
+ ```
140
+
141
+ ## Using types
142
+
143
+ Nested request parameters are [TypedDicts](https://docs.python.org/3/library/typing.html#typing.TypedDict). Responses are [Pydantic models](https://docs.pydantic.dev) which also provide helper methods for things like:
144
+
145
+ - Serializing back into JSON, `model.to_json()`
146
+ - Converting to a dictionary, `model.to_dict()`
147
+
148
+ Typed requests and responses provide autocomplete and documentation within your editor. If you would like to see type errors in VS Code to help catch bugs earlier, set `python.analysis.typeCheckingMode` to `basic`.
149
+
150
+ ## Pagination
151
+
152
+ List methods in the DeepTable API are paginated.
153
+
154
+ This library provides auto-paginating iterators with each list response, so you do not have to request successive pages manually:
155
+
156
+ ```python
157
+ from deeptable import DeepTable
158
+
159
+ client = DeepTable()
160
+
161
+ all_files = []
162
+ # Automatically fetches more pages as needed.
163
+ for file in client.files.list():
164
+ # Do something with file here
165
+ all_files.append(file)
166
+ print(all_files)
167
+ ```
168
+
169
+ Or, asynchronously:
170
+
171
+ ```python
172
+ import asyncio
173
+ from deeptable import AsyncDeepTable
174
+
175
+ client = AsyncDeepTable()
176
+
177
+
178
+ async def main() -> None:
179
+ all_files = []
180
+ # Iterate through items across all pages, issuing requests as needed.
181
+ async for file in client.files.list():
182
+ all_files.append(file)
183
+ print(all_files)
184
+
185
+
186
+ asyncio.run(main())
187
+ ```
188
+
189
+ Alternatively, you can use the `.has_next_page()`, `.next_page_info()`, or `.get_next_page()` methods for more granular control working with pages:
190
+
191
+ ```python
192
+ first_page = await client.files.list()
193
+ if first_page.has_next_page():
194
+ print(f"will fetch next page using these details: {first_page.next_page_info()}")
195
+ next_page = await first_page.get_next_page()
196
+ print(f"number of items we just fetched: {len(next_page.data)}")
197
+
198
+ # Remove `await` for non-async usage.
199
+ ```
200
+
201
+ Or just work directly with the returned data:
202
+
203
+ ```python
204
+ first_page = await client.files.list()
205
+
206
+ print(f"next page cursor: {first_page.after}") # => "next page cursor: ..."
207
+ for file in first_page.data:
208
+ print(file.id)
209
+
210
+ # Remove `await` for non-async usage.
211
+ ```
212
+
213
+ ## File uploads
214
+
215
+ Request parameters that correspond to file uploads can be passed as `bytes`, or a [`PathLike`](https://docs.python.org/3/library/os.html#os.PathLike) instance or a tuple of `(filename, contents, media type)`.
216
+
217
+ ```python
218
+ from pathlib import Path
219
+ from deeptable import DeepTable
220
+
221
+ client = DeepTable()
222
+
223
+ client.files.upload(
224
+ file=Path("/path/to/file"),
225
+ )
226
+ ```
227
+
228
+ The async client uses the exact same interface. If you pass a [`PathLike`](https://docs.python.org/3/library/os.html#os.PathLike) instance, the file contents will be read asynchronously automatically.
229
+
230
+ ## Handling errors
231
+
232
+ When the library is unable to connect to the API (for example, due to network connection problems or a timeout), a subclass of `deeptable.APIConnectionError` is raised.
233
+
234
+ When the API returns a non-success status code (that is, 4xx or 5xx
235
+ response), a subclass of `deeptable.APIStatusError` is raised, containing `status_code` and `response` properties.
236
+
237
+ All errors inherit from `deeptable.APIError`.
238
+
239
+ ```python
240
+ import deeptable
241
+ from deeptable import DeepTable
242
+
243
+ client = DeepTable()
244
+
245
+ try:
246
+ client.structured_sheets.create(
247
+ file_id="file_01h45ytscbebyvny4gc8cr8ma2",
248
+ )
249
+ except deeptable.APIConnectionError as e:
250
+ print("The server could not be reached")
251
+ print(e.__cause__) # an underlying Exception, likely raised within httpx.
252
+ except deeptable.RateLimitError as e:
253
+ print("A 429 status code was received; we should back off a bit.")
254
+ except deeptable.APIStatusError as e:
255
+ print("Another non-200-range status code was received")
256
+ print(e.status_code)
257
+ print(e.response)
258
+ ```
259
+
260
+ Error codes are as follows:
261
+
262
+ | Status Code | Error Type |
263
+ | ----------- | -------------------------- |
264
+ | 400 | `BadRequestError` |
265
+ | 401 | `AuthenticationError` |
266
+ | 403 | `PermissionDeniedError` |
267
+ | 404 | `NotFoundError` |
268
+ | 422 | `UnprocessableEntityError` |
269
+ | 429 | `RateLimitError` |
270
+ | >=500 | `InternalServerError` |
271
+ | N/A | `APIConnectionError` |
272
+
273
+ ### Retries
274
+
275
+ Certain errors are automatically retried 2 times by default, with a short exponential backoff.
276
+ Connection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict,
277
+ 429 Rate Limit, and >=500 Internal errors are all retried by default.
278
+
279
+ You can use the `max_retries` option to configure or disable retry settings:
280
+
281
+ ```python
282
+ from deeptable import DeepTable
283
+
284
+ # Configure the default for all requests:
285
+ client = DeepTable(
286
+ # default is 2
287
+ max_retries=0,
288
+ )
289
+
290
+ # Or, configure per-request:
291
+ client.with_options(max_retries=5).structured_sheets.create(
292
+ file_id="file_01h45ytscbebyvny4gc8cr8ma2",
293
+ )
294
+ ```
295
+
296
+ ### Timeouts
297
+
298
+ By default requests time out after 1 minute. You can configure this with a `timeout` option,
299
+ which accepts a float or an [`httpx.Timeout`](https://www.python-httpx.org/advanced/timeouts/#fine-tuning-the-configuration) object:
300
+
301
+ ```python
302
+ from deeptable import DeepTable
303
+
304
+ # Configure the default for all requests:
305
+ client = DeepTable(
306
+ # 20 seconds (default is 1 minute)
307
+ timeout=20.0,
308
+ )
309
+
310
+ # More granular control:
311
+ client = DeepTable(
312
+ timeout=httpx.Timeout(60.0, read=5.0, write=10.0, connect=2.0),
313
+ )
314
+
315
+ # Override per-request:
316
+ client.with_options(timeout=5.0).structured_sheets.create(
317
+ file_id="file_01h45ytscbebyvny4gc8cr8ma2",
318
+ )
319
+ ```
320
+
321
+ On timeout, an `APITimeoutError` is thrown.
322
+
323
+ Note that requests that time out are [retried twice by default](https://github.com/deeptable-com/deeptable-python/tree/main/#retries).
324
+
325
+ ## Advanced
326
+
327
+ ### Logging
328
+
329
+ We use the standard library [`logging`](https://docs.python.org/3/library/logging.html) module.
330
+
331
+ You can enable logging by setting the environment variable `DEEPTABLE_LOG` to `info`.
332
+
333
+ ```shell
334
+ $ export DEEPTABLE_LOG=info
335
+ ```
336
+
337
+ Or to `debug` for more verbose logging.
338
+
339
+ ### How to tell whether `None` means `null` or missing
340
+
341
+ In an API response, a field may be explicitly `null`, or missing entirely; in either case, its value is `None` in this library. You can differentiate the two cases with `.model_fields_set`:
342
+
343
+ ```py
344
+ if response.my_field is None:
345
+ if 'my_field' not in response.model_fields_set:
346
+ print('Got json like {}, without a "my_field" key present at all.')
347
+ else:
348
+ print('Got json like {"my_field": null}.')
349
+ ```
350
+
351
+ ### Accessing raw response data (e.g. headers)
352
+
353
+ The "raw" Response object can be accessed by prefixing `.with_raw_response.` to any HTTP method call, e.g.,
354
+
355
+ ```py
356
+ from deeptable import DeepTable
357
+
358
+ client = DeepTable()
359
+ response = client.structured_sheets.with_raw_response.create(
360
+ file_id="file_01h45ytscbebyvny4gc8cr8ma2",
361
+ )
362
+ print(response.headers.get('X-My-Header'))
363
+
364
+ structured_sheet = response.parse() # get the object that `structured_sheets.create()` would have returned
365
+ print(structured_sheet.id)
366
+ ```
367
+
368
+ These methods return an [`APIResponse`](https://github.com/deeptable-com/deeptable-python/tree/main/src/deeptable/_response.py) object.
369
+
370
+ The async client returns an [`AsyncAPIResponse`](https://github.com/deeptable-com/deeptable-python/tree/main/src/deeptable/_response.py) with the same structure, the only difference being `await`able methods for reading the response content.
371
+
372
+ #### `.with_streaming_response`
373
+
374
+ The above interface eagerly reads the full response body when you make the request, which may not always be what you want.
375
+
376
+ To stream the response body, use `.with_streaming_response` instead, which requires a context manager and only reads the response body once you call `.read()`, `.text()`, `.json()`, `.iter_bytes()`, `.iter_text()`, `.iter_lines()` or `.parse()`. In the async client, these are async methods.
377
+
378
+ ```python
379
+ with client.structured_sheets.with_streaming_response.create(
380
+ file_id="file_01h45ytscbebyvny4gc8cr8ma2",
381
+ ) as response:
382
+ print(response.headers.get("X-My-Header"))
383
+
384
+ for line in response.iter_lines():
385
+ print(line)
386
+ ```
387
+
388
+ The context manager is required so that the response will reliably be closed.
389
+
390
+ ### Making custom/undocumented requests
391
+
392
+ This library is typed for convenient access to the documented API.
393
+
394
+ If you need to access undocumented endpoints, params, or response properties, the library can still be used.
395
+
396
+ #### Undocumented endpoints
397
+
398
+ To make requests to undocumented endpoints, you can make requests using `client.get`, `client.post`, and other
399
+ http verbs. Options on the client will be respected (such as retries) when making this request.
400
+
401
+ ```py
402
+ import httpx
403
+
404
+ response = client.post(
405
+ "/foo",
406
+ cast_to=httpx.Response,
407
+ body={"my_param": True},
408
+ )
409
+
410
+ print(response.headers.get("x-foo"))
411
+ ```
412
+
413
+ #### Undocumented request params
414
+
415
+ If you want to explicitly send an extra param, you can do so with the `extra_query`, `extra_body`, and `extra_headers` request
416
+ options.
417
+
418
+ #### Undocumented response properties
419
+
420
+ To access undocumented response properties, you can access the extra fields like `response.unknown_prop`. You
421
+ can also get all the extra fields on the Pydantic model as a dict with
422
+ [`response.model_extra`](https://docs.pydantic.dev/latest/api/base_model/#pydantic.BaseModel.model_extra).
423
+
424
+ ### Configuring the HTTP client
425
+
426
+ You can directly override the [httpx client](https://www.python-httpx.org/api/#client) to customize it for your use case, including:
427
+
428
+ - Support for [proxies](https://www.python-httpx.org/advanced/proxies/)
429
+ - Custom [transports](https://www.python-httpx.org/advanced/transports/)
430
+ - Additional [advanced](https://www.python-httpx.org/advanced/clients/) functionality
431
+
432
+ ```python
433
+ import httpx
434
+ from deeptable import DeepTable, DefaultHttpxClient
435
+
436
+ client = DeepTable(
437
+ # Or use the `DEEPTABLE_BASE_URL` env var
438
+ base_url="http://my.test.server.example.com:8083",
439
+ http_client=DefaultHttpxClient(
440
+ proxy="http://my.test.proxy.example.com",
441
+ transport=httpx.HTTPTransport(local_address="0.0.0.0"),
442
+ ),
443
+ )
444
+ ```
445
+
446
+ You can also customize the client on a per-request basis by using `with_options()`:
447
+
448
+ ```python
449
+ client.with_options(http_client=DefaultHttpxClient(...))
450
+ ```
451
+
452
+ ### Managing HTTP resources
453
+
454
+ By default the library closes underlying HTTP connections whenever the client is [garbage collected](https://docs.python.org/3/reference/datamodel.html#object.__del__). You can manually close the client using the `.close()` method if desired, or with a context manager that closes when exiting.
455
+
456
+ ```py
457
+ from deeptable import DeepTable
458
+
459
+ with DeepTable() as client:
460
+ # make requests here
461
+ ...
462
+
463
+ # HTTP client is now closed
464
+ ```
465
+
466
+ ## Versioning
467
+
468
+ This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:
469
+
470
+ 1. Changes that only affect static types, without breaking runtime behavior.
471
+ 2. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_
472
+ 3. Changes that we do not expect to impact the vast majority of users in practice.
473
+
474
+ We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.
475
+
476
+ We are keen for your feedback; please open an [issue](https://www.github.com/deeptable-com/deeptable-python/issues) with questions, bugs, or suggestions.
477
+
478
+ ### Determining the installed version
479
+
480
+ If you've upgraded to the latest version but aren't seeing any new features you were expecting then your python environment is likely still using an older version.
481
+
482
+ You can determine the version that is being used at runtime with:
483
+
484
+ ```py
485
+ import deeptable
486
+ print(deeptable.__version__)
487
+ ```
488
+
489
+ ## Requirements
490
+
491
+ Python 3.9 or higher.
492
+
493
+ ## Contributing
494
+
495
+ See [the contributing documentation](https://github.com/deeptable-com/deeptable-python/tree/main/./CONTRIBUTING.md).