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
9c4e3a9f
Commit
9c4e3a9f
authored
1 year ago
by
Thomas Kluyver
Browse files
Options
Downloads
Patches
Plain Diff
Fix checking Slurm job states
parent
45acad28
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!875
Use status AW in myMdC if correction failed for some detectors in a run
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
webservice/job_monitor.py
+9
-4
9 additions, 4 deletions
webservice/job_monitor.py
with
9 additions
and
4 deletions
webservice/job_monitor.py
+
9
−
4
View file @
9c4e3a9f
...
...
@@ -27,6 +27,10 @@ STATES_FINISHED = { # https://slurm.schedmd.com/squeue.html#lbAG
'
BOOT_FAIL
'
,
'
CANCELLED
'
,
'
COMPLETED
'
,
'
DEADLINE
'
,
'
FAILED
'
,
'
OUT_OF_MEMORY
'
,
'
SPECIAL_EXIT
'
,
'
TIMEOUT
'
,
}
STATE_ABBREVS
=
{
'
PENDING
'
:
'
PD
'
,
'
RUNNING
'
:
'
R
'
,
}
class
NoOpProducer
:
...
...
@@ -55,7 +59,7 @@ def slurm_status(filter_user=True):
:return: a dictionary indexed by slurm jobid and containing a tuple
of (status, run time) as values.
"""
cmd
=
[
"
squeue
"
,
"
--states=all
"
]
cmd
=
[
"
squeue
"
,
"
--states=all
"
,
"
--format=%i %T %M
"
]
if
filter_user
:
cmd
+=
[
"
--me
"
]
res
=
run
(
cmd
,
stdout
=
PIPE
,
stderr
=
PIPE
)
...
...
@@ -64,7 +68,7 @@ def slurm_status(filter_user=True):
statii
=
{}
for
r
in
rlines
[
1
:]:
try
:
jobid
,
_
,
_
,
_
,
status
,
runtime
,
_
,
_
=
r
.
split
()
jobid
,
status
,
runtime
=
r
.
split
()
jobid
=
jobid
.
strip
()
statii
[
jobid
]
=
status
,
runtime
except
ValueError
:
# not enough values to unpack in split
...
...
@@ -179,13 +183,14 @@ class JobsMonitor:
if
str
(
r
[
'
job_id
'
])
in
statii
:
# statii contains jobs which are still going (from squeue)
slstatus
,
runtime
=
statii
[
str
(
r
[
'
job_id
'
])]
execn_ongoing_jobs
.
append
(
f
"
{
slstatus
}
-
{
runtime
}
"
)
else
:
# These jobs have finished (successfully or otherwise)
_
,
runtime
,
slstatus
=
slurm_job_status
(
r
[
'
job_id
'
])
finished
=
slstatus
in
STATES_FINISHED
if
not
finished
:
short_state
=
STATE_ABBREVS
.
get
(
slstatus
,
slstatus
)
execn_ongoing_jobs
.
append
(
f
"
{
short_state
}
-
{
runtime
}
"
)
updates
.
append
((
finished
,
runtime
,
slstatus
,
r
[
'
job_id
'
]))
...
...
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