Skip to content

[MNT] Tags using enums #2235#2437

Closed
lucifer4073 wants to merge 11 commits into
aeon-toolkit:mainfrom
lucifer4073:main
Closed

[MNT] Tags using enums #2235#2437
lucifer4073 wants to merge 11 commits into
aeon-toolkit:mainfrom
lucifer4073:main

Conversation

@lucifer4073
Copy link
Copy Markdown
Contributor

@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
Copy Markdown
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
Copy Markdown
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.

Comment thread aeon/clustering/_clustering_tags.py Outdated
Copy link
Copy Markdown
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.

Comment thread aeon/clustering/_clustering_tags.py Outdated
Comment thread aeon/clustering/_clustering_tags.py Outdated
Comment thread aeon/clustering/_clustering_tags.py Outdated
@lucifer4073
Copy link
Copy Markdown
Contributor 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
Copy Markdown
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

@lucifer4073 lucifer4073 marked this pull request as draft January 25, 2025 20:16
@MatthewMiddlehurst
Copy link
Copy Markdown
Member

I thought the closure above was an accident from the force push, but maybe not. Closing for now as theres no more discussion.

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