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
3ebae6b1
Commit
3ebae6b1
authored
4 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
RF: when cmdonly is used with a wrapper function, assertions are disabled
parent
c63dc780
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
fsl/utils/assertions.py
+5
-2
5 additions, 2 deletions
fsl/utils/assertions.py
fsl/wrappers/wrapperutils.py
+13
-5
13 additions, 5 deletions
fsl/wrappers/wrapperutils.py
with
18 additions
and
7 deletions
fsl/utils/assertions.py
+
5
−
2
View file @
3ebae6b1
...
@@ -39,14 +39,17 @@ _DISABLE_ASSERTIONS = False
...
@@ -39,14 +39,17 @@ _DISABLE_ASSERTIONS = False
@contextlib.contextmanager
@contextlib.contextmanager
def
disabled
():
def
disabled
(
disable
=
True
):
"""
Context manager which allows assertion checks to be temporarily
"""
Context manager which allows assertion checks to be temporarily
disabled.
disabled.
:arg disable: Set to ``True`` (the default) to disable assertions,
or ``False`` to enable them.
"""
"""
global
_DISABLE_ASSERTIONS
global
_DISABLE_ASSERTIONS
oldval
=
_DISABLE_ASSERTIONS
oldval
=
_DISABLE_ASSERTIONS
_DISABLE_ASSERTIONS
=
Tru
e
_DISABLE_ASSERTIONS
=
disabl
e
try
:
try
:
yield
yield
...
...
This diff is collapsed.
Click to expand it.
fsl/wrappers/wrapperutils.py
+
13
−
5
View file @
3ebae6b1
...
@@ -108,10 +108,11 @@ import six
...
@@ -108,10 +108,11 @@ import six
import
nibabel
as
nib
import
nibabel
as
nib
import
numpy
as
np
import
numpy
as
np
import
fsl.utils.run
as
run
import
fsl.utils.run
as
run
import
fsl.utils.path
as
fslpath
import
fsl.utils.assertions
as
asrt
import
fsl.utils.tempdir
as
tempdir
import
fsl.utils.path
as
fslpath
import
fsl.data.image
as
fslimage
import
fsl.utils.tempdir
as
tempdir
import
fsl.data.image
as
fslimage
log
=
logging
.
getLogger
(
__name__
)
log
=
logging
.
getLogger
(
__name__
)
...
@@ -185,7 +186,14 @@ def genxwrapper(func, runner):
...
@@ -185,7 +186,14 @@ def genxwrapper(func, runner):
submit
=
kwargs
.
pop
(
'
submit
'
,
None
)
submit
=
kwargs
.
pop
(
'
submit
'
,
None
)
cmdonly
=
kwargs
.
pop
(
'
cmdonly
'
,
False
)
cmdonly
=
kwargs
.
pop
(
'
cmdonly
'
,
False
)
log
=
kwargs
.
pop
(
'
log
'
,
{
'
tee
'
:
True
})
log
=
kwargs
.
pop
(
'
log
'
,
{
'
tee
'
:
True
})
cmd
=
func
(
*
args
,
**
kwargs
)
# many wrapper functions use fsl.utils.assertions
# statements to check that input arguments are
# valid. Disable these if the cmdonly argument is
# being used to generate a command without running
# it.
with
asrt
.
disabled
(
cmdonly
):
cmd
=
func
(
*
args
,
**
kwargs
)
return
runner
(
cmd
,
return
runner
(
cmd
,
stderr
=
stderr
,
stderr
=
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