diff --git a/.github/workflows/code-style.yml b/.github/workflows/code-style.yml index 41574a123c10..7c0bab5e5c19 100644 --- a/.github/workflows/code-style.yml +++ b/.github/workflows/code-style.yml @@ -21,9 +21,15 @@ jobs: steps: - if: github.event_name == 'push' uses: actions/checkout@v4 - - uses: actions/setup-python@v5 + - uses: astral-sh/setup-uv@v6 with: python-version: "3.11" + activate-environment: true + enable-cache: true + - name: Check lock + id: check-lock + run: | + uv lock --check - run: | bash ./tests/run_code_style.sh install bash ./tests/run_code_style.sh fmt diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index b9f95c3cc7d2..c475a4e0f6c6 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -20,15 +20,17 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 + - uses: astral-sh/setup-uv@v6 with: python-version: "3.10" + activate-environment: true + enable-cache: true - run: sudo npm install katex -g - - uses: actions/cache@v4 - with: - path: ~/.cache/pip - key: pip-${{ hashFiles('requirements-dev.txt') }}-${{ hashFiles('docs/requirements.txt') }} + # - uses: actions/cache@v4 + # with: + # path: ~/.cache/pip + # key: pip-${{ hashFiles('requirements-dev.txt') }}-${{ hashFiles('docs/requirements.txt') }} - name: Install docs deps run: bash .github/workflows/install_docs_deps.sh @@ -51,14 +53,16 @@ jobs: timeout-minutes: 10 steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 + - uses: astral-sh/setup-uv@v6 with: python-version: "3.10" + activate-environment: true + enable-cache: true - - uses: actions/cache@v4 - with: - path: ~/.cache/pip - key: pip-${{ hashFiles('requirements-dev.txt') }}-${{ hashFiles('docs/requirements.txt') }} + # - uses: actions/cache@v4 + # with: + # path: ~/.cache/pip + # key: pip-${{ hashFiles('requirements-dev.txt') }}-${{ hashFiles('docs/requirements.txt') }} - name: Install docs deps run: bash .github/workflows/install_docs_deps.sh @@ -72,15 +76,23 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 + + - uses: astral-sh/setup-uv@v6 with: python-version: "3.10" + activate-environment: true + enable-cache: true + + - name: Check lock + id: check-lock + run: | + uv lock --check - run: sudo npm install katex -g - - uses: actions/cache@v4 - with: - path: ~/.cache/pip - key: pip-${{ hashFiles('requirements-dev.txt') }}-${{ hashFiles('docs/requirements.txt') }} + # - uses: actions/cache@v4 + # with: + # path: ~/.cache/pip + # key: pip-${{ hashFiles('requirements-dev.txt') }}-${{ hashFiles('docs/requirements.txt') }} - name: Install docs deps run: bash .github/workflows/install_docs_deps.sh diff --git a/.github/workflows/hvd-tests.yml b/.github/workflows/hvd-tests.yml index efa73425549e..da7d29aec369 100644 --- a/.github/workflows/hvd-tests.yml +++ b/.github/workflows/hvd-tests.yml @@ -41,29 +41,36 @@ jobs: - name: Get pip cache dir id: pip-cache + shell: bash -l {0} run: | - python3 -m pip install -U pip + uv pip install -U pip echo "pip_cache=$(python3 -m pip cache dir)" >> $GITHUB_OUTPUT - shell: bash -l {0} - - uses: actions/cache@v4 - with: - path: | - ~/conda_pkgs_dir - ${{ steps.pip-cache.outputs.pip_cache }} - key: ${{ steps.get-date.outputs.date }}-horovod-${{ hashFiles('requirements-dev.txt') }} + # - uses: actions/cache@v4 + # with: + # path: | + # ~/conda_pkgs_dir + # ${{ steps.pip-cache.outputs.pip_cache }} + # key: ${{ steps.get-date.outputs.date }}-horovod-${{ hashFiles('requirements-dev.txt') }} - - uses: actions/setup-python@v5 + - uses: astral-sh/setup-uv@v6 with: python-version: ${{ matrix.python-version }} + activate-environment: true + enable-cache: true + - name: Check lock + id: check-lock + run: | + uv lock --check + - name: Install dependencies shell: bash -l {0} run: | - #install other dependencies - pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu - pip install -r requirements-dev.txt + # install other dependencies + uv pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu + uv pip install -r requirements-dev.txt # Install Horovod from source and apply a patch to build with recent pytorch # We can't use pip install as build-env can't find pytorch and @@ -78,7 +85,7 @@ jobs: python -c "import horovod.torch as hvd; hvd.mpi_ops.Sum" # Install ignite - pip install . + uv pip install . # Download MNIST: https://github.com/pytorch/ignite/issues/1737 # to "/tmp" for cpu tests diff --git a/.github/workflows/install_docs_deps.sh b/.github/workflows/install_docs_deps.sh index 499b64211943..0beaca31288b 100644 --- a/.github/workflows/install_docs_deps.sh +++ b/.github/workflows/install_docs_deps.sh @@ -1,6 +1,6 @@ # remove pkg-resources as it causes failure when installing https://github.com/pytorch-ignite/sphinxcontrib-versioning -pip uninstall -y pkg-resources setuptools && pip install --upgrade setuptools pip wheel -pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu -U -pip install -r requirements-dev.txt -pip install -r docs/requirements.txt -pip install git+https://github.com/pytorch-ignite/sphinxcontrib-versioning.git +uv pip uninstall pkg-resources setuptools && pip install --upgrade setuptools pip wheel +uv pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu -U +uv pip install -r requirements-dev.txt +uv pip install -r docs/requirements.txt +uv pip install git+https://github.com/pytorch-ignite/sphinxcontrib-versioning.git diff --git a/.github/workflows/tpu-tests.yml b/.github/workflows/tpu-tests.yml index 2bd5e8f0d2c0..b4fb39ea4224 100644 --- a/.github/workflows/tpu-tests.yml +++ b/.github/workflows/tpu-tests.yml @@ -36,49 +36,51 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Set up Python 3.10 - uses: actions/setup-python@v5 + uses: astral-sh/setup-uv@v6 with: python-version: "3.10" - architecture: "x64" + activate-environment: true + enable-cache: true + + - name: Check lock + id: check-lock + run: | + uv lock --check - name: Get year & week number id: get-date - run: echo "date=$(/bin/date "+%Y-%U")" >> $GITHUB_OUTPUT shell: bash -l {0} + run: echo "date=$(/bin/date "+%Y-%U")" >> $GITHUB_OUTPUT - name: Get pip cache dir id: pip-cache + shell: bash -l {0} run: | - pip3 install -U "pip<24" + uv pip install -U "pip<24" echo "pip_cache=$(pip cache dir)" >> $GITHUB_OUTPUT - shell: bash -l {0} - - - uses: actions/cache@v4 - with: - path: | - ${{ steps.pip-cache.outputs.pip_cache }} - key: ${{ steps.get-date.outputs.date }}-pytorch-${{ runner.os }}-${{ matrix.xla-version }}-${{ hashFiles('requirements-dev.txt') }} - restore-keys: | - ${{ steps.get-date.outputs.date }}-pytorch-${{ runner.os }}-${{ matrix.xla-version }}- - name: Install Torch XLA and others run: | ## Install mkl (alternative approach to https://github.com/pytorch/xla/blob/b0ba29f98a695671972d4a4cc07441014dba2892/.kokoro/common.sh#L31-L32) sudo apt-get update && sudo apt-get install -y libopenblas-dev libomp5 - pip install mkl==2021.4.0 + uv pip install mkl==2021.4.0 ## Install torch & xla and torchvision - pip install --pre torch torchvision --index-url https://download.pytorch.org/whl/nightly/cpu - pip install https://storage.googleapis.com/pytorch-xla-releases/wheels/tpuvm/torch_xla-nightly-cp310-cp310-linux_x86_64.whl + uv pip install --pre torch torchvision --index-url https://download.pytorch.org/whl/nightly/cpu + ## TODO: download file and rename as valid file with version + curl -o torch_xla-2.5.0+gitf0bbaeb-cp310-cp310-linux_x86_64.whl https://storage.googleapis.com/pytorch-xla-releases/wheels/tpuvm/torch_xla-nightly-cp310-cp310-linux_x86_64.whl + uv pip install torch_xla-2.5.0+gitf0bbaeb-cp310-cp310-linux_x86_64.whl + # uv pip install https://storage.googleapis.com/pytorch-xla-releases/wheels/tpuvm/torch_xla-nightly-cp310-cp310-linux_x86_64.whl # Check installation python -c "import torch" ## Install test deps and Ignite - pip install -r requirements-dev.txt - pip install . + uv pip install -r requirements-dev.txt + uv pip install . # Download MNIST: https://github.com/pytorch/ignite/issues/1737 # to "/tmp" for tpu tests diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index c3d0b621e03e..7585a50d006b 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -59,9 +59,11 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 + - uses: astral-sh/setup-uv@v6 with: python-version: ${{ matrix.python-version }} + activate-environment: true + enable-cache: true - name: Get year & week number id: get-date @@ -82,21 +84,21 @@ jobs: restore-keys: | ${{ steps.get-date.outputs.date }}-pytorch-${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.pytorch-channel }}- - - run: pip install pip wheel setuptools -Uqq + - run: uv pip install pip wheel setuptools -Uqq - name: Install PyTorch if: ${{ matrix.pytorch-channel == 'pytorch' }} - run: pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu + run: uv pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu - name: Install PyTorch (nightly) if: ${{ matrix.pytorch-channel == 'pytorch-nightly' }} - run: pip install torch torchvision --index-url https://download.pytorch.org/whl/nightly/cpu --pre + run: uv pip install torch torchvision --index-url https://download.pytorch.org/whl/nightly/cpu --pre - name: Install dependencies run: | - pip install -r requirements-dev.txt - pip install . - pip list + uv pip install -r requirements-dev.txt + uv pip install . + uv pip list - name: Check code formatting run: | @@ -156,7 +158,7 @@ jobs: # 3.1) mnist_with_tensorboard.py with tbX python examples/mnist/mnist_with_tensorboard.py --epochs=1 # 3.2) mnist_with_tensorboard.py with native torch tb - pip uninstall -y tensorboardX + uv pip uninstall tensorboardX python examples/mnist/mnist_with_tensorboard.py --epochs=1 - name: Run MNIST Example With Crash diff --git a/docs/requirements.txt b/docs/requirements.txt index 9a88587a0ee2..8723edbff733 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,5 +1,5 @@ sphinx<6 --e git+https://github.com/pytorch/pytorch_sphinx_theme.git#egg=pytorch_sphinx_theme +git+https://github.com/pytorch/pytorch_sphinx_theme.git#egg=pytorch_sphinx_theme sphinxcontrib-katex sphinx-copybutton==0.4.0 docutils<0.18 diff --git a/pyproject.toml b/pyproject.toml index 1c60c561bafb..d01319b6f56f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,6 +14,7 @@ license-files = ["LICENSE"] classifiers = [ "Programming Language :: Python :: 3", ] +requires-python = ">=3.9,<3.13" dependencies = [ "torch>=1.3,<3", "packaging" diff --git a/tests/run_code_style.sh b/tests/run_code_style.sh index e94a652fbeb9..fe744ff1869e 100755 --- a/tests/run_code_style.sh +++ b/tests/run_code_style.sh @@ -3,12 +3,12 @@ set -xeu if [ $1 = "lint" ]; then - flake8 ignite tests examples --config setup.cfg - ufmt diff . + uv run flake8 ignite tests examples --config setup.cfg + uv run ufmt diff . elif [ $1 = "fmt" ]; then - ufmt format . + uv run ufmt format . elif [ $1 = "mypy" ]; then - mypy --config-file mypy.ini + uv run mypy --config-file mypy.ini elif [ $1 = "install" ]; then - pip install --upgrade flake8 "black==24.10.0" "usort==1.0.8.post1" "ufmt==2.7.3" "mypy" + uv pip install --upgrade flake8 "black==24.10.0" "usort==1.0.8.post1" "ufmt==2.7.3" "mypy" fi