Skip to content

feat: add _resolve_operation helper to FeatureChainParserMixin#242

Merged
TomKaltofen merged 5 commits intomainfrom
feat/dual-path-operation-resolver
Mar 26, 2026
Merged

feat: add _resolve_operation helper to FeatureChainParserMixin#242
TomKaltofen merged 5 commits intomainfrom
feat/dual-path-operation-resolver

Conversation

@TKaltofen
Copy link
Copy Markdown
Collaborator

Summary

  • Adds _resolve_operation(cls, feature_name, options, config_key) classmethod to FeatureChainParserMixin
  • Encapsulates the dual-path resolution pattern: tries string-based parsing via PREFIX_PATTERN first, then falls back to options.get(config_key)
  • Eliminates the need for plugin authors to call FeatureChainParser.parse_feature_name directly, reducing boilerplate in data-ops feature groups

Closes #237

Test plan

  • 5 unit tests: string parsing, config fallback, returns None when neither matches, string takes precedence, works with FeatureName objects
  • 2 integration tests: string and config paths resolve same value, config returns string type
  • All 46 mixin tests pass (39 existing + 7 new)
  • ruff check and mypy --strict clean

@TKaltofen TKaltofen requested a review from TomKaltofen as a code owner March 24, 2026 20:01
def _resolve_operation(
cls,
feature_name: Any,
options: Options,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

  1. update docstring
  2. update /docs
  3. create an issue if the docs guides should be adjusted. Only if worth it


def test_feature_shorthand_config_fallback(self) -> None:
"""Feature shorthand falls back to options when pattern does not match."""
from mloda.user import Feature
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

move all the mloda.user import Feature to top level import


def test_works_with_feature_name_object(self) -> None:
"""Accepts FeatureName objects as well as strings."""
from mloda.core.abstract_plugins.components.feature_name import FeatureName
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

move this to toplevel import

- Move imports to top level in test file (FeatureName, Feature)
- Add mloda.run_all() integration tests (string-based and config-based)
- Improve _resolve_operation docstring with Args section
- Create mloda-registry issue #58 for docs guide updates
- Ruff formatting fixes
…gFeatureGroup

Replace manual dual-path parsing (FeatureChainParser.parse_feature_name +
options fallback) with the new _resolve_operation helper in:
- AggregatedFeatureGroup._extract_aggregation_type
- ScalingFeatureGroup._extract_scaler_type
Copy link
Copy Markdown
Collaborator

@TomKaltofen TomKaltofen Mar 26, 2026

Choose a reason for hiding this comment

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

Do we need this function? Refactor it.

@TomKaltofen TomKaltofen merged commit 8090668 into main Mar 26, 2026
3 checks passed
@TomKaltofen TomKaltofen deleted the feat/dual-path-operation-resolver branch March 26, 2026 16: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.

FeatureChainParserMixin should provide a dual-path operation resolver helper

2 participants