@@ -60,8 +60,8 @@ async def activate_instrument_server_for_session(
6060 machine_config = get_machine_config (instrument_name = instrument_name )[
6161 instrument_name
6262 ]
63- async with aiohttp .ClientSession () as session :
64- async with session .post (
63+ async with aiohttp .ClientSession () as clientsession :
64+ async with clientsession .post (
6565 f"{ machine_config .instrument_server_url } /sessions/{ int (sanitise (str (session_id )))} /token" ,
6666 json = {"access_token" : token , "token_type" : "bearer" },
6767 ) as response :
@@ -80,11 +80,11 @@ async def check_if_session_is_active(instrument_name: str, session_id: int):
8080 if instrument_server_tokens .get (session_id ) is None :
8181 return {"active" : False }
8282 async with lock :
83- async with aiohttp .ClientSession () as session :
83+ async with aiohttp .ClientSession () as clientsession :
8484 machine_config = get_machine_config (instrument_name = instrument_name )[
8585 instrument_name
8686 ]
87- async with session .get (
87+ async with clientsession .get (
8888 f"{ machine_config .instrument_server_url } /sessions/{ int (sanitise (str (session_id )))} /check_token" ,
8989 headers = {
9090 "Authorization" : f"Bearer { instrument_server_tokens [session_id ]['access_token' ]} "
@@ -116,8 +116,8 @@ async def start_multigrid_watcher(
116116 "visit" : visit ,
117117 "default_model" : str (machine_config .default_model ),
118118 }
119- async with aiohttp .ClientSession () as session :
120- async with session .post (
119+ async with aiohttp .ClientSession () as clientsession :
120+ async with clientsession .post (
121121 f"{ machine_config .instrument_server_url } /sessions/{ session_id } /multigrid_watcher" ,
122122 json = {
123123 "source" : str (secure_path (watcher_spec .source / visit )),
@@ -154,6 +154,7 @@ async def pass_proc_params_to_instrument_server(
154154 session = db .exec (select (Session ).where (Session .id == session_id )).one ()
155155
156156 session_processing_parameters = SessionProcessingParameters (
157+ session_id = session_id ,
157158 dose_per_frame = proc_params .dose_per_frame ,
158159 gain_ref = session .current_gain_ref ,
159160 symmetry = proc_params .symmetry ,
@@ -170,8 +171,8 @@ async def pass_proc_params_to_instrument_server(
170171 ]
171172 if machine_config .instrument_server_url :
172173 label = db .exec (select (Session ).where (Session .id == session_id )).one ().name
173- async with aiohttp .ClientSession () as session :
174- async with session .post (
174+ async with aiohttp .ClientSession () as clientsession :
175+ async with clientsession .post (
175176 f"{ machine_config .instrument_server_url } /sessions/{ session_id } /processing_parameters" ,
176177 json = {
177178 "label" : label ,
@@ -199,8 +200,8 @@ async def check_instrument_server(instrument_name: str):
199200 instrument_name
200201 ]
201202 if machine_config .instrument_server_url :
202- async with aiohttp .ClientSession () as session :
203- async with session .get (
203+ async with aiohttp .ClientSession () as clientsession :
204+ async with clientsession .get (
204205 f"{ machine_config .instrument_server_url } /health" ,
205206 ) as resp :
206207 data = await resp .json ()
@@ -220,8 +221,8 @@ async def get_possible_gain_references(
220221 if machine_config .instrument_server_url :
221222 async with lock :
222223 token = instrument_server_tokens [session_id ]["access_token" ]
223- async with aiohttp .ClientSession () as session :
224- async with session .get (
224+ async with aiohttp .ClientSession () as clientsession :
225+ async with clientsession .get (
225226 f"{ machine_config .instrument_server_url } /instruments/{ sanitise (instrument_name )} /sessions/{ sanitise (str (session_id ))} /possible_gain_references" ,
226227 headers = {"Authorization" : f"Bearer { token } " },
227228 ) as resp :
@@ -249,8 +250,8 @@ async def request_gain_reference_upload(
249250 visit_path = f"{ datetime .datetime .now ().year } /{ visit } "
250251 data = {}
251252 if machine_config .instrument_server_url :
252- async with aiohttp .ClientSession () as session :
253- async with session .post (
253+ async with aiohttp .ClientSession () as clientsession :
254+ async with clientsession .post (
254255 f"{ machine_config .instrument_server_url } /instruments/{ instrument_name } /sessions/{ session_id } /upload_gain_reference" ,
255256 json = {
256257 "gain_path" : str (gain_reference_request .gain_path ),
@@ -282,8 +283,8 @@ async def request_upstream_tiff_data_download(
282283 / secure_filename (visit_name )
283284 )
284285 if machine_config .instrument_server_url :
285- async with aiohttp .ClientSession () as session :
286- async with session .post (
286+ async with aiohttp .ClientSession () as clientsession :
287+ async with clientsession .post (
287288 f"{ machine_config .instrument_server_url } /visits/{ secure_filename (visit_name )} /sessions/{ sanitise (str (session_id ))} /upstream_tiff_data_request" ,
288289 json = {"download_dir" : download_dir },
289290 headers = {
@@ -310,8 +311,8 @@ async def stop_rsyncer(
310311 instrument_name
311312 ]
312313 if machine_config .instrument_server_url :
313- async with aiohttp .ClientSession () as session :
314- async with session .post (
314+ async with aiohttp .ClientSession () as clientsession :
315+ async with clientsession .post (
315316 f"{ machine_config .instrument_server_url } /sessions/{ session_id } /stop_rsyncer" ,
316317 json = {
317318 "label" : session_id ,
@@ -337,8 +338,8 @@ async def finalise_rsyncer(
337338 instrument_name
338339 ]
339340 if machine_config .instrument_server_url :
340- async with aiohttp .ClientSession () as session :
341- async with session .post (
341+ async with aiohttp .ClientSession () as clientsession :
342+ async with clientsession .post (
342343 f"{ machine_config .instrument_server_url } /sessions/{ session_id } /finalise_rsyncer" ,
343344 json = {
344345 "label" : session_id ,
@@ -365,8 +366,8 @@ async def remove_rsyncer(
365366 ]
366367 if isinstance (session_id , int ):
367368 if machine_config .instrument_server_url :
368- async with aiohttp .ClientSession () as session :
369- async with session .post (
369+ async with aiohttp .ClientSession () as clientsession :
370+ async with clientsession .post (
370371 f"{ machine_config .instrument_server_url } /sessions/{ session_id } /remove_rsyncer" ,
371372 json = {
372373 "label" : session_id ,
@@ -393,8 +394,8 @@ async def restart_rsyncer(
393394 ]
394395 if isinstance (session_id , int ):
395396 if machine_config .instrument_server_url :
396- async with aiohttp .ClientSession () as session :
397- async with session .post (
397+ async with aiohttp .ClientSession () as clientsession :
398+ async with clientsession .post (
398399 f"{ machine_config .instrument_server_url } /sessions/{ session_id } /restart_rsyncer" ,
399400 json = {
400401 "label" : session_id ,
0 commit comments