Open brimoor opened 5 days ago
The recent updates in the repository focus on improving database configuration management and enhancing test coverage. Key changes include refactoring the get_db_config
function for better handling of multiple config documents, setting default values for configuration attributes, and renaming and refining internal functions. Additionally, minor changes were made to handle database migration logic and test functions to ensure consistency and reliability.
Files | Change Summary |
---|---|
fiftyone/core/odm/database.py |
Refactored get_db_config for better handling of multiple config documents, set default values, and renamed functions |
tests/unittests/utils_tests.py |
Added imports and modified a test function to insert documents with _id based on datetime object |
fiftyone/migrations/runner.py |
Added assignment to ensure config is set during database migration |
In the code where data flows, A rabbit hops, improvements it sows. 🐇 Configs now handled with care, Defaults set, clean and fair. Tests ensure paths are right, Through database fields, shining bright. ✨
[!TIP]
Early access features: enabled
We are currently testing the following features in early access: - **OpenAI `gpt-4o` model for code reviews and chat**: OpenAI claims that this model is better at understanding and generating code than the previous models. We seek your feedback over the next few weeks before making it generally available. Note: - You can enable or disable early access features from the CodeRabbit UI or by updating the CodeRabbit configuration file. - Please join our [Discord Community](https://discord.com/invite/GsXnASn26c) to provide feedback and report issues. - OSS projects are always opted into early access features.
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
Under heavy concurrent SDK usage, some users have reported seeing the following error when connecting to the database:
For context, the
config
collection is supposed to have exactly one document. However, if it were empty for some reason, then this error would occur. How could it be empty? I suspect that, under heavy concurrent usage, this function: https://github.com/voxel51/fiftyone/blob/a5d2209903d3699be3d310a55ab1e518f858050a/fiftyone/core/odm/database.py#L101could be subject to a race condition that accidentally deletes all config docs.
This PR makes two improvements to protect against such a race condition:
version
. Also, for extra protection, only delete the duplicate docs ifdatabase_admin=True
_id
are universally unique while the duplicate config docs likely have the sameversion
, so themax()
logic used to select which doc to keep may not be deterministic, thus causing concurrent sessions to accidentally delete all the config docs_id
is equivalent to sorting by insertion datefoc.VERSION
rather than0.14.4
0.14.4
was previously being inserted to correctly handle migrating <0.14.4 databases up to 0.14.4 (when theconfig
collection was introduced). However, the0.14.4
release is now over 2 years old, so let's assume that everyone has already migrated up. Why? Because...config
collection still somehow becomes empty, the new doc will assume the current client version and thus the compatibility error that we're trying to avoid will no longer occurI don't know for certain that this race condition is actually the reason that users are seeing the compatibility error, but this PR doesn't have any side effects so we might as well give it a shot 🚀
Summary by CodeRabbit
New Features
Tests
Bug Fixes
Refactor