https://prefect.io logo
Title
r

Robin

03/29/2023, 5:58 PM
Follow-Up Question: I successfully triggered a flow via an API call šŸ™‚ However, it remains in
PENDING
. I successfully submitted it with
deployment_id
, but it still remains in
PENDING
šŸ˜• I tried to submit it with
work_pool
but that does not seem to be a valid request? I read the docs but it is not clear to me, which role
work_pool
,
deployment
and
work queue
have šŸ¤” PS: The successful run was triggered in UI, without setting anything different than the flow defaults.
āœ… 2
r

redsquare

03/29/2023, 6:01 PM
has the deployment got the correct work queue
hang on
sorry you might need Create Flow Run From Deployment
so it uses the same queue/settings
r

Robin

03/29/2023, 9:21 PM
Ah, got it! Looks better indeed, although the agent seems to not pick them up for some reason šŸ¤”
@Jeff Hale, Any thoughts on why the same flow triggered via API call remains in
PENDING
?
Just tested again and manually triggering starts it directly (see completed flows), while API remains in
PENDING
(see cancelled and pending flows)
Could it be related to a missing
idempotency_key
?
Ah, seems like setting state to
SCHEDULED
when calling via API solved the problem šŸ™‚
r

redsquare

03/29/2023, 10:41 PM
ah neat
r

Robin

03/30/2023, 7:36 AM
@Jeff Hale, what is the reason behind putting it to "PENDING" by default? May be less confusing for starters to set it to
SCHEDULED
by default?
šŸ‘ 1
c

Carlos Cueto

04/01/2023, 6:26 AM
I had the same issue with using the REST API to trigger flow runs for the first time. I have also seen others having the same concern in the community channel but no one has addressed the issue. I fully agree with making it SCHEDULED by default. Going to PENDING and never getting picked up by work queue seems completely pointless. See this other recent thread by someone else: https://prefect-community.slack.com/archives/CL09KU1K7/p1680121475686169
j

Jeff Hale

04/03/2023, 2:18 PM
Thank you for the feedback! Iā€™m not sure of the reasoning but will raise with the team.
šŸ™ 1
r

Robin

04/03/2023, 2:30 PM
Thank you!
j

justabill

04/03/2023, 2:50 PM
My apologies for allowing this confusing behavior to persist for so long. I've created a issue for it. We will likely make this change this week. Thanks for calling this to my attention @Jeff Hale, @Robin, and @Carlos Cueto.
šŸ‘ 3
:upvote: 3
ā¤ļø 3
r

Robin

04/03/2023, 3:04 PM
Well, on the positive side it forced me to look into things deeper, but new users will probably be delighted that it just works right away šŸ™‚
šŸ‘ 1
c

Chandan Maruthi

04/25/2023, 9:51 PM
Great thread. To summarize the right way to submit a flow run. is this way. Also remember you need to have an agent running. You can do it via CLI or refer recipies for examples of running agents in the cloud
curl --location --request POST '<https://api.prefect.cloud/api/accounts/><account_id>/workspaces/<workspace_id>/deployments/<deployment_id>/create_flow_run' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <api_token>' \
--header 'X-PREFECT-API-VERSION: 0.8.4' \
--data-raw '{
    "name": "my-flow-run",
    "idempotency_key": "string",
    "infrastructure_document_id":"<see deployment screen for this id>",
    "state": {
        "type": "SCHEDULED"
    }
}'