Thank you for your interest in contributing to FedCast! This document provides guidelines and information for contributors to help make the contribution process smooth and effective.
- Code of Conduct
- Getting Started
- Development Setup
- Project Structure
- Contributing Guidelines
- Types of Contributions
- Development Workflow
- Testing
- Code Style and Standards
- Documentation
- Submitting Changes
- Release Process
This project follows the Apache License 2.0. By participating, you agree to uphold this code of conduct. Please report unacceptable behavior to the project maintainers.
- Python 3.9.2 to 3.13.2
- Poetry for dependency management
- Git for version control
-
Fork and Clone the Repository
git clone https://github.com/your-username/FedCast.git cd FedCast -
Install Dependencies
poetry install
-
Activate the Virtual Environment
poetry shell
-
Verify Installation
poetry run pytest
FedCast follows a modular architecture with clear separation of concerns:
fedcast/
├── cast_models/ # Model implementations (MLP, Linear, etc.)
├── datasets/ # Dataset loaders for various time series data
├── experiments/ # Experiment scripts and configurations
├── federated_learning_strategies/ # FL strategies (FedAvg, FedProx, etc.)
└── telemetry/ # MLflow logging and experiment tracking
tests/ # Test suite
├── test_dataset_*.py # Dataset-specific tests
├── test_fed*.py # Strategy-specific tests
└── test_datasets_general.py # General dataset tests
- Models (
fedcast/cast_models/): Neural network architectures for time series forecasting - Datasets (
fedcast/datasets/): Data loaders for various time series domains (ECG, stocks, weather, etc.) - Strategies (
fedcast/federated_learning_strategies/): Federated learning aggregation strategies - Experiments (
fedcast/experiments/): Experiment configurations and grid search scripts - Telemetry (
fedcast/telemetry/): MLflow integration for experiment tracking
We welcome several types of contributions:
- Bug Fixes: Fix issues in existing code
- New Features: Add new models, datasets, or strategies
- Documentation: Improve documentation, add examples, or tutorials
- Tests: Add or improve test coverage
- Performance: Optimize existing code
- Examples: Add new experiment examples
-
Create a Feature Branch
git checkout -b feature/your-feature-name
-
Make Your Changes
- Follow the coding standards (see below)
- Add tests for new functionality
- Update documentation as needed
-
Test Your Changes
poetry run pytest
-
Commit Your Changes
git add . git commit -m "Add: brief description of your changes"
-
Push and Create Pull Request
git push origin feature/your-feature-name
# Run all tests
poetry run pytest
# Run specific test file
poetry run pytest tests/test_dataset_stocks.py
# Run with verbose output
poetry run pytest -v
# Run with coverage
poetry run pytest --cov=fedcast- Follow the existing test patterns in the
tests/directory - Test both success and failure cases
- Use descriptive test names
- Aim for high test coverage for new features
- Dataset Tests: Test data loading, preprocessing, and client partitioning
- Strategy Tests: Test federated learning strategies and aggregation
- Model Tests: Test model initialization, training, and inference
- Integration Tests: Test end-to-end workflows
- Follow PEP 8 style guidelines
- Use type hints where appropriate
- Write docstrings for all public functions and classes
- Keep functions focused and reasonably sized
- Use Google-style docstrings
- Include examples in docstrings for complex functions
- Document all public APIs
- Keep README files up to date
def load_dataset(client_id: int, num_clients: int) -> Dataset:
"""Load dataset for a specific client in federated learning setup.
Args:
client_id: Unique identifier for the client (0 to num_clients-1)
num_clients: Total number of clients in the federation
Returns:
Dataset object containing client-specific data
Raises:
ValueError: If client_id is out of valid range
Example:
>>> dataset = load_dataset(client_id=0, num_clients=10)
>>> print(len(dataset))
1000
"""When adding a new dataset:
- Create a new file in
fedcast/datasets/ - Follow the existing dataset pattern:
- Implement
load_dataset(client_id, num_clients)function - Add proper docstrings and type hints
- Include data downloading and caching logic
- Add client partitioning logic
- Implement
- Add corresponding tests in
tests/ - Update the dataset registry if applicable
When adding a new model:
- Create a new file in
fedcast/cast_models/ - Inherit from appropriate base classes
- Implement required methods (forward, get_parameters, set_parameters)
- Add tests for the new model
- Update the model registry
When adding a new federated learning strategy:
- Create a new file in
fedcast/federated_learning_strategies/ - Follow Flower's strategy interface
- Implement aggregation logic
- Add comprehensive tests
- Consider adding to the grid experiment
-
Create a Pull Request
- Use a descriptive title
- Provide a detailed description of changes
- Reference any related issues
-
Pull Request Template
## Description Brief description of changes ## Type of Change - [ ] Bug fix - [ ] New feature - [ ] Documentation update - [ ] Test improvement - [ ] Performance optimization ## Testing - [ ] Tests pass locally - [ ] New tests added for new functionality - [ ] All existing tests still pass ## Checklist - [ ] Code follows project style guidelines - [ ] Self-review completed - [ ] Documentation updated - [ ] No breaking changes (or clearly documented)
-
Review Process
- Maintainers will review your PR
- Address any feedback promptly
- Keep PRs focused and reasonably sized
Use clear, descriptive commit messages:
Add: new ECG dataset loader with MIT-BIH support
Fix: handle edge case in FedProx aggregation
Update: improve documentation for model registry
We follow Semantic Versioning:
- MAJOR: Breaking changes
- MINOR: New features (backward compatible)
- PATCH: Bug fixes (backward compatible)
- All tests pass
- Documentation is up to date
- Version number updated in
pyproject.toml - CHANGELOG.md updated
- Release notes prepared
- Issues: Use GitHub issues for bug reports and feature requests
- Discussions: Use GitHub discussions for questions and general discussion
- Documentation: Check existing documentation and examples
Contributors will be recognized in:
- CONTRIBUTORS.md file
- Release notes
- Project documentation
Thank you for contributing to FedCast! Your contributions help make federated learning for time series forecasting more accessible and powerful.