From 9060e20e4f938d3eb081b6614c6de0a6b2f74858 Mon Sep 17 00:00:00 2001 From: BanzaiTokyo Date: Wed, 30 Apr 2025 09:54:56 +0000 Subject: [PATCH 01/11] replace conda with uv in mps-tests.yml --- .../workflows/binaries-nightly-release.yml | 15 ++-- .github/workflows/mps-tests.yml | 78 ++++--------------- 2 files changed, 20 insertions(+), 73 deletions(-) diff --git a/.github/workflows/binaries-nightly-release.yml b/.github/workflows/binaries-nightly-release.yml index 6ef1c3f6faa3..5a6c664eb834 100644 --- a/.github/workflows/binaries-nightly-release.yml +++ b/.github/workflows/binaries-nightly-release.yml @@ -12,22 +12,21 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Setup Miniconda - uses: conda-incubator/setup-miniconda@v2 + - name: Setup Python + uses: actions/setup-python@v4 with: - miniconda-version: "latest" python-version: "3.10" - + - name: Install Astral UV + run: curl -LsSf https://astral.sh/uv/install.sh | sh - name: Setup nightly version run: | sed -i "s/__version__ = \"\(.*\)\"/__version__ = \"\1.dev$(date -u +%Y%m%d)\"/g" ignite/__init__.py cat ignite/__init__.py - - name: Install dependencies - shell: bash -l {0} + - name: Install dependencies with UV run: | - conda install -y pytorch torchvision cpuonly -c pytorch-nightly - pip install -r requirements-dev.txt + uv pip install torch torchvision --index-url https://download.pytorch.org/whl/nightly/cpu + uv pip install -r requirements-dev.txt - name: Build and Publish Conda binaries shell: bash -l {0} diff --git a/.github/workflows/mps-tests.yml b/.github/workflows/mps-tests.yml index db278b8cebb4..087bec9c83fd 100644 --- a/.github/workflows/mps-tests.yml +++ b/.github/workflows/mps-tests.yml @@ -22,87 +22,41 @@ on: workflow_dispatch: concurrency: - # -- group: mps-tests-${{ github.ref_name }}-${{ !(github.ref_protected) || github.sha }} cancel-in-progress: true -# Cherry-picked from -# - https://github.com/pytorch/vision/blob/main/.github/workflows/tests.yml -# - https://github.com/pytorch/test-infra/blob/main/.github/workflows/macos_job.yml - jobs: mps-tests: + runs-on: macos-14 strategy: matrix: python-version: [3.11] pytorch-channel: ["pytorch"] skip-distrib-tests: [1] fail-fast: false - runs-on: ["macos-m1-stable"] timeout-minutes: 60 steps: - - name: Clean workspace - run: | - echo "::group::Cleanup debug output" - sudo rm -rfv "${GITHUB_WORKSPACE}" - mkdir -p "${GITHUB_WORKSPACE}" - echo "::endgroup::" - - - name: Checkout repository (pytorch/test-infra) - uses: actions/checkout@v3 - with: - # Support the use case where we need to checkout someone's fork - repository: pytorch/test-infra - path: test-infra + - name: Checkout code + uses: actions/checkout@v4 - - name: Checkout repository (${{ github.repository }}) - uses: actions/checkout@v3 - with: - # Support the use case where we need to checkout someone's fork - repository: ${{ github.repository }} - ref: ${{ github.ref }} - path: ${{ github.repository }} - fetch-depth: 1 - - - name: Setup miniconda - uses: ./test-infra/.github/actions/setup-miniconda + - name: Setup Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} + cache: "pip" - - name: Install PyTorch - if: ${{ matrix.pytorch-channel == 'pytorch' }} - shell: bash -l {0} - run: | - conda shell.bash hook - conda activate $CONDA_ENV - pip install -U torch torchvision - - - name: Install PyTorch (nightly) - if: ${{ matrix.pytorch-channel == 'pytorch-nightly' }} - shell: bash -l {0} + - name: Install uv run: | - conda shell.bash hook - conda activate $CONDA_ENV - pip install --pre -U torch torchvision --index-url https://download.pytorch.org/whl/nightly/cpu + curl -LsSf https://astral.sh/uv/install.sh | sh + echo "$HOME/.cargo/bin" >> $GITHUB_PATH - - name: Install dependencies - shell: bash -l {0} - working-directory: ${{ github.repository }} + - name: Install dependencies with uv run: | - conda activate $CONDA_ENV - # TODO: We add set -xe to explicitly fail the CI if one of the commands is failing. - # Somehow the step is passing even if a subcommand failed - set -xe - pip install -r requirements-dev.txt - echo "1 returned code: $?" - pip install -e . - echo "2 returned code: $?" + uv pip install -r requirements-dev.txt + uv pip install -e . pip list - echo "3 returned code: $?" - # Download MNIST: https://github.com/pytorch/ignite/issues/1737 - # to "/tmp" for unit tests - name: Download MNIST uses: pytorch-ignite/download-mnist-github-action@master with: @@ -114,22 +68,16 @@ jobs: cp -R /tmp/MNIST . - name: Run Tests - shell: bash -l {0} - working-directory: ${{ github.repository }} run: | - conda activate $CONDA_ENV SKIP_DISTRIB_TESTS=${{ matrix.skip-distrib-tests }} bash tests/run_cpu_tests.sh - name: Upload coverage to Codecov uses: codecov/codecov-action@v3 with: - file: ${{ github.repository }}/coverage.xml + file: coverage.xml flags: mps fail_ci_if_error: false - name: Run MNIST Examples - shell: bash -l {0} - working-directory: ${{ github.repository }} run: | - conda activate $CONDA_ENV python examples/mnist/mnist.py --epochs=1 From 1e841324f0f3f89a8bdebcdc38c4419a46b5e8cf Mon Sep 17 00:00:00 2001 From: BanzaiTokyo Date: Wed, 30 Apr 2025 09:54:56 +0000 Subject: [PATCH 02/11] replace conda with uv in mps-tests.yml --- .github/workflows/mps-tests.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/mps-tests.yml b/.github/workflows/mps-tests.yml index 087bec9c83fd..ae1ff7d7c868 100644 --- a/.github/workflows/mps-tests.yml +++ b/.github/workflows/mps-tests.yml @@ -27,13 +27,13 @@ concurrency: jobs: mps-tests: - runs-on: macos-14 strategy: matrix: python-version: [3.11] pytorch-channel: ["pytorch"] skip-distrib-tests: [1] fail-fast: false + runs-on: ["macos-m1-stable"] timeout-minutes: 60 steps: @@ -53,10 +53,12 @@ jobs: - name: Install dependencies with uv run: | - uv pip install -r requirements-dev.txt - uv pip install -e . + uv pip install --system -r requirements-dev.txt + uv pip install --system -e . pip list + # Download MNIST: https://github.com/pytorch/ignite/issues/1737 + # to "/tmp" for unit tests - name: Download MNIST uses: pytorch-ignite/download-mnist-github-action@master with: From 464d9dc7f3c50201ae2362d00bc56d845060538d Mon Sep 17 00:00:00 2001 From: BanzaiTokyo Date: Wed, 30 Apr 2025 13:50:40 +0000 Subject: [PATCH 03/11] add venv --- .github/workflows/mps-tests.yml | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/.github/workflows/mps-tests.yml b/.github/workflows/mps-tests.yml index ae1ff7d7c868..142c01536bd1 100644 --- a/.github/workflows/mps-tests.yml +++ b/.github/workflows/mps-tests.yml @@ -22,9 +22,14 @@ on: workflow_dispatch: concurrency: + # -- group: mps-tests-${{ github.ref_name }}-${{ !(github.ref_protected) || github.sha }} cancel-in-progress: true +# Cherry-picked from +# - https://github.com/pytorch/vision/blob/main/.github/workflows/tests.yml +# - https://github.com/pytorch/test-infra/blob/main/.github/workflows/macos_job.yml + jobs: mps-tests: strategy: @@ -37,24 +42,27 @@ jobs: timeout-minutes: 60 steps: - - name: Checkout code + - name: Checkout repository uses: actions/checkout@v4 - - name: Setup Python ${{ matrix.python-version }} + - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - cache: "pip" + cache: pip - name: Install uv run: | curl -LsSf https://astral.sh/uv/install.sh | sh echo "$HOME/.cargo/bin" >> $GITHUB_PATH - - name: Install dependencies with uv + - name: Set up virtual environment and install dependencies run: | - uv pip install --system -r requirements-dev.txt - uv pip install --system -e . + python -m venv .venv + source .venv/bin/activate + python -m pip install --upgrade pip + uv pip install -r requirements-dev.txt + uv pip install -e . pip list # Download MNIST: https://github.com/pytorch/ignite/issues/1737 @@ -71,6 +79,7 @@ jobs: - name: Run Tests run: | + source .venv/bin/activate SKIP_DISTRIB_TESTS=${{ matrix.skip-distrib-tests }} bash tests/run_cpu_tests.sh - name: Upload coverage to Codecov @@ -82,4 +91,5 @@ jobs: - name: Run MNIST Examples run: | + source .venv/bin/activate python examples/mnist/mnist.py --epochs=1 From 7ab606965302b8e1b7835efd6c2442224634b485 Mon Sep 17 00:00:00 2001 From: BanzaiTokyo Date: Wed, 30 Apr 2025 13:53:48 +0000 Subject: [PATCH 04/11] try macos-14 --- .github/workflows/mps-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/mps-tests.yml b/.github/workflows/mps-tests.yml index 142c01536bd1..d3cc592b285b 100644 --- a/.github/workflows/mps-tests.yml +++ b/.github/workflows/mps-tests.yml @@ -38,7 +38,7 @@ jobs: pytorch-channel: ["pytorch"] skip-distrib-tests: [1] fail-fast: false - runs-on: ["macos-m1-stable"] + runs-on: macos-14 timeout-minutes: 60 steps: From 8751e21b718b6e13b6424782705f1da822594464 Mon Sep 17 00:00:00 2001 From: BanzaiTokyo Date: Wed, 30 Apr 2025 14:15:11 +0000 Subject: [PATCH 05/11] use macos-m1-stable --- .github/workflows/mps-tests.yml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/mps-tests.yml b/.github/workflows/mps-tests.yml index d3cc592b285b..0299c9716cb5 100644 --- a/.github/workflows/mps-tests.yml +++ b/.github/workflows/mps-tests.yml @@ -38,27 +38,28 @@ jobs: pytorch-channel: ["pytorch"] skip-distrib-tests: [1] fail-fast: false - runs-on: macos-14 + runs-on: ["macos-m1-stable"] timeout-minutes: 60 steps: - name: Checkout repository uses: actions/checkout@v4 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - cache: pip + - name: Check system Python + run: | + which python3 + python3 --version - name: Install uv run: | curl -LsSf https://astral.sh/uv/install.sh | sh echo "$HOME/.cargo/bin" >> $GITHUB_PATH + export PATH="$HOME/.cargo/bin:$PATH" + uv --version - name: Set up virtual environment and install dependencies run: | - python -m venv .venv + python3 -m venv .venv source .venv/bin/activate python -m pip install --upgrade pip uv pip install -r requirements-dev.txt From a46b17cbf428b71de16437324d0ea37bcdf4cb0e Mon Sep 17 00:00:00 2001 From: BanzaiTokyo Date: Wed, 30 Apr 2025 14:19:10 +0000 Subject: [PATCH 06/11] add local/bin to PATH --- .github/workflows/mps-tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/mps-tests.yml b/.github/workflows/mps-tests.yml index 0299c9716cb5..95cc22cf6b9d 100644 --- a/.github/workflows/mps-tests.yml +++ b/.github/workflows/mps-tests.yml @@ -53,8 +53,8 @@ jobs: - name: Install uv run: | curl -LsSf https://astral.sh/uv/install.sh | sh - echo "$HOME/.cargo/bin" >> $GITHUB_PATH - export PATH="$HOME/.cargo/bin:$PATH" + echo "$HOME/.local/bin" >> $GITHUB_PATH + export PATH="$HOME/.local/bin:$PATH" uv --version - name: Set up virtual environment and install dependencies From c8222686c9a05925c530f611b32e9f60a2136025 Mon Sep 17 00:00:00 2001 From: BanzaiTokyo Date: Wed, 30 Apr 2025 14:34:23 +0000 Subject: [PATCH 07/11] use setup-uv GitHub Action --- .github/workflows/mps-tests.yml | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/.github/workflows/mps-tests.yml b/.github/workflows/mps-tests.yml index 95cc22cf6b9d..71cd001cc51a 100644 --- a/.github/workflows/mps-tests.yml +++ b/.github/workflows/mps-tests.yml @@ -45,21 +45,18 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 - - name: Check system Python - run: | - which python3 - python3 --version + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + cache: pip - - name: Install uv - run: | - curl -LsSf https://astral.sh/uv/install.sh | sh - echo "$HOME/.local/bin" >> $GITHUB_PATH - export PATH="$HOME/.local/bin:$PATH" - uv --version + - name: Install uv using GitHub Action + uses: astral-sh/setup-uv@v1 - name: Set up virtual environment and install dependencies run: | - python3 -m venv .venv + python -m venv .venv source .venv/bin/activate python -m pip install --upgrade pip uv pip install -r requirements-dev.txt From 0f44a42fe5601ed5aedb8c24f16359bddfb431f5 Mon Sep 17 00:00:00 2001 From: BanzaiTokyo Date: Wed, 30 Apr 2025 14:53:59 +0000 Subject: [PATCH 08/11] use macos-14 --- .github/workflows/mps-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/mps-tests.yml b/.github/workflows/mps-tests.yml index 71cd001cc51a..282be59d691f 100644 --- a/.github/workflows/mps-tests.yml +++ b/.github/workflows/mps-tests.yml @@ -38,7 +38,7 @@ jobs: pytorch-channel: ["pytorch"] skip-distrib-tests: [1] fail-fast: false - runs-on: ["macos-m1-stable"] + runs-on: macos-14 timeout-minutes: 60 steps: From 244be47a885aa2906fb49ef875eb8326f72fd68b Mon Sep 17 00:00:00 2001 From: BanzaiTokyo Date: Wed, 30 Apr 2025 15:10:56 +0000 Subject: [PATCH 09/11] again macos-m1-stable --- .github/workflows/mps-tests.yml | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/.github/workflows/mps-tests.yml b/.github/workflows/mps-tests.yml index 282be59d691f..cdeb6bafe78e 100644 --- a/.github/workflows/mps-tests.yml +++ b/.github/workflows/mps-tests.yml @@ -38,18 +38,22 @@ jobs: pytorch-channel: ["pytorch"] skip-distrib-tests: [1] fail-fast: false - runs-on: macos-14 + runs-on: ["macos-m1-stable"] timeout-minutes: 60 steps: - name: Checkout repository uses: actions/checkout@v4 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - cache: pip + - name: Install pyenv and Python ${{ matrix.python-version }} + run: | + brew update + brew install pyenv + pyenv install ${{ matrix.python-version }} + pyenv global ${{ matrix.python-version }} + echo "$HOME/.pyenv/bin" >> $GITHUB_PATH + echo "$HOME/.pyenv/shims" >> $GITHUB_PATH + python --version - name: Install uv using GitHub Action uses: astral-sh/setup-uv@v1 @@ -58,7 +62,6 @@ jobs: run: | python -m venv .venv source .venv/bin/activate - python -m pip install --upgrade pip uv pip install -r requirements-dev.txt uv pip install -e . pip list From 0c25aaf9a3495bd3c8dc08f11f37c1cb91ff02e2 Mon Sep 17 00:00:00 2001 From: BanzaiTokyo Date: Wed, 30 Apr 2025 15:38:54 +0000 Subject: [PATCH 10/11] Install uv and set the python version (to remove venv) --- .github/workflows/mps-tests.yml | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/.github/workflows/mps-tests.yml b/.github/workflows/mps-tests.yml index cdeb6bafe78e..1932a238df57 100644 --- a/.github/workflows/mps-tests.yml +++ b/.github/workflows/mps-tests.yml @@ -45,23 +45,13 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 - - name: Install pyenv and Python ${{ matrix.python-version }} - run: | - brew update - brew install pyenv - pyenv install ${{ matrix.python-version }} - pyenv global ${{ matrix.python-version }} - echo "$HOME/.pyenv/bin" >> $GITHUB_PATH - echo "$HOME/.pyenv/shims" >> $GITHUB_PATH - python --version - - - name: Install uv using GitHub Action - uses: astral-sh/setup-uv@v1 + - name: Install uv and set the python version + uses: astral-sh/setup-uv@v5 + with: + python-version: ${{ matrix.python-version }} - - name: Set up virtual environment and install dependencies + - name: Install dependencies run: | - python -m venv .venv - source .venv/bin/activate uv pip install -r requirements-dev.txt uv pip install -e . pip list @@ -79,9 +69,7 @@ jobs: cp -R /tmp/MNIST . - name: Run Tests - run: | - source .venv/bin/activate - SKIP_DISTRIB_TESTS=${{ matrix.skip-distrib-tests }} bash tests/run_cpu_tests.sh + run: SKIP_DISTRIB_TESTS=${{ matrix.skip-distrib-tests }} bash tests/run_cpu_tests.sh - name: Upload coverage to Codecov uses: codecov/codecov-action@v3 @@ -91,6 +79,4 @@ jobs: fail_ci_if_error: false - name: Run MNIST Examples - run: | - source .venv/bin/activate - python examples/mnist/mnist.py --epochs=1 + run: python examples/mnist/mnist.py --epochs=1 From 72e8a011f1680f491184e5a221d4d13ba6387108 Mon Sep 17 00:00:00 2001 From: BanzaiTokyo Date: Thu, 1 May 2025 15:00:38 +0000 Subject: [PATCH 11/11] rollback binaries-nightly-release.yml --- .github/workflows/binaries-nightly-release.yml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/binaries-nightly-release.yml b/.github/workflows/binaries-nightly-release.yml index 5a6c664eb834..6ef1c3f6faa3 100644 --- a/.github/workflows/binaries-nightly-release.yml +++ b/.github/workflows/binaries-nightly-release.yml @@ -12,21 +12,22 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Setup Python - uses: actions/setup-python@v4 + - name: Setup Miniconda + uses: conda-incubator/setup-miniconda@v2 with: + miniconda-version: "latest" python-version: "3.10" - - name: Install Astral UV - run: curl -LsSf https://astral.sh/uv/install.sh | sh + - name: Setup nightly version run: | sed -i "s/__version__ = \"\(.*\)\"/__version__ = \"\1.dev$(date -u +%Y%m%d)\"/g" ignite/__init__.py cat ignite/__init__.py - - name: Install dependencies with UV + - name: Install dependencies + shell: bash -l {0} run: | - uv pip install torch torchvision --index-url https://download.pytorch.org/whl/nightly/cpu - uv pip install -r requirements-dev.txt + conda install -y pytorch torchvision cpuonly -c pytorch-nightly + pip install -r requirements-dev.txt - name: Build and Publish Conda binaries shell: bash -l {0}