Skip to content

[ENH] Migrate base class registry to a class based structure and lookup logic#925

Merged
fkiraly merged 7 commits into
sktime:mainfrom
codeit-ronit:refactor-registry
Apr 4, 2026
Merged

[ENH] Migrate base class registry to a class based structure and lookup logic#925
fkiraly merged 7 commits into
sktime:mainfrom
codeit-ronit:refactor-registry

Conversation

@codeit-ronit
Copy link
Copy Markdown
Contributor

Reference Issues/PRs

Fixes #898

What does this implement/fix? Explain your changes.

This PR refactors the skpro/registry module to improve maintainability and resolve potential circular import issues. Key changes include:

  • Extracted base classes from the registry logic into a new dedicated module, skpro/registry/_base_classes.py.

  • Improved the registry structure by separating core lookup logic, scitype inference, and tag management.

  • Lazy Loading: Applied the sktime/skpro standard pattern for soft dependencies to ensure these are only imported when required, preventing premature dependency loading and circular imports.

  • Moved skpro/tests/test_class_register.py to skpro/registry/test_class_register.py to better align tests with the source code structure.
    Note: Also improves modularity and resolves circular dependency patterns in the registry

Did you add any tests for the change?

Yes

  • Added skpro/registry/tests/test_registry_logic.py to verify the new modular structure.

Any other comments?

I have modularized the registry to improve maintainability and decouple core logic. I would appreciate your feedback on two points:

  • Does the extraction of base classes into skpro/registry/_base_classes.py align with your long-term vision?

  • Are there specific registry edge cases I should include in the new test_registry_logic.py?

Note: I encountered a local AssertionError in test_proba_basic.py due to matplotlibversioning in Python 3.13. My code changes are functionally verified and pass the registry/lazy-load sanity checks, but I wanted to flag this in case it affects CI.

Copilot AI review requested due to automatic review settings March 14, 2026 20:00
Copy link
Copy Markdown

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

This PR migrates the skpro base class registry to a class-based structure (following sktime's pattern), as requested in issue #898. It introduces _base_classes.py with scitype classes that register name, description, base class reference, and test class reference, and refactors the test class registry and lookup logic to dynamically use this new structure.

Changes:

  • Added skpro/registry/_base_classes.py with class-based scitype definitions (object, estimator, regressor_proba, distribution, metric, metric_distr, datatype, converter, datatype_example) and utility functions for registry lookup.
  • Refactored test_class_register.py (moved from skpro/tests/ to skpro/registry/) to dynamically build the test class registry from _base_classes instead of hardcoding imports, and added deduplication logic.
  • Fixed a latent bug in _scitype.py where scitypes was unset when tag_type was None, and updated _lookup.py to derive valid object type strings from the new registry.

Reviewed changes

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

Show a summary per file
File Description
skpro/registry/_base_classes.py New module with class-based scitype registry and utility functions
skpro/registry/test_class_register.py Refactored to dynamically build registry from _base_classes
skpro/registry/__init__.py Exports new registry functions and test class utilities
skpro/registry/_lookup.py Uses get_obj_scitype_list() for valid object type strings
skpro/registry/_scitype.py Bug fix: handles None tag_type case
skpro/registry/_tags.py Documentation update
skpro/registry/tests/test_registry_logic.py New tests for the registry logic
skpro/utils/estimator_checks.py Updated import path
skpro/tests/test_switch.py Updated import path

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread skpro/registry/__init__.py Outdated
Comment thread skpro/registry/_base_classes.py
@codeit-ronit
Copy link
Copy Markdown
Contributor Author

Hi @fkiraly , I've submitted this PR to address the circular dependencies in skpro/registry and modularize the architecture. I've tried to take care to follow the project's established patterns for soft dependencies and registry organization.
I'd appreciate your feedback on the architectural changes and test coverage. Thanks for your time!

codeit-ronit and others added 2 commits March 15, 2026 03:37
fixing this : created a circular dependency by exposing test utilities in your main __init__.py

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@codeit-ronit
Copy link
Copy Markdown
Contributor Author

Hi @fkiraly , would appreciate your feedback on this pull request

Comment thread skpro/registry/test_class_register.py Outdated
Comment thread skpro/registry/test_class_register.py Outdated
Copy link
Copy Markdown
Collaborator

@fkiraly fkiraly left a comment

Choose a reason for hiding this comment

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

Looks great, I left a small number of comments above.

@fkiraly fkiraly added enhancement module:base-framework BaseObject, registry, base framework labels Apr 4, 2026
Copy link
Copy Markdown
Collaborator

@fkiraly fkiraly left a comment

Choose a reason for hiding this comment

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

I fixes the issues.

@fkiraly fkiraly merged commit 6444b79 into sktime:main Apr 4, 2026
39 checks passed
@codeit-ronit
Copy link
Copy Markdown
Contributor Author

Hi @fkiraly , sorry could not look into it. Was travelling out. Thank you for the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement module:base-framework BaseObject, registry, base framework

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ENH] migrate base class registry to a class based structure

3 participants