Skip to content

Add experimental replicate.use() function #438

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

Merged
merged 39 commits into from
Jun 9, 2025
Merged
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
e4398b9
Add initial test for `use()` functionality
aron Jun 2, 2025
587ed82
Add unit tests for existing `use()` functionality
aron Jun 2, 2025
70e1da7
Fix warning for missing pytest setting
aron Jun 2, 2025
607150f
Remove unused ignores
aron Jun 2, 2025
736604b
Refactor tests to be easier to work with
aron Jun 2, 2025
40c97a7
Support conversion of file outputs into Path in use()
aron Jun 2, 2025
196aef0
Add support for returning an iterator from use()
aron Jun 2, 2025
9a293e6
Fix bug in output_iterator when prediction is terminal
aron Jun 2, 2025
83d8fad
Update OutputIterator to use polling implementation
aron Jun 2, 2025
f017857
Ensure OutputIterator objects are converted into strings
aron Jun 2, 2025
35eb88b
Implement PathProxy as a way to defer download of file data
aron Jun 2, 2025
8d85629
Skip downloading files passed directly into other models in use()
aron Jun 2, 2025
20a37d1
Add get_url_path() helper to get underlying URL for a PathProxy object
aron Jun 2, 2025
bae5dc8
Export the `use` function
aron Jun 2, 2025
ae1589f
Document the `use()` functionality
aron Jun 2, 2025
82e40ce
Linting
aron Jun 2, 2025
bad0ce4
Rework the async test variant to give better test names
aron Jun 2, 2025
35e66dc
Fix typing of Function create()
aron Jun 2, 2025
639f234
Add support for typing use() function
aron Jun 3, 2025
65a89d3
Clean up tests
aron Jun 3, 2025
b79a5cd
Clean up prediction fixtures
aron Jun 3, 2025
80ce4e5
Remove redundant fixture data
aron Jun 3, 2025
bc5d7d8
Speed up test runs by using REPLICATE_POLL_INTERVAL
aron Jun 3, 2025
4111e82
Actually use PathProxy
aron Jun 3, 2025
e8acdb2
Use new URLPath instead of PathProxy
aron Jun 3, 2025
2df34ed
Silence warning when using cog.current_scope()
aron Jun 3, 2025
c982d53
Add asyncio support to `use()` function
aron Jun 4, 2025
050798e
Document asyncio mode for `use()`
aron Jun 4, 2025
a00b5d2
Improve typing of OutputIterator
aron Jun 4, 2025
83793a0
Correctly resolve OutputIterator when passed to `create()`
aron Jun 4, 2025
2afd364
URLPath.__str__() uses __fspath__()
aron Jun 4, 2025
dd64e91
Implement use(ref, streaming=True) to return iterators
aron Jun 4, 2025
cd12cf4
Correctly handle concatenated output when not streaming
aron Jun 4, 2025
1185b7b
Remove useless comments
aron Jun 4, 2025
f160fef
Implement `streaming` argument for `use()`
aron Jun 4, 2025
57bab3e
Fix lint errors
aron Jun 4, 2025
adb4fa7
Remove top-level restrictions
aron Jun 4, 2025
3b5200b
Clean up linting issues
aron Jun 6, 2025
3fb2024
Document `use()` API in README.md
aron Jun 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix typing of Function create()
  • Loading branch information
aron committed Jun 2, 2025
commit 35e66dc9bfe7fe0a3f3c275cabf70dbaf945840e
6 changes: 3 additions & 3 deletions replicate/use.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from dataclasses import dataclass
from functools import cached_property
from pathlib import Path
from typing import Any, Dict, Iterator, Optional, Tuple, Union
from typing import Any, Iterator, Optional, Tuple, Union
from urllib.parse import urlparse

import httpx
Expand Down Expand Up @@ -333,11 +333,11 @@ def _version(self) -> Version | None:

return version

def __call__(self, **inputs: Dict[str, Any]) -> Any:
def __call__(self, **inputs: Any) -> Any:
run = self.create(**inputs)
return run.output()

def create(self, **inputs: Dict[str, Any]) -> Run:
def create(self, **inputs: Any) -> Run:
"""
Start a prediction with the specified inputs.
"""
Expand Down