Skip to content

Commit 7d51fc9

Browse files
JimyMaHuWen7gemini-code-assist[bot]
authored
switch ctrl image publishing to GHCR (#100)
* switch ctrl image publishing to GHCR * lint * remove tcp which is in another pr * Update dlslime-ctrl/src/net.rs Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> * lazy import httpx * fix nanoctrl lint * update pybind * add auto publish * reformat dir and bump to 0.1.2 * fix ci --------- Co-authored-by: HuWen7 <330508983@qq.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
1 parent 6e440d2 commit 7d51fc9

220 files changed

Lines changed: 1582 additions & 734 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.dockerignore

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Keep the Docker build context small. ctrl.Dockerfile only needs `dlslime-ctrl/`.
2+
3+
# Version control
4+
.git
5+
.gitignore
6+
.gitattributes
7+
.gitmodules
8+
9+
# Rust build artifacts
10+
**/target/
11+
12+
# Python build / cache artifacts
13+
**/build/
14+
**/__pycache__/
15+
**/*.egg-info/
16+
**/.pytest_cache/
17+
**/.mypy_cache/
18+
**/.ruff_cache/
19+
**/*.pyc
20+
**/*.pyo
21+
22+
# C++/CMake build artifacts
23+
**/CMakeCache.txt
24+
**/CMakeFiles/
25+
**/cmake_install.cmake
26+
**/*.o
27+
**/*.so
28+
**/*.a
29+
30+
# IDE / editor
31+
.vscode/
32+
.idea/
33+
*.swp
34+
*.swo
35+
36+
# OS junk
37+
.DS_Store
38+
Thumbs.db
39+
40+
# Top-level dirs not needed by ctrl.Dockerfile
41+
docs/
42+
docker/
43+
dlslime/
44+
cmake/
45+
scripts/
46+
47+
# Markdown / metadata at the repo root
48+
README.md
49+
README_zh.md
50+
LICENSE
51+
MANIFEST.in
52+
pyproject.toml
53+
CMakeLists.txt

.github/workflows/ci.yml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,12 @@ jobs:
7171
-DBUILD_TORCH_PLUGIN=OFF
7272
-DBUILD_ASCEND_DIRECT=OFF
7373
-DBUILD_TEST=OFF
74-
run: python -m build --wheel
74+
# The native wheel lives under dlslime/ (dlslime-ctrl/ is a separate Rust crate).
75+
run: python -m build --wheel --outdir dist dlslime
7576

7677
- name: Install wheel smoke test
7778
run: |
78-
python -m pip install dist/*.whl --no-deps
79+
python -m pip install dist/dlslime-*.whl --no-deps
7980
cd /tmp
8081
python - <<'PY'
8182
import dlslime
@@ -108,6 +109,9 @@ jobs:
108109
}
109110
trap cleanup EXIT
110111
112+
# Mount the runner-checked-out workspace into the container so the
113+
# tests always run against the exact commit being CI'd, not whatever
114+
# stale tree happens to live on the host.
111115
docker run -d \
112116
--gpus all \
113117
--network host \
@@ -116,15 +120,15 @@ jobs:
116120
--cap-add SYS_ADMIN \
117121
--cap-add SYS_PTRACE \
118122
--name "${container_name}" \
119-
-v /mnt/nvme1n1/ml_research/majinming:/mnt/nvme1n1/ml_research/majinming \
123+
-v "${GITHUB_WORKSPACE}:/workspace" \
120124
-v /mnt/nvme1n1/ml_research/models:/models \
121-
-w /mnt/nvme1n1/ml_research/majinming/src/DLSlime \
125+
-w /workspace \
122126
majinming_lmdeploy:v1 \
123127
sleep infinity
124128
125129
docker exec "${container_name}" bash -lc '
126130
set -euxo pipefail
127-
cd /mnt/nvme1n1/ml_research/majinming/src/DLSlime
131+
cd /workspace
128132
export PIP_CONFIG_FILE=/dev/null
129133
export PIP_INDEX_URL=https://mirrors.aliyun.com/pypi/simple/
130134
export PIP_TRUSTED_HOST=mirrors.aliyun.com
@@ -137,8 +141,8 @@ jobs:
137141
python -m pip install -U pip pytest
138142
python -m pip show dlslime || true
139143
python -m pip uninstall -y dlslime || true
140-
python -m pip install -e .
144+
python -m pip install -e dlslime
141145
python -m pip show dlslime
142146
python -c "import dlslime; print(\"dlslime:\", dlslime.__file__); print(\"available_nic:\", dlslime.available_nic())"
143-
pytest tests/python -v
147+
pytest dlslime/tests/python -v
144148
'
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# Build & publish the `dlslime-ctrl` image to GitHub Container Registry (GHCR).
2+
#
3+
# Triggers:
4+
# - Push to main / master -> publish `:edge` (and the commit SHA)
5+
# - Push of a tag like v0.1.2 -> publish `:0.1.2`, `:0.1`, `:latest`
6+
# - Manual workflow_dispatch -> custom tag via input
7+
#
8+
# No external secrets needed — uses the built-in GITHUB_TOKEN for auth.
9+
# After the first successful run, go to:
10+
# https://github.com/orgs/DeepLink-org/packages/container/dlslime-ctrl/settings
11+
# and set the package visibility to "Public" so anonymous `docker pull` works.
12+
13+
name: docker-publish
14+
15+
on:
16+
push:
17+
branches: [main, master]
18+
tags: ["v*"]
19+
paths:
20+
- "dlslime-ctrl/**"
21+
- "docker/**"
22+
- ".github/workflows/docker-publish.yml"
23+
workflow_dispatch:
24+
inputs:
25+
tag:
26+
description: "Extra tag to publish (e.g. dev, rc1)"
27+
required: false
28+
default: ""
29+
30+
permissions:
31+
contents: read
32+
packages: write
33+
34+
env:
35+
REGISTRY: ghcr.io
36+
# GHCR requires lowercase. ${{ github.repository_owner }} = "DeepLink-org",
37+
# so we explicitly lower-case it via the `tolower` toy below.
38+
IMAGE_NAME: deeplink-org/dlslime-ctrl
39+
40+
jobs:
41+
publish:
42+
runs-on: ubuntu-24.04
43+
steps:
44+
- uses: actions/checkout@v6
45+
46+
- name: Set up QEMU (for multi-arch)
47+
uses: docker/setup-qemu-action@v3
48+
49+
- name: Set up Docker Buildx
50+
uses: docker/setup-buildx-action@v3
51+
52+
- name: Log in to GHCR
53+
uses: docker/login-action@v3
54+
with:
55+
registry: ${{ env.REGISTRY }}
56+
username: ${{ github.actor }}
57+
password: ${{ secrets.GITHUB_TOKEN }}
58+
59+
# Generate tags + OCI labels automatically based on the git ref.
60+
# v1.2.3 -> 1.2.3, 1.2, latest
61+
# main -> edge
62+
# any push -> sha-<short>
63+
- name: Compute image metadata
64+
id: meta
65+
uses: docker/metadata-action@v5
66+
with:
67+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
68+
tags: |
69+
type=semver,pattern={{version}}
70+
type=semver,pattern={{major}}.{{minor}}
71+
type=raw,value=edge,enable={{is_default_branch}}
72+
type=sha,prefix=sha-,format=short
73+
type=raw,value=${{ github.event.inputs.tag }},enable=${{ github.event_name == 'workflow_dispatch' && github.event.inputs.tag != '' }}
74+
labels: |
75+
org.opencontainers.image.title=dlslime-ctrl
76+
org.opencontainers.image.description=DLSlime control plane server
77+
org.opencontainers.image.source=https://github.com/${{ github.repository }}
78+
org.opencontainers.image.licenses=MIT
79+
80+
- name: Build & push (linux/amd64, linux/arm64)
81+
uses: docker/build-push-action@v6
82+
with:
83+
context: .
84+
file: docker/ctrl.Dockerfile
85+
platforms: linux/amd64,linux/arm64
86+
push: true
87+
tags: ${{ steps.meta.outputs.tags }}
88+
labels: ${{ steps.meta.outputs.labels }}
89+
cache-from: type=gha
90+
cache-to: type=gha,mode=max
91+
92+
- name: Print published tags
93+
run: |
94+
echo "Published tags:"
95+
echo "${{ steps.meta.outputs.tags }}"

.github/workflows/pypi-publish.yml

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
# Build & publish `dlslime` and `dlslime-ctrl` wheels to PyPI on tag push.
2+
#
3+
# Auth: PyPI Trusted Publishing via OIDC — no secrets needed.
4+
# See RELEASING.md for the one-time PyPI configuration.
5+
#
6+
# Triggered by `vX.Y.Z` tags (e.g. as produced by scripts/release.sh).
7+
8+
name: pypi-publish
9+
10+
on:
11+
push:
12+
tags: ["v*"]
13+
workflow_dispatch:
14+
inputs:
15+
dry_run:
16+
description: "Build wheels but skip the upload step"
17+
type: boolean
18+
default: false
19+
20+
permissions:
21+
id-token: write # required for OIDC token exchange with PyPI
22+
contents: read
23+
24+
jobs:
25+
# ---------------- dlslime (Python + C++ via scikit-build-core) -----------------
26+
build-dlslime-sdist:
27+
runs-on: ubuntu-24.04
28+
steps:
29+
- uses: actions/checkout@v6
30+
- uses: actions/setup-python@v6
31+
with:
32+
python-version: "3.12"
33+
- run: python -m pip install build
34+
- run: python -m build --sdist --outdir dist dlslime
35+
- uses: actions/upload-artifact@v4
36+
with:
37+
name: dist-dlslime-sdist
38+
path: dist/*.tar.gz
39+
40+
build-dlslime-wheels:
41+
runs-on: ubuntu-24.04
42+
strategy:
43+
fail-fast: false
44+
matrix:
45+
python: ["cp310", "cp311", "cp312", "cp313"]
46+
steps:
47+
- uses: actions/checkout@v6
48+
- uses: pypa/cibuildwheel@v2
49+
env:
50+
# Build only the matching Python ABI on x86_64 manylinux.
51+
CIBW_BUILD: "${{ matrix.python }}-manylinux_x86_64"
52+
CIBW_BEFORE_ALL_LINUX: |
53+
yum install -y libibverbs-devel numactl-devel || \
54+
(apt-get update && apt-get install -y libibverbs-dev libnuma-dev)
55+
CIBW_ENVIRONMENT: >-
56+
CMAKE_ARGS=-DBUILD_RDMA=ON -DBUILD_PYTHON=ON
57+
-DBUILD_NVLINK=OFF -DBUILD_TORCH_PLUGIN=OFF
58+
-DBUILD_ASCEND_DIRECT=OFF -DBUILD_TEST=OFF
59+
with:
60+
package-dir: dlslime
61+
output-dir: dist
62+
- uses: actions/upload-artifact@v4
63+
with:
64+
name: dist-dlslime-${{ matrix.python }}
65+
path: dist/*.whl
66+
67+
# ---------------- dlslime-ctrl (Rust bin wheel via maturin) --------------------
68+
build-dlslime-ctrl:
69+
runs-on: ubuntu-24.04
70+
steps:
71+
- uses: actions/checkout@v6
72+
- uses: actions/setup-python@v6
73+
with:
74+
python-version: "3.12"
75+
- uses: dtolnay/rust-toolchain@stable
76+
- run: python -m pip install "maturin>=1.0,<2.0"
77+
- run: maturin build --release --out dist --manifest-path dlslime-ctrl/Cargo.toml
78+
- uses: actions/upload-artifact@v4
79+
with:
80+
name: dist-dlslime-ctrl
81+
path: dist/*.whl
82+
83+
# ---------------- Publish to PyPI (Trusted Publishing) -------------------------
84+
publish-dlslime:
85+
needs: [build-dlslime-sdist, build-dlslime-wheels]
86+
if: ${{ github.event_name == 'push' || !inputs.dry_run }}
87+
runs-on: ubuntu-24.04
88+
environment: pypi # add manual-approval gate via repo Settings → Environments
89+
steps:
90+
- uses: actions/download-artifact@v4
91+
with:
92+
pattern: dist-dlslime-*
93+
path: dist
94+
merge-multiple: true
95+
- uses: pypa/gh-action-pypi-publish@release/v1
96+
with:
97+
packages-dir: dist
98+
# No `password:` — OIDC handles auth.
99+
100+
publish-dlslime-ctrl:
101+
needs: [build-dlslime-ctrl]
102+
if: ${{ github.event_name == 'push' || !inputs.dry_run }}
103+
runs-on: ubuntu-24.04
104+
environment: pypi
105+
steps:
106+
- uses: actions/download-artifact@v4
107+
with:
108+
name: dist-dlslime-ctrl
109+
path: dist
110+
- uses: pypa/gh-action-pypi-publish@release/v1
111+
with:
112+
packages-dir: dist

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,4 +221,4 @@ scripts/.bin/
221221

222222
.codex
223223

224-
bench/results/**
224+
dlslime/bench/results/**

.pre-commit-config.yaml

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ repos:
33
rev: v2.9.0
44
hooks:
55
- id: ufmt
6+
# black 25.x requires Python >= 3.9; pin a recent stable to avoid
7+
# pre-commit defaulting to whatever system python happens to be.
8+
language_version: python3.12
69
additional_dependencies:
710
- black==25.9.0
811
- usort==1.0.8.post1
@@ -33,7 +36,7 @@ repos:
3336
rev: v2.1.0
3437
hooks:
3538
- id: codespell
36-
args: ["-L", "CANN,cann,crate"]
39+
args: ["-L", "CANN,cann,crate,ans"]
3740
exclude: >
3841
(?x)^(
3942
(?:.*/)?docs/imgs/.*|
@@ -46,19 +49,18 @@ repos:
4649
rev: v1.0
4750
hooks:
4851
- id: fmt
49-
name: fmt (NanoCtrl)
50-
args: ["--manifest-path", "NanoCtrl/Cargo.toml"]
51-
files: ^NanoCtrl/
52+
name: fmt (dlslime-ctrl)
53+
args: ["--manifest-path", "dlslime-ctrl/Cargo.toml"]
54+
files: ^dlslime-ctrl/
5255
pass_filenames: false
53-
# NanoCtrl
5456
- id: cargo-check
55-
name: cargo check (NanoCtrl)
56-
args: ["--manifest-path", "NanoCtrl/Cargo.toml"]
57-
files: ^NanoCtrl/
57+
name: cargo check (dlslime-ctrl)
58+
args: ["--manifest-path", "dlslime-ctrl/Cargo.toml"]
59+
files: ^dlslime-ctrl/
5860
- id: clippy
59-
name: clippy (NanoCtrl)
60-
args: ["--manifest-path", "NanoCtrl/Cargo.toml", "--", "-D", "warnings"]
61-
files: ^NanoCtrl/
61+
name: clippy (dlslime-ctrl)
62+
args: ["--manifest-path", "dlslime-ctrl/Cargo.toml", "--", "-D", "warnings"]
63+
files: ^dlslime-ctrl/
6264

6365
- repo: https://github.com/pre-commit/mirrors-clang-format
6466
rev: v18.1.6

NanoCtrl/nanoctrl/__init__.py

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)