Running a task only on a Saturday?

Hi, I am putting together a Cylc8 workflow that comprises 3 tasks that run one after the other each day of the week and then another task that runs only on a Saturday after that day’s first 3 tasks have completed. This last task further relies on input from successful completion of the previous 7 daily tasks (Sun through Saturday inclusive).

I’m after some advice on how to best set up the Cylc graph for this workflow.

The 3 daily tasks can be covered with,

T00 = "Task1 => Task2 => Task3"

but I’m unsure on best practice to graph the final once-a-week task? By ensuring that the initial cycle point of the workflow is always a Sunday (for example 20220522T00Z), is something like,

P7D = Task3[-P6D] & Task3[-P5D] & Task3[-P4D] & Task3[-P3D] & Task3[-P2D] & Task3[-P1D] & Task3 => Task4

okay to use, or is there a more elegant way to achieve this? Here, Task4 is the once a week task to run on a Saturday only after that day’s Task3 has completed?

Thanks in advance for any advice, Stuart.

A quick follow up, with a small tweak to use,

    T00 = task1 => task2 => task3
    P6D = task3[-P6D] & task3[-P5D] & task3[-P4D] & task3[-P3D] & task3[-P2D] & task3[-P1D] & task3 => task4

I get close to what I am after, but task4 still attmepts to run on the initial cycle point of the suite, rather than waiting until the 7th day.

For an initial cycle point = 20220522T0000Z (a Sunday), the Cylc graph for the above is,

How do I get rid of the task4 instance on the very first T00Z cycle?

Thanks, Stuart.

Hi @samoore,

You’re on the right track.

is there a more elegant way to achieve this?

That’s not particularly inelegant - it clearly expresses the actual dependencies you’ve described. However, you could generate them with a Jinja2 loop.

How do I get rid of the task4 instance on the very first T00Z cycle?

There are two problems with using P6D

  • You want a 7 day cycle that lands on each Saturday, not a 6 day cycle
  • P6D is short for R/^/P6D, i.e. it starts at the initial cycle point (which you say must be a Sunday). To fix this, use the full recurrence expression with an offset starting point.

This should do it:

   cycle point format =CCYY-Www-D  # Year-Week-DayOfWeek
   initial cycle point = 20220522T0000Z  # or 2022-W21-7
   initial cycle point constraints = W-7  # Must start on a Sunday
      P1D = "task1 => task2 => task3"
      R/^+P6D/P1W = """
         {% for i in range(7) %}
            task3[-P{{i}}D] => task4
         {% endfor %}

Note I’ve used a week-based cycle point format, which makes it easy to see what’s going on for this sort of workflow, e.g. when graphing it. Just comment out that one line to revert to the normal format.

To see the effect of the Jinja2 loop:

$ cylc view -j --stdout .  # (if in the source directory)

To graph 2 weeks of the workflow:

$ cylc graph . 2022-W21 2022-W22-6

(Note you can still use week-based formats anywhere, like this, regardless of the format set in the workflow definition).

Just to add, the week-based format Hilary is using above is the ISO week calendar: ISO week date - Wikipedia

1 Like