[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [HTCondor-users] Removed all jobs from a cluster via Python binding



Hi Gagan,

It looks like you are missing the curly brackets to insert the clusterid number into the constraint f string:
result = schedd.act(htcondor.JobAction.Remove, f'ClusterId == clusterId') -> f'ClusterId == {clusterId}'

Hope that fixes your issue,
Cole Bollig

From: HTCondor-users <htcondor-users-bounces@xxxxxxxxxxx> on behalf of gagan tiwari <gagan.tiwari@xxxxxxxxxxxxxxxxxx>
Sent: Friday, January 20, 2023 10:49 AM
To: HTCondor-Users Mail List <htcondor-users@xxxxxxxxxxx>
Subject: [HTCondor-users] Removed all jobs from a cluster via Python binding
 
Hi Guys,
                    I need our condor users to be able to remove all of their jobs from a particular  cluster by specifying just cluster id. 

I am using following python codes to achieve this :- 

 In below codes clusid is the int variable that stores cluster id given by the user 

ads = schedd.query(
                                constraint=f'ClusterId == {clusid}',     
                                projection=["ClusterId"],
                                )
                        for ad in ads:
                                clusterId = ad['ClusterId']
                                break
                        result = schedd.act(htcondor.JobAction.Remove, f'ClusterId == clusterId')
                        print(f"Jobs successfully removed: {result['TotalSuccess']}")

But above codes remove all jobs from all clusters instead of all jobs from that particular cluster id. 

Please let me know what I am missing here. 

Thanks,
Gagan