Skip to content

client.trainings.async_create() is broken #408

@houmie

Description

@houmie

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions