KeyError "task_id" from project.import_tasks()
ktl014 opened this issue · 1 comments
ktl014 commented
Description
While trying to run the examples/import_preannotations.py
, I received a keyerror regarding task_ids
upon the execution of the project.import_tasks()
.
- The tasks are able to import into my project, but the only issue is the the
response.json()
in the return of theimport_tasks()
is expecting atask_ids
.
To Reproduce
ls = Client(url=LABEL_STUDIO_URL, api_key=API_KEY)
project = ls.start_project(
title='Project Created from SDK: Image Preannotation',
label_config='''
<View>
<Image name="image" value="$image"/>
<Choices name="image_class" toName="image">
<Choice value="Cat"/>
<Choice value="Dog"/>
</Choices>
</View>
''',
)
project.import_tasks(
[
{
'data': {'image': 'https://data.heartex.net/open-images/train_0/mini/0045dd96bf73936c.jpg'},
'predictions': [
{
'result': [
{
'from_name': 'image_class',
'to_name': 'image',
'type': 'choices',
'value': {'choices': ['Dog']},
}
],
'score': 0.87,
}
],
},
{
'data': {'image': 'https://data.heartex.net/open-images/train_0/mini/0083d02f6ad18b38.jpg'},
'predictions': [
{
'result': [
{
'from_name': 'image_class',
'to_name': 'image',
'type': 'choices',
'value': {'choices': ['Cat']},
}
],
'score': 0.65,
}
],
},
]
)
Expected behavior
Version Details
label-studio == 1.1.1
label-studio-client-sdk == @master
Runtime Environment
Screenshots AND/OR Logs
DEBUG:urllib3.util.retry:Converted retries value: 3 -> Retry(total=3, connect=None, read=None, redirect=None, status=None)
DEBUG:urllib3.util.retry:Converted retries value: 3 -> Retry(total=3, connect=None, read=None, redirect=None, status=None)
DEBUG:label_studio_sdk.client:POST: /api/projects with args=(), kwargs={'json': {'title': 'Project Created from SDK: Image Preannotation', 'label_config': '\n <View>\n <Image name="image" value="$image"/>\n <Choices name="image_class" toName="image">\n <Choice value="Cat"/>\n <Choice value="Dog"/>\n </Choices>\n </View>\n '}, 'timeout': (1.0, 60.0)}
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): aahittagging-dev.aexp.com:443
DEBUG:urllib3.connectionpool:https://aahittagging-dev.aexp.com:443 "POST /api/projects HTTP/1.1" 201 1574
DEBUG:label_studio_sdk.client:POST: /api/projects/46/import with args=(), kwargs={'json': [{'data': {'image': 'https://data.heartex.net/open-images/train_0/mini/0045dd96bf73936c.jpg'}, 'predictions': [{'result': [{'from_name': 'image_class', 'to_name': 'image', 'type': 'choices', 'value': {'choices': ['Dog']}}], 'score': 0.87}]}, {'data': {'image': 'https://data.heartex.net/open-images/train_0/mini/0083d02f6ad18b38.jpg'}, 'predictions': [{'result': [{'from_name': 'image_class', 'to_name': 'image', 'type': 'choices', 'value': {'choices': ['Cat']}}], 'score': 0.65}]}], 'params': {'return_task_ids': '1'}, 'timeout': (1.0, 60.0)}
DEBUG:urllib3.connectionpool:https://aahittagging-dev.aexp.com:443 "POST /api/projects/46/import?return_task_ids=1 HTTP/1.1" 201 175
DEBUG:label_studio_sdk.client:GET: /api/projects/46 with args=(), kwargs={'timeout': (1.0, 60.0)}
DEBUG:urllib3.connectionpool:https://aahittagging-dev.aexp.com:443 "GET /api/projects/46 HTTP/1.1" 200 1562
DEBUG:label_studio_sdk.client:GET: /api/projects/46 with args=(), kwargs={'timeout': (1.0, 60.0)}
DEBUG:urllib3.connectionpool:https://aahittagging-dev.aexp.com:443 "GET /api/projects/46 HTTP/1.1" 200 1562
>>> response.json()
PyDev console: starting.
{'task_count': 2, 'annotation_count': 0, 'prediction_count': 2, 'duration': 0.04142403602600098, 'file_upload_ids': [], 'could_be_tasks_list': False, 'found_formats': [], 'data_columns': []}
DEBUG:label_studio_sdk.client:GET: /api/projects/46 with args=(), kwargs={'timeout': (1.0, 60.0)}
DEBUG:urllib3.connectionpool:https://aahittagging-dev.aexp.com:443 "GET /api/projects/46 HTTP/1.1" 200 1562
DEBUG:label_studio_sdk.client:GET: /api/projects/46 with args=(), kwargs={'timeout': (1.0, 60.0)}
DEBUG:urllib3.connectionpool:https://aahittagging-dev.aexp.com:443 "GET /api/projects/46 HTTP/1.1" 200 1562
Traceback (most recent call last):
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/pydevd.py", line 1483, in _exec
pydev_imports.execfile(file, globals, locals) # execute the script
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/Users/ktle2/personal_projects/label-studio-sdk/examples/import_preannotations/import_preannotations.py", line 29, in <module>
project.import_tasks(
File "/Users/ktle2/personal_projects/label-studio-sdk/label_studio_sdk/project.py", line 481, in import_tasks
return response.json()['task_ids']
KeyError: 'task_ids'
python-BaseException