Skip to content

Commit

Permalink
update workflow examples
Browse files Browse the repository at this point in the history
  • Loading branch information
wxtim committed Jun 13, 2024
1 parent 7db7ae5 commit 8edf19b
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 35 deletions.
32 changes: 32 additions & 0 deletions workflow-state-triggers/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Inter-cycling triggering

A demo of using `cylc workflow-state` in other workflows.

This workflow doesn't do much because it's there for the others
to trigger off from:

# xtrigger

The most up-to-date way of doing inter-workflow triggering
using the provided workflow_state xtrigger.

---

# old notation

classic offset notation.

Included in example for reference only - in general
you should prefer xtriggers.

---

# CLI script

Use the CLI ``cylc workflow-state`` command to poll
for the state of the "first" workflow.

---

Written for Cylc Version: 8
Tested with Cylc Version: 8.3.0.dev
23 changes: 5 additions & 18 deletions workflow-state-triggers/classic/flow.cylc
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
[meta]
title = the first workflow of which others are triggered
title = old notation
description = """
A demo of using `cylc workflow-state` in other workflows.
classic offset notation.
This workflow triggers a series of events, if and only
if, the year is 1066.
The test `is_1066` is totally trivial, and doesn't really
need to reach another flow, but it does for the sake of example.
Included in example for reference only - in general
you should prefer xtriggers.
"""
written for cylc = 8
tested with cylc = 8.3.0.dev@f41602137

[scheduler]
allow implicit tasks = true
Expand All @@ -19,12 +14,4 @@
[scheduling]
initial cycle point = 1066
[[graph]]
R1 = is_1066:succeeded? => arrow => Harold => eye

[runtime]
[[is_1066]]
script = """
cylc workflow-state first --task-pointnfvasjkngjan --point 1065 --status succeeded --task anglo_saxon_chronicle --output foo
"""
[[[meta]]]
description = The chronicle for 1065 has been written.
R1 = snark<first::anglo_saxon_chronicle:succeeded> => arrow => Harold => eye
17 changes: 10 additions & 7 deletions workflow-state-triggers/first/flow.cylc
Original file line number Diff line number Diff line change
@@ -1,26 +1,29 @@
[meta]
title = the first workflow of which others are triggered
title = Inter-cycling triggering
description = """
A demo of using `cylc workflow-state` in other workflows.
This workflow doesn't do much because it's there for the others
to trigger off from.
to trigger off from:
"""
written for cylc = 8
tested with cylc = 8.3.0.dev@f41602137
written for cylc version = 8
tested with cylc version = 8.3.0.dev

[scheduler]
allow implicit tasks = true
# cycle point format = %Y
cycle point format = %Y

[scheduling]
initial cycle point = 1060
final cycle point = 1070
[[graph]]
P1Y = anglo_saxon_chronicle
P1Y = anglo_saxon_chronicle[-P1Y] => anglo_saxon_chronicle

[runtime]
[[anglo_saxon_chronicle]]
script = cylc message -- hardrada
script = """
sleep 5
cylc message -- "Six foot of English ground"
"""
[[[outputs]]]
hardrada = 'Six foot of English ground'
36 changes: 36 additions & 0 deletions workflow-state-triggers/script/flow.cylc
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
[meta]
title = "CLI script"
description = """
Use the CLI ``cylc workflow-state`` command to poll
for the state of the "first" workflow.
"""

[scheduler]
allow implicit tasks = true
cycle point format = %Y

[scheduling]
initial cycle point = 1066
[[graph]]
R1 = """
is_in_normandie:succeeded? => swear_an_oath
is_insult:succeeded? => send_insult
"""

[runtime]
[[HAND_ROLLED_WORKFLOW_STATE_TRIGGER]]
script = """
cylc workflow-state \
first//1065/anglo_saxon_chronicle:${OUTPUT} \
--max-polls=50
"""

[[is_in_normandie]]
inherit = HAND_ROLLED_WORKFLOW_STATE_TRIGGER
[[[environment]]]
OUTPUT="succeeded"

[[is_insult]]
inherit = HAND_ROLLED_WORKFLOW_STATE_TRIGGER
[[[environment]]]
OUTPUT="hardrada"
15 changes: 5 additions & 10 deletions workflow-state-triggers/xtrigger/flow.cylc
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
[meta]
title = the first workflow of which others are triggered
title = xtrigger
description = """
A demo of using `cylc workflow-state` in other workflows.
This workflow triggers a series of events, if and only
if, the year is 1068.
It uses xtriggers to achieve this.
The most up-to-date way of doing inter-workflow triggering
using the provided workflow_state xtrigger.
"""
written for cylc = 8
tested with cylc = 8.3.0.dev@f41602137

[scheduler]
allow implicit tasks = true
# cycle point format = %Y
cycle point format = %Y

[scheduling]
# initial cycle point = 1066
[[graph]]
R1 = @is_1068 => domesday & tapestry # It's an embroidery
[[xtriggers]]
# is_1068 = workflow_state(workflow_task_id=first//1068/anglo_saxon_chronicle:succeeded, offset=None, alt_cylc_run_dir=None)
is_1068 = workflow_state('first', task='anglo_saxon_chronicle', point='1068', status='succeeded')

0 comments on commit 8edf19b

Please sign in to comment.