cvat-ai / cvat

Annotate better with CVAT, the industry-leading data engine for machine learning. Used and trusted by teams at any scale, for data of any scale.
https://cvat.ai
MIT License
11.74k stars 2.88k forks source link

HTTP response body: "Export has not finished" #8045

Closed TimotheeWrightFicha closed 1 week ago

TimotheeWrightFicha commented 1 week ago

Actions before raising this issue

Steps to Reproduce

configuration = Configuration(
        host=main_url,
        username=user_name,
        password=password,
    )

    api_client = ApiClient(configuration)
    error = False
    while True:
        try:
            (_, response) = api_client.tasks_api.retrieve_dataset(
                id=task_id,
                format="COCO 1.0",
                action="download",
                location="local",
                _parse_response=False,
            )
            if response.status == 200:
                break
        except Exception as e:
            print(f"An error occurred: {e}")
            error = True
            break

    data_name = f'Data_{task_id}_{datetime.now().strftime("%Y_%m_%d_%H_%M")}.zip'

    if not error:
        # Save the resulting file
        with open(data_name, "wb") as output_file:
            output_file.write(response.data)
        return data_name

    else:
        return None

Got the error:

An error occurred: Status Code: 400
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Allow': 'GET, HEAD, OPTIONS', 'Content-Length': '25', 'Content-Type': 'application/vnd.cvat+json', 'Cross-Origin-Opener-Policy': 'same-origin', 'Date': 'Tue, 18 Jun 2024 15:03:51 GMT', 'Referrer-Policy': 'same-origin, strict-origin-when-cross-origin', 'Server': 'nginx', 'Vary': 'Accept, Origin, Cookie', 'X-Content-Type-Options': 'nosniff, nosniff', 'X-Frame-Options': 'DENY', 'X-Request-Id': '9444c619-b8e7-44db-a42f-0af10e1b19f3'})
HTTP response body: "Export has not finished"

Expected Behavior

The same code used to work to export data out of CVAT.

Possible Solution

I saw this commit linked to download of dataset was done since the last time we run our code. Maybe it's coming from there ?

Context

Trying to export tasks from CVAT from python

Environment

No response

bsekachev commented 1 week ago

Duplicate of #https://github.com/cvat-ai/cvat/issues/8041

bsekachev commented 1 week ago

Short answer: add action=download only when server returned code 201

darkgod1kandarp commented 1 week ago

Hello @bsekachev I think so CVAT SDK is not supporting this behaviour , it does not allow action values to be set other than "download" . api_client.tasks_api.retrieve_dataset( id=task_id, format="COCO 1.0", action="download", location="local", _parse_response=False, ) So we have to manually write request to download dataset. Can you please correct me if I am wrong? ` while True: try: response = re.get(url, auth=('**', '**')) print(response.status_code)

        if response.status_code == 202:
            print("Dataset is being prepared.")
            continue
        elif response.status_code == 201:
            url =  url + "&action=download"
            print("File path has been created.")
        elif response.status_code == 200:

            data_name = f'Data_{task_id}_{datetime.now().strftime("%Y_%m_%d_%H_%M")}.zip'
            print(data_name)
            with open(data_name, "wb") as output_file:
                output_file.write(response.content)

            break
        else:
            print(f"An error occurred: {response.status_code}")
            error = True
            break

    except Exception as e:
        print(f"An error occurred: {e}")
        error = True
        break

`

bsekachev commented 1 week ago

it does not allow action values to be set other than "download" .

Try to omit this parameter, you do not need to specify other values.