Gabe Villasana
09/01/2023, 10:26 PMChris White
Gabe Villasana
09/02/2023, 12:29 AMGabe Villasana
09/02/2023, 12:30 AMChris White
Create Flow Run From Deployment
Chris White
name
and parameters
)Gabe Villasana
09/02/2023, 12:33 AMGabe Villasana
09/02/2023, 12:34 AMChris White
Gabe Villasana
09/02/2023, 2:51 AMimport requests
import src.constants as constants
def create_flow_run_from_deployment():
"""
Create a flow run from a deployment using the Prefect Cloud API.
Args:
account_id (uuid.UUID): Account ID
workspace_id (uuid.UUID): Workspace ID
deployment_id (uuid.UUID): Deployment ID
api_version (str): API version for the header
token (str): Authorization token
... : Other parameters as specified in the API documentation
Returns:
response: API response object
"""
# Define the API endpoint URL
url = f"<https://api.prefect.cloud/api/accounts/{constants.PREFECT_ACCOUNT_ID}/workspaces/{constants.PREFECT_WORKSPACE_ID}/deployments/{constants.PREFECT_DEPLOYMENT_ID}/create_flow_run>"
# Construct headers
headers = {
"Authorization": f"Bearer {constants.PREFECT_CLOUD_API_KEY}",
"Content-Type": "application/json",
}
# Make the API call
response = <http://requests.post|requests.post>(url, headers=headers)
return response
Chris White
Gabe Villasana
09/02/2023, 3:29 AMrun_deployment
function that you linked but was getting the 403 denied errorGabe Villasana
09/02/2023, 3:37 AMObjectNotFound
error on this line, I don't think the run_deployment
command is recognizing my deployment ID... Maybe I didn't deploy properly? It's appearing in the Prefect Cloud UI... and I know I'm using the same ID ...Gabe Villasana
09/02/2023, 3:41 AMGabe Villasana
09/02/2023, 3:42 AMprefect.exceptions.PrefectHTTPStatusError: Client error '404 Not Found' for url '<http://ephemeral-prefect/api/deployments/3e47a8cf-6055-404c-a2c3-146751ed24b9>'
Response: {'detail': 'Deployment not found'}
Chris White
Chris White
Gabe Villasana
09/02/2023, 12:33 PM