feat(api): add scheduled cleanup task for specific workflow logs#31843
feat(api): add scheduled cleanup task for specific workflow logs#31843hjlarry merged 18 commits intolanggenius:mainfrom
Conversation
Add a new Celery task to clean up workflow run logs for specific workflows with an independent retention policy. This allows setting different retention periods for high-volume workflows without affecting others. Configuration: - SPECIFIC_WORKFLOW_LOG_CLEANUP_ENABLED: enable/disable the task - SPECIFIC_WORKFLOW_IDS: comma-separated workflow IDs to clean - SPECIFIC_WORKFLOW_LOG_RETENTION_DAYS: retention period (default: 7 days) The task runs daily at 3:00 AM and cascades deletion to all related records. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Summary of ChangesHello @razerzhang, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a significant enhancement to workflow log management by implementing a dedicated, scheduled cleanup task for specific workflows. This allows for more granular control over log retention, enabling different policies for high-volume workflows without affecting the general log retention settings. The change improves system maintainability and resource utilization by providing targeted log cleanup capabilities. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a new scheduled task to clean up workflow run logs for specific workflows, allowing for more granular retention policies. The changes, including new configuration options and the Celery task implementation, are well-structured and follow good practices like batch processing and retry mechanisms.
My primary feedback concerns code duplication. The new cleanup logic in clean_specific_workflow_logs.py is nearly identical to existing cleanup tasks. I've provided a comment with a suggestion to refactor this duplicated code into a shared utility to enhance long-term maintainability.
|
Please link an issue in the description. |
crazywoola
left a comment
There was a problem hiding this comment.
These variables should be add to env fires as well.
There was a problem hiding this comment.
Pull request overview
This PR adds a scheduled Celery task to clean up workflow run logs for specific workflows with an independent retention policy, enabling different retention periods for high-volume workflows.
Changes:
- New scheduled task
clean_specific_workflow_logsthat runs daily at 3:00 AM - Configuration options for enabling the task, specifying workflow IDs, and setting retention days
- Cascading deletion of all related records (messages, conversations, workflow logs, etc.)
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| api/schedule/clean_specific_workflow_logs.py | Implements the cleanup task with batch processing, retry logic, and cascading deletion of related records |
| api/extensions/ext_celery.py | Registers the new cleanup task in the Celery beat schedule at 3:00 AM |
| api/configs/feature/init.py | Adds configuration class for the specific workflow log cleanup feature |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Add the new environment variables for specific workflow log cleanup to both api/.env.example and docker/.env.example files. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…low log cleanup Replace direct WorkflowRun model queries with repository layer methods (count_expired_runs_by_workflow_ids, get_expired_run_ids_by_workflow_ids) and change Celery task queue from "dataset" to "retention". Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request enhances the workflow log cleanup task by adding an optional filter to target specific workflow IDs. The implementation refactors the existing cleanup logic to use repository patterns for data access and deletion.
However, there are a few points to consider:
- The pull request description seems to be out of sync with the implementation. It mentions a 'new Celery task' and an 'independent retention policy' with a new configuration variable, but the code modifies an existing task and reuses the global retention policy. It would be beneficial to update the description to match the actual changes.
- There's a potential risk in the current implementation where an empty
WORKFLOW_LOG_CLEANUP_SPECIFIC_WORKFLOW_IDSvalue will cause the task to clean up logs for all workflows. This could be surprising and lead to unintended data loss. I've added a comment with more details. - I've also suggested a minor refactoring to improve the readability of the batch deletion logic.
Overall, the changes are a good step towards more granular control over log cleanup. Addressing the points above will improve the safety and maintainability of the feature.
…ggenius#31843) Co-authored-by: 章润喆 <zhangrunzhe@zhangrunzhedeMacBook-Air.local> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: hjlarry <hjlarry@163.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: hj24 <mambahj24@gmail.com>
Add a new Celery task to clean up workflow run logs for specific workflows with an independent retention policy. This allows setting different retention periods for high-volume workflows without affecting others.
Configuration:
The task runs daily at 3:00 AM and cascades deletion to all related records.
close #31883
Summary
Screenshots
Checklist
make lintandmake type-check(backend) andcd web && npx lint-staged(frontend) to appease the lint gods