Skip to content
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

Error when succesfully deleting model without version #356

Closed
detkov opened this issue Sep 23, 2024 · 3 comments · Fixed by #359
Closed

Error when succesfully deleting model without version #356

detkov opened this issue Sep 23, 2024 · 3 comments · Fixed by #359

Comments

@detkov
Copy link

detkov commented Sep 23, 2024

I had a model model without a version (it was there, but I deleted it):

>>> model
Model(url='https://replicate.com/xxx/yyy', owner='xxx', name='yyy', description=None, visibility='private', github_url=None, paper_url=None, license_url=None, run_count=75, cover_image_url=None, default_example=None, latest_version=None)

I tried to delete it and got the following error:

>>> replicate.models.delete(owner=model.owner, name=model.name)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/ubuntu/.cache/pypoetry/virtualenvs/studio-backend-p27wbUyn-py3.10/lib/python3.10/site-packages/replicate/model.py", line 302, in delete
    return _json_to_model(self._client, resp.json())
  File "/home/ubuntu/.cache/pypoetry/virtualenvs/studio-backend-p27wbUyn-py3.10/lib/python3.10/site-packages/httpx/_models.py", line 756, in json
    return jsonlib.loads(self.text, **kwargs)
  File "/opt/conda/lib/python3.10/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/opt/conda/lib/python3.10/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/opt/conda/lib/python3.10/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

However, when trying to get this model using, another error occurs, which means that the model was indeed deleted:

>>> model = replicate.models.get(owner=model.owner, name=model.name)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/ubuntu/.cache/pypoetry/virtualenvs/studio-backend-p27wbUyn-py3.10/lib/python3.10/site-packages/replicate/model.py", line 263, in get
    resp = self._client._request("GET", url)
  File "/home/ubuntu/.cache/pypoetry/virtualenvs/studio-backend-p27wbUyn-py3.10/lib/python3.10/site-packages/replicate/client.py", line 89, in _request
    _raise_for_status(resp)
  File "/home/ubuntu/.cache/pypoetry/virtualenvs/studio-backend-p27wbUyn-py3.10/lib/python3.10/site-packages/replicate/client.py", line 385, in _raise_for_status
    raise ReplicateError.from_response(resp)
replicate.exceptions.ReplicateError: ReplicateError Details:
status: 404
detail: No ModelRedirect matches the given query.

So it seems to me that the problem is somewhere in the replicate.models.delete response decoding.

replicate==0.33.0

@mattt
Copy link
Contributor

mattt commented Sep 25, 2024

Hi @detkov. Thanks for reporting. I believe this is a problem with the API, so I'll work with the team to get this fixed.

@mattt
Copy link
Contributor

mattt commented Sep 25, 2024

Following up — I just opened #359 to fix what we can on the client. I also filed a ticket internally to get the API to respond with something more helpful when a model isn't found ("No ModelRedirect matches the given query." is a red herring).

mattt added a commit that referenced this issue Sep 25, 2024
Resolves #356 

When deleting a model, Replicate's API returns with a 204 and an empty
response body. The client library fails to decode this and raises and
exception.

This PR updates the `replicate.models.delete` method to return `bool`
instead to indicate success. It also harmonizes the other delete methods
for deployments and files to do the same.

Signed-off-by: Mattt Zmuda <mattt@replicate.com>
@mattt
Copy link
Contributor

mattt commented Sep 25, 2024

This is now fixed in v0.34.1.

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 a pull request may close this issue.

2 participants