I am new to prefect and having trouble trying to trigger my flow via API call on my standalone server.
My API call:
{
"name": "test flow run call",
"flow_id": "24360f7d-5ec6-4b1a-9b08-a47c6a2b0c5e",
"deployment_id": "14dc3405-6519-4b0d-8ead-3952b314d56d",
"state":{
"type": "RUNNING",
"name": "run-flow",
"message": "Run started"
},
"parameters": {
"channel_id": "XXXXXX",
"message": "flow test via api call"
},
"tags": ["dev"]
}
The flow-run is created, but stuck in “RUNNING” and does not do anything. The deployment config is applied to the server.
Deployment config:
###
### A complete description of a Prefect Deployment for flow 'test slack'
###
name: slack_test
description: null
version: 0e8c29233d97810319be0b6f62d3dfcd
# The work queue that will handle this deployment's runs
work_queue_name: dev
work_pool_name: null
tags: []
parameters: {}
schedule: null
is_schedule_active: null
infra_overrides:
env:
PREFECT_LOGGING_LEVEL: DEBUG
infrastructure:
type: process
env: {}
labels: {}
name: null
command: null
stream_output: true
working_dir: null
block_type_slug: process
_block_type_slug: process
stream_output: true
###
### DO NOT EDIT BELOW THIS LINE
###
flow_name: test slack
manifest_path: null
storage: null
path: /opt/prefect
entrypoint: send_message.py:post_message
parameter_openapi_schema:
title: Parameters
type: object
properties:
channel_id:
title: channel_id
position: 0
message:
title: message
position: 1
required: null
definitions: null
timestamp: '2023-04-28T15:50:17.299274+00:00'
My environment setup:
version: "3.9"
services:
### Prefect Database
database:
image: postgres:15.2-alpine
restart: always
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=prefect
expose:
- 5432
volumes:
- db:/var/lib/postgresql/data
profiles: ["server"]
### Prefect Server API and UI
server:
image: prefecthq/prefect:2.10.4-python3.11
restart: always
volumes:
- prefect:/root/.prefect
- "./flows:/opt/prefect/"
entrypoint: ["prefect", "server", "start"]
environment:
- PREFECT_UI_URL=http://0.0.0.0:3000/api
- PREFECT_SERVER_API_HOST=0.0.0.0
- PREFECT_SERVER_API_PORT=3000
- PREFECT_LOGGING_LEVEL=INFO
- PREFECT_API_DATABASE_CONNECTION_URL=postgresql+asyncpg://postgres:postgres@database:5432/prefect
- MESSENGERAPP_URL=${MESSENGERAPP_URL}
- MESSAGE_TOKEN=${MESSAGE_TOKEN}
ports:
- 3000:3000
depends_on:
- database
profiles: ["server"]
## Prefect Agent
agent:
image: prefecthq/prefect:2.10.4-python3.11
restart: always
entrypoint: ["prefect", "agent", "start", "-q", "dev"]
environment:
- PREFECT_API_URL=http://server:3000/api
- PREFECT_UI_URL=http://0.0.0.0:3000/api
- PREFECT_SERVER_API_HOST=0.0.0.0
- PREFECT_SERVER_API_PORT=3000
- PREFECT_LOGGING_LEVEL=INFO
volumes:
- prefect:/root/.prefect
- "./flows:/opt/prefect/"
profiles: ["server"]
volumes:
prefect:
db:
networks:
default:
name: prefect-network
The workflow code exists both on the agent and server containers. I was able to manually trigger deployment and it worked, but the API does not seem to be. I would like all my flows to be trigger via API calls, is there something I am doing wrong?
Any help is appreciated.