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

client.trainings.async_create() is broken

Open houmie opened this issue 11 months ago • 2 comments

As the README states, AsyncIO support works fine by prepending async_ to the method name.

I already do this across many functions, and it works perfectly. However, I discovered a bug when creating training asynchronously. It always fails with the error:

ReplicateError(type=None, title=None, status=404, detail='The requested resource could not be found.', instance=None)

See below:

            training = await self.client.trainings.async_create(
                model=model,
                destination=f"{model.owner}/{model.name}",
                version="ostris/flux-dev-lora-trainer:e440909d3512c31646ee2e0c7d6f6f4923224863a6a10c494606e79fb5844497",
                input={
                    "steps": 1000,
                    "batch_size": 1,
                    "autocaption": True,
                    "input_images": input_images_url, 
                    "trigger_word": internal_trigger_word,
                },
                webhook=webhook_url,
                webhook_events_filter=["completed"],
            )
            return training.id

As you can see, it is correct, but it’s somewhat odd as it requires the model to be passed along with the destination. This might create confusion internally. If you use this in sync mode instead, you’ll notice that the signature is different. As you can see, no model is passed here.

            training = self.client.trainings.create(
                version="ostris/flux-dev-lora-trainer:e440909d3512c31646ee2e0c7d6f6f4923224863a6a10c494606e79fb5844497",
                input={
                    "steps": 1000,
                    "batch_size": 1,
                    "autocaption": True,
                    "input_images": input_images_url,
                    "trigger_word": internal_trigger_word,
                },
                destination=f"houmie/{model_name}",
                webhook=webhook_url,
                webhook_events_filter=["completed"],
            )
            return training.id

The async approach needs to be investigated as it’s currently broken. It’s a shame since I’m using everything else asynchronously, but this one function has to remain synchronous to work.

Thank you

houmie avatar Jan 25 '25 18:01 houmie

@houmie Thank you for the report! You're absolutely right. The sync and async versions are too divergent and the async version is clearly not doing the right thing.

meatballhat avatar Feb 05 '25 04:02 meatballhat

having problem with client.async_create()

error message: 'Client' object has no attribute 'async_create'

is this the same issue?

githubloader avatar Jul 31 '25 04:07 githubloader