Add slot() function and hide gating for derived slot bindings#200
Open
amc-corey-cox wants to merge 2 commits intomainfrom
Open
Add slot() function and hide gating for derived slot bindings#200amc-corey-cox wants to merge 2 commits intomainfrom
amc-corey-cox wants to merge 2 commits intomainfrom
Conversation
Expressions can now call slot('name') to reference previously computed
slot values, enabling multi-stage derivations where value_mappings
handles lookups and expr handles computation. Slots with hide: true
are computed but excluded from output, serving as intermediates.
Closes #164
Contributor
There was a problem hiding this comment.
Pull request overview
Adds support for referencing previously-derived target slot values during object transformation by introducing a slot('name') expression function, and implements hide: true for slot derivations so intermediate computed slots can be used internally but excluded from output.
Changes:
- Extend expression evaluation to accept caller-injected functions (used to provide
slot()). - Evaluate slot derivations in declaration order and support hidden (non-output) derived slots.
- Add unit/integration tests covering
slot()and hidden-slot output suppression.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/linkml_map/transformer/object_transformer.py |
Injects slot() into expression evaluation, computes hidden slots for downstream use, and strips hidden slots from final output. |
src/linkml_map/utils/eval_utils.py |
Adds optional functions parameter to eval_expr_with_mapping to merge caller functions with built-ins. |
tests/test_transformer/test_object_transformer_new.py |
Adds test scaffolds and assertions for slot() behavior and hide: true output exclusion. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
slot('name')to reference previously computed slot values, enabling multi-stage derivations wherevalue_mappingshandles declarative lookups andexprhandles computationhide: trueare computed (available to downstreamslot()calls) but excluded from outputMotivation
Without
slot(), combiningvalue_mappingswithexpris impossible — users are forced to inline everything intocase()expressions that are unreadable and structurally irreversible:Design decisions
slot()references must appear after the referenced slot. No topological sort — YAML authors naturally write top-to-bottom.tgt_attrs, then hidden slots are stripped before returning. This keepsslot()uniform regardless of whether the referenced slot is hidden.slotis a lambda closing overtgt_attrs, threaded through existingfunctionsplumbing ineval_expr_with_mapping. No changes toBindings.Test plan
slot()basic: reference a previously derived slot valuevalue_mappings: declarative lookup →slot()reference patternslot()for missing name returnsNoneCloses #164