Skip to content
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,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think version is optional, is it? It looks like we'll raise a ValueError if you don't pass it in every case.

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