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
a74c5a95
Commit
a74c5a95
authored
1 year ago
by
Karim Ahmed
Browse files
Options
Downloads
Patches
Plain Diff
use deepDiff to find difference in dictionaries
parent
d269d58c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!942
[Tests] Validate metadata for retrieved constants before validating the corrected files
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
setup.py
+2
-0
2 additions, 0 deletions
setup.py
tests/test_reference_runs/test_pre_deployment.py
+11
-19
11 additions, 19 deletions
tests/test_reference_runs/test_pre_deployment.py
with
13 additions
and
19 deletions
setup.py
+
2
−
0
View file @
a74c5a95
...
...
@@ -153,6 +153,7 @@ setup(
],
"
test
"
:
[
"
coverage
"
,
"
deepdiff==6.7.1
"
,
"
nbval
"
,
"
pytest-asyncio
"
,
"
pytest-cov
"
,
...
...
@@ -163,6 +164,7 @@ setup(
],
"
automated_test
"
:
[
"
coverage
"
,
"
deepdiff==6.7.1
"
,
"
nbval
"
,
"
pytest-asyncio
"
,
"
pytest-cov
"
,
...
...
This diff is collapsed.
Click to expand it.
tests/test_reference_runs/test_pre_deployment.py
+
11
−
19
View file @
a74c5a95
...
...
@@ -14,6 +14,7 @@ import h5py
import
numpy
as
np
import
pytest
import
yaml
from
deepdiff
import
DeepDiff
import
xfel_calibrate.calibrate
as
calibrate
...
...
@@ -258,21 +259,10 @@ def slurm_watcher(test_key: str, std_out: str):
LOGGER
.
info
(
f
"
{
test_key
}
'
s jobs were COMPLETED
"
)
def
compare_metadata_ccvs
(
test
,
reference
,
tested_key
):
def
load_yaml
(
file_path
):
with
open
(
file_path
,
'
r
'
)
as
file
:
return
yaml
.
safe_load
(
file
)
def
load_yaml
(
file_path
):
with
open
(
file_path
,
'
r
'
)
as
file
:
return
yaml
.
safe_load
(
file
)
# Load the relevant section from both files
ccvs_test
=
load_yaml
(
test
).
get
(
tested_key
,
{})
ccvs_reference
=
load_yaml
(
reference
).
get
(
tested_key
,
{})
# Compare the content directly
if
ccvs_test
==
ccvs_reference
:
return
True
else
:
return
False
@pytest.mark.manual_run
@pytest.mark.parametrize
(
...
...
@@ -379,11 +369,13 @@ def test_xfel_calibrate(
if
cal_type
.
lower
()
==
"
correct
"
:
# For corrections validate calibration constants
metadata_file
=
f
"
calibration_metadata_
{
cal_conf
[
'
karabo-id
'
]
}
.yml
"
assert
compare_metadata_ccvs
(
out_folder
/
metadata_file
,
reference_folder
/
metadata_file
,
"
retrieved-constants
"
,
),
"
Found difference in the metadata for the retrieved Constants.
"
# Load the relevant section from both files
ccvs_test
=
load_yaml
(
out_folder
/
metadata_file
)[
"
retrieved-constants
"
]
ccvs_reference
=
load_yaml
(
reference_folder
/
metadata_file
)[
"
retrieved-constants
"
]
ccvs_diff
=
DeepDiff
(
ccvs_test
,
ccvs_reference
,
ignore_order
=
True
)
assert
ccvs_diff
==
{},
"
Found difference in the metadata for the retrieved Constants.
"
# noqa
LOGGER
.
info
(
"
Retrieved CCVs validated.
"
)
# Stop tests at this point, if desired.
...
...
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