Skip to content

Commit 9736fb0

Browse files
authored
Add type annotation to Prediction and Training status fields (#209)
Signed-off-by: Mattt Zmuda <[email protected]>
1 parent 9bfa08a commit 9736fb0

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

replicate/prediction.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import re
22
import time
33
from dataclasses import dataclass
4-
from typing import TYPE_CHECKING, Any, Dict, Iterator, List, Optional, Union
4+
from typing import TYPE_CHECKING, Any, Dict, Iterator, List, Literal, Optional, Union
55

66
from typing_extensions import NotRequired, TypedDict, Unpack
77

@@ -37,7 +37,7 @@ class Prediction(Resource):
3737
version: str
3838
"""An identifier for the version of the model used to create the prediction."""
3939

40-
status: str
40+
status: Literal["starting", "processing", "succeeded", "failed", "canceled"]
4141
"""The status of the prediction."""
4242

4343
input: Optional[Dict[str, Any]]

replicate/training.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
Any,
44
Dict,
55
List,
6+
Literal,
67
Optional,
78
Tuple,
89
TypedDict,
@@ -48,7 +49,7 @@ class Training(Resource):
4849
destination: Optional[str]
4950
"""The model destination of the training."""
5051

51-
status: str
52+
status: Literal["starting", "processing", "succeeded", "failed", "canceled"]
5253
"""The status of the training."""
5354

5455
input: Optional[Dict[str, Any]]

tests/test_run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def prediction_with_status(status: str) -> dict:
121121
router.route(method="POST", path="/predictions").mock(
122122
return_value=httpx.Response(
123123
201,
124-
json=prediction_with_status("running"),
124+
json=prediction_with_status("processing"),
125125
)
126126
)
127127
router.route(method="GET", path="/predictions/p1").mock(

0 commit comments

Comments
 (0)