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
2cca9c52eb
commit
5024963eba
1 file changed
+16
-11
+16
-11
@@ -68,12 +68,11 @@ class AareWrapper:
|
||||
print(ret)
|
||||
|
||||
def create_manual_sample(
|
||||
self,
|
||||
s: SampleShortInfo,
|
||||
p: SessionStatus,
|
||||
cellparameters: Optional[str] = None,
|
||||
spacegroupnumber: Optional[int] = None,
|
||||
|
||||
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.
|
||||
@@ -81,19 +80,25 @@ class AareWrapper:
|
||||
Args:
|
||||
s (SampleShortInfo): The sample info object to extract data from.
|
||||
p (SessionStatus): The session status object to extract data from.
|
||||
cellparameters (Optional[str]): Unit cell parameters as a string.
|
||||
spacegroupnumber (Optional[int]): Space group number.
|
||||
|
||||
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
|
||||
)
|
||||
|
||||
data_collection_parameters = None
|
||||
if cellparameters is not None and spacegroupnumber is not None:
|
||||
data_collection_parameters = DataCollectionParameters(
|
||||
cellparameters=cellparameters,
|
||||
spacegroupnumber=spacegroupnumber
|
||||
)
|
||||
|
||||
manual_sample = ManualSampleCreate(
|
||||
pgroup=p.current_pgroup,
|
||||
sample_name=s.sample_name,
|
||||
data_collection_parameters=data_collection_parameters,
|
||||
data_collection_parameters=data_collection_parameters
|
||||
)
|
||||
|
||||
try:
|
||||
|
||||
Reference in new issue
Block a user