Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update pre-commit hook versions, mark wheels as pure python #205

Merged
merged 4 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,31 +28,31 @@ jobs:
uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@branch-24.10
with:
build_type: pull-request
# Package is pure Python and only ever requires one build.
matrix_filter: 'map(select(.ARCH == "amd64" and (.LINUX_VER | test("centos")|not))) | sort_by(.PY_VER | split(".") | map(tonumber)) | [.[-1]]'
# This selects "ARCH=amd64 + the latest supported Python + CUDA".
matrix_filter: map(select(.ARCH == "amd64")) | max_by([(.PY_VER|split(".")|map(tonumber)), (.CUDA_VER|split(".")|map(tonumber))]) | [.]
conda-python-tests:
needs: conda-python-build
secrets: inherit
uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@branch-24.10
with:
build_type: pull-request
# Package is pure Python and only ever requires one build.
matrix_filter: 'map(select(.ARCH == "amd64" and (.LINUX_VER | test("centos")|not))) | sort_by(.PY_VER | split(".") | map(tonumber)) | [.[-1]]'
# This selects "ARCH=amd64 + the latest supported Python + CUDA".
matrix_filter: map(select(.ARCH == "amd64")) | max_by([(.PY_VER|split(".")|map(tonumber)), (.CUDA_VER|split(".")|map(tonumber))]) | [.]
wheel-build:
needs: checks
secrets: inherit
uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.10
with:
build_type: pull-request
# Package is pure Python and only ever requires one build.
matrix_filter: 'map(select((.LINUX_VER | test("centos")|not))) | sort_by((.PY_VER | split(".") | map(tonumber))) | [.[-1] + {ARCH: "amd64"}]'
# This selects the latest supported Python + CUDA
matrix_filter: max_by([(.PY_VER|split(".")|map(tonumber)), (.CUDA_VER|split(".")|map(tonumber))]) | [.]
script: "ci/build_wheel.sh"
wheel-tests:
needs: wheel-build
secrets: inherit
uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-24.10
with:
build_type: pull-request
# Package is pure Python and only ever requires one build.
matrix_filter: 'map(select(.ARCH == "amd64" and (.LINUX_VER | test("centos")|not))) | sort_by(.PY_VER | split(".") | map(tonumber)) | [.[-1]]'
script: "ci/test_wheel.sh"
# This selects the latest supported Python + CUDA
matrix_filter: max_by([(.PY_VER|split(".")|map(tonumber)), (.CUDA_VER|split(".")|map(tonumber))]) | [.]
script: "ci/test_wheel.sh"
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@

repos:
- repo: https://github.com/psf/black
rev: 23.11.0
rev: 24.8.0
hooks:
- id: black
files: jupyterlab_nvdashboard/.*
# Explicitly specify the pyproject.toml at the repo root, not per-project.
args: ['--config', 'pyproject.toml']
- repo: https://github.com/PyCQA/flake8
rev: 6.1.0
rev: 7.1.1
hooks:
- id: flake8
args: ['--config=.flake8']
files: jupyterlab_nvdashboard/.*$
- repo: https://github.com/rapidsai/dependency-file-generator
rev: v1.13.11
rev: v1.14.0
hooks:
- id: rapids-dependency-file-generator
args: ['--clean']
Expand Down
2 changes: 1 addition & 1 deletion ci/build_wheel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ python -m build -s -w

rapids-logger "Uploading JupyterLab NVDashboard wheels to S3"
# Upload Python wheels to S3
RAPIDS_PY_WHEEL_NAME="${package_name}" rapids-upload-wheels-to-s3 dist
RAPIDS_PY_WHEEL_NAME="${package_name}" RAPIDS_PY_WHEEL_PURE="1" rapids-upload-wheels-to-s3 dist
Copy link
Member Author

Choose a reason for hiding this comment

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

Wheels for jupyterlab-nvdashboard are pure python, with names like this when published:

