From dc4f38ff63c3ff73fd94b53f58c9ae09b9d436bd Mon Sep 17 00:00:00 2001 From: Andre Merzky Date: Sat, 16 Mar 2024 14:12:29 +0100 Subject: [PATCH] add flux module path --- src/radical/utils/debug.py | 8 ++++++-- src/radical/utils/flux.py | 21 +++++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/radical/utils/debug.py b/src/radical/utils/debug.py index 78b426ee2..01397baf1 100644 --- a/src/radical/utils/debug.py +++ b/src/radical/utils/debug.py @@ -174,9 +174,13 @@ def get_exception_trace(msg=None): # ------------------------------------------------------------------------------ # -def print_exception_trace(msg=None): +def print_exception_trace(msg=None, exc=None): - print_stacktrace(msg=msg, _stack=get_exception_trace()) + if not exc: + print_stacktrace(msg=msg, _stack=get_exception_trace()) + else: + print_stacktrace(msg=msg, + _stack=traceback.extract_tb(exc.__traceback__)) # ------------------------------------------------------------------------------ diff --git a/src/radical/utils/flux.py b/src/radical/utils/flux.py index bec64006c..1d177a224 100644 --- a/src/radical/utils/flux.py +++ b/src/radical/utils/flux.py @@ -2,6 +2,7 @@ # pylint: disable=cell-var-from-loop import os +import sys import time import json @@ -49,6 +50,16 @@ def __init__(self, uid : str, self._watcher = None try: + cmd = 'flux python -c "import flux; print(flux.__file__)"' + out, err, ret = sh_callout(cmd) + + if ret: + raise RuntimeError('flux not found: %s' % err) + + flux_path = os.path.dirname(out.strip()) + mod_path = os.path.dirname(flux_path) + sys.path.append(mod_path) + self._flux = import_module('flux') self._flux_job = import_module('flux.job') @@ -297,6 +308,16 @@ def __init__(self) -> None: self._executors = list() # TODO try: + cmd = 'flux python -c "import flux; print(flux.__file__)"' + out, err, ret = sh_callout(cmd) + + if ret: + raise RuntimeError('flux not found: %s' % err) + + flux_path = os.path.dirname(out.strip()) + mod_path = os.path.dirname(flux_path) + sys.path.append(mod_path) + self._flux = import_module('flux') self._flux_job = import_module('flux.job')