Skip to content

Conversation

@matthewfeickert
Copy link
Contributor

@matthewfeickert matthewfeickert commented Nov 15, 2025

Resolves #36

Requires PR #37 to go in first.

@matthewfeickert matthewfeickert force-pushed the feat/add-pixi-docker-example branch from e31a1aa to d7eb5f2 Compare November 15, 2025 07:27
@matthewfeickert matthewfeickert marked this pull request as ready for review November 15, 2025 07:27
@matthewfeickert matthewfeickert force-pushed the feat/add-pixi-docker-example branch 2 times, most recently from 0e49408 to 22ee4ca Compare November 15, 2025 07:31
Copy link
Contributor Author

@matthewfeickert matthewfeickert left a comment

Choose a reason for hiding this comment

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

High-level comments for reviewers.

Comment on lines 29 to 34
# As main.py is copied to the worker through transfer_input_files, it is not
# located in the same directory as the Pixi manifest (/app/pixi.toml).
# To avoid moving files around further or complicating the HTCondor submit
# description file have the command written out here instead of using a Pixi
# task.
time pixi run python ./main.py --epochs 20 --save-model
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is just explaining why in the pixi/ example we can use the Pixi task runner system

time pixi run train

but here we give the command explicitly.

universe = container
# To avoid excessive pulls, and potential rate limits, set as "missing" (default value)
docker_pull_policy = missing
container_image = docker://ghcr.io/<your github org>/templates-gpu:mnist-gpu-noble-cuda-12.9
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 prepared such an image already, so if you want to test this you can use

container_image = docker://ghcr.io/matthewfeickert/templates-gpu:mnist-gpu-noble-cuda-12.9

