Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MNT] Tags using enums #2235 #2437

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open

Conversation

lucifer4073
Copy link

@lucifer4073 lucifer4073 commented Dec 10, 2024

Reference Issues/PRs

Contributes to #2235.

What does this implement/fix?

This PR replaces string values in _tags with their corresponding Enum values in the Clustering module. These changes improve maintainability and reduce errors by standardizing tag values across the module.

Key points:

  • Algorithm types can now be directly referenced using the Enum class.
  • Data structures and Python dependencies utilize Enum.value for consistency.
  • Changes applied across all clustering submodules containing tags.
  • Dependent modules will require refactoring if direct Enum usage is extended.

Does your contribution introduce a new dependency?

No

Any other comments?

This change represents a significant milestone in transitioning to Enum-based tags. Approval for this approach in the Clustering module will allow for escalation to other modules.

Some examples of usage:

_tags = {  
    "capability:multivariate": True,  
    "algorithm_type": ClusteringAlgorithmType.DISTANCE,  
}  

tags = {  
    "capability:multivariate": True,  
    "capability:multithreading": True,  
    "python_dependencies": ClusteringAlgorithmType.TSLEARN.value,  
}  

PR checklist

For all contributions
  • @all-contributors please add @lucifer4073
  • The PR title starts with either [ENH], [MNT], [DOC], [BUG], [REF], [DEP] or [GOV] indicating whether the PR topic is related to enhancement, maintenance, documentation, bugs, refactoring, deprecation or governance.

@aeon-actions-bot aeon-actions-bot bot added clustering Clustering package maintenance Continuous integration, unit testing & package distribution labels Dec 10, 2024
@aeon-actions-bot
Copy link
Contributor

Thank you for contributing to aeon

I have added the following labels to this PR based on the title: [ $\color{#EC843A}{\textsf{maintenance}}$ ].
I have added the following labels to this PR based on the changes made: [ $\color{#4011F3}{\textsf{clustering}}$ ]. Feel free to change these if they do not properly represent the PR.

The Checks tab will show the status of our automated tests. You can click on individual test runs in the tab or "Details" in the panel below to see more information if there is a failure.

If our pre-commit code quality check fails, any trivial fixes will automatically be pushed to your PR unless it is a draft.

Don't hesitate to ask questions on the aeon Slack channel if you have any.

PR CI actions

These checkboxes will add labels to enable/disable CI functionality for this PR. This may not take effect immediately, and a new commit may be required to run the new configuration.

  • Run pre-commit checks for all files
  • Run mypy typecheck tests
  • Run all pytest tests and configurations
  • Run all notebook example tests
  • Run numba-disabled codecov tests
  • Stop automatic pre-commit fixes (always disabled for drafts)
  • Disable numba cache loading
  • Push an empty commit to re-run CI checks

Copy link
Member

@MatthewMiddlehurst MatthewMiddlehurst left a comment

Choose a reason for hiding this comment

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

This seems a lot clunkier that just strings at first glance, not sure I'm a fan currently.

Copy link
Member

Choose a reason for hiding this comment

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

I would not do this in the clustering module, it should be more integrated with the other tags stuff in aeon/utils/tags.

aeon/clustering/_clustering_tags.py Outdated Show resolved Hide resolved
aeon/clustering/_clustering_tags.py Outdated Show resolved Hide resolved
aeon/clustering/_clustering_tags.py Outdated Show resolved Hide resolved
@lucifer4073
Copy link
Author

Hi @MatthewMiddlehurst @chrisholder, I have made the required changes as commented.

Since I have shifted the enum_tags.py to utils module it seems to have a circular import issue for the given test case.

Test case: PR Examples / run-notebook-examples (pull_request) Failing after 7m

Error:
ImportError: cannot import name 'BASE_CLASS_REGISTER' from partially initialized module 'aeon.utils.base' (most likely due to a circular import) (/opt/hostedtoolcache/Python/3.10.15/x64/lib/python3.10/site-packages/aeon/utils/base/__init__.py)

I propose to keep it currently in the clustering module or maybe I would need some help to resolve the error.

@TonyBagnall
Copy link
Contributor

I think this issue requires some discussion before progressing, as its not obvious how best to do this and the changes, whilst under the hood, are fairly significant in terms of design

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clustering Clustering package maintenance Continuous integration, unit testing & package distribution
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants