@@ -412,29 +412,31 @@ def _data_collection_form(self, response: dict):
412412 elif self ._register_dc is None :
413413 self ._data_collection_form_complete = True
414414
415- def _start_dc (self , json , from_form : bool = False ):
415+ def _start_dc (self , metadata_json , from_form : bool = False ):
416416 if self .dummy_dc :
417417 return
418418 # for multigrid the analyser sends the message straight to _start_dc by-passing user input
419419 # it is then necessary to extract the data from the message
420420 if from_form :
421- json = json .get ("form" , {})
421+ metadata_json = metadata_json .get ("form" , {})
422422 # Safely convert all entries into strings, but leave None as-is
423- json = {k : str (v ) if v is not None else None for k , v in json .items ()}
424- self ._environment .dose_per_frame = json .get ("dose_per_frame" )
425- self ._environment .gain_ref = json .get ("gain_ref" )
426- self ._environment .symmetry = json .get ("symmetry" )
427- self ._environment .eer_fractionation = json .get ("eer_fractionation" )
428- source = Path (json ["source" ])
423+ metadata_json = {
424+ k : str (v ) if v is not None else None for k , v in metadata_json .items ()
425+ }
426+ self ._environment .dose_per_frame = metadata_json .get ("dose_per_frame" )
427+ self ._environment .gain_ref = metadata_json .get ("gain_ref" )
428+ self ._environment .symmetry = metadata_json .get ("symmetry" )
429+ self ._environment .eer_fractionation = metadata_json .get ("eer_fractionation" )
430+ source = Path (metadata_json ["source" ])
429431 context = self .analysers [source ]._context
430432 if context :
431433 context .data_collection_parameters = {
432- k : None if v == "None" else v for k , v in json .items ()
434+ k : None if v == "None" else v for k , v in metadata_json .items ()
433435 }
434436 if isinstance (context , TomographyContext ):
435- source = Path (json ["source" ])
437+ source = Path (metadata_json ["source" ])
436438 context .register_tomography_data_collections (
437- file_extension = json ["file_extension" ],
439+ file_extension = metadata_json ["file_extension" ],
438440 image_directory = str (self ._environment .default_destinations [source ]),
439441 environment = self ._environment ,
440442 )
@@ -453,10 +455,10 @@ def _start_dc(self, json, from_form: bool = False):
453455 },
454456 )
455457 eer_fractionation_file = eer_response .json ()["eer_fractionation_file" ]
456- json .update ({"eer_fractionation_file" : eer_fractionation_file })
458+ metadata_json .update ({"eer_fractionation_file" : eer_fractionation_file })
457459 capture_post (
458460 f"{ self ._environment .url .geturl ()} { url_path_for ('workflow.tomo_router' , 'register_tomo_proc_params' , session_id = self ._environment .murfey_session )} " ,
459- json = json ,
461+ json = metadata_json ,
460462 )
461463 capture_post (
462464 f"{ self ._environment .url .geturl ()} { url_path_for ('workflow.tomo_router' , 'flush_tomography_processing' , visit_name = self ._environment .visit , session_id = self ._environment .murfey_session )} " ,
@@ -484,24 +486,24 @@ def _start_dc(self, json, from_form: bool = False):
484486 capture_post (url , json = dcg_data )
485487 if from_form :
486488 data = {
487- "voltage" : json ["voltage" ],
488- "pixel_size_on_image" : json ["pixel_size_on_image" ],
489- "experiment_type" : json ["experiment_type" ],
490- "image_size_x" : json ["image_size_x" ],
491- "image_size_y" : json ["image_size_y" ],
492- "file_extension" : json ["file_extension" ],
493- "acquisition_software" : json ["acquisition_software" ],
489+ "voltage" : metadata_json ["voltage" ],
490+ "pixel_size_on_image" : metadata_json ["pixel_size_on_image" ],
491+ "experiment_type" : metadata_json ["experiment_type" ],
492+ "image_size_x" : metadata_json ["image_size_x" ],
493+ "image_size_y" : metadata_json ["image_size_y" ],
494+ "file_extension" : metadata_json ["file_extension" ],
495+ "acquisition_software" : metadata_json ["acquisition_software" ],
494496 "image_directory" : str (
495497 self ._environment .default_destinations [source ]
496498 ),
497499 "tag" : str (source ),
498500 "source" : str (source ),
499- "magnification" : json ["magnification" ],
500- "total_exposed_dose" : json .get ("total_exposed_dose" ),
501- "c2aperture" : json .get ("c2aperture" ),
502- "exposure_time" : json .get ("exposure_time" ),
503- "slit_width" : json .get ("slit_width" ),
504- "phase_plate" : json .get ("phase_plate" , False ),
501+ "magnification" : metadata_json ["magnification" ],
502+ "total_exposed_dose" : metadata_json .get ("total_exposed_dose" ),
503+ "c2aperture" : metadata_json .get ("c2aperture" ),
504+ "exposure_time" : metadata_json .get ("exposure_time" ),
505+ "slit_width" : metadata_json .get ("slit_width" ),
506+ "phase_plate" : metadata_json .get ("phase_plate" , False ),
505507 }
506508 capture_post (
507509 f"{ str (self ._environment .url .geturl ())} { url_path_for ('workflow.router' , 'start_dc' , visit_name = self ._environment .visit , session_id = self .session_id )} " ,
@@ -522,11 +524,14 @@ def _start_dc(self, json, from_form: bool = False):
522524 "recipe" : recipe ,
523525 },
524526 )
525- log .info (f"Posting SPA processing parameters: { json } " )
527+ log .info (f"Posting SPA processing parameters: { metadata_json } " )
526528 response = capture_post (
527529 f"{ self ._environment .url .geturl ()} { url_path_for ('workflow.spa_router' , 'register_spa_proc_params' , session_id = self .session_id )} " ,
528530 json = {
529- ** {k : None if v == "None" else v for k , v in json .items ()},
531+ ** {
532+ k : None if v == "None" else v
533+ for k , v in metadata_json .items ()
534+ },
530535 "tag" : str (source ),
531536 },
532537 )
0 commit comments