```

Note that this manual build and publish process is slow.
It is recommended to have this step be done through a continuous integration and continuous delivery (CI/CD) workflow.
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 used the following GitHub Actions workflow to build my container image.

.github/workflows/docker.yml:
name: Docker Images

on:
  push:
    branches:
      - main
    tags:
      - 'v*'
    paths:
      - 'containers/pixi/pixi.toml'
      - 'containers/pixi/pixi.lock'
      - 'containers/pixi/Dockerfile'
      - 'containers/pixi/.dockerignore'
  pull_request:
    paths:
      - 'containers/pixi/pixi.toml'
      - 'containers/pixi/pixi.lock'
      - 'containers/pixi/Dockerfile'
      - 'containers/pixi/.dockerignore'
  release:
    types: [published]
  workflow_dispatch:

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

permissions: {}

jobs:
  docker:
    name: Build and publish images
    runs-on: ubuntu-latest
    permissions:
      contents: read
      packages: write

    steps:
      - name: Free disk space
        uses: AdityaGarg8/remove-unwanted-software@v5
        with:
          remove-android: 'true'
          remove-dotnet: 'true'
          remove-haskell: 'true'

      - name: Checkout
        uses: actions/checkout@v5
        with:
          fetch-depth: 0

      - name: Docker meta
        id: meta
        uses: docker/metadata-action@v5
        with:
          # images: |
          #   ghcr.io/chtc/templates-gpu
          images: |
            ghcr.io/matthewfeickert/templates-gpu
          # generate Docker tags based on the following events/attributes
          tags: |
            type=raw,value=mnist-gpu-noble-cuda-12.9
            type=raw,value=latest
            type=semver,pattern={{version}}
            type=semver,pattern={{major}}.{{minor}}
            type=sha

      - name: Set up QEMU
        uses: docker/setup-qemu-action@v3

      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v3

      - name: Login to GitHub Container Registry
        if: github.event_name != 'pull_request'
        uses: docker/login-action@v3
        with:
          registry: ghcr.io
          username: ${{ github.repository_owner }}
          password: ${{ secrets.GITHUB_TOKEN }}

      - name: Test build
        id: docker_build_test
        uses: docker/build-push-action@v6
        with:
          context: containers/pixi
          file: containers/pixi/Dockerfile
          tags: ${{ steps.meta.outputs.tags }}
          labels: ${{ steps.meta.outputs.labels }}
          pull: true

      - name: Deploy build
        id: docker_build_deploy
        uses: docker/build-push-action@v6
        with:
          context: containers/pixi
          file: containers/pixi/Dockerfile
          tags: ${{ steps.meta.outputs.tags }}
          labels: ${{ steps.meta.outputs.labels }}
          pull: true
          push: ${{ github.event_name != 'pull_request' }}

I assumed that adding CI for this template repo isn't of interest, but if it is, I can add something.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, I think that it's beyond the scope of this repo, but I think linking out to an example setup or general documentation is fine to plant some seeds.

Copy link
Contributor

Choose a reason for hiding this comment

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

Do you want the readme to point to #38 (comment) to plant that seed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@agitter I was going to point to https://carpentries-incubator.github.io/reproducible-ml-workflows/pixi-deployment.html#automation-with-github-actions-workflows. I have that staged, but haven't pushed yes as am waiting on clarification on #38 (comment).

Thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

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

That would be a better pointer than this thread

> While this approach does work, as there is no shared file system cache that Pixi can leverage it is less efficient than building a Linux container with the Pixi environment and using a `container` universe job.
> Note also that as the jobs executable, `mnist_gpu.sh`, is installing all dependencies from a remote conda channel (conda-forge), multiple copies of the job should not be submitted to avoid intensive bandwidth demand.
>
> Look at the example in the [`containers/pixi`](https://github.com/CHTC/templates-GPUs/tree/master/containers/pixi) directory for the recommended approach for use of Pixi with HTCondor systems with no shared file system.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Noting now that there is a more recommended approach using Linux containers.

@matthewfeickert
Copy link
Contributor Author

matthewfeickert commented Nov 15, 2025

This is ready for review now. Following #37 (comment), @iross @ChristinaLK, if you have any questions or comments let me know. 👍

(CHTC Office hours have been a bit difficult for me to call into lately given conflicting meetings, but I can try to join them if it helps to discuss anything.)

@matthewfeickert
Copy link
Contributor Author

👋 Ping to @iross @ChristinaLK for review. Also happy to close this and move things to https://github.com/CHTC/recipes depending on feedback on CHTC/recipes#29.

@matthewfeickert matthewfeickert force-pushed the feat/add-pixi-docker-example branch from ffcadd4 to bd8dabe Compare December 3, 2025 18:05
@matthewfeickert
Copy link
Contributor Author

(Rebase and force-push was from upgrading and relocking the environment — not necessary, but might as well keep this updated until merge.)

@matthewfeickert
Copy link
Contributor Author

cc @xamberl given CHTC/recipes#29 (comment) (thanks!).

@iross iross self-requested a review December 12, 2025 02:50
@iross iross self-assigned this Dec 12, 2025
Copy link
Contributor

@iross iross left a comment

Choose a reason for hiding this comment

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

The only thing I feel is really necessary before merge is an explanation of the entrypoint pieces with a beginner audience in mind.


FROM ghcr.io/prefix-dev/pixi:noble AS build

# Redeclaring ARGS in a stage without a value inherits the global default
Copy link
Contributor

Choose a reason for hiding this comment

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

This tripped me up for longer than I'd like to admit on something I was working on earlier this week 😆

```

Note that this manual build and publish process is slow.
It is recommended to have this step be done through a continuous integration and continuous delivery (CI/CD) workflow.
Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, I think that it's beyond the scope of this repo, but I think linking out to an example setup or general documentation is fine to plant some seeds.

* Add example of using a Pixi environment distributed in a Docker container
  image.
   - Link to 'Reproducible Machine Learning Workflows for Scientists'
     Carpentries Incubator lesson for CI/CD workflow example.
* Add note in pixi/ example that the containers/pixi example provides a
  recommended approach.
@matthewfeickert matthewfeickert force-pushed the feat/add-pixi-docker-example branch from bd8dabe to 4800eaf Compare December 19, 2025 09:47
Copy link
Contributor Author

@matthewfeickert matthewfeickert left a comment

Choose a reason for hiding this comment

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

Some high-level notes for @iross following his review feedback. 👍

@matthewfeickert
Copy link
Contributor Author

@iross just bumping this in 2026 as I know that I have a plethora of emails and GitHub notifications that have piled up in the liminal weeks at the end of 2025, and I assume you do as well. :P

Copy link
Contributor

@iross iross left a comment

Choose a reason for hiding this comment

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

👍

@iross iross merged commit 80df2e3 into CHTC:master Jan 5, 2026
@matthewfeickert matthewfeickert deleted the feat/add-pixi-docker-example branch January 5, 2026 23:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pixi + Linux container examples

3 participants