Skip to content

Commit

Permalink
chore: S3_MODEL_PATH as variable
Browse files Browse the repository at this point in the history
  • Loading branch information
gary-van-woerkens committed Aug 29, 2024
1 parent c9cd828 commit 7e4f017
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
HUGGING_FACE_TOKEN="xxxxxxxxxxxxxxx"
S3_ACCESS_KEY_ID="xxxxxxxxxxxxxxx"
S3_SECRET_ACCESS_KEY="xxxxxxxxxxxxxxx"
S3_ENDPOINT_URL="https://s3.gra.io.cloud.ovh.net/"
S3_MODEL_PATH="distilgpt2"
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ build/
coverage.json
diff_amendments.csv
grouped_matching.csv
test.sh
.env
14 changes: 14 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
services:
llm-inference-server:
build:
context: .
dockerfile: dockerfile
env_file:
- .env
volumes:
- my_docker_volume:/app/models
ports:
- "8000:8000"

volumes:
my_docker_volume:
21 changes: 14 additions & 7 deletions dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,26 @@ WORKDIR /app
# Copy only requirements
COPY pyproject.toml poetry.lock* /app/

# Install project dependencies
# Install project dependencies (including dev dependencies)
RUN poetry config virtualenvs.create false \
&& poetry install --no-dev --no-interaction --no-ansi \
&& poetry install --no-interaction --no-ansi \
&& rm -rf ${POETRY_CACHE_DIR}

# Start a new stage for a smaller final image
FROM python:3.11-slim-buster

# Copy installed packages and application code from builder
COPY --from=builder /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages
COPY --from=builder /usr/local/bin /usr/local/bin
# Copy the entire Python environment and application code from builder
COPY --from=builder /usr/local /usr/local
COPY --from=builder /app /app

# Set environment variables
ENV PYTHONUNBUFFERED=1 \
POETRY_HOME="/opt/poetry" \
POETRY_VENV="/opt/poetry-venv" \
POETRY_CACHE_DIR="/opt/.cache" \
PYTHONPATH="/app" \
PATH="${PATH}:/opt/poetry/bin"

# Set working directory
WORKDIR /app

Expand All @@ -54,5 +61,5 @@ ARG INFERENCE_SERVER=llm_inference.s3_inference_server
# Set an environment variable using the argument
ENV INFERENCE_SERVER=${INFERENCE_SERVER}

# Run the application
CMD ["sh", "-c", "poetry run python -m ${INFERENCE_SERVER}"]
# Run the application directly with Python (without Poetry)
CMD python -m ${INFERENCE_SERVER}
2 changes: 1 addition & 1 deletion llm_inference/s3_inference_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

# S3 configuration
BUCKET_NAME = "vllm-cache"
S3_MODEL_PATH = "Meta-Llama-3.1-8B"
S3_MODEL_PATH = os.getenv("S3_MODEL_PATH")
local_model_dir = f"models/{S3_MODEL_PATH}"
s3_access_key_id = os.getenv("S3_ACCESS_KEY_ID")
s3_secret_access_key = os.getenv("S3_SECRET_ACCESS_KEY")
Expand Down

0 comments on commit 7e4f017

Please sign in to comment.