Thank you for your interest in contributing to the Point of Presence API! This document provides guidelines and information for contributors.
- Fork the repository on GitHub
- Clone your fork locally:
git clone https://github.com/YOUR_USERNAME/pop.git cd pop - Set up development environment (see Development Setup)
- Create a feature branch from
main:git checkout -b feature/your-feature-name
- Make your changes following our coding standards
- Test your changes thoroughly
- Submit a pull request
- Python 3.9 or higher
- Docker and Docker Compose
- Git
-
Create virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt pip install -r requirements-dev.txt # Development dependencies -
Configure environment:
cp example.env .env # Edit .env with your development settings -
Install pre-commit hooks:
pre-commit install
-
Run the application:
uvicorn api.main:app --reload --port 8000
# Start development environment
docker-compose up -d
# Access the container for development
docker exec -it pop-api bash
# Run tests inside container
docker exec -it pop-api pytest- Type hints: Required for all function parameters and return values
- Docstrings: NumPy-style docstrings for all public functions and classes
- Line length: Maximum 79 characters (PEP 8 compliant)
- Comments: English only, clear and concise
def create_dataset(
dataset_name: str,
owner_org: str,
description: Optional[str] = None
) -> str:
"""
Create a new dataset in CKAN.
Parameters
----------
dataset_name : str
The unique name for the dataset.
owner_org : str
The organization ID that will own the dataset.
description : Optional[str], default=None
Optional description for the dataset.
Returns
-------
str
The ID of the created dataset.
Raises
------
ValueError
If dataset_name is invalid or already exists.
HTTPException
If CKAN API call fails.
"""
# Implementation here
return dataset_id# Run all tests
pytest
# Run with coverage report
pytest --cov=api --cov-report=html
# Run specific test file
pytest tests/test_routes.py
# Run tests with verbose output
pytest -v- Test files: Place in
tests/directory withtest_*.pynaming - Coverage: Aim for >80% code coverage for new features
- Test types: Include unit tests, integration tests, and API endpoint tests
- Fixtures: Use pytest fixtures for common test setup
import pytest
from fastapi.testclient import TestClient
from api.main import app
client = TestClient(app)
def test_create_dataset_success():
"""Test successful dataset creation."""
payload = {
"dataset_name": "test_dataset",
"dataset_title": "Test Dataset",
"owner_org": "test_org"
}
response = client.post("/datasource", json=payload)
assert response.status_code == 201
assert "id" in response.json()
def test_create_dataset_invalid_input():
"""Test dataset creation with invalid input."""
payload = {"invalid": "data"}
response = client.post("/datasource", json=payload)
assert response.status_code == 422- Update tests for any new functionality
- Run the full test suite and ensure it passes
- Update documentation if needed
- Run code formatting:
black api/ tests/ flake8 api/ tests/
- Clear title describing the change
- Detailed description of what was changed and why
- Reference related issues using
Fixes #issue_number - Include screenshots for UI changes
- Test coverage maintained or improved
## Description
Brief description of changes made.
## Type of Change
- [ ] Bug fix (non-breaking change that fixes an issue)
- [ ] New feature (non-breaking change that adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] Documentation update
## Testing
- [ ] Unit tests pass
- [ ] Integration tests pass
- [ ] Manual testing completed
## Checklist
- [ ] Code follows project style guidelines
- [ ] Self-review completed
- [ ] Code is commented appropriately
- [ ] Documentation updated
- [ ] Tests added/updatedUnderstanding the codebase organization:
pop/
├── api/
│ ├── config/ # Configuration management
│ │ ├── ckan_settings.py
│ │ ├── kafka_settings.py
│ │ └── keycloak_settings.py
│ ├── models/ # Pydantic data models
│ │ ├── *request_model.py
│ │ └── *response_model.py
│ ├── routes/ # API endpoints
│ │ ├── register_routes/
│ │ ├── search_routes/
│ │ ├── delete_routes/
│ │ └── update_routes/
│ ├── services/ # Business logic
│ ├── tasks/ # Background tasks
│ └── templates/ # HTML templates
├── tests/ # Test suite
├── static/ # Static web assets
└── docs/ # Additional documentation
- Search existing issues to avoid duplicates
- Test with latest version from main branch
- Gather relevant information (logs, environment details)
**Bug Description**
Clear description of the bug.
**Steps to Reproduce**
1. Step 1
2. Step 2
3. Step 3
**Expected Behavior**
What you expected to happen.
**Actual Behavior**
What actually happened.
**Environment**
- OS: [e.g., Ubuntu 20.04]
- Python version: [e.g., 3.9.7]
- Docker version: [if applicable]
- Browser: [if web-related]
**Additional Context**
Any other relevant information.**Feature Description**
Clear description of the requested feature.
**Problem Statement**
What problem does this feature solve?
**Proposed Solution**
How should this feature work?
**Alternatives Considered**
Any alternative solutions considered?
**Additional Context**
Any other relevant information.bug- Something isn't workingenhancement- New feature or requestdocumentation- Improvements or additions to documentationgood first issue- Good for newcomershelp wanted- Extra attention neededquestion- Further information requestedwontfix- This will not be worked on
- API Documentation: http://localhost:8001/docs (when running locally)
- FastAPI Documentation: https://fastapi.tiangolo.com/
- CKAN API Documentation: https://docs.ckan.org/en/latest/api/
- Pydantic Documentation: https://pydantic-docs.helpmanual.io/
- Pytest Documentation: https://docs.pytest.org/
- Be respectful and inclusive
- Use clear communication in issues and PRs
- Help others when you can
- Follow the code of conduct
- Ask questions if you're unsure about something
Thank you for contributing to POP API! 🎉