@@ -639,71 +639,60 @@ def process_raw_lifs(
639639 lif_file : Path ,
640640 db : Session = murfey_db ,
641641):
642- # Get command line entry point
643- murfey_workflows = entry_points ().select (
644- group = "murfey.workflows" , name = "process_raw_lifs"
645- )
646-
647- # Use entry point if found
648- if murfey_workflows :
649-
650- # Get instrument name from the database
651- # This is needed in order to load the correct config file
652- session_row : MurfeySession = db .exec (
653- select (MurfeySession ).where (MurfeySession .id == session_id )
654- ).one ()
655- instrument_name = session_row .instrument_name
656-
657- # Pass arguments along to the correct workflow
658- workflow : EntryPoint = list (murfey_workflows )[0 ]
659- workflow .load ()(
660- # Match the arguments found in murfey.workflows.process_raw_lifs
661- file = lif_file ,
662- root_folder = "images" ,
663- session_id = session_id ,
664- instrument_name = instrument_name ,
665- messenger = _transport_object ,
666- )
667- return True
668-
669- # Raise error if Murfey workflow not found
670- else :
642+ try :
643+ # Try and load relevant Murfey workflow
644+ workflow : EntryPoint = list (
645+ entry_points ().select (group = "murfey.workflows" , name = "process_raw_lifs" )
646+ )[0 ]
647+ except IndexError :
671648 raise RuntimeError ("The relevant Murfey workflow was not found" )
672649
650+ # Get instrument name from the database to load the correct config file
651+ session_row : MurfeySession = db .exec (
652+ select (MurfeySession ).where (MurfeySession .id == session_id )
653+ ).one ()
654+ instrument_name = session_row .instrument_name
655+
656+ # Pass arguments along to the correct workflow
657+ workflow .load ()(
658+ # Match the arguments found in murfey.workflows.clem.process_raw_lifs
659+ file = lif_file ,
660+ root_folder = "images" ,
661+ session_id = session_id ,
662+ instrument_name = instrument_name ,
663+ messenger = _transport_object ,
664+ )
665+ return True
666+
673667
674668@router .post ("/sessions/{session_id}/clem/preprocessing/process_raw_tiffs" )
675669def process_raw_tiffs (
676670 session_id : int , # Used by the decorator
677671 tiff_info : TIFFSeriesInfo ,
678672 db : Session = murfey_db ,
679673):
680- # Get command line entry point
681- murfey_workflows = entry_points ().select (
682- group = "murfey.workflows" , name = "process_raw_tiffs"
683- )
684-
685- # Use entry point if found
686- if murfey_workflows :
687-
688- # Load instrument name from database
689- session_row : MurfeySession = db .exec (
690- select (MurfeySession ).where (MurfeySession .id == session_id )
691- ).one ()
692- instrument_name = session_row .instrument_name
693-
694- # Pass arguments to correct workflow
695- workflow : EntryPoint = list (murfey_workflows )[0 ]
696- workflow .load ()(
697- # Match the arguments found in murfey.workflows.process_raw_tiffs
698- tiff_list = tiff_info .tiff_files ,
699- root_folder = "images" ,
700- session_id = session_id ,
701- instrument_name = instrument_name ,
702- metadata = tiff_info .series_metadata ,
703- messenger = _transport_object ,
704- )
705- return True
706-
707- # Raise error if Murfey workflow not found
708- else :
674+ try :
675+ # Try and load relevant Murfey workflow
676+ workflow : EntryPoint = list (
677+ entry_points ().select (group = "murfey.workflows" , name = "process_raw_tiffs" )
678+ )[0 ]
679+ except IndexError :
709680 raise RuntimeError ("The relevant Murfey workflow was not found" )
681+
682+ # Get instrument name from the database to load the correct config file
683+ session_row : MurfeySession = db .exec (
684+ select (MurfeySession ).where (MurfeySession .id == session_id )
685+ ).one ()
686+ instrument_name = session_row .instrument_name
687+
688+ # Pass arguments to correct workflow
689+ workflow .load ()(
690+ # Match the arguments found in murfey.workflows.clem.process_raw_tiffs
691+ tiff_list = tiff_info .tiff_files ,
692+ root_folder = "images" ,
693+ session_id = session_id ,
694+ instrument_name = instrument_name ,
695+ metadata = tiff_info .series_metadata ,
696+ messenger = _transport_object ,
697+ )
698+ return True
0 commit comments