Easy way to figure out cycle point name n-cycles back (ISO date cycle format)

So I am currently working on a clean up task that is meant to clean up some temporary directories for cycle points n cycles back but for that I need to know what the desired cycle point

For example, say I’m at cycle point 10000101T000000 and I want to know what the cycle point name is. I could obviously use the recurrence information, along with the current cycle point to figure this out, but that would involve some date logic that I’d hope to avoid. It seems like there should be a simpler way to handle it.

Is there a way within cylc to figure this out? If not, any ideas on the best way to do this?

See cylc cyclepoint --help

You can use this command in the scripting of your clean-up task, to compute n-cycles back from its current point.

1 Like

Perfect! Thanks a lot @hilary.j.oliver

For advanced date-time arithmetic there is also the isodatetime command.

$ isodatetime $CYLC_TASK_CYCLE_POINT --offset='-P30D' --offset='+PT5M' --calendar=360day

Isodatetime provides the cylc-flow date-time functionality, it’s a Cylc project and a dependency of Cylc so the command should always be available in the Cylc environment. (note if you are using a wrapper script for Cylc isodatetime will need the same treatment).

1 Like

On a related note @oliver.sanders @hilary.j.oliver - say we know the following:

  • the start time of our simulation - lets call this start_date
  • the end time of our simulation (end_date), and
  • the simulation chunk size (chunk_size)

and we assign start_date as our initial cycle point

does cylc have any capabilities to easily determine all the cycle points? Specifically the final cycle point, which to be consistent in our date handling and to allow us properly set the dependencies for our final task (we need something similar to this), we need it to be the beginning date of the final task.

Or is the main option to use cylc cycle-point (or some other tool) to do the arithmetic ourselves? It’s definitely feasible for us to do so - we just want to know that we wouldn’t be duplicating technology that is built in to cylc

cc: @swartn

What do you mean exactly by chunk_size? Is it not a datetime interval?

chunk size would indeed be an interval - like P1Y etc.

Well, I may be missing your point, but Cylc does compute “all the cycle points” automatically, as the workflow runs.

Is this sort of thing not what you want?:

    allow implicit tasks = True
    initial cycle point = 2050
    final cycle point = 2055
        R1 = "prep => sim"  # first point
        P1Y = "sim[-P1Y] => sim => post"  # all P1Y points
        R1/$ = "post => beer"  # final point
        script = "sleep 1"

Note the sequence of cycle points here is determined by the initial point and the interval, not the final point (which is essentially a cut-off)… BUT recurrence expressions that explicitly reference the final point (e.g. R1/$) do work with the specified final point. So it is up to you to make sure that the final point lies on the main sequence (if that’s what you want).

If a particular task needs to know all the points in advance for some reason, you could compute them in a bash loop that repeatedly calls cylc cyclepoint.

Easier, the isodatetime command mentioned above can print points in a sequence, e.g.:

$ isodatetime -u R6/2050/P1Y

Perhaps something like this:

$ isodatetime R/<start>/<recurrence> --max=<chunks>


$ isodatetime R/2000/P1Y --max=1000