Skip to content

Commit 59c9f41

Browse files
authored
Troubleshooting: Notes on Jinja2 and Startup config logs (#735)
1 parent 3b103f1 commit 59c9f41

File tree

2 files changed

+134
-1
lines changed

2 files changed

+134
-1
lines changed

src/user-guide/troubleshooting.rst

Lines changed: 132 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,23 @@ for debugging some specific issues:
6161
These files can allow you to see how the configuration was changed between
6262
restarts and reloads.
6363

64+
Each time a workflow is started, restarted or reloaded,
65+
the configuration used is recorded in a file in ``log/config``.
66+
This provides a series of snapshots of the configuration.
67+
These files are named:
68+
69+
``<LOG FILE NUMBER>-<EVENT>-<(RE)START NUMBER>``.
70+
71+
If for example we did:
72+
73+
.. code-block:: console
74+
75+
# Command # File created
76+
cylc play workflow # 01-start-01.cylc
77+
cylc vr workflow # 02-reload-01.cylc
78+
cylc stop workflow
79+
cylc play workflow # 03-restart-02.cylc
80+
6481
6582
Shell Login/Profile Files
6683
-------------------------
@@ -219,7 +236,7 @@ To find out more, see the ``job.err`` file.
219236
.. note::
220237

221238
To ensure Cylc jobs fail when they are supposed to, Cylc configures Bash
222-
to be a bit stricter than it is by default by running ``set -euo pipefail``.
239+
to be stricter than it is by default by running ``set -euo pipefail``.
223240

224241
.. cylc-scope:: flow.cylc[runtime][<namespace>]
225242

@@ -229,6 +246,11 @@ To find out more, see the ``job.err`` file.
229246

230247
.. cylc-scope::
231248

249+
.. tip::
250+
251+
One particularly common issue when developing a workflow is failure
252+
to make a script executable. Use ``ls -l`` to check.
253+
232254
If you're struggling to track down the error, you might want to put the
233255
workflow into debug mode::
234256

@@ -470,6 +492,115 @@ environments. If you encounter this issue in combination with containers,
470492
please let us know.
471493

472494

495+
Debugging Workflow Configurations
496+
---------------------------------
497+
498+
Cylc Debugging Utilities
499+
^^^^^^^^^^^^^^^^^^^^^^^^
500+
501+
.. seealso::
502+
503+
:ref:`user-guide.cheat_sheet`
504+
505+
506+
Cylc comes with a number of utilities designed to allow inspection of
507+
workflows:
508+
509+
``cylc view``
510+
Prints workflow configurations before full parsing by Cylc. This
511+
can include :ref:`Jinja2 <troubleshooting.jinja2>` (use ``-j``)
512+
or Empy template processing.
513+
514+
Include files can be inlined (use ``-i``).
515+
516+
``cylc config``
517+
Prints all or part of the workflow configuration after Cylc has parsed the file
518+
and expanded the runtime inheritance hierarchy. For example:
519+
520+
.. code-block:: cylc
521+
522+
[runtime]
523+
[[root]]
524+
execution time limit = PT5S
525+
[[FAMILY]]
526+
pre-script = sleep 15
527+
[[foo, bar]]
528+
script = echo 'Hello'
529+
[[bar]]
530+
inherit = FAMILY
531+
post-script = echo 'World'
532+
533+
would be shown as (revealing in this example why task ``bar``
534+
always fails):
535+
536+
.. code-block:: cylc
537+
538+
[runtime]
539+
[[root]]
540+
execution time limit = PT5S
541+
[[FAMILY]]
542+
execution time limit = PT5S
543+
pre-script = sleep 15
544+
[[foo]]
545+
execution time limit = PT5S
546+
script = echo 'Hello'
547+
[[bar]]
548+
execution time limit = PT5S
549+
pre-script = sleep 15
550+
script = echo 'Hello'
551+
inherit = FAMILY
552+
post-script = echo 'World'
553+
554+
555+
``cylc lint``
556+
#. Checks the config against the :ref:`style_guide`.
557+
#. Looks for deprecated Cylc 7 configurations and recommends
558+
Cylc 8 configurations to replace them.
559+
560+
.. seealso::
561+
562+
:ref:`cylc_lint_script`
563+
564+
``cylc validate``
565+
566+
Validates the workflow configuration.
567+
568+
.. seealso::
569+
570+
:ref:`Validation`
571+
572+
.. _troubleshooting.jinja2:
573+
574+
See what the Jinja2 is doing
575+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
576+
577+
It can sometimes be difficult to understand what Jinja2
578+
templating is doing to a workflow configuration.
579+
580+
``cylc view --process`` (or ``-p``) shows you what the
581+
configuration will look like after Jinja2 processing.
582+
583+
For example:
584+
585+
.. code-block::
586+
587+
{% for n in my_function(3) %}
588+
R/1983/P{{n}}Y = cicada_{{n}}[-P{{n}}Y] => cicada_{{n}}
589+
{% endfor %}
590+
591+
is much easier to understand as:
592+
593+
.. code-block:: cylc-graph
594+
595+
R/1983/P2Y = cicada_2[-P2Y] => cicada_2
596+
R/1983/P3Y = cicada_3[-P3Y] => cicada_3
597+
R/1983/P5Y = cicada_5[-P5Y] => cicada_5
598+
599+
If you have installed and played a workflow
600+
(even using ``play --pause``) this processed content
601+
is shown in ``log/config/flow-processed.cylc``.
602+
603+
473604
Getting Help
474605
------------
475606

src/workflow-design-guide/style-guide.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.. _style_guide:
2+
13
Style Guidelines
24
================
35

0 commit comments

Comments
 (0)