in src/graph_notebook/magics/graph_magic.py [0:0]
def statistics(self, line, local_ns: dict = None):
parser = argparse.ArgumentParser()
parser.add_argument('language', nargs='?', type=str.lower, default="propertygraph",
help=f'The language endpoint to use. Valid inputs: {STATISTICS_LANGUAGE_INPUTS}. '
f'Default: propertygraph.',
choices=STATISTICS_LANGUAGE_INPUTS)
parser.add_argument('-m', '--mode', type=str, default='',
help=f'The action to perform on the statistics endpoint. Valid inputs: {STATISTICS_MODES}. '
f'Default: `basic` if `--summary` is specified, otherwise `status`.')
parser.add_argument('--summary', action='store_true', default=False, help="Retrieves the graph summary.")
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())
mode = args.mode
if not mode:
mode = 'basic' if args.summary else 'status'
elif (args.summary and mode not in SUMMARY_MODES) or (not args.summary and mode not in STATISTICS_MODES):
if mode == 'refresh' and self.client.is_analytics_domain():
print("Refresh mode is unavailable for Neptune Analytics.")
return
err_endpoint_type, err_mode_list, err_default_mode = ("summary", SUMMARY_MODES[1:], "basic summary view") \
if args.summary else ("statistics", STATISTICS_MODES[1:], "status")
print(f'Invalid {err_endpoint_type} mode. Please specify one of: {err_mode_list}, '
f'or leave blank to retrieve {err_default_mode}.')
return
statistics_res = self.client.statistics(args.language, args.summary, mode)
if statistics_res.status_code == 400:
if args.summary:
process_statistics_400(statistics_res)
else:
process_statistics_400(statistics_res)
return
statistics_res.raise_for_status()
statistics_res_json = statistics_res.json()
if not args.silent:
print(json.dumps(statistics_res_json, indent=2))
store_to_ns(args.store_to, statistics_res_json, local_ns)