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

Fix id serialization in color scheme #4060

Merged
merged 2 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion fiftyone/core/odm/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ def to_dict(self, extended=False):
@classmethod
def from_dict(cls, d):
d = dict(**d)
d["_id"] = ObjectId(d["id"])
d["_id"] = ObjectId(d.get("id", None))
return super().from_dict(d)


Expand Down
21 changes: 21 additions & 0 deletions tests/unittests/odm_tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"""
FiftyOne odm unit tests.

| Copyright 2017-2024, Voxel51, Inc.
| `voxel51.com <https://voxel51.com/>`_
|
"""
import unittest

from bson import ObjectId

import fiftyone as fo


class ColorSchemeTests(unittest.TestCase):
def test_color_scheme_serialization(self):
color_scheme = fo.ColorScheme.from_dict({})
self.assertIsInstance(color_scheme.id, str)

d = fo.ColorScheme().to_dict()
self.assertIsInstance(d["id"], str)
Loading