Skip to content

Make Recipe job storage private#4903

Merged
YuanTingHsieh merged 7 commits into
NVIDIA:mainfrom
nvkevlu:codex/recipe-private-job
Jul 16, 2026
Merged

Make Recipe job storage private#4903
YuanTingHsieh merged 7 commits into
NVIDIA:mainfrom
nvkevlu:codex/recipe-private-job

Conversation

@nvkevlu

@nvkevlu nvkevlu commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator

Makes Recipe job storage private.

Description

Follow-up to #4873, which migrated public examples and documentation away from direct recipe.job access.

This PR completes the cleanup by making the generated FedJob an internal Recipe implementation detail:

  • Renames Recipe.job to Recipe._job.
  • Updates Recipe internals, utilities, framework-specific recipes, and tests.
  • Removes temporary public self.job assignments from XGBoost recipes.
  • Updates integration paths to use public Recipe APIs where appropriate.
  • Adds coverage confirming that Recipe no longer exposes a public job attribute.
  • Rewords errors so they do not direct users toward generated-job internals.

No recipe.job references remain in the repository. No runtime behavior changes are intended; users should customize recipes through the supported Recipe APIs.

Testing

  • Recipe-focused unit tests: 510 passed, 23 skipped
  • Recipe utility tests: 96 passed
  • Multi-study ProdEnv integration: passed
  • Per-site export regression test: passed
  • Server- and client-side MLflow simulations: 2 passed
  • ./runtest.sh --skip-install -s: passed

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 July 14, 2026 20:16

Copilot AI left a comment

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.

Pull request overview

This PR completes the internal cleanup started in #4873 by making the generated FedJob an internal implementation detail of Recipe (renaming Recipe.job to Recipe._job) and updating internal callers/tests so customization flows through supported Recipe APIs rather than direct job access.

Changes:

  • Rename Recipe’s stored job from job to _job and update Recipe internals/utilities accordingly.
  • Update framework-specific recipes (e.g., XGBoost, sklearn, edge) and extensive unit/integration tests to use _job internally.
  • Add/adjust tests to confirm Recipe no longer exposes a public job attribute and update error messaging to avoid directing users to internals.

Reviewed changes

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

Show a summary per file
File Description
tests/unit_test/recipe/utils_test.py Updates recipe/job access and error expectations to _job.
tests/unit_test/recipe/swarm_recipe_test.py Switches assertions and job map access to _job.
tests/unit_test/recipe/spec_test.py Adds coverage asserting Recipe has _job and no public job; updates internal accesses.
tests/unit_test/recipe/server_memory_gc_rounds_test.py Uses _job to inspect server controller config.
tests/unit_test/recipe/scaffold_recipe_test.py Updates deploy map access and assertions to _job.
tests/unit_test/recipe/numpy_lr_recipe_test.py Updates job assertions to _job.
tests/unit_test/recipe/flower_recipe_test.py Updates expected internal job storage to _job.
tests/unit_test/recipe/fedstats_recipe_test.py Updates expected internal job storage to _job.
tests/unit_test/recipe/fedopt_recipe_test.py Updates job assertions/deploy map access to _job.
tests/unit_test/recipe/fedavg_recipe_test.py Updates helpers and assertions to use _job deploy map/component ids.
tests/unit_test/recipe/fed_task_recipe_test.py Updates deploy map/export usage to _job.
tests/unit_test/recipe/eval_recipe_test.py Updates job assertions to _job.
tests/unit_test/recipe/edge_recipe_test.py Updates job assertions and helper calls to _job.
tests/unit_test/recipe/cyclic_recipe_test.py Updates deploy map access and assertions to _job.
tests/unit_test/app_opt/xgboost/xgboost_recipe_test.py Updates deploy map access to _job.
tests/unit_test/app_opt/sklearn/sklearn_recipe_test.py Updates job assertions to _job.
tests/unit_test/app_opt/pt/recipes/fed_eval_recipe_test.py Updates job assertions/name checks to _job.
tests/integration_test/tools/export_recipe_job.py Updates integration export helper to avoid recipe.job and rely on Recipe/internal storage.
tests/integration_test/slow/experiment_tracking_recipes_test.py Updates file attachment calls to _job.
tests/integration_test/fast/study_session_test.py Switches to recipe.execute(env) and reads job id from returned Run.
nvflare/recipe/utils.py Updates helpers/utilities to resolve the backing job via _job and adjusts error wording.
nvflare/recipe/spec.py Renames stored job to _job and updates all internal job interactions accordingly.
nvflare/edge/tools/edge_fed_buff_recipe.py Updates environment processing path to use _job.
nvflare/app_opt/xgboost/recipes/vertical.py Removes public self.job assignment; passes configured job into Recipe without exposing it.
nvflare/app_opt/xgboost/recipes/histogram.py Same as above for histogram recipe.
nvflare/app_opt/xgboost/recipes/bagging.py Same as above for bagging recipe.
nvflare/app_opt/sklearn/recipes/svm.py Updates server component wiring to use _job.
nvflare/app_opt/sklearn/recipes/kmeans.py Updates server component wiring to use _job.
nvflare/app_common/np/recipes/fedavg.py Updates deploy map inspection and client wiring to use _job.

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

