Hi,
I need to get the following values in multiple tasks
NEXT_CYCLE_POINT=$($ISODATETIME ${CYLC_TASK_CYCLE_POINT} --offset1=P1M)
RUN_DURATION_HOURS=$($ISODATETIME ${CYLC_TASK_CYCLE_POINT} ${NEXT_CYCLE_POINT} --as-total H)
Is there a way to make these calculations just once and make them available to all the tasks within a CYCLE_POINT?
Thanks,
Is there a way to make these calculations just once
No.
make them available to all the tasks within a CYCLE_POINT?
Yes.
This will make these environment variables available to all tasks, but it won’t save on the compute cost of running the isodatetime
command:
[runtime]
[[root]]
[[[environment]]]
NEXT_CYCLE_POINT=$($ISODATETIME ${CYLC_TASK_CYCLE_POINT} --offset1=P1M)
RUN_DURATION_HOURS=$($ISODATETIME ${CYLC_TASK_CYCLE_POINT} ${NEXT_CYCLE_POINT} --as-total H)
That said, isodatetime
should be reasonably quick.
Actually there is. The first task in the cycle point could compute the values, then use cylc broadcast
to set them in the environment of all upcoming tasks in the same cycle point.
However, I’d just use @oliver.sanders 's solution (which amounts to having every task compute the same values, but it’s easy).
Good point about broadcast!