Skip to content

Conversation

@mattt
Copy link
Contributor

@mattt mattt commented Aug 28, 2023

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.

@mattt mattt force-pushed the mattt/httpx branch 3 times, most recently from a38f687 to e0a3db6 Compare August 28, 2023 12:00
@mattt mattt force-pushed the mattt/httpx branch 3 times, most recently from 15a5748 to 6f34ca4 Compare September 5, 2023 12:41
@mattt mattt marked this pull request as ready for review September 5, 2023 12:43
@mattt mattt requested a review from a team September 5, 2023 12:43
@mattt mattt mentioned this pull request Sep 28, 2023
mattt added 4 commits October 3, 2023 06:32
Signed-off-by: Mattt Zmuda <[email protected]>

Add respx dependency

Signed-off-by: Mattt Zmuda <[email protected]>
Signed-off-by: Mattt Zmuda <[email protected]>
Signed-off-by: Mattt Zmuda <[email protected]>
@mattt mattt merged commit b822285 into main Oct 3, 2023
@mattt mattt deleted the mattt/httpx branch October 3, 2023 13:37
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 <[email protected]>
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.

2 participants