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

update email template and change config for env vars #1

Merged
merged 2 commits into from
Jan 23, 2025
Merged
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
36 changes: 0 additions & 36 deletions .github/workflows/pull-request-workflow.yml

This file was deleted.

119 changes: 119 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
name: Pre-merge Review

on: [pull_request]

jobs:
setup:
runs-on: ubuntu-latest
outputs:
python-cache-key: ${{ steps.cache-deps.outputs.cache-hit }}
steps:
# Step 1: Checkout code
- name: Checkout code
uses: actions/checkout@v4

# Step 2: Set up Python with caching
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Cache Python dependencies
id: cache-deps
uses: actions/cache@v3
with:
path: |
~/.cache/pypoetry/virtualenvs
.venv
key: ${{ runner.os }}-pip-${{ hashFiles('**/poetry.lock') }}
restore-keys: |
${{ runner.os }}-pip-

# Step 3: Install dependencies
- name: Install dependencies
run: |
pip install poetry
poetry sync

lint:
needs: setup
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Use Python cache
uses: actions/cache@v3
with:
path: |
~/.cache/pypoetry/virtualenvs
.venv
key: ${{ runner.os }}-pip-${{ hashFiles('**/poetry.lock') }}

- name: Install Poetry
run: |
pip install poetry

- name: Run styling checks
run: make style-check

type-check:
needs: setup
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Use Python cache
uses: actions/cache@v3
with:
path: |
~/.cache/pypoetry/virtualenvs
.venv
key: ${{ runner.os }}-pip-${{ hashFiles('**/poetry.lock') }}

- name: Install Poetry
run: |
pip install poetry

- name: Run type checks
run: make type-check

test:
needs: setup
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Use Python cache
uses: actions/cache@v3
with:
path: |
~/.cache/pypoetry/virtualenvs
.venv
key: ${{ runner.os }}-pip-${{ hashFiles('**/poetry.lock') }}

- name: Install Poetry
run: |
pip install poetry

- name: Start services
run: |
IS_CI="True" make init

- name: Check database schema migrations
run: make check-db-schema

- name: Run tests
env:
TEST_STRIPE_SECRET_KEY: ${{ secrets.TEST_STRIPE_SECRET_KEY }}
run: |
echo STRIPE_SECRET_KEY=${{ secrets.TEST_STRIPE_SECRET_KEY }} >> .env.local
echo STRIPE_DEVICE_NAME=CI >> .env.local
DEPLOYMENT_ENV=testing poetry run pytest
- name: Cleanup resources
if: ${{ always() }}
run: |
make kill
docker system prune --force --volumes
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.12-bookworm as builder
FROM python:3.12-bookworm AS builder

RUN pip install poetry==1.4.2

Expand All @@ -14,7 +14,7 @@ RUN poetry add psycopg2-binary

RUN --mount=type=cache,target=$POETRY_CACHE_DIR poetry install --without dev --no-root

FROM python:3.12-slim-bookworm as runtime
FROM python:3.12-slim-bookworm AS runtime

ENV VIRTUAL_ENV=/app/.venv \
PATH="/app/.venv/bin:$PATH"
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ dev-p:
poetry run uvicorn virtual_labs.api:app --reload

init:
./dev-init.sh
./dev-init.sh $(filter-out $@,$(MAKECMDGOALS))

kill:
cd env-prep && docker compose -f docker-compose-dev.yml -p vlm-project down --remove-orphans --volumes
Expand Down
24 changes: 23 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,24 @@ Make sure you have the following dependencies installed:
- [jq](https://jqlang.github.io/jq/download/)
- Stripe API key (`STRIPE_SECRET_KEY` test key and `STRIPE_DEVICE_NAME=dev` in `./.env.local`)

# Configuration

**Running in Macos (M4):**
For users running the virtual-lab-api on macOS with the M4 chip, the docker-compose configuration requires specific updates to ensure compatibility with the architecture and resource management. Please apply the following changes:

**Delta service:**
Add the following property to ensure the service runs using the correct architecture:
```
platform: linux/amd64
```

**Elasticsearch service:**
Include the following environment variables to configure memory usage and disable SVE (Scalable Vector Extensions):
```
ES_JAVA_OPTS: "-Xms512m -Xmx512m -XX:UseSVE=0"
CLI_JAVA_OPTS: "-XX:UseSVE=0"
```

# Development

1. Install the dependencies
Expand All @@ -24,6 +42,10 @@ Make sure you have the following dependencies installed:
```bash
make init
```
If you are using a machine with Apple ships (as M4), use this command instead:
```
make init amd
```
3. Run db migrations (this also initializes the database)

```
Expand All @@ -33,6 +55,7 @@ Make sure you have the following dependencies installed:
This should start the server on port 8000 (http://127.0.0.1:8000)
The docs will be available at http://127.0.0.1:8000/docs#/


# Retrieving tokens for test users

The token for user `test` (only user right now that can create virtual labs) is already copied to your clipboard when you run `make init`.
Expand Down Expand Up @@ -109,7 +132,6 @@ For further details on working with Setup Intents and managing payment methods,
stripe setup_intents confirm seti_1PFtBwFjhkSGAqrAUHCvTAAA \
--payment-method=pm_card_visa
```

# IDE Setup

## VS Code
Expand Down
8 changes: 7 additions & 1 deletion dev-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,16 @@ KC_REALM_NAME="obp-realm"
CLIENT_ID="obpapp"
CLIENT_SECRET="obp-secret"

if [ "$1" == "amd" ]; then
COMPOSE_FILE="env-prep/docker-compose-dev-amd.yml"
else
COMPOSE_FILE="env-prep/docker-compose-dev.yml"
fi

# Start containers
chmod +x ./env-prep/init/init-aws.sh
ls -l ./env-prep/init/init-aws.sh
docker compose -f env-prep/docker-compose-dev.yml -p vlm-project up --wait
docker compose -f "$COMPOSE_FILE" -p vlm-project up --wait

# Check that delta ready to accept connections
echo "Checking that delta is ready to accept connections..."
Expand All @@ -35,6 +40,7 @@ curl -XPUT \
}'

echo "Initialize nexus"

python3 env-prep/init/init.py

echo "📦 Initialize Vl database"
Expand Down
Loading
Loading