[2.8] Add clean_up parameter to recipe Run.get_result()#4550
Conversation
Greptile SummaryThis PR backports
Confidence Score: 5/5The change is safe to merge; it only threads a new boolean through an existing call site, preserves the default behavior, and is covered by a thorough unit test. The implementation is a one-line change with no branching, no state mutation beyond the forwarded argument, and a new test that validates all relevant post-call invariants. No existing tests need updating and backward compatibility is guaranteed by the No files require special attention. Important Files Changed
Sequence DiagramsequenceDiagram
participant Caller
participant Run
participant ExecEnv
Caller->>Run: get_result(timeout, clean_up)
Run->>Run: acquire _lock
alt already stopped
Run-->>Caller: _cached_result
else first call
Run->>ExecEnv: get_job_result(job_id, timeout)
ExecEnv-->>Run: result / exception
Run->>ExecEnv: get_job_status(job_id)
ExecEnv-->>Run: status / exception
Run->>ExecEnv: "stop(clean_up=clean_up)"
Note over ExecEnv: clean_up=True removes workspace<br/>clean_up=False keeps workspace
ExecEnv-->>Run: ok / exception
Run->>Run: "_stopped = True (finally)"
Run-->>Caller: result
end
Reviews (4): Last reviewed commit: "Merge branch '2.8' into codex/backport-r..." | Re-trigger Greptile |
There was a problem hiding this comment.
Pull request overview
This PR backports a small API enhancement to the recipe Run wrapper to let callers decide whether the execution-environment workspace is removed when collecting results, enabling post-run log/workspace inspection for debugging while preserving current behavior by default.
Changes:
- Added
cleanup: bool = Trueparameter toRun.get_result()and forwarded it toexec_env.stop(clean_up=cleanup). - Updated
Run.get_result()docstring to describe the cleanup behavior and debugging use case. - Added a unit test to cover the
cleanup=Falsepropagation path.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
nvflare/recipe/run.py |
Extends Run.get_result() with a cleanup flag and forwards it into ExecEnv.stop(). |
tests/unit_test/recipe/run_test.py |
Adds a unit test ensuring cleanup=False maps to clean_up=False on exec_env.stop(). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
e92af2a to
a5d3a79
Compare
|
/build |
Summary
2.8branch, adjusted per review to use the existingclean_upspelling.clean_up: bool = Trueparameter toRun.get_result()and forwards it toexec_env.stop(clean_up=clean_up)instead of hard-coding cleanup.run.get_result(clean_up=False)for debugging and log inspection.clean_up=Falsepropagation path, including result and cached-state assertions.Testing
git diff --checkpython3 -m py_compile nvflare/recipe/run.py tests/unit_test/recipe/run_test.py