mdp-outbox 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mdp_outbox-0.1.0/.dockerignore +12 -0
- mdp_outbox-0.1.0/.env.example +33 -0
- mdp_outbox-0.1.0/.gitattributes +2 -0
- mdp_outbox-0.1.0/.github/dependabot.yml +26 -0
- mdp_outbox-0.1.0/.github/workflows/ci.yml +44 -0
- mdp_outbox-0.1.0/.github/workflows/release.yml +60 -0
- mdp_outbox-0.1.0/.gitignore +25 -0
- mdp_outbox-0.1.0/.python-version +1 -0
- mdp_outbox-0.1.0/CHANGELOG.md +44 -0
- mdp_outbox-0.1.0/CONTRIBUTING.md +45 -0
- mdp_outbox-0.1.0/Dockerfile +21 -0
- mdp_outbox-0.1.0/LICENSE +21 -0
- mdp_outbox-0.1.0/Makefile +51 -0
- mdp_outbox-0.1.0/PKG-INFO +449 -0
- mdp_outbox-0.1.0/README.md +417 -0
- mdp_outbox-0.1.0/SECURITY.md +33 -0
- mdp_outbox-0.1.0/bench/aggregator.py +114 -0
- mdp_outbox-0.1.0/bench/latency.py +135 -0
- mdp_outbox-0.1.0/bench/storage.py +105 -0
- mdp_outbox-0.1.0/docker-compose.yml +108 -0
- mdp_outbox-0.1.0/docs/adr/0001-watermark-and-allowed-lateness.md +66 -0
- mdp_outbox-0.1.0/docs/adr/0002-idempotent-writes.md +70 -0
- mdp_outbox-0.1.0/docs/adr/0003-redis-streams-over-kafka.md +64 -0
- mdp_outbox-0.1.0/docs/adr/0004-higher-timeframes.md +58 -0
- mdp_outbox-0.1.0/docs/adr/0005-no-candles-for-empty-minutes.md +37 -0
- mdp_outbox-0.1.0/ops/grafana/dashboards/pipeline.json +886 -0
- mdp_outbox-0.1.0/ops/grafana/provisioning/dashboards/pipeline.yml +8 -0
- mdp_outbox-0.1.0/ops/grafana/provisioning/datasources/prometheus.yml +8 -0
- mdp_outbox-0.1.0/ops/prometheus.yml +15 -0
- mdp_outbox-0.1.0/pyproject.toml +91 -0
- mdp_outbox-0.1.0/requirements.txt +119 -0
- mdp_outbox-0.1.0/src/mdp/__init__.py +3 -0
- mdp_outbox-0.1.0/src/mdp/aggregation.py +272 -0
- mdp_outbox-0.1.0/src/mdp/aggregator.py +310 -0
- mdp_outbox-0.1.0/src/mdp/api.py +186 -0
- mdp_outbox-0.1.0/src/mdp/backfill.py +252 -0
- mdp_outbox-0.1.0/src/mdp/cli.py +200 -0
- mdp_outbox-0.1.0/src/mdp/config.py +55 -0
- mdp_outbox-0.1.0/src/mdp/hub.py +156 -0
- mdp_outbox-0.1.0/src/mdp/ingest.py +96 -0
- mdp_outbox-0.1.0/src/mdp/metrics.py +63 -0
- mdp_outbox-0.1.0/src/mdp/normalizer.py +93 -0
- mdp_outbox-0.1.0/src/mdp/py.typed +0 -0
- mdp_outbox-0.1.0/src/mdp/schema.py +89 -0
- mdp_outbox-0.1.0/src/mdp/sources/__init__.py +20 -0
- mdp_outbox-0.1.0/src/mdp/sources/binance.py +88 -0
- mdp_outbox-0.1.0/src/mdp/sources/engine.py +183 -0
- mdp_outbox-0.1.0/src/mdp/sources/kraken.py +102 -0
- mdp_outbox-0.1.0/src/mdp/sources/synthetic.py +121 -0
- mdp_outbox-0.1.0/src/mdp/sources/ws.py +102 -0
- mdp_outbox-0.1.0/src/mdp/storage/__init__.py +57 -0
- mdp_outbox-0.1.0/src/mdp/storage/memory.py +114 -0
- mdp_outbox-0.1.0/src/mdp/storage/schema.sql +76 -0
- mdp_outbox-0.1.0/src/mdp/storage/timescale.py +234 -0
- mdp_outbox-0.1.0/src/mdp/streams.py +57 -0
- mdp_outbox-0.1.0/src/mdp/timeframes.py +57 -0
- mdp_outbox-0.1.0/tests/__init__.py +0 -0
- mdp_outbox-0.1.0/tests/conftest.py +98 -0
- mdp_outbox-0.1.0/tests/fixtures/binance_klines.json +1 -0
- mdp_outbox-0.1.0/tests/fixtures/binance_trades.jsonl +12 -0
- mdp_outbox-0.1.0/tests/fixtures/engine_events.jsonl +5 -0
- mdp_outbox-0.1.0/tests/fixtures/kraken_ohlc.json +1 -0
- mdp_outbox-0.1.0/tests/fixtures/kraken_trades.jsonl +12 -0
- mdp_outbox-0.1.0/tests/helpers.py +45 -0
- mdp_outbox-0.1.0/tests/test_adapters.py +342 -0
- mdp_outbox-0.1.0/tests/test_aggregator.py +131 -0
- mdp_outbox-0.1.0/tests/test_api.py +210 -0
- mdp_outbox-0.1.0/tests/test_backfill.py +201 -0
- mdp_outbox-0.1.0/tests/test_cli.py +47 -0
- mdp_outbox-0.1.0/tests/test_hub.py +105 -0
- mdp_outbox-0.1.0/tests/test_normalizer.py +79 -0
- mdp_outbox-0.1.0/tests/test_pipeline.py +234 -0
- mdp_outbox-0.1.0/tests/test_schema.py +112 -0
- mdp_outbox-0.1.0/tests/test_store.py +153 -0
- mdp_outbox-0.1.0/tests/test_synthetic.py +46 -0
- mdp_outbox-0.1.0/tests/test_watermark.py +102 -0
- mdp_outbox-0.1.0/uv.lock +1041 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Copy to .env; docker compose and `mdp` both read it. Every setting has a
|
|
2
|
+
# default, so an empty .env runs the synthetic demo.
|
|
3
|
+
|
|
4
|
+
# Which feed `mdp ingest` follows: synthetic | binance | kraken | engine
|
|
5
|
+
MDP_SOURCE=synthetic
|
|
6
|
+
# Canonical symbols, BASE-QUOTE. Binance: BTC-USDT. Kraken: BTC-USD.
|
|
7
|
+
MDP_SYMBOLS=BTC-USDT,ETH-USDT
|
|
8
|
+
|
|
9
|
+
# Only outside docker compose, which sets these itself.
|
|
10
|
+
# MDP_REDIS_URL=redis://localhost:6379/0
|
|
11
|
+
# MDP_DATABASE_URL=postgresql://mdp:mdp@localhost:5432/mdp
|
|
12
|
+
|
|
13
|
+
# Synthetic source
|
|
14
|
+
MDP_SYNTHETIC_RATE=20
|
|
15
|
+
MDP_SYNTHETIC_SEED=7
|
|
16
|
+
|
|
17
|
+
# Matching engine: ws://host/path, or redis://host:6379/0#stream-key
|
|
18
|
+
# MDP_ENGINE_URL=redis://engine-redis:6379/0#engine:trades
|
|
19
|
+
# MDP_ENGINE_PRICE_SCALE=2
|
|
20
|
+
# MDP_ENGINE_QTY_SCALE=8
|
|
21
|
+
|
|
22
|
+
# Aggregation
|
|
23
|
+
MDP_ALLOWED_LATENESS_MS=5000
|
|
24
|
+
MDP_IDLE_GRACE_MS=2000
|
|
25
|
+
|
|
26
|
+
# Gap repair (docker compose --profile repair up)
|
|
27
|
+
MDP_REPAIR_SOURCE=binance
|
|
28
|
+
MDP_REPAIR_INTERVAL_S=60
|
|
29
|
+
MDP_REPAIR_LOOKBACK_MINUTES=1440
|
|
30
|
+
|
|
31
|
+
# Credentials for the local stack. Change both before exposing it anywhere.
|
|
32
|
+
POSTGRES_PASSWORD=mdp
|
|
33
|
+
GRAFANA_ADMIN_PASSWORD=admin
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Actions first: an unpinned or abandoned action is the most direct route into
|
|
2
|
+
# a pipeline that can execute code in the repository.
|
|
3
|
+
version: 2
|
|
4
|
+
updates:
|
|
5
|
+
- package-ecosystem: github-actions
|
|
6
|
+
directory: "/"
|
|
7
|
+
schedule:
|
|
8
|
+
interval: weekly
|
|
9
|
+
groups:
|
|
10
|
+
actions:
|
|
11
|
+
patterns: ["*"]
|
|
12
|
+
|
|
13
|
+
# uv.lock is the source of truth; after merging an update, run
|
|
14
|
+
# `make requirements` so CI installs the same versions.
|
|
15
|
+
- package-ecosystem: uv
|
|
16
|
+
directory: "/"
|
|
17
|
+
schedule:
|
|
18
|
+
interval: weekly
|
|
19
|
+
groups:
|
|
20
|
+
python-minor:
|
|
21
|
+
update-types: [minor, patch]
|
|
22
|
+
|
|
23
|
+
- package-ecosystem: docker
|
|
24
|
+
directory: "/"
|
|
25
|
+
schedule:
|
|
26
|
+
interval: weekly
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# The gate in front of main. The checks themselves live in
|
|
2
|
+
# CtrlAltDevelop/ci-workflows so every project runs the same ones.
|
|
3
|
+
|
|
4
|
+
name: CI
|
|
5
|
+
|
|
6
|
+
on:
|
|
7
|
+
pull_request:
|
|
8
|
+
branches: [main]
|
|
9
|
+
push:
|
|
10
|
+
branches: [main]
|
|
11
|
+
|
|
12
|
+
concurrency:
|
|
13
|
+
group: ci-${{ github.ref }}
|
|
14
|
+
cancel-in-progress: true
|
|
15
|
+
|
|
16
|
+
permissions: {}
|
|
17
|
+
|
|
18
|
+
jobs:
|
|
19
|
+
backend:
|
|
20
|
+
name: Backend
|
|
21
|
+
uses: CtrlAltDevelop/ci-workflows/.github/workflows/python-backend.yml@v1.1.1
|
|
22
|
+
permissions:
|
|
23
|
+
contents: read
|
|
24
|
+
with:
|
|
25
|
+
python-version: "3.14"
|
|
26
|
+
# `uv export --all-groups`: runtime and dev dependencies, so pytest,
|
|
27
|
+
# pytest-asyncio and fakeredis come from here, pinned like the rest.
|
|
28
|
+
requirements: requirements.txt
|
|
29
|
+
test-requirements: ""
|
|
30
|
+
# The Postgres service is TimescaleDB, so the storage tests run in CI
|
|
31
|
+
# against the real thing instead of being skipped.
|
|
32
|
+
postgres-image: timescale/timescaledb:latest-pg16
|
|
33
|
+
redis: true
|
|
34
|
+
mypy: true
|
|
35
|
+
|
|
36
|
+
security:
|
|
37
|
+
name: Security
|
|
38
|
+
uses: CtrlAltDevelop/ci-workflows/.github/workflows/security.yml@v1.1.1
|
|
39
|
+
permissions:
|
|
40
|
+
contents: read
|
|
41
|
+
security-events: write
|
|
42
|
+
pull-requests: write
|
|
43
|
+
with:
|
|
44
|
+
languages: '["python"]'
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# =============================================================================
|
|
2
|
+
# Release: build once, publish to PyPI with trusted publishing.
|
|
3
|
+
# =============================================================================
|
|
4
|
+
# Runs on a version tag. No API token exists anywhere: PyPI trusts this
|
|
5
|
+
# workflow's OIDC identity, configured once under the project's "Publishing"
|
|
6
|
+
# settings (owner CtrlAltDevelop, repo mdp-outbox, workflow
|
|
7
|
+
# release.yml, environment pypi).
|
|
8
|
+
|
|
9
|
+
name: Release
|
|
10
|
+
|
|
11
|
+
on:
|
|
12
|
+
push:
|
|
13
|
+
tags: ["v*"]
|
|
14
|
+
|
|
15
|
+
permissions: {}
|
|
16
|
+
|
|
17
|
+
jobs:
|
|
18
|
+
build:
|
|
19
|
+
name: Build
|
|
20
|
+
runs-on: ubuntu-latest
|
|
21
|
+
timeout-minutes: 10
|
|
22
|
+
permissions:
|
|
23
|
+
contents: read
|
|
24
|
+
steps:
|
|
25
|
+
- uses: actions/checkout@v7
|
|
26
|
+
with:
|
|
27
|
+
persist-credentials: false
|
|
28
|
+
- uses: astral-sh/setup-uv@v7
|
|
29
|
+
with:
|
|
30
|
+
python-version: "3.13"
|
|
31
|
+
- name: Tag matches the package version
|
|
32
|
+
run: |
|
|
33
|
+
version=$(uv version --short)
|
|
34
|
+
if [ "v$version" != "$GITHUB_REF_NAME" ]; then
|
|
35
|
+
echo "::error::Tag $GITHUB_REF_NAME does not match version $version in pyproject.toml"
|
|
36
|
+
exit 1
|
|
37
|
+
fi
|
|
38
|
+
- run: uv build
|
|
39
|
+
- uses: actions/upload-artifact@v5
|
|
40
|
+
with:
|
|
41
|
+
name: dist
|
|
42
|
+
path: dist/
|
|
43
|
+
if-no-files-found: error
|
|
44
|
+
|
|
45
|
+
publish:
|
|
46
|
+
name: Publish to PyPI
|
|
47
|
+
needs: build
|
|
48
|
+
runs-on: ubuntu-latest
|
|
49
|
+
timeout-minutes: 10
|
|
50
|
+
environment:
|
|
51
|
+
name: pypi
|
|
52
|
+
url: https://pypi.org/project/mdp-outbox/
|
|
53
|
+
permissions:
|
|
54
|
+
id-token: write # the OIDC token PyPI exchanges for a short-lived upload credential
|
|
55
|
+
steps:
|
|
56
|
+
- uses: actions/download-artifact@v6
|
|
57
|
+
with:
|
|
58
|
+
name: dist
|
|
59
|
+
path: dist/
|
|
60
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*.egg-info/
|
|
5
|
+
build/
|
|
6
|
+
dist/
|
|
7
|
+
.venv/
|
|
8
|
+
|
|
9
|
+
# Tooling caches
|
|
10
|
+
.mypy_cache/
|
|
11
|
+
.pytest_cache/
|
|
12
|
+
.ruff_cache/
|
|
13
|
+
.coverage
|
|
14
|
+
htmlcov/
|
|
15
|
+
|
|
16
|
+
# Local configuration and runtime data
|
|
17
|
+
.env
|
|
18
|
+
data/
|
|
19
|
+
*.log
|
|
20
|
+
|
|
21
|
+
# Editors / OS
|
|
22
|
+
.idea/
|
|
23
|
+
.vscode/
|
|
24
|
+
.DS_Store
|
|
25
|
+
Thumbs.db
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.14
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
4
|
+
and the versions follow [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
5
|
+
For this project, "breaking" means a change to the candle payload, the
|
|
6
|
+
WebSocket protocol, the REST parameters or an `MDP_*` setting.
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
## [0.1.0] - 2026-09-29
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- A normalized trade schema with decimal-string prices, and deduplication on
|
|
15
|
+
`(source, trade_id)` at ingest and in the trade log.
|
|
16
|
+
- Source adapters for the Binance and Kraken public WebSockets and for a
|
|
17
|
+
matching engine's JSON events over WebSocket or a Redis stream, all behind
|
|
18
|
+
one `TradeSource` protocol. Reconnects use exponential backoff with full
|
|
19
|
+
jitter, and a watchdog catches silent connections.
|
|
20
|
+
- A seeded synthetic source for demos, tests and benchmarks.
|
|
21
|
+
- An event-time candle aggregator for 1m, 5m, 1h and 1d with a watermark,
|
|
22
|
+
allowed lateness, a wall-clock idle advance, and dead-lettering of late
|
|
23
|
+
trades.
|
|
24
|
+
- Redis Streams with consumer groups between ingest and aggregation, and a
|
|
25
|
+
dead-letter stream with the reason and original payload of every refusal.
|
|
26
|
+
- TimescaleDB storage: a candles hypertable with idempotent snapshot upserts,
|
|
27
|
+
a deduplicating trade log, and a per-symbol checkpoint written in the same
|
|
28
|
+
transaction. Compression and retention policies.
|
|
29
|
+
- Restart recovery from consumer-group offsets, orphaned messages and the
|
|
30
|
+
checkpoint.
|
|
31
|
+
- `GET /v1/candles`, the `/v1/ws` WebSocket with `candles:{symbol}:{tf}`
|
|
32
|
+
channels fanned out from one Redis subscription per channel, `/healthz`,
|
|
33
|
+
`/readyz` and `/metrics/`.
|
|
34
|
+
- Backfill from Binance and Kraken REST klines, and a repair job that finds
|
|
35
|
+
minutes with no candle and fetches them, then rebuilds the closed higher
|
|
36
|
+
timeframes.
|
|
37
|
+
- Prometheus metrics for throughput, lag, errors and fan-out, and a
|
|
38
|
+
provisioned Grafana dashboard.
|
|
39
|
+
- The `mdp` command, a Dockerfile, and a docker compose stack that runs the
|
|
40
|
+
whole pipeline on the synthetic source.
|
|
41
|
+
- Benchmarks for aggregator throughput, end-to-end latency and storage.
|
|
42
|
+
|
|
43
|
+
[Unreleased]: https://github.com/CtrlAltDevelop/mdp-outbox/compare/v0.1.0...HEAD
|
|
44
|
+
[0.1.0]: https://github.com/CtrlAltDevelop/mdp-outbox/releases/tag/v0.1.0
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
Thanks for considering it. This is a solo-maintained project, so the biggest
|
|
4
|
+
favour a contribution can do is arrive in a shape that is fast to review. This
|
|
5
|
+
page is mostly about that.
|
|
6
|
+
|
|
7
|
+
## Setup
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
uv sync
|
|
11
|
+
make services # Redis on 56380 and TimescaleDB on 55433, in Docker
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Without `make services` the suite still runs: Redis falls back to fakeredis,
|
|
15
|
+
and the TimescaleDB tests are skipped with a reason. Run it against the real
|
|
16
|
+
services before opening a pull request that touches storage or streams.
|
|
17
|
+
|
|
18
|
+
## Before opening a pull request
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
make check # ruff check, ruff format --check, mypy --strict, pytest
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
CI runs the same checks on every push, and a pull request that fails one will
|
|
25
|
+
not be merged until it passes.
|
|
26
|
+
|
|
27
|
+
If you changed dependencies, regenerate the file CI installs from:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
make requirements
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## What makes a change easy to accept
|
|
34
|
+
|
|
35
|
+
- **One concern per pull request.** A fix and a refactor are two PRs.
|
|
36
|
+
- **A test that fails without the change.** For the aggregator, prefer a
|
|
37
|
+
property of the output ("shuffled gives the same candles") over a list of
|
|
38
|
+
expected numbers.
|
|
39
|
+
- **No network in tests.** An adapter change comes with frames recorded from
|
|
40
|
+
the real feed, added to `tests/fixtures/`.
|
|
41
|
+
- **A decision worth recording gets an ADR** in `docs/adr/`: what was decided,
|
|
42
|
+
what else was considered, and what it costs.
|
|
43
|
+
- **Conventional commit messages**, short and imperative:
|
|
44
|
+
`fix: keep a closed candle closed when a stale snapshot replays`.
|
|
45
|
+
- **A CHANGELOG entry** under *Unreleased* for anything a user would notice.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# One image, every process: the compose file picks the subcommand.
|
|
2
|
+
|
|
3
|
+
FROM python:3.14-slim AS build
|
|
4
|
+
COPY --from=ghcr.io/astral-sh/uv:0.12 /uv /usr/local/bin/uv
|
|
5
|
+
ENV UV_COMPILE_BYTECODE=1 UV_LINK_MODE=copy UV_PYTHON_DOWNLOADS=never
|
|
6
|
+
WORKDIR /app
|
|
7
|
+
|
|
8
|
+
# Dependencies first, in their own layer: they change far less often than the code.
|
|
9
|
+
COPY pyproject.toml uv.lock README.md LICENSE ./
|
|
10
|
+
RUN uv sync --locked --no-dev --no-install-project
|
|
11
|
+
COPY src ./src
|
|
12
|
+
RUN uv sync --locked --no-dev --no-editable
|
|
13
|
+
|
|
14
|
+
FROM python:3.14-slim
|
|
15
|
+
RUN useradd --system --uid 10001 --no-create-home mdp
|
|
16
|
+
COPY --from=build /app/.venv /app/.venv
|
|
17
|
+
ENV PATH=/app/.venv/bin:$PATH PYTHONUNBUFFERED=1
|
|
18
|
+
USER mdp
|
|
19
|
+
EXPOSE 8000 9100
|
|
20
|
+
ENTRYPOINT ["mdp"]
|
|
21
|
+
CMD ["api"]
|
mdp_outbox-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Mohammad Zarif
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Everyday commands. Tests read REDIS_URL and DATABASE_URL: `make services`
|
|
2
|
+
# starts both in Docker on the ports below, and the suite skips what it cannot reach.
|
|
3
|
+
|
|
4
|
+
REDIS_PORT ?= 56380
|
|
5
|
+
TIMESCALE_PORT ?= 55433
|
|
6
|
+
export REDIS_URL ?= redis://localhost:$(REDIS_PORT)/0
|
|
7
|
+
export DATABASE_URL ?= postgresql://mdp:mdp@localhost:$(TIMESCALE_PORT)/mdp
|
|
8
|
+
|
|
9
|
+
.PHONY: install lint format typecheck test check services services-down up down bench requirements
|
|
10
|
+
|
|
11
|
+
install:
|
|
12
|
+
uv sync
|
|
13
|
+
|
|
14
|
+
lint:
|
|
15
|
+
uv run ruff check .
|
|
16
|
+
uv run ruff format --check .
|
|
17
|
+
|
|
18
|
+
format:
|
|
19
|
+
uv run ruff check --fix .
|
|
20
|
+
uv run ruff format .
|
|
21
|
+
|
|
22
|
+
typecheck:
|
|
23
|
+
uv run mypy
|
|
24
|
+
|
|
25
|
+
test:
|
|
26
|
+
uv run pytest
|
|
27
|
+
|
|
28
|
+
check: lint typecheck test
|
|
29
|
+
|
|
30
|
+
services:
|
|
31
|
+
docker run -d --rm --name mdp-redis -p $(REDIS_PORT):6379 redis:7-alpine
|
|
32
|
+
docker run -d --rm --name mdp-ts -p $(TIMESCALE_PORT):5432 -e POSTGRES_USER=mdp \
|
|
33
|
+
-e POSTGRES_PASSWORD=mdp -e POSTGRES_DB=mdp timescale/timescaledb:latest-pg16
|
|
34
|
+
|
|
35
|
+
services-down:
|
|
36
|
+
docker rm -f mdp-redis mdp-ts
|
|
37
|
+
|
|
38
|
+
up:
|
|
39
|
+
docker compose up --build -d
|
|
40
|
+
|
|
41
|
+
down:
|
|
42
|
+
docker compose down
|
|
43
|
+
|
|
44
|
+
bench:
|
|
45
|
+
uv run python bench/aggregator.py
|
|
46
|
+
uv run python bench/latency.py
|
|
47
|
+
uv run python bench/storage.py
|
|
48
|
+
|
|
49
|
+
# CI installs with pip from this file; regenerate it whenever uv.lock changes.
|
|
50
|
+
requirements:
|
|
51
|
+
uv export --frozen --no-hashes --no-emit-project --all-groups -o requirements.txt
|