2727import murfey .server .prometheus as prom
2828from murfey .server import _transport_object
2929from murfey .server .api .auth import MurfeySessionID , validate_instrument_token
30- from murfey .server .api .spa import _cryolo_model_path
3130from murfey .server .feedback import (
3231 _murfey_id ,
3332 check_tilt_series_mc ,
5857 TiltSeries ,
5958)
6059from murfey .util .models import ProcessingParametersSPA , ProcessingParametersTomo
61- from murfey .util .processing_params import default_spa_parameters
60+ from murfey .util .processing_params import (
61+ cryolo_model_path ,
62+ default_spa_parameters ,
63+ motion_corrected_mrc ,
64+ )
6265from murfey .util .tomo import midpoint
6366
6467logger = getLogger ("murfey.server.api.workflow" )
@@ -365,29 +368,7 @@ async def request_spa_preprocessing(
365368 machine_config = get_machine_config (instrument_name = instrument_name )[
366369 instrument_name
367370 ]
368- parts = [secure_filename (p ) for p in Path (proc_file .path ).parts ]
369- visit_idx = parts .index (visit_name )
370- core = Path ("/" ) / Path (* parts [: visit_idx + 1 ])
371- ppath = Path ("/" ) / Path (* parts )
372- sub_dataset = ppath .relative_to (core ).parts [0 ]
373- extra_path = machine_config .processed_extra_directory
374- for i , p in enumerate (ppath .parts ):
375- if p .startswith ("raw" ):
376- movies_path_index = i
377- break
378- else :
379- raise ValueError (f"{ proc_file .path } does not contain a raw directory" )
380- mrc_out = (
381- core
382- / machine_config .processed_directory_name
383- / sub_dataset
384- / extra_path
385- / "MotionCorr"
386- / "job002"
387- / "Movies"
388- / "/" .join (ppath .parts [movies_path_index + 1 : - 1 ])
389- / str (ppath .stem + "_motion_corrected.mrc" )
390- )
371+ mrc_out = motion_corrected_mrc (Path (proc_file .path ), visit_name , machine_config )
391372 try :
392373 collected_ids = db .exec (
393374 select (DataCollectionGroup , DataCollection , ProcessingJob , AutoProcProgram )
@@ -479,7 +460,7 @@ async def request_spa_preprocessing(
479460 ),
480461 "do_icebreaker_jobs" : default_spa_parameters .do_icebreaker_jobs ,
481462 "cryolo_model_weights" : str (
482- _cryolo_model_path (visit_name , instrument_name )
463+ cryolo_model_path (visit_name , instrument_name )
483464 ),
484465 },
485466 }
@@ -491,7 +472,8 @@ async def request_spa_preprocessing(
491472 _transport_object .send ("processing_recipe" , zocalo_message )
492473 else :
493474 logger .error (
494- f"Pe-processing was requested for { sanitise (ppath .name )} but no Zocalo transport object was found"
475+ f"Pre-processing was requested for { sanitise (Path (proc_file .path ).name )} "
476+ "but no Zocalo transport object was found"
495477 )
496478 return proc_file
497479
@@ -646,22 +628,7 @@ async def request_tomography_preprocessing(
646628 machine_config = get_machine_config (instrument_name = instrument_name )[
647629 instrument_name
648630 ]
649- visit_idx = Path (proc_file .path ).parts .index (visit_name )
650- core = Path (* Path (proc_file .path ).parts [: visit_idx + 1 ])
651- ppath = Path ("/" .join (secure_filename (p ) for p in Path (proc_file .path ).parts ))
652- sub_dataset = "/" .join (ppath .relative_to (core ).parts [:- 1 ])
653- extra_path = machine_config .processed_extra_directory
654- mrc_out = (
655- core
656- / machine_config .processed_directory_name
657- / sub_dataset
658- / extra_path
659- / "MotionCorr"
660- / "job002"
661- / "Movies"
662- / str (ppath .stem + "_motion_corrected.mrc" )
663- )
664- mrc_out = Path ("/" .join (secure_filename (p ) for p in mrc_out .parts ))
631+ mrc_out = motion_corrected_mrc (Path (proc_file .path ), visit_name , machine_config )
665632
666633 recipe_name = machine_config .recipes .get ("em-tomo-preprocess" , "em-tomo-preprocess" )
667634
@@ -732,7 +699,8 @@ async def request_tomography_preprocessing(
732699 _transport_object .send ("processing_recipe" , zocalo_message )
733700 else :
734701 logger .error (
735- f"Pe-processing was requested for { sanitise (ppath .name )} but no Zocalo transport object was found"
702+ f"Pre-processing was requested for { sanitise (Path (proc_file .path ).name )} "
703+ f"but no Zocalo transport object was found"
736704 )
737705 return proc_file
738706 else :
0 commit comments