Skip to content

[2.8] Add clean_up parameter to recipe Run.get_result()#4550

Merged
YuanTingHsieh merged 3 commits intoNVIDIA:2.8from
YuanTingHsieh:codex/backport-run-get-result-cleanup-2.8
May 8, 2026
Merged

[2.8] Add clean_up parameter to recipe Run.get_result()#4550
YuanTingHsieh merged 3 commits intoNVIDIA:2.8from
YuanTingHsieh:codex/backport-run-get-result-cleanup-2.8

Conversation

@YuanTingHsieh
Copy link
Copy Markdown
Collaborator

@YuanTingHsieh YuanTingHsieh commented May 7, 2026

Summary

  • Backport of Add cleanup parameter to recipe Run.get_result() (default True) #4541 to the 2.8 branch, adjusted per review to use the existing clean_up spelling.
  • Adds a clean_up: bool = True parameter to Run.get_result() and forwards it to exec_env.stop(clean_up=clean_up) instead of hard-coding cleanup.
  • Preserves existing behavior by default while allowing callers to keep the workspace with run.get_result(clean_up=False) for debugging and log inspection.
  • Adds unit coverage for the clean_up=False propagation path, including result and cached-state assertions.

Testing

  • git diff --check
  • python3 -m py_compile nvflare/recipe/run.py tests/unit_test/recipe/run_test.py

Copilot AI review requested due to automatic review settings May 7, 2026 21:22
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 7, 2026

Greptile Summary

This PR backports #4541 to the 2.8 branch, adding a clean_up: bool = True parameter to Run.get_result() and threading it through to exec_env.stop(clean_up=clean_up). Existing behavior is fully preserved by default; callers may now pass clean_up=False to retain the workspace for post-run log inspection.

  • nvflare/recipe/run.py: Single-line change replacing the hard-coded clean_up=True with the caller-supplied value; docstring updated to document the new parameter and its effect on the returned path.
  • tests/unit_test/recipe/run_test.py: New test test_get_result_clean_up_false_forwards_to_exec_env_stop verifies that clean_up=False is correctly forwarded to exec_env.stop() and that _stopped, _cached_status, and _cached_result are all set as expected.

Confidence Score: 5/5

The 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 True default.

No files require special attention.

Important Files Changed

Filename Overview
nvflare/recipe/run.py Adds clean_up: bool = True to get_result() and forwards it to exec_env.stop(); docstring accurately reflects the semantics including the note that the returned path may be removed when clean_up=True.
tests/unit_test/recipe/run_test.py New test fully covers the clean_up=False propagation path, asserting return value, stop call args, _stopped, _cached_status, and _cached_result; parity with the existing test_get_result_waits_caches_and_stops test.

Sequence Diagram

sequenceDiagram
    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
Loading

Reviews (4): Last reviewed commit: "Merge branch '2.8' into codex/backport-r..." | Re-trigger Greptile

Comment thread tests/unit_test/recipe/run_test.py Outdated
Copy link
Copy Markdown
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

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 = True parameter to Run.get_result() and forwarded it to exec_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=False propagation 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.

Comment thread nvflare/recipe/run.py Outdated
Comment thread nvflare/recipe/run.py
Comment thread tests/unit_test/recipe/run_test.py Outdated
Comment thread nvflare/recipe/run.py Outdated
@YuanTingHsieh YuanTingHsieh force-pushed the codex/backport-run-get-result-cleanup-2.8 branch from e92af2a to a5d3a79 Compare May 8, 2026 19:36
@YuanTingHsieh YuanTingHsieh changed the title [2.8] Add cleanup parameter to recipe Run.get_result() [2.8] Add clean_up parameter to recipe Run.get_result() May 8, 2026
@YuanTingHsieh
Copy link
Copy Markdown
Collaborator Author

/build

@YuanTingHsieh YuanTingHsieh merged commit ac7d6e0 into NVIDIA:2.8 May 8, 2026
25 checks passed
@YuanTingHsieh YuanTingHsieh deleted the codex/backport-run-get-result-cleanup-2.8 branch May 8, 2026 21:16
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