Add support for job delete operation#758
Conversation
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
There was a problem hiding this comment.
Pull request overview
Adds first-class support for deleting Azure Quantum jobs through the Workspace API, and wires that operation into the Cirq integration so cirq.Job.delete() uses the delete operation instead of cancel.
Changes:
- Add
Workspace.delete_job()that calls the underlying jobs clientdeleteoperation. - Update
azure.quantum.cirq.Job.delete()to invokeworkspace.delete_job(...). - Add a unit test intended to validate the new delete behavior.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| azure-quantum/azure/quantum/workspace.py | Introduces delete_job() API on Workspace calling the jobs delete operation. |
| azure-quantum/azure/quantum/cirq/job.py | Switches Cirq job deletion to use Workspace.delete_job() instead of cancellation. |
| azure-quantum/tests/test_workspace.py | Adds a new test case covering job delete behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ws.delete_job(job) | ||
|
|
||
| stored_job = ws.get_job(job_id) | ||
|
|
||
| assert stored_job.details.status == "Cancelled" |
|
@v-elegacheva please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
|
|
||
| stored_job = ws.get_job(job_id) | ||
|
|
||
| assert stored_job.details.status == "Cancelled" |
There was a problem hiding this comment.
so when we delete the job the status should be "Cancelled"? what's the difference with cancel operation then?
There was a problem hiding this comment.
That is a good question... From my understanding, the "Cancelled" status is coming from the current WorkspaceMock implementation instead of actual service behavior.
During the E2E validation, a deleted job was no longer retrievable after delete_job() succeeded. It did not transition to a "deleted" status, it just disappeared from the service.
I could update the mock to use a "Deleted" status instead, but I am not sure if "Deleted" would be a valid job status in the real service. My understanding is that once a job is deleted, it is removed rather than entering a new status. How would you prefer I proceed?
There was a problem hiding this comment.
see comment above from Copilot: "Consider updating the mock delete implementation to remove the job from the store and changing this test to assert ws.get_job(job_id) raises (e.g., KeyError in the mock, ResourceNotFoundError in real client), so the test actually covers delete semantics."
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
| def delete_job(self, job: Job) -> None: | ||
| """Deletes a job. | ||
|
|
||
| Note: For service API versions before 2025-12-01-preview, the underlying |
There was a problem hiding this comment.
I think _client directory contains autogenerated client based on one of the latest api versions >= 2025-12-01-preview supported by our typespecs, so we can probably just remove comment that it was cancellation request before that version.
There was a problem hiding this comment.
Sounds good! I will remove comment
Remove outdated note about job deletion behavior.
add job delete operation support