a bit simpler
This commit is contained in:
+3
-7
@@ -20,18 +20,14 @@ def append(beamline: Beamline, pgroup: PGroup, run: int, row: dict[str, Any]):
|
||||
index = pd.Timestamp(run) # adb supports update only for timeseries indexes
|
||||
index = pd.Index([index], name="run")
|
||||
|
||||
run_exists = not adb.get(beamline).read(
|
||||
pgroup,
|
||||
date_range=index,
|
||||
columns=[]
|
||||
).data.index.empty
|
||||
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}")
|
||||
|
||||
df = pd.DataFrame(row, index=index)
|
||||
|
||||
adb.get(beamline).append(pgroup, df)
|
||||
lib.append(pgroup, df)
|
||||
|
||||
row = {"run": run, **row} # setdefault would not force run to be the first column
|
||||
|
||||
|
||||
Reference in New Issue
Block a user