Skip to content

feat: add extract_function_schema with primitive type support#2590

Draft
andeplane wants to merge 1 commit into
masterfrom
001-pr1-python-schema-primitives
Draft

feat: add extract_function_schema with primitive type support#2590
andeplane wants to merge 1 commit into
masterfrom
001-pr1-python-schema-primitives

Conversation

@andeplane
Copy link
Copy Markdown
Contributor

Summary

  • Ports the Python script schema generator into the SDK as a pure-Python, no-network utility (extract_function_schema)
  • Establishes module skeleton, dataclasses (SchemaResult, ErrorResult), AST helpers, and validation
  • Supports primitive types: str, int, float, bool (scalars and list[T] variants)
  • Extended types (NodeId, datetime, DataFrame) and docstring enrichment come in PR 2/3

Changes

  • cognite/client/_api/ai/python_schema.py — new module
  • tests/tests_unit/test_api/test_python_schema.py — 12 tests (all marked @pytest.mark.us1)
  • pyproject.toml — adds griffe>=1.0,<2 and jsonschema>=4.0,<5 as optional deps under a new schema extra
  • pytest.ini — registers us1/us2/us3 markers

Test plan

  • pytest tests/tests_unit/test_api/test_python_schema.py -k us1 — all green
  • No regressions in existing test suite

Stack

  • PR 1/3 (this PR) — primitive types + validation
  • PR 2/3 — NodeId, datetime, DataFrame, list types
  • PR 3/3 — docstring enrichment, default values, re-exports

🤖 Generated with Claude Code

Ports the Python script schema generator into the SDK as a pure-Python,
no-network utility. This PR establishes the module skeleton, dataclasses,
AST helpers, validation, and primitive type support (str, int, float, bool).

- New module: cognite/client/_api/ai/python_schema.py
- New tests: tests/tests_unit/test_api/test_python_schema.py (us1 group)
- pyproject.toml: adds griffe>=1.0,<2 and jsonschema>=4.0,<5 as optional
  deps under a new [schema] extra
- pytest.ini: registers us1/us2/us3 markers

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant