gsitk_compat.py 818 Bytes
Newer Older
J. Fernando Sánchez's avatar
J. Fernando Sánchez committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import logging

logger = logging.getLogger(__name__)

MSG = 'GSITK is not (properly) installed.'
IMPORTMSG = '{} Some functions will be unavailable.'.format(MSG)
RUNMSG = '{} Install it to use this function.'.format(MSG)


def raise_exception(*args, **kwargs):
    raise Exception(RUNMSG)


try:
    from gsitk.datasets.datasets import DatasetManager
    from gsitk.evaluation.evaluation import Evaluation as Eval
    from sklearn.pipeline import Pipeline
18
19
20
    import pkg_resources
    GSITK_VERSION = pkg_resources.get_distribution("gsitk").version.split()
    GSITK_AVAILABLE = GSITK_VERSION > (0, 1, 9, 1)  # Earlier versions have a bug
J. Fernando Sánchez's avatar
J. Fernando Sánchez committed
21
22
    modules = locals()
except ImportError:
23
    logger.warning(IMPORTMSG)
J. Fernando Sánchez's avatar
J. Fernando Sánchez committed
24
    GSITK_AVAILABLE = False
25
    GSITK_VERSION = ()
J. Fernando Sánchez's avatar
J. Fernando Sánchez committed
26
    DatasetManager = Eval = Pipeline = raise_exception