HumanSignal / label-studio

Label Studio is a multi-type data labeling and annotation tool with standardized output format
https://labelstud.io
Apache License 2.0
18.33k stars 2.3k forks source link

NoneType Object error during drafting annotations After Upgrade #6265

Closed liuy129 closed 3 weeks ago

liuy129 commented 3 weeks ago

Describe the bug Attempted to upgrade LabelStudio from 1.7.2dev to 1.9+~1.13.1 However, encounter an Runtime error message box whenever trying to draft a new annotation. Here is the stacktrace as illustrated:

Traceback (most recent call last):
  File "Z:\Venv\env_LabelStudio_py310\env_LS_py310\lib\site-packages\rest_framework\serializers.py", line 962, in create
    instance = ModelClass._default_manager.create(**validated_data)
  File "Z:\Venv\env_LabelStudio_py310\env_LS_py310\lib\site-packages\django\db\models\manager.py", line 85, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "Z:\Venv\env_LabelStudio_py310\env_LS_py310\lib\site-packages\django\db\models\query.py", line 453, in create
    obj.save(force_insert=True, using=self.db)
  File "Z:\Venv\env_LabelStudio_py310\env_LS_py310\lib\site-packages\label_studio\tasks\models.py", line 839, in save
    project.summary.update_created_labels_drafts([self])
  File "Z:\Venv\env_LabelStudio_py310\env_LS_py310\lib\site-packages\label_studio\projects\models.py", line 1323, in update_created_labels_drafts
    labels = dict(self.created_labels_drafts)
TypeError: 'NoneType' object is not iterable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "Z:\Venv\env_LabelStudio_py310\env_LS_py310\lib\site-packages\rest_framework\views.py", line 506, in dispatch
    response = handler(request, *args, **kwargs)
  File "Z:\Venv\env_LabelStudio_py310\env_LS_py310\lib\site-packages\rest_framework\generics.py", line 242, in post
    return self.create(request, *args, **kwargs)
  File "Z:\Venv\env_LabelStudio_py310\env_LS_py310\lib\site-packages\rest_framework\mixins.py", line 19, in create
    self.perform_create(serializer)
  File "Z:\Venv\env_LabelStudio_py310\env_LS_py310\lib\site-packages\label_studio\tasks\api.py", line 626, in perform_create
    serializer.save(task_id=self.kwargs['pk'], annotation_id=annotation_id, user=self.request.user)
  File "Z:\Venv\env_LabelStudio_py310\env_LS_py310\lib\site-packages\rest_framework\serializers.py", line 212, in save
    self.instance = self.create(validated_data)
  File "Z:\Venv\env_LabelStudio_py310\env_LS_py310\lib\site-packages\rest_framework\serializers.py", line 981, in create
    raise TypeError(msg)
TypeError: Got a `TypeError` when calling `AnnotationDraft.objects.create()`. This may be because you have a writable field on the serializer class that is not a valid argument to `AnnotationDraft.objects.create()`. You may need to make the field read-only, or override the AnnotationDraftSerializer.create() method to handle this correctly.
Original exception was:
 Traceback (most recent call last):
  File "Z:\Venv\env_LabelStudio_py310\env_LS_py310\lib\site-packages\rest_framework\serializers.py", line 962, in create
    instance = ModelClass._default_manager.create(**validated_data)
  File "Z:\Venv\env_LabelStudio_py310\env_LS_py310\lib\site-packages\django\db\models\manager.py", line 85, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "Z:\Venv\env_LabelStudio_py310\env_LS_py310\lib\site-packages\django\db\models\query.py", line 453, in create
    obj.save(force_insert=True, using=self.db)
  File "Z:\Venv\env_LabelStudio_py310\env_LS_py310\lib\site-packages\label_studio\tasks\models.py", line 839, in save
    project.summary.update_created_labels_drafts([self])
  File "Z:\Venv\env_LabelStudio_py310\env_LS_py310\lib\site-packages\label_studio\projects\models.py", line 1323, in update_created_labels_drafts
    labels = dict(self.created_labels_drafts)
TypeError: 'NoneType' object is not iterable

also tried to view the error in console of the browser:

