from app.service.generate_batch_image.service_batch_generate_product_image import batch_generate_product, publish_status as product_publish_status
from app.service.generate_batch_image.service_batch_generate_relight_image import batch_generate_relight, publish_status as relight_publish_status
from app.service.generate_batch_image.service_batch_pose_transform import batch_generate_pose_transform, publish_status as pose_transform_publish_status


async def start_product_batch_generate(data):
    generate_clothes_task = batch_generate_product.delay(data.dict())
    print(generate_clothes_task)
    product_publish_status(data.batch_tasks_id, f"0/{len(data.batch_data_list)}", "")
    return {"task_id": data.batch_tasks_id, "state": generate_clothes_task.state}


async def start_relight_batch_generate(data):
    generate_clothes_task = batch_generate_relight.delay(data.dict())
    print(generate_clothes_task)
    relight_publish_status(data.batch_tasks_id, f"0/{len(data.batch_data_list)}", "")
    return {"task_id": data.batch_tasks_id, "state": generate_clothes_task.state}


async def start_pose_transform_batch_generate(data):
    generate_clothes_task = batch_generate_pose_transform.delay(data.dict())
    print(generate_clothes_task)
    pose_transform_publish_status(data.tasks_id, f"0/{data.batch_size}", "")
    return {"task_id": data.tasks_id, "state": generate_clothes_task.state}
