MCPcopy
hub / github.com/hyperopt/hyperopt / delete_all

Method delete_all

hyperopt/mongoexp.py:462–478  ·  view source on GitHub ↗

Delete all jobs and attachments

(self, cond=None)

Source from the content-addressed store, hash-verified

460 raise OperationFailure(e)
461
462 def delete_all(self, cond=None):
463 """Delete all jobs and attachments"""
464 if cond is None:
465 cond = {}
466 try:
467 for d in self.jobs.find(filter=cond, projection=["_id", "_attachments"]):
468 logger.info("deleting job %s" % d["_id"])
469 for name, file_id in d.get("_attachments", []):
470 try:
471 self.gfs.delete(file_id)
472 except gridfs.errors.NoFile:
473 logger.error(f"failed to remove attachment {name}:{file_id}")
474 self.jobs.remove(d)
475 except pymongo.errors.OperationFailure as e:
476 # -- translate pymongo error class into hyperopt error class
477 # see insert() code for rationale.
478 raise OperationFailure(e)
479
480 def delete_all_error_jobs(self):
481 return self.delete_all(cond={"state": JOB_STATE_ERROR})

Callers 2

delete_all_error_jobsMethod · 0.95
delete_allMethod · 0.45

Calls 5

OperationFailureClass · 0.85
infoMethod · 0.80
getMethod · 0.80
deleteMethod · 0.80
errorMethod · 0.80

Tested by

no test coverage detected