replicate-python icon indicating copy to clipboard operation
replicate-python copied to clipboard

`replicate.run()` does not respect `wait=False`

Open zeke opened this issue 1 year ago • 1 comments

Client version: 1.0.4

This snippet blocks until the prediction is done:

import replicate

print("starting")
output = replicate.run(
    "tencent/hunyuan-video:6c9132aee14409cd6568d030453f1ba50f5f3412b844fe67f78a9eb62d55664f",
    input={"prompt": "A cat walks on the grass, realistic style"},
    wait=False
)
print(output.__dict__)
print("done")

I'm not really sure what the expected behavior should be here...

The current docs in the README say this:

The timeout can be configured by passing wait=x to replicate.run() where x is a timeout in seconds between 1 and 60. To disable the sync mode you can pass wait=False.

If you're disabling sync mode with replicate.run, where does that leave you? Async mode? What should it return?

cc @hbqdev

zeke avatar Feb 14 '25 00:02 zeke

replicate.run has always had a blocking interface at the SDK layer. To create a prediction and return the Prediction object before it completes you need to use the predictions.create() interfaces.

The wait param to run() just controls whether the client attempts to keep the HTTP connection open or uses polling. I can see how the name is confusing.

aron avatar Feb 17 '25 11:02 aron