Commit adcd481c authored by Paul McCarthy's avatar Paul McCarthy 🚵
Browse files

RF: fsl.utils.run now uses fsl.wrappers.fsl_sub instead of fsl.utils.fslsub

parent 30a56372
...@@ -31,10 +31,10 @@ import os.path as op ...@@ -31,10 +31,10 @@ import os.path as op
import os import os
from fsl.utils.platform import platform as fslplatform from fsl.utils.platform import platform as fslplatform
import fsl.utils.fslsub as fslsub
import fsl.utils.tempdir as tempdir import fsl.utils.tempdir as tempdir
import fsl.utils.path as fslpath import fsl.utils.path as fslpath
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
...@@ -146,7 +146,7 @@ def run(*args, **kwargs): ...@@ -146,7 +146,7 @@ def run(*args, **kwargs):
:arg submit: Must be passed as a keyword argument. Defaults to ``None``. :arg submit: Must be passed as a keyword argument. Defaults to ``None``.
If ``True``, the command is submitted as a cluster job via If ``True``, the command is submitted as a cluster job via
the :func:`.fslsub.submit` function. May also be a the :mod:`fsl.wrappers.fsl_sub` function. May also be a
dictionary containing arguments to that function. dictionary containing arguments to that function.
:arg cmdonly: Defaults to ``False``. If ``True``, the command is not :arg cmdonly: Defaults to ``False``. If ``True``, the command is not
...@@ -173,10 +173,10 @@ def run(*args, **kwargs): ...@@ -173,10 +173,10 @@ def run(*args, **kwargs):
object (via :func:`_realrun`), unless ``submit=True``, in which case they object (via :func:`_realrun`), unless ``submit=True``, in which case they
are passed through to the :func:`.fslsub.submit` function. are passed through to the :func:`.fslsub.submit` function.
:returns: If ``submit`` is provided, the return value of :returns: If ``submit`` is provided, the ID of the submitted job is
:func:`.fslsub` is returned. Otherwise returns a single returned as a string. Otherwise returns a single value or a
value or a tuple, based on the based on the ``stdout``, tuple, based on the based on the ``stdout``, ``stderr``, and
``stderr``, and ``exitcode`` arguments. ``exitcode`` arguments.
""" """
returnStdout = kwargs.pop('stdout', True) returnStdout = kwargs.pop('stdout', True)
...@@ -217,9 +217,12 @@ def run(*args, **kwargs): ...@@ -217,9 +217,12 @@ def run(*args, **kwargs):
return _dryrun( return _dryrun(
submit, returnStdout, returnStderr, returnExitcode, *args) submit, returnStdout, returnStderr, returnExitcode, *args)
# submit - delegate to fslsub # submit - delegate to fsl_sub. This will induce a nested
# call back to this run function, which is a bit confusing,
# but harmless, as we've popped the "submit" arg above.
if submit is not None: if submit is not None:
return fslsub.submit(' '.join(args), **submit, **kwargs) from fsl.wrappers import fsl_sub # pylint: disable=import-outside-toplevel # noqa: E501
return fsl_sub(*args, **submit, **kwargs)[0].strip()
# Run directly - delegate to _realrun # Run directly - delegate to _realrun
stdout, stderr, exitcode = _realrun( stdout, stderr, exitcode = _realrun(
...@@ -438,13 +441,17 @@ def wslcmd(cmdpath, *args): ...@@ -438,13 +441,17 @@ def wslcmd(cmdpath, *args):
def hold(job_ids, hold_filename=None): def hold(job_ids, hold_filename=None):
""" """Waits until all jobs have finished
Waits until all jobs have finished
:param job_ids: possibly nested sequence of job ids. The job ids
themselves should be strings.
:param job_ids: possibly nested sequence of job ids. The job ids themselves should be strings. :param hold_filename: filename to use as a hold file. The
:param hold_filename: filename to use as a hold file. containing directory should exist, but the
The containing directory should exist, but the file itself should not. file itself should not. Defaults to a
Defaults to a ./.<random characters>.hold in the current directory. ./.<random characters>.hold in the current
:return: only returns when all the jobs have finished directory. :return: only returns when all
the jobs have finished
""" """
import fsl.utils.fslsub as fslsub # pylint: disable=import-outside-toplevel # noqa: E501
fslsub.hold(job_ids, hold_filename) fslsub.hold(job_ids, hold_filename)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment