Skip to content

Local development

Run skynet-app-api directly on your machine — no Docker required for day-to-day development.

Prerequisites

Requirement Notes
Python 3.8 README pins 3.8.2; CI uses 3.8
AWS credentials secretsmanager:GetSecretValue on /common/*, /stg/*; /prd/mysql/skynet-harvester if LOCAL_PROD_DB=1
fs_config Installed via requirements.txt (private GitHub dep)

One-time setup

cd skynet-app-api
python3.8 -m venv .venv
source .venv/bin/activate
pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements_dev.txt   # for tests / pre-commit

On macOS without Python 3.8: brew install python@3.8.

Run the API

Default — staging-backed services

export ENVIRONMENT=local
cd src/skynet_api
python main.py

Uvicorn starts on 0.0.0.0:8080 with reload enabled. Verify:

curl -s -o /dev/null -w "%{http_code}" localhost:8080/api/status
# 200

OpenAPI UI: http://localhost:8080/docs

Local with production MySQL only

export ENVIRONMENT=local
export LOCAL_PROD_DB=1
cd src/skynet_api
python main.py

MySQL resolves from /prd/mysql/skynet-harvester; Redis, RabbitMQ, and URLs stay on staging. Use only when you need prod data and understand write risk.

Unset ENVIRONMENT defaults to production

config/cfg.py treats a missing ENVIRONMENT as prd. Always export ENVIRONMENT=local on a laptop.

IDE debugging (PyCharm / VS Code)

Setting Value
Script src/skynet_api/main.py
Working directory Repository root
Env vars ENVIRONMENT=local (optionally LOCAL_PROD_DB=1)

Set breakpoints in route handlers under src/skynet_api/*/routes.py or in business logic modules. Config loads at import — to step through secret resolution, break in config/cfg.py before other modules import it.

Tests (no AWS)

source .venv/bin/activate
python -m pytest

tests/conftest.py patches fs_config and mocks Redis/MySQL before the app imports, so the suite runs offline. Coverage and junit output go to test-reports/ (gitignored).

Run a single module:

python -m pytest tests/test_auth.py -q

Linting

pre-commit run --all-files   # black, flake8, pyupgrade, reorder-imports

Logging

main.py configures loguru to stderr and ./logs/info.log (rotation 500 MB). Tail the file while debugging:

tail -f logs/info.log

Common issues

Symptom Fix
Import errors on startup Run from src/skynet_api or ensure pythonpath includes src
Secret access denied Check aws sts get-caller-identity and IAM for Secrets Manager
Redis/MySQL connection errors Confirm staging secrets exist; try ENVIRONMENT=local not prd
Port 8080 in use lsof -i :8080 and stop the conflicting process

Docker (optional)

Docker Compose mirrors EC2 scale-out but is not required for local dev:

ENVIRONMENT=stg docker-compose up --build --scale web-api=3

Prefer python main.py for faster iteration.