Advice on how to parametrize the environment

Hi everyone,

I am using cylc 8.6.0.

I created a simple cylc workflow that runs a model on a given HPC, let’s call it Platform1.

Now: half of our users have an account on Platform1, but the other half uses another HPC, let’s call it Platform2. All of them would like to run the exact same workflow.

Of course, on Platform2, SLURM queue, partition, module names, etc. are all different. So I started asking myself how to deal with this, without creating a completely new cylc workflow.

What I came up with is the following: I put all the platform-related variables in a separate git project, and I istall it with rose in the rose-suite.conf (as I do with the configurations, to deal with the different releases of the model).

[env]
ENV_TAG=Platform1/2
[file:env]
source=git:git@gitlab[...]my_suite_env::./::${ENV_TAG}

Now, I can install and validate without any problem. It also runs, but when I try to reaload: cylc vr my_workflow_ID fails, since in flow.cylc I have:

[[ root ]]
        # these env vars will be available to all tasks:
        [[[ environment ]]]
            %include 'env/environment.cylc'

And cylc looks for them in the cycl-src/workflow_ID, while they are present just in the cylc-run/workflow_ID folder.

At this point, I am wondering if I am doint it all wrong, and are there simpler and more “cylc/rose” way of doing this?

Thanks in advance for your help!
Stella

From a quick look, I think the short answer to your question is to use a Jinja2 include instead of Cylc’s baked in include

        [[[ environment ]]]
           {% if CYLC_WORKFLOW_RUN_DIR is defined %}
           {% include CYLC_WORKFLOW_RUN_DIR ~ 'env/environment.cylc' %}
           {% endif %}

Note CYLC_WORKFLOW_RUN_DIR will not be defined when running e.g. cylc validate on the source workflow before it has been installed - see Jinja2 — Cylc 8.6.3 documentation

Is there a reason you want to keep the platform-related variables in separate git projects? It would be simpler if you stored them with the workflow and used Jinja2 to load the correct include file. This would allow validation of the source workflow to work which means that the cylc vip command would work (as wouldcylc vr).

Thanks both!

@MetRonnie I was not aware that you can include files with jija2! This is the way to go

@dpmatthews No, I don’t. In fact my first attempt was to have two subfolders in env:

-env/
  -platform1
  -platoform2

But I could not work out how to parametrize the include, and I was looking for a different method. But now with jinja2 I do:

{% set PLATFORM = 'platform2' %}
{% set env_file = 'env/' ~ PLATFORM ~ '/environment.cylc' %}
[...]
[[[ environment ]]]
{% include env_file %}

And it works very well!

Thanks a lot for your help,
Stella