Skip to content

Update astro web page example#4284

Open
nvkevlu wants to merge 4 commits intoNVIDIA:mainfrom
nvkevlu:update_web_page_example
Open

Update astro web page example#4284
nvkevlu wants to merge 4 commits intoNVIDIA:mainfrom
nvkevlu:update_web_page_example

Conversation

@nvkevlu
Copy link
Collaborator

@nvkevlu nvkevlu commented Mar 10, 2026

Update astro web page example to use the latest Recipe API.

Description

Update astro web page example to use the latest Recipe API.

Types of changes

  • Non-breaking change (fix or new feature that would not break existing functionality).
  • Breaking change (fix or new feature that would cause existing functionality to change).
  • New tests added to cover the changes.
  • Quick tests passed locally by running ./runtest.sh.
  • In-line docstrings updated.
  • Documentation updated.

Copilot AI review requested due to automatic review settings March 10, 2026 21:00
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 10, 2026

Greptile Summary

This PR updates the NVFlare Astro web page to align the "Getting Started" and "Series" examples with the new Recipe API (FedAvgRecipe) and the reorganised examples/hello-world/hello-pt directory, replacing the older examples/getting_started/pt path and the BaseFedJob + ModelController pattern.

Key changes:

  • PyTorch client code updated to use SimpleNetwork (from a separate model.py) and the new FedAvgRecipe/SimEnv job API; argparse is added for --epochs/--batch_size, and pre/post-training evaluation now uses flare.is_evaluate().
  • "Server" tab renamed to "Model" — for PyTorch it now shows model.py; for Lightning/TF, legacy server content is routed into the same model-wrapper element (acknowledged in an HTML comment, but the tab label remains "Model" for all frameworks).
  • TensorFlow Colab button is correctly hidden when no TF notebook exists (colab_link: ""), resolving the previously flagged PyTorch-notebook misdirection.
  • Video walkthrough section is commented out, with a note that the Flare 2.5.0 videos are now out of date.
  • Series cards for "Hello FedAvg" now link to examples/hello-world/hello-pt instead of examples/hello-world/hello-fedavg/README.md; card titles should be verified to set user expectations correctly if hello-fedavg still exists.

Confidence Score: 4/5

  • Safe to merge — changes are documentation/UI only with no runtime logic beyond the web page itself; the critical TF Colab link issue from the previous review has been addressed.
  • All changes are confined to Astro component template strings (example code snippets and links). No backend or SDK logic is modified. The previous TF Colab misdirection bug is fixed. Minor UX concerns remain around the "Model" tab label for Lightning/TF and the "Hello FedAvg" card pointing to hello-pt rather than a dedicated hello-fedavg page, but neither is a correctness regression.
  • web/src/components/code.astro — review the "Model" tab label behaviour for Lightning and TensorFlow frameworks (legacy server content shown under a "Model" label).

Important Files Changed

Filename Overview
web/src/components/code.astro Major update replacing old getting_started/pt examples with the new Recipe API (hello-world/hello-pt); renames "Server" tab to "Model"; correctly hides the TF Colab button when no notebook is available; both sectionMap["server"] and sectionMap["model"] now point to model-wrapper, which is intentional but causes the "Model" tab label to appear for legacy TF/Lightning server content.
web/src/components/gettingStarted.astro Step 2 updated from "Server Code" to "Job (Recipe)" with updated link; video section commented out since Flare 2.5.0 videos are now out of date; Step 2 video field set to empty string (no functional impact since the block is commented out); clean and straightforward changes.
web/src/components/series.astro "Getting Started" link updated from examples/getting_started to examples/hello-world; both "Hello FedAvg" card entries now redirect to examples/hello-world/hello-pt instead of the old hello-fedavg/README.md, which may surprise users expecting a dedicated hello-fedavg page.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[User visits web page] --> B{Select Framework}
    B -->|PyTorch| C[Show PT sections]
    B -->|Lightning| D[Show Lightning sections]
    B -->|TensorFlow| E[Show TF sections]

    C --> C1[Install tab]
    C --> C2[Client tab\nclient.py]
    C --> C3[Model tab\nmodel.py]
    C --> C4[Job tab\nFedAvgRecipe / job.py]
    C --> C5[Run tab\npython job.py]
    C --> C6[Colab button visible\nhello-pt.ipynb]
    C --> C7[GitHub button\nhello-pt.ipynb]

    D --> D1[Install / Client / Server tabs]
    D --> D2[Model tab shows legacy\nserver/workflow code]
    D --> D3[Colab button visible\nhello_lightning.ipynb]

    E --> E1[Install / Client / Server tabs]
    E --> E2[Model tab shows legacy\nserver/workflow code]
    E --> E3[Colab button HIDDEN\nno TF notebook available]
    E --> E4[GitHub button\nhello-tf tree]
