How to kill waiting jobs in azure quantum workspace?

Rajiv Mistry 1 Reputation point
2024-08-08T02:41:41.3533333+00:00

I have a lot of jobs stuck for the simulator provider in azure quantum workspace that i need to cancel programmatically. How can i do so?

Azure Quantum
Azure Quantum
An Azure service that provides quantum computing and optimization solutions.
70 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Q&A Assist
    2024-08-08T02:41:41.39+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    To cancel a job in Azure Quantum, you can use the cancel() method of the job object. However, this method only works for jobs that are not yet in a final state, such as succeeded, failed, or cancelled. If you have a lot of jobs stuck in the waiting state, you can cancel them programmatically by iterating over the list of jobs and cancelling each one that is in the waiting state. Here's an example Python code snippet that cancels all jobs in the waiting state:

    for job in workspace.list_jobs():
        if job.status == 'waiting':
            job.cancel()
    

    Note that cancelling a job after it has started running may still result in partial or full billing for that job. For more information, see the billing documentation for your selected provider.


    References:

    0 comments No comments

  2. Prrudram-MSFT 24,451 Reputation points
    2024-08-10T10:22:16.7433333+00:00

    Hello @Rajiv Mistry

     Thank you for reaching out to the Microsoft Q&A platform.

    You can use the cancel_job method on the workspace to kill a job that has not completed yet.

     job = workspace.get_job('job-id')

    workspace.cancel_job(job)

    --please don't forget to "[Accept the answer]" if the reply is helpful--

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.