diff --git a/webservice/webservice.py b/webservice/webservice.py index d1d5eb98afdac1d1be92c58adc53b632f19eb925..0968f202c619b5a2a03bc78ba855a49b5d27e5bc 100644 --- a/webservice/webservice.py +++ b/webservice/webservice.py @@ -355,9 +355,10 @@ async def copy_untouched_files(file_list, out_folder, run): logging.info("Copying {} to {}".format(f, of)) -async def run_correction(conn, cmd, mode, proposal, run, rid): - """ Run a correction command +async def run_action(job_db, cmd, mode, proposal, run, rid): + """ 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 mode: "prod" or "sim", in the latter case nothing will be executed but the command will be logged @@ -377,8 +378,9 @@ async def run_correction(conn, cmd, mode, proposal, run, rid): else: logging.info(Success.START_CORRECTION.format(proposal, run)) # enter jobs in job db - c = conn.cursor() + c = job_db.cursor() rstr = ret.stdout.decode() + query = "INSERT INTO jobs VALUES ('{rid}', '{jobid}', '{proposal}', '{run}', 'PD', '{now}', '{det}', '{act}')" # noqa for r in rstr.split("\n"): if "Submitted job:" in r: @@ -387,7 +389,7 @@ async def run_correction(conn, cmd, mode, proposal, run, rid): proposal=proposal, run=run, now=datetime.now().isoformat(), det=cmd[3], act=cmd[4])) - conn.commit() + job_db.commit() logging.debug(" ".join(cmd)) if "DARK" in cmd: return Success.START_CHAR.format(proposal, run) @@ -687,7 +689,7 @@ async def server_runner(config, mode): "EPIX", "EPIX10K"]: priority = '0' cmd = ["python", "-m", "xfel_calibrate.calibrate", - detector, "DARK", '--priority', priority] + detector, "DARK", '--priority', priority, '--slurm-priority', '10'] # Avoid giving a reservation parameter after the # ITDM changes for giving xcal high priority by default @@ -705,7 +707,7 @@ async def server_runner(config, mode): 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) status.append(ret) @@ -755,13 +757,13 @@ async def server_runner(config, mode): if "-" in detector: detector, _ = detector.split("-") cmd = ["python", "-m", "xfel_calibrate.calibrate", - detector, "CORRECT"] + detector, "CORRECT", '--slurm-priority', '100'] cmd = await parse_config(cmd, dconfig) if 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) status.append(ret)