Skip to content

Commit deb92e0

Browse files
committed
Fix urllib3 DeprecationWarning about using 'method_whitelist' with Retry
Signed-off-by: Mattt Zmuda <mattt@replicate.com>
1 parent 793868c commit deb92e0

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

replicate/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def __init__(self, api_token: Optional[str] = None) -> None:
3030
total=5,
3131
backoff_factor=2,
3232
# Only retry 500s on GET so we don't unintionally mutute data
33-
method_whitelist=["GET"],
33+
allowed_methods=["GET"],
3434
# https://support.cloudflare.com/hc/en-us/articles/115003011431-Troubleshooting-Cloudflare-5XX-errors
3535
status_forcelist=[
3636
429,
@@ -54,7 +54,7 @@ def __init__(self, api_token: Optional[str] = None) -> None:
5454
write_retries = Retry(
5555
total=5,
5656
backoff_factor=2,
57-
method_whitelist=["POST", "PUT"],
57+
allowed_methods=["POST", "PUT"],
5858
# Only retry POST/PUT requests on rate limits, so we don't unintionally mutute data
5959
status_forcelist=[429],
6060
)

replicate/model.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,8 @@ def create(self, **kwargs) -> Model:
3636
raise NotImplementedError()
3737

3838
def prepare_model(self, attrs: Union[Model, Dict]) -> Model:
39-
attrs["id"] = f"{attrs['username']}/{attrs['name']}"
39+
if isinstance(attrs, BaseModel):
40+
attrs.id = f"{attrs.username}/{attrs.name}"
41+
elif isinstance(attrs, dict):
42+
attrs["id"] = f"{attrs['username']}/{attrs['name']}"
4043
return super().prepare_model(attrs)

0 commit comments

Comments
 (0)