re-ordered

This commit is contained in:
2026-05-29 18:10:36 +02:00
parent 9a9360cbdb
commit 40e933de23
+5 -5
View File
@@ -13,19 +13,19 @@ router = APIRouter()
@router.post("/tables/{pgroup}/append")
def append(beamline: Beamline, pgroup: PGroup, run: int, row: dict[str, Any]):
timestamp = row.pop("timestamp", None)
timestamp = datetime.fromisoformat(timestamp) if timestamp else datetime.now()
row = {"timestamp": timestamp, **row} # setdefault would not force timestamp to be the first column
lib = adb.get(beamline)
index = pd.Timestamp(run) # adb supports update only for timeseries indexes
index = pd.Index([index], name="run")
lib = adb.get(beamline)
run_exists = not lib.read(pgroup, date_range=index, columns=[]).data.index.empty
if run_exists:
raise HTTPException(409, f"run {run} exists already in {beamline}/{pgroup}")
timestamp = row.pop("timestamp", None)
timestamp = datetime.fromisoformat(timestamp) if timestamp else datetime.now()
row = {"timestamp": timestamp, **row} # setdefault would not force timestamp to be the first column
df = pd.DataFrame(row, index=index)
lib.append(pgroup, df)