added has_data method
This commit is contained in:
@@ -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
@@ -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}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user