Said
09/27/2024, 1:00 PMasync def trigger_flow():
async with get_client() as client:
# Retrieve the deployment by name
deployment = await client.read_deployment_by_name('my-first-deployment')
# Create a flow run from the deployment
flow_run = await client.create_flow_run_from_deployment(
deployment_id=deployment.id,
parameters={"data": "Hello, Prefect!"} # Pass your input data here
)
print(f"Flow run created with ID: {flow_run.id}")
# Run the trigger function
if __name__ == "__main__":
asyncio.run(trigger_flow())
I'm using prefect 3, and I tried using the OrionClient which your bot "Marvin" suggested but I encountered a module not found error.
As for the code above: the error is: prefect.exceptions.ObjectNotFound
which is weird because when I query the api directly using the deployment_id I get this:
{
"id": "db8049f9-f7fc-4439-8e03-a2250f745f08",
"created": "2024-09-27T12:15:51.644191Z",
"updated": "2024-09-27T12:58:59.924200Z",
"name": "my-first-deployment",
"version": "62626b08bd32fcabb8a8fe1e4208fb4f",
"description": "None",
"flow_id": "864b88e6-cd60-46c3-a63d-ed103bb1cb67",
"paused": false,
"schedules": [],
"concurrency_limit": null,
"global_concurrency_limit": null,
"concurrency_options": null,
"job_variables": {},
"parameters": {},
"tags": [],
"work_queue_name": null,
"last_polled": "2024-09-27T12:58:59.925632Z",
"parameter_openapi_schema": {
"type": "object",
"title": "Parameters",
"required": [
"data"
],
"properties": {
"data": {
"type": "string",
"title": "data",
"position": 0
}
}
},
"path": ".",
"pull_steps": null,
"entrypoint": "start_pod_flow.py:start_pod_flow",
"storage_document_id": null,
"infrastructure_document_id": null,
"created_by": null,
"updated_by": null,
"work_pool_name": null,
"status": "READY",
"enforce_parameter_schema": true
}
Nate
09/27/2024, 4:03 PM