66from pathlib import Path
77from typing import Optional
88
9+ from murfey .util .config import get_machine_config
10+
911try :
1012 from murfey .server .ispyb import TransportManager # Session
1113except AttributeError :
1517def zocalo_cluster_request (
1618 file : Path ,
1719 root_folder : str ,
20+ session_id : int , # Provided by the client via the API endpoint
21+ instrument_name : str , # Acquired by looking up the Session table
1822 messenger : Optional [TransportManager ] = None ,
1923):
2024 if messenger :
21- # Construct path to session directory
2225 path_parts = list (file .parts )
23- new_path = []
26+
27+ # Construct path to session directory
28+ session_dir_parts = []
2429 for p in range (len (path_parts )):
2530 part = path_parts [p ]
2631 # Remove leading slash for subsequent rejoining
@@ -29,9 +34,26 @@ def zocalo_cluster_request(
2934 # Append up to, but not including, root folder
3035 if part .lower () == root_folder .lower ():
3136 break
32- new_path .append (part )
33- session_dir = Path ("/" .join (new_path ))
37+ session_dir_parts .append (part )
38+ session_dir = Path ("/" .join (session_dir_parts ))
39+
40+ # Construct the job name
41+ job_name_parts = []
42+ trigger = False
43+ for p in range (len (path_parts )):
44+ part = path_parts [p ].replace (" " , "_" ) # Remove spaces
45+ if trigger is True :
46+ job_name_parts .append (part )
47+ # Start appending at the level below the root folder
48+ if part .lower () == root_folder .lower ():
49+ trigger = True
50+ job_name = "--" .join (job_name_parts )
51+
52+ # Load machine config to get the feedback queue
53+ machine_config = get_machine_config ()
54+ feedback_queue = machine_config [instrument_name ].feedback_queue
3455
56+ # Send the message
3557 messenger .send (
3658 "processing_recipe" ,
3759 {
@@ -40,6 +62,9 @@ def zocalo_cluster_request(
4062 "session_dir" : str (session_dir ),
4163 "lif_path" : str (file ),
4264 "root_dir" : root_folder ,
65+ "job_name" : job_name ,
66+ "feedback_queue" : feedback_queue ,
67+ "session_id" : session_id ,
4368 },
4469 },
4570 new_connection = True ,
0 commit comments