Runtime Error: "was cancelled"
Describe the bug
After updating the Label Studio, my old annotation files do not work with storage sync anymore. When I try to sync my local storage, I get Runtime Error "was cancelled". After examining the error and commits, I realized that this commit has broken my annotations -> https://github.com/heartexlabs/label-studio/commit/36de45c9af69514f7b841e8391bf0e4103b4661b by adding cancelled_annotations = len([a for a in annotations if a['was_cancelled']]) line. I cannot find any mention of "was_cancelled" field in documentation about the json annotations for Label Studio.
To Reproduce
- Go to Settings / Cloud Storage
- Add Source Storage
- Select local storage
- Sync Storage
Expected behavior If I understand the intention of the code correctly, I would expect either "was_cancelled" json field to be described in documentation as mandatory, or the code to create some default value for it if it is not provided instead of failing to sync my local storage, which used to work before the update.
Stacktrace
Traceback (most recent call last):
File "/home/user/anaconda3/lib/python3.7/site-packages/rest_framework/views.py", line 506, in dispatch
response = handler(request, *args, **kwargs)
File "/home/user/anaconda3/lib/python3.7/site-packages/django/utils/decorators.py", line 43, in _wrapper
return bound_method(*args, **kwargs)
File "/home/user/anaconda3/lib/python3.7/site-packages/label_studio/io_storages/api.py", line 93, in post
storage.sync()
File "/home/user/anaconda3/lib/python3.7/site-packages/label_studio/io_storages/base_models.py", line 180, in sync
self.scan_and_create_links()
File "/home/user/anaconda3/lib/python3.7/site-packages/label_studio/io_storages/localfiles/models.py", line 94, in scan_and_create_links
return self._scan_and_create_links(LocalFilesImportStorageLink)
File "/home/user/anaconda3/lib/python3.7/site-packages/label_studio/io_storages/base_models.py", line 122, in _scan_and_create_links
cancelled_annotations = len([a for a in annotations if a['was_cancelled']])
File "/home/user/anaconda3/lib/python3.7/site-packages/label_studio/io_storages/base_models.py", line 122, in <listcomp>
cancelled_annotations = len([a for a in annotations if a['was_cancelled']])
KeyError: 'was_cancelled'
Environment: Ubuntu 20.04, Label Studio 1.5.0post0
@iegorval could you please create a PR with the changed line:
len([a for a in annotations if a['was_cancelled']])
=>
len([a for a in annotations if a.get('was_cancelled', False)])
?
Seeing same error with annotation sample https://labelstud.io/guide/tasks.html#Example-JSON-format:
File "/label-studio/label_studio/io_storages/base_models.py", line 128, in
cancelled_annotations = len([a for a in annotations if a['was_cancelled']])