pixi manages all dependencies including Python, graphviz, and test tools:
git clone https://github.com/datajoint/datajoint-python.git
cd datajoint-python
# Run tests (containers managed automatically)
pixi run test
# Run with coverage
pixi run test-cov
# Run pre-commit hooks
pixi run pre-commit run --all-filespip install -e ".[test]"
pytest tests/Tests use testcontainers to automatically manage MySQL and MinIO containers. No manual docker-compose up required.
pixi run test # All tests
pixi run test-cov # With coverage
pixi run -e test pytest tests/unit/ # Unit tests only
pixi run -e test pytest tests/integration/test_blob.py -v # Specific filemacOS Docker Desktop users: If tests fail to connect:
export DOCKER_HOST=unix://$HOME/.docker/run/docker.sockdocker compose up -d db minio
DJ_USE_EXTERNAL_CONTAINERS=1 pixi run test
docker compose downdocker compose --profile test up djtest --buildHooks run automatically on git commit. All must pass.
pixi run pre-commit install # First time only
pixi run pre-commit run --all-files # Run manuallyHooks include: ruff (lint/format), codespell, YAML/JSON/TOML validation.
pixi run test— All tests passpixi run pre-commit run --all-files— Hooks passpixi run test-cov— Coverage maintained
For DJ_USE_EXTERNAL_CONTAINERS=1:
| Variable | Default | Description |
|---|---|---|
DJ_HOST |
localhost |
MySQL hostname |
DJ_PORT |
3306 |
MySQL port |
DJ_USER |
root |
MySQL username |
DJ_PASS |
password |
MySQL password |
S3_ENDPOINT |
localhost:9000 |
MinIO endpoint |
Use NumPy-style docstrings for all public APIs:
def insert(self, rows, *, replace=False):
"""
Insert rows into the table.
Parameters
----------
rows : iterable
Rows to insert. Each row can be a dict, numpy record, or sequence.
replace : bool, optional
If True, replace existing rows with matching keys. Default is False.
Returns
-------
None
Raises
------
DuplicateError
When inserting a duplicate key without ``replace=True``.
Examples
--------
>>> Mouse.insert1({"mouse_id": 1, "dob": "2024-01-15"})
"""- Short summary (one line, imperative mood)
- Extended description
- Parameters
- Returns / Yields
- Raises
- Examples (strongly encouraged)
- See Also
- Do: Imperative mood ("Insert rows" not "Inserts rows")
- Do: Include examples for public APIs
- Don't: Document private methods extensively
- Don't: Repeat function signature in description
See NumPy Docstring Guide for full reference.