Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add api, distributed setup #135

Open
wants to merge 31 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
97455fc
add pubsub
alex-dixon Aug 12, 2024
a85bd64
Merge branch 'main' into pubsub
alex-dixon Aug 12, 2024
03b8d6a
remove unused imports
alex-dixon Aug 12, 2024
b228fb0
slight cleanup
alex-dixon Aug 12, 2024
9daa336
commit latest
alex-dixon Aug 14, 2024
5ed6825
add write invocation api
alex-dixon Aug 15, 2024
6f92642
avoid union none
alex-dixon Aug 15, 2024
7f27826
optional instead of union none
alex-dixon Aug 16, 2024
94f0a69
replace store with client
alex-dixon Aug 18, 2024
2e2a159
fixes, some local + api mode qa
alex-dixon Aug 18, 2024
a78a7d6
dockerize
alex-dixon Aug 18, 2024
9064f3a
minor cleanup
alex-dixon Aug 19, 2024
e4f1525
fix write trace race
alex-dixon Aug 23, 2024
1fa16d7
Merge branch 'MadcowD:main' into pubsub
alex-dixon Aug 23, 2024
6a07b6c
build studio with latest stable node
alex-dixon Aug 23, 2024
1133e40
checkpoint toward distributed multimodal
alex-dixon Sep 7, 2024
882960f
tests passing
alex-dixon Sep 7, 2024
7c84f6d
try fix string formatting
alex-dixon Sep 7, 2024
4a64fbb
more string formatting
alex-dixon Sep 7, 2024
0be7110
mon dieu
alex-dixon Sep 7, 2024
6eac3fa
more fstrings
alex-dixon Sep 7, 2024
fd3f47e
working with studio in docker compose
alex-dixon Sep 7, 2024
71e9fd6
uses is a list
alex-dixon Sep 9, 2024
fe7b0d2
Merge branch 'main' into pubsub
alex-dixon Sep 9, 2024
3c1ed4b
no _ start of Field name
alex-dixon Sep 9, 2024
59b960f
default openai client
alex-dixon Sep 9, 2024
30658be
Merge branch 'main' into pubsub
alex-dixon Sep 18, 2024
99ec47b
poetry lock
alex-dixon Sep 18, 2024
ceeadd2
fix tests
alex-dixon Sep 18, 2024
c47a107
Merge branch 'main' into pubsub
alex-dixon Sep 21, 2024
e7c7710
refactor
alex-dixon Sep 21, 2024
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
10 changes: 10 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
**/__pycache__/
.pytest_cache/
.git
.github
.vscode
.DS_Store
.env


tests
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12.2
23 changes: 23 additions & 0 deletions Dockerfile.api
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM python:3.12

WORKDIR /app

