@tduncan / Nvidia-Optimization-Stack-VLLM Mirror · read-only / commits / 8661c0241d
Fork 0

A high-throughput and memory-efficient inference and serving engine for LLMs

Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git

Synced Nov 15, 14:45 UTC

[CI] Add auto update workflow for Dockerfile graph (#11879)

Signed-off-by: wineandchord <guoqizhou19@gmail.com>

wineandchord committed Apr 10, 2025 at 21:43 UTC 8661c0241d52401b30dbcdfcacb8e263739146c3
2 files changed +84
.pre-commit-config.yaml
+6
@@ -122,6 +122,12 @@ repos:
122 language: system
123 always_run: true
124 pass_filenames: false
125 + - id: update-dockerfile-graph
126 + name: Update Dockerfile dependency graph
127 + entry: tools/update-dockerfile-graph.sh
128 + language: script
129 + files: ^docker/Dockerfile$
130 + pass_filenames: false
131 # Keep `suggestion` last
132 - id: suggestion
133 name: Suggestion
tools/update-dockerfile-graph.sh new
+78
@@ -0,0 +1,78 @@
1 +#!/bin/bash
2 +# Update Dockerfile dependency graph when docker/Dockerfile changes.
3 +# This script is designed to be used as a pre-commit hook.
4 +
5 +set -euo pipefail
6 +
7 +# Check if docker/Dockerfile is staged for commit
8 +if git diff --cached --name-only | grep -q "^docker/Dockerfile$"; then
9 + echo "docker/Dockerfile has changed, attempting to update dependency graph..."
10 +
11 + # Check if Docker is installed and running
12 + if ! command -v docker &> /dev/null; then
13 + echo "Warning: Docker command not found. Skipping Dockerfile graph update."
14 + echo "Please install Docker to automatically update the graph: https://docs.docker.com/get-docker/"
15 + exit 0
16 + fi
17 + if ! docker info &> /dev/null; then
18 + echo "Warning: Docker daemon is not running. Skipping Dockerfile graph update."
19 + echo "Please start Docker to automatically update the graph."
20 + exit 0
21 + fi
22 +
23 + # Define the target file path
24 + TARGET_GRAPH_FILE="docs/source/assets/contributing/dockerfile-stages-dependency.png"
25 +
26 + # Ensure target directory exists
27 + mkdir -p "$(dirname "$TARGET_GRAPH_FILE")"
28 +
29 + # Store old image hash in a variable if the file exists
30 + OLD_HASH=""
31 + if [ -f "$TARGET_GRAPH_FILE" ]; then
32 + OLD_HASH=$(sha256sum "$TARGET_GRAPH_FILE")
33 + fi
34 +
35 + # Generate Dockerfile graph
36 + echo "Running dockerfilegraph tool..."
37 + docker run \
38 + --rm \
39 + --user "$(id -u):$(id -g)" \
40 + --workdir /workspace \
41 + --volume "$(pwd)":/workspace \
42 + ghcr.io/patrickhoefler/dockerfilegraph:alpine \
43 + --output png \
44 + --dpi 200 \
45 + --max-label-length 50 \
46 + --filename docker/Dockerfile \
47 + --legend
48 +
49 + echo "Finding generated PNG file..."
50 + # Check for Dockerfile.png in the root directory (most likely location)
51 + if [ -f "./Dockerfile.png" ]; then
52 + echo "Found generated file at: ./Dockerfile.png"
53 + mv "./Dockerfile.png" "$TARGET_GRAPH_FILE"
54 + else
55 + # Try to find it elsewhere
56 + DOCKERFILE_PNG=$(find . -name "Dockerfile.png" -type f | head -1)
57 +
58 + if [ -n "$DOCKERFILE_PNG" ]; then
59 + echo "Found generated file at: $DOCKERFILE_PNG"
60 + mv "$DOCKERFILE_PNG" "$TARGET_GRAPH_FILE"
61 + else
62 + echo "Error: Could not find the generated PNG file"
63 + find . -name "*.png" -type f -mmin -5
64 + exit 1
65 + fi
66 + fi
67 +
68 + # Check if the graph has changed
69 + NEW_HASH=$(sha256sum "$TARGET_GRAPH_FILE")
70 + if [ "$NEW_HASH" != "$OLD_HASH" ]; then
71 + echo "Graph has changed. Please stage the updated file: $TARGET_GRAPH_FILE"
72 + exit 1
73 + else
74 + echo "No changes in graph detected."
75 + fi
76 +fi
77 +
78 +exit 0