Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion azure-quantum/azure/quantum/cirq/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def cancel(self):

def delete(self):
"""Delete the given job."""
self._azure_job.workspace.cancel_job(self._azure_job)
self._azure_job.workspace.delete_job(self._azure_job)

@rigidit rigidit Jul 13, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would you like to update also
azure-quantum\azure\quantum\cirq\targets\ionq.py?
maybe other places where delete operation would be appropriate?


def __str__(self) -> str:
return f"azure.quantum.cirq.Job(job_id={self.job_id()})"
14 changes: 14 additions & 0 deletions azure-quantum/azure/quantum/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,20 @@ def cancel_job(self, job: Job) -> Job:
job.id)
return Job(self, details)

def delete_job(self, job: Job) -> None:
"""
Deletes a job.

:param job:
Job to delete.
"""
Comment on lines +467 to +473
client = self._get_jobs_client()
client.delete(
self.subscription_id,
self.resource_group,
self.name,
job.details.id)

def get_job(self, job_id: str) -> Job:
"""
Returns the job corresponding to the given id.
Expand Down
28 changes: 28 additions & 0 deletions azure-quantum/tests/test_workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,34 @@ def test_workspace_cancel_job_success():
assert result.details.status == "Cancelled"
assert result.id == job_id

def test_workspace_delete_job_success():
ws = WorkspaceMock(
subscription_id=SUBSCRIPTION_ID,
resource_group=RESOURCE_GROUP,
name=WORKSPACE
)

job_id = "test-delete-success"

details = JobDetails(
id=job_id,
name=job_id,
container_uri="http://example.com/container",
input_data_format="microsoft.resource-estimates.v2",
provider_id="ionq",
target="ionq.simulator",
status="Executing"
Comment on lines +399 to +403
)

ws._client.services.jobs._store.append(details)

job = Job(ws, details)

ws.delete_job(job)

stored_job = ws.get_job(job_id)

assert stored_job.details.status == "Cancelled"
Comment on lines +410 to +414

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so when we delete the job the status should be "Cancelled"? what's the difference with cancel operation then?


def test_workspace_user_agent_appid():
app_id = "MyEnvVarAppId"
Expand Down