-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Reset some rq meta fields when retrying rq job #8719
base: develop
Are you sure you want to change the base?
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 changes involve modifications to job metadata handling during retries and enhancements to error handling within the export cache process. The Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant JobHandler
participant RQMeta
User->>JobHandler: Retry Job
JobHandler->>RQMeta: reset_meta_on_retry(current_rq_job.meta)
RQMeta-->>JobHandler: Updated Metadata
JobHandler->>User: Job Retried with Updated Metadata
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 (
|
Quality Gate passedIssues Measures |
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: 0
🧹 Outside diff range and nitpick comments (2)
cvat/apps/engine/rq_job_handler.py (1)
26-32
: Consider adding documentation and validationThe implementation is good, but could benefit from these enhancements:
- Add a docstring to
reset_meta_on_retry
explaining its purpose and parameters- Consider adding validation for meta_to_update keys to ensure they're valid RQJobMetaField values
Example enhancement:
@classmethod def reset_meta_on_retry(cls, meta_to_update: dict[RQJobMetaField, Any]) -> dict[RQJobMetaField, Any]: + """Filter out resettable fields from the job metadata during retry. + + Args: + meta_to_update: Dictionary containing job metadata + + Returns: + Dictionary with resettable fields removed + """ + # Validate that all keys are valid RQJobMetaField values + if not all(isinstance(k, str) and hasattr(RQJobMetaField, k) for k in meta_to_update): + raise ValueError("Invalid metadata field found") + resettable_fields = cls.get_resettable_fields() return { k: v for k, v in meta_to_update.items() if k not in resettable_fields }cvat/apps/dataset_manager/views.py (1)
Line range hint
82-84
: Consider addressing the parallel jobs concernThe TODO comment and the subsequent note raise important concerns:
- The plan to move to built-in RQ scheduler should be tracked
- The current implementation might lead to parallel jobs with the same name
Consider:
- Adding a unique suffix to retried job IDs to prevent parallel execution
- Creating a tracking issue for the scheduler migration
Would you like me to help create a GitHub issue to track these improvements?
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (2)
cvat/apps/dataset_manager/views.py
(2 hunks)cvat/apps/engine/rq_job_handler.py
(1 hunks)
🔇 Additional comments (5)
cvat/apps/engine/rq_job_handler.py (3)
9-9
: LGTM: Import changes are appropriate
The addition of Any
to the typing imports is necessary and correctly placed with other typing-related imports.
15-24
: LGTM: Well-structured metadata field management
The RQMeta
class and get_resettable_fields
method provide a clean, maintainable way to manage fields that should be reset during job retries. The chosen fields (exception, progress, task progress, and status) are logical choices for reset during retry operations.
15-32
: Verify integration with retry mechanism
The implementation looks solid, but let's verify its integration with the retry mechanism.
✅ Verification successful
Integration with retry mechanism is properly implemented
The implementation is correctly integrated with the retry mechanism:
- The
RQMeta
class is properly used in_retry_current_rq_job
function to reset metadata fields during job retries - The retry mechanism is correctly triggered when
LockNotAvailableError
occurs during export operations - Test coverage confirms the behavior:
- Verifies metadata reset during retries
- Validates retry behavior when lock acquisition fails
- Ensures job retry counter is properly set
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check how the new RQMeta class is integrated with retry logic
# Look for retry-related code that should use this new functionality
rg -l "retry.*rq.*job" --type py
# Check for any existing error handling of LockNotAvailableError
rg -l "LockNotAvailableError" --type py
# Look for test coverage
rg -l "test.*retry" --type py
Length of output: 324
Script:
#!/bin/bash
# Let's examine the retry implementation and LockNotAvailableError handling
# Check dataset_manager/views.py for retry implementation
rg -B 5 -A 10 "retry.*rq.*job|LockNotAvailableError" cvat/apps/dataset_manager/views.py
# Check how RQMeta is used in the codebase
rg -B 3 -A 3 "RQMeta"
# Look at the test implementation
rg -B 5 -A 10 "LockNotAvailableError" cvat/apps/dataset_manager/tests/test_rest_api_formats.py
Length of output: 13131
cvat/apps/dataset_manager/views.py (2)
23-23
: LGTM!
The import statement is correctly placed and the RQMeta
class is properly utilized in the code.
88-88
: Verify the implementation of RQMeta.reset_meta_on_retry
The change correctly introduces meta field reset during job retry. However, we should verify the implementation of the reset_meta_on_retry
method to ensure it properly handles all meta fields.
Let's check the implementation:
✅ Verification successful
Based on the results, I can now generate the final response since I have found the implementation of RQMeta.reset_meta_on_retry
and its usage context.
Implementation of RQMeta.reset_meta_on_retry is properly handling critical fields
The implementation correctly resets the essential meta fields during job retry through get_resettable_fields()
:
FORMATTED_EXCEPTION
: Clears previous error informationPROGRESS
: Resets overall progressTASK_PROGRESS
: Resets task-specific progressSTATUS
: Resets status messages
These fields are the key ones that need resetting when retrying a job, while preserving other important metadata like user info, task IDs, etc.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify the implementation of RQMeta.reset_meta_on_retry
# Find the RQMeta class definition and its reset_meta_on_retry method
rg -A 10 "class RQMeta" cvat/apps/engine/
# Find all usages of meta fields in RQ jobs to ensure we're resetting all necessary fields
rg "\.meta\b" --type py
Length of output: 9524
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #8719 +/- ##
========================================
Coverage 74.22% 74.23%
========================================
Files 401 401
Lines 43513 43522 +9
Branches 3953 3953
========================================
+ Hits 32298 32307 +9
Misses 11215 11215
|
Motivation and context
In the current implementation, if a job is rescheduled for later execution (due to a
LockNotAvailableError
raised during the export process), the job's metadata is not filtered when creating a new job. This PR introduces RQ job metadata fields that must be reset when rescheduling a job.How has this been tested?
Checklist
develop
branch- [ ] I have updated the documentation accordingly- [ ] I have increased versions of npm packages if it is necessary(cvat-canvas,
cvat-core,
cvat-data and
cvat-ui)
License
Feel free to contact the maintainers if that's a concern.
Summary by CodeRabbit