Alvaro Durán Tovar
12/13/2021, 2:04 PMAlvaro Durán Tovar
12/13/2021, 2:05 PMKevin Kho
query = """query {flow{ name, id}}"""
url = '<https://api.prefect.io>'
r = <http://requests.post|requests.post>(url, json={'query': query}, headers={"authorization": "Bearer MY_TOKEN_HERE"})
print(r.status_code)
print(r.text)
Kevin Kho
create_flow_run
mutation instead of courseAnna Geller
prefect run --name your-unique-flow-name --watch
The extra --watch flag allows you to see the flow run logs directly in the terminal.
If your flow is not registered, you can accomplish the same providing a path:
prefect run -p /path/to/flow.py
Alvaro Durán Tovar
12/13/2021, 3:24 PMAlvaro Durán Tovar
12/13/2021, 3:25 PMAnna Geller
Alvaro Durán Tovar
12/13/2021, 4:34 PMAlvaro Durán Tovar
12/13/2021, 4:36 PMAlvaro Durán Tovar
12/13/2021, 4:36 PMAlvaro Durán Tovar
12/13/2021, 4:37 PMAnna Geller
curl '<https://api.prefect.io>' \
-X POST \
-H 'content-type: application/json' \
-H 'authorization: Bearer XXX' \
--data '{
"query":"mutation {create_flow_run(input: { flow_id: \"05f1872f-44b3-443a-bbd4-0a1198351cad\" }) {id}}"
}'
Alvaro Durán Tovar
12/13/2021, 4:52 PMAlvaro Durán Tovar
12/13/2021, 4:53 PMKevin Kho
flow
routeAnna Geller
import requests
query = """
mutation {
create_flow_run(input: { flow_id: "e9827ce5-f686-4183-b3e9-c629d63d7510" }) {
id
}
}
"""
url = "<https://api.prefect.io>"
response = <http://requests.post|requests.post>(
url, json={"query": query}, headers={"authorization": "Bearer XXX"}
)
print(response.status_code)
print(response.text)
You can use the same requests syntax to query for flow ID.Alvaro Durán Tovar
12/13/2021, 6:30 PMCorris Randall
12/15/2021, 8:52 PMKevin Kho
create_flow_run
task takes in project and flow name if you can install Prefect to trigger the new Flow run. This setup above is if you can’t install Prefect on the machineKevin Kho
create_flow_run.run(flow_name="name", project_name="project")
to run the Python underneathKevin Kho
prefect run --project some_name --name flow_name
Corris Randall
12/15/2021, 9:27 PM