Skip to content

Commit 9433426

Browse files
authored
Merge pull request #29 from renbytes/dev-runningSim
Refactor - Poetry and Packages
2 parents c4217f0 + 47a4815 commit 9433426

File tree

24 files changed

+5646
-1602
lines changed

24 files changed

+5646
-1602
lines changed

.env.example

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# ===================================================================
2+
# ARLA ENVIRONMENT CONFIGURATION
3+
# ===================================================================
4+
5+
# --- PostgreSQL Credentials ---
6+
POSTGRES_USER=admin
7+
POSTGRES_PASSWORD=password
8+
POSTGRES_DB=agent_sim_db
9+
10+
# --- Application Service URLs ---
11+
# Use the stable host.docker.internal for all host connections
12+
DATABASE_URL=postgresql+asyncpg://admin:password@host.docker.internal:5432/agent_sim_db
13+
MLFLOW_TRACKING_URI=http://host.docker.internal:5001
14+
REDIS_URL=redis://redis:6379/0
15+
16+
# --- OpenAI API Key (Developer must provide their own) ---
17+
OPENAI_API_KEY=sk-{your_openai_api_key_here}
18+
OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES

.github/workflows/ci.yml

Lines changed: 99 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,125 @@
11
# .github/workflows/ci.yml
22

3-
name: Python Application CI
3+
name: Continuous Integration
44

55
on:
66
push:
7-
branches: [ main ]
7+
branches: [main]
88
pull_request:
9-
branches: [ main ]
9+
branches: [main]
1010

1111
jobs:
12-
build-and-test:
12+
lint-and-format:
13+
name: "Lint & Format"
1314
runs-on: ubuntu-latest
14-
1515
steps:
16-
- name: Check out code
16+
- name: "Checkout code"
1717
uses: actions/checkout@v4
1818

19-
- name: Set up Python 3.11
19+
- name: "Set up Python"
2020
uses: actions/setup-python@v5
2121
with:
22-
python-version: '3.11'
22+
python-version: "3.11.9"
2323

24-
- name: Install Graphviz
24+
- name: "Install Poetry"
2525
run: |
26-
sudo apt-get update
27-
sudo apt-get install -y graphviz graphviz-dev libgraphviz-dev pkg-config
26+
curl -sSL https://install.python-poetry.org | python3 -
27+
echo "$HOME/.local/bin" >> $GITHUB_PATH
28+
29+
- name: "Configure Poetry"
30+
run: |
31+
poetry config virtualenvs.create true
32+
poetry config virtualenvs.in-project true
33+
34+
- name: "Cache Poetry dependencies"
35+
uses: actions/cache@v4
36+
with:
37+
path: .venv
38+
key: poetry-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
39+
restore-keys: |
40+
poetry-${{ runner.os }}-
41+
42+
- name: "Install dependencies"
43+
run: poetry install
44+
45+
- name: "Run Linter & Formatter"
46+
run: |
47+
poetry run ruff check .
48+
poetry run ruff format --check .
49+
50+
type-check:
51+
name: "Type Checking"
52+
runs-on: ubuntu-latest
53+
steps:
54+
- name: "Checkout code"
55+
uses: actions/checkout@v4
56+
57+
- name: "Set up Python"
58+
uses: actions/setup-python@v5
59+
with:
60+
python-version: "3.11.9"
2861

