Skip to content

Python semantic layer: injection resolution and the public API - #256

Draft
jat255 wants to merge 2 commits into
jat255/wwmt-layer-collectionfrom
jat255/wwmt-injections
Draft

Python semantic layer: injection resolution and the public API#256
jat255 wants to merge 2 commits into
jat255/wwmt-layer-collectionfrom
jat255/wwmt-injections

Conversation

@jat255

@jat255 jat255 commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator

Last of four stacked PRs building the Python semantic layer (M3). Based on #249. Completes the milestone.

resolve_injections(measures, injectables) applies the three rules for an injected measure argument. An argument named after a data source receives that source's connection, even when the argument has a default. One matching no source keeps its default. One matching no source and having no default is an error naming the measure, the arguments, and the sources that are available.

It takes a plain Mapping[str, Any], not a data-source type, and nothing in this milestone imports the data layer. That boundary is deliberate rather than a shortcut around M2 not being finished: resolve_injections() in pkg-r/R/measures.R also takes a plain named list, while measure_injectables(), the part that knows what a data source is, lives in pkg-r/R/commons.R with the agent. M5 supplies the mapping when it builds the agent, which is where the error surfaces to a user.

Nothing calls resolve_injections() yet for that reason. Its caller is the agent constructor, which M5 adds.

Also exports the public API: Injected, Measure, SemanticLayer, measure, and semantic_layer. measure_schema_text() and resolve_injections() stay private, matching the R package's export discipline, since they are seams the agent layer imports rather than API a measure author uses. The test fixture files move to the public import path in the same commit, which is what checks the surface is usable the way a measure author will use it.

Verified on both supported interpreters: 187 tests pass on 3.11 and 3.13.

@jat255 jat255 changed the title jat255/wwmt injections Python semantic layer: injection resolution and the public API Sep 2, 2026
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