Skip to content

feat: return bool from the wait functions #267

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Conversation

michalsosn
Copy link
Contributor

@michalsosn michalsosn commented Jun 10, 2025

fixes PY-138

Summary by Sourcery

Convert wait functions to return a boolean success status and propagate failure conditions

Enhancements:

  • Change internal _wait and _wait_for_file_upload methods to return True on success and False on timeout, interruptions, or sync failures
  • Update public wait_for_submission and wait_for_processing methods to return the combined status of metadata operations and file uploads

Copy link

sourcery-ai bot commented Jun 10, 2025

Reviewer's Guide

This PR refactors the waiting logic in run.py to return boolean success flags instead of None, replacing internal loop breaks with explicit True/False returns and updating the public wait_for_submission, wait_for_processing, and _wait_for_file_upload methods to propagate and combine these statuses.

Sequence Diagram: wait_for_submission Return Logic

sequenceDiagram
    participant C as Caller
    participant R as Run
    C->>R: wait_for_submission(timeout, verbose)
    R->>R: _wait(phrase="submitted", ...)
    R-->>R: status_submitted (bool)
    R->>R: _wait_for_file_upload(timeout, verbose)
    R-->>R: status_files (bool)
    R-->>C: return status_submitted and status_files
Loading

Class Diagram: Updated Run Method Signatures

classDiagram
    class Run {
        -_wait(phrase str, sleep_time float, wait_seq OptionalSharedInt, timeout OptionalFloat, verbose bool) bool
        -_wait_for_file_upload(timeout OptionalFloat, verbose bool) bool
        +wait_for_submission(timeout OptionalFloat, verbose bool) bool
        +wait_for_processing(timeout OptionalFloat, verbose bool) bool
    }
Loading

File-Level Changes

Change Details Files
Convert internal _wait method to return a boolean status
  • Changed signature to return bool
  • Early return False on non-positive timeout
  • Replaced break points with return False for interruptions and timeouts
  • Return True upon successful completion and False on KeyboardInterrupt
src/neptune_scale/api/run.py
Update wait_for_submission and wait_for_processing to propagate wait statuses
  • Changed signatures to return bool
  • Captured boolean results of _wait and _wait_for_file_upload
  • Return logical AND of metadata and file upload statuses
src/neptune_scale/api/run.py
Refactor _wait_for_file_upload to return a boolean status
  • Changed signature to return bool
  • Early return False on non-positive timeout
  • Return False on sync interruption, timeout, or user interrupt
  • Return True when all files upload successfully
src/neptune_scale/api/run.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

linear bot commented Jun 10, 2025

@michalsosn michalsosn marked this pull request as ready for review June 10, 2025 14:12
@michalsosn michalsosn force-pushed the ms/bool-wait branch 5 times, most recently from 11f475c to 7b3b741 Compare June 11, 2025 18:34
@michalsosn michalsosn force-pushed the ms/bool-wait branch 4 times, most recently from b46b645 to f96f276 Compare June 12, 2025 04:13
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.

1 participant