Skip to content
Snippets Groups Projects
Verified Commit 9040acd1 authored by Robert Rosca's avatar Robert Rosca
Browse files

Improve xfel_calibrate process error logging

parent 11ff26ec
No related branches found
No related tags found
1 merge request!670Check for transfer conditional on resolved symlink path
This commit is part of merge request !646. Comments created here will be created in the context of that merge request.
......@@ -238,14 +238,16 @@ def change_config(config, updated_config, instrument,
return yaml.safe_dump(new_conf, default_flow_style=False).encode()
async def run_proc_async(cmd: List[str]) -> Tuple[int, bytes]:
async def run_proc_async(cmd: List[str]) -> Tuple[Optional[int], bytes, bytes]:
"""Run a subprocess to completion using asyncio, capturing stdout
Returns the numeric exit code and stdout (bytes)
"""
proc = await asyncio.create_subprocess_exec(*cmd, stdout=asyncio.subprocess.PIPE)
stdout, _ = await proc.communicate()
return proc.returncode, stdout
proc = await asyncio.create_subprocess_exec(
*cmd, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE
)
stdout, stderr = await proc.communicate()
return proc.returncode, stdout, stderr
def slurm_status(filter_user=True):
......@@ -479,9 +481,10 @@ async def run_action(job_db, cmd, mode, proposal, run, rid) -> str:
"""
if mode == "prod":
logging.info(" ".join(cmd))
retcode, stdout = await run_proc_async(cmd)
retcode, stdout, stderr = await run_proc_async(cmd)
if retcode != 0:
logging.error(Errors.JOB_LAUNCH_FAILED.format(cmd, retcode))
logging.error(f"{stdout=}, {stderr=}")
return Errors.JOB_LAUNCH_FAILED.format(cmd, retcode)
if "DARK" in cmd:
......@@ -741,12 +744,13 @@ async def get_slurm_nice(partition: str, instrument: str,
return 0 # Don't apply degressive priority on exfel.
# List all names for jobs running in the specified partition.
returncode, job_names = await run_proc_async(
returncode, job_names, stderr = await run_proc_async(
['squeue', '-h', '-o', '%.20j', '-p', partition, '--me'])
if returncode != 0:
logging.error(f'Non-zero return code {returncode} from '
f'`squeue` upon counting number of jobs')
logging.warning(f"{stderr=}")
return 0 # Fallback if something went wrong.
# Base value depending on proposal type using cycle, assuming that
......
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