in src/graph_notebook/magics/graph_magic.py [0:0]
def load_ids(self, line, local_ns: dict = None):
parser = argparse.ArgumentParser()
parser.add_argument('--details', action='store_true', default=False,
help="Display status details for each load job. Most recent jobs are listed first.")
parser.add_argument('--limit', type=int, default=maxsize,
help='If --details is True, only return the x most recent load job statuses. '
'Defaults to sys.maxsize.')
parser.add_argument('-ct', '--connected-table', action='store_true', default=False,
help=f'Dynamically load jQuery and DataTables resources for iTables. For more information, see: '
f'https://mwouts.github.io/itables/quick_start.html#offline-mode-versus-connected-mode')
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())
ids, res = get_load_ids(self.client)
if not ids:
labels = [widgets.Label(value="No load IDs found.")]
else:
if args.details:
res = {}
res_table = []
for index, label_id in enumerate(ids):
load_status_res = self.client.load_status(label_id)
load_status_res.raise_for_status()
this_res = load_status_res.json()
res[label_id] = this_res
res_row = {}
res_row["loadId"] = label_id
res_row["status"] = this_res["payload"]["overallStatus"]["status"]
res_row.update(this_res["payload"]["overallStatus"])
if "feedCount" in this_res["payload"]:
res_row["feedCount"] = this_res["payload"]["feedCount"]
else:
res_row["feedCount"] = "N/A"
res_table.append(res_row)
if index + 1 == args.limit:
break
if not args.silent:
tab = widgets.Tab()
table_output = widgets.Output(layout=DEFAULT_LAYOUT)
raw_output = widgets.Output(layout=DEFAULT_LAYOUT)
tab.children = [table_output, raw_output]
tab.set_title(0, 'Table')
tab.set_title(1, 'Raw')
display(tab)
results_df = pd.DataFrame(res_table)
results_df.insert(0, "#", range(1, len(results_df) + 1))
with table_output:
init_notebook_mode(connected=args.connected_table)
show(results_df,
connected=args.connected_table,
scrollX=True,
scrollY="475px",
columnDefs=[
{"width": "5%", "targets": 0},
{"className": "nowrap dt-left", "targets": "_all"},
{"createdCell": JavascriptFunction(index_col_js), "targets": 0},
{"createdCell": JavascriptFunction(cell_style_js), "targets": "_all"}
],
paging=True,
scrollCollapse=True,
lengthMenu=[DEFAULT_PAGINATION_OPTIONS, DEFAULT_PAGINATION_MENU],
pageLength=10,
buttons=[
"pageLength",
{
"extend": "copyHtml5",
"text": "Copy",
"exportOptions": RESULTS_EXPORT_OPTIONS
},
{
"extend": "csvHtml5",
"title": LOAD_IDS_FILENAME,
"text": "Download CSV",
"exportOptions": RESULTS_EXPORT_OPTIONS
},
{
"extend": "excelHtml5",
"filename": LOAD_IDS_FILENAME,
"title": None,
"text": "Download XLSX",
"exportOptions": RESULTS_EXPORT_OPTIONS
}
]
)
with raw_output:
print(json.dumps(res, indent=2))
else:
labels = [widgets.Label(value=label_id) for label_id in ids]
if not args.details and not args.silent:
vbox = widgets.VBox(labels)
display(vbox)
store_to_ns(args.store_to, res, local_ns)