Skip to content

Conversation

satyamg1620
Copy link
Contributor

@satyamg1620 satyamg1620 commented Aug 20, 2025

Updated Dockerfile.hf for multi-arch build for amd64 and s390x.

Build logs:
amd64-hf-logs.txt
s390x-hf-logs.txt

Summary by Sourcery

Build:

  • Update Dockerfile.hf to configure multi-arch builds for amd64 and s390x

Copy link

sourcery-ai bot commented Aug 20, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Updates Dockerfile.hf to support multi-architecture builds for amd64 and s390x by parameterizing the base images with buildx’s TARGETPLATFORM and refactoring the file into a concise multi-stage build workflow.

File-Level Changes

Change Details Files
Introduce platform-aware base image selection
  • Add ARG TARGETPLATFORM to capture the target architecture
  • Prefix FROM instructions with --platform=$TARGETPLATFORM to pull the correct image
detectors/Dockerfile.hf
Refactor into a multi-stage build
  • Define a ‘builder’ stage to compile the binary
  • Copy the compiled artifact from builder into a minimal runtime stage
  • Collapse layers to reduce image size
detectors/Dockerfile.hf

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@satyamg1620
Copy link
Contributor Author

Hi @ruivieira, could you please review this PR?
Thanks.

@ruivieira ruivieira added enhancement New feature or request dependencies Pull requests that update a dependency file labels Aug 20, 2025
@satyamg1620 satyamg1620 marked this pull request as ready for review August 22, 2025 06:17
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@satyamg1620
Copy link
Contributor Author

@m-misiura , can you please review this PR
Thanks.

PYTORCH_BUILD_VERSION=${TORCH_VERSION} PYTORCH_BUILD_NUMBER=1 pip wheel . --wheel-dir /torchwheels/ && \
pip install /torchwheels/*.whl; \
else \
pip install --no-cache-dir torch; \
Copy link
Collaborator

Choose a reason for hiding this comment

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

should we pin torch version for consistency across architectures?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For this TORCH_VERSION (2.7.1), it is one of the latest and stable version for s390x architecture. As for amd64, I think it is showing torch>=2.0 in tox.ini file and for amd64 it may download the latest one

pip install --no-cache-dir torch; \
fi


FROM base as builder
Copy link
Collaborator

Choose a reason for hiding this comment

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

in our case, is there a significant advanatage of having a multi-stage build?

e.g. PyTorch must be present in the final image anyway (needed at runtime), so we can't eliminate it in a build stage

Main bulk is PyTorch itself; s390x build tools are relatively small compared to PyTorch there should be no large intermediate build artifacts to exclude?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think the Dockerfile was already in mulit-stage build before this PR, and we have handled torch build for s390x case in the stage where torch is installed for amd64. We can also create a separate PR if we want to handle complete Dockerfile in a single stage build

@satyamg1620 satyamg1620 requested a review from m-misiura August 28, 2025 15:45
@satyamg1620
Copy link
Contributor Author

@ruivieira @m-misiura Can you please review the PR
Thanks

@m-misiura
Copy link
Collaborator

@ruivieira @m-misiura Can you please review the PR Thanks

thanks for your contribution @satyamg1620 -- could you please rebase the PR and then we'll merge it :)

@satyamg1620
Copy link
Contributor Author

Sure @m-misiura

@satyamg1620
Copy link
Contributor Author

@m-misiura Can you please review the PR
Thanks

@m-misiura m-misiura merged commit 5258196 into trustyai-explainability:main Sep 3, 2025
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants