replicate.run() should return the prediction object instead of the output url
matan3178 opened this issue · 7 comments
It should return the prediction object to be used (For example I want to extract the prediction ID in order to delete the prediction from replica's servers
And the cancel-prediction (deletion of prediction) should be added too to the library
Hi @matan3178. The run
method is shorthand for creating a prediction and waiting to get its results. You can use the predictions.create
method to return a reference to the original prediction object. Alternatively, you can find the prediction that corresponds to output returned from run
by using the predictions.list
method.
There is a predictions.cancel
method that operates on prediction objects returned by predictions.create
and other methods. That method cancels a prediction if it's not yet completed. However, it doesn't delete a prediction. For predictions created through the API, those are deleted automatically. From "How does Replicate work":
Input and output (including any files) are automatically deleted after an hour for any predictions created through the API, so you must save a copy of any files in the output if you'd like to continue using them. For more details on how to store prediction data, see the guide to webhooks.
Predictions created through the web interface are kept indefinitely, unless you delete them manually.
To manually delete a prediction on the website, go to your dashboard, find the prediction, and look for a "Delete" button on the prediction page. Clicking this button completely removes the prediction from the site, including any output data and output files associated with it.
Is there an option to delete a prediction via the API as I can do in the website?
For privacy issues, I cannot keep a media file in your servers more than 2 minutes, so waiting an hour is a problem for me.
Thank you!
@matan3178 I'm not aware of a user-facing API to control the deletion of prediction input data from Replicate's servers. However, one option would be to upload this data to a server you control, pass it as a URL to the prediction creation request, and then delete it after the prediction finishes.
I'm curious to know more about your requirements for not allowing media on external servers for more than 2 minutes. Could you please elaborate?
The scenario you described is exactly what I want to do, but automatically via the API, which unfortunately I can't.
This requirements came from my customer - I cannot leave their data in a 3rd party system more than 2 minutes.
Thanks for clarifying, @matan3178. I'll discuss with the rest of the team the possibility of creating a new endpoint for deleting predictions through the API.
In the meantime, the approach I described should allow you to use Replicate while satisfying the data retention requirements of your customer.
Thank you very much!