Optional task - not optional outputs?

Is there a way to have a task be optional to even run? I’ve tried having a ? after a task which doesn’t get triggered, but, that doesn’t work - I believe optional outputs require a task to at least run.

For example, say you had

[[xtriggers]
    must_start = wall_clock(offset=PT6H)
    data_avail_for_A = workflow_state(....)

and a graph like

    @must_start => start_run
    @data_avail_for_A => A_data_avail
    start_run | A_data_avail => process

Assume the workflow should be able to run even if data_avail_for_A is not met - its optional data. How would I do this natively in Cylc and not hit runahead limits? I do have xtriggers which can auto-succeed after a time window has elapsed (from first poll or from an offset from the tasks cycle), but I was curious if Cylc understood this type of optional?

We have required and optional task outputs, so that if a task achieves a final status Cylc can determine whether or not it completed all the outputs that the workflow expected it to.

We don’t have “optional tasks” except in the sense that any task on a branch downstream of an optional output obviously won’t need to run unless that branch gets taken at run time.

Once a task gets spawned into the n=0 active window (a) by one of its prerequisites becoming satisfied, or (b) by the scheduler if it doesn’t have any task prerequisites at all; then it must complete or else be removed (by cylc remove or suicide trigger).

Your xtriggered task falls into category (b). The scheduler spawns it within the runahead limit, at which point it can start checking the xtrigger function. At that point, the task is waiting on the xtrigger to become satisfied. Cylc only distinguishes between “not yet satisfied” (still waiting) and “satisfied” (trigger the task now).

We don’t support the concept of “it will never become satisfied so stop checking and remove the task” - that is one of the few remaining use cases in Cylc 8 for suicide triggers, i.e. remove this waiting task from the active window because circumstances dictate that we no longer need to run it.

So I think you would just need to add start_run => !A_data_avail to the graph.

Automatic task expire might work too, if it is time that determines whether or not the data is available or needed.

Ultimately I’d like to have xtriggers that actively spawn dependent tasks rather than spawned tasks that “have” xtriggers, but that’s TBD and not a high priority.

Thanks for the advice. I’v been too long in Cylc8 and didn’t even think of suicide triggers. I’ve opted for the clock-expire approach you suggested though as I think that best represents what is intended to be happening, whereas removing the task via a suicide trigger just hides what is going on.

1 Like