- Core code lives in
pyth_observer/: CLI entrypoint incli.py, check logic undercheck/, alert dispatchers indispatch.py, event types inevent.py, and HTTP probes inhealth_server.py. - Supporting assets and defaults: sample configs (
sample.config.yaml,sample.publishers.yaml,sample.coingecko.yaml), Dockerfile for container builds, and helper scripts inscripts/(e.g.,build_coingecko_mapping.py). - Tests are in
tests/and mirror module names (test_checks_price_feed.py,test_checks_publisher.py).
- Use Python 3.11 with Poetry 2.x. Suggested bootstrap:
poetry env use $(which python)thenpoetry install. - Common Make targets:
make setup(install deps),make run(devnet run),make test,make cover,make lint,make clean. - Direct commands:
poetry run pyth-observer --config sample.config.yaml --publishers sample.publishers.yaml --coingecko-mapping sample.coingecko.yamlto run locally; add-l debugfor verbose logs. - CoinGecko mapping:
poetry run python scripts/build_coingecko_mapping.py -o my_mapping.jsonand compare with-e sample.coingecko.yamlbefore replacing defaults.
- Framework:
pytest. Quick check withpoetry run pytest; coverage report viamake cover(writeshtmlcov/). - Keep tests colocated under
tests/withtest_*naming. Prefer async tests for async code paths and mock network calls. - Add regression tests alongside new checks or dispatch paths; include sample config fragments when useful.
- Auto-format with
blackand import order viaisort(run together withmake lint). Lint also runspyrightandpyflakes. - Target Python 3.11; favor type hints on public functions and dataclasses/models. Use snake_case for functions/variables, PascalCase for classes, and uppercase for constants.
- Keep config keys consistent with existing YAML samples; avoid hard-coding secrets—read from env vars.
- Follow the existing Conventional Commit style (
fix:,chore:,refactor!:, etc.) seen ingit log. - PRs should summarize behavior changes, link issues, and include reproduction or validation steps (commands run, configs used). Add screenshots only when output formatting changes.
- Keep diffs small and focused; update sample config or docs when user-facing options change.
- Sensitive values (API keys, tokens) must be supplied via environment variables; never commit them. Use
.envlocally and document new keys inREADME.md. - For deployments, wire liveness/readiness probes to
GET /liveandGET /readyon port 8080.