Skip to content

Fix expr slot derivations resolving to None when source class name contains a space#171

Merged
amc-corey-cox merged 3 commits intomainfrom
issue170
Mar 30, 2026
Merged

Fix expr slot derivations resolving to None when source class name contains a space#171
amc-corey-cox merged 3 commits intomainfrom
issue170

Conversation

@matentzn
Copy link
Copy Markdown
Contributor

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.

…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.
@matentzn
Copy link
Copy Markdown
Contributor Author

@amc-corey-cox this works but still best to think it through once - I am slowly understanding the codebase now.

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

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 with ObjectIndex’s class-name mapping behavior.
  • Add regression tests covering expr evaluation 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
Copy link

Copilot AI Mar 28, 2026

Choose a reason for hiding this comment

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

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

Copilot uses AI. Check for mistakes.
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 no new comments.

Copy link
Copy Markdown
Contributor

@amc-corey-cox amc-corey-cox left a comment

Choose a reason for hiding this comment

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

This looks good to me. Thanks @matentzn !

@amc-corey-cox amc-corey-cox merged commit 64d6a39 into main Mar 30, 2026
7 checks passed
@amc-corey-cox amc-corey-cox deleted the issue170 branch March 30, 2026 14:03
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.

expr slot derivations resolve to None when source class name contains a space

3 participants