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

[Fix] missing prophet/catboost/lightgbm library should not prevent use of others models #1360

Merged
merged 2 commits into from
Nov 16, 2022

Conversation

madtoinou
Copy link
Collaborator

Fixes ##1272 and #1217.

Summary

Exception handling in models/__init__.py to display warning message when trying to import models depending on uninstalled external libraries. The logger will display a warning message, linking to the INSTALL.md file when relevant.

Other Information

  • The unavailable models are replaced by dummy class with explicit name so that the user should realize that the import failed even if the warnings are ignored.
  • I had to add similar logic in regression_model.py can eventually depend on the CatBoostRegressor.
  • The exception handling was not extended to the tests so that they remain a reliable way to verify that the local install is correct.

…aries such as prophet, lightgbm and catboost. users with partial install should still be able to import the others model and use them.
@codecov-commenter
Copy link

codecov-commenter commented Nov 14, 2022

Codecov Report

Base: 93.89% // Head: 93.86% // Decreases project coverage by -0.02% ⚠️

Coverage data is based on head (a131304) compared to base (4dc4930).
Patch coverage: 50.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1360      +/-   ##
==========================================
- Coverage   93.89%   93.86%   -0.03%     
==========================================
  Files          78       78              
  Lines        8520     8511       -9     
==========================================
- Hits         8000     7989      -11     
- Misses        520      522       +2     
Impacted Files Coverage Δ
darts/models/forecasting/regression_model.py 97.53% <50.00%> (-0.69%) ⬇️
darts/timeseries.py 92.34% <0.00%> (-0.06%) ⬇️
...arts/models/forecasting/torch_forecasting_model.py 87.08% <0.00%> (-0.06%) ⬇️
darts/models/forecasting/block_rnn_model.py 98.24% <0.00%> (-0.04%) ⬇️
darts/models/forecasting/nhits.py 99.27% <0.00%> (-0.01%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Contributor

@hrzn hrzn left a comment

Choose a reason for hiding this comment

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

LGTM 💯

@madtoinou madtoinou merged commit 16454ef into master Nov 16, 2022
@chartsengrafs
Copy link

chartsengrafs commented Feb 9, 2023

I am still getting this error with =0.23.1

`/opt/conda/envs/myenv/lib/python3.7/site-packages/darts/models/init.py in
10 # Forecasting
11 from darts.models.forecasting.arima import ARIMA
---> 12 from darts.models.forecasting.auto_arima import AutoARIMA
13 from darts.models.forecasting.baselines import NaiveDrift, NaiveMean, NaiveSeasonal
14 from darts.models.forecasting.exponential_smoothing import ExponentialSmoothing

/opt/conda/envs/myenv/lib/python3.7/site-packages/darts/models/forecasting/auto_arima.py in
9
10 from darts.logging import get_logger, raise_if
---> 11 from darts.models.forecasting.forecasting_model import (
12 FutureCovariatesLocalForecastingModel,
13 )

ImportError: cannot import name 'FutureCovariatesLocalForecastingModel' from 'darts.models.forecasting.forecasting_model' (/opt/conda/envs/myenv/lib/python3.7/site-packages/darts/models/forecasting/forecasting_model.py)`

@hrzn
Copy link
Contributor

hrzn commented Feb 10, 2023

Mmhh that's weird. FutureCovariatesLocalForecastingModel should be available. Could you maybe try deleting & recreating your virtual environment and reinstalling darts from scratch?

@madtoinou madtoinou deleted the fix/optional-import-ext-models branch March 12, 2023 14:48
@WangariKimotho
Copy link

hi, also getting the error with darts version 0.23.1:
ImportError: cannot import name 'TFTModel' from 'darts.models' ([/home/ri/anaconda3/envs/ml_ds/lib/python3.10/site-packages/darts/models/init.py])

@WangariKimotho
Copy link

hi, also getting the error with darts version 0.23.1: ImportError: cannot import name 'TFTModel' from 'darts.models' ([/home/ri/anaconda3/envs/ml_ds/lib/python3.10/site-packages/darts/models/init.py])

resolved by "from darts.models.forecasting.tft_model import TFTModel" and "pip install lightning"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants