Skip to content

Commit c9c4b8c

Browse files
committed
Revert "fix files uploading"
This reverts commit 0ec2897.
1 parent 0beb9ef commit c9c4b8c

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

src/replicate/lib/_files.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,9 @@ def encode_json(
5151
if file_encoding_strategy == "base64":
5252
return base64_encode_file(obj)
5353
else:
54-
response = client.files.create(content=obj.read())
55-
return response.urls.get
54+
# todo: support files endpoint
55+
# return client.files.create(obj).urls["get"]
56+
raise NotImplementedError("File upload is not supported yet")
5657
if HAS_NUMPY:
5758
if isinstance(obj, np.integer): # type: ignore
5859
return int(obj)
@@ -90,8 +91,9 @@ async def async_encode_json(
9091
# TODO: This should ideally use an async based file reader path.
9192
return base64_encode_file(obj)
9293
else:
93-
response = await client.files.create(content=obj.read())
94-
return response.urls.get
94+
# todo: support files endpoint
95+
# return (await client.files.async_create(obj)).urls["get"]
96+
raise NotImplementedError("File upload is not supported yet")
9597
if HAS_NUMPY:
9698
if isinstance(obj, np.integer): # type: ignore
9799
return int(obj)

src/replicate/lib/_predictions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,6 @@ def output_iterator(prediction: Prediction, client: Replicate) -> Iterator[Any]:
215215
if prediction.status == "failed":
216216
raise ModelError(prediction=prediction)
217217

218-
output = prediction.output or [] # type: ignore
218+
output: list[Any] = prediction.output or [] # type: ignore[union-attr]
219219
new_output = output[len(previous_output) :]
220220
yield from new_output

src/replicate/resources/files.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def create(
5858
self,
5959
*,
6060
content: FileTypes,
61-
filename: str | NotGiven = NOT_GIVEN,
61+
filename: str,
6262
metadata: object | NotGiven = NOT_GIVEN,
6363
type: str | NotGiven = NOT_GIVEN,
6464
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -336,7 +336,7 @@ async def create(
336336
self,
337337
*,
338338
content: FileTypes,
339-
filename: str | NotGiven = NOT_GIVEN,
339+
filename: str,
340340
metadata: object | NotGiven = NOT_GIVEN,
341341
type: str | NotGiven = NOT_GIVEN,
342342
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.

0 commit comments

Comments
 (0)