Error: [mobx-state-tree] You are trying to read or write to an object that is no longer part of a state tree. (Object type: 'PolygonRegionModel', Path upon death: '/annotationStore/root/children/1/drawingRegion', Subpath: 'id', Action: '/annotationStore/root/children/1/drawingRegion.setupFinalMask()'). Either detach nodes first, or don't use objects after removing / replacing them in the tree.
    at De (mobx-state-tree.module.js:3427:18)
    at t.assertAlive (mobx-state-tree.module.js:1510:21)
    at t.unbox (mobx-state-tree.module.js:1580:14)
    at t.dehanceValue (mobx.module.js:1040:25)
    at t.get (mobx.module.js:1092:21)
    at e.read (mobx.module.js:4136:37)
    at Object.get [as id] (mobx.module.js:4377:36)
    at Object.Ve [as renderItem] (Tree.tsx:240:39)
    at ImageView.jsx:70:35
    at useObserver.js:91:29
    at oe (mobx.module.js:775:24)
    at e.track (mobx.module.js:1809:22)
    at useObserver.js:89:18
    at useQueuedForceUpdate.js:19:22
    at N (useObserver.js:83:12)
    at ImageView.jsx:70:12
    at fr (react-reconciler.production.min.js:74:137)
    at Ur (react-reconciler.production.min.js:97:153)
    at Yr (react-reconciler.production.min.js:95:169)
    at bo (react-reconciler.production.min.js:188:107)
    at ta (react-reconciler.production.min.js:167:347)
    at $o (react-reconciler.production.min.js:167:278)
    at qo (react-reconciler.production.min.js:167:138)
    at Fo (react-reconciler.production.min.js:160:163)
    at react-reconciler.production.min.js:37:115
    at t.unstable_runWithPriority (scheduler.production.min.js:18:343)
    at Yt (react-reconciler.production.min.js:36:325)
    at Ut (react-reconciler.production.min.js:37:61)
    at Bt (react-reconciler.production.min.js:36:427)
    at Go (react-reconciler.production.min.js:154:202)
    at Nr (react-reconciler.production.min.js:87:406)
    at utils.js:25:9
    at useQueuedForceUpdate.js:10:13
    at e.onInvalidate (useObserver.js:36:17)
    at e.runReaction (mobx.module.js:1775:26)
    at He (mobx.module.js:1912:35)
    at Xe (mobx.module.js:1890:47)
    at mobx.module.js:1919:71
    at xs (react-dom.production.min.js:244:160)
    at Xe (mobx.module.js:1919:47)
    at Fe (mobx.module.js:1895:5)
    at Ve (mobx.module.js:1595:9)
    at mobx.module.js:981:5
    at ve (mobx.module.js:935:9)
    at r (mobx.module.js:915:16)
    at mobx-state-tree.module.js:2593:35
    at q (mobx-state-tree.module.js:2456:16)
    at s (mobx-state-tree.module.js:3617:13)
    at c (mobx-state-tree.module.js:3631:21)
(anonymous) @ instrument.js:109
Show 1 more frame
Show lessUnderstand this warning
canvas.js:91 Canvas2D: Multiple readback operations using getImageData are faster with the willReadFrequently attribute set to true. See: https://html.spec.whatwg.org/multipage/canvas.html#concept-canvas-will-read-frequently
b @ canvas.js:91Understand this warning
:8080/api/tasks/9280/drafts?project=57:1 
Failed to load resource: the server responded with a status of 500 (Internal Server Error)Understand this error
instrument.js:109 Object

To Reproduce

Labelling config:

<View>
  <Header value="Select label and start to click on image"/>
  <Image name="image" value="$image" width="1500px" rotateControl="true" contrastControl="true" brightnessControl="true" show_skip_button="true" zoom="true" negativeZoom="true"/>

  <Labels name="labels" toName="image" opacity="0.1">
    <Label value="ObjectToFind" background="#ff6b6b" selected="true"/>
   </Labels>
    <MagicWand name="magicwand" toName="image" opacity="0.7" blurradius="15" defaultthreshold="12"/>
    <Brush name="brushes" toName="image"/>
    <Polygon name="polys" toName="image" opacity="0.1"/>
    <Rectangle name="rects" toName="image"/>

  <TextArea name="comment" value="comment here" toName="image" editable="true" showSubmitButton="true" skipDuplicates="true" maxSubmissions="3" perRegion="false" placeholder="Recognized Text"/>

  <Text name="ratingTxt1" value="Rate the above annotation on a scale of 0 to 5 stars:"/>
  <Text name="lineBreak1" value="----------------------------------------------------------"/>
  <Rating name="rating" toName="image" maxRating="5" defaultValue="0" required="true" requiredMessage="please rate and update" icon="star" size="large"/>
  <Text name="lineBreak2" value="----------------------------------------------------------"/>
panel;"/>
</View>

Steps to reproduce the behavior:

  1. upgrade LS from 1.7.2dev to 1.13.x
  2. use "Python manage.py xxx" (where xxx is migrate, collectstaic, or runserver)
  3. wait for the local sqlite3 database to finish migrate
  4. Go to any 'project'
  5. Click on any 'task'
  6. start annotating the image
  7. within five seconds, runtime error occurs and keep popping up

Expected behavior Expect no Runtime error when drafting annotations

Screenshots Runtime error: image

Labelling config error: image

Environment (please complete the following information):

Additional context in addition, the Labelling config also shows the same error as shown in the second screenshot

makseq commented 3 weeks ago

Try to go to Project settings => Danger Zone And click Reset Cache button there.

liuy129 commented 3 weeks ago

Try to go to Project settings => Danger Zone And click Reset Cache button there.

that resolved my issue. Is that typical when upgrading Label Studio? I have quite a number of projects. I wonder if I can resolve this all at once?