question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Programmatically insert task annotations

See original GitHub issue

Hello,

I’m trying to integrate an external tool to automate some operations using CVAT API. I’m already able to perform most of the operations such as authenticating, creating tasks, listing tasks, uploading videos to tasks and label definitions/configurations to tasks.

But I’m currently struggling with uploading annotations into a task.

I already have a parser that converts from my annotation format to the format described on the endpoint /tasks/{id}/annotations in the /api/swagger docs, if I get my converted annotations json and use the PUT /tasks/{id}/annotations route on the swagger Try it out function it returns me 200 and creates the annotations just fine.

But when using my python tool it returns me 200 and the annotation is not getting created in the task.

Am I missing a header?

Here’s my HTTP debug logs:

HTTP/1.1 PUT http://MY_HOST:8080/api/v1/tasks/56/annotations
Content-Type: application/json
Accept: application/json
Authorization: Basic f644b969c47f732b0110c33729e7505b143fdf1f
X-CSRFToken: lj6cPpfmjBw6knp1TpwRPyRAtYZUnOI4DCmlhwHAyHTzdp88Ov86u1xoO4nJrMm4
Cookie: csrftoken=lj6cPpfmjBw6knp1TpwRPyRAtYZUnOI4DCmlhwHAyHTzdp88Ov86u1xoO4nJrMm4; sessionid=ee907kwqz1yuf5mtrcqw1mmvzij6qjdk
Content-Length: 2710

{"version": 1, "tags": [], "shapes": [{"type": "points", "occluded": false, "label_id": 3603, "points": [0, 0, 0, 0], "group": 0, "frame": 0, "attributes": [{"spec_id": 24944, "value": "89"}, {"spec_id": 24945, "value": "1624"}]}], "tracks": [{"frame": 88, "label_id": 3612, "group": 0, "shapes": [{"type": "rectangle", "frame": 88, "occluded": false, "outside": false, "points": [950.0, 500.0, 1350.0, 1100.0], "attributes": []}, {"type": "rectangle", "frame": 529, "occluded": false, "outside": true, "points": [950.0, 500.0, 1350.0, 1100.0], "attributes": []}], "attributes": [{"spec_id": 25005, "value": ""}, {"spec_id": 25008, "value": "1570530132.277753"}, {"spec_id": 25004, "value": "True"}, {"spec_id": 25002, "value": "None"}, {"spec_id": 25003, "value": "5"}, {"spec_id": 25006, "value": "3"}, {"spec_id": 25007, "value": "1570530113.930426"}]}, {"frame": 602, "label_id": 3667, "group": 0, "shapes": [{"type": "rectangle", "frame": 602, "occluded": false, "outside": false, "points": [400.0, 600.0, 1050.0, 1050.0], "attributes": []}, {"type": "rectangle", "frame": 1114, "occluded": false, "outside": true, "points": [400.0, 600.0, 1050.0, 1050.0], "attributes": []}], "attributes": [{"spec_id": 25390, "value": ""}, {"spec_id": 25393, "value": "1570530156.657058"}, {"spec_id": 25389, "value": "True"}, {"spec_id": 25387, "value": "None"}, {"spec_id": 25388, "value": "3"}, {"spec_id": 25391, "value": "5"}, {"spec_id": 25392, "value": "1570530135.343988"}]}, {"frame": 723, "label_id": 3641, "group": 0, "shapes": [{"type": "rectangle", "frame": 723, "occluded": false, "outside": false, "points": [950.0, 500.0, 1350.0, 1100.0], "attributes": []}, {"type": "rectangle", "frame": 1087, "occluded": false, "outside": true, "points": [950.0, 500.0, 1350.0, 1100.0], "attributes": []}], "attributes": [{"spec_id": 25208, "value": ""}, {"spec_id": 25211, "value": "1570530155.551199"}, {"spec_id": 25207, "value": "True"}, {"spec_id": 25205, "value": "None"}, {"spec_id": 25206, "value": "5"}, {"spec_id": 25209, "value": "3"}, {"spec_id": 25210, "value": "1570530140.370748"}]}, {"frame": 1210, "label_id": 3624, "group": 0, "shapes": [{"type": "rectangle", "frame": 1210, "occluded": false, "outside": false, "points": [950.0, 500.0, 1350.0, 1100.0], "attributes": []}, {"type": "rectangle", "frame": 1609, "occluded": false, "outside": true, "points": [950.0, 500.0, 1350.0, 1100.0], "attributes": []}], "attributes": [{"spec_id": 25089, "value": ""}, {"spec_id": 25092, "value": "1570530177.316677"}, {"spec_id": 25088, "value": "True"}, {"spec_id": 25086, "value": "None"}, {"spec_id": 25087, "value": "5"}, {"spec_id": 25090, "value": "3"}, {"spec_id": 25091, "value": "1570530160.678561"}]}]}


HTTP/1.1 200
Date: Fri, 21 Feb 2020 11:08:40 GMT
Server: Apache
Content-Length: 47
Vary: Accept,Origin,Cookie
Allow: GET, PUT, PATCH, DELETE, HEAD, OPTIONS
X-Frame-Options: SAMEORIGIN
Connection: close
Content-Type: application/json

b'{"version":0,"tags":[],"shapes":[],"tracks":[]}'

Here’s a snippet of my generic method for sending requests to CVAT API, it’s currently working for the other routes.

# ...

if data:
    data = json.dumps(data)

prepped_request = Request(
    method=method,
    url=endpoint_url,
    headers=headers,
    data=data,
    params=params,
    files=files,
    cookies=cookies
)

# ...

response = session.send(prepped_request)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
rcbopcommented, Feb 24, 2020

Ok I found /tasks/{id}/status

0reactions
rcbopcommented, Feb 21, 2020

If I put a time.sleep(10) between creating the task + uploading the video for a task and uploading the annotations it works… is there any way for me to poll on the task to check if it’s ready to receive the annotations upload?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Adding Tasks Programmatically - SSIS - Microsoft Learn
Tasks that are added to the package by using the Add method as an Executable object can be cast as a TaskHost object....
Read more >
Append a text annotations to a task - Forum - bpmn.io
Hi, i'm new in the bpmn world. I'm trying to append programmatically a text annotations to a task. ... Programmatically creating and adding...
Read more >
45 Manage Tasks Programmatically
This chapter describes what to do when you need to programmatically create, set an outcome for, or query task information that resides in...
Read more >
Add Annotations Programmatically to the Document Viewer
This tutorial shows how to programmatically draw an annotation on a document in the Document Viewer in an HTML5 JS application using the...
Read more >
Programmatically attach user object in notes field
I am working on programmatically creating new tasks based on a form submission, and I am including some information about the form submitter ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found