ImageSpec#

class flytekit.image_spec.ImageSpec(name='flytekit', python_version=None, builder=None, source_root=None, env=None, registry=None, packages=None, conda_packages=None, conda_channels=None, requirements=None, apt_packages=None, cuda=None, cudnn=None, base_image=None, platform='linux/amd64', pip_index=None, pip_extra_index_url=None, registry_config=None, entrypoint=None, commands=None, tag_format=None)#

This class is used to specify the docker image that will be used to run the task.

Args:

name: name of the image. python_version: python version of the image. Use default python in the base image if None. builder: Type of plugin to build the image. Use envd by default. source_root: source root of the image. env: environment variables of the image. registry: registry of the image. packages: list of python packages to install. conda_packages: list of conda packages to install. conda_channels: list of conda channels. requirements: path to the requirements.txt file. apt_packages: list of apt packages to install. cuda: version of cuda to install. cudnn: version of cudnn to install. base_image: base image of the image. platform: Specify the target platforms for the build output (for example, windows/amd64 or linux/amd64,darwin/arm64 pip_index: Specify the custom pip index url pip_extra_index_url: Specify one or more pip index urls as a list registry_config: Specify the path to a JSON registry config file entrypoint: List of strings to overwrite the entrypoint of the base image with, set to [] to remove the entrypoint. commands: Command to run during the building process tag_format: Custom string format for image tag. The ImageSpec hash passed in as spec_hash. For example,

to add a “dev” suffix to the image tag, set tag_format=”{spec_hash}-dev”

Parameters:
  • name (str)

  • python_version (str)

  • builder (str | None)

  • source_root (str | None)

  • env (Dict[str, str] | None)

  • registry (str | None)

  • packages (List[str] | None)

  • conda_packages (List[str] | None)

  • conda_channels (List[str] | None)

  • requirements (str | None)

  • apt_packages (List[str] | None)

  • cuda (str | None)

  • cudnn (str | None)

  • base_image (str | ImageSpec | None)

  • platform (str)

  • pip_index (str | None)

  • pip_extra_index_url (List[str] | None)

  • registry_config (str | None)

  • entrypoint (List[str] | None)

  • commands (List[str] | None)

  • tag_format (str | None)

exist()#

Check if the image exists in the registry. Return True if the image exists in the registry, False otherwise. Return None if failed to check if the image exists due to the permission issue or other reasons.

Return type:

bool | None

force_push()#

Builder that returns a new image spec with force push enabled.

Return type:

ImageSpec

property id: str#

Calculate a unique hash as the ID for the ImageSpec, and it will be used to 1. Identify the imageSpec in the ImageConfig in the serialization context. 2. Check if the current container image in the pod is built from this image spec in is_container().

ImageConfig: - deduced abc: flyteorg/flytekit:123 - deduced xyz: flyteorg/flytekit:456

Returns:

a unique identifier of the ImageSpec

image_name()#

Full image name with tag.

Return type:

str

is_container()#

Check if the current container image in the pod is built from current image spec. :return: True if the current container image in the pod is built from current image spec, False otherwise.

Return type:

bool

property tag: str#

Calculate a hash from the image spec. The hash will be the tag of the image. We will also read the content of the requirement file and the source root to calculate the hash. Therefore, it will generate different hash if new dependencies are added or the source code is changed.

with_apt_packages(apt_packages)#

Builder that returns a new image spec with an additional list of apt packages that will be executed during the building process.

Parameters:

apt_packages (str | List[str])

Return type:

ImageSpec

with_commands(commands)#

Builder that returns a new image spec with an additional list of commands that will be executed during the building process.

Parameters:

commands (str | List[str])

Return type:

ImageSpec

with_packages(packages)#

Builder that returns a new image speck with additional python packages that will be installed during the building process.

Parameters:

packages (str | List[str])

Return type:

ImageSpec