Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# .dockerignore
.git
.github
.env
*.pyc
__pycache__
.pytest_cache
.coverage
*.egg-info
.venv
.llamastack-venv
*.log
.DS_Store
16 changes: 16 additions & 0 deletions .env.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# .env.template - Template for Environment Variables
# Copy this file to .env and modify the values as needed

# vLLM Configuration
VLLM_URL=https://your-model-endpoint/v1/completions
VLLM_MAX_TOKENS=4096
VLLM_API_TOKEN=your-api-token
VLLM_TLS_VERIFY=false

# Kubernetes Configuration
K8S_NAMESPACE=default
K8S_SERVICE_ACCOUNT=

# LMEval Provider Configuration
LMEVAL_USE_K8S=true
LMEVAL_DEFAULT_TOKENIZER=google/flan-t5-base
53 changes: 53 additions & 0 deletions Dockerfile.local
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Dockerfile for llama-stack-provider-lmeval (Local Development)
ARG PYTHON_VERSION=3.11
FROM python:${PYTHON_VERSION}-slim

# Set working directory
WORKDIR /app

# Install system dependencies
RUN apt-get update && apt-get install -y \
git \
curl \
wget \
build-essential \
&& rm -rf /var/lib/apt/lists/*

# Install uv for fast Python package management
RUN pip install --no-cache-dir uv

# Set environment variable for uv to use system Python
ENV UV_SYSTEM_PYTHON=1

# Copy project files first (for better layer caching)
COPY pyproject.toml README.md LICENSE ./

# Install dependencies
RUN uv pip install --no-cache -e ".[dev]"

# Copy source code
COPY src/ ./src/
COPY tests/ ./tests/
COPY pytest.ini ./

# Copy demo and configuration files
COPY demo/ ./demo/
COPY providers.d/ ./providers.d/
COPY run.yaml ./run.yaml

# Create directories for llama stack with proper permissions
RUN mkdir -p /.llama/providers.d /.cache && \
chmod -R 777 /.llama /.cache

# Remove uv after installation (following Meta's pattern)
RUN pip uninstall -y uv

# Expose port
EXPOSE 8321

# Set Python path
ENV PYTHONPATH=/app/src:$PYTHONPATH

# Default entrypoint
ENTRYPOINT ["python", "-m", "llama_stack.distribution.server.server"]
CMD ["--help"]
63 changes: 63 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
version: '3.8'

services:
llama-stack-lmeval:
build:
context: .
dockerfile: Dockerfile.local
image: llama-stack-lmeval:local
ports:
- "8321:8321"
volumes:
# Mount your run.yaml config file
- ./run.yaml:/app/run.yaml:ro
# Mount external providers directory
- ./providers.d:/app/providers.d:ro
# Mount source code for development (optional)
- ./src:/app/src:ro
# Mount tests for running them
- ./tests:/app/tests:ro
environment:
- PYTHONPATH=/app/src
# Environment variables that can be overridden
- VLLM_URL=${VLLM_URL:-https://phi-3-predictor-llama-test.apps.rosa.p2i7w2k6p6w7t7e.3emk.p3.openshiftapps.com/v1/completions}
- VLLM_MAX_TOKENS=${VLLM_MAX_TOKENS:-4096}
- VLLM_API_TOKEN=${VLLM_API_TOKEN:-fake}
- VLLM_TLS_VERIFY=${VLLM_TLS_VERIFY:-true}
# Override default command to use your config
command: ["--config", "/app/run.yaml"]
# Or use this to run tests instead:
# command: ["python", "-m", "pytest", "tests/", "-v"]

# Service for running tests only
test:
build:
context: .
dockerfile: Dockerfile.local
image: llama-stack-lmeval:local
volumes:
- ./src:/app/src:ro
- ./tests:/app/tests:ro
- ./pytest.ini:/app/pytest.ini:ro
environment:
- PYTHONPATH=/app/src
command: ["python", "-m", "pytest", "tests/", "-v"]
profiles: ["test"]

# Service for development with shell access
dev:
build:
context: .
dockerfile: Dockerfile.local
image: llama-stack-lmeval:local
volumes:
- ./src:/app/src
- ./tests:/app/tests
- ./run.yaml:/app/run.yaml
- ./providers.d:/app/providers.d
environment:
- PYTHONPATH=/app/src
command: ["bash"]
stdin_open: true
tty: true
profiles: ["dev"]
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ dependencies = [
"aiosqlite",
"uvicorn",
"ipykernel",
"pydantic>=2.0",
"pyyaml",
"litellm",
]

[project.optional-dependencies]
Expand Down
77 changes: 77 additions & 0 deletions scripts/build-and-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/bin/bash
set -euo pipefail

# Color codes
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'

# Error handler
error_handler() {
echo -e "${RED}Error on line $1${NC}"
exit 1
}
trap 'error_handler $LINENO' ERR

# Configuration
IMAGE_NAME="${IMAGE_NAME:-llama-stack-lmeval}"
VERSION="${VERSION:-local}"
FULL_IMAGE_NAME="${IMAGE_NAME}:${VERSION}"

echo -e "${GREEN}🚀 Building ${FULL_IMAGE_NAME} Docker image...${NC}"

# Build the Docker image
docker build -f Dockerfile.local -t "${FULL_IMAGE_NAME}" .

echo -e "${GREEN}✅ Build completed successfully!${NC}"

# Test the installation - Override entrypoint to run python directly
echo -e "${YELLOW}🧪 Testing Python imports...${NC}"
docker run --rm --entrypoint python "${FULL_IMAGE_NAME}" -c "
import sys
sys.path.insert(0, '/app/src')
from llama_stack_provider_lmeval.config import LMEvalEvalProviderConfig
from llama_stack_provider_lmeval.lmeval import LMEval
print('✅ All imports successful!')
"

# Run the unit tests - Override entrypoint
echo -e "${YELLOW}🧪 Running unit tests...${NC}"
docker run --rm \
--entrypoint python \
-v "$(pwd)/src:/app/src:ro" \
-v "$(pwd)/tests:/app/tests:ro" \
-v "$(pwd)/pytest.ini:/app/pytest.ini:ro" \
-e PYTHONPATH=/app/src \
"${FULL_IMAGE_NAME}" \
-m pytest tests/ -v

echo -e "${GREEN}🎉 All tests passed!${NC}"

# Test the server help command (with default entrypoint)
echo -e "${YELLOW}🔧 Testing server startup (help command)...${NC}"
docker run --rm "${FULL_IMAGE_NAME}" --help

# Display usage information
cat << EOF

${GREEN}📋 Usage Examples:${NC}
===================

1. Run the server with your config:
docker run -p 8321:8321 -v \$(pwd)/run.yaml:/app/run.yaml:ro \\
-v \$(pwd)/providers.d:/app/providers.d:ro \\
${FULL_IMAGE_NAME} --config /app/run.yaml

2. Run with docker-compose:
docker-compose up llama-stack-lmeval

3. Run tests:
docker-compose --profile test up test

4. Development shell:
docker-compose --profile dev run --rm dev

${GREEN}✨ Your Docker image is ready: ${FULL_IMAGE_NAME}${NC}
EOF
Empty file modified scripts/run-server.sh
100644 → 100755
Empty file.
5 changes: 1 addition & 4 deletions src/llama_stack_provider_lmeval/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ async def get_adapter_impl(
if deps is None:
deps = {}



# Extract base_url from config if available
base_url = None
if hasattr(config, "model_args") and config.model_args:
Expand All @@ -52,5 +50,4 @@ async def get_adapter_impl(
# Configurations
"LMEval",
"get_provider_spec",

]
]