I am writing a small Lambda function to trigger a prefect flow run on demand. I was wondering if anyone has done similar and could let me know if these queries look right
• given a flow name, get the latest version’s id
LATEST_FLOW_BY_NAME = gql(
'''
query LatestFlowByName($name: String) {
flow(
where: {name: {_eq: $name}},
order_by: {version: desc},
limit: 1,
)
{
id
}
}
''',
)
with:
variable_values={'name': name}
• trigger a flow run
CREATE_FLOW_RUN = gql(
'''
mutation CreateFlowRun($input: create_flow_run_input!) {
create_flow_run(input: $input) {id}
}
''',
)
with:
variable_values={
'input': {
'flow_id': flow_id,
'parameters': parameters,
},
},
My goal here is to specify as little as possible, to ensure the flow runs with the defaults configured for it. I.E. I don’t want to muck with the RunConfig, etc. I am mostly concerned about my logic for getting the latest flow run. I tried to grok the flow groups / versions tables but did not have much luck.