-
Notifications
You must be signed in to change notification settings - Fork 11
Introduce Abstract Base Class (ABC) interface #22
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
Merged
jaleman-vdr-wikimedia
merged 13 commits into
wikimedia-enterprise:main
from
jaleman-vdr-wikimedia:main
Nov 11, 2025
Merged
Introduce Abstract Base Class (ABC) interface #22
jaleman-vdr-wikimedia
merged 13 commits into
wikimedia-enterprise:main
from
jaleman-vdr-wikimedia:main
Nov 11, 2025
Conversation
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
Updated the file to instead fetch latest versions of packages
- Refactored api_client to use Abstract base classes - Re-wrote tests (integration and regular suite) to accommodate said refactor - Re-wrote examples to accommodate refactor, and showcase new method of working with SDK - Fixed a few KeyErrors on a couple data models that the refactor brought to light
Update requirements
Update requirements
This commit aims to fix dependency conflicts due to a new starlette version, released a week ago.
KMontalva-WMF
requested changes
Nov 7, 2025
This commit contains small clean ups done to reflect feedback received on currently open PR.
KMontalva-WMF
approved these changes
Nov 10, 2025
| json_data = json.load(file) | ||
| year, electoral_vote, running_mate, nominee = extract_json_data(json_data) | ||
|
|
||
| # electoral_vote is a set of integers in a string separated by spaces, parse it into a list of integers |
Contributor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to clarify: I'm not opposed to explanatory comments in the code, my comment was about one in particular that seemed only useful in the context of this review, namely # This now returns a List[StructuredContent]
62f5a25
into
wikimedia-enterprise:main
1 check passed
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.
Updated the file to instead fetch latest versions of packages
Refactored api_client to use Abstract base classes
Re-wrote tests (integration and regular suite) to accommodate said refactor
Re-wrote examples to accommodate refactor, and showcase new method of working with SDK
Fixed a few KeyErrors on a couple data models that the refactor brought to light
Below, is the README portion for the new changes implemented on the refactor:
Key Features
Automatic Retries
The client handles network request failures automatically using a built-in
httpxtransport.How it works:
When you initialize the Client, you can specify the max_retries parameter.
By default, this is set to 3 retries.
The client will automatically retry requests that fail with a 5xx server error or a network connection error.
Usage:
To change the number of retries, just pass the parameter during initialization.
Built-in Rate Limiting
To prevent 429 Too Many Request errors, the client includes a configurable, client-side rate limiter. This ensures you don't send requests faster than the API allows.
How it works:
You can specify the rate_limit_per_second parameter.
time.sleep()between requests to ensure the average number of requests per second does not exceed this limit.Usage:
To limit the client to a maximum of 10 requests per second:
The
APIAbstract Base ClassThe
Clientclass implements a formal interface defined in theAPIabstract class. This "contract" defines all the public methods of the client (e.g.,get_projects,download_snapshot, etc.).The benefit of this is type-hinting, allowing you to code against the API interface:
Stoppable Callbacks
For all streaming methods (stream_articles) and large data file methods (read_snapshot, read_batch, read_all), we can control the processing loop.
How it works
All callback functions you provide are expected to return a boolean value.
Return True to continue processing the stream or file.
Return False to stop processing immediately.
The client will check the return value of your callback after every single item (every article in a stream, every line in a file). As soon as it receives
False, it will break the loop and close the stream.Usage
This is useful to to limit processing to a specific number of items.
Example: Obtains 5 articles and then stops
Python