Thank you for your interest in contributing to the Access project! This document provides guidelines and instructions for contributing.
- Fork the repository on GitHub
- Clone your fork locally
- Create a new branch for your feature or bug fix
- Make your changes
- Test your changes
- Submit a pull request
- Python 3.10
- uv (recommended) or pip
# Clone the repository
git clone https://github.com/PhilipMathieu/access.git
cd access
# Install dependencies with uv (recommended)
uv sync --all-groups
# Or with pip
pip install -e ".[dev]"We use pre-commit hooks to ensure code quality. Install them once after cloning:
uv run pre-commit installNow the hooks will run automatically on every commit. To run them manually on all files:
uv run pre-commit run --all-filesThis project uses several tools to maintain code quality:
- Black: Opinionated Python code formatter
- isort: Import statement organizer
- Prettier: For Markdown, JSON, and YAML files
Run formatting:
# Format Python code
uv run black src/ tests/
# Sort imports
uv run isort src/ tests/
# Or let pre-commit handle it
uv run pre-commit run --all-files- Ruff: Fast modern Python linter
- mypy: Static type checker
- Bandit: Security issue scanner
Run linters:
# Lint with Ruff
uv run ruff check src/ tests/
# Type check with mypy
uv run mypy src/
# Security scan with Bandit
uv run bandit -r src/- pip-audit: Dependency vulnerability scanner
- Bandit: Static code security analysis
Run security checks:
# Scan dependencies for vulnerabilities
uv run pip-audit
# Scan code for security issues
uv run bandit -r src/We use pytest for testing. All tests should pass before submitting a pull request.
# Run all tests
uv run pytest
# Run with coverage
uv run pytest --cov=src
# Run specific test file
uv run pytest tests/test_walk_times.py
# Run tests matching a pattern
uv run pytest -k "test_pattern"- Place tests in the
tests/directory - Name test files as
test_*.py - Name test functions as
test_* - Use descriptive test names that explain what is being tested
- Include docstrings for complex tests
Example:
def test_walk_time_calculation_with_valid_input():
"""Test that walk times are calculated correctly with valid input data."""
# Arrange
graph = create_test_graph()
# Act
result = calculate_walk_times(graph, source_nodes, target_nodes)
# Assert
assert result is not None
assert len(result) > 0- Line length: Maximum 100 characters
- Indentation: 4 spaces (enforced by Black)
- Imports: Organized by isort (standard library, third-party, local)
- Docstrings: Use Google-style docstrings
- Type hints: Encouraged for new code
def calculate_walk_times(
graph: nx.Graph,
source_nodes: list[int],
target_nodes: list[int],
max_time: int = 30
) -> pd.DataFrame:
"""Calculate walk times between source and target nodes.
Args:
graph: NetworkX graph with edge weights
source_nodes: List of source node IDs
target_nodes: List of target node IDs
max_time: Maximum walk time in minutes (default: 30)
Returns:
DataFrame with columns: source_id, target_id, walk_time
Raises:
ValueError: If graph is empty or nodes are invalid
Example:
>>> graph = load_graph("maine_walk.graphml")
>>> times = calculate_walk_times(graph, [1, 2], [3, 4])
"""
pass- Use present tense ("Add feature" not "Added feature")
- Use imperative mood ("Move cursor to..." not "Moves cursor to...")
- First line should be 50 characters or less
- Reference issues and pull requests when applicable
- Use conventional commit prefixes:
feat:- New featurefix:- Bug fixdocs:- Documentation changesstyle:- Formatting changesrefactor:- Code refactoringtest:- Adding testschore:- Maintenance tasks
Example:
feat: Add H3 hexagon-based walk time calculation
- Implement calculate_hexagon_walk_times function
- Add tests for hexagon centroid mapping
- Update documentation
Closes #123
-
Update your branch with the latest changes from main:
git fetch origin git rebase origin/main
-
Ensure all tests pass:
uv run pytest
-
Run code quality checks:
uv run pre-commit run --all-files
-
Push to your fork:
git push origin your-branch-name
-
Create a pull request on GitHub with:
- Clear title and description
- Reference to related issues
- Screenshots (if applicable)
- Test results
- Any breaking changes noted
- Tests pass locally
- Code follows style guidelines
- Documentation is updated
- Commit messages are clear
- No merge conflicts
- Pre-commit hooks pass
- Security scan passes
All pull requests require review before merging. Reviewers will check for:
- Code quality and style
- Test coverage
- Documentation completeness
- Security considerations
- Performance implications
- Breaking changes
This project has automated security scanning in place:
- Dependabot: Weekly automated dependency updates
- pip-audit: Dependency vulnerability scanning (runs weekly + on push/PR)
- Bandit: Security code analysis (runs weekly + on push/PR)
When contributing, please:
- Never commit API keys, passwords, or credentials
- Use
.envfiles for local secrets (excluded via.gitignore) - Run
uv run pip-auditbefore submitting PRs - Follow principle of least privilege
- Validate all external inputs
Our CI pipeline runs automatically on all pull requests:
- Code Quality: Black, isort, Ruff, mypy
- Tests: pytest with coverage reporting
- Security: pip-audit and Bandit scans
- Pre-commit hooks: All configured hooks
All checks must pass before merging.
-
Create a feature branch:
git checkout -b feat/my-new-feature
-
Make changes and test locally:
# Edit code uv run pytest uv run pre-commit run --all-files -
Commit changes:
git add . git commit -m "feat: Add new feature"
-
Push and create PR:
git push origin feat/my-new-feature
Before submitting a PR, test the full pipeline:
# Run data processing pipeline
./run_pipeline.sh
# Or use Python directly
python -m src.run_pipelineRecommended extensions:
- Python (Microsoft)
- Pylance
- Ruff
- Black Formatter
- EditorConfig
Settings are configured in .vscode/settings.json and .editorconfig.
Settings are configured in .editorconfig. Enable:
- Black formatter on save
- isort on save
- Ruff linter
If you have questions:
- Open a GitHub issue with the
questionlabel - Contact the project lead: Philip Mathieu (mathieu.p@northeastern.edu)
By contributing, you agree that your contributions will be licensed under the same license as the project.
Thank you for contributing to Access!