Skip to content

Commit

Permalink
Revert using git and use curl + github archive
Browse files Browse the repository at this point in the history
  • Loading branch information
mfuntowicz committed Apr 25, 2024
1 parent 09f83e8 commit c163bc1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 24 deletions.
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,8 @@ tgi_server:
VERSION=${VERSION} TGI_VERSION=${TGI_VERSION} make -C text-generation-inference/server gen-server

tgi_test: test_installs tgi_server
# find text-generation-inference -name "text_generation_server-$(VERSION)-py3-none-any.whl" \
# -exec python -m pip install --force-reinstall {} \;
python -m pip install --force-reinstall /tgi/build/dist/text_generation_server-$(VERSION)-py3-none-any.whl
find text-generation-inference -name "text_generation_server-$(VERSION)-py3-none-any.whl" \
-exec python -m pip install --force-reinstall {} \;
python -m pytest -sv text-generation-inference/tests

tgi_docker_test: tpu-tgi
Expand Down
14 changes: 5 additions & 9 deletions text-generation-inference/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
# Fetch and extract the TGI sources (TGI_VERSION is mandatory)
FROM alpine AS tgi
ARG TGI_VERSION
RUN apk add git && \
test -n ${TGI_VERSION:?} && \
mkdir -p /tgi && \
cd /tgi && \
git init && \
git remote add origin https://github.com/huggingface/text-generation-inference && \
git fetch origin ${TGI_VERSION} && \
git reset --hard FETCH_HEAD
RUN test -n ${TGI_VERSION:?}
RUN mkdir -p /tgi
ADD https://github.com/huggingface/text-generation-inference/archive/${TGI_VERSION}.tar.gz /tgi/sources.tar.gz
RUN tar -C /tgi -xf /tgi/sources.tar.gz --strip-components=1

# Build cargo components (adapted from TGI original Dockerfile)
# Note that the build image is aligned on the same Linux version as the base image (Debian bookworm/ Ubuntu 22.04)
Expand Down Expand Up @@ -121,7 +117,7 @@ COPY --from=builder /usr/src/target/release/text-generation-router /usr/local/bi
COPY --from=builder /usr/src/target/release/text-generation-launcher /usr/local/bin/text-generation-launcher
# Install python server
COPY --from=pyserver /pyserver/build/dist dist
RUN pip install dist/text_generation_server*.whl
RUN pip install dist/text_generation_server*.tar.gz

# TPU compatible image
FROM tpu_base as tpu_entrypoint
Expand Down
21 changes: 9 additions & 12 deletions text-generation-inference/server/Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Initialize base variables
pkg_name := text_generation_server
BUILDDIR ?= /tgi/build
BUILDDIR ?= $(CURDIR)/build
VERSION ?= 0.0.1
TGI_VERSION ?= 1.4.2
TGI_VERSION ?= v2.0.1
mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
mkfile_dir := $(dir $(mkfile_path))
pkg_dir := $(BUILDDIR)/$(pkg_name)

clean:
rm -rf $(BUILDDIR)
rm -rf $(BUILDDIR)/*

# List static sources to be deployed in the package
src_dir := $(mkfile_dir)/$(pkg_name)
Expand All @@ -34,16 +34,13 @@ $(pkg_dir)/%.py: $(src_dir)/%.py

# If not provided, fetch proto files from TGI
ifndef PROTODIR
PROTODIR := $(BUILDDIR)/proto
PROTODIR := $(BUILDDIR)/tgi/proto
endif

$(BUILDDIR)/proto/%.proto:
install -d $(BUILDDIR) && \
cd $(BUILDDIR) && \
git init && \
git remote add origin https://github.com/huggingface/text-generation-inference && \
git fetch origin $(TGI_VERSION) && \
git reset --hard FETCH_HEAD
$(BUILDDIR)/tgi/proto/%.proto:
install -d $(BUILDDIR)/tgi
curl -L https://github.com/huggingface/text-generation-inference/archive/${TGI_VERSION}.tar.gz --output $(BUILDDIR)/tgi/sources.tar.gz
tar -C $(BUILDDIR)/tgi -xf $(BUILDDIR)/tgi/sources.tar.gz --strip-components=1

# Three python files are generated for each protobuf
protobufs := $(PROTODIR)/generate.proto
Expand All @@ -60,4 +57,4 @@ $(pkg_pb_dir)/%_pb2.py $(pkg_pb_dir)/%_pb2.pyi $(pkg_pb_dir)/%_pb2_grpc.py: $(PR
sed -i -e 's/^\(import.*pb2\)/from . \1/g' $(pkg_pb_dir)/$*_pb2_grpc.py

gen-server: $(BUILDDIR)/pyproject.toml $(deployed_sources) $(generated_sources)
python -m build $(BUILDDIR)
python -m build $(BUILDDIR)

0 comments on commit c163bc1

Please sign in to comment.