Skip to content

[ENH] add a tag register to the registry - #2451

Open
echo-xiao wants to merge 8 commits into
sktime:mainfrom
echo-xiao:enh/registry-tags
Open

echo-xiao wants to merge 8 commits into
sktime:mainfrom
echo-xiao:enh/registry-tags

Conversation

@echo-xiao

Copy link
Copy Markdown
Contributor

Reference Issues/PRs

Fixes #2333. Follows up on the review of #2334.

What does this implement/fix? Explain your changes.

Adds a class-based tag register to pytorch_forecasting/_registry, following the pattern sktime and skpro use, and makes it the single place tag semantics are documented.

  • _registry/_tags.py
  • check_tag_is_valid(tag_name, tag_value)
  • all_tags(parent_types, return_names, as_dataframe)
  • all_objects rejects unknown filter_tags
  • docs/source/registry.rst, linked from the v1 and v2 API toctrees

Each tag documents its possible values, its default, and what reads it, as asked for in the review of #2334. The same descriptions were previously copied across five places (both template READMEs, both template _model_pkg.py comment blocks, the package layer page); all five now point at the register.

What should a reviewer concentrate their feedback on?

  • The behaviour change.
  • The three tags no code reads.
  • parent_type for info:pred_type and info:y_type.

Did you add any tests for the change?

Yes, _registry/tests/test_tags.py, 68 cases. Three are worth calling out:

  • test_every_tag_is_documented
  • test_every_declared_tag_is_registered and test_every_declared_tag_value_is_valid
  • test_metric_type_enum_matches_test_all_metrics and test_object_type_enum_covers_test_class_registry

Any other comments?

Reading each tag's consumers turned up three things

  1. The capability:* family has no defaults, so an omitted tag reads back as None, not False.
  2. info:pred_type is missing from every v2 package and info:y_type from three, although the v2 template asks for them. The fallback to [] is silent and narrows which losses those models are tested against. TFTForecaster in [ENH] Add forecaster support and remove _pkg class for new API #2434 has the same gap.
  3. info:metric_name, capability:quantile_generation and shape:adds_quantile_dimension have no consumer anywhere, including docs and tests.

PR checklist

  • The PR title starts with either [ENH], [MNT], [DOC], or [BUG].
  • Added/modified tests
  • Used pre-commit hooks when committing to ensure that code is compliant with hooks.

Adds _BaseTag, the register assembly and check_tag_is_valid, with three
tags covering the three tag_type shapes. Excludes _registry from the
all_objects crawl so tag classes are not returned as objects.
Completes the register at 22 tags and adds two package-wide tests: every
tag declared anywhere must be registered, and every declared value must
satisfy its declared tag_type.
The all_objects docstring has pointed at a registry.all_tags utility that
did not exist; this adds it.
A misspelt tag name used to return an empty list with no indication of
what went wrong.
Also corrects three Effect sections: the metric test class is
TestAllPtMetrics, and info:pred_type and info:y_type are read by
EstimatorFixtureGenerator to choose which losses a model is tested
against, not to choose test data.
The same tag descriptions were copied across two READMEs, two templates and
the package layer page. The register is now the single authority.
@codecov

codecov Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 36.99187% with 155 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (main@903e968). Learn more about missing BASE report.

Files with missing lines Patch % Lines
pytorch_forecasting/_registry/tests/test_tags.py 0.00% 113 Missing ⚠️
pytorch_forecasting/_registry/_tags.py 70.83% 28 Missing ⚠️
pytorch_forecasting/_registry/_lookup.py 58.82% 14 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2451   +/-   ##
=======================================
  Coverage        ?   87.78%           
=======================================
  Files           ?      220           
  Lines           ?    11915           
  Branches        ?        0           
=======================================
  Hits            ?    10459           
  Misses          ?     1456           
  Partials        ?        0           
Flag Coverage Δ
cpu 87.78% <36.99%> (?)
pytest 87.78% <36.99%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@phoeenniixx phoeenniixx left a comment

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 think we should not remove the comments and change the readme for the extension templates. There is no harm in having the explaination in two places.
This registry is mainly to access the info via code, but some contributors just look at the extension templates

Also do we want all these tests for the tags? I thought this registry is more of a documentaion work, so there can be almost no possibility of getting any bug there?

I think some minimal tests should be enough. See how sktime does it.

I have not looked very deeply into those tests, but i feel there are a lot of tests here that can be simplified or removed (like checking if a specific param is present in the doc).
Or do you think all these tests are necessary?

Comment on lines -39 to -42
# todo: update all tag values to match your model
#
# Human-readable model name — MUST match the model class name.
# Valid values: str

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.

maybe we should leave these comments as well. This makes things easier ig

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.

[ENH] Add _tags.py to registry

2 participants