From bc311f3f235555a572ea47d9ea4681e053158955 Mon Sep 17 00:00:00 2001 From: Peeter Piegaze <1153481+ppiegaze@users.noreply.github.com> Date: Tue, 2 Jul 2024 16:54:18 +0200 Subject: [PATCH] Add full explanation of ImageSpec in comments Signed-off-by: Peeter Piegaze <1153481+ppiegaze@users.noreply.github.com> --- .../workflows/example.py | 74 +++++++++++++++++ .../workflows/example.py | 80 ++++++++++++++++++- 2 files changed, 153 insertions(+), 1 deletion(-) diff --git a/basic-union-byoc-template/{{cookiecutter.project_name}}/workflows/example.py b/basic-union-byoc-template/{{cookiecutter.project_name}}/workflows/example.py index 737186a..9f60394 100644 --- a/basic-union-byoc-template/{{cookiecutter.project_name}}/workflows/example.py +++ b/basic-union-byoc-template/{{cookiecutter.project_name}}/workflows/example.py @@ -1,10 +1,84 @@ +"""Basic Union BYOC workflow template.""" + from unionai import task, workflow, ImageSpec +# ImageSpec defines the container image used for the Kubernetes pods that run the tasks in Union. image_spec = ImageSpec( + + # The name of the image name="basic-union-byoc-image", + + # The base image on which this image is based base_image="ghcr.io/flyteorg/flytekit:py3.11-latest", + + # Use the requirements.txt to define the packages to be installed in the the image requirements="requirements.txt", + + # Container registry to which the image will be pushed. + # Make sure that: + # * You subsitutue the actual name of the registry here. + # If you are using GHCR, substitute with your github org name. + # * You have Docker installed locally and are logged into this registry. + # * The image, once pushed to the registry, is accessible to Union + # (for example, for GHCR, make sure the image is public) + # + # Only needed for BYOC. + # On Serverless, Images are stored in Union's own container registry. registry="ghcr.io/" + + # Python version of the image. Use default python in the base image if None. + # python_version="3.11" + + # Plugin used to build the image locally. + # Uses flytekitplugin_envd by default. + # + # Only applies to BYOC. + # On Serverless, Images are built by Union's ImageBuilder service. + # builder="flytekitplugins_envd" + + # Source root of the image. + # source_root="/path/to/source/root" + + # Environment variables to be set in the image. + # env=[FOO="foo", BAR="bar"] + + # List of python packages to install. + # packages=["package-1", "package-2"] + + # List of conda packages to install. + # conda_packages=["package-1", "package-2"] + + # List of conda channels. + # conda_channels=["channel-1", "channel-2"] + + # List of apt packages to install. + # apt_packages=["package-1", "package-2"] + + # Version of cuda to install. + # cuda="12.5" + + # Version of cudnn to install. + # cudnn="9.2.0" + + # Target platforms for the build output + # (for example: windows/amd64, linux/amd64, darwin/arm64) + # platform=["linux/amd64"] + + # Custom pip index url + # pip_index="https://my-pypi.mywebsite.com/simple" + + # One or more pip index urls as a list + # pip_extra_index_url=["https://my-pypi.mywebsite.com/simple", "https://my-other-pypi.mywebsite.com/simple"] + + # Path to a JSON registry config file + # registry_config ="/path/to/registry/config.json" + + # Commands to run during the build process + # commands= ["pip install -r requirements.txt"] + + # Custom string format for image tag. The ImageSpec hash is passed in as `spec_hash`. + # So, for example, to add a "dev" suffix to the image tag use: + # tag_format = "{spec_hash}-dev" ) @task(container_image=image_spec) diff --git a/basic-union-serverless-template/{{cookiecutter.project_name}}/workflows/example.py b/basic-union-serverless-template/{{cookiecutter.project_name}}/workflows/example.py index 8a63072..cecacfb 100644 --- a/basic-union-serverless-template/{{cookiecutter.project_name}}/workflows/example.py +++ b/basic-union-serverless-template/{{cookiecutter.project_name}}/workflows/example.py @@ -1,9 +1,87 @@ +"""Basic Union Serverless workflow template.""" + from unionai import task, workflow, ImageSpec image_spec = ImageSpec( + + # The name of the image name="basic-union-serverless-image", + + # The base image on which this image is based base_image="ghcr.io/flyteorg/flytekit:py3.11-latest", - requirements="requirements.txt" + + # Use the requirements.txt to define the packages to be installed in the the image + requirements="requirements.txt", + + # Container registry to which the image will be pushed. + # Make sure that: + # * You subsitutue the actual name of the registry here. + # If you are using GHCR, substitute with your github org name. + # * You have Docker installed locally and are logged into this registry. + # * The image, once pushed to the registry, is accessible to Union + # (for example, for GHCR, make sure the image is public) + # + # Only needed for BYOC. + # On Serverless, Images are stored in Union's own container registry. + # registry="ghcr.io/" + + # Python version of the image. Use default python in the base image if None. + # python_version="3.11" + + # Plugin used to build the image locally. + # Uses flytekitplugin_envd by default. + # + # Only applies to BYOC. + # On Serverless, Images are built by Union's ImageBuilder service. + # builder="flytekitplugins_envd" + + # Source root of the image. + # source_root="/path/to/source/root" + + # Environment variables to be set in the image. + # env=[FOO="foo", BAR="bar"] + + # List of python packages to install. + # packages=["package-1", "package-2"] + + # List of conda packages to install. + # conda_packages=["package-1", "package-2"] + + # List of conda channels. + # conda_channels=["channel-1", "channel-2"] + + # List of apt packages to install. + # apt_packages=["package-1", "package-2"] + + # Version of cuda to install. + # cuda="12.5" + + # Version of cudnn to install. + # cudnn="9.2.0" + + # Target platforms for the build output + # (for example: windows/amd64, linux/amd64, darwin/arm64) + # platform=["linux/amd64"] + + # Custom pip index url + # pip_index="https://my-pypi.mywebsite.com/simple" + + # One or more pip index urls as a list + # pip_extra_index_url=["https://my-pypi.mywebsite.com/simple", "https://my-other-pypi.mywebsite.com/simple"] + + # Path to a JSON registry config file + # registry_config ="/path/to/registry/config.json" + + # Commands to run during the build process + # commands= ["pip install -r requirements.txt"] + + # Custom string format for image tag. The ImageSpec hash is passed in as `spec_hash`. + # So, for example, to add a "dev" suffix to the image tag use: + # tag_format = "{spec_hash}-dev" + + + + ) @task(container_image=image_spec)