29-
- name: Install dependencies
62+
- name: "Install Poetry"
3063
run: |
31-
python -m pip install --upgrade pip
32-
# Install ALL packages in editable mode to build the correct environment
33-
# This makes all sub-repos available.
34-
pip install -e ./agent-core -e ./agent-concurrent -e ./agent-engine -e ./agent-persist -e ./agent-sim
35-
pip install -e ".[dev]"
64+
curl -sSL https://install.python-poetry.org | python3 -
65+
echo "$HOME/.local/bin" >> $GITHUB_PATH
3666
37-
- name: Lint with Ruff
67+
- name: "Configure Poetry"
3868
run: |
39-
ruff check .
69+
poetry config virtualenvs.create true
70+
poetry config virtualenvs.in-project true
4071
41-
- name: Check formatting with Ruff
72+
- name: "Cache Poetry dependencies"
73+
uses: actions/cache@v4
74+
with:
75+
path: .venv
76+
key: poetry-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
77+
restore-keys: |
78+
poetry-${{ runner.os }}-
79+
80+
- name: "Install dependencies"
81+
run: poetry install
82+
83+
- name: "Run Type Checker"
84+
run: poetry run mypy agent-core agent-engine agent-concurrent agent-persist agent-sim
85+
86+
test:
87+
name: "Tests"
88+
runs-on: ubuntu-latest
89+
steps:
90+
- name: "Checkout code"
91+
uses: actions/checkout@v4
92+
93+
- name: "Set up Python"
94+
uses: actions/setup-python@v5
95+
with:
96+
python-version: "3.11.9"
97+
98+
- name: "Install Graphviz"
4299
run: |
43-
# Have ruff format check the entire project, not just a single 'src' folder.
44-
ruff format --diff .
100+
sudo apt-get update
101+
sudo apt-get install -y graphviz graphviz-dev libgraphviz-dev pkg-config
45102
46-
- name: Type check with Mypy
103+
- name: "Install Poetry"
47104
run: |
48-
# Only check packages that have Python files and aren't excluded
49-
mypy agent-core/src agent-engine/src agent-concurrent/src agent-persist/src
105+
curl -sSL https://install.python-poetry.org | python3 -
106+
echo "$HOME/.local/bin" >> $GITHUB_PATH
50107
51-
- name: Run tests with Pytest
108+
- name: "Configure Poetry"
52109
run: |
53-
# This command is fine. Pytest will now work because the 'Install dependencies'
54-
# step has correctly set up the environment.
55-
pytest
110+
poetry config virtualenvs.create true
111+
poetry config virtualenvs.in-project true
112+
113+
- name: "Cache Poetry dependencies"
114+
uses: actions/cache@v4
115+
with:
116+
path: .venv
117+
key: poetry-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
118+
restore-keys: |
119+
poetry-${{ runner.os }}-
120+
121+
- name: "Install dependencies"
122+
run: poetry install
123+
124+
- name: "Run Tests"
125+
run: poetry run pytest

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.11.9

Dockerfile

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Pin the Python version to match your poetry.lock file
2+
FROM python:3.11.9-slim
3+
4+
# Set the working directory inside the container
5+
WORKDIR /app
6+
7+
# Use modern ENV syntax
8+
ENV PYTHONDONTWRITEBYTECODE=1
9+
ENV PYTHONUNBUFFERED=1
10+
ENV POETRY_NO_INTERACTION=1 \
11+
POETRY_VIRTUALENVS_IN_PROJECT=1 \
12+
POETRY_VIRTUALENVS_CREATE=1
13+
14+
# Install build tools, git, AND the graphviz development library
15+
RUN apt-get update && apt-get install -y build-essential git graphviz-dev
16+
17+
# Install Poetry
18+
RUN pip install --no-cache-dir poetry
19+
20+
# Copy dependency files first
21+
COPY pyproject.toml poetry.lock ./
22+
COPY agent-sim/pyproject.toml ./agent-sim/
23+
24+
# Copy the entire project source code BEFORE running install
25+
COPY . .
26+
27+
# Install project dependencies using the lock file
28+
RUN poetry install --no-root
29+
30+
# The command to run when the container starts
31+
CMD ["tail", "-f", "/dev/null"]

Makefile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
.PHONY: setup up down run-example logs
2+
3+
# Default target
4+
all: up
5+
6+
# Set up the environment by copying the example .env file
7+
setup:
8+
@if [ ! -f .env ]; then \
9+
echo "--- Setup: Creating .env file from .env.example..."; \
10+
cp .env.example .env; \
11+
else \
12+
echo "--- Setup: .env file already exists."; \
13+
fi
14+
15+
# Build and start all services in the background
16+
up: setup
17+
@echo "--- Starting all services with Docker Compose..."
18+
docker compose up --build -d
19+
20+
# Stop and remove all services
21+
down:
22+
@echo "--- Stopping all services..."
23+
docker compose down
24+
25+
# Use the direct path to the venv's python executable
26+
run-example:
27+
@echo "--- Running: Executing example scenario inside Docker..."
28+
docker compose exec app /app/.venv/bin/python -m agent_sim.main --scenario simulations/soul_sim/scenarios/default.json --steps 50
29+
30+
# View the logs from all running services
31+
logs:
32+
@echo "--- Tailing logs from all services..."
33+
docker compose logs -f

0 commit comments

Comments
 (0)