feat(python-notebook-migration): add backend endpoint to delete a workflow's stored notebook and mapping - #7132
Conversation
Automated Reviewer SuggestionsBased on the
|
|
/request-review @mengw15 |
There was a problem hiding this comment.
Pull request overview
Adds a new REST endpoint to the notebook-migration backend service to delete a workflow’s stored notebook and rely on FK cascade to remove the associated workflow→notebook mapping, enabling an end-to-end “discard migrated notebook” flow.
Changes:
- Added
POST /notebook-migration/delete-notebook-and-mappingthat deletes thenotebookrow bywidand returns{"success": true, "deleted": <count>}. - Added resource-spec coverage for successful deletion (including cascade), idempotent no-op deletion, 403 on insufficient access, and 500 on malformed JSON.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| notebook-migration-service/src/main/scala/org/apache/texera/service/resource/NotebookMigrationResource.scala | Adds the new delete endpoint implementation and JAX-RS route. |
| notebook-migration-service/src/test/scala/org/apache/texera/service/resource/NotebookMigrationResourceSpec.scala | Adds tests validating delete behavior, authorization, idempotency, and error path. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
wait wait this PR has no CI ran. I think this python-notebook-migration service is not in labeler system correctly. Can we fix that first? |
@Yicong-Huang I think the CI is not running because we added this service in the labeler system in PR #6945, which is waiting for your input to be merged. |
|
ah. let's merge that one first. I will change this to draft. this PR CI has to be retriggered. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #7132 +/- ##
============================================
- Coverage 79.57% 79.46% -0.11%
+ Complexity 3829 3783 -46
============================================
Files 1160 1159 -1
Lines 46164 45878 -286
Branches 5135 5111 -24
============================================
- Hits 36736 36458 -278
- Misses 7795 7801 +6
+ Partials 1633 1619 -14
*This pull request uses carry forward flags. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
What changes were proposed in this PR?
Adds a single backend REST endpoint to the notebook-migration service that deletes a workflow's stored notebook and its workflow-to-notebook mapping.
Until now the service could store and fetch a workflow's notebook (
store-notebook-and-mapping,fetch-notebook-and-mapping) but had no way to remove one. Once stored, a notebook and its mapping stayed in the database with no server-side operation to clear them. This left the persisted rows behind whenever a user closed or discarded a migrated notebook, and it blocked the end-to-end deletion flow, which needs a backend call to remove the notebook before the UI can reset the state that reflects whether a notebook exists.New endpoint:
POST /notebook-migration/delete-notebook-and-mapping.Behavior:
widfrom the JSON body.vidis not required:notebook.widis UNIQUE (one notebook per workflow), sowidalone identifies the row.notebookrow for the workflow. Theworkflow_notebook_mappingrows are removed by the existingON DELETE CASCADEforeign key, so a single delete clears both tables and cannot leave them inconsistent.{"success": true, "deleted": <count>}, where the count is 1 when a notebook was removed and 0 when nothing was stored, so the caller can tell a real deletion from a no-op.deleted: 0.POST with a JSON body is used to stay consistent with the existing store and fetch endpoints, which already read
widfrom a JSON body.This is backend only. The frontend service method, the close-panel wiring, and any Jupyter-server cleanup are intentionally left to the follow-on end-to-end deletion work that consumes this endpoint.
Note: if the workflow itself is deleted, the notebook and mapping are already removed by existing cascades, so this endpoint targets the case where the workflow survives but its notebook should be discarded.
Any related issues, documentation, discussions?
Closes #7131
Parent issue #4301
How was this PR tested?
Added resource spec cases in
NotebookMigrationResourceSpeccovering:deleted: 1.deleted: 0when nothing is stored.Was this PR authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Claude Opus 4.8)