<@U01J90KBSU9> in the video you linked, they brief...
# ask-the-community
e
@Samhita Alla 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?
s
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.
e
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
s
What do you mean by real dynamic?
e
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
s
Yeah.
while True
won't work. There should exist some sort of determinism.
n
Hi @ewam 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
k
@Niels Bantilan 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
100 Views