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
Package registry
Model registry
Operate
Environments
Terraform modules
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
Evan Edmond
fslpy
Commits
bbd81728
Commit
bbd81728
authored
6 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
ENH: If outprefix is set to LOAD, all outputs are loaded.
parent
6d16a2a8
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/wrappers/wrapperutils.py
+28
-9
28 additions, 9 deletions
fsl/wrappers/wrapperutils.py
with
28 additions
and
9 deletions
fsl/wrappers/wrapperutils.py
+
28
−
9
View file @
bbd81728
...
@@ -90,6 +90,8 @@ import os
...
@@ -90,6 +90,8 @@ import os
import
sys
import
sys
import
glob
import
glob
import
shutil
import
shutil
import
random
import
string
import
fnmatch
import
fnmatch
import
inspect
import
inspect
import
logging
import
logging
...
@@ -616,14 +618,16 @@ class _FileOrThing(object):
...
@@ -616,14 +618,16 @@ class _FileOrThing(object):
for
filename
in
allPrefixed
:
for
filename
in
allPrefixed
:
basename
=
op
.
basename
(
filename
)
basename
=
op
.
basename
(
filename
)
for
pref
ix
in
prefixes
:
for
pref
Pat
,
prefName
in
prefixes
.
items
()
:
if
fnmatch
.
fnmatch
(
basename
,
'
{}*
'
.
format
(
pref
ix
)):
if
fnmatch
.
fnmatch
(
basename
,
'
{}*
'
.
format
(
pref
Pat
)):
log
.
debug
(
'
Loading prefixed output %s: %s
'
,
log
.
debug
(
'
Loading prefixed output %s
[%s]
: %s
'
,
pref
ix
,
filename
)
pref
Pat
,
prefName
,
filename
)
fval
=
self
.
__load
(
filename
)
fval
=
self
.
__load
(
filename
)
basename
=
self
.
__removeExt
(
basename
)
basename
=
self
.
__removeExt
(
basename
)
basename
=
basename
.
replace
(
prefPat
,
prefName
)
result
[
basename
]
=
fval
result
[
basename
]
=
fval
break
break
...
@@ -669,15 +673,15 @@ class _FileOrThing(object):
...
@@ -669,15 +673,15 @@ class _FileOrThing(object):
- A dictionary of ``{ name : filename }`` mappings,
- A dictionary of ``{ name : filename }`` mappings,
for all arguments with a value of ``LOAD``.
for all arguments with a value of ``LOAD``.
- A
list
``
[
file
name ]
`` paths, for
all
- A
dictionary
``
{
file
pat : replstr }
`` paths, for
output-prefix arguments with a value of ``LOAD``.
all
output-prefix arguments with a value of ``LOAD``.
"""
"""
# These containers keep track
# These containers keep track
# of output files which are to
# of output files which are to
# be loaded into memory
# be loaded into memory
outfiles
=
dict
()
outfiles
=
dict
()
prefixedFiles
=
[]
prefixedFiles
=
dict
()
allargs
=
{
k
:
v
for
k
,
v
in
zip
(
argnames
,
args
)}
allargs
=
{
k
:
v
for
k
,
v
in
zip
(
argnames
,
args
)}
allargs
.
update
(
kwargs
)
allargs
.
update
(
kwargs
)
...
@@ -696,9 +700,23 @@ class _FileOrThing(object):
...
@@ -696,9 +700,23 @@ class _FileOrThing(object):
# accept an output prefix which contains
# accept an output prefix which contains
# a directory path.
# a directory path.
if
prefix
is
not
None
:
if
prefix
is
not
None
:
# If prefix is set to LOAD,
# all generated output files
# should be loaded - we use a
# randomly generated prefix,
# and add it to prefixedFiles,
# so that every file which
# starts with it will be
# loaded.
if
prefix
is
LOAD
:
prefix
=
random
.
sample
(
string
.
ascii_letters
,
10
)
prefix
=
''
.
join
(
prefix
)
realPrefix
=
prefix
realPrefix
=
prefix
prefix
=
op
.
basename
(
prefix
)
prefix
=
op
.
basename
(
prefix
)
allargs
[
self
.
__outprefix
]
=
op
.
join
(
workdir
,
prefix
)
allargs
[
self
.
__outprefix
]
=
op
.
join
(
workdir
,
prefix
)
prefixedFiles
[
prefix
]
=
self
.
__outprefix
if
len
(
self
.
__things
)
>
0
:
things
=
self
.
__things
if
len
(
self
.
__things
)
>
0
:
things
=
self
.
__things
else
:
things
=
allargs
.
keys
()
else
:
things
=
allargs
.
keys
()
...
@@ -717,7 +735,8 @@ class _FileOrThing(object):
...
@@ -717,7 +735,8 @@ class _FileOrThing(object):
# be given a value of LOAD
# be given a value of LOAD
if
isprefixed
and
val
is
not
LOAD
:
if
isprefixed
and
val
is
not
LOAD
:
raise
ValueError
(
'
Cannot specify name of prefixed file - the
'
raise
ValueError
(
'
Cannot specify name of prefixed file - the
'
'
name is defined by the output prefix
'
)
'
name is defined by the output prefix:
'
'
{}
'
.
format
(
name
))
if
val
is
LOAD
:
if
val
is
LOAD
:
...
@@ -728,7 +747,7 @@ class _FileOrThing(object):
...
@@ -728,7 +747,7 @@ class _FileOrThing(object):
# function. So we don't pass it
# function. So we don't pass it
# through.
# through.
if
isprefixed
:
if
isprefixed
:
prefixedFiles
.
append
(
name
)
prefixedFiles
[
name
]
=
name
allargs
.
pop
(
name
)
allargs
.
pop
(
name
)
# regular output-file argument
# regular output-file argument
...
...
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