Skip to content

Add silent option to %%graph_notebook_config #641

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Starting with v1.31.6, this file will contain a record of major features and upd

## Upcoming
- 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))
- 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))
Expand Down
17 changes: 11 additions & 6 deletions src/graph_notebook/magics/graph_magic.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,30 +451,35 @@ def graph_notebook_config(self, line='', cell='', local_ns: dict = None):
parser.add_argument('mode', nargs='?', default='show',
help='mode (default=show) [show|reset|silent]')
parser.add_argument('--store-to', type=str, default='', help='store query result to this variable')
parser.add_argument('--silent', action='store_true', default=False, help="Display no output.")
args = parser.parse_args(line.split())

if cell != '':
data = json.loads(cell)
config = get_config_from_dict(data, neptune_hosts=self.neptune_cfg_allowlist)
self.graph_notebook_config = config
self._generate_client_from_config(config)
print('set notebook config to:')
print(json.dumps(self.graph_notebook_config.to_dict(), indent=4))
if not args.silent:
print('set notebook config to:')
print(json.dumps(self.graph_notebook_config.to_dict(), indent=4))
elif args.mode == 'reset':
self.graph_notebook_config = get_config(self.config_location, neptune_hosts=self.neptune_cfg_allowlist)
print('reset notebook config to:')
print(json.dumps(self.graph_notebook_config.to_dict(), indent=4))
if not args.silent:
print('reset notebook config to:')
print(json.dumps(self.graph_notebook_config.to_dict(), indent=4))
elif args.mode == 'silent':
"""
silent option to that our neptune_menu extension can receive json instead
of python Configuration object
"""
config_dict = self.graph_notebook_config.to_dict()
store_to_ns(args.store_to, json.dumps(config_dict, indent=4), local_ns)
return print(json.dumps(config_dict, indent=4))
if not args.silent:
return print(json.dumps(config_dict, indent=4))
else:
config_dict = self.graph_notebook_config.to_dict()
print(json.dumps(config_dict, indent=4))
if not args.silent:
print(json.dumps(config_dict, indent=4))

store_to_ns(args.store_to, json.dumps(self.graph_notebook_config.to_dict(), indent=4), local_ns)

Expand Down
Loading