Skip to content

Commit b004e54

Browse files
Convert from ids to tokens (#6503)
Co-authored-by: Ronnie Dutta <[email protected]>
1 parent 1e3699a commit b004e54

File tree

1 file changed

+28
-23
lines changed

1 file changed

+28
-23
lines changed

cylc/flow/scheduler.py

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
get_user,
7676
is_remote_platform,
7777
)
78-
from cylc.flow.id import Tokens, quick_relative_id
78+
from cylc.flow.id import Tokens
7979
from cylc.flow.log_level import verbosity_to_env, verbosity_to_opts
8080
from cylc.flow.loggingutil import (
8181
ReferenceLogFileHandler,
@@ -1067,17 +1067,17 @@ def remove_tasks(
10671067

10681068
if flow_nums is None:
10691069
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()
10731073
to_kill: List[TaskProxy] = []
10741074

10751075
for itask in active:
10761076
fnums_to_remove = itask.match_flows(flow_nums)
10771077
if not fnums_to_remove:
1078-
not_removed.add(itask.identity)
1078+
not_removed.add(itask.tokens.task)
10791079
continue
1080-
removed[itask.identity] = fnums_to_remove
1080+
removed[itask.tokens.task] = fnums_to_remove
10811081
if fnums_to_remove == itask.flow_nums:
10821082
# Need to remove the task from the pool.
10831083
# Spawn next occurrence of xtrigger sequential task (otherwise
@@ -1089,19 +1089,20 @@ def remove_tasks(
10891089
itask.flow_nums.difference_update(fnums_to_remove)
10901090

10911091
# All the matched tasks (including inactive & applicable active tasks):
1092-
matched_task_ids = {
1092+
matched_tasks = {
10931093
*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),
10951095
}
10961096

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']]
11001099

11011100
# Go through any tasks downstream of this matched task to see if
11021101
# any need to stand down as a result of this task being removed:
11031102
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()
11051106
)):
11061107
child_itask = self.pool.get_task(child.point, child.name)
11071108
if not child_itask:
@@ -1116,9 +1117,11 @@ def remove_tasks(
11161117
):
11171118
# Unset any prereqs naturally satisfied by these tasks
11181119
# (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):
11201121
prereqs_changed = True
1121-
removed.setdefault(id_, set()).update(fnums_to_remove)
1122+
removed.setdefault(tokens, set()).update(
1123+
fnums_to_remove
1124+
)
11221125
if not prereqs_changed:
11231126
continue
11241127
self.data_store_mgr.delta_task_prerequisite(child_itask)
@@ -1135,7 +1138,7 @@ def remove_tasks(
11351138
# Check if downstream task should remain spawned:
11361139
if (
11371140
# Ignoring tasks we are already dealing with:
1138-
child_itask.identity in matched_task_ids
1141+
child_itask.tokens.task in matched_tasks
11391142
or child_itask.state.any_satisfied_prerequisite_outputs()
11401143
):
11411144
continue
@@ -1149,32 +1152,34 @@ def remove_tasks(
11491152

11501153
# Remove the matched tasks from the flows in the DB tables:
11511154
db_removed_fnums = self.workflow_db_mgr.remove_task_from_flows(
1152-
point_str, name, flow_nums
1155+
tokens['cycle'], tokens['task'], flow_nums,
11531156
)
11541157
if db_removed_fnums:
1155-
removed.setdefault(id_, set()).update(db_removed_fnums)
1158+
removed.setdefault(tokens, set()).update(db_removed_fnums)
11561159

11571160
if to_kill:
11581161
self.kill_tasks(to_kill, warn=False)
11591162

11601163
if removed:
11611164
tasks_str_list = []
11621165
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+
)
11641169
tasks_str_list.append(
1165-
f"{task} {repr_flow_nums(fnums, full=True)}"
1170+
f"{task.relative_id} {repr_flow_nums(fnums, full=True)}"
11661171
)
11671172
LOG.info(f"Removed task(s): {', '.join(sorted(tasks_str_list))}")
11681173

1169-
not_removed.update(matched_task_ids.difference(removed))
1174+
not_removed.update(matched_tasks.difference(removed))
11701175
if not_removed:
11711176
fnums_str = (
11721177
repr_flow_nums(flow_nums, full=True) if flow_nums else ''
11731178
)
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)
11771181
)
1182+
LOG.warning(f"Task(s) not removable: {tasks_str} {fnums_str}")
11781183

11791184
if removed and self.pool.compute_runahead():
11801185
self.pool.release_runahead_tasks()

0 commit comments

Comments
 (0)