added has_data method

This commit is contained in:
2026-06-03 10:56:52 +02:00
parent e10897f5dc
commit 6ae8a4a7eb
2 changed files with 8 additions and 5 deletions
+7
View File
@@ -38,4 +38,11 @@ class ArcticLibrary:
return df
def has_data(self, *args, **kwargs):
try:
return not self.lib.read(*args, columns=[], **kwargs).data.index.empty
except adb.exceptions.NoSuchVersionException:
return False
+1 -5
View File
@@ -25,11 +25,7 @@ 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")
try:
run_exists = not lib.read(pgroup, date_range=index, columns=[]).data.index.empty
except adb.exceptions.NoSuchVersionException:
run_exists = False
run_exists = lib.has_data(pgroup, date_range=index)
if run_exists:
raise HTTPException(HTTPStatus.CONFLICT, f"run {run} exists already in {beamline}/{pgroup}")