-
Notifications
You must be signed in to change notification settings - Fork 222
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
Replace requests with httpx #147
Merged
Merged
Conversation
This file contains 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
mattt
force-pushed
the
mattt/httpx
branch
3 times, most recently
from
August 28, 2023 12:00
a38f687
to
e0a3db6
Compare
mattt
force-pushed
the
mattt/httpx
branch
3 times, most recently
from
September 5, 2023 12:41
15a5748
to
6f34ca4
Compare
Closed
Signed-off-by: Mattt Zmuda <mattt@replicate.com>
Signed-off-by: Mattt Zmuda <mattt@replicate.com>
Signed-off-by: Mattt Zmuda <mattt@replicate.com>
Signed-off-by: Mattt Zmuda <mattt@replicate.com>
Signed-off-by: Mattt Zmuda <mattt@replicate.com>
Signed-off-by: Mattt Zmuda <mattt@replicate.com> Add respx dependency Signed-off-by: Mattt Zmuda <mattt@replicate.com>
Signed-off-by: Mattt Zmuda <mattt@replicate.com>
Signed-off-by: Mattt Zmuda <mattt@replicate.com>
Signed-off-by: Mattt Zmuda <mattt@replicate.com>
This was referenced Oct 3, 2023
Closed
mattt
added a commit
that referenced
this pull request
Oct 9, 2023
#147 changed some logic in how the underlying networking client is initialized. Some clients that set the `REPLICATE_API_TOKEN` environment variable after importing the `replicate` package relied on that behavior, and are now getting authentication errors (#169) This PR restores some of the original behavior by lazily instantiating the underlying client until the first request is made. This should resolve the regression observed by users who were modifying the environment after import. --------- Signed-off-by: Mattt Zmuda <mattt@replicate.com>
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.
This PR updates our networking stack to use HTTPX, which has several benefits over requests, including support for Python
async
/await
and for using VCR recordings instead of mocking for tests.HTTPX is mostly a drop-in replacement for requests, but one thing that was missing was support for retryable requests. This PR implements a custom transport adapted from this issue thread. Unlike our current retry behavior, this version retries only on HTTP status codes 429, 503, and 504. This seems more correct to me than retrying for 429 + 5XX, but is worth calling out as a potentially breaking change.