Skip to content

Better timeout options handling in wait started#451

Merged
aalexfvk merged 4 commits intoyandex:mainfrom
kirillgarbar:wait-started
Mar 17, 2026
Merged

Better timeout options handling in wait started#451
aalexfvk merged 4 commits intoyandex:mainfrom
kirillgarbar:wait-started

Conversation

@kirillgarbar
Copy link
Contributor

@kirillgarbar kirillgarbar commented Mar 2, 2026

Allows to use --timeout with default timeout strategy and handles the case when only max-timeout is passed and is lesser than default min_timeout

Summary by Sourcery

Adjust timeout handling for file-based wait strategy to better support default values and user-provided limits.

Enhancements:

  • Allow the file-based wait timeout strategy to accept the general wait timeout option in addition to its own parameters.
  • Improve computation of min and max timeouts when one or both values are omitted, ensuring sensible defaults and consistent bounds.

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Mar 2, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adjusts timeout handling for the 'wait started' file-based timeout strategy to support --timeout with the default strategy and to ensure sane defaults when only one of min/max timeout is provided.

Flow diagram for updated timeout calculation logic in get_timeout_by_files

flowchart TD
    A["Start get_timeout_by_files"] --> B["Set file_processing_speed to provided value or DEFAULT_FILE_PROCESSING_SPEED"]
    B --> C{"Is min_timeout None and max_timeout None?"}

    C -->|"Yes"| D["Set min_timeout to DEFAULT_MIN_TIMEOUT"]
    D --> E["Set max_timeout to DEFAULT_MAX_TIMEOUT"]

    C -->|"No"| F{"Is min_timeout None?"}
    F -->|"Yes"| G["Set min_timeout to min(DEFAULT_MIN_TIMEOUT, max_timeout)"]
    F -->|"No"| H{"Is max_timeout None?"}
    H -->|"Yes"| I["Set max_timeout to max(DEFAULT_MAX_TIMEOUT, min_timeout)"]
    H -->|"No"| J["Keep provided min_timeout and max_timeout"]

    E --> K["Compute file_processing_timeout as get_file_count() divided by file_processing_speed"]
    G --> K
    I --> K
    J --> K

    K --> L["Compute clamped_timeout as max(min_timeout, min(file_processing_timeout, max_timeout))"]
    L --> M["Return clamped_timeout"]
Loading

File-Level Changes

Change Details Files
Relax and extend CLI constraint validation for file-based timeout strategy to include the wait/timeout option.
  • Increase the maximum number of accepted options when timeout_strategy is 'files' to account for an additional parameter.
  • Include the wait/timeout option in the list of constrained parameters for the 'files' timeout strategy.
ch_tools/chadmin/cli/wait_group.py
Refine timeout derivation logic when using the file-based timeout strategy so that default min/max timeouts are applied consistently depending on which values are provided.
  • Use both default min and max timeouts only when neither is explicitly provided.
  • Derive min timeout from the lower of the default minimum and provided max timeout when only max timeout is specified.
  • Derive max timeout from the higher of the default maximum and provided min timeout when only min timeout is specified.
ch_tools/chadmin/cli/wait_group.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
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • In get_timeout_by_files, consider explicitly validating and raising a clear error when both min_timeout and max_timeout are provided but min_timeout > max_timeout, since the current clamp logic will silently return a value greater than the user-specified max_timeout.
  • The branching in get_timeout_by_files for deriving min_timeout/max_timeout from defaults and user input is becoming a bit dense; consider extracting this into a small helper or adding a short inline comment describing the intended precedence rules to make future maintenance easier.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `get_timeout_by_files`, consider explicitly validating and raising a clear error when both `min_timeout` and `max_timeout` are provided but `min_timeout > max_timeout`, since the current clamp logic will silently return a value greater than the user-specified `max_timeout`.
- The branching in `get_timeout_by_files` for deriving `min_timeout`/`max_timeout` from defaults and user input is becoming a bit dense; consider extracting this into a small helper or adding a short inline comment describing the intended precedence rules to make future maintenance easier.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@aalexfvk
Copy link
Contributor

Rebase pls

@aalexfvk aalexfvk merged commit a30388f into yandex:main Mar 17, 2026
14 checks passed
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.

2 participants