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
463aa549
Commit
463aa549
authored
6 months ago
by
Thomas Kluyver
Browse files
Options
Downloads
Patches
Plain Diff
--detector option to select detector type
parent
dfaf6d84
No related branches found
No related tags found
1 merge request
!1076
Script to validate YAML config against notebooks
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/xfel_calibrate/validate_nbs_config.py
+8
-4
8 additions, 4 deletions
src/xfel_calibrate/validate_nbs_config.py
with
8 additions
and
4 deletions
src/xfel_calibrate/validate_nbs_config.py
+
8
−
4
View file @
463aa549
...
...
@@ -46,7 +46,7 @@ n_probs = 0
def
config_problem
(
problem
,
detail
,
file
,
key
):
global
n_probs
n_probs
+=
1
print
(
f
"
{
problem
}
\n
{
detail
}
\n
file:
{
file
}
\n
key:
{
'
/
'
.
join
(
key
)
}
"
)
print
(
f
"
{
problem
}
\n
{
detail
}
\n
file:
{
file
}
\n
key:
{
'
/
'
.
join
(
key
)
}
\n
"
)
def
bad_list_element_types
(
value
,
param
:
nbparameterise
.
Parameter
):
...
...
@@ -94,7 +94,7 @@ def like_type(value, param_type):
return
False
def
check_yaml_file
(
path
:
Path
,
config_dir
:
Path
,
nb_params
):
def
check_yaml_file
(
path
:
Path
,
config_dir
:
Path
,
nb_params
,
detectors
):
rel_path
=
path
.
relative_to
(
config_dir
)
with
path
.
open
(
'
r
'
)
as
f
:
cfg
=
yaml
.
safe_load
(
f
)
...
...
@@ -124,6 +124,9 @@ def check_yaml_file(path: Path, config_dir: Path, nb_params):
)
continue
if
detectors
and
(
det
not
in
detectors
):
continue
try
:
det_params
=
nb_params
[
det
][
action
.
upper
()]
except
KeyError
:
...
...
@@ -162,6 +165,7 @@ def check_yaml_file(path: Path, config_dir: Path, nb_params):
def
main
(
argv
=
None
):
ap
=
argparse
.
ArgumentParser
()
ap
.
add_argument
(
'
--config-dir
'
,
type
=
Path
,
default
=
"
~/calibration_config/
"
)
ap
.
add_argument
(
'
--detector
'
,
choices
=
notebooks
.
keys
(),
action
=
'
append
'
)
args
=
ap
.
parse_args
(
argv
)
config_dir
=
args
.
config_dir
.
expanduser
()
...
...
@@ -174,9 +178,9 @@ def main(argv=None):
print
(
f
"
Checking
{
len
(
files
)
}
files in
{
config_dir
}
...
\n
"
)
for
file
in
files
:
check_yaml_file
(
file
,
config_dir
,
nb_params
)
check_yaml_file
(
file
,
config_dir
,
nb_params
,
detectors
=
args
.
detector
)
print
(
f
"
\n
{
n_probs
}
config issues found
"
)
print
(
f
"
{
n_probs
}
config issues found
"
)
sys
.
exit
(
1
if
n_probs
else
0
)
...
...
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