Contributing¶
Setup¶
git clone https://github.com/DiogoRibeiro7/anomalybench
cd anomalybench
poetry install
poetry run pre-commit install
Python 3.12 only — 3.13 is not yet supported.
Quality gates¶
CI runs the same three checks on every pull request, with pinned tool versions so a suppression that is required locally is not flagged as unused in CI:
poetry run ruff check .
poetry run mypy anomalybench src tests
poetry run pytest -q --cov=anomalybench --cov-report=term-missing --cov-fail-under=71
Use poetry run, and make sure it resolves to the venv
poetry run mypy will silently fall through to a mypy on PATH if one is
not installed in the virtualenv. That produces results from a different
version than CI uses, which looks like unexplained drift. Install the pinned
tools into the venv:
Adding a detector¶
- Subclass
BaseDetectorin the appropriate module underanomalybench/analytics/detectors/. - Implement
fitandscore, and declarescore_orientation. Leaving it at theestimator_defineddefault means benchmark evaluation refuses the detector. - Register it in
anomalybench/analytics/detectors/__init__.pywith a dottedmodule:Classpath — the registry is lazy, so a detector needing a heavy framework costs nothing until it is selected. - Add tests covering the behaviour and the edge cases.
- Update the README and these docs when user-facing capability changes.
Registrations are strings, not imports
The entries in the registry are dotted-path strings. A refactor that renames a module will not break them at import time, and the linter will not catch them either — the failure appears only when that detector is selected.
Adding a dataset¶
- Put compact, redistributable assets under
anomalybench/benchmarks/. - Implement a loader in
load_datasets.pyreturning(dataframe, feature_columns, label_column, display_name). - Describe it in
datasets.ymlwith tags (tabular,graph,time_series) and source metadata. - Cover it in
tests/test_benchmark_catalog.py.
Commit messages¶
The project uses Conventional Commits — release-please derives the version bump and the changelog from them, so the prefix is functional, not cosmetic:
| Prefix | Effect |
|---|---|
feat: |
minor bump, "Added" section |
fix: |
patch bump, "Fixed" section |
perf: |
patch bump, "Performance" section |
revert: |
patch bump, "Reverts" section |
deps: |
patch bump, "Dependencies" section |
chore:, ci:, docs:, test:, refactor:, style:, build: |
no release |
Housekeeping prefixes are deliberately non-releasing. Marking them releasable cuts versions for commits that changed nothing a user can observe.
Documentation¶
poetry run pip install mkdocs==1.6.1 mkdocs-material==9.7.7 \
mkdocstrings[python]==1.0.6
poetry run mkdocs serve # live preview on localhost:8000
poetry run mkdocs build --strict # what CI runs
--strict turns broken links and unresolved mkdocstrings references into
failures. Run it before opening a PR.