Skip to content

Image

Represents a container image for a job.

The image is defined based on Python dependencies and two build scripts expressed as Dockerfile commands.

Parameters:

Name Type Description Default
python_version str

Python version string or "auto".

'auto'
python_requirements str | list[str]

Requirements spec, file path, list, or "auto".

''
build_script_pre str

Pre-build Dockerfile commands or file path.

''
build_script_post str

Post-build Dockerfile commands or file path.

''
branch_name str | None

Git branch name for the repo, if applicable.

None
commit_hash str | None

Git commit hash for the repo, if applicable.

None
path_to_repo str | None

Path to the repository root, if applicable.

None
path_to_module str | None

Path to the Python module, if applicable.

None

Attributes:

Name Type Description
python_version str

Resolved Python version string.

python_requirements str

Requirements string (newline-delimited).

build_script_pre str

Pre-build Dockerfile commands.

build_script_post str

Post-build Dockerfile commands.

branch_name str | None

Git branch name.

commit_hash str | None

Git commit hash.

path_to_repo str | None

Path to the repository root.

path_to_module str | None

Path to the Python module.

build_stdout str | None

Stdout captured from the last build, if any.

build_stderr str | None

Stderr captured from the last build, if any.

name str | None

Built image name, if any.

last_build_succeeded bool | None

Whether the last build succeeded.

bundle_name str | None

Bundle name, if any.

registry str | None

Registry URL or name, if any.

run_after_build bool | None

Whether to run after build.

tag str | None

Image tag, if any.

__init__(python_version='auto', python_requirements='', build_script_pre='', build_script_post='', branch_name=None, commit_hash=None, path_to_repo=None, path_to_module=None)

Initialize an Image configuration.

Parameters:

Name Type Description Default
python_version str

Python version for the container (e.g. "3.12"). Use "auto" to match the current interpreter version.

'auto'
python_requirements str | list[str]

Python dependencies. Accepts a pip-freeze string, a list of package specifiers, a path to a requirements.txt file, or "auto" to run pip freeze.

''
build_script_pre str

Dockerfile commands to execute before installing Python requirements. Can be a string or a file path.

''
build_script_post str

Dockerfile commands to execute after installing Python requirements. Can be a string or a file path.

''
branch_name Optional[str]

Git branch name (populated automatically during build).

None
commit_hash Optional[str]

Git commit hash (populated automatically during build).

None
path_to_repo Optional[str]

Absolute path to the source repository root.

None
path_to_module Optional[str]

Relative path from the repository root to the Python module containing the entrypoint.

None

from_dict(data)

Create an Image instance from a dictionary representation.

to_dict()

Convert the Image instance to a dictionary representation.

to_json()

Convert the Image instance to a JSON string representation.

update(**kwargs)

Update one or more Image attributes.

Parameters:

Name Type Description Default
**kwargs

Attribute names and their new values.

{}

Raises:

Type Description
TypeError

If a string-only attribute receives a non-string value.

AttributeError

If an attribute name does not exist on the Image.