Skip to content

Commit

Permalink
add pre-commit checks
Browse files Browse the repository at this point in the history
  • Loading branch information
jameslamb committed May 10, 2024
1 parent b24d308 commit f9f6e55
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 27 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/build_and_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,24 @@ permissions:
statuses: none

jobs:
checks:
runs-on: ubuntu-latest
container:
image: rapidsai/ci-conda:latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 1
- uses: actions/cache@v4
with:
path: ~/.cache/pre-commit
key: pre-commit-0|${{ hashFiles('.pre-commit-config.yaml') }}
- name: Run pre-commit
run: |
pre-commit run --all-files --show-diff-on-failure
compute-matrices:
needs: checks
runs-on: ubuntu-latest
outputs:
BUILD_MATRIX: ${{ steps.compute-matrix.outputs.BUILD_MATRIX }}
Expand Down
20 changes: 20 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright (c) 2024, NVIDIA CORPORATION.

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- repo: https://github.com/PyCQA/isort
rev: 5.13.2
hooks:
- id: isort
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.4
hooks:
- id: ruff
- id: ruff-format

default_language_version:
python: python3
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This repository hosts code for building wheels of [UCX](https://github.com/openucx/ucx/).

## Purpose
## Purpose
RAPIDS publishes multiple libraries that rely on UCX, including [ucxx](https://github.com/rapidsai/ucxx/) and [ucx-py](https://github.com/rapidsai/ucx-py).
One of the ways that RAPIDS vendors these libraries is in the form of [pip wheels](https://packaging.python.org/en/latest/specifications/binary-distribution-format/).
For portability, wheels should be as self-contained as possible as per the [manylinux standard](https://peps.python.org/pep-0513/).
Expand Down
10 changes: 5 additions & 5 deletions python/libucx/libucx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@

from .load import load_library


__version__ = (
importlib.resources.files("libucx")
.joinpath("VERSION")
.read_text()
.strip()
importlib.resources.files("libucx").joinpath("VERSION").read_text().strip()
)

__all__ = [
"load_library",
]
3 changes: 1 addition & 2 deletions python/libucx/libucx/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import ctypes
import os


# IMPORTANT: The load order here matters! libucm.so depends on symbols in libucs.so, but
# it does not express this via a DT_NEEDED entry, presumably because libucs.so also has
# a dependency on libucm.so and the libraries are attempting to avoid a circular
Expand All @@ -33,8 +32,8 @@
"libucp.so",
]

def load_library():

def load_library():
# Dynamically load libucx.so. Prefer a system library if one is present to
# avoid clobbering symbols that other packages might expect, but if no
# other library is present use the one in the wheel.
Expand Down
55 changes: 36 additions & 19 deletions python/libucx/setup.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from setuptools import setup
from setuptools.command.build_py import build_py as build_orig
import subprocess
from contextlib import contextmanager
import glob
import os
import subprocess
import tempfile
import glob
from contextlib import contextmanager

import packaging.version
from setuptools import setup
from setuptools.command.build_py import build_py as build_orig


@contextmanager
Expand All @@ -24,7 +25,7 @@ def run(self):

with open("VERSION") as f:
package_version = f.read().strip()

# strip off any other non-UCX version components, like ".post1"
ucx_semver = packaging.version.parse(package_version).base_version
ucx_tag = f"v{ucx_semver}"
Expand All @@ -33,20 +34,36 @@ def run(self):

with tempfile.TemporaryDirectory() as tmpdir:
with chdir(tmpdir):
subprocess.run(["git", "clone", "-b", f"{ucx_tag}", "https://github.com/openucx/ucx.git", "ucx"])
subprocess.run(
[
"git",
"clone",
"-b",
f"{ucx_tag}",
"https://github.com/openucx/ucx.git",
"ucx",
]
)
with chdir("ucx"):
subprocess.run(["./autogen.sh"])
subprocess.run(["./contrib/configure-release",
f"--prefix={install_prefix}",
"--enable-mt",
"--enable-cma",
"--enable-numa",
"--with-gnu-ld",
"--with-sysroot",
"--without-verbs",
"--without-rdmacm",
"--with-cuda=/usr/local/cuda"])
subprocess.run(["make", "-j"], env={**os.environ, "CPPFLAGS": "-I/usr/local/cuda/include"})
subprocess.run(
[
"./contrib/configure-release",
f"--prefix={install_prefix}",
"--enable-mt",
"--enable-cma",
"--enable-numa",
"--with-gnu-ld",
"--with-sysroot",
"--without-verbs",
"--without-rdmacm",
"--with-cuda=/usr/local/cuda",
]
)
subprocess.run(
["make", "-j"],
env={**os.environ, "CPPFLAGS": "-I/usr/local/cuda/include"},
)
subprocess.run(["make", "install"])
# The config file built into UCX is not relocatable. We need to fix
# that so that we can package up UCX and distribute it in a wheel.
Expand All @@ -55,7 +72,7 @@ def run(self):
"sed",
"-i",
r"s/^set(prefix.*/set(prefix \"${CMAKE_CURRENT_LIST_DIR}\/..\/..\/..\")/",
f"{install_prefix}/lib/cmake/ucx/ucx-targets.cmake"
f"{install_prefix}/lib/cmake/ucx/ucx-targets.cmake",
]
)
# The UCX libraries must be able to find each other as dependencies.
Expand Down

0 comments on commit f9f6e55

Please sign in to comment.