Fix expr slot derivations resolving to None when source class name contains a space#171
Merged
amc-corey-cox merged 3 commits intomainfrom Mar 30, 2026
Merged
Fix expr slot derivations resolving to None when source class name contains a space#171amc-corey-cox merged 3 commits intomainfrom
amc-corey-cox merged 3 commits intomainfrom
Conversation
…ntains a space dynamic_object() created Python types using the raw class name (e.g. "my record"), but ObjectIndex.class_name_mappings() CamelCases keys (e.g. "MyRecord"). When ObjectIndex.bless() looked up type(obj).__name__, the mismatch caused a KeyError, silently returning None for all expr-based slot derivations. Apply camelcase() to the type name in dynamic_object() so it matches ObjectIndex's class map. The populated_from path was unaffected because it reads directly from the source dict without going through ObjectIndex.
Contributor
Author
|
@amc-corey-cox this works but still best to think it through once - I am slowly understanding the codebase now. |
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a bug where expr-based slot derivations unexpectedly resolved to None when the source class name contained spaces, due to a mismatch between dynamically generated Python type names and ObjectIndex class-name mappings.
Changes:
- Camelcase the dynamic Python type name created in
dynamic_object()to align withObjectIndex’s class-name mapping behavior. - Add regression tests covering
exprevaluation with spaced class names, with and without an index.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
tests/test_transformer/test_class_name_spaces.py |
Adds regression tests ensuring expr slot derivations work when the source class name contains spaces (including indexed path). |
src/linkml_map/utils/dynamic_object.py |
Updates dynamic type creation to use camelcase(target) so ObjectIndex.bless() can resolve the class consistently. |
Comment on lines
+11
to
+12
| import pytest | ||
| import yaml |
There was a problem hiding this comment.
pytest and yaml are imported but not used in this test module; consider removing them to avoid unused-import lint noise and keep the test focused.
Suggested change
| import pytest | |
| import yaml |
3 tasks
amc-corey-cox
approved these changes
Mar 30, 2026
Contributor
amc-corey-cox
left a comment
There was a problem hiding this comment.
This looks good to me. Thanks @matentzn !
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.
Fixes #170
Fix expr slot derivations resolving to None when source class name contains a space
dynamic_object() created Python types using the raw class name (e.g. "my record"), but ObjectIndex.class_name_mappings() CamelCases keys (e.g. "MyRecord"). When ObjectIndex.bless() looked up type(obj).name, the mismatch caused a KeyError, silently returning None for all expr-based slot derivations.
Apply camelcase() to the type name in dynamic_object() so it matches ObjectIndex's class map. The populated_from path was unaffected because it reads directly from the source dict without going through ObjectIndex.