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
cb8c5d80
Commit
cb8c5d80
authored
1 year ago
by
Thomas Kluyver
Browse files
Options
Downloads
Patches
Plain Diff
Check for unfinished corrections before launching a new one
parent
d3932bb4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!836
[Webservice] Check for unfinished corrections before launching a new one
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
webservice/messages.py
+1
-0
1 addition, 0 deletions
webservice/messages.py
webservice/webservice.py
+23
-0
23 additions, 0 deletions
webservice/webservice.py
with
24 additions
and
0 deletions
webservice/messages.py
+
1
−
0
View file @
cb8c5d80
...
@@ -43,3 +43,4 @@ class Success:
...
@@ -43,3 +43,4 @@ class Success:
REPROD_QUEUED
=
"
SUCCESS: Queued proposal {}, run {} for reproducing previous offline calibration
"
REPROD_QUEUED
=
"
SUCCESS: Queued proposal {}, run {} for reproducing previous offline calibration
"
DONE_CORRECTION
=
"
SUCCESS: Finished correction: proposal {}. run {}
"
DONE_CORRECTION
=
"
SUCCESS: Finished correction: proposal {}. run {}
"
DONE_CHAR
=
"
SUCCESS: Finished dark characterization: proposal {}, run {}
"
DONE_CHAR
=
"
SUCCESS: Finished dark characterization: proposal {}, run {}
"
ALREADY_REQUESTED
=
"
SUCCESS: Correction already queued/running for proposal {}, run {}
"
This diff is collapsed.
Click to expand it.
webservice/webservice.py
+
23
−
0
View file @
cb8c5d80
...
@@ -62,6 +62,7 @@ def init_job_db(config):
...
@@ -62,6 +62,7 @@ def init_job_db(config):
action,
action,
timestamp
timestamp
);
);
CREATE INDEX IF NOT EXISTS req_by_run ON requests(proposal, run, action);
CREATE TABLE IF NOT EXISTS executions(
CREATE TABLE IF NOT EXISTS executions(
exec_id INTEGER PRIMARY KEY,
exec_id INTEGER PRIMARY KEY,
req_id REFERENCES requests(req_id),
req_id REFERENCES requests(req_id),
...
@@ -962,6 +963,12 @@ class ActionsServer:
...
@@ -962,6 +963,12 @@ class ActionsServer:
proposal
=
self
.
_normalise_proposal_num
(
proposal
)
proposal
=
self
.
_normalise_proposal_num
(
proposal
)
pconf_full
=
self
.
load_proposal_config
(
cycle
,
proposal
)
pconf_full
=
self
.
load_proposal_config
(
cycle
,
proposal
)
if
self
.
check_unfinished_correction
(
proposal
,
int
(
runnr
)):
# A correction is already running for this run
msg
=
Success
.
ALREADY_REQUESTED
.
format
(
proposal
,
runnr
)
logging
.
debug
(
msg
)
return
msg
with
time_db_transaction
(
self
.
job_db
,
'
Insert request
'
):
with
time_db_transaction
(
self
.
job_db
,
'
Insert request
'
):
cur
=
self
.
job_db
.
execute
(
# 2
cur
=
self
.
job_db
.
execute
(
# 2
"
INSERT INTO requests VALUES (NULL, ?, ?, ?,
'
CORRECT
'
, ?)
"
,
"
INSERT INTO requests VALUES (NULL, ?, ?, ?,
'
CORRECT
'
, ?)
"
,
...
@@ -1082,6 +1089,12 @@ class ActionsServer:
...
@@ -1082,6 +1089,12 @@ class ActionsServer:
request_time
=
datetime
.
now
()
request_time
=
datetime
.
now
()
try
:
try
:
if
self
.
check_unfinished_correction
(
proposal
,
int
(
runnr
)):
# A correction is already running for this run
msg
=
Success
.
ALREADY_REQUESTED
.
format
(
proposal
,
runnr
)
logging
.
debug
(
msg
)
return
msg
with
time_db_transaction
(
self
.
job_db
,
'
Insert request
'
):
with
time_db_transaction
(
self
.
job_db
,
'
Insert request
'
):
cur
=
self
.
job_db
.
execute
(
cur
=
self
.
job_db
.
execute
(
"
INSERT INTO requests VALUES (NULL, ?, ?, ?,
'
CORRECT
'
, ?)
"
,
"
INSERT INTO requests VALUES (NULL, ?, ?, ?,
'
CORRECT
'
, ?)
"
,
...
@@ -1368,6 +1381,16 @@ class ActionsServer:
...
@@ -1368,6 +1381,16 @@ class ActionsServer:
# Helper methods for handlers ---------------------------------------------
# Helper methods for handlers ---------------------------------------------
def
check_unfinished_correction
(
self
,
proposal
:
str
,
runnr
:
int
):
row
=
self
.
job_db
.
execute
(
"
SELECT job_id FROM slurm_jobs
"
"
INNER JOIN executions USING (exec_id)
"
"
INNER JOIN requests USING (req_id)
"
"
WHERE proposal = ? AND run = ? AND action =
'
CORRECT
'
"
"
AND slurm_jobs.finished = 0
"
,
(
proposal
,
runnr
)
)
return
row
is
not
None
@staticmethod
@staticmethod
def
_normalise_proposal_num
(
p
:
str
)
->
str
:
def
_normalise_proposal_num
(
p
:
str
)
->
str
:
return
"
{:06d}
"
.
format
(
int
(
p
.
strip
(
'
p
'
)))
return
"
{:06d}
"
.
format
(
int
(
p
.
strip
(
'
p
'
)))
...
...
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