import six
import uuid


def start_detect_image(ibs, image_uuid_list, callback_url=None, callback_method=None):
    """
    REST:
        Method: GET
        URL: /api/engine/detect/cnn/yolo/

    Args:
        image_uuid_list (list) : list of image uuids to detect on.
        callback_url (url) : url that will be called when detection succeeds or fails
    """
    # Check UUIDs
    ibs.web_check_uuids(image_uuid_list=image_uuid_list)

    #import ibeis
    #from ibeis.web import apis_engine
    #ibs.load_plugin_module(apis_engine)
    def ensure_uuid_list(list_):
        if list_ is not None and len(list_) > 0 and isinstance(list_[0], six.string_types):
            list_ = list(map(uuid.UUID, list_))
        return list_

    image_uuid_list = ensure_uuid_list(image_uuid_list)
    gid_list = ibs.get_image_gids_from_uuid(image_uuid_list)
    args = (gid_list,)
    jobid = ibs.job_manager.jobiface.queue_job('detect_cnn_yolo_json', callback_url, callback_method, *args)

    #if callback_url is not None:
    #    #import requests
    #    #requests.
    #    #callback_url
    return jobid