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
8e8d740a
Commit
8e8d740a
authored
2 years ago
by
Thomas Kluyver
Browse files
Options
Downloads
Patches
Plain Diff
Add some docstrings, type hints
parent
bad1af5e
No related branches found
No related tags found
1 merge request
!683
[Webservice] Restructure database to give more meaningful success/failure information
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
webservice/job_monitor.py
+10
-5
10 additions, 5 deletions
webservice/job_monitor.py
with
10 additions
and
5 deletions
webservice/job_monitor.py
+
10
−
5
View file @
8e8d740a
...
@@ -111,9 +111,6 @@ class JobsMonitor:
...
@@ -111,9 +111,6 @@ class JobsMonitor:
def
do_updates
(
self
):
def
do_updates
(
self
):
ongoing_jobs_by_exn
=
self
.
get_updates_by_exec_id
()
ongoing_jobs_by_exn
=
self
.
get_updates_by_exec_id
()
# ^ dict grouping statuses of unfinished jobs by execution ID:
# {12345: ['R-5:41', 'PD-0:00', ...]}
# Newly completed executions are present with an empty list.
# For executions still running, regroup the jobs by request
# For executions still running, regroup the jobs by request
# (by run, for correction requests):
# (by run, for correction requests):
...
@@ -144,7 +141,13 @@ class JobsMonitor:
...
@@ -144,7 +141,13 @@ class JobsMonitor:
for
req_id
in
reqs_finished
:
for
req_id
in
reqs_finished
:
self
.
process_request_finished
(
req_id
)
self
.
process_request_finished
(
req_id
)
def
get_updates_by_exec_id
(
self
):
def
get_updates_by_exec_id
(
self
)
->
dict
:
"""
Get statuses of unfinished jobs, grouped by execution ID
E.g. {12345: [
'
R-5:41
'
,
'
PD-0:00
'
, ...]}
Newly completed executions are present with an empty list.
"""
c
=
self
.
job_db
.
cursor
()
c
=
self
.
job_db
.
cursor
()
c
.
execute
(
"
SELECT job_id, exec_id FROM slurm_jobs WHERE finished = 0
"
)
c
.
execute
(
"
SELECT job_id, exec_id FROM slurm_jobs WHERE finished = 0
"
)
...
@@ -202,7 +205,7 @@ class JobsMonitor:
...
@@ -202,7 +205,7 @@ class JobsMonitor:
self
.
mymdc_update_dark
(
mymdc_id
,
msg
)
self
.
mymdc_update_dark
(
mymdc_id
,
msg
)
def
process_execution_finished
(
self
,
exec_id
):
def
process_execution_finished
(
self
,
exec_id
):
"""
Send notification that one execution has finished
"""
"""
Send notification
& record
that one execution has finished
"""
statuses
=
[
r
[
0
]
for
r
in
self
.
job_db
.
execute
(
statuses
=
[
r
[
0
]
for
r
in
self
.
job_db
.
execute
(
"
SELECT status FROM slurm_jobs WHERE exec_id = ?
"
,
(
exec_id
,)
"
SELECT status FROM slurm_jobs WHERE exec_id = ?
"
,
(
exec_id
,)
).
fetchall
()]
).
fetchall
()]
...
@@ -283,6 +286,7 @@ class JobsMonitor:
...
@@ -283,6 +286,7 @@ class JobsMonitor:
self
.
mymdc_update_dark
(
r
[
'
mymdc_id
'
],
msg
,
status
)
self
.
mymdc_update_dark
(
r
[
'
mymdc_id
'
],
msg
,
status
)
def
mymdc_update_run
(
self
,
run_id
,
msg
,
status
=
'
R
'
):
def
mymdc_update_run
(
self
,
run_id
,
msg
,
status
=
'
R
'
):
"""
Update correction status in MyMdC
"""
data
=
{
'
flg_cal_data_status
'
:
status
,
data
=
{
'
flg_cal_data_status
'
:
status
,
'
cal_pipeline_reply
'
:
msg
}
'
cal_pipeline_reply
'
:
msg
}
if
status
!=
'
R
'
:
if
status
!=
'
R
'
:
...
@@ -293,6 +297,7 @@ class JobsMonitor:
...
@@ -293,6 +297,7 @@ class JobsMonitor:
log
.
error
(
Errors
.
MDC_RESPONSE
.
format
(
response
))
log
.
error
(
Errors
.
MDC_RESPONSE
.
format
(
response
))
def
mymdc_update_dark
(
self
,
dark_run_id
,
msg
,
status
=
'
IP
'
):
def
mymdc_update_dark
(
self
,
dark_run_id
,
msg
,
status
=
'
IP
'
):
"""
Update dark run status in MyMdC
"""
data
=
{
'
dark_run
'
:
{
'
flg_status
'
:
status
,
data
=
{
'
dark_run
'
:
{
'
flg_status
'
:
status
,
'
calcat_feedback
'
:
msg
}}
'
calcat_feedback
'
:
msg
}}
response
=
self
.
mdc
.
update_dark_run_api
(
dark_run_id
,
data
)
response
=
self
.
mdc
.
update_dark_run_api
(
dark_run_id
,
data
)
...
...
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