2020from murfey .client .rsync import RSyncer , RSyncerUpdate , TransferResult
2121from murfey .client .tui .screens import determine_default_destination
2222from murfey .client .watchdir import DirWatcher
23+ from murfey .server .api .file_manip import router as file_manip_router
24+ from murfey .server .api .session_control import router as session_router
25+ from murfey .server .api .workflow import router as workflow_router
26+ from murfey .server .api .workflow import spa_router as workflow_spa_router
27+ from murfey .server .api .workflow import tomo_router as workflow_tomo_router
2328from murfey .util import posix_path
2429from murfey .util .client import capture_post , get_machine_config_client
2530
@@ -114,7 +119,7 @@ async def dormancy_check(self):
114119 ):
115120 async with aiohttp .ClientSession () as clientsession :
116121 async with clientsession .delete (
117- f"{ self ._environment .url .geturl ()} /sessions/ { self .session_id } " ,
122+ f"{ self ._environment .url .geturl ()} { session_router . url_path_for ( 'remove_session' , session_id = self .session_id ) } " ,
118123 json = {"access_token" : self .token , "token_type" : "bearer" },
119124 ) as response :
120125 success = response .status == 200
@@ -153,7 +158,7 @@ def _start_rsyncer_multigrid(
153158 log .info (f"starting multigrid rsyncer: { source } " )
154159 destination_overrides = destination_overrides or {}
155160 machine_data = requests .get (
156- f"{ self ._environment .url .geturl ()} /instruments/ { self .instrument_name } /machine "
161+ f"{ self ._environment .url .geturl ()} { session_router . url_path_for ( 'machine_info_by_instrument' , instrument_name = self .instrument_name ) } "
157162 ).json ()
158163 if destination_overrides .get (source ):
159164 destination = (
@@ -428,7 +433,7 @@ def _start_dc(self, json, from_form: bool = False):
428433 log .info ("Registering tomography processing parameters" )
429434 if self ._environment .data_collection_parameters .get ("num_eer_frames" ):
430435 eer_response = requests .post (
431- f"{ str (self ._environment .url .geturl ())} /visits/ { self ._environment .visit } / { self ._environment .murfey_session } /eer_fractionation_file " ,
436+ f"{ str (self ._environment .url .geturl ())} { file_manip_router . url_path_for ( 'write_eer_fractionation_file' , visit_name = self ._environment .visit , session_id = self ._environment .murfey_session ) } " ,
432437 json = {
433438 "num_frames" : self ._environment .data_collection_parameters [
434439 "num_eer_frames"
@@ -445,17 +450,17 @@ def _start_dc(self, json, from_form: bool = False):
445450 eer_fractionation_file = eer_response .json ()["eer_fractionation_file" ]
446451 json .update ({"eer_fractionation_file" : eer_fractionation_file })
447452 capture_post (
448- f"{ self ._environment .url .geturl ()} /sessions/ { self ._environment .murfey_session } /tomography_processing_parameters " ,
453+ f"{ self ._environment .url .geturl ()} { workflow_tomo_router . url_path_for ( 'register_tomo_proc_params' , session_id = self ._environment .murfey_session ) } " ,
449454 json = json ,
450455 )
451456 capture_post (
452- f"{ self ._environment .url .geturl ()} /visits/ { self ._environment .visit } / { self ._environment .murfey_session } /flush_tomography_processing " ,
457+ f"{ self ._environment .url .geturl ()} { workflow_tomo_router . url_path_for ( 'flush_tomography_processing' , visit_name = self ._environment .visit , session_id = self ._environment .murfey_session ) } " ,
453458 json = {"rsync_source" : str (source )},
454459 )
455460 log .info ("Tomography processing flushed" )
456461
457462 elif isinstance (context , SPAModularContext ):
458- url = f"{ str (self ._environment .url .geturl ())} /visits/ { str ( self ._environment .visit ) } / { self .session_id } /register_data_collection_group "
463+ url = f"{ str (self ._environment .url .geturl ())} { workflow_router . url_path_for ( 'register_dc_group' , visit_name = self ._environment .visit , session_id = self .session_id ) } "
459464 dcg_data = {
460465 "experiment_type" : "single particle" ,
461466 "experiment_type_id" : 37 ,
@@ -494,7 +499,7 @@ def _start_dc(self, json, from_form: bool = False):
494499 "phase_plate" : json .get ("phase_plate" , False ),
495500 }
496501 capture_post (
497- f"{ str (self ._environment .url .geturl ())} /visits/ { str ( self ._environment .visit ) } / { self .session_id } /start_data_collection " ,
502+ f"{ str (self ._environment .url .geturl ())} { workflow_spa_router . url_path_for ( 'start_dc' , visit_name = self ._environment .visit , session_id = self .session_id ) } " ,
498503 json = data ,
499504 )
500505 for recipe in (
@@ -505,7 +510,7 @@ def _start_dc(self, json, from_form: bool = False):
505510 "em-spa-refine" ,
506511 ):
507512 capture_post (
508- f"{ str (self ._environment .url .geturl ())} /visits/ { str ( self ._environment .visit ) } / { self .session_id } /register_processing_job " ,
513+ f"{ str (self ._environment .url .geturl ())} { workflow_router . url_path_for ( 'register_proc' , visit_name = self ._environment .visit , session_id = self .session_id ) } " ,
509514 json = {
510515 "tag" : str (source ),
511516 "source" : str (source ),
@@ -514,7 +519,7 @@ def _start_dc(self, json, from_form: bool = False):
514519 )
515520 log .info (f"Posting SPA processing parameters: { json } " )
516521 response = capture_post (
517- f"{ self ._environment .url .geturl ()} /sessions/ { self .session_id } /spa_processing_parameters " ,
522+ f"{ self ._environment .url .geturl ()} { workflow_router . url_path_for ( 'register_spa_proc_params' , session_id = self .session_id ) } " ,
518523 json = {
519524 ** {k : None if v == "None" else v for k , v in json .items ()},
520525 "tag" : str (source ),
@@ -523,7 +528,7 @@ def _start_dc(self, json, from_form: bool = False):
523528 if response and not str (response .status_code ).startswith ("2" ):
524529 log .warning (f"{ response .reason } " )
525530 capture_post (
526- f"{ self ._environment .url .geturl ()} /visits/ { self ._environment .visit } / { self .session_id } /flush_spa_processing " ,
531+ f"{ self ._environment .url .geturl ()} { workflow_spa_router . url_path_for ( 'flush_spa_processing' , visit_name = self ._environment .visit , session_id = self .session_id ) } " ,
527532 json = {"tag" : str (source )},
528533 )
529534
0 commit comments