Comment thread tests/integration_test/tools/export_recipe_job.py Outdated
Comment thread tests/integration_test/tools/export_recipe_job.py
Comment thread nvflare/edge/tools/edge_fed_buff_recipe.py Outdated
@nvkevlu
nvkevlu force-pushed the codex/recipe-private-job branch from da10a4b to 5201f8a Compare July 14, 2026 20:21
@greptile-apps

greptile-apps Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR makes generated Recipe jobs an internal implementation detail. The main changes are:

  • Replaces internal Recipe access from job to _job.
  • Sets the public Recipe name from the backing job.
  • Updates recipe utilities, framework recipes, and tests.
  • Adjusts the export helper to use Recipe APIs and captured execution arguments.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.

Important Files Changed

Filename Overview
tests/integration_test/tools/export_recipe_job.py Captures execute arguments and exports through Recipe.export() before copying src/ into the exported job.
nvflare/recipe/spec.py Stores the backing job privately and keeps Recipe.name aligned with the generated job name.
nvflare/recipe/utils.py Updates Recipe utility paths to use the private backing job and public Recipe metadata.
nvflare/app_common/np/recipes/fedavg.py Uses the Recipe client-app helper when adding the NumPy validation component.

Reviews (7): Last reviewed commit: "Preserve per-site apps when adding NumPy..." | Re-trigger Greptile

Comment thread tests/integration_test/tools/export_recipe_job.py
@codecov-commenter

codecov-commenter commented Jul 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.85106% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 61.79%. Comparing base (3b0c264) to head (38269b2).

Files with missing lines Patch % Lines
nvflare/recipe/spec.py 80.00% 4 Missing ⚠️
nvflare/edge/tools/edge_fed_buff_recipe.py 0.00% 3 Missing ⚠️
nvflare/recipe/utils.py 86.66% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4903      +/-   ##
==========================================
+ Coverage   61.77%   61.79%   +0.02%     
==========================================
  Files         985      985              
  Lines       95805    95771      -34     
==========================================
+ Hits        59182    59185       +3     
+ Misses      36623    36586      -37     
Flag Coverage Δ
unit-tests 61.79% <80.85%> (+0.02%) ⬆️

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.

@YuanTingHsieh YuanTingHsieh left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

One non-blocking design question.

Comment thread nvflare/app_common/np/recipes/fedavg.py Outdated

@YuanTingHsieh YuanTingHsieh left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

One blocking issue found on re-review.

Comment thread nvflare/app_common/np/recipes/fedavg.py Outdated
@YuanTingHsieh
YuanTingHsieh merged commit e0ac02b into NVIDIA:main Jul 16, 2026
18 checks passed
@nvkevlu
nvkevlu deleted the codex/recipe-private-job branch July 16, 2026 14:02
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.

4 participants