Skip to content

Commit

Permalink
Merge branch 'devel' into fix/ci
Browse files Browse the repository at this point in the history
  • Loading branch information
andre-merzky authored Mar 20, 2024
2 parents 0f65fff + 5f3af6f commit 6436ba9
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 17 deletions.
8 changes: 6 additions & 2 deletions src/radical/utils/debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__))


# ------------------------------------------------------------------------------
Expand Down
21 changes: 21 additions & 0 deletions src/radical/utils/flux.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# pylint: disable=cell-var-from-loop

import os
import sys
import time
import json

Expand Down Expand Up @@ -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')

Expand Down Expand Up @@ -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')

Expand Down
39 changes: 24 additions & 15 deletions src/radical/utils/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@
"""


# ------------------------------------------------------------------------------
#
# NOTE: ForkingPickler does not like lambdas nor local functions, thus use
# a module level function to disable loggers.
#
def _noop(*args, **kwargs):
pass


# ------------------------------------------------------------------------------
#
import os
Expand Down Expand Up @@ -403,21 +412,21 @@ def _ensure_handler(self):
# class has no constructor, we do it this way.

# disable all loggers
self.critical = lambda *args, **kwargs: None
self.error = lambda *args, **kwargs: None
self.warn = lambda *args, **kwargs: None
self.warning = lambda *args, **kwargs: None
self.info = lambda *args, **kwargs: None
self.debug = lambda *args, **kwargs: None
self.debug_1 = lambda *args, **kwargs: None
self.debug_2 = lambda *args, **kwargs: None
self.debug_3 = lambda *args, **kwargs: None
self.debug_4 = lambda *args, **kwargs: None
self.debug_5 = lambda *args, **kwargs: None
self.debug_6 = lambda *args, **kwargs: None
self.debug_7 = lambda *args, **kwargs: None
self.debug_8 = lambda *args, **kwargs: None
self.debug_9 = lambda *args, **kwargs: None
self.critical = _noop
self.error = _noop
self.warn = _noop
self.warning = _noop
self.info = _noop
self.debug = _noop
self.debug_1 = _noop
self.debug_2 = _noop
self.debug_3 = _noop
self.debug_4 = _noop
self.debug_5 = _noop
self.debug_6 = _noop
self.debug_7 = _noop
self.debug_8 = _noop
self.debug_9 = _noop

# enable the ones we are configured for:
if self._num_level <= 50: self.critical = self._logger.critical
Expand Down

0 comments on commit 6436ba9

Please sign in to comment.