Skip to content

[eval] DRY: drop repeated "winml.modelkit.eval." prefix in _EVALUATOR_REGISTRY #808

@timenick

Description

@timenick

Component: eval
Type: cleanup / quality

Context

eval/evaluate.py::_EVALUATOR_REGISTRY maps task -> "module_path:ClassName", e.g.:

"image-feature-extraction":
    "winml.modelkit.eval.image_feature_extraction_evaluator:WinMLImageFeatureExtractionEvaluator",

The winml.modelkit.eval. prefix is repeated for all 15 entries. Because the full single-line entries exceed the 100-char limit, the dict is currently wrapped in # fmt: off / # fmt: on to preserve the readable key/value-per-line layout (otherwise ruff-format collapses each entry onto one >100-char line, which trips E501). Introduced/surfaced in #807.

Proposed cleanup

  • Store the relative "<module>:<ClassName>" (drop the repeated package prefix).
  • Prepend winml.modelkit.eval. once in get_evaluator_class: importlib.import_module(f"winml.modelkit.eval.{module_path}").
  • Most entries then fit on a single line naturally; only the 3 longest (image-feature-extraction, zero-shot-classification, zero-shot-image-classification) still need # noqa: E501.
  • This removes the # fmt: off / # fmt: on block.

Note

tests/unit/eval/test_eval.py::test_registered_task_returns_class asserts cls.__module__ == module_path; update it to compare against the full prefixed path.

Out of scope

Behavior is unchanged — purely a storage-format/readability cleanup.

Metadata

Metadata

Assignees

No one assigned

    Labels

    refactorCode refactoring

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions