Skip to content

[Parity]: Add completion reason inference#71

Closed
ghost wants to merge 1 commit intomainfrom
unknown repository
Closed

[Parity]: Add completion reason inference#71
ghost wants to merge 1 commit intomainfrom
unknown repository

Conversation

@ghost
Copy link

@ghost ghost commented Oct 20, 2025

  • Adds completion reason inference based on the rules outlined in the
    typescript implementation / spec.

fixes: #36

items: Iterable[BatchItemStatus], completion_config: CompletionConfig | None = None
) -> CompletionReason:
"""
Infer completion reason based on batch item statuses and completion config.
Copy link
Contributor

Choose a reason for hiding this comment

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

instead of an arbitrary _helper func, maybe let it live in the BatchResult.from_items() instead, it's not getting used anywhere else.

Copy link
Author

Choose a reason for hiding this comment

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

I planned on using it with parallel and map for completion to ensure the logic remains identical and isolated 🤔

Copy link
Contributor

Choose a reason for hiding this comment

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

there actually already is a thread-safe Counters class in Concurrency, and some logic to calculate the result with that.

I have a suspicion that it might not be so easy to reuse that for this though - the logic is not necessarily exactly the same, but I haven't fully thought it through. tldr; might be that having this "special" case here with it's own reconstruction logic is leaner.

Copy link
Author

Choose a reason for hiding this comment

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

There's a bit of a difference between this and that, they are concerned with different stages, so it's best to keep this logic here, and when needed to construct BatchResult e.g. due to replay, to use the from_items function directly.

items: Iterable[BatchItem[R]],
completion_config: CompletionConfig | None = None,
):
items = list(items)
Copy link
Contributor

Choose a reason for hiding this comment

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

necessary?

- Adds completion reason inference based on the rules outlined in the
  typescript implementation / spec.

fixes: #36
@ghost ghost force-pushed the batch-completion-assumption branch 2 times, most recently from afe384b to fc0992a Compare October 21, 2025 20:37
@ghost ghost marked this pull request as ready for review October 21, 2025 20:50
@ghost ghost force-pushed the batch-completion-assumption branch from e7fd080 to fc0992a Compare October 21, 2025 21:14
@ghost ghost mentioned this pull request Oct 21, 2025
@ghost
Copy link
Author

ghost commented Oct 21, 2025

Closing as duplicate.

@ghost ghost closed this Oct 21, 2025
This pull request was closed.
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.

BatchResult CompletionReason Default Assumption

2 participants