Skip to content

[ENH] Add contributor extension template for v2 model implementation #2194#2230

Draft
sujanyd wants to merge 1 commit intosktime:mainfrom
sujanyd:feat/add-v2-model-templates
Draft

[ENH] Add contributor extension template for v2 model implementation #2194#2230
sujanyd wants to merge 1 commit intosktime:mainfrom
sujanyd:feat/add-v2-model-templates

Conversation

@sujanyd
Copy link
Copy Markdown

@sujanyd sujanyd commented Mar 24, 2026

-> Reference Issues/PRs

Fixes #2194. See also #1993 (v2 roadmap).


-> What does this implement/fix? Explain your changes.

This PR adds standardized extension templates for contributors implementing new models under the v2 architecture. Previously, contributors had to reverse-engineer the expected structure from existing model implementations that were themselves still being migrated.

New files added
- pytorch_forecasting/models/model_template.py
Template for subclassing BaseModel, including init, forward, and optional training_step with inline RATIONALE: comments
- pytorch_forecasting/models/pkg_template.py
Template for the model’s package container (Base_pkg), with _tags, get_cls, get_datamodule_cls, and get_test_train_params
- pytorch_forecasting/data/datamodule_template.py
Template for a custom DataModule when EncoderDecoderTimeSeriesDataModule is insufficient
- tests/test_models/test_template.py
Test template covering integration and pickle tests

Modified files
- CONTRIBUTING.md
Added Implementing New Models (v2) section with direct links to all templates


-> Bonus enhancement (can be split into a separate PR if preferred)
- pytorch_forecasting/data/timeseries/_timeseries.py
Added interpolation_strategy parameter (forward_fill, linear, zero) to TimeSeriesDataSet
- tests/test_data/test_interpolation.py
Full test coverage for all strategies including mixed per-column strategies
- scripts/demo_interpolation.py
Visual demo comparing the three interpolation strategies


-> What should a reviewer concentrate their feedback on?
- Are the CONTRIBUTOR TODO and RATIONALE: comments clear and sufficient for a new contributor?
- Does the model_template.py correctly reflect the v2 BaseModel API (especially metadata, _pkg, and training_step)?
- Is pkg_template.py aligned with the current Base_pkg interface?
- Should the interpolation changes in _timeseries.py be moved to a separate PR?

-> Did you add any tests for the change?
- Added tests/test_models/test_template.py
A contributor-facing test template with integration and pickle test stubs
- Added tests/test_data/test_interpolation.py
Full tests for the interpolation_strategy feature covering forward_fill, linear, zero, and mixed per-column strategies


-> Any other comments?

This was listed as an explicit open work item in the v2 roadmap issue #1993: Add extension Templates for new contributors.

All template files follow a consistent pattern of CONTRIBUTOR TODO for actionable items and RATIONALE: for explanatory context, to make onboarding as smooth as possible.

-> PR checklist
- The PR title starts with [ENH]
- Added/modified tests
- Used pre-commit hooks when committing to ensure that code is compliant with hooks
(Install hooks with pre-commit install. To run hooks independently, execute pre-commit run --all-files)

@review-notebook-app
Copy link
Copy Markdown

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@sujanyd sujanyd changed the title Feat/add v2 model templates [ENH] Add contributor extension template for v2 model implementation #2194 Mar 24, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 24, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@602ee15). Learn more about missing BASE report.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2230   +/-   ##
=======================================
  Coverage        ?   86.71%           
=======================================
  Files           ?      167           
  Lines           ?     9782           
  Branches        ?        0           
=======================================
  Hits            ?     8482           
  Misses          ?     1300           
  Partials        ?        0           
Flag Coverage Δ
cpu 86.71% <100.00%> (?)
pytest 86.71% <100.00%> (?)

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

☔ View full report in Codecov by Sentry.
📢 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.

@sujanyd sujanyd force-pushed the feat/add-v2-model-templates branch 7 times, most recently from 8e89a01 to 59e81cf Compare March 25, 2026 03:28
@sujanyd sujanyd marked this pull request as ready for review March 25, 2026 12:56
Copy link
Copy Markdown
Member

@phoeenniixx phoeenniixx left a comment

Choose a reason for hiding this comment

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

Thanks a lot!

  • Can you please create 2 separate files - for model and pkg.
  • Please add the pointers to all the methods what they expect, what to pass etc. Look at sktime extension templates for reference.
  • Add all the tags and what they mean in the pkg class

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.

Do we need tests for templates as well?

@phoeenniixx phoeenniixx added the enhancement New feature or request label Mar 29, 2026
@sujanyd sujanyd force-pushed the feat/add-v2-model-templates branch from 59e81cf to 6f436a9 Compare March 29, 2026 09:08
@sujanyd sujanyd force-pushed the feat/add-v2-model-templates branch from 6f436a9 to 2f52d7b Compare March 29, 2026 09:20
@sujanyd sujanyd marked this pull request as draft March 30, 2026 13:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ENH] Add contributor extension template for v2 model implementation

2 participants