Skip to content

Commit 83b2f4d

Browse files
committed
Improve function doc & add type annotations
1 parent 04bd83b commit 83b2f4d

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

cylc/flow/task_pool.py

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,8 @@ def __init__(
210210
self.config.runtime['descendants']
211211
)
212212

213-
self.tasks_to_hold: Set[Tuple[str, 'PointBase']] = set()
214-
self.tasks_to_trigger_now: Set['TaskProxy'] = set()
213+
self.tasks_to_hold: set[tuple[str, 'PointBase']] = set()
214+
self.tasks_to_trigger_now: set['TaskProxy'] = set()
215215
self.pre_start_tasks_to_trigger: set[tuple[str, 'PointBase']] = set()
216216

217217
def set_stop_task(self, task_id):
@@ -1729,8 +1729,8 @@ def can_be_spawned(self, name: str, point: 'PointBase') -> bool:
17291729
return True
17301730

17311731
def _get_task_history(
1732-
self, name: str, point: 'PointBase', flow_nums: Set[int]
1733-
) -> Tuple[int, Optional[str], bool]:
1732+
self, name: str, point: 'PointBase', flow_nums: 'FlowNums'
1733+
) -> tuple[int, str | None, bool]:
17341734
"""Get submit_num, status, flow_wait for point/name in flow_nums.
17351735
17361736
Args:
@@ -1768,7 +1768,10 @@ def _get_task_history(
17681768
return submit_num, status, flow_wait
17691769

17701770
def _load_historical_outputs(self, itask: 'TaskProxy') -> None:
1771-
"""Load a task's historical outputs from the DB."""
1771+
"""Load a task's historical outputs from the DB.
1772+
1773+
NOTE this creates a task_states/task_outputs DB entry if not present.
1774+
"""
17721775
info = self.workflow_db_mgr.pri_dao.select_task_outputs(
17731776
itask.tdef.name, str(itask.point))
17741777
if not info:
@@ -1805,9 +1808,9 @@ def spawn_task(
18051808
self,
18061809
name: str,
18071810
point: 'PointBase',
1808-
flow_nums: Set[int],
1811+
flow_nums: 'FlowNums',
18091812
flow_wait: bool = False,
1810-
) -> Optional[TaskProxy]:
1813+
) -> TaskProxy | None:
18111814
"""Return a new task proxy for the given flow if possible.
18121815
18131816
We need to hit the DB for:
@@ -1838,7 +1841,7 @@ def spawn_task(
18381841
return None
18391842

18401843
# Create the task proxy with any completed outputs loaded.
1841-
itask = self._get_task_proxy_db_outputs(
1844+
itask = self._load_db_task_proxy(
18421845
point,
18431846
self.config.get_taskdef(name),
18441847
flow_nums,
@@ -1936,7 +1939,7 @@ def _spawn_after_flow_wait(self, itask: TaskProxy) -> None:
19361939
self.workflow_db_mgr.put_update_task_flow_wait(itask)
19371940
return None
19381941

1939-
def _get_task_proxy_db_outputs(
1942+
def _load_db_task_proxy(
19401943
self,
19411944
point: 'PointBase',
19421945
taskdef: 'TaskDef',
@@ -1946,8 +1949,11 @@ def _get_task_proxy_db_outputs(
19461949
transient: bool = False,
19471950
is_manual_submit: bool = False,
19481951
submit_num: int = 0,
1949-
) -> Optional['TaskProxy']:
1950-
"""Spawn a task, update outputs from DB."""
1952+
) -> 'TaskProxy | None':
1953+
"""Spawn a task, update outputs from DB.
1954+
1955+
NOTE this creates a task_states/task_outputs DB entry if not present.
1956+
"""
19511957

19521958
if not self.can_be_spawned(taskdef.name, point):
19531959
return None
@@ -2151,7 +2157,7 @@ def set_prereqs_and_outputs(
21512157
no_op = False
21522158
else:
21532159
# Outputs (may be empty list)
2154-
trans = self._get_task_proxy_db_outputs(
2160+
trans = self._load_db_task_proxy(
21552161
icycle, tdef, flow_nums,
21562162
flow_wait=flow_wait, transient=True
21572163
)

0 commit comments

Comments
 (0)