schemez 1.2.2__py3-none-any.whl → 1.2.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- schemez/functionschema.py +7 -9
- schemez/helpers.py +5 -38
- {schemez-1.2.2.dist-info → schemez-1.2.3.dist-info}/METADATA +1 -1
- {schemez-1.2.2.dist-info → schemez-1.2.3.dist-info}/RECORD +6 -6
- {schemez-1.2.2.dist-info → schemez-1.2.3.dist-info}/WHEEL +1 -1
- {schemez-1.2.2.dist-info → schemez-1.2.3.dist-info}/licenses/LICENSE +0 -0
schemez/functionschema.py
CHANGED
@@ -119,6 +119,9 @@ class FunctionSchema(pydantic.BaseModel):
|
|
119
119
|
required = self.parameters.get("required", self.required)
|
120
120
|
|
121
121
|
for name, details in properties.items():
|
122
|
+
if name.startswith("_"): # TODO: kwarg for renaming instead perhaps?
|
123
|
+
logger.debug("Skipping parameter %s due to leading underscore", name)
|
124
|
+
continue
|
122
125
|
# Get base type
|
123
126
|
if "enum" in details:
|
124
127
|
values = tuple(details["enum"]) # type: ignore
|
@@ -246,19 +249,14 @@ class FunctionSchema(pydantic.BaseModel):
|
|
246
249
|
RuntimeError: If datamodel-codegen is not available
|
247
250
|
subprocess.CalledProcessError: If code generation fails
|
248
251
|
"""
|
252
|
+
import shutil
|
249
253
|
import subprocess
|
250
254
|
import tempfile
|
251
255
|
|
252
|
-
|
253
|
-
|
254
|
-
subprocess.run(
|
255
|
-
["datamodel-codegen", "--version"],
|
256
|
-
check=True,
|
257
|
-
capture_output=True,
|
258
|
-
)
|
259
|
-
except (subprocess.CalledProcessError, FileNotFoundError) as e:
|
256
|
+
# Check if datamodel-codegen is available
|
257
|
+
if not shutil.which("datamodel-codegen"):
|
260
258
|
msg = "datamodel-codegen not available"
|
261
|
-
raise RuntimeError(msg)
|
259
|
+
raise RuntimeError(msg)
|
262
260
|
|
263
261
|
name = class_name or f"{self.name.title()}Response"
|
264
262
|
|
schemez/helpers.py
CHANGED
@@ -6,6 +6,7 @@ import asyncio
|
|
6
6
|
import importlib
|
7
7
|
import os
|
8
8
|
from pathlib import Path
|
9
|
+
import shutil
|
9
10
|
import subprocess
|
10
11
|
import sys
|
11
12
|
import tempfile
|
@@ -177,42 +178,6 @@ def resolve_type_string(type_string: str, safe: bool = True) -> type:
|
|
177
178
|
raise ValueError(msg) from e
|
178
179
|
|
179
180
|
|
180
|
-
async def _detect_command(command: str, *, test_flag: str = "--version") -> list[str]:
|
181
|
-
"""Detect the correct command prefix for running a command.
|
182
|
-
|
183
|
-
Tries 'uv run' first, then falls back to direct execution.
|
184
|
-
|
185
|
-
Args:
|
186
|
-
command: The command to detect
|
187
|
-
test_flag: Flag to test command availability with
|
188
|
-
|
189
|
-
Returns:
|
190
|
-
Command prefix list (empty for direct execution)
|
191
|
-
|
192
|
-
Raises:
|
193
|
-
RuntimeError: If command is not available
|
194
|
-
"""
|
195
|
-
cmd_prefixes = [["uv", "run"], []]
|
196
|
-
|
197
|
-
for prefix in cmd_prefixes:
|
198
|
-
try:
|
199
|
-
proc = await asyncio.create_subprocess_exec(
|
200
|
-
*prefix,
|
201
|
-
command,
|
202
|
-
test_flag,
|
203
|
-
stdout=asyncio.subprocess.PIPE,
|
204
|
-
stderr=asyncio.subprocess.PIPE,
|
205
|
-
)
|
206
|
-
await proc.communicate()
|
207
|
-
if proc.returncode == 0:
|
208
|
-
return prefix
|
209
|
-
except FileNotFoundError:
|
210
|
-
continue
|
211
|
-
|
212
|
-
msg = f"{command} not available (tried both 'uv run' and direct execution)"
|
213
|
-
raise RuntimeError(msg)
|
214
|
-
|
215
|
-
|
216
181
|
async def model_to_python_code(
|
217
182
|
model: type[BaseModel] | dict[str, Any],
|
218
183
|
*,
|
@@ -236,7 +201,10 @@ async def model_to_python_code(
|
|
236
201
|
RuntimeError: If datamodel-codegen is not available
|
237
202
|
subprocess.CalledProcessError: If code generation fails
|
238
203
|
"""
|
239
|
-
|
204
|
+
# Check if datamodel-codegen is available
|
205
|
+
if not shutil.which("datamodel-codegen"):
|
206
|
+
msg = "datamodel-codegen not available"
|
207
|
+
raise RuntimeError(msg)
|
240
208
|
|
241
209
|
if isinstance(model, dict):
|
242
210
|
schema = model
|
@@ -271,7 +239,6 @@ async def model_to_python_code(
|
|
271
239
|
|
272
240
|
try: # Generate model using datamodel-codegen
|
273
241
|
proc = await asyncio.create_subprocess_exec(
|
274
|
-
*working_prefix,
|
275
242
|
"datamodel-codegen",
|
276
243
|
*args,
|
277
244
|
stdout=asyncio.subprocess.PIPE,
|
@@ -5,8 +5,8 @@ schemez/convert.py,sha256=3sOxOgDaFzV7uiOUSM6_Sy0YlafIlZRSevs5y2vT1Kw,4403
|
|
5
5
|
schemez/create_type.py,sha256=wrdqdzXtfxZfsgp9IroldoYGTJs_Rdli8TiscqhV2bI,11647
|
6
6
|
schemez/docstrings.py,sha256=kmd660wcomXzKac0SSNYxPRNbVCUovrpmE9jwnVRS6c,4115
|
7
7
|
schemez/executable.py,sha256=YM4WcmRyJ9CpzKpNgS0A-Ri0Jd7mAzfHmoaXONI-mIs,7134
|
8
|
-
schemez/functionschema.py,sha256=
|
9
|
-
schemez/helpers.py,sha256=
|
8
|
+
schemez/functionschema.py,sha256=NXQsZKeo7GRr7gnhEMHJvnjZhQktn9Kjf1W8xWyWh5Y,26135
|
9
|
+
schemez/helpers.py,sha256=_4-S8n7m3yajVYdYckSyrG1GsfMqCOfm5O-bGkYI1qc,7917
|
10
10
|
schemez/log.py,sha256=i0SDbIfWmuC_nfJdQOYAdUYaR0TBk3Mhu-K3M-lnAM4,364
|
11
11
|
schemez/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
12
12
|
schemez/pydantic_types.py,sha256=8vgSl8i2z9n0fB-8AJj-D3TBByEWE5IxItBxQ0XwXFI,1640
|
@@ -19,7 +19,7 @@ schemez/tool_executor/executor.py,sha256=lQFnVO5J64nFNEsy82jRS-q52PaU3fWsnuQddaL
|
|
19
19
|
schemez/tool_executor/helpers.py,sha256=jxBv1G_R8rQU3ACHGgfVEecqO0DSZQ6qUIHcn25Ucc4,1470
|
20
20
|
schemez/tool_executor/types.py,sha256=l2DxUIEHP9bjLnEaXZ6X428cSviicTDJsc3wfSNqKxg,675
|
21
21
|
schemez/typedefs.py,sha256=3OAUQ1nin9nlsOcTPAO5xrsOqVUfwsH_7_cexQYREus,6091
|
22
|
-
schemez-1.2.
|
23
|
-
schemez-1.2.
|
24
|
-
schemez-1.2.
|
25
|
-
schemez-1.2.
|
22
|
+
schemez-1.2.3.dist-info/licenses/LICENSE,sha256=AteGCH9r177TxxrOFEiOARrastASsf7yW6MQxlAHdwA,1078
|
23
|
+
schemez-1.2.3.dist-info/WHEEL,sha256=X16MKk8bp2DRsAuyteHJ-9qOjzmnY0x1aj0P1ftqqWA,78
|
24
|
+
schemez-1.2.3.dist-info/METADATA,sha256=VPcDp5yYQYgz_YPcUsmDFhVh3-oeL7JTOdS4cAw0Aio,11616
|
25
|
+
schemez-1.2.3.dist-info/RECORD,,
|
File without changes
|