From 3a08510629dea413bbf538ece0b416ba8bbabe66 Mon Sep 17 00:00:00 2001 From: maestroque Date: Tue, 3 Sep 2024 17:03:27 +0300 Subject: [PATCH] Add better logs for pydra package import handling --- physutils/tasks.py | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/physutils/tasks.py b/physutils/tasks.py index 1589164..f34ced7 100644 --- a/physutils/tasks.py +++ b/physutils/tasks.py @@ -14,12 +14,6 @@ pydra_imported = True except ImportError: - logger.warning( - "Pydra is not installed, so the physutils tasks are not available as pydra tasks" - ) - LGR.warning( - "Pydra is not installed, so the physutils tasks are not available as pydra tasks" - ) pydra_imported = False @@ -29,20 +23,11 @@ def decorator(func): # If the decorator exists, apply it @wraps(func) def wrapped_func(*args, **kwargs): + logger.debug(f"Creating pydra task for {func.__name__}") return pydra.mark.task(func)(*args, **kwargs) return wrapped_func # Otherwise, return the original function - logger.warning( - "Pydra is not installed, so {} is not available as a pydra task".format( - func.__name__ - ) - ) - LGR.warning( - "Pydra is not installed, so {} is not available as a pydra task".format( - func.__name__ - ) - ) return func return decorator @@ -52,6 +37,10 @@ def wrapped_func(*args, **kwargs): def transform_to_physio( input_file: str, mode="physio", fs=None, bids_parameters=dict(), bids_channel=None ) -> Physio: + if not pydra_imported: + LGR.warning( + "Pydra is not installed, thus transform_to_physio is not available as a pydra task. Using the function directly" + ) LGR.debug(f"Loading physio object from {input_file}") if not fs: fs = None