[tune] explicitly raising tune import Error “[tune]” (#16575)

Co-authored-by: Richard Liaw <rliaw@berkeley.edu>
This commit is contained in:
gurunath 2021-07-12 12:10:10 +05:30 committed by GitHub
parent 0935ec30d0
commit e3966f59e3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,3 +1,4 @@
import sys
import logging
logger = logging.getLogger(__name__)
@ -7,8 +8,10 @@ TuneGridSearchCV = None
try:
from tune_sklearn import TuneSearchCV, TuneGridSearchCV
except ImportError:
logger.info("tune_sklearn is not installed. Please run "
"`pip install tune-sklearn`.")
except ImportError as exc:
# Changed in 1.5.0 -- Raises an exception instead of returning None.
tb = sys.exc_info()[2]
msg = ("Tune's Scikit-Learn bindings (tune-sklearn) is not installed. "
"Please run `pip install tune-sklearn`.")
raise type(exc)().with_traceback(tb) from None
__all__ = ["TuneSearchCV", "TuneGridSearchCV"]