Skip to content

Add store-too functionality for magic commands #18

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 11 commits into from
Nov 19, 2020
Merged

Conversation

austinkline
Copy link
Contributor

Issue #, if available: #17

Description of changes:

  • Add a parameter to many line and cell magics to allow the query result to be stored to a specified variable. Syntax:
# this is a notebook cell
%%gremlin --store-to gremlin_res

g.V().limit(1)
# this is another notebook cell executed after the first
print(gremlin_res)

[v[some-id-here]]

If a cell throws an exception, we will populate the variable graph_notebook_error with the exception. For Example:

# this is a notebook cell
%%gremlin 

g.V().invalidStep()
# this is another notebook cell
print(graph_notebook_error)

499: {"code":"MalformedQueryException","requestId":"...","detailedMessage":"Query parsing failed at line 2, character position at 13, error message : token recognition error at: 'St'"}

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@austinkline austinkline added the enhancement New feature or request label Nov 16, 2020
@austinkline austinkline linked an issue Nov 16, 2020 that may be closed by this pull request
@@ -87,10 +97,12 @@ def __init__(self, shell):
super(Graph, self).__init__(shell)

try:
self.graph_notebook_config = get_config()
self.config_location = os.getenv('GRAPH_NOTEBOOK_CONFIG', DEFAULT_CONFIG_LOCATION)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this something we will expose to users?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not documented yet, but we should add this to our README

Copy link
Contributor

@krlawrence krlawrence left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left one comment as a question on the GRAPH_NOTEBOOK_CONFIG env var.

@austinkline austinkline merged commit 97324b0 into main Nov 19, 2020
@austinkline austinkline deleted the austinkline/storeto branch November 19, 2020 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ability to return query results for use in other notebook cells
2 participants