Support enum mapping for slots with multiple enum ranges (any_of)#147
Merged
amc-corey-cox merged 3 commits intomainfrom Mar 23, 2026
Merged
Support enum mapping for slots with multiple enum ranges (any_of)#147amc-corey-cox merged 3 commits intomainfrom
amc-corey-cox merged 3 commits intomainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds support for mapping enum-valued slots whose source schema expresses multiple enum ranges via any_of, by extracting enum names from slot.any_of and trying enum derivations sequentially until a match is found.
Changes:
- Update
ObjectTransformer.map_objectto detect enum ranges inany_of(when slotrangeis missing) and route values through enum transformation. - Extend
transform_enumto accept an ordered list of enum names and try each derivation in order (respectingmirror_sourceshort-circuit). - Add a comprehensive test suite for multi-enum (
any_of) enum mapping behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/linkml_map/transformer/object_transformer.py |
Implements any_of enum extraction and ordered multi-enum derivation mapping. |
tests/test_transformer/test_multi_enum.py |
Adds coverage for single/multivalued mapping across multiple enums, no-match behavior, mirror_source short-circuit, and null passthrough. |
Slots using any_of to specify multiple enum ranges are now correctly transformed. The transformer extracts enum names from slot.any_of and iterates enum derivations in order until a match is found. - transform_enum now accepts a list of enum names - Add _get_any_of_enum_names to extract enums from any_of constraints - Enum handling integrated into _map_value_by_range (no continue hack) - Handles both range: None and range: Any with any_of enum ranges - Values flow through normal coercion/reshaping pipeline - Remove stale EXTRACT markers and step comments from prior refactor Closes #146 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
d783efa to
6cfd09e
Compare
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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
any_ofto specify multiple enum ranges are now correctly transformedtransform_enumaccepts a list of enum names and iterates in order until a match is found_map_value_by_range— values flow through the normal coercion/reshaping pipeline (nocontinuehack)range: Noneandrange: Anywithany_ofenum ranges_get_any_of_enum_namesstatic method to extract enum names from any_of constraintsCloses #146
Test plan
🤖 Generated with Claude Code