-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Refactor bulk_create calls #9047
base: develop
Are you sure you want to change the base?
Conversation
What's the purpose of this? |
As the description states - use chunk size by default. It's often unintentionally forgotten. |
Sure, but why do we want this? |
Because we don't want it to be unintentionally forgotten in random places. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #9047 +/- ##
===========================================
+ Coverage 73.43% 73.92% +0.48%
===========================================
Files 419 428 +9
Lines 44351 44536 +185
Branches 3875 3881 +6
===========================================
+ Hits 32569 32922 +353
+ Misses 11782 11614 -168
|
cvat/apps/engine/model_utils.py
Outdated
ignore_conflicts: bool = ..., | ||
update_conflicts: bool | None = ..., | ||
update_fields: Sequence[str] | None = ..., | ||
unique_fields: Sequence[str] | None = ..., |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't this be replaced with **kwargs
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can, I just wanted it to be a "drop-in" replacement with the same signature. It can't be a pure drop-in, because now we require the first model argument, but this design offers good enough compatibility.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, but then why use the ellipses? Seems like you could copy the default values from the original signature as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used annotations from https://github.com/sbdchd/django-types/blob/062b1bfe5313b7e9f1a0a165fa5bf549e6b4addd/django-stubs/db/models/query.pyi#L52 that are used by VS Code, which is our default development environment, and what most developers will typically see in the editor help. The more official django-stubs repo has the same annotations. Ellipses are supposed to mean "unchanged", and this is enforced by the implementation. If the official defaults ever change, we will not have to do any changes in this function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and what most developers will typically see in the editor help.
I mean... would you rather see ellipses or actual values?
The more official django-stubs repo has the same annotations.
No it doesn't, check again. 🙂
Ellipses are supposed to mean "unchanged", and this is enforced by the implementation. If the official defaults ever change, we will not have to do any changes in this function.
I think the official defaults changing would imply a backwards compatibility break, so wouldn't it actually be useful for us to have hardcoded them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No it doesn't, check again. 🙂
Ok, probably I missed this.
I think the official defaults changing would imply a backwards compatibility break, so wouldn't it actually be useful for us to have hardcoded them?
I think it doesn't matter. Time spent on discussing this question is probably bigger than for changing the code in such case.
It seems Django is quite confident about the values, so I copied them from the "official" stub.
|
Motivation and context
bulk_create()
callsHow has this been tested?
Checklist
develop
branchLicense
Feel free to contact the maintainers if that's a concern.