20
20
21
21
Print information about a running workflow.
22
22
23
+ This command can provide information about active tasks, e.g. running or queued
24
+ tasks. For more detailed view of the workflow see `cylc tui` or `cylc gui`.
25
+
23
26
For command line monitoring:
24
27
* `cylc tui`
25
28
* `watch cylc dump WORKFLOW_ID` works for small simple workflows
28
31
its prerequisites and outputs, see 'cylc show'.
29
32
30
33
Examples:
31
- # Display the state of all running tasks, sorted by cycle point:
34
+ # Display the state of all active tasks, sorted by cycle point:
32
35
$ cylc dump --tasks --sort WORKFLOW_ID | grep running
33
36
34
- # Display the state of all tasks in a particular cycle point:
37
+ # Display the state of all active in a particular cycle point:
35
38
$ cylc dump -t WORKFLOW_ID | grep 2010082406
36
39
"""
37
40
38
- from graphene . utils . str_converters import to_snake_case
41
+ import asyncio
39
42
import json
40
- import sys
41
43
from typing import TYPE_CHECKING
42
44
45
+ from graphene .utils .str_converters import to_snake_case
46
+
43
47
from cylc .flow .exceptions import CylcError
44
- from cylc .flow .id_cli import parse_id
48
+ from cylc .flow .id_cli import parse_id_async
45
49
from cylc .flow .option_parsers import (
46
50
WORKFLOW_ID_ARG_DOC ,
47
51
CylcOptionParser as COP ,
59
63
name
60
64
cyclePoint
61
65
state
66
+ graphDepth
62
67
isHeld
63
68
isQueued
64
69
isRunahead
@@ -179,7 +184,11 @@ def get_option_parser():
179
184
180
185
@cli_function (get_option_parser )
181
186
def main (_ , options : 'Values' , workflow_id : str ) -> None :
182
- workflow_id , * _ = parse_id (
187
+ asyncio .run (dump (workflow_id , options ))
188
+
189
+
190
+ async def dump (workflow_id , options , write = print ):
191
+ workflow_id , * _ = await parse_id_async (
183
192
workflow_id ,
184
193
constraint = 'workflows' ,
185
194
)
@@ -195,6 +204,9 @@ def main(_, options: 'Values', workflow_id: str) -> None:
195
204
else :
196
205
sort_args = {'keys' : ['name' , 'cyclePoint' ]}
197
206
207
+ # retrict to the n=0 window
208
+ graph_depth = 0
209
+
198
210
if options .disp_form == "raw" :
199
211
query = f'''
200
212
{ TASK_SUMMARY_FRAGMENT }
@@ -203,10 +215,10 @@ def main(_, options: 'Values', workflow_id: str) -> None:
203
215
query ($wFlows: [ID]!, $sortBy: SortArgs) {{
204
216
workflows (ids: $wFlows, stripNull: false) {{
205
217
...wFlow
206
- taskProxies (sort: $sortBy) {{
218
+ taskProxies (sort: $sortBy, graphDepth: { graph_depth } ) {{
207
219
...tProxy
208
220
}}
209
- familyProxies (sort: $sortBy) {{
221
+ familyProxies (sort: $sortBy, graphDepth: { graph_depth } ) {{
210
222
...fProxy
211
223
}}
212
224
}}
@@ -224,7 +236,7 @@ def main(_, options: 'Values', workflow_id: str) -> None:
224
236
{ TASK_SUMMARY_FRAGMENT }
225
237
query ($wFlows: [ID]!, $sortBy: SortArgs) {{
226
238
workflows (ids: $wFlows, stripNull: false) {{
227
- taskProxies (sort: $sortBy) {{
239
+ taskProxies (sort: $sortBy, graphDepth: { graph_depth } ) {{
228
240
...tProxy
229
241
}}
230
242
}}
@@ -235,15 +247,15 @@ def main(_, options: 'Values', workflow_id: str) -> None:
235
247
'variables' : {'wFlows' : [workflow_id ], 'sortBy' : sort_args }
236
248
}
237
249
238
- workflows = pclient ('graphql' , query_kwargs )
250
+ workflows = await pclient . async_request ('graphql' , query_kwargs )
239
251
240
252
try :
241
253
for summary in workflows ['workflows' ]:
242
254
if options .disp_form == "raw" :
243
255
if options .pretty :
244
- sys . stdout . write (json .dumps (summary , indent = 4 ) + ' \n ' )
256
+ write (json .dumps (summary , indent = 4 ))
245
257
else :
246
- print (summary )
258
+ write (summary )
247
259
else :
248
260
if options .disp_form != "tasks" :
249
261
node_urls = {
@@ -261,7 +273,7 @@ def main(_, options: 'Values', workflow_id: str) -> None:
261
273
del summary ['families' ]
262
274
del summary ['meta' ]
263
275
for key , value in sorted (summary .items ()):
264
- print (
276
+ write (
265
277
f'{ to_snake_case (key ).replace ("_" , " " )} ={ value } ' )
266
278
else :
267
279
for item in summary ['taskProxies' ]:
@@ -282,7 +294,7 @@ def main(_, options: 'Values', workflow_id: str) -> None:
282
294
else 'not-runahead' )
283
295
if options .show_flows :
284
296
values .append (item ['flowNums' ])
285
- print (', ' .join (values ))
297
+ write (', ' .join (values ))
286
298
except Exception as exc :
287
299
raise CylcError (
288
300
json .dumps (workflows , indent = 4 ) + '\n ' + str (exc ) + '\n ' )
0 commit comments