Thank you for your interest in contributing to Harmonia! This document provides guidelines and instructions for contributing to the project.
By participating in this project, you agree to abide by the OHDSI Code of Conduct.
- Node.js 18+ and npm 9+
- Git
- Basic understanding of TypeScript and federated learning concepts
- Familiarity with OMOP CDM (helpful but not required)
-
Fork the repository on GitHub
-
Clone your fork:
git clone https://github.com/YOUR_USERNAME/Harmonia.git cd Harmonia -
Add upstream remote:
git remote add upstream https://github.com/OHDSI/Harmonia.git
-
Install dependencies:
npm install
-
Build all packages:
npm run build
-
Run tests:
npm test
Always create a new branch for your work:
git checkout -b feature/your-feature-name
# or
git checkout -b fix/issue-number-description
# or
git checkout -b docs/documentation-updateBranch naming conventions:
feature/- New featuresfix/- Bug fixesdocs/- Documentation updatesrefactor/- Code refactoringtest/- Test additions or updateschore/- Maintenance tasks
- Write clear, commented code
- Follow the existing code style
- Add tests for new functionality
- Update documentation as needed
- Keep commits focused and atomic
IMPORTANT: Run this before every commit and push:
# Run all quality checks at once (recommended)
npm run validateThis runs all checks in sequence:
- Lint (ESLint)
- Format check (Prettier)
- Type check (TypeScript)
- All tests
Or run individual checks:
# Format code
npm run format
# Lint code
npm run lint
# Type check
npm run typecheck
# Run tests
npm test** All checks must pass before pushing to remote.**
Write clear, descriptive commit messages:
git add .
git commit -m "feat: add differential privacy module
- Implement Gaussian mechanism for DP
- Add privacy budget tracking
- Include comprehensive unit tests
"Commit message format:
feat:- New featurefix:- Bug fixdocs:- Documentation changestest:- Adding or updating testsrefactor:- Code refactoringchore:- Maintenance tasks
git push origin feature/your-feature-nameThen create a Pull Request on GitHub with:
- Clear title describing the change
- Detailed description of what and why
- Reference to related issues (if any)
- Screenshots (if UI changes)
All new features should include tests:
// packages/core/src/__tests__/fedavg.test.ts
import { aggregateWeights } from '../horizontal/fedavg';
describe('FedAvg Algorithm', () => {
it('should aggregate weights correctly', () => {
const updates = [
{ siteId: 'A', weights: mockWeights1, sampleCount: 100 },
{ siteId: 'B', weights: mockWeights2, sampleCount: 200 },
];
const result = aggregateWeights(updates, {
minParticipants: 2,
totalRounds: 10,
aggregationStrategy: 'weighted',
});
expect(result).toBeDefined();
// Add more assertions
});
});# Run all tests
npm test
# Run tests for specific package
npm test --workspace=@harmonia/core
# Run tests in watch mode
npm test -- --watch
# Run tests with coverage
npm test -- --coverage-
Create package directory:
mkdir -p packages/new-package/src
-
Create
package.json:{ "name": "@harmonia/new-package", "version": "0.1.0", "description": "Description", "main": "dist/index.js", "types": "dist/index.d.ts" } -
Create
tsconfig.json:{ "extends": "../../tsconfig.json", "compilerOptions": { "outDir": "./dist", "rootDir": "./src" } } -
Update root
package.jsonworkspaces if needed
- Use workspace dependencies for internal packages:
"@harmonia/core": "^0.1.0" - Pin external dependencies to specific versions
- Keep dependencies minimal
DO NOT open public GitHub issues for security vulnerabilities.
Instead, email: security@ohdsi.org
- Never commit credentials or secrets
- Validate all user inputs
- Use parameterized queries for database access
- Follow OWASP guidelines for web security
- Keep dependencies updated
Use JSDoc comments for all public APIs:
/**
* Aggregate client updates using weighted averaging
*
* @param updates - Array of client updates to aggregate
* @param config - Federated averaging configuration
* @returns Aggregated model weights
* @throws {Error} If insufficient participants
*
* @example
* ```typescript
* const aggregated = aggregateWeights(updates, {
* minParticipants: 3,
* totalRounds: 10,
* aggregationStrategy: 'weighted'
* });
* ```
*/
export function aggregateWeights(updates: ClientUpdate[], config: FedAvgConfig): SerializedWeights {
// Implementation
}When adding new features:
- Update relevant README files
- Add examples
- Update API documentation
- Add to changelog
- Check existing issues
- Verify it's reproducible
- Test on latest version
**Describe the bug**
A clear description of the bug.
**To Reproduce**
Steps to reproduce:
1. Go to '...'
2. Click on '...'
3. See error
**Expected behavior**
What you expected to happen.
**Environment:**
- OS: [e.g., Ubuntu 22.04]
- Node.js version: [e.g., 18.17.0]
- Harmonia version: [e.g., 0.1.0]
**Additional context**
Any other relevant information.**Is your feature request related to a problem?**
Clear description of the problem.
**Describe the solution you'd like**
What you want to happen.
**Describe alternatives you've considered**
Other solutions considered.
**Additional context**
Any other relevant information.Look for issues labeled good first issue - these are great starting points for new contributors!
- OHDSI Forums: https://forums.ohdsi.org
- GitHub Discussions: For design discussions
- GitHub Issues: For bugs and features
- Email: harmonia@ohdsi.org
By contributing to Harmonia, you agree that your contributions will be licensed under the Apache License 2.0.
All contributors will be recognized in:
- GitHub contributors page
- CHANGELOG.md
- Project documentation
- Academic publications (for significant contributions)
If you have questions:
- Check existing documentation
- Search GitHub issues
- Ask in OHDSI forums
- Email: harmonia@ohdsi.org
Thank you for contributing to Harmonia!