From 48b85f769e9e8556b1974aff5cba4f6190dcacb9 Mon Sep 17 00:00:00 2001 From: Paul Ferrell Date: Wed, 9 Aug 2023 15:15:16 -0600 Subject: [PATCH 1/2] Fixed flux import. --- lib/pavilion/schedulers/plugins/flux.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/lib/pavilion/schedulers/plugins/flux.py b/lib/pavilion/schedulers/plugins/flux.py index eca0564b2..c05fe8953 100644 --- a/lib/pavilion/schedulers/plugins/flux.py +++ b/lib/pavilion/schedulers/plugins/flux.py @@ -22,6 +22,7 @@ # Just import flux once +HAS_FLUX = False try: import flux import flux.hostlist @@ -30,7 +31,25 @@ from flux.job import JobspecV1 HAS_FLUX = True except ImportError: - HAS_FLUX = False + _minor_version = sys.version_info.minor + _flux_path = None + for i in range(_minor_version, 5, -1): + _flux_path = "/usr/lib64/flux/python3.{}".format(_minor_version) + if os.path.exists(_flux_path): + break + + if _flux_path is not None: + sys.path.append(_flux_path) + try: + import flux + import flux.hostlist + import flux.job + import flux.resource + from flux.job import JobspecV1 + HAS_FLUX = True + except ImportError: + pass + flux_states = [ "DEPEND", From 78a9a0beb94ddc0a7c85314f9ed71f34a8eb09a8 Mon Sep 17 00:00:00 2001 From: Paul Ferrell Date: Wed, 9 Aug 2023 15:28:38 -0600 Subject: [PATCH 2/2] Fixed style issue. --- lib/pavilion/schedulers/plugins/flux.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/pavilion/schedulers/plugins/flux.py b/lib/pavilion/schedulers/plugins/flux.py index c05fe8953..79d28ed2b 100644 --- a/lib/pavilion/schedulers/plugins/flux.py +++ b/lib/pavilion/schedulers/plugins/flux.py @@ -31,15 +31,15 @@ from flux.job import JobspecV1 HAS_FLUX = True except ImportError: - _minor_version = sys.version_info.minor - _flux_path = None - for i in range(_minor_version, 5, -1): - _flux_path = "/usr/lib64/flux/python3.{}".format(_minor_version) - if os.path.exists(_flux_path): + _MINOR_VERSION = sys.version_info.minor + _FLUX_PATH = None + for i in range(_MINOR_VERSION, 5, -1): + _FLUX_PATH = "/usr/lib64/flux/python3.{}".format(_MINOR_VERSION) + if os.path.exists(_FLUX_PATH): break - if _flux_path is not None: - sys.path.append(_flux_path) + if _FLUX_PATH is not None: + sys.path.append(_FLUX_PATH) try: import flux import flux.hostlist