Skip to content

Commit c558bb5

Browse files
authored
Merge pull request #156 from OpenMOSS/dev
Update on UI; minor fixes
2 parents ac0071f + 7ad0019 commit c558bb5

File tree

104 files changed

+12761
-2779
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+12761
-2779
lines changed

.DS_Store

6 KB
Binary file not shown.
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
name: Docker
2+
3+
# This workflow builds Docker images on push to main/dev branches
4+
# and publishes (pushes) them to GHCR on version tags.
5+
6+
on:
7+
push:
8+
branches:
9+
- main
10+
- dev
11+
tags:
12+
- "v*"
13+
14+
env:
15+
REGISTRY: ghcr.io
16+
IMAGE_NAME: ${{ github.repository }}
17+
18+
jobs:
19+
build-and-push:
20+
runs-on: ubuntu-latest
21+
permissions:
22+
contents: read
23+
packages: write
24+
25+
strategy:
26+
matrix:
27+
include:
28+
- context: .
29+
file: server/Dockerfile
30+
image: ghcr.io/${{ github.repository }}-backend
31+
- context: ui-ssr
32+
file: ui-ssr/Dockerfile
33+
image: ghcr.io/${{ github.repository }}-frontend
34+
35+
steps:
36+
- name: Free Disk Space
37+
uses: jlumbroso/free-disk-space@main
38+
with:
39+
tool-cache: true
40+
android: true
41+
dotnet: true
42+
haskell: true
43+
large-packages: true
44+
swap-storage: true
45+
46+
- name: Checkout repository
47+
uses: actions/checkout@v4
48+
with:
49+
submodules: "true"
50+
51+
- name: Set up QEMU
52+
uses: docker/setup-qemu-action@v3
53+
54+
- name: Set up Docker Buildx
55+
uses: docker/setup-buildx-action@v3
56+
57+
- name: Log in to the Container registry
58+
# Only login if we are going to push
59+
if: startsWith(github.ref, 'refs/tags/v')
60+
uses: docker/login-action@v3
61+
with:
62+
registry: ${{ env.REGISTRY }}
63+
username: ${{ github.actor }}
64+
password: ${{ secrets.GITHUB_TOKEN }}
65+
66+
- name: Extract metadata (tags, labels) for Docker
67+
id: meta
68+
uses: docker/metadata-action@v5
69+
with:
70+
images: ${{ matrix.image }}
71+
tags: |
72+
# Tag with the exact git tag
73+
type=ref,event=tag
74+
# Extract version from tag (stripping 'v' prefix if present)
75+
type=match,pattern=v(.*),group=1
76+
# Standard semver (if valid)
77+
type=semver,pattern={{version}}
78+
type=semver,pattern={{major}}.{{minor}}
79+
# Branch and SHA
80+
type=ref,event=branch
81+
type=sha
82+
# latest tag only for stable releases (no 'a', 'b', 'rc' etc. in the tag name)
83+
type=raw,value=latest,enable=${{ github.ref_type == 'tag' && !contains(github.ref_name, 'a') && !contains(github.ref_name, 'b') && !contains(github.ref_name, 'rc') }}
84+
85+
- name: Build and push Docker image
86+
uses: docker/build-push-action@v5
87+
with:
88+
context: ${{ matrix.context }}
89+
file: ${{ matrix.file }}
90+
# Only push on tags
91+
push: ${{ startsWith(github.ref, 'refs/tags/v') }}
92+
tags: ${{ steps.meta.outputs.tags }}
93+
labels: ${{ steps.meta.outputs.labels }}
94+
cache-from: type=gha
95+
cache-to: type=gha,mode=max

.gitignore

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,4 @@ pyrightconfig.json
196196
/analysis-results
197197
/analysis
198198
/results
199-
/graphs
200-
201-
# uv
202-
# We ignore uv.lock as conflicting optional dependencies generates non-compatible uv.lock files.
203-
uv.lock
199+
/graphs

docker-compose.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
services:
2+
mongodb:
3+
image: mongo:latest
4+
restart: always
5+
ports:
6+
- "27017:27017"
7+
volumes:
8+
- mongodb_data:/data/db
9+
10+
backend:
11+
build:
12+
context: .
13+
dockerfile: server/Dockerfile
14+
restart: always
15+
ports:
16+
- "24577:24577"
17+
environment:
18+
- MONGO_URI=mongodb://mongodb:27017/
19+
- MONGO_DB=mechinterp
20+
depends_on:
21+
- mongodb
22+
# Mount volumes for models and SAEs if needed, or use environment variables to point to paths
23+
# volumes:
24+
# - ./models:/models
25+
# - ./saes:/saes
26+
27+
frontend:
28+
build:
29+
context: ui-ssr
30+
dockerfile: Dockerfile
31+
restart: always
32+
ports:
33+
- "24576:24576"
34+
environment:
35+
- BACKEND_URL=http://backend:24577
36+
depends_on:
37+
- backend
38+
39+
volumes:
40+
mongodb_data:

pyproject.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ dependencies = [
2222
"jaxtyping>=0.2.34",
2323
"safetensors>=0.4.5",
2424
"pydantic>=2.10.6",
25-
"argparse>=1.4.0",
25+
"typer>=0.15.0",
26+
"rich>=13.0.0",
2627
"pyyaml>=6.0.2",
2728
"tomlkit>=0.13.2",
2829
"torch==2.9.0",
@@ -63,7 +64,7 @@ email = "junxuanwang21@m.fudan.edu.cn"
6364
text = "MIT"
6465

6566
[project.scripts]
66-
lm-saes = "lm_saes.entrypoint:entrypoint"
67+
lm-saes = "lm_saes.cli:entrypoint"
6768

6869
[build-system]
6970
requires = ["uv_build>=0.9.6,<0.10.0"]
@@ -72,6 +73,7 @@ build-backend = "uv_build"
7273
[dependency-groups]
7374
dev = [
7475
"transformer-lens",
76+
"argparse>=1.4.0",
7577
"jupyter>=1.1.1",
7678
"ipywidgets>=8.1.5",
7779
"pytest>=8.3.3",

server/Dockerfile

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
FROM ghcr.io/astral-sh/uv:python3.11-bookworm-slim
2+
3+
WORKDIR /app
4+
5+
# Enable bytecode compilation
6+
ENV UV_COMPILE_BYTECODE=1
7+
8+
# Copy from the cache instead of linking since it's a mounted volume
9+
ENV UV_LINK_MODE=copy
10+
11+
# Copy the project's dependency files and local dependencies
12+
COPY pyproject.toml uv.lock README.md ./
13+
COPY TransformerLens ./TransformerLens
14+
15+
# Install the project's dependencies using the lockfile and settings
16+
RUN --mount=type=cache,target=/root/.cache/uv \
17+
uv sync --locked --no-dev --no-install-project
18+
19+
# Copy the source code
20+
COPY src ./src
21+
COPY server ./server
22+
23+
RUN --mount=type=cache,target=/root/.cache/uv \
24+
uv sync --locked --no-dev
25+
26+
# Place executables in the environment at the front of the path
27+
ENV PATH="/app/.venv/bin:$PATH"
28+
29+
# Reset the entrypoint, don't invoke `uv`
30+
ENTRYPOINT []
31+
32+
# Expose the port
33+
EXPOSE 24577
34+
35+
# Run the application
36+
CMD ["uvicorn", "server.app:app", "--host", "0.0.0.0", "--port", "24577"]
37+

0 commit comments

Comments
 (0)