I'm back already haha - sorry. The python API for ...
# prefect-community
I'm back already haha - sorry. The python API for creating a flow run seems like a hassle to me so I may be missing something. Using the client, I can script flow runs via:
Copy code
But this requires me to store or know the flow_id, which I'd rather not do between separate scripts. Is there a reason this type of submission isn't supported?:
Copy code
client.create_flow_run(project_name, flow_name)
The CLI supports this so I expected the python API for client to as well. If it's alright, I'd like to open a feature-request on github. I think the fix will be easy. Something like:
Copy code
def create_flow_run(flow_id=None, project_name=None, flow_name=None):
	if not flow_id and not (project_name and flow_name):
		raise ValueError("Either a flow_id or a project_name+flow_name must be provided")
	# then add if/else to handle proper graphql mutation
Maybe it'll be better for the client to have a
method that returns a flow id or
given the project name and flow name. This way, you can get the flow id to pass to
and should there be some other use cases requiring flow id, they'll benefit too.
I could definitely add a get_flow_id method as well -- for the Client class, no other methods need the flow_id so it may be worth just leaving that method to a graphql query until there's more repeated need for it. I still think a single method call is easier (as oppossed to two method calls each time with get_flow_id and then create_flow_run). It looks like the create_flow_run method already takes dynamic inputs with the version_group_id option.
I'll go ahead and move this discussion to github as well. I'll assign it to myself and add these methods for us.