From 1b3c5ee363df329ad113149bd1e048e47a786fb8 Mon Sep 17 00:00:00 2001 From: Michael Chin Date: Tue, 1 Oct 2024 02:01:17 -0700 Subject: [PATCH 1/2] Use /queries endpoint for %%oc --- src/graph_notebook/neptune/client.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/graph_notebook/neptune/client.py b/src/graph_notebook/neptune/client.py index 75cf0200..84d6754d 100644 --- a/src/graph_notebook/neptune/client.py +++ b/src/graph_notebook/neptune/client.py @@ -541,23 +541,31 @@ def opencypher_http(self, query: str, headers: dict = None, explain: str = None, if headers is None: headers = {} - url = f'{self._http_protocol}://{self.host}:{self.port}/' + url = f'{self._http_protocol}://{self.host}' if self.is_neptune_domain(): - if 'content-type' not in headers: - headers['content-type'] = 'application/x-www-form-urlencoded' - url += 'openCypher' data = {} + if self.is_analytics_domain(): + url += f'/queries' + data['language'] = 'opencypher' + else: + if 'content-type' not in headers: + headers['content-type'] = 'application/x-www-form-urlencoded' + url += f':{self.port}/openCypher' if plan_cache: if plan_cache not in OPENCYPHER_PLAN_CACHE_MODES: print('Invalid --plan-cache mode specified, defaulting to auto.') else: - if self.is_analytics_domain(): - data['planCache'] = plan_cache - elif plan_cache != 'auto': - query = set_plan_cache_hint(query, plan_cache) + if plan_cache != 'auto': + if self.is_analytics_domain(): + data['planCache'] = plan_cache + else: + query = set_plan_cache_hint(query, plan_cache) data['query'] = query if explain: + if self.is_analytics_domain(): + data['explain.mode'] = explain + data['explain-mode'] = explain data['explain'] = explain headers['Accept'] = "text/html" if query_params: From 2c32973053f15cf4da7737ae7ddfdbf761398877 Mon Sep 17 00:00:00 2001 From: Michael Chin Date: Tue, 1 Oct 2024 02:09:42 -0700 Subject: [PATCH 2/2] update changelog --- ChangeLog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog.md b/ChangeLog.md index 082eb03a..43933f34 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -4,6 +4,7 @@ Starting with v1.31.6, this file will contain a record of major features and upd ## Upcoming +- Updated `%%oc` to use the `/queries` endpoint for Neptune Analytics ([Link to PR](https://github.com/aws/graph-notebook/pull/705)) - Added experimental TinkerPop 4.0 support ([Link to PR](https://github.com/aws/graph-notebook/pull/704)) - Added documentation for group keys in `%%graph_notebook_vis_options` ([Link to PR](https://github.com/aws/graph-notebook/pull/703)) - Enabled `--query-timeout` on `%%oc explain` for Neptune Analytics ([Link to PR](https://github.com/aws/graph-notebook/pull/701))