fiftyone
fiftyone copied to clipboard
[BUG] load annotations exception while deleting labels
Describe the problem
load annotations results in an exception
Code to reproduce issue
>>> gs =fo.load_dataset('test')
>>> gs.list_annotation_runs()
['test1', 'test12']
>>> gs.load_annotations('test12')
Downloading labels from Label Studio...
Download complete
Loading labels for field 'ground_truth'...
Traceback (most recent call last):
File "/home/testuser/git/testrepo/model/venv/lib64/python3.11/site-packages/fiftyone/core/odm/database.py", line 807, in bulk_write
coll.bulk_write(batch, ordered=ordered)
File "/home/testuser/git/testrepo/model/venv/lib64/python3.11/site-packages/pymongo/_csot.py", line 107, in csot_wrapper
return func(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/testuser/git/testrepo/model/venv/lib64/python3.11/site-packages/pymongo/collection.py", line 569, in bulk_write
bulk_api_result = blk.execute(write_concern, session)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/testuser/git/testrepo/model/venv/lib64/python3.11/site-packages/pymongo/bulk.py", line 576, in execute
return self.execute_command(generator, write_concern, session)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/testuser/git/testrepo/model/venv/lib64/python3.11/site-packages/pymongo/bulk.py", line 446, in execute_command
_raise_bulk_write_error(full_result)
File "/home/testuser/git/testrepo/model/venv/lib64/python3.11/site-packages/pymongo/bulk.py", line 157, in _raise_bulk_write_error
raise BulkWriteError(full_result)
pymongo.errors.BulkWriteError: batch op errors occurred, full error: {'writeErrors': [{'index': 0, 'code': 2, 'errmsg': 'Cannot apply $pull to a non-array value', 'op': {'q': {'ground_truth.detections': {'$exists': True}}, 'u': {'$pull': {'ground_truth.detections': {'_id': {'$in': [ObjectId('65578a3b7499471472bb40e1'), ObjectId('6551158dfd0a50d1decf13be'), ObjectId('65bd13ddb36066900d2c2d9b'), ObjectId('65511598fd0a50d1decf3849'), ObjectId('6557445e59d3f439ba79cd5d'), ObjectId('65bd1531500399d9ed879671'), ObjectId('65577f7f66df65c20c6de81f'), ObjectId('65bd13ddb36066900d2c2cfc'), ObjectId('65bd13ddb36066900d2c2cfb'), ObjectId('65bd13ddb36066900d2c2cfd'), ObjectId('6551158dfd0a50d1decf13ba'), ObjectId('65bd13deb36066900d2c434a'), ObjectId('65bd13ddb36066900d2c2d0d')]}}}}, 'multi': True, 'upsert': False}}], 'writeConcernErrors': [], 'nInserted': 0, 'nUpserted': 0, 'nMatched': 0, 'nModified': 0, 'nRemoved': 0, 'upserted': []}
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/testuser/git/testrepo/model/venv/lib64/python3.11/site-packages/fiftyone/core/collections.py", line 8837, in load_annotations
return foua.load_annotations(
^^^^^^^^^^^^^^^^^^^^^^
File "/home/testuser/git/testrepo/model/venv/lib64/python3.11/site-packages/fiftyone/utils/annotations.py", line 1079, in load_annotations
_merge_labels(
File "/home/testuser/git/testrepo/model/venv/lib64/python3.11/site-packages/fiftyone/utils/annotations.py", line 1486, in _merge_labels
dataset.delete_labels(ids=_del_ids, fields=label_field)
File "/home/testuser/git/testrepo/model/venv/lib64/python3.11/site-packages/fiftyone/core/dataset.py", line 3230, in delete_labels
foo.bulk_write(sample_ops, self._sample_collection)
File "/home/testuser/git/testrepo/model/venv/lib64/python3.11/site-packages/fiftyone/core/odm/database.py", line 816, in bulk_write
raise ValueError(msg) from bwe
ValueError: Cannot apply $pull to a non-array value
System information
- opensuse tumbleweed
- python 3.11.8
- FiftyOne v0.23.7
- installed from pip
Willingness to contribute
The FiftyOne Community encourages bug fix contributions. Would you or another member of your organization be willing to contribute a fix for this bug to the FiftyOne codebase?
- [ ] Yes. I can contribute a fix for this bug independently
- [x] Yes. I would be willing to contribute a fix for this bug with guidance from the FiftyOne community
- [ ] No. I cannot contribute a bug fix at this time
Hi @spaced, if you add reproduction steps we will be able to diagnose 🙏
I am experiencing this same issue as well. I loaded a detection dataset from a file, called annotate with classes=dataset.get_classes("gt_bounding_boxes") + ["small_blurry"] (the only difference from when I last did this), labeled 500 images in labels studio, and then called load_annotations.
Same error here...
I created an annotation job for CVAT from fiftyone. Calling load_annotations from there shows this error
---------------------------------------------------------------------------
BulkWriteError Traceback (most recent call last)
File venv/lib/python3.9/site-packages/fiftyone/core/odm/database.py:807, in bulk_write(ops, coll, ordered, progress)
[806](/venv/lib/python3.9/site-packages/fiftyone/core/odm/database.py:806) batch = list(batch)
--> [807](/venv/lib/python3.9/site-packages/fiftyone/core/odm/database.py:807) coll.bulk_write(batch, ordered=ordered)
[808](/venv/lib/python3.9/site-packages/fiftyone/core/odm/database.py:808) if batcher.manual_backpressure:
[809](/venv/lib/python3.9/site-packages/fiftyone/core/odm/database.py:809) # @todo can we infer content size from bulk_write() above?
[810](/venv/lib/python3.9/site-packages/fiftyone/core/odm/database.py:810) # @todo do we need a more accurate measure of size here?
File venv/lib/python3.9/site-packages/pymongo/_csot.py:107, in apply.<locals>.csot_wrapper(self, *args, **kwargs)
[106](/venv/lib/python3.9/site-packages/pymongo/_csot.py:106) return func(self, *args, **kwargs)
--> [107](/venv/lib/python3.9/site-packages/pymongo/_csot.py:107) return func(self, *args, **kwargs)
File venv/lib/python3.9/site-packages/pymongo/collection.py:569, in Collection.bulk_write(self, requests, ordered, bypass_document_validation, session, comment, let)
[568](/venv/lib/python3.9/site-packages/pymongo/collection.py:568) write_concern = self._write_concern_for(session)
--> [569](/venv/lib/python3.9/site-packages/pymongo/collection.py:569) bulk_api_result = blk.execute(write_concern, session)
[570](/venv/lib/python3.9/site-packages/pymongo/collection.py:570) if bulk_api_result is not None:
File venv/lib/python3.9/site-packages/pymongo/bulk.py:576, in _Bulk.execute(self, write_concern, session)
[575](/venv/lib/python3.9/site-packages/pymongo/bulk.py:575) else:
--> [576](/venv/lib/python3.9/site-packages/pymongo/bulk.py:576) return self.execute_command(generator, write_concern, session)
File venv/lib/python3.9/site-packages/pymongo/bulk.py:446, in _Bulk.execute_command(self, generator, write_concern, session)
[445](/venv/lib/python3.9/site-packages/pymongo/bulk.py:445) if full_result["writeErrors"] or full_result["writeConcernErrors"]:
--> [446](/venv/lib/python3.9/site-packages/pymongo/bulk.py:446) _raise_bulk_write_error(full_result)
...
[814](/venv/lib/python3.9/site-packages/fiftyone/core/odm/database.py:814) except BulkWriteError as bwe:
[815](/venv/lib/python3.9/site-packages/fiftyone/core/odm/database.py:815) msg = bwe.details["writeErrors"][0]["errmsg"]
--> [816](/venv/lib/python3.9/site-packages/fiftyone/core/odm/database.py:816) raise ValueError(msg) from bwe
ValueError: Cannot apply $pull to a non-array value