I have a fairly basic question… Let’s assume I ha...
# ask-community
s
I have a fairly basic question… Let’s assume I have some Python app that uploads something to S3. Now I want to kick off my flow. So I add this to my aforementioned Python app:
Copy code
from prefect import Client

client = Client()
client.create_flow_run(flow_id="<some flow_id>")
But lo and behold, someone comes along an re-registers the flow with Cloud. The previous flow_id gets archived and a new one is generated. Now I have to go and update my Python app with the new flow_id? Can this be done by name or something? Or can I pull the flow_id as a variable? Or? Thank you.
k
Hi @Scott Vermillion, maybe you can use the StartFlowRun task which takes in project name and flow name. It uses the Client() under the hood so authentication should be the same. You can just use
StartFlowRun(…).run()
to run it.
s
Wow, thanks so much Kevin! I was not expecting a Sunday response! And that looks like exactly what I’m looking for. Happy weekend!!
Hi Kevin (et al). You mention authentication in your response. I spent the remainder of my Sunday approaching that from different angles based on what I was seeing the docs. Is it safe to say that if I want to distribute the aforementioned python app (it’s a GUI to a bunch of Python scripts, really), then anyone installing it must also install the Prefect CLI and do ‘prefect auth login’? That was all I was able to get working, in any event.
k
Yes that's right. Using the Client requires authentication so either the StartFlowRun or the client.create_flow_run will need it because they are creating new flows. If your UI is tied to new flow creation, then yes to the
prefect auth login
.
s
OK, that all seems reasonable, Kevin. I was kind of hoping there might be a way to embed auth into the UI in order to avoid the need of the separate auth, but I honestly can’t think of a way that could be done securely, so this all makes sense. Thanks very much once again!!
👍 1