diff --git a/example-plugins/async_plugin.py b/example-plugins/async_plugin.py index e274425..dd628f1 100644 --- a/example-plugins/async_plugin.py +++ b/example-plugins/async_plugin.py @@ -11,7 +11,7 @@ class Async(AnalysisPlugin): '''An example of an asynchronous module''' author = '@balkian' version = '0.2' - async = True + sync = False def _do_async(self, num_processes): pool = multiprocessing.Pool(processes=num_processes) diff --git a/senpy/extensions.py b/senpy/extensions.py index d545485..b399221 100644 --- a/senpy/extensions.py +++ b/senpy/extensions.py @@ -351,7 +351,7 @@ class Senpy(object): logger.info("Activating plugin: {}".format(plugin.name)) - if sync or not getattr(plugin, 'async', True): + if sync or not getattr(plugin, 'async', True) or getattr(plugin, 'sync', False): return self._activate(plugin) else: th = Thread(target=partial(self._activate, plugin)) @@ -374,7 +374,7 @@ class Senpy(object): self._set_active(plugin, False) - if sync or not getattr(plugin, 'async', True): + if sync or not getattr(plugin, 'async', True) or not getattr(plugin, 'sync', False): self._deactivate(plugin) else: th = Thread(target=partial(self._deactivate, plugin)) diff --git a/senpy/gsitk_compat.py b/senpy/gsitk_compat.py index aef66da..3cc143f 100644 --- a/senpy/gsitk_compat.py +++ b/senpy/gsitk_compat.py @@ -1,5 +1,7 @@ import logging +from pkg_resources import parse_version, get_distribution, DistributionNotFound + logger = logging.getLogger(__name__) MSG = 'GSITK is not (properly) installed.' @@ -12,15 +14,18 @@ def raise_exception(*args, **kwargs): try: + gsitk_distro = get_distribution("gsitk") + GSITK_VERSION = parse_version(gsitk_distro.version) + GSITK_AVAILABLE = GSITK_VERSION > parse_version("0.1.9.1") # Earlier versions have a bug +except DistributionNotFound: + GSITK_AVAILABLE = False + GSITK_VERSION = () + +if GSITK_AVAILABLE: from gsitk.datasets.datasets import DatasetManager from gsitk.evaluation.evaluation import Evaluation as Eval from sklearn.pipeline import Pipeline - 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 modules = locals() -except ImportError: +else: logger.warning(IMPORTMSG) - GSITK_AVAILABLE = False - GSITK_VERSION = () DatasetManager = Eval = Pipeline = raise_exception