Conversation
(NVIDIA#4011 and NVIDIA#4173 already on main; only 4168 changes applied.)
There was a problem hiding this comment.
Pull request overview
This PR is a cherry-pick from PR #4168 to main, enhancing the hello-numpy-cross-val example with improved client-side error handling and fail-fast behavior for cross-site evaluation workflows.
Changes:
- Added comprehensive unit tests for the hello-numpy-cross-val client script with mock-based testing approach
- Enhanced
base_model_controller.pyto conditionally set fl_context properties only when not already present - Refactored hello-numpy-cross-val client with explicit task type handling (train/evaluate/submit_model) and fail-fast error checking
Reviewed changes
Copilot reviewed 1 out of 1 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| tests/unit_test/recipe/hello_numpy_cross_val_client_test.py | New comprehensive unit tests for client helper functions and fail-fast behavior using pytest and mock objects |
| nvflare/app_common/workflows/base_model_controller.py | Modified set_fl_context to only set CURRENT_ROUND and NUM_ROUNDS when not already present, preventing overwrite of workflow-set values |
| examples/hello-world/hello-numpy-cross-val/client.py | Refactored to explicitly handle train/evaluate/submit_model tasks with proper error handling and fail-fast checks for missing parameters |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Greptile SummaryThis cherry-pick of #4181 to
Key points:
Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant WF as FedAvg / Workflow
participant BMC as BaseModelController
participant FLC as FLContext (self.fl_ctx)
participant FCM as FLContextManager (sticker store)
WF->>BMC: broadcast_model(data, round=N)
BMC->>BMC: set_fl_context(data)
alt data is None
BMC-->>BMC: early return
else data.current_round is not None
BMC->>FLC: set_prop(CURRENT_ROUND, N, private=True, sticky=True)
FLC->>FCM: update_sticker(CURRENT_ROUND, N, mask)
FCM-->>FLC: sticker updated
FLC-->>BMC: True (updated local props + sticker)
else data.current_round is None
BMC->>BMC: debug("no current_round in FLModel")
end
alt data.total_rounds is not None
BMC->>FLC: set_prop(NUM_ROUNDS, T, private=True, sticky=True)
FLC->>FCM: update_sticker(NUM_ROUNDS, T, mask)
FCM-->>FLC: sticker updated
end
BMC->>BMC: broadcast_and_wait(fl_ctx=self.fl_ctx)
Note over BMC,FLC: _process_result callback (per client response)
BMC->>FLC: self.fl_ctx = result_fl_ctx
BMC->>FLC: set_prop(CURRENT_ROUND, N, sticky=True) [from task header]
|
b18a8bb to
2cc7f1a
Compare
|
/build |
pcnudde
left a comment
There was a problem hiding this comment.
I'm a bit confused with the other PR into 2.7
|
The other PR into 2.7 was created to match this one, however, there were further comments from copilot that resulted in additional updates. This one actually needs to be further updated to match those changes to have the right behavior: get_prop_detail() + reuse existing (private, sticky) when updating, so the value is updated every round and set_prop() never fails or warns. |
|
/build |
Update to match fix in main in #4201 ### Description Updates nvflare/app_common/workflows/base_model_controller.py to match #4201 after further changes from greptile comments. ### Types of changes <!--- Put an `x` in all the boxes that apply, and remove the not applicable items --> - [x] 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. --------- Co-authored-by: Chester Chen <512707+chesterxgchen@users.noreply.github.com>
|
/build |
|
/build |
|
/build |
|
/build |
|
/build |
Update to match fix in main in NVIDIA#4201 Updates nvflare/app_common/workflows/base_model_controller.py to match <!--- Put an `x` in all the boxes that apply, and remove the not applicable items --> - [x] 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. --------- Co-authored-by: Chester Chen <512707+chesterxgchen@users.noreply.github.com>
Update to match fix in main in NVIDIA#4201 Updates nvflare/app_common/workflows/base_model_controller.py to match <!--- Put an `x` in all the boxes that apply, and remove the not applicable items --> - [x] 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. --------- Co-authored-by: Chester Chen <512707+chesterxgchen@users.noreply.github.com>
Update to match fix in main in NVIDIA#4201 Updates nvflare/app_common/workflows/base_model_controller.py to match <!--- Put an `x` in all the boxes that apply, and remove the not applicable items --> - [x] 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. --------- Co-authored-by: Chester Chen <512707+chesterxgchen@users.noreply.github.com>
Update to match fix in main in NVIDIA#4201 Updates nvflare/app_common/workflows/base_model_controller.py to match <!--- Put an `x` in all the boxes that apply, and remove the not applicable items --> - [x] 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. --------- Co-authored-by: Chester Chen <512707+chesterxgchen@users.noreply.github.com>
Update to match fix in main in NVIDIA#4201 ### Description Updates nvflare/app_common/workflows/base_model_controller.py to match NVIDIA#4201 after further changes from greptile comments. ### Types of changes <!--- Put an `x` in all the boxes that apply, and remove the not applicable items --> - [x] 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. --------- Co-authored-by: Chester Chen <512707+chesterxgchen@users.noreply.github.com>
Update to match fix in main in NVIDIA#4201 ### Description Updates nvflare/app_common/workflows/base_model_controller.py to match NVIDIA#4201 after further changes from greptile comments. ### Types of changes <!--- Put an `x` in all the boxes that apply, and remove the not applicable items --> - [x] 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. --------- Co-authored-by: Chester Chen <512707+chesterxgchen@users.noreply.github.com>
Cherry pick 4181 to main.
Description
Cherry pick 4181 to main.
Types of changes
./runtest.sh.