@@ -141,8 +141,16 @@ def check_token(session_id: MurfeySessionID):
141141def setup_multigrid_watcher (
142142 session_id : MurfeySessionID , watcher_spec : MultigridWatcherSpec
143143):
144+ # Return True if controllers are already set up
144145 if controllers .get (session_id ) is not None :
145146 return {"success" : True }
147+
148+ # Load machine config as dictionary
149+ machine_config : dict [str , Any ] = requests .get (
150+ f"{ _get_murfey_url ()} /instruments/{ sanitise_nonpath (watcher_spec .instrument_name )} /machine" ,
151+ headers = {"Authorization" : f"Bearer { tokens [session_id ]} " },
152+ ).json ()
153+
146154 label = watcher_spec .label
147155 for sid , controller in controllers .items ():
148156 if controller .dormant :
@@ -156,22 +164,19 @@ def setup_multigrid_watcher(
156164 demo = True ,
157165 do_transfer = True ,
158166 processing_enabled = not watcher_spec .skip_existing_processing ,
159- _machine_config = watcher_spec . configuration . dict () ,
167+ _machine_config = machine_config ,
160168 token = tokens .get (session_id , "token" ),
161169 data_collection_parameters = data_collection_parameters .get (label , {}),
162170 rsync_restarts = watcher_spec .rsync_restarts ,
163171 visit_end_time = watcher_spec .visit_end_time ,
164172 )
165173 watcher_spec .source .mkdir (exist_ok = True )
166- machine_config = requests .get (
167- f"{ _get_murfey_url ()} /instruments/{ sanitise_nonpath (watcher_spec .instrument_name )} /machine" ,
168- headers = {"Authorization" : f"Bearer { tokens [session_id ]} " },
169- ).json ()
174+
170175 for d in machine_config .get ("create_directories" , []):
171176 (watcher_spec .source / d ).mkdir (exist_ok = True )
172177 watchers [session_id ] = MultigridDirWatcher (
173178 watcher_spec .source ,
174- watcher_spec . configuration . dict () ,
179+ machine_config ,
175180 skip_existing_processing = watcher_spec .skip_existing_processing ,
176181 )
177182 watchers [session_id ].subscribe (
0 commit comments