feat job cancellation#759
Open
Felipedino wants to merge 2 commits into
Open
Conversation
…ion, and improve job management - Added atomic file and directory write helpers in `atomic.py` to ensure safe writes and prevent data corruption during job cancellations. - Refactored `save_dataset` in `dashai_dataset.py` to utilize atomic directory operations for saving datasets. - Introduced a `cancel` method in `BaseJobQueue` to handle job cancellations, including both queued and running jobs. - Enhanced `HueyJobQueue` to support job cancellation and added a watchdog to detect crashed worker subprocesses. - Updated `BaseJob` to include `on_cancel` method for cleanup after job cancellation. - Implemented cleanup logic in `DatasetJob` to remove partially written artifacts upon cancellation. - Modified various job classes to support atomic operations for saving files. - Updated front-end components and translations to reflect new job cancellation functionality.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves job cancellation semantics across the stack and adds “atomic write” helpers intended to prevent partially-written artifacts when jobs are interrupted. It extends the Huey-backed queue to support cancelling queued/running jobs, adds cancellation cleanup hooks for jobs that write to disk/DB, and updates the UI/i18n to distinguish cancel vs delete.
Changes:
- Added atomic file/directory write helpers and adopted them in dataset/model/explainer persistence paths.
- Implemented job cancellation in the backend queue + API (including worker PID tracking and a watchdog for crashed workers).
- Updated the job queue UI and translations to show “Cancel job” for running jobs vs “Delete job” for terminal jobs.
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| DashAI/back/core/atomic.py | New atomic write utilities for files/dirs/paths used to reduce corruption on interruption. |
| DashAI/back/dependencies/job_queues/base_job_queue.py | Adds cancel() to the queue interface. |
| DashAI/back/dependencies/job_queues/huey_job_queue.py | Implements cancellation for queued/running jobs, persistent worker management, PID tracking, watchdog, and status guards. |
| DashAI/back/api/api_v1/endpoints/jobs.py | Updates endpoints to cancel (not delete) jobs, including async handling for cancellation. |
| DashAI/back/job/base_job.py | Adds ISOLATED/RESETS_WORKER flags and an on_cancel() hook for cleanup. |
| DashAI/back/job/dataset_job.py | Adds cancellation cleanup to remove partial artifacts + early persistence of file_path for cleanup. |
| DashAI/back/job/model_job.py | Uses atomic save path when persisting model runs. |
| DashAI/back/job/explainer_job.py | Uses atomic file writes for explanation artifacts. |
| DashAI/back/job/pipeline_job.py | Marks PipelineJob as non-isolated due to non-serializable args/async run. |
| DashAI/back/job/sync_components_job.py | Marks job non-isolated and forces worker reset due to registry mutation. |
| DashAI/back/dataloaders/classes/dashai_dataset.py | Writes datasets via atomic directory swap to avoid partial dataset directories. |
| DashAI/front/src/components/jobs/JobQueueWidget.jsx | UI now labels the action as cancel vs delete depending on job status. |
| DashAI/front/src/utils/i18n/locales/en/common.json | Adds cancelJob translation key. |
| DashAI/front/src/utils/i18n/locales/de/common.json | Adds cancelJob translation key. |
| DashAI/front/src/utils/i18n/locales/es/common.json | Adds cancelJob translation key. |
| DashAI/front/src/utils/i18n/locales/pt/common.json | Adds cancelJob translation key. |
| DashAI/front/src/utils/i18n/locales/zh/common.json | Adds cancelJob translation key. |
Comments suppressed due to low confidence (1)
DashAI/front/src/components/jobs/JobQueueWidget.jsx:577
- This button now represents either “Cancel job” (for
started) or “Delete job” (for other non-deleted statuses), butaria-labelis always "delete". Screen readers will announce the wrong action for running jobs. Make thearia-labelconditional to match the tooltip text.
<IconButton
edge="end"
aria-label="delete"
size="small"
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
… update explanation file format to pickle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces robust job cancellation and atomic file handling to prevent data corruption during job interruptions. It adds new atomic write utilities, improves backend job cancellation logic, and ensures that partially-written files and directories are properly cleaned up if a job is cancelled. The UI is also updated to distinguish between cancelling and deleting jobs.
Backend improvements:
atomic.pymodule with context managers (atomic_open,atomic_directory,atomic_save_path) for atomic file and directory writes, ensuring outputs are not left in a corrupt state if a process is killed mid-write.cancelmethod inBaseJobQueueand updated API endpoints to support cancelling both queued and running jobs, with improved logic to ensure jobs are properly terminated and resources released. [1] [2] [3]on_cancelhooks to jobs, especiallyDatasetJob, to clean up any temporary directories, partially-written datasets, and database records if a job is cancelled before completion. [1] [2] [3]Job isolation and worker management:
ISOLATEDandRESETS_WORKERflags toBaseJoband set them in jobs where necessary, allowing certain jobs to run inline without subprocess isolation or to trigger worker restarts when needed. [1] [2] [3]Frontend and localization:
These changes make job management more robust, prevent data corruption, and provide clearer UI feedback when cancelling or deleting jobs.