|
44 | 44 | LOAD_JOB_MODES, MODE_AUTO, FINAL_LOAD_STATUSES, SPARQL_ACTION, FORMAT_CSV, FORMAT_OPENCYPHER, FORMAT_NTRIPLE, \ |
45 | 45 | FORMAT_NQUADS, FORMAT_RDFXML, FORMAT_TURTLE, STREAM_RDF, STREAM_PG, STREAM_ENDPOINTS, \ |
46 | 46 | NEPTUNE_CONFIG_HOST_IDENTIFIERS, is_allowed_neptune_host, \ |
47 | | - STATISTICS_LANGUAGE_INPUTS, STATISTICS_MODES, SUMMARY_MODES |
| 47 | + STATISTICS_LANGUAGE_INPUTS, STATISTICS_MODES, SUMMARY_MODES, \ |
| 48 | + SPARQL_EXPLAIN_MODES, OPENCYPHER_EXPLAIN_MODES |
48 | 49 | from graph_notebook.network import SPARQLNetwork |
49 | 50 | from graph_notebook.network.gremlin.GremlinNetwork import parse_pattern_list_str, GremlinNetwork |
50 | 51 | from graph_notebook.visualization.rows_and_columns import sparql_get_rows_and_columns, opencypher_get_rows_and_columns |
@@ -516,9 +517,9 @@ def sparql(self, line='', cell='', local_ns: dict = None): |
516 | 517 | help='prefix path to sparql endpoint. For example, if "foo/bar" were specified, ' |
517 | 518 | 'the endpoint called would be host:port/foo/bar') |
518 | 519 | parser.add_argument('--expand-all', action='store_true') |
519 | | - parser.add_argument('--explain-type', default='dynamic', |
520 | | - help='explain mode to use when using the explain query mode', |
521 | | - choices=['dynamic', 'static', 'details']) |
| 520 | + parser.add_argument('--explain-type', type=str.lower, default='dynamic', |
| 521 | + help=f'Explain mode to use when using the explain query mode. ' |
| 522 | + f'Expected values: ${SPARQL_EXPLAIN_MODES}') |
522 | 523 | parser.add_argument('--explain-format', default='text/html', help='response format for explain query mode', |
523 | 524 | choices=['text/csv', 'text/html']) |
524 | 525 | parser.add_argument('-m', '--media-type', type=str, default='', |
@@ -804,6 +805,8 @@ def gremlin(self, line, cell, local_ns: dict = None): |
804 | 805 | parser = argparse.ArgumentParser() |
805 | 806 | parser.add_argument('query_mode', nargs='?', default='query', |
806 | 807 | help='query mode (default=query) [query|explain|profile]') |
| 808 | + parser.add_argument('--explain-type', type=str.lower, default='', |
| 809 | + help='Explain mode to use when using the explain query mode.') |
807 | 810 | parser.add_argument('-p', '--path-pattern', default='', help='path pattern') |
808 | 811 | parser.add_argument('-g', '--group-by', type=str, default='T.label', |
809 | 812 | help='Property used to group nodes (e.g. code, T.region) default is T.label') |
@@ -881,7 +884,8 @@ def gremlin(self, line, cell, local_ns: dict = None): |
881 | 884 | transport_args = {'max_content_length': args.max_content_length} |
882 | 885 |
|
883 | 886 | if mode == QueryMode.EXPLAIN: |
884 | | - res = self.client.gremlin_explain(cell) |
| 887 | + res = self.client.gremlin_explain(cell, |
| 888 | + args={'explain.mode': args.explain_type} if args.explain_type else {}) |
885 | 889 | res.raise_for_status() |
886 | 890 | # Replace strikethrough character bytes, can't be encoded to ASCII |
887 | 891 | explain_bytes = res.content.replace(b'\xcc', b'-') |
@@ -2685,9 +2689,9 @@ def handle_opencypher_query(self, line, cell, local_ns): |
2685 | 2689 | This method in its own handler so that the magics %%opencypher and %%oc can both call it |
2686 | 2690 | """ |
2687 | 2691 | parser = argparse.ArgumentParser() |
2688 | | - parser.add_argument('--explain-type', default='dynamic', |
2689 | | - help='explain mode to use when using the explain query mode', |
2690 | | - choices=['dynamic', 'static', 'details', 'debug']) |
| 2692 | + parser.add_argument('--explain-type', type=str.lower, default='dynamic', |
| 2693 | + help=f'Explain mode to use when using the explain query mode. ' |
| 2694 | + f'Accepted values: ${OPENCYPHER_EXPLAIN_MODES}') |
2691 | 2695 | parser.add_argument('-qp', '--query-parameters', type=str, default='', |
2692 | 2696 | help='Parameter definitions to apply to the query. This option can accept a local variable ' |
2693 | 2697 | 'name, or a string representation of the map.') |
|
0 commit comments