aaredb.py: refactored send_sample_event to use sample_id and not s
This commit is contained in:
+10
-15
@@ -22,6 +22,7 @@ from aareDB import (
|
||||
Detector as DetectorParameters,
|
||||
BeamlineParametersInput,
|
||||
ExperimentParametersCreate)
|
||||
from pydantic import StrictInt
|
||||
|
||||
from aare.common.coordinate import Coordinate
|
||||
from aare.common.logger_config import setup_logger
|
||||
@@ -110,26 +111,20 @@ class AareWrapper:
|
||||
@log_timing(logger, "AareDB call")
|
||||
def send_sample_event(
|
||||
self,
|
||||
s: Optional[SampleShortInfo],
|
||||
sample_id: StrictInt,
|
||||
event_type: SampleEventType,
|
||||
comment: Optional[str] = None,
|
||||
) -> None:
|
||||
if s is None:
|
||||
logger.debug("Sample info is None, skipping sample event")
|
||||
return
|
||||
if s.db_id is None or s.db_id < 0:
|
||||
logger.debug(
|
||||
f"Sample db_id is invalid ({s.db_id}), skipping sample event {event_type!s}"
|
||||
)
|
||||
if sample_id is None or sample_id < 0:
|
||||
if sample_id is None:
|
||||
logger.debug(f"Sample db_id is None, skipping sample event {event_type!s}")
|
||||
elif sample_id < 0:
|
||||
logger.debug(
|
||||
f"Sample db_id is invalid ({sample_id}), skipping sample event {event_type!s}"
|
||||
)
|
||||
return
|
||||
try:
|
||||
self.__sample_api.create_sample_event(
|
||||
sample_id=s.db_id,
|
||||
sample_event_create=SampleEventCreate(
|
||||
event_type=event_type,
|
||||
comment=comment,
|
||||
),
|
||||
)
|
||||
self.__sample_api.create_sample_event(sample_id=sample_id, sample_event_create=SampleEventCreate(event_type=event_type, comment=comment))
|
||||
except Exception as e:
|
||||
logger.error(f"Error sending sample event {event_type!s} to db: {e}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user