Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
2 tasks done
TimotheeWrightFicha opened this issue Jun 18, 2024 · 4 comments
Closed
2 tasks done

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

TimotheeWrightFicha opened this issue Jun 18, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@TimotheeWrightFicha
Copy link

Actions before raising this issue

  • I searched the existing issues and did not find anything similar.
  • I read/searched the docs

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

@TimotheeWrightFicha TimotheeWrightFicha added the bug Something isn't working label Jun 18, 2024
@bsekachev
Copy link
Member

Duplicate of ##8041

@bsekachev
Copy link
Member

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

@darkgod1kandarp
Copy link

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
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants