Local development¶
Run skynet-dealer on your laptop without Docker. The server is a single Python process: HTTP routes plus in-process RabbitMQ consumers for provider and task queues.
Prerequisites¶
| Requirement | Notes |
|---|---|
| Python 3.8 | CI and setup.cfg target 3.8 |
| AWS credentials | Read access to /stg/* Secrets Manager and SSM |
fs_config |
Installed via requirements.txt (private GitHub dep) |
skynet-provider-api |
Pin via requirements-dev.txt (stage) or requirements-local.txt |
One-time setup¶
cd skynet-dealer
python3.8 -m venv env
source env/bin/activate
pip install --upgrade pip setuptools wheel
pip install .
pip install -r requirements.txt
pip install -r requirements-dev.txt # spapi @ stage
pip install -r requirements_tests.txt # for pytest
For a feature-branch provider API pin:
pip install -r requirements-local.txt
Run the server¶
export ENVIRONMENT=local
export PYTHONPATH="$(pwd)/src"
python src/dealer/server.py --port 5001
ENVIRONMENT=local selects staging secrets but uses the dev queue names
from SSM /stg/skynet-dealer/rabbitmq-queues-dev (dealer-dev, etc.) so local
runs do not compete with staging workers.
Verify:
curl -s localhost:5001/health | python -m json.tool
Optional: production MySQL only¶
export ENVIRONMENT=local
export LOCAL_PROD_DB=1
export PYTHONPATH="$(pwd)/src"
python src/dealer/server.py --port 5001
MySQL uses /prd/skynet-dealer/mysql; RabbitMQ, Redis, and queues stay on
staging/dev paths.
Preprod queue variant¶
On hosts (or locally for testing preprod routing):
export DEALER_VARIANT=preprod
Selects rabbitmq-queues-preprod from SSM instead of the default queue JSON.
Unset ENVIRONMENT defaults to production
Missing ENVIRONMENT loads /prd/... secrets and production queue names.
Always set ENVIRONMENT=local for laptop work.
Server CLI flags¶
src/dealer/server.py accepts:
| Flag | Purpose |
|---|---|
--port |
HTTP listen port (default 5000; use 5001 locally to avoid conflicts) |
--rest |
REST-only mode |
--socket |
WebSocket-only mode |
--prod |
Combined REST + sockets |
Note: --rest, --socket, and --prod use type=bool in argparse — pass
--rest True style if needed.
Workers start automatically¶
Importing controllers.py constructs ProviderStack() and TasksStack().
RabbitMQ listeners start in the same process as the HTTP server — no
separate worker containers locally.
Logs write under src/dealer/logs/ (per-module rotation).
Tests (no AWS)¶
source env/bin/activate
pytest
tests/conftest.py stubs fs_config before any dealer import. Coverage and
JUnit output go to test-reports/ (gitignored).
tests/test_common_functions.py imports every worker module listed in
tests/tests.json to catch import regressions.
Linting¶
pre-commit run --all-files
Black (120 cols), trailing whitespace, reorder-imports, pyupgrade.
Debugging tips¶
| Technique | When to use |
|---|---|
Tail src/dealer/logs/ProviderStack.log* |
Provider job execution |
logging.DEBUG in server.py |
Verbose startup (already enabled) |
Breakpoint in workers/<provider>.py |
Single-provider action debugging |
| RabbitMQ management UI | Confirm messages land on dealer-dev queue |
GET /health |
Provider + tasks stack liveness |
Common issues¶
| Symptom | Fix |
|---|---|
fs_config / import errors |
Activate venv; pip install . and requirements |
| RabbitMQ connection refused | Check staging secret /<env>/shared/rabbitmq and VPN/network |
403 on POST /put |
User lacks action permission in Redis/MySQL settings |
| Wrong queue consumed | Confirm ENVIRONMENT=local (dev queues, not prd) |
Production wrapper (reference)¶
On EC2, run_server.sh sources /srv/skynet-dealer/.env then execs
server.py. Local dev sets env vars directly — no wrapper required.