Browse Source

trying to get typing classes to work...

ogert 3 years ago
parent
commit
93bfceb535

+ 9 - 1
cdplib/hyperopt/HyperoptPipelineSelector.py

@@ -14,6 +14,7 @@ Created on Tue Oct  6 15:04:25 2020
 """
 
 import os
+import sys
 
 import pickle
 
@@ -31,7 +32,14 @@ from hyperopt import fmin, tpe, rand, Trials, space_eval
 from cdplib.pipeline_selector.PipelineSelector import PipelineSelector,\
      SpaceElementType
 
-from typing import Callable, Optional, Literal, Dict, Union, List
+# from typing import Callable, Optional, Literal, Dict, Union, List
+if (sys.version_info.major == 3) & (sys.version_info.minor >= 8):
+    from typing import Callable, \
+    Literal, Dict, List, Union
+else:
+    # from typing_extensions import *
+    from typing_extensions import Callable, \
+    Literal, Dict, List, Union
 
 from cdplib.log import Log
 

+ 6 - 4
cdplib/pipeline_selector/PipelineSelector.py

@@ -28,12 +28,14 @@ from copy import deepcopy
 from abc import ABC, abstractmethod, abstractproperty
 
 if (sys.version_info.major == 3) & (sys.version_info.minor >= 8):
+    print("I have python version {}.{} and will import typing".format(sys.version_info.major, sys.version_info.minor))
     from typing import Callable, TypedDict,\
     Literal, Dict, Iterable, List, Tuple, Union
 else:
-    from typing_extensions import *
-    # from typing_extensions import Callable, TypedDict,\
-    # Literal, Dict, Iterable, List, Tuple, Union
+    # from typing_extensions import *
+    print("I have python version {}.{} and will import typing_extensions".format(sys.version_info.major, sys.version_info.minor))
+    from typing_extensions import Callable, TypedDict,\
+    Literal, Dict, Iterable, List, Tuple, Union
 
 import functools
 from sklearn.pipeline import Pipeline
@@ -41,7 +43,7 @@ from sklearn.model_selection import cross_validate as sklearn_cross_validation
 from sklearn.metrics import make_scorer
 from hyperopt import STATUS_OK, STATUS_FAIL
 from cdplib.log import Log
-from cdplib.utils import ExceptionsHandler
+from cdplib.utils.ExceptionsHandler import ExceptionsHandler
 from cdplib.utils import LoadingUtils
 from cdplib.ml_validation import CVComposer