label-studio icon indicating copy to clipboard operation
label-studio copied to clipboard

Runtime Error: "was cancelled"

Open iegorval opened this issue 3 years ago • 1 comments

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

  1. Go to Settings / Cloud Storage
  2. Add Source Storage
  3. Select local storage
  4. 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 avatar Aug 22 '22 09:08 iegorval

@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)])

?

makseq avatar Aug 23 '22 22:08 makseq

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']])

teebu avatar Dec 13 '22 23:12 teebu