https://prefect.io logo
j

Joish

07/28/2023, 9:04 PM
@Marvin how do i override the infrastructure in UI for a particular deployment?
n

Nate

07/28/2023, 9:05 PM
this is not something you can do in the UI at this time you can!
m

Marvin

07/28/2023, 9:05 PM
Ah, the joys of infrastructure management. It's almost as thrilling as watching paint dry. But I digress. Here's how you override the infrastructure in the UI for a particular deployment: 1. Specify an infrastructure block when creating a deployment. This block will be used to specify infrastructure for flow runs created by the deployment at runtime. Infrastructure can only be used with a deployment. When you run a flow directly by calling the flow yourself, you are responsible for the environment in which the flow executes. 2. Prefect uses infrastructure to create the environment for a user's flow to execute. Infrastructure is attached to a deployment and is propagated to flow runs created for that deployment. Infrastructure is deserialized by the agent and it has two jobs: Create execution environment infrastructure. 3. You can start with Prefect defaults — this is what happens when you pass the -ior --infraflag and provide a type when building deployment files. 4. Alternatively, you can pre-configure infrastructure settings as blocks and base your deployment infrastructure on those settings — by passing -ibor --infra-block and a block slug when building deployment files. For example, when creating your deployment files, the supported Prefect infrastructure types are: process, docker-container, kubernetes-job, ecs-task, cloud-run-job, container-instance-job. Here's an example command:
Copy code
$ prefect deployment build ./my_flow.py:my_flow -n my-flow-deployment -t test -i docker-container -sb s3/my-bucket --override env.EXTRA_PIP_PACKAGES=s3fs
In this command, we're building a deployment with a Docker container as the infrastructure and overriding the environment to include an extra pip package. For more detailed information, you might want to visit the Prefect documentation here. It's a riveting read, I assure you.
Ah, the joys of infrastructure. It's like building a house, but instead of bricks and mortar, you're using code and configurations. And just like a house, it can fall apart if you're not careful. But I digress. To override the infrastructure in the UI for a specific deployment, you can specify an infrastructure block when creating a deployment. This block will be used to specify infrastructure for flow runs created by the deployment at runtime. Here's how you can do it: 1. Start by building your deployment files. You can do this by passing the
--infra
flag and providing a type when building deployment files. For example, you can use the command:
$ prefect deployment build ./my_flow.py:my_flow -n my-flow-deployment -t test -i docker-container -sb s3/my-bucket --override env.EXTRA_PIP_PACKAGES=s3fs
2. The supported Prefect infrastructure types are:
process
,
docker-container
,
kubernetes-job
,
ecs-task
,
cloud-run-job
,
container-instance-job
. 3. Infrastructure is attached to a deployment and is propagated to flow runs created for that deployment. Infrastructure is deserialized by the agent and it has two jobs: to create the execution environment infrastructure. Remember, infrastructure can only be used with a deployment. When you run a flow directly by calling the flow yourself, you are responsible for the environment in which the flow executes. For more detailed information, you might want to check out the Prefect documentation here. But then again, you're a human. You might prefer to watch cat videos instead.
n

Nate

07/28/2023, 9:05 PM
slack sends 2 events when you edit the message, just fyi, thats why 2 messages came back
👍 1
j

Joish

07/28/2023, 9:07 PM
@Nate then why do I see the option in the UI
n

Nate

07/28/2023, 9:08 PM
where do you see this? are you running prefect server or on cloud?
j

Joish

07/28/2023, 9:08 PM
cloud
i see this when I try to edit my deployment which already has a infra block attached to it
n

Nate

07/28/2023, 9:09 PM
ah I stand corrected! i usually just do it at deployment creation time
j

Joish

07/28/2023, 9:11 PM
so even when i do this, the pod uses the infra block that was attached to it at the time of creation
n

Nate

07/28/2023, 9:13 PM
what override are you trying to set that you're not seeing applied?
j

Joish

07/28/2023, 9:16 PM
request and limit of cpu and memory resources
n

Nate

07/28/2023, 9:19 PM
hmm, if you recreate the deployment with a different override, does it take effect then? just trying to think of why that might happen
j

Joish

07/28/2023, 9:21 PM
so I should recreate the deployment. For this, i would rather you a new infra block..
3 Views