|
| 1 | +Extending Workflow |
| 2 | +================== |
| 3 | + |
| 4 | +.. cylc:scope:: [scheduling] |
| 5 | +
|
| 6 | +Sometimes we may run a workflow to completion, but subsequently wish to |
| 7 | +run it for a few more cycles. |
| 8 | + |
| 9 | +With Cylc 7 this was often done by changing the `final cycle point` and |
| 10 | +restarting the workflow. This approach worked, but was a little awkward. |
| 11 | +It's possible with Cylc 8, but we would recommend moving away from this |
| 12 | +pattern instead. |
| 13 | + |
| 14 | +The recommended approach to this problem (Cylc 6+) is to use the |
| 15 | +`stop after cycle point` rather than the `final cycle point`. |
| 16 | + |
| 17 | +The `stop after cycle point` tells Cylc to **stop** after the workflow passes |
| 18 | +the specified point, whereas the `final cycle point` tells Cylc that the |
| 19 | +workflow **finishes** at the specified point. |
| 20 | + |
| 21 | +When a workflow **finishes**, it is a little awkward to restart as you have to |
| 22 | +tell Cylc which tasks to continue on from. The `stop after cycle point` |
| 23 | +solution avoids this issue. |
| 24 | + |
| 25 | + |
| 26 | +Simple Example |
| 27 | +-------------- |
| 28 | + |
| 29 | +.. admonition:: Get a copy of this example |
| 30 | + :class: hint |
| 31 | + |
| 32 | + .. code-block:: console |
| 33 | +
|
| 34 | + $ cylc get-resources examples/extending-workflow/simple |
| 35 | +
|
| 36 | +This workflow will stop at the end of the ``2002`` cycle: |
| 37 | + |
| 38 | +.. literalinclude:: simple/flow.cylc |
| 39 | + :language: cylc |
| 40 | + |
| 41 | +After it has run and shut down, change the `stop after cycle point` to |
| 42 | +the desired value and restart it. E.g: |
| 43 | + |
| 44 | +.. code-block:: bash |
| 45 | +
|
| 46 | + # install and run the workflow: |
| 47 | + cylc vip |
| 48 | +
|
| 49 | + # then later edit "stop after cycle point" to "2004" |
| 50 | +
|
| 51 | + # then reinstall and restart the workflow: |
| 52 | + cylc vr |
| 53 | +
|
| 54 | +The workflow will continue from where it left off and run until the end of the |
| 55 | +``2004`` cycle. Because the workflow never hit the `final cycle point` it |
| 56 | +never "finished" so no special steps are required to restart the workflow. |
| 57 | + |
| 58 | +You can also set the `stop after cycle point` when you start the workflow: |
| 59 | + |
| 60 | +.. code-block:: bash |
| 61 | +
|
| 62 | + cylc play --stop-cycle-point=2020 myworkflow |
| 63 | +
|
| 64 | +Or change it at any point whilst the workflow is running: |
| 65 | + |
| 66 | +.. code-block:: bash |
| 67 | +
|
| 68 | + cylc stop myworkflow//2030 # change the stop after cycle point to 2030 |
| 69 | +
|
| 70 | +.. note:: |
| 71 | + |
| 72 | + If you set the `stop after cycle point` on the command line, this value will |
| 73 | + take precedence over the one in the workflow configuration. Use |
| 74 | + ``cylc play --stop-cycle-point=reload`` to restart the workflow using the |
| 75 | + `stop after cycle point` configured in the workflow configuration. |
| 76 | + |
| 77 | + |
| 78 | +Complex Example |
| 79 | +--------------- |
| 80 | + |
| 81 | +.. admonition:: Get a copy of this example |
| 82 | + :class: hint |
| 83 | + |
| 84 | + .. code-block:: console |
| 85 | +
|
| 86 | + $ cylc get-resources examples/extending-workflow/complex |
| 87 | +
|
| 88 | +Sometimes we may want to run some tasks at the `final cycle point` or in the |
| 89 | +cycles leading up to the `final cycle point`. For example you might have some |
| 90 | +analysis or housekeeping tasks to run at the end of the workflow. |
| 91 | + |
| 92 | +We can schedule such task like so: |
| 93 | + |
| 94 | +.. code-block:: cylc |
| 95 | +
|
| 96 | + # run once in the "2000" cycle |
| 97 | + R1/2000 # 2000 |
| 98 | +
|
| 99 | + # run every year three times ending in 2000 |
| 100 | + R3/P1Y/2000 # 1998, 1999, 2000 |
| 101 | +
|
| 102 | +For more information see :ref:`user_guide.cycling_format_4`. |
| 103 | + |
| 104 | +This example uses Jinja2 to template the cycling expressions above to schedule |
| 105 | +tasks to run at, and in the run up to, the `stop after cycle point`: |
| 106 | + |
| 107 | +.. literalinclude:: complex/flow.cylc |
| 108 | + :language: cylc |
| 109 | + |
| 110 | +.. code-block:: bash |
| 111 | +
|
| 112 | + # install and run the workflow: |
| 113 | + cylc vip |
| 114 | +
|
| 115 | + # then reinstall and restart the workflow extending the stop cycle: |
| 116 | + cylc vr -s stop_cycle=2020 |
| 117 | +
|
| 118 | +
|
| 119 | +.. cylc:scope:: |
0 commit comments