cylc / cylc-doc

Documentation (User Guide, Cheat Sheets, etc.) for the Cylc Workflow Engine.
https://cylc.github.io/cylc-doc/
GNU General Public License v3.0
9 stars 19 forks source link

Update Jinja2 and EmPy templating sections. #631

Closed hjoliver closed 1 year ago

hjoliver commented 1 year ago

Requirements check-list

hjoliver commented 1 year ago

(Assigned reviewers of the cylc-flow sibling PR).

hjoliver commented 1 year ago

Test case, to confirm the docs:

#!Jinja2
[scheduling]
   [[graph]]
      R1 = "foo"
[runtime]
   [[foo]]
      script = """
# ALL:
echo   CYLC_VERSION {{CYLC_VERSION}}
echo   CYLC_WORKFLOW_NAME {{CYLC_WORKFLOW_NAME}}
echo   CYLC_TEMPLATE_VARS {{CYLC_TEMPLATE_VARS}}

# ONLY if installed:
echo   CYLC_WORKFLOW_ID {{CYLC_WORKFLOW_ID | default("xxxxxxxxxxxx")}}
echo   CYLC_WORKFLOW_RUN_DIR {{CYLC_WORKFLOW_RUN_DIR   | default("xxxxxxxxxxxx")}}

# ONLY if running:
echo   CYLC_WORKFLOW_LOG_DIR {{CYLC_WORKFLOW_LOG_DIR   | default("xxxxxxxxxxxx")}}
echo   CYLC_WORKFLOW_SHARE_DIR {{CYLC_WORKFLOW_SHARE_DIR | default("xxxxxxxxxxxx")}}
echo   CYLC_WORKFLOW_WORK_DIR {{CYLC_WORKFLOW_WORK_DIR  | default("xxxxxxxxxxxx")}}
      """

Result:

cylc-src/bug $ cylc config -i '[runtime][foo]script' .  # src
# ALL:
echo   CYLC_VERSION 8.3.0.dev
echo   CYLC_WORKFLOW_NAME bug
echo   CYLC_TEMPLATE_VARS {'CYLC_VERSION': '8.3.0.dev', 'CYLC_TEMPLATE_VARS': {...}}
# ONLY if installed:
echo   CYLC_WORKFLOW_ID xxxxxxxxxxxx
echo   CYLC_WORKFLOW_RUN_DIR xxxxxxxxxxxx
# ONLY if running:
echo   CYLC_WORKFLOW_LOG_DIR xxxxxxxxxxxx
echo   CYLC_WORKFLOW_SHARE_DIR xxxxxxxxxxxx
echo   CYLC_WORKFLOW_WORK_DIR xxxxxxxxxxxx

cylc-src/bug $ cylc config -i '[runtime][foo]script' bug  # installed
# ALL:
echo   CYLC_VERSION 8.3.0.dev
echo   CYLC_WORKFLOW_NAME bug
echo   CYLC_TEMPLATE_VARS {'CYLC_VERSION': '8.3.0.dev', 'CYLC_TEMPLATE_VARS': {...}}
# ONLY if installed:
echo   CYLC_WORKFLOW_ID bug/run19
echo   CYLC_WORKFLOW_RUN_DIR /home/oliverh/cylc-run/bug/run19
# ONLY if running:
echo   CYLC_WORKFLOW_LOG_DIR xxxxxxxxxxxx
echo   CYLC_WORKFLOW_SHARE_DIR xxxxxxxxxxxx
echo   CYLC_WORKFLOW_WORK_DIR xxxxxxxxxxxx
hjoliver commented 1 year ago

Merged your two suggestions @MetRonnie