Contributing

NVIDIA FLARE is developed on GitHub at NVIDIA/NVFlare under the Apache 2.0 license. This page summarizes the development setup, test and lint tooling, documentation build, and pull request rules from the repository's CONTRIBUTING.md and runtest.sh.

Before You Start

  • External contributors must open an issue first. Pull requests from people without write, maintain, or admin access must reference an existing issue in NVIDIA/NVFlare that describes the problem or improvement and predates the PR. PRs without one are not accepted.
  • Opening a draft PR (or a [WIP] title) early is encouraged.
  • Every commit needs a DCO sign-off (git commit -s) and a verified GPG signature: the repository enforces GitHub commit signature verification.
git commit -s -S -m "Fix scheduling of resource-less jobs"

Development Setup

git clone https://github.com/NVIDIA/NVFlare.git
cd NVFlare
python3 -m venv .venv
source .venv/bin/activate
./runtest.sh -p          # install development dependencies only

runtest.sh installs the project in editable mode with the dev extra (dev_mac on macOS; dev_cpu plus CPU-only PyTorch wheels with --torch-backend=cpu on Linux), using uv when it is available. Style-only commands install the lighter test_support extra.

runtest.sh

./runtest.sh              # default: license check, style check, style FIX, unit tests with coverage
./runtest.sh -f           # fix formatting with black and isort
./runtest.sh -u           # unit tests only
./runtest.sh -u -c        # unit tests with coverage
./runtest.sh -u tests/unit_test/fuel   # a subset (target defaults to tests/unit_test)

Note: Running ./runtest.sh with no flags also runs the formatter (black and isort) in fix mode after the checks, so it can rewrite files in your working tree. Commit or stash first if you only want a report, or use -s.

Flag Description
-h Help.
-l Check license headers.
-s Check style (black, isort, flake8).
-f Fix style in place (black, isort).
-u Run unit tests.
-n Run notebook tests.
-r With -u: write a JUnit report (unit_test.xml).
-c With -u: coverage reports (cov_html/, cov.xml).
-p Install dependencies only.
--numprocesses N Parallel test workers (default 8).
--torch-backend=cpu Install CPU-only PyTorch.
--skip-install Use the current environment as-is.
-v Verbose.
-d Dry run: print commands without running them.
--clean Remove build and cache artifacts.

Code Style

  • Linting: flake8 with plugins, black, and isort; line length 120.
  • Every source file starts with the Apache 2.0 license header:
# Copyright (c) 2024, NVIDIA CORPORATION.  All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

Tests

Unit tests live under tests/unit_test/ and follow the [module_name]_test.py naming pattern. New code should come with tests, and the full suite must pass locally before you open the PR. Integration tests are under tests/integration_test.

Building the Documentation

The official docs are Sphinx sources under docs/. Use a separate environment so training dependencies are not disturbed:

python3.10 -m venv .venv-docs
source .venv-docs/bin/activate
./build_doc.sh --html               # full build, including the API reference
./build_doc.sh --html --skip-api    # quick preview of narrative pages
./build_doc.sh --clean

Open docs/_build/index.html to read the result. Production dependency pins are in docs/constraints.txt.

Pull Request Checklist

  1. Branch from the latest main in your fork.
  2. Make the change with clear commit messages, signed off and GPG-signed.
  3. Add or update tests; run ./runtest.sh.
  4. Open the PR against main, explaining what changes, why, and how it was validated (include commands and results, and say what could not be verified).
  5. Make sure CI passes. Do not add [skip ci] markers: they suppress required checks and block the PR. Documentation-only changes are detected automatically and get lighter checks.
  6. Respond to every review comment; all conversations must be resolved before merge.

The PR description should scale with the change: root cause and regression test for a bug fix; motivation, design, alternatives, and risks for a feature; paper references, experiment setup, results, and a runnable example for an algorithm.

See Also