Contributing¶
The SDK is contributor-friendly: adding a new analytics function, a new storage backend, or a new CLI command is a small, self-contained change. The PR checklist below applies to every contribution.
Purpose¶
This page covers:
- The setup (clone, install, test).
- How to add a new analytics function.
- How to add a new storage backend.
- How to add a new CLI command.
- The PR checklist.
Setup¶
git clone https://github.com/Horizon-Labs-Building-AI-Systems/un-comtrade-sdk.git
cd un-comtrade-sdk
pip install -e .[all,dev]
pytest tests/ -x
The full test suite currently runs 3,117 tests across 38 modules.
Adding a new analytics function¶
- Pick a submodule under
un_comtrade/analytics/(country.py,partner.py,commodity.py,timeseries.py,balance.py,compare.py). - Add the function. It MUST accept a
CanonicalDataset(or anyIterable[TradeRecord]) and return a tuple of frozen dataclasses withDecimalarithmetic. - Add unit tests in
tests/test_analytics_<submodule>.py. - Add a recipe in
recipes/<category>/<file>.py(userecipes/_TEMPLATE.py). - Add a regression test in
tests/test_recipes_verification.py. - Update the documentation page under
website/docs/guides/python/analytics.md.
Adding a new storage backend¶
- Create
un_comtrade/storage/<backend>.pyexposing a class withread(config) -> CanonicalDatasetandwrite(config, dataset) -> None. - Register the backend in
un_comtrade/storage/__init__.py'sStorageRegistry. - Add unit tests in
tests/test_storage_<backend>.py. - Add cross-backend round-trip tests in
tests/test_storage_round_trip.py. - Add a recipe in
recipes/storage/. - Update
website/docs/guides/python/storage.mdandwebsite/docs/api/storage.md.
Adding a new CLI command¶
- Add the command module under
un_comtrade/cli/. - Wire it up in
un_comtrade/cli/__init__.py'sCOMMAND_MODULESregistry. - Add CLI integration tests in
tests/test_cli_<command>.py. - Add a recipe in
recipes/cli/. - Update
website/docs/guides/cli/<command>.md.
PR checklist¶
Every PR MUST include:
- Source code change with type hints.
- Unit tests covering the happy path + at least one failure mode.
- Recipe demonstrating the new feature (if user-facing).
- Regression test in
tests/test_recipes_verification.py. - Documentation update under
website/docs/. - Changelog entry in
docs/CHANGELOG.md(CHG-NNNN). - Task log entry in
docs/TASK_LOG.md(TASK-NNN). - Context update in
docs/002_CONTEXT.md.
Code style¶
- Maximum line length: 100 characters (per
docs/015_CODING_STANDARD.md). - Maximum module size: 500 lines.
- Type hints mandatory on every public interface.
Decimalarithmetic only — nofloat()for monetary values.- Imports only public SDK symbols; no
from un_comtrade._foo import ....
Testing¶
Run the full suite:
Run only the recipes:
Run with coverage:
Related Recipes¶
- RECIPE template — the canonical recipe scaffold.
Related API¶
un_comtrade.ComtradeClient— the entry point your code extends.
Related Guides¶
- SDK overview — read this first.
- Testing — the testing standard.
- Cookbook — the recipe contract.