https://prefect.io logo
v

vinoth paari

02/09/2022, 5:00 AM
Hi How to call outside flow from task. I am getting error
k

Kevin Kho

02/09/2022, 5:03 AM
Copy code
with Flow(..) as flow:
    create_flow_run(...)
if you need to use it outside a Flow, just do
Copy code
create_flow_run.run(...)
v

vinoth paari

02/09/2022, 5:05 AM
is it possible to call flow from task?
And Not working in while loop
k

Kevin Kho

02/09/2022, 5:07 AM
If you want to use a task in another task, you have to call the .run() method explicitly but it’s not treated as a task. It’s just the Python underneath that is invoked.
What are you trying to do with the infinite loop? I would not recommend that because you should just spin up an infinite number of flow runs. I would put the infinite loop inside a task inside if you want an indefinitely running Flow.
But it’s not a pattern Prefect specifically supports
v

vinoth paari

02/09/2022, 5:11 AM
My requirement is streaming data processing Step : I will configure the One flow which is continuosly listening my API . If my API gives any reponses . It will trigger another flow where i will do some operation .
Initiate the another flow continuously like parallel process
k

Kevin Kho

02/09/2022, 5:13 AM
What is your requirement for the latency? Because Prefect can’t really do this at below 1 minute level
v

vinoth paari

02/09/2022, 5:14 AM
yes . thaty i using while loop for listing . my problem is unable to initiate another flow from task
k

Kevin Kho

02/09/2022, 5:15 AM
It’s primarily a batch orchestrator. Prefect 2.0 though will support this use case but it is still in technical preview
You can by calling
.run()
Copy code
@task
def some_task():
    create_flow_run.run(...)
but create_flow_run is not a task anymore. Just the Python under the hood
v

vinoth paari

02/09/2022, 5:16 AM
so i missed .run right?
k

Kevin Kho

02/09/2022, 5:17 AM
In this example yes but just not it’s not a task anymore.
It wont get retries and state tracking
v

vinoth paari

02/09/2022, 5:18 AM
yes it working now
2 Views