functime-org / functime

Time-series machine learning at scale. Built with Polars for embarrassingly parallel feature extraction and forecasts on panel data.
https://docs.functime.ai
Apache License 2.0
969 stars 52 forks source link

rework missing import mechanism? #193

Open baggiponte opened 2 months ago

baggiponte commented 2 months ago

Currently we deal with ImportErrors like this:

try:
    from .lance import ann
except ImportError:
    msg = "Missing ann extras: `pip install functime[ann]`"
    ann = ImportError(msg)

try:
    from .automl import auto_lightgbm
    from .lightgbm import flaml_lightgbm, lightgbm
except ImportError:
    msg = "Missing lightgbm extras: `pip install functime[lgb]`"
    auto_lightgbm = ImportError(msg)
    flaml_lightgbm = ImportError(msg)
    lightgbm = ImportError(msg)

try:
    from .catboost import catboost
except ImportError:
    catboost = ImportError("Missing catboost extras: `pip install functime[cat]`")

try:
    from .xgboost import xgboost
except ImportError:
    xgboost = ImportError("Missing xgboost extras: `pip install functime[xgb]`")

This is clever but means that the issue is raised "lazily" and can lead to issues such as #190 . I think we should revert this.

FBruzzesi commented 2 months ago

In scikit-lego we have a little more sophisticated version of such error which can help to point at which version to install (proof).

In general there is a tradeoff between:

Personally, as the base/core dependencies of the functime are already quite broad, I would not add them all 😇 my two cents

baggiponte commented 2 months ago

+1 on that. I would actually like to remove as many dependencies as I can (I am looking at you, cloudpickle). I need to improve on the lazy imports though. Polars does too.