Skip to content

Remove nvflare from example requirements.txt and install it first in the docs - #5541

Open
chesterxgchen wants to merge 5 commits into
NVIDIA:mainfrom
chesterxgchen:docs/requirements-without-nvflare
Open

chesterxgchen wants to merge 5 commits into
NVIDIA:mainfrom
chesterxgchen:docs/requirements-without-nvflare

Conversation

@chesterxgchen

Copy link
Copy Markdown
Collaborator

Description

Example requirements.txt files no longer name nvflare. nvflare examples get selects an example's source revision from the NVFlare distribution that is already installed (stable nvflare, nightly, or an editable checkout), so a requirements line such as nvflare~=2.7.2rc can replace or downgrade that distribution and leave the example out of step with it. Of the 81 requirements files that named nvflare, 58 pinned a release below 2.10. The integration tests already strip these lines (install_requirements.py --exclude nvflare, sed -i '/nvflare\|jupyter\|notebook/d'), so this also removes that workaround's reason to exist.

Because pip install -r requirements.txt no longer installs NVFlare, every document that installs those files now installs NVFlare first.

  • Requirements (79 files). Remove the nvflare line. Where an extra supplied packages, list them directly: torch and torchvision for PT (only the missing ones), tenseal with the same python_version markers as setup.cfg for HE. Five files that would be empty keep a one-line comment, because tests/integration_test/src/example.py requires an example to have a requirements.txt and pip install -r accepts a comment-only file.
  • Install step (about 70 places). Before each pip install -r <changed file> in a README, docs page or notebook, add a comment and pip install nvflare (or the matching %pip / !pip form). Notebooks keep the magic of the original cell. A script resolved each requirements path, including paths after cd, and a second check confirms an NVFlare install precedes every such line.
  • PT extra. The PyTorch example READMEs (hello-pt, hello-lightning, hello-huggingface, collab), their docs/hello-world mirror pages, examples_command.rst and hello_world.ipynb install NVFlare alone, since those examples' requirements already list torch and torchvision. Source-checkout paths that relied on the extra now install the example requirements too. The invalid nvflare[TF] line in hello_world.ipynb is gone.
  • Other consumers. The medical-devices Dockerfile installs NVFlare explicitly; the qwen3-vl README installs it before install_requirements.sh; the evo2 environment test expects the new file contents; the gnn, llm_hf and recipe-k8s READMEs no longer describe removing or pinning nvflare; hello-pt-mlflow's README now points at the parent requirements.txt that actually exists.

Not changed, on purpose: research/auto-fl-research (its requirements still name nvflare) and AGENTS.md, whose "Main Branch Versioning" rule about pinning the upcoming NVFlare version in example requirements no longer matches this pattern and should be updated separately. flower_job_structure.rst mentions nvflare~=2.9.0rc as a job's own requirement, which is a different mechanism. Related: #5328 (README and Quick Start).

Types of changes

  • Non-breaking change (fix or new feature that would not break existing functionality).
  • Documentation updated.

