Eric Albanese
09/12/2024, 6:51 PMprefect.yaml
deployment config for a dozen jobs which has worked well. Coming up, I'm looking to port over a huge pile of older, unmanged pipelines into Prefect. Right now each deployment config in my YAML is about 13 lines. Feels like there has to be a more efficient way to do this rather than configuring 1300 lines where each job has a different name, schedule, and ~2 parameters. Maybe a script to take a flattened input and re-create the prefect YAML every time I deploy?Nate
09/12/2024, 7:12 PM.deploy()
method on flows or instead the deploy(*many_flows)
utilNate
09/12/2024, 7:13 PMEric Albanese
09/12/2024, 7:51 PMNate
09/12/2024, 7:53 PMEric Albanese
09/12/2024, 7:58 PMfrom prefect import flow, deploy
from flows import flow1, flow2
if __name__ == "__main__":
deploy(
flow1.to_deployment("my-deployment-1"),
flow2.to_deployment("my-deployment-2"),
)
Nate
09/12/2024, 7:58 PMEric Albanese
09/12/2024, 8:27 PMNate
09/12/2024, 8:28 PMEric Albanese
09/12/2024, 9:16 PMvar_config = {
"network_mode": "host",
"volumes": [
"/var/run/docker.sock:/var/run/docker.sock:ro",
"/home/ubuntu/.docker/config.json:/root/.docker/config.json:ro"
]
}
my_flow_1.deploy(
name='test-my_flow',
image="xxxx/prefect:v10284.0",
push=False,
work_pool_name="ec2-docker",
job_variables=var_config
)
print(f"Deployed to Prefect Cloud")
Eric Albanese
09/12/2024, 9:17 PM- name: poc
version: null
tags: null
description: null
schedule: {}
entrypoint: flows/api_trigger_poc.py:execute
parameters:
tenant_key: "dummy1"
data_location: "dummy2"
work_pool:
name: ec2-docker
work_queue_name: null
job_variables:
image: "xxxx/prefect:{{ $TAG }}"
network_mode: "host"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
- "/home/ubuntu/.docker/config.json:/root/.docker/config.json:ro"
Eric Albanese
09/12/2024, 9:20 PMRuntimeError: Failed to generate Dockerfile. Dockerfile already exists in the current directory.
messageNate
09/12/2024, 9:21 PMbuild=False
Nate
09/12/2024, 9:21 PMNate
09/12/2024, 9:21 PMimage
then you dont need thatEric Albanese
09/12/2024, 9:21 PMEric Albanese
09/12/2024, 9:22 PMEric Albanese
09/12/2024, 9:39 PMentrypoint_type
.
Also checking other configs, I have this under Pull Steps that I think I need to migrate over as well
[
{
"prefect.deployments.steps.set_working_directory": {
"directory": "./"
}
}
]
Nate
09/12/2024, 9:41 PMEric Albanese
09/12/2024, 9:41 PMNate
09/12/2024, 10:30 PMset_working_directory
args, which in the python way you can do something like
deploy(*[f.from_source(..).to_deployment(...) for f, config in zip(flows, configs)])
where from_source
will get translated to a set_working_directory
step in the pull
section if you pass source=str(Path(...))
and entrypoint='filename.py:decorated_fn'
like this