jupyterlab_nvdashboard-0.10.0-py3-none-any.whl
jupyterlab_nvdashboard-0.11.0-py3-none-any.whl

(https://pypi.anaconda.org/rapidsai-wheels-nightly/simple/jupyterlab-nvdashboard/)

So, for example, it's totally fine to build a wheel on x86_64 with Python 3.10 and run it on arm64 with Python 3.12.

However, CI here has been uploading artifacts to S3 with Python-version-specific names, like this:

jupyterlab-nvdashboard_wheel_python_jupyterlab-nvdashboard_py312_x86_64.tar.gz

(https://downloads.rapids.ai/ci/jupyterlab-nvdashboard/pull-request/205/976585f/)

That means when this project uses a matrix_filters in GitHub Actions to limit to only running one build and one test job, it's necessary for their Python and CUDA versions to exactly match. When that doesn't happen, you'll get errors like this one that I saw:

download failed: s3://rapids-downloads/ci/jupyterlab-nvdashboard/pull-request/205/0de97c7/jupyterlab-nvdashboard_wheel_python_jupyterlab-nvdashboard_py310_x86_64.tar.gz to - An error occurred (404) when calling the HeadObject operation: Not Found

(build link)

This proposes setting RAPIDS_PY_WHEEL_PURE=1 to produce artifact names like this:

jupyterlab-nvdashboard_wheel_python_jupyterlab-nvdashboard.tar.gz

That way, CI here won't be broken by future shared-workflows matrix changes.

Why wasn't this a problem before?

This repo was getting lucky with its matrix filters. The matrix changed in rapidsai/shared-workflows#213 in a way that breaks CI here.

2 changes: 1 addition & 1 deletion ci/test_wheel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ set -eou pipefail
package_name="jupyterlab-nvdashboard"

rapids-logger "Downloading artifacts from previous jobs"
RAPIDS_PY_WHEEL_NAME="${package_name}" rapids-download-wheels-from-s3 ./dist
RAPIDS_PY_WHEEL_NAME="${package_name}" RAPIDS_PY_WHEEL_PURE="1" rapids-download-wheels-from-s3 ./dist

# echo to expand wildcard before adding `[extra]` required for pip
python -m pip install $(echo ./dist/jupyterlab_nvdashboard*.whl)[test]
Expand Down
4 changes: 1 addition & 3 deletions jupyterlab_nvdashboard/apps/gpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@

# Maximum bandwidth is bidirectional, divide by 2 for separate RX & TX
max_bw = (
max(
sum(i.value.ullVal for i in bw) * 1024**2 for bw in bandwidth
)
max(sum(i.value.ullVal for i in bw) * 1024**2 for bw in bandwidth)
/ 2
)
except (IndexError, pynvml.nvml.NVMLError_NotSupported):
Expand Down
7 changes: 4 additions & 3 deletions jupyterlab_nvdashboard/tests/test_cpu_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ def mock_handler(monkeypatch):

@pytest.fixture
def handler_args():
with patch("tornado.web.Application") as mock_application, patch(
"tornado.httputil.HTTPServerRequest"
) as mock_request:
with (
patch("tornado.web.Application") as mock_application,
patch("tornado.httputil.HTTPServerRequest") as mock_request,
):
# Mock the settings to return appropriate values
mock_settings = {
"base_url": "/",
Expand Down
7 changes: 4 additions & 3 deletions jupyterlab_nvdashboard/tests/test_gpu_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ def mock_handler(monkeypatch):

@pytest.fixture
def handler_args():
with patch("tornado.web.Application") as mock_application, patch(
"tornado.httputil.HTTPServerRequest"
) as mock_request:
with (
patch("tornado.web.Application") as mock_application,
patch("tornado.httputil.HTTPServerRequest") as mock_request,
):
# Mock the settings to return appropriate values
mock_settings = {
"base_url": "/",
Expand Down