Skip to content

Commit

Permalink
Add better logs for pydra package import handling
Browse files Browse the repository at this point in the history
  • Loading branch information
maestroque committed Sep 3, 2024
1 parent 67ee789 commit 3a08510
Showing 1 changed file with 5 additions and 16 deletions.
21 changes: 5 additions & 16 deletions physutils/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 3a08510

Please sign in to comment.