sktime / pytorch-forecasting

Time series forecasting with PyTorch
https://pytorch-forecasting.readthedocs.io/
MIT License
3.99k stars 631 forks source link

[MNT] isolate `optuna` and `statsmodels` as soft dependencies #1629

Closed fkiraly closed 2 months ago

fkiraly commented 2 months ago

Isolates optuna, optuna-integration, and statsmodels as soft dependencies in a new soft dep set all_extras to collect all soft dependencies, and in another soft dep set tuning. Towards https://github.com/jdb78/pytorch-forecasting/issues/1616

This was quite simple, since the imports happen in only one very narrow location, the optimize_hyperparameters utility which is also not core architecturally.

codecov-commenter commented 2 months ago

:warning: Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 91.66667% with 1 line in your changes missing coverage. Please review.

Project coverage is 90.19%. Comparing base (0a1e784) to head (5f50b20).

Files with missing lines Patch % Lines
...sting/models/temporal_fusion_transformer/tuning.py 91.66% 1 Missing :warning:

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #1629 +/- ## ========================================== - Coverage 90.20% 90.19% -0.02% ========================================== Files 32 32 Lines 4729 4734 +5 ========================================== + Hits 4266 4270 +4 - Misses 463 464 +1 ``` | [Flag](https://app.codecov.io/gh/jdb78/pytorch-forecasting/pull/1629/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Jan+Beitner) | Coverage Δ | | |---|---|---| | [cpu](https://app.codecov.io/gh/jdb78/pytorch-forecasting/pull/1629/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Jan+Beitner) | `90.19% <91.66%> (-0.02%)` | :arrow_down: | | [pytest](https://app.codecov.io/gh/jdb78/pytorch-forecasting/pull/1629/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Jan+Beitner) | `90.19% <91.66%> (-0.02%)` | :arrow_down: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Jan+Beitner#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

yarnabrina commented 2 months ago

If you do not mind, I'll request you to consider these changes in this PR. I have two points to request you to consider.

  1. In sktime, we quite often face issues as a lot of dependencies are part of public all_extras and their interdependcies and conflicts create weird situations in testing and debugging. I think it may be better to have a plan with everyone who are planning to help maintenance here, e.g. Benedikt, Xinyu, Felix etc.

  2. pytorch-forecasting is quite popular along with its tuning interface. If it suddenly looses those as part of main installation, I fear that may appear as a significant breaking change for a considerable part of its user base.

fkiraly commented 2 months ago

Ok, point taken.

Some comments and options for discussion.

fkiraly commented 2 months ago

Pinging everyone @yarnabrina mentioned: @benHeid, @XinyuWuu, @fnhirwa

fkiraly commented 2 months ago

On a more architectural level, and "defining scope", the tuner seems more like something that should be in optuna-integrations rather than in pytorch-forecasting proper. It's already apparent from the coupling which is very localized, and the general scope of content in pytorch-forecasting. This is perhaps not a change we want to make, it's just an architectural statement from the a-priori perspective of "all other things being equal" (e.g., not having to worry about breaking code, separate package management processes, testing, etc, which we obviously have to).

The closest thing to making it actually external is making it a soft dependency, which mitigates things like integration, release, testing.

Side note: my assessment is different for the sktime optuna tuner - that one is sktime API compliant, and sktime has its dependency management layer, these two arguments make it less clear where it should live, although it could also live in optuna-integrations and be indexed from sktime.

fkiraly commented 2 months ago

On a more personal usage level, i.e., considering myself as an user and my opinions in that respect:

fkiraly commented 2 months ago

from discussion on discord: agreed on a compromise solution where the tuning soft deps go into a tuning soft dependency set.