Skip to content

Support enum mapping for slots with multiple enum ranges (any_of)#147

Merged
amc-corey-cox merged 3 commits intomainfrom
multi-enum-any-of
Mar 23, 2026
Merged

Support enum mapping for slots with multiple enum ranges (any_of)#147
amc-corey-cox merged 3 commits intomainfrom
multi-enum-any-of

Conversation

@amc-corey-cox
Copy link
Copy Markdown
Contributor

@amc-corey-cox amc-corey-cox commented Mar 9, 2026

Summary

  • Slots using any_of to specify multiple enum ranges are now correctly transformed
  • transform_enum accepts a list of enum names and iterates in order until a match is found
  • Enum handling integrated into _map_value_by_range — values flow through the normal coercion/reshaping pipeline (no continue hack)
  • Handles both range: None and range: Any with any_of enum ranges
  • Add _get_any_of_enum_names static method to extract enum names from any_of constraints
  • Clean up stale EXTRACT markers and step comments from prior refactor

Closes #146

Test plan

  • 13 new enum-specific tests (single-valued, multivalued, container, mirror_source, no match, null)
  • All 124 transformer tests pass
  • Lint and format clean

🤖 Generated with Claude Code

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_object to detect enum ranges in any_of (when slot range is missing) and route values through enum transformation.
  • Extend transform_enum to accept an ordered list of enum names and try each derivation in order (respecting mirror_source short-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.

Comment thread src/linkml_map/transformer/object_transformer.py Outdated
Comment thread src/linkml_map/transformer/object_transformer.py Outdated
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>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

Comment thread src/linkml_map/transformer/object_transformer.py Outdated
Comment thread tests/test_transformer/test_multi_enum.py
Comment thread src/linkml_map/transformer/object_transformer.py
Comment thread src/linkml_map/transformer/object_transformer.py
Comment thread src/linkml_map/transformer/object_transformer.py
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@amc-corey-cox amc-corey-cox merged commit d50bd66 into main Mar 23, 2026
27 checks passed
@amc-corey-cox amc-corey-cox deleted the multi-enum-any-of branch March 23, 2026 21:27
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.

Support enum mapping for slots with multiple enum ranges (any_of)

2 participants