Commit 114783ae authored by Paul McCarthy's avatar Paul McCarthy 🚵
Browse files

RF: FileOrThing passes through if cmdonly=True

parent 111c77a0
...@@ -482,25 +482,27 @@ class FileOrThing(object): ...@@ -482,25 +482,27 @@ class FileOrThing(object):
the dictionary. the dictionary.
**Cluster submission** **Exceptions**
The above description holds in all situations, except when an argument The above description holds in all situations, except when arguments called
called ``submit`` is passed, and is set to a value which evaluates to ``submit`` and/or ``cmdonly`` are passed, and are set to values which
``True``. In this case, the ``FileOrThing`` decorator will pass all evaluate to ``True``. In this case, the ``FileOrThing`` decorator will pass
arguments straight through to the decorated function, and will return its all arguments straight through to the decorated function, and will return
return value unchanged. its return value unchanged.
This is because most functions that are decorated with the This is because most functions that are decorated with the
:func:`fileOrImage` or :func:`fileOrArray` decorators will invoke a call :func:`fileOrImage` or :func:`fileOrArray` decorators will invoke a call
to :func:`.run.run` or :func:`.runfsl`, where a value of ``submit=True`` to :func:`.run.run` or :func:`.runfsl`, where:
will cause the command to be executed asynchronously on a cluster
platform.
- a value of ``submit=True`` will cause the command to be executed
asynchronously on a cluster platform.
- a value of ``cmdonly=True`` will cause the command to *not* be executed,
but instead the command that would have been executed is returned.
A :exc:`ValueError` will be raised if the decorated function is called A :exc:`ValueError` will be raised if the decorated function is called
with ``submit=True``, and with any in-memory objects or ``LOAD`` symbols. with ``submit=True`` and/or ``cmdonly=True``, and with any in-memory
objects or ``LOAD`` symbols.
**Example** **Example**
...@@ -684,9 +686,11 @@ class FileOrThing(object): ...@@ -684,9 +686,11 @@ class FileOrThing(object):
# Special case - if fsl.utils.run[fsl] is # Special case - if fsl.utils.run[fsl] is
# being decorated (e.g. via cmdwrapper/ # being decorated (e.g. via cmdwrapper/
# fslwrapper), and submit=True, this call # fslwrapper), and submit=True or
# will ultimately submit the job to the # cmdonly=True, this call will ultimately
# cluster, and will return immediately. # submit the job to the cluster, or will
# return the command that would have been
# executed, and will return immediately.
# #
# We error if we are given any in-memory # We error if we are given any in-memory
# things, or LOAD symbols. # things, or LOAD symbols.
...@@ -694,7 +698,8 @@ class FileOrThing(object): ...@@ -694,7 +698,8 @@ class FileOrThing(object):
# n.b. testing values to be strings could # n.b. testing values to be strings could
# interfere with the fileOrText decorator. # interfere with the fileOrText decorator.
# Possible solution is to use pathlib? # Possible solution is to use pathlib?
if kwargs.get('submit', False): if kwargs.get('submit', False) or \
kwargs.get('cmdonly', False):
allargs = {**dict(zip(argnames, args)), **kwargs} allargs = {**dict(zip(argnames, args)), **kwargs}
for name, val in allargs.items(): for name, val in allargs.items():
if (name in self.__things) and \ if (name in self.__things) and \
......
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