# Install system dependencies
RUN apt-get update && apt-get install -y \
gcc \
&& rm -rf /var/lib/apt/lists/*

# Install Poetry
RUN pip install --no-cache-dir poetry

# Copy only requirements to cache them in docker layer
COPY pyproject.toml poetry.lock* ./

# Project initialization:
RUN poetry config virtualenvs.create false \
&& poetry install --no-interaction --no-ansi

# Copy project
COPY src .

CMD ["python", "-m", "ell.api"]
44 changes: 44 additions & 0 deletions Dockerfile.studio
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Start with a Node.js base image for building the React app
FROM node:20 AS client-builder

WORKDIR /app/ell-studio

# Copy package.json and package-lock.json (if available)
COPY ell-studio/package.json ell-studio/package-lock.json* ./

# Install dependencies
RUN npm ci

# Copy the rest of the client code
COPY ell-studio .

# Build the React app
RUN npm run build

# Now, start with the Python base image
FROM python:3.12

WORKDIR /app

# Install system dependencies
RUN apt-get update && apt-get install -y \
gcc \
&& rm -rf /var/lib/apt/lists/*

# Install Poetry
RUN pip install --no-cache-dir poetry

# Copy only requirements to cache them in docker layer
COPY pyproject.toml poetry.lock* ./

# Project initialization:
RUN poetry config virtualenvs.create false \
&& poetry install --no-interaction --no-ansi

# Copy the Python project
COPY src .

# Copy the built React app from the client-builder stage
COPY --from=client-builder /app/ell-studio/build /app/ell/studio/static

CMD ["python", "-m", "ell.studio"]
74 changes: 74 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
services:
api:
build:
context: .
dockerfile: Dockerfile.api
tags:
- ell-api

ports:
- "8081:8081"
environment:
- HOST=0.0.0.0
- PORT=8081
- ELL_PG_CONNECTION_STRING=postgresql://ell_user:ell_password@postgres:5432/ell_db
- ELL_MQTT_CONNECTION_STRING=mqtt://mqtt:1883
- LOG_LEVEL=DEBUG
depends_on:
- postgres
- mqtt

studio:
build:
context: .
dockerfile: Dockerfile.studio
tags:
- ell-studio
ports:
- "8080:8080"
environment:
- HOST=0.0.0.0
- PORT=8080 # currently doesn't take effect -- cli defaults it
- ELL_PG_CONNECTION_STRING=postgresql://ell_user:ell_password@postgres:5432/ell_db
- ELL_MQTT_CONNECTION_STRING=mqtt://mqtt:1883
depends_on:
- postgres
- mqtt
develop:
watch:
- action: sync+restart
path: ./src/ell/studio
target: /app/ell/studio

mqtt:
image: eclipse-mosquitto:latest
ports:
- "1883:1883"
command: mosquitto -c /mosquitto/config/mosquitto.conf
volumes:
- mosquitto_config:/mosquitto/config
depends_on:
- mqtt-config

mqtt-config:
image: busybox
volumes:
- mosquitto_config:/mosquitto/config
command: >
sh -c "echo 'listener 1883' > /mosquitto/config/mosquitto.conf &&
echo 'allow_anonymous true' >> /mosquitto/config/mosquitto.conf"

postgres:
image: postgres:16
environment:
- POSTGRES_USER=ell_user
- POSTGRES_PASSWORD=ell_password
- POSTGRES_DB=ell_db
volumes:
- postgres_data:/var/lib/postgresql/data
ports:
- "5432:5432"

volumes:
postgres_data:
mosquitto_config:
Empty file added examples/calculator.py
Empty file.
8 changes: 6 additions & 2 deletions examples/calculator_structured.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from typing import Any, Literal, Type, Union
import pydantic

from ell.stores.sql import SQLiteStore

ell.config.verbose = True

Expand Down Expand Up @@ -69,5 +68,10 @@ def calc_structured(task: str) -> float:


if __name__ == "__main__":
ell.set_store('./logdir', autocommit=True)
# Local
ell.init(storage_dir='./logdir', autocommit=True)

# API server
# ell.init(base_url="http://localhost:8081", autocommit=True)

print(calc_structured("What is two plus two?"))
137 changes: 134 additions & 3 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ include = [
]

[tool.poetry.dependencies]
python = ">=3.9"
python = ">=3.9,<4"
fastapi = "^0.111.1"
numpy = "^2.0.1"
dill = "^0.3.8"
Expand All @@ -41,8 +41,12 @@ typing-extensions = "^4.12.2"
black = "^24.8.0"
json-fix = "^1.0.0"
pillow = "^10.4.0"
aiomqtt = "^2.3.0"
psycopg2 = "^2.9.9"
[tool.poetry.group.dev.dependencies]
pytest = "^8.3.2"
polyfactory = "^2.16.2"
pytest-mock = "^3.14.0"

sphinx = "<8.0.0"
sphinx-rtd-theme = "^2.0.0"
Expand Down
10 changes: 5 additions & 5 deletions src/ell/__version__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
try:
from importlib.metadata import version
except ImportError:
from importlib_metadata import version
from importlib.metadata import version, PackageNotFoundError

__version__ = version("ell-ai")
try:
__version__ = version("ell-ai")
except PackageNotFoundError:
__version__ = "unknown"
Empty file added src/ell/api/__init__.py
Empty file.
Loading
Loading