flytekit.extend.ImageConfig

class flytekit.extend.ImageConfig(default_image=None, images=None)[source]

We recommend you to use ImageConfig.auto(img_name=None) to create an ImageConfig. For example, ImageConfig.auto(img_name=””ghcr.io/flyteorg/flytecookbook:v1.0.0””) will create an ImageConfig.

ImageConfig holds available images which can be used at registration time. A default image can be specified along with optional additional images. Each image in the config must have a unique name.

Parameters:
default_image

The default image to be used as a container for task serialization.

Type:

Optional[Image]

images

Optional, additional images which can be used in task container definitions.

Type:

List[Image]

Methods

classmethod auto(config_file=None, img_name=None)[source]

Reads from config file or from img_name Note that this function does not take into account the flytekit default images (see the Dockerfiles at the base of this repo). To pick those up, see the auto_default_image function..

Parameters:
  • config_file (str | ConfigFile | None)

  • img_name (str | None)

Returns:

Return type:

ImageConfig

classmethod auto_default_image()[source]
Return type:

ImageConfig

classmethod create_from(default_image, other_images=None)[source]
Parameters:
Return type:

ImageConfig

find_image(name)[source]

Return an image, by name, if it exists.

Return type:

Image | None

classmethod from_dict(kvs, *, infer_missing=False)
Parameters:

kvs (dict | list | str | int | float | bool | None)

Return type:

A

classmethod from_images(default_image, m=None)[source]

Allows you to programmatically create an ImageConfig. Usually only the default_image is required, unless your workflow uses multiple images

ImageConfig.from_dict(
    "ghcr.io/flyteorg/flytecookbook:v1.0.0",
     {
          "spark": "ghcr.io/flyteorg/myspark:...",
          "other": "...",
     }
)
Returns:

Parameters:
classmethod from_json(s, *, parse_float=None, parse_int=None, parse_constant=None, infer_missing=False, **kw)
Parameters:

s (str | bytes | bytearray)

Return type:

A

classmethod schema(*, infer_missing=False, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)
Parameters:
Return type:

SchemaF[A]

to_dict(encode_json=False)
Return type:

Dict[str, dict | list | str | int | float | bool | None]

to_json(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, indent=None, separators=None, default=None, sort_keys=False, **kw)
Parameters:
Return type:

str

static validate_image(_, param, values)[source]

Validates the image to match the standard format. Also validates that only one default image is provided. a default image, is one that is specified as default=<image_uri> or just <image_uri>. All other images should be provided with a name, in the format name=<image_uri> This method can be used with the CLI

Parameters:
  • _ (Any) – click argument, ignored here.

  • param (str) – the click argument, here should be “image”

  • values (tuple) – user-supplied images

Returns:

Return type:

ImageConfig

Attributes

dataclass_json_config = None
default_image: Image | None = None
images: List[Image] | None = None