@@ -40,7 +40,6 @@ class MultigridController:
4040 finalising : bool = False
4141 dormant : bool = False
4242 multigrid_watcher_active : bool = True
43- processing_enabled : bool = True
4443 do_transfer : bool = True
4544 dummy_dc : bool = False
4645 force_mdoc_metadata : bool = True
@@ -86,8 +85,6 @@ def __post_init__(self):
8685 for ds in val .values ()
8786 for s in ds
8887 ]
89- self ._data_collection_form_complete = False
90- self ._register_dc : bool | None = None
9188 self .rsync_processes = self .rsync_processes or {}
9289 self .analysers = self .analysers or {}
9390
@@ -260,7 +257,6 @@ def _start_rsyncer_multigrid(
260257 self ._start_rsyncer (
261258 source ,
262259 destination ,
263- force_metadata = self .processing_enabled ,
264260 analyse = analyse ,
265261 remove_files = remove_files ,
266262 tag = tag ,
@@ -324,7 +320,6 @@ def _start_rsyncer(
324320 source : Path ,
325321 destination : str ,
326322 visit_path : str = "" ,
327- force_metadata : bool = False ,
328323 analyse : bool = True ,
329324 remove_files : bool = False ,
330325 tag : str = "" ,
@@ -455,12 +450,7 @@ def rsync_result(update: RSyncerUpdate):
455450 force_mdoc_metadata = self .force_mdoc_metadata ,
456451 limited = limited ,
457452 )
458- if force_metadata :
459- self .analysers [source ].subscribe (
460- partial (self ._start_dc , from_form = True )
461- )
462- else :
463- self .analysers [source ].subscribe (self ._data_collection_form )
453+ self .analysers [source ].subscribe (self ._start_dc )
464454 self .analysers [source ].start ()
465455 if transfer :
466456 self .rsync_processes [source ].subscribe (self .analysers [source ].enqueue )
@@ -502,32 +492,13 @@ def _rsync_update_converter(p: Path) -> None:
502492 )
503493 self ._environment .watchers [source ].start ()
504494
505- def _data_collection_form (self , response : dict ):
506- log .info ("data collection form ready" )
507- if self ._data_collection_form_complete :
508- return
509- if self ._register_dc and response .get ("form" ):
510- self ._form_values = {k : str (v ) for k , v in response .get ("form" , {}).items ()}
511- log .info (
512- f"gain reference is set to { self ._form_values .get ('gain_ref' )} , { self ._environment .gain_ref } "
513- )
514- if self ._form_values .get ("gain_ref" ) in (None , "None" ):
515- self ._form_values ["gain_ref" ] = self ._environment .gain_ref
516- self ._data_collection_form_complete = True
517- elif self ._register_dc is None :
518- self ._data_collection_form_complete = True
519-
520- def _start_dc (self , metadata_json , from_form : bool = False ):
495+ def _start_dc (self , metadata_json ):
521496 if self .dummy_dc :
522497 return
523- # for multigrid the analyser sends the message straight to _start_dc by-passing user input
524- # it is then necessary to extract the data from the message
525- if from_form :
526- metadata_json = metadata_json .get ("form" , {})
527- # Safely convert all entries into strings, but leave None as-is
528- metadata_json = {
529- k : str (v ) if v is not None else None for k , v in metadata_json .items ()
530- }
498+ # Safely convert all entries into strings, but leave None as-is
499+ metadata_json = {
500+ k : str (v ) if v is not None else None for k , v in metadata_json .items ()
501+ }
531502 self ._environment .dose_per_frame = metadata_json .get ("dose_per_frame" )
532503 self ._environment .gain_ref = metadata_json .get ("gain_ref" )
533504 self ._environment .symmetry = metadata_json .get ("symmetry" )
@@ -601,82 +572,76 @@ def _start_dc(self, metadata_json, from_form: bool = False):
601572 environment = self ._environment ,
602573 token = self .token ,
603574 )
604- if from_form :
605- data = {
606- "voltage" : metadata_json ["voltage" ],
607- "pixel_size_on_image" : metadata_json ["pixel_size_on_image" ],
608- "experiment_type" : metadata_json ["experiment_type" ],
609- "image_size_x" : metadata_json ["image_size_x" ],
610- "image_size_y" : metadata_json ["image_size_y" ],
611- "file_extension" : metadata_json ["file_extension" ],
612- "acquisition_software" : metadata_json ["acquisition_software" ],
613- "image_directory" : str (
614- self ._environment .default_destinations [source ]
615- ),
616- "tag" : str (source ),
617- "source" : str (source ),
618- "magnification" : metadata_json ["magnification" ],
619- "total_exposed_dose" : metadata_json .get ("total_exposed_dose" ),
620- "c2aperture" : metadata_json .get ("c2aperture" ),
621- "exposure_time" : metadata_json .get ("exposure_time" ),
622- "slit_width" : metadata_json .get ("slit_width" ),
623- "phase_plate" : metadata_json .get ("phase_plate" , False ),
624- }
575+ data = {
576+ "voltage" : metadata_json ["voltage" ],
577+ "pixel_size_on_image" : metadata_json ["pixel_size_on_image" ],
578+ "experiment_type" : metadata_json ["experiment_type" ],
579+ "image_size_x" : metadata_json ["image_size_x" ],
580+ "image_size_y" : metadata_json ["image_size_y" ],
581+ "file_extension" : metadata_json ["file_extension" ],
582+ "acquisition_software" : metadata_json ["acquisition_software" ],
583+ "image_directory" : str (self ._environment .default_destinations [source ]),
584+ "tag" : str (source ),
585+ "source" : str (source ),
586+ "magnification" : metadata_json ["magnification" ],
587+ "total_exposed_dose" : metadata_json .get ("total_exposed_dose" ),
588+ "c2aperture" : metadata_json .get ("c2aperture" ),
589+ "exposure_time" : metadata_json .get ("exposure_time" ),
590+ "slit_width" : metadata_json .get ("slit_width" ),
591+ "phase_plate" : metadata_json .get ("phase_plate" , False ),
592+ }
593+ capture_post (
594+ base_url = str (self ._environment .url .geturl ()),
595+ router_name = "workflow.router" ,
596+ function_name = "start_dc" ,
597+ token = self .token ,
598+ visit_name = self ._environment .visit ,
599+ session_id = self .session_id ,
600+ data = data ,
601+ )
602+ for recipe in (
603+ "em-spa-preprocess" ,
604+ "em-spa-extract" ,
605+ "em-spa-class2d" ,
606+ "em-spa-class3d" ,
607+ "em-spa-refine" ,
608+ ):
625609 capture_post (
626610 base_url = str (self ._environment .url .geturl ()),
627611 router_name = "workflow.router" ,
628- function_name = "start_dc " ,
612+ function_name = "register_proc " ,
629613 token = self .token ,
630614 visit_name = self ._environment .visit ,
631615 session_id = self .session_id ,
632- data = data ,
633- )
634- for recipe in (
635- "em-spa-preprocess" ,
636- "em-spa-extract" ,
637- "em-spa-class2d" ,
638- "em-spa-class3d" ,
639- "em-spa-refine" ,
640- ):
641- capture_post (
642- base_url = str (self ._environment .url .geturl ()),
643- router_name = "workflow.router" ,
644- function_name = "register_proc" ,
645- token = self .token ,
646- visit_name = self ._environment .visit ,
647- session_id = self .session_id ,
648- data = {
649- "tag" : str (source ),
650- "source" : str (source ),
651- "recipe" : recipe ,
652- },
653- )
654- log .info (f"Posting SPA processing parameters: { metadata_json } " )
655- response = capture_post (
656- base_url = str (self ._environment .url .geturl ()),
657- router_name = "workflow.spa_router" ,
658- function_name = "register_spa_proc_params" ,
659- token = self .token ,
660- session_id = self .session_id ,
661616 data = {
662- ** {
663- k : None if v == "None" else v
664- for k , v in metadata_json .items ()
665- },
666617 "tag" : str (source ),
618+ "source" : str (source ),
619+ "recipe" : recipe ,
667620 },
668621 )
669- if response and not str (response .status_code ).startswith ("2" ):
670- log .warning (f"{ response .reason } " )
671- capture_post (
672- base_url = str (self ._environment .url .geturl ()),
673- router_name = "workflow.spa_router" ,
674- function_name = "flush_spa_processing" ,
675- token = self .token ,
676- visit_name = self ._environment .visit ,
677- session_id = self .session_id ,
678- data = {"tag" : str (source )},
679- )
622+ log .info (f"Posting SPA processing parameters: { metadata_json } " )
623+ response = capture_post (
624+ base_url = str (self ._environment .url .geturl ()),
625+ router_name = "workflow.spa_router" ,
626+ function_name = "register_spa_proc_params" ,
627+ token = self .token ,
628+ session_id = self .session_id ,
629+ data = {
630+ ** {k : None if v == "None" else v for k , v in metadata_json .items ()},
631+ "tag" : str (source ),
632+ },
633+ )
634+ if response and not str (response .status_code ).startswith ("2" ):
635+ log .warning (f"{ response .reason } " )
636+ capture_post (
637+ base_url = str (self ._environment .url .geturl ()),
638+ router_name = "workflow.spa_router" ,
639+ function_name = "flush_spa_processing" ,
640+ token = self .token ,
641+ visit_name = self ._environment .visit ,
642+ session_id = self .session_id ,
643+ data = {"tag" : str (source )},
644+ )
680645
681646 def _increment_file_count (
682647 self , observed_files : List [Path ], source : str , destination : str
0 commit comments