#!Jinja2

[meta]
    title = task expire example workflow
    description = """
Skip a daily post-processing workflow if the 'copy' task has expired."""

[scheduler]
    cycle point format = %Y-%m-%dT%H
    allow implicit tasks = True
    cycle point time zone = {{CPTZ}}
    [[events]]
        abort on stall timeout = True
        stall timeout = PT1M
[scheduling]
    initial cycle point = now
    final cycle point = +P3D
    [[special tasks]]
        clock-expire = copy(-P1DT1H)
        # NOTE this would normally be copy(P1D) i.e. expire if more than 1 day
        # behind the wall clock, but here we have to start from 'now' in order
        # to stay near the wall clock, so expire the task if more than 1 day
        # behind "now + 1 day". This makes the first two 'copy' tasks expire.
    [[graph]]
        P1D = """
            model[-P1D] => model => copy? => proc
            copy:expired? => !proc
        """
[runtime]
    [[root]]
        script = true
    [[copy]]
        script = """
# Abort if I run in either of the first two cycle points.
test "${CYLC_TASK_CYCLE_POINT}" != "${CYLC_WORKFLOW_INITIAL_CYCLE_POINT}"
P2D="$(cylc cyclepoint --offset='P1D' "${CYLC_WORKFLOW_INITIAL_CYCLE_POINT}")"
test "${CYLC_TASK_CYCLE_POINT}" != "${P2D}"
"""
