75
75
get_user ,
76
76
is_remote_platform ,
77
77
)
78
- from cylc .flow .id import Tokens , quick_relative_id
78
+ from cylc .flow .id import Tokens
79
79
from cylc .flow .log_level import verbosity_to_env , verbosity_to_opts
80
80
from cylc .flow .loggingutil import (
81
81
ReferenceLogFileHandler ,
@@ -1067,17 +1067,17 @@ def remove_tasks(
1067
1067
1068
1068
if flow_nums is None :
1069
1069
flow_nums = set ()
1070
- # Mapping of task IDs to removed flow numbers:
1071
- removed : Dict [str , FlowNums ] = {}
1072
- not_removed : Set [str ] = set ()
1070
+ # Mapping of *relative* task IDs to removed flow numbers:
1071
+ removed : Dict [Tokens , FlowNums ] = {}
1072
+ not_removed : Set [Tokens ] = set ()
1073
1073
to_kill : List [TaskProxy ] = []
1074
1074
1075
1075
for itask in active :
1076
1076
fnums_to_remove = itask .match_flows (flow_nums )
1077
1077
if not fnums_to_remove :
1078
- not_removed .add (itask .identity )
1078
+ not_removed .add (itask .tokens . task )
1079
1079
continue
1080
- removed [itask .identity ] = fnums_to_remove
1080
+ removed [itask .tokens . task ] = fnums_to_remove
1081
1081
if fnums_to_remove == itask .flow_nums :
1082
1082
# Need to remove the task from the pool.
1083
1083
# Spawn next occurrence of xtrigger sequential task (otherwise
@@ -1089,19 +1089,20 @@ def remove_tasks(
1089
1089
itask .flow_nums .difference_update (fnums_to_remove )
1090
1090
1091
1091
# All the matched tasks (including inactive & applicable active tasks):
1092
- matched_task_ids = {
1092
+ matched_tasks = {
1093
1093
* removed .keys (),
1094
- * (quick_relative_id (cycle , task ) for task , cycle in inactive ),
1094
+ * (Tokens (cycle = str ( cycle ), task = task ) for task , cycle in inactive ),
1095
1095
}
1096
1096
1097
- for id_ in matched_task_ids :
1098
- point_str , name = id_ .split ('/' , 1 )
1099
- tdef = self .config .taskdefs [name ]
1097
+ for tokens in matched_tasks :
1098
+ tdef = self .config .taskdefs [tokens ['task' ]]
1100
1099
1101
1100
# Go through any tasks downstream of this matched task to see if
1102
1101
# any need to stand down as a result of this task being removed:
1103
1102
for child in set (itertools .chain .from_iterable (
1104
- generate_graph_children (tdef , get_point (point_str )).values ()
1103
+ generate_graph_children (
1104
+ tdef , get_point (tokens ['cycle' ])
1105
+ ).values ()
1105
1106
)):
1106
1107
child_itask = self .pool .get_task (child .point , child .name )
1107
1108
if not child_itask :
@@ -1116,9 +1117,11 @@ def remove_tasks(
1116
1117
):
1117
1118
# Unset any prereqs naturally satisfied by these tasks
1118
1119
# (do not unset those satisfied by `cylc set --pre`):
1119
- if prereq .unset_naturally_satisfied (id_ ):
1120
+ if prereq .unset_naturally_satisfied (tokens . relative_id ):
1120
1121
prereqs_changed = True
1121
- removed .setdefault (id_ , set ()).update (fnums_to_remove )
1122
+ removed .setdefault (tokens , set ()).update (
1123
+ fnums_to_remove
1124
+ )
1122
1125
if not prereqs_changed :
1123
1126
continue
1124
1127
self .data_store_mgr .delta_task_prerequisite (child_itask )
@@ -1135,7 +1138,7 @@ def remove_tasks(
1135
1138
# Check if downstream task should remain spawned:
1136
1139
if (
1137
1140
# Ignoring tasks we are already dealing with:
1138
- child_itask .identity in matched_task_ids
1141
+ child_itask .tokens . task in matched_tasks
1139
1142
or child_itask .state .any_satisfied_prerequisite_outputs ()
1140
1143
):
1141
1144
continue
@@ -1149,32 +1152,34 @@ def remove_tasks(
1149
1152
1150
1153
# Remove the matched tasks from the flows in the DB tables:
1151
1154
db_removed_fnums = self .workflow_db_mgr .remove_task_from_flows (
1152
- point_str , name , flow_nums
1155
+ tokens [ 'cycle' ], tokens [ 'task' ] , flow_nums ,
1153
1156
)
1154
1157
if db_removed_fnums :
1155
- removed .setdefault (id_ , set ()).update (db_removed_fnums )
1158
+ removed .setdefault (tokens , set ()).update (db_removed_fnums )
1156
1159
1157
1160
if to_kill :
1158
1161
self .kill_tasks (to_kill , warn = False )
1159
1162
1160
1163
if removed :
1161
1164
tasks_str_list = []
1162
1165
for task , fnums in removed .items ():
1163
- self .data_store_mgr .delta_remove_task_flow_nums (task , fnums )
1166
+ self .data_store_mgr .delta_remove_task_flow_nums (
1167
+ task .relative_id , fnums
1168
+ )
1164
1169
tasks_str_list .append (
1165
- f"{ task } { repr_flow_nums (fnums , full = True )} "
1170
+ f"{ task . relative_id } { repr_flow_nums (fnums , full = True )} "
1166
1171
)
1167
1172
LOG .info (f"Removed task(s): { ', ' .join (sorted (tasks_str_list ))} " )
1168
1173
1169
- not_removed .update (matched_task_ids .difference (removed ))
1174
+ not_removed .update (matched_tasks .difference (removed ))
1170
1175
if not_removed :
1171
1176
fnums_str = (
1172
1177
repr_flow_nums (flow_nums , full = True ) if flow_nums else ''
1173
1178
)
1174
- LOG .warning (
1175
- "Task(s) not removable: "
1176
- f"{ ', ' .join (sorted (not_removed ))} { fnums_str } "
1179
+ tasks_str = ', ' .join (
1180
+ sorted (tokens .relative_id for tokens in not_removed )
1177
1181
)
1182
+ LOG .warning (f"Task(s) not removable: { tasks_str } { fnums_str } " )
1178
1183
1179
1184
if removed and self .pool .compute_runahead ():
1180
1185
self .pool .release_runahead_tasks ()
0 commit comments