Skip to content

Commit f623b2b

Browse files
committed
use uv instead
1 parent 23ba2ba commit f623b2b

File tree

6 files changed

+1384
-9
lines changed

6 files changed

+1384
-9
lines changed

.github/workflows/build-images-ssh.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ jobs:
5252
- name: Build ${{ matrix.image-type }} image on remote server
5353
id: build
5454
run: |
55-
ssh gpuserver "cd /tmp/repo-${{ github.run_id }} && make build-${{ matrix.image-type }} BUILD_DIR=/tmp/vm-images-build-${{ github.run_id }}"
55+
ssh -t gpuserver "export COLUMNS=200 && cd /tmp/repo-${{ github.run_id }} && make build-${{ matrix.image-type }} BUILD_DIR=/tmp/vm-images-build-${{ github.run_id }}"
5656
IMAGE_NAME=$(ssh gpuserver "cd /tmp/vm-images-build-${{ github.run_id }}-${{ matrix.image-type }} && ls -1 *.qcow2 2>/dev/null | head -1 | sed 's/.qcow2$//'")
5757
echo "image_name=$IMAGE_NAME" >> $GITHUB_OUTPUT
5858

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,7 @@ vm-images/dib.log
33
vm-images/build-output.log
44
vm-images/*.qcow2
55
vm-images/*.d/
6+
7+
# UV environment
8+
vm-images/.venv/
9+
vm_images.egg-info/

Makefile

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@ IMAGE_NAME := ubuntu-2404-$(IMAGE_TYPE)-$(TIMESTAMP)
1010
REPO_DIR := $(shell pwd)
1111
VM_IMAGES_DIR := $(REPO_DIR)/vm-images
1212
OPENSTACK_RC ?= /etc/kolla/admin-openrc.sh
13-
CONDA_BASE ?= /opt/stack/miniconda3
14-
CONDA_ENV ?= kolla
13+
UV ?= uv
1514

1615
help:
1716
@echo "VM Image Build Makefile"
1817
@echo ""
18+
@echo "Requirements:"
19+
@echo " - uv (https://docs.astral.sh/uv/)"
20+
@echo ""
1921
@echo "Targets:"
2022
@echo " build-cpu - Build CPU image"
2123
@echo " build-gpu - Build GPU image"
@@ -30,6 +32,7 @@ help:
3032
@echo " BUILD_DIR=$(BUILD_DIR)"
3133
@echo " IMAGE_TYPE=$(IMAGE_TYPE)"
3234
@echo " IMAGE_NAME=$(IMAGE_NAME)"
35+
@echo " UV=$(UV)"
3336

3437
build-cpu:
3538
@$(MAKE) _build IMAGE_TYPE=cpu
@@ -50,7 +53,8 @@ _build:
5053
cd $(BUILD_DIR)-$(IMAGE_TYPE) && \
5154
sed -i 's/imagename: $(IMAGE_TYPE)-image.qcow2/imagename: $(IMAGE_NAME).qcow2/' $(IMAGE_TYPE)-image.yaml
5255
cd $(BUILD_DIR)-$(IMAGE_TYPE) && \
53-
IMAGE_YAML=$(IMAGE_TYPE)-image.yaml bash build-image.sh
56+
$(UV) sync && \
57+
IMAGE_YAML=$(IMAGE_TYPE)-image.yaml $(UV) run bash build-image.sh
5458
@echo ""
5559
@$(MAKE) show-image IMAGE_TYPE=$(IMAGE_TYPE) BUILD_DIR=$(BUILD_DIR)
5660

@@ -91,17 +95,15 @@ _upload:
9195
@echo "======================================"
9296
@cd $(BUILD_DIR)-$(IMAGE_TYPE) && \
9397
source $(OPENSTACK_RC) && \
94-
source $(CONDA_BASE)/bin/activate && \
95-
conda activate $(CONDA_ENV) && \
9698
IMAGE_FILE=$$(ls -1 *.qcow2 2>/dev/null | head -1) && \
9799
IMAGE_BASE=$$(basename $$IMAGE_FILE .qcow2) && \
98100
echo "Uploading $$IMAGE_FILE..." && \
99-
openstack image create $$IMAGE_BASE \
101+
$(UV) run openstack image create $$IMAGE_BASE \
100102
--public --disk-format qcow2 \
101103
--container-format bare \
102104
--file $$IMAGE_FILE && \
103105
echo "Image uploaded successfully!" && \
104-
openstack image show $$IMAGE_BASE
106+
$(UV) run openstack image show $$IMAGE_BASE
105107

106108
clean:
107109
@echo "Cleaning up build directories..."

vm-images/build-image.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,12 @@ if [[ -z "${IMAGE_YAML}" ]]; then
2222
fi
2323

2424
export TMP=$(pwd)
25+
export COLUMNS=${COLUMNS:-200}
26+
export TERM=${TERM:-xterm}
27+
2528
echo "Starting Disk Image builder"
2629
echo "Using config: ${IMAGE_YAML}"
2730

28-
sudo -E /opt/stack/miniconda3/envs/kolla/bin/diskimage-builder "${IMAGE_YAML}"
31+
uv run diskimage-builder "${IMAGE_YAML}"
2932

3033
echo "Disk Image Build Finished"

vm-images/pyproject.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[project]
2+
name = "vm-images"
3+
version = "0.1.0"
4+
description = "VM image builder for OpenStack GPU server"
5+
requires-python = ">=3.10"
6+
dependencies = [
7+
"diskimage-builder==3.40.0",
8+
"python-openstackclient==6.0.0",
9+
]
10+
11+
[build-system]
12+
requires = ["setuptools>=61.0"]
13+
build-backend = "setuptools.build_meta"

0 commit comments

Comments
 (0)