Skip to content

Commit 7d06286

Browse files
authored
Fix Pydantic validation errors for Training responses (#90)
* Relax Training version type constraint to be Optional Signed-off-by: Mattt Zmuda <[email protected]> * Delete version field from JSON response in trainnings.get Signed-off-by: Mattt Zmuda <[email protected]> * Remove version field from trainings.create response Signed-off-by: Mattt Zmuda <[email protected]> --------- Signed-off-by: Mattt Zmuda <[email protected]>
1 parent 298e2ab commit 7d06286

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

replicate/training.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from replicate.exceptions import ReplicateException
77
from replicate.files import upload_file
88
from replicate.json import encode_json
9+
from replicate.version import Version
910

1011

1112
class Training(BaseModel):
@@ -19,7 +20,7 @@ class Training(BaseModel):
1920
output: Optional[Any]
2021
started_at: Optional[str]
2122
status: str
22-
version: str
23+
version: Optional[Version]
2324

2425
def cancel(self) -> None:
2526
"""Cancel a running training"""
@@ -44,6 +45,8 @@ def get(self, id: str) -> Training:
4445
f"/v1/trainings/{id}",
4546
)
4647
obj = resp.json()
48+
# HACK: resolve this? make it lazy somehow?
49+
del obj["version"]
4750
return self.prepare_model(obj)
4851

4952
def create( # type: ignore
@@ -83,4 +86,5 @@ def create( # type: ignore
8386
json=body,
8487
)
8588
obj = resp.json()
89+
del obj["version"]
8690
return self.prepare_model(obj)

0 commit comments

Comments
 (0)