Skip to content

Report non-function Image build failures better #3172

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

Merged
merged 1 commit into from
May 27, 2025
Merged
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
60 changes: 38 additions & 22 deletions modal/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,13 @@ async def _load(self: _Image, resolver: Resolver, existing_object_id: Optional[s
metadata = resp.metadata

if result.status == api_pb2.GenericResult.GENERIC_STATUS_FAILURE:
raise RemoteError(f"Image build for {image_id} failed with the exception:\n{result.exception}")
if result.exception:
raise RemoteError(f"Image build for {image_id} failed with the exception:\n{result.exception}")
else:
msg = f"Image build for {image_id} failed. See build logs for more details."
if not _get_output_manager():
msg += " (Hint: Use `modal.enable_output()` to see logs from the process building the Image.)"
raise RemoteError(msg)
elif result.status == api_pb2.GenericResult.GENERIC_STATUS_TERMINATED:
raise RemoteError(f"Image build for {image_id} terminated due to external shut-down. Please try again.")
elif result.status == api_pb2.GenericResult.GENERIC_STATUS_TIMEOUT:
Expand Down Expand Up @@ -1522,12 +1528,14 @@ def _registry_setup_commands(
modal_requirements_commands = []
if builder_version <= "2024.10":
# past 2024.10, client dependencies are mounted at runtime
modal_requirements_commands.extend([
f"COPY {CONTAINER_REQUIREMENTS_PATH} {CONTAINER_REQUIREMENTS_PATH}",
f"RUN python -m pip install --upgrade {_base_image_config('package_tools', builder_version)}",
f"RUN {requirements_prefix}{_get_modal_requirements_command(builder_version)}",
])
if "2024.10" >= builder_version > "2023.12":
modal_requirements_commands.extend(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this pulled in some unrelated ruff changes...

[
f"COPY {CONTAINER_REQUIREMENTS_PATH} {CONTAINER_REQUIREMENTS_PATH}",
f"RUN python -m pip install --upgrade {_base_image_config('package_tools', builder_version)}",
f"RUN {requirements_prefix}{_get_modal_requirements_command(builder_version)}",
]
)
if "2024.10" >= builder_version > "2023.12":
modal_requirements_commands.append(f"RUN rm {CONTAINER_REQUIREMENTS_PATH}")

return [
Expand Down Expand Up @@ -1830,23 +1838,31 @@ def build_dockerfile(version: ImageBuilderVersion) -> DockerfileSpec:
f"FROM python:{full_python_version}-slim-{debian_codename}",
]
if version <= "2024.10":
commands.extend([
f"COPY {CONTAINER_REQUIREMENTS_PATH} {CONTAINER_REQUIREMENTS_PATH}",
])
commands.extend([
"RUN apt-get update",
"RUN apt-get install -y gcc gfortran build-essential",
f"RUN pip install --upgrade {_base_image_config('package_tools', version)}",
])
commands.extend(
[
f"COPY {CONTAINER_REQUIREMENTS_PATH} {CONTAINER_REQUIREMENTS_PATH}",
]
)
commands.extend(
[
"RUN apt-get update",
"RUN apt-get install -y gcc gfortran build-essential",
f"RUN pip install --upgrade {_base_image_config('package_tools', version)}",
]
)
if version <= "2024.10":
# after 2024.10, modal requirements are mounted at runtime
commands.extend([
f"RUN {_get_modal_requirements_command(version)}",
])
commands.extend([
# Set debian front-end to non-interactive to avoid users getting stuck with input prompts.
"RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections",
])
commands.extend(
[
f"RUN {_get_modal_requirements_command(version)}",
]
)
commands.extend(
[
# Set debian front-end to non-interactive to avoid users getting stuck with input prompts.
"RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections",
]
)
if "2024.10" >= version > "2023.12":
commands.append(f"RUN rm {CONTAINER_REQUIREMENTS_PATH}")
if version > "2024.10":
Expand Down
Loading