Skip to content

Commit e5569a2

Browse files
authored
DP-498: Log Prediction URLs (#446)
* Logs prediction URLs after prediction creation if the environment variable `R8_LOG_PREDICTION_URL` is set to `1` https://linear.app/replicate/issue/DP-498/log-prediction-urls-in-terminal-for-easier-access-during-local
1 parent 974dd7f commit e5569a2

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

replicate/use.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,12 @@ def _resolve_ref(obj: Any) -> Any:
210210
return result
211211

212212

213+
def _log_prediction_url(id: str) -> None:
214+
if os.environ.get("R8_LOG_PREDICTION_URL") != "1":
215+
return
216+
print(f"Running prediction https://replicate.com/p/{id}")
217+
218+
213219
T = TypeVar("T")
214220

215221

@@ -436,6 +442,8 @@ def create(self, *_: Input.args, **inputs: Input.kwargs) -> Run[Output]:
436442
model=self._model, input=processed_inputs
437443
)
438444

445+
_log_prediction_url(prediction.id)
446+
439447
return Run(
440448
prediction=prediction,
441449
schema=self.openapi_schema(),
@@ -649,6 +657,8 @@ async def create(self, *_: Input.args, **inputs: Input.kwargs) -> AsyncRun[Outpu
649657
model=model, input=processed_inputs
650658
)
651659

660+
_log_prediction_url(prediction.id)
661+
652662
return AsyncRun(
653663
prediction=prediction,
654664
schema=await self.openapi_schema(),

0 commit comments

Comments
 (0)