replicate.run fails with wrong error when missing apikey
DoryZi opened this issue · 2 comments
DoryZi commented
When I run the following code the api returns in correct Replicate.exceptions.ReplicateError: The specified version does not exist (or perhaps you don't have permission to use it masking the real error:
- The error should be fixed, might be the version of httpx
- The real error should not be masked but passed up.
output = replicate.run(
"meta/codellama-13b:01d17250ffa554142c31e96e7dc0e4d313d62006e15684062c84d2eadb13bf11",
input={"prompt": "an astronaut riding a rainbow unicorn"}
)
The api returns an incorrect error message: r_eplicate.exceptions.ReplicateError: The specified version does not exist (or perhaps you don't have permission to use it?)_
Exception has occurred: ReplicateError (note: full exception trace is shown but execution is paused at: _run_module_as_main)
The specified version does not exist (or perhaps you don't have permission to use it?)
File "/home/dory/withmartion/adapters/.venv/lib/python3.11/site-packages/replicate/client.py", line 73, in _request
raise ReplicateError(resp.json()["detail"])
File "/home/dory/withmartion/adapters/.venv/lib/python3.11/site-packages/replicate/prediction.py", line 210, in create
resp = self._client._request(
^^^^^^^^^^^^^^^^^^^^^^
File "/home/dory/withmartion/adapters/.venv/lib/python3.11/site-packages/replicate/client.py", line 116, in run
prediction = self.predictions.create(version=version_id, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/dory/withmartion/adapters/main.py", line 21, in <module>
output = replicate.run(
^^^^^^^^^^^^^^
File "/usr/lib/python3.11/runpy.py", line 88, in _run_code
exec(code, run_globals)
File "/usr/lib/python3.11/runpy.py", line 198, in _run_module_as_main (Current frame)
return _run_code(code, main_globals, None,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
replicate.exceptions.ReplicateError: The specified version does not exist (or perhaps you don't have permission to use it?)
Debugging the replicate code it seems that the error is different:
The real error is a 422 returned from api:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/dory/withmartion/adapters/.venv/lib/python3.11/site-packages/httpx/_models.py", line 574, in text
content = self.content
^^^^^^^^^^^^
File "/home/dory/withmartion/adapters/.venv/lib/python3.11/site-packages/httpx/_models.py", line 568, in content
raise ResponseNotRead()
httpx.ResponseNotRead: Attempted to access streaming response content, without having called `read()`.d error: