jevaro 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
jevaro-0.1.0/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,2 @@
1
+ include example.py
2
+ recursive-include tests *.py
jevaro-0.1.0/NOTICE ADDED
@@ -0,0 +1,4 @@
1
+ Jevaro
2
+ Copyright 2026 Columnar Technologies Inc.
3
+
4
+ Licensed under the Apache License, Version 2.0.
jevaro-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,150 @@
1
+ Metadata-Version: 2.4
2
+ Name: jevaro
3
+ Version: 0.1.0
4
+ Summary: TypeSafe-style Python client for Jevaro Arrow streams
5
+ Author: Columnar Technologies Inc.
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/columnar-tech/jevaro
8
+ Project-URL: Documentation, https://github.com/columnar-tech/jevaro/blob/main/jevaro-python/README.md
9
+ Project-URL: Repository, https://github.com/columnar-tech/jevaro
10
+ Project-URL: Issues, https://github.com/columnar-tech/jevaro/issues
11
+ Requires-Python: >=3.11
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ License-File: NOTICE
15
+ Requires-Dist: typesafe-sdk==0.7.2
16
+ Requires-Dist: httpx2<3,>=2.13
17
+ Requires-Dist: pyarrow==25.0.1
18
+ Dynamic: license-file
19
+
20
+ # Jevaro Python SDK
21
+
22
+ Use TypeSafe-style arguments and read the answers as Arrow. Requires Python
23
+ 3.11+ and a running Jevaro server. Start with the
24
+ [quickstart](https://github.com/columnar-tech/jevaro/blob/main/docs/quickstart.md).
25
+
26
+ ## Install
27
+
28
+ ```sh
29
+ python3 -m venv .venv
30
+ .venv/bin/python -m pip install jevaro
31
+ ```
32
+
33
+ ## Read results
34
+
35
+ ```python
36
+ from jevaro import Noul, TypeSafeClient
37
+
38
+ with TypeSafeClient() as client:
39
+ with client.system_one(
40
+ states=["Please refund the shoes.", "Where is my parcel?"],
41
+ questions={"refund": Noul(instructions="Is a refund being requested?")},
42
+ ) as reader:
43
+ print(reader.schema)
44
+ for batch in reader:
45
+ print(batch.to_pylist())
46
+ ```
47
+
48
+ The reader is a `pyarrow.RecordBatchReader`. Its schema is available before
49
+ answers arrive. The first batch has zero rows; later batches have one row each.
50
+ Use `reader.read_all()` to collect a `pyarrow.Table`.
51
+
52
+ Keep the client open while reading. A context manager closes the HTTP response
53
+ if you stop early; full iteration closes it automatically.
54
+
55
+ ## Questions and arguments
56
+
57
+ `Choice`, `Score`, and `Noul` are re-exported from the official TypeSafe SDK.
58
+ Question dictionaries work too. See the bundled
59
+ [three-type example](https://github.com/columnar-tech/jevaro/blob/main/jevaro-python/example.py).
60
+
61
+ `system_one(state, questions, *, states=..., model=..., timeout=..., extra_headers=...)`
62
+ returns an `ArrowReader`. Supply exactly one of `state` and `states`.
63
+
64
+ | Argument | Meaning |
65
+ | --- | --- |
66
+ | `state` | One string, object, or array |
67
+ | `states` | A nonempty list of states |
68
+ | `questions` | A nonempty mapping of question IDs to definitions |
69
+ | `model` | Override the client's model |
70
+ | `timeout` | Override the client's I/O timeout, in seconds |
71
+ | `extra_headers` | Add or override headers for this request |
72
+
73
+ An array in singular `state` is one evaluation. Use `states` to evaluate its
74
+ elements separately.
75
+
76
+ ## Client configuration
77
+
78
+ `TypeSafeClient` and `AsyncTypeSafeClient` accept these keyword arguments:
79
+
80
+ | Option | Default |
81
+ | --- | --- |
82
+ | `api_key` | `TYPESAFE_API_KEY`; otherwise the server may supply its key |
83
+ | `base_url` | `TYPESAFE_BASE_URL`, then `http://127.0.0.1:8000` |
84
+ | `model` | `TYPESAFE_DEFAULT_MODEL`, then `jev-latest` |
85
+ | `timeout` | 60 seconds per HTTP I/O operation |
86
+ | `headers` | No extra headers |
87
+
88
+ The timeout is not a deadline for the whole batch. Call `client.close()` when
89
+ not using a context manager; use `await client.aclose()` for the async client.
90
+
91
+ ## Async
92
+
93
+ ```python
94
+ import asyncio
95
+ from jevaro import AsyncTypeSafeClient, Noul
96
+
97
+ async def main():
98
+ async with AsyncTypeSafeClient() as client:
99
+ async with await client.system_one(
100
+ states=["Please refund the shoes.", "Where is my parcel?"],
101
+ questions={"refund": Noul(instructions="Is a refund being requested?")},
102
+ ) as reader:
103
+ async for batch in reader:
104
+ print(batch.to_pylist())
105
+
106
+ asyncio.run(main())
107
+ ```
108
+
109
+ `AsyncArrowReader` has `schema`, async iteration, `await read_next_batch()`,
110
+ `await read_all()`, and `await aclose()`. Read methods return PyArrow batches or
111
+ a table. `read_next_batch()` raises `StopAsyncIteration` at the end.
112
+
113
+ Use the async interface for normal reads. Its `reader` property exposes the
114
+ underlying PyArrow reader; direct reads must run through `asyncio.to_thread`.
115
+ Consume a reader from one task at a time.
116
+
117
+ ## Metadata and files
118
+
119
+ Choice selections are integer indices into schema labels. Score legends also
120
+ live in schema metadata. See the
121
+ [Arrow schema](https://github.com/columnar-tech/jevaro/blob/main/docs/arrow-schema.md)
122
+ for decoding rules. `batch.to_pylist()` exposes these storage values.
123
+
124
+ To save a stream, open a writer with `reader.schema` and pass each batch to
125
+ `writer.write_batch(batch)`. The bundled example does this:
126
+
127
+ ```sh
128
+ .venv/bin/python jevaro-python/example.py --output jevaro-results.arrows
129
+ .venv/bin/python scripts/read_results.py jevaro-results.arrows
130
+ ```
131
+
132
+ `read_results.py` reconstructs full answer objects using only the saved schema
133
+ and PyArrow. Run these commands from the repository root.
134
+
135
+ ## Errors and compatibility
136
+
137
+ Invalid argument combinations raise `ValueError`. HTTP errors before streaming
138
+ raise `httpx2.HTTPStatusError`. Network or Arrow errors can occur during reading.
139
+ Unexpected row counts raise `OSError`.
140
+
141
+ This SDK implements System One evaluation with Arrow results. Model listing,
142
+ custom JSON response models, usage objects, and the official SDK's error
143
+ classes are outside its API. Per-state retries happen at the proxy; the SDK
144
+ does not retry an entire batch.
145
+
146
+ See [Contributing](https://github.com/columnar-tech/jevaro/blob/main/CONTRIBUTING.md)
147
+ for tests.
148
+
149
+ [Apache-2.0](https://github.com/columnar-tech/jevaro/blob/main/LICENSE).
150
+ Copyright 2026 Columnar Technologies Inc.
jevaro-0.1.0/README.md ADDED
@@ -0,0 +1,131 @@
1
+ # Jevaro Python SDK
2
+
3
+ Use TypeSafe-style arguments and read the answers as Arrow. Requires Python
4
+ 3.11+ and a running Jevaro server. Start with the
5
+ [quickstart](https://github.com/columnar-tech/jevaro/blob/main/docs/quickstart.md).
6
+
7
+ ## Install
8
+
9
+ ```sh
10
+ python3 -m venv .venv
11
+ .venv/bin/python -m pip install jevaro
12
+ ```
13
+
14
+ ## Read results
15
+
16
+ ```python
17
+ from jevaro import Noul, TypeSafeClient
18
+
19
+ with TypeSafeClient() as client:
20
+ with client.system_one(
21
+ states=["Please refund the shoes.", "Where is my parcel?"],
22
+ questions={"refund": Noul(instructions="Is a refund being requested?")},
23
+ ) as reader:
24
+ print(reader.schema)
25
+ for batch in reader:
26
+ print(batch.to_pylist())
27
+ ```
28
+
29
+ The reader is a `pyarrow.RecordBatchReader`. Its schema is available before
30
+ answers arrive. The first batch has zero rows; later batches have one row each.
31
+ Use `reader.read_all()` to collect a `pyarrow.Table`.
32
+
33
+ Keep the client open while reading. A context manager closes the HTTP response
34
+ if you stop early; full iteration closes it automatically.
35
+
36
+ ## Questions and arguments
37
+
38
+ `Choice`, `Score`, and `Noul` are re-exported from the official TypeSafe SDK.
39
+ Question dictionaries work too. See the bundled
40
+ [three-type example](https://github.com/columnar-tech/jevaro/blob/main/jevaro-python/example.py).
41
+
42
+ `system_one(state, questions, *, states=..., model=..., timeout=..., extra_headers=...)`
43
+ returns an `ArrowReader`. Supply exactly one of `state` and `states`.
44
+
45
+ | Argument | Meaning |
46
+ | --- | --- |
47
+ | `state` | One string, object, or array |
48
+ | `states` | A nonempty list of states |
49
+ | `questions` | A nonempty mapping of question IDs to definitions |
50
+ | `model` | Override the client's model |
51
+ | `timeout` | Override the client's I/O timeout, in seconds |
52
+ | `extra_headers` | Add or override headers for this request |
53
+
54
+ An array in singular `state` is one evaluation. Use `states` to evaluate its
55
+ elements separately.
56
+
57
+ ## Client configuration
58
+
59
+ `TypeSafeClient` and `AsyncTypeSafeClient` accept these keyword arguments:
60
+
61
+ | Option | Default |
62
+ | --- | --- |
63
+ | `api_key` | `TYPESAFE_API_KEY`; otherwise the server may supply its key |
64
+ | `base_url` | `TYPESAFE_BASE_URL`, then `http://127.0.0.1:8000` |
65
+ | `model` | `TYPESAFE_DEFAULT_MODEL`, then `jev-latest` |
66
+ | `timeout` | 60 seconds per HTTP I/O operation |
67
+ | `headers` | No extra headers |
68
+
69
+ The timeout is not a deadline for the whole batch. Call `client.close()` when
70
+ not using a context manager; use `await client.aclose()` for the async client.
71
+
72
+ ## Async
73
+
74
+ ```python
75
+ import asyncio
76
+ from jevaro import AsyncTypeSafeClient, Noul
77
+
78
+ async def main():
79
+ async with AsyncTypeSafeClient() as client:
80
+ async with await client.system_one(
81
+ states=["Please refund the shoes.", "Where is my parcel?"],
82
+ questions={"refund": Noul(instructions="Is a refund being requested?")},
83
+ ) as reader:
84
+ async for batch in reader:
85
+ print(batch.to_pylist())
86
+
87
+ asyncio.run(main())
88
+ ```
89
+
90
+ `AsyncArrowReader` has `schema`, async iteration, `await read_next_batch()`,
91
+ `await read_all()`, and `await aclose()`. Read methods return PyArrow batches or
92
+ a table. `read_next_batch()` raises `StopAsyncIteration` at the end.
93
+
94
+ Use the async interface for normal reads. Its `reader` property exposes the
95
+ underlying PyArrow reader; direct reads must run through `asyncio.to_thread`.
96
+ Consume a reader from one task at a time.
97
+
98
+ ## Metadata and files
99
+
100
+ Choice selections are integer indices into schema labels. Score legends also
101
+ live in schema metadata. See the
102
+ [Arrow schema](https://github.com/columnar-tech/jevaro/blob/main/docs/arrow-schema.md)
103
+ for decoding rules. `batch.to_pylist()` exposes these storage values.
104
+
105
+ To save a stream, open a writer with `reader.schema` and pass each batch to
106
+ `writer.write_batch(batch)`. The bundled example does this:
107
+
108
+ ```sh
109
+ .venv/bin/python jevaro-python/example.py --output jevaro-results.arrows
110
+ .venv/bin/python scripts/read_results.py jevaro-results.arrows
111
+ ```
112
+
113
+ `read_results.py` reconstructs full answer objects using only the saved schema
114
+ and PyArrow. Run these commands from the repository root.
115
+
116
+ ## Errors and compatibility
117
+
118
+ Invalid argument combinations raise `ValueError`. HTTP errors before streaming
119
+ raise `httpx2.HTTPStatusError`. Network or Arrow errors can occur during reading.
120
+ Unexpected row counts raise `OSError`.
121
+
122
+ This SDK implements System One evaluation with Arrow results. Model listing,
123
+ custom JSON response models, usage objects, and the official SDK's error
124
+ classes are outside its API. Per-state retries happen at the proxy; the SDK
125
+ does not retry an entire batch.
126
+
127
+ See [Contributing](https://github.com/columnar-tech/jevaro/blob/main/CONTRIBUTING.md)
128
+ for tests.
129
+
130
+ [Apache-2.0](https://github.com/columnar-tech/jevaro/blob/main/LICENSE).
131
+ Copyright 2026 Columnar Technologies Inc.
@@ -0,0 +1,48 @@
1
+ """Evaluate three customer messages through Jevaro; optionally save Arrow IPC."""
2
+
3
+ import argparse
4
+ import json
5
+ from contextlib import ExitStack
6
+
7
+ import pyarrow as pa
8
+ from jevaro import Choice, Noul, Score, TypeSafeClient
9
+
10
+ QUESTIONS = {
11
+ "department": Choice(
12
+ instructions="Which team should handle this customer message?",
13
+ criteria={"returns": "Returns, exchanges, refunds", "shipping": "Delivery problems",
14
+ "billing": "Charges and payments", "other": "None of these teams fits"},
15
+ ),
16
+ "urgency": Score(
17
+ instructions="How soon does the customer want a resolution?",
18
+ criteria=["No deadline or can wait", "Within the next few days", "Today or immediately"],
19
+ ),
20
+ "refund": Noul(instructions="Is the customer requesting a refund?"),
21
+ }
22
+ STATES = [
23
+ "The shoes don't fit. Please refund my money today.",
24
+ "My parcel is marked delivered but isn't here. Please help me find it.",
25
+ "I was charged twice for my coffee maker. Please fix the duplicate charge this week.",
26
+ ]
27
+
28
+
29
+ def main():
30
+ parser = argparse.ArgumentParser(description=__doc__)
31
+ parser.add_argument("--output", help="also write an Arrow IPC stream to this file")
32
+ args = parser.parse_args()
33
+ with ExitStack() as stack:
34
+ client = stack.enter_context(TypeSafeClient())
35
+ reader = stack.enter_context(client.system_one(states=STATES, questions=QUESTIONS))
36
+ metadata = reader.schema.field("department").metadata
37
+ labels = json.loads(metadata[b"ARROW:extension:metadata"])["labels"]
38
+ writer = stack.enter_context(pa.ipc.new_stream(args.output, reader.schema)) if args.output else None
39
+ for batch in reader:
40
+ if writer:
41
+ writer.write_batch(batch)
42
+ for row in batch.to_pylist():
43
+ print(json.dumps({"department": labels[row["department"]["choice"]],
44
+ "urgency": row["urgency"]["score"], "refund": row["refund"]}))
45
+
46
+
47
+ if __name__ == "__main__":
48
+ main()
@@ -0,0 +1,26 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77.0.3"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "jevaro"
7
+ version = "0.1.0"
8
+ description = "TypeSafe-style Python client for Jevaro Arrow streams"
9
+ readme = "README.md"
10
+ authors = [{name = "Columnar Technologies Inc."}]
11
+ license = "Apache-2.0"
12
+ license-files = ["LICENSE", "NOTICE"]
13
+ requires-python = ">=3.11"
14
+ dependencies = ["typesafe-sdk==0.7.2", "httpx2>=2.13,<3", "pyarrow==25.0.1"]
15
+
16
+ [project.urls]
17
+ Homepage = "https://github.com/columnar-tech/jevaro"
18
+ Documentation = "https://github.com/columnar-tech/jevaro/blob/main/jevaro-python/README.md"
19
+ Repository = "https://github.com/columnar-tech/jevaro"
20
+ Issues = "https://github.com/columnar-tech/jevaro/issues"
21
+
22
+ [tool.setuptools.packages.find]
23
+ where = ["src"]
24
+
25
+ [tool.setuptools.package-data]
26
+ jevaro = ["py.typed"]
jevaro-0.1.0/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,8 @@
1
+ """TypeSafe-style requests; streaming Arrow readers as results."""
2
+
3
+ from typesafe_sdk import Choice, Noul, Score
4
+
5
+ from .client import ArrowReader, AsyncArrowReader, AsyncTypeSafeClient, TypeSafeClient
6
+
7
+ __all__ = ["TypeSafeClient", "AsyncTypeSafeClient", "ArrowReader", "AsyncArrowReader",
8
+ "Choice", "Noul", "Score"]
@@ -0,0 +1,49 @@
1
+ """Let PyArrow's worker threads read an async HTTP connection owned by the loop.
2
+
3
+ Using async network I/O lets cancellation interrupt a blocked socket read;
4
+ closing a synchronous socket from a second thread can wait for its read timeout.
5
+ """
6
+
7
+ import asyncio
8
+
9
+ import httpx2
10
+
11
+
12
+ class AsyncTransport(httpx2.BaseTransport):
13
+ def __init__(self):
14
+ self.client = httpx2.AsyncClient()
15
+ self.loop = None
16
+
17
+ def bind_loop(self):
18
+ loop = asyncio.get_running_loop()
19
+ if self.loop is not None and self.loop is not loop:
20
+ raise RuntimeError("Use an AsyncTypeSafeClient in one event loop")
21
+ self.loop = loop
22
+
23
+ def run(self, coroutine):
24
+ # Only called from the PyArrow/client worker threads, never the loop.
25
+ return asyncio.run_coroutine_threadsafe(coroutine, self.loop).result()
26
+
27
+ def handle_request(self, request):
28
+ response = self.run(self.client.send(request, stream=True))
29
+ return httpx2.Response(
30
+ response.status_code, headers=response.headers,
31
+ stream=AsyncBody(response, self), extensions=response.extensions,
32
+ )
33
+
34
+ def close(self):
35
+ self.run(self.client.aclose())
36
+
37
+
38
+ class AsyncBody(httpx2.SyncByteStream):
39
+ def __init__(self, response, transport):
40
+ self.response = response
41
+ self.transport = transport
42
+
43
+ def __iter__(self):
44
+ chunks = self.response.aiter_raw()
45
+ while (chunk := self.transport.run(anext(chunks, None))) is not None:
46
+ yield chunk
47
+
48
+ def close(self):
49
+ self.transport.run(self.response.aclose())
@@ -0,0 +1,258 @@
1
+ """Small sync/async clients. HTTP bodies are read only as Arrow requests bytes."""
2
+
3
+ import asyncio
4
+ import io
5
+ import os
6
+ from collections.abc import Mapping
7
+
8
+ import httpx2
9
+ import pyarrow as pa
10
+ from typesafe_sdk import JSONContent, Question
11
+
12
+ from ._async_transport import AsyncTransport
13
+
14
+ MEDIA_TYPE = "application/vnd.apache.arrow.stream"
15
+ _MISSING = object()
16
+ _END = object()
17
+
18
+
19
+ class _HTTPInput(io.RawIOBase):
20
+ def __init__(self, response):
21
+ super().__init__()
22
+ self.response = response
23
+ self.chunks = iter(response.iter_bytes())
24
+ self.pending = bytearray()
25
+
26
+ def readable(self):
27
+ return True
28
+
29
+ def read(self, size=-1):
30
+ if self.closed:
31
+ raise ValueError("I/O operation on closed Arrow stream")
32
+ while size < 0 or len(self.pending) < size:
33
+ chunk = next(self.chunks, None)
34
+ if chunk is None:
35
+ break
36
+ self.pending.extend(chunk)
37
+ if size < 0:
38
+ size = len(self.pending)
39
+ result = bytes(self.pending[:size])
40
+ del self.pending[:size]
41
+ return result
42
+
43
+ def close(self):
44
+ if not self.closed:
45
+ try:
46
+ self.response.close()
47
+ finally:
48
+ super().close()
49
+
50
+
51
+ class ArrowReader(pa.ipc.RecordBatchStreamReader):
52
+ """A real PyArrow reader which also owns and closes its HTTP response."""
53
+
54
+ def __init__(self, response, expected_rows, on_close):
55
+ self._source = _HTTPInput(response)
56
+ self._expected_rows = expected_rows
57
+ self._rows = 0
58
+ self._closed = False
59
+ self._on_close = on_close
60
+ try:
61
+ super().__init__(self._source)
62
+ except BaseException:
63
+ self._source.close()
64
+ raise
65
+
66
+ def read_next_batch(self) -> pa.RecordBatch:
67
+ try:
68
+ batch = super().read_next_batch()
69
+ self._rows += batch.num_rows
70
+ if self._rows > self._expected_rows:
71
+ raise OSError("Jevaro returned more rows than requested")
72
+ return batch
73
+ except StopIteration:
74
+ self.close()
75
+ if self._rows != self._expected_rows:
76
+ raise OSError(
77
+ f"Incomplete Jevaro stream: expected {self._expected_rows} rows, got {self._rows}"
78
+ ) from None
79
+ raise
80
+ except BaseException:
81
+ self.close()
82
+ raise
83
+
84
+ def __iter__(self):
85
+ return self
86
+
87
+ def __next__(self):
88
+ return self.read_next_batch()
89
+
90
+ def read_all(self) -> pa.Table:
91
+ return pa.Table.from_batches(self, schema=self.schema)
92
+
93
+ def close(self):
94
+ if not self._closed:
95
+ self._closed = True
96
+ try:
97
+ # Release HTTP before Arrow: an async caller may be cancelling
98
+ # while a worker thread is blocked inside read_next_batch().
99
+ self._source.close()
100
+ finally:
101
+ try:
102
+ super().close()
103
+ finally:
104
+ self._on_close(self)
105
+
106
+ def __enter__(self):
107
+ return self
108
+
109
+ def __exit__(self, *exc):
110
+ self.close()
111
+
112
+
113
+ class TypeSafeClient:
114
+ def __init__(
115
+ self, *, api_key: str | None = None, base_url: str | None = None,
116
+ model: str | None = None, timeout: float = 60.0,
117
+ headers: Mapping[str, str] | None = None,
118
+ _transport: httpx2.BaseTransport | None = None,
119
+ ):
120
+ self.api_key = api_key if api_key is not None else os.environ.get("TYPESAFE_API_KEY")
121
+ self.base_url = (base_url or os.environ.get("TYPESAFE_BASE_URL")
122
+ or "http://127.0.0.1:8000").rstrip("/")
123
+ self.model = model or os.environ.get("TYPESAFE_DEFAULT_MODEL", "jev-latest")
124
+ self._http = httpx2.Client(timeout=timeout, headers=headers, transport=_transport)
125
+ self._readers = set()
126
+
127
+ def system_one(
128
+ self, state: JSONContent = _MISSING,
129
+ questions: Mapping[str, Question] | None = None, *,
130
+ states: list[JSONContent] = _MISSING, model: str | None = None,
131
+ timeout: float | None = None, extra_headers: Mapping[str, str] | None = None,
132
+ ) -> ArrowReader:
133
+ if (state is _MISSING) == (states is _MISSING):
134
+ raise ValueError("Supply exactly one of state or states")
135
+ if states is not _MISSING and (not isinstance(states, list) or not states):
136
+ raise ValueError("states must be a nonempty list")
137
+ if not questions:
138
+ raise ValueError("questions must be a nonempty mapping")
139
+ body = {
140
+ "model": model or self.model,
141
+ "questions": {
142
+ name: q.model_dump(mode="json") if hasattr(q, "model_dump") else q
143
+ for name, q in questions.items()
144
+ },
145
+ }
146
+ body["state" if states is _MISSING else "states"] = state if states is _MISSING else states
147
+ expected_rows = 1 if states is _MISSING else len(states)
148
+ headers = {"Accept": MEDIA_TYPE}
149
+ if self.api_key:
150
+ headers["Authorization"] = f"Bearer {self.api_key}"
151
+ headers.update(extra_headers or {})
152
+ kwargs = {} if timeout is None else {"timeout": timeout}
153
+ request = self._http.build_request(
154
+ "POST", f"{self.base_url}/v1/systemone", json=body, headers=headers, **kwargs,
155
+ )
156
+ response = self._http.send(request, stream=True)
157
+ try:
158
+ if response.is_error:
159
+ response.read()
160
+ response.raise_for_status()
161
+ if response.headers.get("content-type", "").split(";", 1)[0] != MEDIA_TYPE:
162
+ raise ValueError("Expected an Arrow IPC stream from Jevaro")
163
+ reader = ArrowReader(response, expected_rows, self._readers.discard)
164
+ except BaseException:
165
+ response.close()
166
+ raise
167
+ self._readers.add(reader)
168
+ return reader
169
+
170
+ def close(self):
171
+ for reader in list(self._readers):
172
+ reader.close()
173
+ self._http.close()
174
+
175
+ def __enter__(self):
176
+ return self
177
+
178
+ def __exit__(self, *exc):
179
+ self.close()
180
+
181
+
182
+ class AsyncArrowReader:
183
+ """Async iteration over a PyArrow reader; blocking I/O runs in worker threads."""
184
+
185
+ def __init__(self, reader: ArrowReader):
186
+ self.reader = reader
187
+
188
+ @property
189
+ def schema(self):
190
+ return self.reader.schema
191
+
192
+ async def read_next_batch(self) -> pa.RecordBatch:
193
+ def read():
194
+ return next(self.reader, _END)
195
+
196
+ try:
197
+ batch = await asyncio.to_thread(read)
198
+ except asyncio.CancelledError:
199
+ await self.aclose()
200
+ raise
201
+ if batch is _END:
202
+ raise StopAsyncIteration
203
+ return batch
204
+
205
+ def __aiter__(self):
206
+ return self
207
+
208
+ async def __anext__(self):
209
+ return await self.read_next_batch()
210
+
211
+ async def read_all(self) -> pa.Table:
212
+ return pa.Table.from_batches([batch async for batch in self], schema=self.schema)
213
+
214
+ async def aclose(self):
215
+ await asyncio.to_thread(self.reader.close)
216
+
217
+ async def __aenter__(self):
218
+ return self
219
+
220
+ async def __aexit__(self, *exc):
221
+ await self.aclose()
222
+
223
+
224
+ class AsyncTypeSafeClient:
225
+ def __init__(self, **kwargs):
226
+ self._transport = AsyncTransport()
227
+ self._client = TypeSafeClient(**kwargs, _transport=self._transport)
228
+
229
+ async def system_one(
230
+ self, state: JSONContent = _MISSING,
231
+ questions: Mapping[str, Question] | None = None, *,
232
+ states: list[JSONContent] = _MISSING, model: str | None = None,
233
+ timeout: float | None = None, extra_headers: Mapping[str, str] | None = None,
234
+ ) -> AsyncArrowReader:
235
+ self._transport.bind_loop()
236
+ opening = asyncio.create_task(asyncio.to_thread(
237
+ self._client.system_one, state, questions, states=states, model=model,
238
+ timeout=timeout, extra_headers=extra_headers,
239
+ ))
240
+ try:
241
+ return AsyncArrowReader(await asyncio.shield(opening))
242
+ except asyncio.CancelledError:
243
+ # A cancelled caller must not leave a subsequently opened HTTP stream alive.
244
+ def cleanup(task):
245
+ if not task.cancelled() and task.exception() is None:
246
+ asyncio.create_task(asyncio.to_thread(task.result().close))
247
+ opening.add_done_callback(cleanup)
248
+ raise
249
+
250
+ async def aclose(self):
251
+ self._transport.bind_loop()
252
+ await asyncio.to_thread(self._client.close)
253
+
254
+ async def __aenter__(self):
255
+ return self
256
+
257
+ async def __aexit__(self, *exc):
258
+ await self.aclose()
File without changes
@@ -0,0 +1,150 @@
1
+ Metadata-Version: 2.4
2
+ Name: jevaro
3
+ Version: 0.1.0
4
+ Summary: TypeSafe-style Python client for Jevaro Arrow streams
5
+ Author: Columnar Technologies Inc.
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/columnar-tech/jevaro
8
+ Project-URL: Documentation, https://github.com/columnar-tech/jevaro/blob/main/jevaro-python/README.md
9
+ Project-URL: Repository, https://github.com/columnar-tech/jevaro
10
+ Project-URL: Issues, https://github.com/columnar-tech/jevaro/issues
11
+ Requires-Python: >=3.11
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ License-File: NOTICE
15
+ Requires-Dist: typesafe-sdk==0.7.2
16
+ Requires-Dist: httpx2<3,>=2.13
17
+ Requires-Dist: pyarrow==25.0.1
18
+ Dynamic: license-file
19
+
20
+ # Jevaro Python SDK
21
+
22
+ Use TypeSafe-style arguments and read the answers as Arrow. Requires Python
23
+ 3.11+ and a running Jevaro server. Start with the
24
+ [quickstart](https://github.com/columnar-tech/jevaro/blob/main/docs/quickstart.md).
25
+
26
+ ## Install
27
+
28
+ ```sh
29
+ python3 -m venv .venv
30
+ .venv/bin/python -m pip install jevaro
31
+ ```
32
+
33
+ ## Read results
34
+
35
+ ```python
36
+ from jevaro import Noul, TypeSafeClient
37
+
38
+ with TypeSafeClient() as client:
39
+ with client.system_one(
40
+ states=["Please refund the shoes.", "Where is my parcel?"],
41
+ questions={"refund": Noul(instructions="Is a refund being requested?")},
42
+ ) as reader:
43
+ print(reader.schema)
44
+ for batch in reader:
45
+ print(batch.to_pylist())
46
+ ```
47
+
48
+ The reader is a `pyarrow.RecordBatchReader`. Its schema is available before
49
+ answers arrive. The first batch has zero rows; later batches have one row each.
50
+ Use `reader.read_all()` to collect a `pyarrow.Table`.
51
+
52
+ Keep the client open while reading. A context manager closes the HTTP response
53
+ if you stop early; full iteration closes it automatically.
54
+
55
+ ## Questions and arguments
56
+
57
+ `Choice`, `Score`, and `Noul` are re-exported from the official TypeSafe SDK.
58
+ Question dictionaries work too. See the bundled
59
+ [three-type example](https://github.com/columnar-tech/jevaro/blob/main/jevaro-python/example.py).
60
+
61
+ `system_one(state, questions, *, states=..., model=..., timeout=..., extra_headers=...)`
62
+ returns an `ArrowReader`. Supply exactly one of `state` and `states`.
63
+
64
+ | Argument | Meaning |
65
+ | --- | --- |
66
+ | `state` | One string, object, or array |
67
+ | `states` | A nonempty list of states |
68
+ | `questions` | A nonempty mapping of question IDs to definitions |
69
+ | `model` | Override the client's model |
70
+ | `timeout` | Override the client's I/O timeout, in seconds |
71
+ | `extra_headers` | Add or override headers for this request |
72
+
73
+ An array in singular `state` is one evaluation. Use `states` to evaluate its
74
+ elements separately.
75
+
76
+ ## Client configuration
77
+
78
+ `TypeSafeClient` and `AsyncTypeSafeClient` accept these keyword arguments:
79
+
80
+ | Option | Default |
81
+ | --- | --- |
82
+ | `api_key` | `TYPESAFE_API_KEY`; otherwise the server may supply its key |
83
+ | `base_url` | `TYPESAFE_BASE_URL`, then `http://127.0.0.1:8000` |
84
+ | `model` | `TYPESAFE_DEFAULT_MODEL`, then `jev-latest` |
85
+ | `timeout` | 60 seconds per HTTP I/O operation |
86
+ | `headers` | No extra headers |
87
+
88
+ The timeout is not a deadline for the whole batch. Call `client.close()` when
89
+ not using a context manager; use `await client.aclose()` for the async client.
90
+
91
+ ## Async
92
+
93
+ ```python
94
+ import asyncio
95
+ from jevaro import AsyncTypeSafeClient, Noul
96
+
97
+ async def main():
98
+ async with AsyncTypeSafeClient() as client:
99
+ async with await client.system_one(
100
+ states=["Please refund the shoes.", "Where is my parcel?"],
101
+ questions={"refund": Noul(instructions="Is a refund being requested?")},
102
+ ) as reader:
103
+ async for batch in reader:
104
+ print(batch.to_pylist())
105
+
106
+ asyncio.run(main())
107
+ ```
108
+
109
+ `AsyncArrowReader` has `schema`, async iteration, `await read_next_batch()`,
110
+ `await read_all()`, and `await aclose()`. Read methods return PyArrow batches or
111
+ a table. `read_next_batch()` raises `StopAsyncIteration` at the end.
112
+
113
+ Use the async interface for normal reads. Its `reader` property exposes the
114
+ underlying PyArrow reader; direct reads must run through `asyncio.to_thread`.
115
+ Consume a reader from one task at a time.
116
+
117
+ ## Metadata and files
118
+
119
+ Choice selections are integer indices into schema labels. Score legends also
120
+ live in schema metadata. See the
121
+ [Arrow schema](https://github.com/columnar-tech/jevaro/blob/main/docs/arrow-schema.md)
122
+ for decoding rules. `batch.to_pylist()` exposes these storage values.
123
+
124
+ To save a stream, open a writer with `reader.schema` and pass each batch to
125
+ `writer.write_batch(batch)`. The bundled example does this:
126
+
127
+ ```sh
128
+ .venv/bin/python jevaro-python/example.py --output jevaro-results.arrows
129
+ .venv/bin/python scripts/read_results.py jevaro-results.arrows
130
+ ```
131
+
132
+ `read_results.py` reconstructs full answer objects using only the saved schema
133
+ and PyArrow. Run these commands from the repository root.
134
+
135
+ ## Errors and compatibility
136
+
137
+ Invalid argument combinations raise `ValueError`. HTTP errors before streaming
138
+ raise `httpx2.HTTPStatusError`. Network or Arrow errors can occur during reading.
139
+ Unexpected row counts raise `OSError`.
140
+
141
+ This SDK implements System One evaluation with Arrow results. Model listing,
142
+ custom JSON response models, usage objects, and the official SDK's error
143
+ classes are outside its API. Per-state retries happen at the proxy; the SDK
144
+ does not retry an entire batch.
145
+
146
+ See [Contributing](https://github.com/columnar-tech/jevaro/blob/main/CONTRIBUTING.md)
147
+ for tests.
148
+
149
+ [Apache-2.0](https://github.com/columnar-tech/jevaro/blob/main/LICENSE).
150
+ Copyright 2026 Columnar Technologies Inc.
@@ -0,0 +1,16 @@
1
+ LICENSE
2
+ MANIFEST.in
3
+ NOTICE
4
+ README.md
5
+ example.py
6
+ pyproject.toml
7
+ src/jevaro/__init__.py
8
+ src/jevaro/_async_transport.py
9
+ src/jevaro/client.py
10
+ src/jevaro/py.typed
11
+ src/jevaro.egg-info/PKG-INFO
12
+ src/jevaro.egg-info/SOURCES.txt
13
+ src/jevaro.egg-info/dependency_links.txt
14
+ src/jevaro.egg-info/requires.txt
15
+ src/jevaro.egg-info/top_level.txt
16
+ tests/test_client.py
@@ -0,0 +1,3 @@
1
+ typesafe-sdk==0.7.2
2
+ httpx2<3,>=2.13
3
+ pyarrow==25.0.1
@@ -0,0 +1 @@
1
+ jevaro
@@ -0,0 +1,90 @@
1
+ import io
2
+ import unittest
3
+
4
+ import httpx2
5
+ import pyarrow as pa
6
+ from jevaro import Noul, TypeSafeClient
7
+
8
+
9
+ def ipc(values):
10
+ data = io.BytesIO()
11
+ table = pa.table({"answer": pa.array(values, type=pa.float64())})
12
+ with pa.ipc.new_stream(data, table.schema) as writer:
13
+ writer.write_table(table)
14
+ return data.getvalue()
15
+
16
+
17
+ class Chunks(httpx2.SyncByteStream):
18
+ def __init__(self, data):
19
+ self.data = data
20
+ self.closed = False
21
+
22
+ def __iter__(self):
23
+ for offset in range(0, len(self.data), 7):
24
+ yield self.data[offset:offset + 7]
25
+
26
+ def close(self):
27
+ self.closed = True
28
+
29
+
30
+ class ClientTests(unittest.TestCase):
31
+ def client(self, values=(0.12345678901234567,), status=200, content_type="application/vnd.apache.arrow.stream"):
32
+ client = TypeSafeClient(api_key="test-key")
33
+ client._http.close()
34
+ stream = Chunks(ipc(values))
35
+ client._http = httpx2.Client(transport=httpx2.MockTransport(lambda request: httpx2.Response(
36
+ status, stream=stream, headers={"Content-Type": content_type},
37
+ )))
38
+ self.addCleanup(client.close)
39
+ return client, stream
40
+
41
+ def test_chunk_boundaries_native_reader_and_close_on_exhaustion(self):
42
+ client, stream = self.client()
43
+ reader = client.system_one(state="one", questions={"answer": Noul()})
44
+ self.assertIsInstance(reader, pa.RecordBatchReader)
45
+ self.assertFalse(stream.closed)
46
+ self.assertEqual(reader.read_all()["answer"].to_pylist(), [0.12345678901234567])
47
+ self.assertTrue(stream.closed)
48
+ self.assertFalse(client._readers)
49
+
50
+ def test_clean_eof_with_missing_rows_is_an_error(self):
51
+ client, stream = self.client()
52
+ reader = client.system_one(states=["one", "two"], questions={"answer": Noul()})
53
+ with self.assertRaisesRegex(OSError, "expected 2 rows, got 1"):
54
+ reader.read_all()
55
+ self.assertTrue(stream.closed)
56
+
57
+ def test_extra_rows_are_an_error(self):
58
+ client, stream = self.client(values=(0.1, 0.2))
59
+ reader = client.system_one(state="one", questions={"answer": Noul()})
60
+ with self.assertRaisesRegex(OSError, "more rows"):
61
+ reader.read_all()
62
+ self.assertTrue(stream.closed)
63
+
64
+ def test_client_close_closes_unconsumed_readers(self):
65
+ client, stream = self.client()
66
+ client.system_one(state="one", questions={"answer": Noul()})
67
+ client.close()
68
+ self.assertTrue(stream.closed)
69
+
70
+ def test_http_errors_close_body(self):
71
+ client, stream = self.client(status=422)
72
+ with self.assertRaises(httpx2.HTTPStatusError):
73
+ client.system_one(state="one", questions={"answer": Noul()})
74
+ self.assertTrue(stream.closed)
75
+
76
+ def test_wrong_media_type_closes_body(self):
77
+ client, stream = self.client(content_type="application/json")
78
+ with self.assertRaisesRegex(ValueError, "Arrow IPC stream"):
79
+ client.system_one(state="one", questions={"answer": Noul()})
80
+ self.assertTrue(stream.closed)
81
+
82
+ def test_invalid_arguments(self):
83
+ client, _ = self.client()
84
+ for args in ({}, {"states": []}, {"states": "no"}, {"state": "a", "states": ["b"]}):
85
+ with self.assertRaises(ValueError):
86
+ client.system_one(**args, questions={"answer": Noul()})
87
+
88
+
89
+ if __name__ == "__main__":
90
+ unittest.main()