Loading

Comments Outside Diff (2)

  1. web/src/components/code.astro, line 511-513 (link)

    "Model" tab label shown for Lightning/TF legacy server content

    Both sectionMap["model"] and sectionMap["server"] now point to document.getElementById('model-wrapper'), and the visible tab button is unconditionally labelled "Model" for all frameworks. For PyTorch this is correct, but Lightning and TensorFlow still carry type: "server" sections (unchanged), so users on those frameworks will see a tab titled "Model" that actually renders legacy ModelController/workflow server code. The HTML comment in the wrapper acknowledges this (Recipe: model.py; legacy server content for Lightning/TF), but the UX mismatch could confuse users.

    Consider dynamically relabelling the tab based on the active framework (e.g., keeping "Server" for Lightning/TF, using "Model" only for PyTorch), or adding a short explanatory subtitle inside the wrapper for legacy frameworks.

  2. web/src/components/series.astro, line 185-190 (link)

    "Hello FedAvg" card redirects to hello-pt, not hello-fedavg

    Both "Hello FedAvg (Recipe)" entries (100-series line ~190 and 200-series line ~684) now link to examples/hello-world/hello-pt rather than the previous dedicated examples/hello-world/hello-fedavg/README.md. If the hello-fedavg directory still exists in the repo alongside hello-pt, users clicking the card may land somewhere unexpected. If hello-fedavg is being intentionally retired in favour of hello-pt, a brief rename of the card title (e.g. "Hello PT (FedAvg Recipe)") would make the destination clearer.

    This same redirect applies at series.astro:684 in the 200-series section.

Last reviewed commit: b92beb0

id: "tensorflow",
colab_link: `https://colab.research.google.com/github/NVIDIA/NVFlare/blob/${gh_branch}/examples/getting_started/tf/nvflare_tf_getting_started.ipynb`,
github_link: `https://github.com/NVIDIA/NVFlare/blob/${gh_branch}/examples/getting_started/tf/nvflare_tf_getting_started.ipynb`,
colab_link: `https://colab.research.google.com/github/NVIDIA/NVFlare/blob/${gh_branch}/examples/hello-world/hello-pt/hello-pt.ipynb`,
Copy link
Contributor

Choose a reason for hiding this comment

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

TensorFlow Colab link points to PyTorch notebook

The colab_link for the TensorFlow framework was updated to examples/hello-world/hello-pt/hello-pt.ipynb, which is the PyTorch notebook. This appears to be a copy-paste error — users selecting the TensorFlow tab and clicking "Open in Google Colab" will land in a PyTorch notebook. The github_link was correctly set to examples/hello-world/hello-tf, but the Colab link needs a corresponding TF notebook path.

Suggested change
colab_link: `https://colab.research.google.com/github/NVIDIA/NVFlare/blob/${gh_branch}/examples/hello-world/hello-pt/hello-pt.ipynb`,
colab_link: `https://colab.research.google.com/github/NVIDIA/NVFlare/blob/${gh_branch}/examples/hello-world/hello-tf/hello_tf.ipynb`,

If a TF-specific Colab notebook doesn't exist yet at that path, the link should at minimum point to the TF tree (/tree/…) or be removed until the notebook is available, rather than silently redirecting to the PT notebook.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the Astro-based website examples to reference NVFlare’s newer Recipe API and the hello-world example set, so the web walkthrough and example links better match the current recommended workflow.

Changes:

  • Update “Getting Started” and series cards to point to examples/hello-world and Recipe-based FedAvg content.
  • Replace the PyTorch “server” code block with a Recipe-oriented “model + job” presentation and update Colab/GitHub links accordingly.
  • Adjust UI tab labeling from “Server” to “Model” in the example code component.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
