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
dad5ecee
Commit
dad5ecee
authored
1 year ago
by
Thomas Kluyver
Browse files
Options
Downloads
Patches
Plain Diff
Create correction reports in MyMdC when jobs have finished
parent
e80a4e2a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!943
[Webservice] Create correction reports in MyMdC when jobs have finished
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
setup.py
+1
-1
1 addition, 1 deletion
setup.py
webservice/job_monitor.py
+42
-1
42 additions, 1 deletion
webservice/job_monitor.py
with
43 additions
and
2 deletions
setup.py
+
1
−
1
View file @
dad5ecee
...
@@ -79,7 +79,7 @@ install_requires = [
...
@@ -79,7 +79,7 @@ install_requires = [
"
lxml==4.5.0
"
,
"
lxml==4.5.0
"
,
"
markupsafe==2.0.1
"
,
"
markupsafe==2.0.1
"
,
"
matplotlib==3.4.2
"
,
"
matplotlib==3.4.2
"
,
"
metadata_client==
3
.0.
8
"
,
"
metadata_client==
4
.0.
0
"
,
"
nbclient==0.5.1
"
,
"
nbclient==0.5.1
"
,
"
nbconvert==5.6.1
"
,
"
nbconvert==5.6.1
"
,
"
nbformat==5.0.7
"
,
"
nbformat==5.0.7
"
,
...
...
This diff is collapsed.
Click to expand it.
webservice/job_monitor.py
+
42
−
1
View file @
dad5ecee
...
@@ -3,6 +3,8 @@ import argparse
...
@@ -3,6 +3,8 @@ import argparse
import
json
import
json
import
locale
import
locale
import
logging
import
logging
import
os.path
import
shlex
import
signal
import
signal
import
time
import
time
from
datetime
import
datetime
,
timezone
from
datetime
import
datetime
,
timezone
...
@@ -232,7 +234,7 @@ class JobsMonitor:
...
@@ -232,7 +234,7 @@ class JobsMonitor:
).
fetchall
()]
).
fetchall
()]
success
=
set
(
statuses
)
==
{
'
COMPLETED
'
}
success
=
set
(
statuses
)
==
{
'
COMPLETED
'
}
r
=
self
.
job_db
.
execute
(
r
=
self
.
job_db
.
execute
(
"
SELECT det_type, karabo_id, req_id, proposal, run, action
"
"
SELECT det_type, karabo_id,
command,
req_id, proposal, run, action
, mymdc_id
"
"
FROM executions JOIN requests USING (req_id)
"
"
FROM executions JOIN requests USING (req_id)
"
"
WHERE exec_id = ?
"
,
"
WHERE exec_id = ?
"
,
(
exec_id
,)
(
exec_id
,)
...
@@ -259,6 +261,10 @@ class JobsMonitor:
...
@@ -259,6 +261,10 @@ class JobsMonitor:
log
.
warning
(
"
Error sending Kafka notification
"
,
log
.
warning
(
"
Error sending Kafka notification
"
,
exc_info
=
True
)
exc_info
=
True
)
self
.
record_correction_report
(
r
[
'
mymdc_id
'
],
r
[
'
command
'
],
r
[
'
karabo_id
'
],
success
)
return
r
[
'
req_id
'
]
return
r
[
'
req_id
'
]
def
process_request_finished
(
self
,
req_id
):
def
process_request_finished
(
self
,
req_id
):
...
@@ -331,9 +337,44 @@ class JobsMonitor:
...
@@ -331,9 +337,44 @@ class JobsMonitor:
log
.
error
(
"
Failed to update MDC dark run id %s
"
,
dark_run_id
)
log
.
error
(
"
Failed to update MDC dark run id %s
"
,
dark_run_id
)
log
.
error
(
Errors
.
MDC_RESPONSE
.
format
(
response
))
log
.
error
(
Errors
.
MDC_RESPONSE
.
format
(
response
))
def
record_correction_report
(
self
,
mymdc_run_id
,
command
,
karabo_id
,
success
):
"""
Add report to MyMdC when a correction execution has finished
"""
args
=
shlex
.
split
(
command
)
try
:
report_path
=
args
[
args
.
index
(
"
--report-to
"
)
+
1
]
+
"
.pdf
"
except
(
ValueError
,
IndexError
):
log
.
warning
(
"
Couldn
'
t find report path in %r
"
,
args
)
return
if
not
os
.
path
.
isfile
(
report_path
):
log
.
warning
(
"
Jobs finished, but report file %s missing
"
,
report_path
)
return
ts
=
datetime
.
fromtimestamp
(
os
.
stat
(
report_path
).
st_mtime
,
tz
=
timezone
.
utc
)
desc
=
f
"
{
karabo_id
}
detector corrections
"
if
not
success
:
desc
+=
"
(errors occurred)
"
log
.
debug
(
"
Adding report file %s to MDC for run ID %s
"
,
report_path
,
mymdc_run_id
)
response
=
self
.
mdc
.
create_report_api
({
"
name
"
:
os
.
path
.
basename
(
report_path
),
"
cal_report_path
"
:
os
.
path
.
dirname
(
report_path
).
rstrip
(
'
/
'
)
+
'
/
'
,
"
cal_report_at
"
:
ts
.
isoformat
(),
"
run_id
"
:
mymdc_run_id
,
"
description
"
:
desc
,
})
if
response
.
status_code
>=
400
:
log
.
error
(
"
Failed to add report to MDC for run ID %s: HTTP status %s
"
,
mymdc_run_id
,
response
.
status_code
)
def
interrupted
(
signum
,
frame
):
def
interrupted
(
signum
,
frame
):
raise
KeyboardInterrupt
raise
KeyboardInterrupt
def
main
(
argv
=
None
):
def
main
(
argv
=
None
):
# Ensure files are opened as UTF-8 by default, regardless of environment.
# Ensure files are opened as UTF-8 by default, regardless of environment.
locale
.
setlocale
(
locale
.
LC_CTYPE
,
(
'
en_US
'
,
'
UTF-8
'
))
locale
.
setlocale
(
locale
.
LC_CTYPE
,
(
'
en_US
'
,
'
UTF-8
'
))
...
...
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