1010from murfey .server import _murfey_id , _transport_object , sanitise
1111from murfey .server .api .auth import MurfeySessionID
1212from murfey .util .config import get_machine_config , get_microscope
13- from murfey .util .db import DataCollectionGroup , FoilHole , GridSquare
13+ from murfey .util .db import (
14+ AutoProcProgram ,
15+ DataCollection ,
16+ DataCollectionGroup ,
17+ FoilHole ,
18+ GridSquare ,
19+ Movie ,
20+ PreprocessStash ,
21+ ProcessingJob ,
22+ )
23+ from murfey .util .db import Session as MurfeySession
24+ from murfey .util .db import SPAFeedbackParameters , SPARelionParameters
1425from murfey .util .models import FoilHoleParameters , GridSquareParameters
1526from murfey .util .processing_params import default_spa_parameters
1627from murfey .util .spa_metadata import (
@@ -201,7 +212,7 @@ def _flush_position_analysis(
201212) -> Optional [int ]:
202213 """Register a grid square and foil hole in the database"""
203214 data_collection_group = db .exec (
204- select (db . DataCollectionGroup ).where (db . DataCollectionGroup .id == dcg_id )
215+ select (DataCollectionGroup ).where (DataCollectionGroup .id == dcg_id )
205216 ).one ()
206217
207218 # Work out the grid square and associated metadata file
@@ -283,14 +294,14 @@ def _flush_position_analysis(
283294def flush_spa_preprocess (message : dict , db : Session , demo : bool = False ):
284295 session_id = message ["session_id" ]
285296 stashed_files = db .exec (
286- select (db . PreprocessStash )
287- .where (db . PreprocessStash .session_id == session_id )
288- .where (db . PreprocessStash .tag == message ["tag" ])
297+ select (PreprocessStash )
298+ .where (PreprocessStash .session_id == session_id )
299+ .where (PreprocessStash .tag == message ["tag" ])
289300 ).all ()
290301 if not stashed_files :
291302 return None
292303 instrument_name = (
293- db .exec (select (db . Session ).where (db . Session .id == message ["session_id" ]))
304+ db .exec (select (MurfeySession ).where (MurfeySession .id == message ["session_id" ]))
294305 .one ()
295306 .instrument_name
296307 )
@@ -300,22 +311,22 @@ def flush_spa_preprocess(message: dict, db: Session, demo: bool = False):
300311 recipe_name = machine_config .recipes .get ("em-spa-preprocess" , "em-spa-preprocess" )
301312 collected_ids = db .exec (
302313 select (
303- db . DataCollectionGroup ,
304- db . DataCollection ,
305- db . ProcessingJob ,
306- db . AutoProcProgram ,
314+ DataCollectionGroup ,
315+ DataCollection ,
316+ ProcessingJob ,
317+ AutoProcProgram ,
307318 )
308- .where (db . DataCollectionGroup .session_id == session_id )
309- .where (db . DataCollectionGroup .tag == message ["tag" ])
310- .where (db . DataCollection .dcg_id == db . DataCollectionGroup .id )
311- .where (db . ProcessingJob .dc_id == db . DataCollection .id )
312- .where (db . AutoProcProgram .pj_id == db . ProcessingJob .id )
313- .where (db . ProcessingJob .recipe == recipe_name )
319+ .where (DataCollectionGroup .session_id == session_id )
320+ .where (DataCollectionGroup .tag == message ["tag" ])
321+ .where (DataCollection .dcg_id == DataCollectionGroup .id )
322+ .where (ProcessingJob .dc_id == DataCollection .id )
323+ .where (AutoProcProgram .pj_id == ProcessingJob .id )
324+ .where (ProcessingJob .recipe == recipe_name )
314325 ).one ()
315326 params = db .exec (
316- select (db . SPARelionParameters , db . SPAFeedbackParameters )
317- .where (db . SPARelionParameters .pj_id == collected_ids [2 ].id )
318- .where (db . SPAFeedbackParameters .pj_id == db . SPARelionParameters .pj_id )
327+ select (SPARelionParameters , SPAFeedbackParameters )
328+ .where (SPARelionParameters .pj_id == collected_ids [2 ].id )
329+ .where (SPAFeedbackParameters .pj_id == SPARelionParameters .pj_id )
319330 ).one ()
320331 proc_params = params [0 ]
321332 feedback_params = params [1 ]
@@ -360,7 +371,7 @@ def flush_spa_preprocess(message: dict, db: Session, demo: bool = False):
360371 ppath = Path (f .file_path )
361372 if not mrcp .parent .exists ():
362373 mrcp .parent .mkdir (parents = True )
363- movie = db . Movie (
374+ movie = Movie (
364375 murfey_id = murfey_ids [2 * i ],
365376 path = f .file_path ,
366377 image_number = f .image_number ,
0 commit comments