schemez 1.2.2__tar.gz → 1.2.4__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.

Potentially problematic release.


This version of schemez might be problematic. Click here for more details.

Files changed (25) hide show
  1. {schemez-1.2.2 → schemez-1.2.4}/PKG-INFO +1 -1
  2. {schemez-1.2.2 → schemez-1.2.4}/pyproject.toml +1 -1
  3. {schemez-1.2.2 → schemez-1.2.4}/src/schemez/functionschema.py +9 -11
  4. {schemez-1.2.2 → schemez-1.2.4}/src/schemez/helpers.py +5 -40
  5. {schemez-1.2.2 → schemez-1.2.4}/src/schemez/schema.py +5 -4
  6. {schemez-1.2.2 → schemez-1.2.4}/src/schemez/tool_executor/executor.py +7 -6
  7. {schemez-1.2.2 → schemez-1.2.4}/src/schemez/tool_executor/helpers.py +2 -2
  8. {schemez-1.2.2 → schemez-1.2.4}/LICENSE +0 -0
  9. {schemez-1.2.2 → schemez-1.2.4}/README.md +0 -0
  10. {schemez-1.2.2 → schemez-1.2.4}/src/schemez/__init__.py +0 -0
  11. {schemez-1.2.2 → schemez-1.2.4}/src/schemez/bind_kwargs.py +0 -0
  12. {schemez-1.2.2 → schemez-1.2.4}/src/schemez/code.py +0 -0
  13. {schemez-1.2.2 → schemez-1.2.4}/src/schemez/convert.py +0 -0
  14. {schemez-1.2.2 → schemez-1.2.4}/src/schemez/create_type.py +0 -0
  15. {schemez-1.2.2 → schemez-1.2.4}/src/schemez/docstrings.py +0 -0
  16. {schemez-1.2.2 → schemez-1.2.4}/src/schemez/executable.py +0 -0
  17. {schemez-1.2.2 → schemez-1.2.4}/src/schemez/log.py +0 -0
  18. {schemez-1.2.2 → schemez-1.2.4}/src/schemez/py.typed +0 -0
  19. {schemez-1.2.2 → schemez-1.2.4}/src/schemez/pydantic_types.py +0 -0
  20. {schemez-1.2.2 → schemez-1.2.4}/src/schemez/schema_generators.py +0 -0
  21. {schemez-1.2.2 → schemez-1.2.4}/src/schemez/schemadef/__init__.py +0 -0
  22. {schemez-1.2.2 → schemez-1.2.4}/src/schemez/schemadef/schemadef.py +0 -0
  23. {schemez-1.2.2 → schemez-1.2.4}/src/schemez/tool_executor/__init__.py +0 -0
  24. {schemez-1.2.2 → schemez-1.2.4}/src/schemez/tool_executor/types.py +0 -0
  25. {schemez-1.2.2 → schemez-1.2.4}/src/schemez/typedefs.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: schemez
3
- Version: 1.2.2
3
+ Version: 1.2.4
4
4
  Summary: Pydantic shim for config stuff
5
5
  Keywords:
6
6
  Author: Philipp Temminghoff
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "schemez"
3
- version = "1.2.2"
3
+ version = "1.2.4"
4
4
  description = "Pydantic shim for config stuff"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.13"
@@ -12,7 +12,6 @@ import decimal
12
12
  import enum
13
13
  import inspect
14
14
  import ipaddress
15
- import logging
16
15
  from pathlib import Path
17
16
  import re
18
17
  import types
@@ -23,6 +22,7 @@ from uuid import UUID
23
22
  import docstring_parser
24
23
  import pydantic
25
24
 
25
+ from schemez import log
26
26
  from schemez.typedefs import (
27
27
  OpenAIFunctionDefinition,
28
28
  OpenAIFunctionTool,
@@ -34,7 +34,7 @@ if typing.TYPE_CHECKING:
34
34
  from schemez.typedefs import Property
35
35
 
36
36
 
37
- logger = logging.getLogger(__name__)
37
+ logger = log.get_logger(__name__)
38
38
 
39
39
 
40
40
  class FunctionType(enum.StrEnum):
@@ -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
- try:
253
- # Check if datamodel-codegen is available
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) from e
259
+ raise RuntimeError(msg)
262
260
 
263
261
  name = class_name or f"{self.name.title()}Response"
264
262
 
@@ -4,8 +4,8 @@ from __future__ import annotations
4
4
 
5
5
  import asyncio
6
6
  import importlib
7
- import os
8
7
  from pathlib import Path
8
+ import shutil
9
9
  import subprocess
10
10
  import sys
11
11
  import tempfile
@@ -15,7 +15,6 @@ from pydantic import BaseModel
15
15
  from pydantic_core import to_json
16
16
 
17
17
 
18
- StrPath = str | os.PathLike[str]
19
18
  PythonVersion = Literal["3.13", "3.14", "3.15"]
20
19
 
21
20
  if TYPE_CHECKING:
@@ -177,42 +176,6 @@ def resolve_type_string(type_string: str, safe: bool = True) -> type:
177
176
  raise ValueError(msg) from e
178
177
 
