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
6d59ac9e
Commit
6d59ac9e
authored
5 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Plain Diff
Merge branch 'bf/fslsub' into 'master'
Bf/fslsub See merge request fsl/fslpy!207
parents
54d0e61d
d9de5b15
No related branches found
No related tags found
No related merge requests found
Pipeline
#5115
passed
5 years ago
Stage: test
Stage: style
Stage: doc
Stage: deploy
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CHANGELOG.rst
+1
-0
1 addition, 0 deletions
CHANGELOG.rst
fsl/utils/fslsub.py
+4
-4
4 additions, 4 deletions
fsl/utils/fslsub.py
tests/test_fslsub.py
+23
-0
23 additions, 0 deletions
tests/test_fslsub.py
with
28 additions
and
4 deletions
CHANGELOG.rst
+
1
−
0
View file @
6d59ac9e
...
...
@@ -55,6 +55,7 @@ Fixed
* Updated the :func:`.prepareArgs` function to use ``shlex.split`` when
preparing shell command arguments, instead of performing a naive whitespace
split.
* Fixed some bugs in the :func:`.fslsub.info` function.
2.8.4 (Monday 2nd March 2020)
...
...
This diff is collapsed.
Click to expand it.
fsl/utils/fslsub.py
+
4
−
4
View file @
6d59ac9e
...
...
@@ -40,8 +40,7 @@ Example usage, building a short pipeline::
"""
from
six
import
string_types
,
BytesIO
import
subprocess
as
sp
from
six
import
BytesIO
import
os.path
as
op
import
glob
import
time
...
...
@@ -149,8 +148,9 @@ def info(job_id):
:return: dictionary with information on the submitted job (empty
if job does not exist)
"""
from
fsl.utils.run
import
run
try
:
result
=
sp
.
call
([
'
qstat
'
,
'
-j
'
,
job_id
])
.
decode
(
'
utf-8
'
)
result
=
run
([
'
qstat
'
,
'
-j
'
,
job_id
])
except
FileNotFoundError
:
log
.
debug
(
"
qstat not found; assuming not on cluster
"
)
return
{}
...
...
@@ -158,7 +158,7 @@ def info(job_id):
return
{}
res
=
{}
for
line
in
result
.
splitlines
()[
1
:]:
key
,
value
=
line
.
split
(
'
:
'
,
nsplit
=
1
)
key
,
value
=
line
.
split
(
'
:
'
,
1
)
res
[
key
.
strip
()]
=
value
.
strip
()
return
res
...
...
This diff is collapsed.
Click to expand it.
tests/test_fslsub.py
+
23
−
0
View file @
6d59ac9e
...
...
@@ -102,6 +102,29 @@ def test_submit():
assert
stderr
.
strip
()
==
'
standard error
'
def
test_info
():
mock_qstat
=
tw
.
dedent
(
"""
#!/usr/bin/env bash
echo
"
#####################
"
echo
"
job_number: 1
"
echo
"
exec_file: 2
"
echo
"
submission_time: 3
"
echo
"
owner: 4
"
"""
).
strip
()
with
mockFSLDIR
()
as
fsldir
:
qstatbin
=
op
.
join
(
fsldir
,
'
bin
'
,
'
qstat
'
)
with
open
(
qstatbin
,
'
wt
'
)
as
f
:
f
.
write
(
mock_qstat
)
os
.
chmod
(
qstatbin
,
0o755
)
exp
=
{
'
job_number
'
:
'
1
'
,
'
exec_file
'
:
'
2
'
,
'
submission_time
'
:
'
3
'
,
'
owner
'
:
'
4
'
}
assert
fslsub
.
info
(
'
12345
'
)
==
exp
def
myfunc
():
print
(
'
standard output
'
)
print
(
'
standard error
'
,
file
=
sys
.
stderr
)
...
...
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