Add method to insert manual samples into the database
Introduce `create_manual_sample` method to handle the creation of manual samples using `SampleShortInfo`. This includes optional handling of data collection parameters and integrates with the existing API for database insertion.
This commit is contained in:
+2
-2
@@ -13,12 +13,12 @@ dependencies = [
|
||||
"fastapi==0.115.12",
|
||||
"uvicorn==0.34.2",
|
||||
"ultralytics==8.3.133",
|
||||
"aaredb==0.1.1a9",
|
||||
"aaredb==0.1.1a11",
|
||||
"opencv-python-headless==4.11.0.86",
|
||||
"python_multipart==0.0.20",
|
||||
"websocket-client",
|
||||
"sseclient-py>=1.8.0",
|
||||
"aaredaqlib==0.2.0"
|
||||
#"aaredaqlib==0.2.0",
|
||||
]
|
||||
|
||||
[lint]
|
||||
|
||||
@@ -25,7 +25,7 @@ from aaredaqlib.models import (
|
||||
PuckLoadedInfo,
|
||||
DewarAddress,
|
||||
SampleShortInfoList,
|
||||
DAQStatusModel,
|
||||
DAQStatusModel, SessionStatus,
|
||||
)
|
||||
|
||||
from aaredaqlib.beamline import MXBeamline
|
||||
@@ -67,6 +67,43 @@ class AareWrapper:
|
||||
)
|
||||
print(ret)
|
||||
|
||||
def create_manual_sample(
|
||||
self,
|
||||
s: SampleShortInfo,
|
||||
p: SessionStatus,
|
||||
cellparameters: Optional[str] = None,
|
||||
spacegroupnumber: Optional[int] = None,
|
||||
|
||||
) -> Optional[object]:
|
||||
"""
|
||||
Insert a new manual sample into the database using a SampleShortInfo object.
|
||||
|
||||
Args:
|
||||
s (SampleShortInfo): The sample info object to extract data from.
|
||||
p (SessionStatus): The session status object to extract data from.
|
||||
|
||||
Returns:
|
||||
API response object or None if there was an error.
|
||||
"""
|
||||
from aareDBclient.models import ManualSampleCreate, DataCollectionParameters
|
||||
data_collection_parameters = DataCollectionParameters(
|
||||
cellparameters="76.79, 76.79, 37.8, 90.0, 90.0, 90.0",
|
||||
spacegroupnumber=96
|
||||
)
|
||||
manual_sample = ManualSampleCreate(
|
||||
pgroup=p.current_pgroup,
|
||||
sample_name=s.sample_name,
|
||||
data_collection_parameters=data_collection_parameters,
|
||||
)
|
||||
|
||||
try:
|
||||
result = self.__sample_api.insert_sample(manual_sample)
|
||||
print(f"Sample created: {result}")
|
||||
return result
|
||||
except Exception as e:
|
||||
print(f"Error inserting sample: {e}")
|
||||
return None
|
||||
|
||||
def sample_mounted(self, s: Optional[SampleShortInfo]):
|
||||
if s is not None:
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user