diff --git a/ChangeLog.md b/ChangeLog.md index e9ff12fb..25b8fd77 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -8,6 +8,7 @@ Starting with v1.31.6, this file will contain a record of major features and upd - Path: 01-Neptune-Database > 03-Sample-Applications > 07-Games-Industry-Graphs - Added `--connected-table` option to magics with table widget output ([Link to PR](https://github.com/aws/graph-notebook/pull/634)) - Added `--silent` option to the `%%graph_notebook_config` line and cell magics ([Link to PR](https://github.com/aws/graph-notebook/pull/641)) +- Added helpful redirect messaging for service-specific Neptune magics ([Link to PR](https://github.com/aws/graph-notebook/pull/643)) - Changed `%%gremlin --store-to` to also store exceptions from non-Neptune queries ([Link to PR](https://github.com/aws/graph-notebook/pull/635)) - Fixed broken `--help` option for `%%gremlin` ([Link to PR](https://github.com/aws/graph-notebook/pull/630)) - Fixed openCypher query bug regression in the [`01-About-the-Neptune-Notebook`](https://github.com/aws/graph-notebook/blob/main/src/graph_notebook/notebooks/01-Getting-Started/01-About-the-Neptune-Notebook.ipynb) sample ([Link to PR](https://github.com/aws/graph-notebook/pull/631)) diff --git a/src/graph_notebook/decorators/decorators.py b/src/graph_notebook/decorators/decorators.py index 9d554086..0d3343e3 100644 --- a/src/graph_notebook/decorators/decorators.py +++ b/src/graph_notebook/decorators/decorators.py @@ -21,6 +21,17 @@ check_if_access_regex = re.compile(r'^[a-zA-Z0-9_]+((\[\'.*?\'\])|(\[\".*?\"\])|(\[.*?\]))+$') var_name_regex = re.compile(r'^[^\[]*') +db_to_graph_redirects = { + "statistics": "summary", + "db_reset": "graph_reset" +} + +graph_to_db_redirects = { + "get_graph": "status", + "reset_graph": "db_reset", + "graph_reset": "db_reset" +} + def get_variable_injection_name_and_indices(raw_var: str, keys_are_str: bool = True): # get the name of the dict @@ -138,12 +149,15 @@ def neptune_db_only(func): @functools.wraps(func) def check_neptune_db(*args, **kwargs): self = args[0] + magic_name = func.__name__ if not hasattr(self.graph_notebook_config, 'neptune_service'): return func(*args, **kwargs) else: service_type = self.graph_notebook_config.neptune_service if service_type == NEPTUNE_ANALYTICS_SERVICE_NAME: print(f'This magic is unavailable for Neptune Analytics.') + if magic_name in db_to_graph_redirects: + print(f'\nPlease use %{db_to_graph_redirects[magic_name]} instead.') return else: return func(*args, **kwargs) @@ -155,12 +169,15 @@ def neptune_graph_only(func): @functools.wraps(func) def check_neptune_graph(*args, **kwargs): self = args[0] + magic_name = func.__name__ if not hasattr(self.graph_notebook_config, 'neptune_service'): return func(*args, **kwargs) else: service_type = self.graph_notebook_config.neptune_service if service_type == NEPTUNE_DB_SERVICE_NAME: print(f'This magic is unavailable for Neptune DB.') + if magic_name in graph_to_db_redirects: + print(f'\nPlease use %{graph_to_db_redirects[magic_name]} instead.') return else: return func(*args, **kwargs)