From f56e77e9f4b000dfc5816beea64a849496816a1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20S=C3=A1nchez-Gallego?= Date: Tue, 17 Sep 2024 06:01:31 +0000 Subject: [PATCH] Add /spectrographs/fills/running endpoint --- src/lvmapi/routers/spectrographs.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/lvmapi/routers/spectrographs.py b/src/lvmapi/routers/spectrographs.py index b79999a..06a592a 100644 --- a/src/lvmapi/routers/spectrographs.py +++ b/src/lvmapi/routers/spectrographs.py @@ -9,6 +9,7 @@ from __future__ import annotations import datetime +import pathlib import re import warnings @@ -271,8 +272,18 @@ async def route_get_cryostats(): ) +@router.get("/fills/running", summary="Is a fill currently running?") +async def route_get_fills_running() -> bool: + """Returns whether an LN2 fill is currently running.""" + + return pathlib.Path("/data/lvmcryo.lock").exists() + + @router.get("/fills/measurements", summary="Cryostat fill measurements") -async def route_get_fill_data(start_time: int, end_time: int) -> list[FillDataModel]: +async def route_get_fills_measurements( + start_time: int, + end_time: int, +) -> list[FillDataModel]: """Returns cryostat fill measurements.""" if start_time < 0 or end_time < 0 or start_time > end_time: @@ -285,7 +296,7 @@ async def route_get_fill_data(start_time: int, end_time: int) -> list[FillDataMo @router.post("/fills/register", summary="Register an LN2 fill") -async def route_post_register_fill(data: RegisterFillPostModel) -> int: +async def route_post_fills_register(data: RegisterFillPostModel) -> int: """Registers an LN2 fill.""" try: