Skip to content

Commit 7820501

Browse files
committed
Constructed parameters from file path; updated parameter names
1 parent 398b09e commit 7820501

File tree

1 file changed

+25
-28
lines changed

1 file changed

+25
-28
lines changed

src/murfey/workflows/lif_to_stack.py

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -22,49 +22,46 @@ def zocalo_cluster_request(
2222
messenger: Optional[TransportManager] = None,
2323
):
2424
if messenger:
25-
path_parts = list(file.parts)
25+
# Use file path parts to construct parameters
26+
path_parts = list((file.parent / file.stem).parts)
27+
# Replace leading "/" in Unix paths
28+
path_parts[0] = "" if path_parts[0] == "/" else path_parts[0]
29+
try:
30+
# Find the position of the root folder in the list
31+
root_index = [p.lower() for p in path_parts].index(root_folder.lower())
32+
except ValueError:
33+
raise Exception(
34+
f"Unable to find the root folder {root_folder!r} in the file path {file!r}"
35+
)
2636

27-
# Construct path to session directory
28-
session_dir_parts = []
29-
for p in range(len(path_parts)):
30-
part = path_parts[p]
31-
# Remove leading slash for subsequent rejoining
32-
if part == "/":
33-
part = ""
34-
# Append up to, but not including, root folder
35-
if part.lower() == root_folder.lower():
36-
break
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)
37+
# Construct the session
38+
session_dir = "/".join(path_parts[:root_index])
39+
job_name = "--".join(
40+
[p.replace(" ", "_") if " " in p else p for p in path_parts][
41+
root_index + 1 :
42+
]
43+
)
5144

5245
# Load machine config to get the feedback queue
5346
machine_config = get_machine_config()
5447
feedback_queue = machine_config[instrument_name].feedback_queue
5548

5649
# Send the message
50+
# The keys under "parameters" will populate all the matching fields in {}
51+
# in the processing recipe
5752
messenger.send(
5853
"processing_recipe",
5954
{
6055
"recipes": ["clem-lif-to-stack"],
6156
"parameters": {
57+
# Job parameters
58+
"lif_file": str(file),
59+
"root_folder": root_folder,
60+
# Other recipe parameters
6261
"session_dir": str(session_dir),
63-
"lif_path": str(file),
64-
"root_dir": root_folder,
62+
"session_id": session_id,
6563
"job_name": job_name,
6664
"feedback_queue": feedback_queue,
67-
"session_id": session_id,
6865
},
6966
},
7067
new_connection=True,

0 commit comments

Comments
 (0)