fix: Fix ClientSnapshot overload calculation#1228
Merged
Conversation
…he absolute error count
This reverts commit 07cdfe1.
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes the ClientSnapshot overload calculation by introducing a new field, new_error_count, and updating the overload logic accordingly. Key changes include updating the snapshot creation logic in the autoscaling module, modifying unit tests to reflect the new overload rule, and updating type definitions for ClientSnapshot.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| tests/unit/_autoscaling/test_system_status.py | Updated tests to initialize ClientSnapshot with a new error count and overload logic. |
| tests/unit/_autoscaling/test_snapshotter.py | Added tests to validate the new overload behavior on client snapshots. |
| src/crawlee/_autoscaling/snapshotter.py | Modified snapshot creation to compute new_error_count based on previous data. |
| src/crawlee/_autoscaling/_types.py | Extended the ClientSnapshot type with the new_error_count attribute and updated overload logic. |
Comments suppressed due to low confidence (2)
src/crawlee/_autoscaling/snapshotter.py:316
- Consider ensuring that new_error_count is non-negative, for example by using max(error_count - previous_error_count, 0), to handle cases where the error count might unexpectedly decrease.
new_error_count=error_count - previous_error_count,
tests/unit/_autoscaling/test_system_status.py:205
- [nitpick] Consider clarifying the inline comment about the overloaded snapshot ratio to better reflect how snapshots are selected and how the ratio is computed.
# Ratio of overloaded snapshots is 2/3 (2 minutes out of 3)
Collaborator
Author
|
(This change aligns with JS implementation.) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Add
new_error_countto theClientSnapshot. Calculate overload based on the new error count instead of the absolute error count.Issues