Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fslpy
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FSL
fslpy
Commits
0c1673bc
Commit
0c1673bc
authored
4 years ago
by
Michiel Cottaar
Browse files
Options
Downloads
Patches
Plain Diff
DOC: added much more detailed documentation to SubmitParams
parent
0ba5b9ea
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
fsl/utils/fslsub.py
+38
-0
38 additions, 0 deletions
fsl/utils/fslsub.py
with
38 additions
and
0 deletions
fsl/utils/fslsub.py
+
38
−
0
View file @
0c1673bc
...
...
@@ -62,6 +62,38 @@ log = logging.getLogger(__name__)
class
SubmitParams
(
object
):
"""
Represents the fsl_sub parameters
Any command line script can be submitted by the parameters by calling the `SubmitParams` object:
.. codeblock:: python
submit = SubmitParams(minutes=1, logdir=
'
log
'
, wait_for=[
'
108023
'
,
'
108019
'
])
submit(
'
echo finished
'
)
This will run
"
echo finished
"
with a maximum runtime of 1 minute after the jobs with IDs 108023 and 108019 are finished.
It is the equivalent of
.. codeblock:: bash
fsl_sub -T 1 -l log -j 108023,108019
"
echo finished
"
For python scripts that submit themselves to the cluster, it might be useful to give the user some control
over at least some of the submission parameters. This can be done using:
.. codeblock:: python
import argparse
parser = argparse.ArgumentParser(
"
my script doing awesome stuff
"
)
parser.add_argument(
"
input_file
"
)
parser.add_argument(
"
output_file
"
)
SubmitParams.add_to_parser(parser, include=(
'
wait_for
'
,
'
logdir
'
))
args = parser.parse_args()
submitter = SubmitParams.from_args(args).update(minutes=10)
from fsl import wrappers
wrappers.bet(input_file, output_file, fslsub=submitter)
This submits a BET job using the -j and -l flags set by the user and a maximum time of 10 minutes.
"""
minutes
:
Optional
[
float
]
=
None
queue
:
Optional
[
str
]
=
None
...
...
@@ -91,6 +123,9 @@ class SubmitParams(object):
}
def
__post_init__
(
self
):
"""
If not set explicitly by the user don
'
t alter the environment in which the script will be submitted
"""
if
self
.
env
is
None
:
self
.
env
=
{}
...
...
@@ -205,6 +240,9 @@ class SubmitParams(object):
@classmethod
def
from_args
(
cls
,
args
):
"""
Create a SubmitParams from the command line arguments
"""
as_dict
=
{
value
:
getattr
(
args
,
'
_sub_
'
+
value
,
None
)
for
value
in
cls
.
cmd_line_flags
.
values
()}
if
args
.
_sub_wait_for
is
not
None
:
as_dict
[
'
wait_for
'
]
=
args
.
_sub_wait_for
.
split
(
'
,
'
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment