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

Adjust Trainings#async_create signature #409

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
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
16 changes: 12 additions & 4 deletions replicate/training.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,9 @@ def create( # type: ignore

async def async_create(
self,
model: Union[str, Tuple[str, str], "Model"],
version: Union[str, Version],
input: Dict[str, Any],
model: Optional[Union[str, Tuple[str, str], "Model"]] = None,
version: Optional[Union[str, Version]] = None,
input: Optional[Dict[str, Any]] = None,
**params: Unpack["Trainings.CreateTrainingParams"],
) -> Training:
"""
Expand All @@ -326,7 +326,15 @@ async def async_create(
The training object.
"""

url = _create_training_url_from_model_and_version(model, version)
url = None

if model and version:
url = _create_training_url_from_model_and_version(model, version)
elif model is None and isinstance(version, str):
url = _create_training_url_from_shorthand(version)

if not url:
raise ValueError("model and version or shorthand version must be specified")

file_encoding_strategy = params.pop("file_encoding_strategy", None)
if input is not None:
Expand Down