From 78aefc8bd6a654675e09bfc6635908310c180e00 Mon Sep 17 00:00:00 2001 From: Evgeni Burovski Date: Mon, 3 Feb 2025 13:39:38 +0100 Subject: [PATCH 1/3] CI: add a CuPy CI run --- .github/workflows/array-api-tests-cupy.yml | 54 ++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 .github/workflows/array-api-tests-cupy.yml diff --git a/.github/workflows/array-api-tests-cupy.yml b/.github/workflows/array-api-tests-cupy.yml new file mode 100644 index 00000000..319596ac --- /dev/null +++ b/.github/workflows/array-api-tests-cupy.yml @@ -0,0 +1,54 @@ +name: CuPy Array API Tests + +on: [push, pull_request] + +env: + PYTEST_ARGS: "--max-examples 200 -v -rxXfE --ci ${{ inputs.pytest-extra-args }} --hypothesis-disable-deadline" + +permissions: + contents: read # to fetch code (actions/checkout) + + +jobs: + tests: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ['3.11'] + + steps: + - name: Checkout array-api-compat + uses: actions/checkout@v4 + with: + path: array-api-compat + - name: Checkout array-api-tests + uses: actions/checkout@v4 + with: + repository: data-apis/array-api-tests + submodules: 'true' + path: array-api-tests + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Initialize submodules in -tests + run: | + cd array-api-tests + git submodule update --init + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install -r ${GITHUB_WORKSPACE}/array-api-tests/requirements.txt + python -m pip install cupy-cuda12x + + - name: Run the array API testsuite (CuPy) + env: + ARRAY_API_TESTS_MODULE: array_api_compat.cupy + ARRAY_API_TESTS_VERSION: 2023.12 + PYTEST_ARGS: "--max-examples 200 -v -rxXfE --ci --hypothesis-disable-deadline" + run: | + export PYTHONPATH="${GITHUB_WORKSPACE}/array-api-compat" + cd ${GITHUB_WORKSPACE}/array-api-tests + pytest array_api_tests/ --xfails-file ${GITHUB_WORKSPACE}/array-api-compat/cupy-xfails.txt ${PYTEST_ARGS} From 421a662c5e1a27df02bd9050216b9048313e0cf7 Mon Sep 17 00:00:00 2001 From: Evgeni Burovski Date: Mon, 3 Feb 2025 13:40:28 +0100 Subject: [PATCH 2/3] REVERT: temp rm other workflows --- .github/workflows/array-api-tests-dask.yml | 13 -- .../workflows/array-api-tests-numpy-1-21.yml | 11 -- .../workflows/array-api-tests-numpy-1-26.yml | 11 -- .../workflows/array-api-tests-numpy-dev.yml | 11 -- .../array-api-tests-numpy-latest.yml | 9 -- .github/workflows/array-api-tests-torch.yml | 11 -- .github/workflows/array-api-tests.yml | 85 ------------- .github/workflows/dependabot-auto-merge.yml | 23 ---- .github/workflows/docs-build.yml | 22 ---- .github/workflows/docs-deploy.yml | 30 ----- .github/workflows/publish-package.yml | 112 ------------------ .github/workflows/ruff.yml | 19 --- .github/workflows/tests.yml | 46 ------- 13 files changed, 403 deletions(-) delete mode 100644 .github/workflows/array-api-tests-dask.yml delete mode 100644 .github/workflows/array-api-tests-numpy-1-21.yml delete mode 100644 .github/workflows/array-api-tests-numpy-1-26.yml delete mode 100644 .github/workflows/array-api-tests-numpy-dev.yml delete mode 100644 .github/workflows/array-api-tests-numpy-latest.yml delete mode 100644 .github/workflows/array-api-tests-torch.yml delete mode 100644 .github/workflows/array-api-tests.yml delete mode 100644 .github/workflows/dependabot-auto-merge.yml delete mode 100644 .github/workflows/docs-build.yml delete mode 100644 .github/workflows/docs-deploy.yml delete mode 100644 .github/workflows/publish-package.yml delete mode 100644 .github/workflows/ruff.yml delete mode 100644 .github/workflows/tests.yml diff --git a/.github/workflows/array-api-tests-dask.yml b/.github/workflows/array-api-tests-dask.yml deleted file mode 100644 index 78010233..00000000 --- a/.github/workflows/array-api-tests-dask.yml +++ /dev/null @@ -1,13 +0,0 @@ -name: Array API Tests (Dask) - -on: [push, pull_request] - -jobs: - array-api-tests-dask: - uses: ./.github/workflows/array-api-tests.yml - with: - package-name: dask - package-version: '>= 2024.9.0' - module-name: dask.array - extra-requires: numpy - pytest-extra-args: --disable-deadline --max-examples=5 diff --git a/.github/workflows/array-api-tests-numpy-1-21.yml b/.github/workflows/array-api-tests-numpy-1-21.yml deleted file mode 100644 index 2d81c3cd..00000000 --- a/.github/workflows/array-api-tests-numpy-1-21.yml +++ /dev/null @@ -1,11 +0,0 @@ -name: Array API Tests (NumPy 1.21) - -on: [push, pull_request] - -jobs: - array-api-tests-numpy-1-21: - uses: ./.github/workflows/array-api-tests.yml - with: - package-name: numpy - package-version: '== 1.21.*' - xfails-file-extra: '-1-21' diff --git a/.github/workflows/array-api-tests-numpy-1-26.yml b/.github/workflows/array-api-tests-numpy-1-26.yml deleted file mode 100644 index 660935f0..00000000 --- a/.github/workflows/array-api-tests-numpy-1-26.yml +++ /dev/null @@ -1,11 +0,0 @@ -name: Array API Tests (NumPy 1.26) - -on: [push, pull_request] - -jobs: - array-api-tests-numpy-latest: - uses: ./.github/workflows/array-api-tests.yml - with: - package-name: numpy - package-version: '== 1.26.*' - xfails-file-extra: '-1-26' diff --git a/.github/workflows/array-api-tests-numpy-dev.yml b/.github/workflows/array-api-tests-numpy-dev.yml deleted file mode 100644 index eef4269d..00000000 --- a/.github/workflows/array-api-tests-numpy-dev.yml +++ /dev/null @@ -1,11 +0,0 @@ -name: Array API Tests (NumPy dev) - -on: [push, pull_request] - -jobs: - array-api-tests-numpy-dev: - uses: ./.github/workflows/array-api-tests.yml - with: - package-name: numpy - extra-requires: '--pre --extra-index https://pypi.anaconda.org/scientific-python-nightly-wheels/simple' - xfails-file-extra: '-dev' diff --git a/.github/workflows/array-api-tests-numpy-latest.yml b/.github/workflows/array-api-tests-numpy-latest.yml deleted file mode 100644 index 36984345..00000000 --- a/.github/workflows/array-api-tests-numpy-latest.yml +++ /dev/null @@ -1,9 +0,0 @@ -name: Array API Tests (NumPy Latest) - -on: [push, pull_request] - -jobs: - array-api-tests-numpy-latest: - uses: ./.github/workflows/array-api-tests.yml - with: - package-name: numpy diff --git a/.github/workflows/array-api-tests-torch.yml b/.github/workflows/array-api-tests-torch.yml deleted file mode 100644 index 56ab81a3..00000000 --- a/.github/workflows/array-api-tests-torch.yml +++ /dev/null @@ -1,11 +0,0 @@ -name: Array API Tests (PyTorch Latest) - -on: [push, pull_request] - -jobs: - array-api-tests-torch: - uses: ./.github/workflows/array-api-tests.yml - with: - package-name: torch - extra-env-vars: | - ARRAY_API_TESTS_SKIP_DTYPES=uint16,uint32,uint64 diff --git a/.github/workflows/array-api-tests.yml b/.github/workflows/array-api-tests.yml deleted file mode 100644 index e0d5d84e..00000000 --- a/.github/workflows/array-api-tests.yml +++ /dev/null @@ -1,85 +0,0 @@ -name: Array API Tests - -on: - workflow_call: - inputs: - package-name: - required: true - type: string - module-name: - required: false - type: string - extra-requires: - required: false - type: string - package-version: - required: false - type: string - default: '>= 0' - pytest-extra-args: - required: false - type: string - # This is not how I would prefer to implement this but it's the only way - # that seems possible with GitHub Actions' limited expressions syntax - xfails-file-extra: - required: false - type: string - skips-file-extra: - required: false - type: string - extra-env-vars: - required: false - type: string - description: "Multiline string of environment variables to set for the test run." - -env: - PYTEST_ARGS: "--max-examples 200 -v -rxXfE --ci ${{ inputs.pytest-extra-args }} --hypothesis-disable-deadline" - -jobs: - tests: - runs-on: ubuntu-latest - strategy: - matrix: - # min version of dask we needs drops support for python 3.9 - python-version: ${{ inputs.package-name == 'dask' && fromJson('[''3.10'', ''3.11'', ''3.12'']') || fromJson('[''3.9'', ''3.10'', ''3.11'', ''3.12'']') }} - - steps: - - name: Checkout array-api-compat - uses: actions/checkout@v4 - with: - path: array-api-compat - - name: Checkout array-api-tests - uses: actions/checkout@v4 - with: - repository: data-apis/array-api-tests - submodules: 'true' - path: array-api-tests - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - name: Set Extra Environment Variables - # Set additional environment variables if provided - if: inputs.extra-env-vars - run: | - echo "${{ inputs.extra-env-vars }}" >> $GITHUB_ENV - - name: Install dependencies - # NumPy 1.21 doesn't support Python 3.11. There doesn't seem to be a way - # to put this in the numpy 1.21 config file. - if: "! ((matrix.python-version == '3.11' || matrix.python-version == '3.12') && inputs.package-name == 'numpy' && contains(inputs.package-version, '1.21'))" - run: | - python -m pip install --upgrade pip - python -m pip install '${{ inputs.package-name }} ${{ inputs.package-version }}' ${{ inputs.extra-requires }} - python -m pip install -r ${GITHUB_WORKSPACE}/array-api-tests/requirements.txt - - name: Run the array API testsuite (${{ inputs.package-name }}) - if: "! ((matrix.python-version == '3.11' || matrix.python-version == '3.12') && inputs.package-name == 'numpy' && contains(inputs.package-version, '1.21'))" - env: - ARRAY_API_TESTS_MODULE: array_api_compat.${{ inputs.module-name || inputs.package-name }} - ARRAY_API_TESTS_VERSION: 2023.12 - # This enables the NEP 50 type promotion behavior (without it a lot of - # tests fail on bad scalar type promotion behavior) - NPY_PROMOTION_STATE: weak - run: | - export PYTHONPATH="${GITHUB_WORKSPACE}/array-api-compat" - cd ${GITHUB_WORKSPACE}/array-api-tests - pytest array_api_tests/ --xfails-file ${GITHUB_WORKSPACE}/array-api-compat/${{ inputs.package-name }}${{ inputs.xfails-file-extra }}-xfails.txt --skips-file ${GITHUB_WORKSPACE}/array-api-compat/${{ inputs.package-name }}${{ inputs.skips-file-extra}}-skips.txt ${PYTEST_ARGS} diff --git a/.github/workflows/dependabot-auto-merge.yml b/.github/workflows/dependabot-auto-merge.yml deleted file mode 100644 index bd29e25b..00000000 --- a/.github/workflows/dependabot-auto-merge.yml +++ /dev/null @@ -1,23 +0,0 @@ -# https://docs.github.com/en/code-security/dependabot/working-with-dependabot/automating-dependabot-with-github-actions#approve-a-pull-request -name: Dependabot auto-merge -on: pull_request - -permissions: - contents: write - pull-requests: write - -jobs: - dependabot: - runs-on: ubuntu-latest - if: github.actor == 'dependabot[bot]' - steps: - - name: Dependabot metadata - id: metadata - uses: dependabot/fetch-metadata@v2 - with: - github-token: "${{ secrets.GITHUB_TOKEN }}" - - name: Enable auto-merge for Dependabot PRs - run: gh pr merge --auto --merge "$PR_URL" - env: - PR_URL: ${{github.event.pull_request.html_url}} - GH_TOKEN: ${{secrets.GITHUB_TOKEN}} diff --git a/.github/workflows/docs-build.yml b/.github/workflows/docs-build.yml deleted file mode 100644 index 04c3aa66..00000000 --- a/.github/workflows/docs-build.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: Docs Build - -on: [push, pull_request] - -jobs: - docs-build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - - name: Install Dependencies - run: | - python -m pip install -r docs/requirements.txt - - name: Build Docs - run: | - cd docs - make html - - name: Upload Artifact - uses: actions/upload-artifact@v4 - with: - name: docs-build - path: docs/_build/html diff --git a/.github/workflows/docs-deploy.yml b/.github/workflows/docs-deploy.yml deleted file mode 100644 index 3700c17d..00000000 --- a/.github/workflows/docs-deploy.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: Docs Deploy - -on: - push: - branches: - - main - -jobs: - docs-deploy: - runs-on: ubuntu-latest - environment: - name: docs-deploy - steps: - - uses: actions/checkout@v4 - - name: Download Artifact - uses: dawidd6/action-download-artifact@v8 - with: - workflow: docs-build.yml - name: docs-build - path: docs/_build/html - - # Note, the gh-pages deployment requires setting up a SSH deploy key. - # See - # https://github.com/JamesIves/github-pages-deploy-action/tree/dev#using-an-ssh-deploy-key- - - name: Deploy - uses: JamesIves/github-pages-deploy-action@v4 - with: - folder: docs/_build/html - ssh-key: ${{ secrets.DEPLOY_KEY }} - force: no diff --git a/.github/workflows/publish-package.yml b/.github/workflows/publish-package.yml deleted file mode 100644 index 7b975aa5..00000000 --- a/.github/workflows/publish-package.yml +++ /dev/null @@ -1,112 +0,0 @@ -name: publish distributions -on: - push: - branches: - - main - tags: - - '[0-9]+.[0-9]+' - - '[0-9]+.[0-9]+.[0-9]+' - pull_request: - branches: - - main - release: - types: [published] - workflow_dispatch: - inputs: - publish: - type: choice - description: 'Publish to TestPyPI?' - options: - - false - - true - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - build: - name: Build Python distribution - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: '3.x' - - - name: Install python-build and twine - run: | - python -m pip install --upgrade pip setuptools - python -m pip install build twine - python -m pip list - - - name: Build a wheel and a sdist - run: | - PYTHONWARNINGS=error,default::DeprecationWarning python -m build . - - - name: Verify the distribution - run: twine check --strict dist/* - - - name: List contents of sdist - run: python -m tarfile --list dist/array_api_compat-*.tar.gz - - - name: List contents of wheel - run: python -m zipfile --list dist/array_api_compat-*.whl - - - name: Upload distribution artifact - uses: actions/upload-artifact@v4 - with: - name: dist-artifact - path: dist - - publish: - name: Publish Python distribution to (Test)PyPI - if: github.event_name != 'pull_request' && github.repository == 'data-apis/array-api-compat' && github.ref_type == 'tag' - needs: build - runs-on: ubuntu-latest - # Mandatory for publishing with a trusted publisher - # c.f. https://docs.pypi.org/trusted-publishers/using-a-publisher/ - permissions: - id-token: write - contents: write - # Restrict to the environment set for the trusted publisher - environment: - name: publish-package - - steps: - - name: Download distribution artifact - uses: actions/download-artifact@v4 - with: - name: dist-artifact - path: dist - - - name: List all files - run: ls -lh dist - - - name: Publish distribution 📦 to Test PyPI - # Publish to TestPyPI on tag events of if manually triggered - # Compare to 'true' string as booleans get turned into strings in the console - if: >- - (github.event_name == 'push' && startsWith(github.ref, 'refs/tags')) - || (github.event_name == 'workflow_dispatch' && github.event.inputs.publish == 'true') - uses: pypa/gh-action-pypi-publish@v1.12.4 - with: - repository-url: https://test.pypi.org/legacy/ - print-hash: true - - - name: Create GitHub Release from a Tag - uses: softprops/action-gh-release@v2 - if: startsWith(github.ref, 'refs/tags/') - with: - files: dist/* - - - name: Publish distribution 📦 to PyPI - if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') - uses: pypa/gh-action-pypi-publish@v1.12.4 - with: - print-hash: true diff --git a/.github/workflows/ruff.yml b/.github/workflows/ruff.yml deleted file mode 100644 index a9f0fd4b..00000000 --- a/.github/workflows/ruff.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: CI -on: [push, pull_request] -jobs: - check-ruff: - runs-on: ubuntu-latest - continue-on-error: true - steps: - - uses: actions/checkout@v4 - - name: Install Python - uses: actions/setup-python@v5 - with: - python-version: "3.11" - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install ruff - # Update output format to enable automatic inline annotations. - - name: Run Ruff - run: ruff check --output-format=github . diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml deleted file mode 100644 index fcd43367..00000000 --- a/.github/workflows/tests.yml +++ /dev/null @@ -1,46 +0,0 @@ -name: Tests -on: [push, pull_request] -jobs: - tests: - runs-on: ubuntu-latest - strategy: - matrix: - python-version: ['3.9', '3.10', '3.11', '3.12'] - numpy-version: ['1.21', '1.26', '2.0', 'dev'] - exclude: - - python-version: '3.11' - numpy-version: '1.21' - - python-version: '3.12' - numpy-version: '1.21' - fail-fast: true - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - name: Install Dependencies - run: | - python -m pip install --upgrade pip - if [ "${{ matrix.numpy-version }}" == "dev" ]; then - PIP_EXTRA='numpy --pre --extra-index-url https://pypi.anaconda.org/scientific-python-nightly-wheels/simple' - elif [ "${{ matrix.numpy-version }}" == "1.21" ]; then - PIP_EXTRA='numpy==1.21.*' - else - PIP_EXTRA='numpy==1.26.*' - fi - - if [ "${{ matrix.python-version }}" == "3.9" ]; then - sed -i '/^ndonnx/d' requirements-dev.txt - fi - - python -m pip install -r requirements-dev.txt $PIP_EXTRA - - - name: Run Tests - run: | - if [[ "${{ matrix.numpy-version }}" == "1.21" || "${{ matrix.numpy-version }}" == "dev" ]]; then - PYTEST_EXTRA=(-k "numpy and not jax and not torch and not dask and not sparse") - fi - pytest -v "${PYTEST_EXTRA[@]}" - - # Make sure it installs - python -m pip install . From d0ed5a6e887b7db061e6bb8b39a689f6215151a7 Mon Sep 17 00:00:00 2001 From: Evgeni Burovski Date: Mon, 3 Feb 2025 13:45:37 +0100 Subject: [PATCH 3/3] update the runner --- .github/workflows/array-api-tests-cupy.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/array-api-tests-cupy.yml b/.github/workflows/array-api-tests-cupy.yml index 319596ac..f04f6d57 100644 --- a/.github/workflows/array-api-tests-cupy.yml +++ b/.github/workflows/array-api-tests-cupy.yml @@ -11,7 +11,7 @@ permissions: jobs: tests: - runs-on: ubuntu-latest + runs-on: ghcr.io/cirruslabs/ubuntu-runner-amd64-gpu:22.04 strategy: matrix: python-version: ['3.11'] @@ -21,17 +21,25 @@ jobs: uses: actions/checkout@v4 with: path: array-api-compat + - name: Checkout array-api-tests uses: actions/checkout@v4 with: repository: data-apis/array-api-tests submodules: 'true' path: array-api-tests + - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} + - name: run nvidia-smi + run: nvidia-smi + + - name: run nvidia-smi --query + run: nvidia-smi --query + - name: Initialize submodules in -tests run: | cd array-api-tests