Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
LINC
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
ResearchAndDevelopment
LINC
Commits
15ad5313
Commit
15ad5313
authored
3 years ago
by
Matthijs van der Wild
Browse files
Options
Downloads
Patches
Plain Diff
Replace check_workflow_results.py
Former-commit-id:
b4841233
[formerly
7026d589
] Former-commit-id:
46758d32
Former-commit-id:
d86b916d
parent
ba61dd71
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
test_jobs/check_workflow_results.py
+45
-40
45 additions, 40 deletions
test_jobs/check_workflow_results.py
with
45 additions
and
40 deletions
test_jobs/check_workflow_results.py
+
45
−
40
View file @
15ad5313
#!
/usr/bin/env python3
#!/usr/bin/env python3
"""
Checks the outputs of a workflow run
"""
import
argparse
from
argparse
import
RawTextHelpFormatter
from
losoto.h5parm
import
h5parm
import
os
import
h5py
import
sys
from
filecmp
import
dircmp
import
numpy
as
np
def
main
(
results_path
,
control_path
):
def
main
(
check
,
control
):
"""
Checks the outputs of an end-to-end workflow job
...
...
@@ -22,45 +19,53 @@ def main(results_path, control_path):
control_path : str
Path to control results directory
"""
error
=
False
# Check that all expected output files are present
dcmp
=
dircmp
(
results_path
,
control_path
)
if
len
(
dcmp
.
left_only
)
>
0
or
len
(
dcmp
.
right_only
)
>
0
:
if
len
(
dcmp
.
left_only
)
>
0
:
print
(
'
ERROR: The following files are present in the output but not in the
'
'
control: {}
'
.
format
(
dcmp
.
left_only
))
if
len
(
dcmp
.
right_only
)
>
0
:
print
(
'
ERROR: The following files are present in the control but not in the
'
'
output: {}
'
.
format
(
dcmp
.
right_only
))
error
=
True
check_path
=
check
+
'
/cal_values/cal_solutions.h5
'
control_path
=
control
+
'
/cal_values/cal_solutions.h5
'
check_h5
=
h5py
.
File
(
check_path
,
'
r
'
)
control_h5
=
h5py
.
File
(
control_path
,
'
r
'
)
# Check that the calibration solutions match the control ones
check_h5parm
=
os
.
path
.
join
(
results_path
,
'
cal_values
'
,
'
cal_solutions.h5
'
)
control_h5parm
=
os
.
path
.
join
(
control_path
,
'
cal_values
'
,
'
cal_solutions.h5
'
)
check_h5
=
h5parm
(
check_h5parm
,
readonly
=
True
)
control_h5
=
h5parm
(
control_h5parm
,
readonly
=
True
)
for
check_solset
in
check_h5
.
getSolsets
():
control_solset
=
control_h5
.
getSolset
(
check_solset
.
name
)
for
check_soltab
in
check_solset
.
getSoltabs
():
control_soltab
=
control_solset
.
getSoltab
(
check_soltab
.
name
)
if
not
np
.
allclose
(
check_soltab
.
val
,
control_soltab
.
val
,
rtol
=
1e-03
,
atol
=
1e-03
,
equal_nan
=
True
):
error
=
True
print
(
'
ERROR: Val array of soltab {} of solset {} does not match
'
'
the control
'
.
format
(
check_soltab
.
name
,
check_solset
.
name
))
with
open
(
"
check_soltab.{}.val
"
.
format
(
check_soltab
.
name
),
"
w
"
)
as
f
:
f
.
write
(
str
(
check_soltab
.
val
))
with
open
(
"
control_soltab.{}.val
"
.
format
(
control_soltab
.
name
),
"
w
"
)
as
f
:
f
.
write
(
str
(
control_soltab
.
val
))
for
solsetname
in
check_h5
:
soltabnames
=
[
name
for
name
in
check_h5
[
solsetname
]
if
name
not
in
(
'
source
'
,
'
antenna
'
)]
try
:
control_h5
[
solsetname
]
except
:
print
(
"
Error: solset {} not present in control.
"
.
format
(
solsetname
))
sys
.
exit
(
1
)
for
soltabname
in
soltabnames
:
try
:
control_h5
[
solsetname
][
soltabname
]
except
:
print
(
"
Error: soltab {} not present in control.
"
.
format
(
soltabname
))
sys
.
exit
(
1
)
check_soltabval
=
check_h5
[
solsetname
][
soltabname
][
'
val
'
]
control_soltabval
=
control_h5
[
solsetname
][
soltabname
][
'
val
'
]
matching_vals
=
control_soltabval
if
'
freq
'
in
check_h5
[
solsetname
][
soltabname
].
keys
():
check_axes
=
check_soltabval
.
attrs
[
'
AXES
'
].
decode
(
'
utf-8
'
).
split
(
'
,
'
)
freq_axis_index
=
check_axes
.
index
(
'
freq
'
)
check_soltabfreq
=
check_h5
[
solsetname
][
soltabname
][
'
freq
'
][:]
control_soltabfreq
=
control_h5
[
solsetname
][
soltabname
][
'
freq
'
][:]
matches
=
np
.
isclose
(
control_soltabfreq
[:,
np
.
newaxis
],
check_soltabfreq
)
matching_freq_indices
=
np
.
where
(
matches
)[
0
]
matching_vals
=
np
.
take
(
control_soltabval
,
matching_freq_indices
,
axis
=
freq_axis_index
)
if
not
np
.
allclose
(
check_soltabval
,
matching_vals
,
rtol
=
1e-03
,
atol
=
1e-03
,
equal_nan
=
True
):
print
(
"
Val array of soltab {} does not match the control
"
.
format
(
soltabname
))
with
open
(
"
check_soltab.{}.val
"
.
format
(
soltabname
),
"
w
"
)
as
f
:
f
.
write
(
str
(
check_soltabval
[:]))
with
open
(
"
control_soltab.{}.val
"
.
format
(
soltabname
),
"
w
"
)
as
f
:
f
.
write
(
str
(
check_soltabval
[:]))
else
:
print
(
'
INFO: Val array of soltab {} of solset {} matches
'
'
the control
'
.
format
(
check_soltab
.
name
,
check_solset
.
name
))
control_h5
.
close
()
print
(
"
Val array of soltab {} matches the control
"
.
format
(
soltabname
))
check_h5
.
close
()
sys
.
exit
(
error
)
control_h5
.
close
()
sys
.
exit
(
0
)
if
__name__
==
'
__main__
'
:
descriptiontext
=
"
Checks the ouput of a workflow run.
\n
"
descriptiontext
=
"
Checks the ou
t
put of a workflow run.
\n
"
parser
=
argparse
.
ArgumentParser
(
description
=
descriptiontext
,
formatter_class
=
RawTextHelpFormatter
)
parser
.
add_argument
(
'
results_path
'
,
help
=
'
Path to output results
'
)
...
...
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