Can I expose flows through API using prefect cloud...
# ask-community
d
Can I expose flows through API using prefect cloud? A use case is that some ETLs are running in SSIS sever which is windows environment, and some programs running in other dedicated applications servers. I'm imaging that I need to install prefect agent on each server, and a dedicated flow to run programs installed on the server and then use one flow to orchestrate them together. each dedicated flow works as a task in this "parent" flow. and in each task, I could call API to trigger these flows in various servers. Does that make sense? Any better solutions? I'm newbie here.
a
@David Yang I’m sure that you can trigger a flow run via an API call from SSIS, but I don’t think it’s possible the other way around, i.e. triggering SSIS packages from Prefect. If all you need is to trigger a flow run from SSIS, you need to call the create_flow_run mutation from there.
k
Hey @David Yang, this is quite a setup, but it makes sense and can be done. First, you need an agent on each of those servers. You need to make sure each Flow runs on the right agent with the use of labels . You can trigger Flows with a main Flow using the
create_flow_run
task
I think is saying he has a main flow that will call a subflow to run on the make machine as SSIS. After that’s done, he wants to trigger more work on a different machine with another Flow.
d
Thanks Anna and Kevin. @Anna Geller, I will trigger SSIS packages from Prefect through SQL server. From SQL Server 2014(?), we can kick off SSIS packages through SQL statement although the SSIS package mode should be project mode. Legacy systems.... @Kevin Kho, Yes, we will install agent on each machine. We should use StartFlowRun or create_flow_run? I need to know the execution state.create_flow_run runs on background. seems that it runs async. Is that right?
👍 1
k
You can use the
wait_for_flow_run
to wait for it
Copy code
with Flow("parent-flow", schedule=weekday_schedule) as flow:
    
    # assumes you have registered the following flows in a project named "examples"
    flow_a = create_flow_run(flow_name="A", project_name="examples")
    wait_for_flow_a = wait_for_flow_run(flow_a, raise_final_state=True)
    
    flow_b = create_flow_run(flow_name="B", project_name="examples")
    wait_for_flow_b = wait_for_flow_run(flow_b, raise_final_state=True)
💯 1
1