-
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
Fix Pylint warnings in migrations #8869
Conversation
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughThe pull request introduces significant changes to the CVAT (Computer Vision Annotation Tool) migration scripts. The modifications focus on restructuring data models, adding new models like Changes
Sequence DiagramsequenceDiagram
participant User
participant Task
participant Data
participant Profile
participant Review
User ->> Profile: Create/Update Profile
User ->> Task: Create Task
Task ->> Data: Associate Data
User ->> Review: Create Job Review
Review ->> Task: Link to Job
Poem
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 1
🧹 Nitpick comments (1)
cvat/apps/engine/migrations/0038_manifest.py (1)
113-113
: Consider handling zero-step cases
Using the regexr"step\s*=\s*([1-9]\d*)"
excludes0
as a valid step. If a step of0
is ever expected or mistakenly set, it will be silently ignored. Ensure this logic is correct or extend it to handle that scenario if needed.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
cvat/apps/engine/migrations/0024_auto_20191023_1025.py
(1 hunks)cvat/apps/engine/migrations/0034_auto_20201125_1426.py
(1 hunks)cvat/apps/engine/migrations/0038_manifest.py
(1 hunks)
🔇 Additional comments (1)
cvat/apps/engine/migrations/0024_auto_20191023_1025.py (1)
149-149
: Double-check potential out-of-range usage in get_preview(0)
If reader
expects the first frame to be index 1 or if there are no frames available, calling get_preview(0)
might cause unexpected behavior or an error. Ensure that 0
is always a valid frame index, or add error handling to gracefully handle scenarios where no frames exist.
User = apps.get_model('auth', 'User') | ||
Profile = apps.get_model('engine', 'Profile') | ||
for user in User.objects.all(): | ||
profile = Profile() | ||
profile.user = user | ||
profile.save() |
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.
🛠️ Refactor suggestion
Prevent potential profile duplication issues
Creating a profile for every user without checking if a user profile already exists can lead to collisions or integrity errors, especially if some users already have associated profiles. Consider verifying the existence of a profile before creating a new one.
Below is a possible fix:
def create_profile(apps, schema_editor):
User = apps.get_model('auth', 'User')
Profile = apps.get_model('engine', 'Profile')
for user in User.objects.all():
- profile = Profile()
- profile.user = user
- profile.save()
+ if not Profile.objects.filter(user=user).exists():
+ Profile.objects.create(user=user)
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
User = apps.get_model('auth', 'User') | |
Profile = apps.get_model('engine', 'Profile') | |
for user in User.objects.all(): | |
profile = Profile() | |
profile.user = user | |
profile.save() | |
User = apps.get_model('auth', 'User') | |
Profile = apps.get_model('engine', 'Profile') | |
for user in User.objects.all(): | |
if not Profile.objects.filter(user=user).exists(): | |
Profile.objects.create(user=user) |
dca523d
to
8d40fd2
Compare
Quality Gate passedIssues Measures |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #8869 +/- ##
===========================================
+ Coverage 73.87% 73.91% +0.03%
===========================================
Files 408 408
Lines 44086 44108 +22
Branches 3986 3986
===========================================
+ Hits 32570 32603 +33
+ Misses 11516 11505 -11
|
Motivation and context
How has this been tested?
Checklist
develop
branch(cvat-canvas,
cvat-core,
cvat-data and
cvat-ui)
License
Feel free to contact the maintainers if that's a concern.
Summary by CodeRabbit
New Features
Data
model to enhance task data management.Profile
model for user profiles, establishing a one-to-one relationship with users.Review
,Issue
, andComment
to support enhanced job and review functionalities.reviewer
field to the job model for improved user assignment.Bug Fixes
create_profile
function for proper execution.Improvements