Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move DeploymentImage to prefect.docker #14151

Merged
merged 9 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions docs/2.19.x/how-to-guides/work-pools/deploying-flows.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,12 @@ Prefect generates a Dockerfile for you that will build an image based off of one

### Automatically build a custom Docker image with a local Dockerfile

If you want to use a custom Dockerfile, you can specify the path to the Dockerfile with the `DeploymentImage` class:
If you want to use a custom Dockerfile, you can specify the path to the Dockerfile with the `DockerImage` class:


```python custom_dockerfile.py
from prefect import flow
from prefect.deployments import DeploymentImage
from prefect.docker import DockerImage


@flow(log_prints=True)
Expand All @@ -161,7 +161,7 @@ if __name__ == "__main__":
buy.deploy(
name="my-custom-dockerfile-deployment",
work_pool_name="my-docker-pool",
image=DeploymentImage(
image=DockerImage(
name="my_image",
tag="deploy-guide",
dockerfile="Dockerfile"
Expand All @@ -172,7 +172,7 @@ if __name__ == "__main__":
```


The `DeploymentImage` object allows for a great deal of image customization.
The `DockerImage` object allows for a great deal of image customization.

For example, you can install a private Python package from GCP's artifact registry like this:

Expand All @@ -189,13 +189,13 @@ RUN pip install --extra-index-url ${AUTHED_ARTIFACT_REG_URL} -r /requirements.tx
```


Create our deployment by leveraging the DeploymentImage class.
Create our deployment by leveraging the DockerImage class.


```python private-package.py

from prefect import flow
from prefect.deployments.runner import DeploymentImage
from prefect.deployments.runner import DockerImage
from prefect.blocks.system import Secret
from my_private_package import do_something_cool

Expand All @@ -211,7 +211,7 @@ if __name__ == "__main__":
my_flow.deploy(
name="my-deployment",
work_pool_name="k8s-demo",
image=DeploymentImage(
image=DockerImage(
name="my-image",
tag="test",
dockerfile="Dockerfile",
Expand All @@ -224,7 +224,7 @@ if __name__ == "__main__":

Note that we used a [Prefect Secret block](https://docs.prefect.io/concepts/blocks/) to load the URL configuration for the artifact registry above.

See all the optional keyword arguments for the DeploymentImage class [here](https://docker-py.readthedocs.io/en/stable/images.html#docker.models.images.ImageCollection.build).
See all the optional keyword arguments for the DockerImage class [here](https://docker-py.readthedocs.io/en/stable/images.html#docker.models.images.ImageCollection.build).

<Tip>
**Default Docker namespace**
Expand Down
12 changes: 6 additions & 6 deletions docs/2.19.x/how-to-guides/work-pools/serverless-push-work.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ example\_deploy\_script.py

```
from prefect import flow
from prefect.deployments import DeploymentImage
from prefect.docker import DockerImage

@flow(log_prints=True)
def my_flow(name: str = "world"):
Expand All @@ -211,7 +211,7 @@ if __name__ == "__main__":
my_flow.deploy(
name="my-deployment",
work_pool_name="my-work-pool",
image=DeploymentImage(
image=DockerImage(
name="my-repository:latest",
platform="linux/amd64",
)
Expand Down Expand Up @@ -284,7 +284,7 @@ To take advantage of this functionality, you can write your deploy scripts like
```python example_deploy_script.py

from prefect import flow
from prefect.deployments import DeploymentImage
from prefect.docker import DockerImage


@flow(log_prints=True)
Expand All @@ -296,7 +296,7 @@ if __name__ == "__main__":
my_flow.deploy(
name="my-deployment",
work_pool_name="my-work-pool",
image=DeploymentImage(
image=DockerImage(
name="my-image:latest",
platform="linux/amd64",
)
Expand Down Expand Up @@ -368,7 +368,7 @@ example\_deploy\_script.py

```
from prefect import flow
from prefect.deployments import DeploymentImage
from prefect.docker import DockerImage


@flow(log_prints=True)
Expand All @@ -380,7 +380,7 @@ if __name__ == "__main__":
my_flow.deploy(
name="my-deployment",
work_pool_name="above-ground",
image=DeploymentImage(
image=DockerImage(
name="my-image:latest",
platform="linux/amd64",
)
Expand Down
6 changes: 3 additions & 3 deletions docs/2.19.x/tutorial/work-pools.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ To take advantage of this functionality, you can write your deploy script like t
```python example_deploy_script.py

from prefect import flow
from prefect.deployments import DeploymentImage
from prefect.docker import DockerImage


@flow(log_prints=True)
Expand All @@ -270,7 +270,7 @@ if __name__ == "__main__":
name="my-deployment",
work_pool_name="above-ground",
cron="0 1 * * *",
image=DeploymentImage(
image=DockerImage(
name="my-image:latest",
platform="linux/amd64",
)
Expand All @@ -288,7 +288,7 @@ Running this script will build a Docker image with the tag `<region>-docker.pkg.
Make sure you have Docker running locally before running this script.
</Tip>

Note that you only need to include an object of the `DeploymentImage` class with the argument `platform="linux/amd64` if you're building your image on a machine with an ARM-based processor. Otherwise, you could just pass `image="my-image:latest"` to `deploy`.
Note that you only need to include an object of the `DockerImage` class with the argument `platform="linux/amd64` if you're building your image on a machine with an ARM-based processor. Otherwise, you could just pass `image="my-image:latest"` to `deploy`.

Also note that the `cron` argument will schedule the deployment to run at 1am every day. See the [schedules](https://docs.prefect.io/concepts/schedules/) docs for more information on scheduling options.

Expand Down
6 changes: 3 additions & 3 deletions docs/2.19.x/tutorial/workers.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,12 @@ Prefect will build a custom Docker image containing your workflow code that the

In this example, Prefect generates a Dockerfile for you that will build an image based off of one of Prefect's published images. The generated Dockerfile will copy the current directory into the Docker image and install any dependencies listed in a `requirements.txt` file.

If you want to use a custom Dockerfile, you can specify the path to the Dockerfile using the `DeploymentImage` class:
If you want to use a custom Dockerfile, you can specify the path to the Dockerfile using the `DockerImage` class:

```python repo_info.py
import httpx
from prefect import flow
from prefect.deployments import DeploymentImage
from prefect.docker import DockerImage


@flow(log_prints=True)
Expand All @@ -175,7 +175,7 @@ if __name__ == "__main__":
get_repo_info.deploy(
name="my-first-deployment",
work_pool_name="my-docker-pool",
image=DeploymentImage(
image=DockerImage(
name="my-first-deployment-image",
tag="tutorial",
dockerfile="Dockerfile"
Expand Down
Loading