-
Notifications
You must be signed in to change notification settings - Fork 9
[Issue #799] Transform PoC #810
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
bf1e8a8
Issue #799 Transform PoC
jcrichlake 3e8d260
Fixing plugin in makefile
jcrichlake 12bde81
Merge branch 'main' into 799-transform-poc
jcrichlake 8850fb1
Adding custom handler example
jcrichlake c6af48c
Updating transform contract
jcrichlake 0139cde
Fixing make:checks errors
jcrichlake bb1c766
Reducing duplicate tests and updating makefile
jcrichlake 84576f6
Fixing pr comments.
jcrichlake ffd4051
Adding ADR fixes
jcrichlake 915c6c5
PR comments rd 2
jcrichlake bea786d
Update website/src/content/docs/governance/adr/0022-plugin-framework.mdx
jcrichlake 2d22aba
Merge branch 'HOLD-transforms' into 799-transform-poc
jcrichlake File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,28 +1,81 @@ | ||
| """Plugin configuration and composition APIs.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from dataclasses import dataclass | ||
| from typing import Generic, TypeVar | ||
| from typing import Any, Callable, Generic, TypeVar | ||
|
|
||
| from .specs import SchemaExtensions | ||
| from .types import ClientConfig, ObjectSchemas, ObjectSchemasInput, PluginExtensionsMeta | ||
|
|
||
| T = TypeVar("T") | ||
|
|
||
|
|
||
| @dataclass(frozen=True) | ||
| class PluginConfig: | ||
| """Build-time plugin config discoverable by the generator.""" | ||
| """Build-time plugin config discoverable by the code generator. | ||
|
|
||
| extensions: custom field declarations (read by generate.py — do not rename). | ||
| meta: optional plugin identity and capability declaration. | ||
| transform_schemas: optional bidirectional transform callables per object. | ||
| Stored as ObjectSchemasInput (not compiled to ObjectSchemas) in the PoC. | ||
| Full compilation with model_validate wrapping is a TODO for the real SDK. | ||
|
|
||
| TODO (full SDK): add get_client, filters. | ||
| """ | ||
|
|
||
| extensions: SchemaExtensions | ||
| meta: PluginExtensionsMeta | None = None | ||
| transform_schemas: dict[str, ObjectSchemasInput[Any, Any]] | None = None | ||
|
|
||
|
|
||
| @dataclass(frozen=True) | ||
| @dataclass | ||
| class Plugin(Generic[T]): | ||
| """Runtime plugin container with both extension specs and generated schemas.""" | ||
| """Runtime plugin container with extension specs and generated schemas. | ||
|
|
||
| extensions: SchemaExtensions used by generate.py (do not rename or reorder — | ||
| the generated __init__.py constructs Plugin(extensions=..., schemas=...)). | ||
| schemas: generated _Schemas object (typed Pydantic model classes from generate.py). | ||
| NOTE: there is a naming collision: ADR-0022 also calls its runtime transform | ||
| dict "schemas". These are different concepts sharing the same name — a design | ||
| question to resolve in the full SDK (see Design Finding #1 in the spec). | ||
| transform_schemas: ADR-0022 runtime transform dict; named distinctly from | ||
| `schemas` to avoid collision with the generated schemas field in the PoC. | ||
|
|
||
| TODO (full SDK): memoize get_client. | ||
| """ | ||
|
|
||
| extensions: SchemaExtensions | ||
| schemas: T | ||
| schemas: T # generated _Schemas object — keep as positional for generate.py compat | ||
| meta: PluginExtensionsMeta | None = None | ||
| get_client: Callable[[ClientConfig], Any] | None = None # TODO: memoize | ||
| # PoC stores ObjectSchemasInput here (no compilation yet); full SDK will store | ||
| # ObjectSchemas after model_validate wrapping. Annotated as the union so both | ||
| # the current PoC usage and the future compiled form are type-safe. | ||
| transform_schemas: ( | ||
| dict[str, ObjectSchemasInput[Any, Any] | ObjectSchemas[Any, Any]] | None | ||
| ) = None | ||
| filters: dict[str, dict[str, Any]] | None = None | ||
|
|
||
|
|
||
| def define_plugin( | ||
| extensions: SchemaExtensions, | ||
| meta: PluginExtensionsMeta | None = None, | ||
| transform_schemas: dict[str, ObjectSchemasInput[Any, Any]] | None = None, | ||
| # TODO (full SDK): get_client, filters | ||
| ) -> PluginConfig: | ||
| """Create a PluginConfig object consumed by the code generator. | ||
|
|
||
| Backward-compatible: existing callers passing only `extensions` are unaffected. | ||
| New params are stored as-is — no compilation occurs in the PoC. | ||
|
|
||
| def define_plugin(extensions: SchemaExtensions) -> PluginConfig: | ||
| """Create a plugin config object consumed by the code generator.""" | ||
| return PluginConfig(extensions=extensions) | ||
| TODO (full SDK): | ||
| - Auto-generate transforms from extensions.schemas[obj].mappings when no | ||
| explicit to_common/from_common is supplied. | ||
| - Wrap transform output with model_validate. | ||
| """ | ||
| return PluginConfig( | ||
| extensions=extensions, | ||
| meta=meta, | ||
| transform_schemas=transform_schemas, | ||
| ) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure we want this commited?