web/src/components/series.astro Updates series descriptions/links to hello-world + Recipe-based FedAvg.
web/src/components/gettingStarted.astro Updates walkthrough step titles/descriptions and source links to Recipe-based hello-pt example.
web/src/components/code.astro Refactors displayed example code/links toward Recipe API and renames “Server” tab to “Model”.
Comments suppressed due to low confidence (2)

web/src/components/code.astro:708

  • Lightning code sections are still describing/showing legacy "server" + BaseFedJob-style file names (e.g., cifar10_lightning_fl.py, fedavg.py), but the framework links now point to the hello-lightning Recipe API notebook. Align the displayed Lightning code snippets/titles with examples/hello-world/hello-lightning (client.py, model.py, job.py) so the page content matches the linked source.
    colab_link: `https://colab.research.google.com/github/NVIDIA/NVFlare/blob/${gh_branch}/examples/hello-world/hello-lightning/hello_lightning.ipynb`,
    github_link: `https://github.com/NVIDIA/NVFlare/blob/${gh_branch}/examples/hello-world/hello-lightning/hello_lightning.ipynb`,
    sections: [
      {
        id: "install-lightning",
        type: "install",
        framework: "lightning",
        title: "Installation",
        description:
          "Install the required PyTorch Lightning dependencies for this example.",
        code: installCode_lt,
      },
      {
        id: "client-lightning",
        type: "client",
        framework: "lightning",
        title: "Client Code (cifar10_lightning_fl.py)",
        description:
          "We use the Client API to convert the centralized training PyTorch Lightning code into federated learning code with only a few lines of changes highlighted below. Essentially the client will receive a model from NVIDIA FLARE, perform local training and validation, and then send the model back.",
        code: clientCode_lt,
        highlighted_lines: "97,116,118,123",
      },
      {
        id: "server-lightning",
        type: "server",
        framework: "lightning",
        title: "Server Code (fedavg.py)",
        description:
          "The ModelController API is used to write a federated routine with mechanisms for distributing and receiving models from clients. Here we implement the basic FedAvg algorithm using some helper functions from BaseFedAvg..",
        code: serverCode_lt,

web/src/components/code.astro:772

  • TensorFlow framework now links to examples/hello-world/hello-tf, but the displayed TensorFlow code sections still show the older BaseFedJob/ModelController-based scripts (cifar10_tf_fl.py, fedavg_cifar10_tf_job.py, etc.). Update the TensorFlow snippets/titles to match hello-tf’s Recipe API files (client.py, model.py, job.py) so users don’t see code that doesn’t correspond to the linked example.
    colab_link: `https://colab.research.google.com/github/NVIDIA/NVFlare/blob/${gh_branch}/examples/hello-world/hello-pt/hello-pt.ipynb`,
    github_link: `https://github.com/NVIDIA/NVFlare/tree/${gh_branch}/examples/hello-world/hello-tf`,
    sections: [
      {
        id: "install-tensorflow",
        type: "install",
        framework: "tensorflow",
        title: "Installation",
        description:
          "Install the required TensorFlow dependencies for this example.",
        code: installCode_tf,
      },
      {
        id: "client-tensorflow",
        type: "client",
        framework: "tensorflow",
        title: "Client Code (cifar10_tf_fl.py)",
        description:
          "We use the Client API to convert the centralized training TensorFlow code into federated learning code with only a few lines of changes highlighted below. Essentially the client will receive a model from NVIDIA FLARE, perform local training and validation, and then send the model back.",
        code: clientCode_tf,
        highlighted_lines: "31,46,49,50,78-81,83",
      },
      {
        id: "server-tensorflow",
        type: "server",
        framework: "tensorflow",
        title: "Server Code (fedavg.py)",
        description:
          "The ModelController API is used to write a federated routine with mechanisms for distributing and receiving models from clients. Here we implement the basic FedAvg algorithm using some helper functions from BaseFedAvg..",
        code: serverCode_tf,
        highlighted_lines: "7,17,23",
      },
      {
        id: "job-tensorflow",
        type: "job",
        framework: "tensorflow",
        title: "Job Code (fedavg_cifar10_tf_job.py)",
        description:
          "Lastly we construct the job with our 'cifar10_tf_fl.py' client script and 'FedAvg' server controller. The BaseFedJob automatically configures components for model persistence, model selection, and TensorBoard streaming. We then run the job with the FL simulator.",
        code: jobCode_tf,

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@nvkevlu
Copy link
Collaborator Author

nvkevlu commented Mar 11, 2026

/build

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