Skip to content

Feat/async map op - #37

Merged
GregoryKogan merged 2 commits into
devfrom
feat/async-map-op
Jul 23, 2026
Merged

Feat/async map op#37
GregoryKogan merged 2 commits into
devfrom
feat/async-map-op

Conversation

@GregoryKogan

@GregoryKogan GregoryKogan commented Jul 23, 2026

Copy link
Copy Markdown
Owner

Summary by Sourcery

Add optional asynchronous mode to the YT map operation helper while updating lint configuration.

New Features:

  • Allow run_map to submit a YT map operation without waiting by adding a sync flag that returns the Operation when async mode is used.

Enhancements:

  • Extend run_map return type and documentation to reflect the new asynchronous behavior option.

Build:

  • Update pyproject.toml lint configuration to exempt the map command operation module from high-arity function warnings.

Tests:

  • Add a test verifying that run_map with sync=False returns the submitted Operation and does not wait for completion.

Когановский Григорий Игоревич added 2 commits July 23, 2026 15:13
…ission

- Updated the `run_map` function to include a `sync` parameter, allowing users to choose between waiting for operation completion or returning the operation object immediately.
- Revised the function's docstring to clarify the behavior based on the `sync` parameter, improving usability and documentation accuracy.
- Ensured backward compatibility by maintaining the original behavior when `sync` is set to True.
@GregoryKogan GregoryKogan self-assigned this Jul 23, 2026
@sourcery-ai

sourcery-ai Bot commented Jul 23, 2026

Copy link
Copy Markdown

Reviewer's Guide

Add an optional asynchronous mode to run_map that returns the YT Operation without waiting, and update tests and lint configuration accordingly.

Sequence diagram for async mode in run_map

sequenceDiagram
    actor Client
    participant run_map
    participant yt_client

    Client->>run_map: run_map(sync)
    alt [sync=True]
        run_map->>yt_client: wait_for_operation(operation)
        yt_client-->>run_map: success
        run_map-->>Client: bool
    else [sync=False]
        run_map-->>Client: Operation
    end
Loading

File-Level Changes

Change Details Files
Add async-style behavior to run_map via a sync flag and updated return type/docs.
  • Extend run_map signature with keyword-only sync: bool = True and adjust return type to bool
Operation.
  • Update run_map docstring to describe sync behavior and Operation return when not waiting.
  • Import Operation from yt.wrapper to type the asynchronous return value.
  • Short-circuit run_map to return the submitted operation immediately when sync is False, skipping wait_for_operation.
  • Add test coverage for non-sync behavior of run_map.
    • Create a new test that calls run_map with sync=False and asserts it returns the submitted operation.
    • Verify in the new test that wait_for_operation is not called when sync=False.
    tests/test_map.py
    Suppress PLR0913 lint rule for the high-arity run_map function.
    • Add yt_framework/operations/command_ops/map.py to the PLR0913 ignore list in the lint configuration.
    pyproject.toml

    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

    @sourcery-ai sourcery-ai Bot left a comment

    Copy link
    Copy Markdown

    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:

    • Returning bool | Operation from run_map based on the sync flag can make call sites harder to reason about; consider either splitting this into two functions or returning a single consistent type (e.g., always Operation and letting callers decide whether to wait).
    • The new async path bypasses wait_for_operation, so any logging/metrics or error handling tied to completion will be skipped; if those are important, consider providing a helper or callback mechanism for tracking async operation completion outside this function.
    Prompt for AI Agents
    Please address the comments from this code review:
    
    ## Overall Comments
    - Returning `bool | Operation` from `run_map` based on the `sync` flag can make call sites harder to reason about; consider either splitting this into two functions or returning a single consistent type (e.g., always `Operation` and letting callers decide whether to wait).
    - The new async path bypasses `wait_for_operation`, so any logging/metrics or error handling tied to completion will be skipped; if those are important, consider providing a helper or callback mechanism for tracking async operation completion outside this function.

    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.

    @GregoryKogan
    GregoryKogan merged commit 01ea744 into dev Jul 23, 2026
    8 checks passed
    @GregoryKogan
    GregoryKogan deleted the feat/async-map-op branch July 23, 2026 12:29
    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