60
60
from cylc .flow .id_cli import contains_fnmatch
61
61
from cylc .flow .id_match import filter_ids
62
62
from cylc .flow .platforms import get_platform
63
+ from cylc .flow .prerequisite import PrereqTuple
63
64
from cylc .flow .run_modes import RunMode
64
65
from cylc .flow .run_modes .skip import process_outputs as get_skip_mode_outputs
65
66
from cylc .flow .task_action_timer import (
@@ -1862,9 +1863,7 @@ def _get_task_proxy_db_outputs(
1862
1863
self ._load_historical_outputs (itask )
1863
1864
return itask
1864
1865
1865
- def _standardise_prereqs (
1866
- self , prereqs : 'List[str]'
1867
- ) -> 'Set[Tuple[str,str,str]]' :
1866
+ def _standardise_prereqs (self , prereqs : 'List[str]' ) -> 'Set[PrereqTuple]' :
1868
1867
"""Convert trigger prerequisites to task messages."""
1869
1868
_prereqs = set ()
1870
1869
for prereq in prereqs :
@@ -1889,7 +1888,7 @@ def _standardise_prereqs(
1889
1888
LOG .warning (
1890
1889
f'Invalid prerequisite cycle point:\n { exc .args [0 ]} ' )
1891
1890
else :
1892
- _prereqs .add (( cycle , pre [ " task" ] , msg ))
1891
+ _prereqs .add (PrereqTuple ( str ( cycle ), str ( pre . task ) , msg ))
1893
1892
return _prereqs
1894
1893
1895
1894
def _standardise_outputs (
@@ -1943,17 +1942,15 @@ def set_prereqs_and_outputs(
1943
1942
1944
1943
Prerequisite format: "cycle/task:output" or "all".
1945
1944
1945
+ Prerequisite validity is checked via the taskdef prior to spawning
1946
+ so we can easily back out it if no valid prerequisites are given.
1947
+
1946
1948
Set outputs:
1947
1949
- update task outputs in the DB
1948
1950
- (implied outputs are handled by the event manager)
1949
1951
- spawn children of the outputs (if not spawned)
1950
1952
- update the child prerequisites
1951
1953
1952
- Task matching restrictions (for now):
1953
- - globs (cycle and name) only match in the pool
1954
- - inactive tasks must be specified individually
1955
- - family names are not expanded to members
1956
-
1957
1954
Uses a transient task proxy to spawn children. (Even if parent was
1958
1955
previously spawned in this flow its children might not have been).
1959
1956
@@ -2052,22 +2049,22 @@ def _get_valid_prereqs(
2052
2049
set of tokens {(cycle, task, task_message),}
2053
2050
2054
2051
"""
2055
- valid : 'Set[Tuple[str, str, str]]' = set ()
2056
- for pre in tdef .get_prereqs (point ):
2057
- valid .update (list (pre .get_tuples ()))
2052
+ valid = {pre .keys () for pre in tdef .get_prereqs (point )}
2058
2053
2059
2054
# Get prerequisite tuples in terms of task messages not triggers.
2060
2055
requested = self ._standardise_prereqs (prereqs )
2061
2056
2062
2057
for prereq in requested - valid :
2063
2058
# But log bad ones in using triggers, not messages.
2064
- trg = self .config .get_taskdef (str (prereq [1 ])).get_output (prereq [2 ])
2059
+ trg = self .config .get_taskdef (
2060
+ prereq .task
2061
+ ).get_output (prereq .output )
2065
2062
LOG .warning (
2066
2063
f'{ point } /{ tdef .name } does not depend on '
2067
- f'"{ prereq [ 0 ] } / { prereq [ 1 ] } :{ trg } "'
2064
+ f'"{ prereq . get_id () } :{ trg } "'
2068
2065
)
2069
2066
return {
2070
- Tokens (cycle = pre [ 0 ] , task = pre [ 1 ] , task_sel = pre [ 2 ] )
2067
+ Tokens (cycle = pre . cycle , task = pre . task , task_sel = pre . output )
2071
2068
for pre in valid & requested
2072
2069
}
2073
2070
@@ -2076,7 +2073,10 @@ def _set_outputs_itask(
2076
2073
itask : 'TaskProxy' ,
2077
2074
outputs : Iterable [str ],
2078
2075
) -> None :
2079
- """Set requested outputs on a task proxy and spawn children."""
2076
+ """Set requested outputs on a task proxy and spawn children.
2077
+
2078
+ Designated flows should already be merged to the task proxy.
2079
+ """
2080
2080
if not outputs :
2081
2081
outputs = itask .state .outputs .iter_required_messages ()
2082
2082
else :
@@ -2119,8 +2119,10 @@ def _set_prereqs_itask(
2119
2119
prereqs : 'Iterable[Tokens]' ,
2120
2120
set_all : bool
2121
2121
):
2122
- """Set prerequisites on a task proxy."""
2123
- # (No need to check for unmatched - prereqs already validated)
2122
+ """Set prerequisites on a task proxy.
2123
+
2124
+ Designated flows should already be merged to the task proxy.
2125
+ """
2124
2126
if set_all :
2125
2127
itask .state .set_prerequisites_all_satisfied ()
2126
2128
else :
@@ -2436,7 +2438,14 @@ def filter_task_proxies(
2436
2438
warn_no_active : bool = True ,
2437
2439
inactive : bool = False ,
2438
2440
) -> 'Tuple[List[TaskProxy], Set[Tuple[TaskDef, PointBase]], List[str]]' :
2439
- """Return task proxies that match names, points, states in items.
2441
+ """Return task proxies and inactive tasks that match ids.
2442
+
2443
+ (TODO: method should be renamed to "filter_tasks").
2444
+
2445
+ Restrictions (for now):
2446
+ - globs (cycle and name) only match in the pool
2447
+ - inactive tasks must be specified individually
2448
+ - family names are not expanded to members
2440
2449
2441
2450
Args:
2442
2451
ids:
0 commit comments