179
178
 
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
179
  async def model_to_python_code(
217
180
  model: type[BaseModel] | dict[str, Any],
218
181
  *,
@@ -236,7 +199,10 @@ async def model_to_python_code(
236
199
  RuntimeError: If datamodel-codegen is not available
237
200
  subprocess.CalledProcessError: If code generation fails
238
201
  """
239
- working_prefix = await _detect_command("datamodel-codegen")
202
+ # Check if datamodel-codegen is available
203
+ if not shutil.which("datamodel-codegen"):
204
+ msg = "datamodel-codegen not available"
205
+ raise RuntimeError(msg)
240
206
 
241
207
  if isinstance(model, dict):
242
208
  schema = model
@@ -271,7 +237,6 @@ async def model_to_python_code(
271
237
 
272
238
  try: # Generate model using datamodel-codegen
273
239
  proc = await asyncio.create_subprocess_exec(
274
- *working_prefix,
275
240
  "datamodel-codegen",
276
241
  *args,
277
242
  stdout=asyncio.subprocess.PIPE,
@@ -2,7 +2,6 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
- import os
6
5
  from typing import TYPE_CHECKING, Any, Literal, Self
7
6
 
8
7
  import anyenv
@@ -15,9 +14,9 @@ if TYPE_CHECKING:
15
14
 
16
15
  from llmling_agent.agent.agent import AgentType
17
16
  from llmling_agent.models.content import BaseContent
17
+ from upath.types import JoinablePathLike
18
18
 
19
19
 
20
- StrPath = str | os.PathLike[str]
21
20
  SourceType = Literal["pdf", "image"]
22
21
  PythonVersion = Literal["3.13", "3.14", "3.15"]
23
22
 
@@ -43,7 +42,9 @@ class Schema(BaseModel):
43
42
  return merge_models(self, other)
44
43
 
45
44
  @classmethod
46
- def from_yaml(cls, content: str, inherit_path: StrPath | None = None) -> Self:
45
+ def from_yaml(
46
+ cls, content: str, inherit_path: JoinablePathLike | None = None
47
+ ) -> Self:
47
48
  """Create from YAML string."""
48
49
  import yamling
49
50
 
@@ -233,7 +234,7 @@ class Schema(BaseModel):
233
234
  )
234
235
  return yamling.dump_yaml(text)
235
236
 
236
- def save(self, path: StrPath, overwrite: bool = False) -> None:
237
+ def save(self, path: JoinablePathLike, overwrite: bool = False) -> None:
237
238
  """Save configuration to a YAML file.
238
239
 
239
240
  Args:
@@ -3,7 +3,6 @@
3
3
  from __future__ import annotations
4
4
 
5
5
  import asyncio
6
- import logging
7
6
  from pathlib import Path
8
7
  import time
9
8
  from typing import TYPE_CHECKING, Any
@@ -12,6 +11,7 @@ from pydantic import BaseModel
12
11
  from pydantic_core import from_json
13
12
  from upath import UPath
14
13
 
14
+ from schemez import log
15
15
  from schemez.functionschema import FunctionSchema
16
16
  from schemez.tool_executor.helpers import clean_generated_code, generate_input_model
17
17
 
@@ -20,11 +20,12 @@ if TYPE_CHECKING:
20
20
  from collections.abc import Callable, Sequence
21
21
 
22
22
  from fastapi import FastAPI
23
+ from upath.types import JoinablePathLike
23
24
 
24
25
  from schemez.tool_executor.types import ToolHandler
25
26
 
26
27
 
27
- logger = logging.getLogger(__name__)
28
+ logger = log.get_logger(__name__)
28
29
 
29
30
 
30
31
  class HttpToolExecutor:
@@ -32,7 +33,7 @@ class HttpToolExecutor:
32
33
 
33
34
  def __init__(
34
35
  self,
35
- schemas: Sequence[dict[str, Any] | Path],
36
+ schemas: Sequence[dict[str, Any] | UPath],
36
37
  handler: ToolHandler,
37
38
  base_url: str = "http://localhost:8000",
38
39
  ):
@@ -61,7 +62,7 @@ class HttpToolExecutor:
61
62
  match schema:
62
63
  case dict():
63
64
  loaded_schemas.append(schema)
64
- case str() | Path():
65
+ case str() | Path() | UPath():
65
66
  text = UPath(schema).read_text("utf-8")
66
67
  loaded_schemas.append(from_json(text))
67
68
  case _:
@@ -264,7 +265,7 @@ from datetime import datetime
264
265
  uvicorn.run(app, host=host, port=port)
265
266
  return None
266
267
 
267
- async def save_to_files(self, output_dir: Path) -> dict[str, Path]:
268
+ async def save_to_files(self, output_dir: JoinablePathLike) -> dict[str, UPath]:
268
269
  """Save generated code to files.
269
270
 
270
271
  Args:
@@ -273,7 +274,7 @@ from datetime import datetime
273
274
  Returns:
274
275
  Dictionary mapping file types to paths
275
276
  """
276
- output_dir = Path(output_dir)
277
+ output_dir = UPath(output_dir)
277
278
  output_dir.mkdir(parents=True, exist_ok=True)
278
279
 
279
280
  saved_files = {}
@@ -2,13 +2,13 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
- import logging
6
5
  import time
7
6
 
7
+ from schemez import log
8
8
  from schemez.helpers import model_to_python_code
9
9
 
10
10
 
11
- logger = logging.getLogger(__name__)
11
+ logger = log.get_logger(__name__)
12
12
 
13
13
 
14
14
  async def generate_input_model(schema_dict: dict) -> tuple[str, str]:
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes