Skip to content

Commit 900352e

Browse files
authored
Fix --store-to option for several magics (#463)
* Fix --store-to for %statistics and %summary * update changelog --------- Co-authored-by: Michael Chin <chnmch@amazon.com>
1 parent 4e5fba8 commit 900352e

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

ChangeLog.md

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
Starting with v1.31.6, this file will contain a record of major features and updates made in each release of graph-notebook.
44

55
## Upcoming
6+
- Fixed `--store-to` option for several magics ([Link to PR](https://github.com/aws/graph-notebook/pull/463))
67

78
## Release 3.7.3 (March 14, 2023)
89
- Fixed detailed mode output for graph summary requests ([Link to PR](https://github.com/aws/graph-notebook/pull/461))

src/graph_notebook/magics/graph_magic.py

+9-10
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,8 @@ def stream_viewer(self,line):
416416
viewer.show()
417417

418418
@line_magic
419+
@needs_local_scope
420+
@display_exceptions
419421
def statistics(self, line, local_ns: dict = None):
420422
parser = argparse.ArgumentParser()
421423
parser.add_argument('language', nargs='?', type=str.lower, default="propertygraph",
@@ -453,10 +455,11 @@ def statistics(self, line, local_ns: dict = None):
453455
if not args.silent:
454456
print(json.dumps(statistics_res_json, indent=2))
455457

456-
if args.store_to != '' and local_ns is not None:
457-
local_ns[args.store_to] = statistics_res_json
458+
store_to_ns(args.store_to, statistics_res_json, local_ns)
458459

459460
@line_magic
461+
@needs_local_scope
462+
@display_exceptions
460463
def summary(self, line, local_ns: dict = None):
461464
parser = argparse.ArgumentParser()
462465
parser.add_argument('language', nargs='?', type=str.lower, default="propertygraph",
@@ -484,8 +487,7 @@ def summary(self, line, local_ns: dict = None):
484487
if not args.silent:
485488
print(json.dumps(summary_res_json, indent=2))
486489

487-
if args.store_to != '' and local_ns is not None:
488-
local_ns[args.store_to] = summary_res_json
490+
store_to_ns(args.store_to, summary_res_json, local_ns)
489491

490492
@line_magic
491493
def graph_notebook_host(self, line):
@@ -1903,8 +1905,7 @@ def load_ids(self, line, local_ns: dict = None):
19031905
vbox = widgets.VBox(labels)
19041906
display(vbox)
19051907

1906-
if args.store_to != '' and local_ns is not None:
1907-
local_ns[args.store_to] = res
1908+
store_to_ns(args.store_to, res, local_ns)
19081909

19091910
@line_magic
19101911
@display_exceptions
@@ -1934,8 +1935,7 @@ def load_status(self, line, local_ns: dict = None):
19341935
if not args.silent:
19351936
print(json.dumps(res, indent=2))
19361937

1937-
if args.store_to != '' and local_ns is not None:
1938-
local_ns[args.store_to] = res
1938+
store_to_ns(args.store_to, res, local_ns)
19391939

19401940
@line_magic
19411941
@display_exceptions
@@ -1984,8 +1984,7 @@ def cancel_load(self, line, local_ns: dict = None):
19841984
else:
19851985
print("No cancellable load jobs were found.")
19861986

1987-
if args.store_to != '' and local_ns is not None:
1988-
local_ns[args.store_to] = raw_res
1987+
store_to_ns(args.store_to, raw_res, local_ns)
19891988

19901989
@line_magic
19911990
@display_exceptions

0 commit comments

Comments
 (0)