@@ -62,6 +62,50 @@ documentation, configuration files, etc. When the workflow is :ref:`installed
62
62
equivalent directories in the :ref: `workflow_share_directories `.
63
63
64
64
65
+ .. _UnderstandingCodeInCylcConfigurations :
66
+
67
+ Understanding Code in Workflow Configurations
68
+ ---------------------------------------------
69
+
70
+ A workflow configuration is not executable code. It configures the scheduler
71
+ program to run your workflow. A `flow.cylc ` file may contain:
72
+
73
+ - Embedded Python-like Jinja2 or EmPy templating code, such as
74
+ ``{% set PLANET = "earth" %} ``
75
+ - Bash shell variable assignments and scripting, such as
76
+ ``script = "run-model.exe /path/to/data" ``
77
+
78
+ Jinja2 (or EmPy) templating code gets executed as a preprocessing step, to
79
+ programmatically generate the workflow configuration for the scheduler.
80
+ To see the result after template processing:
81
+
82
+ .. code-block :: shell
83
+
84
+ # print the workflow configuration, processed but not parsed:
85
+ $ cylc view --process < workflow-id>
86
+
87
+ # print the workflow configuration, processed and parsed:
88
+ $ cylc config < workflow-id>
89
+
90
+
91
+ The scheduler does not interpret shell syntax, but certain string-valued
92
+ config items may contain shell code that gets written verbatim to job scripts,
93
+ to be executed by the running job.
94
+
95
+ Some things to be aware of:
96
+
97
+ - Jinja2 code is evaluated once when the workflow is started.
98
+ - Jinja2 code can only reference Jinja2 variables, not Cylc config items.
99
+ - Jinja2 (like Python) has its own syntax for reading environment variables.
100
+ - Jinja2 code that reads the environment or the filesystem will do so
101
+ during config file parsing on the scheduler run host, not on job hosts.
102
+ Beware of doing this in task definitions - do you want the scheduler
103
+ environment to affect shell code that runs in the job environment?
104
+ - Shell code destined for the job script can read the environment or
105
+ access the filesystem as the job runs on the job host, not on the
106
+ scheduler host.
107
+
108
+
65
109
.. _SyntaxHighlighting :
66
110
67
111
Syntax Highlighting For Workflow Configuration
0 commit comments