Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] load annotations exception while deleting labels #4196

Open
1 of 3 tasks
spaced opened this issue Mar 25, 2024 · 1 comment
Open
1 of 3 tasks

[BUG] load annotations exception while deleting labels #4196

spaced opened this issue Mar 25, 2024 · 1 comment
Labels
bug Bug fixes

Comments

@spaced
Copy link

spaced commented Mar 25, 2024

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
  • 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
@spaced spaced added the bug Bug fixes label Mar 25, 2024
@benjaminpkane
Copy link
Contributor

Hi @spaced, if you add reproduction steps we will be able to diagnose 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug fixes
Projects
None yet
Development

No branches or pull requests

2 participants