From c6c84f5093def5670fa6e4478dec4c7c5c0fdb26 Mon Sep 17 00:00:00 2001 From: Olivier Richard Date: Mon, 9 Sep 2024 21:59:03 +0200 Subject: [PATCH] [lib/job_handling] fix filter ...in_ stmt --- oar/lib/job_handling.py | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/oar/lib/job_handling.py b/oar/lib/job_handling.py index 6fe1ebc8..e09968d7 100644 --- a/oar/lib/job_handling.py +++ b/oar/lib/job_handling.py @@ -738,7 +738,25 @@ def get_current_jobs_dependencies(session, jobs): def get_current_not_waiting_jobs( session, ): - jobs = session.query(Job).filter(Job.state in ('Hold','toLaunch','toError','toAckReservation','Launching','Running','Suspended','Resuming','Finishing')).all() + jobs = ( + session.query(Job) + .filter( + Job.state.in_( + ( + "Hold", + "toLaunch", + "toError", + "toAckReservation", + "Launching", + "Running", + "Suspended", + "Resuming", + "Finishing", + ) + ) + ) + .all() + ) jobs_by_state = {} for job in jobs: if job.state not in jobs_by_state: @@ -1976,6 +1994,7 @@ def get_job_cpuset_name(session, job_id, job=None): return user + "_" + str(job_id) + def convert_status_code(code): if code is None: return None @@ -1983,11 +2002,12 @@ def convert_status_code(code): exit_value = code >> 8 exit_kill = code & 127 - if exit_value != 0 : + if exit_value != 0: return exit_value - else : + else: return exit_kill + def get_job_exit_status_code(session, job_id, job=None): """Get the converted exit code for the given job""" if job is None: @@ -1998,6 +2018,7 @@ def get_job_exit_status_code(session, job_id, job=None): return convert_status_code(code) + def job_fragged(session, job_id): """Set the flag 'ToFrag' of a job to 'No'""" session.query(FragJob).filter(FragJob.job_id == job_id).update(