Skip to content
Snippets Groups Projects
Commit 777c5c55 authored by Cyril Danilevski's avatar Cyril Danilevski :scooter:
Browse files

Merge branch 'feat/mymdc_begin_end' into 'master'

[webservice] Update MyMDC with begin and end times

See merge request detectors/pycalibration!560
parents 34299b7b 04fac40f
No related branches found
No related tags found
1 merge request!560[webservice] Update MyMDC with begin and end times
......@@ -15,11 +15,11 @@ import sys
import time
import urllib.parse
from asyncio import get_event_loop, shield
from datetime import datetime
from datetime import datetime, timezone
from pathlib import Path
from subprocess import PIPE, run
from threading import Thread
from typing import Any, Dict, List, Optional
from typing import Any, Dict, List, Optional, Tuple
import yaml
import zmq
......@@ -237,7 +237,7 @@ 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]) -> (int, bytes):
async def run_proc_async(cmd: List[str]) -> Tuple[int, bytes]:
"""Run a subprocess to completion using asyncio, capturing stdout
Returns the numeric exit code and stdout (bytes)
......@@ -427,6 +427,10 @@ def update_job_db(config):
except KafkaError:
logging.warning("Error sending Kafka notification",
exc_info=True)
mdc.update_run_api(
rid, # The result from MyMDC does not matter here.
{'cal_last_end_at': datetime.now(tz=timezone.utc).isoformat()}
)
msg = "\n".join(statii)
msg_debug = f"Update MDC {rid}, {msg}"
logging.debug(msg_debug.replace('\n', ', '))
......@@ -928,6 +932,11 @@ class ActionsServer:
request_time,
)
await update_mdc_status(self.mdc, 'correct', rid, ret)
loop = get_event_loop()
await loop.run_in_executor(
None, self.mdc.update_run_api,
rid, {'cal_last_begin_at': datetime.now(tz=timezone.utc).isoformat()}
)
# END of part to run after sending reply
asyncio.ensure_future(_continue())
......@@ -1133,7 +1142,7 @@ class ActionsServer:
async def launch_jobs(
self, run_nrs, rid, detectors, action, instrument, cycle, proposal,
request_time
) -> (str, List[str]):
) -> Tuple[str, List[str]]:
report = []
ret = []
# run xfel_calibrate
......
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