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:
1 parent
59539f80d4
commit
a3cc9f29a7
2 files changed
+40
-3
No files matched your search
@@ -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