Get a development environment running in under five minutes.
git clone https://github.com/NLR-Distribution-Suite/shift.git
cd shift
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -e ".[dev,doc]"To also work on the MCP server, install the MCP extras:
pip install -e ".[dev,doc,mcp]"pytestAll tests should pass. If you see import errors, re-run pip install -e ".[dev]".
ruff check . # Lint
ruff format . # Format
pytest # Testpytest # All tests
pytest tests/test_graph.py # Single file
pytest tests/test_graph.py::test_name -v # Single test, verbose
pytest --cov=shift --cov-report=html # With coverage report
pytest -m "not slow" # Skip slow testsruff check . # Check lint rules
ruff check --fix . # Auto-fix lint issues
ruff format . # Format codecd docs && make html
# Open docs/_build/html/index.html- Branch —
git checkout -b feature/your-feature-name - Code — Edit source, add tests, update docs
- Validate —
pytest && ruff check . - Commit —
git commit -m "Add feature: description" - Push —
git push origin feature/your-feature-name - PR — Open a pull request on GitHub
shift/
├── src/shift/ # Source code
│ ├── __init__.py # Public API exports
│ ├── data_model.py # ParcelModel, NodeModel, EdgeModel, etc.
│ ├── parcel.py # OpenStreetMap parcel fetching
│ ├── system_builder.py
│ ├── graph/ # DistributionGraph, OpenStreetGraphBuilder, PRSG
│ ├── mapper/ # Phase, voltage, and equipment mappers
│ ├── mcp_server/ # MCP server for LLM agent integration
│ └── utils/ # Clustering, nearest points, mesh networks
├── tests/ # pytest test files (test_*.py)
├── docs/ # Jupyter Book documentation
│ ├── usage/ # How-to guides
│ └── references/ # Auto-generated API docs
└── pyproject.toml # Project config, dependencies, tool settings
| File | What It Does |
|---|---|
src/shift/__init__.py |
Defines the public API — start here to see what's exported |
src/shift/graph/distribution_graph.py |
Core graph with typed nodes and edges |
src/shift/graph/prsgb.py |
Primary/secondary graph builder from road networks |
src/shift/mapper/ |
Phase, voltage, and equipment assignment |
Tests live in tests/ and follow the pattern test_<module>.py.
import pytest
from shift import DistributionGraph, NodeModel
from infrasys import Location
@pytest.fixture
def sample_graph():
"""Provide a graph with one node for testing."""
graph = DistributionGraph()
graph.add_node(NodeModel(name="n1", location=Location(x=-97.3, y=32.7)))
return graph
def test_node_retrieval(sample_graph):
"""Verify nodes can be retrieved by name."""
node = sample_graph.get_node("n1")
assert node.name == "n1"- Run tests often — catch regressions early
- Keep commits small — one logical change per commit
- Add docstrings — use NumPy-style format (see CONTRIBUTING.md)
- Add type hints — all function signatures should be annotated
- Check coverage — aim for > 80% on new code
- Tests pass (
pytest) - Lint clean (
ruff check .) - Code formatted (
ruff format .) - Docstrings added/updated
- CHANGELOG.md updated
- README — Project overview and quick start
- CONTRIBUTING — Full contribution guidelines
- Complete Example — End-to-end workflow
- API Reference — Class and function reference