Testing

  • python -m pytest -o addopts= -q tests/unit_test/tool/examples tests/unit_test/examples — 372 passed, 7 skipped; examples/advanced/bionemo/evo2/tests/evo2_verify_environment_test.py — 5 passed.
  • All 31 modified notebooks pass nbformat validation; every one of the 393 remaining requirement lines parses with packaging; ci/check_relative_doc_links.py, ci/check_license_header.py and git diff --check pass.
  • Install-order check over all Markdown, RST and notebooks: 91 installs from changed requirements files, each with an earlier NVFlare install, except the two lines in the excluded auto-fl-research README.
  • pip install --dry-run -r on a comment-only requirements file succeeds.
  • A fresh-context review of the final diff reported two documentation gaps (the examples overview page and recipe-k8s's version notice), both fixed in the last commit, and no install-path breaks.

Not run: a live nvflare examples get plus install of any example, real package resolution (torch or tenseal wheels), executing any notebook, and the full runtest.sh suite.

Risk

Documentation and dependency files only; no runtime code changes. A reader who runs only pip install -r requirements.txt from an example no longer gets NVFlare, which the updated READMEs, docs pages and notebooks now state first. An example whose README was not updated here and whose environment lacks NVFlare would fail at import time. The PT-extra removal assumes each example's requirements.txt lists what its code imports; I checked torch and torchvision against the examples I changed.

How to revert

Revert the four commits. No configuration or saved state is affected.

🤖 Generated with Claude Code

chesterxgchen and others added 5 commits October 25, 2026 00:34
The PyTorch examples' requirements.txt already list torch and torchvision,
which is all the PT extra provides, so their READMEs and docs pages install
NVFlare alone and then the example's requirements. The source-checkout paths
that relied on the extra now install the example requirements too, and the
examples command page and hello_world notebook stop teaching framework extras.

Co-Authored-By: Claude Code <noreply@anthropic.com>
The notebooks' requirements.txt files no longer name nvflare, so each install
cell installs NVFlare first. The homomorphic-encryption chapter lists tenseal
directly instead of the nvflare[HE] extra.

Co-Authored-By: Claude Code <noreply@anthropic.com>
The research examples' requirements.txt files no longer name nvflare, so their
READMEs install NVFlare first. fed-ce lists the PyTorch packages that the PT
extra used to provide. research/auto-fl-research is not changed.

Co-Authored-By: Claude Code <noreply@anthropic.com>
Examples install NVFlare as stable, nightly or editable before their own
dependencies, so a requirements file that names nvflare can replace or
downgrade the distribution that nvflare examples get selected the example
from; most of these files pinned a release below 2.10. Remove the lines and
add the NVFlare install step to every README, docs page and notebook that
installs those files. Where an extra supplied packages, list them directly
(torch and torchvision for PT, tenseal for HE). Files left with no packages
keep a one-line comment, because the integration-test framework requires a
requirements.txt. The evo2 environment test, the medical-devices Dockerfile,
the qwen3-vl setup steps and two READMEs that pointed at a missing file are
updated to match. research/auto-fl-research and AGENTS.md are not changed.

Co-Authored-By: Claude Code <noreply@anthropic.com>
The examples overview page and the two amplify job READMEs install requirements
files that no longer name nvflare, and the recipe-k8s notice still described a
pinned requirement.

Co-Authored-By: Claude Code <noreply@anthropic.com>
@greptile-apps

greptile-apps Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] The change reaches setup workflows across many examples and learning materials.

Enforce the documented minimum NVFlare versions before merging so existing older installations cannot pass setup.

Findings

  1. P1 Older installations pass setup ▶
  2. P2 Setup stops before installation ▶
  3. P2 Requirements path assumes another directory ▶

Summary

Separates NVFlare installation from example dependencies across examples, tutorials, and research projects.

  • Example setup installs NVFlare separately from example packages.

Acknowledged exclusions:

  • chesterxgchen explicitly deferred updating the AGENTS.md version-pinning rule.
  • chesterxgchen intentionally left research/auto-fl-research unchanged and retained the separate job-requirement example in flower_job_structure.rst.

Reviews (1) · Last reviewed commit: "docs: finish the NVFlare install step in..." · Reviewed by Greptile


```bash
# Stable release; use nvflare-nightly for a nightly build, or `-e .` for this checkout
python3 -m pip install nvflare

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Older installations pass setup

If a reader already has NVFlare 2.8 installed, pip install nvflare leaves it unchanged. With the version constraint also removed from requirements.txt, setup succeeds but job.py cannot import the required 2.9 APIs. Use pip install "nvflare>=2.9" for the stable path while keeping the nightly and editable alternatives. The same issue appears in research/fed-ce/README.md.

Comment on lines +39 to +40
"# Install NVFlare first (use nvflare-nightly or an editable install if you work with those)\n",
"! pip install nvflare\n",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Setup stops before installation

The new NVFlare install runs after import nvflare in the same cell. In a fresh notebook environment, that import raises ModuleNotFoundError and stops the cell before installation. Move the install above the version checks so readers can use this added setup step.

python -m pip install -r requirements.txt
# Install NVFlare first (stable shown; use nvflare-nightly, or "pip install -e ." from a source checkout)
python -m pip install nvflare
python -m pip install -r ../requirements.txt

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Requirements path assumes another directory

The corrected ../requirements.txt path assumes the reader is already inside hello-pt-mlflow, but setup never tells them to enter that directory. The following sections instead show paths from the repository root. State the working directory here, or use the full repository-relative requirements path, so readers following setup from the root do not get a missing-file error.

Suggested change
python -m pip install -r ../requirements.txt
python -m pip install -r examples/advanced/experiment-tracking/mlflow/requirements.txt

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 71.66%. Comparing base (a0a3501) to head (756d34c).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5541      +/-   ##
==========================================
+ Coverage   71.65%   71.66%   +0.01%     
==========================================
  Files        1048     1048              
  Lines      112323   112323              
==========================================
+ Hits        80480    80492      +12     
+ Misses      31843    31831      -12     
Flag Coverage Δ
unit-tests 71.66% <ø> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants