From dfa5e787abbbe167f63c947d2bc6907bf85ffb80 Mon Sep 17 00:00:00 2001 From: Thanh Son Phung Date: Fri, 13 Oct 2023 19:07:04 -0400 Subject: [PATCH] Make TaskVineExecutor importable when ndcctools is not available (#2909) Fixes issue #2903 --- parsl/executors/taskvine/factory.py | 11 ++++++++++- parsl/executors/taskvine/manager_config.py | 7 ++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/parsl/executors/taskvine/factory.py b/parsl/executors/taskvine/factory.py index 24f74f3fe3..614413705d 100644 --- a/parsl/executors/taskvine/factory.py +++ b/parsl/executors/taskvine/factory.py @@ -3,13 +3,22 @@ from parsl.process_loggers import wrap_with_logs from parsl.executors.taskvine.errors import TaskVineFactoryFailure -from ndcctools.taskvine import Factory +# This try except clause prevents import errors +# when TaskVine is not used in Parsl. +try: + from ndcctools.taskvine import Factory + taskvine_available = True +except ImportError: + taskvine_available = False logger = logging.getLogger(__name__) @wrap_with_logs def _taskvine_factory(should_stop, factory_config): + if not taskvine_available: + logger.debug("TaskVine package cannot be found. Please install the ndcctools package.") + return logger.debug("Starting TaskVine factory process") try: diff --git a/parsl/executors/taskvine/manager_config.py b/parsl/executors/taskvine/manager_config.py index ee7c65a873..8c19743722 100644 --- a/parsl/executors/taskvine/manager_config.py +++ b/parsl/executors/taskvine/manager_config.py @@ -2,7 +2,12 @@ from dataclasses import dataclass from typing import Optional -from ndcctools.taskvine.cvine import VINE_DEFAULT_PORT +# This try except clause prevents import errors +# when TaskVine is not used in Parsl. +try: + from ndcctools.taskvine.cvine import VINE_DEFAULT_PORT +except ImportError: + VINE_DEFAULT_PORT = 0 # use any available port. @dataclass