<@U01J90KBSU9> in the video you linked, they brief...
# flyte-support
f
@tall-lock-23197 in the video you linked, they briefly say you could implement "periodic triggers" using
sleep
(attached screenshot). But there is no example given, unfortunately. Therefore, I'm asking here again: How would you use
sleep
to trigger a task periodically inside a `@dynamic`workflow and how would the DAG look like in that case?
t
Here's an example:
Copy code
from datetime import timedelta

from flytekit import dynamic, task
from flytekit.core.gate import sleep


@task
def t1(a: int):
    ...


@dynamic
def wf_sleep(n: int):
    for i in range(n):
        x = sleep(timedelta(minutes=10))
        b = t1(a=5)
        x >> b
t1
task will be triggered
n
number of times with a fixed interval of 10 minutes between every two triggers.
f
Thanks!
My misunderstandings come from the fact that I expected
@dynamic
workflows to be "real" dynamic. But unfortunately, they still require a known DAG. "Real" dynamic DAGs would be a nice addition to flyte imho
t
What do you mean by real dynamic?
f
Copy code
from datetime import timedelta

from flytekit import dynamic, task
from flytekit.core.gate import sleep


@task
def t1(a: int):
    ...


@dynamic
def wf_sleep():
    while True:
        x = sleep(timedelta(minutes=10))
        b = t1(a=5)
        x >> b
i.e. not just DAG support but also loop support
above
dynamic
workflow cannot be evaluated pre runtime (while True)
but as I understand it, this is a requirement
what I need is truly event-driven task pipelines I guess
t
Yeah.
while True
won't work. There should exist some sort of determinism.
b
Hi @flaky-car-61813 can you expand on what you mean by “real dynamic”? Might be useful to write psuedo-code in plain Python to show the desired behavior
f
@broad-monitor-993 his code indicates that he wants to interact with the outputs of a task execution in python and then launch another task. This is what we have been calling eager or async/await
152 Views