-
Notifications
You must be signed in to change notification settings - Fork 10
Ensure that DJORNL queries do not have additional properties #26
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
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -71,41 +71,50 @@ def run_query(): | |
| - public stored queries (these have access controls within them based on params) | ||
| """ | ||
| json_body = parse_json.get_json_body() or {} | ||
| # Don't allow the user to set the special 'ws_ids' field | ||
| json_body['ws_ids'] = [] | ||
| auth_token = auth.get_auth_header() | ||
| # Fetch any authorized workspace IDs using a KBase auth token, if present | ||
| ws_ids = auth.get_workspace_ids(auth_token) | ||
| # fetch number of documents to return | ||
| batch_size = int(flask.request.args.get('batch_size', 10000)) | ||
| full_count = flask.request.args.get('full_count', False) | ||
|
|
||
| if 'query' in json_body: | ||
| # Run an adhoc query for a sysadmin | ||
| auth.require_auth_token(roles=['RE_ADMIN']) | ||
| query_text = _preprocess_stored_query(json_body['query'], json_body) | ||
| del json_body['query'] | ||
| json_body['ws_ids'] = ws_ids | ||
| if 'ws_ids' in query_text: | ||
| # Fetch any authorized workspace IDs using a KBase auth token, if present | ||
| auth_token = auth.get_auth_header() | ||
| json_body['ws_ids'] = auth.get_workspace_ids(auth_token) | ||
|
|
||
| resp_body = arango_client.run_query(query_text=query_text, | ||
| bind_vars=json_body, | ||
| batch_size=batch_size, | ||
| full_count=full_count) | ||
| return flask.jsonify(resp_body) | ||
|
|
||
| if 'stored_query' in flask.request.args or 'view' in flask.request.args: | ||
| # Run a query from a query name | ||
| # Note: we are maintaining backwards compatibility here with the "view" arg. | ||
| # "stored_query" is the more accurate name | ||
| query_name = flask.request.args.get('stored_query') or flask.request.args.get('view') | ||
| stored_query = spec_loader.get_stored_query(query_name) | ||
| stored_query_source = _preprocess_stored_query(stored_query['query'], stored_query) | ||
|
|
||
| if 'params' in stored_query: | ||
| # Validate the user params for the query | ||
| run_validator(schema=stored_query['params'], data=json_body) | ||
| json_body['ws_ids'] = ws_ids | ||
| stored_query_path = spec_loader.get_stored_query(query_name, path_only=True) | ||
| run_validator(schema_file=stored_query_path, data=json_body, validate_at='/params') | ||
|
Comment on lines
+103
to
+104
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use the path, so that relative references in the files work. |
||
|
|
||
| stored_query_source = _preprocess_stored_query(stored_query['query'], stored_query) | ||
| if 'ws_ids' in stored_query_source: | ||
| # Fetch any authorized workspace IDs using a KBase auth token, if present | ||
| auth_token = auth.get_auth_header() | ||
| json_body['ws_ids'] = auth.get_workspace_ids(auth_token) | ||
|
|
||
| resp_body = arango_client.run_query(query_text=stored_query_source, | ||
| bind_vars=json_body, | ||
| batch_size=batch_size, | ||
| full_count=full_count) | ||
| return flask.jsonify(resp_body) | ||
|
|
||
| if 'cursor_id' in flask.request.args: | ||
| # Run a query from a cursor ID | ||
| cursor_id = flask.request.args['cursor_id'] | ||
|
|
@@ -167,9 +176,9 @@ def show_config(): | |
|
|
||
| def _preprocess_stored_query(query_text, config): | ||
| """Inject some default code into each stored query.""" | ||
| ws_id_text = " LET ws_ids = @ws_ids " if 'ws_ids' in query_text else "" | ||
| return ( | ||
| config.get('query_prefix', '') + | ||
| " LET ws_ids = @ws_ids " + | ||
| # " LET maxint = 9007199254740991 " + | ||
| ws_id_text + | ||
| query_text | ||
| ) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| name: distance | ||
| type: integer | ||
| title: Traversal Distance | ||
| description: How many hops to find neighbors and neighbors-of-neighbors | ||
| default: 1 | ||
| minimum: 0 | ||
| maximum: 100 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't have to revert, but i prefer not having all these additional newlines in the function body
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find adding newlines aids readability -- otherwise it's just a bunch of lines with the same indentation and there's added cognitive load in understanding the code before you can edit it. 😖