in src/graph_notebook/magics/graph_magic.py [0:0]
def cancel_load(self, line, local_ns: dict = None):
parser = argparse.ArgumentParser()
parser.add_argument('load_id', nargs="?", default='', help='loader id to check status for')
parser.add_argument('--all-in-queue', action='store_true', default=False,
help="Cancel all load jobs with LOAD_IN_QUEUE status.")
parser.add_argument('--silent', action='store_true', default=False, help="Display no output.")
parser.add_argument('--store-to', type=str, default='')
args = parser.parse_args(line.split())
loads_to_cancel = []
raw_res = {}
print_res = {}
if args.load_id:
loads_to_cancel.append(args.load_id)
elif args.all_in_queue:
all_job_ids = get_load_ids(self.client)[0]
for job_id in all_job_ids:
load_status_res = self.client.load_status(job_id)
load_status_res.raise_for_status()
this_res = load_status_res.json()
if this_res["payload"]["overallStatus"]["status"] == "LOAD_IN_QUEUE":
loads_to_cancel.append(job_id)
else:
print("Please specify either a single load_id or --all-in-queue.")
return
for load_id in loads_to_cancel:
cancel_res = self.client.cancel_load(load_id)
cancel_res.raise_for_status()
res = cancel_res.json()
if res:
raw_res[load_id] = res
print_res[load_id] = 'Cancelled successfully.'
else:
raw_res[load_id] = 'Something went wrong cancelling bulk load job.'
print_res[load_id] = 'Something went wrong cancelling bulk load job.'
if not args.silent:
if print_res:
print(json.dumps(print_res, indent=2))
else:
print("No cancellable load jobs were found.")
store_to_ns(args.store_to, raw_res, local_ns)