| 1 |
.. _examples.extending-workflow: |
| 2 |
|
| 3 |
Extending Workflow |
| 4 |
------------------ |
| 5 |
|
| 6 |
.. cylc-scope:: flow.cylc[scheduling] |
| 7 |
|
| 8 |
Sometimes we may run a workflow to :ref:`completion <workflow completion>`, |
| 9 |
but subsequently wish to run it for a few more cycles. |
| 10 |
|
| 11 |
With Cylc 7 this was often done by changing the `final cycle point` and |
| 12 |
restarting the workflow. This approach worked, but was a little awkward. |
| 13 |
It's possible with Cylc 8, but we would recommend moving away from this |
| 14 |
pattern instead. |
| 15 |
|
| 16 |
The recommended approach to this problem (Cylc 6+) is to use the |
| 17 |
`stop after cycle point` rather than the `final cycle point`. |
| 18 |
|
| 19 |
The `stop after cycle point` tells Cylc to **stop** after the workflow passes |
| 20 |
the specified point, whereas the `final cycle point` tells Cylc that the |
| 21 |
workflow **finishes** at the specified point. |
| 22 |
|
| 23 |
When a workflow **finishes**, it is a little awkward to restart as you have to |
| 24 |
tell Cylc which tasks to continue on from. The `stop after cycle point` |
| 25 |
solution avoids this issue. |
| 26 |
|
| 27 |
|
| 28 |
Example |
| 29 |
^^^^^^^ |
| 30 |
|
| 31 |
.. admonition:: Get a copy of this example |
| 32 |
:class: hint |
| 33 |
|
| 34 |
.. code-block:: console |
| 35 |
|
| 36 |
$ cylc get-resources examples/extending-workflow/simple |
| 37 |
|
| 38 |
This workflow will stop at the end of the ``2002`` cycle: |
| 39 |
|
| 40 |
.. literalinclude:: simple/flow.cylc |
| 41 |
:language: cylc |
| 42 |
|
| 43 |
After it has run and shut down, change the `stop after cycle point` to |
| 44 |
the desired value and restart it. E.g: |
| 45 |
|
| 46 |
.. code-block:: bash |
| 47 |
|
| 48 |
# install and run the workflow: |
| 49 |
cylc vip |
| 50 |
|
| 51 |
# then later edit "stop after cycle point" to "2004" |
| 52 |
|
| 53 |
# then reinstall and restart the workflow: |
| 54 |
cylc vr |
| 55 |
|
| 56 |
The workflow will continue from where it left off and run until the end of the |
| 57 |
``2004`` cycle. Because the workflow never hit the `final cycle point` it |
| 58 |
never "finished" so no special steps are required to restart the workflow. |
| 59 |
|
| 60 |
You can also set the `stop after cycle point` when you start the workflow: |
| 61 |
|
| 62 |
.. code-block:: bash |
| 63 |
|
| 64 |
cylc play --stop-cycle-point=2020 myworkflow |
| 65 |
|
| 66 |
Or change it at any point whilst the workflow is running: |
| 67 |
|
| 68 |
.. code-block:: bash |
| 69 |
|
| 70 |
cylc stop myworkflow//2030 # change the stop after cycle point to 2030 |
| 71 |
|
| 72 |
.. note:: |
| 73 |
|
| 74 |
If you set the `stop after cycle point` on the command line, this value will |
| 75 |
take precedence over the one in the workflow configuration. Use |
| 76 |
``cylc play --stop-cycle-point=reload`` to restart the workflow using the |
| 77 |
`stop after cycle point` configured in the workflow configuration. |
| 78 |
|
| 79 |
|
| 80 |
Running Tasks At The `stop after cycle point` |
| 81 |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 82 |
|
| 83 |
If you have tasks that you want to run before the workflow shuts down at the |
| 84 |
`stop after cycle point`, use the recurrence ``R1/<cycle-point>`` to schedule |
| 85 |
them, e.g: |
| 86 |
|
| 87 |
.. code-block:: cylc |
| 88 |
|
| 89 |
#!Jinja2 |
| 90 |
|
| 91 |
{% set stop_cycle = '3000' %} |
| 92 |
|
| 93 |
[scheduling] |
| 94 |
initial cycle point = 2000 |
| 95 |
stop after cycle point = {{ stop_cycle }} |
| 96 |
[[graph]] |
| 97 |
R1/{{ stop_cycle }} = """ |
| 98 |
# these tasks will run *before* the workflow shuts down |
| 99 |
z => run_me => and_me |
| 100 |
""" |
| 101 |
|
| 102 |
When the workflow is subsequently restarted with a later |
| 103 |
`stop after cycle point`, these tasks will be re-scheduled at the new |
| 104 |
stop point. |
| 105 |
|
| 106 |
|
| 107 |
.. cylc-scope:: |