Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pycalibration
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Analyze
Contributor 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
calibration
pycalibration
Commits
24085c44
Commit
24085c44
authored
4 months ago
by
Thomas Kluyver
Browse files
Options
Downloads
Patches
Plain Diff
Condense two non-reproducibility checks into one
parent
f857edc6
No related branches found
No related tags found
1 merge request
!1116
Require --not-reproducible for selected notebook parameters
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/xfel_calibrate/nb_args.py
+24
-34
24 additions, 34 deletions
src/xfel_calibrate/nb_args.py
with
24 additions
and
34 deletions
src/xfel_calibrate/nb_args.py
+
24
−
34
View file @
24085c44
...
...
@@ -411,32 +411,6 @@ def parse_argv_and_load_nb(argv) -> Tuple[Dict, NBDetails]:
print
(
"
Not one of the known calibrations or detectors
"
)
sys
.
exit
(
1
)
# Pick out any arguments that may prevent reproducibility from
# working, sorted alphabetically and converted back to their
# canonical representation.
not_reproducible_args
=
sorted
(
(
'
--
'
+
x
.
replace
(
'
_
'
,
'
-
'
)
for
x
in
[
'
skip_env_freeze
'
]
if
getattr
(
args
,
x
))
)
# If any of these arguments are set, present a warning.
if
not_reproducible_args
:
print
(
'
WARNING: One or more command line arguments ({}) may prevent
'
'
this specific correction result from being reproducible based
'
'
on its metadata. It may not be possible to restore identical
'
'
output data files when they have been deleted or lost. Please
'
'
ensure that the data retention policy of the chosen storage
'
'
location is sufficient for your
'
'
needs.
'
.
format
(
'
,
'
.
join
(
not_reproducible_args
)))
if
not
args
.
not_reproducible
:
# If not explicitly specified that reproducibility may be
# broken, remind the user and exit.
print
(
'
To proceed, you can explicitly allow reproducibility to
'
'
be broken by adding --not-reproducible
'
)
sys
.
exit
(
1
)
if
nb_info
[
"
notebook
"
]:
notebook
=
os
.
path
.
join
(
PKG_DIR
,
nb_info
[
"
notebook
"
])
else
:
...
...
@@ -477,18 +451,34 @@ def parse_argv_and_load_nb(argv) -> Tuple[Dict, NBDetails]:
arg_dict
=
deconsolize_args
(
vars
(
parser
.
parse_args
(
argv
[
1
:])))
not_reproducible_params
=
[
# Pick out any arguments that may prevent reproducibility from
# working
not_reproducible_args
=
[
x
for
x
in
[
'
skip_env_freeze
'
]
if
getattr
(
args
,
x
)
]
+
[
p
for
p
in
nb
.
metadata
.
get
(
"
euxfel_not_reproducible_params
"
,
[])
if
p
in
arg_dict
and
arg_dict
[
p
]
!=
default_values
[
p
]
]
if
not_reproducible_params
:
print
(
f
"
WARNING: you have specified parameters (
{
'
,
'
.
join
(
not_reproducible_params
)
}
)
"
f
"
which may interfere with reproducibility, potentially making it
"
f
"
impossible to reconstruct the resulting data in the future.
"
)
if
not
args
.
not_reproducible
:
sys
.
exit
(
"
To continue anyway, re-run the command with the
"
"
--not-reproducible flag.
"
)
# If any of these arguments are set, present a warning.
if
not_reproducible_args
:
fmted
=
'
,
'
.
join
(
sorted
(
'
--
'
+
x
.
replace
(
'
_
'
,
'
-
'
)
for
x
in
not_reproducible_args
))
print
(
f
'
WARNING: One or more command line arguments (
{
fmted
}
) may prevent
'
'
this specific correction result from being reproducible based
'
'
on its metadata. It may not be possible to restore identical
'
'
output data files when they have been deleted or lost. Please
'
'
ensure that the data retention policy of the chosen storage
'
'
location is sufficient for your
'
'
needs.
'
)
if
not
args
.
not_reproducible
:
# If not explicitly specified that reproducibility may be
# broken, remind the user and exit.
print
(
'
To proceed, you can explicitly allow reproducibility to
'
'
be broken by adding --not-reproducible
'
)
sys
.
exit
(
1
)
user_venv
=
nb_info
.
get
(
"
user
"
,
{}).
get
(
"
venv
"
)
if
user_venv
is
not
None
:
...
...
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