Skip to content
Snippets Groups Projects
Commit 5c496d77 authored by Karim Ahmed's avatar Karim Ahmed
Browse files

give higher niceness priority to DARKs

parent 12e7bdb8
No related branches found
No related tags found
1 merge request!228Feat/batch prioritization darks
...@@ -355,9 +355,10 @@ async def copy_untouched_files(file_list, out_folder, run): ...@@ -355,9 +355,10 @@ async def copy_untouched_files(file_list, out_folder, run):
logging.info("Copying {} to {}".format(f, of)) logging.info("Copying {} to {}".format(f, of))
async def run_correction(conn, cmd, mode, proposal, run, rid): async def run_action(job_db, cmd, mode, proposal, run, rid):
""" Run a correction command """ Run action command (CORRECT OR DARK)
:param job_db: jobs database
:param cmd: to run, should be a in list for as expected by subprocess.run :param cmd: to run, should be a in list for as expected by subprocess.run
:param mode: "prod" or "sim", in the latter case nothing will be executed :param mode: "prod" or "sim", in the latter case nothing will be executed
but the command will be logged but the command will be logged
...@@ -377,8 +378,9 @@ async def run_correction(conn, cmd, mode, proposal, run, rid): ...@@ -377,8 +378,9 @@ async def run_correction(conn, cmd, mode, proposal, run, rid):
else: else:
logging.info(Success.START_CORRECTION.format(proposal, run)) logging.info(Success.START_CORRECTION.format(proposal, run))
# enter jobs in job db # enter jobs in job db
c = conn.cursor() c = job_db.cursor()
rstr = ret.stdout.decode() rstr = ret.stdout.decode()
query = "INSERT INTO jobs VALUES ('{rid}', '{jobid}', '{proposal}', '{run}', 'PD', '{now}', '{det}', '{act}')" # noqa query = "INSERT INTO jobs VALUES ('{rid}', '{jobid}', '{proposal}', '{run}', 'PD', '{now}', '{det}', '{act}')" # noqa
for r in rstr.split("\n"): for r in rstr.split("\n"):
if "Submitted job:" in r: if "Submitted job:" in r:
...@@ -387,7 +389,7 @@ async def run_correction(conn, cmd, mode, proposal, run, rid): ...@@ -387,7 +389,7 @@ async def run_correction(conn, cmd, mode, proposal, run, rid):
proposal=proposal, run=run, proposal=proposal, run=run,
now=datetime.now().isoformat(), now=datetime.now().isoformat(),
det=cmd[3], act=cmd[4])) det=cmd[3], act=cmd[4]))
conn.commit() job_db.commit()
logging.debug(" ".join(cmd)) logging.debug(" ".join(cmd))
if "DARK" in cmd: if "DARK" in cmd:
return Success.START_CHAR.format(proposal, run) return Success.START_CHAR.format(proposal, run)
...@@ -687,7 +689,7 @@ async def server_runner(config, mode): ...@@ -687,7 +689,7 @@ async def server_runner(config, mode):
"EPIX", "EPIX10K"]: "EPIX", "EPIX10K"]:
priority = '0' priority = '0'
cmd = ["python", "-m", "xfel_calibrate.calibrate", cmd = ["python", "-m", "xfel_calibrate.calibrate",
detector, "DARK", '--priority', priority] detector, "DARK", '--priority', priority, '--slurm-priority', '10']
# Avoid giving a reservation parameter after the # Avoid giving a reservation parameter after the
# ITDM changes for giving xcal high priority by default # ITDM changes for giving xcal high priority by default
...@@ -705,7 +707,7 @@ async def server_runner(config, mode): ...@@ -705,7 +707,7 @@ async def server_runner(config, mode):
cmd = await parse_config(cmd, dconfig) cmd = await parse_config(cmd, dconfig)
ret = await run_correction(job_db, cmd, mode, proposal, ret = await run_action(job_db, cmd, mode, proposal,
wait_runs[0], 0) wait_runs[0], 0)
status.append(ret) status.append(ret)
...@@ -755,13 +757,13 @@ async def server_runner(config, mode): ...@@ -755,13 +757,13 @@ async def server_runner(config, mode):
if "-" in detector: if "-" in detector:
detector, _ = detector.split("-") detector, _ = detector.split("-")
cmd = ["python", "-m", "xfel_calibrate.calibrate", cmd = ["python", "-m", "xfel_calibrate.calibrate",
detector, "CORRECT"] detector, "CORRECT", '--slurm-priority', '100']
cmd = await parse_config(cmd, dconfig) cmd = await parse_config(cmd, dconfig)
if priority: if priority:
cmd += ["--priority", str(priority)] cmd += ["--priority", str(priority)]
ret = await run_correction(job_db, cmd, mode, proposal, ret = await run_action(job_db, cmd, mode, proposal,
runnr, rid) runnr, rid)
status.append(ret) status.append(ret)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment