Αλκιβιάδης Σαββόπουλος
11/07/2024, 5:44 PM# master_deployment.py
from prefect import flow, task
from prefect.runner.storage import GitRepository
from prefect_github import GitHubCredentials
from prefect.docker import DockerImage
@flow
def master_deployment_flow(client_id: str, client_preferences: dict):
# This flow triggers the creation of a client-specific deployment
source = GitRepository(
url="actual_url",
credentials=GitHubCredentials.load("actual_credentials")
)
# Define and deploy the client-specific deployment
client_deployment_id = flow.from_source(
source=source,
entrypoint="scripts/flow.py:flow_function",
).deploy(
name=f"{client_id}",
work_pool_name="my-ecs-pool",
image=DockerImage(
name="actual_docker_image",
platform="linux/amd64",
dockerfile="Dockerfile.prefect"
),
job_variables={
"parameters": {
"client_id": client_id,
"client_preferences": client_preferences
}
},
cron="*/10 * * * *",
push=False,
build=False
)
print(f"Deployment ID for client {client_id}: {client_deployment_id}")
if __name__ == "__main__":
# Deploy the master flow itself (this only needs to be done once)
source = GitRepository(
url="actual_url",
credentials=GitHubCredentials.load("github-creda-1")
)
master_deployment_id=flow.from_source(
source=source,
entrypoint="prefect_deployments/master_deployment.py:master_deployment_flow"
).deploy(
name="master-deployment",
work_pool_name="my-ecs-pool",
image=DockerImage(
name="...actual docker image...",
platform="linux/amd64",
dockerfile="Dockerfile.prefect"
),
push=False,
build=False
)
Αλκιβιάδης Σαββόπουλος
11/07/2024, 5:50 PMΑλκιβιάδης Σαββόπουλος
11/07/2024, 8:05 PMBianca Hoch
11/08/2024, 9:58 PMΑλκιβιάδης Σαββόπουλος
11/11/2024, 9:01 AMFailed due to a(n) crashed flow run - Flow run process exited with non-zero status code 1. Further investigation needed to determine the cause of the crash.
which is basically, explaining, well, nothing at all. Where else can I get more logs? I have an ECS:push Work Pool.Αλκιβιάδης Σαββόπουλος
11/11/2024, 1:59 PMBianca Hoch
11/12/2024, 8:58 PMmaster_deployment_flow
. One thing I noticed that may be causing problems for you:
• Parameters for client-specific deployments are being set within the job_variables
of your .deploy()
method. Try setting them in the parameters
argument instead (see below).
# master_deployment.py
from prefect import flow
import os
@flow(log_prints=True)
def master_deployment_flow(client_id: str, client_preferences: str):
# Define and deploy the client-specific deployment
client_deployment_id = flow.from_source(
source="<https://github.com/PrefectHQ/prefect.git>",
entrypoint="flows/hello_world.py:hello"
).deploy(
name=f"{client_id}",
work_pool_name="my_process_pool",
cron="*/10 * * * *",
parameters={"name": client_preferences},
push=False,
build=False,
)
print(f"Deployment ID for client {client_id}: {client_deployment_id}")
if __name__ == "__main__":
master_deployment_flow.from_source(
source=os.path.dirname(__file__),
entrypoint=f"{os.path.basename(__file__)}:master_deployment_flow"
).deploy(
name="master-deployment",
work_pool_name="my_process_pool",
parameters={"client_id": "client-a", "client_preferences": "Marvin"},
)
Bianca Hoch
11/12/2024, 9:00 PMif __name__ == "__main__"
block, I also set the default parameter values for the master_deployment_flow
there as well (client_id and client_preferences)Bianca Hoch
11/12/2024, 10:46 PMWhere else can I get more logs? I have an ECS:push Work Pool.Enabling debug level logging may help you out here. You can set it as an ENV var in your work pool base template:
PREFECT_LOGGING_LEVEL=DEBUG
Αλκιβιάδης Σαββόπουλος
11/12/2024, 10:52 PMBianca Hoch
11/12/2024, 10:55 PMmaster_deployment_flow
lives here: https://github.com/PrefectHQ/prefect/blob/main/flows/hello_world.py