feat(neuron): add server standalone installation

This commit is contained in:
David Corvoysier 2025-02-11 15:51:09 +00:00
parent 9c25afb832
commit 337329fff3
3 changed files with 25 additions and 5 deletions

View File

@ -16,13 +16,15 @@ mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
mkfile_dir := $(dir $(mkfile_path))
root_dir := "${mkfile_dir}/../.."
.PHONY: image
.PHONY: image install_server
VERSION := $(shell gawk 'match($$0, /^version = "(.*)"/, a) {print a[1]}' ${root_dir}/Cargo.toml)
image:
docker build --rm -f ${root_dir}/Dockerfile.neuron \
--build-arg VERSION=$(VERSION) \
--ulimit nofile=100000:100000 \
-t text-generation-inference:$(VERSION)-neuron ${root_dir}
docker tag text-generation-inference:$(VERSION)-neuron text-generation-inference:latest-neuron
install_server:
make -C ${mkfile_dir}/server install VERSION:=${VERSION}

View File

@ -1,15 +1,20 @@
# Initialize base variables
SHELL := /bin/bash
pkg_name := text_generation_server
BUILDDIR ?= $(CURDIR)/build
VERSION ?= 0.0.1
mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
mkfile_dir := $(dir $(mkfile_path))
pkg_dir := $(BUILDDIR)/$(pkg_name)
pkg_dist := ${BUILDDIR}/dist/${pkg_name}-${VERSION}.tar.gz
py_version := $(subst -,.,${VERSION})
pkg_dist := ${BUILDDIR}/dist/${pkg_name}-$(py_version).tar.gz
clean:
rm -rf $(BUILDDIR)/*
${BUILDDIR}:
install -d $@
# List static sources to be deployed in the package
src_dir := $(mkfile_dir)/$(pkg_name)
sources := $(wildcard $(src_dir)/*.py)
@ -21,7 +26,15 @@ define COPY
cp -f $< $@
endef
$(BUILDDIR)/pyproject.toml: $(mkfile_dir)/pyproject.toml
# We use a PHONY target to represent the VERSION
.PHONY: VERSION
VERSION: ${BUILDDIR}
# The trick is to compare the value of the variable with the content of a file in the build directory
@if [[ `cat ${BUILDDIR}/VERSION 2>&1` != '$(VERSION)' ]]; then echo -n $(VERSION) >${BUILDDIR}/VERSION; fi
# Depending on the PHONY VERSION target makes sure the pyproject.toml is regenerated if the version changes
$(BUILDDIR)/pyproject.toml: $(mkfile_dir)/pyproject.toml VERSION
mkdir -p $(BUILDDIR)
$(COPY)
sed -i -e 's/version = "VERSION"/version = \"${VERSION}\"/' $@
@ -55,3 +68,7 @@ ${pkg_dist}: $(BUILDDIR)/pyproject.toml $(deployed_sources) $(generated_sources)
python -m build $(BUILDDIR)
package: ${pkg_dist}
install: ${pkg_dist}
python3 -m pip uninstall -y ${pkg_name}
python3 -m pip install ${pkg_dist}

View File

@ -15,7 +15,8 @@ dependencies = [
'grpc-interceptor == 0.15.2',
'typer == 0.6.1',
'safetensors',
'loguru == 0.6.0'
'loguru == 0.6.0',
'optimum-neuron[neuronx] >= 0.0.28',
]
[tool.setuptools]