Skip to content

Commit

Permalink
[ENH] Run workflows in serial mode by default
Browse files Browse the repository at this point in the history
  • Loading branch information
ghisvail committed Apr 5, 2024
1 parent 14b6b2d commit 5496c7a
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions clinica/pydra/engine_utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from os import PathLike
from typing import Optional

Expand Down Expand Up @@ -50,7 +52,7 @@ def list_workflow_inputs(wf: Workflow) -> dict:
return inputs


def run(wf: Workflow, n_procs: Optional[int] = None) -> Result:
def run(wf: Workflow, n_procs: int | None = None) -> Result:
"""Execute a Pydra workflow.
If the execution of the workflow fails, the
Expand All @@ -62,19 +64,19 @@ def run(wf: Workflow, n_procs: Optional[int] = None) -> Result:
The workflow to be executed.
n_procs : int, optional
The number of CPU cores to be used to run the workflow.
If None, all available cores will be used.
The number of CPU cores used to run the workflow concurrently.
If None, the workflow is run sequentially.
Returns
-------
Result :
The result of running the Workflow
"""
import re

try:
with Submitter(plugin="cf", n_procs=n_procs) as submitter:
submitter_args = {"plugin": "cf", "n_procs": n_procs} if n_procs else {"plugin": "serial"}
with Submitter(**submitter_args) as submitter:
submitter(wf)
except Exception as e:
path = re.search(r"/.*\.pklz", str(e))
Expand Down

0 comments on commit 5496c7a

Please sign in to comment.