From b97812bef349e3497b1054f49bed8ecef329ffaf Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 9 Oct 2018 15:52:27 -0700 Subject: [PATCH 001/732] Init --- api/README.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 api/README.md diff --git a/api/README.md b/api/README.md new file mode 100644 index 00000000..e69de29b From c8c737e15c7988a78ed48acf0e0a2d6b8e06134c Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 9 Oct 2018 16:38:14 -0700 Subject: [PATCH 002/732] Get up all the working basic scaffolding with running tests and docker-compose --- api/.env.example | 0 api/.gitignore | 12 ++++++++++ api/Dockerfile | 18 ++++++++++++++ api/LICENSE.md | 7 ++++++ api/Makefile | 18 ++++++++++++++ api/dev-requirements.txt | 7 ++++++ api/docker-compose.yaml | 12 ++++++++++ api/requirements.txt | 6 +++++ api/src/arangodb_biochem_server/__init__.py | 0 .../arangodb_biochem_server/api/__init__.py | 0 api/src/arangodb_biochem_server/api/api_v1.py | 10 ++++++++ api/src/arangodb_biochem_server/app.py | 24 +++++++++++++++++++ api/src/test/test_api_v1.py | 18 ++++++++++++++ api/tox.ini | 2 ++ 14 files changed, 134 insertions(+) create mode 100644 api/.env.example create mode 100644 api/.gitignore create mode 100644 api/Dockerfile create mode 100644 api/LICENSE.md create mode 100644 api/Makefile create mode 100644 api/dev-requirements.txt create mode 100644 api/docker-compose.yaml create mode 100644 api/requirements.txt create mode 100644 api/src/arangodb_biochem_server/__init__.py create mode 100644 api/src/arangodb_biochem_server/api/__init__.py create mode 100644 api/src/arangodb_biochem_server/api/api_v1.py create mode 100644 api/src/arangodb_biochem_server/app.py create mode 100644 api/src/test/test_api_v1.py create mode 100644 api/tox.ini diff --git a/api/.env.example b/api/.env.example new file mode 100644 index 00000000..e69de29b diff --git a/api/.gitignore b/api/.gitignore new file mode 100644 index 00000000..2da1cb6c --- /dev/null +++ b/api/.gitignore @@ -0,0 +1,12 @@ +# Environment variables +.env + +# Caches and temp dirs +build +dist +*.pyc +.mypy_cache +.cache +tmp/* +coverage_report/ +.coverage diff --git a/api/Dockerfile b/api/Dockerfile new file mode 100644 index 00000000..a9b38680 --- /dev/null +++ b/api/Dockerfile @@ -0,0 +1,18 @@ +FROM python:3.7-alpine + +COPY requirements.txt /app/requirements.txt +COPY dev-requirements.txt /app/dev-requirements.txt +WORKDIR /app + +# Install dependencies +RUN apk --update add make +RUN apk --update add --virtual build-dependencies python-dev build-base && \ + pip install --upgrade pip && \ + pip install -r requirements.txt && \ + pip install -r dev-requirements.txt && \ + apk del build-dependencies + +# Run the app +COPY . /app + +CMD ["gunicorn", "--worker-class", "gevent", "--timeout", "1800", "--workers", "17", "-b", ":5000", "--reload", "src.arangodb_biochem_server.app:app"] diff --git a/api/LICENSE.md b/api/LICENSE.md new file mode 100644 index 00000000..a1fa12dc --- /dev/null +++ b/api/LICENSE.md @@ -0,0 +1,7 @@ +Copyright (c) 2018 The KBase Project and its Contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/api/Makefile b/api/Makefile new file mode 100644 index 00000000..85a3a646 --- /dev/null +++ b/api/Makefile @@ -0,0 +1,18 @@ +.PHONY: dev-server dev-build test test-local + +dev-server: + DEVELOPMENT=1 docker-compose up + +dev-build: + docker-compose down + docker-compose build --build-arg DEVELOPMENT=1 --no-cache web + +test: + docker-compose run web make test-local + +test-local: + flake8 --max-complexity 5 src + mypy --ignore-missing-imports src + python -m pyflakes src + bandit -r src + python -m unittest discover src/test/ diff --git a/api/dev-requirements.txt b/api/dev-requirements.txt new file mode 100644 index 00000000..906dda96 --- /dev/null +++ b/api/dev-requirements.txt @@ -0,0 +1,7 @@ +mypy==0.630 +bandit==1.5.1 +mccabe==0.6.1 +pyflakes==2.0.0 +flake8==3.5.0 +grequests==0.3.0 +coverage==4.5.1 diff --git a/api/docker-compose.yaml b/api/docker-compose.yaml new file mode 100644 index 00000000..d15f53dd --- /dev/null +++ b/api/docker-compose.yaml @@ -0,0 +1,12 @@ +version: '3' + +services: + + # For running the Flask server + web: + build: . + env_file: .env + ports: + - "5000:5000" + volumes: + - .:/app diff --git a/api/requirements.txt b/api/requirements.txt new file mode 100644 index 00000000..c3cef4a0 --- /dev/null +++ b/api/requirements.txt @@ -0,0 +1,6 @@ +Flask==1.0.2 +gunicorn==19.9.0 +gevent==1.3.6 +simplejson==3.16.0 +python-dotenv==0.9.1 +requests==2.19.1 diff --git a/api/src/arangodb_biochem_server/__init__.py b/api/src/arangodb_biochem_server/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/api/src/arangodb_biochem_server/api/__init__.py b/api/src/arangodb_biochem_server/api/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/api/src/arangodb_biochem_server/api/api_v1.py b/api/src/arangodb_biochem_server/api/api_v1.py new file mode 100644 index 00000000..34645f37 --- /dev/null +++ b/api/src/arangodb_biochem_server/api/api_v1.py @@ -0,0 +1,10 @@ +"""The primary router for the Biochem API v1.""" +import flask + +api_v1 = flask.Blueprint('api_v1', __name__) + + +@api_v1.route('/', methods=['GET']) +def root(): + """Root route for the API which lists all paths.""" + return flask.jsonify({'test': True}) diff --git a/api/src/arangodb_biochem_server/app.py b/api/src/arangodb_biochem_server/app.py new file mode 100644 index 00000000..426ad1b1 --- /dev/null +++ b/api/src/arangodb_biochem_server/app.py @@ -0,0 +1,24 @@ +"""The main entrypoint for running the Flask server.""" +import flask +import os +from uuid import uuid4 + +from .api.api_v1 import api_v1 + +app = flask.Flask(__name__) +app.config['DEBUG'] = os.environ.get('FLASK_DEBUG', True) +app.config['SECRET_KEY'] = os.environ.get('FLASK_SECRET_KEY', str(uuid4())) +app.url_map.strict_slashes = False # allow both `get /v1/` and `get /v1` + +app.register_blueprint(api_v1, url_prefix='/v1') + + +@app.route('/', methods=['GET']) +def root(): + """Root path for the entire service; lists all API endpoints.""" + return flask.jsonify({'test': True}) + + +@app.errorhandler(404) +def page_not_found(err): + return (flask.jsonify({'status': 'error', 'error': '404 - Not found.'}), 404) diff --git a/api/src/test/test_api_v1.py b/api/src/test/test_api_v1.py new file mode 100644 index 00000000..1d750963 --- /dev/null +++ b/api/src/test/test_api_v1.py @@ -0,0 +1,18 @@ +""" +Simple integration tests on the API itself. + +We make actual ajax requests to the running docker container. +""" +import unittest +import requests + +url = 'http://web:5000/v1' + + +class TestApiV1(unittest.TestCase): + + def test_root(self): + """Test root path for api.""" + resp = requests.get(url) + json = resp.json() + self.assertTrue(json['test']) diff --git a/api/tox.ini b/api/tox.ini new file mode 100644 index 00000000..6deafc26 --- /dev/null +++ b/api/tox.ini @@ -0,0 +1,2 @@ +[flake8] +max-line-length = 120 From 8d67a2cd83d605443de9c40dfdbb9397649a6235 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 9 Oct 2018 16:40:49 -0700 Subject: [PATCH 003/732] Create README.md --- api/README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/api/README.md b/api/README.md index e69de29b..1d46a505 100644 --- a/api/README.md +++ b/api/README.md @@ -0,0 +1,16 @@ +# Biochem Server with ArangoDB + +## Development + +Start up the server with `docker-compose up` or `make dev-server`. + +Rebuild the server with `make dev-build`. + +Run the tests with `make test`. + +## Project anatomy + +* Source code is in `./src` +* Tests are in `./src/test` +* The server startup code is in `./src/arangodb_biochem_server/app.py` +* API v1 endpoints are in `./src/arangodb_biochem_server/api/api_v1.py` From 98c32a9e448e1cea2bb8c4309de5af5b2ea215de Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 10 Oct 2018 17:48:30 -0700 Subject: [PATCH 004/732] Get a big start on making a swagger API with all the endpoints --- api/requirements.txt | 1 + api/src/arangodb_biochem_server/api/api_v1.py | 69 +++++++++++++++++-- .../api/create_schema.yaml | 28 ++++++++ .../api/create_view.yaml | 8 +++ .../api/fetch_schemas.yaml | 15 ++++ api/src/arangodb_biochem_server/app.py | 44 +++++++++++- 6 files changed, 159 insertions(+), 6 deletions(-) create mode 100644 api/src/arangodb_biochem_server/api/create_schema.yaml create mode 100644 api/src/arangodb_biochem_server/api/create_view.yaml create mode 100644 api/src/arangodb_biochem_server/api/fetch_schemas.yaml diff --git a/api/requirements.txt b/api/requirements.txt index c3cef4a0..7ad7e583 100644 --- a/api/requirements.txt +++ b/api/requirements.txt @@ -4,3 +4,4 @@ gevent==1.3.6 simplejson==3.16.0 python-dotenv==0.9.1 requests==2.19.1 +flasgger==0.9.1 diff --git a/api/src/arangodb_biochem_server/api/api_v1.py b/api/src/arangodb_biochem_server/api/api_v1.py index 34645f37..2d9c4796 100644 --- a/api/src/arangodb_biochem_server/api/api_v1.py +++ b/api/src/arangodb_biochem_server/api/api_v1.py @@ -1,10 +1,71 @@ -"""The primary router for the Biochem API v1.""" +"""The primary router for the Relation Engine API v1.""" import flask +from flasgger import swag_from api_v1 = flask.Blueprint('api_v1', __name__) -@api_v1.route('/', methods=['GET']) -def root(): - """Root route for the API which lists all paths.""" +@swag_from('create_view.yaml') +@api_v1.route('/views', methods=['POST']) +def create_view(): + """See ./create_view.yaml for documentation.""" return flask.jsonify({'test': True}) + + +@api_v1.route('/views', methods=['GET']) +def query_view(): + """ + Run a saved query (a "view") using custom arguments. + --- + tags: ["views"] + parameters: [] + responses: + 200: + description: TODO + schema: {type: object} + """ + return flask.jsonify([]) + + +@swag_from('create_schema.yaml') +@api_v1.route('/schemas', methods=['POST']) +def create_schema(): + """See ./create_schema.yaml for documentation.""" + return flask.jsonify({}) + + +@swag_from('fetch_schemas.yaml') +@api_v1.route('/schemas', methods=['GET']) +def fetch_schemas(): + """See ./fetch_schemas.yaml for documentation.""" + return flask.jsonify({}) + + +@api_v1.route('/documents', methods=['PUT']) +def save_documents(): + """ + Create, update, or replace one or more documents in the database. + --- + tags: ["documents"] + parameters: [] + responses: + 200: + description: TODO + schema: {type: object} + """ + return flask.jsonify({}) + + +@api_v1.route('/documents', methods=['DELETE']) +def delete_documents(): + """ + Remove one or more documents from the database. + --- + tags: ["documents"] + parameters: [] + responses: + 200: + description: TODO + schema: {type: object} + """ + return flask.jsonify({}) diff --git a/api/src/arangodb_biochem_server/api/create_schema.yaml b/api/src/arangodb_biochem_server/api/create_schema.yaml new file mode 100644 index 00000000..e793a70d --- /dev/null +++ b/api/src/arangodb_biochem_server/api/create_schema.yaml @@ -0,0 +1,28 @@ +Create/update/replace one or more schemas, which define document validation rules for a collection. +--- +tags: ["schemas"] +parameters: + - name: action + in: body + required: true + description: 'One of "create", "update", "replace", "create_or_update", or "create_or_replace"' + schema: + type: string + example: create_or_update + - name: schemas + in: body + required: true + description: "The JSON schemas to create -- an array of objects with properties for + 'collection' (collection name) and 'schema' (JSON schema data)." + schema: + type: array + items: + type: object + properties: + collection: {type: string, example: genomes} + schema: + type: object + example: {name: string, accession_id: string, feature_count: integer} +responses: + 200: + description: Save operation was successful diff --git a/api/src/arangodb_biochem_server/api/create_view.yaml b/api/src/arangodb_biochem_server/api/create_view.yaml new file mode 100644 index 00000000..7321d207 --- /dev/null +++ b/api/src/arangodb_biochem_server/api/create_view.yaml @@ -0,0 +1,8 @@ +Create a new saved query (a "view"), which can be used by other API users. +--- +tags: ["views"] +parameters: [] +responses: + 200: + description: TODO + schema: {type: object} diff --git a/api/src/arangodb_biochem_server/api/fetch_schemas.yaml b/api/src/arangodb_biochem_server/api/fetch_schemas.yaml new file mode 100644 index 00000000..c02f6cb7 --- /dev/null +++ b/api/src/arangodb_biochem_server/api/fetch_schemas.yaml @@ -0,0 +1,15 @@ +Fetch a list of saved schemas with optional filters. +--- +tags: [schemas] +parameters: +- name: "collection_names" + in: query + required: false + description: "A comma-separated string listing collection names to filter for accessible schemas" + schema: + type: string + example: "genomes,genes,reactions" +responses: + 200: + description: "An object of endpoints in the form {endpoint_name: endpoint_path}" + schema: {type: object} diff --git a/api/src/arangodb_biochem_server/app.py b/api/src/arangodb_biochem_server/app.py index 426ad1b1..d35a1b36 100644 --- a/api/src/arangodb_biochem_server/app.py +++ b/api/src/arangodb_biochem_server/app.py @@ -1,7 +1,10 @@ """The main entrypoint for running the Flask server.""" +import time import flask import os +import subprocess from uuid import uuid4 +from flasgger import Swagger from .api.api_v1 import api_v1 @@ -12,11 +15,48 @@ app.register_blueprint(api_v1, url_prefix='/v1') +swagger_template = { + 'swagger': '2.0', + 'info': { + 'title': 'Relation Engine API', + 'description': 'API for working with the KBase Relation Engine graph database.', + 'contact': { + 'responsibleOrganization': 'DOE KBase', + 'responsibleDeveloper': 'Jay R Bolton ', + 'email': 'scanon@lbl.gov', + 'url': 'https://kbase.us' + }, + 'version': '1' + }, + 'schemes': ['https'] +} + +swagger = Swagger(app, template=swagger_template) + @app.route('/', methods=['GET']) def root(): - """Root path for the entire service; lists all API endpoints.""" - return flask.jsonify({'test': True}) + """ + Root endpoint that gives server status. + --- + tags: ["root"] + parameters: [] + responses: + 200: + description: "An object of API version links in the form {version_name: version_path}" + schema: {type: object} + schema: + type: object + properties: + versions: {type: array, items: {type: string}} + server_time: {type: integer} + current_commit_hash: {type: string} + """ + return flask.jsonify({ + 'versions': ['/v1'], + 'server_time': int(time.time() * 1000), + 'current_commit_hash': subprocess.check_output(['cat', '.git/refs/heads/master']).strip() + }) @app.errorhandler(404) From 815d8cb0965a7772a0d7e7a24fe8cd0c5034cef6 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Thu, 11 Oct 2018 15:08:32 -0700 Subject: [PATCH 005/732] Get all swagger config yaml files separated out; finish the first api for deleting documents --- api/src/arangodb_biochem_server/api/api_v1.py | 35 +++---------------- .../api/delete_documents.yaml | 20 +++++++++++ .../api/query_view.yaml | 8 +++++ .../api/save_documents.yaml | 8 +++++ api/src/arangodb_biochem_server/app.py | 19 +++++----- 5 files changed, 50 insertions(+), 40 deletions(-) create mode 100644 api/src/arangodb_biochem_server/api/delete_documents.yaml create mode 100644 api/src/arangodb_biochem_server/api/query_view.yaml create mode 100644 api/src/arangodb_biochem_server/api/save_documents.yaml diff --git a/api/src/arangodb_biochem_server/api/api_v1.py b/api/src/arangodb_biochem_server/api/api_v1.py index 2d9c4796..30024641 100644 --- a/api/src/arangodb_biochem_server/api/api_v1.py +++ b/api/src/arangodb_biochem_server/api/api_v1.py @@ -12,18 +12,10 @@ def create_view(): return flask.jsonify({'test': True}) +@swag_from('query_view.yaml') @api_v1.route('/views', methods=['GET']) def query_view(): - """ - Run a saved query (a "view") using custom arguments. - --- - tags: ["views"] - parameters: [] - responses: - 200: - description: TODO - schema: {type: object} - """ + """See ./query_view.yaml for documentation.""" return flask.jsonify([]) @@ -43,29 +35,12 @@ def fetch_schemas(): @api_v1.route('/documents', methods=['PUT']) def save_documents(): - """ - Create, update, or replace one or more documents in the database. - --- - tags: ["documents"] - parameters: [] - responses: - 200: - description: TODO - schema: {type: object} - """ + """See ./save_documents.yaml for documentation.""" return flask.jsonify({}) +@swag_from('delete_documents.yaml') @api_v1.route('/documents', methods=['DELETE']) def delete_documents(): - """ - Remove one or more documents from the database. - --- - tags: ["documents"] - parameters: [] - responses: - 200: - description: TODO - schema: {type: object} - """ + """See ./delete_documents.yaml for documentation.""" return flask.jsonify({}) diff --git a/api/src/arangodb_biochem_server/api/delete_documents.yaml b/api/src/arangodb_biochem_server/api/delete_documents.yaml new file mode 100644 index 00000000..fa3fe7c4 --- /dev/null +++ b/api/src/arangodb_biochem_server/api/delete_documents.yaml @@ -0,0 +1,20 @@ +Remove one or more documents from the database. +--- +tags: ["documents"] +parameters: +- name: ids + in: body + required: true + description: "An array of document IDs to delete." + schema: + type: array + items: + type: string + example: "docid" +responses: + 200: + description: Success status + content: + application/json: + schema: + type: string diff --git a/api/src/arangodb_biochem_server/api/query_view.yaml b/api/src/arangodb_biochem_server/api/query_view.yaml new file mode 100644 index 00000000..06c92f91 --- /dev/null +++ b/api/src/arangodb_biochem_server/api/query_view.yaml @@ -0,0 +1,8 @@ +Run a saved query (a "view") using custom arguments. +--- +tags: ["views"] +parameters: [] +responses: + 200: + description: TODO + schema: {type: object} diff --git a/api/src/arangodb_biochem_server/api/save_documents.yaml b/api/src/arangodb_biochem_server/api/save_documents.yaml new file mode 100644 index 00000000..50b87b8f --- /dev/null +++ b/api/src/arangodb_biochem_server/api/save_documents.yaml @@ -0,0 +1,8 @@ +Create, update, or replace one or more documents in the database. +--- +tags: ["documents"] +parameters: [] +responses: + 200: + description: TODO + schema: {type: object} diff --git a/api/src/arangodb_biochem_server/app.py b/api/src/arangodb_biochem_server/app.py index d35a1b36..be6a964e 100644 --- a/api/src/arangodb_biochem_server/app.py +++ b/api/src/arangodb_biochem_server/app.py @@ -16,7 +16,7 @@ app.register_blueprint(api_v1, url_prefix='/v1') swagger_template = { - 'swagger': '2.0', + 'swagger': '3.0', 'info': { 'title': 'Relation Engine API', 'description': 'API for working with the KBase Relation Engine graph database.', @@ -42,15 +42,14 @@ def root(): tags: ["root"] parameters: [] responses: - 200: - description: "An object of API version links in the form {version_name: version_path}" - schema: {type: object} - schema: - type: object - properties: - versions: {type: array, items: {type: string}} - server_time: {type: integer} - current_commit_hash: {type: string} + 200: + description: "An object of API version links in the form {version_name: version_path}" + schema: + type: object + properties: + versions: {type: array, items: {type: string}} + server_time: {type: integer} + current_commit_hash: {type: string} """ return flask.jsonify({ 'versions': ['/v1'], From 22c7bee333daef1d0acf2f4721404de2c0fa227f Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Fri, 12 Oct 2018 13:40:37 -0700 Subject: [PATCH 006/732] Init --- spec/README.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 spec/README.md diff --git a/spec/README.md b/spec/README.md new file mode 100644 index 00000000..e69de29b From b9d9cfe110819bdaa345fbc9635f4166a4b781e2 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Fri, 12 Oct 2018 13:59:52 -0700 Subject: [PATCH 007/732] Add some ideas --- spec/README.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/spec/README.md b/spec/README.md index e69de29b..c6685d05 100644 --- a/spec/README.md +++ b/spec/README.md @@ -0,0 +1,24 @@ +# Relation Engine Spec + +This repo holds the views and schemas for the relation engine graph database service. + +The views are stored ([AQL queries](https://docs.arangodb.com/3.3/AQL/index.html)) that can be used +by KBase SDK apps to fetch data from the database. + +Schemas are [JSON schemas](https://json-schema.org/) that define what form of data can be stored in +the database's collections. + +Migrations are python modules that connect to the database and are responsible for transitioning +the data in a collection from an old schema to a newer one. + +Versioning on collections: +- Schemas and migrations have a simple incremental version +- The database associates a version with each collection +- If a new schema/migration is added with a higher version, then the migration is run, the new + schema is saved, and the version in the database is incremented. +- If there are multiple schemas/migrations that are newer for a collection, then each migration + will get run in order until they have all been applied. + +Questions: +- How do developers write and test new views and migrations and run them against test data? + - Provide a small docker image with a subset of data from prod From 946a6f4924085208d68eea738c1fd56835924823 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Fri, 12 Oct 2018 14:16:18 -0700 Subject: [PATCH 008/732] Add some more prototyping --- spec/Makefile | 5 +++++ spec/README.md | 5 ++++- spec/src/migrations/example.py | 1 + spec/src/schemas/example.json | 1 + spec/src/views/example.aql | 1 + 5 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 spec/Makefile create mode 100644 spec/src/migrations/example.py create mode 100644 spec/src/schemas/example.json create mode 100644 spec/src/views/example.aql diff --git a/spec/Makefile b/spec/Makefile new file mode 100644 index 00000000..81bd78a3 --- /dev/null +++ b/spec/Makefile @@ -0,0 +1,5 @@ +test: + echo "TODO run all python tests in ./src/test against the test server" + +test-server: + echo "TODO run a single-node arango database server with pre-loaded test data" diff --git a/spec/README.md b/spec/README.md index c6685d05..2f94267e 100644 --- a/spec/README.md +++ b/spec/README.md @@ -1,6 +1,6 @@ # Relation Engine Spec -This repo holds the views and schemas for the relation engine graph database service. +This repo holds the [views](src/views), [schemas](src/schemas), and [migrations](src/migrations) for the relation engine graph database service. The views are stored ([AQL queries](https://docs.arangodb.com/3.3/AQL/index.html)) that can be used by KBase SDK apps to fetch data from the database. @@ -18,7 +18,10 @@ Versioning on collections: schema is saved, and the version in the database is incremented. - If there are multiple schemas/migrations that are newer for a collection, then each migration will get run in order until they have all been applied. +- Migrations can get rolled back (each migration has an `up` and `down` function). Questions: - How do developers write and test new views and migrations and run them against test data? - Provide a small docker image with a subset of data from prod +- Python test modules for views and migrations? + diff --git a/spec/src/migrations/example.py b/spec/src/migrations/example.py new file mode 100644 index 00000000..46409041 --- /dev/null +++ b/spec/src/migrations/example.py @@ -0,0 +1 @@ +# TODO diff --git a/spec/src/schemas/example.json b/spec/src/schemas/example.json new file mode 100644 index 00000000..6e00ec9d --- /dev/null +++ b/spec/src/schemas/example.json @@ -0,0 +1 @@ +{"TODO": true} diff --git a/spec/src/views/example.aql b/spec/src/views/example.aql new file mode 100644 index 00000000..70b786d1 --- /dev/null +++ b/spec/src/views/example.aql @@ -0,0 +1 @@ +// TODO From 603c3f767050f66aa1ed59c512195f9b3382bfd8 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Mon, 15 Oct 2018 12:48:03 -0700 Subject: [PATCH 009/732] Add some more prototype docs --- spec/README.md | 12 ++++++----- spec/src/migrations/README.md | 9 +++++++++ spec/src/schemas/README.md | 20 +++++++++++++++++++ .../schemas/{example.json => example.hjson} | 0 spec/src/test/README.md | 10 ++++++++++ spec/src/views/README.md | 13 ++++++++++++ 6 files changed, 59 insertions(+), 5 deletions(-) create mode 100644 spec/src/migrations/README.md create mode 100644 spec/src/schemas/README.md rename spec/src/schemas/{example.json => example.hjson} (100%) create mode 100644 spec/src/test/README.md create mode 100644 spec/src/views/README.md diff --git a/spec/README.md b/spec/README.md index 2f94267e..0c5b1112 100644 --- a/spec/README.md +++ b/spec/README.md @@ -2,8 +2,8 @@ This repo holds the [views](src/views), [schemas](src/schemas), and [migrations](src/migrations) for the relation engine graph database service. -The views are stored ([AQL queries](https://docs.arangodb.com/3.3/AQL/index.html)) that can be used -by KBase SDK apps to fetch data from the database. +The views are stored [AQL queries](https://docs.arangodb.com/3.3/AQL/index.html) that can be used +by KBase apps to fetch data from the database. Schemas are [JSON schemas](https://json-schema.org/) that define what form of data can be stored in the database's collections. @@ -20,8 +20,10 @@ Versioning on collections: will get run in order until they have all been applied. - Migrations can get rolled back (each migration has an `up` and `down` function). -Questions: +Views and migrations both have python tests located in [`./src/test`](src/test) + + +_Questions_ + - How do developers write and test new views and migrations and run them against test data? - Provide a small docker image with a subset of data from prod -- Python test modules for views and migrations? - diff --git a/spec/src/migrations/README.md b/spec/src/migrations/README.md new file mode 100644 index 00000000..994aaca1 --- /dev/null +++ b/spec/src/migrations/README.md @@ -0,0 +1,9 @@ +# Relation Engine Migrations + +Migrations are python scripts (using pyArango) that migrate (or roll back) the database to a new +schema version. + +## Guidelines + +- Every migration script has two functions -- `forward` and `backward -- for migrating the database forwards or backwards. +- Every migration should specify a collection name, the version we're migrating *from*, and version we're migrating *to* diff --git a/spec/src/schemas/README.md b/spec/src/schemas/README.md new file mode 100644 index 00000000..46a122dc --- /dev/null +++ b/spec/src/schemas/README.md @@ -0,0 +1,20 @@ +# Relation Engine Document Schemas + +Document schemas define a required format for each collection in the database. Schemas use the +[JSON Schema](https://json-schema.org/specification.html) specification and follow the [HJSON +format](https://hjson.org). + +## Guidelines + +- The filename should be the name of the collection that the schema applies to. +- All schemas should be in [HJSON format](https://hjson.org/) and follow the [JSON + Schema](https://json-schema.org/) specification. +- You can add reusable JSON schema definitions by placing them in the + [`./definitions`](/src/schemas/definitions) directory. +- When writing a new schema, also make a [migration script](/src/migrations) that can update the + database. + +## Testing your schema format + +Run `make test` in the root of the repo, which will validate all the schemas in this directory. You +can also run `make test-schemas` or `make test-schema ` to test schemas specifically. diff --git a/spec/src/schemas/example.json b/spec/src/schemas/example.hjson similarity index 100% rename from spec/src/schemas/example.json rename to spec/src/schemas/example.hjson diff --git a/spec/src/test/README.md b/spec/src/test/README.md new file mode 100644 index 00000000..7159caaf --- /dev/null +++ b/spec/src/test/README.md @@ -0,0 +1,10 @@ +# Relation Engine Spec Tests + +This directory holds python unit-tests for Relation Engine views and migrations. + +A view test should test that a query returns the expected data, traverses the graph correctly, and +does not return data that we don't want. + +A migration test should test that all the data in a test database has been updated in the correct +way after a migration is run. It should also test that when a migration rolls back, data is +restored to its original form. diff --git a/spec/src/views/README.md b/spec/src/views/README.md new file mode 100644 index 00000000..a6dc70d4 --- /dev/null +++ b/spec/src/views/README.md @@ -0,0 +1,13 @@ +# Relation Engine Views + +Views are templated AQL queries that fetch data from the database. + +Variables in views are prefixed with `@`. + +## Required format + +Each view file should have a set of comments at the top describing the purpose of the query. + +## Using views from the API + +See the [API docs]() to see how to run these queries using the API. From 4f47ed22a5b4c05c4b4183a5d6c62e9cc8208704 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Mon, 15 Oct 2018 13:25:47 -0700 Subject: [PATCH 010/732] Update some details in schema docs (HJSON -> JSON5) --- spec/src/schemas/README.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/spec/src/schemas/README.md b/spec/src/schemas/README.md index 46a122dc..9ee36f9f 100644 --- a/spec/src/schemas/README.md +++ b/spec/src/schemas/README.md @@ -1,13 +1,13 @@ # Relation Engine Document Schemas Document schemas define a required format for each collection in the database. Schemas use the -[JSON Schema](https://json-schema.org/specification.html) specification and follow the [HJSON -format](https://hjson.org). +[JSON Schema](https://json-schema.org/specification.html) specification and follow the [JSON5 +format](https://json5.org/) ## Guidelines - The filename should be the name of the collection that the schema applies to. -- All schemas should be in [HJSON format](https://hjson.org/) and follow the [JSON +- All schemas should be in [JSON5 format](https://json5.org/) and follow the [JSON Schema](https://json-schema.org/) specification. - You can add reusable JSON schema definitions by placing them in the [`./definitions`](/src/schemas/definitions) directory. @@ -18,3 +18,7 @@ format](https://hjson.org). Run `make test` in the root of the repo, which will validate all the schemas in this directory. You can also run `make test-schemas` or `make test-schema ` to test schemas specifically. + +## Resources + +- Quickly validate JSON schemas: https://www.jsonschemavalidator.net/ From 6d3b5a9d3146b63e8948c3501d0db8d86f745dc6 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Mon, 15 Oct 2018 15:07:10 -0700 Subject: [PATCH 011/732] Delete example schema --- spec/src/schemas/example.hjson | 1 - 1 file changed, 1 deletion(-) delete mode 100644 spec/src/schemas/example.hjson diff --git a/spec/src/schemas/example.hjson b/spec/src/schemas/example.hjson deleted file mode 100644 index 6e00ec9d..00000000 --- a/spec/src/schemas/example.hjson +++ /dev/null @@ -1 +0,0 @@ -{"TODO": true} From a63ee70762c979af9509e00d359208ccadf7553a Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Mon, 22 Oct 2018 16:05:25 -0700 Subject: [PATCH 012/732] Change name to relation_engine_api --- api/Dockerfile | 2 +- .../__init__.py | 0 .../api/__init__.py | 0 .../api/api_v1.py | 0 .../api/create_schema.yaml | 0 .../api/create_view.yaml | 0 .../api/delete_documents.yaml | 0 .../api/fetch_schemas.yaml | 0 .../api/query_view.yaml | 0 .../api/save_documents.yaml | 0 api/src/{arangodb_biochem_server => relation_engine_api}/app.py | 0 11 files changed, 1 insertion(+), 1 deletion(-) rename api/src/{arangodb_biochem_server => relation_engine_api}/__init__.py (100%) rename api/src/{arangodb_biochem_server => relation_engine_api}/api/__init__.py (100%) rename api/src/{arangodb_biochem_server => relation_engine_api}/api/api_v1.py (100%) rename api/src/{arangodb_biochem_server => relation_engine_api}/api/create_schema.yaml (100%) rename api/src/{arangodb_biochem_server => relation_engine_api}/api/create_view.yaml (100%) rename api/src/{arangodb_biochem_server => relation_engine_api}/api/delete_documents.yaml (100%) rename api/src/{arangodb_biochem_server => relation_engine_api}/api/fetch_schemas.yaml (100%) rename api/src/{arangodb_biochem_server => relation_engine_api}/api/query_view.yaml (100%) rename api/src/{arangodb_biochem_server => relation_engine_api}/api/save_documents.yaml (100%) rename api/src/{arangodb_biochem_server => relation_engine_api}/app.py (100%) diff --git a/api/Dockerfile b/api/Dockerfile index a9b38680..ebef61ae 100644 --- a/api/Dockerfile +++ b/api/Dockerfile @@ -15,4 +15,4 @@ RUN apk --update add --virtual build-dependencies python-dev build-base && \ # Run the app COPY . /app -CMD ["gunicorn", "--worker-class", "gevent", "--timeout", "1800", "--workers", "17", "-b", ":5000", "--reload", "src.arangodb_biochem_server.app:app"] +CMD ["gunicorn", "--worker-class", "gevent", "--timeout", "1800", "--workers", "17", "-b", ":5000", "--reload", "src.relation_engine_api.app:app"] diff --git a/api/src/arangodb_biochem_server/__init__.py b/api/src/relation_engine_api/__init__.py similarity index 100% rename from api/src/arangodb_biochem_server/__init__.py rename to api/src/relation_engine_api/__init__.py diff --git a/api/src/arangodb_biochem_server/api/__init__.py b/api/src/relation_engine_api/api/__init__.py similarity index 100% rename from api/src/arangodb_biochem_server/api/__init__.py rename to api/src/relation_engine_api/api/__init__.py diff --git a/api/src/arangodb_biochem_server/api/api_v1.py b/api/src/relation_engine_api/api/api_v1.py similarity index 100% rename from api/src/arangodb_biochem_server/api/api_v1.py rename to api/src/relation_engine_api/api/api_v1.py diff --git a/api/src/arangodb_biochem_server/api/create_schema.yaml b/api/src/relation_engine_api/api/create_schema.yaml similarity index 100% rename from api/src/arangodb_biochem_server/api/create_schema.yaml rename to api/src/relation_engine_api/api/create_schema.yaml diff --git a/api/src/arangodb_biochem_server/api/create_view.yaml b/api/src/relation_engine_api/api/create_view.yaml similarity index 100% rename from api/src/arangodb_biochem_server/api/create_view.yaml rename to api/src/relation_engine_api/api/create_view.yaml diff --git a/api/src/arangodb_biochem_server/api/delete_documents.yaml b/api/src/relation_engine_api/api/delete_documents.yaml similarity index 100% rename from api/src/arangodb_biochem_server/api/delete_documents.yaml rename to api/src/relation_engine_api/api/delete_documents.yaml diff --git a/api/src/arangodb_biochem_server/api/fetch_schemas.yaml b/api/src/relation_engine_api/api/fetch_schemas.yaml similarity index 100% rename from api/src/arangodb_biochem_server/api/fetch_schemas.yaml rename to api/src/relation_engine_api/api/fetch_schemas.yaml diff --git a/api/src/arangodb_biochem_server/api/query_view.yaml b/api/src/relation_engine_api/api/query_view.yaml similarity index 100% rename from api/src/arangodb_biochem_server/api/query_view.yaml rename to api/src/relation_engine_api/api/query_view.yaml diff --git a/api/src/arangodb_biochem_server/api/save_documents.yaml b/api/src/relation_engine_api/api/save_documents.yaml similarity index 100% rename from api/src/arangodb_biochem_server/api/save_documents.yaml rename to api/src/relation_engine_api/api/save_documents.yaml diff --git a/api/src/arangodb_biochem_server/app.py b/api/src/relation_engine_api/app.py similarity index 100% rename from api/src/arangodb_biochem_server/app.py rename to api/src/relation_engine_api/app.py From 630c10de5997733c2d925b9a69193fcf62ef6920 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 23 Oct 2018 10:31:30 -0700 Subject: [PATCH 013/732] Get a prototype swagger api going --- api/src/relation_engine_api/api/api_v1.py | 59 +++++++++++-------- .../api/create_schema.yaml | 28 --------- .../relation_engine_api/api/create_view.yaml | 8 --- .../api/fetch_schemas.yaml | 15 ----- .../relation_engine_api/api/query_view.yaml | 8 --- .../relation_engine_api/api/run_query.yaml | 14 +++++ .../api/save_documents.yaml | 40 +++++++++++-- .../relation_engine_api/api/show_schemas.yaml | 15 +++++ .../relation_engine_api/api/show_views.yaml | 14 +++++ api/src/relation_engine_api/app.py | 31 +++------- 10 files changed, 122 insertions(+), 110 deletions(-) delete mode 100644 api/src/relation_engine_api/api/create_schema.yaml delete mode 100644 api/src/relation_engine_api/api/create_view.yaml delete mode 100644 api/src/relation_engine_api/api/fetch_schemas.yaml delete mode 100644 api/src/relation_engine_api/api/query_view.yaml create mode 100644 api/src/relation_engine_api/api/run_query.yaml create mode 100644 api/src/relation_engine_api/api/show_schemas.yaml create mode 100644 api/src/relation_engine_api/api/show_views.yaml diff --git a/api/src/relation_engine_api/api/api_v1.py b/api/src/relation_engine_api/api/api_v1.py index 30024641..cbee102f 100644 --- a/api/src/relation_engine_api/api/api_v1.py +++ b/api/src/relation_engine_api/api/api_v1.py @@ -1,46 +1,59 @@ """The primary router for the Relation Engine API v1.""" +import time +import subprocess import flask from flasgger import swag_from api_v1 = flask.Blueprint('api_v1', __name__) -@swag_from('create_view.yaml') -@api_v1.route('/views', methods=['POST']) -def create_view(): - """See ./create_view.yaml for documentation.""" +@api_v1.route('/', methods=['GET']) +def root(): + """ + Server status. + --- + tags: ["root"] + parameters: [] + responses: + 200: {description: "Server status."} + """ + return flask.jsonify({ + 'docs': '/apidocs', + 'server_time': int(time.time() * 1000), + 'current_commit_hash': subprocess.check_output(['cat', '.git/refs/heads/master']).strip() + }) + + +@swag_from('show_views.yaml') +@api_v1.route('/views', methods=['GET']) +def show_views(): + """See ./show_views.yaml for documentation.""" return flask.jsonify({'test': True}) -@swag_from('query_view.yaml') -@api_v1.route('/views', methods=['GET']) -def query_view(): - """See ./query_view.yaml for documentation.""" +@swag_from('run_query.yaml') +@api_v1.route('/query', methods=['GET']) +def run_query(): + """See ./run_query.yaml for documentation.""" return flask.jsonify([]) -@swag_from('create_schema.yaml') -@api_v1.route('/schemas', methods=['POST']) -def create_schema(): - """See ./create_schema.yaml for documentation.""" - return flask.jsonify({}) - - -@swag_from('fetch_schemas.yaml') +@swag_from('show_schemas.yaml') @api_v1.route('/schemas', methods=['GET']) -def fetch_schemas(): - """See ./fetch_schemas.yaml for documentation.""" +def show_schemas(): + """See ./show_schemas.yaml for documentation.""" return flask.jsonify({}) +@swag_from('save_documents.yaml') @api_v1.route('/documents', methods=['PUT']) def save_documents(): """See ./save_documents.yaml for documentation.""" return flask.jsonify({}) -@swag_from('delete_documents.yaml') -@api_v1.route('/documents', methods=['DELETE']) -def delete_documents(): - """See ./delete_documents.yaml for documentation.""" - return flask.jsonify({}) +# @swag_from('delete_documents.yaml') +# @api_v1.route('/documents', methods=['DELETE']) +# def delete_documents(): +# """See ./delete_documents.yaml for documentation.""" +# return flask.jsonify({}) diff --git a/api/src/relation_engine_api/api/create_schema.yaml b/api/src/relation_engine_api/api/create_schema.yaml deleted file mode 100644 index e793a70d..00000000 --- a/api/src/relation_engine_api/api/create_schema.yaml +++ /dev/null @@ -1,28 +0,0 @@ -Create/update/replace one or more schemas, which define document validation rules for a collection. ---- -tags: ["schemas"] -parameters: - - name: action - in: body - required: true - description: 'One of "create", "update", "replace", "create_or_update", or "create_or_replace"' - schema: - type: string - example: create_or_update - - name: schemas - in: body - required: true - description: "The JSON schemas to create -- an array of objects with properties for - 'collection' (collection name) and 'schema' (JSON schema data)." - schema: - type: array - items: - type: object - properties: - collection: {type: string, example: genomes} - schema: - type: object - example: {name: string, accession_id: string, feature_count: integer} -responses: - 200: - description: Save operation was successful diff --git a/api/src/relation_engine_api/api/create_view.yaml b/api/src/relation_engine_api/api/create_view.yaml deleted file mode 100644 index 7321d207..00000000 --- a/api/src/relation_engine_api/api/create_view.yaml +++ /dev/null @@ -1,8 +0,0 @@ -Create a new saved query (a "view"), which can be used by other API users. ---- -tags: ["views"] -parameters: [] -responses: - 200: - description: TODO - schema: {type: object} diff --git a/api/src/relation_engine_api/api/fetch_schemas.yaml b/api/src/relation_engine_api/api/fetch_schemas.yaml deleted file mode 100644 index c02f6cb7..00000000 --- a/api/src/relation_engine_api/api/fetch_schemas.yaml +++ /dev/null @@ -1,15 +0,0 @@ -Fetch a list of saved schemas with optional filters. ---- -tags: [schemas] -parameters: -- name: "collection_names" - in: query - required: false - description: "A comma-separated string listing collection names to filter for accessible schemas" - schema: - type: string - example: "genomes,genes,reactions" -responses: - 200: - description: "An object of endpoints in the form {endpoint_name: endpoint_path}" - schema: {type: object} diff --git a/api/src/relation_engine_api/api/query_view.yaml b/api/src/relation_engine_api/api/query_view.yaml deleted file mode 100644 index 06c92f91..00000000 --- a/api/src/relation_engine_api/api/query_view.yaml +++ /dev/null @@ -1,8 +0,0 @@ -Run a saved query (a "view") using custom arguments. ---- -tags: ["views"] -parameters: [] -responses: - 200: - description: TODO - schema: {type: object} diff --git a/api/src/relation_engine_api/api/run_query.yaml b/api/src/relation_engine_api/api/run_query.yaml new file mode 100644 index 00000000..efb72eae --- /dev/null +++ b/api/src/relation_engine_api/api/run_query.yaml @@ -0,0 +1,14 @@ +Execute a saved query (a "view") using custom arguments and return the results as JSON. +--- +tags: ["views"] +parameters: +- name: name + in: query + required: true + description: Name of the view to run. + schema: + type: string + example: "view_name" +responses: + 200: + description: Result data. diff --git a/api/src/relation_engine_api/api/save_documents.yaml b/api/src/relation_engine_api/api/save_documents.yaml index 50b87b8f..662dbb12 100644 --- a/api/src/relation_engine_api/api/save_documents.yaml +++ b/api/src/relation_engine_api/api/save_documents.yaml @@ -1,8 +1,38 @@ -Create, update, or replace one or more documents in the database. +Create, update, or replace documents in the database. + +Pass in an array of objects that describe documents to be created, updated, and/or replaced in the +database. View the "Model" below for further details on the structure of the parameters. + +"onDuplicate" controls what happens when we encounter documents with the same "_key" attributes. +Valid options are "error", "update", "replace", or "ignore". The default is "error". + +If any update fails, then no changes are made to the database. --- tags: ["documents"] -parameters: [] +parameters: +- name: body + in: body + required: true + schema: + type: array + items: + type: object + required: [collection, doc] + properties: + collection: {type: string, example: "genes"} + onDuplicate: + type: string + default: "error" + enum: ["error", "update", "replace", "ignore"] + doc: + type: object + required: ["_key"] + example: { + "_key": "DAES_RS11325", + "location_start": 1111, + "location_end": 9999 + } + properties: + _key: {type: string} responses: - 200: - description: TODO - schema: {type: object} + 200: {description: "Success status."} diff --git a/api/src/relation_engine_api/api/show_schemas.yaml b/api/src/relation_engine_api/api/show_schemas.yaml new file mode 100644 index 00000000..96cbcd96 --- /dev/null +++ b/api/src/relation_engine_api/api/show_schemas.yaml @@ -0,0 +1,15 @@ +Fetch a list of saved schemas with optional filters. +--- +tags: ["schemas"] +parameters: +- name: collection_names + in: query + required: false + description: An array listing collection names to filter for accessible schemas + schema: + type: array + items: {type: string} + example: [genomes, genes, reactions] +responses: + 200: + description: "View data." diff --git a/api/src/relation_engine_api/api/show_views.yaml b/api/src/relation_engine_api/api/show_views.yaml new file mode 100644 index 00000000..8813dc05 --- /dev/null +++ b/api/src/relation_engine_api/api/show_views.yaml @@ -0,0 +1,14 @@ +List out all the available views, optionally showing the parameters and AQL source query. +--- +tags: ["views"] +parameters: +- name: names + in: query + required: true + description: Array of view names to fetch (if blank, then all views are fetched) + schema: + type: array + items: {type: string} +responses: + 200: + description: "Array of views." diff --git a/api/src/relation_engine_api/app.py b/api/src/relation_engine_api/app.py index be6a964e..15ae5b1c 100644 --- a/api/src/relation_engine_api/app.py +++ b/api/src/relation_engine_api/app.py @@ -1,8 +1,6 @@ """The main entrypoint for running the Flask server.""" -import time import flask import os -import subprocess from uuid import uuid4 from flasgger import Swagger @@ -16,7 +14,7 @@ app.register_blueprint(api_v1, url_prefix='/v1') swagger_template = { - 'swagger': '3.0', + 'openapi': '3.0.2', 'info': { 'title': 'Relation Engine API', 'description': 'API for working with the KBase Relation Engine graph database.', @@ -36,28 +34,15 @@ @app.route('/', methods=['GET']) def root(): - """ - Root endpoint that gives server status. - --- - tags: ["root"] - parameters: [] - responses: - 200: - description: "An object of API version links in the form {version_name: version_path}" - schema: - type: object - properties: - versions: {type: array, items: {type: string}} - server_time: {type: integer} - current_commit_hash: {type: string} - """ - return flask.jsonify({ - 'versions': ['/v1'], - 'server_time': int(time.time() * 1000), - 'current_commit_hash': subprocess.check_output(['cat', '.git/refs/heads/master']).strip() - }) + """Redirects to the Swagger API docs.""" + return flask.redirect('/apidocs') @app.errorhandler(404) def page_not_found(err): return (flask.jsonify({'status': 'error', 'error': '404 - Not found.'}), 404) + + +@app.errorhandler(405) +def method_not_allowed(err): + return (flask.jsonify({'status': 'error', 'error': '405 - Method not allowed.'}), 405) From 35299e96ac2aa6d432348b4885d0ffd86584c4bf Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 23 Oct 2018 12:06:13 -0700 Subject: [PATCH 014/732] Add some setuptools packaging boilerplate --- spec/.gitignore | 13 +++++++++++++ spec/setup.py | 16 ++++++++++++++++ spec/src/__init__.py | 0 spec/src/migrations/__init__.py | 0 spec/src/migrations/example.py | 2 ++ spec/src/schemas/__init__.py | 1 + spec/src/schemas/taxon.json5 | 18 ++++++++++++++++++ spec/src/views/__init__.py | 0 spec/src/views/example.aql | 8 +++++++- spec/test.py | 0 10 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 spec/.gitignore create mode 100644 spec/setup.py create mode 100644 spec/src/__init__.py create mode 100644 spec/src/migrations/__init__.py create mode 100644 spec/src/schemas/__init__.py create mode 100644 spec/src/schemas/taxon.json5 create mode 100644 spec/src/views/__init__.py create mode 100644 spec/test.py diff --git a/spec/.gitignore b/spec/.gitignore new file mode 100644 index 00000000..e818d490 --- /dev/null +++ b/spec/.gitignore @@ -0,0 +1,13 @@ +# Environment variables +.env + +# Caches and temp dirs +build +dist +*.pyc +.mypy_cache +.cache +tmp/* +coverage_report/ +.coverage +*.egg-info/ diff --git a/spec/setup.py b/spec/setup.py new file mode 100644 index 00000000..8df345d3 --- /dev/null +++ b/spec/setup.py @@ -0,0 +1,16 @@ +from setuptools import setup, find_packages + +setup( + name='relation_engine_spec', + version='0.1', + author='Jay Bolton', + author_email='jrbolton@lbl.gov', + package_dir={'': 'src'}, + packages=find_packages('src'), + include_package_data=True, + package_data={'': ['*.aql', '*.json5']}, + license='MIT', + description='Specifications for the KBase Relation Engine API.', + url='https://kbase.us', + python_requires='>=3' +) diff --git a/spec/src/__init__.py b/spec/src/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/spec/src/migrations/__init__.py b/spec/src/migrations/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/spec/src/migrations/example.py b/spec/src/migrations/example.py index 46409041..ce5ce389 100644 --- a/spec/src/migrations/example.py +++ b/spec/src/migrations/example.py @@ -1 +1,3 @@ # TODO + +x = 1 diff --git a/spec/src/schemas/__init__.py b/spec/src/schemas/__init__.py new file mode 100644 index 00000000..fec56017 --- /dev/null +++ b/spec/src/schemas/__init__.py @@ -0,0 +1 @@ +# Hello diff --git a/spec/src/schemas/taxon.json5 b/spec/src/schemas/taxon.json5 new file mode 100644 index 00000000..f24fe40c --- /dev/null +++ b/spec/src/schemas/taxon.json5 @@ -0,0 +1,18 @@ +{ + $schema: 'http://json-schema.org/draft-07/schema', + description: 'A taxon', + type: 'object', + required: ['_key', 'name'], + additionalProperties: false, + properties: { + _key: { + type: 'string', + description: 'A 16-byte blake2b hash of the name' + }, + name: { + type: 'string', + description: 'The taxon name.', + example: 'Porphyromonas' + } + } +} diff --git a/spec/src/views/__init__.py b/spec/src/views/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/spec/src/views/example.aql b/spec/src/views/example.aql index 70b786d1..8dabcc1e 100644 --- a/spec/src/views/example.aql +++ b/spec/src/views/example.aql @@ -1 +1,7 @@ -// TODO +// Return count of documents in a collection +// Args: +// collection - name of collection to count docs + +for v in @collection: + collect with count into length + return length diff --git a/spec/test.py b/spec/test.py new file mode 100644 index 00000000..e69de29b From 1ab8153447dc1640f2feaecde7eea0717df5a1c1 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 24 Oct 2018 10:31:15 -0700 Subject: [PATCH 015/732] Add some basic code that loads views and schemas into python --- spec/README.md | 11 ++++++++++ spec/setup.py | 5 ++++- spec/src/migrations/__init__.py | 1 + spec/src/migrations/example.py | 1 + spec/src/schemas/__init__.py | 39 ++++++++++++++++++++++++++++++++- spec/src/schemas/taxon.json | 18 +++++++++++++++ spec/src/schemas/taxon.json5 | 18 --------------- spec/src/views/__init__.py | 29 ++++++++++++++++++++++++ 8 files changed, 102 insertions(+), 20 deletions(-) create mode 100644 spec/src/schemas/taxon.json delete mode 100644 spec/src/schemas/taxon.json5 diff --git a/spec/README.md b/spec/README.md index 0c5b1112..b1034487 100644 --- a/spec/README.md +++ b/spec/README.md @@ -27,3 +27,14 @@ _Questions_ - How do developers write and test new views and migrations and run them against test data? - Provide a small docker image with a subset of data from prod + + +# Publish the package + +The package can be published to anaconda, where it can then be installed via pip or conda. + +```sh +$ python setup.py sdist +$ anaconda upload -i -u kbase dist/*.tar.gz +``` + diff --git a/spec/setup.py b/spec/setup.py index 8df345d3..d847ad69 100644 --- a/spec/setup.py +++ b/spec/setup.py @@ -12,5 +12,8 @@ license='MIT', description='Specifications for the KBase Relation Engine API.', url='https://kbase.us', - python_requires='>=3' + python_requires='>=3', + install_requires=[ + 'jsonschema' + ] ) diff --git a/spec/src/migrations/__init__.py b/spec/src/migrations/__init__.py index e69de29b..8b137891 100644 --- a/spec/src/migrations/__init__.py +++ b/spec/src/migrations/__init__.py @@ -0,0 +1 @@ + diff --git a/spec/src/migrations/example.py b/spec/src/migrations/example.py index ce5ce389..214701eb 100644 --- a/spec/src/migrations/example.py +++ b/spec/src/migrations/example.py @@ -1,3 +1,4 @@ # TODO x = 1 + diff --git a/spec/src/schemas/__init__.py b/spec/src/schemas/__init__.py index fec56017..4d2a852b 100644 --- a/spec/src/schemas/__init__.py +++ b/spec/src/schemas/__init__.py @@ -1 +1,38 @@ -# Hello +import os +import json +import jsonschema + + +def get_schema_names(): + current_dir = os.path.dirname(__file__) + schema_names = [] + for file_name in os.listdir(current_dir): + (basename, ext) = os.path.splitext(file_name) + if ext == '.json': + schema_names.append(basename) + return schema_names + + +def get_schema_as_dict(schema_name): + """Parse a schema into a python dictionary.""" + current_dir = os.path.dirname(__file__) + file_path = os.path.join(current_dir, schema_name + '.json') + if not os.path.isfile(file_path): + raise SchemaNonexistent(schema_name) + with open(file_path, 'r') as fd: + return json.loads(fd.read()) + + +def validate_data_against_schema(schema, data): + """Given a parsed JSON schema and some python data, validate the data structure against the schema.""" + jsonschema.validate(data, schema) + + +class SchemaNonexistent(Exception): + """Schema that we tried to fetch by name does not exist.""" + + def __init__(self, schema_name): + self.schema_name = schema_name + + def __str__(self): + return 'Schema does not exist %s. Available schemas are: %s' % (self.schema_name, str(get_schema_names())) diff --git a/spec/src/schemas/taxon.json b/spec/src/schemas/taxon.json new file mode 100644 index 00000000..1a3181d5 --- /dev/null +++ b/spec/src/schemas/taxon.json @@ -0,0 +1,18 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema", + "description": "A taxon", + "type": "object", + "required": ["_key", "name"], + "additionalProperties": false, + "properties": { + "_key": { + "type": "string", + "description": "A 16-byte blake2b hash of the name" + }, + "name": { + "type": "string", + "description": "The taxon name.", + "example": "Porphyromonas" + } + } +} diff --git a/spec/src/schemas/taxon.json5 b/spec/src/schemas/taxon.json5 deleted file mode 100644 index f24fe40c..00000000 --- a/spec/src/schemas/taxon.json5 +++ /dev/null @@ -1,18 +0,0 @@ -{ - $schema: 'http://json-schema.org/draft-07/schema', - description: 'A taxon', - type: 'object', - required: ['_key', 'name'], - additionalProperties: false, - properties: { - _key: { - type: 'string', - description: 'A 16-byte blake2b hash of the name' - }, - name: { - type: 'string', - description: 'The taxon name.', - example: 'Porphyromonas' - } - } -} diff --git a/spec/src/views/__init__.py b/spec/src/views/__init__.py index e69de29b..36aa1c4a 100644 --- a/spec/src/views/__init__.py +++ b/spec/src/views/__init__.py @@ -0,0 +1,29 @@ +import os + + +def get_view_names(): + current_dir = os.path.dirname(__file__) + view_names = [] + for file_name in os.listdir(current_dir): + (basename, ext) = os.path.splitext(file_name) + if ext == '.aql': + view_names.append(basename) + return view_names + + +def get_view_content(view_name): + current_dir = os.path.dirname(__file__) + file_path = os.path.join(current_dir, view_name + '.aql') + if not os.path.isfile(file_path): + raise ViewNonexistent() + with open(file_path, 'r') as fd: + return fd.read() + + +class ViewNonexistent(Exception): + + def __init__(self): + pass + + def __str__(self): + return 'View does not exist. Available views are: ' + str(get_view_names()) From 9c52218c53659ba5feca1943724af8b21e3a6b93 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 24 Oct 2018 11:38:48 -0700 Subject: [PATCH 016/732] Move the directory structure to get setuptools working better --- spec/{src => relation_engine_spec}/__init__.py | 0 spec/{src => relation_engine_spec}/migrations/README.md | 0 spec/{src => relation_engine_spec}/migrations/__init__.py | 0 spec/{src => relation_engine_spec}/migrations/example.py | 0 spec/{src => relation_engine_spec}/schemas/README.md | 0 spec/{src => relation_engine_spec}/schemas/__init__.py | 0 spec/{src => relation_engine_spec}/schemas/taxon.json | 0 spec/{src => relation_engine_spec}/test/README.md | 0 spec/{src => relation_engine_spec}/views/README.md | 0 spec/{src => relation_engine_spec}/views/__init__.py | 0 spec/{src => relation_engine_spec}/views/example.aql | 0 spec/setup.py | 5 ++--- 12 files changed, 2 insertions(+), 3 deletions(-) rename spec/{src => relation_engine_spec}/__init__.py (100%) rename spec/{src => relation_engine_spec}/migrations/README.md (100%) rename spec/{src => relation_engine_spec}/migrations/__init__.py (100%) rename spec/{src => relation_engine_spec}/migrations/example.py (100%) rename spec/{src => relation_engine_spec}/schemas/README.md (100%) rename spec/{src => relation_engine_spec}/schemas/__init__.py (100%) rename spec/{src => relation_engine_spec}/schemas/taxon.json (100%) rename spec/{src => relation_engine_spec}/test/README.md (100%) rename spec/{src => relation_engine_spec}/views/README.md (100%) rename spec/{src => relation_engine_spec}/views/__init__.py (100%) rename spec/{src => relation_engine_spec}/views/example.aql (100%) diff --git a/spec/src/__init__.py b/spec/relation_engine_spec/__init__.py similarity index 100% rename from spec/src/__init__.py rename to spec/relation_engine_spec/__init__.py diff --git a/spec/src/migrations/README.md b/spec/relation_engine_spec/migrations/README.md similarity index 100% rename from spec/src/migrations/README.md rename to spec/relation_engine_spec/migrations/README.md diff --git a/spec/src/migrations/__init__.py b/spec/relation_engine_spec/migrations/__init__.py similarity index 100% rename from spec/src/migrations/__init__.py rename to spec/relation_engine_spec/migrations/__init__.py diff --git a/spec/src/migrations/example.py b/spec/relation_engine_spec/migrations/example.py similarity index 100% rename from spec/src/migrations/example.py rename to spec/relation_engine_spec/migrations/example.py diff --git a/spec/src/schemas/README.md b/spec/relation_engine_spec/schemas/README.md similarity index 100% rename from spec/src/schemas/README.md rename to spec/relation_engine_spec/schemas/README.md diff --git a/spec/src/schemas/__init__.py b/spec/relation_engine_spec/schemas/__init__.py similarity index 100% rename from spec/src/schemas/__init__.py rename to spec/relation_engine_spec/schemas/__init__.py diff --git a/spec/src/schemas/taxon.json b/spec/relation_engine_spec/schemas/taxon.json similarity index 100% rename from spec/src/schemas/taxon.json rename to spec/relation_engine_spec/schemas/taxon.json diff --git a/spec/src/test/README.md b/spec/relation_engine_spec/test/README.md similarity index 100% rename from spec/src/test/README.md rename to spec/relation_engine_spec/test/README.md diff --git a/spec/src/views/README.md b/spec/relation_engine_spec/views/README.md similarity index 100% rename from spec/src/views/README.md rename to spec/relation_engine_spec/views/README.md diff --git a/spec/src/views/__init__.py b/spec/relation_engine_spec/views/__init__.py similarity index 100% rename from spec/src/views/__init__.py rename to spec/relation_engine_spec/views/__init__.py diff --git a/spec/src/views/example.aql b/spec/relation_engine_spec/views/example.aql similarity index 100% rename from spec/src/views/example.aql rename to spec/relation_engine_spec/views/example.aql diff --git a/spec/setup.py b/spec/setup.py index d847ad69..a8deb9f3 100644 --- a/spec/setup.py +++ b/spec/setup.py @@ -5,10 +5,9 @@ version='0.1', author='Jay Bolton', author_email='jrbolton@lbl.gov', - package_dir={'': 'src'}, - packages=find_packages('src'), + packages=find_packages(), include_package_data=True, - package_data={'': ['*.aql', '*.json5']}, + package_data={'': ['*.aql', '*.json']}, license='MIT', description='Specifications for the KBase Relation Engine API.', url='https://kbase.us', From 8e9ee5156b06075286e9930606d25bd0e2e65346 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 24 Oct 2018 11:52:25 -0700 Subject: [PATCH 017/732] Some setuptools build improvements (add MANIFEST.in) --- spec/MANIFEST.in | 3 +++ spec/Makefile | 6 ++++++ spec/relation_engine_spec/views/MANIFEST.in | 1 + spec/setup.py | 1 - 4 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 spec/MANIFEST.in create mode 100644 spec/relation_engine_spec/views/MANIFEST.in diff --git a/spec/MANIFEST.in b/spec/MANIFEST.in new file mode 100644 index 00000000..abc88185 --- /dev/null +++ b/spec/MANIFEST.in @@ -0,0 +1,3 @@ +include README.md +include relation_engine_spec/views/*.aql +include relation_engine_spec/schemas/*.json diff --git a/spec/Makefile b/spec/Makefile index 81bd78a3..2f810097 100644 --- a/spec/Makefile +++ b/spec/Makefile @@ -3,3 +3,9 @@ test: test-server: echo "TODO run a single-node arango database server with pre-loaded test data" + +build-dist: + python setup.py sdist + +publish: + anaconda upload -i -u kbase dist/*.tar.gz diff --git a/spec/relation_engine_spec/views/MANIFEST.in b/spec/relation_engine_spec/views/MANIFEST.in new file mode 100644 index 00000000..af790b8a --- /dev/null +++ b/spec/relation_engine_spec/views/MANIFEST.in @@ -0,0 +1 @@ +include example.aql diff --git a/spec/setup.py b/spec/setup.py index a8deb9f3..85f35b50 100644 --- a/spec/setup.py +++ b/spec/setup.py @@ -7,7 +7,6 @@ author_email='jrbolton@lbl.gov', packages=find_packages(), include_package_data=True, - package_data={'': ['*.aql', '*.json']}, license='MIT', description='Specifications for the KBase Relation Engine API.', url='https://kbase.us', From 5ba08e06164a5c6d0f94de9fdce581e6adcd7cf8 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 24 Oct 2018 17:55:09 -0700 Subject: [PATCH 018/732] Make various headway towards a working API for running queries from views --- api/Dockerfile | 8 +++- api/docker-compose.yaml | 1 + api/requirements.txt | 2 + api/setup.py | 20 ++++++++++ .../{app.py => __main__.py} | 31 ++++++++++----- api/src/relation_engine_api/api/api_v1.py | 38 ++++++++++++------- .../relation_engine_api/api/run_query.yaml | 20 ++++++---- .../api/save_documents.yaml | 6 +-- .../relation_engine_api/api/show_schemas.yaml | 9 ++--- .../relation_engine_api/api/show_views.yaml | 9 ++--- .../arango_utils/arango_requests.py | 27 +++++++++++++ 11 files changed, 124 insertions(+), 47 deletions(-) create mode 100644 api/setup.py rename api/src/relation_engine_api/{app.py => __main__.py} (69%) create mode 100644 api/src/relation_engine_api/arango_utils/arango_requests.py diff --git a/api/Dockerfile b/api/Dockerfile index ebef61ae..39b67ade 100644 --- a/api/Dockerfile +++ b/api/Dockerfile @@ -8,11 +8,15 @@ WORKDIR /app RUN apk --update add make RUN apk --update add --virtual build-dependencies python-dev build-base && \ pip install --upgrade pip && \ - pip install -r requirements.txt && \ + pip install --upgrade --no-cache-dir \ + --extra-index-url https://pypi.anaconda.org/kbase/simple \ + -r requirements.txt && \ pip install -r dev-requirements.txt && \ apk del build-dependencies # Run the app COPY . /app -CMD ["gunicorn", "--worker-class", "gevent", "--timeout", "1800", "--workers", "17", "-b", ":5000", "--reload", "src.relation_engine_api.app:app"] +ENV PYTHONUNBUFFERED="true" + +CMD ["gunicorn", "--worker-class", "gevent", "--timeout", "1800", "--workers", "17", "-b", ":5000", "--reload", "src.relation_engine_api.__main__:app"] diff --git a/api/docker-compose.yaml b/api/docker-compose.yaml index d15f53dd..3480b25f 100644 --- a/api/docker-compose.yaml +++ b/api/docker-compose.yaml @@ -10,3 +10,4 @@ services: - "5000:5000" volumes: - .:/app + network_mode: host diff --git a/api/requirements.txt b/api/requirements.txt index 7ad7e583..79539d76 100644 --- a/api/requirements.txt +++ b/api/requirements.txt @@ -5,3 +5,5 @@ simplejson==3.16.0 python-dotenv==0.9.1 requests==2.19.1 flasgger==0.9.1 +relation_engine_spec==0.1 +connexion==1.5.3 diff --git a/api/setup.py b/api/setup.py new file mode 100644 index 00000000..f06a1cbc --- /dev/null +++ b/api/setup.py @@ -0,0 +1,20 @@ +from setuptools import setup, find_packages + + +setup( + name='relation_engine_api', + version='0.0.1', + description='Relation Engine API', + author_email='info@kbase.us', + url='', + install_requires=[ + 'connexion' + ], + packages=find_packages(), + package_data={'': ['src/relation_engine_api/openapi/api_v1.yaml']}, + include_package_data=True, + entry_points={ + 'console_scripts': ['swagger_server=relation_engine_api.__main__:main'] + }, + long_description='Relation Engine Rest/JSON API.''' +) diff --git a/api/src/relation_engine_api/app.py b/api/src/relation_engine_api/__main__.py similarity index 69% rename from api/src/relation_engine_api/app.py rename to api/src/relation_engine_api/__main__.py index 15ae5b1c..c845aa40 100644 --- a/api/src/relation_engine_api/app.py +++ b/api/src/relation_engine_api/__main__.py @@ -6,13 +6,6 @@ from .api.api_v1 import api_v1 -app = flask.Flask(__name__) -app.config['DEBUG'] = os.environ.get('FLASK_DEBUG', True) -app.config['SECRET_KEY'] = os.environ.get('FLASK_SECRET_KEY', str(uuid4())) -app.url_map.strict_slashes = False # allow both `get /v1/` and `get /v1` - -app.register_blueprint(api_v1, url_prefix='/v1') - swagger_template = { 'openapi': '3.0.2', 'info': { @@ -29,6 +22,11 @@ 'schemes': ['https'] } +app = flask.Flask(__name__) +app.config['DEBUG'] = os.environ.get('FLASK_DEBUG', True) +app.config['SECRET_KEY'] = os.environ.get('FLASK_SECRET_KEY', str(uuid4())) +app.url_map.strict_slashes = False # allow both `get /v1/` and `get /v1` +app.register_blueprint(api_v1, url_prefix='/v1') swagger = Swagger(app, template=swagger_template) @@ -40,9 +38,24 @@ def root(): @app.errorhandler(404) def page_not_found(err): - return (flask.jsonify({'status': 'error', 'error': '404 - Not found.'}), 404) + return (flask.jsonify({'error': '404 - Not found.'}), 404) @app.errorhandler(405) def method_not_allowed(err): - return (flask.jsonify({'status': 'error', 'error': '405 - Method not allowed.'}), 405) + return (flask.jsonify({'error': '405 - Method not allowed.'}), 405) + + +# Any other unhandled exceptions -> 500 +@app.errorhandler(Exception) +@app.errorhandler(500) +def server_error(err): + print(err) + return (flask.jsonify({'error': 'Server error: %s' % str(err)}), 500) + + +@app.after_request +def log_response(response): + """Simple log of each request's response.""" + print(' '.join([flask.request.method, flask.request.path, '->', response.status])) + return response diff --git a/api/src/relation_engine_api/api/api_v1.py b/api/src/relation_engine_api/api/api_v1.py index cbee102f..97f00220 100644 --- a/api/src/relation_engine_api/api/api_v1.py +++ b/api/src/relation_engine_api/api/api_v1.py @@ -3,6 +3,9 @@ import subprocess import flask from flasgger import swag_from +import relation_engine_spec.views + +from src.relation_engine_api.arango_utils.arango_requests import make_arango_request api_v1 = flask.Blueprint('api_v1', __name__) @@ -24,36 +27,45 @@ def root(): }) -@swag_from('show_views.yaml') +@swag_from('show_views.yaml', validation=True) @api_v1.route('/views', methods=['GET']) def show_views(): """See ./show_views.yaml for documentation.""" - return flask.jsonify({'test': True}) + view_names = relation_engine_spec.views.get_view_names() + resp = {'names': view_names} + if flask.request.args.get('show_source'): + resp['content'] = {} + for name in view_names: + resp['content'][name] = relation_engine_spec.views.get_view_content(name) + return flask.jsonify(resp) -@swag_from('run_query.yaml') -@api_v1.route('/query', methods=['GET']) -def run_query(): +@swag_from('run_query.yaml', validation=True) +@api_v1.route('/views//query', methods=['POST']) +def run_query(view_name): """See ./run_query.yaml for documentation.""" - return flask.jsonify([]) + view_source = relation_engine_spec.views.get_view_content(view_name) + # args = flask.request.json + # Make a request to the Arango server to run the query + req_data = {'query': view_source, 'batchSize': 100, 'count': True} + resp_data = make_arango_request('/_api/cursor', req_data) + return flask.jsonify(resp_data) -@swag_from('show_schemas.yaml') +@swag_from('show_schemas.yaml', validation=True) @api_v1.route('/schemas', methods=['GET']) def show_schemas(): """See ./show_schemas.yaml for documentation.""" return flask.jsonify({}) -@swag_from('save_documents.yaml') +@swag_from('save_documents.yaml', validation=True) @api_v1.route('/documents', methods=['PUT']) def save_documents(): """See ./save_documents.yaml for documentation.""" return flask.jsonify({}) -# @swag_from('delete_documents.yaml') -# @api_v1.route('/documents', methods=['DELETE']) -# def delete_documents(): -# """See ./delete_documents.yaml for documentation.""" -# return flask.jsonify({}) +@api_v1.errorhandler(relation_engine_spec.views.ViewNonexistent) +def view_does_not_exist(err): + return (flask.jsonify({'error': str(err)}), 400) diff --git a/api/src/relation_engine_api/api/run_query.yaml b/api/src/relation_engine_api/api/run_query.yaml index efb72eae..e2b41514 100644 --- a/api/src/relation_engine_api/api/run_query.yaml +++ b/api/src/relation_engine_api/api/run_query.yaml @@ -1,14 +1,20 @@ -Execute a saved query (a "view") using custom arguments and return the results as JSON. +Execute a view as a query against the database. --- tags: ["views"] parameters: -- name: name - in: query +- name: view_name + in: path required: true - description: Name of the view to run. - schema: - type: string - example: "view_name" + description: Name of the view for running the query. + schema: {type: string} +requestBody: + description: Arguments for the query. + content: + application/json: + required: true + schema: + type: object + required: true responses: 200: description: Result data. diff --git a/api/src/relation_engine_api/api/save_documents.yaml b/api/src/relation_engine_api/api/save_documents.yaml index 662dbb12..b8b8e170 100644 --- a/api/src/relation_engine_api/api/save_documents.yaml +++ b/api/src/relation_engine_api/api/save_documents.yaml @@ -1,10 +1,8 @@ Create, update, or replace documents in the database. -Pass in an array of objects that describe documents to be created, updated, and/or replaced in the -database. View the "Model" below for further details on the structure of the parameters. +Pass in an array of objects that describe documents to be created, updated, and/or replaced in the database. View the "Model" below for further details on the structure of the parameters. -"onDuplicate" controls what happens when we encounter documents with the same "_key" attributes. -Valid options are "error", "update", "replace", or "ignore". The default is "error". +"onDuplicate" controls what happens when we encounter documents with the same "_key" attributes. Valid options are "error", "update", "replace", or "ignore". The default is "error". If any update fails, then no changes are made to the database. --- diff --git a/api/src/relation_engine_api/api/show_schemas.yaml b/api/src/relation_engine_api/api/show_schemas.yaml index 96cbcd96..b4653d57 100644 --- a/api/src/relation_engine_api/api/show_schemas.yaml +++ b/api/src/relation_engine_api/api/show_schemas.yaml @@ -2,14 +2,11 @@ Fetch a list of saved schemas with optional filters. --- tags: ["schemas"] parameters: -- name: collection_names +- name: show_source in: query required: false - description: An array listing collection names to filter for accessible schemas - schema: - type: array - items: {type: string} - example: [genomes, genes, reactions] + description: Whether to show the JSON of each schema. + schema: {type: boolean} responses: 200: description: "View data." diff --git a/api/src/relation_engine_api/api/show_views.yaml b/api/src/relation_engine_api/api/show_views.yaml index 8813dc05..11c5d18f 100644 --- a/api/src/relation_engine_api/api/show_views.yaml +++ b/api/src/relation_engine_api/api/show_views.yaml @@ -2,13 +2,10 @@ List out all the available views, optionally showing the parameters and AQL sour --- tags: ["views"] parameters: -- name: names +- name: show_source in: query - required: true - description: Array of view names to fetch (if blank, then all views are fetched) - schema: - type: array - items: {type: string} + description: Whether to show the AQL source code for each view. + schema: {type: boolean} responses: 200: description: "Array of views." diff --git a/api/src/relation_engine_api/arango_utils/arango_requests.py b/api/src/relation_engine_api/arango_utils/arango_requests.py new file mode 100644 index 00000000..72d5a707 --- /dev/null +++ b/api/src/relation_engine_api/arango_utils/arango_requests.py @@ -0,0 +1,27 @@ +""" +Make ajax requests to the ArangoDB server +""" +import json +import requests +import os + + +db_url = os.environ.get('DB_URL', 'http://localhost:8529') +db_user = os.environ.get('DB_USER', 'root') +db_pass = os.environ.get('DB_PASS', 'password') + + +test_query = """ +for doc in @@collection + collect with count into length + return length +""" + + +def make_arango_request(path, data): + data = {'query': test_query, 'bindVars': {'@collection': 'genes'}} + print('-' * 80) + print(db_url + path) + print(data) + resp = requests.post(db_url + path, data=json.dumps(data), auth=(db_user, db_pass)) + return resp.text From 2764a262c92d85a9c90505e95f6f06afe63e7169 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Thu, 25 Oct 2018 15:42:41 -0700 Subject: [PATCH 019/732] Generalize the small function that makes requests to arango --- .../arango_utils/arango_requests.py | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/api/src/relation_engine_api/arango_utils/arango_requests.py b/api/src/relation_engine_api/arango_utils/arango_requests.py index 72d5a707..34f46728 100644 --- a/api/src/relation_engine_api/arango_utils/arango_requests.py +++ b/api/src/relation_engine_api/arango_utils/arango_requests.py @@ -11,17 +11,7 @@ db_pass = os.environ.get('DB_PASS', 'password') -test_query = """ -for doc in @@collection - collect with count into length - return length -""" - - def make_arango_request(path, data): - data = {'query': test_query, 'bindVars': {'@collection': 'genes'}} - print('-' * 80) - print(db_url + path) - print(data) + """Make a generic arango request.""" resp = requests.post(db_url + path, data=json.dumps(data), auth=(db_user, db_pass)) return resp.text From b014646958841d4048fc9f4c1293269df3ee134f Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Fri, 26 Oct 2018 13:24:38 -0700 Subject: [PATCH 020/732] Improvements: - Add functionality for bulk document updates - Add functionality for viewing schema names and content - Improve functionality for running queries - Add an "arangodb_status" message to the root endpoint - Add a basic root endpoint test --- api/docker-compose.yaml | 11 ++++- api/src/relation_engine_api/api/api_v1.py | 35 +++++++++++--- .../api/save_documents.yaml | 28 +++++------ .../arango_utils/arango_requests.py | 46 ++++++++++++++++--- api/src/test/test_api_v1.py | 4 +- 5 files changed, 96 insertions(+), 28 deletions(-) diff --git a/api/docker-compose.yaml b/api/docker-compose.yaml index 3480b25f..808c050b 100644 --- a/api/docker-compose.yaml +++ b/api/docker-compose.yaml @@ -10,4 +10,13 @@ services: - "5000:5000" volumes: - .:/app - network_mode: host + environment: + - DB_URL=http://arangodb:8529 + + # For running (and testing against) ArangoDB + arangodb: + image: arangodb + ports: + - 8529:8529 + environment: + - ARANGO_ROOT_PASSWORD=password diff --git a/api/src/relation_engine_api/api/api_v1.py b/api/src/relation_engine_api/api/api_v1.py index 97f00220..0eda6bb8 100644 --- a/api/src/relation_engine_api/api/api_v1.py +++ b/api/src/relation_engine_api/api/api_v1.py @@ -1,11 +1,15 @@ """The primary router for the Relation Engine API v1.""" import time -import subprocess import flask from flasgger import swag_from import relation_engine_spec.views +import relation_engine_spec.schemas -from src.relation_engine_api.arango_utils.arango_requests import make_arango_request +from src.relation_engine_api.arango_utils.arango_requests import ( + arango_post_request, + arango_server_status, + ArangoServerError +) api_v1 = flask.Blueprint('api_v1', __name__) @@ -20,10 +24,12 @@ def root(): responses: 200: {description: "Server status."} """ + with open('.git/refs/heads/master', 'r') as fd: + commit_hash = fd.read().strip() return flask.jsonify({ - 'docs': '/apidocs', 'server_time': int(time.time() * 1000), - 'current_commit_hash': subprocess.check_output(['cat', '.git/refs/heads/master']).strip() + 'current_commit_hash': commit_hash, + 'arangodb_status': arango_server_status() }) @@ -45,10 +51,10 @@ def show_views(): def run_query(view_name): """See ./run_query.yaml for documentation.""" view_source = relation_engine_spec.views.get_view_content(view_name) - # args = flask.request.json + bind_vars = flask.request.json # Make a request to the Arango server to run the query - req_data = {'query': view_source, 'batchSize': 100, 'count': True} - resp_data = make_arango_request('/_api/cursor', req_data) + req_json = {'query': view_source, 'batchSize': 100, 'count': True, 'bindVars': bind_vars} + resp_data = arango_post_request('/_api/cursor', data=req_json) return flask.jsonify(resp_data) @@ -56,6 +62,12 @@ def run_query(view_name): @api_v1.route('/schemas', methods=['GET']) def show_schemas(): """See ./show_schemas.yaml for documentation.""" + schema_names = relation_engine_spec.schemas.get_schema_names() + resp = {'names': schema_names} + if flask.request.args.get('show_source'): + resp['content'] = {} + for name in schema_names: + resp['content'][name] = relation_engine_spec.schemas.get_schema_content(name) return flask.jsonify({}) @@ -63,9 +75,18 @@ def show_schemas(): @api_v1.route('/documents', methods=['PUT']) def save_documents(): """See ./save_documents.yaml for documentation.""" + data_stream = flask.request.stream + q = { + 'collection': flask.request.args['collection'], + 'onDuplicate': flask.request.args['onDuplicate'], + 'type': 'documents' + } + arango_post_request('/_api/import', data_stream, query=q) return flask.jsonify({}) +@api_v1.errorhandler(ArangoServerError) @api_v1.errorhandler(relation_engine_spec.views.ViewNonexistent) def view_does_not_exist(err): + """General error cases.""" return (flask.jsonify({'error': str(err)}), 400) diff --git a/api/src/relation_engine_api/api/save_documents.yaml b/api/src/relation_engine_api/api/save_documents.yaml index b8b8e170..41cc5c3e 100644 --- a/api/src/relation_engine_api/api/save_documents.yaml +++ b/api/src/relation_engine_api/api/save_documents.yaml @@ -1,8 +1,8 @@ Create, update, or replace documents in the database. -Pass in an array of objects that describe documents to be created, updated, and/or replaced in the database. View the "Model" below for further details on the structure of the parameters. +Pass in an array of objects that describe documents to be created, updated, and/or replaced in the database. -"onDuplicate" controls what happens when we encounter documents with the same "_key" attributes. Valid options are "error", "update", "replace", or "ignore". The default is "error". +"onDuplicate" controls what happens when we encounter documents with the same "_key" attribute. Valid options are "error", "update", "replace", or "ignore". The default is "error". If any update fails, then no changes are made to the database. --- @@ -12,17 +12,19 @@ parameters: in: body required: true schema: - type: array - items: - type: object - required: [collection, doc] - properties: - collection: {type: string, example: "genes"} - onDuplicate: - type: string - default: "error" - enum: ["error", "update", "replace", "ignore"] - doc: + type: object + required: ["collection", "docs"] + properties: + onDuplicate: + type: string + default: "error" + enum: ["error", "update", "replace", "ignore"] + collection: + type: string + examples: ["collection_name"] + docs: + type: array + items: type: object required: ["_key"] example: { diff --git a/api/src/relation_engine_api/arango_utils/arango_requests.py b/api/src/relation_engine_api/arango_utils/arango_requests.py index 34f46728..5660ed1f 100644 --- a/api/src/relation_engine_api/arango_utils/arango_requests.py +++ b/api/src/relation_engine_api/arango_utils/arango_requests.py @@ -1,17 +1,51 @@ """ -Make ajax requests to the ArangoDB server +Make ajax requests to the ArangoDB server. """ -import json import requests import os - db_url = os.environ.get('DB_URL', 'http://localhost:8529') db_user = os.environ.get('DB_USER', 'root') db_pass = os.environ.get('DB_PASS', 'password') -def make_arango_request(path, data): - """Make a generic arango request.""" - resp = requests.post(db_url + path, data=json.dumps(data), auth=(db_user, db_pass)) +def arango_server_status(): + """Get the status of our connection and authorization to the ArangoDB server.""" + try: + resp = requests.get(db_url + '/_api/endpoint', auth=(db_user, db_pass)) + except requests.exceptions.ConnectionError: + return 'Failed to establish a connection to %s.' % db_url + if resp.status_code == 200: + return 'Connected and authorized.' + elif resp.status_code == 401: + return 'Unauthorized; username or password is invalid.' + else: + return 'Failed to connect: %s' % resp.text + + +def arango_post_request(path, data, query={}, method='post'): + """Make a generic arango post request.""" + resp = requests.post( + db_url + path, + data=data, + auth=(db_user, db_pass), + params=query + ) + if resp.status_code != 200: + raise ArangoServerError(resp.text) return resp.text + + +class ArangoServerError(Exception): + """A request to the ArangoDB server has failed (non-2xx).""" + + def __init__(self, resp_text): + self.resp_text = resp_text + + def __str__(self): + return '\n'.join([ + '-' * 80, + 'ArangoDB server error', + self.resp_text, + '-' * 80 + ]) diff --git a/api/src/test/test_api_v1.py b/api/src/test/test_api_v1.py index 1d750963..3ee0d125 100644 --- a/api/src/test/test_api_v1.py +++ b/api/src/test/test_api_v1.py @@ -15,4 +15,6 @@ def test_root(self): """Test root path for api.""" resp = requests.get(url) json = resp.json() - self.assertTrue(json['test']) + self.assertEqual(json['arangodb_status'], 'Connected and authorized.') + self.assertTrue(json['server_time']) + self.assertTrue(json['current_commit_hash']) From 08ddc517fd6b92450ebff2bc7ca82978dfb196f8 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Fri, 26 Oct 2018 13:51:51 -0700 Subject: [PATCH 021/732] Add some more docker parameters in preparation for prod deployment --- api/Dockerfile | 11 +++++++---- api/docker-compose.yaml | 1 + api/src/relation_engine_api/__main__.py | 3 +-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/api/Dockerfile b/api/Dockerfile index 39b67ade..e88376c5 100644 --- a/api/Dockerfile +++ b/api/Dockerfile @@ -1,5 +1,10 @@ FROM python:3.7-alpine +# Are we in development or testing mode? +ARG DEVELOPMENT +# How many workers to use in running the server +ARG WORKERS=17 + COPY requirements.txt /app/requirements.txt COPY dev-requirements.txt /app/dev-requirements.txt WORKDIR /app @@ -11,12 +16,10 @@ RUN apk --update add --virtual build-dependencies python-dev build-base && \ pip install --upgrade --no-cache-dir \ --extra-index-url https://pypi.anaconda.org/kbase/simple \ -r requirements.txt && \ - pip install -r dev-requirements.txt && \ + if [ "$DEVELOPMENT" ]; then pip install -r dev-requirements.txt; fi && \ apk del build-dependencies # Run the app COPY . /app -ENV PYTHONUNBUFFERED="true" - -CMD ["gunicorn", "--worker-class", "gevent", "--timeout", "1800", "--workers", "17", "-b", ":5000", "--reload", "src.relation_engine_api.__main__:app"] +CMD ["gunicorn", "--worker-class", "gevent", "--timeout", "1800", "--workers", $WORKERS, "-b", ":5000", "--reload", "src.relation_engine_api.__main__:app"] diff --git a/api/docker-compose.yaml b/api/docker-compose.yaml index 808c050b..46f5a443 100644 --- a/api/docker-compose.yaml +++ b/api/docker-compose.yaml @@ -11,6 +11,7 @@ services: volumes: - .:/app environment: + - PYTHONUNBUFFERED=true - DB_URL=http://arangodb:8529 # For running (and testing against) ArangoDB diff --git a/api/src/relation_engine_api/__main__.py b/api/src/relation_engine_api/__main__.py index c845aa40..3a88bdab 100644 --- a/api/src/relation_engine_api/__main__.py +++ b/api/src/relation_engine_api/__main__.py @@ -13,8 +13,7 @@ 'description': 'API for working with the KBase Relation Engine graph database.', 'contact': { 'responsibleOrganization': 'DOE KBase', - 'responsibleDeveloper': 'Jay R Bolton ', - 'email': 'scanon@lbl.gov', + 'email': 'info@kbase.us', 'url': 'https://kbase.us' }, 'version': '1' From 476a03be4ce144ffdc4f79c04aac4bc1e05348a1 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Fri, 26 Oct 2018 16:29:44 -0700 Subject: [PATCH 022/732] More docker and build improvements --- api/.env.development.example | 4 ++++ api/.env.production.example | 7 +++++++ api/Dockerfile | 5 +---- api/Makefile | 6 +----- api/README.md | 18 +++++++++++++----- api/docker-compose.yaml | 9 ++++++++- api/setup.py | 20 -------------------- api/start_server.sh | 8 ++++++++ 8 files changed, 42 insertions(+), 35 deletions(-) create mode 100644 api/.env.development.example create mode 100644 api/.env.production.example delete mode 100644 api/setup.py create mode 100644 api/start_server.sh diff --git a/api/.env.development.example b/api/.env.development.example new file mode 100644 index 00000000..960f394c --- /dev/null +++ b/api/.env.development.example @@ -0,0 +1,4 @@ +DB_URL=http://localhost:8529 +DB_USER=root +DB_PASS=password +KBASE_ENDPOINT="https://ci.kbase.us/services/" diff --git a/api/.env.production.example b/api/.env.production.example new file mode 100644 index 00000000..776c28e1 --- /dev/null +++ b/api/.env.production.example @@ -0,0 +1,7 @@ +DB_URL=http://graph1:8529 +DB_USER=root +DB_PASS=password +KBASE_ENDPOINT="https://ci.kbase.us/services/" + +# You can also set: +# WORKERS - set number of gevent workers (otherwise automatically calculated) diff --git a/api/Dockerfile b/api/Dockerfile index e88376c5..cb766e7f 100644 --- a/api/Dockerfile +++ b/api/Dockerfile @@ -1,9 +1,6 @@ FROM python:3.7-alpine -# Are we in development or testing mode? ARG DEVELOPMENT -# How many workers to use in running the server -ARG WORKERS=17 COPY requirements.txt /app/requirements.txt COPY dev-requirements.txt /app/dev-requirements.txt @@ -22,4 +19,4 @@ RUN apk --update add --virtual build-dependencies python-dev build-base && \ # Run the app COPY . /app -CMD ["gunicorn", "--worker-class", "gevent", "--timeout", "1800", "--workers", $WORKERS, "-b", ":5000", "--reload", "src.relation_engine_api.__main__:app"] +CMD ["sh", "start_server.sh"] diff --git a/api/Makefile b/api/Makefile index 85a3a646..1a9c8596 100644 --- a/api/Makefile +++ b/api/Makefile @@ -1,11 +1,7 @@ .PHONY: dev-server dev-build test test-local dev-server: - DEVELOPMENT=1 docker-compose up - -dev-build: - docker-compose down - docker-compose build --build-arg DEVELOPMENT=1 --no-cache web + docker-compose up test: docker-compose run web make test-local diff --git a/api/README.md b/api/README.md index 1d46a505..5bb07477 100644 --- a/api/README.md +++ b/api/README.md @@ -1,16 +1,24 @@ # Biochem Server with ArangoDB +A simple API that allows KBase community developers to interact with the Relation Engine graph database. You can run stored queries or do bulk updates on documents. + +View the root path of the running server in your browser to get the Swagger API interface. + +View `/v1` to get server status. All API endpoints are nested under `/v1` and are documented via the Swagger API. + ## Development -Start up the server with `docker-compose up` or `make dev-server`. +Copy `.env.development.example` or `.env.production.example` to `.env` and edit it, if needed. + +The docker image is pushed to Docker Hub when new commits are made to master. -Rebuild the server with `make dev-build`. +Start up the server `make dev-server`. -Run the tests with `make test`. +Run tests against the server with `make test`. ## Project anatomy * Source code is in `./src` * Tests are in `./src/test` -* The server startup code is in `./src/arangodb_biochem_server/app.py` -* API v1 endpoints are in `./src/arangodb_biochem_server/api/api_v1.py` +* The main server code is in `./src/relation_engine_api/__main__.py` +* API v1 endpoints are in `./src/relation_engine_api/api/api_v1.py` diff --git a/api/docker-compose.yaml b/api/docker-compose.yaml index 46f5a443..4853b0d5 100644 --- a/api/docker-compose.yaml +++ b/api/docker-compose.yaml @@ -1,10 +1,15 @@ version: '3' +# This docker-compose is for developer convenience, not for running in production. + services: # For running the Flask server web: - build: . + build: + context: . + args: + DEVELOPMENT: 1 env_file: .env ports: - "5000:5000" @@ -13,6 +18,8 @@ services: environment: - PYTHONUNBUFFERED=true - DB_URL=http://arangodb:8529 + - FLASK_ENV=development + - FLASK_DEBUG=1 # For running (and testing against) ArangoDB arangodb: diff --git a/api/setup.py b/api/setup.py deleted file mode 100644 index f06a1cbc..00000000 --- a/api/setup.py +++ /dev/null @@ -1,20 +0,0 @@ -from setuptools import setup, find_packages - - -setup( - name='relation_engine_api', - version='0.0.1', - description='Relation Engine API', - author_email='info@kbase.us', - url='', - install_requires=[ - 'connexion' - ], - packages=find_packages(), - package_data={'': ['src/relation_engine_api/openapi/api_v1.yaml']}, - include_package_data=True, - entry_points={ - 'console_scripts': ['swagger_server=relation_engine_api.__main__:main'] - }, - long_description='Relation Engine Rest/JSON API.''' -) diff --git a/api/start_server.sh b/api/start_server.sh new file mode 100644 index 00000000..880398d1 --- /dev/null +++ b/api/start_server.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +# Set the number of gevent workers to number of cores * 2 + 1 +# See: http://docs.gunicorn.org/en/stable/design.html#how-many-workers +calc_workers="$(($(nproc) * 2 + 1))" +workers=${WORKERS:-$calc_workers} + +gunicorn --worker-class gevent --timeout 1800 --workers $workers -b :5000 --reload src.relation_engine_api.__main__:app From e74f6e999ebf5f5de239e64a722a2f443dd8a07b Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Fri, 26 Oct 2018 16:32:47 -0700 Subject: [PATCH 023/732] Add .travis.yml --- api/.travis.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 api/.travis.yml diff --git a/api/.travis.yml b/api/.travis.yml new file mode 100644 index 00000000..dff73b74 --- /dev/null +++ b/api/.travis.yml @@ -0,0 +1,10 @@ +sudo: required +services: +- docker +language: python +python: +- '3.7' +script: +- cp .env.development.example .env +- docker-compose up -d +- make test From 2fcecde1e44775061d80003990b1223186620761 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Fri, 26 Oct 2018 16:34:28 -0700 Subject: [PATCH 024/732] Fix title --- api/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/README.md b/api/README.md index 5bb07477..21576cc6 100644 --- a/api/README.md +++ b/api/README.md @@ -1,4 +1,4 @@ -# Biochem Server with ArangoDB +# Relation Engine API A simple API that allows KBase community developers to interact with the Relation Engine graph database. You can run stored queries or do bulk updates on documents. From 6741af34d631f62dc3b4fad7c05170132cacabbb Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Fri, 26 Oct 2018 16:37:59 -0700 Subject: [PATCH 025/732] Add hooks/build for docker --- api/.gitignore | 8 ++++---- api/hooks/build | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 4 deletions(-) create mode 100755 api/hooks/build diff --git a/api/.gitignore b/api/.gitignore index 2da1cb6c..2be5fcda 100644 --- a/api/.gitignore +++ b/api/.gitignore @@ -2,11 +2,11 @@ .env # Caches and temp dirs -build -dist +/build/ +/dist/ *.pyc -.mypy_cache -.cache +.mypy_cache/ +.cache/ tmp/* coverage_report/ .coverage diff --git a/api/hooks/build b/api/hooks/build new file mode 100755 index 00000000..ffed9243 --- /dev/null +++ b/api/hooks/build @@ -0,0 +1,14 @@ +#!/bin/bash + +# See the docs for automated docker builds: https://docs.docker.com/docker-cloud/builds/advanced/ + +# $IMAGE_NAME var is injected into the build so the tag is correct. + +echo "Build hook running" +export BRANCH=${TRAVIS_BRANCH:-`git symbolic-ref --short HEAD`} +export DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` +export COMMIT=${TRAVIS_COMMIT:-`git rev-parse --short HEAD`} +docker build --build-arg BUILD_DATE=$DATE \ + --build-arg VCS_REF=$COMMIT \ + --build-arg BRANCH=$BRANCH \ + -t ${IMAGE_NAME} . From 372f4b822715aa0b111c5c11c08c3e5982774e31 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Fri, 26 Oct 2018 16:50:24 -0700 Subject: [PATCH 026/732] Clean up some package organization; add some client boilerplate --- api/.env.development.example | 4 -- api/.env.example | 7 ++++ api/.env.production.example | 7 ---- api/README.md | 42 ++++++++++++++++++- api/src/relation_engine_client/__init__.py | 3 ++ .../__init__.py | 0 .../__main__.py | 0 .../api/__init__.py | 0 .../api/api_v1.py | 2 +- .../api/delete_documents.yaml | 0 .../api/run_query.yaml | 0 .../api/save_documents.yaml | 0 .../api/show_schemas.yaml | 0 .../api/show_views.yaml | 0 .../arango_utils/arango_requests.py | 0 api/start_server.sh | 2 +- 16 files changed, 52 insertions(+), 15 deletions(-) delete mode 100644 api/.env.development.example delete mode 100644 api/.env.production.example create mode 100644 api/src/relation_engine_client/__init__.py rename api/src/{relation_engine_api => relation_engine_server}/__init__.py (100%) rename api/src/{relation_engine_api => relation_engine_server}/__main__.py (100%) rename api/src/{relation_engine_api => relation_engine_server}/api/__init__.py (100%) rename api/src/{relation_engine_api => relation_engine_server}/api/api_v1.py (97%) rename api/src/{relation_engine_api => relation_engine_server}/api/delete_documents.yaml (100%) rename api/src/{relation_engine_api => relation_engine_server}/api/run_query.yaml (100%) rename api/src/{relation_engine_api => relation_engine_server}/api/save_documents.yaml (100%) rename api/src/{relation_engine_api => relation_engine_server}/api/show_schemas.yaml (100%) rename api/src/{relation_engine_api => relation_engine_server}/api/show_views.yaml (100%) rename api/src/{relation_engine_api => relation_engine_server}/arango_utils/arango_requests.py (100%) diff --git a/api/.env.development.example b/api/.env.development.example deleted file mode 100644 index 960f394c..00000000 --- a/api/.env.development.example +++ /dev/null @@ -1,4 +0,0 @@ -DB_URL=http://localhost:8529 -DB_USER=root -DB_PASS=password -KBASE_ENDPOINT="https://ci.kbase.us/services/" diff --git a/api/.env.example b/api/.env.example index e69de29b..776c28e1 100644 --- a/api/.env.example +++ b/api/.env.example @@ -0,0 +1,7 @@ +DB_URL=http://graph1:8529 +DB_USER=root +DB_PASS=password +KBASE_ENDPOINT="https://ci.kbase.us/services/" + +# You can also set: +# WORKERS - set number of gevent workers (otherwise automatically calculated) diff --git a/api/.env.production.example b/api/.env.production.example deleted file mode 100644 index 776c28e1..00000000 --- a/api/.env.production.example +++ /dev/null @@ -1,7 +0,0 @@ -DB_URL=http://graph1:8529 -DB_USER=root -DB_PASS=password -KBASE_ENDPOINT="https://ci.kbase.us/services/" - -# You can also set: -# WORKERS - set number of gevent workers (otherwise automatically calculated) diff --git a/api/README.md b/api/README.md index 21576cc6..4df0c13a 100644 --- a/api/README.md +++ b/api/README.md @@ -6,6 +6,34 @@ View the root path of the running server in your browser to get the Swagger API View `/v1` to get server status. All API endpoints are nested under `/v1` and are documented via the Swagger API. +## Using the client + +A python client is provided and published on anaconda, installable via pip or conda: + +```sh +$ pip install --extra-index-url https://pypi.anaconda.org/kbase/simple relation_engine_client==0.1 +``` + +Then import it: + +```py +import relation_engine_client as rec +``` + +List out all the current relation engine views: + +```py +views = rec.get_views(show_source=True) +# returns an array of {name, source} +``` + +List out all the current schemas + +```py +schemas = rec.get_schemas(show_source=True) +# returns an array of {name, source} +``` + ## Development Copy `.env.development.example` or `.env.production.example` to `.env` and edit it, if needed. @@ -16,9 +44,19 @@ Start up the server `make dev-server`. Run tests against the server with `make test`. +## Building and publishing the client + +The client package is built with setuptools and published to anaconda, where it can then be installed via pip or conda. + +```sh +$ make build-client +$ make publish-client +``` + ## Project anatomy * Source code is in `./src` * Tests are in `./src/test` -* The main server code is in `./src/relation_engine_api/__main__.py` -* API v1 endpoints are in `./src/relation_engine_api/api/api_v1.py` +* The main server code is in `./src/relation_engine_server/__main__.py` +* API v1 endpoints are in `./src/relation_engine_server/api/api_v1.py` +* A python client package is in `./src/relation_engine_client` diff --git a/api/src/relation_engine_client/__init__.py b/api/src/relation_engine_client/__init__.py new file mode 100644 index 00000000..ce5ce389 --- /dev/null +++ b/api/src/relation_engine_client/__init__.py @@ -0,0 +1,3 @@ +# TODO + +x = 1 diff --git a/api/src/relation_engine_api/__init__.py b/api/src/relation_engine_server/__init__.py similarity index 100% rename from api/src/relation_engine_api/__init__.py rename to api/src/relation_engine_server/__init__.py diff --git a/api/src/relation_engine_api/__main__.py b/api/src/relation_engine_server/__main__.py similarity index 100% rename from api/src/relation_engine_api/__main__.py rename to api/src/relation_engine_server/__main__.py diff --git a/api/src/relation_engine_api/api/__init__.py b/api/src/relation_engine_server/api/__init__.py similarity index 100% rename from api/src/relation_engine_api/api/__init__.py rename to api/src/relation_engine_server/api/__init__.py diff --git a/api/src/relation_engine_api/api/api_v1.py b/api/src/relation_engine_server/api/api_v1.py similarity index 97% rename from api/src/relation_engine_api/api/api_v1.py rename to api/src/relation_engine_server/api/api_v1.py index 0eda6bb8..f6c03482 100644 --- a/api/src/relation_engine_api/api/api_v1.py +++ b/api/src/relation_engine_server/api/api_v1.py @@ -5,7 +5,7 @@ import relation_engine_spec.views import relation_engine_spec.schemas -from src.relation_engine_api.arango_utils.arango_requests import ( +from src.relation_engine_server.arango_utils.arango_requests import ( arango_post_request, arango_server_status, ArangoServerError diff --git a/api/src/relation_engine_api/api/delete_documents.yaml b/api/src/relation_engine_server/api/delete_documents.yaml similarity index 100% rename from api/src/relation_engine_api/api/delete_documents.yaml rename to api/src/relation_engine_server/api/delete_documents.yaml diff --git a/api/src/relation_engine_api/api/run_query.yaml b/api/src/relation_engine_server/api/run_query.yaml similarity index 100% rename from api/src/relation_engine_api/api/run_query.yaml rename to api/src/relation_engine_server/api/run_query.yaml diff --git a/api/src/relation_engine_api/api/save_documents.yaml b/api/src/relation_engine_server/api/save_documents.yaml similarity index 100% rename from api/src/relation_engine_api/api/save_documents.yaml rename to api/src/relation_engine_server/api/save_documents.yaml diff --git a/api/src/relation_engine_api/api/show_schemas.yaml b/api/src/relation_engine_server/api/show_schemas.yaml similarity index 100% rename from api/src/relation_engine_api/api/show_schemas.yaml rename to api/src/relation_engine_server/api/show_schemas.yaml diff --git a/api/src/relation_engine_api/api/show_views.yaml b/api/src/relation_engine_server/api/show_views.yaml similarity index 100% rename from api/src/relation_engine_api/api/show_views.yaml rename to api/src/relation_engine_server/api/show_views.yaml diff --git a/api/src/relation_engine_api/arango_utils/arango_requests.py b/api/src/relation_engine_server/arango_utils/arango_requests.py similarity index 100% rename from api/src/relation_engine_api/arango_utils/arango_requests.py rename to api/src/relation_engine_server/arango_utils/arango_requests.py diff --git a/api/start_server.sh b/api/start_server.sh index 880398d1..d5a6470b 100644 --- a/api/start_server.sh +++ b/api/start_server.sh @@ -5,4 +5,4 @@ calc_workers="$(($(nproc) * 2 + 1))" workers=${WORKERS:-$calc_workers} -gunicorn --worker-class gevent --timeout 1800 --workers $workers -b :5000 --reload src.relation_engine_api.__main__:app +gunicorn --worker-class gevent --timeout 1800 --workers $workers -b :5000 --reload src.relation_engine_server.__main__:app From 6c06c5dfc68554a783becc709d5315a2becaf09b Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 30 Oct 2018 16:47:39 -0700 Subject: [PATCH 027/732] Lots of iteration on the functionality and specs --- api/.env.example | 3 +- api/requirements.txt | 3 +- api/src/relation_engine_server/__main__.py | 60 ----------- api/src/relation_engine_server/api.py | 88 +++++++++++++++ .../relation_engine_server/api/__init__.py | 0 api/src/relation_engine_server/api/api_v1.py | 92 ---------------- .../api/delete_documents.yaml | 20 ---- .../relation_engine_server/api/run_query.yaml | 20 ---- .../api/save_documents.yaml | 38 ------- .../api/show_schemas.yaml | 12 --- .../api/show_views.yaml | 11 -- api/src/relation_engine_server/app.py | 77 +++++++++++++ .../arango_utils/arango_requests.py | 16 +-- api/src/relation_engine_server/auth.py | 43 ++++++++ api/src/relation_engine_server/docs.py | 100 +++++++++++++++++ api/src/relation_engine_server/exceptions.py | 18 ++++ api/src/relation_engine_server/schemas.py | 102 ++++++++++++++++++ .../relation_engine_server/server_spec.json | 81 ++++++++++++++ api/src/test/test_api.py | 66 ++++++++++++ api/src/test/test_api_v1.py | 20 ---- api/start_server.sh | 2 +- 21 files changed, 587 insertions(+), 285 deletions(-) delete mode 100644 api/src/relation_engine_server/__main__.py create mode 100644 api/src/relation_engine_server/api.py delete mode 100644 api/src/relation_engine_server/api/__init__.py delete mode 100644 api/src/relation_engine_server/api/api_v1.py delete mode 100644 api/src/relation_engine_server/api/delete_documents.yaml delete mode 100644 api/src/relation_engine_server/api/run_query.yaml delete mode 100644 api/src/relation_engine_server/api/save_documents.yaml delete mode 100644 api/src/relation_engine_server/api/show_schemas.yaml delete mode 100644 api/src/relation_engine_server/api/show_views.yaml create mode 100644 api/src/relation_engine_server/app.py create mode 100644 api/src/relation_engine_server/auth.py create mode 100644 api/src/relation_engine_server/docs.py create mode 100644 api/src/relation_engine_server/exceptions.py create mode 100644 api/src/relation_engine_server/schemas.py create mode 100644 api/src/relation_engine_server/server_spec.json create mode 100644 api/src/test/test_api.py delete mode 100644 api/src/test/test_api_v1.py diff --git a/api/.env.example b/api/.env.example index 776c28e1..503acfb2 100644 --- a/api/.env.example +++ b/api/.env.example @@ -1,7 +1,8 @@ DB_URL=http://graph1:8529 DB_USER=root DB_PASS=password -KBASE_ENDPOINT="https://ci.kbase.us/services/" +KBASE_ENDPOINT=https://ci.kbase.us/services +KBASE_TEST_AUTH_TOKEN=xyz # You can also set: # WORKERS - set number of gevent workers (otherwise automatically calculated) diff --git a/api/requirements.txt b/api/requirements.txt index 79539d76..68bb9ed4 100644 --- a/api/requirements.txt +++ b/api/requirements.txt @@ -4,6 +4,5 @@ gevent==1.3.6 simplejson==3.16.0 python-dotenv==0.9.1 requests==2.19.1 -flasgger==0.9.1 relation_engine_spec==0.1 -connexion==1.5.3 +jsonschema==2.6.0 diff --git a/api/src/relation_engine_server/__main__.py b/api/src/relation_engine_server/__main__.py deleted file mode 100644 index 3a88bdab..00000000 --- a/api/src/relation_engine_server/__main__.py +++ /dev/null @@ -1,60 +0,0 @@ -"""The main entrypoint for running the Flask server.""" -import flask -import os -from uuid import uuid4 -from flasgger import Swagger - -from .api.api_v1 import api_v1 - -swagger_template = { - 'openapi': '3.0.2', - 'info': { - 'title': 'Relation Engine API', - 'description': 'API for working with the KBase Relation Engine graph database.', - 'contact': { - 'responsibleOrganization': 'DOE KBase', - 'email': 'info@kbase.us', - 'url': 'https://kbase.us' - }, - 'version': '1' - }, - 'schemes': ['https'] -} - -app = flask.Flask(__name__) -app.config['DEBUG'] = os.environ.get('FLASK_DEBUG', True) -app.config['SECRET_KEY'] = os.environ.get('FLASK_SECRET_KEY', str(uuid4())) -app.url_map.strict_slashes = False # allow both `get /v1/` and `get /v1` -app.register_blueprint(api_v1, url_prefix='/v1') -swagger = Swagger(app, template=swagger_template) - - -@app.route('/', methods=['GET']) -def root(): - """Redirects to the Swagger API docs.""" - return flask.redirect('/apidocs') - - -@app.errorhandler(404) -def page_not_found(err): - return (flask.jsonify({'error': '404 - Not found.'}), 404) - - -@app.errorhandler(405) -def method_not_allowed(err): - return (flask.jsonify({'error': '405 - Method not allowed.'}), 405) - - -# Any other unhandled exceptions -> 500 -@app.errorhandler(Exception) -@app.errorhandler(500) -def server_error(err): - print(err) - return (flask.jsonify({'error': 'Server error: %s' % str(err)}), 500) - - -@app.after_request -def log_response(response): - """Simple log of each request's response.""" - print(' '.join([flask.request.method, flask.request.path, '->', response.status])) - return response diff --git a/api/src/relation_engine_server/api.py b/api/src/relation_engine_server/api.py new file mode 100644 index 00000000..ddbab9f8 --- /dev/null +++ b/api/src/relation_engine_server/api.py @@ -0,0 +1,88 @@ +"""The primary router for the Relation Engine API.""" +import flask +import relation_engine_spec.views +import relation_engine_spec.schemas + +from src.relation_engine_server.arango_utils.arango_requests import ( + bulk_import, + ArangoServerError +) + +from .auth import require_auth_token + +api = flask.Blueprint('api', __name__) + + +@api.route('/views', methods=['GET']) +def show_views(): + """ + Fetch view names and content. + See ./show_views.yaml for documentation. + Auth: public + """ + view_names = relation_engine_spec.views.get_view_names() + resp = {'names': view_names} + if flask.request.args.get('show_source'): + resp['content'] = {} + for name in view_names: + resp['content'][name] = relation_engine_spec.views.get_view_content(name) + return flask.jsonify(resp) + + +@api.route('/views//query', methods=['POST']) +def run_query(view_name): + """ + Run a stored view as a query against the database. + See ./run_query.yaml for documentation. + Auth: only kbase users (any role) + """ + require_auth_token([]) + # view_source = relation_engine_spec.views.get_view_content(view_name) + # bind_vars = flask.request.json + # Make a request to the Arango server to run the query + # req_json = {'query': view_source, 'batchSize': 100, 'count': True, 'bindVars': bind_vars} + # resp_data = run_query('/_api/cursor', data=req_json) + return flask.jsonify({}) # resp_data) + + +@api.route('/schemas', methods=['GET']) +def show_schemas(): + """ + Fetch schema names and content. + See ./show_schemas.yaml for documentation. + Auth: public + """ + schema_names = relation_engine_spec.schemas.get_schema_names() + resp = {'names': schema_names} + if flask.request.args.get('show_source'): + resp['content'] = {} + for name in schema_names: + resp['content'][name] = relation_engine_spec.schemas.get_schema_as_dict(name) + return flask.jsonify(resp) + + +@api.route('/documents', methods=['PUT']) +def save_documents(): + """ + Create, update, or replace many documents in a batch. + See ./save_documents.yaml for documentation. + Auth: only sysadmins + """ + require_auth_token(['RE_ADMIN']) + query = { + 'collection': flask.request.args['collection'], + 'type': 'documents' + } + if flask.request.args.get('on_duplicate'): + query['onDuplicate'] = flask.request.args['on_duplicate'] + if flask.request.args.get('overwrite'): + query['overwrite'] = 'true' + resp_text = bulk_import(flask.request.get_data(), query) + return resp_text + + +@api.errorhandler(ArangoServerError) +@api.errorhandler(relation_engine_spec.views.ViewNonexistent) +def view_does_not_exist(err): + """General error cases.""" + return (flask.jsonify({'error': str(err)}), 400) diff --git a/api/src/relation_engine_server/api/__init__.py b/api/src/relation_engine_server/api/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/api/src/relation_engine_server/api/api_v1.py b/api/src/relation_engine_server/api/api_v1.py deleted file mode 100644 index f6c03482..00000000 --- a/api/src/relation_engine_server/api/api_v1.py +++ /dev/null @@ -1,92 +0,0 @@ -"""The primary router for the Relation Engine API v1.""" -import time -import flask -from flasgger import swag_from -import relation_engine_spec.views -import relation_engine_spec.schemas - -from src.relation_engine_server.arango_utils.arango_requests import ( - arango_post_request, - arango_server_status, - ArangoServerError -) - -api_v1 = flask.Blueprint('api_v1', __name__) - - -@api_v1.route('/', methods=['GET']) -def root(): - """ - Server status. - --- - tags: ["root"] - parameters: [] - responses: - 200: {description: "Server status."} - """ - with open('.git/refs/heads/master', 'r') as fd: - commit_hash = fd.read().strip() - return flask.jsonify({ - 'server_time': int(time.time() * 1000), - 'current_commit_hash': commit_hash, - 'arangodb_status': arango_server_status() - }) - - -@swag_from('show_views.yaml', validation=True) -@api_v1.route('/views', methods=['GET']) -def show_views(): - """See ./show_views.yaml for documentation.""" - view_names = relation_engine_spec.views.get_view_names() - resp = {'names': view_names} - if flask.request.args.get('show_source'): - resp['content'] = {} - for name in view_names: - resp['content'][name] = relation_engine_spec.views.get_view_content(name) - return flask.jsonify(resp) - - -@swag_from('run_query.yaml', validation=True) -@api_v1.route('/views//query', methods=['POST']) -def run_query(view_name): - """See ./run_query.yaml for documentation.""" - view_source = relation_engine_spec.views.get_view_content(view_name) - bind_vars = flask.request.json - # Make a request to the Arango server to run the query - req_json = {'query': view_source, 'batchSize': 100, 'count': True, 'bindVars': bind_vars} - resp_data = arango_post_request('/_api/cursor', data=req_json) - return flask.jsonify(resp_data) - - -@swag_from('show_schemas.yaml', validation=True) -@api_v1.route('/schemas', methods=['GET']) -def show_schemas(): - """See ./show_schemas.yaml for documentation.""" - schema_names = relation_engine_spec.schemas.get_schema_names() - resp = {'names': schema_names} - if flask.request.args.get('show_source'): - resp['content'] = {} - for name in schema_names: - resp['content'][name] = relation_engine_spec.schemas.get_schema_content(name) - return flask.jsonify({}) - - -@swag_from('save_documents.yaml', validation=True) -@api_v1.route('/documents', methods=['PUT']) -def save_documents(): - """See ./save_documents.yaml for documentation.""" - data_stream = flask.request.stream - q = { - 'collection': flask.request.args['collection'], - 'onDuplicate': flask.request.args['onDuplicate'], - 'type': 'documents' - } - arango_post_request('/_api/import', data_stream, query=q) - return flask.jsonify({}) - - -@api_v1.errorhandler(ArangoServerError) -@api_v1.errorhandler(relation_engine_spec.views.ViewNonexistent) -def view_does_not_exist(err): - """General error cases.""" - return (flask.jsonify({'error': str(err)}), 400) diff --git a/api/src/relation_engine_server/api/delete_documents.yaml b/api/src/relation_engine_server/api/delete_documents.yaml deleted file mode 100644 index fa3fe7c4..00000000 --- a/api/src/relation_engine_server/api/delete_documents.yaml +++ /dev/null @@ -1,20 +0,0 @@ -Remove one or more documents from the database. ---- -tags: ["documents"] -parameters: -- name: ids - in: body - required: true - description: "An array of document IDs to delete." - schema: - type: array - items: - type: string - example: "docid" -responses: - 200: - description: Success status - content: - application/json: - schema: - type: string diff --git a/api/src/relation_engine_server/api/run_query.yaml b/api/src/relation_engine_server/api/run_query.yaml deleted file mode 100644 index e2b41514..00000000 --- a/api/src/relation_engine_server/api/run_query.yaml +++ /dev/null @@ -1,20 +0,0 @@ -Execute a view as a query against the database. ---- -tags: ["views"] -parameters: -- name: view_name - in: path - required: true - description: Name of the view for running the query. - schema: {type: string} -requestBody: - description: Arguments for the query. - content: - application/json: - required: true - schema: - type: object - required: true -responses: - 200: - description: Result data. diff --git a/api/src/relation_engine_server/api/save_documents.yaml b/api/src/relation_engine_server/api/save_documents.yaml deleted file mode 100644 index 41cc5c3e..00000000 --- a/api/src/relation_engine_server/api/save_documents.yaml +++ /dev/null @@ -1,38 +0,0 @@ -Create, update, or replace documents in the database. - -Pass in an array of objects that describe documents to be created, updated, and/or replaced in the database. - -"onDuplicate" controls what happens when we encounter documents with the same "_key" attribute. Valid options are "error", "update", "replace", or "ignore". The default is "error". - -If any update fails, then no changes are made to the database. ---- -tags: ["documents"] -parameters: -- name: body - in: body - required: true - schema: - type: object - required: ["collection", "docs"] - properties: - onDuplicate: - type: string - default: "error" - enum: ["error", "update", "replace", "ignore"] - collection: - type: string - examples: ["collection_name"] - docs: - type: array - items: - type: object - required: ["_key"] - example: { - "_key": "DAES_RS11325", - "location_start": 1111, - "location_end": 9999 - } - properties: - _key: {type: string} -responses: - 200: {description: "Success status."} diff --git a/api/src/relation_engine_server/api/show_schemas.yaml b/api/src/relation_engine_server/api/show_schemas.yaml deleted file mode 100644 index b4653d57..00000000 --- a/api/src/relation_engine_server/api/show_schemas.yaml +++ /dev/null @@ -1,12 +0,0 @@ -Fetch a list of saved schemas with optional filters. ---- -tags: ["schemas"] -parameters: -- name: show_source - in: query - required: false - description: Whether to show the JSON of each schema. - schema: {type: boolean} -responses: - 200: - description: "View data." diff --git a/api/src/relation_engine_server/api/show_views.yaml b/api/src/relation_engine_server/api/show_views.yaml deleted file mode 100644 index 11c5d18f..00000000 --- a/api/src/relation_engine_server/api/show_views.yaml +++ /dev/null @@ -1,11 +0,0 @@ -List out all the available views, optionally showing the parameters and AQL source query. ---- -tags: ["views"] -parameters: -- name: show_source - in: query - description: Whether to show the AQL source code for each view. - schema: {type: boolean} -responses: - 200: - description: "Array of views." diff --git a/api/src/relation_engine_server/app.py b/api/src/relation_engine_server/app.py new file mode 100644 index 00000000..f817b633 --- /dev/null +++ b/api/src/relation_engine_server/app.py @@ -0,0 +1,77 @@ +"""The main entrypoint for running the Flask server.""" +import flask +import os +from uuid import uuid4 +import traceback + +from .arango_utils.arango_requests import arango_server_status + +from .api import api +from .docs import docs +from .exceptions import MissingHeader, UnauthorizedAccess + +app = flask.Flask(__name__) +app.config['DEBUG'] = os.environ.get('FLASK_DEBUG', True) +app.config['SECRET_KEY'] = os.environ.get('FLASK_SECRET_KEY', str(uuid4())) +app.url_map.strict_slashes = False # allow both `get /v1/` and `get /v1` + +app.register_blueprint(api, url_prefix='/api') +app.register_blueprint(docs, url_prefix='/docs') + + +@app.route('/', methods=['GET']) +def root(): + """Server status and link to docs.""" + with open('.git/refs/heads/master', 'r') as fd: + commit_hash = fd.read().strip() + arangodb_status = arango_server_status() + repo_url = 'https://github.com/kbase/relation_engine_api.git' + return flask.jsonify({ + 'arangodb_status': arangodb_status, + 'commit_hash': commit_hash, + 'repo_url': repo_url, + 'docs': '/docs' + }) + + +@app.errorhandler(UnauthorizedAccess) +def unauthorized_access(err): + resp = { + 'error': '403 - Unauthorized', + 'auth_url': err.auth_url + } + return (flask.jsonify(resp), 403) + + +@app.errorhandler(404) +def page_not_found(err): + return (flask.jsonify({'error': '404 - Not found.'}), 404) + + +@app.errorhandler(405) +def method_not_allowed(err): + return (flask.jsonify({'error': '405 - Method not allowed.'}), 405) + + +@app.errorhandler(MissingHeader) +def generic_400(err): + return (flask.jsonify({'error': str(err)}), 400) + + +# Any other unhandled exceptions -> 500 +@app.errorhandler(Exception) +@app.errorhandler(500) +def server_error(err): + print('=' * 80) + print('500 Unexpected Server Error') + print('-' * 80) + traceback.print_exc() + print('=' * 80) + return (flask.jsonify({'error': 'Unexpected server error'}), 500) + + +@app.after_request +def log_response(response): + """Simple log of each request's response.""" + print(' '.join([flask.request.method, flask.request.path, '->', response.status])) + return response diff --git a/api/src/relation_engine_server/arango_utils/arango_requests.py b/api/src/relation_engine_server/arango_utils/arango_requests.py index 5660ed1f..2d2c2a20 100644 --- a/api/src/relation_engine_server/arango_utils/arango_requests.py +++ b/api/src/relation_engine_server/arango_utils/arango_requests.py @@ -14,24 +14,24 @@ def arango_server_status(): try: resp = requests.get(db_url + '/_api/endpoint', auth=(db_user, db_pass)) except requests.exceptions.ConnectionError: - return 'Failed to establish a connection to %s.' % db_url - if resp.status_code == 200: - return 'Connected and authorized.' + return 'no_connection' + if resp.ok: + return 'connected_authorized' elif resp.status_code == 401: - return 'Unauthorized; username or password is invalid.' + return 'unauthorized' else: - return 'Failed to connect: %s' % resp.text + return 'unknown_failure' -def arango_post_request(path, data, query={}, method='post'): +def bulk_import(data, query): """Make a generic arango post request.""" resp = requests.post( - db_url + path, + db_url + '/_api/import', data=data, auth=(db_user, db_pass), params=query ) - if resp.status_code != 200: + if not resp.ok: raise ArangoServerError(resp.text) return resp.text diff --git a/api/src/relation_engine_server/auth.py b/api/src/relation_engine_server/auth.py new file mode 100644 index 00000000..00680a6c --- /dev/null +++ b/api/src/relation_engine_server/auth.py @@ -0,0 +1,43 @@ +""" +Authorization and authentication utilities. +""" +import os +import flask +import requests + +from .exceptions import MissingHeader, UnauthorizedAccess + + +def require_auth_token(roles=[]): + """ + Function that validates an authentication token in a flask request context. + + If any roles are provided, the token holder must have *at least one* of the roles. + + Raises some exception if any auth requirement is not met. + """ + kbase_endpoint = os.environ.get('KBASE_ENDPOINT', 'https://ci.kbase.us/services') + kbase_auth_url = kbase_endpoint + '/auth' + if not flask.request.headers.get('Authorization'): + # No authorization token was provided in the headers + raise MissingHeader('Authorization') + token = flask.request.headers.get('Authorization').replace('Bearer', '').strip() + # Make an authorization request to the kbase auth2 server + headers = {'Authorization': token} + url = kbase_auth_url + '/api/V2/me' + print(url) + auth_resp = requests.get(url, headers=headers) + if not auth_resp.ok: + print('-' * 80) + print(auth_resp.text) + raise UnauthorizedAccess(kbase_auth_url) + auth_json = auth_resp.json() + if len(roles): + check_roles(required=roles, given=auth_json['customroles'], auth_url=kbase_auth_url) + + +def check_roles(required, given, auth_url): + for role in required: + if role in given: + return + raise UnauthorizedAccess(auth_url) diff --git a/api/src/relation_engine_server/docs.py b/api/src/relation_engine_server/docs.py new file mode 100644 index 00000000..0139d46f --- /dev/null +++ b/api/src/relation_engine_server/docs.py @@ -0,0 +1,100 @@ +"""Fetch documentation for the API.""" +import flask + +from . import schemas + +docs = flask.Blueprint('docs', __name__) + + +@docs.route('/', methods=['GET']) +def root(): + """API documentation.""" + return flask.jsonify({ + 'info': { + 'name': 'Relation Engine API', + 'description': 'Interface for updating or querying data in the KBase Relation Engine graph database.' + }, + 'api_prefix': '/api', + 'actions': { + '/views GET': { + 'description': 'Fetch view names and (optionally) their AQL source code.', + 'auth': 'public', + 'query': { + 'show_sources': { + 'type': 'boolean', + 'default': False, + 'description': 'Whether to show the AQL source code for each view.' + } + }, + 'responses': { + '200': { + 'schema': ['view'], + 'description': 'A list of views with names and (optionally) AQL source.' + }, + 'not_ok': {'schema': 'error'} + } + }, + '/query POST': { + 'description': 'Execute a view as a query against the database.', + 'auth': 'bearer', + 'query': { + 'view_name': { + 'description': 'Name of the view that we want to use for the query.', + 'type': 'string' + } + }, + 'body': { + 'description': 'Arguments for the query. These go into the bind variables in the AQL.', + 'type': 'object' + }, + 'responses': { + '200': { + 'schema': 'query_results', + 'description': 'Resulting data from running the query' + }, + 'not_ok': {'schema': 'error'} + } + }, + '/schemas GET': { + 'description': 'Fetch available schema names and optionally their JSON sources.', + 'auth': 'public', + 'query': { + 'show_sources': { + 'type': 'boolean', + 'description': 'Whether to show the JSON source for each schema.' + } + }, + 'responses': { + '200': { + 'schema': { + 'type': 'array', + 'item': {'schema': 'view'} + }, + 'description': 'Array of schema name and (optionally) schema content.' + }, + 'not_ok': {'schema': 'error'} + } + }, + '/documents PUT': { + 'description': 'Create, update, or replace documents in the database in a certain collection.', + 'auth': 'bearer', + 'query': { + 'on_duplicate': { + 'description': 'How to handle duplicate documents based on a "_key" match.', + 'type': 'string', + 'enum': ['error', 'update', 'replace', 'ignore'] + } + }, + 'responses': { + '200': {'description': 'Successful save.'}, + 'not_ok': {'schema': 'error'} + } + } + }, + 'schemas': { + 'error': schemas.error, + 'view': schemas.view, + 'query_results': schemas.query_results, + 'document_save_results': schemas.document_save_results + } + }) diff --git a/api/src/relation_engine_server/exceptions.py b/api/src/relation_engine_server/exceptions.py new file mode 100644 index 00000000..c6376e58 --- /dev/null +++ b/api/src/relation_engine_server/exceptions.py @@ -0,0 +1,18 @@ +""" +Collection of exception classes for the Relation Engine server. +""" + + +class MissingHeader(Exception): + + def __init__(self, header_name): + self.header_name = header_name + + def __str__(self): + return "Missing header: " + self.header_name + + +class UnauthorizedAccess(Exception): + + def __init__(self, auth_url): + self.auth_url = auth_url diff --git a/api/src/relation_engine_server/schemas.py b/api/src/relation_engine_server/schemas.py new file mode 100644 index 00000000..fdb188fe --- /dev/null +++ b/api/src/relation_engine_server/schemas.py @@ -0,0 +1,102 @@ +"""Fetch schemas for the API.""" + +# An AQL stored query +view = { + 'type': 'object', + 'required': ['name'], + 'description': 'Stored query for use in fetching graph data.', + 'properties': { + 'name': { + 'type': 'string', + 'description': 'Unique name of the view' + }, + 'source': { + 'type': 'string', + 'description': 'AQL source code for this schema (if requested).' + } + } +} + +# An error response (any non-2xx) +error = { + 'type': 'object', + 'required': ['error', 'request_id', 'error_code'], + 'properties': { + 'error': { + 'type': 'string', + 'description': 'Error message.' + }, + 'error_code': { + 'type': 'string', + 'description': 'Code representing the error type.' + }, + 'request_id': { + 'type': 'string', + 'description': 'Unique ID of the request, used in fetching error logs.' + } + } +} + +# Results from running a query +query_results = { + 'description': 'Resulting status and data from running a query.', + 'type': 'object', + 'required': ['has_more', 'data', 'count', 'cursor_id'], + 'properties': { + 'has_more': { + 'type': 'boolean', + 'description': 'Whether there are more results in the query. If so, use the cursor ID to fetch them.' + }, + 'data': { + 'type': 'array', + 'description': 'Array of result data, up to a maximum of 100 results.', + 'item': {'type': 'object'} + }, + 'count': { + 'type': 'integer', + 'description': 'Total count of resulting documents.' + }, + 'cursor_id': { + 'type': 'string', + 'description': ('If has_more is true, then this is set to an ID that you can use' + ' to fetch additional results.') + } + } +} + +# Results from bulk-saving documents +document_save_results = { + 'description': 'Result info after bulk-saving documents in the database.', + 'type': 'object', + 'properties': { + 'created': { + 'type': 'integer', + 'description': 'Number of documents created.' + }, + 'updated': { + 'type': 'integer', + 'description': 'Number of documents updated.' + }, + 'replaced': { + 'type': 'integer', + 'description': 'Number of documents replaced.' + } + } +} + +# Schema inception ^_^ +schema = { + 'description': 'A stored schema that describes the validation for a collection in the database.', + 'type': 'object', + 'required': ['name'], + 'properties': { + 'name': { + 'type': 'string', + 'description': 'Unique name of the schema (maps to a name of a collection, such as "genes").' + }, + 'source': { + 'type': 'object', + 'description': 'JSON schema object used for validating a collection of documents in the database.' + } + } +} diff --git a/api/src/relation_engine_server/server_spec.json b/api/src/relation_engine_server/server_spec.json new file mode 100644 index 00000000..06847b78 --- /dev/null +++ b/api/src/relation_engine_server/server_spec.json @@ -0,0 +1,81 @@ +{ + "info": { + "name": "Relation Engine API", + "repository": "https://github.com/kbase/relation_engine_api", + "description": "Interface for updating or querying data in the KBase Relation Engine graph database." + }, + "api_prefix": "/api", + "actions": { + "/views GET": { + "description": "Fetch view names and (optionally) their AQL source code.", + "auth": "public", + "query": { + "show_sources": { + "type": "boolean", + "default": false, + "description": "Whether to show the AQL source code for each view." + } + }, + "responses": { + "200": { + "schema": ["/schemas/view"], + "description": "A list of views with names and (optionally) AQL source." + }, + "not_ok": {"schema": "/schemas/error"} + } + }, + "/query POST": { + "description": "Execute a view as a query against the database.", + "auth": "bearer", + "query": { + "view_name": { + "description": "Name of the view that we want to use for the query.", + "type": "string" + } + }, + "body": { + "description": "Arguments for the query. These go into the bind variables in the AQL.", + "type": "object" + }, + "responses": { + "200": { + "schema": "/schemas/query_results", + "description": "Resulting data from running the query" + }, + "not_ok": {"schema": "/schemas/error"} + } + }, + "/schemas GET": { + "description": "Fetch available schema names and optionally their JSON sources.", + "auth": "public", + "query": { + "show_sources": { + "type": "boolean", + "description": "Whether to show the JSON source for each schema." + } + }, + "responses": { + "200": { + "schema": ["schemas"], + "description": "Array of schema name and (optionally) schema content." + }, + "not_ok": {"schema": "error"} + } + }, + "/documents PUT": { + "description": "Create, update, or replace documents in the database in a certain collection.", + "auth": "bearer", + "query": { + "on_duplicate": { + "description": "How to handle duplicate documents based on a '_key' match.", + "type": "string", + "enum": ["error", "update", "replace", "ignore"] + } + }, + "responses": { + "200": {"description": "Successful save."}, + "not_ok": {"schema": "error"} + } + } + }, +} diff --git a/api/src/test/test_api.py b/api/src/test/test_api.py new file mode 100644 index 00000000..5a6e645a --- /dev/null +++ b/api/src/test/test_api.py @@ -0,0 +1,66 @@ +""" +Simple integration tests on the API itself. + +We make actual ajax requests to the running docker container. +""" +import unittest +import requests +import os + +url = 'http://web:5000' +auth_token = os.environ.get('KBASE_TEST_AUTH_TOKEN', '') + + +class TestApi(unittest.TestCase): + + def test_root(self): + """Test root path for api.""" + resp = requests.get(url).json() + self.assertEqual(resp['arangodb_status'], 'Connected and authorized.') + self.assertEqual(resp['docs'], '/docs') + self.assertTrue(resp['commit_hash']) + self.assertTrue(resp['repo_url']) + + def test_list_views(self): + resp = requests.get(url + '/api/views?show_source=1').json() + self.assertTrue(len(resp['names']) > 0) + for name in resp['names']: + self.assertTrue(resp['content'][name]) + resp = requests.get(url + '/api/views').json() + self.assertTrue(len(resp['names']) > 0) + self.assertFalse(resp.get('content')) + + def test_list_schemas(self): + resp = requests.get(url + '/api/schemas?show_source=1').json() + self.assertTrue(len(resp['names']) > 0) + for name in resp['names']: + self.assertTrue(resp['content'][name]) + resp = requests.get(url + '/api/views').json() + self.assertTrue(len(resp['names']) > 0) + self.assertFalse(resp.get('content')) + + def test_save_documents_no_auth(self): + resp = requests.put(url + '/api/documents?on_duplicate=error&overwrite=true&collection').json() + self.assertTrue('Missing header' in resp['error']) + resp = requests.put( + url + '/api/documents?on_duplicate=error&overwrite=true&collection', + headers={'Authorization': 'Bearer xyz'} + ).json() + self.assertTrue('Unauthorized' in resp['error']) + + def test_save_documents_with_create(self): + resp = requests.put( + url + '/api/documents', + params={ + 'overwrite': True, + 'collection': 'genes' + }, + data='\n'.join([ + '{"name": "x", "_key": "1"}', + '{"name": "y", "_key": "2"}', + '{"name": "z", "_key": "3"}' + ]), + headers={'Authorization': 'Bearer ' + auth_token} + ).json() + expected = {'created': 3, 'errors': 0, 'empty': 0, 'updated': 0, 'ignored': 0, 'error': False} + self.assertEqual(resp, expected) diff --git a/api/src/test/test_api_v1.py b/api/src/test/test_api_v1.py deleted file mode 100644 index 3ee0d125..00000000 --- a/api/src/test/test_api_v1.py +++ /dev/null @@ -1,20 +0,0 @@ -""" -Simple integration tests on the API itself. - -We make actual ajax requests to the running docker container. -""" -import unittest -import requests - -url = 'http://web:5000/v1' - - -class TestApiV1(unittest.TestCase): - - def test_root(self): - """Test root path for api.""" - resp = requests.get(url) - json = resp.json() - self.assertEqual(json['arangodb_status'], 'Connected and authorized.') - self.assertTrue(json['server_time']) - self.assertTrue(json['current_commit_hash']) diff --git a/api/start_server.sh b/api/start_server.sh index d5a6470b..45986d37 100644 --- a/api/start_server.sh +++ b/api/start_server.sh @@ -5,4 +5,4 @@ calc_workers="$(($(nproc) * 2 + 1))" workers=${WORKERS:-$calc_workers} -gunicorn --worker-class gevent --timeout 1800 --workers $workers -b :5000 --reload src.relation_engine_server.__main__:app +gunicorn --worker-class gevent --timeout 1800 --workers $workers -b :5000 --reload src.relation_engine_server.app:app From 5be580de4bbe4c78c4c34cc482e911e58afba5e2 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 30 Oct 2018 18:02:51 -0700 Subject: [PATCH 028/732] Get more features working around bulk imports and validation --- api/src/relation_engine_server/api.py | 21 ++++++++---- api/src/relation_engine_server/app.py | 2 +- .../arango_utils/arango_requests.py | 23 +++++++++++-- api/src/test/test_api.py | 32 +++++++++++++++++-- 4 files changed, 66 insertions(+), 12 deletions(-) diff --git a/api/src/relation_engine_server/api.py b/api/src/relation_engine_server/api.py index ddbab9f8..4a368a40 100644 --- a/api/src/relation_engine_server/api.py +++ b/api/src/relation_engine_server/api.py @@ -1,5 +1,9 @@ """The primary router for the Relation Engine API.""" import flask +import json +import tempfile +import jsonschema + import relation_engine_spec.views import relation_engine_spec.schemas @@ -37,12 +41,11 @@ def run_query(view_name): Auth: only kbase users (any role) """ require_auth_token([]) - # view_source = relation_engine_spec.views.get_view_content(view_name) - # bind_vars = flask.request.json + view_source = relation_engine_spec.views.get_view_content(view_name) + bind_vars = flask.request.json # Make a request to the Arango server to run the query - # req_json = {'query': view_source, 'batchSize': 100, 'count': True, 'bindVars': bind_vars} - # resp_data = run_query('/_api/cursor', data=req_json) - return flask.jsonify({}) # resp_data) + resp = run_query(view_source, bind_vars) + return flask.jsonify(resp) @api.route('/schemas', methods=['GET']) @@ -73,11 +76,17 @@ def save_documents(): 'collection': flask.request.args['collection'], 'type': 'documents' } + schema = relation_engine_spec.schemas.get_schema_as_dict(query['collection']) if flask.request.args.get('on_duplicate'): query['onDuplicate'] = flask.request.args['on_duplicate'] if flask.request.args.get('overwrite'): query['overwrite'] = 'true' - resp_text = bulk_import(flask.request.get_data(), query) + with tempfile.TemporaryFile(mode='w', encoding='utf-8') as temp_fd: + for line in flask.request.stream: + json_line = json.loads(line) + jsonschema.validate(json_line, schema) + json.dump(json_line, temp_fd) + resp_text = bulk_import(temp_fd, query) return resp_text diff --git a/api/src/relation_engine_server/app.py b/api/src/relation_engine_server/app.py index f817b633..ea7d675f 100644 --- a/api/src/relation_engine_server/app.py +++ b/api/src/relation_engine_server/app.py @@ -67,7 +67,7 @@ def server_error(err): print('-' * 80) traceback.print_exc() print('=' * 80) - return (flask.jsonify({'error': 'Unexpected server error'}), 500) + return (flask.jsonify({'error': 'Unexpected server error', 'message': str(err)}), 500) @app.after_request diff --git a/api/src/relation_engine_server/arango_utils/arango_requests.py b/api/src/relation_engine_server/arango_utils/arango_requests.py index 2d2c2a20..c3dba1b7 100644 --- a/api/src/relation_engine_server/arango_utils/arango_requests.py +++ b/api/src/relation_engine_server/arango_utils/arango_requests.py @@ -2,6 +2,7 @@ Make ajax requests to the ArangoDB server. """ import requests +import json import os db_url = os.environ.get('DB_URL', 'http://localhost:8529') @@ -23,11 +24,29 @@ def arango_server_status(): return 'unknown_failure' -def bulk_import(data, query): +def run_query(query_text, bind_vars): + req_json = { + 'query': query_text, + 'batchSize': 100, + 'memoryLimit': 16000000000, # 16gb + 'count': True, + 'bindVars': bind_vars + } + resp = requests.post( + db_url + '/_api/cursor', + data=json.dumps(req_json), + auth=(db_user, db_pass) + ) + if not resp.ok: + raise ArangoServerError(resp.text) + return resp.text + + +def bulk_import(file_desc, query): """Make a generic arango post request.""" resp = requests.post( db_url + '/_api/import', - data=data, + data=file_desc, auth=(db_user, db_pass), params=query ) diff --git a/api/src/test/test_api.py b/api/src/test/test_api.py index 5a6e645a..db51e25a 100644 --- a/api/src/test/test_api.py +++ b/api/src/test/test_api.py @@ -16,7 +16,7 @@ class TestApi(unittest.TestCase): def test_root(self): """Test root path for api.""" resp = requests.get(url).json() - self.assertEqual(resp['arangodb_status'], 'Connected and authorized.') + self.assertEqual(resp['arangodb_status'], 'connected_authorized') self.assertEqual(resp['docs'], '/docs') self.assertTrue(resp['commit_hash']) self.assertTrue(resp['repo_url']) @@ -40,20 +40,32 @@ def test_list_schemas(self): self.assertFalse(resp.get('content')) def test_save_documents_no_auth(self): + # Missing bearer resp = requests.put(url + '/api/documents?on_duplicate=error&overwrite=true&collection').json() self.assertTrue('Missing header' in resp['error']) + # Invalid bearer resp = requests.put( url + '/api/documents?on_duplicate=error&overwrite=true&collection', headers={'Authorization': 'Bearer xyz'} ).json() self.assertTrue('Unauthorized' in resp['error']) - def test_save_documents_with_create(self): + def test_save_documents_no_keys(self): + resp = requests.put( + url + '/api/documents', + params={'on_duplicate': 'ignore', 'collection': 'taxon'}, + data='{"name": "x"}\n{"name": "y"}', + headers={'Authorization': 'Bearer ' + auth_token} + ) + print('resp!', resp.text) + + def test_save_documents(self): + # Create resp = requests.put( url + '/api/documents', params={ 'overwrite': True, - 'collection': 'genes' + 'collection': 'taxon' }, data='\n'.join([ '{"name": "x", "_key": "1"}', @@ -64,3 +76,17 @@ def test_save_documents_with_create(self): ).json() expected = {'created': 3, 'errors': 0, 'empty': 0, 'updated': 0, 'ignored': 0, 'error': False} self.assertEqual(resp, expected) + # TODO Update + # TODO Replace + # TODO error on duplicate + # TODO ignore duplicates + # TODO empty lines + # TODO invalid collection + # TODO invalid schema + + def test_query(self): + pass + # TODO valid query + # TODO missing query name + # TODO missing bind variables + # TODO bind variable is invalid From 5e6ebe74f059e0c18471c352a7f462957201afce Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 31 Oct 2018 11:33:28 -0700 Subject: [PATCH 029/732] Add an error case and tests for invalid schemas --- api/src/relation_engine_server/api.py | 14 ++++++++++++++ api/src/relation_engine_server/app.py | 6 +++++- api/src/test/test_api.py | 8 ++++++-- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/api/src/relation_engine_server/api.py b/api/src/relation_engine_server/api.py index 4a368a40..0a57c6e1 100644 --- a/api/src/relation_engine_server/api.py +++ b/api/src/relation_engine_server/api.py @@ -3,6 +3,7 @@ import json import tempfile import jsonschema +from jsonschema.exceptions import ValidationError import relation_engine_spec.views import relation_engine_spec.schemas @@ -95,3 +96,16 @@ def save_documents(): def view_does_not_exist(err): """General error cases.""" return (flask.jsonify({'error': str(err)}), 400) + + +@api.errorhandler(ValidationError) +def validation_error(err): + """Json Schema validation error.""" + resp = { + 'error': str(err).split('\n')[0], + 'instance': err.instance, + 'validator': err.validator, + 'validator_value': err.validator_value, + 'schema': err.schema + } + return (flask.jsonify(resp), 400) diff --git a/api/src/relation_engine_server/app.py b/api/src/relation_engine_server/app.py index ea7d675f..184d7770 100644 --- a/api/src/relation_engine_server/app.py +++ b/api/src/relation_engine_server/app.py @@ -67,7 +67,11 @@ def server_error(err): print('-' * 80) traceback.print_exc() print('=' * 80) - return (flask.jsonify({'error': 'Unexpected server error', 'message': str(err)}), 500) + resp = {'error': '500 - Unexpected server error'} + if os.environ.get('FLASK_DEBUG'): + resp['error_class'] = err.__class__.__name__ + resp['error_details'] = str(err) + return (flask.jsonify(resp), 500) @app.after_request diff --git a/api/src/test/test_api.py b/api/src/test/test_api.py index db51e25a..0e71334c 100644 --- a/api/src/test/test_api.py +++ b/api/src/test/test_api.py @@ -56,8 +56,12 @@ def test_save_documents_no_keys(self): params={'on_duplicate': 'ignore', 'collection': 'taxon'}, data='{"name": "x"}\n{"name": "y"}', headers={'Authorization': 'Bearer ' + auth_token} - ) - print('resp!', resp.text) + ).json() + self.assertEqual(resp['error'], "'_key' is a required property") + self.assertEqual(resp['instance'], {'name': 'x'}) + self.assertTrue(resp['schema']) + self.assertEqual(resp['validator'], 'required') + self.assertEqual(resp['validator_value'], ['_key', 'name']) def test_save_documents(self): # Create From 3b318c68a719d9db39e7ad810665bd3cc0ceb06d Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 31 Oct 2018 12:30:56 -0700 Subject: [PATCH 030/732] Add error case for non-existent schema with a test --- api/src/relation_engine_server/api.py | 11 +++++++++++ api/src/test/test_api.py | 12 +++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/api/src/relation_engine_server/api.py b/api/src/relation_engine_server/api.py index 0a57c6e1..a9f87dfc 100644 --- a/api/src/relation_engine_server/api.py +++ b/api/src/relation_engine_server/api.py @@ -109,3 +109,14 @@ def validation_error(err): 'schema': err.schema } return (flask.jsonify(resp), 400) + + +@api.errorhandler(relation_engine_spec.schemas.SchemaNonexistent) +def schema_nonexistent(err): + """A schema/collection was requested but does not exist.""" + resp = { + 'error': str(err) + # 'available_schemas': err.available_schemas + # 'nonexistent_schema': err.schema_name + } + return (flask.jsonify(resp), 400) diff --git a/api/src/test/test_api.py b/api/src/test/test_api.py index 0e71334c..102c36a5 100644 --- a/api/src/test/test_api.py +++ b/api/src/test/test_api.py @@ -51,6 +51,7 @@ def test_save_documents_no_auth(self): self.assertTrue('Unauthorized' in resp['error']) def test_save_documents_no_keys(self): + """Test the case where some documents fail against their schema.""" resp = requests.put( url + '/api/documents', params={'on_duplicate': 'ignore', 'collection': 'taxon'}, @@ -63,6 +64,16 @@ def test_save_documents_no_keys(self): self.assertEqual(resp['validator'], 'required') self.assertEqual(resp['validator_value'], ['_key', 'name']) + def test_save_documents_missing_schema(self): + """Test the case where the collection/schema does not exist.""" + resp = requests.put( + url + '/api/documents', + params={'collection': 'xyzabc'}, + data='', + headers={'Authorization': 'Bearer ' + auth_token} + ).json() + self.assertTrue('Schema does not exist' in resp['error']) + def test_save_documents(self): # Create resp = requests.put( @@ -86,7 +97,6 @@ def test_save_documents(self): # TODO ignore duplicates # TODO empty lines # TODO invalid collection - # TODO invalid schema def test_query(self): pass From b6920b66018052f96970717226113e908b0a3ed1 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 31 Oct 2018 13:56:00 -0700 Subject: [PATCH 031/732] Fix some issues with bulk import data streaming --- api/src/relation_engine_server/api.py | 21 ++++++++++++++++--- .../arango_utils/arango_requests.py | 15 ++++++------- api/src/test/test_api.py | 13 ++++++++++-- 3 files changed, 37 insertions(+), 12 deletions(-) diff --git a/api/src/relation_engine_server/api.py b/api/src/relation_engine_server/api.py index a9f87dfc..abb720a9 100644 --- a/api/src/relation_engine_server/api.py +++ b/api/src/relation_engine_server/api.py @@ -82,15 +82,30 @@ def save_documents(): query['onDuplicate'] = flask.request.args['on_duplicate'] if flask.request.args.get('overwrite'): query['overwrite'] = 'true' - with tempfile.TemporaryFile(mode='w', encoding='utf-8') as temp_fd: + temp_fd = tempfile.NamedTemporaryFile() + with open(temp_fd.name, 'a') as fd: for line in flask.request.stream: json_line = json.loads(line) jsonschema.validate(json_line, schema) - json.dump(json_line, temp_fd) - resp_text = bulk_import(temp_fd, query) + fd.write(json.dumps(json_line) + '\n') + resp_text = bulk_import(temp_fd.name, query) + temp_fd.close() # Also deletes the file return resp_text +@api.errorhandler(json.decoder.JSONDecodeError) +def json_decode_error(err): + """A problem parsing json.""" + resp = { + 'error': 'Unable to parse JSON', + 'source_json': err.doc, + 'pos': err.pos, + 'lineno': err.lineno, + 'colno': err.colno + } + return (flask.jsonify(resp), 400) + + @api.errorhandler(ArangoServerError) @api.errorhandler(relation_engine_spec.views.ViewNonexistent) def view_does_not_exist(err): diff --git a/api/src/relation_engine_server/arango_utils/arango_requests.py b/api/src/relation_engine_server/arango_utils/arango_requests.py index c3dba1b7..26f729de 100644 --- a/api/src/relation_engine_server/arango_utils/arango_requests.py +++ b/api/src/relation_engine_server/arango_utils/arango_requests.py @@ -42,14 +42,15 @@ def run_query(query_text, bind_vars): return resp.text -def bulk_import(file_desc, query): +def bulk_import(file_path, query): """Make a generic arango post request.""" - resp = requests.post( - db_url + '/_api/import', - data=file_desc, - auth=(db_user, db_pass), - params=query - ) + with open(file_path, 'rb') as file_desc: + resp = requests.post( + db_url + '/_api/import', + data=file_desc, + auth=(db_user, db_pass), + params=query + ) if not resp.ok: raise ArangoServerError(resp.text) return resp.text diff --git a/api/src/test/test_api.py b/api/src/test/test_api.py index 102c36a5..f7b7ae53 100644 --- a/api/src/test/test_api.py +++ b/api/src/test/test_api.py @@ -74,6 +74,17 @@ def test_save_documents_missing_schema(self): ).json() self.assertTrue('Schema does not exist' in resp['error']) + def test_save_documents_invalid_json(self): + resp = requests.put( + url + '/api/documents', + params={'collection': 'taxon'}, + data='\n', + headers={'Authorization': 'Bearer ' + auth_token} + ).json() + self.assertTrue('Unable to parse' in resp['error']) + self.assertEqual(resp['pos'], 1) + self.assertEqual(resp['source_json'], '\n') + def test_save_documents(self): # Create resp = requests.put( @@ -95,8 +106,6 @@ def test_save_documents(self): # TODO Replace # TODO error on duplicate # TODO ignore duplicates - # TODO empty lines - # TODO invalid collection def test_query(self): pass From ddb3ccdf68d446d752282cf98a6b6a136ea89a0a Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 31 Oct 2018 14:11:02 -0700 Subject: [PATCH 032/732] Add the query cursor endpoint --- api/src/relation_engine_server/api.py | 19 ++++++++++++++----- .../arango_utils/arango_requests.py | 14 ++++++++++---- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/api/src/relation_engine_server/api.py b/api/src/relation_engine_server/api.py index abb720a9..f2aa6f4f 100644 --- a/api/src/relation_engine_server/api.py +++ b/api/src/relation_engine_server/api.py @@ -22,7 +22,6 @@ def show_views(): """ Fetch view names and content. - See ./show_views.yaml for documentation. Auth: public """ view_names = relation_engine_spec.views.get_view_names() @@ -34,18 +33,28 @@ def show_views(): return flask.jsonify(resp) -@api.route('/views//query', methods=['POST']) -def run_query(view_name): +@api.route('/query_cursor', methods=['GET']) +def run_query_cursor(): + """ + Continue fetching query results from a cursor id + """ + cursor_id = flask.request.args['id'] + resp = run_query(cursor_id=cursor_id) + return flask.jsonify(resp) + + +@api.route('query', methods=['POST']) +def run_query(): """ Run a stored view as a query against the database. - See ./run_query.yaml for documentation. Auth: only kbase users (any role) """ require_auth_token([]) + view_name = flask.request.args['view'] view_source = relation_engine_spec.views.get_view_content(view_name) bind_vars = flask.request.json # Make a request to the Arango server to run the query - resp = run_query(view_source, bind_vars) + resp = run_query(query=view_source, bind_vars=bind_vars) return flask.jsonify(resp) diff --git a/api/src/relation_engine_server/arango_utils/arango_requests.py b/api/src/relation_engine_server/arango_utils/arango_requests.py index 26f729de..7f2a99f1 100644 --- a/api/src/relation_engine_server/arango_utils/arango_requests.py +++ b/api/src/relation_engine_server/arango_utils/arango_requests.py @@ -24,16 +24,22 @@ def arango_server_status(): return 'unknown_failure' -def run_query(query_text, bind_vars): +def run_query(query_text=None, cursor_id=None, bind_vars={}): + """Run a query using the arango HTTP api. Can return a cursor to get more results.""" + url = db_url + '/_api/cursor' req_json = { - 'query': query_text, 'batchSize': 100, 'memoryLimit': 16000000000, # 16gb 'count': True, - 'bindVars': bind_vars } + if cursor_id: + url += '/' + cursor_id + else: + req_json['bindVars'] = bind_vars + req_json['query'] = query_text + resp = requests.post( - db_url + '/_api/cursor', + url, data=json.dumps(req_json), auth=(db_user, db_pass) ) From d308a25d620c31eb90fe467ef7ee5e3e36b7891a Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 31 Oct 2018 14:26:10 -0700 Subject: [PATCH 033/732] Finish set of integration tests for bulk-saving documents --- api/src/relation_engine_server/api.py | 4 +- api/src/test/test_api.py | 66 +++++++++++++++++++++------ 2 files changed, 55 insertions(+), 15 deletions(-) diff --git a/api/src/relation_engine_server/api.py b/api/src/relation_engine_server/api.py index f2aa6f4f..d65e4a1e 100644 --- a/api/src/relation_engine_server/api.py +++ b/api/src/relation_engine_server/api.py @@ -37,7 +37,9 @@ def show_views(): def run_query_cursor(): """ Continue fetching query results from a cursor id + Auth: only kbase users (any role) """ + require_auth_token(roles=[]) cursor_id = flask.request.args['id'] resp = run_query(cursor_id=cursor_id) return flask.jsonify(resp) @@ -49,7 +51,7 @@ def run_query(): Run a stored view as a query against the database. Auth: only kbase users (any role) """ - require_auth_token([]) + require_auth_token(roles=[]) view_name = flask.request.args['view'] view_source = relation_engine_spec.views.get_view_content(view_name) bind_vars = flask.request.json diff --git a/api/src/test/test_api.py b/api/src/test/test_api.py index f7b7ae53..3fcb2291 100644 --- a/api/src/test/test_api.py +++ b/api/src/test/test_api.py @@ -86,28 +86,66 @@ def test_save_documents_invalid_json(self): self.assertEqual(resp['source_json'], '\n') def test_save_documents(self): + """Test all valid cases for saving documents.""" + example_data = '\n'.join([ + '{"name": "x", "_key": "1"}', + '{"name": "y", "_key": "2"}', + '{"name": "z", "_key": "3"}' + ]) + headers = {'Authorization': 'Bearer ' + auth_token} # Create resp = requests.put( url + '/api/documents', - params={ - 'overwrite': True, - 'collection': 'taxon' - }, - data='\n'.join([ - '{"name": "x", "_key": "1"}', - '{"name": "y", "_key": "2"}', - '{"name": "z", "_key": "3"}' - ]), - headers={'Authorization': 'Bearer ' + auth_token} + params={'overwrite': True, 'collection': 'taxon'}, + data=example_data, + headers=headers ).json() expected = {'created': 3, 'errors': 0, 'empty': 0, 'updated': 0, 'ignored': 0, 'error': False} self.assertEqual(resp, expected) - # TODO Update - # TODO Replace - # TODO error on duplicate - # TODO ignore duplicates + # update on duplicate + resp = requests.put( + url + '/api/documents', + params={'on_duplicate': 'update', 'collection': 'taxon'}, + data=example_data, + headers=headers + ).json() + expected = {'created': 0, 'errors': 0, 'empty': 0, 'updated': 3, 'ignored': 0, 'error': False} + self.assertEqual(resp, expected) + # replace on duplicate + resp = requests.put( + url + '/api/documents', + params={'on_duplicate': 'replace', 'collection': 'taxon'}, + data=example_data, + headers=headers + ).json() + expected = {'created': 0, 'errors': 0, 'empty': 0, 'updated': 3, 'ignored': 0, 'error': False} + self.assertEqual(resp, expected) + # error on duplicate + resp = requests.put( + url + '/api/documents', + params={'on_duplicate': 'error', 'collection': 'taxon'}, + data=example_data, + headers=headers + ).json() + expected = {'created': 0, 'errors': 3, 'empty': 0, 'updated': 0, 'ignored': 0, 'error': False} + self.assertEqual(resp, expected) + # ignore duplicates + resp = requests.put( + url + '/api/documents', + params={'on_duplicate': 'ignore', 'collection': 'taxon'}, + data=example_data, + headers=headers + ).json() + expected = {'created': 0, 'errors': 0, 'empty': 0, 'updated': 0, 'ignored': 3, 'error': False} + self.assertEqual(resp, expected) def test_query(self): + resp = requests.post( + url + '/api/query', + params={'view': 'example'}, + headers={'Authorization': 'Bearer ' + auth_token} + ).json() + print('!', resp) pass # TODO valid query # TODO missing query name From 7588fdd21836e213835e2cbfeaa55e779649eecd Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 31 Oct 2018 14:33:24 -0700 Subject: [PATCH 034/732] Delete a whole bunch of stuff that is not needed right now --- spec/MANIFEST.in | 3 -- spec/Makefile | 6 --- .../migrations/README.md | 0 .../migrations/__init__.py | 0 .../migrations/example.py | 0 spec/relation_engine_spec/__init__.py | 0 spec/relation_engine_spec/schemas/__init__.py | 38 ------------------- spec/relation_engine_spec/test/README.md | 10 ----- spec/relation_engine_spec/views/MANIFEST.in | 1 - spec/relation_engine_spec/views/__init__.py | 29 -------------- .../schemas/README.md | 0 .../schemas/taxon.json | 0 spec/setup.py | 17 --------- spec/test.py | 0 .../views/README.md | 0 .../views/example.aql | 2 +- 16 files changed, 1 insertion(+), 105 deletions(-) delete mode 100644 spec/MANIFEST.in rename spec/{relation_engine_spec => }/migrations/README.md (100%) rename spec/{relation_engine_spec => }/migrations/__init__.py (100%) rename spec/{relation_engine_spec => }/migrations/example.py (100%) delete mode 100644 spec/relation_engine_spec/__init__.py delete mode 100644 spec/relation_engine_spec/schemas/__init__.py delete mode 100644 spec/relation_engine_spec/test/README.md delete mode 100644 spec/relation_engine_spec/views/MANIFEST.in delete mode 100644 spec/relation_engine_spec/views/__init__.py rename spec/{relation_engine_spec => }/schemas/README.md (100%) rename spec/{relation_engine_spec => }/schemas/taxon.json (100%) delete mode 100644 spec/setup.py delete mode 100644 spec/test.py rename spec/{relation_engine_spec => }/views/README.md (100%) rename spec/{relation_engine_spec => }/views/example.aql (87%) diff --git a/spec/MANIFEST.in b/spec/MANIFEST.in deleted file mode 100644 index abc88185..00000000 --- a/spec/MANIFEST.in +++ /dev/null @@ -1,3 +0,0 @@ -include README.md -include relation_engine_spec/views/*.aql -include relation_engine_spec/schemas/*.json diff --git a/spec/Makefile b/spec/Makefile index 2f810097..81bd78a3 100644 --- a/spec/Makefile +++ b/spec/Makefile @@ -3,9 +3,3 @@ test: test-server: echo "TODO run a single-node arango database server with pre-loaded test data" - -build-dist: - python setup.py sdist - -publish: - anaconda upload -i -u kbase dist/*.tar.gz diff --git a/spec/relation_engine_spec/migrations/README.md b/spec/migrations/README.md similarity index 100% rename from spec/relation_engine_spec/migrations/README.md rename to spec/migrations/README.md diff --git a/spec/relation_engine_spec/migrations/__init__.py b/spec/migrations/__init__.py similarity index 100% rename from spec/relation_engine_spec/migrations/__init__.py rename to spec/migrations/__init__.py diff --git a/spec/relation_engine_spec/migrations/example.py b/spec/migrations/example.py similarity index 100% rename from spec/relation_engine_spec/migrations/example.py rename to spec/migrations/example.py diff --git a/spec/relation_engine_spec/__init__.py b/spec/relation_engine_spec/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/spec/relation_engine_spec/schemas/__init__.py b/spec/relation_engine_spec/schemas/__init__.py deleted file mode 100644 index 4d2a852b..00000000 --- a/spec/relation_engine_spec/schemas/__init__.py +++ /dev/null @@ -1,38 +0,0 @@ -import os -import json -import jsonschema - - -def get_schema_names(): - current_dir = os.path.dirname(__file__) - schema_names = [] - for file_name in os.listdir(current_dir): - (basename, ext) = os.path.splitext(file_name) - if ext == '.json': - schema_names.append(basename) - return schema_names - - -def get_schema_as_dict(schema_name): - """Parse a schema into a python dictionary.""" - current_dir = os.path.dirname(__file__) - file_path = os.path.join(current_dir, schema_name + '.json') - if not os.path.isfile(file_path): - raise SchemaNonexistent(schema_name) - with open(file_path, 'r') as fd: - return json.loads(fd.read()) - - -def validate_data_against_schema(schema, data): - """Given a parsed JSON schema and some python data, validate the data structure against the schema.""" - jsonschema.validate(data, schema) - - -class SchemaNonexistent(Exception): - """Schema that we tried to fetch by name does not exist.""" - - def __init__(self, schema_name): - self.schema_name = schema_name - - def __str__(self): - return 'Schema does not exist %s. Available schemas are: %s' % (self.schema_name, str(get_schema_names())) diff --git a/spec/relation_engine_spec/test/README.md b/spec/relation_engine_spec/test/README.md deleted file mode 100644 index 7159caaf..00000000 --- a/spec/relation_engine_spec/test/README.md +++ /dev/null @@ -1,10 +0,0 @@ -# Relation Engine Spec Tests - -This directory holds python unit-tests for Relation Engine views and migrations. - -A view test should test that a query returns the expected data, traverses the graph correctly, and -does not return data that we don't want. - -A migration test should test that all the data in a test database has been updated in the correct -way after a migration is run. It should also test that when a migration rolls back, data is -restored to its original form. diff --git a/spec/relation_engine_spec/views/MANIFEST.in b/spec/relation_engine_spec/views/MANIFEST.in deleted file mode 100644 index af790b8a..00000000 --- a/spec/relation_engine_spec/views/MANIFEST.in +++ /dev/null @@ -1 +0,0 @@ -include example.aql diff --git a/spec/relation_engine_spec/views/__init__.py b/spec/relation_engine_spec/views/__init__.py deleted file mode 100644 index 36aa1c4a..00000000 --- a/spec/relation_engine_spec/views/__init__.py +++ /dev/null @@ -1,29 +0,0 @@ -import os - - -def get_view_names(): - current_dir = os.path.dirname(__file__) - view_names = [] - for file_name in os.listdir(current_dir): - (basename, ext) = os.path.splitext(file_name) - if ext == '.aql': - view_names.append(basename) - return view_names - - -def get_view_content(view_name): - current_dir = os.path.dirname(__file__) - file_path = os.path.join(current_dir, view_name + '.aql') - if not os.path.isfile(file_path): - raise ViewNonexistent() - with open(file_path, 'r') as fd: - return fd.read() - - -class ViewNonexistent(Exception): - - def __init__(self): - pass - - def __str__(self): - return 'View does not exist. Available views are: ' + str(get_view_names()) diff --git a/spec/relation_engine_spec/schemas/README.md b/spec/schemas/README.md similarity index 100% rename from spec/relation_engine_spec/schemas/README.md rename to spec/schemas/README.md diff --git a/spec/relation_engine_spec/schemas/taxon.json b/spec/schemas/taxon.json similarity index 100% rename from spec/relation_engine_spec/schemas/taxon.json rename to spec/schemas/taxon.json diff --git a/spec/setup.py b/spec/setup.py deleted file mode 100644 index 85f35b50..00000000 --- a/spec/setup.py +++ /dev/null @@ -1,17 +0,0 @@ -from setuptools import setup, find_packages - -setup( - name='relation_engine_spec', - version='0.1', - author='Jay Bolton', - author_email='jrbolton@lbl.gov', - packages=find_packages(), - include_package_data=True, - license='MIT', - description='Specifications for the KBase Relation Engine API.', - url='https://kbase.us', - python_requires='>=3', - install_requires=[ - 'jsonschema' - ] -) diff --git a/spec/test.py b/spec/test.py deleted file mode 100644 index e69de29b..00000000 diff --git a/spec/relation_engine_spec/views/README.md b/spec/views/README.md similarity index 100% rename from spec/relation_engine_spec/views/README.md rename to spec/views/README.md diff --git a/spec/relation_engine_spec/views/example.aql b/spec/views/example.aql similarity index 87% rename from spec/relation_engine_spec/views/example.aql rename to spec/views/example.aql index 8dabcc1e..d8170863 100644 --- a/spec/relation_engine_spec/views/example.aql +++ b/spec/views/example.aql @@ -2,6 +2,6 @@ // Args: // collection - name of collection to count docs -for v in @collection: +for v in @collection collect with count into length return length From 81927678961aef4c136198d499a86f8d6466360b Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 31 Oct 2018 14:38:46 -0700 Subject: [PATCH 035/732] Fix function call for run_query --- api/src/relation_engine_server/api.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/api/src/relation_engine_server/api.py b/api/src/relation_engine_server/api.py index d65e4a1e..27a9cd35 100644 --- a/api/src/relation_engine_server/api.py +++ b/api/src/relation_engine_server/api.py @@ -8,8 +8,9 @@ import relation_engine_spec.views import relation_engine_spec.schemas -from src.relation_engine_server.arango_utils.arango_requests import ( +from .arango_utils.arango_requests import ( bulk_import, + run_query, ArangoServerError ) @@ -46,7 +47,7 @@ def run_query_cursor(): @api.route('query', methods=['POST']) -def run_query(): +def run_query_from_view(): """ Run a stored view as a query against the database. Auth: only kbase users (any role) @@ -56,7 +57,7 @@ def run_query(): view_source = relation_engine_spec.views.get_view_content(view_name) bind_vars = flask.request.json # Make a request to the Arango server to run the query - resp = run_query(query=view_source, bind_vars=bind_vars) + resp = run_query(query_text=view_source, bind_vars=bind_vars) return flask.jsonify(resp) From 542a302d7fc47039ff9690c7a63559041397dd12 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 31 Oct 2018 16:14:12 -0700 Subject: [PATCH 036/732] Get the relation engine spec dynamically updating by using a very simple git pull whenever we fetch info from it. --- api/.gitignore | 3 + api/Dockerfile | 10 ++- api/requirements.txt | 1 - api/src/relation_engine_server/api.py | 20 ++--- api/src/relation_engine_server/spec_loader.py | 83 +++++++++++++++++++ api/src/test/test_api.py | 1 + 6 files changed, 102 insertions(+), 16 deletions(-) create mode 100644 api/src/relation_engine_server/spec_loader.py diff --git a/api/.gitignore b/api/.gitignore index 2be5fcda..1cbe1853 100644 --- a/api/.gitignore +++ b/api/.gitignore @@ -10,3 +10,6 @@ tmp/* coverage_report/ .coverage + +# Relation engine spec sub-repo that gets pulled while the server is running +/relation_engine_spec/ diff --git a/api/Dockerfile b/api/Dockerfile index cb766e7f..eefc6e72 100644 --- a/api/Dockerfile +++ b/api/Dockerfile @@ -1,22 +1,24 @@ FROM python:3.7-alpine ARG DEVELOPMENT +ARG spec_url=https://github.com/kbase/relation_engine_spec +ARG spec_path=/spec COPY requirements.txt /app/requirements.txt COPY dev-requirements.txt /app/dev-requirements.txt WORKDIR /app # Install dependencies -RUN apk --update add make +RUN apk --update add make git RUN apk --update add --virtual build-dependencies python-dev build-base && \ pip install --upgrade pip && \ - pip install --upgrade --no-cache-dir \ - --extra-index-url https://pypi.anaconda.org/kbase/simple \ - -r requirements.txt && \ + pip install --upgrade --no-cache-dir -r requirements.txt && \ if [ "$DEVELOPMENT" ]; then pip install -r dev-requirements.txt; fi && \ apk del build-dependencies # Run the app COPY . /app +# Clone the spec files +RUN git clone ${spec_url} ${spec_path} CMD ["sh", "start_server.sh"] diff --git a/api/requirements.txt b/api/requirements.txt index 68bb9ed4..eb6fc4b2 100644 --- a/api/requirements.txt +++ b/api/requirements.txt @@ -4,5 +4,4 @@ gevent==1.3.6 simplejson==3.16.0 python-dotenv==0.9.1 requests==2.19.1 -relation_engine_spec==0.1 jsonschema==2.6.0 diff --git a/api/src/relation_engine_server/api.py b/api/src/relation_engine_server/api.py index 27a9cd35..6a7f5eff 100644 --- a/api/src/relation_engine_server/api.py +++ b/api/src/relation_engine_server/api.py @@ -5,9 +5,6 @@ import jsonschema from jsonschema.exceptions import ValidationError -import relation_engine_spec.views -import relation_engine_spec.schemas - from .arango_utils.arango_requests import ( bulk_import, run_query, @@ -15,6 +12,7 @@ ) from .auth import require_auth_token +from . import spec_loader api = flask.Blueprint('api', __name__) @@ -25,12 +23,12 @@ def show_views(): Fetch view names and content. Auth: public """ - view_names = relation_engine_spec.views.get_view_names() + view_names = spec_loader.get_view_names() resp = {'names': view_names} if flask.request.args.get('show_source'): resp['content'] = {} for name in view_names: - resp['content'][name] = relation_engine_spec.views.get_view_content(name) + resp['content'][name] = spec_loader.get_view_content(name) return flask.jsonify(resp) @@ -54,7 +52,7 @@ def run_query_from_view(): """ require_auth_token(roles=[]) view_name = flask.request.args['view'] - view_source = relation_engine_spec.views.get_view_content(view_name) + view_source = spec_loader.get_view_content(view_name) bind_vars = flask.request.json # Make a request to the Arango server to run the query resp = run_query(query_text=view_source, bind_vars=bind_vars) @@ -68,12 +66,12 @@ def show_schemas(): See ./show_schemas.yaml for documentation. Auth: public """ - schema_names = relation_engine_spec.schemas.get_schema_names() + schema_names = spec_loader.get_schema_names() resp = {'names': schema_names} if flask.request.args.get('show_source'): resp['content'] = {} for name in schema_names: - resp['content'][name] = relation_engine_spec.schemas.get_schema_as_dict(name) + resp['content'][name] = spec_loader.get_schema_as_dict(name) return flask.jsonify(resp) @@ -89,7 +87,7 @@ def save_documents(): 'collection': flask.request.args['collection'], 'type': 'documents' } - schema = relation_engine_spec.schemas.get_schema_as_dict(query['collection']) + schema = spec_loader.get_schema_as_dict(query['collection']) if flask.request.args.get('on_duplicate'): query['onDuplicate'] = flask.request.args['on_duplicate'] if flask.request.args.get('overwrite'): @@ -119,7 +117,7 @@ def json_decode_error(err): @api.errorhandler(ArangoServerError) -@api.errorhandler(relation_engine_spec.views.ViewNonexistent) +@api.errorhandler(spec_loader.ViewNonexistent) def view_does_not_exist(err): """General error cases.""" return (flask.jsonify({'error': str(err)}), 400) @@ -138,7 +136,7 @@ def validation_error(err): return (flask.jsonify(resp), 400) -@api.errorhandler(relation_engine_spec.schemas.SchemaNonexistent) +@api.errorhandler(spec_loader.SchemaNonexistent) def schema_nonexistent(err): """A schema/collection was requested but does not exist.""" resp = { diff --git a/api/src/relation_engine_server/spec_loader.py b/api/src/relation_engine_server/spec_loader.py new file mode 100644 index 00000000..f11127fa --- /dev/null +++ b/api/src/relation_engine_server/spec_loader.py @@ -0,0 +1,83 @@ +""" +Utilities for loading views, schemas, and migrations from the spec. +""" +import os +import json +import subprocess # nosec + +_spec_path = os.environ.get('SPEC_PATH', '/spec') + + +def get_schema_names(): + """Return a list of all schema names.""" + git_pull() + schema_path = os.path.join(_spec_path, 'schemas') + return _get_file_names(schema_path, '.json') + + +def get_view_names(): + """Return a list of all view names.""" + git_pull() + view_path = os.path.join(_spec_path, 'views') + return _get_file_names(view_path, '.aql') + + +def get_view_content(name): + """Return the AQL source code for a view.""" + view_names = get_view_names() + if name not in view_names: + raise ViewNonexistent(name, view_names) + view_path = os.path.join(_spec_path, 'views', name + '.aql') + print('name', name) + print('view_path', view_path) + with open(view_path, 'r') as fd: + return fd.read() + + +def get_schema_as_dict(name): + """Return a particular JSON schema as a python dict.""" + schema_names = get_schema_names() + if name not in schema_names: + raise SchemaNonexistent(name, schema_names) + schema_path = os.path.join(_spec_path, 'schemas', name + '.json') + with open(schema_path, 'r') as fd: + return json.loads(fd.read()) + + +def git_pull(): + """Git pull the spec repo to get any updates.""" + output = subprocess.check_output(['git', '-C', _spec_path, 'pull']) # nosec + print('git pull output', output) + return output + + +def _get_file_names(dir_path, target_extension): + """Get a list of file basenames in a certain directory with a certain extension.""" + names = [] + for name in os.listdir(dir_path): + filename, extension = os.path.splitext(name) + if extension == target_extension: + names.append(filename) + return names + + +class ViewNonexistent(Exception): + """Requested view is not in the spec.""" + + def __init__(self, name, available): + self.name = name + self.available = available + + def __str__(self): + return 'View does not exist.' + + +class SchemaNonexistent(Exception): + """Requested schema is not in the spec.""" + + def __init__(self, name, available): + self.name = name + self.available = available + + def __str__(self): + return 'Schema does not exist.' diff --git a/api/src/test/test_api.py b/api/src/test/test_api.py index 3fcb2291..eb3438a6 100644 --- a/api/src/test/test_api.py +++ b/api/src/test/test_api.py @@ -139,6 +139,7 @@ def test_save_documents(self): expected = {'created': 0, 'errors': 0, 'empty': 0, 'updated': 0, 'ignored': 3, 'error': False} self.assertEqual(resp, expected) + @unittest.skip('TODO') def test_query(self): resp = requests.post( url + '/api/query', From 5abd0b68e3ffe809b26e3233760facdc65372d5e Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 31 Oct 2018 16:21:06 -0700 Subject: [PATCH 037/732] Optimize some functions that pull data from the spec --- api/src/relation_engine_server/api.py | 18 ++++------- api/src/relation_engine_server/spec_loader.py | 32 +++++++++++-------- 2 files changed, 24 insertions(+), 26 deletions(-) diff --git a/api/src/relation_engine_server/api.py b/api/src/relation_engine_server/api.py index 6a7f5eff..c7cd988e 100644 --- a/api/src/relation_engine_server/api.py +++ b/api/src/relation_engine_server/api.py @@ -26,9 +26,7 @@ def show_views(): view_names = spec_loader.get_view_names() resp = {'names': view_names} if flask.request.args.get('show_source'): - resp['content'] = {} - for name in view_names: - resp['content'][name] = spec_loader.get_view_content(name) + resp['content'] = spec_loader.get_view_content(view_names) return flask.jsonify(resp) @@ -52,7 +50,7 @@ def run_query_from_view(): """ require_auth_token(roles=[]) view_name = flask.request.args['view'] - view_source = spec_loader.get_view_content(view_name) + view_source = spec_loader.get_view_content([view_name])[view_name] bind_vars = flask.request.json # Make a request to the Arango server to run the query resp = run_query(query_text=view_source, bind_vars=bind_vars) @@ -69,9 +67,7 @@ def show_schemas(): schema_names = spec_loader.get_schema_names() resp = {'names': schema_names} if flask.request.args.get('show_source'): - resp['content'] = {} - for name in schema_names: - resp['content'][name] = spec_loader.get_schema_as_dict(name) + resp['content'] = spec_loader.get_schema_dicts(schema_names) return flask.jsonify(resp) @@ -83,11 +79,9 @@ def save_documents(): Auth: only sysadmins """ require_auth_token(['RE_ADMIN']) - query = { - 'collection': flask.request.args['collection'], - 'type': 'documents' - } - schema = spec_loader.get_schema_as_dict(query['collection']) + coll = flask.request.args['collection'] + query = {'collection': coll, 'type': 'documents'} + schema = spec_loader.get_schema_dicts([coll])[coll] if flask.request.args.get('on_duplicate'): query['onDuplicate'] = flask.request.args['on_duplicate'] if flask.request.args.get('overwrite'): diff --git a/api/src/relation_engine_server/spec_loader.py b/api/src/relation_engine_server/spec_loader.py index f11127fa..4ca42fec 100644 --- a/api/src/relation_engine_server/spec_loader.py +++ b/api/src/relation_engine_server/spec_loader.py @@ -22,26 +22,30 @@ def get_view_names(): return _get_file_names(view_path, '.aql') -def get_view_content(name): +def get_view_content(names): """Return the AQL source code for a view.""" + views = {} view_names = get_view_names() - if name not in view_names: - raise ViewNonexistent(name, view_names) - view_path = os.path.join(_spec_path, 'views', name + '.aql') - print('name', name) - print('view_path', view_path) - with open(view_path, 'r') as fd: - return fd.read() + for name in names: + if name not in view_names: + raise ViewNonexistent(name, view_names) + view_path = os.path.join(_spec_path, 'views', name + '.aql') + with open(view_path, 'r') as fd: + views[name] = fd.read() + return views -def get_schema_as_dict(name): +def get_schema_dicts(names): """Return a particular JSON schema as a python dict.""" + schemas = {} schema_names = get_schema_names() - if name not in schema_names: - raise SchemaNonexistent(name, schema_names) - schema_path = os.path.join(_spec_path, 'schemas', name + '.json') - with open(schema_path, 'r') as fd: - return json.loads(fd.read()) + for name in names: + if name not in schema_names: + raise SchemaNonexistent(name, schema_names) + schema_path = os.path.join(_spec_path, 'schemas', name + '.json') + with open(schema_path, 'r') as fd: + schemas[name] = json.loads(fd.read()) + return schemas def git_pull(): From 7e95b58c899e0fbe11222526d1ed957c560aed54 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 31 Oct 2018 16:28:14 -0700 Subject: [PATCH 038/732] Fix bind var --- spec/views/example.aql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/views/example.aql b/spec/views/example.aql index d8170863..fc862a0d 100644 --- a/spec/views/example.aql +++ b/spec/views/example.aql @@ -2,6 +2,6 @@ // Args: // collection - name of collection to count docs -for v in @collection +for v in @@collection collect with count into length return length From f5c5dcf0914de6b4a3673731f39eac91f96820ce Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 31 Oct 2018 16:58:35 -0700 Subject: [PATCH 039/732] Finish the rest of the functionality and tests for running stored queries with bind vars --- api/src/relation_engine_server/api.py | 33 +++++++---- api/src/relation_engine_server/app.py | 5 +- .../arango_requests.py => arango_client.py} | 21 ++++--- api/src/relation_engine_server/auth.py | 1 - api/src/test/test_api.py | 59 ++++++++++++++++--- 5 files changed, 87 insertions(+), 32 deletions(-) rename api/src/relation_engine_server/{arango_utils/arango_requests.py => arango_client.py} (81%) diff --git a/api/src/relation_engine_server/api.py b/api/src/relation_engine_server/api.py index c7cd988e..dca4f0fa 100644 --- a/api/src/relation_engine_server/api.py +++ b/api/src/relation_engine_server/api.py @@ -5,14 +5,9 @@ import jsonschema from jsonschema.exceptions import ValidationError -from .arango_utils.arango_requests import ( - bulk_import, - run_query, - ArangoServerError -) - from .auth import require_auth_token from . import spec_loader +from . import arango_client api = flask.Blueprint('api', __name__) @@ -38,7 +33,7 @@ def run_query_cursor(): """ require_auth_token(roles=[]) cursor_id = flask.request.args['id'] - resp = run_query(cursor_id=cursor_id) + resp = arango_client.run_query(cursor_id=cursor_id) return flask.jsonify(resp) @@ -51,9 +46,9 @@ def run_query_from_view(): require_auth_token(roles=[]) view_name = flask.request.args['view'] view_source = spec_loader.get_view_content([view_name])[view_name] - bind_vars = flask.request.json + bind_vars = flask.request.json or {} # Make a request to the Arango server to run the query - resp = run_query(query_text=view_source, bind_vars=bind_vars) + resp = arango_client.run_query(query_text=view_source, bind_vars=bind_vars) return flask.jsonify(resp) @@ -92,7 +87,7 @@ def save_documents(): json_line = json.loads(line) jsonschema.validate(json_line, schema) fd.write(json.dumps(json_line) + '\n') - resp_text = bulk_import(temp_fd.name, query) + resp_text = arango_client.bulk_import(temp_fd.name, query) temp_fd.close() # Also deletes the file return resp_text @@ -110,11 +105,25 @@ def json_decode_error(err): return (flask.jsonify(resp), 400) -@api.errorhandler(ArangoServerError) +@api.errorhandler(arango_client.ArangoServerError) +def arango_server_error(err): + resp = { + 'error': str(err), + 'arango_message': err.resp_json['errorMessage'] + } + return (flask.jsonify(resp), 400) + + +@api.errorhandler(spec_loader.SchemaNonexistent) @api.errorhandler(spec_loader.ViewNonexistent) def view_does_not_exist(err): """General error cases.""" - return (flask.jsonify({'error': str(err)}), 400) + resp = { + 'error': str(err), + 'name': err.name, + 'available': err.available + } + return (flask.jsonify(resp), 400) @api.errorhandler(ValidationError) diff --git a/api/src/relation_engine_server/app.py b/api/src/relation_engine_server/app.py index 184d7770..ee48e840 100644 --- a/api/src/relation_engine_server/app.py +++ b/api/src/relation_engine_server/app.py @@ -4,11 +4,10 @@ from uuid import uuid4 import traceback -from .arango_utils.arango_requests import arango_server_status - from .api import api from .docs import docs from .exceptions import MissingHeader, UnauthorizedAccess +from . import arango_client app = flask.Flask(__name__) app.config['DEBUG'] = os.environ.get('FLASK_DEBUG', True) @@ -24,7 +23,7 @@ def root(): """Server status and link to docs.""" with open('.git/refs/heads/master', 'r') as fd: commit_hash = fd.read().strip() - arangodb_status = arango_server_status() + arangodb_status = arango_client.server_status() repo_url = 'https://github.com/kbase/relation_engine_api.git' return flask.jsonify({ 'arangodb_status': arangodb_status, diff --git a/api/src/relation_engine_server/arango_utils/arango_requests.py b/api/src/relation_engine_server/arango_client.py similarity index 81% rename from api/src/relation_engine_server/arango_utils/arango_requests.py rename to api/src/relation_engine_server/arango_client.py index 7f2a99f1..9fac1a8f 100644 --- a/api/src/relation_engine_server/arango_utils/arango_requests.py +++ b/api/src/relation_engine_server/arango_client.py @@ -10,7 +10,7 @@ db_pass = os.environ.get('DB_PASS', 'password') -def arango_server_status(): +def server_status(): """Get the status of our connection and authorization to the ArangoDB server.""" try: resp = requests.get(db_url + '/_api/endpoint', auth=(db_user, db_pass)) @@ -45,7 +45,16 @@ def run_query(query_text=None, cursor_id=None, bind_vars={}): ) if not resp.ok: raise ArangoServerError(resp.text) - return resp.text + resp_json = resp.json() + if resp_json['error']: + raise ArangoServerError(resp.text) + return { + 'results': resp_json['result'], + 'count': resp_json['count'], + 'has_more': resp_json['hasMore'], + 'cursor_id': resp_json.get('id'), + 'stats': resp_json['extra']['stats'] + } def bulk_import(file_path, query): @@ -67,11 +76,7 @@ class ArangoServerError(Exception): def __init__(self, resp_text): self.resp_text = resp_text + self.resp_json = json.loads(resp_text) def __str__(self): - return '\n'.join([ - '-' * 80, - 'ArangoDB server error', - self.resp_text, - '-' * 80 - ]) + return 'ArangoDB server error.' diff --git a/api/src/relation_engine_server/auth.py b/api/src/relation_engine_server/auth.py index 00680a6c..e16658e4 100644 --- a/api/src/relation_engine_server/auth.py +++ b/api/src/relation_engine_server/auth.py @@ -25,7 +25,6 @@ def require_auth_token(roles=[]): # Make an authorization request to the kbase auth2 server headers = {'Authorization': token} url = kbase_auth_url + '/api/V2/me' - print(url) auth_resp = requests.get(url, headers=headers) if not auth_resp.ok: print('-' * 80) diff --git a/api/src/test/test_api.py b/api/src/test/test_api.py index eb3438a6..1b2d8f18 100644 --- a/api/src/test/test_api.py +++ b/api/src/test/test_api.py @@ -5,6 +5,7 @@ """ import unittest import requests +import json import os url = 'http://web:5000' @@ -139,16 +140,58 @@ def test_save_documents(self): expected = {'created': 0, 'errors': 0, 'empty': 0, 'updated': 0, 'ignored': 3, 'error': False} self.assertEqual(resp, expected) - @unittest.skip('TODO') def test_query(self): resp = requests.post( url + '/api/query', params={'view': 'example'}, - headers={'Authorization': 'Bearer ' + auth_token} + data=json.dumps({'@collection': 'taxon'}), + headers={ + 'Authorization': 'Bearer ' + auth_token, + 'Content-Type': 'application/json' + } + ).json() + self.assertEqual(resp['results'], [3]) + self.assertEqual(resp['count'], 1) + self.assertEqual(resp['has_more'], False) + self.assertEqual(resp['cursor_id'], None) + self.assertTrue(resp['stats']) + + def test_query_no_name(self): + resp = requests.post( + url + '/api/query', + params={'view': 'nonexistent'}, + data=json.dumps({'@collection': 'taxon'}), + headers={ + 'Authorization': 'Bearer ' + auth_token, + 'Content-Type': 'application/json' + } + ).json() + self.assertEqual(resp['error'], 'View does not exist.') + self.assertEqual(resp['name'], 'nonexistent') + self.assertTrue(len(resp['available']) > 0) + + def test_query_missing_bind_var(self): + resp = requests.post( + url + '/api/query', + params={'view': 'example'}, + data=json.dumps({'xyz': 'taxon'}), + headers={ + 'Authorization': 'Bearer ' + auth_token, + 'Content-Type': 'application/json' + } + ).json() + self.assertEqual(resp['error'], 'ArangoDB server error.') + self.assertTrue(resp['arango_message']) + + def test_query_incorrect_collection(self): + resp = requests.post( + url + '/api/query', + params={'view': 'example'}, + data=json.dumps({'@collection': 123}), + headers={ + 'Authorization': 'Bearer ' + auth_token, + 'Content-Type': 'application/json' + } ).json() - print('!', resp) - pass - # TODO valid query - # TODO missing query name - # TODO missing bind variables - # TODO bind variable is invalid + self.assertEqual(resp['error'], 'ArangoDB server error.') + self.assertTrue(resp['arango_message']) From dcb3542e667310a57b0e8637f4a44bd25dd2b08f Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Thu, 1 Nov 2018 13:45:51 -0700 Subject: [PATCH 040/732] Update documentation --- api/Makefile | 3 - api/README.md | 194 +++++++++++++++++- .../relation_engine_server/arango_client.py | 2 +- 3 files changed, 189 insertions(+), 10 deletions(-) diff --git a/api/Makefile b/api/Makefile index 1a9c8596..bf7e9133 100644 --- a/api/Makefile +++ b/api/Makefile @@ -1,8 +1,5 @@ .PHONY: dev-server dev-build test test-local -dev-server: - docker-compose up - test: docker-compose run web make test-local diff --git a/api/README.md b/api/README.md index 4df0c13a..89b0f6e2 100644 --- a/api/README.md +++ b/api/README.md @@ -6,7 +6,189 @@ View the root path of the running server in your browser to get the Swagger API View `/v1` to get server status. All API endpoints are nested under `/v1` and are documented via the Swagger API. -## Using the client +## HTTP API + +### GET /api/views + +Return a list of view names and optionally the AQL source code for each. + +_Example_ + +```sh +$ curl -X GET http://relation_engine/api/views?show_source=1 +``` + +_Query params_ +* `show_source` - optional - boolean - whether to show the full AQL source for each view + +_Response JSON schema_ + +```json +{ "type": "object", + "properties": { + "names": { + "type": "array", + "item": "string", + "description": "Array of view names" + }, + "content": { + "type": "object", + "description": "An object where keys are view names and properties are AQL source." + } + } +} +``` + +The `"content"` property is returned only if the `show_source` query parameter is truthy. + +### GET /api/schemas + +Return a list of schema names and optionall the JSON schema source for each. + +_Example_ + +```sh +$ curl -X GET http://relation_engine/api/schemas?show_source=1 +``` + +_Query params_ +* `show_source` - optional - boolean - whether to show the full JSON source for each schema + +_Response JSON schema_ +```json +{ "type": "object", + "properties": { + "names": { + "type": "array", + "item": "string", + "description": "Array of schema names" + }, + "content": { + "type": "object", + "description": "An object where keys are schema names and properties are JSON schemas." + } + } +} +``` + +### POST /query + +Run a new query using a view. + +_Example_ + +```sh +$ curl -X - POST http://relation_engine/api/query?view=example +``` + +_Query params_ +* `view` - required - string - name of the view to run as a query against the database + +_Response JSON schema_ + +```json +{ "type": "object", + "properties": { + "results": { + "type": "array", + "description": "Result data from running with a maximum of 100 entries." + }, + "count": { + "type": "integer", + "description": "Total count of results." + }, + "has_more": { + "type": "boolean", + "description": "Whether additional results can be fetched with the cursor_id." + }, + "cursor_id": { + "type": "string", + "description": "A cursor ID that you can use to fetch more results, if they are present." + }, + "stats": { + "type": "object", + "description": "Information about how this query affected the database and its run-time." + } + } +} +``` + +Results are limited to 100 items. To continue fetching additional results, use the `cursor_id` below: + +### GET /query_cursor + +Fetch more results from existing query results using a cursor ID + +_Example_ + +```sh +$ curl -X GET http://relation_engine/api/query_cursor?id=123123123 +``` + +_Query params_ +* `id` - required - string - cursor ID as found in the query results object above when `has_more` is true. + +The response JSON will match the same JSON schema as the one for the response under `POST /query` + +### PUT /documents + +Bulk-update documents by either creating, replacing, or updating. + +_Example_ + +```sh +$ curl -X PUT http://relation_engine/api/documents?collection=genes& +``` + +_Query params_ +* `collection` - required - string - name of the collection that we want to bulk-import into. +* `on_duplicate` - optional - "replace", "update", "ignore", "error" - Action to take when we are saving a duplicate document by matching `_key`. "replace" replaces the whole document. "update" merges in the new values. "ignore" takes no action. "error" cancels the entire transaction. +* `overwrite` - optional - boolean - whether to overwrite the whole collection (that is, delete all documents currently in the collection before creating the documents you provide) + +_Request body_ + +The request body should be a series of JSON documents separated by line-breaks. For example: + +``` +{"_key": "1", "name": "x"} +{"_key": "2", "name": "y"} +``` + +_Response JSON schema_ + +```json +{ "type": "object", + "properties": { + "created": { + "type": "integer", + "description": "Count of documents that were created." + }, + "errors": { + "type": "integer", + "description": "Count of documents that had an error in saving." + }, + "empty": { + "type": "integer", + "description": "Count of empty lines in the import." + }, + "updated": { + "type": "integer", + "description": "Count of documents that were updated with an attribute merge." + }, + "ignored": { + "type": "integer", + "description": "Count of documents that were not imported due to a match." + }, + "error": { + "type": "boolean", + "description": "Whether the entire save operation was cancelled due to an error." + } + } +} +expected = {'created': 3, 'errors': 0, 'empty': 0, 'updated': 0, 'ignored': 0, 'error': False} +``` + +## Python client API A python client is provided and published on anaconda, installable via pip or conda: @@ -20,6 +202,8 @@ Then import it: import relation_engine_client as rec ``` +You can set the environment variable `RELATION_ENGINE_URL` to set the URL of the HTTP API you want to use. + List out all the current relation engine views: ```py @@ -36,13 +220,11 @@ schemas = rec.get_schemas(show_source=True) ## Development -Copy `.env.development.example` or `.env.production.example` to `.env` and edit it, if needed. - -The docker image is pushed to Docker Hub when new commits are made to master. +Copy `.env.example` to `.env`. Start the server with `docker-compose up`. -Start up the server `make dev-server`. +Run tests with `make test`. -Run tests against the server with `make test`. +The docker image is pushed to Docker Hub when new commits are made to master. The script that runs when pushing to docker hub is found in `hooks/build`. ## Building and publishing the client diff --git a/api/src/relation_engine_server/arango_client.py b/api/src/relation_engine_server/arango_client.py index 9fac1a8f..4182764d 100644 --- a/api/src/relation_engine_server/arango_client.py +++ b/api/src/relation_engine_server/arango_client.py @@ -25,7 +25,7 @@ def server_status(): def run_query(query_text=None, cursor_id=None, bind_vars={}): - """Run a query using the arango HTTP api. Can return a cursor to get more results.""" + """Run a query using the arangodb http api. Can return a cursor to get more results.""" url = db_url + '/_api/cursor' req_json = { 'batchSize': 100, From d033fea639fab948e1c60ddbd0cb05844411193d Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Thu, 1 Nov 2018 14:05:05 -0700 Subject: [PATCH 041/732] Update README.md --- api/README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/api/README.md b/api/README.md index 89b0f6e2..d0ea5d19 100644 --- a/api/README.md +++ b/api/README.md @@ -4,10 +4,12 @@ A simple API that allows KBase community developers to interact with the Relatio View the root path of the running server in your browser to get the Swagger API interface. -View `/v1` to get server status. All API endpoints are nested under `/v1` and are documented via the Swagger API. - ## HTTP API +### GET / + +Returns server status + ### GET /api/views Return a list of view names and optionally the AQL source code for each. From ffc82d3ac674863d46778a8b520ccc64410177b0 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Thu, 1 Nov 2018 14:44:19 -0700 Subject: [PATCH 042/732] Update README.md --- api/README.md | 52 ++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 47 insertions(+), 5 deletions(-) diff --git a/api/README.md b/api/README.md index d0ea5d19..ded2eee2 100644 --- a/api/README.md +++ b/api/README.md @@ -8,7 +8,7 @@ View the root path of the running server in your browser to get the Swagger API ### GET / -Returns server status +Returns server status info ### GET /api/views @@ -80,12 +80,20 @@ Run a new query using a view. _Example_ ```sh -$ curl -X - POST http://relation_engine/api/query?view=example +$ curl -X -d '{"argument": "value"}' POST http://relation_engine/api/query?view=example ``` _Query params_ * `view` - required - string - name of the view to run as a query against the database +_Request body_ + +The request body should be a JSON object of all bind variables for the query. Anything with a `@name` in the query source should have an entry in the object here. For example, for a query with bind vars for `@@collection` and `@value`, you will need to pass: + +```json +{ "@collection": "collection_name", "value": "my_value"} +``` + _Response JSON schema_ ```json @@ -187,7 +195,6 @@ _Response JSON schema_ } } } -expected = {'created': 3, 'errors': 0, 'empty': 0, 'updated': 0, 'ignored': 0, 'error': False} ``` ## Python client API @@ -210,16 +217,51 @@ List out all the current relation engine views: ```py views = rec.get_views(show_source=True) -# returns an array of {name, source} ``` List out all the current schemas ```py schemas = rec.get_schemas(show_source=True) -# returns an array of {name, source} ``` +Run a query: + +```py +results = rec.query(view=view_name, bind_vars={'@collection': 'genes', 'value': 123}) +``` + +Get more results from a cursor: + +```py +more_results = rec.run_query(cursor_id=results['cursor_id']) +``` + +Save documents from python dictionaries: + +```py +save_results = rec.save_documents( + collection='genes', + on_duplicate='update', + docs=[ + {'_key': 'x', 'name': 'x'}, + {'_key': 'y', 'name': 'y'} + ] +) +``` + +Bulk-save documents from a file: + +```py +save_results = rec.save_documents( + collection='genes', + on_duplicate='update', + from_file='my-file-path.json' +) +``` + +Where the file contains multiple JSON documents separated by line-breaks. + ## Development Copy `.env.example` to `.env`. Start the server with `docker-compose up`. From 28da5c87e4ca17458e77e3e22ee692829917b3ce Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Thu, 1 Nov 2018 14:50:01 -0700 Subject: [PATCH 043/732] Update README.md --- api/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/README.md b/api/README.md index ded2eee2..d69ec9a6 100644 --- a/api/README.md +++ b/api/README.md @@ -147,7 +147,7 @@ Bulk-update documents by either creating, replacing, or updating. _Example_ ```sh -$ curl -X PUT http://relation_engine/api/documents?collection=genes& +$ curl -X PUT http://relation_engine/api/documents?collection=genes&on_duplicate=update ``` _Query params_ From 1afad2fd969bfa0ddad1b86bf6ec6d87dbfa3a66 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Thu, 1 Nov 2018 15:09:25 -0700 Subject: [PATCH 044/732] Reduce some code further; optimize the git puller a bit --- api/src/relation_engine_server/app.py | 7 +- api/src/relation_engine_server/docs.py | 100 ------------------ .../relation_engine_server/server_spec.json | 81 -------------- api/src/relation_engine_server/spec_loader.py | 7 +- api/src/test/test_api.py | 1 - api/start_server.sh | 1 + 6 files changed, 8 insertions(+), 189 deletions(-) delete mode 100644 api/src/relation_engine_server/docs.py delete mode 100644 api/src/relation_engine_server/server_spec.json diff --git a/api/src/relation_engine_server/app.py b/api/src/relation_engine_server/app.py index ee48e840..fa158b0d 100644 --- a/api/src/relation_engine_server/app.py +++ b/api/src/relation_engine_server/app.py @@ -5,7 +5,6 @@ import traceback from .api import api -from .docs import docs from .exceptions import MissingHeader, UnauthorizedAccess from . import arango_client @@ -15,12 +14,11 @@ app.url_map.strict_slashes = False # allow both `get /v1/` and `get /v1` app.register_blueprint(api, url_prefix='/api') -app.register_blueprint(docs, url_prefix='/docs') @app.route('/', methods=['GET']) def root(): - """Server status and link to docs.""" + """Server status.""" with open('.git/refs/heads/master', 'r') as fd: commit_hash = fd.read().strip() arangodb_status = arango_client.server_status() @@ -28,8 +26,7 @@ def root(): return flask.jsonify({ 'arangodb_status': arangodb_status, 'commit_hash': commit_hash, - 'repo_url': repo_url, - 'docs': '/docs' + 'repo_url': repo_url }) diff --git a/api/src/relation_engine_server/docs.py b/api/src/relation_engine_server/docs.py deleted file mode 100644 index 0139d46f..00000000 --- a/api/src/relation_engine_server/docs.py +++ /dev/null @@ -1,100 +0,0 @@ -"""Fetch documentation for the API.""" -import flask - -from . import schemas - -docs = flask.Blueprint('docs', __name__) - - -@docs.route('/', methods=['GET']) -def root(): - """API documentation.""" - return flask.jsonify({ - 'info': { - 'name': 'Relation Engine API', - 'description': 'Interface for updating or querying data in the KBase Relation Engine graph database.' - }, - 'api_prefix': '/api', - 'actions': { - '/views GET': { - 'description': 'Fetch view names and (optionally) their AQL source code.', - 'auth': 'public', - 'query': { - 'show_sources': { - 'type': 'boolean', - 'default': False, - 'description': 'Whether to show the AQL source code for each view.' - } - }, - 'responses': { - '200': { - 'schema': ['view'], - 'description': 'A list of views with names and (optionally) AQL source.' - }, - 'not_ok': {'schema': 'error'} - } - }, - '/query POST': { - 'description': 'Execute a view as a query against the database.', - 'auth': 'bearer', - 'query': { - 'view_name': { - 'description': 'Name of the view that we want to use for the query.', - 'type': 'string' - } - }, - 'body': { - 'description': 'Arguments for the query. These go into the bind variables in the AQL.', - 'type': 'object' - }, - 'responses': { - '200': { - 'schema': 'query_results', - 'description': 'Resulting data from running the query' - }, - 'not_ok': {'schema': 'error'} - } - }, - '/schemas GET': { - 'description': 'Fetch available schema names and optionally their JSON sources.', - 'auth': 'public', - 'query': { - 'show_sources': { - 'type': 'boolean', - 'description': 'Whether to show the JSON source for each schema.' - } - }, - 'responses': { - '200': { - 'schema': { - 'type': 'array', - 'item': {'schema': 'view'} - }, - 'description': 'Array of schema name and (optionally) schema content.' - }, - 'not_ok': {'schema': 'error'} - } - }, - '/documents PUT': { - 'description': 'Create, update, or replace documents in the database in a certain collection.', - 'auth': 'bearer', - 'query': { - 'on_duplicate': { - 'description': 'How to handle duplicate documents based on a "_key" match.', - 'type': 'string', - 'enum': ['error', 'update', 'replace', 'ignore'] - } - }, - 'responses': { - '200': {'description': 'Successful save.'}, - 'not_ok': {'schema': 'error'} - } - } - }, - 'schemas': { - 'error': schemas.error, - 'view': schemas.view, - 'query_results': schemas.query_results, - 'document_save_results': schemas.document_save_results - } - }) diff --git a/api/src/relation_engine_server/server_spec.json b/api/src/relation_engine_server/server_spec.json deleted file mode 100644 index 06847b78..00000000 --- a/api/src/relation_engine_server/server_spec.json +++ /dev/null @@ -1,81 +0,0 @@ -{ - "info": { - "name": "Relation Engine API", - "repository": "https://github.com/kbase/relation_engine_api", - "description": "Interface for updating or querying data in the KBase Relation Engine graph database." - }, - "api_prefix": "/api", - "actions": { - "/views GET": { - "description": "Fetch view names and (optionally) their AQL source code.", - "auth": "public", - "query": { - "show_sources": { - "type": "boolean", - "default": false, - "description": "Whether to show the AQL source code for each view." - } - }, - "responses": { - "200": { - "schema": ["/schemas/view"], - "description": "A list of views with names and (optionally) AQL source." - }, - "not_ok": {"schema": "/schemas/error"} - } - }, - "/query POST": { - "description": "Execute a view as a query against the database.", - "auth": "bearer", - "query": { - "view_name": { - "description": "Name of the view that we want to use for the query.", - "type": "string" - } - }, - "body": { - "description": "Arguments for the query. These go into the bind variables in the AQL.", - "type": "object" - }, - "responses": { - "200": { - "schema": "/schemas/query_results", - "description": "Resulting data from running the query" - }, - "not_ok": {"schema": "/schemas/error"} - } - }, - "/schemas GET": { - "description": "Fetch available schema names and optionally their JSON sources.", - "auth": "public", - "query": { - "show_sources": { - "type": "boolean", - "description": "Whether to show the JSON source for each schema." - } - }, - "responses": { - "200": { - "schema": ["schemas"], - "description": "Array of schema name and (optionally) schema content." - }, - "not_ok": {"schema": "error"} - } - }, - "/documents PUT": { - "description": "Create, update, or replace documents in the database in a certain collection.", - "auth": "bearer", - "query": { - "on_duplicate": { - "description": "How to handle duplicate documents based on a '_key' match.", - "type": "string", - "enum": ["error", "update", "replace", "ignore"] - } - }, - "responses": { - "200": {"description": "Successful save."}, - "not_ok": {"schema": "error"} - } - } - }, -} diff --git a/api/src/relation_engine_server/spec_loader.py b/api/src/relation_engine_server/spec_loader.py index 4ca42fec..e8414509 100644 --- a/api/src/relation_engine_server/spec_loader.py +++ b/api/src/relation_engine_server/spec_loader.py @@ -50,8 +50,11 @@ def get_schema_dicts(names): def git_pull(): """Git pull the spec repo to get any updates.""" - output = subprocess.check_output(['git', '-C', _spec_path, 'pull']) # nosec - print('git pull output', output) + output = subprocess.check_output(['git', '-C', _spec_path, 'rev-list', 'HEAD..origin/master', '--count']) # nosec + change_count = int(output.strip()) + if change_count > 0: + output = subprocess.check_output(['git', '-C', _spec_path, 'pull']) # nosec + print('git pull output', output) return output diff --git a/api/src/test/test_api.py b/api/src/test/test_api.py index 1b2d8f18..c19ac2b7 100644 --- a/api/src/test/test_api.py +++ b/api/src/test/test_api.py @@ -18,7 +18,6 @@ def test_root(self): """Test root path for api.""" resp = requests.get(url).json() self.assertEqual(resp['arangodb_status'], 'connected_authorized') - self.assertEqual(resp['docs'], '/docs') self.assertTrue(resp['commit_hash']) self.assertTrue(resp['repo_url']) diff --git a/api/start_server.sh b/api/start_server.sh index 45986d37..dafbf6d2 100644 --- a/api/start_server.sh +++ b/api/start_server.sh @@ -3,6 +3,7 @@ # Set the number of gevent workers to number of cores * 2 + 1 # See: http://docs.gunicorn.org/en/stable/design.html#how-many-workers calc_workers="$(($(nproc) * 2 + 1))" +# Use the WORKERS environment variable, if present workers=${WORKERS:-$calc_workers} gunicorn --worker-class gevent --timeout 1800 --workers $workers -b :5000 --reload src.relation_engine_server.app:app From c049d46ad0bd4630de95b88918001700dc9713b4 Mon Sep 17 00:00:00 2001 From: JamesJeffryes Date: Thu, 1 Nov 2018 18:43:54 -0500 Subject: [PATCH 045/732] Add WS object related schemas --- spec/schemas/object_hashes.json | 27 ++++++++++++++++++++ spec/schemas/users.json | 19 ++++++++++++++ spec/schemas/workspaces.json | 35 +++++++++++++++++++++++++ spec/schemas/ws_object_versions.json | 38 ++++++++++++++++++++++++++++ spec/schemas/ws_objects.json | 18 +++++++++++++ 5 files changed, 137 insertions(+) create mode 100644 spec/schemas/object_hashes.json create mode 100644 spec/schemas/users.json create mode 100644 spec/schemas/workspaces.json create mode 100644 spec/schemas/ws_object_versions.json create mode 100644 spec/schemas/ws_objects.json diff --git a/spec/schemas/object_hashes.json b/spec/schemas/object_hashes.json new file mode 100644 index 00000000..1ca8778d --- /dev/null +++ b/spec/schemas/object_hashes.json @@ -0,0 +1,27 @@ +{ + "definitions": {}, + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "version": 1, + "additionalProperties": false, + "required": [ + "_key", + "type" + ], + "properties": { + "_key": { + "type": "string", + "description": "The key is the hash", + "examples": [ + "2406642b28312b3ccbfb2e17e231e2c7" + ] + }, + "type": { + "type": "string", + "description": "The hashing algorithm used", + "examples": [ + "MD5" + ] + } + } +} \ No newline at end of file diff --git a/spec/schemas/users.json b/spec/schemas/users.json new file mode 100644 index 00000000..eec12a87 --- /dev/null +++ b/spec/schemas/users.json @@ -0,0 +1,19 @@ +{ + "definitions": {}, + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "version": 1, + "additionalProperties": false, + "required": ["_key"], + "properties": { + "_key": { + "$id": "#/properties/_key", + "type": "string", + "description": "The username for this user", + "examples": [ + "jjeffryes" + ], + "pattern": "^\\w+$" + } + } +} \ No newline at end of file diff --git a/spec/schemas/workspaces.json b/spec/schemas/workspaces.json new file mode 100644 index 00000000..132795b2 --- /dev/null +++ b/spec/schemas/workspaces.json @@ -0,0 +1,35 @@ +{ + "definitions": {}, + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "version": 1, + "additionalProperties": false, + "required": [ + "_key", + "name", + "public" + ], + "properties": { + "_key": { + "type": "string", + "description": "The workspace ID for this workspace", + "examples": [ + "35414" + ], + "pattern": "^\\d+$" + }, + "name": { + "type": "string", + "description": "The workspace name for this workspace", + "examples": [ + "jjeffryes:narrative_1534187093329" + ] + }, + "public": { + "type": "boolean", + "examples": [ + false + ] + } + } +} \ No newline at end of file diff --git a/spec/schemas/ws_object_versions.json b/spec/schemas/ws_object_versions.json new file mode 100644 index 00000000..334cb832 --- /dev/null +++ b/spec/schemas/ws_object_versions.json @@ -0,0 +1,38 @@ +{ + "definitions": {}, + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "version": 1, + "additionalProperties": false, + "required": [ + "_key", + "size", + "epoch" + ], + "properties": { + "_key": { + "type": "string", + "description": "The UPA for this data", + "examples": [ + "35414/73/1" + ], + "pattern": "^\\d+\\/\\d+\\/\\d+$" + }, + "size": { + "type": "integer", + "description": "Size in bits", + "default": 0, + "examples": [ + 8870316 + ] + }, + "epoch": { + "type": "integer", + "description": "Creation time in UTC epoch", + "default": 0, + "examples": [ + 1540402856060 + ] + } + } +} \ No newline at end of file diff --git a/spec/schemas/ws_objects.json b/spec/schemas/ws_objects.json new file mode 100644 index 00000000..006cab4b --- /dev/null +++ b/spec/schemas/ws_objects.json @@ -0,0 +1,18 @@ +{ + "definitions": {}, + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "version": 1, + "additionalProperties": false, + "required": ["_key"], + "properties": { + "_key": { + "type": "string", + "description": "The wsid/objectid for this data", + "examples": [ + "35414/73" + ], + "pattern": "^\\d+\\/\\d+$" + } + } +} \ No newline at end of file From 5d3afab5ebb99081cabeabd19333ffc64d2a6e8c Mon Sep 17 00:00:00 2001 From: JamesJeffryes Date: Thu, 1 Nov 2018 19:23:37 -0500 Subject: [PATCH 046/732] Add type related schemas --- spec/schemas/type_modules.json | 17 +++++++++++++++++ spec/schemas/type_versions.json | 17 +++++++++++++++++ spec/schemas/types.json | 17 +++++++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 spec/schemas/type_modules.json create mode 100644 spec/schemas/type_versions.json create mode 100644 spec/schemas/types.json diff --git a/spec/schemas/type_modules.json b/spec/schemas/type_modules.json new file mode 100644 index 00000000..f57350ec --- /dev/null +++ b/spec/schemas/type_modules.json @@ -0,0 +1,17 @@ +{ + "definitions": {}, + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "version": 1, + "additionalProperties": false, + "required": ["_key"], + "properties": { + "_key": { + "type": "string", + "examples": [ + "KBaseGenomes" + ], + "pattern": "^\\w+$" + } + } +} \ No newline at end of file diff --git a/spec/schemas/type_versions.json b/spec/schemas/type_versions.json new file mode 100644 index 00000000..a2ae6b3e --- /dev/null +++ b/spec/schemas/type_versions.json @@ -0,0 +1,17 @@ +{ + "definitions": {}, + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "version": 1, + "additionalProperties": false, + "required": ["_key"], + "properties": { + "_key": { + "type": "string", + "examples": [ + "KBaseGenomes.Genome‑9.0" + ], + "pattern": "^\\w+\\.\\w+-\\d+\\.\\d+$" + } + } +} \ No newline at end of file diff --git a/spec/schemas/types.json b/spec/schemas/types.json new file mode 100644 index 00000000..99f8d8b3 --- /dev/null +++ b/spec/schemas/types.json @@ -0,0 +1,17 @@ +{ + "definitions": {}, + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "version": 1, + "additionalProperties": false, + "required": ["_key"], + "properties": { + "_key": { + "type": "string", + "examples": [ + "KBaseGenomes.Genome" + ], + "pattern": "^\\w+\\.\\w+$" + } + } +} \ No newline at end of file From a7a1ca27e28aed506d2bf167691a56d63682c141 Mon Sep 17 00:00:00 2001 From: JamesJeffryes Date: Fri, 2 Nov 2018 14:03:21 -0500 Subject: [PATCH 047/732] use colons for WS delimiters --- spec/schemas/ws_object_versions.json | 4 ++-- spec/schemas/ws_objects.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/schemas/ws_object_versions.json b/spec/schemas/ws_object_versions.json index 334cb832..d7dcf959 100644 --- a/spec/schemas/ws_object_versions.json +++ b/spec/schemas/ws_object_versions.json @@ -14,9 +14,9 @@ "type": "string", "description": "The UPA for this data", "examples": [ - "35414/73/1" + "35414:73:1" ], - "pattern": "^\\d+\\/\\d+\\/\\d+$" + "pattern": "^\\d+:\\d+:\\d+$" }, "size": { "type": "integer", diff --git a/spec/schemas/ws_objects.json b/spec/schemas/ws_objects.json index 006cab4b..47db3a45 100644 --- a/spec/schemas/ws_objects.json +++ b/spec/schemas/ws_objects.json @@ -10,9 +10,9 @@ "type": "string", "description": "The wsid/objectid for this data", "examples": [ - "35414/73" + "35414:73" ], - "pattern": "^\\d+\\/\\d+$" + "pattern": "^\\d+:\\d+$" } } } \ No newline at end of file From a8acffcbd4c169356066e23698fea3c6f2fba620 Mon Sep 17 00:00:00 2001 From: JamesJeffryes Date: Mon, 5 Nov 2018 09:42:05 -0600 Subject: [PATCH 048/732] remove definitions & $id --- spec/schemas/type_modules.json | 1 - spec/schemas/type_versions.json | 1 - spec/schemas/types.json | 1 - spec/schemas/users.json | 2 -- spec/schemas/workspaces.json | 1 - spec/schemas/ws_object_versions.json | 10 ++++++++-- spec/schemas/ws_objects.json | 1 - 7 files changed, 8 insertions(+), 9 deletions(-) diff --git a/spec/schemas/type_modules.json b/spec/schemas/type_modules.json index f57350ec..2918aa05 100644 --- a/spec/schemas/type_modules.json +++ b/spec/schemas/type_modules.json @@ -1,5 +1,4 @@ { - "definitions": {}, "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "version": 1, diff --git a/spec/schemas/type_versions.json b/spec/schemas/type_versions.json index a2ae6b3e..0fa68829 100644 --- a/spec/schemas/type_versions.json +++ b/spec/schemas/type_versions.json @@ -1,5 +1,4 @@ { - "definitions": {}, "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "version": 1, diff --git a/spec/schemas/types.json b/spec/schemas/types.json index 99f8d8b3..10908751 100644 --- a/spec/schemas/types.json +++ b/spec/schemas/types.json @@ -1,5 +1,4 @@ { - "definitions": {}, "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "version": 1, diff --git a/spec/schemas/users.json b/spec/schemas/users.json index eec12a87..015bdfb7 100644 --- a/spec/schemas/users.json +++ b/spec/schemas/users.json @@ -1,5 +1,4 @@ { - "definitions": {}, "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "version": 1, @@ -7,7 +6,6 @@ "required": ["_key"], "properties": { "_key": { - "$id": "#/properties/_key", "type": "string", "description": "The username for this user", "examples": [ diff --git a/spec/schemas/workspaces.json b/spec/schemas/workspaces.json index 132795b2..73536ff5 100644 --- a/spec/schemas/workspaces.json +++ b/spec/schemas/workspaces.json @@ -1,5 +1,4 @@ { - "definitions": {}, "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "version": 1, diff --git a/spec/schemas/ws_object_versions.json b/spec/schemas/ws_object_versions.json index d7dcf959..7c211ed0 100644 --- a/spec/schemas/ws_object_versions.json +++ b/spec/schemas/ws_object_versions.json @@ -1,5 +1,4 @@ { - "definitions": {}, "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "version": 1, @@ -18,9 +17,16 @@ ], "pattern": "^\\d+:\\d+:\\d+$" }, + "name": { + "type": "string", + "description": "The workspace name for this workspace", + "examples": [ + "jjeffryes:narrative_1534187093329" + ] + }, "size": { "type": "integer", - "description": "Size in bits", + "description": "Size in bytes", "default": 0, "examples": [ 8870316 diff --git a/spec/schemas/ws_objects.json b/spec/schemas/ws_objects.json index 47db3a45..ad387aa5 100644 --- a/spec/schemas/ws_objects.json +++ b/spec/schemas/ws_objects.json @@ -1,5 +1,4 @@ { - "definitions": {}, "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "version": 1, From 2d461615f8062e76754a1824c58c9f3486f89171 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Mon, 5 Nov 2018 10:30:50 -0800 Subject: [PATCH 049/732] Rename server module; clean up a test --- api/src/relation_engine_server/auth.py | 5 +++ .../{app.py => server.py} | 0 api/src/test/test_api.py | 33 +++++++++++-------- api/start_server.sh | 2 +- 4 files changed, 26 insertions(+), 14 deletions(-) rename api/src/relation_engine_server/{app.py => server.py} (100%) diff --git a/api/src/relation_engine_server/auth.py b/api/src/relation_engine_server/auth.py index e16658e4..1f452b12 100644 --- a/api/src/relation_engine_server/auth.py +++ b/api/src/relation_engine_server/auth.py @@ -30,6 +30,11 @@ def require_auth_token(roles=[]): print('-' * 80) print(auth_resp.text) raise UnauthorizedAccess(kbase_auth_url) + print('*' * 80) + print(headers) + print(url) + print(auth_resp.text) + print('*' * 80) auth_json = auth_resp.json() if len(roles): check_roles(required=roles, given=auth_json['customroles'], auth_url=kbase_auth_url) diff --git a/api/src/relation_engine_server/app.py b/api/src/relation_engine_server/server.py similarity index 100% rename from api/src/relation_engine_server/app.py rename to api/src/relation_engine_server/server.py diff --git a/api/src/test/test_api.py b/api/src/test/test_api.py index c19ac2b7..b803fc54 100644 --- a/api/src/test/test_api.py +++ b/api/src/test/test_api.py @@ -10,6 +10,22 @@ url = 'http://web:5000' auth_token = os.environ.get('KBASE_TEST_AUTH_TOKEN', '') +headers = {'Authorization': 'Bearer ' + auth_token} +example_data = '\n'.join([ + '{"name": "x", "_key": "1"}', + '{"name": "y", "_key": "2"}', + '{"name": "z", "_key": "3"}' +]) + + +def create_docs(): + """Generic function to create a few docs -- reused in a couple places in the tests.""" + return requests.put( + url + '/api/documents', + params={'overwrite': True, 'collection': 'taxon'}, + data=example_data, + headers=headers + ).json() class TestApi(unittest.TestCase): @@ -85,21 +101,10 @@ def test_save_documents_invalid_json(self): self.assertEqual(resp['pos'], 1) self.assertEqual(resp['source_json'], '\n') - def test_save_documents(self): + def test_save_documents_and_query(self): """Test all valid cases for saving documents.""" - example_data = '\n'.join([ - '{"name": "x", "_key": "1"}', - '{"name": "y", "_key": "2"}', - '{"name": "z", "_key": "3"}' - ]) - headers = {'Authorization': 'Bearer ' + auth_token} # Create - resp = requests.put( - url + '/api/documents', - params={'overwrite': True, 'collection': 'taxon'}, - data=example_data, - headers=headers - ).json() + resp = create_docs() expected = {'created': 3, 'errors': 0, 'empty': 0, 'updated': 0, 'ignored': 0, 'error': False} self.assertEqual(resp, expected) # update on duplicate @@ -140,6 +145,8 @@ def test_save_documents(self): self.assertEqual(resp, expected) def test_query(self): + """Test a query that fetches some docs.""" + create_docs() resp = requests.post( url + '/api/query', params={'view': 'example'}, diff --git a/api/start_server.sh b/api/start_server.sh index dafbf6d2..3c24af56 100644 --- a/api/start_server.sh +++ b/api/start_server.sh @@ -6,4 +6,4 @@ calc_workers="$(($(nproc) * 2 + 1))" # Use the WORKERS environment variable, if present workers=${WORKERS:-$calc_workers} -gunicorn --worker-class gevent --timeout 1800 --workers $workers -b :5000 --reload src.relation_engine_server.app:app +gunicorn --worker-class gevent --timeout 1800 --workers $workers -b :5000 --reload src.relation_engine_server.server:app From 106679afdf08844b3ba3a33180c3b1c0a0f99c54 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Mon, 5 Nov 2018 10:37:42 -0800 Subject: [PATCH 050/732] Remove prints --- api/src/relation_engine_server/auth.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/api/src/relation_engine_server/auth.py b/api/src/relation_engine_server/auth.py index 1f452b12..e16658e4 100644 --- a/api/src/relation_engine_server/auth.py +++ b/api/src/relation_engine_server/auth.py @@ -30,11 +30,6 @@ def require_auth_token(roles=[]): print('-' * 80) print(auth_resp.text) raise UnauthorizedAccess(kbase_auth_url) - print('*' * 80) - print(headers) - print(url) - print(auth_resp.text) - print('*' * 80) auth_json = auth_resp.json() if len(roles): check_roles(required=roles, given=auth_json['customroles'], auth_url=kbase_auth_url) From effd870387876a31a4ddc90a5fab492ae46fc454 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Mon, 5 Nov 2018 10:38:27 -0800 Subject: [PATCH 051/732] Print server errors while we prototype --- api/src/relation_engine_server/server.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/api/src/relation_engine_server/server.py b/api/src/relation_engine_server/server.py index fa158b0d..b044c146 100644 --- a/api/src/relation_engine_server/server.py +++ b/api/src/relation_engine_server/server.py @@ -64,9 +64,9 @@ def server_error(err): traceback.print_exc() print('=' * 80) resp = {'error': '500 - Unexpected server error'} - if os.environ.get('FLASK_DEBUG'): - resp['error_class'] = err.__class__.__name__ - resp['error_details'] = str(err) + # if os.environ.get('FLASK_DEBUG'): TODO + resp['error_class'] = err.__class__.__name__ + resp['error_details'] = str(err) return (flask.jsonify(resp), 500) From 8b6f36b0025d98949af35ab64a0bb121b3dd6070 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Mon, 5 Nov 2018 12:07:14 -0800 Subject: [PATCH 052/732] Allow the test url to be optionally set by an env var --- api/src/test/test_api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/src/test/test_api.py b/api/src/test/test_api.py index b803fc54..5b663554 100644 --- a/api/src/test/test_api.py +++ b/api/src/test/test_api.py @@ -8,7 +8,7 @@ import json import os -url = 'http://web:5000' +url = os.environ.get('TEST_URL', 'http://web:5000') auth_token = os.environ.get('KBASE_TEST_AUTH_TOKEN', '') headers = {'Authorization': 'Bearer ' + auth_token} example_data = '\n'.join([ From 904f237a595a0f537867cbd3cd7af55371807dfb Mon Sep 17 00:00:00 2001 From: JamesJeffryes Date: Mon, 5 Nov 2018 16:03:57 -0600 Subject: [PATCH 053/732] allow nesting in spec paths --- api/src/relation_engine_server/spec_loader.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/api/src/relation_engine_server/spec_loader.py b/api/src/relation_engine_server/spec_loader.py index e8414509..76300a20 100644 --- a/api/src/relation_engine_server/spec_loader.py +++ b/api/src/relation_engine_server/spec_loader.py @@ -1,6 +1,7 @@ """ Utilities for loading views, schemas, and migrations from the spec. """ +import glob import os import json import subprocess # nosec @@ -42,7 +43,8 @@ def get_schema_dicts(names): for name in names: if name not in schema_names: raise SchemaNonexistent(name, schema_names) - schema_path = os.path.join(_spec_path, 'schemas', name + '.json') + schema_path = glob.glob(os.path.join(_spec_path, 'schemas', '**', name + '.json'), + recursive=True)[0] with open(schema_path, 'r') as fd: schemas[name] = json.loads(fd.read()) return schemas @@ -59,13 +61,8 @@ def git_pull(): def _get_file_names(dir_path, target_extension): - """Get a list of file basenames in a certain directory with a certain extension.""" - names = [] - for name in os.listdir(dir_path): - filename, extension = os.path.splitext(name) - if extension == target_extension: - names.append(filename) - return names + """Get a list of file basenames in all subdirectory of a dir_path with a certain extension.""" + return [os.path.basename(p) for p in glob.iglob(os.path.join(dir_path, '**', '*' + target_extension), recursive=True)] class ViewNonexistent(Exception): From d61845ada69c6076eb551b0b260e2ccc60f5ef77 Mon Sep 17 00:00:00 2001 From: JamesJeffryes Date: Mon, 5 Nov 2018 18:09:45 -0600 Subject: [PATCH 054/732] add app vertexes --- spec/schemas/app_module_versions.json | 53 +++++++++++++++++++++++++++ spec/schemas/app_modules.json | 16 ++++++++ spec/schemas/apps.json | 17 +++++++++ 3 files changed, 86 insertions(+) create mode 100644 spec/schemas/app_module_versions.json create mode 100644 spec/schemas/app_modules.json create mode 100644 spec/schemas/apps.json diff --git a/spec/schemas/app_module_versions.json b/spec/schemas/app_module_versions.json new file mode 100644 index 00000000..04dc9739 --- /dev/null +++ b/spec/schemas/app_module_versions.json @@ -0,0 +1,53 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "version": 1, + "additionalProperties": false, + "required": [ + "_key", + "name", + "commit", + "ver", + "code_url" + ], + "properties": { + "_key": { + "type": "string", + "examples": [ + "kb_uploadmethods:8ebb66e4f2c27bc4a9b7cddff7d7b0f27f4ee433" + ], + "description": ":", + "pattern": "^\\w+:\\w+$" + }, + "name": { + "type": "string", + "examples": [ + "kb_uploadmethods" + ], + "pattern": "^\\w+$" + }, + "commit": { + "type": "string", + "examples": [ + "8ebb66e4f2c27bc4a9b7cddff7d7b0f27f4ee433" + ], + "description": "Git commit hash", + "pattern": "^\\w+$" + }, + "ver": { + "type": "string", + "examples": [ + "1.0.13" + ], + "description": "Module semantic version", + "pattern": "^\\d+\\.\\d+\\.\\d+$" + }, + "code_url": { + "type": "string", + "examples": [ + "https://github.com/kbaseapps/kb_uploadmethods" + ], + "description": "URL of source code" + } + } +} \ No newline at end of file diff --git a/spec/schemas/app_modules.json b/spec/schemas/app_modules.json new file mode 100644 index 00000000..1f7c2df1 --- /dev/null +++ b/spec/schemas/app_modules.json @@ -0,0 +1,16 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "version": 1, + "additionalProperties": false, + "required": ["_key"], + "properties": { + "_key": { + "type": "string", + "examples": [ + "kb_uploadmethods" + ], + "pattern": "^\\w+$" + } + } +} \ No newline at end of file diff --git a/spec/schemas/apps.json b/spec/schemas/apps.json new file mode 100644 index 00000000..d2c46c40 --- /dev/null +++ b/spec/schemas/apps.json @@ -0,0 +1,17 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "version": 1, + "additionalProperties": false, + "required": ["_key"], + "properties": { + "_key": { + "type": "string", + "examples": [ + "kb_uploadmethods.import_fasta_as_assembly_from_staging" + ], + "description": ".", + "pattern": "^\\w+\\.\\w+$" + } + } +} \ No newline at end of file From 1c4ab3d0624185db363d85a05d20ef28d899c342 Mon Sep 17 00:00:00 2001 From: JamesJeffryes Date: Mon, 5 Nov 2018 18:10:11 -0600 Subject: [PATCH 055/732] remove taxon and add moddate to workspace --- spec/schemas/taxon.json | 18 ------------------ spec/schemas/workspaces.json | 9 +++++++++ 2 files changed, 9 insertions(+), 18 deletions(-) delete mode 100644 spec/schemas/taxon.json diff --git a/spec/schemas/taxon.json b/spec/schemas/taxon.json deleted file mode 100644 index 1a3181d5..00000000 --- a/spec/schemas/taxon.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema", - "description": "A taxon", - "type": "object", - "required": ["_key", "name"], - "additionalProperties": false, - "properties": { - "_key": { - "type": "string", - "description": "A 16-byte blake2b hash of the name" - }, - "name": { - "type": "string", - "description": "The taxon name.", - "example": "Porphyromonas" - } - } -} diff --git a/spec/schemas/workspaces.json b/spec/schemas/workspaces.json index 73536ff5..3451439b 100644 --- a/spec/schemas/workspaces.json +++ b/spec/schemas/workspaces.json @@ -6,6 +6,7 @@ "required": [ "_key", "name", + "moddate", "public" ], "properties": { @@ -24,6 +25,14 @@ "jjeffryes:narrative_1534187093329" ] }, + "moddate": { + "type": "string", + "description": "Date when the Workspace was last modified", + "examples": [ + "2014-04-09T19:40:25+0000" + ], + "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}$" + }, "public": { "type": "boolean", "examples": [ From 9d3fd078b1bfe3e9bac2c1903370623b3f21ce8b Mon Sep 17 00:00:00 2001 From: JamesJeffryes Date: Mon, 5 Nov 2018 18:23:54 -0600 Subject: [PATCH 056/732] add typ related edges --- spec/schemas/edges/contains.json | 25 +++++++++++++++++++++++++ spec/schemas/edges/latest_version.json | 25 +++++++++++++++++++++++++ spec/schemas/edges/owns.json | 24 ++++++++++++++++++++++++ spec/schemas/edges/version_of.json | 25 +++++++++++++++++++++++++ 4 files changed, 99 insertions(+) create mode 100644 spec/schemas/edges/contains.json create mode 100644 spec/schemas/edges/latest_version.json create mode 100644 spec/schemas/edges/owns.json create mode 100644 spec/schemas/edges/version_of.json diff --git a/spec/schemas/edges/contains.json b/spec/schemas/edges/contains.json new file mode 100644 index 00000000..d41dcf8a --- /dev/null +++ b/spec/schemas/edges/contains.json @@ -0,0 +1,25 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "version": 1, + "additionalProperties": false, + "required": ["_from", "_to"], + "properties": { + "_from": { + "type": "string", + "examples": [ + "KBaseGenomes.Genome", + "kb_uploadmethods" + ], + "description": "A Workspace Object, Module, or Type" + }, + "_to": { + "type": "string", + "examples": [ + "KBaseGenomes.Genome‑9.0", + "kb_uploadmethods:8ebb66e4f2c27bc4a9b7cddff7d7b0f27f4ee433" + ], + "description": "The versioned entity (Workspace Object, Module, or Type)" + } + } +} \ No newline at end of file diff --git a/spec/schemas/edges/latest_version.json b/spec/schemas/edges/latest_version.json new file mode 100644 index 00000000..d41dcf8a --- /dev/null +++ b/spec/schemas/edges/latest_version.json @@ -0,0 +1,25 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "version": 1, + "additionalProperties": false, + "required": ["_from", "_to"], + "properties": { + "_from": { + "type": "string", + "examples": [ + "KBaseGenomes.Genome", + "kb_uploadmethods" + ], + "description": "A Workspace Object, Module, or Type" + }, + "_to": { + "type": "string", + "examples": [ + "KBaseGenomes.Genome‑9.0", + "kb_uploadmethods:8ebb66e4f2c27bc4a9b7cddff7d7b0f27f4ee433" + ], + "description": "The versioned entity (Workspace Object, Module, or Type)" + } + } +} \ No newline at end of file diff --git a/spec/schemas/edges/owns.json b/spec/schemas/edges/owns.json new file mode 100644 index 00000000..821e3330 --- /dev/null +++ b/spec/schemas/edges/owns.json @@ -0,0 +1,24 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "version": 1, + "additionalProperties": false, + "required": ["_from", "_to"], + "properties": { + "_from": { + "type": "string", + "examples": [ + "jjeffryes" + ], + "description": "A username" + }, + "_to": { + "type": "string", + "examples": [ + "KBaseGenomes", + "35414" + ], + "description": "A Workspace or Type Module" + } + } +} \ No newline at end of file diff --git a/spec/schemas/edges/version_of.json b/spec/schemas/edges/version_of.json new file mode 100644 index 00000000..204605b8 --- /dev/null +++ b/spec/schemas/edges/version_of.json @@ -0,0 +1,25 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "version": 1, + "additionalProperties": false, + "required": ["_from", "_to"], + "properties": { + "_from": { + "type": "string", + "examples": [ + "KBaseGenomes.Genome‑9.0", + "kb_uploadmethods:8ebb66e4f2c27bc4a9b7cddff7d7b0f27f4ee433" + ], + "description": "The versioned entity (Workspace Object, Module, or Type)" + }, + "_to": { + "type": "string", + "examples": [ + "KBaseGenomes.Genome", + "kb_uploadmethods" + ], + "description": "A Workspace Object, Module, or Type" + } + } +} \ No newline at end of file From bfbcf4a8ac5880b478035103641d61b7d129c944 Mon Sep 17 00:00:00 2001 From: JamesJeffryes Date: Mon, 5 Nov 2018 18:25:08 -0600 Subject: [PATCH 057/732] move vertices --- spec/schemas/{ => vertices}/app_module_versions.json | 0 spec/schemas/{ => vertices}/app_modules.json | 0 spec/schemas/{ => vertices}/apps.json | 0 spec/schemas/{ => vertices}/object_hashes.json | 0 spec/schemas/{ => vertices}/type_modules.json | 0 spec/schemas/{ => vertices}/type_versions.json | 0 spec/schemas/{ => vertices}/types.json | 0 spec/schemas/{ => vertices}/users.json | 0 spec/schemas/{ => vertices}/workspaces.json | 0 spec/schemas/{ => vertices}/ws_object_versions.json | 0 spec/schemas/{ => vertices}/ws_objects.json | 0 11 files changed, 0 insertions(+), 0 deletions(-) rename spec/schemas/{ => vertices}/app_module_versions.json (100%) rename spec/schemas/{ => vertices}/app_modules.json (100%) rename spec/schemas/{ => vertices}/apps.json (100%) rename spec/schemas/{ => vertices}/object_hashes.json (100%) rename spec/schemas/{ => vertices}/type_modules.json (100%) rename spec/schemas/{ => vertices}/type_versions.json (100%) rename spec/schemas/{ => vertices}/types.json (100%) rename spec/schemas/{ => vertices}/users.json (100%) rename spec/schemas/{ => vertices}/workspaces.json (100%) rename spec/schemas/{ => vertices}/ws_object_versions.json (100%) rename spec/schemas/{ => vertices}/ws_objects.json (100%) diff --git a/spec/schemas/app_module_versions.json b/spec/schemas/vertices/app_module_versions.json similarity index 100% rename from spec/schemas/app_module_versions.json rename to spec/schemas/vertices/app_module_versions.json diff --git a/spec/schemas/app_modules.json b/spec/schemas/vertices/app_modules.json similarity index 100% rename from spec/schemas/app_modules.json rename to spec/schemas/vertices/app_modules.json diff --git a/spec/schemas/apps.json b/spec/schemas/vertices/apps.json similarity index 100% rename from spec/schemas/apps.json rename to spec/schemas/vertices/apps.json diff --git a/spec/schemas/object_hashes.json b/spec/schemas/vertices/object_hashes.json similarity index 100% rename from spec/schemas/object_hashes.json rename to spec/schemas/vertices/object_hashes.json diff --git a/spec/schemas/type_modules.json b/spec/schemas/vertices/type_modules.json similarity index 100% rename from spec/schemas/type_modules.json rename to spec/schemas/vertices/type_modules.json diff --git a/spec/schemas/type_versions.json b/spec/schemas/vertices/type_versions.json similarity index 100% rename from spec/schemas/type_versions.json rename to spec/schemas/vertices/type_versions.json diff --git a/spec/schemas/types.json b/spec/schemas/vertices/types.json similarity index 100% rename from spec/schemas/types.json rename to spec/schemas/vertices/types.json diff --git a/spec/schemas/users.json b/spec/schemas/vertices/users.json similarity index 100% rename from spec/schemas/users.json rename to spec/schemas/vertices/users.json diff --git a/spec/schemas/workspaces.json b/spec/schemas/vertices/workspaces.json similarity index 100% rename from spec/schemas/workspaces.json rename to spec/schemas/vertices/workspaces.json diff --git a/spec/schemas/ws_object_versions.json b/spec/schemas/vertices/ws_object_versions.json similarity index 100% rename from spec/schemas/ws_object_versions.json rename to spec/schemas/vertices/ws_object_versions.json diff --git a/spec/schemas/ws_objects.json b/spec/schemas/vertices/ws_objects.json similarity index 100% rename from spec/schemas/ws_objects.json rename to spec/schemas/vertices/ws_objects.json From 4b46b1e3b330f6241eb2eecc4cb82d20d20f0091 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Mon, 5 Nov 2018 16:56:52 -0800 Subject: [PATCH 058/732] Add example schemas for edges and vertices for testing --- spec/schemas/edges/example_edges.json | 13 +++++++++++++ spec/schemas/vertices/example_vertices.json | 15 +++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 spec/schemas/edges/example_edges.json create mode 100644 spec/schemas/vertices/example_vertices.json diff --git a/spec/schemas/edges/example_edges.json b/spec/schemas/edges/example_edges.json new file mode 100644 index 00000000..34d518c4 --- /dev/null +++ b/spec/schemas/edges/example_edges.json @@ -0,0 +1,13 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "additionalProperties": false, + "required": ["_from", "_to", "_key"], + "description": "Example edge schema for testing.", + "properties": { + "_from": {"type": "string"}, + "_to": {"type": "string"}, + "_key": {"type": "string"} + } +} + diff --git a/spec/schemas/vertices/example_vertices.json b/spec/schemas/vertices/example_vertices.json new file mode 100644 index 00000000..cb749e6b --- /dev/null +++ b/spec/schemas/vertices/example_vertices.json @@ -0,0 +1,15 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "version": 1, + "additionalProperties": false, + "required": ["_key"], + "description": "An example vertex schema for testing", + "properties": { + "_key": { + "type": "string", + "example": "123" + } + } +} + From 05cbe335359896c94de978398e19164c5e456beb Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Mon, 5 Nov 2018 17:03:00 -0800 Subject: [PATCH 059/732] Simplify a bit --- spec/schemas/edges/example_edges.json | 6 ++---- spec/schemas/vertices/example_vertices.json | 7 +------ 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/spec/schemas/edges/example_edges.json b/spec/schemas/edges/example_edges.json index 34d518c4..68a5fae7 100644 --- a/spec/schemas/edges/example_edges.json +++ b/spec/schemas/edges/example_edges.json @@ -1,13 +1,11 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", - "additionalProperties": false, - "required": ["_from", "_to", "_key"], + "required": ["_from", "_to"], "description": "Example edge schema for testing.", "properties": { "_from": {"type": "string"}, - "_to": {"type": "string"}, - "_key": {"type": "string"} + "_to": {"type": "string"} } } diff --git a/spec/schemas/vertices/example_vertices.json b/spec/schemas/vertices/example_vertices.json index cb749e6b..508751e9 100644 --- a/spec/schemas/vertices/example_vertices.json +++ b/spec/schemas/vertices/example_vertices.json @@ -1,15 +1,10 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", - "version": 1, - "additionalProperties": false, "required": ["_key"], "description": "An example vertex schema for testing", "properties": { - "_key": { - "type": "string", - "example": "123" - } + "_key": {"type": "string"} } } From c826db1f2f5f61e6bc62eaa18d2c052097ee4174 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 6 Nov 2018 10:24:30 -0800 Subject: [PATCH 060/732] Clean up spec loader and misc bits --- api/src/relation_engine_server/api.py | 64 +++++----- api/src/relation_engine_server/spec_loader.py | 110 ++++++++++-------- api/src/test/test_api.py | 54 ++++----- 3 files changed, 120 insertions(+), 108 deletions(-) diff --git a/api/src/relation_engine_server/api.py b/api/src/relation_engine_server/api.py index dca4f0fa..268e307b 100644 --- a/api/src/relation_engine_server/api.py +++ b/api/src/relation_engine_server/api.py @@ -5,9 +5,7 @@ import jsonschema from jsonschema.exceptions import ValidationError -from .auth import require_auth_token -from . import spec_loader -from . import arango_client +from . import spec_loader, arango_client, auth api = flask.Blueprint('api', __name__) @@ -18,11 +16,7 @@ def show_views(): Fetch view names and content. Auth: public """ - view_names = spec_loader.get_view_names() - resp = {'names': view_names} - if flask.request.args.get('show_source'): - resp['content'] = spec_loader.get_view_content(view_names) - return flask.jsonify(resp) + return flask.jsonify(spec_loader.get_view_names()) @api.route('/query_cursor', methods=['GET']) @@ -31,7 +25,7 @@ def run_query_cursor(): Continue fetching query results from a cursor id Auth: only kbase users (any role) """ - require_auth_token(roles=[]) + auth.require_auth_token(roles=[]) cursor_id = flask.request.args['id'] resp = arango_client.run_query(cursor_id=cursor_id) return flask.jsonify(resp) @@ -43,9 +37,9 @@ def run_query_from_view(): Run a stored view as a query against the database. Auth: only kbase users (any role) """ - require_auth_token(roles=[]) + auth.require_auth_token(roles=[]) view_name = flask.request.args['view'] - view_source = spec_loader.get_view_content([view_name])[view_name] + view_source = spec_loader.get_view(view_name) bind_vars = flask.request.json or {} # Make a request to the Arango server to run the query resp = arango_client.run_query(query_text=view_source, bind_vars=bind_vars) @@ -56,27 +50,39 @@ def run_query_from_view(): def show_schemas(): """ Fetch schema names and content. - See ./show_schemas.yaml for documentation. Auth: public """ - schema_names = spec_loader.get_schema_names() - resp = {'names': schema_names} - if flask.request.args.get('show_source'): - resp['content'] = spec_loader.get_schema_dicts(schema_names) - return flask.jsonify(resp) + return flask.jsonify(spec_loader.get_schema_names()) + + +@api.route('/schemas/', methods=['GET']) +def show_schema(name): + """ + Fetch the JSON for a single schema. + Auth: public + """ + return flask.jsonify(spec_loader.get_schema(name)) + + +@api.route('/views/', methods=['GET']) +def show_view(name): + """ + Fetch the AQL for a single view. + Auth: public + """ + return flask.Response(spec_loader.get_view(name), mimetype='text/plain') @api.route('/documents', methods=['PUT']) def save_documents(): """ Create, update, or replace many documents in a batch. - See ./save_documents.yaml for documentation. Auth: only sysadmins """ - require_auth_token(['RE_ADMIN']) - coll = flask.request.args['collection'] - query = {'collection': coll, 'type': 'documents'} - schema = spec_loader.get_schema_dicts([coll])[coll] + auth.require_auth_token(['RE_ADMIN']) + collection_name = flask.request.args['collection'] + query = {'collection': collection_name, 'type': 'documents'} + schema = spec_loader.get_schema(collection_name) if flask.request.args.get('on_duplicate'): query['onDuplicate'] = flask.request.args['on_duplicate'] if flask.request.args.get('overwrite'): @@ -120,8 +126,7 @@ def view_does_not_exist(err): """General error cases.""" resp = { 'error': str(err), - 'name': err.name, - 'available': err.available + 'name': err.name } return (flask.jsonify(resp), 400) @@ -137,14 +142,3 @@ def validation_error(err): 'schema': err.schema } return (flask.jsonify(resp), 400) - - -@api.errorhandler(spec_loader.SchemaNonexistent) -def schema_nonexistent(err): - """A schema/collection was requested but does not exist.""" - resp = { - 'error': str(err) - # 'available_schemas': err.available_schemas - # 'nonexistent_schema': err.schema_name - } - return (flask.jsonify(resp), 400) diff --git a/api/src/relation_engine_server/spec_loader.py b/api/src/relation_engine_server/spec_loader.py index 76300a20..4e422371 100644 --- a/api/src/relation_engine_server/spec_loader.py +++ b/api/src/relation_engine_server/spec_loader.py @@ -6,71 +6,88 @@ import json import subprocess # nosec -_spec_path = os.environ.get('SPEC_PATH', '/spec') +_spec_dir = os.environ.get('SPEC_PATH', '/spec') +_view_dir = os.path.join(_spec_dir, 'views') +_schema_dir = os.path.join(_spec_dir, 'schemas') +_vertex_dir = os.path.join(_schema_dir, 'vertices') +_edge_dir = os.path.join(_schema_dir, 'edges') def get_schema_names(): - """Return a list of all schema names.""" + """Return a dict of vertex and edge base names.""" git_pull() - schema_path = os.path.join(_spec_path, 'schemas') - return _get_file_names(schema_path, '.json') + return { + 'vertices': [ + _get_file_name(path) + for path in _find_paths(_vertex_dir, '*.json') + ], + 'edges': [ + _get_file_name(path) + for path in _find_paths(_edge_dir, '*.json') + ] + } def get_view_names(): - """Return a list of all view names.""" + """Return an array of all view base names.""" git_pull() - view_path = os.path.join(_spec_path, 'views') - return _get_file_names(view_path, '.aql') - - -def get_view_content(names): - """Return the AQL source code for a view.""" - views = {} - view_names = get_view_names() - for name in names: - if name not in view_names: - raise ViewNonexistent(name, view_names) - view_path = os.path.join(_spec_path, 'views', name + '.aql') - with open(view_path, 'r') as fd: - views[name] = fd.read() - return views - - -def get_schema_dicts(names): - """Return a particular JSON schema as a python dict.""" - schemas = {} - schema_names = get_schema_names() - for name in names: - if name not in schema_names: - raise SchemaNonexistent(name, schema_names) - schema_path = glob.glob(os.path.join(_spec_path, 'schemas', '**', name + '.json'), - recursive=True)[0] - with open(schema_path, 'r') as fd: - schemas[name] = json.loads(fd.read()) - return schemas + return [ + _get_file_name(path) + for path in _find_paths(_view_dir, '*.aql') + ] + + +def get_schema(name): + """Get JSON content for a specific schema. Throws an error if nonexistent.""" + git_pull() + try: + path = _find_paths(_schema_dir, name + '.json')[0] + except IndexError: + raise SchemaNonexistent(name) + with open(path, 'r', encoding='utf8') as fd: + return json.load(fd) + + +def get_view(name): + """Get AQL content for a specific view. Throws an error if nonexistent.""" + git_pull() + try: + path = _find_paths(_view_dir, name + '.aql')[0] + except IndexError: + raise ViewNonexistent(name) + with open(path, 'r', encoding='utf8') as fd: + return fd.read() def git_pull(): """Git pull the spec repo to get any updates.""" - output = subprocess.check_output(['git', '-C', _spec_path, 'rev-list', 'HEAD..origin/master', '--count']) # nosec - change_count = int(output.strip()) - if change_count > 0: - output = subprocess.check_output(['git', '-C', _spec_path, 'pull']) # nosec - print('git pull output', output) - return output + output = subprocess.check_output(['git', '-C', _spec_dir, 'fetch']) # nosec + if output: + # Pull if there were updates on fetch + subprocess.check_output(['git', '-C', _spec_dir, 'pull']) # nosec + + +def _find_paths(dir_path, file_pattern): + """ + Return all file paths from a filename pattern, starting from a parent + directory and looking in all subdirectories. + """ + pattern = os.path.join(dir_path, '**', file_pattern) + return glob.glob(pattern, recursive=True) -def _get_file_names(dir_path, target_extension): - """Get a list of file basenames in all subdirectory of a dir_path with a certain extension.""" - return [os.path.basename(p) for p in glob.iglob(os.path.join(dir_path, '**', '*' + target_extension), recursive=True)] +def _get_file_name(path): + """ + Get the file base name without extension from a file path. + """ + return os.path.splitext(os.path.basename(path))[0] class ViewNonexistent(Exception): """Requested view is not in the spec.""" - def __init__(self, name, available): + def __init__(self, name): self.name = name - self.available = available def __str__(self): return 'View does not exist.' @@ -79,9 +96,8 @@ def __str__(self): class SchemaNonexistent(Exception): """Requested schema is not in the spec.""" - def __init__(self, name, available): + def __init__(self, name): self.name = name - self.available = available def __str__(self): return 'Schema does not exist.' diff --git a/api/src/test/test_api.py b/api/src/test/test_api.py index 5b663554..2019eed3 100644 --- a/api/src/test/test_api.py +++ b/api/src/test/test_api.py @@ -22,7 +22,7 @@ def create_docs(): """Generic function to create a few docs -- reused in a couple places in the tests.""" return requests.put( url + '/api/documents', - params={'overwrite': True, 'collection': 'taxon'}, + params={'overwrite': True, 'collection': 'example_vertices'}, data=example_data, headers=headers ).json() @@ -38,22 +38,25 @@ def test_root(self): self.assertTrue(resp['repo_url']) def test_list_views(self): - resp = requests.get(url + '/api/views?show_source=1').json() - self.assertTrue(len(resp['names']) > 0) - for name in resp['names']: - self.assertTrue(resp['content'][name]) resp = requests.get(url + '/api/views').json() - self.assertTrue(len(resp['names']) > 0) - self.assertFalse(resp.get('content')) + self.assertTrue('example' in resp) + + def test_show_view(self): + resp = requests.get(url + '/api/views/example').text + self.assertTrue('Return count of documents' in resp) def test_list_schemas(self): - resp = requests.get(url + '/api/schemas?show_source=1').json() - self.assertTrue(len(resp['names']) > 0) - for name in resp['names']: - self.assertTrue(resp['content'][name]) - resp = requests.get(url + '/api/views').json() - self.assertTrue(len(resp['names']) > 0) - self.assertFalse(resp.get('content')) + resp = requests.get(url + '/api/schemas').json() + self.assertTrue('example_vertices' in resp['vertices']) + self.assertTrue('example_edges' in resp['edges']) + self.assertFalse('error' in resp) + self.assertTrue(len(resp)) + + def test_show_schema(self): + resp = requests.get(url + '/api/schemas/example_edges').text + self.assertTrue('_from' in resp) + resp = requests.get(url + '/api/schemas/example_vertices').text + self.assertTrue('_key' in resp) def test_save_documents_no_auth(self): # Missing bearer @@ -66,11 +69,11 @@ def test_save_documents_no_auth(self): ).json() self.assertTrue('Unauthorized' in resp['error']) - def test_save_documents_no_keys(self): + def test_save_documents_invalid_schema(self): """Test the case where some documents fail against their schema.""" resp = requests.put( url + '/api/documents', - params={'on_duplicate': 'ignore', 'collection': 'taxon'}, + params={'on_duplicate': 'ignore', 'collection': 'example_vertices'}, data='{"name": "x"}\n{"name": "y"}', headers={'Authorization': 'Bearer ' + auth_token} ).json() @@ -78,7 +81,7 @@ def test_save_documents_no_keys(self): self.assertEqual(resp['instance'], {'name': 'x'}) self.assertTrue(resp['schema']) self.assertEqual(resp['validator'], 'required') - self.assertEqual(resp['validator_value'], ['_key', 'name']) + self.assertEqual(resp['validator_value'], ['_key']) def test_save_documents_missing_schema(self): """Test the case where the collection/schema does not exist.""" @@ -93,7 +96,7 @@ def test_save_documents_missing_schema(self): def test_save_documents_invalid_json(self): resp = requests.put( url + '/api/documents', - params={'collection': 'taxon'}, + params={'collection': 'example_vertices'}, data='\n', headers={'Authorization': 'Bearer ' + auth_token} ).json() @@ -110,7 +113,7 @@ def test_save_documents_and_query(self): # update on duplicate resp = requests.put( url + '/api/documents', - params={'on_duplicate': 'update', 'collection': 'taxon'}, + params={'on_duplicate': 'update', 'collection': 'example_vertices'}, data=example_data, headers=headers ).json() @@ -119,7 +122,7 @@ def test_save_documents_and_query(self): # replace on duplicate resp = requests.put( url + '/api/documents', - params={'on_duplicate': 'replace', 'collection': 'taxon'}, + params={'on_duplicate': 'replace', 'collection': 'example_vertices'}, data=example_data, headers=headers ).json() @@ -128,7 +131,7 @@ def test_save_documents_and_query(self): # error on duplicate resp = requests.put( url + '/api/documents', - params={'on_duplicate': 'error', 'collection': 'taxon'}, + params={'on_duplicate': 'error', 'collection': 'example_vertices'}, data=example_data, headers=headers ).json() @@ -137,7 +140,7 @@ def test_save_documents_and_query(self): # ignore duplicates resp = requests.put( url + '/api/documents', - params={'on_duplicate': 'ignore', 'collection': 'taxon'}, + params={'on_duplicate': 'ignore', 'collection': 'example_vertices'}, data=example_data, headers=headers ).json() @@ -150,7 +153,7 @@ def test_query(self): resp = requests.post( url + '/api/query', params={'view': 'example'}, - data=json.dumps({'@collection': 'taxon'}), + data=json.dumps({'@collection': 'example_vertices'}), headers={ 'Authorization': 'Bearer ' + auth_token, 'Content-Type': 'application/json' @@ -166,7 +169,7 @@ def test_query_no_name(self): resp = requests.post( url + '/api/query', params={'view': 'nonexistent'}, - data=json.dumps({'@collection': 'taxon'}), + data=json.dumps({'@collection': 'example_vertices'}), headers={ 'Authorization': 'Bearer ' + auth_token, 'Content-Type': 'application/json' @@ -174,13 +177,12 @@ def test_query_no_name(self): ).json() self.assertEqual(resp['error'], 'View does not exist.') self.assertEqual(resp['name'], 'nonexistent') - self.assertTrue(len(resp['available']) > 0) def test_query_missing_bind_var(self): resp = requests.post( url + '/api/query', params={'view': 'example'}, - data=json.dumps({'xyz': 'taxon'}), + data=json.dumps({'xyz': 'example_vertices'}), headers={ 'Authorization': 'Bearer ' + auth_token, 'Content-Type': 'application/json' From aa952e6a9e64c8bd1fbc0bb06a3f5c1d2f6b60ca Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 6 Nov 2018 11:07:08 -0800 Subject: [PATCH 061/732] Clean up various schemas --- spec/schemas/edges/contains.json | 15 +++------------ ...{version_of.json => is_latest_version_of.json} | 7 +++---- .../schemas/edges/{owns.json => is_owner_of.json} | 3 +-- .../{latest_version.json => is_version_of.json} | 15 +++++++-------- spec/schemas/vertices/app_module_versions.json | 3 +-- spec/schemas/vertices/app_modules.json | 3 +-- spec/schemas/vertices/object_hashes.json | 3 +-- spec/schemas/vertices/type_modules.json | 3 +-- spec/schemas/vertices/type_versions.json | 3 +-- spec/schemas/vertices/types.json | 3 +-- spec/schemas/vertices/users.json | 3 +-- spec/schemas/vertices/workspaces.json | 10 +++------- spec/schemas/vertices/ws_object_versions.json | 11 +++-------- spec/schemas/vertices/ws_objects.json | 3 +-- 14 files changed, 28 insertions(+), 57 deletions(-) rename spec/schemas/edges/{version_of.json => is_latest_version_of.json} (58%) rename spec/schemas/edges/{owns.json => is_owner_of.json} (96%) rename spec/schemas/edges/{latest_version.json => is_version_of.json} (68%) diff --git a/spec/schemas/edges/contains.json b/spec/schemas/edges/contains.json index d41dcf8a..f0139d25 100644 --- a/spec/schemas/edges/contains.json +++ b/spec/schemas/edges/contains.json @@ -1,25 +1,16 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", - "version": 1, "additionalProperties": false, "required": ["_from", "_to"], "properties": { "_from": { "type": "string", - "examples": [ - "KBaseGenomes.Genome", - "kb_uploadmethods" - ], - "description": "A Workspace Object, Module, or Type" + "description": "The ID of the document that contains something else." }, "_to": { "type": "string", - "examples": [ - "KBaseGenomes.Genome‑9.0", - "kb_uploadmethods:8ebb66e4f2c27bc4a9b7cddff7d7b0f27f4ee433" - ], - "description": "The versioned entity (Workspace Object, Module, or Type)" + "description": "The ID of the document that is contained by something else." } } -} \ No newline at end of file +} diff --git a/spec/schemas/edges/version_of.json b/spec/schemas/edges/is_latest_version_of.json similarity index 58% rename from spec/schemas/edges/version_of.json rename to spec/schemas/edges/is_latest_version_of.json index 204605b8..109cbae2 100644 --- a/spec/schemas/edges/version_of.json +++ b/spec/schemas/edges/is_latest_version_of.json @@ -1,7 +1,6 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", - "version": 1, "additionalProperties": false, "required": ["_from", "_to"], "properties": { @@ -11,7 +10,7 @@ "KBaseGenomes.Genome‑9.0", "kb_uploadmethods:8ebb66e4f2c27bc4a9b7cddff7d7b0f27f4ee433" ], - "description": "The versioned entity (Workspace Object, Module, or Type)" + "description": "A versioned entity, representing the most recent version of an entity in a group (most likely a workspace object, module, or workspace type)." }, "_to": { "type": "string", @@ -19,7 +18,7 @@ "KBaseGenomes.Genome", "kb_uploadmethods" ], - "description": "A Workspace Object, Module, or Type" + "description": "The unversioned entity group, where all members of the group are different versions of something (eg. a workspace object, module, or workspace type)" } } -} \ No newline at end of file +} diff --git a/spec/schemas/edges/owns.json b/spec/schemas/edges/is_owner_of.json similarity index 96% rename from spec/schemas/edges/owns.json rename to spec/schemas/edges/is_owner_of.json index 821e3330..ca907b89 100644 --- a/spec/schemas/edges/owns.json +++ b/spec/schemas/edges/is_owner_of.json @@ -1,7 +1,6 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", - "version": 1, "additionalProperties": false, "required": ["_from", "_to"], "properties": { @@ -21,4 +20,4 @@ "description": "A Workspace or Type Module" } } -} \ No newline at end of file +} diff --git a/spec/schemas/edges/latest_version.json b/spec/schemas/edges/is_version_of.json similarity index 68% rename from spec/schemas/edges/latest_version.json rename to spec/schemas/edges/is_version_of.json index d41dcf8a..a7bd4e4d 100644 --- a/spec/schemas/edges/latest_version.json +++ b/spec/schemas/edges/is_version_of.json @@ -1,25 +1,24 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", - "version": 1, "additionalProperties": false, "required": ["_from", "_to"], "properties": { "_from": { "type": "string", "examples": [ - "KBaseGenomes.Genome", - "kb_uploadmethods" + "KBaseGenomes.Genome‑9.0", + "kb_uploadmethods:8ebb66e4f2c27bc4a9b7cddff7d7b0f27f4ee433" ], - "description": "A Workspace Object, Module, or Type" + "description": "A versioned entity (eg. a workspace object, module, or workspace type)" }, "_to": { "type": "string", "examples": [ - "KBaseGenomes.Genome‑9.0", - "kb_uploadmethods:8ebb66e4f2c27bc4a9b7cddff7d7b0f27f4ee433" + "KBaseGenomes.Genome", + "kb_uploadmethods" ], - "description": "The versioned entity (Workspace Object, Module, or Type)" + "description": "A non-versioned grouping of versioned entities (eg. a workspace object, module, or workspace type)." } } -} \ No newline at end of file +} diff --git a/spec/schemas/vertices/app_module_versions.json b/spec/schemas/vertices/app_module_versions.json index 04dc9739..46fdec40 100644 --- a/spec/schemas/vertices/app_module_versions.json +++ b/spec/schemas/vertices/app_module_versions.json @@ -1,7 +1,6 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", - "version": 1, "additionalProperties": false, "required": [ "_key", @@ -50,4 +49,4 @@ "description": "URL of source code" } } -} \ No newline at end of file +} diff --git a/spec/schemas/vertices/app_modules.json b/spec/schemas/vertices/app_modules.json index 1f7c2df1..94989fd4 100644 --- a/spec/schemas/vertices/app_modules.json +++ b/spec/schemas/vertices/app_modules.json @@ -1,7 +1,6 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", - "version": 1, "additionalProperties": false, "required": ["_key"], "properties": { @@ -13,4 +12,4 @@ "pattern": "^\\w+$" } } -} \ No newline at end of file +} diff --git a/spec/schemas/vertices/object_hashes.json b/spec/schemas/vertices/object_hashes.json index 1ca8778d..075a5242 100644 --- a/spec/schemas/vertices/object_hashes.json +++ b/spec/schemas/vertices/object_hashes.json @@ -2,7 +2,6 @@ "definitions": {}, "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", - "version": 1, "additionalProperties": false, "required": [ "_key", @@ -24,4 +23,4 @@ ] } } -} \ No newline at end of file +} diff --git a/spec/schemas/vertices/type_modules.json b/spec/schemas/vertices/type_modules.json index 2918aa05..bc33b4f8 100644 --- a/spec/schemas/vertices/type_modules.json +++ b/spec/schemas/vertices/type_modules.json @@ -1,7 +1,6 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", - "version": 1, "additionalProperties": false, "required": ["_key"], "properties": { @@ -13,4 +12,4 @@ "pattern": "^\\w+$" } } -} \ No newline at end of file +} diff --git a/spec/schemas/vertices/type_versions.json b/spec/schemas/vertices/type_versions.json index 0fa68829..86b894d1 100644 --- a/spec/schemas/vertices/type_versions.json +++ b/spec/schemas/vertices/type_versions.json @@ -1,7 +1,6 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", - "version": 1, "additionalProperties": false, "required": ["_key"], "properties": { @@ -13,4 +12,4 @@ "pattern": "^\\w+\\.\\w+-\\d+\\.\\d+$" } } -} \ No newline at end of file +} diff --git a/spec/schemas/vertices/types.json b/spec/schemas/vertices/types.json index 10908751..d2d5d183 100644 --- a/spec/schemas/vertices/types.json +++ b/spec/schemas/vertices/types.json @@ -1,7 +1,6 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", - "version": 1, "additionalProperties": false, "required": ["_key"], "properties": { @@ -13,4 +12,4 @@ "pattern": "^\\w+\\.\\w+$" } } -} \ No newline at end of file +} diff --git a/spec/schemas/vertices/users.json b/spec/schemas/vertices/users.json index 015bdfb7..e59b8173 100644 --- a/spec/schemas/vertices/users.json +++ b/spec/schemas/vertices/users.json @@ -1,7 +1,6 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", - "version": 1, "additionalProperties": false, "required": ["_key"], "properties": { @@ -14,4 +13,4 @@ "pattern": "^\\w+$" } } -} \ No newline at end of file +} diff --git a/spec/schemas/vertices/workspaces.json b/spec/schemas/vertices/workspaces.json index 3451439b..e7129038 100644 --- a/spec/schemas/vertices/workspaces.json +++ b/spec/schemas/vertices/workspaces.json @@ -1,7 +1,6 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", - "version": 1, "additionalProperties": false, "required": [ "_key", @@ -31,13 +30,10 @@ "examples": [ "2014-04-09T19:40:25+0000" ], - "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}$" + "format": "date-time" }, "public": { - "type": "boolean", - "examples": [ - false - ] + "type": "boolean" } } -} \ No newline at end of file +} diff --git a/spec/schemas/vertices/ws_object_versions.json b/spec/schemas/vertices/ws_object_versions.json index 7c211ed0..34f1e4d9 100644 --- a/spec/schemas/vertices/ws_object_versions.json +++ b/spec/schemas/vertices/ws_object_versions.json @@ -1,7 +1,6 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", - "version": 1, "additionalProperties": false, "required": [ "_key", @@ -28,17 +27,13 @@ "type": "integer", "description": "Size in bytes", "default": 0, - "examples": [ - 8870316 - ] + "minimum": 0 }, "epoch": { "type": "integer", "description": "Creation time in UTC epoch", "default": 0, - "examples": [ - 1540402856060 - ] + "minimum": 0 } } -} \ No newline at end of file +} diff --git a/spec/schemas/vertices/ws_objects.json b/spec/schemas/vertices/ws_objects.json index ad387aa5..9f9a144d 100644 --- a/spec/schemas/vertices/ws_objects.json +++ b/spec/schemas/vertices/ws_objects.json @@ -1,7 +1,6 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", - "version": 1, "additionalProperties": false, "required": ["_key"], "properties": { @@ -14,4 +13,4 @@ "pattern": "^\\d+:\\d+$" } } -} \ No newline at end of file +} From a970662a7e1718fcf767910490ecb5788b96d9e5 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 6 Nov 2018 14:16:11 -0800 Subject: [PATCH 062/732] Update readme to reflect the latest API --- api/README.md | 126 +++++++++++++++++++++++++++++++------------------- 1 file changed, 79 insertions(+), 47 deletions(-) diff --git a/api/README.md b/api/README.md index d69ec9a6..12081c07 100644 --- a/api/README.md +++ b/api/README.md @@ -2,8 +2,6 @@ A simple API that allows KBase community developers to interact with the Relation Engine graph database. You can run stored queries or do bulk updates on documents. -View the root path of the running server in your browser to get the Swagger API interface. - ## HTTP API ### GET / @@ -12,64 +10,77 @@ Returns server status info ### GET /api/views -Return a list of view names and optionally the AQL source code for each. +Return a list of view names. -_Example_ +_Example request_ ```sh -$ curl -X GET http://relation_engine/api/views?show_source=1 +$ curl -X GET http://relation_engine/api/views ``` -_Query params_ -* `show_source` - optional - boolean - whether to show the full AQL source for each view +_Example response_ -_Response JSON schema_ +```json +['example_view1', 'example_view1'] +``` + +### GET /api/schemas + +Fetch the registered schema names. + +_Example request_ + +```sh +$ curl -X GET http://relation_engine/api/schemas +``` + +_Example response_ ```json -{ "type": "object", - "properties": { - "names": { - "type": "array", - "item": "string", - "description": "Array of view names" - }, - "content": { - "type": "object", - "description": "An object where keys are view names and properties are AQL source." - } - } +{ + 'vertices': ['vertex_examples1', 'vertex_examples2'], + 'edges': ['edge_example1', edge_example2'] } ``` -The `"content"` property is returned only if the `show_source` query parameter is truthy. +### GET /api/views/ -### GET /api/schemas +Get the AQL source code for a view -Return a list of schema names and optionall the JSON schema source for each. +_Example request_ -_Example_ +```sh +$ curl http://relation_engine/api/views/example_view1 +``` + +Response has mimetype of text/plain + +_Example response_ + +```json +// This is some AQL source code + +for x in @@collection + return x +``` + +### GET /api/schemas/ + +Get the JSON source for a registered schema by name. + +_Example request_ ```sh -$ curl -X GET http://relation_engine/api/schemas?show_source=1 +$ curl http://relation_engine/api/schemas/vertex_examples1 ``` -_Query params_ -* `show_source` - optional - boolean - whether to show the full JSON source for each schema +_Example response_ -_Response JSON schema_ ```json -{ "type": "object", - "properties": { - "names": { - "type": "array", - "item": "string", - "description": "Array of schema names" - }, - "content": { - "type": "object", - "description": "An object where keys are schema names and properties are JSON schemas." - } - } +{ + "type": "object", + "required": ["_key"], + "properties": {"_key": {"type": "string"}} } ``` @@ -77,10 +88,10 @@ _Response JSON schema_ Run a new query using a view. -_Example_ +_Example rquest_ ```sh -$ curl -X -d '{"argument": "value"}' POST http://relation_engine/api/query?view=example +$ curl -X POST -d '{"argument": "value"}' http://relation_engine/api/query?view=example ``` _Query params_ @@ -94,6 +105,18 @@ The request body should be a JSON object of all bind variables for the query. An { "@collection": "collection_name", "value": "my_value"} ``` +_Example response_ + +```json +{ + "results": [..], + "count": 100, + "has_more": true, + "cursor_id": 123, + "stats": {..} +} +``` + _Response JSON schema_ ```json @@ -125,18 +148,19 @@ _Response JSON schema_ Results are limited to 100 items. To continue fetching additional results, use the `cursor_id` below: -### GET /query_cursor +### GET /cursor -Fetch more results from existing query results using a cursor ID +Fetch more results after an initial query using a cursor ID _Example_ ```sh -$ curl -X GET http://relation_engine/api/query_cursor?id=123123123 +$ curl http://relation_engine/api/cursor?id=123123123 ``` _Query params_ -* `id` - required - string - cursor ID as found in the query results object above when `has_more` is true. + +* `id` - required - string - cursor ID as found in the query results object when `has_more` is true. The response JSON will match the same JSON schema as the one for the response under `POST /query` @@ -152,7 +176,7 @@ $ curl -X PUT http://relation_engine/api/documents?collection=genes&on_duplicate _Query params_ * `collection` - required - string - name of the collection that we want to bulk-import into. -* `on_duplicate` - optional - "replace", "update", "ignore", "error" - Action to take when we are saving a duplicate document by matching `_key`. "replace" replaces the whole document. "update" merges in the new values. "ignore" takes no action. "error" cancels the entire transaction. +* `on_duplicate` - optional - "replace", "update", "ignore", "error" - Action to take when we find a duplicate document by `_key`. "replace" replaces the whole document. "update" merges in the new values. "ignore" takes no action. "error" cancels the entire transaction. * `overwrite` - optional - boolean - whether to overwrite the whole collection (that is, delete all documents currently in the collection before creating the documents you provide) _Request body_ @@ -164,6 +188,12 @@ The request body should be a series of JSON documents separated by line-breaks. {"_key": "2", "name": "y"} ``` +_Example response_ + +```json +{"created": 3, "errors": 2, "empty": 0, "updated": 0, "ignored": 0, "error": false} +``` + _Response JSON schema_ ```json @@ -199,6 +229,8 @@ _Response JSON schema_ ## Python client API +> NOTE: Work in progress -- this is not yet available + A python client is provided and published on anaconda, installable via pip or conda: ```sh From 34e2f0cb3bbaf4f9399dfda69ec2e6a45617e344 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 6 Nov 2018 14:16:20 -0800 Subject: [PATCH 063/732] Change /query_cursor endpoint to /cursor --- api/src/relation_engine_server/api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/src/relation_engine_server/api.py b/api/src/relation_engine_server/api.py index 268e307b..db51318f 100644 --- a/api/src/relation_engine_server/api.py +++ b/api/src/relation_engine_server/api.py @@ -19,7 +19,7 @@ def show_views(): return flask.jsonify(spec_loader.get_view_names()) -@api.route('/query_cursor', methods=['GET']) +@api.route('/cursor', methods=['GET']) def run_query_cursor(): """ Continue fetching query results from a cursor id From fb76846f7def6f770fca241e83bfa746e054009e Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 6 Nov 2018 14:57:12 -0800 Subject: [PATCH 064/732] Fix quotes in docs --- api/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/api/README.md b/api/README.md index 12081c07..82dc210f 100644 --- a/api/README.md +++ b/api/README.md @@ -21,7 +21,7 @@ $ curl -X GET http://relation_engine/api/views _Example response_ ```json -['example_view1', 'example_view1'] +["example_view1", "example_view1"] ``` ### GET /api/schemas @@ -38,8 +38,8 @@ _Example response_ ```json { - 'vertices': ['vertex_examples1', 'vertex_examples2'], - 'edges': ['edge_example1', edge_example2'] + "vertices": ["vertex_examples1", "vertex_examples2"], + "edges": ["edge_example1", "edge_example2"] } ``` From 8027df7cab61d16a80fdc81575243202947f24e1 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 6 Nov 2018 15:34:55 -0800 Subject: [PATCH 065/732] Add some validators on the schemas/views with a travis config --- spec/.travis.yaml | 5 +++ spec/Makefile | 4 ++- spec/test/__init__.py | 0 spec/test/tox.ini | 2 ++ spec/test/validate.py | 79 +++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 spec/.travis.yaml create mode 100644 spec/test/__init__.py create mode 100644 spec/test/tox.ini create mode 100644 spec/test/validate.py diff --git a/spec/.travis.yaml b/spec/.travis.yaml new file mode 100644 index 00000000..c91a8f8c --- /dev/null +++ b/spec/.travis.yaml @@ -0,0 +1,5 @@ +language: python +python: +- '3.7' +script: +- make test diff --git a/spec/Makefile b/spec/Makefile index 81bd78a3..91f35b41 100644 --- a/spec/Makefile +++ b/spec/Makefile @@ -1,5 +1,7 @@ +.PHONY: test + test: - echo "TODO run all python tests in ./src/test against the test server" + python test/validate.py test-server: echo "TODO run a single-node arango database server with pre-loaded test data" diff --git a/spec/test/__init__.py b/spec/test/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/spec/test/tox.ini b/spec/test/tox.ini new file mode 100644 index 00000000..6deafc26 --- /dev/null +++ b/spec/test/tox.ini @@ -0,0 +1,2 @@ +[flake8] +max-line-length = 120 diff --git a/spec/test/validate.py b/spec/test/validate.py new file mode 100644 index 00000000..8bec887d --- /dev/null +++ b/spec/test/validate.py @@ -0,0 +1,79 @@ +""" +Validate everything in this repo, such as syntax, structure, etc. +""" +import re +import os +import glob +import json +import jsonschema +from jsonschema.exceptions import ValidationError + + +def validate_json_schemas(): + """Validate the syntax of all the JSON schemas.""" + print('Validating JSON schemas..') + names = {} + for path in glob.iglob('schemas/**/*.json', recursive=True): + name = os.path.basename(path) + # Make sure collection is lower snake case + if not re.match(r'^[a-z_]+.json$', name): + print('Name must be lowercase, alphabetical, with underscores in ' + path) + exit(1) + # Check for any duplicate schema names + if names.get(name): + print('Duplicate schemas for name ' + name) + exit(1) + else: + names[name] = True + # Load and parse the schema data as a python dict + with open(path, 'r') as fd: + try: + schema = json.load(fd) + except Exception as err: + print('=' * 80) + print('Unable to parse json in ' + path) + print(str(err)) + exit(1) + # Make sure it can be used as a JSON schema + try: + jsonschema.validate({}, schema) + except ValidationError: + pass + except Exception as err: + print('=' * 80) + print('Unable to load schema in ' + path) + print(str(err)) + exit(1) + # All schemas must be object types + if schema['type'] != 'object': + print('Schemas must be an object. Schema in %s is not an object.' % path) + exit(1) + required = schema.get('required', []) + # Edges must require _from and _to while vertices must require _key + if '/edges/' in path and ('_from' not in required or '_to' not in required): + print('Edge schemas must require _from and _to attributes in ' + path) + exit(1) + elif '/vertices/' in path and '_key' not in required: + print('Vertex schemas must require the _key attribute in ' + path) + exit(1) + print('..all valid.') + + +def validate_aql_syntax(): + """Validate the syntax of all the queries.""" + # TODO check AQL syntax. Unsure how to do this without connecting to a running arango server :/ + print('Validating AQL queries..') + names = {} + for path in glob.iglob('views/**/*.aql', recursive=True): + name = os.path.basename(path) + if names.get(name): + print('Duplicate queries named ' + name) + exit(1) + else: + names[name] = True + print('..all valid.') + + +if __name__ == '__main__': + validate_json_schemas() + validate_aql_syntax() From a11caa6617a195d36b49435b1617b9be90ec1512 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 6 Nov 2018 16:22:32 -0800 Subject: [PATCH 066/732] Dont git pull on every spec load --- api/src/relation_engine_server/api.py | 9 +++++++++ api/src/relation_engine_server/spec_loader.py | 5 +---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/api/src/relation_engine_server/api.py b/api/src/relation_engine_server/api.py index db51318f..cb7c27d2 100644 --- a/api/src/relation_engine_server/api.py +++ b/api/src/relation_engine_server/api.py @@ -73,6 +73,15 @@ def show_view(name): return flask.Response(spec_loader.get_view(name), mimetype='text/plain') +@api.route('/refresh_specs', methods=['GET']) +def refresh_specs(): + """ + Manually pull from the spec git repo to get updates. + """ + updates = spec_loader.git_pull() + return flask.jsonify({"updates": updates}) + + @api.route('/documents', methods=['PUT']) def save_documents(): """ diff --git a/api/src/relation_engine_server/spec_loader.py b/api/src/relation_engine_server/spec_loader.py index 4e422371..ba710b91 100644 --- a/api/src/relation_engine_server/spec_loader.py +++ b/api/src/relation_engine_server/spec_loader.py @@ -15,7 +15,6 @@ def get_schema_names(): """Return a dict of vertex and edge base names.""" - git_pull() return { 'vertices': [ _get_file_name(path) @@ -30,7 +29,6 @@ def get_schema_names(): def get_view_names(): """Return an array of all view base names.""" - git_pull() return [ _get_file_name(path) for path in _find_paths(_view_dir, '*.aql') @@ -39,7 +37,6 @@ def get_view_names(): def get_schema(name): """Get JSON content for a specific schema. Throws an error if nonexistent.""" - git_pull() try: path = _find_paths(_schema_dir, name + '.json')[0] except IndexError: @@ -50,7 +47,6 @@ def get_schema(name): def get_view(name): """Get AQL content for a specific view. Throws an error if nonexistent.""" - git_pull() try: path = _find_paths(_view_dir, name + '.aql')[0] except IndexError: @@ -65,6 +61,7 @@ def git_pull(): if output: # Pull if there were updates on fetch subprocess.check_output(['git', '-C', _spec_dir, 'pull']) # nosec + return bool(output) def _find_paths(dir_path, file_pattern): From 2c4b5dde28270801aab13011ad00fccb3f50aa2c Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 7 Nov 2018 10:50:17 -0800 Subject: [PATCH 067/732] Initialize collections when pulling new schemas --- .../relation_engine_server/arango_client.py | 33 +++++++++++++++++++ api/src/relation_engine_server/spec_loader.py | 4 +++ 2 files changed, 37 insertions(+) diff --git a/api/src/relation_engine_server/arango_client.py b/api/src/relation_engine_server/arango_client.py index 4182764d..fea186cf 100644 --- a/api/src/relation_engine_server/arango_client.py +++ b/api/src/relation_engine_server/arango_client.py @@ -57,6 +57,39 @@ def run_query(query_text=None, cursor_id=None, bind_vars={}): } +def init_collections(schemas): + """Initialize any uninitialized collections in the database from a set of schemas.""" + edges = schemas['edges'] + vertices = schemas['vertices'] + for edge_name in edges: + create_collection(edge_name, is_edge=True) + for vertex_name in vertices: + create_collection(vertex_name, is_edge=False) + + +def create_collection(name, is_edge): + url = db_url + '/_api/collection' + # collection types: + # 2 is a document collection + # 3 is an edge collection + collection_type = 3 if is_edge else 2 + resp = requests.post( + url, + data=json.dumps({ + 'keyOptions': { + 'allowUserKeys': True, + }, + 'name': name, + 'type': collection_type + }), + auth=(db_user, db_pass) + ).json() + if resp['error']: + if 'duplicate' not in resp['errorMessage']: + # Unable to create a collection + raise Exception(resp.text) + + def bulk_import(file_path, query): """Make a generic arango post request.""" with open(file_path, 'rb') as file_desc: diff --git a/api/src/relation_engine_server/spec_loader.py b/api/src/relation_engine_server/spec_loader.py index ba710b91..3fca2003 100644 --- a/api/src/relation_engine_server/spec_loader.py +++ b/api/src/relation_engine_server/spec_loader.py @@ -6,6 +6,8 @@ import json import subprocess # nosec +from . import arango_client + _spec_dir = os.environ.get('SPEC_PATH', '/spec') _view_dir = os.path.join(_spec_dir, 'views') _schema_dir = os.path.join(_spec_dir, 'schemas') @@ -61,6 +63,8 @@ def git_pull(): if output: # Pull if there were updates on fetch subprocess.check_output(['git', '-C', _spec_dir, 'pull']) # nosec + # Initialize any collections + arango_client.init_collections(get_schema_names()) return bool(output) From 06804807be2a07629e01f94a7cbe6387b35daef8 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 7 Nov 2018 10:53:34 -0800 Subject: [PATCH 068/732] Clean up some code --- .../relation_engine_server/arango_client.py | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/api/src/relation_engine_server/arango_client.py b/api/src/relation_engine_server/arango_client.py index fea186cf..4a4f8b7f 100644 --- a/api/src/relation_engine_server/arango_client.py +++ b/api/src/relation_engine_server/arango_client.py @@ -68,26 +68,25 @@ def init_collections(schemas): def create_collection(name, is_edge): + """ + Create a single collection by name using some basic defaults. + We ignore duplicates. For any other server error, an exception is thrown. + """ url = db_url + '/_api/collection' # collection types: # 2 is a document collection # 3 is an edge collection collection_type = 3 if is_edge else 2 - resp = requests.post( - url, - data=json.dumps({ - 'keyOptions': { - 'allowUserKeys': True, - }, - 'name': name, - 'type': collection_type - }), - auth=(db_user, db_pass) - ).json() + data = json.dumps({ + 'keyOptions': {'allowUserKeys': True}, + 'name': name, + 'type': collection_type + }) + resp = requests.post(url, data, auth=(db_user, db_pass)) if resp['error']: if 'duplicate' not in resp['errorMessage']: # Unable to create a collection - raise Exception(resp.text) + raise ArangoServerError(resp.text) def bulk_import(file_path, query): From e67cc7a15720ca9cf5da726652551b30421ab2be Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 7 Nov 2018 11:09:15 -0800 Subject: [PATCH 069/732] Add a couple very basic views --- .../{example.aql => count_documents_in_collection.aql} | 1 + spec/views/list_all_documents_in_collection.aql | 6 ++++++ 2 files changed, 7 insertions(+) rename spec/views/{example.aql => count_documents_in_collection.aql} (99%) create mode 100644 spec/views/list_all_documents_in_collection.aql diff --git a/spec/views/example.aql b/spec/views/count_documents_in_collection.aql similarity index 99% rename from spec/views/example.aql rename to spec/views/count_documents_in_collection.aql index fc862a0d..5d86c46e 100644 --- a/spec/views/example.aql +++ b/spec/views/count_documents_in_collection.aql @@ -5,3 +5,4 @@ for v in @@collection collect with count into length return length + diff --git a/spec/views/list_all_documents_in_collection.aql b/spec/views/list_all_documents_in_collection.aql new file mode 100644 index 00000000..bc0969a3 --- /dev/null +++ b/spec/views/list_all_documents_in_collection.aql @@ -0,0 +1,6 @@ +// Return *all* full documents in a collection +// Args: +// collection - name of collection to count docs + +for v in @@collection + return v From 4d2c00cae5cc91b2b36732edcb80ea298e1fe2b9 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 7 Nov 2018 14:51:08 -0800 Subject: [PATCH 070/732] Add tests and clean up some logic around cursors and queries --- api/README.md | 27 ++--- api/src/relation_engine_server/api.py | 36 +++---- .../relation_engine_server/arango_client.py | 11 ++- api/src/relation_engine_server/spec_loader.py | 12 +-- api/src/test/test_api.py | 99 +++++++++++++------ 5 files changed, 103 insertions(+), 82 deletions(-) diff --git a/api/README.md b/api/README.md index 82dc210f..ca6a6e5f 100644 --- a/api/README.md +++ b/api/README.md @@ -84,9 +84,9 @@ _Example response_ } ``` -### POST /query +### POST /query_results -Run a new query using a view. +Run a query using a view or a cursor ID. Semantically, this is a GET, but it's a POST to allow better support for passing JSON in the request body (eg. Postman doesn't allow request body data in get requests) _Example rquest_ @@ -96,15 +96,20 @@ $ curl -X POST -d '{"argument": "value"}' http://relation_engine/api/query?view= _Query params_ * `view` - required - string - name of the view to run as a query against the database +* `cursor_id` - required - string - ID of a cursor that was returned from a previous query with >100 results + +Pass one of `view` or `cursor_id` -- not both. _Request body_ -The request body should be a JSON object of all bind variables for the query. Anything with a `@name` in the query source should have an entry in the object here. For example, for a query with bind vars for `@@collection` and `@value`, you will need to pass: +When running a new query with a view, the request body should be a JSON object of all bind variables for the query. Anything with a `@name` in the query source should have an entry in the object here. For example, a query with bind vars for `@@collection` and `@value`, you will need to pass: ```json { "@collection": "collection_name", "value": "my_value"} ``` +If you are using a cursor, the request body should be blank. + _Example response_ ```json @@ -148,22 +153,6 @@ _Response JSON schema_ Results are limited to 100 items. To continue fetching additional results, use the `cursor_id` below: -### GET /cursor - -Fetch more results after an initial query using a cursor ID - -_Example_ - -```sh -$ curl http://relation_engine/api/cursor?id=123123123 -``` - -_Query params_ - -* `id` - required - string - cursor ID as found in the query results object when `has_more` is true. - -The response JSON will match the same JSON schema as the one for the response under `POST /query` - ### PUT /documents Bulk-update documents by either creating, replacing, or updating. diff --git a/api/src/relation_engine_server/api.py b/api/src/relation_engine_server/api.py index cb7c27d2..324b1927 100644 --- a/api/src/relation_engine_server/api.py +++ b/api/src/relation_engine_server/api.py @@ -19,30 +19,24 @@ def show_views(): return flask.jsonify(spec_loader.get_view_names()) -@api.route('/cursor', methods=['GET']) -def run_query_cursor(): - """ - Continue fetching query results from a cursor id - Auth: only kbase users (any role) - """ - auth.require_auth_token(roles=[]) - cursor_id = flask.request.args['id'] - resp = arango_client.run_query(cursor_id=cursor_id) - return flask.jsonify(resp) - - -@api.route('query', methods=['POST']) -def run_query_from_view(): +@api.route('/query_results', methods=['POST']) +def run_query(): """ Run a stored view as a query against the database. Auth: only kbase users (any role) """ auth.require_auth_token(roles=[]) - view_name = flask.request.args['view'] - view_source = spec_loader.get_view(view_name) - bind_vars = flask.request.json or {} - # Make a request to the Arango server to run the query - resp = arango_client.run_query(query_text=view_source, bind_vars=bind_vars) + if 'view' in flask.request.args: + view_name = flask.request.args['view'] + view_source = spec_loader.get_view(view_name) + bind_vars = flask.request.json or {} + resp = arango_client.run_query(query_text=view_source, bind_vars=bind_vars) + elif 'cursor_id' in flask.request.args: + cursor_id = flask.request.args['cursor_id'] + resp = arango_client.run_query(cursor_id=cursor_id) + else: + resp = {'error': 'Pass in a view or a cursor_id'} + return (flask.jsonify(resp), 400) return flask.jsonify(resp) @@ -78,8 +72,8 @@ def refresh_specs(): """ Manually pull from the spec git repo to get updates. """ - updates = spec_loader.git_pull() - return flask.jsonify({"updates": updates}) + git_output = spec_loader.git_pull() + return flask.jsonify({"updates": git_output}) @api.route('/documents', methods=['PUT']) diff --git a/api/src/relation_engine_server/arango_client.py b/api/src/relation_engine_server/arango_client.py index 4a4f8b7f..56303086 100644 --- a/api/src/relation_engine_server/arango_client.py +++ b/api/src/relation_engine_server/arango_client.py @@ -29,16 +29,19 @@ def run_query(query_text=None, cursor_id=None, bind_vars={}): url = db_url + '/_api/cursor' req_json = { 'batchSize': 100, - 'memoryLimit': 16000000000, # 16gb - 'count': True, + 'memoryLimit': 16000000000 # 16gb } if cursor_id: + method = 'PUT' url += '/' + cursor_id else: + method = 'POST' + req_json['count'] = True req_json['bindVars'] = bind_vars req_json['query'] = query_text - resp = requests.post( + resp = requests.request( + method, url, data=json.dumps(req_json), auth=(db_user, db_pass) @@ -82,7 +85,7 @@ def create_collection(name, is_edge): 'name': name, 'type': collection_type }) - resp = requests.post(url, data, auth=(db_user, db_pass)) + resp = requests.post(url, data, auth=(db_user, db_pass)).json() if resp['error']: if 'duplicate' not in resp['errorMessage']: # Unable to create a collection diff --git a/api/src/relation_engine_server/spec_loader.py b/api/src/relation_engine_server/spec_loader.py index 3fca2003..b81345ab 100644 --- a/api/src/relation_engine_server/spec_loader.py +++ b/api/src/relation_engine_server/spec_loader.py @@ -59,13 +59,11 @@ def get_view(name): def git_pull(): """Git pull the spec repo to get any updates.""" - output = subprocess.check_output(['git', '-C', _spec_dir, 'fetch']) # nosec - if output: - # Pull if there were updates on fetch - subprocess.check_output(['git', '-C', _spec_dir, 'pull']) # nosec - # Initialize any collections - arango_client.init_collections(get_schema_names()) - return bool(output) + # Pull if there were updates on fetch + output = subprocess.check_output(['git', '-C', _spec_dir, 'pull']) # nosec + # Initialize any collections + arango_client.init_collections(get_schema_names()) + return output def _find_paths(dir_path, file_pattern): diff --git a/api/src/test/test_api.py b/api/src/test/test_api.py index 2019eed3..d9ce8601 100644 --- a/api/src/test/test_api.py +++ b/api/src/test/test_api.py @@ -11,19 +11,21 @@ url = os.environ.get('TEST_URL', 'http://web:5000') auth_token = os.environ.get('KBASE_TEST_AUTH_TOKEN', '') headers = {'Authorization': 'Bearer ' + auth_token} -example_data = '\n'.join([ - '{"name": "x", "_key": "1"}', - '{"name": "y", "_key": "2"}', - '{"name": "z", "_key": "3"}' -]) -def create_docs(): - """Generic function to create a few docs -- reused in a couple places in the tests.""" +def create_test_docs(count): + """Produce some test documents.""" + def doc(i): + return '{"name": "name", "_key": "%s"}' % i + return '\n'.join(doc(i) for i in range(0, count)) + + +def save_test_docs(count): + docs = create_test_docs(count) return requests.put( url + '/api/documents', params={'overwrite': True, 'collection': 'example_vertices'}, - data=example_data, + data=docs, headers=headers ).json() @@ -39,10 +41,10 @@ def test_root(self): def test_list_views(self): resp = requests.get(url + '/api/views').json() - self.assertTrue('example' in resp) + self.assertTrue('list_all_documents_in_collection' in resp) def test_show_view(self): - resp = requests.get(url + '/api/views/example').text + resp = requests.get(url + '/api/views/count_documents_in_collection').text self.assertTrue('Return count of documents' in resp) def test_list_schemas(self): @@ -104,70 +106,105 @@ def test_save_documents_invalid_json(self): self.assertEqual(resp['pos'], 1) self.assertEqual(resp['source_json'], '\n') - def test_save_documents_and_query(self): + def test_create_documents(self): """Test all valid cases for saving documents.""" # Create - resp = create_docs() + resp = save_test_docs(3) expected = {'created': 3, 'errors': 0, 'empty': 0, 'updated': 0, 'ignored': 0, 'error': False} self.assertEqual(resp, expected) - # update on duplicate + + def test_update_documents(self): + """Test updating existing documents.""" resp = requests.put( url + '/api/documents', params={'on_duplicate': 'update', 'collection': 'example_vertices'}, - data=example_data, + data=create_test_docs(3), headers=headers ).json() expected = {'created': 0, 'errors': 0, 'empty': 0, 'updated': 3, 'ignored': 0, 'error': False} self.assertEqual(resp, expected) - # replace on duplicate + + def test_replace_documents(self): + """Test replacing of existing documents.""" resp = requests.put( url + '/api/documents', params={'on_duplicate': 'replace', 'collection': 'example_vertices'}, - data=example_data, + data=create_test_docs(3), headers=headers ).json() expected = {'created': 0, 'errors': 0, 'empty': 0, 'updated': 3, 'ignored': 0, 'error': False} self.assertEqual(resp, expected) - # error on duplicate + + def test_save_documents_dupe_errors(self): + """Test where we want to raise errors on duplicate documents.""" resp = requests.put( url + '/api/documents', params={'on_duplicate': 'error', 'collection': 'example_vertices'}, - data=example_data, + data=create_test_docs(3), headers=headers ).json() expected = {'created': 0, 'errors': 3, 'empty': 0, 'updated': 0, 'ignored': 0, 'error': False} self.assertEqual(resp, expected) - # ignore duplicates + + def test_save_documents_ignore_dupes(self): + """Test ignoring duplicate, existing documents when saving.""" resp = requests.put( url + '/api/documents', params={'on_duplicate': 'ignore', 'collection': 'example_vertices'}, - data=example_data, + data=create_test_docs(3), headers=headers ).json() expected = {'created': 0, 'errors': 0, 'empty': 0, 'updated': 0, 'ignored': 3, 'error': False} self.assertEqual(resp, expected) def test_query(self): - """Test a query that fetches some docs.""" - create_docs() + """Test a basic query that fetches some docs.""" + save_test_docs(3) resp = requests.post( - url + '/api/query', - params={'view': 'example'}, + url + '/api/query_results', + params={'view': 'list_all_documents_in_collection'}, data=json.dumps({'@collection': 'example_vertices'}), headers={ 'Authorization': 'Bearer ' + auth_token, 'Content-Type': 'application/json' } ).json() - self.assertEqual(resp['results'], [3]) - self.assertEqual(resp['count'], 1) + self.assertEqual(len(resp['results']), 3) + self.assertEqual(resp['count'], 3) self.assertEqual(resp['has_more'], False) self.assertEqual(resp['cursor_id'], None) self.assertTrue(resp['stats']) + def test_query_with_cursor(self): + """Test getting more data via a query cursor.""" + save_test_docs(count=200) + resp = requests.post( + url + '/api/query_results', + params={'view': 'list_all_documents_in_collection'}, + data=json.dumps({'@collection': 'example_vertices'}), + headers={ + 'Authorization': 'Bearer ' + auth_token, + 'Content-Type': 'application/json' + } + ).json() + cursor_id = resp['cursor_id'] + self.assertTrue(resp['cursor_id']) + self.assertEqual(resp['has_more'], True) + self.assertEqual(resp['count'], 200) + self.assertTrue(len(resp['results']), 100) + resp = requests.post( + url + '/api/query_results', + params={'cursor_id': cursor_id}, + headers={'Authorization': 'Bearer ' + auth_token} + ).json() + self.assertEqual(resp['count'], 200) + self.assertEqual(resp['has_more'], False) + self.assertEqual(resp['cursor_id'], None) + self.assertTrue(len(resp['results']), 100) + def test_query_no_name(self): resp = requests.post( - url + '/api/query', + url + '/api/query_results', params={'view': 'nonexistent'}, data=json.dumps({'@collection': 'example_vertices'}), headers={ @@ -180,8 +217,8 @@ def test_query_no_name(self): def test_query_missing_bind_var(self): resp = requests.post( - url + '/api/query', - params={'view': 'example'}, + url + '/api/query_results', + params={'view': 'list_all_documents_in_collection'}, data=json.dumps({'xyz': 'example_vertices'}), headers={ 'Authorization': 'Bearer ' + auth_token, @@ -193,8 +230,8 @@ def test_query_missing_bind_var(self): def test_query_incorrect_collection(self): resp = requests.post( - url + '/api/query', - params={'view': 'example'}, + url + '/api/query_results', + params={'view': 'list_all_documents_in_collection'}, data=json.dumps({'@collection': 123}), headers={ 'Authorization': 'Bearer ' + auth_token, From d1cf7fb44502598199849d7f52330f1fc014661e Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 7 Nov 2018 14:54:23 -0800 Subject: [PATCH 071/732] Fix comment --- api/src/relation_engine_server/spec_loader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/src/relation_engine_server/spec_loader.py b/api/src/relation_engine_server/spec_loader.py index b81345ab..5084bb5a 100644 --- a/api/src/relation_engine_server/spec_loader.py +++ b/api/src/relation_engine_server/spec_loader.py @@ -59,7 +59,7 @@ def get_view(name): def git_pull(): """Git pull the spec repo to get any updates.""" - # Pull if there were updates on fetch + # This always git-pulls no matter what. We may want to throttle or change this in the future. output = subprocess.check_output(['git', '-C', _spec_dir, 'pull']) # nosec # Initialize any collections arango_client.init_collections(get_schema_names()) From 757071ec8bb04b93166387cbadc1bdabdde2eb8d Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 7 Nov 2018 15:08:02 -0800 Subject: [PATCH 072/732] Update README.md --- spec/README.md | 41 ++++++++++------------------------------- 1 file changed, 10 insertions(+), 31 deletions(-) diff --git a/spec/README.md b/spec/README.md index b1034487..345d7912 100644 --- a/spec/README.md +++ b/spec/README.md @@ -1,40 +1,19 @@ # Relation Engine Spec -This repo holds the [views](src/views), [schemas](src/schemas), and [migrations](src/migrations) for the relation engine graph database service. +This repo holds the [views](views), [schemas](schemas), and [migrations](migrations) for the relation engine graph database service. -The views are stored [AQL queries](https://docs.arangodb.com/3.3/AQL/index.html) that can be used -by KBase apps to fetch data from the database. +These specifications are used by the [Relation Engine API]() -Schemas are [JSON schemas](https://json-schema.org/) that define what form of data can be stored in +* **Views** are stored [AQL queries](https://docs.arangodb.com/3.3/AQL/index.html) that can be used +by KBase apps to fetch data from the database. +* **Schemas** are [JSON schemas](https://json-schema.org/) that define what form of data can be stored in the database's collections. +* **Migrations** are python modules that connect to the database and are responsible for transitioning the data in a collection from an old schema to a newer one. -Migrations are python modules that connect to the database and are responsible for transitioning -the data in a collection from an old schema to a newer one. - -Versioning on collections: -- Schemas and migrations have a simple incremental version -- The database associates a version with each collection -- If a new schema/migration is added with a higher version, then the migration is run, the new - schema is saved, and the version in the database is incremented. -- If there are multiple schemas/migrations that are newer for a collection, then each migration - will get run in order until they have all been applied. -- Migrations can get rolled back (each migration has an `up` and `down` function). - -Views and migrations both have python tests located in [`./src/test`](src/test) - - -_Questions_ - -- How do developers write and test new views and migrations and run them against test data? - - Provide a small docker image with a subset of data from prod - - -# Publish the package +## Development -The package can be published to anaconda, where it can then be installed via pip or conda. +### Running tests -```sh -$ python setup.py sdist -$ anaconda upload -i -u kbase dist/*.tar.gz -``` +The tests will validate JSON schema syntax and will look for any duplicate schema or view names. +Using python 3.5+, run `make test`. From 9edce9ffc1709f49a17ba1dd98baa2bac4220ab1 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 7 Nov 2018 15:11:35 -0800 Subject: [PATCH 073/732] Update requests to 2.20 due to a vulnerability in 2.19 --- api/requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/requirements.txt b/api/requirements.txt index eb6fc4b2..70e6efe7 100644 --- a/api/requirements.txt +++ b/api/requirements.txt @@ -1,7 +1,7 @@ Flask==1.0.2 gunicorn==19.9.0 -gevent==1.3.6 +gevent==1.3.7 simplejson==3.16.0 python-dotenv==0.9.1 -requests==2.19.1 +requests==2.20.0 jsonschema==2.6.0 From fd7f4461bf55c281449f493614355316130743a5 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 7 Nov 2018 15:18:54 -0800 Subject: [PATCH 074/732] Add a test to make sure the cursor is deleted once used --- api/src/test/test_api.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/api/src/test/test_api.py b/api/src/test/test_api.py index d9ce8601..c9beea9b 100644 --- a/api/src/test/test_api.py +++ b/api/src/test/test_api.py @@ -201,6 +201,14 @@ def test_query_with_cursor(self): self.assertEqual(resp['has_more'], False) self.assertEqual(resp['cursor_id'], None) self.assertTrue(len(resp['results']), 100) + # Try to get the same cursor again + resp = requests.post( + url + '/api/query_results', + params={'cursor_id': cursor_id}, + headers={'Authorization': 'Bearer ' + auth_token} + ).json() + self.assertTrue(resp['error']) + self.assertEqual(resp['arango_message'], 'cursor not found') def test_query_no_name(self): resp = requests.post( From 6997232f87a3fdcc070ec4a84207a43737b4000b Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 7 Nov 2018 15:58:04 -0800 Subject: [PATCH 075/732] Add CODEOWNERS file --- api/CODEOWNERS | 1 + 1 file changed, 1 insertion(+) create mode 100644 api/CODEOWNERS diff --git a/api/CODEOWNERS b/api/CODEOWNERS new file mode 100644 index 00000000..788e5f5d --- /dev/null +++ b/api/CODEOWNERS @@ -0,0 +1 @@ +* @jayrbolton From 1b40f751ed4d8f6f08189550b551a7b5a32e5296 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 7 Nov 2018 15:58:52 -0800 Subject: [PATCH 076/732] Add CODEOWNERS file --- spec/CODEOWNERS | 1 + 1 file changed, 1 insertion(+) create mode 100644 spec/CODEOWNERS diff --git a/spec/CODEOWNERS b/spec/CODEOWNERS new file mode 100644 index 00000000..788e5f5d --- /dev/null +++ b/spec/CODEOWNERS @@ -0,0 +1 @@ +* @jayrbolton From da0c1d2cba8e55e57872181075d2cfdfbb852cdd Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 7 Nov 2018 16:47:04 -0800 Subject: [PATCH 077/732] Work in progress -- add everything except genes and genomes. --- spec/schemas/edges/is_child_of.json | 17 +++++ spec/schemas/edges/is_produced_by.json | 19 ++++++ spec/schemas/edges/is_similar_to.json | 18 ++++++ spec/schemas/vertices/chemical_reactions.json | 62 +++++++++++++++++++ .../vertices/gene_reaction_complex.json | 26 ++++++++ spec/schemas/vertices/taxa.json | 18 ++++++ 6 files changed, 160 insertions(+) create mode 100644 spec/schemas/edges/is_child_of.json create mode 100644 spec/schemas/edges/is_produced_by.json create mode 100644 spec/schemas/edges/is_similar_to.json create mode 100644 spec/schemas/vertices/chemical_reactions.json create mode 100644 spec/schemas/vertices/gene_reaction_complex.json create mode 100644 spec/schemas/vertices/taxa.json diff --git a/spec/schemas/edges/is_child_of.json b/spec/schemas/edges/is_child_of.json new file mode 100644 index 00000000..f00e9ce0 --- /dev/null +++ b/spec/schemas/edges/is_child_of.json @@ -0,0 +1,17 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "required": ["_from", "_to"], + "description": "A taxonomic, parent-child hierarchical relationship.", + "additionalProperties": true, + "properties": { + "_from": { + "type": "string", + "description": "The ID of a child vertex that inherits from a parent." + }, + "_to": { + "type": "string", + "description": "The ID of a parent vertex that is inherited by a child." + } + } +} diff --git a/spec/schemas/edges/is_produced_by.json b/spec/schemas/edges/is_produced_by.json new file mode 100644 index 00000000..dbe50615 --- /dev/null +++ b/spec/schemas/edges/is_produced_by.json @@ -0,0 +1,19 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "required": ["_from", "_to"], + "description": "An entity produced from something else.", + "additionalProperties": true, + "properties": { + "_from": { + "type": "string", + "description": "The ID of a vertex that produces something else." + }, + "_to": { + "type": "string", + "description": "The ID of a vertex that is produced by something else." + } + } +} + + diff --git a/spec/schemas/edges/is_similar_to.json b/spec/schemas/edges/is_similar_to.json new file mode 100644 index 00000000..6bb3f1e1 --- /dev/null +++ b/spec/schemas/edges/is_similar_to.json @@ -0,0 +1,18 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "required": ["_from", "_to"], + "description": "A generic similarity association.", + "additionalProperties": true, + "properties": { + "_from": { + "type": "string", + "description": "The ID of a vertex" + }, + "_to": { + "type": "string", + "description": "The ID of a vertex" + } + } +} + diff --git a/spec/schemas/vertices/chemical_reactions.json b/spec/schemas/vertices/chemical_reactions.json new file mode 100644 index 00000000..a183551e --- /dev/null +++ b/spec/schemas/vertices/chemical_reactions.json @@ -0,0 +1,62 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "additionalProperties": false, + "required": ["_key"], + "description": "Chemical reactions", + "properties": { + "_key": { + "type": "string", + "example": "rxn02201", + "description": "ms id", + "pattern": "^rxn\\d+#" + }, + "direction": { + "type": "string", + "enum": [">", "<", "="] + }, + "name": { + "type": "string", + "description": "Chemical names", + "example": "trans-2-Methyl-5-isopropylhexa-2,5-dienal dehydrogenase_c0" + }, + "gpr": { + "type": "string", + "example": "PGN_RS01070" + }, + "enzyme": { + "type": "string", + "example": "2.7.3.7", + "pattern": "^\\d+\\.\\d+\\.\\d+\\.\\d+$" + }, + "bbcwn": { + "type": "number", + "example": -108 + }, + "equation": { + "type": "string", + "description": "Reaction formula using compound IDs (eg. cd00443)", + "example": "(1) cpd00443[c0] + (1) cpd02920[c0] => (1) cpd00012[c0] + (1) cpd00067[c0] + (1) cpd00683[c0]" + }, + "definition": { + "type": "string", + "description": "Reaction formula. Same as equation, but with compound IDs replaced with chemical names." + }, + "bigg_id": { + "type": "string", + "example": "DHPS2" + }, + "kegg_id": { + "type": "string", + "example": "R03067" + }, + "kegg_pathways": { + "type": "string", + "example": "Folate biosynthesis" + }, + "metacyc_pathways": { + "type": "string", + "example": "AMINE-DEG|Creatinine-Degradation|Degradation" + } + } +} diff --git a/spec/schemas/vertices/gene_reaction_complex.json b/spec/schemas/vertices/gene_reaction_complex.json new file mode 100644 index 00000000..5849e1d7 --- /dev/null +++ b/spec/schemas/vertices/gene_reaction_complex.json @@ -0,0 +1,26 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "additionalProperties": false, + "description": "Groups of genes that take part in producing a chemical reaction in the cell.", + "required": ["_key", "conjunctions"], + "properties": { + "_key": { + "type": "string", + "description": "Hash of the conjunctions." + }, + "conjunctions": { + "type": "array", + "example": [["A", "B"], ["C", "D"]], + "description": "Array of conjunctions of genes. Eg: (A AND B) OR (C AND D).", + "items": { + "type": "array", + "description": "Conjunction of genes necessary to produce a reaction (eg. gene X AND Y AND Z)", + "items": { + "type": "string", + "description": "Gene vertex ID" + } + } + } +} + diff --git a/spec/schemas/vertices/taxa.json b/spec/schemas/vertices/taxa.json new file mode 100644 index 00000000..711da348 --- /dev/null +++ b/spec/schemas/vertices/taxa.json @@ -0,0 +1,18 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "additionalProperties": false, + "description": "Biological taxonomic node (class, order, family, genus, species, organism)", + "required": ["_key", "name"], + "properties": { + "_key": { + "type": "string", + "example": "haloferax_volcanii", + "description": "Normalized name (lower-cased and snake-cased)" + }, + "name": { + "type": "string", + "example": "Haloferax Volcanii" + } + } +} From ceadbca0bdd8efcc2b88c0fd34b5a6c68e45ac0b Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 7 Nov 2018 16:49:09 -0800 Subject: [PATCH 078/732] Fix name --- .../{gene_reaction_complex.json => gene_reaction_complexes.json} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename spec/schemas/vertices/{gene_reaction_complex.json => gene_reaction_complexes.json} (100%) diff --git a/spec/schemas/vertices/gene_reaction_complex.json b/spec/schemas/vertices/gene_reaction_complexes.json similarity index 100% rename from spec/schemas/vertices/gene_reaction_complex.json rename to spec/schemas/vertices/gene_reaction_complexes.json From beef88fe22d22269b5faa1250aa48788c0c03a08 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 7 Nov 2018 16:51:11 -0800 Subject: [PATCH 079/732] Fix syntax --- spec/schemas/vertices/gene_reaction_complexes.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/schemas/vertices/gene_reaction_complexes.json b/spec/schemas/vertices/gene_reaction_complexes.json index 5849e1d7..38594380 100644 --- a/spec/schemas/vertices/gene_reaction_complexes.json +++ b/spec/schemas/vertices/gene_reaction_complexes.json @@ -19,8 +19,8 @@ "items": { "type": "string", "description": "Gene vertex ID" + } } } } } - From e0b16cd318380429d5b24e33eeaf5c03a601a74e Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 7 Nov 2018 16:53:51 -0800 Subject: [PATCH 080/732] Fix pattern --- spec/schemas/vertices/chemical_reactions.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/schemas/vertices/chemical_reactions.json b/spec/schemas/vertices/chemical_reactions.json index a183551e..ef0a7eb6 100644 --- a/spec/schemas/vertices/chemical_reactions.json +++ b/spec/schemas/vertices/chemical_reactions.json @@ -9,7 +9,7 @@ "type": "string", "example": "rxn02201", "description": "ms id", - "pattern": "^rxn\\d+#" + "pattern": "^rxn\\d+$" }, "direction": { "type": "string", From 62a02e2688c241417fa2550b9ff995f5a24ae88b Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Thu, 8 Nov 2018 08:36:14 -0800 Subject: [PATCH 081/732] Add a error details display option for imports with a test case --- api/src/relation_engine_server/api.py | 3 +++ api/src/test/test_api.py | 8 +++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/api/src/relation_engine_server/api.py b/api/src/relation_engine_server/api.py index 324b1927..7b9643d6 100644 --- a/api/src/relation_engine_server/api.py +++ b/api/src/relation_engine_server/api.py @@ -85,6 +85,9 @@ def save_documents(): auth.require_auth_token(['RE_ADMIN']) collection_name = flask.request.args['collection'] query = {'collection': collection_name, 'type': 'documents'} + if flask.request.args.get('display_errors'): + # Display an array of error messages + query['details'] = 'true' schema = spec_loader.get_schema(collection_name) if flask.request.args.get('on_duplicate'): query['onDuplicate'] = flask.request.args['on_duplicate'] diff --git a/api/src/test/test_api.py b/api/src/test/test_api.py index c9beea9b..ea985038 100644 --- a/api/src/test/test_api.py +++ b/api/src/test/test_api.py @@ -137,14 +137,16 @@ def test_replace_documents(self): def test_save_documents_dupe_errors(self): """Test where we want to raise errors on duplicate documents.""" + save_test_docs(3) resp = requests.put( url + '/api/documents', - params={'on_duplicate': 'error', 'collection': 'example_vertices'}, + params={'on_duplicate': 'error', 'collection': 'example_vertices', 'display_errors': '1'}, data=create_test_docs(3), headers=headers ).json() - expected = {'created': 0, 'errors': 3, 'empty': 0, 'updated': 0, 'ignored': 0, 'error': False} - self.assertEqual(resp, expected) + self.assertEqual(resp['created'], 0) + self.assertEqual(resp['errors'], 3) + self.assertTrue(resp['details']) def test_save_documents_ignore_dupes(self): """Test ignoring duplicate, existing documents when saving.""" From b457b07831e9a3c297ac8989b9e56642f02f8c2f Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Thu, 8 Nov 2018 11:47:41 -0800 Subject: [PATCH 082/732] Update some fields based on feedback from @JamesJeffryes --- spec/schemas/edges/is_produced_by.json | 2 +- spec/schemas/vertices/chemical_reactions.json | 7 ++++--- spec/schemas/vertices/gene_reaction_complexes.json | 12 ++++-------- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/spec/schemas/edges/is_produced_by.json b/spec/schemas/edges/is_produced_by.json index dbe50615..eba921cd 100644 --- a/spec/schemas/edges/is_produced_by.json +++ b/spec/schemas/edges/is_produced_by.json @@ -2,7 +2,7 @@ "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "required": ["_from", "_to"], - "description": "An entity produced from something else.", + "description": "An entity produced from something else. Eg: reactions -> is_produced_by -> gene_reaction_complexes", "additionalProperties": true, "properties": { "_from": { diff --git a/spec/schemas/vertices/chemical_reactions.json b/spec/schemas/vertices/chemical_reactions.json index ef0a7eb6..759d93f3 100644 --- a/spec/schemas/vertices/chemical_reactions.json +++ b/spec/schemas/vertices/chemical_reactions.json @@ -24,7 +24,7 @@ "type": "string", "example": "PGN_RS01070" }, - "enzyme": { + "ec_number": { "type": "string", "example": "2.7.3.7", "pattern": "^\\d+\\.\\d+\\.\\d+\\.\\d+$" @@ -55,8 +55,9 @@ "example": "Folate biosynthesis" }, "metacyc_pathways": { - "type": "string", - "example": "AMINE-DEG|Creatinine-Degradation|Degradation" + "type": "array", + "items": {"type": "string"}, + "example": ["AMINE-DEG", "Creatinine-Degradation", "Degradation"] } } } diff --git a/spec/schemas/vertices/gene_reaction_complexes.json b/spec/schemas/vertices/gene_reaction_complexes.json index 38594380..52cf1edf 100644 --- a/spec/schemas/vertices/gene_reaction_complexes.json +++ b/spec/schemas/vertices/gene_reaction_complexes.json @@ -11,15 +11,11 @@ }, "conjunctions": { "type": "array", - "example": [["A", "B"], ["C", "D"]], - "description": "Array of conjunctions of genes. Eg: (A AND B) OR (C AND D).", + "example": ["A", "B", "C", "D"], + "description": "Array of conjunctions of genes. Eg: (A AND B AND C AND D).", "items": { - "type": "array", - "description": "Conjunction of genes necessary to produce a reaction (eg. gene X AND Y AND Z)", - "items": { - "type": "string", - "description": "Gene vertex ID" - } + "type": "String", + "description": "Gene vertex _key" } } } From 168762186bdc8572a98c766aefac555868af86b1 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Thu, 8 Nov 2018 11:50:25 -0800 Subject: [PATCH 083/732] Add a couple field titles --- spec/schemas/vertices/chemical_reactions.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spec/schemas/vertices/chemical_reactions.json b/spec/schemas/vertices/chemical_reactions.json index 759d93f3..fbb1872e 100644 --- a/spec/schemas/vertices/chemical_reactions.json +++ b/spec/schemas/vertices/chemical_reactions.json @@ -8,7 +8,7 @@ "_key": { "type": "string", "example": "rxn02201", - "description": "ms id", + "title": "ModelSeed ID", "pattern": "^rxn\\d+$" }, "direction": { @@ -27,6 +27,7 @@ "ec_number": { "type": "string", "example": "2.7.3.7", + "title": "Enzyme Commission Number", "pattern": "^\\d+\\.\\d+\\.\\d+\\.\\d+$" }, "bbcwn": { From a4f2188ec74f82ed6d6efdf637afdae362971c9e Mon Sep 17 00:00:00 2001 From: JamesJeffryes Date: Mon, 12 Nov 2018 10:31:16 -0600 Subject: [PATCH 084/732] update edge schemas --- spec/schemas/edges/is_copy_of.json | 23 +++++++++++++ spec/schemas/edges/is_latest_version_of.json | 10 +++--- spec/schemas/edges/is_owner_of.json | 6 ++-- spec/schemas/edges/is_version_of.json | 10 +++--- spec/schemas/edges/refers_to.json | 23 +++++++++++++ spec/schemas/edges/was_created_by.json | 32 +++++++++++++++++++ spec/schemas/edges/was_created_with.json | 23 +++++++++++++ spec/schemas/edges/was_input_for.json | 23 +++++++++++++ spec/schemas/vertices/ws_object_versions.json | 11 +++++-- 9 files changed, 146 insertions(+), 15 deletions(-) create mode 100644 spec/schemas/edges/is_copy_of.json create mode 100644 spec/schemas/edges/refers_to.json create mode 100644 spec/schemas/edges/was_created_by.json create mode 100644 spec/schemas/edges/was_created_with.json create mode 100644 spec/schemas/edges/was_input_for.json diff --git a/spec/schemas/edges/is_copy_of.json b/spec/schemas/edges/is_copy_of.json new file mode 100644 index 00000000..305290fe --- /dev/null +++ b/spec/schemas/edges/is_copy_of.json @@ -0,0 +1,23 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "additionalProperties": false, + "required": ["_from", "_to"], + "description": "The _from object was created by as an exact copy of the _to object.", + "properties": { + "_from": { + "type": "string", + "examples": [ + "ws_object_versions/35414:73:1" + ], + "description": "A versioned workspace object" + }, + "_to": { + "type": "string", + "examples": [ + "ws_object_versions/35414:73:1" + ], + "description": "A versioned workspace object" + } + } +} diff --git a/spec/schemas/edges/is_latest_version_of.json b/spec/schemas/edges/is_latest_version_of.json index 109cbae2..febdffc6 100644 --- a/spec/schemas/edges/is_latest_version_of.json +++ b/spec/schemas/edges/is_latest_version_of.json @@ -7,18 +7,18 @@ "_from": { "type": "string", "examples": [ - "KBaseGenomes.Genome‑9.0", - "kb_uploadmethods:8ebb66e4f2c27bc4a9b7cddff7d7b0f27f4ee433" + "type_versions/KBaseGenomes.Genome‑9.0", + "app_module_versions/kb_uploadmethods:8ebb66e4f2c27bc4a9b7cddff7d7b0f27f4ee433" ], "description": "A versioned entity, representing the most recent version of an entity in a group (most likely a workspace object, module, or workspace type)." }, "_to": { "type": "string", "examples": [ - "KBaseGenomes.Genome", - "kb_uploadmethods" + "types/KBaseGenomes.Genome", + "app_modules/kb_uploadmethods" ], - "description": "The unversioned entity group, where all members of the group are different versions of something (eg. a workspace object, module, or workspace type)" + "description": "The non-versioned entity group, where all members of the group are different versions of something (eg. a workspace object, module, or workspace type)" } } } diff --git a/spec/schemas/edges/is_owner_of.json b/spec/schemas/edges/is_owner_of.json index ca907b89..cf103ece 100644 --- a/spec/schemas/edges/is_owner_of.json +++ b/spec/schemas/edges/is_owner_of.json @@ -7,15 +7,15 @@ "_from": { "type": "string", "examples": [ - "jjeffryes" + "users/jjeffryes" ], "description": "A username" }, "_to": { "type": "string", "examples": [ - "KBaseGenomes", - "35414" + "type_modules/KBaseGenomes", + "workspaces/35414" ], "description": "A Workspace or Type Module" } diff --git a/spec/schemas/edges/is_version_of.json b/spec/schemas/edges/is_version_of.json index a7bd4e4d..0d439434 100644 --- a/spec/schemas/edges/is_version_of.json +++ b/spec/schemas/edges/is_version_of.json @@ -7,18 +7,18 @@ "_from": { "type": "string", "examples": [ - "KBaseGenomes.Genome‑9.0", - "kb_uploadmethods:8ebb66e4f2c27bc4a9b7cddff7d7b0f27f4ee433" + "type_versions/KBaseGenomes.Genome‑9.0", + "app_module_versions/kb_uploadmethods:8ebb66e4f2c27bc4a9b7cddff7d7b0f27f4ee433" ], "description": "A versioned entity (eg. a workspace object, module, or workspace type)" }, "_to": { "type": "string", "examples": [ - "KBaseGenomes.Genome", - "kb_uploadmethods" + "types/KBaseGenomes.Genome", + "app_modules/kb_uploadmethods" ], - "description": "A non-versioned grouping of versioned entities (eg. a workspace object, module, or workspace type)." + "description": "The non-versioned entity group, where all members of the group are different versions of something (eg. a workspace object, module, or workspace type)." } } } diff --git a/spec/schemas/edges/refers_to.json b/spec/schemas/edges/refers_to.json new file mode 100644 index 00000000..3c9b2e2d --- /dev/null +++ b/spec/schemas/edges/refers_to.json @@ -0,0 +1,23 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "additionalProperties": false, + "required": ["_from", "_to"], + "description": "The _from object possess an attribute which is a reference to the _to object.", + "properties": { + "_from": { + "type": "string", + "examples": [ + "ws_object_versions/35414:73:1" + ], + "description": "A versioned workspace object" + }, + "_to": { + "type": "string", + "examples": [ + "ws_object_versions/35414:73:1" + ], + "description": "A versioned workspace object" + } + } +} diff --git a/spec/schemas/edges/was_created_by.json b/spec/schemas/edges/was_created_by.json new file mode 100644 index 00000000..813612c6 --- /dev/null +++ b/spec/schemas/edges/was_created_by.json @@ -0,0 +1,32 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "additionalProperties": false, + "required": [ + "_from", + "_to", + "method_params" + ], + "description": "The _from object was generated by a method that utilized the _to module version.", + "properties": { + "_from": { + "type": "string", + "examples": [ + "ws_object_versions/35414:73:1" + ], + "description": "A versioned workspace object" + }, + "_to": { + "type": "string", + "examples": [ + "app_versions/kb_uploadmethods:8ebb66e4f2c27bc4a9b7cddff7d7b0f27f4ee433.import_genbank_from_staging", + "app_versions/kb_uploadmethods:UNKNOWN.import_genbank_from_staging" + ], + "description": "A version of app" + }, + "method_params": { + "type": "object", + "description": "The input parameters for the method used to create the object." + } + } +} diff --git a/spec/schemas/edges/was_created_with.json b/spec/schemas/edges/was_created_with.json new file mode 100644 index 00000000..df26161d --- /dev/null +++ b/spec/schemas/edges/was_created_with.json @@ -0,0 +1,23 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "additionalProperties": false, + "required": ["_from", "_to"], + "description": "The _from object was generated by a method that utilized the _to module version.", + "properties": { + "_from": { + "type": "string", + "examples": [ + "ws_object_versions/35414:73:1" + ], + "description": "A versioned workspace object" + }, + "_to": { + "type": "string", + "examples": [ + "app_module_versions/kb_uploadmethods:8ebb66e4f2c27bc4a9b7cddff7d7b0f27f4ee433" + ], + "description": "A version of module" + } + } +} diff --git a/spec/schemas/edges/was_input_for.json b/spec/schemas/edges/was_input_for.json new file mode 100644 index 00000000..97a6a265 --- /dev/null +++ b/spec/schemas/edges/was_input_for.json @@ -0,0 +1,23 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "additionalProperties": false, + "required": ["_from", "_to"], + "description": "The _from object was used as an input in the app that created the _to object.", + "properties": { + "_from": { + "type": "string", + "examples": [ + "ws_object_versions/35414:73:1" + ], + "description": "A versioned workspace object" + }, + "_to": { + "type": "string", + "examples": [ + "ws_object_versions/35414:73:1" + ], + "description": "A versioned workspace object" + } + } +} diff --git a/spec/schemas/vertices/ws_object_versions.json b/spec/schemas/vertices/ws_object_versions.json index 34f1e4d9..73ffc26c 100644 --- a/spec/schemas/vertices/ws_object_versions.json +++ b/spec/schemas/vertices/ws_object_versions.json @@ -18,9 +18,16 @@ }, "name": { "type": "string", - "description": "The workspace name for this workspace", + "description": "The user supplied name for this object", "examples": [ - "jjeffryes:narrative_1534187093329" + "my_awesome_object" + ] + }, + "hash": { + "type": "string", + "description": "The md5 hash of the workspace object", + "examples": [ + "94edd584731298befa53119cb151d82e" ] }, "size": { From af6216cdebcd428e431ab78a1048130586105f53 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Mon, 12 Nov 2018 11:51:54 -0800 Subject: [PATCH 085/732] Copy edit --- spec/schemas/edges/is_copy_of.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/schemas/edges/is_copy_of.json b/spec/schemas/edges/is_copy_of.json index 305290fe..ef5f66fc 100644 --- a/spec/schemas/edges/is_copy_of.json +++ b/spec/schemas/edges/is_copy_of.json @@ -3,7 +3,7 @@ "type": "object", "additionalProperties": false, "required": ["_from", "_to"], - "description": "The _from object was created by as an exact copy of the _to object.", + "description": "The _from object was created as an exact copy of the _to object.", "properties": { "_from": { "type": "string", From 77c4e5aac67c4ae8571b80073c6c2cca58d06456 Mon Sep 17 00:00:00 2001 From: JamesJeffryes Date: Mon, 12 Nov 2018 14:26:56 -0600 Subject: [PATCH 086/732] Automatically generate _key for edges --- api/Makefile | 2 +- api/src/relation_engine_server/api.py | 6 +++++ api/src/test/test_api.py | 36 ++++++++++++++++++++++++--- 3 files changed, 40 insertions(+), 4 deletions(-) diff --git a/api/Makefile b/api/Makefile index bf7e9133..e2c944ba 100644 --- a/api/Makefile +++ b/api/Makefile @@ -4,7 +4,7 @@ test: docker-compose run web make test-local test-local: - flake8 --max-complexity 5 src + flake8 --max-complexity 6 src mypy --ignore-missing-imports src python -m pyflakes src bandit -r src diff --git a/api/src/relation_engine_server/api.py b/api/src/relation_engine_server/api.py index 7b9643d6..6d314e1d 100644 --- a/api/src/relation_engine_server/api.py +++ b/api/src/relation_engine_server/api.py @@ -1,5 +1,6 @@ """The primary router for the Relation Engine API.""" import flask +import hashlib import json import tempfile import jsonschema @@ -98,6 +99,11 @@ def save_documents(): for line in flask.request.stream: json_line = json.loads(line) jsonschema.validate(json_line, schema) + # for edges, we want a deterministic key so that there are not duplicates + if "_key" not in json_line and "_from" in json_line and "_to" in json_line: + json_line['_key'] = hashlib.blake2b( + json_line["_from"].encode() + json_line["_to"].encode(), digest_size=10 + ).hexdigest() fd.write(json.dumps(json_line) + '\n') resp_text = arango_client.bulk_import(temp_fd.name, query) temp_fd.close() # Also deletes the file diff --git a/api/src/test/test_api.py b/api/src/test/test_api.py index ea985038..a5dadcae 100644 --- a/api/src/test/test_api.py +++ b/api/src/test/test_api.py @@ -20,11 +20,23 @@ def doc(i): return '\n'.join(doc(i) for i in range(0, count)) -def save_test_docs(count): - docs = create_test_docs(count) +def create_test_edges(count): + """Produce some test edges.""" + def doc(i): + return '{"_from": "example_vertices/%s", "_to": "example_vertices/%s"}' % (i, i) + return '\n'.join(doc(i) for i in range(0, count)) + + +def save_test_docs(count, edges=False): + if edges: + docs = create_test_edges(count) + collection = 'example_edges' + else: + docs = create_test_docs(count) + collection = 'example_vertices' return requests.put( url + '/api/documents', - params={'overwrite': True, 'collection': 'example_vertices'}, + params={'overwrite': True, 'collection': collection}, data=docs, headers=headers ).json() @@ -113,6 +125,13 @@ def test_create_documents(self): expected = {'created': 3, 'errors': 0, 'empty': 0, 'updated': 0, 'ignored': 0, 'error': False} self.assertEqual(resp, expected) + def test_create_edges(self): + """Test all valid cases for saving edges.""" + # Create + resp = save_test_docs(3, edges=True) + expected = {'created': 3, 'errors': 0, 'empty': 0, 'updated': 0, 'ignored': 0, 'error': False} + self.assertEqual(resp, expected) + def test_update_documents(self): """Test updating existing documents.""" resp = requests.put( @@ -124,6 +143,17 @@ def test_update_documents(self): expected = {'created': 0, 'errors': 0, 'empty': 0, 'updated': 3, 'ignored': 0, 'error': False} self.assertEqual(resp, expected) + def test_update_edge(self): + """Test updating existing edge.""" + resp = requests.put( + url + '/api/documents', + params={'on_duplicate': 'update', 'collection': 'example_edges'}, + data=create_test_edges(3), + headers=headers + ).json() + expected = {'created': 0, 'errors': 0, 'empty': 0, 'updated': 3, 'ignored': 0, 'error': False} + self.assertEqual(resp, expected) + def test_replace_documents(self): """Test replacing of existing documents.""" resp = requests.put( From 89c75fb71f273dfc148fc590812d3a165a4dde12 Mon Sep 17 00:00:00 2001 From: JamesJeffryes Date: Mon, 12 Nov 2018 14:28:48 -0600 Subject: [PATCH 087/732] Making things crystal --- .../edges/{was_input_for.json => was_input_in_creation_of.json} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename spec/schemas/edges/{was_input_for.json => was_input_in_creation_of.json} (100%) diff --git a/spec/schemas/edges/was_input_for.json b/spec/schemas/edges/was_input_in_creation_of.json similarity index 100% rename from spec/schemas/edges/was_input_for.json rename to spec/schemas/edges/was_input_in_creation_of.json From 68d270f303471dc76a19c3cf362e74f40f9e4750 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Mon, 12 Nov 2018 13:06:56 -0800 Subject: [PATCH 088/732] Do a git pull on server start --- api/src/relation_engine_server/server.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/api/src/relation_engine_server/server.py b/api/src/relation_engine_server/server.py index b044c146..ffc60ce4 100644 --- a/api/src/relation_engine_server/server.py +++ b/api/src/relation_engine_server/server.py @@ -6,7 +6,7 @@ from .api import api from .exceptions import MissingHeader, UnauthorizedAccess -from . import arango_client +from . import arango_client, spec_loader app = flask.Flask(__name__) app.config['DEBUG'] = os.environ.get('FLASK_DEBUG', True) @@ -15,6 +15,9 @@ app.register_blueprint(api, url_prefix='/api') +# Pull any updates to the spec on startup +spec_loader.git_pull() + @app.route('/', methods=['GET']) def root(): From 6ceb60f25e5563661364bc306461913b81be6b06 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Mon, 12 Nov 2018 13:07:21 -0800 Subject: [PATCH 089/732] Split out some of the git commands in the git_pull function for easier debugging --- api/src/relation_engine_server/spec_loader.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/api/src/relation_engine_server/spec_loader.py b/api/src/relation_engine_server/spec_loader.py index 5084bb5a..b0a74cf5 100644 --- a/api/src/relation_engine_server/spec_loader.py +++ b/api/src/relation_engine_server/spec_loader.py @@ -60,10 +60,11 @@ def get_view(name): def git_pull(): """Git pull the spec repo to get any updates.""" # This always git-pulls no matter what. We may want to throttle or change this in the future. - output = subprocess.check_output(['git', '-C', _spec_dir, 'pull']) # nosec + subprocess.check_output(['git', '-C', _spec_dir, 'checkout', 'master']) + subprocess.check_output(['git', '-C', _spec_dir, 'fetch', 'origin']) + subprocess.check_output(['git', '-C', _spec_dir, 'merge', 'origin/master']) # Initialize any collections arango_client.init_collections(get_schema_names()) - return output def _find_paths(dir_path, file_pattern): From 522afe401a0aa156dd89b2d45a065eb8fe566a8b Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Mon, 12 Nov 2018 13:34:38 -0800 Subject: [PATCH 090/732] Set complexity down to 5 --- api/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/Makefile b/api/Makefile index e2c944ba..bf7e9133 100644 --- a/api/Makefile +++ b/api/Makefile @@ -4,7 +4,7 @@ test: docker-compose run web make test-local test-local: - flake8 --max-complexity 6 src + flake8 --max-complexity 5 src mypy --ignore-missing-imports src python -m pyflakes src bandit -r src From 7fe9fe2fa51e7401698545ab7886a11ffe0206c0 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Mon, 12 Nov 2018 13:35:13 -0800 Subject: [PATCH 091/732] Revert back to not pulling on startup, as it doesn't work well with gunicorn --- api/src/relation_engine_server/server.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/api/src/relation_engine_server/server.py b/api/src/relation_engine_server/server.py index ffc60ce4..b044c146 100644 --- a/api/src/relation_engine_server/server.py +++ b/api/src/relation_engine_server/server.py @@ -6,7 +6,7 @@ from .api import api from .exceptions import MissingHeader, UnauthorizedAccess -from . import arango_client, spec_loader +from . import arango_client app = flask.Flask(__name__) app.config['DEBUG'] = os.environ.get('FLASK_DEBUG', True) @@ -15,9 +15,6 @@ app.register_blueprint(api, url_prefix='/api') -# Pull any updates to the spec on startup -spec_loader.git_pull() - @app.route('/', methods=['GET']) def root(): From c12fef64326a4906ff4f039c6a1887e3fa594cc3 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Mon, 12 Nov 2018 13:37:12 -0800 Subject: [PATCH 092/732] Split out some code and reduce complexity --- api/src/relation_engine_server/api.py | 22 ++---------- api/src/relation_engine_server/bulk_import.py | 35 +++++++++++++++++++ api/src/relation_engine_server/pull_spec.py | 21 +++++++++++ api/src/relation_engine_server/spec_loader.py | 13 ------- 4 files changed, 59 insertions(+), 32 deletions(-) create mode 100644 api/src/relation_engine_server/bulk_import.py create mode 100644 api/src/relation_engine_server/pull_spec.py diff --git a/api/src/relation_engine_server/api.py b/api/src/relation_engine_server/api.py index 6d314e1d..de5880a1 100644 --- a/api/src/relation_engine_server/api.py +++ b/api/src/relation_engine_server/api.py @@ -1,12 +1,9 @@ """The primary router for the Relation Engine API.""" import flask -import hashlib import json -import tempfile -import jsonschema from jsonschema.exceptions import ValidationError -from . import spec_loader, arango_client, auth +from . import spec_loader, arango_client, auth, bulk_import, pull_spec api = flask.Blueprint('api', __name__) @@ -73,7 +70,7 @@ def refresh_specs(): """ Manually pull from the spec git repo to get updates. """ - git_output = spec_loader.git_pull() + git_output = pull_spec.pull_spec() return flask.jsonify({"updates": git_output}) @@ -89,24 +86,11 @@ def save_documents(): if flask.request.args.get('display_errors'): # Display an array of error messages query['details'] = 'true' - schema = spec_loader.get_schema(collection_name) if flask.request.args.get('on_duplicate'): query['onDuplicate'] = flask.request.args['on_duplicate'] if flask.request.args.get('overwrite'): query['overwrite'] = 'true' - temp_fd = tempfile.NamedTemporaryFile() - with open(temp_fd.name, 'a') as fd: - for line in flask.request.stream: - json_line = json.loads(line) - jsonschema.validate(json_line, schema) - # for edges, we want a deterministic key so that there are not duplicates - if "_key" not in json_line and "_from" in json_line and "_to" in json_line: - json_line['_key'] = hashlib.blake2b( - json_line["_from"].encode() + json_line["_to"].encode(), digest_size=10 - ).hexdigest() - fd.write(json.dumps(json_line) + '\n') - resp_text = arango_client.bulk_import(temp_fd.name, query) - temp_fd.close() # Also deletes the file + resp_text = bulk_import.bulk_import(query) return resp_text diff --git a/api/src/relation_engine_server/bulk_import.py b/api/src/relation_engine_server/bulk_import.py new file mode 100644 index 00000000..7b85b637 --- /dev/null +++ b/api/src/relation_engine_server/bulk_import.py @@ -0,0 +1,35 @@ +import tempfile +import flask +import json +import jsonschema +import hashlib + +from . import spec_loader, arango_client + + +def bulk_import(query_params): + """ + Stream lines of JSON from a request body, validating each one against a + schema, then write them into a temporary file that can be passed into the + arango client. + """ + schema = spec_loader.get_schema(query_params['collection']) + temp_fd = tempfile.NamedTemporaryFile() + with open(temp_fd.name, 'a') as fd: + for line in flask.request.stream: + json_line = json.loads(line) + jsonschema.validate(json_line, schema) + json_line = _write_edge_key(json_line) + fd.write(json.dumps(json_line) + '\n') + resp_text = arango_client.bulk_import(temp_fd.name, query_params) + temp_fd.close() # Also deletes the file + return resp_text + + +def _write_edge_key(json_line): + """For edges, we want a deterministic key so there are no duplicates.""" + if "_key" not in json_line and "_from" in json_line and "_to" in json_line: + json_line['_key'] = hashlib.blake2b( + json_line["_from"].encode() + json_line["_to"].encode(), digest_size=8 + ).hexdigest() + return json_line diff --git a/api/src/relation_engine_server/pull_spec.py b/api/src/relation_engine_server/pull_spec.py new file mode 100644 index 00000000..b88fbca9 --- /dev/null +++ b/api/src/relation_engine_server/pull_spec.py @@ -0,0 +1,21 @@ +import os +import subprocess # nosec + +from . import arango_client, spec_loader + +_spec_dir = os.environ.get('SPEC_PATH', '/spec') + + +def pull_spec(): + """Download the spec repo to get any updates.""" + # This always git-pulls no matter what. We may want to throttle or change this in the future. + subprocess.check_output(['git', '-C', _spec_dir, 'pull', 'origin', 'master']) # nosec + # Initialize any collections + arango_client.init_collections(spec_loader.get_schema_names()) + + +# Run from bash with `python -m src.relation_engine_server.pull_spec` +if __name__ == '__main__': + print('Pulling relation engine spec..') + pull_spec() + print('..done.') diff --git a/api/src/relation_engine_server/spec_loader.py b/api/src/relation_engine_server/spec_loader.py index b0a74cf5..d1fc7fe1 100644 --- a/api/src/relation_engine_server/spec_loader.py +++ b/api/src/relation_engine_server/spec_loader.py @@ -4,9 +4,6 @@ import glob import os import json -import subprocess # nosec - -from . import arango_client _spec_dir = os.environ.get('SPEC_PATH', '/spec') _view_dir = os.path.join(_spec_dir, 'views') @@ -57,16 +54,6 @@ def get_view(name): return fd.read() -def git_pull(): - """Git pull the spec repo to get any updates.""" - # This always git-pulls no matter what. We may want to throttle or change this in the future. - subprocess.check_output(['git', '-C', _spec_dir, 'checkout', 'master']) - subprocess.check_output(['git', '-C', _spec_dir, 'fetch', 'origin']) - subprocess.check_output(['git', '-C', _spec_dir, 'merge', 'origin/master']) - # Initialize any collections - arango_client.init_collections(get_schema_names()) - - def _find_paths(dir_path, file_pattern): """ Return all file paths from a filename pattern, starting from a parent From 5d69e6e4e63907a71748cc72546e12c3164580b2 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Mon, 12 Nov 2018 16:37:23 -0800 Subject: [PATCH 093/732] Add the start of the genomes and publications schemas --- spec/schemas/edges/published_in.json | 19 +++++ spec/schemas/vertices/genomes.json | 104 ++++++++++++++++++++++++ spec/schemas/vertices/publications.json | 34 ++++++++ 3 files changed, 157 insertions(+) create mode 100644 spec/schemas/edges/published_in.json create mode 100644 spec/schemas/vertices/genomes.json create mode 100644 spec/schemas/vertices/publications.json diff --git a/spec/schemas/edges/published_in.json b/spec/schemas/edges/published_in.json new file mode 100644 index 00000000..2be69fd8 --- /dev/null +++ b/spec/schemas/edges/published_in.json @@ -0,0 +1,19 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "required": ["_from", "_to"], + "description": "The _from dataset was published in the _to publication", + "additionalProperties": true, + "properties": { + "_from": { + "type": "string", + "description": "The ID of the data that was published in _to" + }, + "_to": { + "type": "string", + "pattern": "^publications/.+$", + "description": "The ID of a publication that was published in _from" + } + } +} + diff --git a/spec/schemas/vertices/genomes.json b/spec/schemas/vertices/genomes.json new file mode 100644 index 00000000..294c67f3 --- /dev/null +++ b/spec/schemas/vertices/genomes.json @@ -0,0 +1,104 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "additionalProperties": false, + "description": "Whole-genome metadata (genes are separate vertices)", + "required": ["_key", "scientific_name", "domain"], + "properties": { + "_key": { + "type": "string", + "description": "Hash of the full set of data contained in this genome." + }, + "refseq_id": { + "type": "string", + "example": "NC_008270.1", + "description": "RefSeq database accession id" + }, + "scientific_name": { + "type": "string", + "example": "Haloferax Volcanii" + }, + "domain": { + "type": "string", + "enum": ["Archaea", "Bacteria", "Eukarya"] + }, + "feature_counts": { + "type": "object", + "additionalProperties": true, + "description": "TODO", + "patternProperties": { + ".*": {"type": "integer"} + } + }, + "genetic_code": { + "type": "integer", + "description": "TODO" + }, + "dna_size": { + "type": "integer", + "title": "Nucleotide count" + }, + "num_contigs": { + "type": "integer", + "title": "Number of contigs", + "description": "Number of consensus regions of the DNA." + }, + "molecule_type": { + "type": "string", + "title": "Molecule type", + "example": "DNA", + "description": "Can include genomic DNA, genomic RNA, precursor RNA, mRNA (cDNA), ribosomal RNA, transfer RNA, small nuclear RNA, and small cytoplasmic RNA" + }, + "contig_lengths": { + "type": "array", + "description": "Nucleotide length of each contig", + "items": {"type": "integer"} + }, + "contig_strings": { + "type": "array", + "description": "Nucleotide content of each contig", + "items": {"type": "string"} + }, + "source": { + "type": "string", + "description": "TODO" + }, + "source_id": { + "type": "string", + "description": "TODO" + }, + "taxonomy": { + "type": "array", + "description": "Full taxonomy parent-to-child linkage up to the domain.", + "example": ["Bacteria", "Actinobacteria", "Corynebacteriales", "Nocardiaceae", "Rhodococcus"], + "items": { + "type": "string" + } + }, + "gc_content": { + "type": "number", + "description": "TODO" + }, + "is_suspect": { + "type": "boolean", + "description": "TODO" + }, + "notes": { + "type": "string", + "description": "TODO" + }, + "original_source_file_name": { + "type": "string", + "description": "TODO" + }, + "external_source_origination_date": { + "type": "string", + "format": "date-time" + }, + "release": { + "type": "string", + "description": "TODO" + } + } +} + diff --git a/spec/schemas/vertices/publications.json b/spec/schemas/vertices/publications.json new file mode 100644 index 00000000..f4d0a482 --- /dev/null +++ b/spec/schemas/vertices/publications.json @@ -0,0 +1,34 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "additionalProperties": false, + "description": "The citation for an academic publication", + "required": ["_key", "scientific_name", "domain"], + "properties": { + "pubmed_id": { + "type": "number" + }, + "source": { + "type": "string", + "example": "Pubmed" + }, + "title": { + "type": "string" + }, + "web_address": { + "type": "string", + "format": "url" + }, + "publication_year": { + "type": "integer", + "min": 1800 + }, + "authors": { + "type": "string" + }, + "journal": { + "type": "string" + } + } +} + From a0d185775d7b5606898b977792db370e18ea714f Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Mon, 12 Nov 2018 16:58:55 -0800 Subject: [PATCH 094/732] Take a stab at features --- spec/schemas/vertices/features.json | 95 +++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 spec/schemas/vertices/features.json diff --git a/spec/schemas/vertices/features.json b/spec/schemas/vertices/features.json new file mode 100644 index 00000000..749e908e --- /dev/null +++ b/spec/schemas/vertices/features.json @@ -0,0 +1,95 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "additionalProperties": false, + "required": [ + "_key", + "type", + "dna_sequence", + "location_start", + "location_end" + ], + "properties": { + "_key": { + "type": "string", + "title": "Content hash", + "description": "Hash of the DNA sequence for this feature." + }, + "type": { + "type": "string", + "enum": ["feature", "non-coding-feature", "CDS", "mRNA"] + }, + "location_start": { + "type": "integer", + "title": "Location start index", + "description": "Index in the genome sequence where this feature starts." + }, + "location_end": { + "type": "integer", + "title": "location end index", + "description": "Location in the genome sequence where this feature ends." + }, + "flags": { + "type": "array", + "description": "TODO", + "items": {"type": "string"} + }, + "warnings": { + "type": "array", + "description": "TODO", + "items": {"type": "string"} + }, + "inference_data": { + "type": "array", + "description": "TODO", + "example": "TODO", + "items": { + "type": "object", + "properties": { + "category": { + "type": "string", + "description": "TODO" + }, + "type": { + "type": "string", + "description": "TODO" + }, + "evidence": { + "type": "string", + "description": "TODO" + } + } + } + }, + "dna_sequence": { + "type": "string", + "description": "Nucleotide sequence for this feature." + }, + "dna_sequence_length": { + "type": "integer", + "description": "Total character/nucleotide length of dna_sequence" + }, + "db_xrefs": { + "type": "array", + "title": "Database cross-references", + "description": "TODO", + "items": { + "type": "object", + "patternProperties": { + ".*": {"type": "string"} + } + } + }, + "aliases": { + "type": "array", + "description": "TODO", + "items": { + "type": "object", + "patternProperties": { + ".*": {"type": "string"} + } + } + } + } +} + From d4ff36c1067b5e915fa0cda2ef976f228e4f934b Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Mon, 12 Nov 2018 17:08:37 -0800 Subject: [PATCH 095/732] Add more feature attributes --- spec/schemas/vertices/apps.json | 3 +-- spec/schemas/vertices/features.json | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/spec/schemas/vertices/apps.json b/spec/schemas/vertices/apps.json index d2c46c40..7fe80301 100644 --- a/spec/schemas/vertices/apps.json +++ b/spec/schemas/vertices/apps.json @@ -1,7 +1,6 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", - "version": 1, "additionalProperties": false, "required": ["_key"], "properties": { @@ -14,4 +13,4 @@ "pattern": "^\\w+\\.\\w+$" } } -} \ No newline at end of file +} diff --git a/spec/schemas/vertices/features.json b/spec/schemas/vertices/features.json index 749e908e..ed912e79 100644 --- a/spec/schemas/vertices/features.json +++ b/spec/schemas/vertices/features.json @@ -2,6 +2,7 @@ "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "additionalProperties": false, + "description": "A component of a DNA sequence, such as a CDS, mRNA, etc.", "required": [ "_key", "type", @@ -15,6 +16,34 @@ "title": "Content hash", "description": "Hash of the DNA sequence for this feature." }, + "protein_translation": { + "type": "string", + "title": "Protein translation", + "description": "Longest coded protein (representative protein for splice variants)" + }, + "protein_translation_length": { + "type": "integer", + "description": "Length of protein_translation" + }, + "protein_hash": { + "type": "string", + "title": "Protein content hash", + "description": "Hash of the protein sequence that this feature encodes." + }, + "note": { + "type": "string", + "description": "TODO" + }, + "functions": { + "type": "array", + "title": "Gene functions", + "items": {"type": "string"} + }, + "functional_descriptions": { + "type": "array", + "title": "Gene function descriptions", + "items": {"type": "string"} + }, "type": { "type": "string", "enum": ["feature", "non-coding-feature", "CDS", "mRNA"] From c89a2c5866f64d919746a799fc7ebf827312e208 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Mon, 12 Nov 2018 17:28:32 -0800 Subject: [PATCH 096/732] Add linter comments --- spec/test/validate.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/test/validate.py b/spec/test/validate.py index 8bec887d..31dfa246 100644 --- a/spec/test/validate.py +++ b/spec/test/validate.py @@ -12,7 +12,7 @@ def validate_json_schemas(): """Validate the syntax of all the JSON schemas.""" print('Validating JSON schemas..') - names = {} + names = {} # type: dict for path in glob.iglob('schemas/**/*.json', recursive=True): name = os.path.basename(path) # Make sure collection is lower snake case @@ -63,7 +63,7 @@ def validate_aql_syntax(): """Validate the syntax of all the queries.""" # TODO check AQL syntax. Unsure how to do this without connecting to a running arango server :/ print('Validating AQL queries..') - names = {} + names = {} # type: dict for path in glob.iglob('views/**/*.aql', recursive=True): name = os.path.basename(path) if names.get(name): From 592f7e5c870eb5929ac695240a754076946701dd Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Mon, 12 Nov 2018 17:34:02 -0800 Subject: [PATCH 097/732] Add a set of files in .gitattributes that get ignored when creating a release tarball --- spec/.gitattributes | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 spec/.gitattributes diff --git a/spec/.gitattributes b/spec/.gitattributes new file mode 100644 index 00000000..c84b3361 --- /dev/null +++ b/spec/.gitattributes @@ -0,0 +1,7 @@ +/CODEOWNERS export-ignore +/.gitattributes export-ignore +/.gitignore export-ignore +/.travis.yaml export-ignore +/README.md export-ignore +/Makefile export-ignore +/test export-ignore From 67e0f7aa2f14dec1a307203de55fd52c6ad654b9 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Mon, 12 Nov 2018 17:37:24 -0800 Subject: [PATCH 098/732] Add nested readmes in .gitattributes --- spec/.gitattributes | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spec/.gitattributes b/spec/.gitattributes index c84b3361..b441f100 100644 --- a/spec/.gitattributes +++ b/spec/.gitattributes @@ -3,5 +3,8 @@ /.gitignore export-ignore /.travis.yaml export-ignore /README.md export-ignore +/migrations/README.md export-ignore +/schemas/README.md export-ignore +/views/README.md export-ignore /Makefile export-ignore /test export-ignore From e85bcc241ea17105da74ceec3a1870b820039968 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Mon, 12 Nov 2018 17:38:08 -0800 Subject: [PATCH 099/732] Simplify readme patterns in gitattributes --- spec/.gitattributes | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/spec/.gitattributes b/spec/.gitattributes index b441f100..eb4fa0e8 100644 --- a/spec/.gitattributes +++ b/spec/.gitattributes @@ -2,9 +2,6 @@ /.gitattributes export-ignore /.gitignore export-ignore /.travis.yaml export-ignore -/README.md export-ignore -/migrations/README.md export-ignore -/schemas/README.md export-ignore -/views/README.md export-ignore +README.md export-ignore /Makefile export-ignore /test export-ignore From 0dbf106c149fffd9b4ff8025ba29389e8f9ae6ac Mon Sep 17 00:00:00 2001 From: JamesJeffryes Date: Tue, 13 Nov 2018 11:04:42 -0600 Subject: [PATCH 100/732] Updates to genome specs --- spec/schemas/vertices/features.json | 87 +++++++++++++------------ spec/schemas/vertices/genomes.json | 39 ++++------- spec/schemas/vertices/publications.json | 16 ++++- 3 files changed, 72 insertions(+), 70 deletions(-) diff --git a/spec/schemas/vertices/features.json b/spec/schemas/vertices/features.json index ed912e79..d77cd024 100644 --- a/spec/schemas/vertices/features.json +++ b/spec/schemas/vertices/features.json @@ -6,9 +6,8 @@ "required": [ "_key", "type", - "dna_sequence", - "location_start", - "location_end" + "location", + "dna_sequence_hash" ], "properties": { "_key": { @@ -32,7 +31,7 @@ }, "note": { "type": "string", - "description": "TODO" + "description": "Free-text discription of this feature" }, "functions": { "type": "array", @@ -46,50 +45,41 @@ }, "type": { "type": "string", - "enum": ["feature", "non-coding-feature", "CDS", "mRNA"] - }, - "location_start": { - "type": "integer", - "title": "Location start index", - "description": "Index in the genome sequence where this feature starts." - }, - "location_end": { - "type": "integer", - "title": "location end index", - "description": "Location in the genome sequence where this feature ends." + "examples": ["Gene", "ncRNA", "repeat", "CDS", "mRNA"] }, + "location": { + "type": "array", + "description": "A list of segments of sequence that comprise this feature" + items: { + "contig": { + "type": "string", + "description": "Contig ID where this segment occurs + } + "strand": { + "type": "string", + "description": "Strand where this segment occurs" + "enum": ["+", "-", "?"] + }, + "start": { + "type": "integer", + "description": "Index in the genome sequence where this segment of the feature starts" + }, + "length": { + "type": "integer", + "description": "Length of this segment of the feature" + } + } + } "flags": { "type": "array", - "description": "TODO", + "description": "Addition flags about the feature such trans_splicing", "items": {"type": "string"} }, "warnings": { "type": "array", - "description": "TODO", + "description": "Warnings generated by the uploader about this feature", "items": {"type": "string"} }, - "inference_data": { - "type": "array", - "description": "TODO", - "example": "TODO", - "items": { - "type": "object", - "properties": { - "category": { - "type": "string", - "description": "TODO" - }, - "type": { - "type": "string", - "description": "TODO" - }, - "evidence": { - "type": "string", - "description": "TODO" - } - } - } - }, "dna_sequence": { "type": "string", "description": "Nucleotide sequence for this feature." @@ -98,24 +88,35 @@ "type": "integer", "description": "Total character/nucleotide length of dna_sequence" }, + "dna_sequence_hash": { + "type": "string", + "description": "The MD5 hash of the feature sequence" + } "db_xrefs": { "type": "array", "title": "Database cross-references", - "description": "TODO", + + "description": "IDs for these feature in other databases, grouped by database", "items": { "type": "object", "patternProperties": { - ".*": {"type": "string"} + ".*": { + "type": "array", + "items": {"type": "string"} + } } } }, "aliases": { "type": "array", - "description": "TODO", + "description": "Aliases for these feature, grouped by alias type", "items": { "type": "object", "patternProperties": { - ".*": {"type": "string"} + ".*": { + "type": "array", + "items": {"type": "string"} + } } } } diff --git a/spec/schemas/vertices/genomes.json b/spec/schemas/vertices/genomes.json index 294c67f3..9c294ac6 100644 --- a/spec/schemas/vertices/genomes.json +++ b/spec/schemas/vertices/genomes.json @@ -25,15 +25,11 @@ "feature_counts": { "type": "object", "additionalProperties": true, - "description": "TODO", + "description": "A count of the number of instaces of each feature type such as CDSs, repeats etc.", "patternProperties": { ".*": {"type": "integer"} } }, - "genetic_code": { - "type": "integer", - "description": "TODO" - }, "dna_size": { "type": "integer", "title": "Nucleotide count" @@ -54,22 +50,27 @@ "description": "Nucleotide length of each contig", "items": {"type": "integer"} }, - "contig_strings": { + "contig_ids": { "type": "array", - "description": "Nucleotide content of each contig", + "description": "The ids of each condtig in the associated assembly", "items": {"type": "string"} }, "source": { "type": "string", - "description": "TODO" + "description": "The tool or database that produced the genome", + "example": ["RefSeq", "Ensembl", "Phytozome", "RAST", "Prokka", "User_upload"] }, "source_id": { "type": "string", - "description": "TODO" + "description": "The ID assigned the to the genome by that source" + }, + "release": { + "type": "string", + "description": "The release version of the source database for this genome if applicable" }, "taxonomy": { "type": "array", - "description": "Full taxonomy parent-to-child linkage up to the domain.", + "description": "Full taxonomy parent-to-child linkage up to the domain", "example": ["Bacteria", "Actinobacteria", "Corynebacteriales", "Nocardiaceae", "Rhodococcus"], "items": { "type": "string" @@ -77,27 +78,15 @@ }, "gc_content": { "type": "number", - "description": "TODO" + "description": "Fraction of GC pairs in the genome" }, "is_suspect": { "type": "boolean", - "description": "TODO" + "description": "Flag indicating that the genome has failed to pass one or more validation tests" }, "notes": { "type": "string", - "description": "TODO" - }, - "original_source_file_name": { - "type": "string", - "description": "TODO" - }, - "external_source_origination_date": { - "type": "string", - "format": "date-time" - }, - "release": { - "type": "string", - "description": "TODO" + "description": "Free text notes from the genome upload" } } } diff --git a/spec/schemas/vertices/publications.json b/spec/schemas/vertices/publications.json index f4d0a482..b390351f 100644 --- a/spec/schemas/vertices/publications.json +++ b/spec/schemas/vertices/publications.json @@ -3,8 +3,20 @@ "type": "object", "additionalProperties": false, "description": "The citation for an academic publication", - "required": ["_key", "scientific_name", "domain"], + "required": [ + "_key", + "pubmed_id", + "source", + "title", + "web_address", + "publication_year", + "authors", + "journal" + ], "properties": { + "_key": { + "type": "number" + }, "pubmed_id": { "type": "number" }, @@ -21,7 +33,7 @@ }, "publication_year": { "type": "integer", - "min": 1800 + "min": 1700 }, "authors": { "type": "string" From 5b33a30be44a16c31a0f9318dbb6781792c95a86 Mon Sep 17 00:00:00 2001 From: JamesJeffryes Date: Tue, 13 Nov 2018 11:12:47 -0600 Subject: [PATCH 101/732] remove duplicate key --- spec/schemas/vertices/features.json | 5 ----- 1 file changed, 5 deletions(-) diff --git a/spec/schemas/vertices/features.json b/spec/schemas/vertices/features.json index d77cd024..d3cb7a74 100644 --- a/spec/schemas/vertices/features.json +++ b/spec/schemas/vertices/features.json @@ -7,7 +7,6 @@ "_key", "type", "location", - "dna_sequence_hash" ], "properties": { "_key": { @@ -88,10 +87,6 @@ "type": "integer", "description": "Total character/nucleotide length of dna_sequence" }, - "dna_sequence_hash": { - "type": "string", - "description": "The MD5 hash of the feature sequence" - } "db_xrefs": { "type": "array", "title": "Database cross-references", From ce4db99b3b301cb6bb4d998e0fe4905226759765 Mon Sep 17 00:00:00 2001 From: JamesJeffryes Date: Tue, 13 Nov 2018 11:39:09 -0600 Subject: [PATCH 102/732] json cleanup --- spec/schemas/vertices/features.json | 18 +++++++++--------- spec/schemas/vertices/genomes.json | 4 ++-- spec/schemas/vertices/publications.json | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/spec/schemas/vertices/features.json b/spec/schemas/vertices/features.json index d3cb7a74..5f4c94d8 100644 --- a/spec/schemas/vertices/features.json +++ b/spec/schemas/vertices/features.json @@ -6,7 +6,7 @@ "required": [ "_key", "type", - "location", + "location" ], "properties": { "_key": { @@ -30,7 +30,7 @@ }, "note": { "type": "string", - "description": "Free-text discription of this feature" + "description": "Free-text description of this feature" }, "functions": { "type": "array", @@ -48,15 +48,15 @@ }, "location": { "type": "array", - "description": "A list of segments of sequence that comprise this feature" - items: { + "description": "A list of segments of sequence that comprise this feature", + "items": { "contig": { "type": "string", - "description": "Contig ID where this segment occurs - } + "description": "Contig ID where this segment occurs" + }, "strand": { "type": "string", - "description": "Strand where this segment occurs" + "description": "Strand where this segment occurs", "enum": ["+", "-", "?"] }, "start": { @@ -68,10 +68,10 @@ "description": "Length of this segment of the feature" } } - } + }, "flags": { "type": "array", - "description": "Addition flags about the feature such trans_splicing", + "description": "Additional flags about the feature such trans_splicing", "items": {"type": "string"} }, "warnings": { diff --git a/spec/schemas/vertices/genomes.json b/spec/schemas/vertices/genomes.json index 9c294ac6..8247d7a0 100644 --- a/spec/schemas/vertices/genomes.json +++ b/spec/schemas/vertices/genomes.json @@ -25,7 +25,7 @@ "feature_counts": { "type": "object", "additionalProperties": true, - "description": "A count of the number of instaces of each feature type such as CDSs, repeats etc.", + "description": "A count of the number of instances of each feature type such as CDSs, repeats etc.", "patternProperties": { ".*": {"type": "integer"} } @@ -52,7 +52,7 @@ }, "contig_ids": { "type": "array", - "description": "The ids of each condtig in the associated assembly", + "description": "The ids of each contig in the associated assembly", "items": {"type": "string"} }, "source": { diff --git a/spec/schemas/vertices/publications.json b/spec/schemas/vertices/publications.json index b390351f..18f72983 100644 --- a/spec/schemas/vertices/publications.json +++ b/spec/schemas/vertices/publications.json @@ -15,7 +15,7 @@ ], "properties": { "_key": { - "type": "number" + "type": "string" }, "pubmed_id": { "type": "number" From 1b70d1fbb1ba62521df62bf510827bc145e58331 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 13 Nov 2018 10:04:56 -0800 Subject: [PATCH 103/732] Remove extra linebreak --- spec/schemas/vertices/features.json | 1 - 1 file changed, 1 deletion(-) diff --git a/spec/schemas/vertices/features.json b/spec/schemas/vertices/features.json index 5f4c94d8..511d1726 100644 --- a/spec/schemas/vertices/features.json +++ b/spec/schemas/vertices/features.json @@ -90,7 +90,6 @@ "db_xrefs": { "type": "array", "title": "Database cross-references", - "description": "IDs for these feature in other databases, grouped by database", "items": { "type": "object", From b52d01d0c9ea37c554ddaccd458d3df4d2bd79f4 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 13 Nov 2018 10:13:23 -0800 Subject: [PATCH 104/732] fix "examples" lines --- spec/schemas/vertices/genomes.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/spec/schemas/vertices/genomes.json b/spec/schemas/vertices/genomes.json index 8247d7a0..d7313d50 100644 --- a/spec/schemas/vertices/genomes.json +++ b/spec/schemas/vertices/genomes.json @@ -11,12 +11,12 @@ }, "refseq_id": { "type": "string", - "example": "NC_008270.1", + "examples": ["NC_008270.1"], "description": "RefSeq database accession id" }, "scientific_name": { "type": "string", - "example": "Haloferax Volcanii" + "examples": ["Haloferax Volcanii"] }, "domain": { "type": "string", @@ -42,7 +42,7 @@ "molecule_type": { "type": "string", "title": "Molecule type", - "example": "DNA", + "examples": ["DNA"], "description": "Can include genomic DNA, genomic RNA, precursor RNA, mRNA (cDNA), ribosomal RNA, transfer RNA, small nuclear RNA, and small cytoplasmic RNA" }, "contig_lengths": { @@ -58,7 +58,7 @@ "source": { "type": "string", "description": "The tool or database that produced the genome", - "example": ["RefSeq", "Ensembl", "Phytozome", "RAST", "Prokka", "User_upload"] + "examples": ["RefSeq", "Ensembl", "Phytozome", "RAST", "Prokka", "User_upload"] }, "source_id": { "type": "string", @@ -71,7 +71,7 @@ "taxonomy": { "type": "array", "description": "Full taxonomy parent-to-child linkage up to the domain", - "example": ["Bacteria", "Actinobacteria", "Corynebacteriales", "Nocardiaceae", "Rhodococcus"], + "examples": [["Bacteria", "Actinobacteria", "Corynebacteriales", "Nocardiaceae", "Rhodococcus"]], "items": { "type": "string" } From 7f72d735a17299f45dfcc451e705140553225375 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 13 Nov 2018 10:28:32 -0800 Subject: [PATCH 105/732] Minor edits --- spec/schemas/vertices/features.json | 1 + spec/schemas/vertices/genomes.json | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/spec/schemas/vertices/features.json b/spec/schemas/vertices/features.json index 511d1726..5790256e 100644 --- a/spec/schemas/vertices/features.json +++ b/spec/schemas/vertices/features.json @@ -106,6 +106,7 @@ "description": "Aliases for these feature, grouped by alias type", "items": { "type": "object", + "description": "All values are arrays of strings", "patternProperties": { ".*": { "type": "array", diff --git a/spec/schemas/vertices/genomes.json b/spec/schemas/vertices/genomes.json index d7313d50..8cfe26cb 100644 --- a/spec/schemas/vertices/genomes.json +++ b/spec/schemas/vertices/genomes.json @@ -3,7 +3,11 @@ "type": "object", "additionalProperties": false, "description": "Whole-genome metadata (genes are separate vertices)", - "required": ["_key", "scientific_name", "domain"], + "required": [ + "_key", + "scientific_name", + "domain" + ], "properties": { "_key": { "type": "string", From 7e2c2ec053a1c838e7efba61de389712ff2f86f1 Mon Sep 17 00:00:00 2001 From: JamesJeffryes Date: Tue, 13 Nov 2018 12:27:43 -0600 Subject: [PATCH 106/732] let there be travis --- spec/{.travis.yaml => .travis.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename spec/{.travis.yaml => .travis.yml} (100%) diff --git a/spec/.travis.yaml b/spec/.travis.yml similarity index 100% rename from spec/.travis.yaml rename to spec/.travis.yml From 77417ee08d7ad64bb60b93a94887e45049e46493 Mon Sep 17 00:00:00 2001 From: JamesJeffryes Date: Tue, 13 Nov 2018 12:36:52 -0600 Subject: [PATCH 107/732] no 3.7 yet? SHAME Travis SHAME! --- spec/.travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/.travis.yml b/spec/.travis.yml index c91a8f8c..82d0f619 100644 --- a/spec/.travis.yml +++ b/spec/.travis.yml @@ -1,5 +1,5 @@ language: python python: -- '3.7' +- 3.6 script: - make test From d730614b107b31ae610c777925c7e3ea210934b4 Mon Sep 17 00:00:00 2001 From: JamesJeffryes Date: Tue, 13 Nov 2018 12:40:30 -0600 Subject: [PATCH 108/732] And we need jsonschema --- spec/.travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spec/.travis.yml b/spec/.travis.yml index 82d0f619..c7b6fcfe 100644 --- a/spec/.travis.yml +++ b/spec/.travis.yml @@ -1,5 +1,7 @@ language: python python: - 3.6 +before_script: +- pip install jsonschema script: - make test From 52118fb0ec2ba281cd23d137c08de04023d5e9d1 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 13 Nov 2018 10:48:31 -0800 Subject: [PATCH 109/732] Some travis yaml fixes --- api/.travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/.travis.yml b/api/.travis.yml index dff73b74..a14319e5 100644 --- a/api/.travis.yml +++ b/api/.travis.yml @@ -3,8 +3,8 @@ services: - docker language: python python: -- '3.7' +- 3.6 script: -- cp .env.development.example .env +- cp .env.example .env - docker-compose up -d - make test From ffe439c53ea9bf321a846c4f0634c6a4b22d9a8f Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 13 Nov 2018 11:14:16 -0800 Subject: [PATCH 110/732] Fix some "examples" properties --- spec/schemas/vertices/chemical_reactions.json | 20 +++++++++---------- .../vertices/gene_reaction_complexes.json | 4 ++-- spec/schemas/vertices/publications.json | 3 +-- spec/schemas/vertices/taxa.json | 4 ++-- 4 files changed, 15 insertions(+), 16 deletions(-) diff --git a/spec/schemas/vertices/chemical_reactions.json b/spec/schemas/vertices/chemical_reactions.json index fbb1872e..9d9b99aa 100644 --- a/spec/schemas/vertices/chemical_reactions.json +++ b/spec/schemas/vertices/chemical_reactions.json @@ -7,7 +7,7 @@ "properties": { "_key": { "type": "string", - "example": "rxn02201", + "examples": ["rxn02201"], "title": "ModelSeed ID", "pattern": "^rxn\\d+$" }, @@ -18,26 +18,26 @@ "name": { "type": "string", "description": "Chemical names", - "example": "trans-2-Methyl-5-isopropylhexa-2,5-dienal dehydrogenase_c0" + "examples": ["trans-2-Methyl-5-isopropylhexa-2,5-dienal dehydrogenase_c0"] }, "gpr": { "type": "string", - "example": "PGN_RS01070" + "examples": ["PGN_RS01070"] }, "ec_number": { "type": "string", - "example": "2.7.3.7", + "examples": ["2.7.3.7"], "title": "Enzyme Commission Number", "pattern": "^\\d+\\.\\d+\\.\\d+\\.\\d+$" }, "bbcwn": { "type": "number", - "example": -108 + "examples": [-108] }, "equation": { "type": "string", "description": "Reaction formula using compound IDs (eg. cd00443)", - "example": "(1) cpd00443[c0] + (1) cpd02920[c0] => (1) cpd00012[c0] + (1) cpd00067[c0] + (1) cpd00683[c0]" + "examples": ["(1) cpd00443[c0] + (1) cpd02920[c0] => (1) cpd00012[c0] + (1) cpd00067[c0] + (1) cpd00683[c0]"] }, "definition": { "type": "string", @@ -45,20 +45,20 @@ }, "bigg_id": { "type": "string", - "example": "DHPS2" + "examples": ["DHPS2"] }, "kegg_id": { "type": "string", - "example": "R03067" + "examples": ["R03067"] }, "kegg_pathways": { "type": "string", - "example": "Folate biosynthesis" + "examples": ["Folate biosynthesis"] }, "metacyc_pathways": { "type": "array", "items": {"type": "string"}, - "example": ["AMINE-DEG", "Creatinine-Degradation", "Degradation"] + "examples": [["AMINE-DEG", "Creatinine-Degradation", "Degradation"]] } } } diff --git a/spec/schemas/vertices/gene_reaction_complexes.json b/spec/schemas/vertices/gene_reaction_complexes.json index 52cf1edf..9e41b04f 100644 --- a/spec/schemas/vertices/gene_reaction_complexes.json +++ b/spec/schemas/vertices/gene_reaction_complexes.json @@ -11,10 +11,10 @@ }, "conjunctions": { "type": "array", - "example": ["A", "B", "C", "D"], + "examples": [["SO_0001", "SO_0001"]], "description": "Array of conjunctions of genes. Eg: (A AND B AND C AND D).", "items": { - "type": "String", + "type": "string", "description": "Gene vertex _key" } } diff --git a/spec/schemas/vertices/publications.json b/spec/schemas/vertices/publications.json index 18f72983..238911e5 100644 --- a/spec/schemas/vertices/publications.json +++ b/spec/schemas/vertices/publications.json @@ -22,7 +22,7 @@ }, "source": { "type": "string", - "example": "Pubmed" + "examples": ["Pubmed"] }, "title": { "type": "string" @@ -43,4 +43,3 @@ } } } - diff --git a/spec/schemas/vertices/taxa.json b/spec/schemas/vertices/taxa.json index 711da348..64f436e9 100644 --- a/spec/schemas/vertices/taxa.json +++ b/spec/schemas/vertices/taxa.json @@ -7,12 +7,12 @@ "properties": { "_key": { "type": "string", - "example": "haloferax_volcanii", + "examples": ["haloferax_volcanii"], "description": "Normalized name (lower-cased and snake-cased)" }, "name": { "type": "string", - "example": "Haloferax Volcanii" + "examples": ["Haloferax Volcanii"] } } } From 757b8f96f19b753e21a8d8cb8ae541ee3c10bb47 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 13 Nov 2018 15:55:01 -0800 Subject: [PATCH 111/732] Add logic to pull specs from github releases, checking IDs --- api/src/relation_engine_server/api.py | 10 +- api/src/relation_engine_server/pull_spec.py | 94 ++++++++++++++++--- api/src/relation_engine_server/spec_loader.py | 11 ++- 3 files changed, 95 insertions(+), 20 deletions(-) diff --git a/api/src/relation_engine_server/api.py b/api/src/relation_engine_server/api.py index de5880a1..0d063a98 100644 --- a/api/src/relation_engine_server/api.py +++ b/api/src/relation_engine_server/api.py @@ -65,13 +65,17 @@ def show_view(name): return flask.Response(spec_loader.get_view(name), mimetype='text/plain') -@api.route('/refresh_specs', methods=['GET']) +@api.route('/update_specs', methods=['GET']) def refresh_specs(): """ Manually pull from the spec git repo to get updates. """ - git_output = pull_spec.pull_spec() - return flask.jsonify({"updates": git_output}) + auth.require_auth_token(['RE_ADMIN']) + status = pull_spec.download_latest( + reset='reset' in flask.request.args, + init_collections='init_collections' in flask.request.args + ) + return flask.jsonify({'status': status}) @api.route('/documents', methods=['PUT']) diff --git a/api/src/relation_engine_server/pull_spec.py b/api/src/relation_engine_server/pull_spec.py index b88fbca9..edc370d6 100644 --- a/api/src/relation_engine_server/pull_spec.py +++ b/api/src/relation_engine_server/pull_spec.py @@ -1,21 +1,91 @@ import os -import subprocess # nosec +import requests +import tarfile +import tempfile +import shutil from . import arango_client, spec_loader _spec_dir = os.environ.get('SPEC_PATH', '/spec') +_api_url = 'https://api.github.com/repos/kbase/relation_engine_spec' +_release_id_path = os.path.join(_spec_dir, '.release_id') -def pull_spec(): - """Download the spec repo to get any updates.""" - # This always git-pulls no matter what. We may want to throttle or change this in the future. - subprocess.check_output(['git', '-C', _spec_dir, 'pull', 'origin', 'master']) # nosec - # Initialize any collections - arango_client.init_collections(spec_loader.get_schema_names()) +def download_latest(reset=False, init_collections=True): + """Check and download the latest spec and extract it to the spec path.""" + if reset and os.path.exists(_spec_dir): + shutil.rmtree(_spec_dir) + os.makedirs(_spec_dir, exist_ok=True) + # Download information about the latest release + release_resp = requests.get(_api_url + '/releases/latest') + release_info = release_resp.json() + if release_resp.status_code != 200: + # This may be a github API rate usage limit, or some other error + return release_info['message'] + if _has_latest_spec(release_info): + return 'already up to date: ' + release_info['tag_name'] + # Download and extract a new release to /spec/repo + spec_repo_path = os.path.join(_spec_dir, 'repo') + tarball_url = release_info['tarball_url'] + resp = requests.get(tarball_url, stream=True) + temp_file = tempfile.NamedTemporaryFile() + # Download from the tarball url to the temp file + _download_file(resp, temp_file.name) + # Extract the downloaded tarball into the spec path + _extract_tarball(temp_file.name, _spec_dir) + temp_file.close() # Also deletes it + # The files will be extracted into a directory like /spec/kbase-relation_engine_spec-xyz + # We want to move that to /spec/repo + _rename_directories(_spec_dir, spec_repo_path) + # Save the release ID to /spec/.release_id + _save_release_id(release_info) + # Initialize all the collections + if init_collections: + schemas = spec_loader.get_schema_names() + arango_client.init_collections(schemas) + return 'updated to ' + release_info['tag_name'] -# Run from bash with `python -m src.relation_engine_server.pull_spec` -if __name__ == '__main__': - print('Pulling relation engine spec..') - pull_spec() - print('..done.') +def _download_file(resp, path): + """Download a streaming response as a file to path.""" + with open(path, 'wb') as tar_file: + for chunk in resp.iter_content(chunk_size=1024): + tar_file.write(chunk) + + +def _extract_tarball(tar_path, dest_dir): + """Extract a gzipped tarball to a destination directory.""" + with tarfile.open(tar_path, 'r:gz') as tar: + tar.extractall(path=dest_dir) + + +def _rename_directories(dir_path, dest_path): + """ + Rename directories under a path. + The files will be extracted into a directory like /spec/kbase-relation_engine_spec-xyz + We want to move it to /spec/repo. + This could probably be improved to be less confusing. + """ + for file_name in os.listdir(dir_path): + file_path = os.path.join(dir_path, file_name) + if os.path.isdir(file_path): + os.rename(file_path, dest_path) + + +def _has_latest_spec(info): + """Check if downloaded release info matches the latest downloaded spec.""" + release_id = str(info['id']) + if os.path.exists(_release_id_path): + with open(_release_id_path, 'r') as fd: + current_release_id = fd.read() + if release_id == current_release_id: + return True + return False + + +def _save_release_id(info): + """Save a release ID as the latest downloaded spec.""" + release_id = str(info['id']) + # Write the release ID to /spec/.release_id + with open(_release_id_path, 'w') as fd: + fd.write(release_id) diff --git a/api/src/relation_engine_server/spec_loader.py b/api/src/relation_engine_server/spec_loader.py index d1fc7fe1..62ae4d46 100644 --- a/api/src/relation_engine_server/spec_loader.py +++ b/api/src/relation_engine_server/spec_loader.py @@ -5,11 +5,12 @@ import os import json -_spec_dir = os.environ.get('SPEC_PATH', '/spec') -_view_dir = os.path.join(_spec_dir, 'views') -_schema_dir = os.path.join(_spec_dir, 'schemas') -_vertex_dir = os.path.join(_schema_dir, 'vertices') -_edge_dir = os.path.join(_schema_dir, 'edges') +_spec_root_dir = os.environ.get('SPEC_PATH', '/spec') +_spec_dir = os.path.join(_spec_root_dir, 'repo') # /spec/repo +_view_dir = os.path.join(_spec_dir, 'views') # /spec/repo/views +_schema_dir = os.path.join(_spec_dir, 'schemas') # /spec/repo/schemas +_vertex_dir = os.path.join(_schema_dir, 'vertices') # /spec/repo/schemas/vertices +_edge_dir = os.path.join(_schema_dir, 'edges') # /spec/repo/schemas/edges def get_schema_names(): From e4b466401e13db631ccfb911208f2b504c47bec3 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 13 Nov 2018 15:55:30 -0800 Subject: [PATCH 112/732] Add a sanity check test on /update_specs, just to guarantee it works --- api/src/test/test_api.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/api/src/test/test_api.py b/api/src/test/test_api.py index a5dadcae..53b10b58 100644 --- a/api/src/test/test_api.py +++ b/api/src/test/test_api.py @@ -51,6 +51,13 @@ def test_root(self): self.assertTrue(resp['commit_hash']) self.assertTrue(resp['repo_url']) + def test_update_specs(self): + resp = requests.get( + url + '/api/update_specs', + headers={'Authorization': 'Bearer ' + auth_token} + ).json() + self.assertTrue(len(resp['status'])) + def test_list_views(self): resp = requests.get(url + '/api/views').json() self.assertTrue('list_all_documents_in_collection' in resp) From 99b78c94dfea50206921a2d862b3054a181e4fbc Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 13 Nov 2018 15:55:44 -0800 Subject: [PATCH 113/732] Add some documentation on /api/update_specs --- api/README.md | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/api/README.md b/api/README.md index ca6a6e5f..95d83906 100644 --- a/api/README.md +++ b/api/README.md @@ -29,7 +29,6 @@ _Example response_ Fetch the registered schema names. _Example request_ - ```sh $ curl -X GET http://relation_engine/api/schemas ``` @@ -84,7 +83,7 @@ _Example response_ } ``` -### POST /query_results +### POST /api/query_results Run a query using a view or a cursor ID. Semantically, this is a GET, but it's a POST to allow better support for passing JSON in the request body (eg. Postman doesn't allow request body data in get requests) @@ -153,7 +152,7 @@ _Response JSON schema_ Results are limited to 100 items. To continue fetching additional results, use the `cursor_id` below: -### PUT /documents +### PUT /api/documents Bulk-update documents by either creating, replacing, or updating. @@ -216,6 +215,20 @@ _Response JSON schema_ } ``` +### GET /api/update_specs + +Manually check and pull spec updates. Requires sysadmin auth. + +_Example_ + +``` +$ curl http://relation_engine/api/update_specs +``` + +_Query params_ +* `init_collections` - optional - boolean - whether to initialize any new collections in arango +* `reset` - optional - boolean - whether to completely reset the spec data (do a clean download and overwrite) + ## Python client API > NOTE: Work in progress -- this is not yet available From 37b886eff7e87ddb6a3b76a00b9d008581245d12 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 13 Nov 2018 16:10:46 -0800 Subject: [PATCH 114/732] A couple small tweaks on test/docs --- api/src/relation_engine_server/api.py | 2 +- api/src/test/test_api.py | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/api/src/relation_engine_server/api.py b/api/src/relation_engine_server/api.py index 0d063a98..7a7a8849 100644 --- a/api/src/relation_engine_server/api.py +++ b/api/src/relation_engine_server/api.py @@ -68,7 +68,7 @@ def show_view(name): @api.route('/update_specs', methods=['GET']) def refresh_specs(): """ - Manually pull from the spec git repo to get updates. + Manually check for updates, download spec releases, and init new collections. """ auth.require_auth_token(['RE_ADMIN']) status = pull_spec.download_latest( diff --git a/api/src/test/test_api.py b/api/src/test/test_api.py index 53b10b58..256e600c 100644 --- a/api/src/test/test_api.py +++ b/api/src/test/test_api.py @@ -55,8 +55,10 @@ def test_update_specs(self): resp = requests.get( url + '/api/update_specs', headers={'Authorization': 'Bearer ' + auth_token} - ).json() - self.assertTrue(len(resp['status'])) + ) + resp_json = resp.json() + self.assertEqual(resp.status_code, 200) + self.assertTrue(len(resp_json['status'])) def test_list_views(self): resp = requests.get(url + '/api/views').json() From 38b5e8d6e76bb65b6981d51ee96dae56ba7571f7 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 13 Nov 2018 16:12:58 -0800 Subject: [PATCH 115/732] Add some query params to the update_specs test --- api/src/test/test_api.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/api/src/test/test_api.py b/api/src/test/test_api.py index 256e600c..170664f8 100644 --- a/api/src/test/test_api.py +++ b/api/src/test/test_api.py @@ -54,7 +54,8 @@ def test_root(self): def test_update_specs(self): resp = requests.get( url + '/api/update_specs', - headers={'Authorization': 'Bearer ' + auth_token} + headers={'Authorization': 'Bearer ' + auth_token}, + params={'reset': '1', 'init_collections': '1'} ) resp_json = resp.json() self.assertEqual(resp.status_code, 200) From bd16308325149193202ab4feeb0c5fc0b35cda9b Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 14 Nov 2018 09:59:46 -0800 Subject: [PATCH 116/732] Wrap a chunk in a context manager --- api/src/relation_engine_server/pull_spec.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/api/src/relation_engine_server/pull_spec.py b/api/src/relation_engine_server/pull_spec.py index edc370d6..16033695 100644 --- a/api/src/relation_engine_server/pull_spec.py +++ b/api/src/relation_engine_server/pull_spec.py @@ -28,12 +28,12 @@ def download_latest(reset=False, init_collections=True): spec_repo_path = os.path.join(_spec_dir, 'repo') tarball_url = release_info['tarball_url'] resp = requests.get(tarball_url, stream=True) - temp_file = tempfile.NamedTemporaryFile() - # Download from the tarball url to the temp file - _download_file(resp, temp_file.name) - # Extract the downloaded tarball into the spec path - _extract_tarball(temp_file.name, _spec_dir) - temp_file.close() # Also deletes it + with tempfile.NamedTemporaryFile() as temp_file: + # The temp file will be closed/deleted when the context ends + # Download from the tarball url to the temp file + _download_file(resp, temp_file.name) + # Extract the downloaded tarball into the spec path + _extract_tarball(temp_file.name, _spec_dir) # The files will be extracted into a directory like /spec/kbase-relation_engine_spec-xyz # We want to move that to /spec/repo _rename_directories(_spec_dir, spec_repo_path) From 7aeb820df30e4b4a02c87756e7926736fb424db2 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 14 Nov 2018 12:04:42 -0800 Subject: [PATCH 117/732] Refactor edge semantics --- spec/schemas/edges/is_copy_of.json | 23 ------------- spec/schemas/edges/is_equal_to.json | 11 +++++++ spec/schemas/edges/is_produced_by.json | 2 +- spec/schemas/edges/refers_to.json | 18 ++--------- spec/schemas/edges/was_created_by.json | 32 ------------------- ...reated_with.json => was_created_from.json} | 11 +++---- spec/schemas/edges/was_created_using.json | 18 +++++++++++ .../edges/was_input_in_creation_of.json | 23 ------------- spec/was_copied_from.json | 11 +++++++ 9 files changed, 49 insertions(+), 100 deletions(-) delete mode 100644 spec/schemas/edges/is_copy_of.json create mode 100644 spec/schemas/edges/is_equal_to.json delete mode 100644 spec/schemas/edges/was_created_by.json rename spec/schemas/edges/{was_created_with.json => was_created_from.json} (58%) create mode 100644 spec/schemas/edges/was_created_using.json delete mode 100644 spec/schemas/edges/was_input_in_creation_of.json create mode 100644 spec/was_copied_from.json diff --git a/spec/schemas/edges/is_copy_of.json b/spec/schemas/edges/is_copy_of.json deleted file mode 100644 index ef5f66fc..00000000 --- a/spec/schemas/edges/is_copy_of.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "additionalProperties": false, - "required": ["_from", "_to"], - "description": "The _from object was created as an exact copy of the _to object.", - "properties": { - "_from": { - "type": "string", - "examples": [ - "ws_object_versions/35414:73:1" - ], - "description": "A versioned workspace object" - }, - "_to": { - "type": "string", - "examples": [ - "ws_object_versions/35414:73:1" - ], - "description": "A versioned workspace object" - } - } -} diff --git a/spec/schemas/edges/is_equal_to.json b/spec/schemas/edges/is_equal_to.json new file mode 100644 index 00000000..ba3b5361 --- /dev/null +++ b/spec/schemas/edges/is_equal_to.json @@ -0,0 +1,11 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "required": ["_from", "_to"], + "description": "The _from entity is exactly equal to the _to entity.", + "properties": { + "_from": { "type": "string" }, + "_to": { "type": "string" } + } +} + diff --git a/spec/schemas/edges/is_produced_by.json b/spec/schemas/edges/is_produced_by.json index eba921cd..39daa2a8 100644 --- a/spec/schemas/edges/is_produced_by.json +++ b/spec/schemas/edges/is_produced_by.json @@ -2,7 +2,7 @@ "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "required": ["_from", "_to"], - "description": "An entity produced from something else. Eg: reactions -> is_produced_by -> gene_reaction_complexes", + "description": "An entity produced from something else. Eg: reactions -> is_produced_by -> gene_reaction_complexes. This is in contrast to `was_created_from` or `was_created_using`, because this represents the relationship '_from is generally produced by _to' (and may be produced by other things), instead of '_from was specifically created from the data in _to'", "additionalProperties": true, "properties": { "_from": { diff --git a/spec/schemas/edges/refers_to.json b/spec/schemas/edges/refers_to.json index 3c9b2e2d..f39de906 100644 --- a/spec/schemas/edges/refers_to.json +++ b/spec/schemas/edges/refers_to.json @@ -3,21 +3,9 @@ "type": "object", "additionalProperties": false, "required": ["_from", "_to"], - "description": "The _from object possess an attribute which is a reference to the _to object.", + "description": "The _from entity has an attribute which is a reference to the _to object.", "properties": { - "_from": { - "type": "string", - "examples": [ - "ws_object_versions/35414:73:1" - ], - "description": "A versioned workspace object" - }, - "_to": { - "type": "string", - "examples": [ - "ws_object_versions/35414:73:1" - ], - "description": "A versioned workspace object" - } + "_from": { "type": "string" }, + "_to": { "type": "string" } } } diff --git a/spec/schemas/edges/was_created_by.json b/spec/schemas/edges/was_created_by.json deleted file mode 100644 index 813612c6..00000000 --- a/spec/schemas/edges/was_created_by.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "additionalProperties": false, - "required": [ - "_from", - "_to", - "method_params" - ], - "description": "The _from object was generated by a method that utilized the _to module version.", - "properties": { - "_from": { - "type": "string", - "examples": [ - "ws_object_versions/35414:73:1" - ], - "description": "A versioned workspace object" - }, - "_to": { - "type": "string", - "examples": [ - "app_versions/kb_uploadmethods:8ebb66e4f2c27bc4a9b7cddff7d7b0f27f4ee433.import_genbank_from_staging", - "app_versions/kb_uploadmethods:UNKNOWN.import_genbank_from_staging" - ], - "description": "A version of app" - }, - "method_params": { - "type": "object", - "description": "The input parameters for the method used to create the object." - } - } -} diff --git a/spec/schemas/edges/was_created_with.json b/spec/schemas/edges/was_created_from.json similarity index 58% rename from spec/schemas/edges/was_created_with.json rename to spec/schemas/edges/was_created_from.json index df26161d..98480da2 100644 --- a/spec/schemas/edges/was_created_with.json +++ b/spec/schemas/edges/was_created_from.json @@ -3,21 +3,20 @@ "type": "object", "additionalProperties": false, "required": ["_from", "_to"], - "description": "The _from object was generated by a method that utilized the _to module version.", + "description": "The _from entity is derived from the _to data. Eg: an assembly is created *from* reads.", "properties": { "_from": { "type": "string", - "examples": [ - "ws_object_versions/35414:73:1" - ], - "description": "A versioned workspace object" + "description": "The entity that was created." }, "_to": { "type": "string", "examples": [ "app_module_versions/kb_uploadmethods:8ebb66e4f2c27bc4a9b7cddff7d7b0f27f4ee433" ], - "description": "A version of module" + "description": "The originating data that led to the creation of the _from data." } } } + + diff --git a/spec/schemas/edges/was_created_using.json b/spec/schemas/edges/was_created_using.json new file mode 100644 index 00000000..59ccd77d --- /dev/null +++ b/spec/schemas/edges/was_created_using.json @@ -0,0 +1,18 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "additionalProperties": false, + "required": ["_from", "_to"], + "description": "The _from entity was created using the _to entity as config or a tool. Eg: an assembly is created *using* spades, or homology data was created *using* mash sketches.", + "properties": { + "_from": { + "type": "string", + "description": "The entity that was created." + }, + "_to": { + "type": "string", + "description": "The tool, configuration, or parameter that took part in the creation of _to." + } + } +} + diff --git a/spec/schemas/edges/was_input_in_creation_of.json b/spec/schemas/edges/was_input_in_creation_of.json deleted file mode 100644 index 97a6a265..00000000 --- a/spec/schemas/edges/was_input_in_creation_of.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "additionalProperties": false, - "required": ["_from", "_to"], - "description": "The _from object was used as an input in the app that created the _to object.", - "properties": { - "_from": { - "type": "string", - "examples": [ - "ws_object_versions/35414:73:1" - ], - "description": "A versioned workspace object" - }, - "_to": { - "type": "string", - "examples": [ - "ws_object_versions/35414:73:1" - ], - "description": "A versioned workspace object" - } - } -} diff --git a/spec/was_copied_from.json b/spec/was_copied_from.json new file mode 100644 index 00000000..c197be04 --- /dev/null +++ b/spec/was_copied_from.json @@ -0,0 +1,11 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "additionalProperties": false, + "required": ["_from", "_to"], + "description": "The _from object was created as an exact copy of the _to object.", + "properties": { + "_from": { "type": "string" }, + "_to": { "type": "string" } + } +} From bb0eb6057704a5711fc932555f982ae9c7cad148 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 14 Nov 2018 12:56:20 -0800 Subject: [PATCH 118/732] More clarification in was_created_from; --- spec/schemas/edges/was_created_from.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/schemas/edges/was_created_from.json b/spec/schemas/edges/was_created_from.json index 98480da2..c793a7ea 100644 --- a/spec/schemas/edges/was_created_from.json +++ b/spec/schemas/edges/was_created_from.json @@ -3,7 +3,7 @@ "type": "object", "additionalProperties": false, "required": ["_from", "_to"], - "description": "The _from entity is derived from the _to data. Eg: an assembly is created *from* reads.", + "description": "The _from entity is derived from the _to data. Eg: an assembly is created *from* reads, a house is created *from* wood.", "properties": { "_from": { "type": "string", @@ -14,7 +14,7 @@ "examples": [ "app_module_versions/kb_uploadmethods:8ebb66e4f2c27bc4a9b7cddff7d7b0f27f4ee433" ], - "description": "The originating data that led to the creation of the _from data." + "description": "The originating data that was material in the creation of the _from data." } } } From bb219fe86f12a2ef52ae8cd8b78bf27ab34f0d39 Mon Sep 17 00:00:00 2001 From: JamesJeffryes Date: Wed, 14 Nov 2018 15:00:14 -0600 Subject: [PATCH 119/732] Add workspace IDs for use with access control --- spec/schemas/vertices/ws_object_versions.json | 20 +++++++++++++++++++ spec/schemas/vertices/ws_objects.json | 16 ++++++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/spec/schemas/vertices/ws_object_versions.json b/spec/schemas/vertices/ws_object_versions.json index 73ffc26c..707abf1f 100644 --- a/spec/schemas/vertices/ws_object_versions.json +++ b/spec/schemas/vertices/ws_object_versions.json @@ -4,6 +4,11 @@ "additionalProperties": false, "required": [ "_key", + "workspace_id", + "object_id", + "version", + "name", + "hash", "size", "epoch" ], @@ -16,6 +21,21 @@ ], "pattern": "^\\d+:\\d+:\\d+$" }, + "workspace_id": { + "type": "integer", + "description": "The workspace_id for this object", + "minimum": 1 + }, + "object_id": { + "type": "integer", + "description": "The permanent object id", + "minimum": 1 + }, + "version": { + "type": "integer", + "description": "The object's version", + "minimum": 1 + }, "name": { "type": "string", "description": "The user supplied name for this object", diff --git a/spec/schemas/vertices/ws_objects.json b/spec/schemas/vertices/ws_objects.json index 9f9a144d..edcc7468 100644 --- a/spec/schemas/vertices/ws_objects.json +++ b/spec/schemas/vertices/ws_objects.json @@ -2,7 +2,11 @@ "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "additionalProperties": false, - "required": ["_key"], + "required": [ + "_key", + "workspace_id", + "object_id" + ], "properties": { "_key": { "type": "string", @@ -11,6 +15,16 @@ "35414:73" ], "pattern": "^\\d+:\\d+$" + }, + "workspace_id": { + "type": "integer", + "description": "The workspace_id for this object", + "minimum": 1 + }, + "object_id": { + "type": "integer", + "description": "The permanent object id", + "minimum": 1 } } } From ebadfa90b6c9ce2527d718944846bedc49285add Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 14 Nov 2018 13:41:42 -0800 Subject: [PATCH 120/732] Rename is_equal_to to is_identical_to --- spec/schemas/edges/{is_equal_to.json => is_identical_to.json} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename spec/schemas/edges/{is_equal_to.json => is_identical_to.json} (72%) diff --git a/spec/schemas/edges/is_equal_to.json b/spec/schemas/edges/is_identical_to.json similarity index 72% rename from spec/schemas/edges/is_equal_to.json rename to spec/schemas/edges/is_identical_to.json index ba3b5361..61938e05 100644 --- a/spec/schemas/edges/is_equal_to.json +++ b/spec/schemas/edges/is_identical_to.json @@ -2,7 +2,7 @@ "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "required": ["_from", "_to"], - "description": "The _from entity is exactly equal to the _to entity.", + "description": "The _from entity is exactly identical to the _to entity.", "properties": { "_from": { "type": "string" }, "_to": { "type": "string" } From 600c73473228fcb95f31d8962a240e6ca63af656 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 14 Nov 2018 14:57:04 -0800 Subject: [PATCH 121/732] Move around some module and method stuff --- spec/schemas/edges/was_created_from.json | 3 - .../ws_object_was_created_with_method.json | 28 ++++++++++ .../ws_object_was_created_with_module.json | 28 ++++++++++ .../vertices/sdk_module_method_versions.json | 56 +++++++++++++++++++ .../{apps.json => sdk_module_methods.json} | 0 ...versions.json => sdk_module_versions.json} | 5 +- .../{app_modules.json => sdk_modules.json} | 0 7 files changed, 114 insertions(+), 6 deletions(-) create mode 100644 spec/schemas/edges/ws_object_was_created_with_method.json create mode 100644 spec/schemas/edges/ws_object_was_created_with_module.json create mode 100644 spec/schemas/vertices/sdk_module_method_versions.json rename spec/schemas/vertices/{apps.json => sdk_module_methods.json} (100%) rename spec/schemas/vertices/{app_module_versions.json => sdk_module_versions.json} (93%) rename spec/schemas/vertices/{app_modules.json => sdk_modules.json} (100%) diff --git a/spec/schemas/edges/was_created_from.json b/spec/schemas/edges/was_created_from.json index c793a7ea..44d856db 100644 --- a/spec/schemas/edges/was_created_from.json +++ b/spec/schemas/edges/was_created_from.json @@ -11,9 +11,6 @@ }, "_to": { "type": "string", - "examples": [ - "app_module_versions/kb_uploadmethods:8ebb66e4f2c27bc4a9b7cddff7d7b0f27f4ee433" - ], "description": "The originating data that was material in the creation of the _from data." } } diff --git a/spec/schemas/edges/ws_object_was_created_with_method.json b/spec/schemas/edges/ws_object_was_created_with_method.json new file mode 100644 index 00000000..1a466e2e --- /dev/null +++ b/spec/schemas/edges/ws_object_was_created_with_method.json @@ -0,0 +1,28 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "additionalProperties": false, + "required": ["_from", "_to", "method_params"], + "description": "The _from object was generated by the _to module method.", + "properties": { + "_from": { + "type": "string", + "examples": ["ws_object_versions/35414:73:1"], + "pattern": "^ws_object_versions/.+$", + "description": "A versioned workspace object." + }, + "_to": { + "type": "string", + "examples": [ + "sdk_module_method_versions/kb_uploadmethods:8ebb66e4f2c27bc4a9b7cddff7d7b0f27f4ee433.import_genbank_from_staging", + "sdk_module_method_versions/kb_uploadmethods:UNKNOWN.import_genbank_from_staging" + ], + "pattern": "^sdk_module_method_versions/.+$", + "description": "A version of a module with a method." + }, + "method_params": { + "type": "object", + "description": "The input parameters for the method used to create the object." + } + } +} diff --git a/spec/schemas/edges/ws_object_was_created_with_module.json b/spec/schemas/edges/ws_object_was_created_with_module.json new file mode 100644 index 00000000..ddf26060 --- /dev/null +++ b/spec/schemas/edges/ws_object_was_created_with_module.json @@ -0,0 +1,28 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "additionalProperties": false, + "required": ["_from", "_to", "method_params"], + "description": "The _from object was generated by the _to module version.", + "properties": { + "_from": { + "type": "string", + "examples": ["ws_object_versions/35414:73:1"], + "pattern": "^ws_object_versions/.+$", + "description": "A versioned workspace object." + }, + "_to": { + "type": "string", + "examples": [ + "sdk_module_versions/kb_uploadmethods:8ebb66e4f2c27bc4a9b7cddff7d7b0f27f4ee433.import_genbank_from_staging", + "sdk_module_versions/kb_uploadmethods:UNKNOWN.import_genbank_from_staging" + ], + "pattern": "^sdk_module_versions/.+$", + "description": "A version of an SDK module." + }, + "method_params": { + "type": "object", + "description": "The input parameters for the method used to create the object." + } + } +} diff --git a/spec/schemas/vertices/sdk_module_method_versions.json b/spec/schemas/vertices/sdk_module_method_versions.json new file mode 100644 index 00000000..f25d9d38 --- /dev/null +++ b/spec/schemas/vertices/sdk_module_method_versions.json @@ -0,0 +1,56 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "additionalProperties": false, + "description": "A specific method within a version of an SDK module.", + "required": [ + "_key", + "module_name", + "method_name", + "commit", + "ver", + "code_url" + ], + "properties": { + "_key": { + "type": "string", + "examples": [ + "module_name:version_hash.method_name", + "module_name:UNKNOWN.method_name", + "sdk_module_method_versions/kb_uploadmethods:8ebb66e4f2c27bc4a9b7cddff7d7b0f27f4ee433.import_genbank_from_staging" + ], + "description": ":.", + "pattern": "^\\w+:\\w+\\.\\w+$" + }, + "module_name": { + "type": "string", + "examples": ["kb_uploadmethods"], + "pattern": "^\\w+$" + }, + "method_name": { + "type": "string", + "examples": ["import_genbank_from_staging"], + "pattern": "^\\w+$" + }, + "commit": { + "type": "string", + "examples": ["8ebb66e4f2c27bc4a9b7cddff7d7b0f27f4ee433"], + "title": "Git commit hash", + "pattern": "^\\w+$" + }, + "ver": { + "type": "string", + "examples": ["1.0.13"], + "title": "Version", + "description": "Semantic version of the module", + "pattern": "^\\d+\\.\\d+\\.\\d+$" + }, + "code_url": { + "type": "string", + "examples": [ + "https://github.com/kbaseapps/kb_uploadmethods" + ], + "title": "URL of source code" + } + } +} diff --git a/spec/schemas/vertices/apps.json b/spec/schemas/vertices/sdk_module_methods.json similarity index 100% rename from spec/schemas/vertices/apps.json rename to spec/schemas/vertices/sdk_module_methods.json diff --git a/spec/schemas/vertices/app_module_versions.json b/spec/schemas/vertices/sdk_module_versions.json similarity index 93% rename from spec/schemas/vertices/app_module_versions.json rename to spec/schemas/vertices/sdk_module_versions.json index 46fdec40..fd371de9 100644 --- a/spec/schemas/vertices/app_module_versions.json +++ b/spec/schemas/vertices/sdk_module_versions.json @@ -20,9 +20,8 @@ }, "name": { "type": "string", - "examples": [ - "kb_uploadmethods" - ], + "title": "Module name", + "examples": ["kb_uploadmethods"], "pattern": "^\\w+$" }, "commit": { diff --git a/spec/schemas/vertices/app_modules.json b/spec/schemas/vertices/sdk_modules.json similarity index 100% rename from spec/schemas/vertices/app_modules.json rename to spec/schemas/vertices/sdk_modules.json From bed9194da8dd67e0be69a11a4c3d557b79972084 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 14 Nov 2018 15:03:30 -0800 Subject: [PATCH 122/732] Move schema to its correct place --- spec/{ => schemas/vertices}/was_copied_from.json | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename spec/{ => schemas/vertices}/was_copied_from.json (100%) diff --git a/spec/was_copied_from.json b/spec/schemas/vertices/was_copied_from.json similarity index 100% rename from spec/was_copied_from.json rename to spec/schemas/vertices/was_copied_from.json From fdddd77bbb5ed20d19aa4b73adec89ce76d45aea Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 14 Nov 2018 15:06:26 -0800 Subject: [PATCH 123/732] Move schema to its correct place --- spec/schemas/{vertices => edges}/was_copied_from.json | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename spec/schemas/{vertices => edges}/was_copied_from.json (100%) diff --git a/spec/schemas/vertices/was_copied_from.json b/spec/schemas/edges/was_copied_from.json similarity index 100% rename from spec/schemas/vertices/was_copied_from.json rename to spec/schemas/edges/was_copied_from.json From 5a88f8f25e436acbcd18be5c76571ff891aeaf61 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 14 Nov 2018 15:07:55 -0800 Subject: [PATCH 124/732] Remove unneeded edge `ws_object_was_created_with_module.json` --- .../ws_object_was_created_with_module.json | 28 ------------------- 1 file changed, 28 deletions(-) delete mode 100644 spec/schemas/edges/ws_object_was_created_with_module.json diff --git a/spec/schemas/edges/ws_object_was_created_with_module.json b/spec/schemas/edges/ws_object_was_created_with_module.json deleted file mode 100644 index ddf26060..00000000 --- a/spec/schemas/edges/ws_object_was_created_with_module.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "additionalProperties": false, - "required": ["_from", "_to", "method_params"], - "description": "The _from object was generated by the _to module version.", - "properties": { - "_from": { - "type": "string", - "examples": ["ws_object_versions/35414:73:1"], - "pattern": "^ws_object_versions/.+$", - "description": "A versioned workspace object." - }, - "_to": { - "type": "string", - "examples": [ - "sdk_module_versions/kb_uploadmethods:8ebb66e4f2c27bc4a9b7cddff7d7b0f27f4ee433.import_genbank_from_staging", - "sdk_module_versions/kb_uploadmethods:UNKNOWN.import_genbank_from_staging" - ], - "pattern": "^sdk_module_versions/.+$", - "description": "A version of an SDK module." - }, - "method_params": { - "type": "object", - "description": "The input parameters for the method used to create the object." - } - } -} From 0811992ded3125bba265064d02eaac2ae5fe8321 Mon Sep 17 00:00:00 2001 From: JamesJeffryes Date: Thu, 15 Nov 2018 09:45:54 -0600 Subject: [PATCH 125/732] add "is_instance_of" to link objects and types (for now) --- spec/schemas/edges/is_instance_of.json | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 spec/schemas/edges/is_instance_of.json diff --git a/spec/schemas/edges/is_instance_of.json b/spec/schemas/edges/is_instance_of.json new file mode 100644 index 00000000..9cdd20b4 --- /dev/null +++ b/spec/schemas/edges/is_instance_of.json @@ -0,0 +1,11 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "additionalProperties": false, + "required": ["_from", "_to"], + "description": "The _from entity is an instance of the _to entity.", + "properties": { + "_from": { "type": "string" }, + "_to": { "type": "string" } + } +} From cd7ca30dde328c932900b74579de17eaed646c79 Mon Sep 17 00:00:00 2001 From: JamesJeffryes Date: Thu, 15 Nov 2018 15:47:56 -0600 Subject: [PATCH 126/732] update WS objects --- spec/schemas/vertices/workspaces.json | 16 ++++++++-------- spec/schemas/vertices/ws_object_versions.json | 6 +++++- spec/schemas/vertices/ws_objects.json | 6 +++++- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/spec/schemas/vertices/workspaces.json b/spec/schemas/vertices/workspaces.json index e7129038..37332059 100644 --- a/spec/schemas/vertices/workspaces.json +++ b/spec/schemas/vertices/workspaces.json @@ -5,7 +5,7 @@ "required": [ "_key", "name", - "moddate", + "mod_epoch", "public" ], "properties": { @@ -24,16 +24,16 @@ "jjeffryes:narrative_1534187093329" ] }, - "moddate": { - "type": "string", - "description": "Date when the Workspace was last modified", - "examples": [ - "2014-04-09T19:40:25+0000" - ], - "format": "date-time" + "mod_epoch": { + "type": "integer", + "description": "Epoch when the Workspace was last modified", + "minimum": 0 }, "public": { "type": "boolean" + }, + "deleted": { + "type": "boolean" } } } diff --git a/spec/schemas/vertices/ws_object_versions.json b/spec/schemas/vertices/ws_object_versions.json index 707abf1f..b3c9fa2e 100644 --- a/spec/schemas/vertices/ws_object_versions.json +++ b/spec/schemas/vertices/ws_object_versions.json @@ -10,7 +10,8 @@ "name", "hash", "size", - "epoch" + "epoch", + "deleted" ], "properties": { "_key": { @@ -61,6 +62,9 @@ "description": "Creation time in UTC epoch", "default": 0, "minimum": 0 + }, + "deleted": { + "type": "boolean" } } } diff --git a/spec/schemas/vertices/ws_objects.json b/spec/schemas/vertices/ws_objects.json index edcc7468..9d7f244a 100644 --- a/spec/schemas/vertices/ws_objects.json +++ b/spec/schemas/vertices/ws_objects.json @@ -5,7 +5,8 @@ "required": [ "_key", "workspace_id", - "object_id" + "object_id", + "deleted" ], "properties": { "_key": { @@ -25,6 +26,9 @@ "type": "integer", "description": "The permanent object id", "minimum": 1 + }, + "deleted": { + "type": "boolean" } } } From 528560e68b7deea5be4d4ce7d43cc72774c817a3 Mon Sep 17 00:00:00 2001 From: JamesJeffryes Date: Thu, 15 Nov 2018 15:48:23 -0600 Subject: [PATCH 127/732] add edges for sdk modules --- spec/schemas/edges/is_consumed_by.json | 19 +++++++++++++++++++ spec/schemas/edges/is_version_of.json | 5 +++++ spec/schemas/vertices/sdk_modules.json | 15 ++++++++++++++- 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 spec/schemas/edges/is_consumed_by.json diff --git a/spec/schemas/edges/is_consumed_by.json b/spec/schemas/edges/is_consumed_by.json new file mode 100644 index 00000000..f6ce5596 --- /dev/null +++ b/spec/schemas/edges/is_consumed_by.json @@ -0,0 +1,19 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "required": ["_from", "_to"], + "description": "An entity consumed by something else. For example a type -> is_consumed_by -> sdk_method_version", + "additionalProperties": true, + "properties": { + "_from": { + "type": "string", + "description": "The ID of a vertex that consumes something else." + }, + "_to": { + "type": "string", + "description": "The ID of a vertex that is consumed by something else." + } + } +} + + diff --git a/spec/schemas/edges/is_version_of.json b/spec/schemas/edges/is_version_of.json index 0d439434..d6478bb3 100644 --- a/spec/schemas/edges/is_version_of.json +++ b/spec/schemas/edges/is_version_of.json @@ -19,6 +19,11 @@ "app_modules/kb_uploadmethods" ], "description": "The non-versioned entity group, where all members of the group are different versions of something (eg. a workspace object, module, or workspace type)." + }, + "tag": { + "type": "string", + "description": "Tags for entities managed by catalog", + "enum": ["release", "beta", "dev"] } } } diff --git a/spec/schemas/vertices/sdk_modules.json b/spec/schemas/vertices/sdk_modules.json index 94989fd4..456c0a6d 100644 --- a/spec/schemas/vertices/sdk_modules.json +++ b/spec/schemas/vertices/sdk_modules.json @@ -2,7 +2,11 @@ "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "additionalProperties": false, - "required": ["_key"], + "required": [ + "_key", + "language", + "dynamic_service" + ], "properties": { "_key": { "type": "string", @@ -10,6 +14,15 @@ "kb_uploadmethods" ], "pattern": "^\\w+$" + }, + "language": { + "type": "string", + "enum": ["python", "perl", "java"], + "description": "The programing language the module is written in" + }, + "dynamic_service": { + "type": "boolean", + "description": "Indicates if the module can be run as a webservice" } } } From e6abb0fc80376ea4153b56f3417e84b37b6e3180 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Mon, 19 Nov 2018 15:06:15 -0800 Subject: [PATCH 128/732] Add the ability for sysadmins to run ad-hoc queries --- api/README.md | 12 +++++++++++ api/src/relation_engine_server/api.py | 14 ++++++++++--- api/src/test/test_api.py | 29 ++++++++++++++++++++++++++- 3 files changed, 51 insertions(+), 4 deletions(-) diff --git a/api/README.md b/api/README.md index 95d83906..e7137b7b 100644 --- a/api/README.md +++ b/api/README.md @@ -152,6 +152,18 @@ _Response JSON schema_ Results are limited to 100 items. To continue fetching additional results, use the `cursor_id` below: +#### Ad-hoc sysadmin queries + +System admins can run ad-hoc queries by specifying a "query" property in the JSON request body. + +```sh +$ curl -X POST \ + -d '{"query": "for v in coll sort rand() limit @count return v", "count": 1}' \ + http://relation_engine/api/query?view=example +``` + +This will return the same form of results as above. + ### PUT /api/documents Bulk-update documents by either creating, replacing, or updating. diff --git a/api/src/relation_engine_server/api.py b/api/src/relation_engine_server/api.py index 7a7a8849..3478e9af 100644 --- a/api/src/relation_engine_server/api.py +++ b/api/src/relation_engine_server/api.py @@ -23,12 +23,20 @@ def run_query(): Run a stored view as a query against the database. Auth: only kbase users (any role) """ - auth.require_auth_token(roles=[]) + json_body = flask.request.json or {} + if 'query' in json_body: + # Run an adhoc query for a sysadmin + auth.require_auth_token(roles=['RE_ADMIN']) + query_text = json_body['query'] + del json_body['query'] + resp = arango_client.run_query(query_text=query_text, bind_vars=json_body) + return flask.jsonify(resp) + else: + auth.require_auth_token(roles=[]) if 'view' in flask.request.args: view_name = flask.request.args['view'] view_source = spec_loader.get_view(view_name) - bind_vars = flask.request.json or {} - resp = arango_client.run_query(query_text=view_source, bind_vars=bind_vars) + resp = arango_client.run_query(query_text=view_source, bind_vars=json_body) elif 'cursor_id' in flask.request.args: cursor_id = flask.request.args['cursor_id'] resp = arango_client.run_query(cursor_id=cursor_id) diff --git a/api/src/test/test_api.py b/api/src/test/test_api.py index 170664f8..b1e0856b 100644 --- a/api/src/test/test_api.py +++ b/api/src/test/test_api.py @@ -10,7 +10,7 @@ url = os.environ.get('TEST_URL', 'http://web:5000') auth_token = os.environ.get('KBASE_TEST_AUTH_TOKEN', '') -headers = {'Authorization': 'Bearer ' + auth_token} +headers = {'Authorization': 'Bearer ' + auth_token, 'Content-Type': 'application/json'} def create_test_docs(count): @@ -199,6 +199,33 @@ def test_save_documents_ignore_dupes(self): expected = {'created': 0, 'errors': 0, 'empty': 0, 'updated': 0, 'ignored': 3, 'error': False} self.assertEqual(resp, expected) + def test_admin_query(self): + """Test an ad-hoc query made by an admin.""" + resp = requests.post( + url + '/api/query_results', + params={}, + headers=headers, + data=json.dumps({ + 'query': 'for v in example_vertices sort rand() limit @count return v._id', + 'count': 1 + }) + ).json() + self.assertEqual(resp['count'], 1) + self.assertEqual(len(resp['results']), 1) + + def test_admin_query_invalid_auth(self): + """Test the error response for an ad-hoc admin query without auth.""" + resp = requests.post( + url + '/api/query_results', + params={}, + headers={'Content-Type': 'application/json', 'Authorization': 'xyz'}, + data=json.dumps({ + 'query': 'for v in example_vertices sort rand() limit @count return v._id', + 'count': 1 + }) + ).json() + self.assertEqual(resp['error'], '403 - Unauthorized') + def test_query(self): """Test a basic query that fetches some docs.""" save_test_docs(3) From dd98987fedeb533e41ac0f36caff0058c3bf29ce Mon Sep 17 00:00:00 2001 From: JamesJeffryes Date: Tue, 20 Nov 2018 09:21:51 -0700 Subject: [PATCH 129/732] add 'r' as a valid programming language --- spec/schemas/vertices/sdk_modules.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/schemas/vertices/sdk_modules.json b/spec/schemas/vertices/sdk_modules.json index 456c0a6d..36bb0fde 100644 --- a/spec/schemas/vertices/sdk_modules.json +++ b/spec/schemas/vertices/sdk_modules.json @@ -17,7 +17,7 @@ }, "language": { "type": "string", - "enum": ["python", "perl", "java"], + "enum": ["python", "perl", "java", "r"], "description": "The programing language the module is written in" }, "dynamic_service": { From a90baba1d1caffbde7adf51b28454adf2c44ed90 Mon Sep 17 00:00:00 2001 From: JamesJeffryes Date: Tue, 20 Nov 2018 09:47:37 -0700 Subject: [PATCH 130/732] relax username validation (let's let the WS handle this) --- spec/schemas/vertices/users.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/schemas/vertices/users.json b/spec/schemas/vertices/users.json index e59b8173..7f7d963c 100644 --- a/spec/schemas/vertices/users.json +++ b/spec/schemas/vertices/users.json @@ -8,9 +8,9 @@ "type": "string", "description": "The username for this user", "examples": [ - "jjeffryes" - ], - "pattern": "^\\w+$" + "jjeffryes", + "sean-mccorkle3." + ] } } } From 03c2d96566d65f5441df6b8257c22215a97fe207 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 20 Nov 2018 09:46:53 -0800 Subject: [PATCH 131/732] WIP --- api/Dockerfile | 2 +- api/dev-requirements.txt | 2 + api/src/test/mock_auth.py | 61 +++++++++++++++++ api/src/test/test_api.py | 136 ++++++++++++++++++++++++++------------ 4 files changed, 156 insertions(+), 45 deletions(-) create mode 100644 api/src/test/mock_auth.py diff --git a/api/Dockerfile b/api/Dockerfile index eefc6e72..46aa9e1e 100644 --- a/api/Dockerfile +++ b/api/Dockerfile @@ -21,4 +21,4 @@ COPY . /app # Clone the spec files RUN git clone ${spec_url} ${spec_path} -CMD ["sh", "start_server.sh"] +CMD ["python", "server.py"] diff --git a/api/dev-requirements.txt b/api/dev-requirements.txt index 906dda96..bf184e08 100644 --- a/api/dev-requirements.txt +++ b/api/dev-requirements.txt @@ -5,3 +5,5 @@ pyflakes==2.0.0 flake8==3.5.0 grequests==0.3.0 coverage==4.5.1 +responses==0.10.4 +requests-mock==1.5.2 diff --git a/api/src/test/mock_auth.py b/api/src/test/mock_auth.py new file mode 100644 index 00000000..f0a8dc29 --- /dev/null +++ b/api/src/test/mock_auth.py @@ -0,0 +1,61 @@ +import os +import responses +from contextlib import contextmanager + +kbase_endpoint = os.environ.get('KBASE_ENDPOINT', 'https://ci.kbase.us/services') +auth_url = kbase_endpoint + '/auth/api/V2/me' + +# Some test auth tokens +tokens = { + 'admin': 're_admin', + 'non_admin': 'standard_dev' +} + +valid_non_admin_response = { + 'created': 1528306100471, + 'lastlogin': 1542068355002, + 'display': 'Test User', + 'roles': [], + 'customroles': [], + 'policyids': [], + 'user': 'username', + 'local': False, + 'email': 'user@example.com', + 'idents': [] +} + +valid_re_admin_response = { + 'created': 1528306100471, + 'lastlogin': 1542068355002, + 'display': 'Test User', + 'roles': [], + 'customroles': ['RE_ADMIN'], + 'policyids': [], + 'user': 'username', + 'local': False, + 'email': 'user@example.com', + 'idents': [] +} + +web_url = os.environ.get('TEST_URL', 'http://web:5000') +responses.add_passthru(web_url) + + +@contextmanager +def mock_auth(*args, **kwargs): + with responses.RequestsMock() as resps: + # Mock an admin authorization + resps.add(responses.Response( + method='GET', + url=auth_url, + headers={'Authorization': tokens['admin']}, + json=valid_re_admin_response + )) + # Mock a non-admin user auth + resps.add(responses.Response( + method='GET', + url=auth_url, + headers={'Authorization': tokens['non_admin']}, + json=valid_non_admin_response + )) + yield resps diff --git a/api/src/test/test_api.py b/api/src/test/test_api.py index b1e0856b..982335f5 100644 --- a/api/src/test/test_api.py +++ b/api/src/test/test_api.py @@ -5,12 +5,16 @@ """ import unittest import requests +import responses import json import os +from src.test.mock_auth import tokens + url = os.environ.get('TEST_URL', 'http://web:5000') -auth_token = os.environ.get('KBASE_TEST_AUTH_TOKEN', '') -headers = {'Authorization': 'Bearer ' + auth_token, 'Content-Type': 'application/json'} + +headers_non_admin = {'Authorization': 'Bearer ' + tokens['non_admin'], 'Content-Type': 'application/json'} +headers_admin = {'Authorization': 'Bearer ' + tokens['admin'], 'Content-Type': 'application/json'} def create_test_docs(count): @@ -38,7 +42,7 @@ def save_test_docs(count, edges=False): url + '/api/documents', params={'overwrite': True, 'collection': collection}, data=docs, - headers=headers + headers=headers_admin ).json() @@ -52,54 +56,81 @@ def test_root(self): self.assertTrue(resp['repo_url']) def test_update_specs(self): + """Test the endpoint that triggers an update on the specs.""" + with resp = requests.get( url + '/api/update_specs', - headers={'Authorization': 'Bearer ' + auth_token}, + headers=headers_admin, params={'reset': '1', 'init_collections': '1'} ) resp_json = resp.json() self.assertEqual(resp.status_code, 200) self.assertTrue(len(resp_json['status'])) + @unittest.skip('x') def test_list_views(self): + """Test the listing out of saved AQL views.""" resp = requests.get(url + '/api/views').json() self.assertTrue('list_all_documents_in_collection' in resp) + @unittest.skip('x') def test_show_view(self): + """Test the endpoint that displays AQL source code for one view.""" resp = requests.get(url + '/api/views/count_documents_in_collection').text self.assertTrue('Return count of documents' in resp) + @unittest.skip('x') def test_list_schemas(self): + """Test the listing out of registered JSON schemas for vertices and edges.""" resp = requests.get(url + '/api/schemas').json() self.assertTrue('example_vertices' in resp['vertices']) self.assertTrue('example_edges' in resp['edges']) self.assertFalse('error' in resp) self.assertTrue(len(resp)) + @unittest.skip('x') def test_show_schema(self): + """Test the endpoint that displays the JSON source for one schema.""" resp = requests.get(url + '/api/schemas/example_edges').text self.assertTrue('_from' in resp) resp = requests.get(url + '/api/schemas/example_vertices').text self.assertTrue('_key' in resp) - def test_save_documents_no_auth(self): - # Missing bearer - resp = requests.put(url + '/api/documents?on_duplicate=error&overwrite=true&collection').json() - self.assertTrue('Missing header' in resp['error']) - # Invalid bearer + @unittest.skip('x') + def test_save_documents_missing_auth(self): + """Test an invalid attempt to save a doc with a missing auth token.""" + resp = requests.put( + url + '/api/documents?on_duplicate=error&overwrite=true&collection', + headers={} + ).json() + self.assertEqual(resp['error'], 'Missing header: authorization') + + @unittest.skip('x') + def test_save_documents_invalid_auth(self): + """Test an invalid attempt to save a doc with a bad auth token.""" resp = requests.put( url + '/api/documents?on_duplicate=error&overwrite=true&collection', headers={'Authorization': 'Bearer xyz'} ).json() - self.assertTrue('Unauthorized' in resp['error']) + self.assertEqual(resp['error'], '403 - Unauthorized') + + @unittest.skip('x') + def test_save_documents_non_admin(self): + """Test an invalid attempt to save a doc as a non-admin.""" + resp = requests.put( + url + '/api/documents?on_duplicate=error&overwrite=true&collection', + headers=headers_non_admin + ).json() + self.assertEqual(resp['error'], '403 - Unauthorized') + @unittest.skip('x') def test_save_documents_invalid_schema(self): """Test the case where some documents fail against their schema.""" resp = requests.put( url + '/api/documents', params={'on_duplicate': 'ignore', 'collection': 'example_vertices'}, data='{"name": "x"}\n{"name": "y"}', - headers={'Authorization': 'Bearer ' + auth_token} + headers=headers_admin ).json() self.assertEqual(resp['error'], "'_key' is a required property") self.assertEqual(resp['instance'], {'name': 'x'}) @@ -107,74 +138,81 @@ def test_save_documents_invalid_schema(self): self.assertEqual(resp['validator'], 'required') self.assertEqual(resp['validator_value'], ['_key']) + @unittest.skip('x') def test_save_documents_missing_schema(self): """Test the case where the collection/schema does not exist.""" resp = requests.put( url + '/api/documents', params={'collection': 'xyzabc'}, data='', - headers={'Authorization': 'Bearer ' + auth_token} + headers=headers_admin ).json() self.assertTrue('Schema does not exist' in resp['error']) + @unittest.skip('x') def test_save_documents_invalid_json(self): + """Test an attempt to save documents with an invalid JSON body.""" resp = requests.put( url + '/api/documents', params={'collection': 'example_vertices'}, data='\n', - headers={'Authorization': 'Bearer ' + auth_token} + headers=headers_admin ).json() self.assertTrue('Unable to parse' in resp['error']) self.assertEqual(resp['pos'], 1) self.assertEqual(resp['source_json'], '\n') + @unittest.skip('x') def test_create_documents(self): """Test all valid cases for saving documents.""" - # Create resp = save_test_docs(3) expected = {'created': 3, 'errors': 0, 'empty': 0, 'updated': 0, 'ignored': 0, 'error': False} self.assertEqual(resp, expected) + @unittest.skip('x') def test_create_edges(self): """Test all valid cases for saving edges.""" - # Create resp = save_test_docs(3, edges=True) expected = {'created': 3, 'errors': 0, 'empty': 0, 'updated': 0, 'ignored': 0, 'error': False} self.assertEqual(resp, expected) + @unittest.skip('x') def test_update_documents(self): """Test updating existing documents.""" resp = requests.put( url + '/api/documents', params={'on_duplicate': 'update', 'collection': 'example_vertices'}, data=create_test_docs(3), - headers=headers + headers=headers_admin ).json() expected = {'created': 0, 'errors': 0, 'empty': 0, 'updated': 3, 'ignored': 0, 'error': False} self.assertEqual(resp, expected) + @unittest.skip('x') def test_update_edge(self): """Test updating existing edge.""" resp = requests.put( url + '/api/documents', params={'on_duplicate': 'update', 'collection': 'example_edges'}, data=create_test_edges(3), - headers=headers + headers=headers_admin ).json() expected = {'created': 0, 'errors': 0, 'empty': 0, 'updated': 3, 'ignored': 0, 'error': False} self.assertEqual(resp, expected) + @unittest.skip('x') def test_replace_documents(self): """Test replacing of existing documents.""" resp = requests.put( url + '/api/documents', params={'on_duplicate': 'replace', 'collection': 'example_vertices'}, data=create_test_docs(3), - headers=headers + headers=headers_admin ).json() expected = {'created': 0, 'errors': 0, 'empty': 0, 'updated': 3, 'ignored': 0, 'error': False} self.assertEqual(resp, expected) + @unittest.skip('x') def test_save_documents_dupe_errors(self): """Test where we want to raise errors on duplicate documents.""" save_test_docs(3) @@ -182,29 +220,31 @@ def test_save_documents_dupe_errors(self): url + '/api/documents', params={'on_duplicate': 'error', 'collection': 'example_vertices', 'display_errors': '1'}, data=create_test_docs(3), - headers=headers + headers=headers_admin ).json() self.assertEqual(resp['created'], 0) self.assertEqual(resp['errors'], 3) self.assertTrue(resp['details']) + @unittest.skip('x') def test_save_documents_ignore_dupes(self): """Test ignoring duplicate, existing documents when saving.""" resp = requests.put( url + '/api/documents', params={'on_duplicate': 'ignore', 'collection': 'example_vertices'}, data=create_test_docs(3), - headers=headers + headers=headers_admin ).json() expected = {'created': 0, 'errors': 0, 'empty': 0, 'updated': 0, 'ignored': 3, 'error': False} self.assertEqual(resp, expected) + @unittest.skip('x') def test_admin_query(self): """Test an ad-hoc query made by an admin.""" resp = requests.post( url + '/api/query_results', params={}, - headers=headers, + headers=headers_admin, data=json.dumps({ 'query': 'for v in example_vertices sort rand() limit @count return v._id', 'count': 1 @@ -213,12 +253,27 @@ def test_admin_query(self): self.assertEqual(resp['count'], 1) self.assertEqual(len(resp['results']), 1) + @unittest.skip('x') + def test_admin_query_non_admin(self): + """Test an ad-hoc query error as a non-admin.""" + resp = requests.post( + url + '/api/query_results', + params={}, + headers=headers_non_admin, + data=json.dumps({ + 'query': 'for v in example_vertices sort rand() limit @count return v._id', + 'count': 1 + }) + ).json() + self.assertEqual(resp['error'], '403 - Unauthorized') + + @unittest.skip('x') def test_admin_query_invalid_auth(self): """Test the error response for an ad-hoc admin query without auth.""" resp = requests.post( url + '/api/query_results', params={}, - headers={'Content-Type': 'application/json', 'Authorization': 'xyz'}, + headers={'Authorization': 'xyz'}, data=json.dumps({ 'query': 'for v in example_vertices sort rand() limit @count return v._id', 'count': 1 @@ -226,6 +281,7 @@ def test_admin_query_invalid_auth(self): ).json() self.assertEqual(resp['error'], '403 - Unauthorized') + @unittest.skip('x') def test_query(self): """Test a basic query that fetches some docs.""" save_test_docs(3) @@ -233,10 +289,7 @@ def test_query(self): url + '/api/query_results', params={'view': 'list_all_documents_in_collection'}, data=json.dumps({'@collection': 'example_vertices'}), - headers={ - 'Authorization': 'Bearer ' + auth_token, - 'Content-Type': 'application/json' - } + headers=headers_non_admin ).json() self.assertEqual(len(resp['results']), 3) self.assertEqual(resp['count'], 3) @@ -244,6 +297,7 @@ def test_query(self): self.assertEqual(resp['cursor_id'], None) self.assertTrue(resp['stats']) + @unittest.skip('x') def test_query_with_cursor(self): """Test getting more data via a query cursor.""" save_test_docs(count=200) @@ -251,10 +305,7 @@ def test_query_with_cursor(self): url + '/api/query_results', params={'view': 'list_all_documents_in_collection'}, data=json.dumps({'@collection': 'example_vertices'}), - headers={ - 'Authorization': 'Bearer ' + auth_token, - 'Content-Type': 'application/json' - } + headers=headers_non_admin ).json() cursor_id = resp['cursor_id'] self.assertTrue(resp['cursor_id']) @@ -264,7 +315,7 @@ def test_query_with_cursor(self): resp = requests.post( url + '/api/query_results', params={'cursor_id': cursor_id}, - headers={'Authorization': 'Bearer ' + auth_token} + headers=headers_non_admin ).json() self.assertEqual(resp['count'], 200) self.assertEqual(resp['has_more'], False) @@ -274,46 +325,43 @@ def test_query_with_cursor(self): resp = requests.post( url + '/api/query_results', params={'cursor_id': cursor_id}, - headers={'Authorization': 'Bearer ' + auth_token} + headers=headers_non_admin ).json() self.assertTrue(resp['error']) self.assertEqual(resp['arango_message'], 'cursor not found') + @unittest.skip('x') def test_query_no_name(self): + """Test a query error with a view name that does not exist.""" resp = requests.post( url + '/api/query_results', params={'view': 'nonexistent'}, data=json.dumps({'@collection': 'example_vertices'}), - headers={ - 'Authorization': 'Bearer ' + auth_token, - 'Content-Type': 'application/json' - } + headers=headers_non_admin ).json() self.assertEqual(resp['error'], 'View does not exist.') self.assertEqual(resp['name'], 'nonexistent') + @unittest.skip('x') def test_query_missing_bind_var(self): + """Test a query error with a missing bind variable.""" resp = requests.post( url + '/api/query_results', params={'view': 'list_all_documents_in_collection'}, data=json.dumps({'xyz': 'example_vertices'}), - headers={ - 'Authorization': 'Bearer ' + auth_token, - 'Content-Type': 'application/json' - } + headers=headers_non_admin ).json() self.assertEqual(resp['error'], 'ArangoDB server error.') self.assertTrue(resp['arango_message']) + @unittest.skip('x') def test_query_incorrect_collection(self): + """Test a query error with an invalid collection name.""" resp = requests.post( url + '/api/query_results', params={'view': 'list_all_documents_in_collection'}, data=json.dumps({'@collection': 123}), - headers={ - 'Authorization': 'Bearer ' + auth_token, - 'Content-Type': 'application/json' - } + headers=headers_non_admin ).json() self.assertEqual(resp['error'], 'ArangoDB server error.') self.assertTrue(resp['arango_message']) From d83d28dbb9819e213f92bcaa4c1faa8951202f18 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 20 Nov 2018 09:57:39 -0800 Subject: [PATCH 132/732] Clean up some adhoc query logic --- api/src/relation_engine_server/api.py | 28 +++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/api/src/relation_engine_server/api.py b/api/src/relation_engine_server/api.py index 3478e9af..1eb07011 100644 --- a/api/src/relation_engine_server/api.py +++ b/api/src/relation_engine_server/api.py @@ -23,27 +23,30 @@ def run_query(): Run a stored view as a query against the database. Auth: only kbase users (any role) """ - json_body = flask.request.json or {} + # Note that flask.request.json only works if the request Content-Type is application/json + json_body = json.loads(flask.request.get_data() or '{}') if 'query' in json_body: # Run an adhoc query for a sysadmin auth.require_auth_token(roles=['RE_ADMIN']) query_text = json_body['query'] del json_body['query'] - resp = arango_client.run_query(query_text=query_text, bind_vars=json_body) - return flask.jsonify(resp) - else: - auth.require_auth_token(roles=[]) + resp_body = arango_client.run_query(query_text=query_text, bind_vars=json_body) + return flask.jsonify(resp_body) + auth.require_auth_token(roles=[]) if 'view' in flask.request.args: + # Run a query from a view name view_name = flask.request.args['view'] view_source = spec_loader.get_view(view_name) - resp = arango_client.run_query(query_text=view_source, bind_vars=json_body) + resp_body = arango_client.run_query(query_text=view_source, bind_vars=json_body) + return flask.jsonify(resp_body) elif 'cursor_id' in flask.request.args: + # Run a query from a cursor ID cursor_id = flask.request.args['cursor_id'] - resp = arango_client.run_query(cursor_id=cursor_id) - else: - resp = {'error': 'Pass in a view or a cursor_id'} - return (flask.jsonify(resp), 400) - return flask.jsonify(resp) + resp_body = arango_client.run_query(cursor_id=cursor_id) + return flask.jsonify(resp_body) + # No valid options were passed + resp_body = {'error': 'Pass in a view or a cursor_id'} + return (flask.jsonify(resp_body), 500) @api.route('/schemas', methods=['GET']) @@ -77,6 +80,7 @@ def show_view(name): def refresh_specs(): """ Manually check for updates, download spec releases, and init new collections. + Auth: admin """ auth.require_auth_token(['RE_ADMIN']) status = pull_spec.download_latest( @@ -90,7 +94,7 @@ def refresh_specs(): def save_documents(): """ Create, update, or replace many documents in a batch. - Auth: only sysadmins + Auth: admin """ auth.require_auth_token(['RE_ADMIN']) collection_name = flask.request.args['collection'] From ad486296d347c6f58cbb5da28e62cd8df6515af1 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 20 Nov 2018 10:50:57 -0800 Subject: [PATCH 133/732] Get it working using the mock_microservice iamge --- api/.env.example | 3 + api/Dockerfile | 5 +- api/Makefile | 9 +-- api/docker-compose.yaml | 11 ++- api/scripts/run_tests.sh | 9 +++ api/{ => scripts}/start_server.sh | 0 api/src/relation_engine_server/auth.py | 2 +- api/src/test/mock_auth.py | 61 ----------------- api/src/test/mock_auth/endpoints.json | 95 ++++++++++++++++++++++++++ api/src/test/test_api.py | 42 +++--------- 10 files changed, 128 insertions(+), 109 deletions(-) create mode 100644 api/scripts/run_tests.sh rename api/{ => scripts}/start_server.sh (100%) delete mode 100644 api/src/test/mock_auth.py create mode 100644 api/src/test/mock_auth/endpoints.json diff --git a/api/.env.example b/api/.env.example index 503acfb2..283fb5cc 100644 --- a/api/.env.example +++ b/api/.env.example @@ -4,5 +4,8 @@ DB_PASS=password KBASE_ENDPOINT=https://ci.kbase.us/services KBASE_TEST_AUTH_TOKEN=xyz +# Optional - will fall back to use KBASE_ENDPOINT +KBASE_AUTH_URL=https://ci.kbase.us/services/auth + # You can also set: # WORKERS - set number of gevent workers (otherwise automatically calculated) diff --git a/api/Dockerfile b/api/Dockerfile index 46aa9e1e..82af9f2f 100644 --- a/api/Dockerfile +++ b/api/Dockerfile @@ -9,7 +9,6 @@ COPY dev-requirements.txt /app/dev-requirements.txt WORKDIR /app # Install dependencies -RUN apk --update add make git RUN apk --update add --virtual build-dependencies python-dev build-base && \ pip install --upgrade pip && \ pip install --upgrade --no-cache-dir -r requirements.txt && \ @@ -18,7 +17,5 @@ RUN apk --update add --virtual build-dependencies python-dev build-base && \ # Run the app COPY . /app -# Clone the spec files -RUN git clone ${spec_url} ${spec_path} -CMD ["python", "server.py"] +CMD ["sh", "scripts/start_server.sh"] diff --git a/api/Makefile b/api/Makefile index bf7e9133..c1e7dd95 100644 --- a/api/Makefile +++ b/api/Makefile @@ -1,11 +1,4 @@ .PHONY: dev-server dev-build test test-local test: - docker-compose run web make test-local - -test-local: - flake8 --max-complexity 5 src - mypy --ignore-missing-imports src - python -m pyflakes src - bandit -r src - python -m unittest discover src/test/ + docker-compose run web sh scripts/run_tests.sh diff --git a/api/docker-compose.yaml b/api/docker-compose.yaml index 4853b0d5..6374a034 100644 --- a/api/docker-compose.yaml +++ b/api/docker-compose.yaml @@ -12,10 +12,11 @@ services: DEVELOPMENT: 1 env_file: .env ports: - - "5000:5000" + - 5000:5000 volumes: - - .:/app + - ${PWD}:/app environment: + - KBASE_AUTH_URL=http://auth:5000 - PYTHONUNBUFFERED=true - DB_URL=http://arangodb:8529 - FLASK_ENV=development @@ -28,3 +29,9 @@ services: - 8529:8529 environment: - ARANGO_ROOT_PASSWORD=password + + # A mock kbase auth server (see src/test/mock_auth/endpoints.json) + auth: + image: mockservices/mock_json_service + volumes: + - ${PWD}/src/test/mock_auth:/config diff --git a/api/scripts/run_tests.sh b/api/scripts/run_tests.sh new file mode 100644 index 00000000..4342b07f --- /dev/null +++ b/api/scripts/run_tests.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +set -e + +flake8 --max-complexity 5 src +mypy --ignore-missing-imports src +python -m pyflakes src +bandit -r src +python -m unittest discover src/test/ diff --git a/api/start_server.sh b/api/scripts/start_server.sh similarity index 100% rename from api/start_server.sh rename to api/scripts/start_server.sh diff --git a/api/src/relation_engine_server/auth.py b/api/src/relation_engine_server/auth.py index e16658e4..73d8d4a5 100644 --- a/api/src/relation_engine_server/auth.py +++ b/api/src/relation_engine_server/auth.py @@ -17,7 +17,7 @@ def require_auth_token(roles=[]): Raises some exception if any auth requirement is not met. """ kbase_endpoint = os.environ.get('KBASE_ENDPOINT', 'https://ci.kbase.us/services') - kbase_auth_url = kbase_endpoint + '/auth' + kbase_auth_url = os.environ.get('KBASE_AUTH_URL', kbase_endpoint + '/auth') if not flask.request.headers.get('Authorization'): # No authorization token was provided in the headers raise MissingHeader('Authorization') diff --git a/api/src/test/mock_auth.py b/api/src/test/mock_auth.py deleted file mode 100644 index f0a8dc29..00000000 --- a/api/src/test/mock_auth.py +++ /dev/null @@ -1,61 +0,0 @@ -import os -import responses -from contextlib import contextmanager - -kbase_endpoint = os.environ.get('KBASE_ENDPOINT', 'https://ci.kbase.us/services') -auth_url = kbase_endpoint + '/auth/api/V2/me' - -# Some test auth tokens -tokens = { - 'admin': 're_admin', - 'non_admin': 'standard_dev' -} - -valid_non_admin_response = { - 'created': 1528306100471, - 'lastlogin': 1542068355002, - 'display': 'Test User', - 'roles': [], - 'customroles': [], - 'policyids': [], - 'user': 'username', - 'local': False, - 'email': 'user@example.com', - 'idents': [] -} - -valid_re_admin_response = { - 'created': 1528306100471, - 'lastlogin': 1542068355002, - 'display': 'Test User', - 'roles': [], - 'customroles': ['RE_ADMIN'], - 'policyids': [], - 'user': 'username', - 'local': False, - 'email': 'user@example.com', - 'idents': [] -} - -web_url = os.environ.get('TEST_URL', 'http://web:5000') -responses.add_passthru(web_url) - - -@contextmanager -def mock_auth(*args, **kwargs): - with responses.RequestsMock() as resps: - # Mock an admin authorization - resps.add(responses.Response( - method='GET', - url=auth_url, - headers={'Authorization': tokens['admin']}, - json=valid_re_admin_response - )) - # Mock a non-admin user auth - resps.add(responses.Response( - method='GET', - url=auth_url, - headers={'Authorization': tokens['non_admin']}, - json=valid_non_admin_response - )) - yield resps diff --git a/api/src/test/mock_auth/endpoints.json b/api/src/test/mock_auth/endpoints.json new file mode 100644 index 00000000..d6adcd5e --- /dev/null +++ b/api/src/test/mock_auth/endpoints.json @@ -0,0 +1,95 @@ +[ + { + "methods": [ + "GET" + ], + "path": "/api/V2/me", + "headers": { + "Authorization": "non_admin_token" + }, + "response": { + "status": "200", + "body": { + "created": 1528306100471, + "lastlogin": 1542068355002, + "display": "Test User", + "roles": [], + "customroles": [], + "policyids": [], + "user": "username", + "local": false, + "email": "user@example.com", + "idents": [] + } + } + }, + { + "methods": [ + "GET" + ], + "path": "/api/V2/me", + "headers": { + "Authorization": "admin_token" + }, + "response": { + "status": "200", + "body": { + "created": 1528306100471, + "lastlogin": 1542068355002, + "display": "Test User", + "roles": [], + "customroles": [ + "RE_ADMIN" + ], + "policyids": [], + "user": "username", + "local": false, + "email": "user@example.com", + "idents": [] + } + } + }, + { + "methods": [ + "GET" + ], + "path": "/api/V2/me", + "headers": { + "Authorization": "invalid_token" + }, + "response": { + "status": "401", + "body": { + "error": { + "httpcode": 401, + "httpstatus": "Unauthorized", + "appcode": 10020, + "apperror": "Invalid token", + "message": "10020 Invalid token", + "callid": "1757210147564211", + "time": 1542737889450 + } + } + } + }, + { + "methods": [ + "GET" + ], + "path": "/api/V2/me", + "response": { + "status": "400", + "body": { + "error": { + "httpcode": 400, + "httpstatus": "Bad Request", + "appcode": 10010, + "apperror": "No authentication token", + "message": "10010 No authentication token: No user token provided", + "callid": "7334881776774415", + "time": 1542737656377 + } + } + } + } +] diff --git a/api/src/test/test_api.py b/api/src/test/test_api.py index 982335f5..e0ff4e30 100644 --- a/api/src/test/test_api.py +++ b/api/src/test/test_api.py @@ -5,16 +5,19 @@ """ import unittest import requests -import responses import json import os -from src.test.mock_auth import tokens +# Use the mock auth tokens +non_admin_token = 'non_admin_token' +admin_token = 'admin_token' +invalid_token = 'invalid_token' +# Use the docker-compose url of the running flask server url = os.environ.get('TEST_URL', 'http://web:5000') -headers_non_admin = {'Authorization': 'Bearer ' + tokens['non_admin'], 'Content-Type': 'application/json'} -headers_admin = {'Authorization': 'Bearer ' + tokens['admin'], 'Content-Type': 'application/json'} +headers_non_admin = {'Authorization': 'Bearer ' + non_admin_token, 'Content-Type': 'application/json'} +headers_admin = {'Authorization': 'Bearer ' + admin_token, 'Content-Type': 'application/json'} def create_test_docs(count): @@ -57,7 +60,6 @@ def test_root(self): def test_update_specs(self): """Test the endpoint that triggers an update on the specs.""" - with resp = requests.get( url + '/api/update_specs', headers=headers_admin, @@ -67,19 +69,16 @@ def test_update_specs(self): self.assertEqual(resp.status_code, 200) self.assertTrue(len(resp_json['status'])) - @unittest.skip('x') def test_list_views(self): """Test the listing out of saved AQL views.""" resp = requests.get(url + '/api/views').json() self.assertTrue('list_all_documents_in_collection' in resp) - @unittest.skip('x') def test_show_view(self): """Test the endpoint that displays AQL source code for one view.""" resp = requests.get(url + '/api/views/count_documents_in_collection').text self.assertTrue('Return count of documents' in resp) - @unittest.skip('x') def test_list_schemas(self): """Test the listing out of registered JSON schemas for vertices and edges.""" resp = requests.get(url + '/api/schemas').json() @@ -88,7 +87,6 @@ def test_list_schemas(self): self.assertFalse('error' in resp) self.assertTrue(len(resp)) - @unittest.skip('x') def test_show_schema(self): """Test the endpoint that displays the JSON source for one schema.""" resp = requests.get(url + '/api/schemas/example_edges').text @@ -96,16 +94,13 @@ def test_show_schema(self): resp = requests.get(url + '/api/schemas/example_vertices').text self.assertTrue('_key' in resp) - @unittest.skip('x') def test_save_documents_missing_auth(self): """Test an invalid attempt to save a doc with a missing auth token.""" resp = requests.put( - url + '/api/documents?on_duplicate=error&overwrite=true&collection', - headers={} + url + '/api/documents?on_duplicate=error&overwrite=true&collection' ).json() - self.assertEqual(resp['error'], 'Missing header: authorization') + self.assertEqual(resp['error'], 'Missing header: Authorization') - @unittest.skip('x') def test_save_documents_invalid_auth(self): """Test an invalid attempt to save a doc with a bad auth token.""" resp = requests.put( @@ -114,7 +109,6 @@ def test_save_documents_invalid_auth(self): ).json() self.assertEqual(resp['error'], '403 - Unauthorized') - @unittest.skip('x') def test_save_documents_non_admin(self): """Test an invalid attempt to save a doc as a non-admin.""" resp = requests.put( @@ -123,7 +117,6 @@ def test_save_documents_non_admin(self): ).json() self.assertEqual(resp['error'], '403 - Unauthorized') - @unittest.skip('x') def test_save_documents_invalid_schema(self): """Test the case where some documents fail against their schema.""" resp = requests.put( @@ -138,7 +131,6 @@ def test_save_documents_invalid_schema(self): self.assertEqual(resp['validator'], 'required') self.assertEqual(resp['validator_value'], ['_key']) - @unittest.skip('x') def test_save_documents_missing_schema(self): """Test the case where the collection/schema does not exist.""" resp = requests.put( @@ -149,7 +141,6 @@ def test_save_documents_missing_schema(self): ).json() self.assertTrue('Schema does not exist' in resp['error']) - @unittest.skip('x') def test_save_documents_invalid_json(self): """Test an attempt to save documents with an invalid JSON body.""" resp = requests.put( @@ -162,21 +153,18 @@ def test_save_documents_invalid_json(self): self.assertEqual(resp['pos'], 1) self.assertEqual(resp['source_json'], '\n') - @unittest.skip('x') def test_create_documents(self): """Test all valid cases for saving documents.""" resp = save_test_docs(3) expected = {'created': 3, 'errors': 0, 'empty': 0, 'updated': 0, 'ignored': 0, 'error': False} self.assertEqual(resp, expected) - @unittest.skip('x') def test_create_edges(self): """Test all valid cases for saving edges.""" resp = save_test_docs(3, edges=True) expected = {'created': 3, 'errors': 0, 'empty': 0, 'updated': 0, 'ignored': 0, 'error': False} self.assertEqual(resp, expected) - @unittest.skip('x') def test_update_documents(self): """Test updating existing documents.""" resp = requests.put( @@ -188,7 +176,6 @@ def test_update_documents(self): expected = {'created': 0, 'errors': 0, 'empty': 0, 'updated': 3, 'ignored': 0, 'error': False} self.assertEqual(resp, expected) - @unittest.skip('x') def test_update_edge(self): """Test updating existing edge.""" resp = requests.put( @@ -200,7 +187,6 @@ def test_update_edge(self): expected = {'created': 0, 'errors': 0, 'empty': 0, 'updated': 3, 'ignored': 0, 'error': False} self.assertEqual(resp, expected) - @unittest.skip('x') def test_replace_documents(self): """Test replacing of existing documents.""" resp = requests.put( @@ -212,7 +198,6 @@ def test_replace_documents(self): expected = {'created': 0, 'errors': 0, 'empty': 0, 'updated': 3, 'ignored': 0, 'error': False} self.assertEqual(resp, expected) - @unittest.skip('x') def test_save_documents_dupe_errors(self): """Test where we want to raise errors on duplicate documents.""" save_test_docs(3) @@ -226,7 +211,6 @@ def test_save_documents_dupe_errors(self): self.assertEqual(resp['errors'], 3) self.assertTrue(resp['details']) - @unittest.skip('x') def test_save_documents_ignore_dupes(self): """Test ignoring duplicate, existing documents when saving.""" resp = requests.put( @@ -238,7 +222,6 @@ def test_save_documents_ignore_dupes(self): expected = {'created': 0, 'errors': 0, 'empty': 0, 'updated': 0, 'ignored': 3, 'error': False} self.assertEqual(resp, expected) - @unittest.skip('x') def test_admin_query(self): """Test an ad-hoc query made by an admin.""" resp = requests.post( @@ -253,7 +236,6 @@ def test_admin_query(self): self.assertEqual(resp['count'], 1) self.assertEqual(len(resp['results']), 1) - @unittest.skip('x') def test_admin_query_non_admin(self): """Test an ad-hoc query error as a non-admin.""" resp = requests.post( @@ -267,7 +249,6 @@ def test_admin_query_non_admin(self): ).json() self.assertEqual(resp['error'], '403 - Unauthorized') - @unittest.skip('x') def test_admin_query_invalid_auth(self): """Test the error response for an ad-hoc admin query without auth.""" resp = requests.post( @@ -281,7 +262,6 @@ def test_admin_query_invalid_auth(self): ).json() self.assertEqual(resp['error'], '403 - Unauthorized') - @unittest.skip('x') def test_query(self): """Test a basic query that fetches some docs.""" save_test_docs(3) @@ -297,7 +277,6 @@ def test_query(self): self.assertEqual(resp['cursor_id'], None) self.assertTrue(resp['stats']) - @unittest.skip('x') def test_query_with_cursor(self): """Test getting more data via a query cursor.""" save_test_docs(count=200) @@ -330,7 +309,6 @@ def test_query_with_cursor(self): self.assertTrue(resp['error']) self.assertEqual(resp['arango_message'], 'cursor not found') - @unittest.skip('x') def test_query_no_name(self): """Test a query error with a view name that does not exist.""" resp = requests.post( @@ -342,7 +320,6 @@ def test_query_no_name(self): self.assertEqual(resp['error'], 'View does not exist.') self.assertEqual(resp['name'], 'nonexistent') - @unittest.skip('x') def test_query_missing_bind_var(self): """Test a query error with a missing bind variable.""" resp = requests.post( @@ -354,7 +331,6 @@ def test_query_missing_bind_var(self): self.assertEqual(resp['error'], 'ArangoDB server error.') self.assertTrue(resp['arango_message']) - @unittest.skip('x') def test_query_incorrect_collection(self): """Test a query error with an invalid collection name.""" resp = requests.post( From b5119da1aae23ab117e68a59e3b9e55d46ecf17f Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 20 Nov 2018 10:53:32 -0800 Subject: [PATCH 134/732] Remove unneeded example env entry --- api/.env.example | 1 - 1 file changed, 1 deletion(-) diff --git a/api/.env.example b/api/.env.example index 283fb5cc..90cb150b 100644 --- a/api/.env.example +++ b/api/.env.example @@ -2,7 +2,6 @@ DB_URL=http://graph1:8529 DB_USER=root DB_PASS=password KBASE_ENDPOINT=https://ci.kbase.us/services -KBASE_TEST_AUTH_TOKEN=xyz # Optional - will fall back to use KBASE_ENDPOINT KBASE_AUTH_URL=https://ci.kbase.us/services/auth From b9615d837b7e78d8668d4bde6d64fe5282c7f85b Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 20 Nov 2018 10:53:57 -0800 Subject: [PATCH 135/732] Remove extra makefile items --- api/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/Makefile b/api/Makefile index c1e7dd95..c7dd3651 100644 --- a/api/Makefile +++ b/api/Makefile @@ -1,4 +1,4 @@ -.PHONY: dev-server dev-build test test-local +.PHONY: test test: docker-compose run web sh scripts/run_tests.sh From b9d342b40b716f5284f9edd58ad82e6d893815e8 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 20 Nov 2018 10:54:18 -0800 Subject: [PATCH 136/732] Remove unneeded dev requirements --- api/dev-requirements.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/api/dev-requirements.txt b/api/dev-requirements.txt index bf184e08..906dda96 100644 --- a/api/dev-requirements.txt +++ b/api/dev-requirements.txt @@ -5,5 +5,3 @@ pyflakes==2.0.0 flake8==3.5.0 grequests==0.3.0 coverage==4.5.1 -responses==0.10.4 -requests-mock==1.5.2 From 74ee491c5c782d089e4901797302f482783f7268 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 20 Nov 2018 10:56:20 -0800 Subject: [PATCH 137/732] Comment out .env.example entries by default --- api/.env.example | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/api/.env.example b/api/.env.example index 90cb150b..fc3b1cd7 100644 --- a/api/.env.example +++ b/api/.env.example @@ -1,10 +1,10 @@ -DB_URL=http://graph1:8529 -DB_USER=root -DB_PASS=password -KBASE_ENDPOINT=https://ci.kbase.us/services +# DB_URL=http://graph1:8529 +# DB_USER=root +# DB_PASS=password +# KBASE_ENDPOINT=https://ci.kbase.us/services -# Optional - will fall back to use KBASE_ENDPOINT -KBASE_AUTH_URL=https://ci.kbase.us/services/auth +# # Optional - will fall back to use KBASE_ENDPOINT +# KBASE_AUTH_URL=https://ci.kbase.us/services/auth -# You can also set: -# WORKERS - set number of gevent workers (otherwise automatically calculated) +# # You can also set: +# WORKERS - set number of gevent workers (otherwise automatically calculated) From 7c9d6a0723403c7c27326e932d87a01c4bfca5fd Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 20 Nov 2018 11:17:33 -0800 Subject: [PATCH 138/732] Add travis line to initialize the spec --- api/.travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/api/.travis.yml b/api/.travis.yml index a14319e5..4baafb45 100644 --- a/api/.travis.yml +++ b/api/.travis.yml @@ -7,4 +7,5 @@ python: script: - cp .env.example .env - docker-compose up -d +- "curl -H 'Authorization: admin_token' http://localhost:5000/api/update_specs" - make test From 049afb8e58259d40f71c9fc3fa6c2d57bd07908b Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 20 Nov 2018 11:25:35 -0800 Subject: [PATCH 139/732] Debug curl call to initialize specs in travis --- api/.travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/.travis.yml b/api/.travis.yml index 4baafb45..8c073d47 100644 --- a/api/.travis.yml +++ b/api/.travis.yml @@ -7,5 +7,5 @@ python: script: - cp .env.example .env - docker-compose up -d -- "curl -H 'Authorization: admin_token' http://localhost:5000/api/update_specs" +- "curl -v -H 'Authorization: admin_token' http://127.0.0.1:5000/api/update_specs" - make test From 9cdf0e11d08a92d682a89390e9ae8414a285f2a4 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 20 Nov 2018 12:45:53 -0800 Subject: [PATCH 140/732] Debug travis --- api/.travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/api/.travis.yml b/api/.travis.yml index 8c073d47..a9f01745 100644 --- a/api/.travis.yml +++ b/api/.travis.yml @@ -8,4 +8,5 @@ script: - cp .env.example .env - docker-compose up -d - "curl -v -H 'Authorization: admin_token' http://127.0.0.1:5000/api/update_specs" +- sleep 10 - make test From b2c4111935468a20ad62866bef7e43789ecc0da6 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 20 Nov 2018 12:52:40 -0800 Subject: [PATCH 141/732] Debug travis --- api/.travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/.travis.yml b/api/.travis.yml index a9f01745..c61791d3 100644 --- a/api/.travis.yml +++ b/api/.travis.yml @@ -7,6 +7,6 @@ python: script: - cp .env.example .env - docker-compose up -d -- "curl -v -H 'Authorization: admin_token' http://127.0.0.1:5000/api/update_specs" - sleep 10 +- "curl -v -H 'Authorization: admin_token' http://127.0.0.1:5000/api/update_specs" - make test From 21f04498ec48aa2d18d9a3a10a8cbc329214f7d9 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 20 Nov 2018 15:23:47 -0800 Subject: [PATCH 142/732] Debug travis --- api/.travis.yml | 3 ++- api/src/test/test_api.py | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/api/.travis.yml b/api/.travis.yml index c61791d3..c9d72b3f 100644 --- a/api/.travis.yml +++ b/api/.travis.yml @@ -7,6 +7,7 @@ python: script: - cp .env.example .env - docker-compose up -d -- sleep 10 +- sleep 30 - "curl -v -H 'Authorization: admin_token' http://127.0.0.1:5000/api/update_specs" +- sleep 20 - make test diff --git a/api/src/test/test_api.py b/api/src/test/test_api.py index e0ff4e30..8aa67d20 100644 --- a/api/src/test/test_api.py +++ b/api/src/test/test_api.py @@ -233,6 +233,7 @@ def test_admin_query(self): 'count': 1 }) ).json() + print('RESP', resp) self.assertEqual(resp['count'], 1) self.assertEqual(len(resp['results']), 1) From bcf7f602e85331c42b83442be00cd49d145d4845 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 20 Nov 2018 15:50:40 -0800 Subject: [PATCH 143/732] Debug travis --- api/.travis.yml | 4 ++-- api/docker-compose.yaml | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/api/.travis.yml b/api/.travis.yml index c9d72b3f..333bc933 100644 --- a/api/.travis.yml +++ b/api/.travis.yml @@ -7,7 +7,7 @@ python: script: - cp .env.example .env - docker-compose up -d -- sleep 30 +- sleep 10 - "curl -v -H 'Authorization: admin_token' http://127.0.0.1:5000/api/update_specs" -- sleep 20 +- sleep 60 - make test diff --git a/api/docker-compose.yaml b/api/docker-compose.yaml index 6374a034..76cb3dfb 100644 --- a/api/docker-compose.yaml +++ b/api/docker-compose.yaml @@ -10,7 +10,6 @@ services: context: . args: DEVELOPMENT: 1 - env_file: .env ports: - 5000:5000 volumes: @@ -19,12 +18,14 @@ services: - KBASE_AUTH_URL=http://auth:5000 - PYTHONUNBUFFERED=true - DB_URL=http://arangodb:8529 + - DB_USER=root + - DB_PASS=password - FLASK_ENV=development - FLASK_DEBUG=1 # For running (and testing against) ArangoDB arangodb: - image: arangodb + image: arangodb:latest ports: - 8529:8529 environment: From 883e3f8b7d6709e520876e13c8dfa92dab593887 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 20 Nov 2018 16:44:35 -0800 Subject: [PATCH 144/732] Debug travis --- api/.travis.yml | 4 +--- api/docker-compose.yaml | 2 +- api/src/relation_engine_server/bulk_import.py | 20 +++++++++++++++++-- api/src/test/test_api.py | 10 +++++++++- 4 files changed, 29 insertions(+), 7 deletions(-) diff --git a/api/.travis.yml b/api/.travis.yml index 333bc933..99e89f42 100644 --- a/api/.travis.yml +++ b/api/.travis.yml @@ -7,7 +7,5 @@ python: script: - cp .env.example .env - docker-compose up -d -- sleep 10 -- "curl -v -H 'Authorization: admin_token' http://127.0.0.1:5000/api/update_specs" -- sleep 60 +- sleep 15 - make test diff --git a/api/docker-compose.yaml b/api/docker-compose.yaml index 76cb3dfb..da8a0bec 100644 --- a/api/docker-compose.yaml +++ b/api/docker-compose.yaml @@ -25,7 +25,7 @@ services: # For running (and testing against) ArangoDB arangodb: - image: arangodb:latest + image: arangodb:3.3.19 ports: - 8529:8529 environment: diff --git a/api/src/relation_engine_server/bulk_import.py b/api/src/relation_engine_server/bulk_import.py index 7b85b637..91ad7cca 100644 --- a/api/src/relation_engine_server/bulk_import.py +++ b/api/src/relation_engine_server/bulk_import.py @@ -3,8 +3,10 @@ import json import jsonschema import hashlib +import requests -from . import spec_loader, arango_client +from . import spec_loader +from .arango_client import ArangoServerError, db_url, db_user, db_pass def bulk_import(query_params): @@ -21,7 +23,7 @@ def bulk_import(query_params): jsonschema.validate(json_line, schema) json_line = _write_edge_key(json_line) fd.write(json.dumps(json_line) + '\n') - resp_text = arango_client.bulk_import(temp_fd.name, query_params) + resp_text = _import_from_file(temp_fd.name, query_params) temp_fd.close() # Also deletes the file return resp_text @@ -33,3 +35,17 @@ def _write_edge_key(json_line): json_line["_from"].encode() + json_line["_to"].encode(), digest_size=8 ).hexdigest() return json_line + + +def _import_from_file(file_path, query): + """Open a file of line-separated JSON and bulk-import it.""" + with open(file_path, 'rb') as file_desc: + resp = requests.post( + db_url + '/_api/import', + data=file_desc, + auth=(db_user, db_pass), + params=query + ) + if not resp.ok: + raise ArangoServerError(resp.text) + return resp.text diff --git a/api/src/test/test_api.py b/api/src/test/test_api.py index 8aa67d20..2e8a0da9 100644 --- a/api/src/test/test_api.py +++ b/api/src/test/test_api.py @@ -51,6 +51,15 @@ def save_test_docs(count, edges=False): class TestApi(unittest.TestCase): + @classmethod + def setUpClass(cls): + # Initialize collections before running any tests + requests.get( + url + '/api/update_specs', + headers=headers_admin, + params={'reset': '1', 'init_collections': '1'} + ) + def test_root(self): """Test root path for api.""" resp = requests.get(url).json() @@ -233,7 +242,6 @@ def test_admin_query(self): 'count': 1 }) ).json() - print('RESP', resp) self.assertEqual(resp['count'], 1) self.assertEqual(len(resp['results']), 1) From e4f2b32a646345b6813f85bf68e8b0c3dd5b34cd Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 20 Nov 2018 16:54:36 -0800 Subject: [PATCH 145/732] Debug travis --- api/src/test/test_api.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/api/src/test/test_api.py b/api/src/test/test_api.py index 2e8a0da9..98f3cfac 100644 --- a/api/src/test/test_api.py +++ b/api/src/test/test_api.py @@ -62,7 +62,7 @@ def setUpClass(cls): def test_root(self): """Test root path for api.""" - resp = requests.get(url).json() + resp = requests.get(url + '/').json() self.assertEqual(resp['arangodb_status'], 'connected_authorized') self.assertTrue(resp['commit_hash']) self.assertTrue(resp['repo_url']) @@ -242,6 +242,7 @@ def test_admin_query(self): 'count': 1 }) ).json() + print('RESP', resp) self.assertEqual(resp['count'], 1) self.assertEqual(len(resp['results']), 1) From 9f69455c68c6c18509dfc86d77a9f901339dfdee Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 20 Nov 2018 17:01:26 -0800 Subject: [PATCH 146/732] Debug travis --- api/src/test/test_api.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/api/src/test/test_api.py b/api/src/test/test_api.py index 98f3cfac..e9ce2d9b 100644 --- a/api/src/test/test_api.py +++ b/api/src/test/test_api.py @@ -63,6 +63,7 @@ def setUpClass(cls): def test_root(self): """Test root path for api.""" resp = requests.get(url + '/').json() + print('RESP', resp) self.assertEqual(resp['arangodb_status'], 'connected_authorized') self.assertTrue(resp['commit_hash']) self.assertTrue(resp['repo_url']) @@ -233,6 +234,7 @@ def test_save_documents_ignore_dupes(self): def test_admin_query(self): """Test an ad-hoc query made by an admin.""" + save_test_docs(1, edges=True) resp = requests.post( url + '/api/query_results', params={}, @@ -242,7 +244,6 @@ def test_admin_query(self): 'count': 1 }) ).json() - print('RESP', resp) self.assertEqual(resp['count'], 1) self.assertEqual(len(resp['results']), 1) From 91edc8c01a99e6db72cdbe0c40163d404532675d Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 20 Nov 2018 17:11:50 -0800 Subject: [PATCH 147/732] Debug travis --- api/src/relation_engine_server/server.py | 5 +++-- api/src/test/test_api.py | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/api/src/relation_engine_server/server.py b/api/src/relation_engine_server/server.py index b044c146..c1cb44b0 100644 --- a/api/src/relation_engine_server/server.py +++ b/api/src/relation_engine_server/server.py @@ -19,8 +19,9 @@ @app.route('/', methods=['GET']) def root(): """Server status.""" - with open('.git/refs/heads/master', 'r') as fd: - commit_hash = fd.read().strip() + if os.path.exists('.git/refs/heads/master'): + with open('.git/refs/heads/master', 'r') as fd: + commit_hash = fd.read().strip() arangodb_status = arango_client.server_status() repo_url = 'https://github.com/kbase/relation_engine_api.git' return flask.jsonify({ diff --git a/api/src/test/test_api.py b/api/src/test/test_api.py index e9ce2d9b..b976cd53 100644 --- a/api/src/test/test_api.py +++ b/api/src/test/test_api.py @@ -244,6 +244,7 @@ def test_admin_query(self): 'count': 1 }) ).json() + print('RESP', resp) self.assertEqual(resp['count'], 1) self.assertEqual(len(resp['results']), 1) From ac04ff8b603bbe0de30987c7c9b78d55d2c36f7e Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 20 Nov 2018 17:18:41 -0800 Subject: [PATCH 148/732] Travis debug --- api/src/relation_engine_server/server.py | 2 ++ api/src/test/test_api.py | 4 +--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/api/src/relation_engine_server/server.py b/api/src/relation_engine_server/server.py index c1cb44b0..52cb083a 100644 --- a/api/src/relation_engine_server/server.py +++ b/api/src/relation_engine_server/server.py @@ -22,6 +22,8 @@ def root(): if os.path.exists('.git/refs/heads/master'): with open('.git/refs/heads/master', 'r') as fd: commit_hash = fd.read().strip() + else: + commit_hash = 'unknown' arangodb_status = arango_client.server_status() repo_url = 'https://github.com/kbase/relation_engine_api.git' return flask.jsonify({ diff --git a/api/src/test/test_api.py b/api/src/test/test_api.py index b976cd53..0474bf5b 100644 --- a/api/src/test/test_api.py +++ b/api/src/test/test_api.py @@ -63,7 +63,6 @@ def setUpClass(cls): def test_root(self): """Test root path for api.""" resp = requests.get(url + '/').json() - print('RESP', resp) self.assertEqual(resp['arangodb_status'], 'connected_authorized') self.assertTrue(resp['commit_hash']) self.assertTrue(resp['repo_url']) @@ -234,7 +233,7 @@ def test_save_documents_ignore_dupes(self): def test_admin_query(self): """Test an ad-hoc query made by an admin.""" - save_test_docs(1, edges=True) + save_test_docs(1) resp = requests.post( url + '/api/query_results', params={}, @@ -244,7 +243,6 @@ def test_admin_query(self): 'count': 1 }) ).json() - print('RESP', resp) self.assertEqual(resp['count'], 1) self.assertEqual(len(resp['results']), 1) From 6dc88e4a24e31bb06a410e869a578709c0d746e2 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 21 Nov 2018 10:28:06 -0800 Subject: [PATCH 149/732] Clean up some organization around bulk import modules --- .../relation_engine_server/arango_client.py | 2 +- api/src/relation_engine_server/bulk_import.py | 29 +++++-------------- 2 files changed, 9 insertions(+), 22 deletions(-) diff --git a/api/src/relation_engine_server/arango_client.py b/api/src/relation_engine_server/arango_client.py index 56303086..e03cb01e 100644 --- a/api/src/relation_engine_server/arango_client.py +++ b/api/src/relation_engine_server/arango_client.py @@ -92,7 +92,7 @@ def create_collection(name, is_edge): raise ArangoServerError(resp.text) -def bulk_import(file_path, query): +def import_from_file(file_path, query): """Make a generic arango post request.""" with open(file_path, 'rb') as file_desc: resp = requests.post( diff --git a/api/src/relation_engine_server/bulk_import.py b/api/src/relation_engine_server/bulk_import.py index 91ad7cca..516af831 100644 --- a/api/src/relation_engine_server/bulk_import.py +++ b/api/src/relation_engine_server/bulk_import.py @@ -3,10 +3,10 @@ import json import jsonschema import hashlib -import requests +import os from . import spec_loader -from .arango_client import ArangoServerError, db_url, db_user, db_pass +from .arango_client import import_from_file def bulk_import(query_params): @@ -16,15 +16,16 @@ def bulk_import(query_params): arango client. """ schema = spec_loader.get_schema(query_params['collection']) - temp_fd = tempfile.NamedTemporaryFile() - with open(temp_fd.name, 'a') as fd: + with tempfile.NamedTemporaryFile(mode='a', delete=False) as temp_fd: + # temp_fd is closed and deleted when the context ends for line in flask.request.stream: + print('line', line) json_line = json.loads(line) jsonschema.validate(json_line, schema) json_line = _write_edge_key(json_line) - fd.write(json.dumps(json_line) + '\n') - resp_text = _import_from_file(temp_fd.name, query_params) - temp_fd.close() # Also deletes the file + print(temp_fd.write(json.dumps(json_line) + '\n')) + resp_text = import_from_file(temp_fd.name, query_params) + os.remove(temp_fd.name) return resp_text @@ -35,17 +36,3 @@ def _write_edge_key(json_line): json_line["_from"].encode() + json_line["_to"].encode(), digest_size=8 ).hexdigest() return json_line - - -def _import_from_file(file_path, query): - """Open a file of line-separated JSON and bulk-import it.""" - with open(file_path, 'rb') as file_desc: - resp = requests.post( - db_url + '/_api/import', - data=file_desc, - auth=(db_user, db_pass), - params=query - ) - if not resp.ok: - raise ArangoServerError(resp.text) - return resp.text From 9a2254352c85128b00b4695dc28ee1200272f9df Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 21 Nov 2018 10:31:26 -0800 Subject: [PATCH 150/732] Use invalid_token instead of "xyz" in tests --- api/src/test/test_api.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/src/test/test_api.py b/api/src/test/test_api.py index 0474bf5b..f757b23e 100644 --- a/api/src/test/test_api.py +++ b/api/src/test/test_api.py @@ -114,7 +114,7 @@ def test_save_documents_invalid_auth(self): """Test an invalid attempt to save a doc with a bad auth token.""" resp = requests.put( url + '/api/documents?on_duplicate=error&overwrite=true&collection', - headers={'Authorization': 'Bearer xyz'} + headers={'Authorization': 'Bearer ' + invalid_token} ).json() self.assertEqual(resp['error'], '403 - Unauthorized') @@ -264,7 +264,7 @@ def test_admin_query_invalid_auth(self): resp = requests.post( url + '/api/query_results', params={}, - headers={'Authorization': 'xyz'}, + headers={'Authorization': invalid_token}, data=json.dumps({ 'query': 'for v in example_vertices sort rand() limit @count return v._id', 'count': 1 From e40911998bb6aded2408a3e658cb921ee28144ad Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 21 Nov 2018 10:42:22 -0800 Subject: [PATCH 151/732] Debug travis --- api/.travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/.travis.yml b/api/.travis.yml index 99e89f42..698ae832 100644 --- a/api/.travis.yml +++ b/api/.travis.yml @@ -6,6 +6,6 @@ python: - 3.6 script: - cp .env.example .env -- docker-compose up -d +- docker-compose up --build -d - sleep 15 - make test From 092bfe82696bf5be3192640ef1b6bf7fc5ea538f Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 21 Nov 2018 10:55:18 -0800 Subject: [PATCH 152/732] Print the results of update_specs for travis --- api/src/test/test_api.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/api/src/test/test_api.py b/api/src/test/test_api.py index f757b23e..ed694559 100644 --- a/api/src/test/test_api.py +++ b/api/src/test/test_api.py @@ -54,11 +54,12 @@ class TestApi(unittest.TestCase): @classmethod def setUpClass(cls): # Initialize collections before running any tests - requests.get( + resp = requests.get( url + '/api/update_specs', headers=headers_admin, params={'reset': '1', 'init_collections': '1'} ) + print('update_specs response', resp.text) def test_root(self): """Test root path for api.""" From 5d43cb90725f3926439db2275895d9218c4bef9f Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 21 Nov 2018 11:33:31 -0800 Subject: [PATCH 153/732] Provide the option to set the spec release url via an env var --- api/.travis.yml | 2 ++ api/src/relation_engine_server/pull_spec.py | 27 ++++++++++++--------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/api/.travis.yml b/api/.travis.yml index 698ae832..fe33517a 100644 --- a/api/.travis.yml +++ b/api/.travis.yml @@ -2,6 +2,8 @@ sudo: required services: - docker language: python +env: + - SPEC_RELEASE_URL=https://api.github.com/repos/kbase/relation_engine_spec/tarball/v0.0.2 python: - 3.6 script: diff --git a/api/src/relation_engine_server/pull_spec.py b/api/src/relation_engine_server/pull_spec.py index 16033695..ea33c2b3 100644 --- a/api/src/relation_engine_server/pull_spec.py +++ b/api/src/relation_engine_server/pull_spec.py @@ -16,17 +16,12 @@ def download_latest(reset=False, init_collections=True): if reset and os.path.exists(_spec_dir): shutil.rmtree(_spec_dir) os.makedirs(_spec_dir, exist_ok=True) - # Download information about the latest release - release_resp = requests.get(_api_url + '/releases/latest') - release_info = release_resp.json() - if release_resp.status_code != 200: - # This may be a github API rate usage limit, or some other error - return release_info['message'] - if _has_latest_spec(release_info): - return 'already up to date: ' + release_info['tag_name'] # Download and extract a new release to /spec/repo spec_repo_path = os.path.join(_spec_dir, 'repo') - tarball_url = release_info['tarball_url'] + if 'SPEC_RELEASE_URL' in os.environ: + tarball_url = os.environ['SPEC_RELEASE_URL'] + else: + tarball_url = _fetch_github_release_url() resp = requests.get(tarball_url, stream=True) with tempfile.NamedTemporaryFile() as temp_file: # The temp file will be closed/deleted when the context ends @@ -37,13 +32,21 @@ def download_latest(reset=False, init_collections=True): # The files will be extracted into a directory like /spec/kbase-relation_engine_spec-xyz # We want to move that to /spec/repo _rename_directories(_spec_dir, spec_repo_path) - # Save the release ID to /spec/.release_id - _save_release_id(release_info) # Initialize all the collections if init_collections: schemas = spec_loader.get_schema_names() arango_client.init_collections(schemas) - return 'updated to ' + release_info['tag_name'] + return 'updated from ' + tarball_url + + +def _fetch_github_release_url(): + # Download information about the latest release + release_resp = requests.get(_api_url + '/releases/latest') + release_info = release_resp.json() + if release_resp.status_code != 200: + # This may be a github API rate usage limit, or some other error + raise Exception(release_info['message']) + return release_info['tarball_url'] def _download_file(resp, path): From 75f4b0d55c7bd5bfcdc1d7f0deda8a0861148873 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 21 Nov 2018 14:12:47 -0800 Subject: [PATCH 154/732] Add non-api tarball url of specs for travis --- api/.travis.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/api/.travis.yml b/api/.travis.yml index a14319e5..e2d1a41e 100644 --- a/api/.travis.yml +++ b/api/.travis.yml @@ -2,6 +2,11 @@ sudo: required services: - docker language: python +<<<<<<< Updated upstream +======= +env: + - SPEC_RELEASE_URL=https://github.com/kbase/relation_engine_spec/archive/v0.0.2.tar.gz +>>>>>>> Stashed changes python: - 3.6 script: From c1929bb18c5f1aefdef2748f21c99caef2f23488 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 5 Dec 2018 10:46:26 -0800 Subject: [PATCH 155/732] Update CODEOWNERS --- spec/CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/CODEOWNERS b/spec/CODEOWNERS index 788e5f5d..9703c9e0 100644 --- a/spec/CODEOWNERS +++ b/spec/CODEOWNERS @@ -1 +1 @@ -* @jayrbolton +* @jayrbolton @JamesJeffryes From 17bd3ad5b189961d2e2486b32956844929278840 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 5 Dec 2018 11:02:33 -0800 Subject: [PATCH 156/732] Add the things --- spec/schemas/edges/wsprov_input_in.js | 18 ++++++++++++++++ spec/schemas/edges/wsprov_produced.json | 16 ++++++++++++++ spec/schemas/edges/wsprov_similar_to.json | 18 ++++++++++++++++ spec/schemas/vertices/wsprov_action.json | 26 +++++++++++++++++++++++ spec/schemas/vertices/wsprov_object.json | 25 ++++++++++++++++++++++ 5 files changed, 103 insertions(+) create mode 100644 spec/schemas/edges/wsprov_input_in.js create mode 100644 spec/schemas/edges/wsprov_produced.json create mode 100644 spec/schemas/edges/wsprov_similar_to.json create mode 100644 spec/schemas/vertices/wsprov_action.json create mode 100644 spec/schemas/vertices/wsprov_object.json diff --git a/spec/schemas/edges/wsprov_input_in.js b/spec/schemas/edges/wsprov_input_in.js new file mode 100644 index 00000000..100a5323 --- /dev/null +++ b/spec/schemas/edges/wsprov_input_in.js @@ -0,0 +1,18 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "required": ["_from", "_to"], + "description": "The workspace object was input in a provenance action", + "properties": { + "_from": { + "type": "string", + "examples": ["wsprov_object/1:2:3"] + }, + "_to": { + "type": "string", + "examples": ["wsprov_action/1:2:3"] + } + } +} + + diff --git a/spec/schemas/edges/wsprov_produced.json b/spec/schemas/edges/wsprov_produced.json new file mode 100644 index 00000000..6bd39904 --- /dev/null +++ b/spec/schemas/edges/wsprov_produced.json @@ -0,0 +1,16 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "required": ["_from", "_to"], + "description": "The provenance action produced the workspace object", + "properties": { + "_from": { + "type": "string", + "examples": ["wsprov_action/1:2:3"] + }, + "_to": { + "type": "string", + "examples": ["wsprov_object/1:2:3"] + } + } +} diff --git a/spec/schemas/edges/wsprov_similar_to.json b/spec/schemas/edges/wsprov_similar_to.json new file mode 100644 index 00000000..78acd476 --- /dev/null +++ b/spec/schemas/edges/wsprov_similar_to.json @@ -0,0 +1,18 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "required": ["_from", "_to"], + "description": "The workspace object is similar to another object", + "properties": { + "_from": { + "type": "string", + "examples": ["wsprov_object/1:2:3"] + }, + "_to": { + "type": "string", + "examples": ["wsprov_object/1:2:3"] + } + } +} + + diff --git a/spec/schemas/vertices/wsprov_action.json b/spec/schemas/vertices/wsprov_action.json new file mode 100644 index 00000000..fc6f2549 --- /dev/null +++ b/spec/schemas/vertices/wsprov_action.json @@ -0,0 +1,26 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "required": [ + "_key", + "workspace_id", + "runner" + ], + "properties": { + "_key": { + "type": "string", + "description": "Slugified name of the action with its timestamp and workspace id", + "examples": [ "copy:123123123:42" ] + }, + "workspace_id": { + "type": "integer", + "description": "The workspace_id in which this action was performed", + "minimum": 1 + }, + "runner": { + "type": "string", + "description": "The person who ran this action" + } + } +} + diff --git a/spec/schemas/vertices/wsprov_object.json b/spec/schemas/vertices/wsprov_object.json new file mode 100644 index 00000000..333848f9 --- /dev/null +++ b/spec/schemas/vertices/wsprov_object.json @@ -0,0 +1,25 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "required": [ + "_key", + "workspace_id", + "owner" + ], + "properties": { + "_key": { + "type": "string", + "description": "The workspace reference for this object", + "examples": [ "1:2:3" ] + }, + "workspace_id": { + "type": "integer", + "description": "The workspace_id for this object", + "minimum": 1 + }, + "owner": { + "type": "string", + "description": "The owner of this workspace object" + } + } +} From b9f4f32c50d62b405f9244daa8e3b6a0dd7540fe Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 11 Dec 2018 12:49:45 -0800 Subject: [PATCH 157/732] Reorganize schemas with prefixes and subfolders --- spec/schemas/edges/is_child_of.json | 17 ------- spec/schemas/edges/is_identical_to.json | 11 ----- spec/schemas/edges/is_produced_by.json | 19 -------- .../mash_genome_similar_to.json} | 0 .../ncbi_genomes/ncbi_gene_within_genome.json | 0 .../wsprov_input_in.js | 0 .../wsprov_produced.json | 0 spec/schemas/edges/published_in.json | 19 -------- .../rxn_gene_within_complex.json | 0 .../rxn_reaction_within_complex.json | 0 .../rxn_similar_to_reaction.json} | 0 .../{example_edges.json => test_edge.json} | 0 .../wsfull_consumed_by.json} | 0 .../wsfull_contains.json} | 0 .../wsfull_copied_from.json} | 0 .../wsfull_created_from.json} | 0 .../wsfull_created_using.json} | 0 .../wsfull_created_with_method.json} | 0 .../wsfull_instance_of.json} | 0 .../wsfull_latest_version_of.json} | 0 .../wsfull_owner_of.json} | 0 .../wsfull_refers_to.json} | 0 .../wsfull_version_of.json} | 0 .../ncbi_gene.json} | 0 .../ncbi_genome.json} | 0 .../wsprov_action.json | 0 .../wsprov_object.json | 0 spec/schemas/vertices/publications.json | 45 ------------------- .../rxn_gene_complex.json} | 0 .../rxn_reaction.json} | 0 spec/schemas/vertices/taxa.json | 18 -------- ...example_vertices.json => test_vertex.json} | 0 .../wsfull_method.json} | 0 .../wsfull_method_version.json} | 0 .../wsfull_module.json} | 0 .../wsfull_module_version.json} | 0 .../wsfull_object.json} | 0 .../wsfull_object_hash.json} | 0 .../wsfull_object_version.json} | 0 .../wsfull_type.json} | 0 .../wsfull_type_module.json} | 0 .../wsfull_type_version.json} | 0 .../wsfull_user.json} | 0 .../wsfull_workspace.json} | 0 44 files changed, 129 deletions(-) delete mode 100644 spec/schemas/edges/is_child_of.json delete mode 100644 spec/schemas/edges/is_identical_to.json delete mode 100644 spec/schemas/edges/is_produced_by.json rename spec/schemas/edges/{wsprov_similar_to.json => mash_homology/mash_genome_similar_to.json} (100%) create mode 100644 spec/schemas/edges/ncbi_genomes/ncbi_gene_within_genome.json rename spec/schemas/edges/{ => provenance_simple}/wsprov_input_in.js (100%) rename spec/schemas/edges/{ => provenance_simple}/wsprov_produced.json (100%) delete mode 100644 spec/schemas/edges/published_in.json create mode 100644 spec/schemas/edges/reaction_homology/rxn_gene_within_complex.json create mode 100644 spec/schemas/edges/reaction_homology/rxn_reaction_within_complex.json rename spec/schemas/edges/{is_similar_to.json => reaction_homology/rxn_similar_to_reaction.json} (100%) rename spec/schemas/edges/{example_edges.json => test_edge.json} (100%) rename spec/schemas/edges/{is_consumed_by.json => workspace_full/wsfull_consumed_by.json} (100%) rename spec/schemas/edges/{contains.json => workspace_full/wsfull_contains.json} (100%) rename spec/schemas/edges/{was_copied_from.json => workspace_full/wsfull_copied_from.json} (100%) rename spec/schemas/edges/{was_created_from.json => workspace_full/wsfull_created_from.json} (100%) rename spec/schemas/edges/{was_created_using.json => workspace_full/wsfull_created_using.json} (100%) rename spec/schemas/edges/{ws_object_was_created_with_method.json => workspace_full/wsfull_created_with_method.json} (100%) rename spec/schemas/edges/{is_instance_of.json => workspace_full/wsfull_instance_of.json} (100%) rename spec/schemas/edges/{is_latest_version_of.json => workspace_full/wsfull_latest_version_of.json} (100%) rename spec/schemas/edges/{is_owner_of.json => workspace_full/wsfull_owner_of.json} (100%) rename spec/schemas/edges/{refers_to.json => workspace_full/wsfull_refers_to.json} (100%) rename spec/schemas/edges/{is_version_of.json => workspace_full/wsfull_version_of.json} (100%) rename spec/schemas/vertices/{features.json => ncbi_genomes/ncbi_gene.json} (100%) rename spec/schemas/vertices/{genomes.json => ncbi_genomes/ncbi_genome.json} (100%) rename spec/schemas/vertices/{ => provenance_simple}/wsprov_action.json (100%) rename spec/schemas/vertices/{ => provenance_simple}/wsprov_object.json (100%) delete mode 100644 spec/schemas/vertices/publications.json rename spec/schemas/vertices/{gene_reaction_complexes.json => reaction_homology/rxn_gene_complex.json} (100%) rename spec/schemas/vertices/{chemical_reactions.json => reaction_homology/rxn_reaction.json} (100%) delete mode 100644 spec/schemas/vertices/taxa.json rename spec/schemas/vertices/{example_vertices.json => test_vertex.json} (100%) rename spec/schemas/vertices/{sdk_module_methods.json => workspace_full/wsfull_method.json} (100%) rename spec/schemas/vertices/{sdk_module_method_versions.json => workspace_full/wsfull_method_version.json} (100%) rename spec/schemas/vertices/{sdk_modules.json => workspace_full/wsfull_module.json} (100%) rename spec/schemas/vertices/{sdk_module_versions.json => workspace_full/wsfull_module_version.json} (100%) rename spec/schemas/vertices/{ws_objects.json => workspace_full/wsfull_object.json} (100%) rename spec/schemas/vertices/{object_hashes.json => workspace_full/wsfull_object_hash.json} (100%) rename spec/schemas/vertices/{ws_object_versions.json => workspace_full/wsfull_object_version.json} (100%) rename spec/schemas/vertices/{types.json => workspace_full/wsfull_type.json} (100%) rename spec/schemas/vertices/{type_modules.json => workspace_full/wsfull_type_module.json} (100%) rename spec/schemas/vertices/{type_versions.json => workspace_full/wsfull_type_version.json} (100%) rename spec/schemas/vertices/{users.json => workspace_full/wsfull_user.json} (100%) rename spec/schemas/vertices/{workspaces.json => workspace_full/wsfull_workspace.json} (100%) diff --git a/spec/schemas/edges/is_child_of.json b/spec/schemas/edges/is_child_of.json deleted file mode 100644 index f00e9ce0..00000000 --- a/spec/schemas/edges/is_child_of.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "required": ["_from", "_to"], - "description": "A taxonomic, parent-child hierarchical relationship.", - "additionalProperties": true, - "properties": { - "_from": { - "type": "string", - "description": "The ID of a child vertex that inherits from a parent." - }, - "_to": { - "type": "string", - "description": "The ID of a parent vertex that is inherited by a child." - } - } -} diff --git a/spec/schemas/edges/is_identical_to.json b/spec/schemas/edges/is_identical_to.json deleted file mode 100644 index 61938e05..00000000 --- a/spec/schemas/edges/is_identical_to.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "required": ["_from", "_to"], - "description": "The _from entity is exactly identical to the _to entity.", - "properties": { - "_from": { "type": "string" }, - "_to": { "type": "string" } - } -} - diff --git a/spec/schemas/edges/is_produced_by.json b/spec/schemas/edges/is_produced_by.json deleted file mode 100644 index 39daa2a8..00000000 --- a/spec/schemas/edges/is_produced_by.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "required": ["_from", "_to"], - "description": "An entity produced from something else. Eg: reactions -> is_produced_by -> gene_reaction_complexes. This is in contrast to `was_created_from` or `was_created_using`, because this represents the relationship '_from is generally produced by _to' (and may be produced by other things), instead of '_from was specifically created from the data in _to'", - "additionalProperties": true, - "properties": { - "_from": { - "type": "string", - "description": "The ID of a vertex that produces something else." - }, - "_to": { - "type": "string", - "description": "The ID of a vertex that is produced by something else." - } - } -} - - diff --git a/spec/schemas/edges/wsprov_similar_to.json b/spec/schemas/edges/mash_homology/mash_genome_similar_to.json similarity index 100% rename from spec/schemas/edges/wsprov_similar_to.json rename to spec/schemas/edges/mash_homology/mash_genome_similar_to.json diff --git a/spec/schemas/edges/ncbi_genomes/ncbi_gene_within_genome.json b/spec/schemas/edges/ncbi_genomes/ncbi_gene_within_genome.json new file mode 100644 index 00000000..e69de29b diff --git a/spec/schemas/edges/wsprov_input_in.js b/spec/schemas/edges/provenance_simple/wsprov_input_in.js similarity index 100% rename from spec/schemas/edges/wsprov_input_in.js rename to spec/schemas/edges/provenance_simple/wsprov_input_in.js diff --git a/spec/schemas/edges/wsprov_produced.json b/spec/schemas/edges/provenance_simple/wsprov_produced.json similarity index 100% rename from spec/schemas/edges/wsprov_produced.json rename to spec/schemas/edges/provenance_simple/wsprov_produced.json diff --git a/spec/schemas/edges/published_in.json b/spec/schemas/edges/published_in.json deleted file mode 100644 index 2be69fd8..00000000 --- a/spec/schemas/edges/published_in.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "required": ["_from", "_to"], - "description": "The _from dataset was published in the _to publication", - "additionalProperties": true, - "properties": { - "_from": { - "type": "string", - "description": "The ID of the data that was published in _to" - }, - "_to": { - "type": "string", - "pattern": "^publications/.+$", - "description": "The ID of a publication that was published in _from" - } - } -} - diff --git a/spec/schemas/edges/reaction_homology/rxn_gene_within_complex.json b/spec/schemas/edges/reaction_homology/rxn_gene_within_complex.json new file mode 100644 index 00000000..e69de29b diff --git a/spec/schemas/edges/reaction_homology/rxn_reaction_within_complex.json b/spec/schemas/edges/reaction_homology/rxn_reaction_within_complex.json new file mode 100644 index 00000000..e69de29b diff --git a/spec/schemas/edges/is_similar_to.json b/spec/schemas/edges/reaction_homology/rxn_similar_to_reaction.json similarity index 100% rename from spec/schemas/edges/is_similar_to.json rename to spec/schemas/edges/reaction_homology/rxn_similar_to_reaction.json diff --git a/spec/schemas/edges/example_edges.json b/spec/schemas/edges/test_edge.json similarity index 100% rename from spec/schemas/edges/example_edges.json rename to spec/schemas/edges/test_edge.json diff --git a/spec/schemas/edges/is_consumed_by.json b/spec/schemas/edges/workspace_full/wsfull_consumed_by.json similarity index 100% rename from spec/schemas/edges/is_consumed_by.json rename to spec/schemas/edges/workspace_full/wsfull_consumed_by.json diff --git a/spec/schemas/edges/contains.json b/spec/schemas/edges/workspace_full/wsfull_contains.json similarity index 100% rename from spec/schemas/edges/contains.json rename to spec/schemas/edges/workspace_full/wsfull_contains.json diff --git a/spec/schemas/edges/was_copied_from.json b/spec/schemas/edges/workspace_full/wsfull_copied_from.json similarity index 100% rename from spec/schemas/edges/was_copied_from.json rename to spec/schemas/edges/workspace_full/wsfull_copied_from.json diff --git a/spec/schemas/edges/was_created_from.json b/spec/schemas/edges/workspace_full/wsfull_created_from.json similarity index 100% rename from spec/schemas/edges/was_created_from.json rename to spec/schemas/edges/workspace_full/wsfull_created_from.json diff --git a/spec/schemas/edges/was_created_using.json b/spec/schemas/edges/workspace_full/wsfull_created_using.json similarity index 100% rename from spec/schemas/edges/was_created_using.json rename to spec/schemas/edges/workspace_full/wsfull_created_using.json diff --git a/spec/schemas/edges/ws_object_was_created_with_method.json b/spec/schemas/edges/workspace_full/wsfull_created_with_method.json similarity index 100% rename from spec/schemas/edges/ws_object_was_created_with_method.json rename to spec/schemas/edges/workspace_full/wsfull_created_with_method.json diff --git a/spec/schemas/edges/is_instance_of.json b/spec/schemas/edges/workspace_full/wsfull_instance_of.json similarity index 100% rename from spec/schemas/edges/is_instance_of.json rename to spec/schemas/edges/workspace_full/wsfull_instance_of.json diff --git a/spec/schemas/edges/is_latest_version_of.json b/spec/schemas/edges/workspace_full/wsfull_latest_version_of.json similarity index 100% rename from spec/schemas/edges/is_latest_version_of.json rename to spec/schemas/edges/workspace_full/wsfull_latest_version_of.json diff --git a/spec/schemas/edges/is_owner_of.json b/spec/schemas/edges/workspace_full/wsfull_owner_of.json similarity index 100% rename from spec/schemas/edges/is_owner_of.json rename to spec/schemas/edges/workspace_full/wsfull_owner_of.json diff --git a/spec/schemas/edges/refers_to.json b/spec/schemas/edges/workspace_full/wsfull_refers_to.json similarity index 100% rename from spec/schemas/edges/refers_to.json rename to spec/schemas/edges/workspace_full/wsfull_refers_to.json diff --git a/spec/schemas/edges/is_version_of.json b/spec/schemas/edges/workspace_full/wsfull_version_of.json similarity index 100% rename from spec/schemas/edges/is_version_of.json rename to spec/schemas/edges/workspace_full/wsfull_version_of.json diff --git a/spec/schemas/vertices/features.json b/spec/schemas/vertices/ncbi_genomes/ncbi_gene.json similarity index 100% rename from spec/schemas/vertices/features.json rename to spec/schemas/vertices/ncbi_genomes/ncbi_gene.json diff --git a/spec/schemas/vertices/genomes.json b/spec/schemas/vertices/ncbi_genomes/ncbi_genome.json similarity index 100% rename from spec/schemas/vertices/genomes.json rename to spec/schemas/vertices/ncbi_genomes/ncbi_genome.json diff --git a/spec/schemas/vertices/wsprov_action.json b/spec/schemas/vertices/provenance_simple/wsprov_action.json similarity index 100% rename from spec/schemas/vertices/wsprov_action.json rename to spec/schemas/vertices/provenance_simple/wsprov_action.json diff --git a/spec/schemas/vertices/wsprov_object.json b/spec/schemas/vertices/provenance_simple/wsprov_object.json similarity index 100% rename from spec/schemas/vertices/wsprov_object.json rename to spec/schemas/vertices/provenance_simple/wsprov_object.json diff --git a/spec/schemas/vertices/publications.json b/spec/schemas/vertices/publications.json deleted file mode 100644 index 238911e5..00000000 --- a/spec/schemas/vertices/publications.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "additionalProperties": false, - "description": "The citation for an academic publication", - "required": [ - "_key", - "pubmed_id", - "source", - "title", - "web_address", - "publication_year", - "authors", - "journal" - ], - "properties": { - "_key": { - "type": "string" - }, - "pubmed_id": { - "type": "number" - }, - "source": { - "type": "string", - "examples": ["Pubmed"] - }, - "title": { - "type": "string" - }, - "web_address": { - "type": "string", - "format": "url" - }, - "publication_year": { - "type": "integer", - "min": 1700 - }, - "authors": { - "type": "string" - }, - "journal": { - "type": "string" - } - } -} diff --git a/spec/schemas/vertices/gene_reaction_complexes.json b/spec/schemas/vertices/reaction_homology/rxn_gene_complex.json similarity index 100% rename from spec/schemas/vertices/gene_reaction_complexes.json rename to spec/schemas/vertices/reaction_homology/rxn_gene_complex.json diff --git a/spec/schemas/vertices/chemical_reactions.json b/spec/schemas/vertices/reaction_homology/rxn_reaction.json similarity index 100% rename from spec/schemas/vertices/chemical_reactions.json rename to spec/schemas/vertices/reaction_homology/rxn_reaction.json diff --git a/spec/schemas/vertices/taxa.json b/spec/schemas/vertices/taxa.json deleted file mode 100644 index 64f436e9..00000000 --- a/spec/schemas/vertices/taxa.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "additionalProperties": false, - "description": "Biological taxonomic node (class, order, family, genus, species, organism)", - "required": ["_key", "name"], - "properties": { - "_key": { - "type": "string", - "examples": ["haloferax_volcanii"], - "description": "Normalized name (lower-cased and snake-cased)" - }, - "name": { - "type": "string", - "examples": ["Haloferax Volcanii"] - } - } -} diff --git a/spec/schemas/vertices/example_vertices.json b/spec/schemas/vertices/test_vertex.json similarity index 100% rename from spec/schemas/vertices/example_vertices.json rename to spec/schemas/vertices/test_vertex.json diff --git a/spec/schemas/vertices/sdk_module_methods.json b/spec/schemas/vertices/workspace_full/wsfull_method.json similarity index 100% rename from spec/schemas/vertices/sdk_module_methods.json rename to spec/schemas/vertices/workspace_full/wsfull_method.json diff --git a/spec/schemas/vertices/sdk_module_method_versions.json b/spec/schemas/vertices/workspace_full/wsfull_method_version.json similarity index 100% rename from spec/schemas/vertices/sdk_module_method_versions.json rename to spec/schemas/vertices/workspace_full/wsfull_method_version.json diff --git a/spec/schemas/vertices/sdk_modules.json b/spec/schemas/vertices/workspace_full/wsfull_module.json similarity index 100% rename from spec/schemas/vertices/sdk_modules.json rename to spec/schemas/vertices/workspace_full/wsfull_module.json diff --git a/spec/schemas/vertices/sdk_module_versions.json b/spec/schemas/vertices/workspace_full/wsfull_module_version.json similarity index 100% rename from spec/schemas/vertices/sdk_module_versions.json rename to spec/schemas/vertices/workspace_full/wsfull_module_version.json diff --git a/spec/schemas/vertices/ws_objects.json b/spec/schemas/vertices/workspace_full/wsfull_object.json similarity index 100% rename from spec/schemas/vertices/ws_objects.json rename to spec/schemas/vertices/workspace_full/wsfull_object.json diff --git a/spec/schemas/vertices/object_hashes.json b/spec/schemas/vertices/workspace_full/wsfull_object_hash.json similarity index 100% rename from spec/schemas/vertices/object_hashes.json rename to spec/schemas/vertices/workspace_full/wsfull_object_hash.json diff --git a/spec/schemas/vertices/ws_object_versions.json b/spec/schemas/vertices/workspace_full/wsfull_object_version.json similarity index 100% rename from spec/schemas/vertices/ws_object_versions.json rename to spec/schemas/vertices/workspace_full/wsfull_object_version.json diff --git a/spec/schemas/vertices/types.json b/spec/schemas/vertices/workspace_full/wsfull_type.json similarity index 100% rename from spec/schemas/vertices/types.json rename to spec/schemas/vertices/workspace_full/wsfull_type.json diff --git a/spec/schemas/vertices/type_modules.json b/spec/schemas/vertices/workspace_full/wsfull_type_module.json similarity index 100% rename from spec/schemas/vertices/type_modules.json rename to spec/schemas/vertices/workspace_full/wsfull_type_module.json diff --git a/spec/schemas/vertices/type_versions.json b/spec/schemas/vertices/workspace_full/wsfull_type_version.json similarity index 100% rename from spec/schemas/vertices/type_versions.json rename to spec/schemas/vertices/workspace_full/wsfull_type_version.json diff --git a/spec/schemas/vertices/users.json b/spec/schemas/vertices/workspace_full/wsfull_user.json similarity index 100% rename from spec/schemas/vertices/users.json rename to spec/schemas/vertices/workspace_full/wsfull_user.json diff --git a/spec/schemas/vertices/workspaces.json b/spec/schemas/vertices/workspace_full/wsfull_workspace.json similarity index 100% rename from spec/schemas/vertices/workspaces.json rename to spec/schemas/vertices/workspace_full/wsfull_workspace.json From 11bf647e0e300232f2ba9dd6a596f79f75f2e90a Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 12 Dec 2018 16:50:13 -0800 Subject: [PATCH 158/732] Clean up more wsfull schemas --- .../workspace_full/wsfull_consumed_by.json | 6 +++--- .../edges/workspace_full/wsfull_contains.json | 1 + .../workspace_full/wsfull_created_from.json | 19 ------------------- .../workspace_full/wsfull_created_using.json | 18 ------------------ .../workspace_full/wsfull_instance_of.json | 2 +- .../wsfull_latest_version_of.json | 8 ++++---- ...on => wsfull_obj_created_with_method.json} | 10 ++++------ .../wsfull_obj_created_with_module.json | 18 ++++++++++++++++++ .../edges/workspace_full/wsfull_owner_of.json | 7 ++++--- .../workspace_full/wsfull_refers_to.json | 2 +- .../workspace_full/wsfull_version_of.json | 9 +++++---- .../workspace_full/wsfull_method.json | 1 + .../workspace_full/wsfull_method_version.json | 2 +- .../workspace_full/wsfull_module.json | 1 + .../workspace_full/wsfull_module_version.json | 1 + 15 files changed, 45 insertions(+), 60 deletions(-) delete mode 100644 spec/schemas/edges/workspace_full/wsfull_created_from.json delete mode 100644 spec/schemas/edges/workspace_full/wsfull_created_using.json rename spec/schemas/edges/workspace_full/{wsfull_created_with_method.json => wsfull_obj_created_with_method.json} (55%) create mode 100644 spec/schemas/edges/workspace_full/wsfull_obj_created_with_module.json diff --git a/spec/schemas/edges/workspace_full/wsfull_consumed_by.json b/spec/schemas/edges/workspace_full/wsfull_consumed_by.json index f6ce5596..d85da19c 100644 --- a/spec/schemas/edges/workspace_full/wsfull_consumed_by.json +++ b/spec/schemas/edges/workspace_full/wsfull_consumed_by.json @@ -2,16 +2,16 @@ "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "required": ["_from", "_to"], - "description": "An entity consumed by something else. For example a type -> is_consumed_by -> sdk_method_version", + "description": "The _from type is consumed by the _to SDK method", "additionalProperties": true, "properties": { "_from": { "type": "string", - "description": "The ID of a vertex that consumes something else." + "description": "The ID of the type that is consumed." }, "_to": { "type": "string", - "description": "The ID of a vertex that is consumed by something else." + "description": "The ID of the SDK method that consumes the type." } } } diff --git a/spec/schemas/edges/workspace_full/wsfull_contains.json b/spec/schemas/edges/workspace_full/wsfull_contains.json index f0139d25..b77450a7 100644 --- a/spec/schemas/edges/workspace_full/wsfull_contains.json +++ b/spec/schemas/edges/workspace_full/wsfull_contains.json @@ -1,6 +1,7 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", + "description": "A module contains a method, a workspace contains an object.", "additionalProperties": false, "required": ["_from", "_to"], "properties": { diff --git a/spec/schemas/edges/workspace_full/wsfull_created_from.json b/spec/schemas/edges/workspace_full/wsfull_created_from.json deleted file mode 100644 index 44d856db..00000000 --- a/spec/schemas/edges/workspace_full/wsfull_created_from.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "additionalProperties": false, - "required": ["_from", "_to"], - "description": "The _from entity is derived from the _to data. Eg: an assembly is created *from* reads, a house is created *from* wood.", - "properties": { - "_from": { - "type": "string", - "description": "The entity that was created." - }, - "_to": { - "type": "string", - "description": "The originating data that was material in the creation of the _from data." - } - } -} - - diff --git a/spec/schemas/edges/workspace_full/wsfull_created_using.json b/spec/schemas/edges/workspace_full/wsfull_created_using.json deleted file mode 100644 index 59ccd77d..00000000 --- a/spec/schemas/edges/workspace_full/wsfull_created_using.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "additionalProperties": false, - "required": ["_from", "_to"], - "description": "The _from entity was created using the _to entity as config or a tool. Eg: an assembly is created *using* spades, or homology data was created *using* mash sketches.", - "properties": { - "_from": { - "type": "string", - "description": "The entity that was created." - }, - "_to": { - "type": "string", - "description": "The tool, configuration, or parameter that took part in the creation of _to." - } - } -} - diff --git a/spec/schemas/edges/workspace_full/wsfull_instance_of.json b/spec/schemas/edges/workspace_full/wsfull_instance_of.json index 9cdd20b4..72ca7b6f 100644 --- a/spec/schemas/edges/workspace_full/wsfull_instance_of.json +++ b/spec/schemas/edges/workspace_full/wsfull_instance_of.json @@ -3,7 +3,7 @@ "type": "object", "additionalProperties": false, "required": ["_from", "_to"], - "description": "The _from entity is an instance of the _to entity.", + "description": "The _from WS versioned object is an instance of the _to versioned type.", "properties": { "_from": { "type": "string" }, "_to": { "type": "string" } diff --git a/spec/schemas/edges/workspace_full/wsfull_latest_version_of.json b/spec/schemas/edges/workspace_full/wsfull_latest_version_of.json index febdffc6..cbfafb0c 100644 --- a/spec/schemas/edges/workspace_full/wsfull_latest_version_of.json +++ b/spec/schemas/edges/workspace_full/wsfull_latest_version_of.json @@ -7,16 +7,16 @@ "_from": { "type": "string", "examples": [ - "type_versions/KBaseGenomes.Genome‑9.0", - "app_module_versions/kb_uploadmethods:8ebb66e4f2c27bc4a9b7cddff7d7b0f27f4ee433" + "wsfull_type_version/KBaseGenomes.Genome‑9.0", + "wsfull_module_version/kb_uploadmethods:8ebb66e4f2c27bc4a9b7cddff7d7b0f27f4ee433" ], "description": "A versioned entity, representing the most recent version of an entity in a group (most likely a workspace object, module, or workspace type)." }, "_to": { "type": "string", "examples": [ - "types/KBaseGenomes.Genome", - "app_modules/kb_uploadmethods" + "wsfull_type/KBaseGenomes.Genome", + "wsfull_module/kb_uploadmethods" ], "description": "The non-versioned entity group, where all members of the group are different versions of something (eg. a workspace object, module, or workspace type)" } diff --git a/spec/schemas/edges/workspace_full/wsfull_created_with_method.json b/spec/schemas/edges/workspace_full/wsfull_obj_created_with_method.json similarity index 55% rename from spec/schemas/edges/workspace_full/wsfull_created_with_method.json rename to spec/schemas/edges/workspace_full/wsfull_obj_created_with_method.json index 1a466e2e..79c4af99 100644 --- a/spec/schemas/edges/workspace_full/wsfull_created_with_method.json +++ b/spec/schemas/edges/workspace_full/wsfull_obj_created_with_method.json @@ -3,21 +3,19 @@ "type": "object", "additionalProperties": false, "required": ["_from", "_to", "method_params"], - "description": "The _from object was generated by the _to module method.", + "description": "The _from WS versioned object was created by the _to SDK versioned method.", "properties": { "_from": { "type": "string", - "examples": ["ws_object_versions/35414:73:1"], - "pattern": "^ws_object_versions/.+$", + "examples": ["wsfull_object_version/35414:73:1"], "description": "A versioned workspace object." }, "_to": { "type": "string", "examples": [ - "sdk_module_method_versions/kb_uploadmethods:8ebb66e4f2c27bc4a9b7cddff7d7b0f27f4ee433.import_genbank_from_staging", - "sdk_module_method_versions/kb_uploadmethods:UNKNOWN.import_genbank_from_staging" + "wsfull_method_version/kb_uploadmethods:8ebb66e4f2c27bc4a9b7cddff7d7b0f27f4ee433.import_genbank_from_staging", + "wsfull_method_version/kb_uploadmethods:UNKNOWN.import_genbank_from_staging" ], - "pattern": "^sdk_module_method_versions/.+$", "description": "A version of a module with a method." }, "method_params": { diff --git a/spec/schemas/edges/workspace_full/wsfull_obj_created_with_module.json b/spec/schemas/edges/workspace_full/wsfull_obj_created_with_module.json new file mode 100644 index 00000000..21b65cd7 --- /dev/null +++ b/spec/schemas/edges/workspace_full/wsfull_obj_created_with_module.json @@ -0,0 +1,18 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "additionalProperties": false, + "required": ["_from", "_to"], + "description": "The _from WS versioned object was created with the _to SDK versioned module.", + "properties": { + "_from": { + "type": "string", + "description": "The WS versioned object that was created." + }, + "_to": { + "type": "string", + "description": "The SDK versioned module that created the object." + } + } +} + diff --git a/spec/schemas/edges/workspace_full/wsfull_owner_of.json b/spec/schemas/edges/workspace_full/wsfull_owner_of.json index cf103ece..c2086803 100644 --- a/spec/schemas/edges/workspace_full/wsfull_owner_of.json +++ b/spec/schemas/edges/workspace_full/wsfull_owner_of.json @@ -2,20 +2,21 @@ "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "additionalProperties": false, + "description": "The user is an owner of a workspace or type module.", "required": ["_from", "_to"], "properties": { "_from": { "type": "string", "examples": [ - "users/jjeffryes" + "wsfull_user/jjeffryes" ], "description": "A username" }, "_to": { "type": "string", "examples": [ - "type_modules/KBaseGenomes", - "workspaces/35414" + "wsfull_type_module/KBaseGenomes", + "wsfull_workspace/35414" ], "description": "A Workspace or Type Module" } diff --git a/spec/schemas/edges/workspace_full/wsfull_refers_to.json b/spec/schemas/edges/workspace_full/wsfull_refers_to.json index f39de906..4b43e678 100644 --- a/spec/schemas/edges/workspace_full/wsfull_refers_to.json +++ b/spec/schemas/edges/workspace_full/wsfull_refers_to.json @@ -3,7 +3,7 @@ "type": "object", "additionalProperties": false, "required": ["_from", "_to"], - "description": "The _from entity has an attribute which is a reference to the _to object.", + "description": "The _from object has an attribute which is a reference to the _to object.", "properties": { "_from": { "type": "string" }, "_to": { "type": "string" } diff --git a/spec/schemas/edges/workspace_full/wsfull_version_of.json b/spec/schemas/edges/workspace_full/wsfull_version_of.json index d6478bb3..fabb66c2 100644 --- a/spec/schemas/edges/workspace_full/wsfull_version_of.json +++ b/spec/schemas/edges/workspace_full/wsfull_version_of.json @@ -2,21 +2,22 @@ "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "additionalProperties": false, + "description": "The _from entity is a version of a the _to entity (eg. type, method, module).", "required": ["_from", "_to"], "properties": { "_from": { "type": "string", "examples": [ - "type_versions/KBaseGenomes.Genome‑9.0", - "app_module_versions/kb_uploadmethods:8ebb66e4f2c27bc4a9b7cddff7d7b0f27f4ee433" + "wsfull_type_version/KBaseGenomes.Genome‑9.0", + "wsfull_method_version/kb_uploadmethods:8ebb66e4f2c27bc4a9b7cddff7d7b0f27f4ee433" ], "description": "A versioned entity (eg. a workspace object, module, or workspace type)" }, "_to": { "type": "string", "examples": [ - "types/KBaseGenomes.Genome", - "app_modules/kb_uploadmethods" + "wsfull_type/KBaseGenomes.Genome", + "wsfull_method/kb_uploadmethods" ], "description": "The non-versioned entity group, where all members of the group are different versions of something (eg. a workspace object, module, or workspace type)." }, diff --git a/spec/schemas/vertices/workspace_full/wsfull_method.json b/spec/schemas/vertices/workspace_full/wsfull_method.json index 7fe80301..2b2f2396 100644 --- a/spec/schemas/vertices/workspace_full/wsfull_method.json +++ b/spec/schemas/vertices/workspace_full/wsfull_method.json @@ -1,6 +1,7 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", + "description": "SDK module method (unversioned).", "additionalProperties": false, "required": ["_key"], "properties": { diff --git a/spec/schemas/vertices/workspace_full/wsfull_method_version.json b/spec/schemas/vertices/workspace_full/wsfull_method_version.json index f25d9d38..e646fd0c 100644 --- a/spec/schemas/vertices/workspace_full/wsfull_method_version.json +++ b/spec/schemas/vertices/workspace_full/wsfull_method_version.json @@ -17,7 +17,7 @@ "examples": [ "module_name:version_hash.method_name", "module_name:UNKNOWN.method_name", - "sdk_module_method_versions/kb_uploadmethods:8ebb66e4f2c27bc4a9b7cddff7d7b0f27f4ee433.import_genbank_from_staging" + "wsfull_method_version/kb_uploadmethods:8ebb66e4f2c27bc4a9b7cddff7d7b0f27f4ee433.import_genbank_from_staging" ], "description": ":.", "pattern": "^\\w+:\\w+\\.\\w+$" diff --git a/spec/schemas/vertices/workspace_full/wsfull_module.json b/spec/schemas/vertices/workspace_full/wsfull_module.json index 36bb0fde..5442dbc1 100644 --- a/spec/schemas/vertices/workspace_full/wsfull_module.json +++ b/spec/schemas/vertices/workspace_full/wsfull_module.json @@ -1,6 +1,7 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", + "description": "SDK module (unversioned).", "additionalProperties": false, "required": [ "_key", diff --git a/spec/schemas/vertices/workspace_full/wsfull_module_version.json b/spec/schemas/vertices/workspace_full/wsfull_module_version.json index fd371de9..3070b661 100644 --- a/spec/schemas/vertices/workspace_full/wsfull_module_version.json +++ b/spec/schemas/vertices/workspace_full/wsfull_module_version.json @@ -1,6 +1,7 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", + "description": "Versioned SDK Module.", "additionalProperties": false, "required": [ "_key", From 7da7d5e12e66bc370bfceae8df5d97c4a58ffdd0 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 12 Dec 2018 16:55:39 -0800 Subject: [PATCH 159/732] Add some missing schemas --- .../ncbi_genomes/ncbi_gene_within_genome.json | 15 +++++++++++++++ .../rxn_gene_within_complex.json | 15 +++++++++++++++ .../rxn_reaction_within_complex.json | 15 +++++++++++++++ 3 files changed, 45 insertions(+) diff --git a/spec/schemas/edges/ncbi_genomes/ncbi_gene_within_genome.json b/spec/schemas/edges/ncbi_genomes/ncbi_gene_within_genome.json index e69de29b..1d706118 100644 --- a/spec/schemas/edges/ncbi_genomes/ncbi_gene_within_genome.json +++ b/spec/schemas/edges/ncbi_genomes/ncbi_gene_within_genome.json @@ -0,0 +1,15 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "required": ["_from", "_to"], + "properties": { + "_from": { + "type": "string", + "description": "The ncbi_gene that is part of a genome." + }, + "_to": { + "type": "string", + "description": "The ncbi_genome that contains a gene." + } + } +} diff --git a/spec/schemas/edges/reaction_homology/rxn_gene_within_complex.json b/spec/schemas/edges/reaction_homology/rxn_gene_within_complex.json index e69de29b..3c96f786 100644 --- a/spec/schemas/edges/reaction_homology/rxn_gene_within_complex.json +++ b/spec/schemas/edges/reaction_homology/rxn_gene_within_complex.json @@ -0,0 +1,15 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "required": ["_from", "_to"], + "properties": { + "_from": { + "type": "string", + "description": "The ncbi_gene contained within a rxn_gene_complex." + }, + "_to": { + "type": "string", + "description": "The rxn_gene_complex that contains the gene." + } + } +} diff --git a/spec/schemas/edges/reaction_homology/rxn_reaction_within_complex.json b/spec/schemas/edges/reaction_homology/rxn_reaction_within_complex.json index e69de29b..f7f55e88 100644 --- a/spec/schemas/edges/reaction_homology/rxn_reaction_within_complex.json +++ b/spec/schemas/edges/reaction_homology/rxn_reaction_within_complex.json @@ -0,0 +1,15 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "required": ["_from", "_to"], + "properties": { + "_from": { + "type": "string", + "description": "The rxn_reaction contained within a rxn_gene_complex." + }, + "_to": { + "type": "string", + "description": "The rxn_gene_complex that produces a reaction." + } + } +} From da14ad7c0638f55f4bf7ff257567b9d9c7c84396 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Fri, 14 Dec 2018 13:49:10 -0800 Subject: [PATCH 160/732] Remove some unneeded code and update tests --- api/.gitignore | 3 --- api/Dockerfile | 2 -- api/scripts/start_server.sh | 2 ++ api/src/test/test_api.py | 42 ++++++++++++++++++------------------- 4 files changed, 23 insertions(+), 26 deletions(-) diff --git a/api/.gitignore b/api/.gitignore index 1cbe1853..2be5fcda 100644 --- a/api/.gitignore +++ b/api/.gitignore @@ -10,6 +10,3 @@ tmp/* coverage_report/ .coverage - -# Relation engine spec sub-repo that gets pulled while the server is running -/relation_engine_spec/ diff --git a/api/Dockerfile b/api/Dockerfile index 82af9f2f..9b5b8090 100644 --- a/api/Dockerfile +++ b/api/Dockerfile @@ -1,8 +1,6 @@ FROM python:3.7-alpine ARG DEVELOPMENT -ARG spec_url=https://github.com/kbase/relation_engine_spec -ARG spec_path=/spec COPY requirements.txt /app/requirements.txt COPY dev-requirements.txt /app/dev-requirements.txt diff --git a/api/scripts/start_server.sh b/api/scripts/start_server.sh index 3c24af56..4c6cce8c 100644 --- a/api/scripts/start_server.sh +++ b/api/scripts/start_server.sh @@ -1,5 +1,7 @@ #!/bin/sh +set -e + # Set the number of gevent workers to number of cores * 2 + 1 # See: http://docs.gunicorn.org/en/stable/design.html#how-many-workers calc_workers="$(($(nproc) * 2 + 1))" diff --git a/api/src/test/test_api.py b/api/src/test/test_api.py index ed694559..5bd71422 100644 --- a/api/src/test/test_api.py +++ b/api/src/test/test_api.py @@ -30,17 +30,17 @@ def doc(i): def create_test_edges(count): """Produce some test edges.""" def doc(i): - return '{"_from": "example_vertices/%s", "_to": "example_vertices/%s"}' % (i, i) + return '{"_from": "test_vertex/%s", "_to": "test_vertex/%s"}' % (i, i) return '\n'.join(doc(i) for i in range(0, count)) def save_test_docs(count, edges=False): if edges: docs = create_test_edges(count) - collection = 'example_edges' + collection = 'test_edge' else: docs = create_test_docs(count) - collection = 'example_vertices' + collection = 'test_vertex' return requests.put( url + '/api/documents', params={'overwrite': True, 'collection': collection}, @@ -92,16 +92,16 @@ def test_show_view(self): def test_list_schemas(self): """Test the listing out of registered JSON schemas for vertices and edges.""" resp = requests.get(url + '/api/schemas').json() - self.assertTrue('example_vertices' in resp['vertices']) - self.assertTrue('example_edges' in resp['edges']) + self.assertTrue('test_vertex' in resp['vertices']) + self.assertTrue('test_edge' in resp['edges']) self.assertFalse('error' in resp) self.assertTrue(len(resp)) def test_show_schema(self): """Test the endpoint that displays the JSON source for one schema.""" - resp = requests.get(url + '/api/schemas/example_edges').text + resp = requests.get(url + '/api/schemas/test_edge').text self.assertTrue('_from' in resp) - resp = requests.get(url + '/api/schemas/example_vertices').text + resp = requests.get(url + '/api/schemas/test_vertex').text self.assertTrue('_key' in resp) def test_save_documents_missing_auth(self): @@ -131,7 +131,7 @@ def test_save_documents_invalid_schema(self): """Test the case where some documents fail against their schema.""" resp = requests.put( url + '/api/documents', - params={'on_duplicate': 'ignore', 'collection': 'example_vertices'}, + params={'on_duplicate': 'ignore', 'collection': 'test_vertex'}, data='{"name": "x"}\n{"name": "y"}', headers=headers_admin ).json() @@ -155,7 +155,7 @@ def test_save_documents_invalid_json(self): """Test an attempt to save documents with an invalid JSON body.""" resp = requests.put( url + '/api/documents', - params={'collection': 'example_vertices'}, + params={'collection': 'test_vertex'}, data='\n', headers=headers_admin ).json() @@ -179,7 +179,7 @@ def test_update_documents(self): """Test updating existing documents.""" resp = requests.put( url + '/api/documents', - params={'on_duplicate': 'update', 'collection': 'example_vertices'}, + params={'on_duplicate': 'update', 'collection': 'test_vertex'}, data=create_test_docs(3), headers=headers_admin ).json() @@ -190,7 +190,7 @@ def test_update_edge(self): """Test updating existing edge.""" resp = requests.put( url + '/api/documents', - params={'on_duplicate': 'update', 'collection': 'example_edges'}, + params={'on_duplicate': 'update', 'collection': 'test_edge'}, data=create_test_edges(3), headers=headers_admin ).json() @@ -201,7 +201,7 @@ def test_replace_documents(self): """Test replacing of existing documents.""" resp = requests.put( url + '/api/documents', - params={'on_duplicate': 'replace', 'collection': 'example_vertices'}, + params={'on_duplicate': 'replace', 'collection': 'test_vertex'}, data=create_test_docs(3), headers=headers_admin ).json() @@ -213,7 +213,7 @@ def test_save_documents_dupe_errors(self): save_test_docs(3) resp = requests.put( url + '/api/documents', - params={'on_duplicate': 'error', 'collection': 'example_vertices', 'display_errors': '1'}, + params={'on_duplicate': 'error', 'collection': 'test_vertex', 'display_errors': '1'}, data=create_test_docs(3), headers=headers_admin ).json() @@ -225,7 +225,7 @@ def test_save_documents_ignore_dupes(self): """Test ignoring duplicate, existing documents when saving.""" resp = requests.put( url + '/api/documents', - params={'on_duplicate': 'ignore', 'collection': 'example_vertices'}, + params={'on_duplicate': 'ignore', 'collection': 'test_vertex'}, data=create_test_docs(3), headers=headers_admin ).json() @@ -240,7 +240,7 @@ def test_admin_query(self): params={}, headers=headers_admin, data=json.dumps({ - 'query': 'for v in example_vertices sort rand() limit @count return v._id', + 'query': 'for v in test_vertex sort rand() limit @count return v._id', 'count': 1 }) ).json() @@ -254,7 +254,7 @@ def test_admin_query_non_admin(self): params={}, headers=headers_non_admin, data=json.dumps({ - 'query': 'for v in example_vertices sort rand() limit @count return v._id', + 'query': 'for v in test_vertex sort rand() limit @count return v._id', 'count': 1 }) ).json() @@ -267,7 +267,7 @@ def test_admin_query_invalid_auth(self): params={}, headers={'Authorization': invalid_token}, data=json.dumps({ - 'query': 'for v in example_vertices sort rand() limit @count return v._id', + 'query': 'for v in test_vertex sort rand() limit @count return v._id', 'count': 1 }) ).json() @@ -279,7 +279,7 @@ def test_query(self): resp = requests.post( url + '/api/query_results', params={'view': 'list_all_documents_in_collection'}, - data=json.dumps({'@collection': 'example_vertices'}), + data=json.dumps({'@collection': 'test_vertex'}), headers=headers_non_admin ).json() self.assertEqual(len(resp['results']), 3) @@ -294,7 +294,7 @@ def test_query_with_cursor(self): resp = requests.post( url + '/api/query_results', params={'view': 'list_all_documents_in_collection'}, - data=json.dumps({'@collection': 'example_vertices'}), + data=json.dumps({'@collection': 'test_vertex'}), headers=headers_non_admin ).json() cursor_id = resp['cursor_id'] @@ -325,7 +325,7 @@ def test_query_no_name(self): resp = requests.post( url + '/api/query_results', params={'view': 'nonexistent'}, - data=json.dumps({'@collection': 'example_vertices'}), + data=json.dumps({'@collection': 'test_vertex'}), headers=headers_non_admin ).json() self.assertEqual(resp['error'], 'View does not exist.') @@ -336,7 +336,7 @@ def test_query_missing_bind_var(self): resp = requests.post( url + '/api/query_results', params={'view': 'list_all_documents_in_collection'}, - data=json.dumps({'xyz': 'example_vertices'}), + data=json.dumps({'xyz': 'test_vertex'}), headers=headers_non_admin ).json() self.assertEqual(resp['error'], 'ArangoDB server error.') From 0932596653bf485dd29be4d9426a844a29b91476 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Fri, 14 Dec 2018 13:55:46 -0800 Subject: [PATCH 161/732] Update spec release for travis --- api/.travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/.travis.yml b/api/.travis.yml index 0aae96bd..acfd25de 100644 --- a/api/.travis.yml +++ b/api/.travis.yml @@ -3,7 +3,7 @@ services: - docker language: python env: - - SPEC_RELEASE_URL=https://github.com/kbase/relation_engine_spec/archive/v0.0.2.tar.gz + - SPEC_RELEASE_URL=https://github.com/kbase/relation_engine_spec/archive/v0.0.4.tar.gz python: - 3.6 script: From 250d3dec785be453d6fe73421c926d6d2680509f Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Fri, 14 Dec 2018 14:30:41 -0800 Subject: [PATCH 162/732] Avoid downloading spec for travis tests --- api/.travis.yml | 2 -- api/docker-compose.yaml | 1 + api/src/relation_engine_server/api.py | 4 ++-- api/src/relation_engine_server/pull_spec.py | 24 +++++++++++--------- api/src/test/spec_release/spec.tar.gz | Bin 0 -> 6318 bytes 5 files changed, 16 insertions(+), 15 deletions(-) create mode 100644 api/src/test/spec_release/spec.tar.gz diff --git a/api/.travis.yml b/api/.travis.yml index acfd25de..698ae832 100644 --- a/api/.travis.yml +++ b/api/.travis.yml @@ -2,8 +2,6 @@ sudo: required services: - docker language: python -env: - - SPEC_RELEASE_URL=https://github.com/kbase/relation_engine_spec/archive/v0.0.4.tar.gz python: - 3.6 script: diff --git a/api/docker-compose.yaml b/api/docker-compose.yaml index da8a0bec..c087c732 100644 --- a/api/docker-compose.yaml +++ b/api/docker-compose.yaml @@ -17,6 +17,7 @@ services: environment: - KBASE_AUTH_URL=http://auth:5000 - PYTHONUNBUFFERED=true + - SPEC_RELEASE_PATH=/app/src/test/spec_release/spec.tar.gz - DB_URL=http://arangodb:8529 - DB_USER=root - DB_PASS=password diff --git a/api/src/relation_engine_server/api.py b/api/src/relation_engine_server/api.py index 1eb07011..256f30cb 100644 --- a/api/src/relation_engine_server/api.py +++ b/api/src/relation_engine_server/api.py @@ -83,11 +83,11 @@ def refresh_specs(): Auth: admin """ auth.require_auth_token(['RE_ADMIN']) - status = pull_spec.download_latest( + pull_spec.download_latest( reset='reset' in flask.request.args, init_collections='init_collections' in flask.request.args ) - return flask.jsonify({'status': status}) + return flask.jsonify({'status': 'updated'}) @api.route('/documents', methods=['PUT']) diff --git a/api/src/relation_engine_server/pull_spec.py b/api/src/relation_engine_server/pull_spec.py index ea33c2b3..e8e7b5f8 100644 --- a/api/src/relation_engine_server/pull_spec.py +++ b/api/src/relation_engine_server/pull_spec.py @@ -18,17 +18,20 @@ def download_latest(reset=False, init_collections=True): os.makedirs(_spec_dir, exist_ok=True) # Download and extract a new release to /spec/repo spec_repo_path = os.path.join(_spec_dir, 'repo') - if 'SPEC_RELEASE_URL' in os.environ: - tarball_url = os.environ['SPEC_RELEASE_URL'] + if 'SPEC_RELEASE_PATH' in os.environ: + _extract_tarball(os.environ['SPEC_RELEASE_PATH'], _spec_dir) else: - tarball_url = _fetch_github_release_url() - resp = requests.get(tarball_url, stream=True) - with tempfile.NamedTemporaryFile() as temp_file: - # The temp file will be closed/deleted when the context ends - # Download from the tarball url to the temp file - _download_file(resp, temp_file.name) - # Extract the downloaded tarball into the spec path - _extract_tarball(temp_file.name, _spec_dir) + if 'SPEC_RELEASE_URL' in os.environ: + tarball_url = os.environ['SPEC_RELEASE_URL'] + else: + tarball_url = _fetch_github_release_url() + resp = requests.get(tarball_url, stream=True) + with tempfile.NamedTemporaryFile() as temp_file: + # The temp file will be closed/deleted when the context ends + # Download from the tarball url to the temp file + _download_file(resp, temp_file.name) + # Extract the downloaded tarball into the spec path + _extract_tarball(temp_file.name, _spec_dir) # The files will be extracted into a directory like /spec/kbase-relation_engine_spec-xyz # We want to move that to /spec/repo _rename_directories(_spec_dir, spec_repo_path) @@ -36,7 +39,6 @@ def download_latest(reset=False, init_collections=True): if init_collections: schemas = spec_loader.get_schema_names() arango_client.init_collections(schemas) - return 'updated from ' + tarball_url def _fetch_github_release_url(): diff --git a/api/src/test/spec_release/spec.tar.gz b/api/src/test/spec_release/spec.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..6479e337d13606deb02bd384d839262ba27c6f05 GIT binary patch literal 6318 zcmV;f7*XdRiwFP!000001MNNAa@$6-e%4n^X}9Xwi9{3N1-2^Lvx?<7uB;W8<-`w( z4{8VuNmwAjU_eRC)>iE=>@V(@obDL_#FYR+5~O2vB^C(+GmW0<>-6-@>4QG8-4V6* zDWfLy9_=2w0K?%>`~^t=g&+HmlwQBv@AZ0GUxVvPf1s+5CVRjo0}Jj`54!YR*I##E z+3)F>`%GY<62qO%nB#vtQpajnj?SEk%purJZtXb#kn;nmIE}iZ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szM z?qM82VTp3X^1ME)!p`(?K-c(|t#;T8>`MO2g^PS8P$K`k+EB^l|7*Q={l5wLr}Wvv zlw2V{1y>%EQV>n*kp% zAte|-?=#aJJnL(qAfG=Qu`wO=6y>=wQU;3oOlA29SFTT-USNdha1;1w=_e127}JG~ zF~)Arcy<$AOW9DPZ@GO1t4UfjfyB@6Uy!(@*$|NfxIx?Nf5dS8c91grzu(X7|Ipg{ zf6c)0?El^U!c5+A(k1G(k(}FOg5B`{`Xr!I{_kb{f2G@P_y0EmUkd+MPtW#LR6h^|%&;+MzoYbIu{#WyMF zDq|c;y9)=)`uNrz)0IK5uRPPb&wD-fd48yNH7+$`rZ4e9JRw`w?fekE10H5zQ|{yD z0C8qRULZahFAe5HX}Gk_GAV>L^8e0a_q=+Qk77W1xLN%VMeBl2XzPFMA4;lxZ~9MC`&} zjrIxLeCbX21%4p0AIN!hzE13-?*?r`gZ$(K)zcj|`S-uanv9wWOZMRdphMi?q)E8J zllTSSzX++^9F+3EZE;_xVCUBt0j2z}WcL3Kd&;oo{{~>i|6jo%ew9rBeEws==3oW$J!tUY!0Z!war~nuN02MbB@&Et; literal 0 HcmV?d00001 From fc6d8e330b63e2243404d1bf574ae7ad48072221 Mon Sep 17 00:00:00 2001 From: JamesJeffryes Date: Fri, 14 Dec 2018 16:52:22 -0600 Subject: [PATCH 163/732] Add a couple of reaction similarity queries for KE --- .../find_protein_for_similar_reactions.aql | 33 +++++++++++++++++++ ...tein_for_structuraly_similar_reactions.aql | 33 +++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 spec/views/find_protein_for_similar_reactions.aql create mode 100644 spec/views/find_protein_for_structuraly_similar_reactions.aql diff --git a/spec/views/find_protein_for_similar_reactions.aql b/spec/views/find_protein_for_similar_reactions.aql new file mode 100644 index 00000000..a0973b4c --- /dev/null +++ b/spec/views/find_protein_for_similar_reactions.aql @@ -0,0 +1,33 @@ +// Find reactions similar to a query reaction by difference fingerprint and return the proteins +// sequences that encode for genes related to the reaction +// Args: +// rid - reaction id to use as query origin +// df_sim - the minimum similarity of reactions as determined by difference fingerprint + +let similar_rxn_ids = ( +for e in rxn_similar_to_reaction + filter e.df_similarity >= @df_sim + filter e._to == @rid || e._from == @rid + return e._to == @rid ? e._from : e._to +) + +let similar_complex_ids = ( +for e in rxn_reaction_within_complex + filter e._from in similar_rxn_ids + return e._to +) + +let genes = FLATTEN( +for c in rxn_gene_complex + filter c._id IN similar_complex_ids + return c.genes +) + +let sequences = ( +for g in ncbi_gene + filter g._key IN genes + return g.translation +) + +return {sequences: sequences, count: COUNT(sequences)} + diff --git a/spec/views/find_protein_for_structuraly_similar_reactions.aql b/spec/views/find_protein_for_structuraly_similar_reactions.aql new file mode 100644 index 00000000..966ff768 --- /dev/null +++ b/spec/views/find_protein_for_structuraly_similar_reactions.aql @@ -0,0 +1,33 @@ +// Find reactions similar to a query reaction by structure fingerprint and return the proteins +// sequences that encode for genes related to the reaction +// Args: +// rid - reaction id to use as query origin +// sf_sim - the minimum similarity of reactions as determined by structure fingerprint + +let similar_rxn_ids = ( +for e in rxn_similar_to_reaction + filter e.sf_similarity >= @sf_sim + filter e._to == @rid || e._from == @rid + return e._to == @rid ? e._from : e._to +) + +let similar_complex_ids = ( +for e in rxn_reaction_within_complex + filter e._from in similar_rxn_ids + return e._to +) + +let genes = FLATTEN( +for c in rxn_gene_complex + filter c._id IN similar_complex_ids + return c.genes +) + +let sequences = ( +for g in ncbi_gene + filter g._key IN genes + return g.translation +) + +return {sequences: sequences, count: COUNT(sequences)} + From 08ae7186abfb712505e924f6b6b7c740167be64d Mon Sep 17 00:00:00 2001 From: JamesJeffryes Date: Fri, 14 Dec 2018 17:48:56 -0600 Subject: [PATCH 164/732] update rxn KE app queries --- spec/views/find_dna_for_similar_reactions.aql | 33 +++++++++++++++++++ ...na_for_structurally_similar_reactions.aql} | 4 +-- .../find_protein_for_similar_reactions.aql | 4 +-- ...ein_for_structurally_similar_reactions.aql | 33 +++++++++++++++++++ 4 files changed, 70 insertions(+), 4 deletions(-) create mode 100644 spec/views/find_dna_for_similar_reactions.aql rename spec/views/{find_protein_for_structuraly_similar_reactions.aql => find_dna_for_structurally_similar_reactions.aql} (93%) create mode 100644 spec/views/find_protein_for_structurally_similar_reactions.aql diff --git a/spec/views/find_dna_for_similar_reactions.aql b/spec/views/find_dna_for_similar_reactions.aql new file mode 100644 index 00000000..95f2ac33 --- /dev/null +++ b/spec/views/find_dna_for_similar_reactions.aql @@ -0,0 +1,33 @@ +// Find reactions similar to a query reaction by difference fingerprint and return the dna +// sequences that encode for genes related to the reaction +// Args: +// rid - reaction id to use as query origin +// df_sim - the minimum similarity of reactions as determined by difference fingerprint + +let similar_rxn_ids = ( +for e in rxn_similar_to_reaction + filter e.df_similarity >= @df_sim + filter e._to == @rid || e._from == @rid + return e._to == @rid ? e._from : e._to +) + +let similar_complex_ids = ( +for e in rxn_reaction_within_complex + filter e._from in similar_rxn_ids + return e._to +) + +let genes = FLATTEN( +for c in rxn_gene_complex + filter c._id IN similar_complex_ids + return c.genes +) + +let sequences = ( +for g in ncbi_gene + filter g._key IN genes + return g.dna_sequence +) + +return {sequences: sequences, count: COUNT(sequences)} + diff --git a/spec/views/find_protein_for_structuraly_similar_reactions.aql b/spec/views/find_dna_for_structurally_similar_reactions.aql similarity index 93% rename from spec/views/find_protein_for_structuraly_similar_reactions.aql rename to spec/views/find_dna_for_structurally_similar_reactions.aql index 966ff768..78d2296a 100644 --- a/spec/views/find_protein_for_structuraly_similar_reactions.aql +++ b/spec/views/find_dna_for_structurally_similar_reactions.aql @@ -1,4 +1,4 @@ -// Find reactions similar to a query reaction by structure fingerprint and return the proteins +// Find reactions similar to a query reaction by structure fingerprint and return the protein // sequences that encode for genes related to the reaction // Args: // rid - reaction id to use as query origin @@ -26,7 +26,7 @@ for c in rxn_gene_complex let sequences = ( for g in ncbi_gene filter g._key IN genes - return g.translation + return g.dna_sequence ) return {sequences: sequences, count: COUNT(sequences)} diff --git a/spec/views/find_protein_for_similar_reactions.aql b/spec/views/find_protein_for_similar_reactions.aql index a0973b4c..424c14c9 100644 --- a/spec/views/find_protein_for_similar_reactions.aql +++ b/spec/views/find_protein_for_similar_reactions.aql @@ -1,4 +1,4 @@ -// Find reactions similar to a query reaction by difference fingerprint and return the proteins +// Find reactions similar to a query reaction by difference fingerprint and return the protein // sequences that encode for genes related to the reaction // Args: // rid - reaction id to use as query origin @@ -26,7 +26,7 @@ for c in rxn_gene_complex let sequences = ( for g in ncbi_gene filter g._key IN genes - return g.translation + return g.protein_translation ) return {sequences: sequences, count: COUNT(sequences)} diff --git a/spec/views/find_protein_for_structurally_similar_reactions.aql b/spec/views/find_protein_for_structurally_similar_reactions.aql new file mode 100644 index 00000000..78ca943b --- /dev/null +++ b/spec/views/find_protein_for_structurally_similar_reactions.aql @@ -0,0 +1,33 @@ +// Find reactions similar to a query reaction by structure fingerprint and return the dna +// sequences that encode for genes related to the reaction +// Args: +// rid - reaction id to use as query origin +// sf_sim - the minimum similarity of reactions as determined by structure fingerprint + +let similar_rxn_ids = ( +for e in rxn_similar_to_reaction + filter e.sf_similarity >= @sf_sim + filter e._to == @rid || e._from == @rid + return e._to == @rid ? e._from : e._to +) + +let similar_complex_ids = ( +for e in rxn_reaction_within_complex + filter e._from in similar_rxn_ids + return e._to +) + +let genes = FLATTEN( +for c in rxn_gene_complex + filter c._id IN similar_complex_ids + return c.genes +) + +let sequences = ( +for g in ncbi_gene + filter g._key IN genes + return g.protein_translation +) + +return {sequences: sequences, count: COUNT(sequences)} + From ee982e94c2ea0db490620266da1c05227815f15f Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Fri, 14 Dec 2018 16:11:01 -0800 Subject: [PATCH 165/732] Always reset the spec directory when pulling updates --- api/src/relation_engine_server/api.py | 5 +---- api/src/relation_engine_server/pull_spec.py | 9 +++++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/api/src/relation_engine_server/api.py b/api/src/relation_engine_server/api.py index 256f30cb..c46febdb 100644 --- a/api/src/relation_engine_server/api.py +++ b/api/src/relation_engine_server/api.py @@ -83,10 +83,7 @@ def refresh_specs(): Auth: admin """ auth.require_auth_token(['RE_ADMIN']) - pull_spec.download_latest( - reset='reset' in flask.request.args, - init_collections='init_collections' in flask.request.args - ) + pull_spec.download_latest(init_collections='init_collections' in flask.request.args) return flask.jsonify({'status': 'updated'}) diff --git a/api/src/relation_engine_server/pull_spec.py b/api/src/relation_engine_server/pull_spec.py index e8e7b5f8..96f6c611 100644 --- a/api/src/relation_engine_server/pull_spec.py +++ b/api/src/relation_engine_server/pull_spec.py @@ -11,11 +11,12 @@ _release_id_path = os.path.join(_spec_dir, '.release_id') -def download_latest(reset=False, init_collections=True): +def download_latest(init_collections=True): """Check and download the latest spec and extract it to the spec path.""" - if reset and os.path.exists(_spec_dir): - shutil.rmtree(_spec_dir) - os.makedirs(_spec_dir, exist_ok=True) + # Remove the spec directory, ignoring if it is already missing + shutil.rmtree(_spec_dir, ignore_errors=True) + # Recreate the spec directory so we have a clean slate, avoiding name conflicts + os.makedirs(_spec_dir) # Download and extract a new release to /spec/repo spec_repo_path = os.path.join(_spec_dir, 'repo') if 'SPEC_RELEASE_PATH' in os.environ: From 17edee4d28908dc6c3653467cdccf30362348942 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Mon, 17 Dec 2018 10:33:29 -0800 Subject: [PATCH 166/732] Update README.md Fix system admin ad-hoc query curl example. --- api/README.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/api/README.md b/api/README.md index e7137b7b..5d97bf14 100644 --- a/api/README.md +++ b/api/README.md @@ -90,7 +90,7 @@ Run a query using a view or a cursor ID. Semantically, this is a GET, but it's a _Example rquest_ ```sh -$ curl -X POST -d '{"argument": "value"}' http://relation_engine/api/query?view=example +$ curl -X POST -d '{"argument": "value"}' http://relation_engine/api/query_results?view=example ``` _Query params_ @@ -157,9 +157,8 @@ Results are limited to 100 items. To continue fetching additional results, use t System admins can run ad-hoc queries by specifying a "query" property in the JSON request body. ```sh -$ curl -X POST \ - -d '{"query": "for v in coll sort rand() limit @count return v", "count": 1}' \ - http://relation_engine/api/query?view=example +$ curl -d '{"query": "for v in coll sort rand() limit @count return v", "count": 1}' \ + http://relation_engine/api/query_results ``` This will return the same form of results as above. From 3842edca94a43e2ec43cbf64bcbebf5277283ce8 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 18 Dec 2018 13:54:16 -0800 Subject: [PATCH 167/732] Fix edge schema file name --- .../{wsprov_input_in.js => wsprov_input_in.json} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename spec/schemas/edges/provenance_simple/{wsprov_input_in.js => wsprov_input_in.json} (100%) diff --git a/spec/schemas/edges/provenance_simple/wsprov_input_in.js b/spec/schemas/edges/provenance_simple/wsprov_input_in.json similarity index 100% rename from spec/schemas/edges/provenance_simple/wsprov_input_in.js rename to spec/schemas/edges/provenance_simple/wsprov_input_in.json From a5e724c6ff7092f16138caa6d92ce2d9de18606a Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 18 Dec 2018 15:06:04 -0800 Subject: [PATCH 168/732] Enable cross-origin requests --- api/src/relation_engine_server/server.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/api/src/relation_engine_server/server.py b/api/src/relation_engine_server/server.py index 52cb083a..98fda126 100644 --- a/api/src/relation_engine_server/server.py +++ b/api/src/relation_engine_server/server.py @@ -77,4 +77,12 @@ def server_error(err): def log_response(response): """Simple log of each request's response.""" print(' '.join([flask.request.method, flask.request.path, '->', response.status])) + # Enable CORS + # Content type and length + response.headers['Access-Control-Allow-Origin'] = '*' + env_allowed_headers = os.environ.get('HTTP_ACCESS_CONTROL_REQUEST_HEADERS', 'authorization') + response.headers['Access-Control-Allow-Headers'] = env_allowed_headers + # Set JSON content type and responseonse length + response.headers['Content-Type'] = 'application/json' + response.headers['Content-Length'] = response.calculate_content_length() return response From 4a2535a8d6f8fbbc82ce62ded4f6edf33c59346c Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 18 Dec 2018 15:06:54 -0800 Subject: [PATCH 169/732] Fix function name --- api/src/relation_engine_server/server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/src/relation_engine_server/server.py b/api/src/relation_engine_server/server.py index 98fda126..cbf6522f 100644 --- a/api/src/relation_engine_server/server.py +++ b/api/src/relation_engine_server/server.py @@ -74,7 +74,7 @@ def server_error(err): @app.after_request -def log_response(response): +def after_request(response): """Simple log of each request's response.""" print(' '.join([flask.request.method, flask.request.path, '->', response.status])) # Enable CORS From 6c71623b0a60ac3b084cb3a6f1f3e47ad7e25c70 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 18 Dec 2018 15:07:27 -0800 Subject: [PATCH 170/732] Fix comment type --- api/src/relation_engine_server/server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/src/relation_engine_server/server.py b/api/src/relation_engine_server/server.py index cbf6522f..4dd50a31 100644 --- a/api/src/relation_engine_server/server.py +++ b/api/src/relation_engine_server/server.py @@ -82,7 +82,7 @@ def after_request(response): response.headers['Access-Control-Allow-Origin'] = '*' env_allowed_headers = os.environ.get('HTTP_ACCESS_CONTROL_REQUEST_HEADERS', 'authorization') response.headers['Access-Control-Allow-Headers'] = env_allowed_headers - # Set JSON content type and responseonse length + # Set JSON content type and response length response.headers['Content-Type'] = 'application/json' response.headers['Content-Length'] = response.calculate_content_length() return response From 323426b00e12a9ebb88fada16bb20e084c739041 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 18 Dec 2018 15:24:16 -0800 Subject: [PATCH 171/732] Fix some comments --- api/src/relation_engine_server/server.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/api/src/relation_engine_server/server.py b/api/src/relation_engine_server/server.py index 4dd50a31..f89bd48b 100644 --- a/api/src/relation_engine_server/server.py +++ b/api/src/relation_engine_server/server.py @@ -75,10 +75,9 @@ def server_error(err): @app.after_request def after_request(response): - """Simple log of each request's response.""" + """Actions to perform on the response after the request handler finishes running.""" print(' '.join([flask.request.method, flask.request.path, '->', response.status])) # Enable CORS - # Content type and length response.headers['Access-Control-Allow-Origin'] = '*' env_allowed_headers = os.environ.get('HTTP_ACCESS_CONTROL_REQUEST_HEADERS', 'authorization') response.headers['Access-Control-Allow-Headers'] = env_allowed_headers From b3e589f51ae2dc33aea24991b8ea07e36e1ef355 Mon Sep 17 00:00:00 2001 From: JamesJeffryes Date: Wed, 19 Dec 2018 13:40:35 -0600 Subject: [PATCH 172/732] consolidate rxn queries --- spec/views/find_dna_for_similar_reactions.aql | 33 ------------------ ...dna_for_structurally_similar_reactions.aql | 33 ------------------ .../find_protein_for_similar_reactions.aql | 33 ------------------ ...ein_for_structurally_similar_reactions.aql | 33 ------------------ .../list_genes_for_similar_reactions.aql | 34 +++++++++++++++++++ 5 files changed, 34 insertions(+), 132 deletions(-) delete mode 100644 spec/views/find_dna_for_similar_reactions.aql delete mode 100644 spec/views/find_dna_for_structurally_similar_reactions.aql delete mode 100644 spec/views/find_protein_for_similar_reactions.aql delete mode 100644 spec/views/find_protein_for_structurally_similar_reactions.aql create mode 100644 spec/views/list_genes_for_similar_reactions.aql diff --git a/spec/views/find_dna_for_similar_reactions.aql b/spec/views/find_dna_for_similar_reactions.aql deleted file mode 100644 index 95f2ac33..00000000 --- a/spec/views/find_dna_for_similar_reactions.aql +++ /dev/null @@ -1,33 +0,0 @@ -// Find reactions similar to a query reaction by difference fingerprint and return the dna -// sequences that encode for genes related to the reaction -// Args: -// rid - reaction id to use as query origin -// df_sim - the minimum similarity of reactions as determined by difference fingerprint - -let similar_rxn_ids = ( -for e in rxn_similar_to_reaction - filter e.df_similarity >= @df_sim - filter e._to == @rid || e._from == @rid - return e._to == @rid ? e._from : e._to -) - -let similar_complex_ids = ( -for e in rxn_reaction_within_complex - filter e._from in similar_rxn_ids - return e._to -) - -let genes = FLATTEN( -for c in rxn_gene_complex - filter c._id IN similar_complex_ids - return c.genes -) - -let sequences = ( -for g in ncbi_gene - filter g._key IN genes - return g.dna_sequence -) - -return {sequences: sequences, count: COUNT(sequences)} - diff --git a/spec/views/find_dna_for_structurally_similar_reactions.aql b/spec/views/find_dna_for_structurally_similar_reactions.aql deleted file mode 100644 index 78d2296a..00000000 --- a/spec/views/find_dna_for_structurally_similar_reactions.aql +++ /dev/null @@ -1,33 +0,0 @@ -// Find reactions similar to a query reaction by structure fingerprint and return the protein -// sequences that encode for genes related to the reaction -// Args: -// rid - reaction id to use as query origin -// sf_sim - the minimum similarity of reactions as determined by structure fingerprint - -let similar_rxn_ids = ( -for e in rxn_similar_to_reaction - filter e.sf_similarity >= @sf_sim - filter e._to == @rid || e._from == @rid - return e._to == @rid ? e._from : e._to -) - -let similar_complex_ids = ( -for e in rxn_reaction_within_complex - filter e._from in similar_rxn_ids - return e._to -) - -let genes = FLATTEN( -for c in rxn_gene_complex - filter c._id IN similar_complex_ids - return c.genes -) - -let sequences = ( -for g in ncbi_gene - filter g._key IN genes - return g.dna_sequence -) - -return {sequences: sequences, count: COUNT(sequences)} - diff --git a/spec/views/find_protein_for_similar_reactions.aql b/spec/views/find_protein_for_similar_reactions.aql deleted file mode 100644 index 424c14c9..00000000 --- a/spec/views/find_protein_for_similar_reactions.aql +++ /dev/null @@ -1,33 +0,0 @@ -// Find reactions similar to a query reaction by difference fingerprint and return the protein -// sequences that encode for genes related to the reaction -// Args: -// rid - reaction id to use as query origin -// df_sim - the minimum similarity of reactions as determined by difference fingerprint - -let similar_rxn_ids = ( -for e in rxn_similar_to_reaction - filter e.df_similarity >= @df_sim - filter e._to == @rid || e._from == @rid - return e._to == @rid ? e._from : e._to -) - -let similar_complex_ids = ( -for e in rxn_reaction_within_complex - filter e._from in similar_rxn_ids - return e._to -) - -let genes = FLATTEN( -for c in rxn_gene_complex - filter c._id IN similar_complex_ids - return c.genes -) - -let sequences = ( -for g in ncbi_gene - filter g._key IN genes - return g.protein_translation -) - -return {sequences: sequences, count: COUNT(sequences)} - diff --git a/spec/views/find_protein_for_structurally_similar_reactions.aql b/spec/views/find_protein_for_structurally_similar_reactions.aql deleted file mode 100644 index 78ca943b..00000000 --- a/spec/views/find_protein_for_structurally_similar_reactions.aql +++ /dev/null @@ -1,33 +0,0 @@ -// Find reactions similar to a query reaction by structure fingerprint and return the dna -// sequences that encode for genes related to the reaction -// Args: -// rid - reaction id to use as query origin -// sf_sim - the minimum similarity of reactions as determined by structure fingerprint - -let similar_rxn_ids = ( -for e in rxn_similar_to_reaction - filter e.sf_similarity >= @sf_sim - filter e._to == @rid || e._from == @rid - return e._to == @rid ? e._from : e._to -) - -let similar_complex_ids = ( -for e in rxn_reaction_within_complex - filter e._from in similar_rxn_ids - return e._to -) - -let genes = FLATTEN( -for c in rxn_gene_complex - filter c._id IN similar_complex_ids - return c.genes -) - -let sequences = ( -for g in ncbi_gene - filter g._key IN genes - return g.protein_translation -) - -return {sequences: sequences, count: COUNT(sequences)} - diff --git a/spec/views/list_genes_for_similar_reactions.aql b/spec/views/list_genes_for_similar_reactions.aql new file mode 100644 index 00000000..6e35f65b --- /dev/null +++ b/spec/views/list_genes_for_similar_reactions.aql @@ -0,0 +1,34 @@ +// Return genes associated with reactions similar to a query reaction +// Args: +// rid - reaction id +// sf_sim - minimum structural fingerprint similarity score +// df_sim - minimum difference fingerprint similarity score +// exclude_self - if true, don't include the query reactions genes + +let similar_rxn_ids = ( +for e in rxn_similar_to_reaction + filter e.sf_similarity >= @sf_sim + filter e.df_similarity >= @df_sim + filter e._to == @rid || e._from == @rid + return e._to == @rid ? e._from : e._to +) +let self = @exclude_self ? "no_self" : @rid +let similar_complex_ids = ( +for e in rxn_reaction_within_complex + filter e._from in similar_rxn_ids || e._from == self + return e._to +) + +let genes = FLATTEN( +for c in rxn_gene_complex + filter c._id IN similar_complex_ids + return c.genes +) + +let sequences = ( +for g in ncbi_gene + filter g._key IN genes + return {key: g._key, seq: g.protein_translation} +) + +return {count: COUNT(sequences), sequences: sequences} \ No newline at end of file From 5243a31c19f9a14a3b413ca3f5928ff35a9bcb1f Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Thu, 20 Dec 2018 09:58:46 -0800 Subject: [PATCH 173/732] Add some generic edges for the simple provenance namespace --- .../provenance_simple/wsprov_copied_into.json | 17 +++++++++++++++++ .../edges/provenance_simple/wsprov_links.json | 17 +++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 spec/schemas/edges/provenance_simple/wsprov_copied_into.json create mode 100644 spec/schemas/edges/provenance_simple/wsprov_links.json diff --git a/spec/schemas/edges/provenance_simple/wsprov_copied_into.json b/spec/schemas/edges/provenance_simple/wsprov_copied_into.json new file mode 100644 index 00000000..908000bd --- /dev/null +++ b/spec/schemas/edges/provenance_simple/wsprov_copied_into.json @@ -0,0 +1,17 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "required": ["_from", "_to"], + "description": "The object was copied into another object", + "properties": { + "_from": { + "type": "string", + "examples": ["wsprov_object/1:2:3"] + }, + "_to": { + "type": "string", + "examples": ["wsprov_object/1:2:3"] + } + } +} + diff --git a/spec/schemas/edges/provenance_simple/wsprov_links.json b/spec/schemas/edges/provenance_simple/wsprov_links.json new file mode 100644 index 00000000..4f8e807c --- /dev/null +++ b/spec/schemas/edges/provenance_simple/wsprov_links.json @@ -0,0 +1,17 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "required": ["_from", "_to"], + "description": "The object is linked to another object, through references, provenance, etc", + "properties": { + "_from": { + "type": "string", + "examples": ["wsprov_object/1:2:3"] + }, + "_to": { + "type": "string", + "examples": ["wsprov_object/1:2:3"] + } + } +} + From 9bc926c1f6df222a4cd7135b388e631db436197b Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Mon, 7 Jan 2019 15:59:06 -0800 Subject: [PATCH 174/732] Unload and reload the collection before import to (maybe) prevent cluster errors --- api/src/relation_engine_server/arango_client.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/api/src/relation_engine_server/arango_client.py b/api/src/relation_engine_server/arango_client.py index e03cb01e..dda6994d 100644 --- a/api/src/relation_engine_server/arango_client.py +++ b/api/src/relation_engine_server/arango_client.py @@ -94,6 +94,10 @@ def create_collection(name, is_edge): def import_from_file(file_path, query): """Make a generic arango post request.""" + # Unloading and then reloading the collection before import seems to + # prevent the error "cluster internal HTTP connection broken", at least + # with arango 3.3 and MMFiles + _reload_collections(query['collection']) with open(file_path, 'rb') as file_desc: resp = requests.post( db_url + '/_api/import', @@ -106,6 +110,15 @@ def import_from_file(file_path, query): return resp.text +def _reload_collections(collection): + """ + Unload and then reload a collection. + Docs: https://docs.arangodb.com/3.4/HTTP/Collection/Modifying.html + """ + requests.put(db_url + '/_api/collection/' + collection + '/unload') + requests.put(db_url + '/_api/collection/' + collection + '/load') + + class ArangoServerError(Exception): """A request to the ArangoDB server has failed (non-2xx).""" From 88b2844c4465ec688c84a80023e1781dc5733919 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Mon, 7 Jan 2019 16:13:14 -0800 Subject: [PATCH 175/732] Delete unused/insecure views. Can use super-admin ad-hoc queries instead. --- spec/views/count_documents_in_collection.aql | 8 -------- spec/views/list_all_documents_in_collection.aql | 6 ------ 2 files changed, 14 deletions(-) delete mode 100644 spec/views/count_documents_in_collection.aql delete mode 100644 spec/views/list_all_documents_in_collection.aql diff --git a/spec/views/count_documents_in_collection.aql b/spec/views/count_documents_in_collection.aql deleted file mode 100644 index 5d86c46e..00000000 --- a/spec/views/count_documents_in_collection.aql +++ /dev/null @@ -1,8 +0,0 @@ -// Return count of documents in a collection -// Args: -// collection - name of collection to count docs - -for v in @@collection - collect with count into length - return length - diff --git a/spec/views/list_all_documents_in_collection.aql b/spec/views/list_all_documents_in_collection.aql deleted file mode 100644 index bc0969a3..00000000 --- a/spec/views/list_all_documents_in_collection.aql +++ /dev/null @@ -1,6 +0,0 @@ -// Return *all* full documents in a collection -// Args: -// collection - name of collection to count docs - -for v in @@collection - return v From fc5ec4704af7c1dd35f54893f58eab30e73fc5f3 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Mon, 7 Jan 2019 16:37:45 -0800 Subject: [PATCH 176/732] Add the views from the ad-hoc js queries --- spec/views/wsprov_fetch_copies.aql | 24 +++++++++++++++++++ spec/views/wsprov_fetch_linked_objects.aql | 24 +++++++++++++++++++ .../wsprov_fetch_multiple_linked_objects.aql | 19 +++++++++++++++ spec/views/wsprov_fetch_object.aql | 7 ++++++ 4 files changed, 74 insertions(+) create mode 100644 spec/views/wsprov_fetch_copies.aql create mode 100644 spec/views/wsprov_fetch_linked_objects.aql create mode 100644 spec/views/wsprov_fetch_multiple_linked_objects.aql create mode 100644 spec/views/wsprov_fetch_object.aql diff --git a/spec/views/wsprov_fetch_copies.aql b/spec/views/wsprov_fetch_copies.aql new file mode 100644 index 00000000..de91f918 --- /dev/null +++ b/spec/views/wsprov_fetch_copies.aql @@ -0,0 +1,24 @@ +// For a given object, fetch all the objects that it has been copied from or +// to, no matter how many nested times (copies of copies of copies, forward or backward) +// Also returns all linked objects of those copies of any nested level. +// Each sublink result has a 'parent_id' point to the copy that it is linked from. +// Args: +// obj_key - key of the object (eg "1:2:3") +// copy_limit - limit the amount of copy results +// sublink_limit - limit the amount of sublink object results + +let obj_id = CONCAT("wsprov_object/", @obj_key) +let copies = ( + for obj in 1..100 any obj_id wsprov_copied_into + filter obj + return obj +) +let sublinks = ( + for obj in wsprov_object + filter obj in copies + for obj1 in 1..100 any obj wsprov_links + filter obj1 + limit @sublink_limit + return distinct {parent_id: obj._id, obj: obj1} +) +return {copies: copies, sublinks: sublinks} diff --git a/spec/views/wsprov_fetch_linked_objects.aql b/spec/views/wsprov_fetch_linked_objects.aql new file mode 100644 index 00000000..bc8e14e9 --- /dev/null +++ b/spec/views/wsprov_fetch_linked_objects.aql @@ -0,0 +1,24 @@ +// Find all linked objects to a given object +// Returns links of level 1, plus all child links of any nested level ("sublinks") +// Each sublink has a "parent_id" key that points to its parent object +// Args: +// key - wsprov_object key to find links for +// link_limit - how many 1st-level links to return +// sublink_limit - how many child links to return for each link + +let obj_id = CONCAT("wsprov_object/", @key) +let links = ( + for obj in 1..1 any obj_id wsprov_links + filter obj + limit @link_limit + return obj +) +let sublinks = ( + for obj in wsprov_object + filter obj in links + for obj1 in 1..100 any obj wsprov_links + filter obj1 + limit @sublink_limit + return distinct {parent_id: obj._id, obj: obj1} +) +return {links: links, sublinks: sublinks} diff --git a/spec/views/wsprov_fetch_multiple_linked_objects.aql b/spec/views/wsprov_fetch_multiple_linked_objects.aql new file mode 100644 index 00000000..df6ea6eb --- /dev/null +++ b/spec/views/wsprov_fetch_multiple_linked_objects.aql @@ -0,0 +1,19 @@ +// For a set of wsprov_objects, fetch 1st-level linked objects for +// each. This is used, for example, in fetching all linked objects for homology +// results. This does not fetch sub-links (past 1st level nesting). +// The returned objects will each have an 'obj' key (the actual document), as +// well as a 'parent_id' key, which is the ID of the object to which it is +// linked. +// Args: +// obj_ids - array of object ids to fetch linked objects for +// link_limit - limit number of links to return for each parent object + +let links = ( + for obj in wsprov_object + filter obj._id in @obj_ids + for obj1 in 1..100 any obj wsprov_links + filter obj1 + limit @link_limit + return distinct {obj: obj1, parent_id: obj._id} +) +return {links: links} diff --git a/spec/views/wsprov_fetch_object.aql b/spec/views/wsprov_fetch_object.aql new file mode 100644 index 00000000..8507b80f --- /dev/null +++ b/spec/views/wsprov_fetch_object.aql @@ -0,0 +1,7 @@ +// Fetch a wsprov_object +// Args: +// key - key of the object to fetch + +for o in wsprov_object + filter o._key == @key + return o From 4429cdcfedda69cc6a454a3ee35238bcfaf23e38 Mon Sep 17 00:00:00 2001 From: James Jeffryes Date: Tue, 8 Jan 2019 16:59:00 -0600 Subject: [PATCH 177/732] Update ncbi_gene.json --- .../vertices/ncbi_genomes/ncbi_gene.json | 34 ++++++++----------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/spec/schemas/vertices/ncbi_genomes/ncbi_gene.json b/spec/schemas/vertices/ncbi_genomes/ncbi_gene.json index 5790256e..751a6eae 100644 --- a/spec/schemas/vertices/ncbi_genomes/ncbi_gene.json +++ b/spec/schemas/vertices/ncbi_genomes/ncbi_gene.json @@ -23,10 +23,10 @@ "type": "integer", "description": "Length of protein_translation" }, - "protein_hash": { + "md5_hash": { "type": "string", - "title": "Protein content hash", - "description": "Hash of the protein sequence that this feature encodes." + "title": "DNA content hash", + "description": "md5 hash of the dna sequence that this feature encodes." }, "note": { "type": "string", @@ -88,30 +88,24 @@ "description": "Total character/nucleotide length of dna_sequence" }, "db_xrefs": { - "type": "array", "title": "Database cross-references", "description": "IDs for these feature in other databases, grouped by database", - "items": { - "type": "object", - "patternProperties": { - ".*": { - "type": "array", - "items": {"type": "string"} - } + "type": "object", + "patternProperties": { + ".*": { + "type": "array", + "items": {"type": "string"} } } }, "aliases": { - "type": "array", "description": "Aliases for these feature, grouped by alias type", - "items": { - "type": "object", - "description": "All values are arrays of strings", - "patternProperties": { - ".*": { - "type": "array", - "items": {"type": "string"} - } + "type": "object", + "description": "All values are arrays of strings", + "patternProperties": { + ".*": { + "type": "array", + "items": {"type": "string"} } } } From 23e2397b8dbf5067f64e0d8533b925cd8dbefa23 Mon Sep 17 00:00:00 2001 From: James Jeffryes Date: Wed, 9 Jan 2019 14:07:57 -0600 Subject: [PATCH 178/732] Update rxn_gene_complex.json --- .../reaction_homology/rxn_gene_complex.json | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/spec/schemas/vertices/reaction_homology/rxn_gene_complex.json b/spec/schemas/vertices/reaction_homology/rxn_gene_complex.json index 9e41b04f..50907d2a 100644 --- a/spec/schemas/vertices/reaction_homology/rxn_gene_complex.json +++ b/spec/schemas/vertices/reaction_homology/rxn_gene_complex.json @@ -3,20 +3,25 @@ "type": "object", "additionalProperties": false, "description": "Groups of genes that take part in producing a chemical reaction in the cell.", - "required": ["_key", "conjunctions"], + "required": ["_key", "genes"], "properties": { "_key": { "type": "string", "description": "Hash of the conjunctions." }, - "conjunctions": { + "genes": { "type": "array", "examples": [["SO_0001", "SO_0001"]], - "description": "Array of conjunctions of genes. Eg: (A AND B AND C AND D).", + "description": "Array of genes.", "items": { "type": "string", "description": "Gene vertex _key" } + }, + "source": { + "type": "array", + "examples": ["ModelSeed", "KEGG"], + "description": "The source of the gene complex information." } - } + } } From df01a1aa84416109ff37a28008471e1a0106c5b7 Mon Sep 17 00:00:00 2001 From: James Jeffryes Date: Wed, 9 Jan 2019 14:13:20 -0600 Subject: [PATCH 179/732] correct caps for ModelSEED --- spec/schemas/vertices/reaction_homology/rxn_gene_complex.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/schemas/vertices/reaction_homology/rxn_gene_complex.json b/spec/schemas/vertices/reaction_homology/rxn_gene_complex.json index 50907d2a..639ec17d 100644 --- a/spec/schemas/vertices/reaction_homology/rxn_gene_complex.json +++ b/spec/schemas/vertices/reaction_homology/rxn_gene_complex.json @@ -20,7 +20,7 @@ }, "source": { "type": "array", - "examples": ["ModelSeed", "KEGG"], + "examples": ["ModelSEED", "KEGG"], "description": "The source of the gene complex information." } } From 960fe00563db77bb518fbe9e51f52ce49b2906fc Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 9 Jan 2019 15:57:22 -0800 Subject: [PATCH 180/732] Allow view-based queries to be requested without any auth --- api/src/relation_engine_server/api.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/api/src/relation_engine_server/api.py b/api/src/relation_engine_server/api.py index c46febdb..91fafa85 100644 --- a/api/src/relation_engine_server/api.py +++ b/api/src/relation_engine_server/api.py @@ -21,7 +21,8 @@ def show_views(): def run_query(): """ Run a stored view as a query against the database. - Auth: only kbase users (any role) + Auth: only kbase re admins for ad-hoc queries + Public for views (views will have access controls within them based on params) """ # Note that flask.request.json only works if the request Content-Type is application/json json_body = json.loads(flask.request.get_data() or '{}') @@ -32,7 +33,7 @@ def run_query(): del json_body['query'] resp_body = arango_client.run_query(query_text=query_text, bind_vars=json_body) return flask.jsonify(resp_body) - auth.require_auth_token(roles=[]) + # auth.require_auth_token(roles=[]) if 'view' in flask.request.args: # Run a query from a view name view_name = flask.request.args['view'] From 1a572d5c5d33e990c4208284cd395a5e1b10f3bd Mon Sep 17 00:00:00 2001 From: James Jeffryes Date: Thu, 10 Jan 2019 09:48:14 -0600 Subject: [PATCH 181/732] Add "Unknown" as valid domain --- spec/schemas/vertices/ncbi_genomes/ncbi_genome.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/schemas/vertices/ncbi_genomes/ncbi_genome.json b/spec/schemas/vertices/ncbi_genomes/ncbi_genome.json index 8cfe26cb..61f9ec73 100644 --- a/spec/schemas/vertices/ncbi_genomes/ncbi_genome.json +++ b/spec/schemas/vertices/ncbi_genomes/ncbi_genome.json @@ -24,7 +24,7 @@ }, "domain": { "type": "string", - "enum": ["Archaea", "Bacteria", "Eukarya"] + "enum": ["Archaea", "Bacteria", "Eukarya", "Unknown"] }, "feature_counts": { "type": "object", From 55a6b8c8e2667435bc256544828b00b65f36f96d Mon Sep 17 00:00:00 2001 From: JamesJeffryes Date: Thu, 10 Jan 2019 12:40:11 -0600 Subject: [PATCH 182/732] Add DB_NAME environmental variable --- api/src/relation_engine_server/arango_client.py | 1 + 1 file changed, 1 insertion(+) diff --git a/api/src/relation_engine_server/arango_client.py b/api/src/relation_engine_server/arango_client.py index dda6994d..523ef9cc 100644 --- a/api/src/relation_engine_server/arango_client.py +++ b/api/src/relation_engine_server/arango_client.py @@ -6,6 +6,7 @@ import os db_url = os.environ.get('DB_URL', 'http://localhost:8529') +db_url += '/_db/' + os.environ.get('DB_NAME', '_system') db_user = os.environ.get('DB_USER', 'root') db_pass = os.environ.get('DB_PASS', 'password') From a7c7fd9392057cd16fdb59f68eaa4a97bfc6af9d Mon Sep 17 00:00:00 2001 From: JamesJeffryes Date: Thu, 10 Jan 2019 12:40:35 -0600 Subject: [PATCH 183/732] Revert "Unload and reload the collection before import to (maybe) prevent cluster errors" This reverts commit 9bc926c --- api/src/relation_engine_server/arango_client.py | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/api/src/relation_engine_server/arango_client.py b/api/src/relation_engine_server/arango_client.py index 523ef9cc..ae8ea8e3 100644 --- a/api/src/relation_engine_server/arango_client.py +++ b/api/src/relation_engine_server/arango_client.py @@ -95,10 +95,6 @@ def create_collection(name, is_edge): def import_from_file(file_path, query): """Make a generic arango post request.""" - # Unloading and then reloading the collection before import seems to - # prevent the error "cluster internal HTTP connection broken", at least - # with arango 3.3 and MMFiles - _reload_collections(query['collection']) with open(file_path, 'rb') as file_desc: resp = requests.post( db_url + '/_api/import', @@ -111,15 +107,6 @@ def import_from_file(file_path, query): return resp.text -def _reload_collections(collection): - """ - Unload and then reload a collection. - Docs: https://docs.arangodb.com/3.4/HTTP/Collection/Modifying.html - """ - requests.put(db_url + '/_api/collection/' + collection + '/unload') - requests.put(db_url + '/_api/collection/' + collection + '/load') - - class ArangoServerError(Exception): """A request to the ArangoDB server has failed (non-2xx).""" From 8bc94ae1ab2763b381641bcd870e41611e9b336b Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Fri, 11 Jan 2019 16:24:47 -0800 Subject: [PATCH 184/732] Refactor wsprov views --- spec/views/wsprov_fetch_copies.aql | 27 +++++++---------- spec/views/wsprov_fetch_linked_objects.aql | 29 +++++++------------ .../wsprov_fetch_multiple_linked_objects.aql | 19 ------------ spec/views/wsprov_fetch_object.aql | 2 ++ 4 files changed, 23 insertions(+), 54 deletions(-) delete mode 100644 spec/views/wsprov_fetch_multiple_linked_objects.aql diff --git a/spec/views/wsprov_fetch_copies.aql b/spec/views/wsprov_fetch_copies.aql index de91f918..b2a27f19 100644 --- a/spec/views/wsprov_fetch_copies.aql +++ b/spec/views/wsprov_fetch_copies.aql @@ -3,22 +3,15 @@ // Also returns all linked objects of those copies of any nested level. // Each sublink result has a 'parent_id' point to the copy that it is linked from. // Args: +// ws_ids - array of private workspace ids the user has access to // obj_key - key of the object (eg "1:2:3") -// copy_limit - limit the amount of copy results -// sublink_limit - limit the amount of sublink object results +// copy_limit - max results of copies (recommended 10-20) -let obj_id = CONCAT("wsprov_object/", @obj_key) -let copies = ( - for obj in 1..100 any obj_id wsprov_copied_into - filter obj - return obj -) -let sublinks = ( - for obj in wsprov_object - filter obj in copies - for obj1 in 1..100 any obj wsprov_links - filter obj1 - limit @sublink_limit - return distinct {parent_id: obj._id, obj: obj1} -) -return {copies: copies, sublinks: sublinks} +for o in wsprov_object + filter o._key == @obj_key + filter o.is_public || (o.workspace_id IN @ws_ids) + for copy in 1..100 any o wsprov_copied_into + filter copy // no nulls + limit @copy_limit + collect parent_id = o._id into groups = copy + return distinct { copies: groups, parent_id } diff --git a/spec/views/wsprov_fetch_linked_objects.aql b/spec/views/wsprov_fetch_linked_objects.aql index bc8e14e9..6110ca7f 100644 --- a/spec/views/wsprov_fetch_linked_objects.aql +++ b/spec/views/wsprov_fetch_linked_objects.aql @@ -2,23 +2,16 @@ // Returns links of level 1, plus all child links of any nested level ("sublinks") // Each sublink has a "parent_id" key that points to its parent object // Args: -// key - wsprov_object key to find links for -// link_limit - how many 1st-level links to return -// sublink_limit - how many child links to return for each link +// ws_ids - array of private workspace ids the user has access to +// obj_keys - wsprov_object key to find links for +// link_limit - number of link results (10-20 recommended) +// sublink_limit - number of sublink results (10-20 recommended) -let obj_id = CONCAT("wsprov_object/", @key) -let links = ( - for obj in 1..1 any obj_id wsprov_links - filter obj +for o in wsprov_object + filter o._key IN @obj_keys + filter o.is_public || (o.workspace_id IN @ws_ids) + for link in 1..100 any o wsprov_links limit @link_limit - return obj -) -let sublinks = ( - for obj in wsprov_object - filter obj in links - for obj1 in 1..100 any obj wsprov_links - filter obj1 - limit @sublink_limit - return distinct {parent_id: obj._id, obj: obj1} -) -return {links: links, sublinks: sublinks} + filter link // no nulls + collect parent_id = o._id into groups = link + return distinct { links: groups, parent_id } diff --git a/spec/views/wsprov_fetch_multiple_linked_objects.aql b/spec/views/wsprov_fetch_multiple_linked_objects.aql deleted file mode 100644 index df6ea6eb..00000000 --- a/spec/views/wsprov_fetch_multiple_linked_objects.aql +++ /dev/null @@ -1,19 +0,0 @@ -// For a set of wsprov_objects, fetch 1st-level linked objects for -// each. This is used, for example, in fetching all linked objects for homology -// results. This does not fetch sub-links (past 1st level nesting). -// The returned objects will each have an 'obj' key (the actual document), as -// well as a 'parent_id' key, which is the ID of the object to which it is -// linked. -// Args: -// obj_ids - array of object ids to fetch linked objects for -// link_limit - limit number of links to return for each parent object - -let links = ( - for obj in wsprov_object - filter obj._id in @obj_ids - for obj1 in 1..100 any obj wsprov_links - filter obj1 - limit @link_limit - return distinct {obj: obj1, parent_id: obj._id} -) -return {links: links} diff --git a/spec/views/wsprov_fetch_object.aql b/spec/views/wsprov_fetch_object.aql index 8507b80f..b56779e2 100644 --- a/spec/views/wsprov_fetch_object.aql +++ b/spec/views/wsprov_fetch_object.aql @@ -1,7 +1,9 @@ // Fetch a wsprov_object // Args: +// ws_ids - array of private workspace ids the user has access to // key - key of the object to fetch for o in wsprov_object filter o._key == @key + filter o.is_public || (o.workspace_id IN @ws_ids) return o From 17537dc0e5982c92514caa20dc5650d438d5ab04 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Mon, 14 Jan 2019 10:28:54 -0800 Subject: [PATCH 185/732] Add list_test_vertices view --- spec/views/list_test_vertices.aql | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 spec/views/list_test_vertices.aql diff --git a/spec/views/list_test_vertices.aql b/spec/views/list_test_vertices.aql new file mode 100644 index 00000000..ba7c7456 --- /dev/null +++ b/spec/views/list_test_vertices.aql @@ -0,0 +1,8 @@ +// Test query -- lists all test vertices +// Args: +// ws_ids - list of workspace ids the user has access to +// (this is a special param set by the relation engine API) + +for o in test_vertex + filter o.ws_id IN @ws_ids + return o From 8bcaeddb7e3e817f74ef8659fbbcd734daa919ae Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Mon, 14 Jan 2019 10:29:35 -0800 Subject: [PATCH 186/732] Add is_public and ws_id to the test_vertex --- spec/schemas/vertices/test_vertex.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spec/schemas/vertices/test_vertex.json b/spec/schemas/vertices/test_vertex.json index 508751e9..d43d35a7 100644 --- a/spec/schemas/vertices/test_vertex.json +++ b/spec/schemas/vertices/test_vertex.json @@ -4,7 +4,9 @@ "required": ["_key"], "description": "An example vertex schema for testing", "properties": { - "_key": {"type": "string"} + "_key": {"type": "string"}, + "is_public": {"type": "boolean"}, + "ws_id": {"type": "integer"} } } From fe09a068e5d0de4f0ffdbc860941e198b7a529e2 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Mon, 14 Jan 2019 10:33:02 -0800 Subject: [PATCH 187/732] Add is_public to test view --- spec/views/list_test_vertices.aql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/views/list_test_vertices.aql b/spec/views/list_test_vertices.aql index ba7c7456..73439d01 100644 --- a/spec/views/list_test_vertices.aql +++ b/spec/views/list_test_vertices.aql @@ -4,5 +4,5 @@ // (this is a special param set by the relation engine API) for o in test_vertex - filter o.ws_id IN @ws_ids + filter o.is_public || o.ws_id IN @ws_ids return o From 6c5e7f3583fd324e81379a10a6f7386dcb275df0 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Mon, 14 Jan 2019 15:47:13 -0800 Subject: [PATCH 188/732] add ws_ids in a let statement so they are accepted as params --- spec/views/list_genes_for_similar_reactions.aql | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spec/views/list_genes_for_similar_reactions.aql b/spec/views/list_genes_for_similar_reactions.aql index 6e35f65b..8ae646c2 100644 --- a/spec/views/list_genes_for_similar_reactions.aql +++ b/spec/views/list_genes_for_similar_reactions.aql @@ -5,6 +5,8 @@ // df_sim - minimum difference fingerprint similarity score // exclude_self - if true, don't include the query reactions genes +let @ws_ids = ws_ids + let similar_rxn_ids = ( for e in rxn_similar_to_reaction filter e.sf_similarity >= @sf_sim @@ -31,4 +33,4 @@ for g in ncbi_gene return {key: g._key, seq: g.protein_translation} ) -return {count: COUNT(sequences), sequences: sequences} \ No newline at end of file +return {count: COUNT(sequences), sequences: sequences} From 7f8dbf8b7c9b7599b1163aaa0b737be5f96dae60 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Mon, 14 Jan 2019 16:57:50 -0800 Subject: [PATCH 189/732] Backwardz --- spec/views/list_genes_for_similar_reactions.aql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/views/list_genes_for_similar_reactions.aql b/spec/views/list_genes_for_similar_reactions.aql index 8ae646c2..cb7594c8 100644 --- a/spec/views/list_genes_for_similar_reactions.aql +++ b/spec/views/list_genes_for_similar_reactions.aql @@ -5,7 +5,7 @@ // df_sim - minimum difference fingerprint similarity score // exclude_self - if true, don't include the query reactions genes -let @ws_ids = ws_ids +let ws_ids = @ws_ids let similar_rxn_ids = ( for e in rxn_similar_to_reaction From 17fc32e8052c4b8fb5681d5f69f54bb0dd1b7b5a Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 15 Jan 2019 10:29:09 -0800 Subject: [PATCH 190/732] Implement some access control with the workspace --- api/docker-compose.yaml | 7 +++ api/src/relation_engine_server/api.py | 11 +++- api/src/relation_engine_server/auth.py | 28 ++++++++++ api/src/test/mock_workspace/endpoints.json | 46 +++++++++++++++ api/src/test/spec_release/spec.tar.gz | Bin 6318 -> 7519 bytes api/src/test/test_api.py | 62 +++++++++++++-------- 6 files changed, 128 insertions(+), 26 deletions(-) create mode 100644 api/src/test/mock_workspace/endpoints.json diff --git a/api/docker-compose.yaml b/api/docker-compose.yaml index c087c732..144727fa 100644 --- a/api/docker-compose.yaml +++ b/api/docker-compose.yaml @@ -16,6 +16,7 @@ services: - ${PWD}:/app environment: - KBASE_AUTH_URL=http://auth:5000 + - KBASE_WORKSPACE_URL=http://workspace:5000 - PYTHONUNBUFFERED=true - SPEC_RELEASE_PATH=/app/src/test/spec_release/spec.tar.gz - DB_URL=http://arangodb:8529 @@ -37,3 +38,9 @@ services: image: mockservices/mock_json_service volumes: - ${PWD}/src/test/mock_auth:/config + + # Mock workspace server (see src/test/mock_workspace/endpoints.json) + workspace: + image: mockservices/mock_json_service + volumes: + - ${PWD}/src/test/mock_workspace:/config diff --git a/api/src/relation_engine_server/api.py b/api/src/relation_engine_server/api.py index 91fafa85..dfb70ec7 100644 --- a/api/src/relation_engine_server/api.py +++ b/api/src/relation_engine_server/api.py @@ -21,8 +21,9 @@ def show_views(): def run_query(): """ Run a stored view as a query against the database. - Auth: only kbase re admins for ad-hoc queries - Public for views (views will have access controls within them based on params) + Auth: + - only kbase re admins for ad-hoc queries + - public for views (views will have access controls within them based on params) """ # Note that flask.request.json only works if the request Content-Type is application/json json_body = json.loads(flask.request.get_data() or '{}') @@ -33,9 +34,13 @@ def run_query(): del json_body['query'] resp_body = arango_client.run_query(query_text=query_text, bind_vars=json_body) return flask.jsonify(resp_body) - # auth.require_auth_token(roles=[]) if 'view' in flask.request.args: # Run a query from a view name + json_body['ws_ids'] = [] + auth_token = auth.get_auth_header() + if auth_token: + # Handle workspace authentication + json_body['ws_ids'] = auth.get_workspace_ids(auth_token) view_name = flask.request.args['view'] view_source = spec_loader.get_view(view_name) resp_body = arango_client.run_query(query_text=view_source, bind_vars=json_body) diff --git a/api/src/relation_engine_server/auth.py b/api/src/relation_engine_server/auth.py index 73d8d4a5..8ec16211 100644 --- a/api/src/relation_engine_server/auth.py +++ b/api/src/relation_engine_server/auth.py @@ -2,11 +2,14 @@ Authorization and authentication utilities. """ import os +import json import flask import requests from .exceptions import MissingHeader, UnauthorizedAccess +_WS_URL = os.environ.get('KBASE_WORKSPACE_URL', 'https://ci.kbase.us/services/ws') + def require_auth_token(roles=[]): """ @@ -40,3 +43,28 @@ def check_roles(required, given, auth_url): if role in given: return raise UnauthorizedAccess(auth_url) + + +def get_auth_header(): + return flask.request.headers.get('Authorization', '').replace('Bearer', '').strip() + + +def get_workspace_ids(auth_token): + """Get a list of workspace IDs that the given username is allowed to access in the workspace.""" + ws_url = _WS_URL + '/api/V2' + # Make an admin request to the workspace (command is 'listWorkspaceIds') + payload = { + 'method': 'Workspace.list_workspace_ids', + 'params': [{'perm': 'r'}], + 'version': '1.1' + } + headers = {'Authorization': auth_token} + resp = requests.post( + ws_url, + data=json.dumps(payload), + headers=headers + ) + # TODO error handling + resp_json = resp.json() + ws_ids = resp_json['result'][0]['workspaces'] + return ws_ids diff --git a/api/src/test/mock_workspace/endpoints.json b/api/src/test/mock_workspace/endpoints.json new file mode 100644 index 00000000..98042f91 --- /dev/null +++ b/api/src/test/mock_workspace/endpoints.json @@ -0,0 +1,46 @@ +[ + { + "methods": ["POST"], + "path": "/api/V2", + "headers": {"Authorization": "valid_token"}, + "body": { + "method": "Workspace.list_workspace_ids", + "version": "1.1", + "params": [{"perm": "r"}] + }, + "response": { + "status": "200", + "body": { + "version": "1.1", + "result": [ + { + "workspaces": [1, 2, 3], + "pub": [] + } + ] + } + } + }, + { + "methods": ["POST"], + "path": "/api/V2", + "headers": {"Authorization": "invalid_token"}, + "body": { + "method": "Workspace.list_workspace_ids", + "version": "1.1", + "params": [{"perm": "r"}] + }, + "response": { + "status": "500", + "body": { + "version": "1.1", + "error": { + "name": "JSONRPCError", + "code": -32400, + "message": "Token validation failed!", + "error": "..." + } + } + } + } +] diff --git a/api/src/test/spec_release/spec.tar.gz b/api/src/test/spec_release/spec.tar.gz index 6479e337d13606deb02bd384d839262ba27c6f05..a3a5d529ba6800d2e283ed94dee6948a2e3c4316 100644 GIT binary patch literal 7519 zcmV-l9iZYLiwFP!000001MEF(bK5qy`RreT(eBJ9x3(fu589r#cf4_$X1Z}RaoT)n zb2$(RNr)*@AxPWm&d%&#*uS{HQl=ZV@sbA zY!dg$?xDwFG#ZId4%ttBbMQpz4-`#R)P7&#*OkGrr#+eO0hb*3%)>6P(sdkf)pP6a zXB+p0z)(eoGoKUN`|e!r6XOD_qX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^8e0a_q=+Qk77W1xLN%VMeBl2XzPFMA4;lxZ~9MC`&} zjrIxLeCbX21%4p0AIN!hzE13-?*?r`gZ$(K)zcj|`S-uanv9wWOZMRdphMi?q)E8J zllTSSzX++^9F+3EZE;_xVCUBt0j2z}WcL3Kd&;oo{{~>i|6jo%ew9rBeEws==3oW$J!tUY!0Z!war~nuN02MbB@&Et; diff --git a/api/src/test/test_api.py b/api/src/test/test_api.py index 5bd71422..319269f4 100644 --- a/api/src/test/test_api.py +++ b/api/src/test/test_api.py @@ -23,7 +23,7 @@ def create_test_docs(count): """Produce some test documents.""" def doc(i): - return '{"name": "name", "_key": "%s"}' % i + return '{"name": "name", "_key": "%s", "is_public": true}' % i return '\n'.join(doc(i) for i in range(0, count)) @@ -82,12 +82,12 @@ def test_update_specs(self): def test_list_views(self): """Test the listing out of saved AQL views.""" resp = requests.get(url + '/api/views').json() - self.assertTrue('list_all_documents_in_collection' in resp) + self.assertTrue('list_test_vertices' in resp) def test_show_view(self): """Test the endpoint that displays AQL source code for one view.""" - resp = requests.get(url + '/api/views/count_documents_in_collection').text - self.assertTrue('Return count of documents' in resp) + resp = requests.get(url + '/api/views/list_test_vertices').text + self.assertTrue('test_vertex' in resp) def test_list_schemas(self): """Test the listing out of registered JSON schemas for vertices and edges.""" @@ -278,9 +278,7 @@ def test_query(self): save_test_docs(3) resp = requests.post( url + '/api/query_results', - params={'view': 'list_all_documents_in_collection'}, - data=json.dumps({'@collection': 'test_vertex'}), - headers=headers_non_admin + params={'view': 'list_test_vertices'} ).json() self.assertEqual(len(resp['results']), 3) self.assertEqual(resp['count'], 3) @@ -293,9 +291,7 @@ def test_query_with_cursor(self): save_test_docs(count=200) resp = requests.post( url + '/api/query_results', - params={'view': 'list_all_documents_in_collection'}, - data=json.dumps({'@collection': 'test_vertex'}), - headers=headers_non_admin + params={'view': 'list_test_vertices'} ).json() cursor_id = resp['cursor_id'] self.assertTrue(resp['cursor_id']) @@ -324,9 +320,7 @@ def test_query_no_name(self): """Test a query error with a view name that does not exist.""" resp = requests.post( url + '/api/query_results', - params={'view': 'nonexistent'}, - data=json.dumps({'@collection': 'test_vertex'}), - headers=headers_non_admin + params={'view': 'nonexistent'} ).json() self.assertEqual(resp['error'], 'View does not exist.') self.assertEqual(resp['name'], 'nonexistent') @@ -335,20 +329,42 @@ def test_query_missing_bind_var(self): """Test a query error with a missing bind variable.""" resp = requests.post( url + '/api/query_results', - params={'view': 'list_all_documents_in_collection'}, - data=json.dumps({'xyz': 'test_vertex'}), - headers=headers_non_admin + params={'view': 'list_test_vertices'}, + data=json.dumps({'xyz': 'test_vertex'}) ).json() self.assertEqual(resp['error'], 'ArangoDB server error.') self.assertTrue(resp['arango_message']) - def test_query_incorrect_collection(self): - """Test a query error with an invalid collection name.""" + def test_auth_query_with_access(self): + """Test the case where we query a collection with specific workspace access.""" + ws_id = 3 + # Remove all test vertices and create one with a ws_id + requests.put( + url + '/api/documents', + params={'overwrite': True, 'collection': 'test_vertex'}, + data='{"name": "requires_auth", "_key": "1", "ws_id": %s}' % ws_id, + headers=headers_admin + ) resp = requests.post( url + '/api/query_results', - params={'view': 'list_all_documents_in_collection'}, - data=json.dumps({'@collection': 123}), - headers=headers_non_admin + params={'view': 'list_test_vertices'}, + headers={'Authorization': 'valid_token'} ).json() - self.assertEqual(resp['error'], 'ArangoDB server error.') - self.assertTrue(resp['arango_message']) + self.assertEqual(resp['count'], 1) + self.assertEqual(resp['results'][0]['ws_id'], ws_id) + + def test_auth_query_no_access(self): + """Test the case where we try to query a collection without the right workspace access.""" + # Remove all test vertices and create one with a ws_id + requests.put( + url + '/api/documents', + params={'overwrite': True, 'collection': 'test_vertex'}, + data='{"name": "requires_auth", "_key": "1", "ws_id": 9999}', + headers=headers_admin + ) + resp = requests.post( + url + '/api/query_results', + params={'view': 'list_test_vertices'}, + headers={'Authorization': 'valid_token'} + ).json() + self.assertEqual(resp['count'], 0) From 597c4bcc1f86c6ab01295ff30b079f74477489c9 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 15 Jan 2019 10:32:45 -0800 Subject: [PATCH 191/732] Add test case for trying to set ws_ids --- api/src/test/test_api.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/api/src/test/test_api.py b/api/src/test/test_api.py index 319269f4..2d48fdfe 100644 --- a/api/src/test/test_api.py +++ b/api/src/test/test_api.py @@ -368,3 +368,20 @@ def test_auth_query_no_access(self): headers={'Authorization': 'valid_token'} ).json() self.assertEqual(resp['count'], 0) + + def test_query_cannot_pass_ws_ids(self): + """Test that users cannot set the ws_ids param.""" + ws_id = 99 + requests.put( + url + '/api/documents', + params={'overwrite': True, 'collection': 'test_vertex'}, + data='{"name": "requires_auth", "_key": "1", "ws_id": 99}', + headers=headers_admin + ) + resp = requests.post( + url + '/api/query_results', + params={'view': 'list_test_vertices'}, + data=json.dumps({'ws_ids': [ws_id]}), + headers={'Authorization': 'valid_token'} + ).json() + self.assertEqual(resp['count'], 0) From 43720f06861f128216443c8d4d8cf0a8df85aac1 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 15 Jan 2019 10:34:44 -0800 Subject: [PATCH 192/732] Use function instead of dupe code --- api/src/relation_engine_server/auth.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/src/relation_engine_server/auth.py b/api/src/relation_engine_server/auth.py index 8ec16211..f4b4b005 100644 --- a/api/src/relation_engine_server/auth.py +++ b/api/src/relation_engine_server/auth.py @@ -24,7 +24,7 @@ def require_auth_token(roles=[]): if not flask.request.headers.get('Authorization'): # No authorization token was provided in the headers raise MissingHeader('Authorization') - token = flask.request.headers.get('Authorization').replace('Bearer', '').strip() + token = get_auth_header() # Make an authorization request to the kbase auth2 server headers = {'Authorization': token} url = kbase_auth_url + '/api/V2/me' From aa25bc9b8fc5f254533d2c0d52e7370b3eb99080 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 15 Jan 2019 10:39:27 -0800 Subject: [PATCH 193/732] Clean up some test code --- api/src/test/test_api.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/api/src/test/test_api.py b/api/src/test/test_api.py index 2d48fdfe..36b57b60 100644 --- a/api/src/test/test_api.py +++ b/api/src/test/test_api.py @@ -342,13 +342,17 @@ def test_auth_query_with_access(self): requests.put( url + '/api/documents', params={'overwrite': True, 'collection': 'test_vertex'}, - data='{"name": "requires_auth", "_key": "1", "ws_id": %s}' % ws_id, + data=json.dumps({ + 'name': 'requires_auth', + '_key': '123', + 'ws_id': ws_id + }), headers=headers_admin ) resp = requests.post( url + '/api/query_results', params={'view': 'list_test_vertices'}, - headers={'Authorization': 'valid_token'} + headers={'Authorization': 'valid_token'} # see ./mock_workspace/endpoints.json ).json() self.assertEqual(resp['count'], 1) self.assertEqual(resp['results'][0]['ws_id'], ws_id) @@ -365,7 +369,7 @@ def test_auth_query_no_access(self): resp = requests.post( url + '/api/query_results', params={'view': 'list_test_vertices'}, - headers={'Authorization': 'valid_token'} + headers={'Authorization': 'valid_token'} # see ./mock_workspace/endpoints.json ).json() self.assertEqual(resp['count'], 0) From 3f4dbdfbdeb9e79704d7de0dea8204f8a4cc6265 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 15 Jan 2019 11:37:17 -0800 Subject: [PATCH 194/732] Add some minimal workspace auth error handling and add a test case for an invalid token --- api/src/relation_engine_server/auth.py | 11 +++++++---- api/src/test/test_api.py | 16 ++++++++++++++++ 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/api/src/relation_engine_server/auth.py b/api/src/relation_engine_server/auth.py index f4b4b005..c4c11170 100644 --- a/api/src/relation_engine_server/auth.py +++ b/api/src/relation_engine_server/auth.py @@ -64,7 +64,10 @@ def get_workspace_ids(auth_token): data=json.dumps(payload), headers=headers ) - # TODO error handling - resp_json = resp.json() - ws_ids = resp_json['result'][0]['workspaces'] - return ws_ids + try: + resp_json = resp.json() + return resp_json['result'][0]['workspaces'] + except Exception: + # For any problem parsing the auth response, treat it as failed authorization for now. + # In the future, this can return a response with an explicit/descriptive error if we need. + return [] diff --git a/api/src/test/test_api.py b/api/src/test/test_api.py index 36b57b60..43eb60f2 100644 --- a/api/src/test/test_api.py +++ b/api/src/test/test_api.py @@ -389,3 +389,19 @@ def test_query_cannot_pass_ws_ids(self): headers={'Authorization': 'valid_token'} ).json() self.assertEqual(resp['count'], 0) + + def test_auth_query_invalid_token(self): + """Test the case where we try to authorize a query using an invalid auth token.""" + requests.put( + url + '/api/documents', + params={'overwrite': True, 'collection': 'test_vertex'}, + data='{"name": "requires_auth", "_key": "1", "ws_id": 99}', + headers=headers_admin + ) + resp = requests.post( + url + '/api/query_results', + params={'view': 'list_test_vertices'}, + data=json.dumps({'ws_ids': [1]}), + headers={'Authorization': 'invalid_token'} + ).json() + self.assertEqual(resp['count'], 0) From 88bb5eb4257a5dd323b3f885e0164385f14d203e Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 15 Jan 2019 11:49:58 -0800 Subject: [PATCH 195/732] Add an explicit 403 response on a query with an invalid token --- api/src/relation_engine_server/auth.py | 14 +++++--------- api/src/relation_engine_server/exceptions.py | 3 ++- api/src/relation_engine_server/server.py | 3 ++- api/src/test/test_api.py | 4 ++-- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/api/src/relation_engine_server/auth.py b/api/src/relation_engine_server/auth.py index c4c11170..313ac4ac 100644 --- a/api/src/relation_engine_server/auth.py +++ b/api/src/relation_engine_server/auth.py @@ -32,7 +32,7 @@ def require_auth_token(roles=[]): if not auth_resp.ok: print('-' * 80) print(auth_resp.text) - raise UnauthorizedAccess(kbase_auth_url) + raise UnauthorizedAccess(kbase_auth_url, auth_resp.text) auth_json = auth_resp.json() if len(roles): check_roles(required=roles, given=auth_json['customroles'], auth_url=kbase_auth_url) @@ -42,7 +42,7 @@ def check_roles(required, given, auth_url): for role in required: if role in given: return - raise UnauthorizedAccess(auth_url) + raise UnauthorizedAccess(auth_url, 'Missing role') def get_auth_header(): @@ -64,10 +64,6 @@ def get_workspace_ids(auth_token): data=json.dumps(payload), headers=headers ) - try: - resp_json = resp.json() - return resp_json['result'][0]['workspaces'] - except Exception: - # For any problem parsing the auth response, treat it as failed authorization for now. - # In the future, this can return a response with an explicit/descriptive error if we need. - return [] + if not resp.ok: + raise UnauthorizedAccess(ws_url, resp.text) + return resp.json()['result'][0]['workspaces'] diff --git a/api/src/relation_engine_server/exceptions.py b/api/src/relation_engine_server/exceptions.py index c6376e58..d67b912a 100644 --- a/api/src/relation_engine_server/exceptions.py +++ b/api/src/relation_engine_server/exceptions.py @@ -14,5 +14,6 @@ def __str__(self): class UnauthorizedAccess(Exception): - def __init__(self, auth_url): + def __init__(self, auth_url, response): self.auth_url = auth_url + self.response = response diff --git a/api/src/relation_engine_server/server.py b/api/src/relation_engine_server/server.py index f89bd48b..309281e9 100644 --- a/api/src/relation_engine_server/server.py +++ b/api/src/relation_engine_server/server.py @@ -37,7 +37,8 @@ def root(): def unauthorized_access(err): resp = { 'error': '403 - Unauthorized', - 'auth_url': err.auth_url + 'auth_url': err.auth_url, + 'auth_response': err.response } return (flask.jsonify(resp), 403) diff --git a/api/src/test/test_api.py b/api/src/test/test_api.py index 43eb60f2..81ca42e6 100644 --- a/api/src/test/test_api.py +++ b/api/src/test/test_api.py @@ -403,5 +403,5 @@ def test_auth_query_invalid_token(self): params={'view': 'list_test_vertices'}, data=json.dumps({'ws_ids': [1]}), headers={'Authorization': 'invalid_token'} - ).json() - self.assertEqual(resp['count'], 0) + ) + self.assertEqual(resp.status_code, 403) From 4fa4e0f0fc152901e69f8cfa6a5df32eec88d948 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 15 Jan 2019 13:38:39 -0800 Subject: [PATCH 196/732] WIP admin access --- api/src/relation_engine_server/api.py | 15 ++++++++------- api/src/test/mock_workspace/endpoints.json | 2 +- api/src/test/test_api.py | 19 +++++++++++++++++++ 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/api/src/relation_engine_server/api.py b/api/src/relation_engine_server/api.py index dfb70ec7..0db6ad27 100644 --- a/api/src/relation_engine_server/api.py +++ b/api/src/relation_engine_server/api.py @@ -27,6 +27,12 @@ def run_query(): """ # Note that flask.request.json only works if the request Content-Type is application/json json_body = json.loads(flask.request.get_data() or '{}') + # Don't allow the user to set the special 'ws_ids' field + json_body['ws_ids'] = [] + auth_token = auth.get_auth_header() + if auth_token: + # Handle workspace authentication + json_body['ws_ids'] = auth.get_workspace_ids(auth_token) if 'query' in json_body: # Run an adhoc query for a sysadmin auth.require_auth_token(roles=['RE_ADMIN']) @@ -36,23 +42,18 @@ def run_query(): return flask.jsonify(resp_body) if 'view' in flask.request.args: # Run a query from a view name - json_body['ws_ids'] = [] - auth_token = auth.get_auth_header() - if auth_token: - # Handle workspace authentication - json_body['ws_ids'] = auth.get_workspace_ids(auth_token) view_name = flask.request.args['view'] view_source = spec_loader.get_view(view_name) resp_body = arango_client.run_query(query_text=view_source, bind_vars=json_body) return flask.jsonify(resp_body) - elif 'cursor_id' in flask.request.args: + if 'cursor_id' in flask.request.args: # Run a query from a cursor ID cursor_id = flask.request.args['cursor_id'] resp_body = arango_client.run_query(cursor_id=cursor_id) return flask.jsonify(resp_body) # No valid options were passed resp_body = {'error': 'Pass in a view or a cursor_id'} - return (flask.jsonify(resp_body), 500) + return (flask.jsonify(resp_body), 400) @api.route('/schemas', methods=['GET']) diff --git a/api/src/test/mock_workspace/endpoints.json b/api/src/test/mock_workspace/endpoints.json index 98042f91..123c7466 100644 --- a/api/src/test/mock_workspace/endpoints.json +++ b/api/src/test/mock_workspace/endpoints.json @@ -2,7 +2,7 @@ { "methods": ["POST"], "path": "/api/V2", - "headers": {"Authorization": "valid_token"}, + "headers": {"Authorization": "admin_token"}, "body": { "method": "Workspace.list_workspace_ids", "version": "1.1", diff --git a/api/src/test/test_api.py b/api/src/test/test_api.py index 81ca42e6..07970ac7 100644 --- a/api/src/test/test_api.py +++ b/api/src/test/test_api.py @@ -244,6 +244,7 @@ def test_admin_query(self): 'count': 1 }) ).json() + print(resp) self.assertEqual(resp['count'], 1) self.assertEqual(len(resp['results']), 1) @@ -405,3 +406,21 @@ def test_auth_query_invalid_token(self): headers={'Authorization': 'invalid_token'} ) self.assertEqual(resp.status_code, 403) + + def test_auth_adhoc_query(self): + """Test that RE_ADMINs can access objects with any ws_id.""" + ws_id = 3 + requests.put( + url + '/api/documents', + params={'overwrite': True, 'collection': 'test_vertex'}, + data=json.dumps({'name': 'requires_auth', 'key': '1', 'ws_id': ws_id}), + headers={'Authorization': 'valid_token'} + ) + # This is the same query as list_test_vertices.aql in the spec + query = 'for o in test_vertex filter o.is_public || o.ws_id IN @ws_ids return o' + resp = requests.post( + url + '/api/query_results', + params={'query': query}, + headers={'Authorization': 'valid_token'} + ).json() + self.assertEqual(resp['count'], 0) From 2d2740c0593011dcc9d600f3bb1ac1567e08c917 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 16 Jan 2019 11:51:34 -0800 Subject: [PATCH 197/732] Get tests working with some auth token juggling --- api/src/relation_engine_server/api.py | 12 +- api/src/relation_engine_server/auth.py | 6 +- api/src/test/mock_workspace/endpoints.json | 19 ++- api/src/test/test_api.py | 178 +++++++++------------ 4 files changed, 107 insertions(+), 108 deletions(-) diff --git a/api/src/relation_engine_server/api.py b/api/src/relation_engine_server/api.py index 0db6ad27..d8e471a4 100644 --- a/api/src/relation_engine_server/api.py +++ b/api/src/relation_engine_server/api.py @@ -30,12 +30,14 @@ def run_query(): # Don't allow the user to set the special 'ws_ids' field json_body['ws_ids'] = [] auth_token = auth.get_auth_header() - if auth_token: - # Handle workspace authentication - json_body['ws_ids'] = auth.get_workspace_ids(auth_token) - if 'query' in json_body: - # Run an adhoc query for a sysadmin + is_adhoc_query = 'query' in json_body + # Authorize for RE_ADMIN before fetching any workspace IDs + if is_adhoc_query: auth.require_auth_token(roles=['RE_ADMIN']) + # Fetch any authorized workspace IDs using a KBase auth token, if present + json_body['ws_ids'] = auth.get_workspace_ids(auth_token) + if is_adhoc_query: + # Run an adhoc query for a sysadmin query_text = json_body['query'] del json_body['query'] resp_body = arango_client.run_query(query_text=query_text, bind_vars=json_body) diff --git a/api/src/relation_engine_server/auth.py b/api/src/relation_engine_server/auth.py index 313ac4ac..1550dcc1 100644 --- a/api/src/relation_engine_server/auth.py +++ b/api/src/relation_engine_server/auth.py @@ -51,12 +51,14 @@ def get_auth_header(): def get_workspace_ids(auth_token): """Get a list of workspace IDs that the given username is allowed to access in the workspace.""" + if not auth_token: + return [] # anonymous users ws_url = _WS_URL + '/api/V2' # Make an admin request to the workspace (command is 'listWorkspaceIds') payload = { 'method': 'Workspace.list_workspace_ids', - 'params': [{'perm': 'r'}], - 'version': '1.1' + 'version': '1.1', + 'params': [{'perm': 'r'}] } headers = {'Authorization': auth_token} resp = requests.post( diff --git a/api/src/test/mock_workspace/endpoints.json b/api/src/test/mock_workspace/endpoints.json index 123c7466..56d917f2 100644 --- a/api/src/test/mock_workspace/endpoints.json +++ b/api/src/test/mock_workspace/endpoints.json @@ -2,7 +2,7 @@ { "methods": ["POST"], "path": "/api/V2", - "headers": {"Authorization": "admin_token"}, + "headers": {"Authorization": "valid_token"}, "body": { "method": "Workspace.list_workspace_ids", "version": "1.1", @@ -42,5 +42,22 @@ } } } + }, + { + "methods": ["POST"], + "path": "/api/V2", + "headers": {"Authorization": "admin_token"}, + "body": { + "method": "Workspace.list_workspace_ids", + "version": "1.1", + "params": [{"perm": "r"}] + }, + "response": { + "status": "200", + "body": { + "version": "1.1", + "result": [{"workspaces": [99], "pub": []}] + } + } } ] diff --git a/api/src/test/test_api.py b/api/src/test/test_api.py index 07970ac7..03d81ccd 100644 --- a/api/src/test/test_api.py +++ b/api/src/test/test_api.py @@ -9,15 +9,15 @@ import os # Use the mock auth tokens -non_admin_token = 'non_admin_token' -admin_token = 'admin_token' -invalid_token = 'invalid_token' +NON_ADMIN_TOKEN = 'non_admin_token' +ADMIN_TOKEN = 'admin_token' +INVALID_TOKEN = 'invalid_token' # Use the docker-compose url of the running flask server -url = os.environ.get('TEST_URL', 'http://web:5000') +URL = os.environ.get('TEST_URL', 'http://web:5000') -headers_non_admin = {'Authorization': 'Bearer ' + non_admin_token, 'Content-Type': 'application/json'} -headers_admin = {'Authorization': 'Bearer ' + admin_token, 'Content-Type': 'application/json'} +HEADERS_NON_ADMIN = {'Authorization': 'Bearer ' + NON_ADMIN_TOKEN, 'Content-Type': 'application/json'} +HEADERS_ADMIN = {'Authorization': 'Bearer ' + ADMIN_TOKEN, 'Content-Type': 'application/json'} def create_test_docs(count): @@ -42,10 +42,10 @@ def save_test_docs(count, edges=False): docs = create_test_docs(count) collection = 'test_vertex' return requests.put( - url + '/api/documents', + URL + '/api/documents', params={'overwrite': True, 'collection': collection}, data=docs, - headers=headers_admin + headers=HEADERS_ADMIN ).json() @@ -55,15 +55,15 @@ class TestApi(unittest.TestCase): def setUpClass(cls): # Initialize collections before running any tests resp = requests.get( - url + '/api/update_specs', - headers=headers_admin, + URL + '/api/update_specs', + headers=HEADERS_ADMIN, params={'reset': '1', 'init_collections': '1'} ) print('update_specs response', resp.text) def test_root(self): """Test root path for api.""" - resp = requests.get(url + '/').json() + resp = requests.get(URL + '/').json() self.assertEqual(resp['arangodb_status'], 'connected_authorized') self.assertTrue(resp['commit_hash']) self.assertTrue(resp['repo_url']) @@ -71,8 +71,8 @@ def test_root(self): def test_update_specs(self): """Test the endpoint that triggers an update on the specs.""" resp = requests.get( - url + '/api/update_specs', - headers=headers_admin, + URL + '/api/update_specs', + headers=HEADERS_ADMIN, params={'reset': '1', 'init_collections': '1'} ) resp_json = resp.json() @@ -81,17 +81,17 @@ def test_update_specs(self): def test_list_views(self): """Test the listing out of saved AQL views.""" - resp = requests.get(url + '/api/views').json() + resp = requests.get(URL + '/api/views').json() self.assertTrue('list_test_vertices' in resp) def test_show_view(self): """Test the endpoint that displays AQL source code for one view.""" - resp = requests.get(url + '/api/views/list_test_vertices').text + resp = requests.get(URL + '/api/views/list_test_vertices').text self.assertTrue('test_vertex' in resp) def test_list_schemas(self): """Test the listing out of registered JSON schemas for vertices and edges.""" - resp = requests.get(url + '/api/schemas').json() + resp = requests.get(URL + '/api/schemas').json() self.assertTrue('test_vertex' in resp['vertices']) self.assertTrue('test_edge' in resp['edges']) self.assertFalse('error' in resp) @@ -99,41 +99,41 @@ def test_list_schemas(self): def test_show_schema(self): """Test the endpoint that displays the JSON source for one schema.""" - resp = requests.get(url + '/api/schemas/test_edge').text + resp = requests.get(URL + '/api/schemas/test_edge').text self.assertTrue('_from' in resp) - resp = requests.get(url + '/api/schemas/test_vertex').text + resp = requests.get(URL + '/api/schemas/test_vertex').text self.assertTrue('_key' in resp) def test_save_documents_missing_auth(self): """Test an invalid attempt to save a doc with a missing auth token.""" resp = requests.put( - url + '/api/documents?on_duplicate=error&overwrite=true&collection' + URL + '/api/documents?on_duplicate=error&overwrite=true&collection' ).json() self.assertEqual(resp['error'], 'Missing header: Authorization') def test_save_documents_invalid_auth(self): """Test an invalid attempt to save a doc with a bad auth token.""" resp = requests.put( - url + '/api/documents?on_duplicate=error&overwrite=true&collection', - headers={'Authorization': 'Bearer ' + invalid_token} + URL + '/api/documents?on_duplicate=error&overwrite=true&collection', + headers={'Authorization': 'Bearer ' + INVALID_TOKEN} ).json() self.assertEqual(resp['error'], '403 - Unauthorized') def test_save_documents_non_admin(self): """Test an invalid attempt to save a doc as a non-admin.""" resp = requests.put( - url + '/api/documents?on_duplicate=error&overwrite=true&collection', - headers=headers_non_admin + URL + '/api/documents?on_duplicate=error&overwrite=true&collection', + headers=HEADERS_NON_ADMIN ).json() self.assertEqual(resp['error'], '403 - Unauthorized') def test_save_documents_invalid_schema(self): """Test the case where some documents fail against their schema.""" resp = requests.put( - url + '/api/documents', + URL + '/api/documents', params={'on_duplicate': 'ignore', 'collection': 'test_vertex'}, data='{"name": "x"}\n{"name": "y"}', - headers=headers_admin + headers=HEADERS_ADMIN ).json() self.assertEqual(resp['error'], "'_key' is a required property") self.assertEqual(resp['instance'], {'name': 'x'}) @@ -144,20 +144,20 @@ def test_save_documents_invalid_schema(self): def test_save_documents_missing_schema(self): """Test the case where the collection/schema does not exist.""" resp = requests.put( - url + '/api/documents', + URL + '/api/documents', params={'collection': 'xyzabc'}, data='', - headers=headers_admin + headers=HEADERS_ADMIN ).json() self.assertTrue('Schema does not exist' in resp['error']) def test_save_documents_invalid_json(self): """Test an attempt to save documents with an invalid JSON body.""" resp = requests.put( - url + '/api/documents', + URL + '/api/documents', params={'collection': 'test_vertex'}, data='\n', - headers=headers_admin + headers=HEADERS_ADMIN ).json() self.assertTrue('Unable to parse' in resp['error']) self.assertEqual(resp['pos'], 1) @@ -178,10 +178,10 @@ def test_create_edges(self): def test_update_documents(self): """Test updating existing documents.""" resp = requests.put( - url + '/api/documents', + URL + '/api/documents', params={'on_duplicate': 'update', 'collection': 'test_vertex'}, data=create_test_docs(3), - headers=headers_admin + headers=HEADERS_ADMIN ).json() expected = {'created': 0, 'errors': 0, 'empty': 0, 'updated': 3, 'ignored': 0, 'error': False} self.assertEqual(resp, expected) @@ -189,10 +189,10 @@ def test_update_documents(self): def test_update_edge(self): """Test updating existing edge.""" resp = requests.put( - url + '/api/documents', + URL + '/api/documents', params={'on_duplicate': 'update', 'collection': 'test_edge'}, data=create_test_edges(3), - headers=headers_admin + headers=HEADERS_ADMIN ).json() expected = {'created': 0, 'errors': 0, 'empty': 0, 'updated': 3, 'ignored': 0, 'error': False} self.assertEqual(resp, expected) @@ -200,10 +200,10 @@ def test_update_edge(self): def test_replace_documents(self): """Test replacing of existing documents.""" resp = requests.put( - url + '/api/documents', + URL + '/api/documents', params={'on_duplicate': 'replace', 'collection': 'test_vertex'}, data=create_test_docs(3), - headers=headers_admin + headers=HEADERS_ADMIN ).json() expected = {'created': 0, 'errors': 0, 'empty': 0, 'updated': 3, 'ignored': 0, 'error': False} self.assertEqual(resp, expected) @@ -212,10 +212,10 @@ def test_save_documents_dupe_errors(self): """Test where we want to raise errors on duplicate documents.""" save_test_docs(3) resp = requests.put( - url + '/api/documents', + URL + '/api/documents', params={'on_duplicate': 'error', 'collection': 'test_vertex', 'display_errors': '1'}, data=create_test_docs(3), - headers=headers_admin + headers=HEADERS_ADMIN ).json() self.assertEqual(resp['created'], 0) self.assertEqual(resp['errors'], 3) @@ -224,10 +224,10 @@ def test_save_documents_dupe_errors(self): def test_save_documents_ignore_dupes(self): """Test ignoring duplicate, existing documents when saving.""" resp = requests.put( - url + '/api/documents', + URL + '/api/documents', params={'on_duplicate': 'ignore', 'collection': 'test_vertex'}, data=create_test_docs(3), - headers=headers_admin + headers=HEADERS_ADMIN ).json() expected = {'created': 0, 'errors': 0, 'empty': 0, 'updated': 0, 'ignored': 3, 'error': False} self.assertEqual(resp, expected) @@ -235,63 +235,43 @@ def test_save_documents_ignore_dupes(self): def test_admin_query(self): """Test an ad-hoc query made by an admin.""" save_test_docs(1) + query = 'let ws_ids = @ws_ids for v in test_vertex sort rand() limit @count return v._id' resp = requests.post( - url + '/api/query_results', + URL + '/api/query_results', params={}, - headers=headers_admin, - data=json.dumps({ - 'query': 'for v in test_vertex sort rand() limit @count return v._id', - 'count': 1 - }) + headers=HEADERS_ADMIN, + data=json.dumps({'query': query, 'count': 1}) ).json() - print(resp) self.assertEqual(resp['count'], 1) self.assertEqual(len(resp['results']), 1) def test_admin_query_non_admin(self): """Test an ad-hoc query error as a non-admin.""" + query = 'let ws_ids = @ws_ids for v in test_vertex sort rand() limit @count return v._id' resp = requests.post( - url + '/api/query_results', + URL + '/api/query_results', params={}, - headers=headers_non_admin, - data=json.dumps({ - 'query': 'for v in test_vertex sort rand() limit @count return v._id', - 'count': 1 - }) + headers=HEADERS_NON_ADMIN, + data=json.dumps({'query': query, 'count': 1}) ).json() self.assertEqual(resp['error'], '403 - Unauthorized') def test_admin_query_invalid_auth(self): """Test the error response for an ad-hoc admin query without auth.""" + query = 'let ws_ids = @ws_ids for v in test_vertex sort rand() limit @count return v._id' resp = requests.post( - url + '/api/query_results', + URL + '/api/query_results', params={}, - headers={'Authorization': invalid_token}, - data=json.dumps({ - 'query': 'for v in test_vertex sort rand() limit @count return v._id', - 'count': 1 - }) + headers={'Authorization': INVALID_TOKEN}, + data=json.dumps({'query': query, 'count': 1}) ).json() self.assertEqual(resp['error'], '403 - Unauthorized') - def test_query(self): - """Test a basic query that fetches some docs.""" - save_test_docs(3) - resp = requests.post( - url + '/api/query_results', - params={'view': 'list_test_vertices'} - ).json() - self.assertEqual(len(resp['results']), 3) - self.assertEqual(resp['count'], 3) - self.assertEqual(resp['has_more'], False) - self.assertEqual(resp['cursor_id'], None) - self.assertTrue(resp['stats']) - def test_query_with_cursor(self): """Test getting more data via a query cursor.""" save_test_docs(count=200) resp = requests.post( - url + '/api/query_results', + URL + '/api/query_results', params={'view': 'list_test_vertices'} ).json() cursor_id = resp['cursor_id'] @@ -300,9 +280,8 @@ def test_query_with_cursor(self): self.assertEqual(resp['count'], 200) self.assertTrue(len(resp['results']), 100) resp = requests.post( - url + '/api/query_results', - params={'cursor_id': cursor_id}, - headers=headers_non_admin + URL + '/api/query_results', + params={'cursor_id': cursor_id} ).json() self.assertEqual(resp['count'], 200) self.assertEqual(resp['has_more'], False) @@ -310,9 +289,8 @@ def test_query_with_cursor(self): self.assertTrue(len(resp['results']), 100) # Try to get the same cursor again resp = requests.post( - url + '/api/query_results', - params={'cursor_id': cursor_id}, - headers=headers_non_admin + URL + '/api/query_results', + params={'cursor_id': cursor_id} ).json() self.assertTrue(resp['error']) self.assertEqual(resp['arango_message'], 'cursor not found') @@ -320,7 +298,7 @@ def test_query_with_cursor(self): def test_query_no_name(self): """Test a query error with a view name that does not exist.""" resp = requests.post( - url + '/api/query_results', + URL + '/api/query_results', params={'view': 'nonexistent'} ).json() self.assertEqual(resp['error'], 'View does not exist.') @@ -329,7 +307,7 @@ def test_query_no_name(self): def test_query_missing_bind_var(self): """Test a query error with a missing bind variable.""" resp = requests.post( - url + '/api/query_results', + URL + '/api/query_results', params={'view': 'list_test_vertices'}, data=json.dumps({'xyz': 'test_vertex'}) ).json() @@ -341,17 +319,17 @@ def test_auth_query_with_access(self): ws_id = 3 # Remove all test vertices and create one with a ws_id requests.put( - url + '/api/documents', + URL + '/api/documents', params={'overwrite': True, 'collection': 'test_vertex'}, data=json.dumps({ 'name': 'requires_auth', '_key': '123', 'ws_id': ws_id }), - headers=headers_admin + headers=HEADERS_ADMIN ) resp = requests.post( - url + '/api/query_results', + URL + '/api/query_results', params={'view': 'list_test_vertices'}, headers={'Authorization': 'valid_token'} # see ./mock_workspace/endpoints.json ).json() @@ -362,13 +340,13 @@ def test_auth_query_no_access(self): """Test the case where we try to query a collection without the right workspace access.""" # Remove all test vertices and create one with a ws_id requests.put( - url + '/api/documents', + URL + '/api/documents', params={'overwrite': True, 'collection': 'test_vertex'}, data='{"name": "requires_auth", "_key": "1", "ws_id": 9999}', - headers=headers_admin + headers=HEADERS_ADMIN ) resp = requests.post( - url + '/api/query_results', + URL + '/api/query_results', params={'view': 'list_test_vertices'}, headers={'Authorization': 'valid_token'} # see ./mock_workspace/endpoints.json ).json() @@ -378,13 +356,13 @@ def test_query_cannot_pass_ws_ids(self): """Test that users cannot set the ws_ids param.""" ws_id = 99 requests.put( - url + '/api/documents', + URL + '/api/documents', params={'overwrite': True, 'collection': 'test_vertex'}, data='{"name": "requires_auth", "_key": "1", "ws_id": 99}', - headers=headers_admin + headers=HEADERS_ADMIN ) resp = requests.post( - url + '/api/query_results', + URL + '/api/query_results', params={'view': 'list_test_vertices'}, data=json.dumps({'ws_ids': [ws_id]}), headers={'Authorization': 'valid_token'} @@ -394,24 +372,24 @@ def test_query_cannot_pass_ws_ids(self): def test_auth_query_invalid_token(self): """Test the case where we try to authorize a query using an invalid auth token.""" requests.put( - url + '/api/documents', + URL + '/api/documents', params={'overwrite': True, 'collection': 'test_vertex'}, data='{"name": "requires_auth", "_key": "1", "ws_id": 99}', - headers=headers_admin + headers=HEADERS_ADMIN ) resp = requests.post( - url + '/api/query_results', + URL + '/api/query_results', params={'view': 'list_test_vertices'}, data=json.dumps({'ws_ids': [1]}), - headers={'Authorization': 'invalid_token'} + headers={'Authorization': INVALID_TOKEN} ) self.assertEqual(resp.status_code, 403) def test_auth_adhoc_query(self): - """Test that RE_ADMINs can access objects with any ws_id.""" - ws_id = 3 + """Test that the 'ws_ids' bind-var is set for RE_ADMINs.""" + ws_id = 99 requests.put( - url + '/api/documents', + URL + '/api/documents', params={'overwrite': True, 'collection': 'test_vertex'}, data=json.dumps({'name': 'requires_auth', 'key': '1', 'ws_id': ws_id}), headers={'Authorization': 'valid_token'} @@ -419,8 +397,8 @@ def test_auth_adhoc_query(self): # This is the same query as list_test_vertices.aql in the spec query = 'for o in test_vertex filter o.is_public || o.ws_id IN @ws_ids return o' resp = requests.post( - url + '/api/query_results', - params={'query': query}, - headers={'Authorization': 'valid_token'} + URL + '/api/query_results', + data=json.dumps({'query': query}), + headers={'Authorization': ADMIN_TOKEN} # see ./mock_workspace/endpoints.json ).json() - self.assertEqual(resp['count'], 0) + self.assertEqual(resp['count'], 1) From aa808505cb44b70b73592fc9b81575c0bcca9ae0 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 16 Jan 2019 15:33:36 -0800 Subject: [PATCH 198/732] Tweak some acl logic in the wsprov views --- spec/views/wsprov_fetch_copies.aql | 15 +++++++-------- spec/views/wsprov_fetch_linked_objects.aql | 13 ++++++------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/spec/views/wsprov_fetch_copies.aql b/spec/views/wsprov_fetch_copies.aql index b2a27f19..692662f9 100644 --- a/spec/views/wsprov_fetch_copies.aql +++ b/spec/views/wsprov_fetch_copies.aql @@ -7,11 +7,10 @@ // obj_key - key of the object (eg "1:2:3") // copy_limit - max results of copies (recommended 10-20) -for o in wsprov_object - filter o._key == @obj_key - filter o.is_public || (o.workspace_id IN @ws_ids) - for copy in 1..100 any o wsprov_copied_into - filter copy // no nulls - limit @copy_limit - collect parent_id = o._id into groups = copy - return distinct { copies: groups, parent_id } +with wsprov_object +let obj_id = CONCAT('wsprov_object/', @obj_key) +for copy in 1..10 any obj_id wsprov_copied_into + filter copy.is_public || (copy.workspace_id IN @ws_ids) + limit @copy_limit + collect parent_id = obj_id into copies = copy + return distinct { copies, parent_id } diff --git a/spec/views/wsprov_fetch_linked_objects.aql b/spec/views/wsprov_fetch_linked_objects.aql index 6110ca7f..2bef357f 100644 --- a/spec/views/wsprov_fetch_linked_objects.aql +++ b/spec/views/wsprov_fetch_linked_objects.aql @@ -1,4 +1,4 @@ -// Find all linked objects to a given object +// Find all linked objects to a given set of objects // Returns links of level 1, plus all child links of any nested level ("sublinks") // Each sublink has a "parent_id" key that points to its parent object // Args: @@ -8,10 +8,9 @@ // sublink_limit - number of sublink results (10-20 recommended) for o in wsprov_object - filter o._key IN @obj_keys - filter o.is_public || (o.workspace_id IN @ws_ids) - for link in 1..100 any o wsprov_links + filter o._key in @obj_keys + for link in 1..10 any o wsprov_links + filter link.is_public || link.workspace_id IN @ws_ids limit @link_limit - filter link // no nulls - collect parent_id = o._id into groups = link - return distinct { links: groups, parent_id } + collect parent_id = o._id into links = link + return { links, parent_id } From 3b77df14bb3f53da909cc15fab98c26501473b47 Mon Sep 17 00:00:00 2001 From: James Jeffryes Date: Thu, 17 Jan 2019 11:21:30 -0600 Subject: [PATCH 199/732] Update rxn_gene_complex.json --- spec/schemas/vertices/reaction_homology/rxn_gene_complex.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/schemas/vertices/reaction_homology/rxn_gene_complex.json b/spec/schemas/vertices/reaction_homology/rxn_gene_complex.json index 639ec17d..888196b4 100644 --- a/spec/schemas/vertices/reaction_homology/rxn_gene_complex.json +++ b/spec/schemas/vertices/reaction_homology/rxn_gene_complex.json @@ -19,7 +19,7 @@ } }, "source": { - "type": "array", + "type": "string", "examples": ["ModelSEED", "KEGG"], "description": "The source of the gene complex information." } From fd372f57b663dce731f92919b477931264fc2e1e Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Thu, 17 Jan 2019 10:17:23 -0800 Subject: [PATCH 200/732] Remove sublink limit --- spec/views/wsprov_fetch_linked_objects.aql | 1 - 1 file changed, 1 deletion(-) diff --git a/spec/views/wsprov_fetch_linked_objects.aql b/spec/views/wsprov_fetch_linked_objects.aql index 2bef357f..4c9806ca 100644 --- a/spec/views/wsprov_fetch_linked_objects.aql +++ b/spec/views/wsprov_fetch_linked_objects.aql @@ -5,7 +5,6 @@ // ws_ids - array of private workspace ids the user has access to // obj_keys - wsprov_object key to find links for // link_limit - number of link results (10-20 recommended) -// sublink_limit - number of sublink results (10-20 recommended) for o in wsprov_object filter o._key in @obj_keys From a54ffff2e717a1d883bbbfa57acf3f4e34c515c5 Mon Sep 17 00:00:00 2001 From: JamesJeffryes Date: Fri, 18 Jan 2019 10:25:41 -0600 Subject: [PATCH 201/732] Fixes the server_status call which must always be made to _system --- api/src/relation_engine_server/arango_client.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/api/src/relation_engine_server/arango_client.py b/api/src/relation_engine_server/arango_client.py index ae8ea8e3..8aa9fb72 100644 --- a/api/src/relation_engine_server/arango_client.py +++ b/api/src/relation_engine_server/arango_client.py @@ -5,8 +5,8 @@ import json import os -db_url = os.environ.get('DB_URL', 'http://localhost:8529') -db_url += '/_db/' + os.environ.get('DB_NAME', '_system') +arango_url = os.environ.get('DB_URL', 'http://localhost:8529') +db_url = arango_url + '/_db/' + os.environ.get('DB_NAME', '_system') db_user = os.environ.get('DB_USER', 'root') db_pass = os.environ.get('DB_PASS', 'password') @@ -14,7 +14,7 @@ def server_status(): """Get the status of our connection and authorization to the ArangoDB server.""" try: - resp = requests.get(db_url + '/_api/endpoint', auth=(db_user, db_pass)) + resp = requests.get(arango_url + '/_api/endpoint', auth=(db_user, db_pass)) except requests.exceptions.ConnectionError: return 'no_connection' if resp.ok: From 79081acbef40ca448c1cf1514ca76d94a75428e1 Mon Sep 17 00:00:00 2001 From: JamesJeffryes Date: Wed, 23 Jan 2019 11:23:59 -0600 Subject: [PATCH 202/732] extracts some of the urls a bit more cleanly --- api/src/relation_engine_server/auth.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/api/src/relation_engine_server/auth.py b/api/src/relation_engine_server/auth.py index 1550dcc1..e7bd7029 100644 --- a/api/src/relation_engine_server/auth.py +++ b/api/src/relation_engine_server/auth.py @@ -8,7 +8,9 @@ from .exceptions import MissingHeader, UnauthorizedAccess -_WS_URL = os.environ.get('KBASE_WORKSPACE_URL', 'https://ci.kbase.us/services/ws') +_KBASE_ENDPOINT = os.environ.get('KBASE_ENDPOINT', 'https://ci.kbase.us/services') +_KBASE_AUTH_URL = os.environ.get('KBASE_AUTH_URL', _KBASE_ENDPOINT + '/auth') +_WS_URL = os.environ.get('KBASE_WORKSPACE_URL', _KBASE_ENDPOINT + '/ws') def require_auth_token(roles=[]): @@ -19,23 +21,21 @@ def require_auth_token(roles=[]): Raises some exception if any auth requirement is not met. """ - kbase_endpoint = os.environ.get('KBASE_ENDPOINT', 'https://ci.kbase.us/services') - kbase_auth_url = os.environ.get('KBASE_AUTH_URL', kbase_endpoint + '/auth') if not flask.request.headers.get('Authorization'): # No authorization token was provided in the headers raise MissingHeader('Authorization') token = get_auth_header() # Make an authorization request to the kbase auth2 server headers = {'Authorization': token} - url = kbase_auth_url + '/api/V2/me' - auth_resp = requests.get(url, headers=headers) + auth_url = _KBASE_AUTH_URL + '/api/V2/me' + auth_resp = requests.get(auth_url, headers=headers) if not auth_resp.ok: print('-' * 80) print(auth_resp.text) - raise UnauthorizedAccess(kbase_auth_url, auth_resp.text) + raise UnauthorizedAccess(_KBASE_AUTH_URL, auth_resp.text) auth_json = auth_resp.json() if len(roles): - check_roles(required=roles, given=auth_json['customroles'], auth_url=kbase_auth_url) + check_roles(required=roles, given=auth_json['customroles'], auth_url=_KBASE_AUTH_URL) def check_roles(required, given, auth_url): @@ -50,7 +50,8 @@ def get_auth_header(): def get_workspace_ids(auth_token): - """Get a list of workspace IDs that the given username is allowed to access in the workspace.""" + """Get a list of workspace IDs that the given username is allowed to access in + the workspace.""" if not auth_token: return [] # anonymous users ws_url = _WS_URL + '/api/V2' From c1e049c604c083cc243d28af6c3e47796d3c66c6 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 23 Jan 2019 17:05:14 -0800 Subject: [PATCH 203/732] Remove the extra api module/blueprint; add a standalone config module --- api/src/relation_engine_server/api.py | 162 ------------------ api/src/relation_engine_server/schemas.py | 102 ----------- api/src/relation_engine_server/server.py | 161 ++++++++++++++++- .../relation_engine_server/utils/__init__.py | 0 .../{ => utils}/arango_client.py | 24 +-- .../{ => utils}/auth.py | 18 +- .../{ => utils}/bulk_import.py | 0 .../relation_engine_server/utils/config.py | 39 +++++ .../{ => utils}/pull_spec.py | 28 +-- .../{ => utils}/spec_loader.py | 21 ++- 10 files changed, 240 insertions(+), 315 deletions(-) delete mode 100644 api/src/relation_engine_server/api.py delete mode 100644 api/src/relation_engine_server/schemas.py create mode 100644 api/src/relation_engine_server/utils/__init__.py rename api/src/relation_engine_server/{ => utils}/arango_client.py (83%) rename api/src/relation_engine_server/{ => utils}/auth.py (79%) rename api/src/relation_engine_server/{ => utils}/bulk_import.py (100%) create mode 100644 api/src/relation_engine_server/utils/config.py rename api/src/relation_engine_server/{ => utils}/pull_spec.py (79%) rename api/src/relation_engine_server/{ => utils}/spec_loader.py (72%) diff --git a/api/src/relation_engine_server/api.py b/api/src/relation_engine_server/api.py deleted file mode 100644 index d8e471a4..00000000 --- a/api/src/relation_engine_server/api.py +++ /dev/null @@ -1,162 +0,0 @@ -"""The primary router for the Relation Engine API.""" -import flask -import json -from jsonschema.exceptions import ValidationError - -from . import spec_loader, arango_client, auth, bulk_import, pull_spec - -api = flask.Blueprint('api', __name__) - - -@api.route('/views', methods=['GET']) -def show_views(): - """ - Fetch view names and content. - Auth: public - """ - return flask.jsonify(spec_loader.get_view_names()) - - -@api.route('/query_results', methods=['POST']) -def run_query(): - """ - Run a stored view as a query against the database. - Auth: - - only kbase re admins for ad-hoc queries - - public for views (views will have access controls within them based on params) - """ - # Note that flask.request.json only works if the request Content-Type is application/json - json_body = json.loads(flask.request.get_data() or '{}') - # Don't allow the user to set the special 'ws_ids' field - json_body['ws_ids'] = [] - auth_token = auth.get_auth_header() - is_adhoc_query = 'query' in json_body - # Authorize for RE_ADMIN before fetching any workspace IDs - if is_adhoc_query: - auth.require_auth_token(roles=['RE_ADMIN']) - # Fetch any authorized workspace IDs using a KBase auth token, if present - json_body['ws_ids'] = auth.get_workspace_ids(auth_token) - if is_adhoc_query: - # Run an adhoc query for a sysadmin - query_text = json_body['query'] - del json_body['query'] - resp_body = arango_client.run_query(query_text=query_text, bind_vars=json_body) - return flask.jsonify(resp_body) - if 'view' in flask.request.args: - # Run a query from a view name - view_name = flask.request.args['view'] - view_source = spec_loader.get_view(view_name) - resp_body = arango_client.run_query(query_text=view_source, bind_vars=json_body) - 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'] - resp_body = arango_client.run_query(cursor_id=cursor_id) - return flask.jsonify(resp_body) - # No valid options were passed - resp_body = {'error': 'Pass in a view or a cursor_id'} - return (flask.jsonify(resp_body), 400) - - -@api.route('/schemas', methods=['GET']) -def show_schemas(): - """ - Fetch schema names and content. - Auth: public - """ - return flask.jsonify(spec_loader.get_schema_names()) - - -@api.route('/schemas/', methods=['GET']) -def show_schema(name): - """ - Fetch the JSON for a single schema. - Auth: public - """ - return flask.jsonify(spec_loader.get_schema(name)) - - -@api.route('/views/', methods=['GET']) -def show_view(name): - """ - Fetch the AQL for a single view. - Auth: public - """ - return flask.Response(spec_loader.get_view(name), mimetype='text/plain') - - -@api.route('/update_specs', methods=['GET']) -def refresh_specs(): - """ - Manually check for updates, download spec releases, and init new collections. - Auth: admin - """ - auth.require_auth_token(['RE_ADMIN']) - pull_spec.download_latest(init_collections='init_collections' in flask.request.args) - return flask.jsonify({'status': 'updated'}) - - -@api.route('/documents', methods=['PUT']) -def save_documents(): - """ - Create, update, or replace many documents in a batch. - Auth: admin - """ - auth.require_auth_token(['RE_ADMIN']) - collection_name = flask.request.args['collection'] - query = {'collection': collection_name, 'type': 'documents'} - if flask.request.args.get('display_errors'): - # Display an array of error messages - query['details'] = 'true' - if flask.request.args.get('on_duplicate'): - query['onDuplicate'] = flask.request.args['on_duplicate'] - if flask.request.args.get('overwrite'): - query['overwrite'] = 'true' - resp_text = bulk_import.bulk_import(query) - return resp_text - - -@api.errorhandler(json.decoder.JSONDecodeError) -def json_decode_error(err): - """A problem parsing json.""" - resp = { - 'error': 'Unable to parse JSON', - 'source_json': err.doc, - 'pos': err.pos, - 'lineno': err.lineno, - 'colno': err.colno - } - return (flask.jsonify(resp), 400) - - -@api.errorhandler(arango_client.ArangoServerError) -def arango_server_error(err): - resp = { - 'error': str(err), - 'arango_message': err.resp_json['errorMessage'] - } - return (flask.jsonify(resp), 400) - - -@api.errorhandler(spec_loader.SchemaNonexistent) -@api.errorhandler(spec_loader.ViewNonexistent) -def view_does_not_exist(err): - """General error cases.""" - resp = { - 'error': str(err), - 'name': err.name - } - return (flask.jsonify(resp), 400) - - -@api.errorhandler(ValidationError) -def validation_error(err): - """Json Schema validation error.""" - resp = { - 'error': str(err).split('\n')[0], - 'instance': err.instance, - 'validator': err.validator, - 'validator_value': err.validator_value, - 'schema': err.schema - } - return (flask.jsonify(resp), 400) diff --git a/api/src/relation_engine_server/schemas.py b/api/src/relation_engine_server/schemas.py deleted file mode 100644 index fdb188fe..00000000 --- a/api/src/relation_engine_server/schemas.py +++ /dev/null @@ -1,102 +0,0 @@ -"""Fetch schemas for the API.""" - -# An AQL stored query -view = { - 'type': 'object', - 'required': ['name'], - 'description': 'Stored query for use in fetching graph data.', - 'properties': { - 'name': { - 'type': 'string', - 'description': 'Unique name of the view' - }, - 'source': { - 'type': 'string', - 'description': 'AQL source code for this schema (if requested).' - } - } -} - -# An error response (any non-2xx) -error = { - 'type': 'object', - 'required': ['error', 'request_id', 'error_code'], - 'properties': { - 'error': { - 'type': 'string', - 'description': 'Error message.' - }, - 'error_code': { - 'type': 'string', - 'description': 'Code representing the error type.' - }, - 'request_id': { - 'type': 'string', - 'description': 'Unique ID of the request, used in fetching error logs.' - } - } -} - -# Results from running a query -query_results = { - 'description': 'Resulting status and data from running a query.', - 'type': 'object', - 'required': ['has_more', 'data', 'count', 'cursor_id'], - 'properties': { - 'has_more': { - 'type': 'boolean', - 'description': 'Whether there are more results in the query. If so, use the cursor ID to fetch them.' - }, - 'data': { - 'type': 'array', - 'description': 'Array of result data, up to a maximum of 100 results.', - 'item': {'type': 'object'} - }, - 'count': { - 'type': 'integer', - 'description': 'Total count of resulting documents.' - }, - 'cursor_id': { - 'type': 'string', - 'description': ('If has_more is true, then this is set to an ID that you can use' - ' to fetch additional results.') - } - } -} - -# Results from bulk-saving documents -document_save_results = { - 'description': 'Result info after bulk-saving documents in the database.', - 'type': 'object', - 'properties': { - 'created': { - 'type': 'integer', - 'description': 'Number of documents created.' - }, - 'updated': { - 'type': 'integer', - 'description': 'Number of documents updated.' - }, - 'replaced': { - 'type': 'integer', - 'description': 'Number of documents replaced.' - } - } -} - -# Schema inception ^_^ -schema = { - 'description': 'A stored schema that describes the validation for a collection in the database.', - 'type': 'object', - 'required': ['name'], - 'properties': { - 'name': { - 'type': 'string', - 'description': 'Unique name of the schema (maps to a name of a collection, such as "genes").' - }, - 'source': { - 'type': 'object', - 'description': 'JSON schema object used for validating a collection of documents in the database.' - } - } -} diff --git a/api/src/relation_engine_server/server.py b/api/src/relation_engine_server/server.py index 309281e9..09a7e6d4 100644 --- a/api/src/relation_engine_server/server.py +++ b/api/src/relation_engine_server/server.py @@ -1,20 +1,19 @@ """The main entrypoint for running the Flask server.""" import flask +import json import os from uuid import uuid4 import traceback +from jsonschema.exceptions import ValidationError -from .api import api from .exceptions import MissingHeader, UnauthorizedAccess -from . import arango_client +from .utils import arango_client, spec_loader, auth, bulk_import, pull_spec app = flask.Flask(__name__) app.config['DEBUG'] = os.environ.get('FLASK_DEBUG', True) app.config['SECRET_KEY'] = os.environ.get('FLASK_SECRET_KEY', str(uuid4())) app.url_map.strict_slashes = False # allow both `get /v1/` and `get /v1` -app.register_blueprint(api, url_prefix='/api') - @app.route('/', methods=['GET']) def root(): @@ -33,6 +32,160 @@ def root(): }) +@app.route('/api/views', methods=['GET']) +def show_views(): + """ + Fetch view names and content. + Auth: public + """ + return flask.jsonify(spec_loader.get_view_names()) + + +@app.route('/api/query_results', methods=['POST']) +def run_query(): + """ + Run a stored view as a query against the database. + Auth: + - only kbase re admins for ad-hoc queries + - public for views (views will have access controls within them based on params) + """ + # Note that flask.request.json only works if the request Content-Type is application/json + json_body = json.loads(flask.request.get_data() or '{}') + # Don't allow the user to set the special 'ws_ids' field + json_body['ws_ids'] = [] + auth_token = auth.get_auth_header() + is_adhoc_query = 'query' in json_body + # Authorize for RE_ADMIN before fetching any workspace IDs + if is_adhoc_query: + auth.require_auth_token(roles=['RE_ADMIN']) + # Fetch any authorized workspace IDs using a KBase auth token, if present + json_body['ws_ids'] = auth.get_workspace_ids(auth_token) + if is_adhoc_query: + # Run an adhoc query for a sysadmin + query_text = json_body['query'] + del json_body['query'] + resp_body = arango_client.run_query(query_text=query_text, bind_vars=json_body) + return flask.jsonify(resp_body) + if 'view' in flask.request.args: + # Run a query from a view name + view_name = flask.request.args['view'] + view_source = spec_loader.get_view(view_name) + resp_body = arango_client.run_query(query_text=view_source, bind_vars=json_body) + 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'] + resp_body = arango_client.run_query(cursor_id=cursor_id) + return flask.jsonify(resp_body) + # No valid options were passed + resp_body = {'error': 'Pass in a view or a cursor_id'} + return (flask.jsonify(resp_body), 400) + + +@app.route('/api/schemas', methods=['GET']) +def show_schemas(): + """ + Fetch schema names and content. + Auth: public + """ + return flask.jsonify(spec_loader.get_schema_names()) + + +@app.route('/api/schemas/', methods=['GET']) +def show_schema(name): + """ + Fetch the JSON for a single schema. + Auth: public + """ + return flask.jsonify(spec_loader.get_schema(name)) + + +@app.route('/api/views/', methods=['GET']) +def show_view(name): + """ + Fetch the AQL for a single view. + Auth: public + """ + return flask.Response(spec_loader.get_view(name), mimetype='text/plain') + + +@app.route('/api/update_specs', methods=['GET']) +def refresh_specs(): + """ + Manually check for updates, download spec releases, and init new collections. + Auth: admin + """ + auth.require_auth_token(['RE_ADMIN']) + pull_spec.download_latest(init_collections='init_collections' in flask.request.args) + return flask.jsonify({'status': 'updated'}) + + +@app.route('/api/documents', methods=['PUT']) +def save_documents(): + """ + Create, update, or replace many documents in a batch. + Auth: admin + """ + auth.require_auth_token(['RE_ADMIN']) + collection_name = flask.request.args['collection'] + query = {'collection': collection_name, 'type': 'documents'} + if flask.request.args.get('display_errors'): + # Display an array of error messages + query['details'] = 'true' + if flask.request.args.get('on_duplicate'): + query['onDuplicate'] = flask.request.args['on_duplicate'] + if flask.request.args.get('overwrite'): + query['overwrite'] = 'true' + resp_text = bulk_import.bulk_import(query) + return resp_text + + +@app.errorhandler(json.decoder.JSONDecodeError) +def json_decode_error(err): + """A problem parsing json.""" + resp = { + 'error': 'Unable to parse JSON', + 'source_json': err.doc, + 'pos': err.pos, + 'lineno': err.lineno, + 'colno': err.colno + } + return (flask.jsonify(resp), 400) + + +@app.errorhandler(arango_client.ArangoServerError) +def arango_server_error(err): + resp = { + 'error': str(err), + 'arango_message': err.resp_json['errorMessage'] + } + return (flask.jsonify(resp), 400) + + +@app.errorhandler(spec_loader.SchemaNonexistent) +@app.errorhandler(spec_loader.ViewNonexistent) +def view_does_not_exist(err): + """General error cases.""" + resp = { + 'error': str(err), + 'name': err.name + } + return (flask.jsonify(resp), 400) + + +@app.errorhandler(ValidationError) +def validation_error(err): + """Json Schema validation error.""" + resp = { + 'error': str(err).split('\n')[0], + 'instance': err.instance, + 'validator': err.validator, + 'validator_value': err.validator_value, + 'schema': err.schema + } + return (flask.jsonify(resp), 400) + + @app.errorhandler(UnauthorizedAccess) def unauthorized_access(err): resp = { diff --git a/api/src/relation_engine_server/utils/__init__.py b/api/src/relation_engine_server/utils/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/api/src/relation_engine_server/arango_client.py b/api/src/relation_engine_server/utils/arango_client.py similarity index 83% rename from api/src/relation_engine_server/arango_client.py rename to api/src/relation_engine_server/utils/arango_client.py index 8aa9fb72..6fcda524 100644 --- a/api/src/relation_engine_server/arango_client.py +++ b/api/src/relation_engine_server/utils/arango_client.py @@ -3,18 +3,15 @@ """ import requests import json -import os -arango_url = os.environ.get('DB_URL', 'http://localhost:8529') -db_url = arango_url + '/_db/' + os.environ.get('DB_NAME', '_system') -db_user = os.environ.get('DB_USER', 'root') -db_pass = os.environ.get('DB_PASS', 'password') +from .config import get_config def server_status(): """Get the status of our connection and authorization to the ArangoDB server.""" + config = get_config() try: - resp = requests.get(arango_url + '/_api/endpoint', auth=(db_user, db_pass)) + resp = requests.get(config['db_url'] + '/_api/endpoint', auth=(config['db_user'], config['db_pass'])) except requests.exceptions.ConnectionError: return 'no_connection' if resp.ok: @@ -27,7 +24,8 @@ def server_status(): def run_query(query_text=None, cursor_id=None, bind_vars={}): """Run a query using the arangodb http api. Can return a cursor to get more results.""" - url = db_url + '/_api/cursor' + config = get_config() + url = config['db_url'] + '/_api/cursor' req_json = { 'batchSize': 100, 'memoryLimit': 16000000000 # 16gb @@ -45,7 +43,7 @@ def run_query(query_text=None, cursor_id=None, bind_vars={}): method, url, data=json.dumps(req_json), - auth=(db_user, db_pass) + auth=(config['db_user'], config['db_pass']) ) if not resp.ok: raise ArangoServerError(resp.text) @@ -76,7 +74,8 @@ def create_collection(name, is_edge): Create a single collection by name using some basic defaults. We ignore duplicates. For any other server error, an exception is thrown. """ - url = db_url + '/_api/collection' + config = get_config() + url = config['db_url'] + '/_api/collection' # collection types: # 2 is a document collection # 3 is an edge collection @@ -86,7 +85,7 @@ def create_collection(name, is_edge): 'name': name, 'type': collection_type }) - resp = requests.post(url, data, auth=(db_user, db_pass)).json() + resp = requests.post(url, data, auth=(config['db_user'], config['db_pass'])).json() if resp['error']: if 'duplicate' not in resp['errorMessage']: # Unable to create a collection @@ -95,11 +94,12 @@ def create_collection(name, is_edge): def import_from_file(file_path, query): """Make a generic arango post request.""" + config = get_config() with open(file_path, 'rb') as file_desc: resp = requests.post( - db_url + '/_api/import', + config['db_url'] + '/_api/import', data=file_desc, - auth=(db_user, db_pass), + auth=(config['db_user'], config['db_pass']), params=query ) if not resp.ok: diff --git a/api/src/relation_engine_server/auth.py b/api/src/relation_engine_server/utils/auth.py similarity index 79% rename from api/src/relation_engine_server/auth.py rename to api/src/relation_engine_server/utils/auth.py index e7bd7029..6f4f4689 100644 --- a/api/src/relation_engine_server/auth.py +++ b/api/src/relation_engine_server/utils/auth.py @@ -1,16 +1,12 @@ """ Authorization and authentication utilities. """ -import os import json import flask import requests -from .exceptions import MissingHeader, UnauthorizedAccess - -_KBASE_ENDPOINT = os.environ.get('KBASE_ENDPOINT', 'https://ci.kbase.us/services') -_KBASE_AUTH_URL = os.environ.get('KBASE_AUTH_URL', _KBASE_ENDPOINT + '/auth') -_WS_URL = os.environ.get('KBASE_WORKSPACE_URL', _KBASE_ENDPOINT + '/ws') +from .config import get_config +from ..exceptions import MissingHeader, UnauthorizedAccess def require_auth_token(roles=[]): @@ -21,21 +17,22 @@ def require_auth_token(roles=[]): Raises some exception if any auth requirement is not met. """ + config = get_config() if not flask.request.headers.get('Authorization'): # No authorization token was provided in the headers raise MissingHeader('Authorization') token = get_auth_header() # Make an authorization request to the kbase auth2 server headers = {'Authorization': token} - auth_url = _KBASE_AUTH_URL + '/api/V2/me' + auth_url = config['auth_url'] + '/api/V2/me' auth_resp = requests.get(auth_url, headers=headers) if not auth_resp.ok: print('-' * 80) print(auth_resp.text) - raise UnauthorizedAccess(_KBASE_AUTH_URL, auth_resp.text) + raise UnauthorizedAccess(config['auth_url'], auth_resp.text) auth_json = auth_resp.json() if len(roles): - check_roles(required=roles, given=auth_json['customroles'], auth_url=_KBASE_AUTH_URL) + check_roles(required=roles, given=auth_json['customroles'], auth_url=config['auth_url']) def check_roles(required, given, auth_url): @@ -54,7 +51,8 @@ def get_workspace_ids(auth_token): the workspace.""" if not auth_token: return [] # anonymous users - ws_url = _WS_URL + '/api/V2' + config = get_config() + ws_url = config['workspace_url'] + '/api/V2' # Make an admin request to the workspace (command is 'listWorkspaceIds') payload = { 'method': 'Workspace.list_workspace_ids', diff --git a/api/src/relation_engine_server/bulk_import.py b/api/src/relation_engine_server/utils/bulk_import.py similarity index 100% rename from api/src/relation_engine_server/bulk_import.py rename to api/src/relation_engine_server/utils/bulk_import.py diff --git a/api/src/relation_engine_server/utils/config.py b/api/src/relation_engine_server/utils/config.py new file mode 100644 index 00000000..fce0453b --- /dev/null +++ b/api/src/relation_engine_server/utils/config.py @@ -0,0 +1,39 @@ +""" +Load configuration data from environment variables. +""" +import os +from urllib.parse import urljoin + + +def get_config(): + """Load environment configuration data.""" + spec_path = os.environ.get('SPEC_PATH', '/spec') + spec_repo_path = os.path.join(spec_path, 'repo') # /spec/repo + spec_schemas_path = os.path.join(spec_repo_path, 'schemas') # /spec/repo/schemas + spec_url = 'https://api.github.com/repos/kbase/relation_engine_spec' + kbase_endpoint = os.environ.get('KBASE_ENDPOINT', 'https://ci.kbase.us/services') + auth_url = os.environ.get('KBASE_AUTH_URL', urljoin(kbase_endpoint + '/', 'auth')) + workspace_url = os.environ.get('KBASE_WORKSPACE_URL', urljoin(kbase_endpoint + '/', 'ws')) + db_url = os.environ.get('DB_URL', 'http://localhost:8529') + db_name = os.environ.get('DB_NAME', '_system') + db_user = os.environ.get('DB_USER', 'root') + db_pass = os.environ.get('DB_PASS', 'password') + return { + 'auth_url': auth_url, + 'workspace_url': workspace_url, + 'kbase_endpoint': kbase_endpoint, + 'db_url': db_url, + 'db_name': db_name, + 'db_user': db_user, + 'db_pass': db_pass, + 'spec_url': spec_url, + 'spec_paths': { + 'release_id': os.path.join(spec_path, '.release_id'), + 'root': spec_path, + 'repo': spec_repo_path, + 'views': os.path.join(spec_repo_path, 'views'), + 'schemas': spec_schemas_path, + 'vertices': os.path.join(spec_schemas_path, 'vertices'), + 'edges': os.path.join(spec_schemas_path, 'edges') + } + } diff --git a/api/src/relation_engine_server/pull_spec.py b/api/src/relation_engine_server/utils/pull_spec.py similarity index 79% rename from api/src/relation_engine_server/pull_spec.py rename to api/src/relation_engine_server/utils/pull_spec.py index 96f6c611..b698b363 100644 --- a/api/src/relation_engine_server/pull_spec.py +++ b/api/src/relation_engine_server/utils/pull_spec.py @@ -5,22 +5,19 @@ import shutil from . import arango_client, spec_loader - -_spec_dir = os.environ.get('SPEC_PATH', '/spec') -_api_url = 'https://api.github.com/repos/kbase/relation_engine_spec' -_release_id_path = os.path.join(_spec_dir, '.release_id') +from .config import get_config def download_latest(init_collections=True): """Check and download the latest spec and extract it to the spec path.""" + config = get_config() # Remove the spec directory, ignoring if it is already missing - shutil.rmtree(_spec_dir, ignore_errors=True) + shutil.rmtree(config['spec_paths']['root'], ignore_errors=True) # Recreate the spec directory so we have a clean slate, avoiding name conflicts - os.makedirs(_spec_dir) + os.makedirs(config['spec_paths']['root']) # Download and extract a new release to /spec/repo - spec_repo_path = os.path.join(_spec_dir, 'repo') if 'SPEC_RELEASE_PATH' in os.environ: - _extract_tarball(os.environ['SPEC_RELEASE_PATH'], _spec_dir) + _extract_tarball(os.environ['SPEC_RELEASE_PATH'], config['spec_paths']['root']) else: if 'SPEC_RELEASE_URL' in os.environ: tarball_url = os.environ['SPEC_RELEASE_URL'] @@ -32,10 +29,10 @@ def download_latest(init_collections=True): # Download from the tarball url to the temp file _download_file(resp, temp_file.name) # Extract the downloaded tarball into the spec path - _extract_tarball(temp_file.name, _spec_dir) + _extract_tarball(temp_file.name, config['spec_paths']['root']) # The files will be extracted into a directory like /spec/kbase-relation_engine_spec-xyz # We want to move that to /spec/repo - _rename_directories(_spec_dir, spec_repo_path) + _rename_directories(config['spec_paths']['root'], config['spec_paths']['repo']) # Initialize all the collections if init_collections: schemas = spec_loader.get_schema_names() @@ -43,8 +40,9 @@ def download_latest(init_collections=True): def _fetch_github_release_url(): + config = get_config() # Download information about the latest release - release_resp = requests.get(_api_url + '/releases/latest') + release_resp = requests.get(config['spec_url'] + '/releases/latest') release_info = release_resp.json() if release_resp.status_code != 200: # This may be a github API rate usage limit, or some other error @@ -80,9 +78,10 @@ def _rename_directories(dir_path, dest_path): def _has_latest_spec(info): """Check if downloaded release info matches the latest downloaded spec.""" + config = get_config() release_id = str(info['id']) - if os.path.exists(_release_id_path): - with open(_release_id_path, 'r') as fd: + if os.path.exists(config['spec_paths']['release_id']): + with open(config['spec_paths']['release_id'], 'r') as fd: current_release_id = fd.read() if release_id == current_release_id: return True @@ -92,6 +91,7 @@ def _has_latest_spec(info): def _save_release_id(info): """Save a release ID as the latest downloaded spec.""" release_id = str(info['id']) + config = get_config() # Write the release ID to /spec/.release_id - with open(_release_id_path, 'w') as fd: + with open(config['spec_release_id_path'], 'w') as fd: fd.write(release_id) diff --git a/api/src/relation_engine_server/spec_loader.py b/api/src/relation_engine_server/utils/spec_loader.py similarity index 72% rename from api/src/relation_engine_server/spec_loader.py rename to api/src/relation_engine_server/utils/spec_loader.py index 62ae4d46..06d1de42 100644 --- a/api/src/relation_engine_server/spec_loader.py +++ b/api/src/relation_engine_server/utils/spec_loader.py @@ -5,40 +5,38 @@ import os import json -_spec_root_dir = os.environ.get('SPEC_PATH', '/spec') -_spec_dir = os.path.join(_spec_root_dir, 'repo') # /spec/repo -_view_dir = os.path.join(_spec_dir, 'views') # /spec/repo/views -_schema_dir = os.path.join(_spec_dir, 'schemas') # /spec/repo/schemas -_vertex_dir = os.path.join(_schema_dir, 'vertices') # /spec/repo/schemas/vertices -_edge_dir = os.path.join(_schema_dir, 'edges') # /spec/repo/schemas/edges +from .config import get_config def get_schema_names(): """Return a dict of vertex and edge base names.""" + config = get_config() return { 'vertices': [ _get_file_name(path) - for path in _find_paths(_vertex_dir, '*.json') + for path in _find_paths(config['spec_paths']['vertices'], '*.json') ], 'edges': [ _get_file_name(path) - for path in _find_paths(_edge_dir, '*.json') + for path in _find_paths(config['spec_paths']['edges'], '*.json') ] } def get_view_names(): """Return an array of all view base names.""" + config = get_config() return [ _get_file_name(path) - for path in _find_paths(_view_dir, '*.aql') + for path in _find_paths(config['spec_paths']['views'], '*.aql') ] def get_schema(name): """Get JSON content for a specific schema. Throws an error if nonexistent.""" + config = get_config() try: - path = _find_paths(_schema_dir, name + '.json')[0] + path = _find_paths(config['spec_paths']['schemas'], name + '.json')[0] except IndexError: raise SchemaNonexistent(name) with open(path, 'r', encoding='utf8') as fd: @@ -47,8 +45,9 @@ def get_schema(name): def get_view(name): """Get AQL content for a specific view. Throws an error if nonexistent.""" + config = get_config() try: - path = _find_paths(_view_dir, name + '.aql')[0] + path = _find_paths(config['spec_paths']['views'], name + '.aql')[0] except IndexError: raise ViewNonexistent(name) with open(path, 'r', encoding='utf8') as fd: From 0e2bb54bc9cc89f494a54527cf03a0414f4ed25a Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 23 Jan 2019 17:09:31 -0800 Subject: [PATCH 204/732] Add JamesJeffryes as a codeowner --- api/CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/CODEOWNERS b/api/CODEOWNERS index 788e5f5d..9703c9e0 100644 --- a/api/CODEOWNERS +++ b/api/CODEOWNERS @@ -1 +1 @@ -* @jayrbolton +* @jayrbolton @JamesJeffryes From 3858670da4330fa4c4c6e4d84b9ee0667efb4082 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Thu, 24 Jan 2019 10:48:14 -0800 Subject: [PATCH 205/732] Remove print statements in import --- api/src/relation_engine_server/utils/bulk_import.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/api/src/relation_engine_server/utils/bulk_import.py b/api/src/relation_engine_server/utils/bulk_import.py index 516af831..6b1a5da5 100644 --- a/api/src/relation_engine_server/utils/bulk_import.py +++ b/api/src/relation_engine_server/utils/bulk_import.py @@ -19,11 +19,10 @@ def bulk_import(query_params): with tempfile.NamedTemporaryFile(mode='a', delete=False) as temp_fd: # temp_fd is closed and deleted when the context ends for line in flask.request.stream: - print('line', line) json_line = json.loads(line) jsonschema.validate(json_line, schema) json_line = _write_edge_key(json_line) - print(temp_fd.write(json.dumps(json_line) + '\n')) + temp_fd.write(json.dumps(json_line) + '\n') resp_text = import_from_file(temp_fd.name, query_params) os.remove(temp_fd.name) return resp_text From 9a9cab4f249eaa592c12af00925e4e7465fd2867 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Thu, 24 Jan 2019 12:57:52 -0800 Subject: [PATCH 206/732] Add json endpoint for viewing non-private config data --- api/src/relation_engine_server/server.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/api/src/relation_engine_server/server.py b/api/src/relation_engine_server/server.py index 09a7e6d4..2be8b8cf 100644 --- a/api/src/relation_engine_server/server.py +++ b/api/src/relation_engine_server/server.py @@ -7,7 +7,7 @@ from jsonschema.exceptions import ValidationError from .exceptions import MissingHeader, UnauthorizedAccess -from .utils import arango_client, spec_loader, auth, bulk_import, pull_spec +from .utils import arango_client, spec_loader, auth, bulk_import, pull_spec, config app = flask.Flask(__name__) app.config['DEBUG'] = os.environ.get('FLASK_DEBUG', True) @@ -32,6 +32,19 @@ def root(): }) +@app.route('/config', methods=['GET']) +def show_config(): + conf = config.get_config() + return flask.jsonify({ + 'auth_url': conf['auth_url'], + 'workspace_url': conf['workspace_url'], + 'kbase_endpoint': conf['kbase_endpoint'], + 'db_url': conf['db_url'], + 'db_name': conf['db_name'], + 'spec_url': conf['spec_url'] + }) + + @app.route('/api/views', methods=['GET']) def show_views(): """ From af46336ba628951a502fa72abaad1c3cbbde317c Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Thu, 24 Jan 2019 13:35:55 -0800 Subject: [PATCH 207/732] Add a bare bones test for the config endpoint --- api/src/test/test_api.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/api/src/test/test_api.py b/api/src/test/test_api.py index 03d81ccd..59b81d3a 100644 --- a/api/src/test/test_api.py +++ b/api/src/test/test_api.py @@ -68,6 +68,16 @@ def test_root(self): self.assertTrue(resp['commit_hash']) self.assertTrue(resp['repo_url']) + def test_config(self): + """Test config fetch.""" + resp = requests.get(URL + '/config').json() + self.assertTrue(len(resp['auth_url'])) + self.assertTrue(len(resp['workspace_url'])) + self.assertTrue(len(resp['kbase_endpoint'])) + self.assertTrue(len(resp['db_url'])) + self.assertTrue(len(resp['db_name'])) + self.assertTrue(len(resp['spec_url'])) + def test_update_specs(self): """Test the endpoint that triggers an update on the specs.""" resp = requests.get( From 2729603acd9418a52ce95792d10e2e58b21c9e16 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Thu, 24 Jan 2019 16:42:13 -0800 Subject: [PATCH 208/732] Add the uniqueVertices option to prevent circular queries in the wsprov views --- spec/views/wsprov_fetch_copies.aql | 2 +- spec/views/wsprov_fetch_linked_objects.aql | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/views/wsprov_fetch_copies.aql b/spec/views/wsprov_fetch_copies.aql index 692662f9..23e37a80 100644 --- a/spec/views/wsprov_fetch_copies.aql +++ b/spec/views/wsprov_fetch_copies.aql @@ -9,7 +9,7 @@ with wsprov_object let obj_id = CONCAT('wsprov_object/', @obj_key) -for copy in 1..10 any obj_id wsprov_copied_into +for copy in 1..10 any obj_id wsprov_copied_into options {uniqueVertices: 'global', bfs: true} filter copy.is_public || (copy.workspace_id IN @ws_ids) limit @copy_limit collect parent_id = obj_id into copies = copy diff --git a/spec/views/wsprov_fetch_linked_objects.aql b/spec/views/wsprov_fetch_linked_objects.aql index 4c9806ca..6f93fbbb 100644 --- a/spec/views/wsprov_fetch_linked_objects.aql +++ b/spec/views/wsprov_fetch_linked_objects.aql @@ -8,7 +8,7 @@ for o in wsprov_object filter o._key in @obj_keys - for link in 1..10 any o wsprov_links + for link in 1..10 any o wsprov_links options {uniqueVertices: 'global', bfs: true} filter link.is_public || link.workspace_id IN @ws_ids limit @link_limit collect parent_id = o._id into links = link From 1cc52fdb24283eb03f5f15e9fbfd2c1560e8f697 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Fri, 25 Jan 2019 10:22:24 -0800 Subject: [PATCH 209/732] Fix path --- api/src/relation_engine_server/utils/auth.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/src/relation_engine_server/utils/auth.py b/api/src/relation_engine_server/utils/auth.py index 6f4f4689..3e269103 100644 --- a/api/src/relation_engine_server/utils/auth.py +++ b/api/src/relation_engine_server/utils/auth.py @@ -52,7 +52,7 @@ def get_workspace_ids(auth_token): if not auth_token: return [] # anonymous users config = get_config() - ws_url = config['workspace_url'] + '/api/V2' + ws_url = config['workspace_url'] # Make an admin request to the workspace (command is 'listWorkspaceIds') payload = { 'method': 'Workspace.list_workspace_ids', From 27076db1ee27258f8496690991621aa8e2bc0456 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Fri, 25 Jan 2019 10:59:47 -0800 Subject: [PATCH 210/732] Fix endpoints --- api/src/test/mock_workspace/endpoints.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/api/src/test/mock_workspace/endpoints.json b/api/src/test/mock_workspace/endpoints.json index 56d917f2..78de5656 100644 --- a/api/src/test/mock_workspace/endpoints.json +++ b/api/src/test/mock_workspace/endpoints.json @@ -1,7 +1,7 @@ [ { "methods": ["POST"], - "path": "/api/V2", + "path": "/", "headers": {"Authorization": "valid_token"}, "body": { "method": "Workspace.list_workspace_ids", @@ -23,7 +23,7 @@ }, { "methods": ["POST"], - "path": "/api/V2", + "path": "/", "headers": {"Authorization": "invalid_token"}, "body": { "method": "Workspace.list_workspace_ids", @@ -45,7 +45,7 @@ }, { "methods": ["POST"], - "path": "/api/V2", + "path": "/", "headers": {"Authorization": "admin_token"}, "body": { "method": "Workspace.list_workspace_ids", From 4a65a36a43582deeaa9517be24001d73414b12a9 Mon Sep 17 00:00:00 2001 From: JamesJeffryes Date: Tue, 29 Jan 2019 16:29:46 -0600 Subject: [PATCH 211/732] New view for collecting referencing type counts --- spec/views/list_referencing_type_counts.aql | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 spec/views/list_referencing_type_counts.aql diff --git a/spec/views/list_referencing_type_counts.aql b/spec/views/list_referencing_type_counts.aql new file mode 100644 index 00000000..6ff744c1 --- /dev/null +++ b/spec/views/list_referencing_type_counts.aql @@ -0,0 +1,21 @@ +// Fetch the counts of a ws_objects in the RE that is linked to a wsprov_object +// Args: +// ws_ids - array of private workspace ids the user has access to (autofilled by RE-API) +// key - key of the object to start from +// is_private - if present, limit to objects in workspaces that a user has access to +// is_public - if present, limit to objects in public workspaces +// *** if both is_private and is_public are true this will be treated as an OR *** +// owners - if present, limit to objects with owner in list +// simplify_type - if true, strip out the module and version before collecting + +WITH wsprov_object +FOR v IN 1..10 + INBOUND CONCAT('wsprov_object/', @key) wsprov_links + OPTIONS {'uniqueVertices': 'global', 'bfs':true} + // If both is_private and is_public, return if either is true + FILTER (@is_private && @is_public) ? (v.is_public || v.workspace_id IN @ws_ids) : + (!@is_private || v.workspace_id IN @ws_ids) && (!@is_public || v.is_public) + FILTER (!@owners || v.owner IN @owners) + LET ws_type = @simplify_type ? SPLIT(SPLIT(v.ws_type, '-', 1)[0], '.')[1] : v.ws_type + COLLECT type = ws_type WITH COUNT INTO type_count + RETURN {type, type_count} \ No newline at end of file From 7cf5cfa36720ca18284e42ce57df4c8950e25079 Mon Sep 17 00:00:00 2001 From: JamesJeffryes Date: Wed, 30 Jan 2019 09:39:22 -0600 Subject: [PATCH 212/732] allow users to pass a batch_size parameter with queries --- api/src/relation_engine_server/server.py | 17 ++++++++++------- .../utils/arango_client.py | 7 ++++--- api/src/test/test_api.py | 16 ++++++++-------- 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/api/src/relation_engine_server/server.py b/api/src/relation_engine_server/server.py index 2be8b8cf..5cad116f 100644 --- a/api/src/relation_engine_server/server.py +++ b/api/src/relation_engine_server/server.py @@ -67,23 +67,26 @@ def run_query(): # Don't allow the user to set the special 'ws_ids' field json_body['ws_ids'] = [] auth_token = auth.get_auth_header() - is_adhoc_query = 'query' in json_body - # Authorize for RE_ADMIN before fetching any workspace IDs - if is_adhoc_query: - auth.require_auth_token(roles=['RE_ADMIN']) # Fetch any authorized workspace IDs using a KBase auth token, if present json_body['ws_ids'] = auth.get_workspace_ids(auth_token) - if is_adhoc_query: + # fetch number of documents to return + batch_size = int(flask.request.args.get('batch_size', 100)) + if 'query' in json_body: # Run an adhoc query for a sysadmin + auth.require_auth_token(roles=['RE_ADMIN']) query_text = json_body['query'] del json_body['query'] - resp_body = arango_client.run_query(query_text=query_text, bind_vars=json_body) + resp_body = arango_client.run_query(query_text=query_text, + bind_vars=json_body, + batch_size=batch_size) return flask.jsonify(resp_body) if 'view' in flask.request.args: # Run a query from a view name view_name = flask.request.args['view'] view_source = spec_loader.get_view(view_name) - resp_body = arango_client.run_query(query_text=view_source, bind_vars=json_body) + resp_body = arango_client.run_query(query_text=view_source, + bind_vars=json_body, + batch_size=batch_size) return flask.jsonify(resp_body) if 'cursor_id' in flask.request.args: # Run a query from a cursor ID diff --git a/api/src/relation_engine_server/utils/arango_client.py b/api/src/relation_engine_server/utils/arango_client.py index 6fcda524..03875ace 100644 --- a/api/src/relation_engine_server/utils/arango_client.py +++ b/api/src/relation_engine_server/utils/arango_client.py @@ -22,12 +22,12 @@ def server_status(): return 'unknown_failure' -def run_query(query_text=None, cursor_id=None, bind_vars={}): +def run_query(query_text=None, cursor_id=None, bind_vars=None, batch_size=100): """Run a query using the arangodb http api. Can return a cursor to get more results.""" config = get_config() url = config['db_url'] + '/_api/cursor' req_json = { - 'batchSize': 100, + 'batchSize': min(5000, batch_size), 'memoryLimit': 16000000000 # 16gb } if cursor_id: @@ -36,8 +36,9 @@ def run_query(query_text=None, cursor_id=None, bind_vars={}): else: method = 'POST' req_json['count'] = True - req_json['bindVars'] = bind_vars req_json['query'] = query_text + if bind_vars: + req_json['bindVars'] = bind_vars resp = requests.request( method, diff --git a/api/src/test/test_api.py b/api/src/test/test_api.py index 59b81d3a..6d45063b 100644 --- a/api/src/test/test_api.py +++ b/api/src/test/test_api.py @@ -278,25 +278,25 @@ def test_admin_query_invalid_auth(self): self.assertEqual(resp['error'], '403 - Unauthorized') def test_query_with_cursor(self): - """Test getting more data via a query cursor.""" - save_test_docs(count=200) + """Test getting more data via a query cursor and setting batch size.""" + save_test_docs(count=20) resp = requests.post( URL + '/api/query_results', - params={'view': 'list_test_vertices'} + params={'view': 'list_test_vertices', 'batch_size': 10} ).json() - cursor_id = resp['cursor_id'] self.assertTrue(resp['cursor_id']) self.assertEqual(resp['has_more'], True) - self.assertEqual(resp['count'], 200) - self.assertTrue(len(resp['results']), 100) + self.assertEqual(resp['count'], 20) + self.assertTrue(len(resp['results']), 10) + cursor_id = resp['cursor_id'] resp = requests.post( URL + '/api/query_results', params={'cursor_id': cursor_id} ).json() - self.assertEqual(resp['count'], 200) + self.assertEqual(resp['count'], 20) self.assertEqual(resp['has_more'], False) self.assertEqual(resp['cursor_id'], None) - self.assertTrue(len(resp['results']), 100) + self.assertTrue(len(resp['results']), 10) # Try to get the same cursor again resp = requests.post( URL + '/api/query_results', From face357922004ce766e72fe8d8b3321718bdc114 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 30 Jan 2019 09:43:33 -0800 Subject: [PATCH 213/732] Upgrade to arango 3.4 for tests --- api/docker-compose.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/docker-compose.yaml b/api/docker-compose.yaml index 144727fa..202a0990 100644 --- a/api/docker-compose.yaml +++ b/api/docker-compose.yaml @@ -27,7 +27,7 @@ services: # For running (and testing against) ArangoDB arangodb: - image: arangodb:3.3.19 + image: arangodb:3.4 ports: - 8529:8529 environment: From 2beeebb79b1e265bed6427bbd7e231a6bc19b073 Mon Sep 17 00:00:00 2001 From: JamesJeffryes Date: Wed, 30 Jan 2019 14:35:12 -0600 Subject: [PATCH 214/732] New views --- spec/views/wsprov_fetch_linked_objects.aql | 23 +++++++++++++------ .../wsprov_fetch_paths_between_objects.aql | 19 +++++++++++++++ ...> wsprov_list_referencing_type_counts.aql} | 0 3 files changed, 35 insertions(+), 7 deletions(-) create mode 100644 spec/views/wsprov_fetch_paths_between_objects.aql rename spec/views/{list_referencing_type_counts.aql => wsprov_list_referencing_type_counts.aql} (100%) diff --git a/spec/views/wsprov_fetch_linked_objects.aql b/spec/views/wsprov_fetch_linked_objects.aql index 6f93fbbb..77cc8408 100644 --- a/spec/views/wsprov_fetch_linked_objects.aql +++ b/spec/views/wsprov_fetch_linked_objects.aql @@ -4,12 +4,21 @@ // Args: // ws_ids - array of private workspace ids the user has access to // obj_keys - wsprov_object key to find links for +// is_private - if present, limit to objects in workspaces that a user has access to +// is_public - if present, limit to objects in public workspaces +// *** if both is_private and is_public are true this will be treated as an OR *** +// types - simplified workspace types to return (e.g. Genome, Assembly) // link_limit - number of link results (10-20 recommended) -for o in wsprov_object - filter o._key in @obj_keys - for link in 1..10 any o wsprov_links options {uniqueVertices: 'global', bfs: true} - filter link.is_public || link.workspace_id IN @ws_ids - limit @link_limit - collect parent_id = o._id into links = link - return { links, parent_id } +FOR o IN wsprov_object + FILTER o._key in @obj_keys + FOR v IN 1..10 ANY o wsprov_links + OPTIONS {uniqueVertices: 'global', bfs: true} + LET simple_type = SPLIT(SPLIT(v.ws_type, '-', 1)[0], '.')[1] + FILTER (@is_private && @is_public) ? (v.is_public || v.workspace_id IN @ws_ids) : + (!@is_private || v.workspace_id IN @ws_ids) && (!@is_public || v.is_public) + FILTER (!@types || simple_type IN @types) + LIMIT @link_limit + COLLECT parent_id = o._id into objects = v + + RETURN { objects, parent_id } \ No newline at end of file diff --git a/spec/views/wsprov_fetch_paths_between_objects.aql b/spec/views/wsprov_fetch_paths_between_objects.aql new file mode 100644 index 00000000..04506b71 --- /dev/null +++ b/spec/views/wsprov_fetch_paths_between_objects.aql @@ -0,0 +1,19 @@ +// Fetch the counts of a ws_objects in the RE that is linked to a wsprov_object +// Args: +// ws_ids - array of private workspace ids the user has access to (autofilled by RE-API) +// start_key - key of the object to start from +// end_key - key of the object to terminate with +// is_private - if present, limit to objects in workspaces that a user has access to +// is_public - if present, limit to objects in public workspaces +// *** if both is_private and is_public are true this will be treated as an OR *** +// max_depth - longest path to explore + +WITH wsprov_object +FOR v, e, path IN 1..@max_depth + ANY CONCAT('wsprov_object/', @start_key) wsprov_links + OPTIONS {'uniqueVertices': 'path', 'uniqueEdges': 'path'} + // If both is_private and is_public, return if either is true + FILTER (@is_private && @is_public) ? (v.is_public || v.workspace_id IN @ws_ids) : + (!@is_private || v.workspace_id IN @ws_ids) && (!@is_public || v.is_public) + filter v._key == @end_key + RETURN path \ No newline at end of file diff --git a/spec/views/list_referencing_type_counts.aql b/spec/views/wsprov_list_referencing_type_counts.aql similarity index 100% rename from spec/views/list_referencing_type_counts.aql rename to spec/views/wsprov_list_referencing_type_counts.aql From df87766d51b734ef91caa3e754b6d3c61e3077e8 Mon Sep 17 00:00:00 2001 From: JamesJeffryes Date: Wed, 30 Jan 2019 16:59:11 -0600 Subject: [PATCH 215/732] jay's suggestions --- spec/views/wsprov_fetch_copies.aql | 22 ++++++++------- spec/views/wsprov_fetch_linked_objects.aql | 27 +++++++------------ .../wsprov_fetch_paths_between_objects.aql | 11 ++++---- .../wsprov_list_referencing_type_counts.aql | 14 +++++----- 4 files changed, 34 insertions(+), 40 deletions(-) diff --git a/spec/views/wsprov_fetch_copies.aql b/spec/views/wsprov_fetch_copies.aql index 23e37a80..3eded013 100644 --- a/spec/views/wsprov_fetch_copies.aql +++ b/spec/views/wsprov_fetch_copies.aql @@ -1,16 +1,18 @@ // For a given object, fetch all the objects that it has been copied from or // to, no matter how many nested times (copies of copies of copies, forward or backward) // Also returns all linked objects of those copies of any nested level. -// Each sublink result has a 'parent_id' point to the copy that it is linked from. // Args: // ws_ids - array of private workspace ids the user has access to -// obj_key - key of the object (eg "1:2:3") -// copy_limit - max results of copies (recommended 10-20) +// obj_keys - wsprov_object key to find links for +// show_private - limit to objects in workspaces that a user has access to +// show_private - limit to objects in public workspaces +// *** if both show_private and show_private are true this will be treated as an OR *** -with wsprov_object -let obj_id = CONCAT('wsprov_object/', @obj_key) -for copy in 1..10 any obj_id wsprov_copied_into options {uniqueVertices: 'global', bfs: true} - filter copy.is_public || (copy.workspace_id IN @ws_ids) - limit @copy_limit - collect parent_id = obj_id into copies = copy - return distinct { copies, parent_id } +WITH wsprov_object +LET obj_id = CONCAT('wsprov_object/', @obj_key) +FOR v IN 1..10 ANY obj_id wsprov_copied_into + OPTIONS {uniqueVertices: 'global', bfs: true} + LET simple_type = SPLIT(SPLIT(v.ws_type, '-', 1)[0], '.')[1] + FILTER (@show_private && @show_public) ? (v.is_public || v.workspace_id IN @ws_ids) : + (!@show_private || v.workspace_id IN @ws_ids) && (!@show_public || v.is_public) + RETURN v \ No newline at end of file diff --git a/spec/views/wsprov_fetch_linked_objects.aql b/spec/views/wsprov_fetch_linked_objects.aql index 77cc8408..53b3b50d 100644 --- a/spec/views/wsprov_fetch_linked_objects.aql +++ b/spec/views/wsprov_fetch_linked_objects.aql @@ -1,24 +1,17 @@ -// Find all linked objects to a given set of objects -// Returns links of level 1, plus all child links of any nested level ("sublinks") -// Each sublink has a "parent_id" key that points to its parent object +// Find all linked objects to a object // Args: // ws_ids - array of private workspace ids the user has access to // obj_keys - wsprov_object key to find links for -// is_private - if present, limit to objects in workspaces that a user has access to -// is_public - if present, limit to objects in public workspaces -// *** if both is_private and is_public are true this will be treated as an OR *** +// show_private - limit to objects in workspaces that a user has access to +// show_private - limit to objects in public workspaces +// *** if both show_private and show_private are true this will be treated as an OR *** // types - simplified workspace types to return (e.g. Genome, Assembly) -// link_limit - number of link results (10-20 recommended) - -FOR o IN wsprov_object - FILTER o._key in @obj_keys - FOR v IN 1..10 ANY o wsprov_links +WITH wsprov_object +LET obj_id = CONCAT('wsprov_object/', @obj_key) +FOR v IN 1..10 ANY obj_id wsprov_links OPTIONS {uniqueVertices: 'global', bfs: true} LET simple_type = SPLIT(SPLIT(v.ws_type, '-', 1)[0], '.')[1] - FILTER (@is_private && @is_public) ? (v.is_public || v.workspace_id IN @ws_ids) : - (!@is_private || v.workspace_id IN @ws_ids) && (!@is_public || v.is_public) + FILTER (@show_private && @show_public) ? (v.is_public || v.workspace_id IN @ws_ids) : + (!@show_private || v.workspace_id IN @ws_ids) && (!@show_public || v.is_public) FILTER (!@types || simple_type IN @types) - LIMIT @link_limit - COLLECT parent_id = o._id into objects = v - - RETURN { objects, parent_id } \ No newline at end of file + RETURN v \ No newline at end of file diff --git a/spec/views/wsprov_fetch_paths_between_objects.aql b/spec/views/wsprov_fetch_paths_between_objects.aql index 04506b71..919fe026 100644 --- a/spec/views/wsprov_fetch_paths_between_objects.aql +++ b/spec/views/wsprov_fetch_paths_between_objects.aql @@ -3,17 +3,16 @@ // ws_ids - array of private workspace ids the user has access to (autofilled by RE-API) // start_key - key of the object to start from // end_key - key of the object to terminate with -// is_private - if present, limit to objects in workspaces that a user has access to -// is_public - if present, limit to objects in public workspaces -// *** if both is_private and is_public are true this will be treated as an OR *** +// show_private - if present, limit to objects in workspaces that a user has access to +// show_public - if present, limit to objects in public workspaces +// *** if both show_private and show_private are true this will be treated as an OR *** // max_depth - longest path to explore WITH wsprov_object FOR v, e, path IN 1..@max_depth ANY CONCAT('wsprov_object/', @start_key) wsprov_links OPTIONS {'uniqueVertices': 'path', 'uniqueEdges': 'path'} - // If both is_private and is_public, return if either is true - FILTER (@is_private && @is_public) ? (v.is_public || v.workspace_id IN @ws_ids) : - (!@is_private || v.workspace_id IN @ws_ids) && (!@is_public || v.is_public) + FILTER (@show_private && @show_public) ? (v.is_public || v.workspace_id IN @ws_ids) : + (!@show_private || v.workspace_id IN @ws_ids) && (!@show_public || v.is_public) filter v._key == @end_key RETURN path \ No newline at end of file diff --git a/spec/views/wsprov_list_referencing_type_counts.aql b/spec/views/wsprov_list_referencing_type_counts.aql index 6ff744c1..680a0c43 100644 --- a/spec/views/wsprov_list_referencing_type_counts.aql +++ b/spec/views/wsprov_list_referencing_type_counts.aql @@ -2,19 +2,19 @@ // Args: // ws_ids - array of private workspace ids the user has access to (autofilled by RE-API) // key - key of the object to start from -// is_private - if present, limit to objects in workspaces that a user has access to -// is_public - if present, limit to objects in public workspaces -// *** if both is_private and is_public are true this will be treated as an OR *** -// owners - if present, limit to objects with owner in list +// show_private - if present, limit to objects in workspaces that a user has access to +// show_public - if present, limit to objects in public workspaces +// *** if both show_private and show_private are true this will be treated as an OR *** +// owners - if truthy, limit to objects with owner in list // simplify_type - if true, strip out the module and version before collecting WITH wsprov_object FOR v IN 1..10 INBOUND CONCAT('wsprov_object/', @key) wsprov_links OPTIONS {'uniqueVertices': 'global', 'bfs':true} - // If both is_private and is_public, return if either is true - FILTER (@is_private && @is_public) ? (v.is_public || v.workspace_id IN @ws_ids) : - (!@is_private || v.workspace_id IN @ws_ids) && (!@is_public || v.is_public) + // If both show_private and show_public, return if either is true + FILTER (@show_private && @show_public) ? (v.is_public || v.workspace_id IN @ws_ids) : + (!@show_private || v.workspace_id IN @ws_ids) && (!@show_public || v.is_public) FILTER (!@owners || v.owner IN @owners) LET ws_type = @simplify_type ? SPLIT(SPLIT(v.ws_type, '-', 1)[0], '.')[1] : v.ws_type COLLECT type = ws_type WITH COUNT INTO type_count From 9dda14f51d6bc5a95f1c18d9cbed3c5aeaf1ed3a Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Thu, 31 Jan 2019 10:14:50 -0800 Subject: [PATCH 216/732] Fix typo in aql comment --- spec/views/wsprov_fetch_copies.aql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/views/wsprov_fetch_copies.aql b/spec/views/wsprov_fetch_copies.aql index 3eded013..6e383124 100644 --- a/spec/views/wsprov_fetch_copies.aql +++ b/spec/views/wsprov_fetch_copies.aql @@ -3,7 +3,7 @@ // Also returns all linked objects of those copies of any nested level. // Args: // ws_ids - array of private workspace ids the user has access to -// obj_keys - wsprov_object key to find links for +// obj_key - wsprov_object key to find links for // show_private - limit to objects in workspaces that a user has access to // show_private - limit to objects in public workspaces // *** if both show_private and show_private are true this will be treated as an OR *** @@ -15,4 +15,4 @@ FOR v IN 1..10 ANY obj_id wsprov_copied_into LET simple_type = SPLIT(SPLIT(v.ws_type, '-', 1)[0], '.')[1] FILTER (@show_private && @show_public) ? (v.is_public || v.workspace_id IN @ws_ids) : (!@show_private || v.workspace_id IN @ws_ids) && (!@show_public || v.is_public) - RETURN v \ No newline at end of file + RETURN v From 50cb1d72afab741a1437b8546b2d5de6b658cacb Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Mon, 4 Feb 2019 10:50:46 -0800 Subject: [PATCH 217/732] Tweak the script to only have the --reload flag if DEVELOPMENT=1 --- api/docker-compose.yaml | 5 +++-- api/scripts/start_server.sh | 9 +++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/api/docker-compose.yaml b/api/docker-compose.yaml index 202a0990..3daa7cb2 100644 --- a/api/docker-compose.yaml +++ b/api/docker-compose.yaml @@ -15,6 +15,9 @@ services: volumes: - ${PWD}:/app environment: + - DEVELOPMENT=1 + - FLASK_ENV=development + - FLASK_DEBUG=1 - KBASE_AUTH_URL=http://auth:5000 - KBASE_WORKSPACE_URL=http://workspace:5000 - PYTHONUNBUFFERED=true @@ -22,8 +25,6 @@ services: - DB_URL=http://arangodb:8529 - DB_USER=root - DB_PASS=password - - FLASK_ENV=development - - FLASK_DEBUG=1 # For running (and testing against) ArangoDB arangodb: diff --git a/api/scripts/start_server.sh b/api/scripts/start_server.sh index 4c6cce8c..9b28288a 100644 --- a/api/scripts/start_server.sh +++ b/api/scripts/start_server.sh @@ -1,5 +1,4 @@ #!/bin/sh - set -e # Set the number of gevent workers to number of cores * 2 + 1 @@ -8,4 +7,10 @@ calc_workers="$(($(nproc) * 2 + 1))" # Use the WORKERS environment variable, if present workers=${WORKERS:-$calc_workers} -gunicorn --worker-class gevent --timeout 1800 --workers $workers -b :5000 --reload src.relation_engine_server.server:app +gunicorn \ + --worker-class gevent \ + --timeout 1800 \ + --workers $workers \ + --bind :5000 \ + ${DEVELOPMENT:+"--reload"} \ + src.relation_engine_server.server:app From e99768d311a267b816420382fd3633537ba86b26 Mon Sep 17 00:00:00 2001 From: JamesJeffryes Date: Mon, 4 Feb 2019 18:34:17 -0600 Subject: [PATCH 218/732] minimal changes to avoid taxa --- spec/views/wsprov_fetch_copies.aql | 3 ++- spec/views/wsprov_fetch_linked_objects.aql | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/spec/views/wsprov_fetch_copies.aql b/spec/views/wsprov_fetch_copies.aql index 6e383124..75b5a2fb 100644 --- a/spec/views/wsprov_fetch_copies.aql +++ b/spec/views/wsprov_fetch_copies.aql @@ -10,9 +10,10 @@ WITH wsprov_object LET obj_id = CONCAT('wsprov_object/', @obj_key) -FOR v IN 1..10 ANY obj_id wsprov_copied_into +FOR v, e, p IN 1..10 ANY obj_id wsprov_copied_into OPTIONS {uniqueVertices: 'global', bfs: true} LET simple_type = SPLIT(SPLIT(v.ws_type, '-', 1)[0], '.')[1] FILTER (@show_private && @show_public) ? (v.is_public || v.workspace_id IN @ws_ids) : (!@show_private || v.workspace_id IN @ws_ids) && (!@show_public || v.is_public) + FILTER p.vertices[*].ws_type != "KBaseGenomeAnnotations.Taxon-1.0" RETURN v diff --git a/spec/views/wsprov_fetch_linked_objects.aql b/spec/views/wsprov_fetch_linked_objects.aql index 53b3b50d..75ccfae7 100644 --- a/spec/views/wsprov_fetch_linked_objects.aql +++ b/spec/views/wsprov_fetch_linked_objects.aql @@ -8,10 +8,11 @@ // types - simplified workspace types to return (e.g. Genome, Assembly) WITH wsprov_object LET obj_id = CONCAT('wsprov_object/', @obj_key) -FOR v IN 1..10 ANY obj_id wsprov_links +FOR v, e, p IN 1..10 ANY obj_id wsprov_links OPTIONS {uniqueVertices: 'global', bfs: true} LET simple_type = SPLIT(SPLIT(v.ws_type, '-', 1)[0], '.')[1] FILTER (@show_private && @show_public) ? (v.is_public || v.workspace_id IN @ws_ids) : (!@show_private || v.workspace_id IN @ws_ids) && (!@show_public || v.is_public) FILTER (!@types || simple_type IN @types) + FILTER p.vertices[*].ws_type != "KBaseGenomeAnnotations.Taxon-1.0" RETURN v \ No newline at end of file From d578f3c9e0b169f7749d79b88d90e0e1438f72a0 Mon Sep 17 00:00:00 2001 From: JamesJeffryes Date: Tue, 5 Feb 2019 11:46:09 -0600 Subject: [PATCH 219/732] made a guincorn_conf so that specs can be downloaded. Moves most config there as well --- api/scripts/start_server.sh | 12 +--------- .../utils/gunicorn_conf.py | 24 +++++++++++++++++++ 2 files changed, 25 insertions(+), 11 deletions(-) create mode 100644 api/src/relation_engine_server/utils/gunicorn_conf.py diff --git a/api/scripts/start_server.sh b/api/scripts/start_server.sh index 9b28288a..6e1a61f6 100644 --- a/api/scripts/start_server.sh +++ b/api/scripts/start_server.sh @@ -1,16 +1,6 @@ #!/bin/sh set -e -# Set the number of gevent workers to number of cores * 2 + 1 -# See: http://docs.gunicorn.org/en/stable/design.html#how-many-workers -calc_workers="$(($(nproc) * 2 + 1))" -# Use the WORKERS environment variable, if present -workers=${WORKERS:-$calc_workers} - gunicorn \ - --worker-class gevent \ - --timeout 1800 \ - --workers $workers \ - --bind :5000 \ - ${DEVELOPMENT:+"--reload"} \ + --config src/relation_engine_server/utils/gunicorn_conf.py \ src.relation_engine_server.server:app diff --git a/api/src/relation_engine_server/utils/gunicorn_conf.py b/api/src/relation_engine_server/utils/gunicorn_conf.py new file mode 100644 index 00000000..a32b2b69 --- /dev/null +++ b/api/src/relation_engine_server/utils/gunicorn_conf.py @@ -0,0 +1,24 @@ +# Gunicorn configuration file. +import os +import multiprocessing +from src.relation_engine_server.utils import pull_spec + +# server +bind = ':5000' + +# workers +worker_class = 'gevent' +timeout = 1800 +# See: http://docs.gunicorn.org/en/stable/design.html#how-many-workers +if os.environ.get("WORKERS"): + workers = int(os.environ["WORKERS"]) +else: + workers = multiprocessing.cpu_count() * 2 + 1 + +if os.environ.get("DEVELOPMENT"): + reload = True + + +def on_starting(server): + print("Pulling specs") + pull_spec.download_latest(init_collections=False) From 89227371e8ec39ce2b1c4ff94faef8a8e298f728 Mon Sep 17 00:00:00 2001 From: James Jeffryes Date: Tue, 5 Feb 2019 12:17:59 -0600 Subject: [PATCH 220/732] Revert "Load specs when service is launched" --- api/scripts/start_server.sh | 12 +++++++++- .../utils/gunicorn_conf.py | 24 ------------------- 2 files changed, 11 insertions(+), 25 deletions(-) delete mode 100644 api/src/relation_engine_server/utils/gunicorn_conf.py diff --git a/api/scripts/start_server.sh b/api/scripts/start_server.sh index 6e1a61f6..9b28288a 100644 --- a/api/scripts/start_server.sh +++ b/api/scripts/start_server.sh @@ -1,6 +1,16 @@ #!/bin/sh set -e +# Set the number of gevent workers to number of cores * 2 + 1 +# See: http://docs.gunicorn.org/en/stable/design.html#how-many-workers +calc_workers="$(($(nproc) * 2 + 1))" +# Use the WORKERS environment variable, if present +workers=${WORKERS:-$calc_workers} + gunicorn \ - --config src/relation_engine_server/utils/gunicorn_conf.py \ + --worker-class gevent \ + --timeout 1800 \ + --workers $workers \ + --bind :5000 \ + ${DEVELOPMENT:+"--reload"} \ src.relation_engine_server.server:app diff --git a/api/src/relation_engine_server/utils/gunicorn_conf.py b/api/src/relation_engine_server/utils/gunicorn_conf.py deleted file mode 100644 index a32b2b69..00000000 --- a/api/src/relation_engine_server/utils/gunicorn_conf.py +++ /dev/null @@ -1,24 +0,0 @@ -# Gunicorn configuration file. -import os -import multiprocessing -from src.relation_engine_server.utils import pull_spec - -# server -bind = ':5000' - -# workers -worker_class = 'gevent' -timeout = 1800 -# See: http://docs.gunicorn.org/en/stable/design.html#how-many-workers -if os.environ.get("WORKERS"): - workers = int(os.environ["WORKERS"]) -else: - workers = multiprocessing.cpu_count() * 2 + 1 - -if os.environ.get("DEVELOPMENT"): - reload = True - - -def on_starting(server): - print("Pulling specs") - pull_spec.download_latest(init_collections=False) From f34318f6978d8e580700e5cd6c421c9f764b33aa Mon Sep 17 00:00:00 2001 From: JamesJeffryes Date: Tue, 5 Feb 2019 12:43:00 -0600 Subject: [PATCH 221/732] update gene to reaction query --- .../list_genes_for_similar_reactions.aql | 51 ++++++++++--------- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/spec/views/list_genes_for_similar_reactions.aql b/spec/views/list_genes_for_similar_reactions.aql index cb7594c8..33963cb4 100644 --- a/spec/views/list_genes_for_similar_reactions.aql +++ b/spec/views/list_genes_for_similar_reactions.aql @@ -5,32 +5,37 @@ // df_sim - minimum difference fingerprint similarity score // exclude_self - if true, don't include the query reactions genes -let ws_ids = @ws_ids - -let similar_rxn_ids = ( -for e in rxn_similar_to_reaction - filter e.sf_similarity >= @sf_sim - filter e.df_similarity >= @df_sim - filter e._to == @rid || e._from == @rid - return e._to == @rid ? e._from : e._to -) -let self = @exclude_self ? "no_self" : @rid -let similar_complex_ids = ( -for e in rxn_reaction_within_complex - filter e._from in similar_rxn_ids || e._from == self - return e._to +WITH rxn_reaction +LET ws_ids = @ws_ids +LET start = @exclude_self ? 1 : 0 +LET rxns = ( + FOR v, e IN start..1 + ANY @rid rxn_similar_to_reaction + OPTIONS {uniqueVertices: "global", bfs: true} + FILTER !e || e.sf_similarity >= @sf_sim + FILTER !e || e.df_similarity >= @df_sim + RETURN {id: v._id, key: v._key, name: v.name, definition: v.definition, "structural similarity": e.sf_similarity, "difference similarity": e.df_similarity} ) +LET rxn_ids = rxns[*].id -let genes = FLATTEN( -for c in rxn_gene_complex - filter c._id IN similar_complex_ids - return c.genes +LET rxn_gene_links = ( + FOR e in rxn_reaction_within_complex + FILTER e._from in rxn_ids + LET linked_gene_ids = FLATTEN( + FOR c in rxn_gene_complex + FILTER c._id == e._to + RETURN c.genes + ) + COLLECT rxn_id = e._from INTO groups KEEP linked_gene_ids + RETURN {rxn_id: rxn_id, linked_gene_ids: UNIQUE(FLATTEN(groups[*].linked_gene_ids))} ) -let sequences = ( -for g in ncbi_gene - filter g._key IN genes - return {key: g._key, seq: g.protein_translation} +LET gene_ids = UNIQUE(FLATTEN(rxn_gene_links[*].linked_gene_ids)) + +LET genes = ( + FOR g in ncbi_gene + FILTER g._key IN gene_ids + RETURN {key: g._key, product: g.product, function: CONCAT_SEPARATOR(', ', g.functions), sequence: g.protein_translation} ) -return {count: COUNT(sequences), sequences: sequences} +RETURN {rxns: rxns, rxn_gene_links: rxn_gene_links, genes: genes} From 0b3883daecbc8c584764f1ffd2fd345ecd0f812b Mon Sep 17 00:00:00 2001 From: JamesJeffryes Date: Fri, 1 Feb 2019 17:26:35 -0600 Subject: [PATCH 222/732] return narrative count too (cherry picked from commit fbb7360) --- .../wsprov_list_referencing_type_counts.aql | 34 +++++++++++++------ 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/spec/views/wsprov_list_referencing_type_counts.aql b/spec/views/wsprov_list_referencing_type_counts.aql index 680a0c43..b6668b15 100644 --- a/spec/views/wsprov_list_referencing_type_counts.aql +++ b/spec/views/wsprov_list_referencing_type_counts.aql @@ -1,4 +1,4 @@ -// Fetch the counts of a ws_objects in the RE that is linked to a wsprov_object +// Fetch the counts by type of ws_objects that refference an object // Args: // ws_ids - array of private workspace ids the user has access to (autofilled by RE-API) // key - key of the object to start from @@ -9,13 +9,25 @@ // simplify_type - if true, strip out the module and version before collecting WITH wsprov_object -FOR v IN 1..10 - INBOUND CONCAT('wsprov_object/', @key) wsprov_links - OPTIONS {'uniqueVertices': 'global', 'bfs':true} - // If both show_private and show_public, return if either is true - FILTER (@show_private && @show_public) ? (v.is_public || v.workspace_id IN @ws_ids) : - (!@show_private || v.workspace_id IN @ws_ids) && (!@show_public || v.is_public) - FILTER (!@owners || v.owner IN @owners) - LET ws_type = @simplify_type ? SPLIT(SPLIT(v.ws_type, '-', 1)[0], '.')[1] : v.ws_type - COLLECT type = ws_type WITH COUNT INTO type_count - RETURN {type, type_count} \ No newline at end of file +LET ws_objects = ( + FOR v IN 1..10 + INBOUND CONCAT('wsprov_object/', @key) wsprov_links + OPTIONS {'uniqueVertices': 'global', 'bfs':true} + // If both show_private and show_public, return if either is true + FILTER (@show_private && @show_public) ? (v.is_public || v.workspace_id IN @ws_ids) : + (!@show_private || v.workspace_id IN @ws_ids) && (!@show_public || v.is_public) + FILTER (!@owners || v.owner IN @owners) + return v +) + +LET types = ( + FOR v in ws_objects + LET ws_type = @simplify_type ? SPLIT(SPLIT(v.ws_type, '-', 1)[0], '.')[1] : v.ws_type + COLLECT type = ws_type WITH COUNT INTO type_count + RETURN {type, type_count} +) +LET narrs = ( + FOR v in ws_objects + RETURN DISTINCT v.narr_name +) +RETURN PUSH(types, {'type': 'Narrative', 'type_count': COUNT(narrs)}) \ No newline at end of file From ecca88c9ef6dd50e7a87850e0c6c1200cbe0be6a Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 5 Feb 2019 16:00:48 -0800 Subject: [PATCH 223/732] Add limits and fix typos --- spec/views/wsprov_fetch_copies.aql | 6 ++++-- spec/views/wsprov_fetch_linked_objects.aql | 9 ++++++--- spec/views/wsprov_obj_knowledge_score.aql | 14 ++++++++++++++ 3 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 spec/views/wsprov_obj_knowledge_score.aql diff --git a/spec/views/wsprov_fetch_copies.aql b/spec/views/wsprov_fetch_copies.aql index 6e383124..4d538301 100644 --- a/spec/views/wsprov_fetch_copies.aql +++ b/spec/views/wsprov_fetch_copies.aql @@ -5,8 +5,9 @@ // ws_ids - array of private workspace ids the user has access to // obj_key - wsprov_object key to find links for // show_private - limit to objects in workspaces that a user has access to -// show_private - limit to objects in public workspaces -// *** if both show_private and show_private are true this will be treated as an OR *** +// show_public - limit to objects in public workspaces +// *** if both show_private and show_public are true this will be treated as an OR *** +// limit - result limit WITH wsprov_object LET obj_id = CONCAT('wsprov_object/', @obj_key) @@ -15,4 +16,5 @@ FOR v IN 1..10 ANY obj_id wsprov_copied_into LET simple_type = SPLIT(SPLIT(v.ws_type, '-', 1)[0], '.')[1] FILTER (@show_private && @show_public) ? (v.is_public || v.workspace_id IN @ws_ids) : (!@show_private || v.workspace_id IN @ws_ids) && (!@show_public || v.is_public) + LIMIT @limit RETURN v diff --git a/spec/views/wsprov_fetch_linked_objects.aql b/spec/views/wsprov_fetch_linked_objects.aql index 53b3b50d..1e7eb465 100644 --- a/spec/views/wsprov_fetch_linked_objects.aql +++ b/spec/views/wsprov_fetch_linked_objects.aql @@ -3,9 +3,11 @@ // ws_ids - array of private workspace ids the user has access to // obj_keys - wsprov_object key to find links for // show_private - limit to objects in workspaces that a user has access to -// show_private - limit to objects in public workspaces -// *** if both show_private and show_private are true this will be treated as an OR *** +// show_public - limit to objects in public workspaces +// *** if both show_private and show_public are true this will be treated as an OR *** // types - simplified workspace types to return (e.g. Genome, Assembly) +// limit - result limit + WITH wsprov_object LET obj_id = CONCAT('wsprov_object/', @obj_key) FOR v IN 1..10 ANY obj_id wsprov_links @@ -14,4 +16,5 @@ FOR v IN 1..10 ANY obj_id wsprov_links FILTER (@show_private && @show_public) ? (v.is_public || v.workspace_id IN @ws_ids) : (!@show_private || v.workspace_id IN @ws_ids) && (!@show_public || v.is_public) FILTER (!@types || simple_type IN @types) - RETURN v \ No newline at end of file + LIMIT @limit + RETURN v diff --git a/spec/views/wsprov_obj_knowledge_score.aql b/spec/views/wsprov_obj_knowledge_score.aql new file mode 100644 index 00000000..ec3d9179 --- /dev/null +++ b/spec/views/wsprov_obj_knowledge_score.aql @@ -0,0 +1,14 @@ +let ws_ids = @ws_ids +for o in wsprov_object + filter o._id IN @obj_ids + let length_out = FIRST( + for v in 1..100 outbound o._id wsprov_links, wsprov_copied_into + collect with count into length + return length + ) + let length_in = FIRST( + for v in 1..100 outbound o._id wsprov_links, wsprov_copied_into + collect with count into length + return length + ) + return {object_id: o._id, score: length_out + length_in} From 62b4b65d1b58f0f3135cdd9a320fb87f3dea915f Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 5 Feb 2019 16:01:51 -0800 Subject: [PATCH 224/732] Add offsets --- spec/views/wsprov_fetch_copies.aql | 3 ++- spec/views/wsprov_fetch_linked_objects.aql | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/spec/views/wsprov_fetch_copies.aql b/spec/views/wsprov_fetch_copies.aql index 4d538301..3459b92c 100644 --- a/spec/views/wsprov_fetch_copies.aql +++ b/spec/views/wsprov_fetch_copies.aql @@ -8,6 +8,7 @@ // show_public - limit to objects in public workspaces // *** if both show_private and show_public are true this will be treated as an OR *** // limit - result limit +// offset - result offset WITH wsprov_object LET obj_id = CONCAT('wsprov_object/', @obj_key) @@ -16,5 +17,5 @@ FOR v IN 1..10 ANY obj_id wsprov_copied_into LET simple_type = SPLIT(SPLIT(v.ws_type, '-', 1)[0], '.')[1] FILTER (@show_private && @show_public) ? (v.is_public || v.workspace_id IN @ws_ids) : (!@show_private || v.workspace_id IN @ws_ids) && (!@show_public || v.is_public) - LIMIT @limit + LIMIT @offset, @limit RETURN v diff --git a/spec/views/wsprov_fetch_linked_objects.aql b/spec/views/wsprov_fetch_linked_objects.aql index 1e7eb465..d2083c78 100644 --- a/spec/views/wsprov_fetch_linked_objects.aql +++ b/spec/views/wsprov_fetch_linked_objects.aql @@ -7,6 +7,7 @@ // *** if both show_private and show_public are true this will be treated as an OR *** // types - simplified workspace types to return (e.g. Genome, Assembly) // limit - result limit +// offset - result offset WITH wsprov_object LET obj_id = CONCAT('wsprov_object/', @obj_key) @@ -16,5 +17,5 @@ FOR v IN 1..10 ANY obj_id wsprov_links FILTER (@show_private && @show_public) ? (v.is_public || v.workspace_id IN @ws_ids) : (!@show_private || v.workspace_id IN @ws_ids) && (!@show_public || v.is_public) FILTER (!@types || simple_type IN @types) - LIMIT @limit + LIMIT @offset, @limit RETURN v From b4f05f667c14449ad8bc5d00e71e2f2038d4c2f5 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 5 Feb 2019 16:15:09 -0800 Subject: [PATCH 225/732] Remove thing I didn't mean to commit --- spec/views/wsprov_obj_knowledge_score.aql | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 spec/views/wsprov_obj_knowledge_score.aql diff --git a/spec/views/wsprov_obj_knowledge_score.aql b/spec/views/wsprov_obj_knowledge_score.aql deleted file mode 100644 index ec3d9179..00000000 --- a/spec/views/wsprov_obj_knowledge_score.aql +++ /dev/null @@ -1,14 +0,0 @@ -let ws_ids = @ws_ids -for o in wsprov_object - filter o._id IN @obj_ids - let length_out = FIRST( - for v in 1..100 outbound o._id wsprov_links, wsprov_copied_into - collect with count into length - return length - ) - let length_in = FIRST( - for v in 1..100 outbound o._id wsprov_links, wsprov_copied_into - collect with count into length - return length - ) - return {object_id: o._id, score: length_out + length_in} From 9e96557cbcaa679554d987eff75eb52c44cd9ef6 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 5 Feb 2019 17:13:35 -0800 Subject: [PATCH 226/732] Change "limit" var to "result_limit" so it is not a keyword --- spec/views/wsprov_fetch_copies.aql | 4 ++-- spec/views/wsprov_fetch_linked_objects.aql | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/views/wsprov_fetch_copies.aql b/spec/views/wsprov_fetch_copies.aql index c3e769d3..36fd72c5 100644 --- a/spec/views/wsprov_fetch_copies.aql +++ b/spec/views/wsprov_fetch_copies.aql @@ -7,7 +7,7 @@ // show_private - limit to objects in workspaces that a user has access to // show_public - limit to objects in public workspaces // *** if both show_private and show_public are true this will be treated as an OR *** -// limit - result limit +// result_limit - result limit // offset - result offset WITH wsprov_object @@ -18,5 +18,5 @@ FOR v, e, p IN 1..10 ANY obj_id wsprov_copied_into FILTER (@show_private && @show_public) ? (v.is_public || v.workspace_id IN @ws_ids) : (!@show_private || v.workspace_id IN @ws_ids) && (!@show_public || v.is_public) FILTER p.vertices[*].ws_type != "KBaseGenomeAnnotations.Taxon-1.0" - LIMIT @offset, @limit + LIMIT @offset, @result_limit RETURN v diff --git a/spec/views/wsprov_fetch_linked_objects.aql b/spec/views/wsprov_fetch_linked_objects.aql index 59092d7c..6308fbfa 100644 --- a/spec/views/wsprov_fetch_linked_objects.aql +++ b/spec/views/wsprov_fetch_linked_objects.aql @@ -6,7 +6,7 @@ // show_public - limit to objects in public workspaces // *** if both show_private and show_public are true this will be treated as an OR *** // types - simplified workspace types to return (e.g. Genome, Assembly) -// limit - result limit +// result_limit - result limit // offset - result offset WITH wsprov_object @@ -18,5 +18,5 @@ FOR v, e, p IN 1..10 ANY obj_id wsprov_links (!@show_private || v.workspace_id IN @ws_ids) && (!@show_public || v.is_public) FILTER (!@types || simple_type IN @types) FILTER p.vertices[*].ws_type != "KBaseGenomeAnnotations.Taxon-1.0" - LIMIT @offset, @limit + LIMIT @offset, @result_limit RETURN v From 955a36b767ada771a180e626e2f358ffe2c8df70 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 6 Feb 2019 14:28:11 -0800 Subject: [PATCH 227/732] Fix taxon filter. Lower traversal nesting level. Add type filter to copies query --- spec/views/wsprov_fetch_copies.aql | 5 +++-- spec/views/wsprov_fetch_linked_objects.aql | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/spec/views/wsprov_fetch_copies.aql b/spec/views/wsprov_fetch_copies.aql index 36fd72c5..45248686 100644 --- a/spec/views/wsprov_fetch_copies.aql +++ b/spec/views/wsprov_fetch_copies.aql @@ -12,11 +12,12 @@ WITH wsprov_object LET obj_id = CONCAT('wsprov_object/', @obj_key) -FOR v, e, p IN 1..10 ANY obj_id wsprov_copied_into +FOR v, e, p IN 1..3 ANY obj_id wsprov_copied_into OPTIONS {uniqueVertices: 'global', bfs: true} LET simple_type = SPLIT(SPLIT(v.ws_type, '-', 1)[0], '.')[1] FILTER (@show_private && @show_public) ? (v.is_public || v.workspace_id IN @ws_ids) : (!@show_private || v.workspace_id IN @ws_ids) && (!@show_public || v.is_public) - FILTER p.vertices[*].ws_type != "KBaseGenomeAnnotations.Taxon-1.0" + FILTER (!@types || simple_type IN @types) + FILTER p.vertices[*].ws_type none == "KBaseGenomeAnnotations.Taxon-1.0" LIMIT @offset, @result_limit RETURN v diff --git a/spec/views/wsprov_fetch_linked_objects.aql b/spec/views/wsprov_fetch_linked_objects.aql index 6308fbfa..4e65fe96 100644 --- a/spec/views/wsprov_fetch_linked_objects.aql +++ b/spec/views/wsprov_fetch_linked_objects.aql @@ -11,12 +11,12 @@ WITH wsprov_object LET obj_id = CONCAT('wsprov_object/', @obj_key) -FOR v, e, p IN 1..10 ANY obj_id wsprov_links +FOR v, e, p IN 1..3 any obj_id wsprov_links OPTIONS {uniqueVertices: 'global', bfs: true} LET simple_type = SPLIT(SPLIT(v.ws_type, '-', 1)[0], '.')[1] FILTER (@show_private && @show_public) ? (v.is_public || v.workspace_id IN @ws_ids) : (!@show_private || v.workspace_id IN @ws_ids) && (!@show_public || v.is_public) FILTER (!@types || simple_type IN @types) - FILTER p.vertices[*].ws_type != "KBaseGenomeAnnotations.Taxon-1.0" + FILTER p.vertices[*].ws_type none == "KBaseGenomeAnnotations.Taxon-1.0" LIMIT @offset, @result_limit RETURN v From 31c10ff3bfb8727ce58f44716bc5566eee9b0f2d Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Thu, 7 Feb 2019 15:18:50 -0800 Subject: [PATCH 228/732] Copy from the UI prototype --- spec/views/wsprov_fetch_linked_objects.aql | 45 +++++++++++++------ .../wsprov_list_referencing_type_counts.aql | 44 +++++++----------- 2 files changed, 46 insertions(+), 43 deletions(-) diff --git a/spec/views/wsprov_fetch_linked_objects.aql b/spec/views/wsprov_fetch_linked_objects.aql index 4e65fe96..99e978ae 100644 --- a/spec/views/wsprov_fetch_linked_objects.aql +++ b/spec/views/wsprov_fetch_linked_objects.aql @@ -1,22 +1,39 @@ // Find all linked objects to a object // Args: // ws_ids - array of private workspace ids the user has access to -// obj_keys - wsprov_object key to find links for +// obj_key - wsprov_object key to find links for // show_private - limit to objects in workspaces that a user has access to // show_public - limit to objects in public workspaces -// *** if both show_private and show_public are true this will be treated as an OR *** -// types - simplified workspace types to return (e.g. Genome, Assembly) -// result_limit - result limit +// *** if both show_private and show_public are true, this will be treated as an OR *** +// type - ws type to filter on +// owners - list of usernames to filter by owner +// results_limit - limit of total results // offset - result offset WITH wsprov_object -LET obj_id = CONCAT('wsprov_object/', @obj_key) -FOR v, e, p IN 1..3 any obj_id wsprov_links - OPTIONS {uniqueVertices: 'global', bfs: true} - LET simple_type = SPLIT(SPLIT(v.ws_type, '-', 1)[0], '.')[1] - FILTER (@show_private && @show_public) ? (v.is_public || v.workspace_id IN @ws_ids) : - (!@show_private || v.workspace_id IN @ws_ids) && (!@show_public || v.is_public) - FILTER (!@types || simple_type IN @types) - FILTER p.vertices[*].ws_type none == "KBaseGenomeAnnotations.Taxon-1.0" - LIMIT @offset, @result_limit - RETURN v +LET obj_id = CONCAT("wsprov_object/", @obj_key) +FOR v, e, p IN 1..100 + INBOUND obj_id wsprov_links, wsprov_copied_into + OPTIONS {uniqueVertices: "global", bfs: true} + FILTER (!@type || v.ws_type == @type) + FILTER (!@owners || v.owner IN @owners) + FILTER (@show_private && @show_public) + ? (v.is_public || v.workspace_id IN @ws_ids) + : (!@show_private || v.workspace_id IN @ws_ids) && (!@show_public || v.is_public) + LIMIT @offset, @results_limit + RETURN { + vertex: { + _key: v._key, + is_public: v.is_public, + narr_name: v.narr_name, + obj_name: v.obj_name, + owner: v.owner, + save_date: v.save_date, + workspace_id: v.workspace_id, + ws_type: v.ws_type + }, + path: { + edges: p.edges[*]._id, + verts: p.vertices[*]._id + } + } diff --git a/spec/views/wsprov_list_referencing_type_counts.aql b/spec/views/wsprov_list_referencing_type_counts.aql index b6668b15..1321ad4d 100644 --- a/spec/views/wsprov_list_referencing_type_counts.aql +++ b/spec/views/wsprov_list_referencing_type_counts.aql @@ -1,33 +1,19 @@ // Fetch the counts by type of ws_objects that refference an object // Args: -// ws_ids - array of private workspace ids the user has access to (autofilled by RE-API) -// key - key of the object to start from -// show_private - if present, limit to objects in workspaces that a user has access to -// show_public - if present, limit to objects in public workspaces -// *** if both show_private and show_private are true this will be treated as an OR *** -// owners - if truthy, limit to objects with owner in list -// simplify_type - if true, strip out the module and version before collecting +// ws_ids - array of private workspace ids the user has access to +// obj_key - wsprov_object key to count associations for +// show_private - limit to objects in workspaces that a user has access to +// show_public - limit to objects in public workspaces +// *** if both show_private and show_public are true, this will be treated as an OR *** WITH wsprov_object -LET ws_objects = ( - FOR v IN 1..10 - INBOUND CONCAT('wsprov_object/', @key) wsprov_links - OPTIONS {'uniqueVertices': 'global', 'bfs':true} - // If both show_private and show_public, return if either is true - FILTER (@show_private && @show_public) ? (v.is_public || v.workspace_id IN @ws_ids) : - (!@show_private || v.workspace_id IN @ws_ids) && (!@show_public || v.is_public) - FILTER (!@owners || v.owner IN @owners) - return v -) - -LET types = ( - FOR v in ws_objects - LET ws_type = @simplify_type ? SPLIT(SPLIT(v.ws_type, '-', 1)[0], '.')[1] : v.ws_type - COLLECT type = ws_type WITH COUNT INTO type_count - RETURN {type, type_count} -) -LET narrs = ( - FOR v in ws_objects - RETURN DISTINCT v.narr_name -) -RETURN PUSH(types, {'type': 'Narrative', 'type_count': COUNT(narrs)}) \ No newline at end of file +LET obj_id = CONCAT("wsprov_object/", @obj_key) +FOR v, e, p in 1..100 + INBOUND obj_id wsprov_links, wsprov_copied_into + OPTIONS {uniqueVertices: "global", bfs: true} + FILTER p.vertices[1].is_taxon != true + FILTER (@show_private && @show_public) ? (v.is_public || v.workspace_id IN @ws_ids) : + (!@show_private || v.workspace_id IN @ws_ids) && (!@show_public || v.is_public) + COLLECT type = v.ws_type with count into type_count + SORT type_count DESC + RETURN {type, type_count} From 392335721477231857c61f69b6179dc4b24ff510 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Thu, 7 Feb 2019 15:21:36 -0800 Subject: [PATCH 229/732] Remove unused line --- spec/views/wsprov_list_referencing_type_counts.aql | 1 - 1 file changed, 1 deletion(-) diff --git a/spec/views/wsprov_list_referencing_type_counts.aql b/spec/views/wsprov_list_referencing_type_counts.aql index 1321ad4d..671d34d7 100644 --- a/spec/views/wsprov_list_referencing_type_counts.aql +++ b/spec/views/wsprov_list_referencing_type_counts.aql @@ -11,7 +11,6 @@ LET obj_id = CONCAT("wsprov_object/", @obj_key) FOR v, e, p in 1..100 INBOUND obj_id wsprov_links, wsprov_copied_into OPTIONS {uniqueVertices: "global", bfs: true} - FILTER p.vertices[1].is_taxon != true FILTER (@show_private && @show_public) ? (v.is_public || v.workspace_id IN @ws_ids) : (!@show_private || v.workspace_id IN @ws_ids) && (!@show_public || v.is_public) COLLECT type = v.ws_type with count into type_count From 8deca6cb6517f9be62284af09ff37fa12caa41cd Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Thu, 7 Feb 2019 16:00:30 -0800 Subject: [PATCH 230/732] Move the type count query into a separate view --- .../wsprov_count_linked_object_types.aql | 18 ++++++++ .../wsprov_list_referencing_type_counts.aql | 43 +++++++++++++------ 2 files changed, 47 insertions(+), 14 deletions(-) create mode 100644 spec/views/wsprov_count_linked_object_types.aql diff --git a/spec/views/wsprov_count_linked_object_types.aql b/spec/views/wsprov_count_linked_object_types.aql new file mode 100644 index 00000000..671d34d7 --- /dev/null +++ b/spec/views/wsprov_count_linked_object_types.aql @@ -0,0 +1,18 @@ +// Fetch the counts by type of ws_objects that refference an object +// Args: +// ws_ids - array of private workspace ids the user has access to +// obj_key - wsprov_object key to count associations for +// show_private - limit to objects in workspaces that a user has access to +// show_public - limit to objects in public workspaces +// *** if both show_private and show_public are true, this will be treated as an OR *** + +WITH wsprov_object +LET obj_id = CONCAT("wsprov_object/", @obj_key) +FOR v, e, p in 1..100 + INBOUND obj_id wsprov_links, wsprov_copied_into + OPTIONS {uniqueVertices: "global", bfs: true} + FILTER (@show_private && @show_public) ? (v.is_public || v.workspace_id IN @ws_ids) : + (!@show_private || v.workspace_id IN @ws_ids) && (!@show_public || v.is_public) + COLLECT type = v.ws_type with count into type_count + SORT type_count DESC + RETURN {type, type_count} diff --git a/spec/views/wsprov_list_referencing_type_counts.aql b/spec/views/wsprov_list_referencing_type_counts.aql index 671d34d7..2c5dea51 100644 --- a/spec/views/wsprov_list_referencing_type_counts.aql +++ b/spec/views/wsprov_list_referencing_type_counts.aql @@ -1,18 +1,33 @@ // Fetch the counts by type of ws_objects that refference an object // Args: -// ws_ids - array of private workspace ids the user has access to -// obj_key - wsprov_object key to count associations for -// show_private - limit to objects in workspaces that a user has access to -// show_public - limit to objects in public workspaces -// *** if both show_private and show_public are true, this will be treated as an OR *** +// ws_ids - array of private workspace ids the user has access to (autofilled by RE-API) +// key - key of the object to start from +// show_private - if present, limit to objects in workspaces that a user has access to +// show_public - if present, limit to objects in public workspaces +// *** if both show_private and show_private are true this will be treated as an OR *** +// owners - if truthy, limit to objects with owner in list +// simplify_type - if true, strip out the module and version before collecting WITH wsprov_object -LET obj_id = CONCAT("wsprov_object/", @obj_key) -FOR v, e, p in 1..100 - INBOUND obj_id wsprov_links, wsprov_copied_into - OPTIONS {uniqueVertices: "global", bfs: true} - FILTER (@show_private && @show_public) ? (v.is_public || v.workspace_id IN @ws_ids) : - (!@show_private || v.workspace_id IN @ws_ids) && (!@show_public || v.is_public) - COLLECT type = v.ws_type with count into type_count - SORT type_count DESC - RETURN {type, type_count} +LET ws_objects = ( + FOR v IN 1..10 + INBOUND CONCAT('wsprov_object/', @key) wsprov_links + OPTIONS {'uniqueVertices': 'global', 'bfs':true} + // If both show_private and show_public, return if either is true + FILTER (@show_private && @show_public) ? (v.is_public || v.workspace_id IN @ws_ids) : + (!@show_private || v.workspace_id IN @ws_ids) && (!@show_public || v.is_public) + FILTER (!@owners || v.owner IN @owners) + return v +) + +LET types = ( + FOR v in ws_objects + LET ws_type = @simplify_type ? SPLIT(SPLIT(v.ws_type, '-', 1)[0], '.')[1] : v.ws_type + COLLECT type = ws_type WITH COUNT INTO type_count + RETURN {type, type_count} +) +LET narrs = ( + FOR v in ws_objects + RETURN DISTINCT v.narr_name +) +RETURN PUSH(types, {'type': 'Narrative', 'type_count': COUNT(narrs)}) From 4602c0e81687bc58498cd9672b311df56da1c3db Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Mon, 11 Feb 2019 15:48:00 -0800 Subject: [PATCH 231/732] Return path of ws types --- spec/views/wsprov_fetch_linked_objects.aql | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/spec/views/wsprov_fetch_linked_objects.aql b/spec/views/wsprov_fetch_linked_objects.aql index 99e978ae..b1dc5203 100644 --- a/spec/views/wsprov_fetch_linked_objects.aql +++ b/spec/views/wsprov_fetch_linked_objects.aql @@ -32,8 +32,5 @@ FOR v, e, p IN 1..100 workspace_id: v.workspace_id, ws_type: v.ws_type }, - path: { - edges: p.edges[*]._id, - verts: p.vertices[*]._id - } + type_path: p.vertices[*].ws_type } From 6d9d53328de2b8417b55c265f14d72fac60f2f04 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 13 Feb 2019 17:41:11 -0800 Subject: [PATCH 232/732] Expand the wsprov linked object views a little to include both directions --- .../wsprov_count_linked_object_types.aql | 38 +++++++--- spec/views/wsprov_fetch_linked_objects.aql | 74 +++++++++++++------ 2 files changed, 81 insertions(+), 31 deletions(-) diff --git a/spec/views/wsprov_count_linked_object_types.aql b/spec/views/wsprov_count_linked_object_types.aql index 671d34d7..aa68510c 100644 --- a/spec/views/wsprov_count_linked_object_types.aql +++ b/spec/views/wsprov_count_linked_object_types.aql @@ -7,12 +7,32 @@ // *** if both show_private and show_public are true, this will be treated as an OR *** WITH wsprov_object -LET obj_id = CONCAT("wsprov_object/", @obj_key) -FOR v, e, p in 1..100 - INBOUND obj_id wsprov_links, wsprov_copied_into - OPTIONS {uniqueVertices: "global", bfs: true} - FILTER (@show_private && @show_public) ? (v.is_public || v.workspace_id IN @ws_ids) : - (!@show_private || v.workspace_id IN @ws_ids) && (!@show_public || v.is_public) - COLLECT type = v.ws_type with count into type_count - SORT type_count DESC - RETURN {type, type_count} +LET obj_id = concat('wsprov_object/', @obj_key) + +let out = FIRST( + for v, e, p in 1..100 + OUTBOUND obj_id wsprov_links, wsprov_copied_into + OPTIONS {bfs: true, uniqueVertices: 'global'} + FILTER (!@type || v.ws_type == @type) + FILTER (!@owners || v.owner IN @owners) + FILTER (@show_private && @show_public) + ? (v.is_public || v.workspace_id IN @ws_ids) + : (!@show_private || v.workspace_id IN @ws_ids) && (!@show_public || v.is_public) + COLLECT type = v.ws_type with count into type_count + RETURN {type, type_count} +) + +let inb = FIRST( + for v, e, p in 1..100 + INBOUND obj_id wsprov_links, wsprov_copied_into + OPTIONS {bfs: true, uniqueVertices: 'global'} + FILTER (!@type || v.ws_type == @type) + FILTER (!@owners || v.owner IN @owners) + FILTER (@show_private && @show_public) + ? (v.is_public || v.workspace_id IN @ws_ids) + : (!@show_private || v.workspace_id IN @ws_ids) && (!@show_public || v.is_public) + COLLECT type = v.ws_type with count into type_count + RETURN {type, type_count} +) + +return {out, inb} diff --git a/spec/views/wsprov_fetch_linked_objects.aql b/spec/views/wsprov_fetch_linked_objects.aql index b1dc5203..c4760d54 100644 --- a/spec/views/wsprov_fetch_linked_objects.aql +++ b/spec/views/wsprov_fetch_linked_objects.aql @@ -12,25 +12,55 @@ WITH wsprov_object LET obj_id = CONCAT("wsprov_object/", @obj_key) -FOR v, e, p IN 1..100 - INBOUND obj_id wsprov_links, wsprov_copied_into - OPTIONS {uniqueVertices: "global", bfs: true} - FILTER (!@type || v.ws_type == @type) - FILTER (!@owners || v.owner IN @owners) - FILTER (@show_private && @show_public) - ? (v.is_public || v.workspace_id IN @ws_ids) - : (!@show_private || v.workspace_id IN @ws_ids) && (!@show_public || v.is_public) - LIMIT @offset, @results_limit - RETURN { - vertex: { - _key: v._key, - is_public: v.is_public, - narr_name: v.narr_name, - obj_name: v.obj_name, - owner: v.owner, - save_date: v.save_date, - workspace_id: v.workspace_id, - ws_type: v.ws_type - }, - type_path: p.vertices[*].ws_type - } + +let out = ( + FOR v, e, p IN 1..100 + OUTBOUND obj_id wsprov_links, wsprov_copied_into + OPTIONS {uniqueVertices: "global", bfs: true} + FILTER (!@type || v.ws_type == @type) + FILTER (!@owners || v.owner IN @owners) + FILTER (@show_private && @show_public) + ? (v.is_public || v.workspace_id IN @ws_ids) + : (!@show_private || v.workspace_id IN @ws_ids) && (!@show_public || v.is_public) + LIMIT @offset, @results_limit + RETURN { + vertex: { + _key: v._key, + is_public: v.is_public, + narr_name: v.narr_name, + obj_name: v.obj_name, + owner: v.owner, + save_date: v.save_date, + workspace_id: v.workspace_id, + ws_type: v.ws_type + }, + path: p + } +) + +let inb = ( + FOR v, e, p IN 1..100 + OUTBOUND obj_id wsprov_links, wsprov_copied_into + OPTIONS {uniqueVertices: "global", bfs: true} + FILTER (!@type || v.ws_type == @type) + FILTER (!@owners || v.owner IN @owners) + FILTER (@show_private && @show_public) + ? (v.is_public || v.workspace_id IN @ws_ids) + : (!@show_private || v.workspace_id IN @ws_ids) && (!@show_public || v.is_public) + LIMIT @offset, @results_limit + RETURN { + vertex: { + _key: v._key, + is_public: v.is_public, + narr_name: v.narr_name, + obj_name: v.obj_name, + owner: v.owner, + save_date: v.save_date, + workspace_id: v.workspace_id, + ws_type: v.ws_type + }, + path: p + } +) + +return APPEND(out, inb) From 86e0200d4c68e9fa3b0cc533dcfd45f451ce57de Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 13 Feb 2019 17:58:26 -0800 Subject: [PATCH 233/732] Generic field fetch view on wsprov_object with access control --- spec/views/wsprov_fetch_obj_field.aql | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 spec/views/wsprov_fetch_obj_field.aql diff --git a/spec/views/wsprov_fetch_obj_field.aql b/spec/views/wsprov_fetch_obj_field.aql new file mode 100644 index 00000000..956b9755 --- /dev/null +++ b/spec/views/wsprov_fetch_obj_field.aql @@ -0,0 +1,11 @@ +// Fetch some object field for an array of object ids +// Args: +// prop - property name that you want to fetch +// obj_ids - array of object ids +// ws_ids - array of private workspace ids the user has access to + +with wsprov_object +for o in wsprov_object + filter o._id in @obj_ids + filter o.is_public || o.workspace_id IN @ws_ids + return o[@prop] From a14a1317cab8a3ab693085078637702fe74015df Mon Sep 17 00:00:00 2001 From: James Jeffryes Date: Thu, 14 Feb 2019 07:54:53 -0600 Subject: [PATCH 234/732] Add missing args --- spec/views/wsprov_count_linked_object_types.aql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spec/views/wsprov_count_linked_object_types.aql b/spec/views/wsprov_count_linked_object_types.aql index aa68510c..85cfdbad 100644 --- a/spec/views/wsprov_count_linked_object_types.aql +++ b/spec/views/wsprov_count_linked_object_types.aql @@ -5,6 +5,8 @@ // show_private - limit to objects in workspaces that a user has access to // show_public - limit to objects in public workspaces // *** if both show_private and show_public are true, this will be treated as an OR *** +// type - ws type to filter on +// owners - list of usernames to filter by owner WITH wsprov_object LET obj_id = concat('wsprov_object/', @obj_key) From b9818cb040c0cf5539744fc1f8bce65a99fda92b Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Thu, 14 Feb 2019 15:35:48 -0800 Subject: [PATCH 235/732] Make some tweaks on wsfull to support the big workspace perms import --- .../wsfull_can_read_workspace.json | 22 +++++++++++++ .../workspace_full/wsfull_owns_workspace.json | 22 +++++++++++++ .../workspace_full/wsfull_workspace.json | 31 +++++++++++++------ 3 files changed, 65 insertions(+), 10 deletions(-) create mode 100644 spec/schemas/edges/workspace_full/wsfull_can_read_workspace.json create mode 100644 spec/schemas/edges/workspace_full/wsfull_owns_workspace.json diff --git a/spec/schemas/edges/workspace_full/wsfull_can_read_workspace.json b/spec/schemas/edges/workspace_full/wsfull_can_read_workspace.json new file mode 100644 index 00000000..f8ff448d --- /dev/null +++ b/spec/schemas/edges/workspace_full/wsfull_can_read_workspace.json @@ -0,0 +1,22 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "description": "The user can read a workspace.", + "required": ["_from", "_to"], + "properties": { + "_from": { + "type": "string", + "examples": [ + "wsfull_user/jjeffryes" + ], + "description": "A username" + }, + "_to": { + "type": "string", + "examples": [ + "wsfull_workspace/35414" + ], + "description": "A Workspace" + } + } +} diff --git a/spec/schemas/edges/workspace_full/wsfull_owns_workspace.json b/spec/schemas/edges/workspace_full/wsfull_owns_workspace.json new file mode 100644 index 00000000..84cfb8c5 --- /dev/null +++ b/spec/schemas/edges/workspace_full/wsfull_owns_workspace.json @@ -0,0 +1,22 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "description": "The user owns a workspace.", + "required": ["_from", "_to"], + "properties": { + "_from": { + "type": "string", + "examples": [ + "wsfull_user/jjeffryes" + ], + "description": "A username" + }, + "_to": { + "type": "string", + "examples": [ + "wsfull_workspace/35414" + ], + "description": "A Workspace" + } + } +} diff --git a/spec/schemas/vertices/workspace_full/wsfull_workspace.json b/spec/schemas/vertices/workspace_full/wsfull_workspace.json index 37332059..767c9b0a 100644 --- a/spec/schemas/vertices/workspace_full/wsfull_workspace.json +++ b/spec/schemas/vertices/workspace_full/wsfull_workspace.json @@ -1,13 +1,7 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", - "additionalProperties": false, - "required": [ - "_key", - "name", - "mod_epoch", - "public" - ], + "required": ["_key"], "properties": { "_key": { "type": "string", @@ -17,6 +11,22 @@ ], "pattern": "^\\d+$" }, + "narr_name": { + "type": "string", + "title": "Narrative name" + }, + "owner": { + "type": "string", + "title": "Username of workspace owner" + }, + "max_obj_id": { + "type": "integer", + "title": "Maximum object ID in this workspace" + }, + "lock_status": { + "type": "string", + "title": "Status of the workspace lock" + }, "name": { "type": "string", "description": "The workspace name for this workspace", @@ -26,13 +36,14 @@ }, "mod_epoch": { "type": "integer", - "description": "Epoch when the Workspace was last modified", + "title": "Modified date epoch", + "description": "Timestamp of when the workspace was last modified", "minimum": 0 }, - "public": { + "is_public": { "type": "boolean" }, - "deleted": { + "is_deleted": { "type": "boolean" } } From 133e554e7ef199c58ad4a73c18b5e1d4537962bf Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Thu, 14 Feb 2019 15:39:42 -0800 Subject: [PATCH 236/732] Use a more generic permission edge between user and workspace --- .../wsfull_can_read_workspace.json | 22 --------------- .../workspace_full/wsfull_owns_workspace.json | 22 --------------- .../edges/workspace_full/wsfull_ws_perm.json | 28 +++++++++++++++++++ 3 files changed, 28 insertions(+), 44 deletions(-) delete mode 100644 spec/schemas/edges/workspace_full/wsfull_can_read_workspace.json delete mode 100644 spec/schemas/edges/workspace_full/wsfull_owns_workspace.json create mode 100644 spec/schemas/edges/workspace_full/wsfull_ws_perm.json diff --git a/spec/schemas/edges/workspace_full/wsfull_can_read_workspace.json b/spec/schemas/edges/workspace_full/wsfull_can_read_workspace.json deleted file mode 100644 index f8ff448d..00000000 --- a/spec/schemas/edges/workspace_full/wsfull_can_read_workspace.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "description": "The user can read a workspace.", - "required": ["_from", "_to"], - "properties": { - "_from": { - "type": "string", - "examples": [ - "wsfull_user/jjeffryes" - ], - "description": "A username" - }, - "_to": { - "type": "string", - "examples": [ - "wsfull_workspace/35414" - ], - "description": "A Workspace" - } - } -} diff --git a/spec/schemas/edges/workspace_full/wsfull_owns_workspace.json b/spec/schemas/edges/workspace_full/wsfull_owns_workspace.json deleted file mode 100644 index 84cfb8c5..00000000 --- a/spec/schemas/edges/workspace_full/wsfull_owns_workspace.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "description": "The user owns a workspace.", - "required": ["_from", "_to"], - "properties": { - "_from": { - "type": "string", - "examples": [ - "wsfull_user/jjeffryes" - ], - "description": "A username" - }, - "_to": { - "type": "string", - "examples": [ - "wsfull_workspace/35414" - ], - "description": "A Workspace" - } - } -} diff --git a/spec/schemas/edges/workspace_full/wsfull_ws_perm.json b/spec/schemas/edges/workspace_full/wsfull_ws_perm.json new file mode 100644 index 00000000..55d4351c --- /dev/null +++ b/spec/schemas/edges/workspace_full/wsfull_ws_perm.json @@ -0,0 +1,28 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "description": "The user has permissions on a workspace.", + "required": ["_from", "_to", "perm"], + "properties": { + "perm": { + "type": "string", + "enum": ["a", "w", "r", "n"], + "title": "Permissions", + "description": "Represents the permissions a user has on a workspace, where 'a' is 'administrator', 'w' is read/write, 'r' is readonly, and 'n' is 'none'." + }, + "_from": { + "type": "string", + "examples": [ + "wsfull_user/jjeffryes" + ], + "description": "A username" + }, + "_to": { + "type": "string", + "examples": [ + "wsfull_workspace/35414" + ], + "description": "A workspace" + } + } +} From e94061528879ec08499cbec3e6903149ff1c38c2 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Thu, 14 Feb 2019 15:41:31 -0800 Subject: [PATCH 237/732] Remove unneeded "n" perm value --- spec/schemas/edges/workspace_full/wsfull_ws_perm.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/schemas/edges/workspace_full/wsfull_ws_perm.json b/spec/schemas/edges/workspace_full/wsfull_ws_perm.json index 55d4351c..75ecaf6c 100644 --- a/spec/schemas/edges/workspace_full/wsfull_ws_perm.json +++ b/spec/schemas/edges/workspace_full/wsfull_ws_perm.json @@ -6,9 +6,9 @@ "properties": { "perm": { "type": "string", - "enum": ["a", "w", "r", "n"], + "enum": ["a", "w", "r"], "title": "Permissions", - "description": "Represents the permissions a user has on a workspace, where 'a' is 'administrator', 'w' is read/write, 'r' is readonly, and 'n' is 'none'." + "description": "Represents the permissions a user has on a workspace, where 'a' is 'administrator', 'w' is read/write, 'r' is readonly." }, "_from": { "type": "string", From c95c72e2c1c6e7dcffacf8c5e9920914b824fece Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Thu, 14 Feb 2019 16:16:10 -0800 Subject: [PATCH 238/732] Fix type counting --- spec/views/wsprov_count_linked_object_types.aql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/views/wsprov_count_linked_object_types.aql b/spec/views/wsprov_count_linked_object_types.aql index 85cfdbad..a8d2fd30 100644 --- a/spec/views/wsprov_count_linked_object_types.aql +++ b/spec/views/wsprov_count_linked_object_types.aql @@ -11,7 +11,7 @@ WITH wsprov_object LET obj_id = concat('wsprov_object/', @obj_key) -let out = FIRST( +let out = ( for v, e, p in 1..100 OUTBOUND obj_id wsprov_links, wsprov_copied_into OPTIONS {bfs: true, uniqueVertices: 'global'} @@ -24,7 +24,7 @@ let out = FIRST( RETURN {type, type_count} ) -let inb = FIRST( +let inb = ( for v, e, p in 1..100 INBOUND obj_id wsprov_links, wsprov_copied_into OPTIONS {bfs: true, uniqueVertices: 'global'} From a8ffa1e1e8fbd72081adceb9f207de45acba994e Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Thu, 14 Feb 2019 16:57:09 -0800 Subject: [PATCH 239/732] Fix typo - should be "inbound" --- spec/views/wsprov_fetch_linked_objects.aql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/views/wsprov_fetch_linked_objects.aql b/spec/views/wsprov_fetch_linked_objects.aql index c4760d54..1da9e749 100644 --- a/spec/views/wsprov_fetch_linked_objects.aql +++ b/spec/views/wsprov_fetch_linked_objects.aql @@ -40,7 +40,7 @@ let out = ( let inb = ( FOR v, e, p IN 1..100 - OUTBOUND obj_id wsprov_links, wsprov_copied_into + INBOUND obj_id wsprov_links, wsprov_copied_into OPTIONS {uniqueVertices: "global", bfs: true} FILTER (!@type || v.ws_type == @type) FILTER (!@owners || v.owner IN @owners) From 3b8d804ae2db48f9d789ee22cfdfeb1165d2162a Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Fri, 15 Feb 2019 11:06:15 -0800 Subject: [PATCH 240/732] Put key in results --- spec/views/wsprov_fetch_obj_field.aql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/views/wsprov_fetch_obj_field.aql b/spec/views/wsprov_fetch_obj_field.aql index 956b9755..fdf82a62 100644 --- a/spec/views/wsprov_fetch_obj_field.aql +++ b/spec/views/wsprov_fetch_obj_field.aql @@ -8,4 +8,4 @@ with wsprov_object for o in wsprov_object filter o._id in @obj_ids filter o.is_public || o.workspace_id IN @ws_ids - return o[@prop] + return {key: o._key, @prop: o[@prop]} From 4888d1db82f6248e678f6b562f3654d28371ae0d Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Fri, 15 Feb 2019 15:18:48 -0800 Subject: [PATCH 241/732] Fetch references query for an object --- spec/views/wsprov_fetch_references.aql | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 spec/views/wsprov_fetch_references.aql diff --git a/spec/views/wsprov_fetch_references.aql b/spec/views/wsprov_fetch_references.aql new file mode 100644 index 00000000..701027e4 --- /dev/null +++ b/spec/views/wsprov_fetch_references.aql @@ -0,0 +1,17 @@ +// Fetch inbound references for an object with acl +// Args: +// obj_key - wsprov_object ._key field that you want to query against +// result_limit - limit of object results +// offset - result offset for pagination +// ws_ids - array of private workspace ids the user has access to + +with wsprov_object + +let obj_id = concat('wsprov_object/', @obj_key) + +for v, e, p in 1..100 inbound obj_id wsprov_links + options {bfs: true, uniqueVertices: 'global'} + filter p.edges[*].type all == 'reference' + filter v.is_public || v.workspace_id IN @ws_ids + limit @offset, @result_limit + return v From 783dafae90e246d4d75187681274ff44e537fd2b Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 20 Feb 2019 15:38:05 -0800 Subject: [PATCH 242/732] Loosen up some of the schemas, and add wsfull_prov_descendant_of --- .../edges/workspace_full/wsfull_copied_from.json | 1 - .../workspace_full/wsfull_prov_descendant_of.json | 11 +++++++++++ .../edges/workspace_full/wsfull_refers_to.json | 3 +-- .../workspace_full/wsfull_object_version.json | 1 - 4 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 spec/schemas/edges/workspace_full/wsfull_prov_descendant_of.json diff --git a/spec/schemas/edges/workspace_full/wsfull_copied_from.json b/spec/schemas/edges/workspace_full/wsfull_copied_from.json index c197be04..0ed1e87e 100644 --- a/spec/schemas/edges/workspace_full/wsfull_copied_from.json +++ b/spec/schemas/edges/workspace_full/wsfull_copied_from.json @@ -1,7 +1,6 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", - "additionalProperties": false, "required": ["_from", "_to"], "description": "The _from object was created as an exact copy of the _to object.", "properties": { diff --git a/spec/schemas/edges/workspace_full/wsfull_prov_descendant_of.json b/spec/schemas/edges/workspace_full/wsfull_prov_descendant_of.json new file mode 100644 index 00000000..efee5d01 --- /dev/null +++ b/spec/schemas/edges/workspace_full/wsfull_prov_descendant_of.json @@ -0,0 +1,11 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "required": ["_from", "_to"], + "description": "The _from object is a provenance descendant of the _to object (eg. Assembly->Reads).", + "properties": { + "_from": { "type": "string" }, + "_to": { "type": "string" } + } +} + diff --git a/spec/schemas/edges/workspace_full/wsfull_refers_to.json b/spec/schemas/edges/workspace_full/wsfull_refers_to.json index 4b43e678..e19ba75f 100644 --- a/spec/schemas/edges/workspace_full/wsfull_refers_to.json +++ b/spec/schemas/edges/workspace_full/wsfull_refers_to.json @@ -1,9 +1,8 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", - "additionalProperties": false, "required": ["_from", "_to"], - "description": "The _from object has an attribute which is a reference to the _to object.", + "description": "The _from object has a reference to the _to object (eg. Genome->Assembly).", "properties": { "_from": { "type": "string" }, "_to": { "type": "string" } diff --git a/spec/schemas/vertices/workspace_full/wsfull_object_version.json b/spec/schemas/vertices/workspace_full/wsfull_object_version.json index b3c9fa2e..9e78fff7 100644 --- a/spec/schemas/vertices/workspace_full/wsfull_object_version.json +++ b/spec/schemas/vertices/workspace_full/wsfull_object_version.json @@ -1,7 +1,6 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", - "additionalProperties": false, "required": [ "_key", "workspace_id", From f0af16ca0f9d201cad7d47019f05c597741aa180 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 20 Feb 2019 17:32:54 -0800 Subject: [PATCH 243/732] Allow multiple types --- spec/views/wsprov_fetch_linked_objects.aql | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/views/wsprov_fetch_linked_objects.aql b/spec/views/wsprov_fetch_linked_objects.aql index 1da9e749..87987219 100644 --- a/spec/views/wsprov_fetch_linked_objects.aql +++ b/spec/views/wsprov_fetch_linked_objects.aql @@ -5,8 +5,8 @@ // show_private - limit to objects in workspaces that a user has access to // show_public - limit to objects in public workspaces // *** if both show_private and show_public are true, this will be treated as an OR *** -// type - ws type to filter on -// owners - list of usernames to filter by owner +// types - list of ws types to filter on (set as false to disable) +// owners - list of usernames to filter by owner (set as false to disable) // results_limit - limit of total results // offset - result offset @@ -17,7 +17,7 @@ let out = ( FOR v, e, p IN 1..100 OUTBOUND obj_id wsprov_links, wsprov_copied_into OPTIONS {uniqueVertices: "global", bfs: true} - FILTER (!@type || v.ws_type == @type) + FILTER (!@types || v.ws_type IN @types) FILTER (!@owners || v.owner IN @owners) FILTER (@show_private && @show_public) ? (v.is_public || v.workspace_id IN @ws_ids) @@ -42,7 +42,7 @@ let inb = ( FOR v, e, p IN 1..100 INBOUND obj_id wsprov_links, wsprov_copied_into OPTIONS {uniqueVertices: "global", bfs: true} - FILTER (!@type || v.ws_type == @type) + FILTER (!@types || v.ws_type IN @types) FILTER (!@owners || v.owner IN @owners) FILTER (@show_private && @show_public) ? (v.is_public || v.workspace_id IN @ws_ids) From 4b2e7285611af89df65c2cbe09c0e91d77e13bed Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Mon, 25 Feb 2019 12:47:36 -0800 Subject: [PATCH 244/732] Add note on testing in readme --- api/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/README.md b/api/README.md index 5d97bf14..7a79c6b1 100644 --- a/api/README.md +++ b/api/README.md @@ -311,7 +311,7 @@ Where the file contains multiple JSON documents separated by line-breaks. Copy `.env.example` to `.env`. Start the server with `docker-compose up`. -Run tests with `make test`. +Run tests with `make test` (the server should be running in another terminal using `docker-compose up --build`). The docker image is pushed to Docker Hub when new commits are made to master. The script that runs when pushing to docker hub is found in `hooks/build`. From 5a83bcab629399ab277acc50523ffaad80be6540 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Thu, 28 Feb 2019 10:56:11 -0800 Subject: [PATCH 245/732] Add release_url param to the download_specs function --- api/src/relation_engine_server/server.py | 4 +++- api/src/relation_engine_server/utils/pull_spec.py | 7 +++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/api/src/relation_engine_server/server.py b/api/src/relation_engine_server/server.py index 5cad116f..9862fb26 100644 --- a/api/src/relation_engine_server/server.py +++ b/api/src/relation_engine_server/server.py @@ -132,7 +132,9 @@ def refresh_specs(): Auth: admin """ auth.require_auth_token(['RE_ADMIN']) - pull_spec.download_latest(init_collections='init_collections' in flask.request.args) + init_collections = 'init_collections' in flask.request.args + release_url = flask.request.args.get('release_url') + pull_spec.download_specs(init_collections, release_url) return flask.jsonify({'status': 'updated'}) diff --git a/api/src/relation_engine_server/utils/pull_spec.py b/api/src/relation_engine_server/utils/pull_spec.py index b698b363..50e84aa4 100644 --- a/api/src/relation_engine_server/utils/pull_spec.py +++ b/api/src/relation_engine_server/utils/pull_spec.py @@ -8,7 +8,7 @@ from .config import get_config -def download_latest(init_collections=True): +def download_specs(init_collections=True, release_url=None): """Check and download the latest spec and extract it to the spec path.""" config = get_config() # Remove the spec directory, ignoring if it is already missing @@ -19,6 +19,8 @@ def download_latest(init_collections=True): if 'SPEC_RELEASE_PATH' in os.environ: _extract_tarball(os.environ['SPEC_RELEASE_PATH'], config['spec_paths']['root']) else: + if release_url: + tarball_url = release_url if 'SPEC_RELEASE_URL' in os.environ: tarball_url = os.environ['SPEC_RELEASE_URL'] else: @@ -40,13 +42,14 @@ def download_latest(init_collections=True): def _fetch_github_release_url(): + """Find the latest relation engine spec release using the github api.""" config = get_config() # Download information about the latest release release_resp = requests.get(config['spec_url'] + '/releases/latest') release_info = release_resp.json() if release_resp.status_code != 200: # This may be a github API rate usage limit, or some other error - raise Exception(release_info['message']) + raise RuntimeError(release_info['message']) return release_info['tarball_url'] From 1499105593dc086dbb6766f7637c00cda3ab300f Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Thu, 28 Feb 2019 14:48:30 -0800 Subject: [PATCH 246/732] Add docs about "spec_url" and remove deprecated option "reset" for /api/update_specs --- api/README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/api/README.md b/api/README.md index 7a79c6b1..cea72105 100644 --- a/api/README.md +++ b/api/README.md @@ -237,8 +237,10 @@ $ curl http://relation_engine/api/update_specs ``` _Query params_ -* `init_collections` - optional - boolean - whether to initialize any new collections in arango -* `reset` - optional - boolean - whether to completely reset the spec data (do a clean download and overwrite) +* `init_collections` - optional - boolean - defaults to true - whether to initialize any new collections in arango +* `spec_url` - optional - string - the specific url of the release to download and use (as a tarball). If left blank, then the latest release from github is used (not including any pre-releases or drafts). + +Every call to update specs will reset the spec data (do a clean download and overwrite). ## Python client API From 94b767e9b6120d1ba9f07f7f027560be320a5592 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Thu, 28 Feb 2019 15:25:21 -0800 Subject: [PATCH 247/732] Add PR template and contribution guidelines --- api/.github/CONTRIBUTING.md | 22 ++++++++++++++++++++++ api/.github/pull_request_template.md | 3 +++ 2 files changed, 25 insertions(+) create mode 100644 api/.github/CONTRIBUTING.md create mode 100644 api/.github/pull_request_template.md diff --git a/api/.github/CONTRIBUTING.md b/api/.github/CONTRIBUTING.md new file mode 100644 index 00000000..2b5e08cb --- /dev/null +++ b/api/.github/CONTRIBUTING.md @@ -0,0 +1,22 @@ +# Contributing to KBase + +Important resources: + +* [The KBase Code of Conduct](https://kbase.us/code-of-conduct/) +* [The KBase user documentation](https://kbase.us/new-to-kbase/) +* [The KBase users' slack channel](https://kbaseusers.slack.com) +* [The KBase SDK docs](https://kbase.github.io/kb_sdk_docs/) +* [The kbase Github organization](https://github.com/kbase) +* [The kbaseapps Github organization](https://github.com/kbaseapps) + +## Submitting changes + +After opening a Github pull request on the repo you'd like to update, be sure to: + +* Update documentation, including the README.md file, any additional documentation under `/docs`, and any separate documentation sites that cover the functionality. +* Check that you added test coverage for any changes you made. +* Check if your changes break an API. If so, increment the version and ensure that any current dependents will not break. + +Always write a clear log messages for your commits. + +:tada: :100: Thank you for your contributions! diff --git a/api/.github/pull_request_template.md b/api/.github/pull_request_template.md new file mode 100644 index 00000000..989b68a6 --- /dev/null +++ b/api/.github/pull_request_template.md @@ -0,0 +1,3 @@ + +- [ ] I updated the README.md docs to reflect this change. +- [ ] This is either not a breaking API change, or I incremented the API version. From 0a14793fde51b267a78568f7d371638d29f38c0a Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Thu, 28 Feb 2019 15:40:18 -0800 Subject: [PATCH 248/732] Clean up more README.md docs --- api/README.md | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/api/README.md b/api/README.md index 7a79c6b1..baa95ed9 100644 --- a/api/README.md +++ b/api/README.md @@ -4,6 +4,11 @@ A simple API that allows KBase community developers to interact with the Relatio ## HTTP API +The API is a small, rest-ish service where all data is in JSON format. Replace the `{root_url}` in the examples below with one of: + * Production: `https://kbase.us/services/relation_engine_api` + * Staging: `https://ci.kbase.us/services/relation_engine_api` + * App-dev: `https://appdev.kbase.us/services/relation_engine_api` + ### GET / Returns server status info @@ -15,7 +20,7 @@ Return a list of view names. _Example request_ ```sh -$ curl -X GET http://relation_engine/api/views +$ curl -X GET http://{root_url}/api/views ``` _Example response_ @@ -30,7 +35,7 @@ Fetch the registered schema names. _Example request_ ```sh -$ curl -X GET http://relation_engine/api/schemas +$ curl -X GET http://{root_url}/api/schemas ``` _Example response_ @@ -49,7 +54,7 @@ Get the AQL source code for a view _Example request_ ```sh -$ curl http://relation_engine/api/views/example_view1 +$ curl http://{root_url}/api/views/example_view1 ``` Response has mimetype of text/plain @@ -70,7 +75,7 @@ Get the JSON source for a registered schema by name. _Example request_ ```sh -$ curl http://relation_engine/api/schemas/vertex_examples1 +$ curl http://{root_url}/api/schemas/vertex_examples1 ``` _Example response_ @@ -90,7 +95,7 @@ Run a query using a view or a cursor ID. Semantically, this is a GET, but it's a _Example rquest_ ```sh -$ curl -X POST -d '{"argument": "value"}' http://relation_engine/api/query_results?view=example +$ curl -X POST -d '{"argument": "value"}' http://{root_url}/api/query_results?view=example ``` _Query params_ @@ -158,7 +163,7 @@ System admins can run ad-hoc queries by specifying a "query" property in the JSO ```sh $ curl -d '{"query": "for v in coll sort rand() limit @count return v", "count": 1}' \ - http://relation_engine/api/query_results + http://{root_url}/api/query_results ``` This will return the same form of results as above. @@ -170,7 +175,7 @@ Bulk-update documents by either creating, replacing, or updating. _Example_ ```sh -$ curl -X PUT http://relation_engine/api/documents?collection=genes&on_duplicate=update +$ curl -X PUT http://{root_url}/api/documents?collection=genes&on_duplicate=update ``` _Query params_ @@ -233,7 +238,7 @@ Manually check and pull spec updates. Requires sysadmin auth. _Example_ ``` -$ curl http://relation_engine/api/update_specs +$ curl http://{root_url}/api/update_specs ``` _Query params_ @@ -309,25 +314,18 @@ Where the file contains multiple JSON documents separated by line-breaks. ## Development -Copy `.env.example` to `.env`. Start the server with `docker-compose up`. - -Run tests with `make test` (the server should be running in another terminal using `docker-compose up --build`). +See the [Contribution Guidelines](/.github/CONTRIBUTING.md). -The docker image is pushed to Docker Hub when new commits are made to master. The script that runs when pushing to docker hub is found in `hooks/build`. +**Start the server** with `docker-compose up --build`. -## Building and publishing the client +**Run tests** with `make test` (the server should be running in another terminal using `docker-compose up --build`). -The client package is built with setuptools and published to anaconda, where it can then be installed via pip or conda. +## Deployment -```sh -$ make build-client -$ make publish-client -``` +The docker image is pushed to Docker Hub when new commits are made to master. The script that runs when pushing to docker hub is found in `hooks/build`. ## Project anatomy * Source code is in `./src` * Tests are in `./src/test` -* The main server code is in `./src/relation_engine_server/__main__.py` -* API v1 endpoints are in `./src/relation_engine_server/api/api_v1.py` -* A python client package is in `./src/relation_engine_client` +* The main server code is in `./src/relation_engine_server`. From 3e91917790c700310e3d3c4355bedd4db9392fc6 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Fri, 1 Mar 2019 15:12:42 -0800 Subject: [PATCH 249/732] Write the versioning system --- .../api_modules/__init__.py | 0 .../api_modules/api_v1.py | 115 ++++++++ api/src/relation_engine_server/exceptions.py | 10 + api/src/relation_engine_server/server.py | 255 +++++++----------- .../utils/bulk_import.py | 21 +- .../utils/parse_json.py | 11 + api/src/test/{test_api.py => test_api_v1.py} | 84 +++--- 7 files changed, 296 insertions(+), 200 deletions(-) create mode 100644 api/src/relation_engine_server/api_modules/__init__.py create mode 100644 api/src/relation_engine_server/api_modules/api_v1.py create mode 100644 api/src/relation_engine_server/utils/parse_json.py rename api/src/test/{test_api.py => test_api_v1.py} (88%) diff --git a/api/src/relation_engine_server/api_modules/__init__.py b/api/src/relation_engine_server/api_modules/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/api/src/relation_engine_server/api_modules/api_v1.py b/api/src/relation_engine_server/api_modules/api_v1.py new file mode 100644 index 00000000..f90edf46 --- /dev/null +++ b/api/src/relation_engine_server/api_modules/api_v1.py @@ -0,0 +1,115 @@ +import flask +from ..utils import arango_client, spec_loader, auth, bulk_import, pull_spec, config, parse_json +from ..exceptions import InvalidParameters + + +def show_views(): + """Handle /views.""" + name = flask.request.args.get('name') + if name: + return {'view': spec_loader.get_view(name)} + return spec_loader.get_view_names() + + +def show_schemas(): + """Handle /schemas.""" + name = flask.request.args.get('name') + if name: + return spec_loader.get_schema(name) + return spec_loader.get_schema_names() + + +def run_query(): + """ + Run a stored view as a query against the database. + Auth: + - only kbase re admins for ad-hoc queries + - public for views (views will 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 + json_body['ws_ids'] = auth.get_workspace_ids(auth_token) + # fetch number of documents to return + batch_size = int(flask.request.args.get('batch_size', 100)) + if 'query' in json_body: + # Run an adhoc query for a sysadmin + auth.require_auth_token(roles=['RE_ADMIN']) + query_text = json_body['query'] + del json_body['query'] + resp_body = arango_client.run_query(query_text=query_text, + bind_vars=json_body, + batch_size=batch_size) + return resp_body + if 'view' in flask.request.args: + # Run a query from a view name + view_name = flask.request.args['view'] + view_source = spec_loader.get_view(view_name) + resp_body = arango_client.run_query(query_text=view_source, + bind_vars=json_body, + batch_size=batch_size) + return resp_body + if 'cursor_id' in flask.request.args: + # Run a query from a cursor ID + cursor_id = flask.request.args['cursor_id'] + resp_body = arango_client.run_query(cursor_id=cursor_id) + return resp_body + # No valid options were passed + raise InvalidParameters('Pass in a view or a cursor_id') + + +def update_specs(): + """ + Manually check for updates, download spec releases, and init new collections. + Auth: admin + """ + auth.require_auth_token(['RE_ADMIN']) + init_collections = 'init_collections' in flask.request.args + release_url = flask.request.args.get('release_url') + pull_spec.download_specs(init_collections, release_url) + return {'status': 'updated'} + + +def save_documents(): + """ + Create, update, or replace many documents in a batch. + Auth: admin + """ + auth.require_auth_token(['RE_ADMIN']) + collection_name = flask.request.args['collection'] + query = {'collection': collection_name, 'type': 'documents'} + if flask.request.args.get('display_errors'): + # Display an array of error messages + query['details'] = 'true' + if flask.request.args.get('on_duplicate'): + query['onDuplicate'] = flask.request.args['on_duplicate'] + if flask.request.args.get('overwrite'): + query['overwrite'] = 'true' + resp_text = bulk_import.bulk_import(query) + return resp_text + + +def show_config(): + """Show public config data.""" + conf = config.get_config() + return { + 'auth_url': conf['auth_url'], + 'workspace_url': conf['workspace_url'], + 'kbase_endpoint': conf['kbase_endpoint'], + 'db_url': conf['db_url'], + 'db_name': conf['db_name'], + 'spec_url': conf['spec_url'] + } + + +endpoints = { + 'query_results': {'handler': run_query, 'methods': {'POST'}}, + 'specs/schemas': {'handler': show_schemas}, + 'specs/views': {'handler': show_views}, + 'config': {'handler': show_config}, + 'specs': {'handler': update_specs, 'methods': {'PUT'}}, + 'documents': {'handler': save_documents, 'methods': {'PUT'}} +} +deprecations = {} # type: ignore diff --git a/api/src/relation_engine_server/exceptions.py b/api/src/relation_engine_server/exceptions.py index d67b912a..5fda77d2 100644 --- a/api/src/relation_engine_server/exceptions.py +++ b/api/src/relation_engine_server/exceptions.py @@ -3,7 +3,16 @@ """ +class InvalidParameters(Exception): + """Invalid request parameters.""" + + def __init__(self, msg): self.msg = msg + + def __str__(self): return self.msg + + class MissingHeader(Exception): + """Missing required header ina request.""" def __init__(self, header_name): self.header_name = header_name @@ -13,6 +22,7 @@ def __str__(self): class UnauthorizedAccess(Exception): + "Authentication failed for an authorization header.""" def __init__(self, auth_url, response): self.auth_url = auth_url diff --git a/api/src/relation_engine_server/server.py b/api/src/relation_engine_server/server.py index 9862fb26..30a94160 100644 --- a/api/src/relation_engine_server/server.py +++ b/api/src/relation_engine_server/server.py @@ -1,4 +1,5 @@ """The main entrypoint for running the Flask server.""" +import re import flask import json import os @@ -6,8 +7,13 @@ import traceback from jsonschema.exceptions import ValidationError -from .exceptions import MissingHeader, UnauthorizedAccess -from .utils import arango_client, spec_loader, auth, bulk_import, pull_spec, config +from .exceptions import MissingHeader, UnauthorizedAccess, InvalidParameters +from .utils import arango_client, spec_loader +from .api_modules import api_v1 + +# All api version modules, from oldest to newest +_API_VERSIONS = [api_v1.endpoints] +_API_DEPRECATIONS = [api_v1.deprecations] app = flask.Flask(__name__) app.config['DEBUG'] = os.environ.get('FLASK_DEBUG', True) @@ -25,137 +31,90 @@ def root(): commit_hash = 'unknown' arangodb_status = arango_client.server_status() repo_url = 'https://github.com/kbase/relation_engine_api.git' - return flask.jsonify({ + body = { 'arangodb_status': arangodb_status, 'commit_hash': commit_hash, 'repo_url': repo_url - }) - - -@app.route('/config', methods=['GET']) -def show_config(): - conf = config.get_config() - return flask.jsonify({ - 'auth_url': conf['auth_url'], - 'workspace_url': conf['workspace_url'], - 'kbase_endpoint': conf['kbase_endpoint'], - 'db_url': conf['db_url'], - 'db_name': conf['db_name'], - 'spec_url': conf['spec_url'] - }) - - -@app.route('/api/views', methods=['GET']) -def show_views(): - """ - Fetch view names and content. - Auth: public - """ - return flask.jsonify(spec_loader.get_view_names()) - - -@app.route('/api/query_results', methods=['POST']) -def run_query(): - """ - Run a stored view as a query against the database. - Auth: - - only kbase re admins for ad-hoc queries - - public for views (views will have access controls within them based on params) - """ - # Note that flask.request.json only works if the request Content-Type is application/json - json_body = json.loads(flask.request.get_data() 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 - json_body['ws_ids'] = auth.get_workspace_ids(auth_token) - # fetch number of documents to return - batch_size = int(flask.request.args.get('batch_size', 100)) - if 'query' in json_body: - # Run an adhoc query for a sysadmin - auth.require_auth_token(roles=['RE_ADMIN']) - query_text = json_body['query'] - del json_body['query'] - resp_body = arango_client.run_query(query_text=query_text, - bind_vars=json_body, - batch_size=batch_size) - return flask.jsonify(resp_body) - if 'view' in flask.request.args: - # Run a query from a view name - view_name = flask.request.args['view'] - view_source = spec_loader.get_view(view_name) - resp_body = arango_client.run_query(query_text=view_source, - bind_vars=json_body, - batch_size=batch_size) - 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'] - resp_body = arango_client.run_query(cursor_id=cursor_id) - return flask.jsonify(resp_body) - # No valid options were passed - resp_body = {'error': 'Pass in a view or a cursor_id'} - return (flask.jsonify(resp_body), 400) - - -@app.route('/api/schemas', methods=['GET']) -def show_schemas(): - """ - Fetch schema names and content. - Auth: public - """ - return flask.jsonify(spec_loader.get_schema_names()) - - -@app.route('/api/schemas/', methods=['GET']) -def show_schema(name): - """ - Fetch the JSON for a single schema. - Auth: public - """ - return flask.jsonify(spec_loader.get_schema(name)) - - -@app.route('/api/views/', methods=['GET']) -def show_view(name): - """ - Fetch the AQL for a single view. - Auth: public - """ - return flask.Response(spec_loader.get_view(name), mimetype='text/plain') - - -@app.route('/api/update_specs', methods=['GET']) -def refresh_specs(): - """ - Manually check for updates, download spec releases, and init new collections. - Auth: admin - """ - auth.require_auth_token(['RE_ADMIN']) - init_collections = 'init_collections' in flask.request.args - release_url = flask.request.args.get('release_url') - pull_spec.download_specs(init_collections, release_url) - return flask.jsonify({'status': 'updated'}) + } + return _json_resp(body) -@app.route('/api/documents', methods=['PUT']) -def save_documents(): +@app.route('/api/', methods=['GET', 'PUT', 'POST', 'DELETE']) +def api_call(path): """ - Create, update, or replace many documents in a batch. - Auth: admin + Handle an api request, dispatching it to the appropriate versioned module. + + Versioning system: + - Every API version is a discrete python module that contains an 'endpoints' dictionary. + - New versions don't need to redefine previous endpoints. + - If an endpoint is not defined, we fall back to a previous version. + - New versions can overwrite existing methods and add new ones. + - Versions are simple incrementing integers. We only need a new version for breaking changes. + - New modules can deprecate paths by putting them under the 'deprecations' key + Note that endpoints cannot be removed with new versions, only overwritten or added. """ - auth.require_auth_token(['RE_ADMIN']) - collection_name = flask.request.args['collection'] - query = {'collection': collection_name, 'type': 'documents'} - if flask.request.args.get('display_errors'): - # Display an array of error messages - query['details'] = 'true' - if flask.request.args.get('on_duplicate'): - query['onDuplicate'] = flask.request.args['on_duplicate'] - if flask.request.args.get('overwrite'): - query['overwrite'] = 'true' - resp_text = bulk_import.bulk_import(query) - return resp_text + path_parts = path.split('/') + version_int = _get_version(path_parts[0]) + # Get the path and version number + api_path = '/'.join(path_parts[1:]) + # Flag for whether the endpoint we find is deprecated + deprecated = False + # Find our method in the various versioned modules + # If it is not present in a later version, fall back to a previous version + # Iterates by starting at (version-1), stopping at 0, and stepping backwards + # Note: the mypy type checker has difficulties with the path_funcs dicts, so we ignore type checking below + for ver in range(version_int - 1, -1, -1): + path_funcs = _API_VERSIONS[ver] + deprecations = _API_DEPRECATIONS[ver] + if api_path in deprecations: + # We found a deprecation flag on the endpoint + deprecated = True + if api_path in path_funcs: + methods = path_funcs[api_path].get('methods', {'GET'}) # type: ignore + # Mypy is not able to infer that `methods` will always be a set + if flask.request.method not in methods: # type: ignore + return (flask.jsonify({'error': '405 - Method not allowed.'}), 405) + # We found a matching function for the endpoint and method + func = path_funcs[api_path]['handler'] # type: ignore + # Mypy is not able to infer that this is a function + result = func() # type: ignore + return _json_resp(result, 200, deprecated) + body = {'error': f'path not found: {api_path}'} + return _json_resp(body, 404) + + +def _get_version(version_str): + """From a list of path parts, initialize and validate a version int for the api.""" + ver_len = len(_API_VERSIONS) + # Make sure the version looks like 'v12' + if not re.match(r'^v\d+$', version_str): + raise InvalidParameters('Make a request with the format /api//') + # Parse to an int + version_int = int(version_str.replace('v', '')) + # Make sure the version number is valid + if version_int <= 0: + raise InvalidParameters('API version must be > 0') + if version_int > ver_len: + raise InvalidParameters(f'Invalid api version; max is {ver_len}') + return version_int + + +def _json_resp(result, status=200, deprecated=False): + """Send a json response back to the requester with the proper headers.""" + resp = flask.Response(json.dumps(result)) + resp.status_code = status + if deprecated: + # Add a deprecation warning in the headers + resp.headers['Warning'] = 'DEPRECATED' + print(' '.join([flask.request.method, flask.request.path, '->', resp.status])) + # Enable CORS + resp.headers['Access-Control-Allow-Origin'] = '*' + env_allowed_headers = os.environ.get('HTTP_ACCESS_CONTROL_REQUEST_HEADERS', 'authorization') + resp.headers['Access-Control-Allow-Headers'] = env_allowed_headers + # Set JSON content type and response length + resp.headers['Content-Type'] = 'application/json' + resp.headers['Content-Length'] = resp.calculate_content_length() + return resp @app.errorhandler(json.decoder.JSONDecodeError) @@ -168,7 +127,7 @@ def json_decode_error(err): 'lineno': err.lineno, 'colno': err.colno } - return (flask.jsonify(resp), 400) + return _json_resp(resp, 400) @app.errorhandler(arango_client.ArangoServerError) @@ -177,18 +136,22 @@ def arango_server_error(err): 'error': str(err), 'arango_message': err.resp_json['errorMessage'] } - return (flask.jsonify(resp), 400) + return _json_resp(resp, 400) + + +@app.errorhandler(InvalidParameters) +def invalid_params(err): + """Invalid request body json params.""" + resp = {'error': str(err)} + return _json_resp(resp, 400) @app.errorhandler(spec_loader.SchemaNonexistent) @app.errorhandler(spec_loader.ViewNonexistent) def view_does_not_exist(err): """General error cases.""" - resp = { - 'error': str(err), - 'name': err.name - } - return (flask.jsonify(resp), 400) + resp = {'error': str(err), 'name': err.name} + return _json_resp(resp, 400) @app.errorhandler(ValidationError) @@ -201,7 +164,7 @@ def validation_error(err): 'validator_value': err.validator_value, 'schema': err.schema } - return (flask.jsonify(resp), 400) + return _json_resp(resp, 400) @app.errorhandler(UnauthorizedAccess) @@ -211,22 +174,22 @@ def unauthorized_access(err): 'auth_url': err.auth_url, 'auth_response': err.response } - return (flask.jsonify(resp), 403) + return _json_resp(resp, 403) @app.errorhandler(404) def page_not_found(err): - return (flask.jsonify({'error': '404 - Not found.'}), 404) + return _json_resp({'error': '404 - Not found.'}, 404) @app.errorhandler(405) def method_not_allowed(err): - return (flask.jsonify({'error': '405 - Method not allowed.'}), 405) + return _json_resp({'error': '405 - Method not allowed.'}, 405) @app.errorhandler(MissingHeader) def generic_400(err): - return (flask.jsonify({'error': str(err)}), 400) + return _json_resp({'error': str(err)}, 400) # Any other unhandled exceptions -> 500 @@ -242,18 +205,4 @@ def server_error(err): # if os.environ.get('FLASK_DEBUG'): TODO resp['error_class'] = err.__class__.__name__ resp['error_details'] = str(err) - return (flask.jsonify(resp), 500) - - -@app.after_request -def after_request(response): - """Actions to perform on the response after the request handler finishes running.""" - print(' '.join([flask.request.method, flask.request.path, '->', response.status])) - # Enable CORS - response.headers['Access-Control-Allow-Origin'] = '*' - env_allowed_headers = os.environ.get('HTTP_ACCESS_CONTROL_REQUEST_HEADERS', 'authorization') - response.headers['Access-Control-Allow-Headers'] = env_allowed_headers - # Set JSON content type and response length - response.headers['Content-Type'] = 'application/json' - response.headers['Content-Length'] = response.calculate_content_length() - return response + return _json_resp(resp, 500) diff --git a/api/src/relation_engine_server/utils/bulk_import.py b/api/src/relation_engine_server/utils/bulk_import.py index 6b1a5da5..d41ab850 100644 --- a/api/src/relation_engine_server/utils/bulk_import.py +++ b/api/src/relation_engine_server/utils/bulk_import.py @@ -1,9 +1,9 @@ +import os import tempfile import flask import json import jsonschema import hashlib -import os from . import spec_loader from .arango_client import import_from_file @@ -16,16 +16,25 @@ def bulk_import(query_params): arango client. """ schema = spec_loader.get_schema(query_params['collection']) - with tempfile.NamedTemporaryFile(mode='a', delete=False) as temp_fd: - # temp_fd is closed and deleted when the context ends + # We can't use a context manager here + # We need to close the file to have the file contents readable + # and we need to prevent deletion of the temp file on close (default behavior of tempfiles) + temp_fd = tempfile.NamedTemporaryFile(mode='a', delete=False) + try: + # Stream request data line-by-line + # Parse each line to json, validate the schema, and write to a file for line in flask.request.stream: json_line = json.loads(line) jsonschema.validate(json_line, schema) json_line = _write_edge_key(json_line) temp_fd.write(json.dumps(json_line) + '\n') - resp_text = import_from_file(temp_fd.name, query_params) - os.remove(temp_fd.name) - return resp_text + temp_fd.close() + resp_text = import_from_file(temp_fd.name, query_params) + resp_json = json.loads(resp_text) + finally: + # Always remove the temp file + os.remove(temp_fd.name) + return resp_json def _write_edge_key(json_line): diff --git a/api/src/relation_engine_server/utils/parse_json.py b/api/src/relation_engine_server/utils/parse_json.py new file mode 100644 index 00000000..d0dcf8e6 --- /dev/null +++ b/api/src/relation_engine_server/utils/parse_json.py @@ -0,0 +1,11 @@ +import json +import flask + + +def get_json_body(): + """Parse json out of a request body, if present.""" + json_body = None # type: ignore + req_data = flask.request.get_data() + if req_data: + json_body = json.loads(req_data) + return json_body diff --git a/api/src/test/test_api.py b/api/src/test/test_api_v1.py similarity index 88% rename from api/src/test/test_api.py rename to api/src/test/test_api_v1.py index 6d45063b..7356859c 100644 --- a/api/src/test/test_api.py +++ b/api/src/test/test_api_v1.py @@ -15,6 +15,8 @@ # Use the docker-compose url of the running flask server URL = os.environ.get('TEST_URL', 'http://web:5000') +VERSION = 'v1' +API_URL = '/'.join([URL, 'api', VERSION]) HEADERS_NON_ADMIN = {'Authorization': 'Bearer ' + NON_ADMIN_TOKEN, 'Content-Type': 'application/json'} HEADERS_ADMIN = {'Authorization': 'Bearer ' + ADMIN_TOKEN, 'Content-Type': 'application/json'} @@ -42,7 +44,7 @@ def save_test_docs(count, edges=False): docs = create_test_docs(count) collection = 'test_vertex' return requests.put( - URL + '/api/documents', + API_URL + '/documents', params={'overwrite': True, 'collection': collection}, data=docs, headers=HEADERS_ADMIN @@ -54,10 +56,10 @@ class TestApi(unittest.TestCase): @classmethod def setUpClass(cls): # Initialize collections before running any tests - resp = requests.get( - URL + '/api/update_specs', + resp = requests.put( + API_URL + '/specs', headers=HEADERS_ADMIN, - params={'reset': '1', 'init_collections': '1'} + params={'init_collections': '1'} ) print('update_specs response', resp.text) @@ -70,7 +72,7 @@ def test_root(self): def test_config(self): """Test config fetch.""" - resp = requests.get(URL + '/config').json() + resp = requests.get(API_URL + '/config').json() self.assertTrue(len(resp['auth_url'])) self.assertTrue(len(resp['workspace_url'])) self.assertTrue(len(resp['kbase_endpoint'])) @@ -80,8 +82,8 @@ def test_config(self): def test_update_specs(self): """Test the endpoint that triggers an update on the specs.""" - resp = requests.get( - URL + '/api/update_specs', + resp = requests.put( + API_URL + '/specs', headers=HEADERS_ADMIN, params={'reset': '1', 'init_collections': '1'} ) @@ -91,17 +93,17 @@ def test_update_specs(self): def test_list_views(self): """Test the listing out of saved AQL views.""" - resp = requests.get(URL + '/api/views').json() + resp = requests.get(API_URL + '/specs/views').json() self.assertTrue('list_test_vertices' in resp) def test_show_view(self): """Test the endpoint that displays AQL source code for one view.""" - resp = requests.get(URL + '/api/views/list_test_vertices').text + resp = requests.get(API_URL + '/specs/views?name=list_test_vertices').text self.assertTrue('test_vertex' in resp) def test_list_schemas(self): """Test the listing out of registered JSON schemas for vertices and edges.""" - resp = requests.get(URL + '/api/schemas').json() + resp = requests.get(API_URL + '/specs/schemas').json() self.assertTrue('test_vertex' in resp['vertices']) self.assertTrue('test_edge' in resp['edges']) self.assertFalse('error' in resp) @@ -109,22 +111,22 @@ def test_list_schemas(self): def test_show_schema(self): """Test the endpoint that displays the JSON source for one schema.""" - resp = requests.get(URL + '/api/schemas/test_edge').text + resp = requests.get(API_URL + '/specs/schemas?name=test_edge').text self.assertTrue('_from' in resp) - resp = requests.get(URL + '/api/schemas/test_vertex').text + resp = requests.get(API_URL + '/specs/schemas?name=test_vertex').text self.assertTrue('_key' in resp) def test_save_documents_missing_auth(self): """Test an invalid attempt to save a doc with a missing auth token.""" resp = requests.put( - URL + '/api/documents?on_duplicate=error&overwrite=true&collection' + API_URL + '/documents?on_duplicate=error&overwrite=true&collection' ).json() self.assertEqual(resp['error'], 'Missing header: Authorization') def test_save_documents_invalid_auth(self): """Test an invalid attempt to save a doc with a bad auth token.""" resp = requests.put( - URL + '/api/documents?on_duplicate=error&overwrite=true&collection', + API_URL + '/documents?on_duplicate=error&overwrite=true&collection', headers={'Authorization': 'Bearer ' + INVALID_TOKEN} ).json() self.assertEqual(resp['error'], '403 - Unauthorized') @@ -132,7 +134,7 @@ def test_save_documents_invalid_auth(self): def test_save_documents_non_admin(self): """Test an invalid attempt to save a doc as a non-admin.""" resp = requests.put( - URL + '/api/documents?on_duplicate=error&overwrite=true&collection', + API_URL + '/documents?on_duplicate=error&overwrite=true&collection', headers=HEADERS_NON_ADMIN ).json() self.assertEqual(resp['error'], '403 - Unauthorized') @@ -140,7 +142,7 @@ def test_save_documents_non_admin(self): def test_save_documents_invalid_schema(self): """Test the case where some documents fail against their schema.""" resp = requests.put( - URL + '/api/documents', + API_URL + '/documents', params={'on_duplicate': 'ignore', 'collection': 'test_vertex'}, data='{"name": "x"}\n{"name": "y"}', headers=HEADERS_ADMIN @@ -154,7 +156,7 @@ def test_save_documents_invalid_schema(self): def test_save_documents_missing_schema(self): """Test the case where the collection/schema does not exist.""" resp = requests.put( - URL + '/api/documents', + API_URL + '/documents', params={'collection': 'xyzabc'}, data='', headers=HEADERS_ADMIN @@ -164,7 +166,7 @@ def test_save_documents_missing_schema(self): def test_save_documents_invalid_json(self): """Test an attempt to save documents with an invalid JSON body.""" resp = requests.put( - URL + '/api/documents', + API_URL + '/documents', params={'collection': 'test_vertex'}, data='\n', headers=HEADERS_ADMIN @@ -188,7 +190,7 @@ def test_create_edges(self): def test_update_documents(self): """Test updating existing documents.""" resp = requests.put( - URL + '/api/documents', + API_URL + '/documents', params={'on_duplicate': 'update', 'collection': 'test_vertex'}, data=create_test_docs(3), headers=HEADERS_ADMIN @@ -199,7 +201,7 @@ def test_update_documents(self): def test_update_edge(self): """Test updating existing edge.""" resp = requests.put( - URL + '/api/documents', + API_URL + '/documents', params={'on_duplicate': 'update', 'collection': 'test_edge'}, data=create_test_edges(3), headers=HEADERS_ADMIN @@ -210,7 +212,7 @@ def test_update_edge(self): def test_replace_documents(self): """Test replacing of existing documents.""" resp = requests.put( - URL + '/api/documents', + API_URL + '/documents', params={'on_duplicate': 'replace', 'collection': 'test_vertex'}, data=create_test_docs(3), headers=HEADERS_ADMIN @@ -222,7 +224,7 @@ def test_save_documents_dupe_errors(self): """Test where we want to raise errors on duplicate documents.""" save_test_docs(3) resp = requests.put( - URL + '/api/documents', + API_URL + '/documents', params={'on_duplicate': 'error', 'collection': 'test_vertex', 'display_errors': '1'}, data=create_test_docs(3), headers=HEADERS_ADMIN @@ -234,7 +236,7 @@ def test_save_documents_dupe_errors(self): def test_save_documents_ignore_dupes(self): """Test ignoring duplicate, existing documents when saving.""" resp = requests.put( - URL + '/api/documents', + API_URL + '/documents', params={'on_duplicate': 'ignore', 'collection': 'test_vertex'}, data=create_test_docs(3), headers=HEADERS_ADMIN @@ -247,7 +249,7 @@ def test_admin_query(self): save_test_docs(1) query = 'let ws_ids = @ws_ids for v in test_vertex sort rand() limit @count return v._id' resp = requests.post( - URL + '/api/query_results', + API_URL + '/query_results', params={}, headers=HEADERS_ADMIN, data=json.dumps({'query': query, 'count': 1}) @@ -259,7 +261,7 @@ def test_admin_query_non_admin(self): """Test an ad-hoc query error as a non-admin.""" query = 'let ws_ids = @ws_ids for v in test_vertex sort rand() limit @count return v._id' resp = requests.post( - URL + '/api/query_results', + API_URL + '/query_results', params={}, headers=HEADERS_NON_ADMIN, data=json.dumps({'query': query, 'count': 1}) @@ -270,7 +272,7 @@ def test_admin_query_invalid_auth(self): """Test the error response for an ad-hoc admin query without auth.""" query = 'let ws_ids = @ws_ids for v in test_vertex sort rand() limit @count return v._id' resp = requests.post( - URL + '/api/query_results', + API_URL + '/query_results', params={}, headers={'Authorization': INVALID_TOKEN}, data=json.dumps({'query': query, 'count': 1}) @@ -281,7 +283,7 @@ def test_query_with_cursor(self): """Test getting more data via a query cursor and setting batch size.""" save_test_docs(count=20) resp = requests.post( - URL + '/api/query_results', + API_URL + '/query_results', params={'view': 'list_test_vertices', 'batch_size': 10} ).json() self.assertTrue(resp['cursor_id']) @@ -290,7 +292,7 @@ def test_query_with_cursor(self): self.assertTrue(len(resp['results']), 10) cursor_id = resp['cursor_id'] resp = requests.post( - URL + '/api/query_results', + API_URL + '/query_results', params={'cursor_id': cursor_id} ).json() self.assertEqual(resp['count'], 20) @@ -299,7 +301,7 @@ def test_query_with_cursor(self): self.assertTrue(len(resp['results']), 10) # Try to get the same cursor again resp = requests.post( - URL + '/api/query_results', + API_URL + '/query_results', params={'cursor_id': cursor_id} ).json() self.assertTrue(resp['error']) @@ -308,7 +310,7 @@ def test_query_with_cursor(self): def test_query_no_name(self): """Test a query error with a view name that does not exist.""" resp = requests.post( - URL + '/api/query_results', + API_URL + '/query_results', params={'view': 'nonexistent'} ).json() self.assertEqual(resp['error'], 'View does not exist.') @@ -317,7 +319,7 @@ def test_query_no_name(self): def test_query_missing_bind_var(self): """Test a query error with a missing bind variable.""" resp = requests.post( - URL + '/api/query_results', + API_URL + '/query_results', params={'view': 'list_test_vertices'}, data=json.dumps({'xyz': 'test_vertex'}) ).json() @@ -329,7 +331,7 @@ def test_auth_query_with_access(self): ws_id = 3 # Remove all test vertices and create one with a ws_id requests.put( - URL + '/api/documents', + API_URL + '/documents', params={'overwrite': True, 'collection': 'test_vertex'}, data=json.dumps({ 'name': 'requires_auth', @@ -339,7 +341,7 @@ def test_auth_query_with_access(self): headers=HEADERS_ADMIN ) resp = requests.post( - URL + '/api/query_results', + API_URL + '/query_results', params={'view': 'list_test_vertices'}, headers={'Authorization': 'valid_token'} # see ./mock_workspace/endpoints.json ).json() @@ -350,13 +352,13 @@ def test_auth_query_no_access(self): """Test the case where we try to query a collection without the right workspace access.""" # Remove all test vertices and create one with a ws_id requests.put( - URL + '/api/documents', + API_URL + '/documents', params={'overwrite': True, 'collection': 'test_vertex'}, data='{"name": "requires_auth", "_key": "1", "ws_id": 9999}', headers=HEADERS_ADMIN ) resp = requests.post( - URL + '/api/query_results', + API_URL + '/query_results', params={'view': 'list_test_vertices'}, headers={'Authorization': 'valid_token'} # see ./mock_workspace/endpoints.json ).json() @@ -366,13 +368,13 @@ def test_query_cannot_pass_ws_ids(self): """Test that users cannot set the ws_ids param.""" ws_id = 99 requests.put( - URL + '/api/documents', + API_URL + '/documents', params={'overwrite': True, 'collection': 'test_vertex'}, data='{"name": "requires_auth", "_key": "1", "ws_id": 99}', headers=HEADERS_ADMIN ) resp = requests.post( - URL + '/api/query_results', + API_URL + '/query_results', params={'view': 'list_test_vertices'}, data=json.dumps({'ws_ids': [ws_id]}), headers={'Authorization': 'valid_token'} @@ -382,13 +384,13 @@ def test_query_cannot_pass_ws_ids(self): def test_auth_query_invalid_token(self): """Test the case where we try to authorize a query using an invalid auth token.""" requests.put( - URL + '/api/documents', + API_URL + '/documents', params={'overwrite': True, 'collection': 'test_vertex'}, data='{"name": "requires_auth", "_key": "1", "ws_id": 99}', headers=HEADERS_ADMIN ) resp = requests.post( - URL + '/api/query_results', + API_URL + '/query_results', params={'view': 'list_test_vertices'}, data=json.dumps({'ws_ids': [1]}), headers={'Authorization': INVALID_TOKEN} @@ -399,7 +401,7 @@ def test_auth_adhoc_query(self): """Test that the 'ws_ids' bind-var is set for RE_ADMINs.""" ws_id = 99 requests.put( - URL + '/api/documents', + API_URL + '/documents', params={'overwrite': True, 'collection': 'test_vertex'}, data=json.dumps({'name': 'requires_auth', 'key': '1', 'ws_id': ws_id}), headers={'Authorization': 'valid_token'} @@ -407,7 +409,7 @@ def test_auth_adhoc_query(self): # This is the same query as list_test_vertices.aql in the spec query = 'for o in test_vertex filter o.is_public || o.ws_id IN @ws_ids return o' resp = requests.post( - URL + '/api/query_results', + API_URL + '/query_results', data=json.dumps({'query': query}), headers={'Authorization': ADMIN_TOKEN} # see ./mock_workspace/endpoints.json ).json() From da37873bfbd0b22b36209694f66da27db905c3c2 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Fri, 1 Mar 2019 15:27:20 -0800 Subject: [PATCH 250/732] Remove http and $ from curl examples --- api/README.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/api/README.md b/api/README.md index baa95ed9..c21330c0 100644 --- a/api/README.md +++ b/api/README.md @@ -20,7 +20,7 @@ Return a list of view names. _Example request_ ```sh -$ curl -X GET http://{root_url}/api/views +curl -X GET {root_url}/api/views ``` _Example response_ @@ -35,7 +35,7 @@ Fetch the registered schema names. _Example request_ ```sh -$ curl -X GET http://{root_url}/api/schemas +curl -X GET {root_url}/api/schemas ``` _Example response_ @@ -54,7 +54,7 @@ Get the AQL source code for a view _Example request_ ```sh -$ curl http://{root_url}/api/views/example_view1 +curl {root_url}/api/views/example_view1 ``` Response has mimetype of text/plain @@ -75,7 +75,7 @@ Get the JSON source for a registered schema by name. _Example request_ ```sh -$ curl http://{root_url}/api/schemas/vertex_examples1 +curl {root_url}/api/schemas/vertex_examples1 ``` _Example response_ @@ -95,7 +95,7 @@ Run a query using a view or a cursor ID. Semantically, this is a GET, but it's a _Example rquest_ ```sh -$ curl -X POST -d '{"argument": "value"}' http://{root_url}/api/query_results?view=example +curl -X POST -d '{"argument": "value"}' {root_url}/api/query_results?view=example ``` _Query params_ @@ -162,8 +162,8 @@ Results are limited to 100 items. To continue fetching additional results, use t System admins can run ad-hoc queries by specifying a "query" property in the JSON request body. ```sh -$ curl -d '{"query": "for v in coll sort rand() limit @count return v", "count": 1}' \ - http://{root_url}/api/query_results +curl -d '{"query": "for v in coll sort rand() limit @count return v", "count": 1}' \ + {root_url}/api/query_results ``` This will return the same form of results as above. @@ -175,7 +175,7 @@ Bulk-update documents by either creating, replacing, or updating. _Example_ ```sh -$ curl -X PUT http://{root_url}/api/documents?collection=genes&on_duplicate=update +curl -X PUT {root_url}/api/documents?collection=genes&on_duplicate=update ``` _Query params_ @@ -238,7 +238,7 @@ Manually check and pull spec updates. Requires sysadmin auth. _Example_ ``` -$ curl http://{root_url}/api/update_specs +curl {root_url}/api/update_specs ``` _Query params_ From c5122d6759605d3a1a45be2847882d36493055d8 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Fri, 1 Mar 2019 16:52:44 -0800 Subject: [PATCH 251/732] Set up a basic view testing system using docker-compose with an example test module --- spec/Dockerfile | 5 + spec/Makefile | 6 +- spec/docker-compose.yaml | 50 ++++++++++ .../mock_services/mock_auth/endpoints.json | 96 +++++++++++++++++++ .../mock_workspace/endpoints.json | 64 +++++++++++++ spec/test/views/__init__.py | 0 spec/test/views/init_spec.py | 12 +++ spec/test/views/test_list_test_vertices.py | 46 +++++++++ 8 files changed, 276 insertions(+), 3 deletions(-) create mode 100644 spec/Dockerfile create mode 100644 spec/docker-compose.yaml create mode 100644 spec/test/mock_services/mock_auth/endpoints.json create mode 100644 spec/test/mock_services/mock_workspace/endpoints.json create mode 100644 spec/test/views/__init__.py create mode 100644 spec/test/views/init_spec.py create mode 100644 spec/test/views/test_list_test_vertices.py diff --git a/spec/Dockerfile b/spec/Dockerfile new file mode 100644 index 00000000..e3406dc8 --- /dev/null +++ b/spec/Dockerfile @@ -0,0 +1,5 @@ +from python:3.7-slim + +RUN pip install --upgrade pip requests + +COPY . /app diff --git a/spec/Makefile b/spec/Makefile index 91f35b41..dd7457a8 100644 --- a/spec/Makefile +++ b/spec/Makefile @@ -2,6 +2,6 @@ test: python test/validate.py - -test-server: - echo "TODO run a single-node arango database server with pre-loaded test data" + echo "Running view tests" + docker-compose run spec python /app/test/views/init_spec.py + docker-compose run spec python -m unittest discover /app/test/views diff --git a/spec/docker-compose.yaml b/spec/docker-compose.yaml new file mode 100644 index 00000000..a67bf7bb --- /dev/null +++ b/spec/docker-compose.yaml @@ -0,0 +1,50 @@ +version: '3' + +# This docker-compose is for developer convenience and testing, not for running in production. + +services: + + # ArangoDB + arangodb: + image: arangodb:3.4 + ports: + - 8529:8529 + environment: + - ARANGO_ROOT_PASSWORD=password + + # Relation Engine API + re_api: + image: kbase/relation_engine_api:latest + ports: + - 5000:5000 + environment: + - ARANGO_ROOT_PASSWORD=password + environment: + - DEVELOPMENT=1 + - FLASK_ENV=development + - FLASK_DEBUG=1 + - KBASE_AUTH_URL=http://auth:5000 + - KBASE_WORKSPACE_URL=http://workspace:5000 + - PYTHONUNBUFFERED=true + - SPEC_RELEASE_PATH=/app/src/test/spec_release/spec.tar.gz + - DB_URL=http://arangodb:8529 + - DB_USER=root + - DB_PASS=password + + # A mock kbase auth server (see src/test/mock_auth/endpoints.json) + auth: + image: mockservices/mock_json_service + volumes: + - ${PWD}/test/mock_services/mock_auth:/config + + # Mock workspace server (see src/test/mock_workspace/endpoints.json) + workspace: + image: mockservices/mock_json_service + volumes: + - ${PWD}/test/mock_services/mock_workspace:/config + + # General python container for executing tests + spec: + build: . + volumes: + - ${PWD}:/app diff --git a/spec/test/mock_services/mock_auth/endpoints.json b/spec/test/mock_services/mock_auth/endpoints.json new file mode 100644 index 00000000..b3c1f772 --- /dev/null +++ b/spec/test/mock_services/mock_auth/endpoints.json @@ -0,0 +1,96 @@ +[ + { + "methods": [ + "GET" + ], + "path": "/api/V2/me", + "headers": { + "Authorization": "non_admin_token" + }, + "response": { + "status": "200", + "body": { + "created": 1528306100471, + "lastlogin": 1542068355002, + "display": "Test User", + "roles": [], + "customroles": [], + "policyids": [], + "user": "username", + "local": false, + "email": "user@example.com", + "idents": [] + } + } + }, + { + "methods": [ + "GET" + ], + "path": "/api/V2/me", + "headers": { + "Authorization": "admin_token" + }, + "response": { + "status": "200", + "body": { + "created": 1528306100471, + "lastlogin": 1542068355002, + "display": "Test User", + "roles": [], + "customroles": [ + "RE_ADMIN" + ], + "policyids": [], + "user": "username", + "local": false, + "email": "user@example.com", + "idents": [] + } + } + }, + { + "methods": [ + "GET" + ], + "path": "/api/V2/me", + "headers": { + "Authorization": "invalid_token" + }, + "response": { + "status": "401", + "body": { + "error": { + "httpcode": 401, + "httpstatus": "Unauthorized", + "appcode": 10020, + "apperror": "Invalid token", + "message": "10020 Invalid token", + "callid": "1757210147564211", + "time": 1542737889450 + } + } + } + }, + { + "methods": [ + "GET" + ], + "path": "/api/V2/me", + "response": { + "status": "400", + "body": { + "error": { + "httpcode": 400, + "httpstatus": "Bad Request", + "appcode": 10010, + "apperror": "No authentication token", + "message": "10010 No authentication token: No user token provided", + "callid": "7334881776774415", + "time": 1542737656377 + } + } + } + } +] + diff --git a/spec/test/mock_services/mock_workspace/endpoints.json b/spec/test/mock_services/mock_workspace/endpoints.json new file mode 100644 index 00000000..fae8bfae --- /dev/null +++ b/spec/test/mock_services/mock_workspace/endpoints.json @@ -0,0 +1,64 @@ +[ + { + "methods": ["POST"], + "path": "/", + "headers": {"Authorization": "valid_token"}, + "body": { + "method": "Workspace.list_workspace_ids", + "version": "1.1", + "params": [{"perm": "r"}] + }, + "response": { + "status": "200", + "body": { + "version": "1.1", + "result": [ + { + "workspaces": [1, 2, 3], + "pub": [] + } + ] + } + } + }, + { + "methods": ["POST"], + "path": "/", + "headers": {"Authorization": "invalid_token"}, + "body": { + "method": "Workspace.list_workspace_ids", + "version": "1.1", + "params": [{"perm": "r"}] + }, + "response": { + "status": "500", + "body": { + "version": "1.1", + "error": { + "name": "JSONRPCError", + "code": -32400, + "message": "Token validation failed!", + "error": "..." + } + } + } + }, + { + "methods": ["POST"], + "path": "/", + "headers": {"Authorization": "admin_token"}, + "body": { + "method": "Workspace.list_workspace_ids", + "version": "1.1", + "params": [{"perm": "r"}] + }, + "response": { + "status": "200", + "body": { + "version": "1.1", + "result": [{"workspaces": [99], "pub": []}] + } + } + } +] + diff --git a/spec/test/views/__init__.py b/spec/test/views/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/spec/test/views/init_spec.py b/spec/test/views/init_spec.py new file mode 100644 index 00000000..1a27fccc --- /dev/null +++ b/spec/test/views/init_spec.py @@ -0,0 +1,12 @@ +import requests + +_API_URL = 'http://re_api:5000/api' + + +if __name__ == '__main__': + resp = requests.get( + _API_URL + '/update_specs', + headers={'Authorization': 'admin_token'}, + params={'init_collections': '1'} + ) + print(resp) diff --git a/spec/test/views/test_list_test_vertices.py b/spec/test/views/test_list_test_vertices.py new file mode 100644 index 00000000..7291ccd2 --- /dev/null +++ b/spec/test/views/test_list_test_vertices.py @@ -0,0 +1,46 @@ +import json +import unittest +import requests + +_API_URL = 'http://re_api:5000/api' +_QUERY_URL = _API_URL + '/query_results?view=list_test_vertices' + + +def create_test_docs(docs): + body = '\n'.join([json.dumps(d) for d in docs]) + return requests.put( + _API_URL + '/documents', + params={'overwrite': True, 'collection': 'test_vertex'}, + data=body, + headers={'Authorization': 'admin_token'} + ).json() + + +class TestListTestVertices(unittest.TestCase): + + def test_valid(self): + """Test a valid query.""" + create_test_docs([ + {'is_public': True, '_key': 'a', 'ws_id': 10}, # public access + {'is_public': False, '_key': 'b', 'ws_id': 1}, # private access + {'is_public': False, '_key': 'c', 'ws_id': 99} # no access + ]) + resp = requests.post( + _QUERY_URL, + headers={'Authorization': 'valid_token'} # gives access to workspaces [1,2,3] + ).json() + self.assertEqual(resp['count'], 2) + # 'c' is inaccessible + self.assertEqual([r['_key'] for r in resp['results']], ['a', 'b']) + + def test_no_auth(self): + """Test with blank auth.""" + create_test_docs([ + {'is_public': True, '_key': 'a', 'ws_id': 10}, # public access + {'is_public': False, '_key': 'b', 'ws_id': 1}, # private access + {'is_public': False, '_key': 'c', 'ws_id': 99} # no access + ]) + resp = requests.post(_QUERY_URL).json() + self.assertEqual(resp['count'], 1) + # 'b' and 'c' are inaccessible + self.assertEqual([r['_key'] for r in resp['results']], ['a']) From 02a339cfe935cb5ae885ca9c241c98b8b6f759bb Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Fri, 1 Mar 2019 16:55:43 -0800 Subject: [PATCH 252/732] Fix for travis --- spec/.travis.yml | 2 ++ spec/Dockerfile | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/spec/.travis.yml b/spec/.travis.yml index c7b6fcfe..294b31f9 100644 --- a/spec/.travis.yml +++ b/spec/.travis.yml @@ -4,4 +4,6 @@ python: before_script: - pip install jsonschema script: +- docker-compose up --build -d +- sleep 15 - make test diff --git a/spec/Dockerfile b/spec/Dockerfile index e3406dc8..00b007df 100644 --- a/spec/Dockerfile +++ b/spec/Dockerfile @@ -1,5 +1,5 @@ from python:3.7-slim -RUN pip install --upgrade pip requests +RUN pip install --upgrade pip requests jsonschema COPY . /app From 29fc7da72036e8cb212cad55a427e32031d48a08 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Mon, 4 Mar 2019 10:06:08 -0800 Subject: [PATCH 253/732] Simplify and make version modules explicit (remove method shadowing system) --- .../api_modules/api_v1.py | 1 - api/src/relation_engine_server/server.py | 51 +++++++------------ 2 files changed, 18 insertions(+), 34 deletions(-) diff --git a/api/src/relation_engine_server/api_modules/api_v1.py b/api/src/relation_engine_server/api_modules/api_v1.py index f90edf46..e4c07be8 100644 --- a/api/src/relation_engine_server/api_modules/api_v1.py +++ b/api/src/relation_engine_server/api_modules/api_v1.py @@ -112,4 +112,3 @@ def show_config(): 'specs': {'handler': update_specs, 'methods': {'PUT'}}, 'documents': {'handler': save_documents, 'methods': {'PUT'}} } -deprecations = {} # type: ignore diff --git a/api/src/relation_engine_server/server.py b/api/src/relation_engine_server/server.py index 30a94160..f28e81ec 100644 --- a/api/src/relation_engine_server/server.py +++ b/api/src/relation_engine_server/server.py @@ -13,7 +13,6 @@ # All api version modules, from oldest to newest _API_VERSIONS = [api_v1.endpoints] -_API_DEPRECATIONS = [api_v1.deprecations] app = flask.Flask(__name__) app.config['DEBUG'] = os.environ.get('FLASK_DEBUG', True) @@ -46,46 +45,35 @@ def api_call(path): Versioning system: - Every API version is a discrete python module that contains an 'endpoints' dictionary. - - New versions don't need to redefine previous endpoints. - - If an endpoint is not defined, we fall back to a previous version. - - New versions can overwrite existing methods and add new ones. - Versions are simple incrementing integers. We only need a new version for breaking changes. - - New modules can deprecate paths by putting them under the 'deprecations' key Note that endpoints cannot be removed with new versions, only overwritten or added. """ path_parts = path.split('/') version_int = _get_version(path_parts[0]) # Get the path and version number api_path = '/'.join(path_parts[1:]) - # Flag for whether the endpoint we find is deprecated - deprecated = False # Find our method in the various versioned modules # If it is not present in a later version, fall back to a previous version # Iterates by starting at (version-1), stopping at 0, and stepping backwards - # Note: the mypy type checker has difficulties with the path_funcs dicts, so we ignore type checking below - for ver in range(version_int - 1, -1, -1): - path_funcs = _API_VERSIONS[ver] - deprecations = _API_DEPRECATIONS[ver] - if api_path in deprecations: - # We found a deprecation flag on the endpoint - deprecated = True - if api_path in path_funcs: - methods = path_funcs[api_path].get('methods', {'GET'}) # type: ignore - # Mypy is not able to infer that `methods` will always be a set - if flask.request.method not in methods: # type: ignore - return (flask.jsonify({'error': '405 - Method not allowed.'}), 405) - # We found a matching function for the endpoint and method - func = path_funcs[api_path]['handler'] # type: ignore - # Mypy is not able to infer that this is a function - result = func() # type: ignore - return _json_resp(result, 200, deprecated) - body = {'error': f'path not found: {api_path}'} - return _json_resp(body, 404) + # Note: the mypy type checker has difficulties with the endpoints dicts, so we ignore type checking below + endpoints = _API_VERSIONS[version_int] + if api_path not in endpoints: + body = {'error': f'path not found: {api_path}'} + return _json_resp(body, 404) + methods = endpoints[api_path].get('methods', {'GET'}) # type: ignore + # Mypy is not able to infer that `methods` will always be a set + if flask.request.method not in methods: # type: ignore + return (flask.jsonify({'error': '405 - Method not allowed.'}), 405) + # We found a matching function for the endpoint and method + func = endpoints[api_path]['handler'] # type: ignore + # Mypy is not able to infer that this is a function + result = func() # type: ignore + return _json_resp(result, 200) def _get_version(version_str): """From a list of path parts, initialize and validate a version int for the api.""" - ver_len = len(_API_VERSIONS) + max_version = len(_API_VERSIONS) # Make sure the version looks like 'v12' if not re.match(r'^v\d+$', version_str): raise InvalidParameters('Make a request with the format /api//') @@ -94,18 +82,15 @@ def _get_version(version_str): # Make sure the version number is valid if version_int <= 0: raise InvalidParameters('API version must be > 0') - if version_int > ver_len: - raise InvalidParameters(f'Invalid api version; max is {ver_len}') + if version_int > max_version: + raise InvalidParameters(f'Invalid api version; max is {max_version}') return version_int -def _json_resp(result, status=200, deprecated=False): +def _json_resp(result, status=200): """Send a json response back to the requester with the proper headers.""" resp = flask.Response(json.dumps(result)) resp.status_code = status - if deprecated: - # Add a deprecation warning in the headers - resp.headers['Warning'] = 'DEPRECATED' print(' '.join([flask.request.method, flask.request.path, '->', resp.status])) # Enable CORS resp.headers['Access-Control-Allow-Origin'] = '*' From 5fcbe3a96475f1eba6e45a7cbb7e2d72731a0b05 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Mon, 4 Mar 2019 10:07:55 -0800 Subject: [PATCH 254/732] Fix version indexing into list --- api/src/relation_engine_server/server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/src/relation_engine_server/server.py b/api/src/relation_engine_server/server.py index f28e81ec..3865f9a9 100644 --- a/api/src/relation_engine_server/server.py +++ b/api/src/relation_engine_server/server.py @@ -56,7 +56,7 @@ def api_call(path): # If it is not present in a later version, fall back to a previous version # Iterates by starting at (version-1), stopping at 0, and stepping backwards # Note: the mypy type checker has difficulties with the endpoints dicts, so we ignore type checking below - endpoints = _API_VERSIONS[version_int] + endpoints = _API_VERSIONS[version_int - 1] if api_path not in endpoints: body = {'error': f'path not found: {api_path}'} return _json_resp(body, 404) From c36b8ba81a46528f208f04c0d7f8496fbf371f56 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Mon, 4 Mar 2019 10:10:35 -0800 Subject: [PATCH 255/732] Typo --- api/src/relation_engine_server/exceptions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/src/relation_engine_server/exceptions.py b/api/src/relation_engine_server/exceptions.py index 5fda77d2..ed0b0a20 100644 --- a/api/src/relation_engine_server/exceptions.py +++ b/api/src/relation_engine_server/exceptions.py @@ -12,7 +12,7 @@ def __str__(self): return self.msg class MissingHeader(Exception): - """Missing required header ina request.""" + """Missing required header in a request.""" def __init__(self, header_name): self.header_name = header_name From ba5fbddc6f52722b1a6a7884b5d34411495a35ea Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Mon, 4 Mar 2019 10:11:22 -0800 Subject: [PATCH 256/732] Remove irrelevant comment --- api/src/relation_engine_server/server.py | 1 - 1 file changed, 1 deletion(-) diff --git a/api/src/relation_engine_server/server.py b/api/src/relation_engine_server/server.py index 3865f9a9..73f8eb83 100644 --- a/api/src/relation_engine_server/server.py +++ b/api/src/relation_engine_server/server.py @@ -46,7 +46,6 @@ def api_call(path): Versioning system: - Every API version is a discrete python module that contains an 'endpoints' dictionary. - Versions are simple incrementing integers. We only need a new version for breaking changes. - Note that endpoints cannot be removed with new versions, only overwritten or added. """ path_parts = path.split('/') version_int = _get_version(path_parts[0]) From 1f5dfa1124cc3d7e160498edb4eaddc541392240 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Mon, 4 Mar 2019 10:13:25 -0800 Subject: [PATCH 257/732] Fix up some comments --- api/src/relation_engine_server/server.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/api/src/relation_engine_server/server.py b/api/src/relation_engine_server/server.py index 73f8eb83..b9b26f8f 100644 --- a/api/src/relation_engine_server/server.py +++ b/api/src/relation_engine_server/server.py @@ -47,26 +47,23 @@ def api_call(path): - Every API version is a discrete python module that contains an 'endpoints' dictionary. - Versions are simple incrementing integers. We only need a new version for breaking changes. """ + # Get the path and version number path_parts = path.split('/') version_int = _get_version(path_parts[0]) - # Get the path and version number api_path = '/'.join(path_parts[1:]) # Find our method in the various versioned modules - # If it is not present in a later version, fall back to a previous version - # Iterates by starting at (version-1), stopping at 0, and stepping backwards - # Note: the mypy type checker has difficulties with the endpoints dicts, so we ignore type checking below - endpoints = _API_VERSIONS[version_int - 1] + # Note: the mypy type checker has difficulties with the endpoints dict, so we ignore type checking below + endpoints = _API_VERSIONS[version_int - 1] # index 0 == version 1 if api_path not in endpoints: - body = {'error': f'path not found: {api_path}'} + body = {'error': f'Path not found: {api_path}.'} return _json_resp(body, 404) methods = endpoints[api_path].get('methods', {'GET'}) # type: ignore # Mypy is not able to infer that `methods` will always be a set if flask.request.method not in methods: # type: ignore return (flask.jsonify({'error': '405 - Method not allowed.'}), 405) # We found a matching function for the endpoint and method - func = endpoints[api_path]['handler'] # type: ignore # Mypy is not able to infer that this is a function - result = func() # type: ignore + result = endpoints[api_path]['handler']() # type: ignore return _json_resp(result, 200) From b0f2b612f43e5cc662686930dbfafa7ec745ada8 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Mon, 4 Mar 2019 10:15:35 -0800 Subject: [PATCH 258/732] Add comment --- api/src/relation_engine_server/utils/parse_json.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/api/src/relation_engine_server/utils/parse_json.py b/api/src/relation_engine_server/utils/parse_json.py index d0dcf8e6..a65fd5c1 100644 --- a/api/src/relation_engine_server/utils/parse_json.py +++ b/api/src/relation_engine_server/utils/parse_json.py @@ -3,7 +3,10 @@ def get_json_body(): - """Parse json out of a request body, if present.""" + """ + Parse json out of a request body, if present. + If the request body is empty, we return None rather than throwing any parsing errors. + """ json_body = None # type: ignore req_data = flask.request.get_data() if req_data: From bedec760e75c59a99dd17595545b12404bc9f763 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 6 Mar 2019 10:26:10 -0800 Subject: [PATCH 259/732] Clean up and rename things --- spec/schemas/edges/mash/README.md | 1 + .../mash_genome_similar_to.json | 0 spec/schemas/edges/ncbi/README.md | 1 + .../ncbi_gene_within_genome.json | 0 spec/schemas/edges/rxn/README.md | 1 + .../rxn_gene_within_complex.json | 0 .../rxn_reaction_within_complex.json | 0 .../rxn_similar_to_reaction.json | 0 .../edges/workspace_full/wsfull_contains.json | 17 ----------------- spec/schemas/edges/wsfull/README.md | 5 +++++ .../wsfull_copied_from.json | 0 .../wsfull_latest_version_of.json | 0 .../wsfull/wsfull_module_contains_method.json | 17 +++++++++++++++++ .../wsfull_obj_created_with_method.json | 0 .../wsfull_obj_created_with_module.json | 0 .../wsfull_obj_instance_of_type.json} | 0 .../wsfull_owner_of.json | 0 .../wsfull_prov_descendant_of.json | 0 .../wsfull_refers_to.json | 0 .../wsfull_type_consumed_by_method.json} | 0 .../wsfull_version_of.json | 0 .../edges/wsfull/wsfull_ws_contains_obj.json | 17 +++++++++++++++++ .../wsfull_ws_perm.json | 0 spec/schemas/edges/wsprov/README.md | 1 + .../wsprov_copied_into.json | 0 .../wsprov_input_in.json | 0 .../wsprov_links.json | 0 .../wsprov_produced.json | 0 spec/schemas/vertices/README.md | 1 + spec/schemas/vertices/ncbi/README.md | 1 + .../{ncbi_genomes => ncbi}/ncbi_gene.json | 0 .../{ncbi_genomes => ncbi}/ncbi_genome.json | 0 spec/schemas/vertices/rxn/README.md | 1 + .../rxn_gene_complex.json | 0 .../rxn_reaction.json | 0 spec/schemas/vertices/wsfull/README.md | 5 +++++ .../wsfull_method.json | 0 .../wsfull_method_version.json | 0 .../wsfull_module.json | 0 .../wsfull_module_version.json | 0 .../wsfull_object.json | 0 .../wsfull_object_hash.json | 0 .../wsfull_object_version.json | 0 .../{workspace_full => wsfull}/wsfull_type.json | 0 .../wsfull_type_module.json | 0 .../wsfull_type_version.json | 0 .../{workspace_full => wsfull}/wsfull_user.json | 0 .../wsfull_workspace.json | 0 spec/schemas/vertices/wsprov/README.md | 1 + .../wsprov_action.json | 0 .../wsprov_object.json | 0 51 files changed, 52 insertions(+), 17 deletions(-) create mode 100644 spec/schemas/edges/mash/README.md rename spec/schemas/edges/{mash_homology => mash}/mash_genome_similar_to.json (100%) create mode 100644 spec/schemas/edges/ncbi/README.md rename spec/schemas/edges/{ncbi_genomes => ncbi}/ncbi_gene_within_genome.json (100%) create mode 100644 spec/schemas/edges/rxn/README.md rename spec/schemas/edges/{reaction_homology => rxn}/rxn_gene_within_complex.json (100%) rename spec/schemas/edges/{reaction_homology => rxn}/rxn_reaction_within_complex.json (100%) rename spec/schemas/edges/{reaction_homology => rxn}/rxn_similar_to_reaction.json (100%) delete mode 100644 spec/schemas/edges/workspace_full/wsfull_contains.json create mode 100644 spec/schemas/edges/wsfull/README.md rename spec/schemas/edges/{workspace_full => wsfull}/wsfull_copied_from.json (100%) rename spec/schemas/edges/{workspace_full => wsfull}/wsfull_latest_version_of.json (100%) create mode 100644 spec/schemas/edges/wsfull/wsfull_module_contains_method.json rename spec/schemas/edges/{workspace_full => wsfull}/wsfull_obj_created_with_method.json (100%) rename spec/schemas/edges/{workspace_full => wsfull}/wsfull_obj_created_with_module.json (100%) rename spec/schemas/edges/{workspace_full/wsfull_instance_of.json => wsfull/wsfull_obj_instance_of_type.json} (100%) rename spec/schemas/edges/{workspace_full => wsfull}/wsfull_owner_of.json (100%) rename spec/schemas/edges/{workspace_full => wsfull}/wsfull_prov_descendant_of.json (100%) rename spec/schemas/edges/{workspace_full => wsfull}/wsfull_refers_to.json (100%) rename spec/schemas/edges/{workspace_full/wsfull_consumed_by.json => wsfull/wsfull_type_consumed_by_method.json} (100%) rename spec/schemas/edges/{workspace_full => wsfull}/wsfull_version_of.json (100%) create mode 100644 spec/schemas/edges/wsfull/wsfull_ws_contains_obj.json rename spec/schemas/edges/{workspace_full => wsfull}/wsfull_ws_perm.json (100%) create mode 100644 spec/schemas/edges/wsprov/README.md rename spec/schemas/edges/{provenance_simple => wsprov}/wsprov_copied_into.json (100%) rename spec/schemas/edges/{provenance_simple => wsprov}/wsprov_input_in.json (100%) rename spec/schemas/edges/{provenance_simple => wsprov}/wsprov_links.json (100%) rename spec/schemas/edges/{provenance_simple => wsprov}/wsprov_produced.json (100%) create mode 100644 spec/schemas/vertices/README.md create mode 100644 spec/schemas/vertices/ncbi/README.md rename spec/schemas/vertices/{ncbi_genomes => ncbi}/ncbi_gene.json (100%) rename spec/schemas/vertices/{ncbi_genomes => ncbi}/ncbi_genome.json (100%) create mode 100644 spec/schemas/vertices/rxn/README.md rename spec/schemas/vertices/{reaction_homology => rxn}/rxn_gene_complex.json (100%) rename spec/schemas/vertices/{reaction_homology => rxn}/rxn_reaction.json (100%) create mode 100644 spec/schemas/vertices/wsfull/README.md rename spec/schemas/vertices/{workspace_full => wsfull}/wsfull_method.json (100%) rename spec/schemas/vertices/{workspace_full => wsfull}/wsfull_method_version.json (100%) rename spec/schemas/vertices/{workspace_full => wsfull}/wsfull_module.json (100%) rename spec/schemas/vertices/{workspace_full => wsfull}/wsfull_module_version.json (100%) rename spec/schemas/vertices/{workspace_full => wsfull}/wsfull_object.json (100%) rename spec/schemas/vertices/{workspace_full => wsfull}/wsfull_object_hash.json (100%) rename spec/schemas/vertices/{workspace_full => wsfull}/wsfull_object_version.json (100%) rename spec/schemas/vertices/{workspace_full => wsfull}/wsfull_type.json (100%) rename spec/schemas/vertices/{workspace_full => wsfull}/wsfull_type_module.json (100%) rename spec/schemas/vertices/{workspace_full => wsfull}/wsfull_type_version.json (100%) rename spec/schemas/vertices/{workspace_full => wsfull}/wsfull_user.json (100%) rename spec/schemas/vertices/{workspace_full => wsfull}/wsfull_workspace.json (100%) create mode 100644 spec/schemas/vertices/wsprov/README.md rename spec/schemas/vertices/{provenance_simple => wsprov}/wsprov_action.json (100%) rename spec/schemas/vertices/{provenance_simple => wsprov}/wsprov_object.json (100%) diff --git a/spec/schemas/edges/mash/README.md b/spec/schemas/edges/mash/README.md new file mode 100644 index 00000000..bd2f0214 --- /dev/null +++ b/spec/schemas/edges/mash/README.md @@ -0,0 +1 @@ +# Mash homology diff --git a/spec/schemas/edges/mash_homology/mash_genome_similar_to.json b/spec/schemas/edges/mash/mash_genome_similar_to.json similarity index 100% rename from spec/schemas/edges/mash_homology/mash_genome_similar_to.json rename to spec/schemas/edges/mash/mash_genome_similar_to.json diff --git a/spec/schemas/edges/ncbi/README.md b/spec/schemas/edges/ncbi/README.md new file mode 100644 index 00000000..d5dabfab --- /dev/null +++ b/spec/schemas/edges/ncbi/README.md @@ -0,0 +1 @@ +# NCBI genbank data diff --git a/spec/schemas/edges/ncbi_genomes/ncbi_gene_within_genome.json b/spec/schemas/edges/ncbi/ncbi_gene_within_genome.json similarity index 100% rename from spec/schemas/edges/ncbi_genomes/ncbi_gene_within_genome.json rename to spec/schemas/edges/ncbi/ncbi_gene_within_genome.json diff --git a/spec/schemas/edges/rxn/README.md b/spec/schemas/edges/rxn/README.md new file mode 100644 index 00000000..4bac805e --- /dev/null +++ b/spec/schemas/edges/rxn/README.md @@ -0,0 +1 @@ +# Reaction homology diff --git a/spec/schemas/edges/reaction_homology/rxn_gene_within_complex.json b/spec/schemas/edges/rxn/rxn_gene_within_complex.json similarity index 100% rename from spec/schemas/edges/reaction_homology/rxn_gene_within_complex.json rename to spec/schemas/edges/rxn/rxn_gene_within_complex.json diff --git a/spec/schemas/edges/reaction_homology/rxn_reaction_within_complex.json b/spec/schemas/edges/rxn/rxn_reaction_within_complex.json similarity index 100% rename from spec/schemas/edges/reaction_homology/rxn_reaction_within_complex.json rename to spec/schemas/edges/rxn/rxn_reaction_within_complex.json diff --git a/spec/schemas/edges/reaction_homology/rxn_similar_to_reaction.json b/spec/schemas/edges/rxn/rxn_similar_to_reaction.json similarity index 100% rename from spec/schemas/edges/reaction_homology/rxn_similar_to_reaction.json rename to spec/schemas/edges/rxn/rxn_similar_to_reaction.json diff --git a/spec/schemas/edges/workspace_full/wsfull_contains.json b/spec/schemas/edges/workspace_full/wsfull_contains.json deleted file mode 100644 index b77450a7..00000000 --- a/spec/schemas/edges/workspace_full/wsfull_contains.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "description": "A module contains a method, a workspace contains an object.", - "additionalProperties": false, - "required": ["_from", "_to"], - "properties": { - "_from": { - "type": "string", - "description": "The ID of the document that contains something else." - }, - "_to": { - "type": "string", - "description": "The ID of the document that is contained by something else." - } - } -} diff --git a/spec/schemas/edges/wsfull/README.md b/spec/schemas/edges/wsfull/README.md new file mode 100644 index 00000000..cec182df --- /dev/null +++ b/spec/schemas/edges/wsfull/README.md @@ -0,0 +1,5 @@ +# Workspace edges (full details) + +These schemas comprise a full, detailed sync of all the data from the KBase workspace. + +For import code, see: https://github.com/kbaseapps/relation_engine_sync diff --git a/spec/schemas/edges/workspace_full/wsfull_copied_from.json b/spec/schemas/edges/wsfull/wsfull_copied_from.json similarity index 100% rename from spec/schemas/edges/workspace_full/wsfull_copied_from.json rename to spec/schemas/edges/wsfull/wsfull_copied_from.json diff --git a/spec/schemas/edges/workspace_full/wsfull_latest_version_of.json b/spec/schemas/edges/wsfull/wsfull_latest_version_of.json similarity index 100% rename from spec/schemas/edges/workspace_full/wsfull_latest_version_of.json rename to spec/schemas/edges/wsfull/wsfull_latest_version_of.json diff --git a/spec/schemas/edges/wsfull/wsfull_module_contains_method.json b/spec/schemas/edges/wsfull/wsfull_module_contains_method.json new file mode 100644 index 00000000..015d507a --- /dev/null +++ b/spec/schemas/edges/wsfull/wsfull_module_contains_method.json @@ -0,0 +1,17 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "description": "A module contains an SDK method", + "required": ["_from", "_to"], + "properties": { + "_from": { + "type": "string", + "description": "The module ID." + }, + "_to": { + "type": "string", + "description": "The SDK method ID" + } + } +} + diff --git a/spec/schemas/edges/workspace_full/wsfull_obj_created_with_method.json b/spec/schemas/edges/wsfull/wsfull_obj_created_with_method.json similarity index 100% rename from spec/schemas/edges/workspace_full/wsfull_obj_created_with_method.json rename to spec/schemas/edges/wsfull/wsfull_obj_created_with_method.json diff --git a/spec/schemas/edges/workspace_full/wsfull_obj_created_with_module.json b/spec/schemas/edges/wsfull/wsfull_obj_created_with_module.json similarity index 100% rename from spec/schemas/edges/workspace_full/wsfull_obj_created_with_module.json rename to spec/schemas/edges/wsfull/wsfull_obj_created_with_module.json diff --git a/spec/schemas/edges/workspace_full/wsfull_instance_of.json b/spec/schemas/edges/wsfull/wsfull_obj_instance_of_type.json similarity index 100% rename from spec/schemas/edges/workspace_full/wsfull_instance_of.json rename to spec/schemas/edges/wsfull/wsfull_obj_instance_of_type.json diff --git a/spec/schemas/edges/workspace_full/wsfull_owner_of.json b/spec/schemas/edges/wsfull/wsfull_owner_of.json similarity index 100% rename from spec/schemas/edges/workspace_full/wsfull_owner_of.json rename to spec/schemas/edges/wsfull/wsfull_owner_of.json diff --git a/spec/schemas/edges/workspace_full/wsfull_prov_descendant_of.json b/spec/schemas/edges/wsfull/wsfull_prov_descendant_of.json similarity index 100% rename from spec/schemas/edges/workspace_full/wsfull_prov_descendant_of.json rename to spec/schemas/edges/wsfull/wsfull_prov_descendant_of.json diff --git a/spec/schemas/edges/workspace_full/wsfull_refers_to.json b/spec/schemas/edges/wsfull/wsfull_refers_to.json similarity index 100% rename from spec/schemas/edges/workspace_full/wsfull_refers_to.json rename to spec/schemas/edges/wsfull/wsfull_refers_to.json diff --git a/spec/schemas/edges/workspace_full/wsfull_consumed_by.json b/spec/schemas/edges/wsfull/wsfull_type_consumed_by_method.json similarity index 100% rename from spec/schemas/edges/workspace_full/wsfull_consumed_by.json rename to spec/schemas/edges/wsfull/wsfull_type_consumed_by_method.json diff --git a/spec/schemas/edges/workspace_full/wsfull_version_of.json b/spec/schemas/edges/wsfull/wsfull_version_of.json similarity index 100% rename from spec/schemas/edges/workspace_full/wsfull_version_of.json rename to spec/schemas/edges/wsfull/wsfull_version_of.json diff --git a/spec/schemas/edges/wsfull/wsfull_ws_contains_obj.json b/spec/schemas/edges/wsfull/wsfull_ws_contains_obj.json new file mode 100644 index 00000000..be657c29 --- /dev/null +++ b/spec/schemas/edges/wsfull/wsfull_ws_contains_obj.json @@ -0,0 +1,17 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "description": "A workspace contains an object", + "required": ["_from", "_to"], + "properties": { + "_from": { + "type": "string", + "description": "The ID of the workspace" + }, + "_to": { + "type": "string", + "description": "The ID of the object" + } + } +} + diff --git a/spec/schemas/edges/workspace_full/wsfull_ws_perm.json b/spec/schemas/edges/wsfull/wsfull_ws_perm.json similarity index 100% rename from spec/schemas/edges/workspace_full/wsfull_ws_perm.json rename to spec/schemas/edges/wsfull/wsfull_ws_perm.json diff --git a/spec/schemas/edges/wsprov/README.md b/spec/schemas/edges/wsprov/README.md new file mode 100644 index 00000000..d6154877 --- /dev/null +++ b/spec/schemas/edges/wsprov/README.md @@ -0,0 +1 @@ +# Simple workspace provenance data diff --git a/spec/schemas/edges/provenance_simple/wsprov_copied_into.json b/spec/schemas/edges/wsprov/wsprov_copied_into.json similarity index 100% rename from spec/schemas/edges/provenance_simple/wsprov_copied_into.json rename to spec/schemas/edges/wsprov/wsprov_copied_into.json diff --git a/spec/schemas/edges/provenance_simple/wsprov_input_in.json b/spec/schemas/edges/wsprov/wsprov_input_in.json similarity index 100% rename from spec/schemas/edges/provenance_simple/wsprov_input_in.json rename to spec/schemas/edges/wsprov/wsprov_input_in.json diff --git a/spec/schemas/edges/provenance_simple/wsprov_links.json b/spec/schemas/edges/wsprov/wsprov_links.json similarity index 100% rename from spec/schemas/edges/provenance_simple/wsprov_links.json rename to spec/schemas/edges/wsprov/wsprov_links.json diff --git a/spec/schemas/edges/provenance_simple/wsprov_produced.json b/spec/schemas/edges/wsprov/wsprov_produced.json similarity index 100% rename from spec/schemas/edges/provenance_simple/wsprov_produced.json rename to spec/schemas/edges/wsprov/wsprov_produced.json diff --git a/spec/schemas/vertices/README.md b/spec/schemas/vertices/README.md new file mode 100644 index 00000000..8fb3c592 --- /dev/null +++ b/spec/schemas/vertices/README.md @@ -0,0 +1 @@ +# Reaction homology vertices diff --git a/spec/schemas/vertices/ncbi/README.md b/spec/schemas/vertices/ncbi/README.md new file mode 100644 index 00000000..d5dabfab --- /dev/null +++ b/spec/schemas/vertices/ncbi/README.md @@ -0,0 +1 @@ +# NCBI genbank data diff --git a/spec/schemas/vertices/ncbi_genomes/ncbi_gene.json b/spec/schemas/vertices/ncbi/ncbi_gene.json similarity index 100% rename from spec/schemas/vertices/ncbi_genomes/ncbi_gene.json rename to spec/schemas/vertices/ncbi/ncbi_gene.json diff --git a/spec/schemas/vertices/ncbi_genomes/ncbi_genome.json b/spec/schemas/vertices/ncbi/ncbi_genome.json similarity index 100% rename from spec/schemas/vertices/ncbi_genomes/ncbi_genome.json rename to spec/schemas/vertices/ncbi/ncbi_genome.json diff --git a/spec/schemas/vertices/rxn/README.md b/spec/schemas/vertices/rxn/README.md new file mode 100644 index 00000000..4bac805e --- /dev/null +++ b/spec/schemas/vertices/rxn/README.md @@ -0,0 +1 @@ +# Reaction homology diff --git a/spec/schemas/vertices/reaction_homology/rxn_gene_complex.json b/spec/schemas/vertices/rxn/rxn_gene_complex.json similarity index 100% rename from spec/schemas/vertices/reaction_homology/rxn_gene_complex.json rename to spec/schemas/vertices/rxn/rxn_gene_complex.json diff --git a/spec/schemas/vertices/reaction_homology/rxn_reaction.json b/spec/schemas/vertices/rxn/rxn_reaction.json similarity index 100% rename from spec/schemas/vertices/reaction_homology/rxn_reaction.json rename to spec/schemas/vertices/rxn/rxn_reaction.json diff --git a/spec/schemas/vertices/wsfull/README.md b/spec/schemas/vertices/wsfull/README.md new file mode 100644 index 00000000..a3ba8a8a --- /dev/null +++ b/spec/schemas/vertices/wsfull/README.md @@ -0,0 +1,5 @@ +# Workspace vertices (full details) + +These schemas comprise a full, detailed sync of all the data from the KBase workspace. + +For import code, see: https://github.com/kbaseapps/relation_engine_sync diff --git a/spec/schemas/vertices/workspace_full/wsfull_method.json b/spec/schemas/vertices/wsfull/wsfull_method.json similarity index 100% rename from spec/schemas/vertices/workspace_full/wsfull_method.json rename to spec/schemas/vertices/wsfull/wsfull_method.json diff --git a/spec/schemas/vertices/workspace_full/wsfull_method_version.json b/spec/schemas/vertices/wsfull/wsfull_method_version.json similarity index 100% rename from spec/schemas/vertices/workspace_full/wsfull_method_version.json rename to spec/schemas/vertices/wsfull/wsfull_method_version.json diff --git a/spec/schemas/vertices/workspace_full/wsfull_module.json b/spec/schemas/vertices/wsfull/wsfull_module.json similarity index 100% rename from spec/schemas/vertices/workspace_full/wsfull_module.json rename to spec/schemas/vertices/wsfull/wsfull_module.json diff --git a/spec/schemas/vertices/workspace_full/wsfull_module_version.json b/spec/schemas/vertices/wsfull/wsfull_module_version.json similarity index 100% rename from spec/schemas/vertices/workspace_full/wsfull_module_version.json rename to spec/schemas/vertices/wsfull/wsfull_module_version.json diff --git a/spec/schemas/vertices/workspace_full/wsfull_object.json b/spec/schemas/vertices/wsfull/wsfull_object.json similarity index 100% rename from spec/schemas/vertices/workspace_full/wsfull_object.json rename to spec/schemas/vertices/wsfull/wsfull_object.json diff --git a/spec/schemas/vertices/workspace_full/wsfull_object_hash.json b/spec/schemas/vertices/wsfull/wsfull_object_hash.json similarity index 100% rename from spec/schemas/vertices/workspace_full/wsfull_object_hash.json rename to spec/schemas/vertices/wsfull/wsfull_object_hash.json diff --git a/spec/schemas/vertices/workspace_full/wsfull_object_version.json b/spec/schemas/vertices/wsfull/wsfull_object_version.json similarity index 100% rename from spec/schemas/vertices/workspace_full/wsfull_object_version.json rename to spec/schemas/vertices/wsfull/wsfull_object_version.json diff --git a/spec/schemas/vertices/workspace_full/wsfull_type.json b/spec/schemas/vertices/wsfull/wsfull_type.json similarity index 100% rename from spec/schemas/vertices/workspace_full/wsfull_type.json rename to spec/schemas/vertices/wsfull/wsfull_type.json diff --git a/spec/schemas/vertices/workspace_full/wsfull_type_module.json b/spec/schemas/vertices/wsfull/wsfull_type_module.json similarity index 100% rename from spec/schemas/vertices/workspace_full/wsfull_type_module.json rename to spec/schemas/vertices/wsfull/wsfull_type_module.json diff --git a/spec/schemas/vertices/workspace_full/wsfull_type_version.json b/spec/schemas/vertices/wsfull/wsfull_type_version.json similarity index 100% rename from spec/schemas/vertices/workspace_full/wsfull_type_version.json rename to spec/schemas/vertices/wsfull/wsfull_type_version.json diff --git a/spec/schemas/vertices/workspace_full/wsfull_user.json b/spec/schemas/vertices/wsfull/wsfull_user.json similarity index 100% rename from spec/schemas/vertices/workspace_full/wsfull_user.json rename to spec/schemas/vertices/wsfull/wsfull_user.json diff --git a/spec/schemas/vertices/workspace_full/wsfull_workspace.json b/spec/schemas/vertices/wsfull/wsfull_workspace.json similarity index 100% rename from spec/schemas/vertices/workspace_full/wsfull_workspace.json rename to spec/schemas/vertices/wsfull/wsfull_workspace.json diff --git a/spec/schemas/vertices/wsprov/README.md b/spec/schemas/vertices/wsprov/README.md new file mode 100644 index 00000000..d6154877 --- /dev/null +++ b/spec/schemas/vertices/wsprov/README.md @@ -0,0 +1 @@ +# Simple workspace provenance data diff --git a/spec/schemas/vertices/provenance_simple/wsprov_action.json b/spec/schemas/vertices/wsprov/wsprov_action.json similarity index 100% rename from spec/schemas/vertices/provenance_simple/wsprov_action.json rename to spec/schemas/vertices/wsprov/wsprov_action.json diff --git a/spec/schemas/vertices/provenance_simple/wsprov_object.json b/spec/schemas/vertices/wsprov/wsprov_object.json similarity index 100% rename from spec/schemas/vertices/provenance_simple/wsprov_object.json rename to spec/schemas/vertices/wsprov/wsprov_object.json From 003b1499883489b47af3f2cb9cc33f92488ea2a4 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 6 Mar 2019 10:54:56 -0800 Subject: [PATCH 260/732] Add sharding support and run arangodb in cluster mode for testing --- api/docker-compose.yaml | 17 +++++++++-------- .../utils/arango_client.py | 6 +++++- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/api/docker-compose.yaml b/api/docker-compose.yaml index 3daa7cb2..7c2fc9f0 100644 --- a/api/docker-compose.yaml +++ b/api/docker-compose.yaml @@ -26,14 +26,6 @@ services: - DB_USER=root - DB_PASS=password - # For running (and testing against) ArangoDB - arangodb: - image: arangodb:3.4 - ports: - - 8529:8529 - environment: - - ARANGO_ROOT_PASSWORD=password - # A mock kbase auth server (see src/test/mock_auth/endpoints.json) auth: image: mockservices/mock_json_service @@ -45,3 +37,12 @@ services: image: mockservices/mock_json_service volumes: - ${PWD}/src/test/mock_workspace:/config + + # Arangodb server in cluster mode + arangodb: + image: arangodb:3.4 + ports: + - 8529:8529 + environment: + - ARANGO_ROOT_PASSWORD=password + command: arangodb --starter.local diff --git a/api/src/relation_engine_server/utils/arango_client.py b/api/src/relation_engine_server/utils/arango_client.py index 03875ace..9b7584f0 100644 --- a/api/src/relation_engine_server/utils/arango_client.py +++ b/api/src/relation_engine_server/utils/arango_client.py @@ -1,6 +1,7 @@ """ Make ajax requests to the ArangoDB server. """ +import os import requests import json @@ -74,7 +75,9 @@ def create_collection(name, is_edge): """ Create a single collection by name using some basic defaults. We ignore duplicates. For any other server error, an exception is thrown. + Shard the new collection based on the number of db nodes (10 shards for each). """ + num_shards = os.environ.get('SHARD_COUNT', 30) config = get_config() url = config['db_url'] + '/_api/collection' # collection types: @@ -84,7 +87,8 @@ def create_collection(name, is_edge): data = json.dumps({ 'keyOptions': {'allowUserKeys': True}, 'name': name, - 'type': collection_type + 'type': collection_type, + 'numberOfShards': num_shards }) resp = requests.post(url, data, auth=(config['db_user'], config['db_pass'])).json() if resp['error']: From 645eef7eba3445da75f6598963789cdcacbbe2d9 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 6 Mar 2019 10:58:18 -0800 Subject: [PATCH 261/732] Add some environment variable docs --- api/README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/api/README.md b/api/README.md index cea72105..5ae82a16 100644 --- a/api/README.md +++ b/api/README.md @@ -309,6 +309,17 @@ save_results = rec.save_documents( Where the file contains multiple JSON documents separated by line-breaks. +## Administration + +The following environment variables should be configured: + +* `KBASE_AUTH_URL` - url of the KBase authentication (auth2) server to use +* `SHARD_COUNT` - number of shards to use when creating new collections +* `KBASE_WORKSPACE_URL` - url of the KBase workspace server to use (for authenticating workspace access) +* `DB_URL` - url of the arangodb database to use for http API access +* `DB_USER` - username for the arangodb database +* `DB_PASS` - password for the arangodb database + ## Development Copy `.env.example` to `.env`. Start the server with `docker-compose up`. From f6884c12d5af0c59c2ba71481fff0094fd4cbcda Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Fri, 8 Mar 2019 10:57:57 -0800 Subject: [PATCH 262/732] Implement it --- .../utils/arango_client.py | 40 ++++++++++++++++++- .../relation_engine_server/utils/config.py | 4 ++ api/src/test/test_api_v1.py | 12 ++++++ 3 files changed, 54 insertions(+), 2 deletions(-) diff --git a/api/src/relation_engine_server/utils/arango_client.py b/api/src/relation_engine_server/utils/arango_client.py index 03875ace..b62a655e 100644 --- a/api/src/relation_engine_server/utils/arango_client.py +++ b/api/src/relation_engine_server/utils/arango_client.py @@ -39,12 +39,14 @@ def run_query(query_text=None, cursor_id=None, bind_vars=None, batch_size=100): req_json['query'] = query_text if bind_vars: req_json['bindVars'] = bind_vars - + # Initialize the readonly user + _init_readonly_user() + # Run the query as the readonly user resp = requests.request( method, url, data=json.dumps(req_json), - auth=(config['db_user'], config['db_pass']) + auth=(config['db_readonly_user'], config['db_readonly_pass']) ) if not resp.ok: raise ArangoServerError(resp.text) @@ -108,6 +110,40 @@ def import_from_file(file_path, query): return resp.text +def _init_readonly_user(): + """ + Using the root user, initialize an admin readonly user for use with ad-hoc queries. + + If the user cannot be created, we raise an ArangoServerError + If the user already exists, or is successfully created, we return None and do not raise. + """ + config = get_config() + user = config['db_readonly_user'] + # Check if the user exists, in which case this is a no-op + resp = requests.get( + config['db_url'] + '/_api/user/' + user, + auth=(config['db_user'], config['db_pass']) + ) + if resp.status_code == 200: + return + # Create the user + resp = requests.post( + config['db_url'] + '/_api/user', + data=json.dumps({'user': user, 'passwd': config['db_readonly_user']}), + auth=(config['db_user'], config['db_pass']) + ) + if resp.status_code != 201: + raise ArangoServerError(resp.text) + # Grant read access to the current database + resp = requests.put( + config['db_url'] + '/_api/user/' + user + '/database/' + config['db_name'], + data=json.dumps({'grant': 'ro'}), + auth=(config['db_user'], config['db_pass']) + ) + if resp.status_code != 200: + raise ArangoServerError(resp.text) + + class ArangoServerError(Exception): """A request to the ArangoDB server has failed (non-2xx).""" diff --git a/api/src/relation_engine_server/utils/config.py b/api/src/relation_engine_server/utils/config.py index fce0453b..6dca1e22 100644 --- a/api/src/relation_engine_server/utils/config.py +++ b/api/src/relation_engine_server/utils/config.py @@ -18,6 +18,8 @@ def get_config(): db_name = os.environ.get('DB_NAME', '_system') db_user = os.environ.get('DB_USER', 'root') db_pass = os.environ.get('DB_PASS', 'password') + db_readonly_user = os.environ.get('DB_READONLY_USER', 'readonly') + db_readonly_pass = os.environ.get('DB_READONLY_PASS', 'readonly') return { 'auth_url': auth_url, 'workspace_url': workspace_url, @@ -26,6 +28,8 @@ def get_config(): 'db_name': db_name, 'db_user': db_user, 'db_pass': db_pass, + 'db_readonly_user': db_readonly_user, + 'db_readonly_pass': db_readonly_pass, 'spec_url': spec_url, 'spec_paths': { 'release_id': os.path.join(spec_path, '.release_id'), diff --git a/api/src/test/test_api_v1.py b/api/src/test/test_api_v1.py index 7356859c..8bf6478e 100644 --- a/api/src/test/test_api_v1.py +++ b/api/src/test/test_api_v1.py @@ -414,3 +414,15 @@ def test_auth_adhoc_query(self): headers={'Authorization': ADMIN_TOKEN} # see ./mock_workspace/endpoints.json ).json() self.assertEqual(resp['count'], 1) + + def test_queries_are_readonly(self): + """Test that ad-hoc admin queries cannot do any writing.""" + save_test_docs(1) + query = 'let ws_ids = @ws_ids for v in test_vertex remove v in test_vertex' + resp = requests.post( + API_URL + '/query_results', + headers=HEADERS_ADMIN, + data=json.dumps({'query': query}) + ).json() + self.assertTrue(resp['error']) + self.assertTrue('read only' in resp['arango_message']) From cb495fbe44a225580af469b806441ce26056d98f Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Fri, 8 Mar 2019 10:59:29 -0800 Subject: [PATCH 263/732] Update README.md --- api/README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/api/README.md b/api/README.md index 71c9b30e..b7b2d153 100644 --- a/api/README.md +++ b/api/README.md @@ -155,7 +155,8 @@ _Response JSON schema_ } ``` -Results are limited to 100 items. To continue fetching additional results, use the `cursor_id` below: +Results are limited to 100 items. To continue fetching additional results, use the `cursor_id` parameter. + #### Ad-hoc sysadmin queries @@ -168,6 +169,8 @@ curl -d '{"query": "for v in coll sort rand() limit @count return v", "count": 1 This will return the same form of results as above. +**Note:** Currently, all queries are read-only. This includes view queries and ad-hoc admin queries. Commands like `UPDATE` or `REMOVE` will fail. + ### PUT /api/documents Bulk-update documents by either creating, replacing, or updating. From a91d66c018fa5f0a4a9a54b8d3035f6a7b105a7b Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Fri, 8 Mar 2019 13:24:29 -0800 Subject: [PATCH 264/732] Debug line for travis --- api/src/test/test_api_v1.py | 1 + 1 file changed, 1 insertion(+) diff --git a/api/src/test/test_api_v1.py b/api/src/test/test_api_v1.py index 8bf6478e..d80668b3 100644 --- a/api/src/test/test_api_v1.py +++ b/api/src/test/test_api_v1.py @@ -424,5 +424,6 @@ def test_queries_are_readonly(self): headers=HEADERS_ADMIN, data=json.dumps({'query': query}) ).json() + print('READONLY_RESP', resp) self.assertTrue(resp['error']) self.assertTrue('read only' in resp['arango_message']) From 21297e3569aa2839ce8281a820fe27bcb97e0492 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Fri, 8 Mar 2019 13:26:12 -0800 Subject: [PATCH 265/732] Fix comment --- api/src/relation_engine_server/utils/arango_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/src/relation_engine_server/utils/arango_client.py b/api/src/relation_engine_server/utils/arango_client.py index b62a655e..19f4d709 100644 --- a/api/src/relation_engine_server/utils/arango_client.py +++ b/api/src/relation_engine_server/utils/arango_client.py @@ -112,7 +112,7 @@ def import_from_file(file_path, query): def _init_readonly_user(): """ - Using the root user, initialize an admin readonly user for use with ad-hoc queries. + Using the admin user, initialize an admin readonly user for use with ad-hoc queries. If the user cannot be created, we raise an ArangoServerError If the user already exists, or is successfully created, we return None and do not raise. From 53f035d1097632954d2bbba7d7904e46ad316761 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Fri, 8 Mar 2019 13:27:58 -0800 Subject: [PATCH 266/732] Remove extraneous json parsing --- api/src/relation_engine_server/utils/arango_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/src/relation_engine_server/utils/arango_client.py b/api/src/relation_engine_server/utils/arango_client.py index 19f4d709..6810fa71 100644 --- a/api/src/relation_engine_server/utils/arango_client.py +++ b/api/src/relation_engine_server/utils/arango_client.py @@ -137,7 +137,7 @@ def _init_readonly_user(): # Grant read access to the current database resp = requests.put( config['db_url'] + '/_api/user/' + user + '/database/' + config['db_name'], - data=json.dumps({'grant': 'ro'}), + data='{"grant": "ro"}', auth=(config['db_user'], config['db_pass']) ) if resp.status_code != 200: From cf93a293643f066e593414d49e79e1676eae4f92 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Fri, 8 Mar 2019 13:42:47 -0800 Subject: [PATCH 267/732] Small doc addition --- api/README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/api/README.md b/api/README.md index b7b2d153..ee4156e2 100644 --- a/api/README.md +++ b/api/README.md @@ -325,6 +325,14 @@ See the [Contribution Guidelines](/.github/CONTRIBUTING.md). **Run tests** with `make test` (the server should be running in another terminal using `docker-compose up --build`). +To do a hard reset of your docker build, do: + +```sh +docker-compose rm -vf +docker-compose build --no-cache +docker-compose up +``` + ## Deployment The docker image is pushed to Docker Hub when new commits are made to master. The script that runs when pushing to docker hub is found in `hooks/build`. From 8d7ce25f05810f26301cfc525be84e99bb59b2a8 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Fri, 8 Mar 2019 13:42:55 -0800 Subject: [PATCH 268/732] Debug for travis (TODO remove) --- api/src/relation_engine_server/utils/arango_client.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/api/src/relation_engine_server/utils/arango_client.py b/api/src/relation_engine_server/utils/arango_client.py index 6810fa71..527c6f17 100644 --- a/api/src/relation_engine_server/utils/arango_client.py +++ b/api/src/relation_engine_server/utils/arango_client.py @@ -42,6 +42,9 @@ def run_query(query_text=None, cursor_id=None, bind_vars=None, batch_size=100): # Initialize the readonly user _init_readonly_user() # Run the query as the readonly user + # XXX REMOVE ME + print('auth', config['db_readonly_user'], config['db_readonly_pass']) + # XXX REMOVE ME resp = requests.request( method, url, @@ -125,6 +128,7 @@ def _init_readonly_user(): auth=(config['db_user'], config['db_pass']) ) if resp.status_code == 200: + print('xyz user exists') return # Create the user resp = requests.post( @@ -133,7 +137,9 @@ def _init_readonly_user(): auth=(config['db_user'], config['db_pass']) ) if resp.status_code != 201: + print('xyz error creating ro user') raise ArangoServerError(resp.text) + print('xyz created ro user') # Grant read access to the current database resp = requests.put( config['db_url'] + '/_api/user/' + user + '/database/' + config['db_name'], @@ -141,7 +147,9 @@ def _init_readonly_user(): auth=(config['db_user'], config['db_pass']) ) if resp.status_code != 200: + print('xyz error granting ro user') raise ArangoServerError(resp.text) + print('xyz granted ro user') class ArangoServerError(Exception): From d9dd9bff059ea3bfb77b0abc2b50e246ec83cc5f Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 13 Mar 2019 16:29:28 -0700 Subject: [PATCH 269/732] Tweak dockerfile --- api/Dockerfile | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/api/Dockerfile b/api/Dockerfile index 9b5b8090..0e2d4c54 100644 --- a/api/Dockerfile +++ b/api/Dockerfile @@ -2,15 +2,14 @@ FROM python:3.7-alpine ARG DEVELOPMENT -COPY requirements.txt /app/requirements.txt -COPY dev-requirements.txt /app/dev-requirements.txt +COPY requirements.txt dev-requirements.txt /tmp/ WORKDIR /app # Install dependencies RUN apk --update add --virtual build-dependencies python-dev build-base && \ pip install --upgrade pip && \ - pip install --upgrade --no-cache-dir -r requirements.txt && \ - if [ "$DEVELOPMENT" ]; then pip install -r dev-requirements.txt; fi && \ + pip install --no-cache-dir -r /tmp/requirements.txt && \ + if [ "$DEVELOPMENT" ]; then pip install --no-cache-dir -r /tmp/dev-requirements.txt; fi && \ apk del build-dependencies # Run the app From ea328100e97e32ad9b8357141194488e45cf5ff6 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 13 Mar 2019 16:45:15 -0700 Subject: [PATCH 270/732] Debug travis --- api/.env.example | 10 ---------- api/.travis.yml | 4 ---- .../relation_engine_server/utils/arango_client.py | 14 ++++++-------- 3 files changed, 6 insertions(+), 22 deletions(-) delete mode 100644 api/.env.example diff --git a/api/.env.example b/api/.env.example deleted file mode 100644 index fc3b1cd7..00000000 --- a/api/.env.example +++ /dev/null @@ -1,10 +0,0 @@ -# DB_URL=http://graph1:8529 -# DB_USER=root -# DB_PASS=password -# KBASE_ENDPOINT=https://ci.kbase.us/services - -# # Optional - will fall back to use KBASE_ENDPOINT -# KBASE_AUTH_URL=https://ci.kbase.us/services/auth - -# # You can also set: -# WORKERS - set number of gevent workers (otherwise automatically calculated) diff --git a/api/.travis.yml b/api/.travis.yml index 698ae832..3b2930a9 100644 --- a/api/.travis.yml +++ b/api/.travis.yml @@ -1,11 +1,7 @@ sudo: required services: - docker -language: python -python: -- 3.6 script: -- cp .env.example .env - docker-compose up --build -d - sleep 15 - make test diff --git a/api/src/relation_engine_server/utils/arango_client.py b/api/src/relation_engine_server/utils/arango_client.py index 527c6f17..40aad695 100644 --- a/api/src/relation_engine_server/utils/arango_client.py +++ b/api/src/relation_engine_server/utils/arango_client.py @@ -42,9 +42,7 @@ def run_query(query_text=None, cursor_id=None, bind_vars=None, batch_size=100): # Initialize the readonly user _init_readonly_user() # Run the query as the readonly user - # XXX REMOVE ME - print('auth', config['db_readonly_user'], config['db_readonly_pass']) - # XXX REMOVE ME + print('auth', config['db_readonly_user'], config['db_readonly_pass']) # XXX remove me resp = requests.request( method, url, @@ -128,7 +126,7 @@ def _init_readonly_user(): auth=(config['db_user'], config['db_pass']) ) if resp.status_code == 200: - print('xyz user exists') + print('xyz user exists') # XXX remove me return # Create the user resp = requests.post( @@ -137,9 +135,9 @@ def _init_readonly_user(): auth=(config['db_user'], config['db_pass']) ) if resp.status_code != 201: - print('xyz error creating ro user') + print('xyz error creating ro user') # XXX remove me raise ArangoServerError(resp.text) - print('xyz created ro user') + print('xyz created ro user') # XXX remove me # Grant read access to the current database resp = requests.put( config['db_url'] + '/_api/user/' + user + '/database/' + config['db_name'], @@ -147,9 +145,9 @@ def _init_readonly_user(): auth=(config['db_user'], config['db_pass']) ) if resp.status_code != 200: - print('xyz error granting ro user') + print('xyz error granting ro user') # XXX remove me raise ArangoServerError(resp.text) - print('xyz granted ro user') + print('xyz granted ro user') # XXX remove me class ArangoServerError(Exception): From 1b0903888acb901b1be2b5e8a5c93a769007d85c Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 13 Mar 2019 18:07:53 -0700 Subject: [PATCH 271/732] Grant on collection too.. --- .../utils/arango_client.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/api/src/relation_engine_server/utils/arango_client.py b/api/src/relation_engine_server/utils/arango_client.py index 7bb050d1..de739f58 100644 --- a/api/src/relation_engine_server/utils/arango_client.py +++ b/api/src/relation_engine_server/utils/arango_client.py @@ -43,7 +43,6 @@ def run_query(query_text=None, cursor_id=None, bind_vars=None, batch_size=100): # Initialize the readonly user _init_readonly_user() # Run the query as the readonly user - print('auth', config['db_readonly_user'], config['db_readonly_pass']) # XXX remove me resp = requests.request( method, url, @@ -130,7 +129,6 @@ def _init_readonly_user(): auth=(config['db_user'], config['db_pass']) ) if resp.status_code == 200: - print('xyz user exists') # XXX remove me return # Create the user resp = requests.post( @@ -139,19 +137,24 @@ def _init_readonly_user(): auth=(config['db_user'], config['db_pass']) ) if resp.status_code != 201: - print('xyz error creating ro user') # XXX remove me raise ArangoServerError(resp.text) - print('xyz created ro user') # XXX remove me + db_grant_path = config['db_url'] + '/_api/user/' + user + '/database/' + config['db_name'] # Grant read access to the current database resp = requests.put( - config['db_url'] + '/_api/user/' + user + '/database/' + config['db_name'], + db_grant_path, + data='{"grant": "ro"}', + auth=(config['db_user'], config['db_pass']) + ) + if resp.status_code != 200: + raise ArangoServerError(resp.text) + # Grant read access to all collections + resp = requests.put( + db_grant_path + '/*', data='{"grant": "ro"}', auth=(config['db_user'], config['db_pass']) ) if resp.status_code != 200: - print('xyz error granting ro user') # XXX remove me raise ArangoServerError(resp.text) - print('xyz granted ro user') # XXX remove me class ArangoServerError(Exception): From 2931fca8de13778801e409718888df9cb767cb85 Mon Sep 17 00:00:00 2001 From: JamesJeffryes Date: Thu, 14 Mar 2019 11:19:46 -0500 Subject: [PATCH 272/732] Add compound &rxn search views --- spec/views/search_compounds.aql | 11 +++++++++++ spec/views/search_reactions.aql | 10 ++++++++++ 2 files changed, 21 insertions(+) create mode 100644 spec/views/search_compounds.aql create mode 100644 spec/views/search_reactions.aql diff --git a/spec/views/search_compounds.aql b/spec/views/search_compounds.aql new file mode 100644 index 00000000..c0c526a7 --- /dev/null +++ b/spec/views/search_compounds.aql @@ -0,0 +1,11 @@ +\\ Use ArangoSearch to search documents in the compounds index. Returns documents in their natural order +\\ include_obsolete - should obsolete documents be included +\\ offset - how many documents to skip +\\ result_limit - Maximum documents to return +FOR doc IN Compounds + SEARCH ANALYZER(PHRASE(doc.id, @search_text) + OR PHRASE(doc.abbreviation, @search_text) + OR PHRASE(doc.aliases, @search_text), 'text_en') + FILTER @include_obsolete || doc.is_obsolete == 0 + LIMIT @offset, @result_limit + RETURN doc \ No newline at end of file diff --git a/spec/views/search_reactions.aql b/spec/views/search_reactions.aql new file mode 100644 index 00000000..401f42d8 --- /dev/null +++ b/spec/views/search_reactions.aql @@ -0,0 +1,10 @@ +\\ Use ArangoSearch to search documents in the Reactions index. Returns documents in their natural order +\\ include_obsolete - should obsolete documents be included +\\ offset - how many documents to skip +\\ result_limit - Maximum documents to return +FOR doc IN Reactions + SEARCH ANALYZER(PHRASE(doc.name, @search_text) + OR PHRASE(doc.aliases, @search_text), 'text_en') + FILTER @include_obsolete || doc.is_obsolete == 0 + LIMIT @offset, @result_limit + RETURN doc \ No newline at end of file From fc6eddf515508e1a47ed62f6070915ceaf3d6cf1 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Thu, 14 Mar 2019 10:57:39 -0700 Subject: [PATCH 273/732] Fix the docker cluster mode auth for testing by giving it a jwtSecret file --- api/.gitignore | 2 +- api/docker-compose.yaml | 6 ++---- api/src/relation_engine_client/__init__.py | 2 -- api/src/relation_engine_server/server.py | 1 - api/src/relation_engine_server/utils/arango_client.py | 10 ++++++---- api/src/relation_engine_server/utils/config.py | 2 +- api/src/test/test_api_v1.py | 1 - 7 files changed, 10 insertions(+), 14 deletions(-) diff --git a/api/.gitignore b/api/.gitignore index 2be5fcda..8d6440a4 100644 --- a/api/.gitignore +++ b/api/.gitignore @@ -7,6 +7,6 @@ *.pyc .mypy_cache/ .cache/ -tmp/* +/tmp/ coverage_report/ .coverage diff --git a/api/docker-compose.yaml b/api/docker-compose.yaml index 7c2fc9f0..da936089 100644 --- a/api/docker-compose.yaml +++ b/api/docker-compose.yaml @@ -24,7 +24,6 @@ services: - SPEC_RELEASE_PATH=/app/src/test/spec_release/spec.tar.gz - DB_URL=http://arangodb:8529 - DB_USER=root - - DB_PASS=password # A mock kbase auth server (see src/test/mock_auth/endpoints.json) auth: @@ -43,6 +42,5 @@ services: image: arangodb:3.4 ports: - 8529:8529 - environment: - - ARANGO_ROOT_PASSWORD=password - command: arangodb --starter.local + command: sh -c "arangodb create jwt-secret --secret=jwtSecret && + arangodb --starter.local --auth.jwt-secret=./jwtSecret" diff --git a/api/src/relation_engine_client/__init__.py b/api/src/relation_engine_client/__init__.py index ce5ce389..46409041 100644 --- a/api/src/relation_engine_client/__init__.py +++ b/api/src/relation_engine_client/__init__.py @@ -1,3 +1 @@ # TODO - -x = 1 diff --git a/api/src/relation_engine_server/server.py b/api/src/relation_engine_server/server.py index b9b26f8f..4a1244e5 100644 --- a/api/src/relation_engine_server/server.py +++ b/api/src/relation_engine_server/server.py @@ -183,7 +183,6 @@ def server_error(err): traceback.print_exc() print('=' * 80) resp = {'error': '500 - Unexpected server error'} - # if os.environ.get('FLASK_DEBUG'): TODO resp['error_class'] = err.__class__.__name__ resp['error_details'] = str(err) return _json_resp(resp, 500) diff --git a/api/src/relation_engine_server/utils/arango_client.py b/api/src/relation_engine_server/utils/arango_client.py index de739f58..bfd69e23 100644 --- a/api/src/relation_engine_server/utils/arango_client.py +++ b/api/src/relation_engine_server/utils/arango_client.py @@ -92,15 +92,17 @@ def create_collection(name, is_edge): 'type': collection_type, 'numberOfShards': num_shards }) - resp = requests.post(url, data, auth=(config['db_user'], config['db_pass'])).json() - if resp['error']: - if 'duplicate' not in resp['errorMessage']: + print('authh', config) + resp = requests.post(url, data, auth=(config['db_user'], config['db_pass'])) + resp_json = resp.json() + if not resp.ok: + if 'duplicate' not in resp_json['errorMessage']: # Unable to create a collection raise ArangoServerError(resp.text) def import_from_file(file_path, query): - """Make a generic arango post request.""" + """Import documents from a file.""" config = get_config() with open(file_path, 'rb') as file_desc: resp = requests.post( diff --git a/api/src/relation_engine_server/utils/config.py b/api/src/relation_engine_server/utils/config.py index 6dca1e22..c9daeac0 100644 --- a/api/src/relation_engine_server/utils/config.py +++ b/api/src/relation_engine_server/utils/config.py @@ -17,7 +17,7 @@ def get_config(): db_url = os.environ.get('DB_URL', 'http://localhost:8529') db_name = os.environ.get('DB_NAME', '_system') db_user = os.environ.get('DB_USER', 'root') - db_pass = os.environ.get('DB_PASS', 'password') + db_pass = os.environ.get('DB_PASS', '') db_readonly_user = os.environ.get('DB_READONLY_USER', 'readonly') db_readonly_pass = os.environ.get('DB_READONLY_PASS', 'readonly') return { diff --git a/api/src/test/test_api_v1.py b/api/src/test/test_api_v1.py index d80668b3..8bf6478e 100644 --- a/api/src/test/test_api_v1.py +++ b/api/src/test/test_api_v1.py @@ -424,6 +424,5 @@ def test_queries_are_readonly(self): headers=HEADERS_ADMIN, data=json.dumps({'query': query}) ).json() - print('READONLY_RESP', resp) self.assertTrue(resp['error']) self.assertTrue('read only' in resp['arango_message']) From d41d9b83f6adc7138dd7f0c2c3d7a5f450fa0c13 Mon Sep 17 00:00:00 2001 From: JamesJeffryes Date: Thu, 14 Mar 2019 13:55:36 -0500 Subject: [PATCH 274/732] update biochem schemas --- .../rxn/rxn_compound_linked_to_compound.json | 15 ++++ .../rxn/rxn_compound_within_reaction.json | 22 +++++ .../rxn/rxn_reaction_linked_to_reaction.json | 15 ++++ spec/schemas/vertices/rxn/rxn_compound | 83 +++++++++++++++++++ spec/schemas/vertices/rxn/rxn_reaction.json | 2 +- 5 files changed, 136 insertions(+), 1 deletion(-) create mode 100644 spec/schemas/edges/rxn/rxn_compound_linked_to_compound.json create mode 100644 spec/schemas/edges/rxn/rxn_compound_within_reaction.json create mode 100644 spec/schemas/edges/rxn/rxn_reaction_linked_to_reaction.json create mode 100644 spec/schemas/vertices/rxn/rxn_compound diff --git a/spec/schemas/edges/rxn/rxn_compound_linked_to_compound.json b/spec/schemas/edges/rxn/rxn_compound_linked_to_compound.json new file mode 100644 index 00000000..e832972c --- /dev/null +++ b/spec/schemas/edges/rxn/rxn_compound_linked_to_compound.json @@ -0,0 +1,15 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "required": ["_from", "_to"], + "properties": { + "_from": { + "type": "string", + "description": "A reaction" + }, + "_to": { + "type": "string", + "description": "Another reaction" + } + } +} diff --git a/spec/schemas/edges/rxn/rxn_compound_within_reaction.json b/spec/schemas/edges/rxn/rxn_compound_within_reaction.json new file mode 100644 index 00000000..9f5d30a4 --- /dev/null +++ b/spec/schemas/edges/rxn/rxn_compound_within_reaction.json @@ -0,0 +1,22 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "required": ["_from", "_to"], + "description": "A compound is a memeber of a reaction", + "additionalProperties": true, + "properties": { + "_from": { + "type": "string", + "description": "The ID of the compound" + }, + "_to": { + "type": "string", + "description": "The ID of the reaction" + }, + "stoichiometry": { + "type": "float", + "description": "The stochiometry of compound in the reaction" + } + } +} + diff --git a/spec/schemas/edges/rxn/rxn_reaction_linked_to_reaction.json b/spec/schemas/edges/rxn/rxn_reaction_linked_to_reaction.json new file mode 100644 index 00000000..e832972c --- /dev/null +++ b/spec/schemas/edges/rxn/rxn_reaction_linked_to_reaction.json @@ -0,0 +1,15 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "required": ["_from", "_to"], + "properties": { + "_from": { + "type": "string", + "description": "A reaction" + }, + "_to": { + "type": "string", + "description": "Another reaction" + } + } +} diff --git a/spec/schemas/vertices/rxn/rxn_compound b/spec/schemas/vertices/rxn/rxn_compound new file mode 100644 index 00000000..85d5e220 --- /dev/null +++ b/spec/schemas/vertices/rxn/rxn_compound @@ -0,0 +1,83 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "additionalProperties": true, + "required": ["_key"], + "description": "Chemical reactions", + "properties": { + "_key": { + "type": "string", + "examples": ["cpd02201"], + "title": "ModelSeed ID", + "pattern": "^cpd\\d+$" + }, + "abbreviation": { + "type": "string", + "examples": ["phpyr"] + }, + "aliases": { + "type": "string", + "examples": ["AraCyc:PYRUVATE;BiGG:pyr;BrachyCyc:PYRUVATE;KEGG:C00022"] + }, + "charge": { + "type": ["integer"], + "examples": ["-1"] + }, + "deltag": { + "type": ["float", "null"], + "description": "The change in Free Energy of Formation" + }, + "deltagerr": { + "type": ["float", "null"], + "description": "The error associated with the Free Energy of Formation" + }, + "formula": { + "type": "string", + "examples": ["C6H6"] + }, + "id": { + "type": "string", + "examples": ["cpd02201"], + "title": "ModelSeed ID", + "pattern": "^cpd\\d+$" + }, + "inchikey": { + "type": "string", + "examples": ["LCTONWCANYUPML-UHFFFAOYSA-M"] + }, + "is_cofactor": { + "type": "integer", + "description": "The compound is a cofactor" + }, + "is_core": { + "type": "integer", + "description": "The compound is involved in core metabolism" + }, + "is_obsolete": { + "type": "integer", + "description": "The compound is a deprecated" + }, + "linked_compound": { + "type": ["string", "null"], + "description": "If the compound is deprecated, the compound that supersedes this entry" + }, + "mass": { + "type": ["float", "null"], + }, + "name": { + "type": "string", + }, + "pka": { + "type": "string", + }, + "pkb": { + "type": "string", + }, + "smiles": { + "type": "string", + }, + "source": { + "type": "string", + }, + } +} diff --git a/spec/schemas/vertices/rxn/rxn_reaction.json b/spec/schemas/vertices/rxn/rxn_reaction.json index 9d9b99aa..6332ff9a 100644 --- a/spec/schemas/vertices/rxn/rxn_reaction.json +++ b/spec/schemas/vertices/rxn/rxn_reaction.json @@ -1,7 +1,7 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", - "additionalProperties": false, + "additionalProperties": true, "required": ["_key"], "description": "Chemical reactions", "properties": { From a4a7d60293c8e0899debb3777b6e95fe185ab78e Mon Sep 17 00:00:00 2001 From: JamesJeffryes Date: Thu, 14 Mar 2019 13:58:24 -0500 Subject: [PATCH 275/732] extend queries & fix schema --- spec/schemas/vertices/rxn/rxn_compound | 6 +++--- spec/views/search_compounds.aql | 1 + spec/views/search_reactions.aql | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/spec/schemas/vertices/rxn/rxn_compound b/spec/schemas/vertices/rxn/rxn_compound index 85d5e220..a7fab5a5 100644 --- a/spec/schemas/vertices/rxn/rxn_compound +++ b/spec/schemas/vertices/rxn/rxn_compound @@ -24,11 +24,11 @@ "examples": ["-1"] }, "deltag": { - "type": ["float", "null"], + "type": ["number", "null"], "description": "The change in Free Energy of Formation" }, "deltagerr": { - "type": ["float", "null"], + "type": ["number", "null"], "description": "The error associated with the Free Energy of Formation" }, "formula": { @@ -62,7 +62,7 @@ "description": "If the compound is deprecated, the compound that supersedes this entry" }, "mass": { - "type": ["float", "null"], + "type": ["number", "null"], }, "name": { "type": "string", diff --git a/spec/views/search_compounds.aql b/spec/views/search_compounds.aql index c0c526a7..6f7b347b 100644 --- a/spec/views/search_compounds.aql +++ b/spec/views/search_compounds.aql @@ -4,6 +4,7 @@ \\ result_limit - Maximum documents to return FOR doc IN Compounds SEARCH ANALYZER(PHRASE(doc.id, @search_text) + OR PHRASE(doc.name, @search_text) OR PHRASE(doc.abbreviation, @search_text) OR PHRASE(doc.aliases, @search_text), 'text_en') FILTER @include_obsolete || doc.is_obsolete == 0 diff --git a/spec/views/search_reactions.aql b/spec/views/search_reactions.aql index 401f42d8..c9684009 100644 --- a/spec/views/search_reactions.aql +++ b/spec/views/search_reactions.aql @@ -3,7 +3,8 @@ \\ offset - how many documents to skip \\ result_limit - Maximum documents to return FOR doc IN Reactions - SEARCH ANALYZER(PHRASE(doc.name, @search_text) + SEARCH ANALYZER(PHRASE(doc.id, @search_text) + OR PHRASE(doc.name, @search_text) OR PHRASE(doc.aliases, @search_text), 'text_en') FILTER @include_obsolete || doc.is_obsolete == 0 LIMIT @offset, @result_limit From 208da3bbf9c33b99f10dd4889fb55572af885e23 Mon Sep 17 00:00:00 2001 From: JamesJeffryes Date: Thu, 14 Mar 2019 14:12:05 -0500 Subject: [PATCH 276/732] comp descriptions --- .../vertices/rxn/{rxn_compound => rxn_compound.json} | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) rename spec/schemas/vertices/rxn/{rxn_compound => rxn_compound.json} (83%) diff --git a/spec/schemas/vertices/rxn/rxn_compound b/spec/schemas/vertices/rxn/rxn_compound.json similarity index 83% rename from spec/schemas/vertices/rxn/rxn_compound rename to spec/schemas/vertices/rxn/rxn_compound.json index a7fab5a5..8c6cfc62 100644 --- a/spec/schemas/vertices/rxn/rxn_compound +++ b/spec/schemas/vertices/rxn/rxn_compound.json @@ -63,21 +63,26 @@ }, "mass": { "type": ["number", "null"], + "description": "Molecular mass of compound" }, "name": { - "type": "string", + "type": "string" }, "pka": { "type": "string", + "description": "Acid dissociation constants of compound" }, "pkb": { "type": "string", + "description": "Base dissociation constants of compound" }, "smiles": { "type": "string", + "description": "Structure of the compound in Simplified Molecular Input Line Entry System" }, "source": { "type": "string", + "description": "Does this compound come from a primary database or a metabolic model?" }, } } From 66ddff1ab0d0276ba9fdd2b81b5646c019905224 Mon Sep 17 00:00:00 2001 From: JamesJeffryes Date: Thu, 14 Mar 2019 14:17:25 -0500 Subject: [PATCH 277/732] link descriptions --- spec/schemas/edges/rxn/rxn_compound_linked_to_compound.json | 1 + spec/schemas/edges/rxn/rxn_reaction_linked_to_reaction.json | 1 + spec/schemas/vertices/rxn/rxn_compound.json | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/spec/schemas/edges/rxn/rxn_compound_linked_to_compound.json b/spec/schemas/edges/rxn/rxn_compound_linked_to_compound.json index e832972c..5008d405 100644 --- a/spec/schemas/edges/rxn/rxn_compound_linked_to_compound.json +++ b/spec/schemas/edges/rxn/rxn_compound_linked_to_compound.json @@ -2,6 +2,7 @@ "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "required": ["_from", "_to"], + "description": "Generally these linkages indicate a that one compound has been made obsolete and replaced with the linked compound. This may arise from duplicates in the database or errors in the obsolete entity", "properties": { "_from": { "type": "string", diff --git a/spec/schemas/edges/rxn/rxn_reaction_linked_to_reaction.json b/spec/schemas/edges/rxn/rxn_reaction_linked_to_reaction.json index e832972c..668db047 100644 --- a/spec/schemas/edges/rxn/rxn_reaction_linked_to_reaction.json +++ b/spec/schemas/edges/rxn/rxn_reaction_linked_to_reaction.json @@ -2,6 +2,7 @@ "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "required": ["_from", "_to"], + "description": "Generally these linkages indicate a that one reaction has been made obsolete and replaced with the linked reaction. This may arise from duplicates in the database or errors in the obsolete entity", "properties": { "_from": { "type": "string", diff --git a/spec/schemas/vertices/rxn/rxn_compound.json b/spec/schemas/vertices/rxn/rxn_compound.json index 8c6cfc62..ccc71935 100644 --- a/spec/schemas/vertices/rxn/rxn_compound.json +++ b/spec/schemas/vertices/rxn/rxn_compound.json @@ -83,6 +83,6 @@ "source": { "type": "string", "description": "Does this compound come from a primary database or a metabolic model?" - }, + } } } From 08623f656038e3f152220af7b4e5ff620514734b Mon Sep 17 00:00:00 2001 From: JamesJeffryes Date: Thu, 14 Mar 2019 14:28:32 -0500 Subject: [PATCH 278/732] Ugg --- spec/schemas/edges/rxn/rxn_compound_within_reaction.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/schemas/edges/rxn/rxn_compound_within_reaction.json b/spec/schemas/edges/rxn/rxn_compound_within_reaction.json index 9f5d30a4..d4bfd498 100644 --- a/spec/schemas/edges/rxn/rxn_compound_within_reaction.json +++ b/spec/schemas/edges/rxn/rxn_compound_within_reaction.json @@ -14,7 +14,7 @@ "description": "The ID of the reaction" }, "stoichiometry": { - "type": "float", + "type": "number", "description": "The stochiometry of compound in the reaction" } } From 5cf87594670e675a049d95cda75e926c3eb025ad Mon Sep 17 00:00:00 2001 From: JamesJeffryes Date: Thu, 14 Mar 2019 16:34:30 -0500 Subject: [PATCH 279/732] sorted compound and using the versioned API --- spec/test/views/init_spec.py | 8 ++++---- spec/test/views/test_list_test_vertices.py | 13 +++++++------ spec/views/search_compounds.aql | 3 ++- spec/views/search_reactions.aql | 3 ++- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/spec/test/views/init_spec.py b/spec/test/views/init_spec.py index 1a27fccc..53e7a2a6 100644 --- a/spec/test/views/init_spec.py +++ b/spec/test/views/init_spec.py @@ -1,12 +1,12 @@ import requests -_API_URL = 'http://re_api:5000/api' +_API_URL = 'http://re_api:5000/api/v1' if __name__ == '__main__': - resp = requests.get( - _API_URL + '/update_specs', + resp = requests.put( + _API_URL + '/specs', headers={'Authorization': 'admin_token'}, params={'init_collections': '1'} ) - print(resp) + print(resp.text) diff --git a/spec/test/views/test_list_test_vertices.py b/spec/test/views/test_list_test_vertices.py index 7291ccd2..e768a26e 100644 --- a/spec/test/views/test_list_test_vertices.py +++ b/spec/test/views/test_list_test_vertices.py @@ -3,13 +3,14 @@ import requests _API_URL = 'http://re_api:5000/api' -_QUERY_URL = _API_URL + '/query_results?view=list_test_vertices' +_VERSION = 'v1' +_QUERY_URL = f'{_API_URL}/{_VERSION}/query_results?view=list_test_vertices' def create_test_docs(docs): body = '\n'.join([json.dumps(d) for d in docs]) return requests.put( - _API_URL + '/documents', + f'{_API_URL}/{_VERSION}/documents', params={'overwrite': True, 'collection': 'test_vertex'}, data=body, headers={'Authorization': 'admin_token'} @@ -20,11 +21,11 @@ class TestListTestVertices(unittest.TestCase): def test_valid(self): """Test a valid query.""" - create_test_docs([ + print(create_test_docs([ {'is_public': True, '_key': 'a', 'ws_id': 10}, # public access {'is_public': False, '_key': 'b', 'ws_id': 1}, # private access {'is_public': False, '_key': 'c', 'ws_id': 99} # no access - ]) + ])) resp = requests.post( _QUERY_URL, headers={'Authorization': 'valid_token'} # gives access to workspaces [1,2,3] @@ -35,11 +36,11 @@ def test_valid(self): def test_no_auth(self): """Test with blank auth.""" - create_test_docs([ + print(create_test_docs([ {'is_public': True, '_key': 'a', 'ws_id': 10}, # public access {'is_public': False, '_key': 'b', 'ws_id': 1}, # private access {'is_public': False, '_key': 'c', 'ws_id': 99} # no access - ]) + ])) resp = requests.post(_QUERY_URL).json() self.assertEqual(resp['count'], 1) # 'b' and 'c' are inaccessible diff --git a/spec/views/search_compounds.aql b/spec/views/search_compounds.aql index 6f7b347b..4cffed01 100644 --- a/spec/views/search_compounds.aql +++ b/spec/views/search_compounds.aql @@ -1,4 +1,4 @@ -\\ Use ArangoSearch to search documents in the compounds index. Returns documents in their natural order +\\ Use ArangoSearch to search documents in the compounds index. Returns documents by ascending id. \\ include_obsolete - should obsolete documents be included \\ offset - how many documents to skip \\ result_limit - Maximum documents to return @@ -8,5 +8,6 @@ FOR doc IN Compounds OR PHRASE(doc.abbreviation, @search_text) OR PHRASE(doc.aliases, @search_text), 'text_en') FILTER @include_obsolete || doc.is_obsolete == 0 + SORT doc.id LIMIT @offset, @result_limit RETURN doc \ No newline at end of file diff --git a/spec/views/search_reactions.aql b/spec/views/search_reactions.aql index c9684009..024d44f2 100644 --- a/spec/views/search_reactions.aql +++ b/spec/views/search_reactions.aql @@ -1,4 +1,4 @@ -\\ Use ArangoSearch to search documents in the Reactions index. Returns documents in their natural order +\\ Use ArangoSearch to search documents in the Reactions index. Returns documents by ascending id. \\ include_obsolete - should obsolete documents be included \\ offset - how many documents to skip \\ result_limit - Maximum documents to return @@ -7,5 +7,6 @@ FOR doc IN Reactions OR PHRASE(doc.name, @search_text) OR PHRASE(doc.aliases, @search_text), 'text_en') FILTER @include_obsolete || doc.is_obsolete == 0 + SORT doc.id LIMIT @offset, @result_limit RETURN doc \ No newline at end of file From 1cf9f0701a1f95d19ae376f1cde4a1a7aedda84c Mon Sep 17 00:00:00 2001 From: James Jeffryes Date: Thu, 14 Mar 2019 16:42:59 -0500 Subject: [PATCH 280/732] Update readme for v1 api --- api/README.md | 39 ++++++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/api/README.md b/api/README.md index 33d944de..dadbbff2 100644 --- a/api/README.md +++ b/api/README.md @@ -2,7 +2,7 @@ A simple API that allows KBase community developers to interact with the Relation Engine graph database. You can run stored queries or do bulk updates on documents. -## HTTP API +## HTTP API v1 The API is a small, rest-ish service where all data is in JSON format. Replace the `{root_url}` in the examples below with one of: * Production: `https://kbase.us/services/relation_engine_api` @@ -47,14 +47,14 @@ _Example response_ } ``` -### GET /api/views/ +### GET /api/v1/specs/views/ Get the AQL source code for a view _Example request_ ```sh -curl {root_url}/api/views/example_view1 +curl {root_url}/api/v1/specs/views/example_view1 ``` Response has mimetype of text/plain @@ -68,14 +68,14 @@ for x in @@collection return x ``` -### GET /api/schemas/ +### GET /api/v1/specs/schemas/ Get the JSON source for a registered schema by name. _Example request_ ```sh -curl {root_url}/api/schemas/vertex_examples1 +curl {root_url}/api/v1/specs/schemas/vertex_examples1 ``` _Example response_ @@ -88,14 +88,35 @@ _Example response_ } ``` -### POST /api/query_results +### GET /api/v1/config/ + +Check the current public service configuration. + +_Example_ + +``` +curl {root_url}/api/config +``` + +_Example response_ + +```json +{ "auth_url": "http://auth:5000", + "workspace_url": "http://workspace:5000", + "kbase_endpoint": "https://ci.kbase.us/services", + "db_url": "http://arangodb:8529", + "db_name": "_system", + "spec_url": "https://api.github.com/repos/kbase/relation_engine_spec"} +``` + +### POST /api/v1/query_results Run a query using a view or a cursor ID. Semantically, this is a GET, but it's a POST to allow better support for passing JSON in the request body (eg. Postman doesn't allow request body data in get requests) _Example rquest_ ```sh -curl -X POST -d '{"argument": "value"}' {root_url}/api/query_results?view=example +curl -X POST -d '{"argument": "value"}' {root_url}/api/v1/query_results?view=example ``` _Query params_ @@ -171,7 +192,7 @@ This will return the same form of results as above. **Note:** Currently, all queries are read-only. This includes view queries and ad-hoc admin queries. Commands like `UPDATE` or `REMOVE` will fail. -### PUT /api/documents +### PUT /api/v1/documents Bulk-update documents by either creating, replacing, or updating. @@ -234,7 +255,7 @@ _Response JSON schema_ } ``` -### GET /api/update_specs +### PUT /api/v1/specs/ Manually check and pull spec updates. Requires sysadmin auth. From 144bbb396166dec44a4c9ef023b578285bf48571 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 20 Mar 2019 10:25:25 -0700 Subject: [PATCH 281/732] Add backwards compat for old api --- api/scripts/run_tests.sh | 2 +- api/src/relation_engine_server/server.py | 19 +++++++++++++------ api/src/test/test_api_v1.py | 15 +++++++++++++++ 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/api/scripts/run_tests.sh b/api/scripts/run_tests.sh index 4342b07f..5212f273 100644 --- a/api/scripts/run_tests.sh +++ b/api/scripts/run_tests.sh @@ -2,7 +2,7 @@ set -e -flake8 --max-complexity 5 src +flake8 src mypy --ignore-missing-imports src python -m pyflakes src bandit -r src diff --git a/api/src/relation_engine_server/server.py b/api/src/relation_engine_server/server.py index 4a1244e5..c04787b8 100644 --- a/api/src/relation_engine_server/server.py +++ b/api/src/relation_engine_server/server.py @@ -49,8 +49,7 @@ def api_call(path): """ # Get the path and version number path_parts = path.split('/') - version_int = _get_version(path_parts[0]) - api_path = '/'.join(path_parts[1:]) + (version_int, api_path) = _get_version_and_path(path_parts) # Find our method in the various versioned modules # Note: the mypy type checker has difficulties with the endpoints dict, so we ignore type checking below endpoints = _API_VERSIONS[version_int - 1] # index 0 == version 1 @@ -67,12 +66,19 @@ def api_call(path): return _json_resp(result, 200) -def _get_version(version_str): - """From a list of path parts, initialize and validate a version int for the api.""" +def _get_version_and_path(path_parts): + """ + From a list of path parts, initialize and validate a version int for the api. + Returns pair of (version_int, path_str) + """ + version_str = path_parts[0] max_version = len(_API_VERSIONS) # Make sure the version looks like 'v12' if not re.match(r'^v\d+$', version_str): - raise InvalidParameters('Make a request with the format /api//') + # Fallback to v1 for paths like /api/ with no version option + # TODO temporary + return (1, '/'.join(path_parts)) + # raise InvalidParameters('Make a request with the format /api//') # Parse to an int version_int = int(version_str.replace('v', '')) # Make sure the version number is valid @@ -80,7 +86,8 @@ def _get_version(version_str): raise InvalidParameters('API version must be > 0') if version_int > max_version: raise InvalidParameters(f'Invalid api version; max is {max_version}') - return version_int + path_str = '/'.join(path_parts[1:]) + return (version_int, path_str) def _json_resp(result, status=200): diff --git a/api/src/test/test_api_v1.py b/api/src/test/test_api_v1.py index 8bf6478e..657bdd81 100644 --- a/api/src/test/test_api_v1.py +++ b/api/src/test/test_api_v1.py @@ -426,3 +426,18 @@ def test_queries_are_readonly(self): ).json() self.assertTrue(resp['error']) self.assertTrue('read only' in resp['arango_message']) + + def test_no_version_in_path(self): + """Test that leaving out api version in the path falls back to v1""" + # TODO XXX temporary + save_test_docs(1) + query = 'let ws_ids = @ws_ids for v in test_vertex sort rand() limit @count return v._id' + url = '/'.join([URL, 'api']) # Leaving off version + resp = requests.post( + url + '/query_results', + params={}, + headers=HEADERS_ADMIN, + data=json.dumps({'query': query, 'count': 1}) + ).json() + self.assertEqual(resp['count'], 1) + self.assertEqual(len(resp['results']), 1) From 74f16b8e97554488ac90ab7762f7d24af312120a Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 20 Mar 2019 10:26:43 -0700 Subject: [PATCH 282/732] Revert accidental change --- api/scripts/run_tests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/scripts/run_tests.sh b/api/scripts/run_tests.sh index 5212f273..4342b07f 100644 --- a/api/scripts/run_tests.sh +++ b/api/scripts/run_tests.sh @@ -2,7 +2,7 @@ set -e -flake8 src +flake8 --max-complexity 5 src mypy --ignore-missing-imports src python -m pyflakes src bandit -r src From e13594d3d6e3bdc4cad1cd15518dba9ffc081bc5 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 20 Mar 2019 15:11:00 -0700 Subject: [PATCH 283/732] Make sure cors headers are set for all requests; remove print statement --- api/src/relation_engine_server/server.py | 55 +++++++++---------- .../utils/arango_client.py | 1 - 2 files changed, 27 insertions(+), 29 deletions(-) diff --git a/api/src/relation_engine_server/server.py b/api/src/relation_engine_server/server.py index c04787b8..853f1afc 100644 --- a/api/src/relation_engine_server/server.py +++ b/api/src/relation_engine_server/server.py @@ -35,7 +35,7 @@ def root(): 'commit_hash': commit_hash, 'repo_url': repo_url } - return _json_resp(body) + return flask.jsonify(body) @app.route('/api/', methods=['GET', 'PUT', 'POST', 'DELETE']) @@ -55,7 +55,7 @@ def api_call(path): endpoints = _API_VERSIONS[version_int - 1] # index 0 == version 1 if api_path not in endpoints: body = {'error': f'Path not found: {api_path}.'} - return _json_resp(body, 404) + return (flask.jsonify(body), 404) methods = endpoints[api_path].get('methods', {'GET'}) # type: ignore # Mypy is not able to infer that `methods` will always be a set if flask.request.method not in methods: # type: ignore @@ -63,7 +63,7 @@ def api_call(path): # We found a matching function for the endpoint and method # Mypy is not able to infer that this is a function result = endpoints[api_path]['handler']() # type: ignore - return _json_resp(result, 200) + return (flask.jsonify(result), 200) def _get_version_and_path(path_parts): @@ -90,21 +90,6 @@ def _get_version_and_path(path_parts): return (version_int, path_str) -def _json_resp(result, status=200): - """Send a json response back to the requester with the proper headers.""" - resp = flask.Response(json.dumps(result)) - resp.status_code = status - print(' '.join([flask.request.method, flask.request.path, '->', resp.status])) - # Enable CORS - resp.headers['Access-Control-Allow-Origin'] = '*' - env_allowed_headers = os.environ.get('HTTP_ACCESS_CONTROL_REQUEST_HEADERS', 'authorization') - resp.headers['Access-Control-Allow-Headers'] = env_allowed_headers - # Set JSON content type and response length - resp.headers['Content-Type'] = 'application/json' - resp.headers['Content-Length'] = resp.calculate_content_length() - return resp - - @app.errorhandler(json.decoder.JSONDecodeError) def json_decode_error(err): """A problem parsing json.""" @@ -115,7 +100,7 @@ def json_decode_error(err): 'lineno': err.lineno, 'colno': err.colno } - return _json_resp(resp, 400) + return (flask.jsonify(resp), 400) @app.errorhandler(arango_client.ArangoServerError) @@ -124,14 +109,14 @@ def arango_server_error(err): 'error': str(err), 'arango_message': err.resp_json['errorMessage'] } - return _json_resp(resp, 400) + return (flask.jsonify(resp), 400) @app.errorhandler(InvalidParameters) def invalid_params(err): """Invalid request body json params.""" resp = {'error': str(err)} - return _json_resp(resp, 400) + return (flask.jsonify(resp), 400) @app.errorhandler(spec_loader.SchemaNonexistent) @@ -139,7 +124,7 @@ def invalid_params(err): def view_does_not_exist(err): """General error cases.""" resp = {'error': str(err), 'name': err.name} - return _json_resp(resp, 400) + return (flask.jsonify(resp), 400) @app.errorhandler(ValidationError) @@ -152,7 +137,7 @@ def validation_error(err): 'validator_value': err.validator_value, 'schema': err.schema } - return _json_resp(resp, 400) + return (flask.jsonify(resp), 400) @app.errorhandler(UnauthorizedAccess) @@ -162,22 +147,22 @@ def unauthorized_access(err): 'auth_url': err.auth_url, 'auth_response': err.response } - return _json_resp(resp, 403) + return (flask.jsonify(resp), 403) @app.errorhandler(404) def page_not_found(err): - return _json_resp({'error': '404 - Not found.'}, 404) + return (flask.jsonify({'error': '404 - Not found.'}), 404) @app.errorhandler(405) def method_not_allowed(err): - return _json_resp({'error': '405 - Method not allowed.'}, 405) + return (flask.jsonify({'error': '405 - Method not allowed.'}), 405) @app.errorhandler(MissingHeader) def generic_400(err): - return _json_resp({'error': str(err)}, 400) + return (flask.jsonify({'error': str(err)}), 400) # Any other unhandled exceptions -> 500 @@ -192,4 +177,18 @@ def server_error(err): resp = {'error': '500 - Unexpected server error'} resp['error_class'] = err.__class__.__name__ resp['error_details'] = str(err) - return _json_resp(resp, 500) + return (flask.jsonify(resp), 500) + + +@app.after_request +def after_request(resp): + # Log request + print(' '.join([flask.request.method, flask.request.path, '->', resp.status])) + # Enable CORS + resp.headers['Access-Control-Allow-Origin'] = '*' + env_allowed_headers = os.environ.get('HTTP_ACCESS_CONTROL_REQUEST_HEADERS', 'Authorization, Content-Type') + resp.headers['Access-Control-Allow-Headers'] = env_allowed_headers + # Set JSON content type and response length + resp.headers['Content-Type'] = 'application/json' + resp.headers['Content-Length'] = resp.calculate_content_length() + return resp diff --git a/api/src/relation_engine_server/utils/arango_client.py b/api/src/relation_engine_server/utils/arango_client.py index bfd69e23..8767aa2f 100644 --- a/api/src/relation_engine_server/utils/arango_client.py +++ b/api/src/relation_engine_server/utils/arango_client.py @@ -92,7 +92,6 @@ def create_collection(name, is_edge): 'type': collection_type, 'numberOfShards': num_shards }) - print('authh', config) resp = requests.post(url, data, auth=(config['db_user'], config['db_pass'])) resp_json = resp.json() if not resp.ok: From 07ff0b2cf56fdf9596a38e846bc045f76cea7646 Mon Sep 17 00:00:00 2001 From: JamesJeffryes Date: Thu, 21 Mar 2019 11:28:08 -0500 Subject: [PATCH 284/732] Add full_count option for pagination --- api/src/relation_engine_server/utils/arango_client.py | 3 ++- api/src/test/test_api_v1.py | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/api/src/relation_engine_server/utils/arango_client.py b/api/src/relation_engine_server/utils/arango_client.py index 8767aa2f..736552eb 100644 --- a/api/src/relation_engine_server/utils/arango_client.py +++ b/api/src/relation_engine_server/utils/arango_client.py @@ -29,7 +29,8 @@ def run_query(query_text=None, cursor_id=None, bind_vars=None, batch_size=100): url = config['db_url'] + '/_api/cursor' req_json = { 'batchSize': min(5000, batch_size), - 'memoryLimit': 16000000000 # 16gb + 'memoryLimit': 16000000000, # 16gb + 'options': {'fullCount': True} } if cursor_id: method = 'PUT' diff --git a/api/src/test/test_api_v1.py b/api/src/test/test_api_v1.py index 657bdd81..4c93482f 100644 --- a/api/src/test/test_api_v1.py +++ b/api/src/test/test_api_v1.py @@ -289,6 +289,7 @@ def test_query_with_cursor(self): self.assertTrue(resp['cursor_id']) self.assertEqual(resp['has_more'], True) self.assertEqual(resp['count'], 20) + self.assertEqual(resp['stats']['fullCount'], 20) self.assertTrue(len(resp['results']), 10) cursor_id = resp['cursor_id'] resp = requests.post( @@ -296,6 +297,7 @@ def test_query_with_cursor(self): params={'cursor_id': cursor_id} ).json() self.assertEqual(resp['count'], 20) + self.assertEqual(resp['stats']['fullCount'], 20) self.assertEqual(resp['has_more'], False) self.assertEqual(resp['cursor_id'], None) self.assertTrue(len(resp['results']), 10) From 64d47340f2f933e8ab773755297db21231833686 Mon Sep 17 00:00:00 2001 From: JamesJeffryes Date: Thu, 21 Mar 2019 11:43:08 -0500 Subject: [PATCH 285/732] make full_count optional --- api/.github/pull_request_template.md | 3 ++- api/README.md | 1 + api/src/relation_engine_server/api_modules/api_v1.py | 7 +++++-- api/src/relation_engine_server/utils/arango_client.py | 11 +++++------ api/src/test/test_api_v1.py | 2 +- 5 files changed, 14 insertions(+), 10 deletions(-) diff --git a/api/.github/pull_request_template.md b/api/.github/pull_request_template.md index 989b68a6..bd4ec908 100644 --- a/api/.github/pull_request_template.md +++ b/api/.github/pull_request_template.md @@ -1,3 +1,4 @@ - [ ] I updated the README.md docs to reflect this change. -- [ ] This is either not a breaking API change, or I incremented the API version. +- [ ] This is not a breaking API change OR +- [ ] This is a breaking API change and I have incremented the API version. diff --git a/api/README.md b/api/README.md index dadbbff2..abb748ce 100644 --- a/api/README.md +++ b/api/README.md @@ -122,6 +122,7 @@ curl -X POST -d '{"argument": "value"}' {root_url}/api/v1/query_results?view=exa _Query params_ * `view` - required - string - name of the view to run as a query against the database * `cursor_id` - required - string - ID of a cursor that was returned from a previous query with >100 results +* `full_count` - optional - bool - If true, return a count of the total documents before any LIMIT is applied (for example, in pagination). This might make some queries run more slowly Pass one of `view` or `cursor_id` -- not both. diff --git a/api/src/relation_engine_server/api_modules/api_v1.py b/api/src/relation_engine_server/api_modules/api_v1.py index e4c07be8..db55daae 100644 --- a/api/src/relation_engine_server/api_modules/api_v1.py +++ b/api/src/relation_engine_server/api_modules/api_v1.py @@ -34,6 +34,7 @@ def run_query(): json_body['ws_ids'] = auth.get_workspace_ids(auth_token) # fetch number of documents to return batch_size = int(flask.request.args.get('batch_size', 100)) + 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']) @@ -41,7 +42,8 @@ def run_query(): del json_body['query'] resp_body = arango_client.run_query(query_text=query_text, bind_vars=json_body, - batch_size=batch_size) + batch_size=batch_size, + full_count=full_count) return resp_body if 'view' in flask.request.args: # Run a query from a view name @@ -49,7 +51,8 @@ def run_query(): view_source = spec_loader.get_view(view_name) resp_body = arango_client.run_query(query_text=view_source, bind_vars=json_body, - batch_size=batch_size) + batch_size=batch_size, + full_count=full_count) return resp_body if 'cursor_id' in flask.request.args: # Run a query from a cursor ID diff --git a/api/src/relation_engine_server/utils/arango_client.py b/api/src/relation_engine_server/utils/arango_client.py index 736552eb..3361a210 100644 --- a/api/src/relation_engine_server/utils/arango_client.py +++ b/api/src/relation_engine_server/utils/arango_client.py @@ -23,14 +23,13 @@ def server_status(): return 'unknown_failure' -def run_query(query_text=None, cursor_id=None, bind_vars=None, batch_size=100): +def run_query(query_text=None, cursor_id=None, bind_vars=None, batch_size=100, full_count=False): """Run a query using the arangodb http api. Can return a cursor to get more results.""" config = get_config() url = config['db_url'] + '/_api/cursor' req_json = { 'batchSize': min(5000, batch_size), 'memoryLimit': 16000000000, # 16gb - 'options': {'fullCount': True} } if cursor_id: method = 'PUT' @@ -39,6 +38,8 @@ def run_query(query_text=None, cursor_id=None, bind_vars=None, batch_size=100): method = 'POST' req_json['count'] = True req_json['query'] = query_text + if full_count: + req_json['options'] = {'fullCount': True} if bind_vars: req_json['bindVars'] = bind_vars # Initialize the readonly user @@ -50,10 +51,8 @@ def run_query(query_text=None, cursor_id=None, bind_vars=None, batch_size=100): data=json.dumps(req_json), auth=(config['db_readonly_user'], config['db_readonly_pass']) ) - if not resp.ok: - raise ArangoServerError(resp.text) resp_json = resp.json() - if resp_json['error']: + if not resp.ok or resp_json['error']: raise ArangoServerError(resp.text) return { 'results': resp_json['result'], @@ -155,7 +154,7 @@ def _init_readonly_user(): data='{"grant": "ro"}', auth=(config['db_user'], config['db_pass']) ) - if resp.status_code != 200: + if not resp.ok: raise ArangoServerError(resp.text) diff --git a/api/src/test/test_api_v1.py b/api/src/test/test_api_v1.py index 4c93482f..46979730 100644 --- a/api/src/test/test_api_v1.py +++ b/api/src/test/test_api_v1.py @@ -284,7 +284,7 @@ def test_query_with_cursor(self): save_test_docs(count=20) resp = requests.post( API_URL + '/query_results', - params={'view': 'list_test_vertices', 'batch_size': 10} + params={'view': 'list_test_vertices', 'batch_size': 10, 'full_count': True} ).json() self.assertTrue(resp['cursor_id']) self.assertEqual(resp['has_more'], True) From b6d3291a97ac6f759da6d764d0e9e741e95a8428 Mon Sep 17 00:00:00 2001 From: JamesJeffryes Date: Thu, 21 Mar 2019 12:00:01 -0500 Subject: [PATCH 286/732] update biochemistry search documents --- spec/views/search_compounds.aql | 12 +++++++----- spec/views/search_reactions.aql | 13 ++++++++----- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/spec/views/search_compounds.aql b/spec/views/search_compounds.aql index 4cffed01..bd45576c 100644 --- a/spec/views/search_compounds.aql +++ b/spec/views/search_compounds.aql @@ -1,12 +1,14 @@ -\\ Use ArangoSearch to search documents in the compounds index. Returns documents by ascending id. -\\ include_obsolete - should obsolete documents be included -\\ offset - how many documents to skip -\\ result_limit - Maximum documents to return +// Use ArangoSearch to search documents in the compounds index. Returns documents by ascending id. +// search_text - text to match to document fields +// all_documents - ignore the search_text and return all documents +// include_obsolete - should obsolete documents be included +// offset - how many documents to skip +// result_limit - Maximum documents to return FOR doc IN Compounds SEARCH ANALYZER(PHRASE(doc.id, @search_text) OR PHRASE(doc.name, @search_text) OR PHRASE(doc.abbreviation, @search_text) - OR PHRASE(doc.aliases, @search_text), 'text_en') + OR PHRASE(doc.aliases, @search_text), 'text_en') OR @all_documents FILTER @include_obsolete || doc.is_obsolete == 0 SORT doc.id LIMIT @offset, @result_limit diff --git a/spec/views/search_reactions.aql b/spec/views/search_reactions.aql index 024d44f2..b38c35d2 100644 --- a/spec/views/search_reactions.aql +++ b/spec/views/search_reactions.aql @@ -1,11 +1,14 @@ -\\ Use ArangoSearch to search documents in the Reactions index. Returns documents by ascending id. -\\ include_obsolete - should obsolete documents be included -\\ offset - how many documents to skip -\\ result_limit - Maximum documents to return +// Use ArangoSearch to search documents in the Reactions index. Returns documents by ascending id. +// search_text - text to match to document fields +// all_documents - ignore the search_text and return all documents +// include_obsolete - should obsolete documents be included +// offset - how many documents to skip +// result_limit - Maximum documents to return FOR doc IN Reactions SEARCH ANALYZER(PHRASE(doc.id, @search_text) OR PHRASE(doc.name, @search_text) - OR PHRASE(doc.aliases, @search_text), 'text_en') + OR PHRASE(doc.abbreviation, @search_text) + OR PHRASE(doc.aliases, @search_text), 'text_en') OR @all_documents FILTER @include_obsolete || doc.is_obsolete == 0 SORT doc.id LIMIT @offset, @result_limit From e2300498e649c4bf6d5f83bfc0e2e40c541f18ae Mon Sep 17 00:00:00 2001 From: JamesJeffryes Date: Thu, 21 Mar 2019 14:33:10 -0500 Subject: [PATCH 287/732] update biochemistry search documents --- spec/views/search_compounds.aql | 1 + spec/views/search_reactions.aql | 1 + 2 files changed, 2 insertions(+) diff --git a/spec/views/search_compounds.aql b/spec/views/search_compounds.aql index bd45576c..2e937a94 100644 --- a/spec/views/search_compounds.aql +++ b/spec/views/search_compounds.aql @@ -4,6 +4,7 @@ // include_obsolete - should obsolete documents be included // offset - how many documents to skip // result_limit - Maximum documents to return +LET ws_ids = @ws_ids FOR doc IN Compounds SEARCH ANALYZER(PHRASE(doc.id, @search_text) OR PHRASE(doc.name, @search_text) diff --git a/spec/views/search_reactions.aql b/spec/views/search_reactions.aql index b38c35d2..ebb226b4 100644 --- a/spec/views/search_reactions.aql +++ b/spec/views/search_reactions.aql @@ -4,6 +4,7 @@ // include_obsolete - should obsolete documents be included // offset - how many documents to skip // result_limit - Maximum documents to return +LET ws_ids = @ws_ids FOR doc IN Reactions SEARCH ANALYZER(PHRASE(doc.id, @search_text) OR PHRASE(doc.name, @search_text) From 91b06826b9bde128e61d6a2957d0f17ee9e9bdb3 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Thu, 21 Mar 2019 13:43:36 -0700 Subject: [PATCH 288/732] Dockerize and philosophize --- api/Dockerfile | 23 +++++++++++++++++++++-- api/dev-requirements.txt | 1 - api/scripts/run_tests.sh | 3 +-- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/api/Dockerfile b/api/Dockerfile index 0e2d4c54..5c8a6543 100644 --- a/api/Dockerfile +++ b/api/Dockerfile @@ -1,10 +1,22 @@ FROM python:3.7-alpine ARG DEVELOPMENT +ARG BUILD_DATE +ARG VCS_REF +ARG BRANCH=develop COPY requirements.txt dev-requirements.txt /tmp/ WORKDIR /app +# Install dockerize +ENV DOCKERIZE_VERSION v0.6.1 +RUN apk --update add --virtual build-dependencies curl tar gzip && \ + curl -o dockerize.tar.gz \ + https://raw.githubusercontent.com/kbase/dockerize/master/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz && \ + tar -C /usr/local/bin -xvzf dockerize.tar.gz && \ + rm dockerize.tar.gz && \ + apk del build-dependencies + # Install dependencies RUN apk --update add --virtual build-dependencies python-dev build-base && \ pip install --upgrade pip && \ @@ -12,7 +24,14 @@ RUN apk --update add --virtual build-dependencies python-dev build-base && \ if [ "$DEVELOPMENT" ]; then pip install --no-cache-dir -r /tmp/dev-requirements.txt; fi && \ apk del build-dependencies -# Run the app COPY . /app -CMD ["sh", "scripts/start_server.sh"] +LABEL org.label-schema.build-date=$BUILD_DATE \ + org.label-schema.vcs-url="https://github.com/kbase/relation_engine_api" \ + org.label-schema.vcs-ref=$VCS_REF \ + org.label-schema.schema-version="1.0.0-rc1" \ + us.kbase.vcs-branch=$BRANCH \ + maintainer="KBase Team" + +ENTRYPOINT ["/usr/local/bin/dockerize"] +CMD ["sh", "-x", "scripts/start_server.sh"] diff --git a/api/dev-requirements.txt b/api/dev-requirements.txt index 906dda96..ab184106 100644 --- a/api/dev-requirements.txt +++ b/api/dev-requirements.txt @@ -1,7 +1,6 @@ mypy==0.630 bandit==1.5.1 mccabe==0.6.1 -pyflakes==2.0.0 flake8==3.5.0 grequests==0.3.0 coverage==4.5.1 diff --git a/api/scripts/run_tests.sh b/api/scripts/run_tests.sh index 4342b07f..70f1ffbf 100644 --- a/api/scripts/run_tests.sh +++ b/api/scripts/run_tests.sh @@ -2,8 +2,7 @@ set -e -flake8 --max-complexity 5 src +flake8 --max-complexity 10 src mypy --ignore-missing-imports src -python -m pyflakes src bandit -r src python -m unittest discover src/test/ From d88bf41bf2438d9a5123fd84ecc5c1cd50a79549 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Fri, 29 Mar 2019 10:42:17 -0700 Subject: [PATCH 289/732] Actually use the db name --- api/Makefile | 8 +++++++- .../relation_engine_server/utils/arango_client.py | 12 ++++++------ api/src/relation_engine_server/utils/config.py | 2 ++ 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/api/Makefile b/api/Makefile index c7dd3651..04fabc4b 100644 --- a/api/Makefile +++ b/api/Makefile @@ -1,4 +1,10 @@ -.PHONY: test +.PHONY: test reset test: docker-compose run web sh scripts/run_tests.sh + +reset: + docker-compose down + docker-compose rm -vf + docker-compose build --no-cache + docker-compose up diff --git a/api/src/relation_engine_server/utils/arango_client.py b/api/src/relation_engine_server/utils/arango_client.py index 3361a210..3943591e 100644 --- a/api/src/relation_engine_server/utils/arango_client.py +++ b/api/src/relation_engine_server/utils/arango_client.py @@ -26,7 +26,7 @@ def server_status(): def run_query(query_text=None, cursor_id=None, bind_vars=None, batch_size=100, full_count=False): """Run a query using the arangodb http api. Can return a cursor to get more results.""" config = get_config() - url = config['db_url'] + '/_api/cursor' + url = config['api_url'] + '/cursor' req_json = { 'batchSize': min(5000, batch_size), 'memoryLimit': 16000000000, # 16gb @@ -81,7 +81,7 @@ def create_collection(name, is_edge): """ num_shards = os.environ.get('SHARD_COUNT', 30) config = get_config() - url = config['db_url'] + '/_api/collection' + url = config['api_url'] + '/collection' # collection types: # 2 is a document collection # 3 is an edge collection @@ -105,7 +105,7 @@ def import_from_file(file_path, query): config = get_config() with open(file_path, 'rb') as file_desc: resp = requests.post( - config['db_url'] + '/_api/import', + config['api_url'] + '/import', data=file_desc, auth=(config['db_user'], config['db_pass']), params=query @@ -126,20 +126,20 @@ def _init_readonly_user(): user = config['db_readonly_user'] # Check if the user exists, in which case this is a no-op resp = requests.get( - config['db_url'] + '/_api/user/' + user, + config['api_url'] + '/user/' + user, auth=(config['db_user'], config['db_pass']) ) if resp.status_code == 200: return # Create the user resp = requests.post( - config['db_url'] + '/_api/user', + config['api_url'] + '/user', data=json.dumps({'user': user, 'passwd': config['db_readonly_user']}), auth=(config['db_user'], config['db_pass']) ) if resp.status_code != 201: raise ArangoServerError(resp.text) - db_grant_path = config['db_url'] + '/_api/user/' + user + '/database/' + config['db_name'] + db_grant_path = config['api_url'] + '/user/' + user + '/database/' + config['db_name'] # Grant read access to the current database resp = requests.put( db_grant_path, diff --git a/api/src/relation_engine_server/utils/config.py b/api/src/relation_engine_server/utils/config.py index c9daeac0..1e288b15 100644 --- a/api/src/relation_engine_server/utils/config.py +++ b/api/src/relation_engine_server/utils/config.py @@ -18,6 +18,7 @@ def get_config(): db_name = os.environ.get('DB_NAME', '_system') db_user = os.environ.get('DB_USER', 'root') db_pass = os.environ.get('DB_PASS', '') + api_url = db_url + '/_db/' + db_name + '/_api' db_readonly_user = os.environ.get('DB_READONLY_USER', 'readonly') db_readonly_pass = os.environ.get('DB_READONLY_PASS', 'readonly') return { @@ -25,6 +26,7 @@ def get_config(): 'workspace_url': workspace_url, 'kbase_endpoint': kbase_endpoint, 'db_url': db_url, + 'api_url': api_url, 'db_name': db_name, 'db_user': db_user, 'db_pass': db_pass, From 9c9dca27bbaa6d290f79900fca376cbec680411d Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 23 Apr 2019 16:24:34 -0700 Subject: [PATCH 290/732] Update CODEOWNERS --- api/CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/CODEOWNERS b/api/CODEOWNERS index 9703c9e0..d65e940f 100644 --- a/api/CODEOWNERS +++ b/api/CODEOWNERS @@ -1 +1 @@ -* @jayrbolton @JamesJeffryes +* @jayrbolton @slebras From 13578fe071f4dc43bfbcba573e323f874fba5faa Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 23 Apr 2019 16:25:49 -0700 Subject: [PATCH 291/732] Update CODEOWNERS --- spec/CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/CODEOWNERS b/spec/CODEOWNERS index 9703c9e0..788e5f5d 100644 --- a/spec/CODEOWNERS +++ b/spec/CODEOWNERS @@ -1 +1 @@ -* @jayrbolton @JamesJeffryes +* @jayrbolton From 87040cca287cafb448ed68d2123de02b14c74170 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 24 Apr 2019 10:35:47 -0700 Subject: [PATCH 292/732] Add gtdb schemas --- spec/schemas/edges/gtdb/README.md | 7 ++++++ .../edges/gtdb/gtdb_child_of_taxon.json | 17 ++++++++++++++ spec/schemas/vertices/gtdb/README.md | 7 ++++++ spec/schemas/vertices/gtdb/gtdb_organism.json | 13 +++++++++++ spec/schemas/vertices/gtdb/gtdb_taxon.json | 23 +++++++++++++++++++ 5 files changed, 67 insertions(+) create mode 100644 spec/schemas/edges/gtdb/README.md create mode 100644 spec/schemas/edges/gtdb/gtdb_child_of_taxon.json create mode 100644 spec/schemas/vertices/gtdb/README.md create mode 100644 spec/schemas/vertices/gtdb/gtdb_organism.json create mode 100644 spec/schemas/vertices/gtdb/gtdb_taxon.json diff --git a/spec/schemas/edges/gtdb/README.md b/spec/schemas/edges/gtdb/README.md new file mode 100644 index 00000000..05d97d6c --- /dev/null +++ b/spec/schemas/edges/gtdb/README.md @@ -0,0 +1,7 @@ +# Genome Taxonomy Database + +KBase Relation Engine schemas for GTDB taxonomy data + +References: + +* http://gtdb.ecogenomic.org/ diff --git a/spec/schemas/edges/gtdb/gtdb_child_of_taxon.json b/spec/schemas/edges/gtdb/gtdb_child_of_taxon.json new file mode 100644 index 00000000..26ed8fb3 --- /dev/null +++ b/spec/schemas/edges/gtdb/gtdb_child_of_taxon.json @@ -0,0 +1,17 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "required": ["_from", "_to"], + "description": "A gtdb_taxon or gtdb_organism is a child of a parent gtdb_taxon in the taxonomy tree.", + "properties": { + "_from": { + "type": "string", + "description": "The child. A gtdb_taxon or gtdb_organism." + }, + "_to": { + "type": "string", + "description": "The parent gtdb_taxon." + } + } +} + diff --git a/spec/schemas/vertices/gtdb/README.md b/spec/schemas/vertices/gtdb/README.md new file mode 100644 index 00000000..05d97d6c --- /dev/null +++ b/spec/schemas/vertices/gtdb/README.md @@ -0,0 +1,7 @@ +# Genome Taxonomy Database + +KBase Relation Engine schemas for GTDB taxonomy data + +References: + +* http://gtdb.ecogenomic.org/ diff --git a/spec/schemas/vertices/gtdb/gtdb_organism.json b/spec/schemas/vertices/gtdb/gtdb_organism.json new file mode 100644 index 00000000..01881fb8 --- /dev/null +++ b/spec/schemas/vertices/gtdb/gtdb_organism.json @@ -0,0 +1,13 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "description": "An organism in the GTDB taxonomy tree.", + "required": ["_key"], + "properties": { + "_key": { + "type": "string", + "description": "Accession ID (Refseq prefixed with 'RS_' and Genbank prefixed with 'GB_').", + "examples": ["RS_GCF_001300075.1", "GB_GCA_002387705.1"] + } + } +} diff --git a/spec/schemas/vertices/gtdb/gtdb_taxon.json b/spec/schemas/vertices/gtdb/gtdb_taxon.json new file mode 100644 index 00000000..84a491c9 --- /dev/null +++ b/spec/schemas/vertices/gtdb/gtdb_taxon.json @@ -0,0 +1,23 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "description": "A entry in the GTDB taxonomy tree.", + "required": ["_key", "type", "name"], + "properties": { + "_key": { + "type": "string", + "description": "Taxon type abbreviation plus name", + "examples": ["d:Bacteria", "p:Firmicutes"] + }, + "name": { + "type": "string", + "title": "Taxon name.", + "examples": ["Bacteria", "Firmicutes"] + }, + "type": { + "type": "string", + "title": "Taxon type.", + "examples": ["Domain", "Phylum"] + } + } +} From aed2533638963e8a739da0e564d36e4ff61f52af Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Mon, 1 Jul 2019 09:59:39 -0700 Subject: [PATCH 293/732] Fix the readme --- spec/schemas/vertices/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/schemas/vertices/README.md b/spec/schemas/vertices/README.md index 8fb3c592..0bc58d97 100644 --- a/spec/schemas/vertices/README.md +++ b/spec/schemas/vertices/README.md @@ -1 +1 @@ -# Reaction homology vertices +# Relation engine vertices From 841cc8d3b13fdff99df0c02b0e58959ad3f06184 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Mon, 1 Jul 2019 12:07:41 -0700 Subject: [PATCH 294/732] Fix and improve tests --- spec/.travis.yml | 2 - spec/Makefile | 3 +- spec/docker-compose.yaml | 33 ++++--- spec/test/mock_services/mock_auth/admin.json | 26 +++++ .../mock_services/mock_auth/endpoints.json | 96 ------------------- .../test/mock_services/mock_auth/invalid.json | 23 +++++ .../mock_services/mock_auth/invalid2.json | 20 ++++ spec/test/mock_services/mock_auth/valid.json | 24 +++++ .../mock_workspace/endpoints.json | 64 ------------- .../list_workspace_ids_admin.json | 17 ++++ .../list_workspace_ids_invalid1.json | 22 +++++ .../list_workspace_ids_valid.json | 22 +++++ spec/test/views/test_list_test_vertices.py | 19 ++++ 13 files changed, 193 insertions(+), 178 deletions(-) create mode 100644 spec/test/mock_services/mock_auth/admin.json delete mode 100644 spec/test/mock_services/mock_auth/endpoints.json create mode 100644 spec/test/mock_services/mock_auth/invalid.json create mode 100644 spec/test/mock_services/mock_auth/invalid2.json create mode 100644 spec/test/mock_services/mock_auth/valid.json delete mode 100644 spec/test/mock_services/mock_workspace/endpoints.json create mode 100644 spec/test/mock_services/mock_workspace/list_workspace_ids_admin.json create mode 100644 spec/test/mock_services/mock_workspace/list_workspace_ids_invalid1.json create mode 100644 spec/test/mock_services/mock_workspace/list_workspace_ids_valid.json diff --git a/spec/.travis.yml b/spec/.travis.yml index 294b31f9..c7b6fcfe 100644 --- a/spec/.travis.yml +++ b/spec/.travis.yml @@ -4,6 +4,4 @@ python: before_script: - pip install jsonschema script: -- docker-compose up --build -d -- sleep 15 - make test diff --git a/spec/Makefile b/spec/Makefile index dd7457a8..754353f0 100644 --- a/spec/Makefile +++ b/spec/Makefile @@ -3,5 +3,4 @@ test: python test/validate.py echo "Running view tests" - docker-compose run spec python /app/test/views/init_spec.py - docker-compose run spec python -m unittest discover /app/test/views + docker-compose run spec sh -c "python /app/test/views/init_spec.py && python -m unittest discover /app/test/views" diff --git a/spec/docker-compose.yaml b/spec/docker-compose.yaml index a67bf7bb..9da52a5c 100644 --- a/spec/docker-compose.yaml +++ b/spec/docker-compose.yaml @@ -4,22 +4,25 @@ version: '3' services: - # ArangoDB - arangodb: - image: arangodb:3.4 - ports: - - 8529:8529 - environment: - - ARANGO_ROOT_PASSWORD=password + # General python container for executing tests + spec: + build: . + volumes: + - ${PWD}:/app + depends_on: + - re_api # Relation Engine API re_api: image: kbase/relation_engine_api:latest ports: - 5000:5000 + depends_on: + - arangodb + - auth + - workspace environment: - ARANGO_ROOT_PASSWORD=password - environment: - DEVELOPMENT=1 - FLASK_ENV=development - FLASK_DEBUG=1 @@ -31,6 +34,14 @@ services: - DB_USER=root - DB_PASS=password + # ArangoDB + arangodb: + image: arangodb:3.4 + ports: + - 8529:8529 + environment: + - ARANGO_ROOT_PASSWORD=password + # A mock kbase auth server (see src/test/mock_auth/endpoints.json) auth: image: mockservices/mock_json_service @@ -42,9 +53,3 @@ services: image: mockservices/mock_json_service volumes: - ${PWD}/test/mock_services/mock_workspace:/config - - # General python container for executing tests - spec: - build: . - volumes: - - ${PWD}:/app diff --git a/spec/test/mock_services/mock_auth/admin.json b/spec/test/mock_services/mock_auth/admin.json new file mode 100644 index 00000000..631e5bea --- /dev/null +++ b/spec/test/mock_services/mock_auth/admin.json @@ -0,0 +1,26 @@ +{ + "methods": [ + "GET" + ], + "path": "/api/V2/me", + "headers": { + "Authorization": "admin_token" + }, + "response": { + "status": "200", + "body": { + "created": 1528306100471, + "lastlogin": 1542068355002, + "display": "Test User", + "roles": [], + "customroles": [ + "RE_ADMIN" + ], + "policyids": [], + "user": "username", + "local": false, + "email": "user@example.com", + "idents": [] + } + } +} diff --git a/spec/test/mock_services/mock_auth/endpoints.json b/spec/test/mock_services/mock_auth/endpoints.json deleted file mode 100644 index b3c1f772..00000000 --- a/spec/test/mock_services/mock_auth/endpoints.json +++ /dev/null @@ -1,96 +0,0 @@ -[ - { - "methods": [ - "GET" - ], - "path": "/api/V2/me", - "headers": { - "Authorization": "non_admin_token" - }, - "response": { - "status": "200", - "body": { - "created": 1528306100471, - "lastlogin": 1542068355002, - "display": "Test User", - "roles": [], - "customroles": [], - "policyids": [], - "user": "username", - "local": false, - "email": "user@example.com", - "idents": [] - } - } - }, - { - "methods": [ - "GET" - ], - "path": "/api/V2/me", - "headers": { - "Authorization": "admin_token" - }, - "response": { - "status": "200", - "body": { - "created": 1528306100471, - "lastlogin": 1542068355002, - "display": "Test User", - "roles": [], - "customroles": [ - "RE_ADMIN" - ], - "policyids": [], - "user": "username", - "local": false, - "email": "user@example.com", - "idents": [] - } - } - }, - { - "methods": [ - "GET" - ], - "path": "/api/V2/me", - "headers": { - "Authorization": "invalid_token" - }, - "response": { - "status": "401", - "body": { - "error": { - "httpcode": 401, - "httpstatus": "Unauthorized", - "appcode": 10020, - "apperror": "Invalid token", - "message": "10020 Invalid token", - "callid": "1757210147564211", - "time": 1542737889450 - } - } - } - }, - { - "methods": [ - "GET" - ], - "path": "/api/V2/me", - "response": { - "status": "400", - "body": { - "error": { - "httpcode": 400, - "httpstatus": "Bad Request", - "appcode": 10010, - "apperror": "No authentication token", - "message": "10010 No authentication token: No user token provided", - "callid": "7334881776774415", - "time": 1542737656377 - } - } - } - } -] - diff --git a/spec/test/mock_services/mock_auth/invalid.json b/spec/test/mock_services/mock_auth/invalid.json new file mode 100644 index 00000000..e74e7269 --- /dev/null +++ b/spec/test/mock_services/mock_auth/invalid.json @@ -0,0 +1,23 @@ +{ + "methods": [ + "GET" + ], + "path": "/api/V2/me", + "headers": { + "Authorization": "invalid_token" + }, + "response": { + "status": "401", + "body": { + "error": { + "httpcode": 401, + "httpstatus": "Unauthorized", + "appcode": 10020, + "apperror": "Invalid token", + "message": "10020 Invalid token", + "callid": "1757210147564211", + "time": 1542737889450 + } + } + } +} diff --git a/spec/test/mock_services/mock_auth/invalid2.json b/spec/test/mock_services/mock_auth/invalid2.json new file mode 100644 index 00000000..d588d613 --- /dev/null +++ b/spec/test/mock_services/mock_auth/invalid2.json @@ -0,0 +1,20 @@ +{ + "methods": [ + "GET" + ], + "path": "/api/V2/me", + "response": { + "status": "400", + "body": { + "error": { + "httpcode": 400, + "httpstatus": "Bad Request", + "appcode": 10010, + "apperror": "No authentication token", + "message": "10010 No authentication token: No user token provided", + "callid": "7334881776774415", + "time": 1542737656377 + } + } + } +} diff --git a/spec/test/mock_services/mock_auth/valid.json b/spec/test/mock_services/mock_auth/valid.json new file mode 100644 index 00000000..9236f450 --- /dev/null +++ b/spec/test/mock_services/mock_auth/valid.json @@ -0,0 +1,24 @@ +{ + "methods": [ + "GET" + ], + "path": "/api/V2/me", + "headers": { + "Authorization": "non_admin_token" + }, + "response": { + "status": "200", + "body": { + "created": 1528306100471, + "lastlogin": 1542068355002, + "display": "Test User", + "roles": [], + "customroles": [], + "policyids": [], + "user": "username", + "local": false, + "email": "user@example.com", + "idents": [] + } + } +} diff --git a/spec/test/mock_services/mock_workspace/endpoints.json b/spec/test/mock_services/mock_workspace/endpoints.json deleted file mode 100644 index fae8bfae..00000000 --- a/spec/test/mock_services/mock_workspace/endpoints.json +++ /dev/null @@ -1,64 +0,0 @@ -[ - { - "methods": ["POST"], - "path": "/", - "headers": {"Authorization": "valid_token"}, - "body": { - "method": "Workspace.list_workspace_ids", - "version": "1.1", - "params": [{"perm": "r"}] - }, - "response": { - "status": "200", - "body": { - "version": "1.1", - "result": [ - { - "workspaces": [1, 2, 3], - "pub": [] - } - ] - } - } - }, - { - "methods": ["POST"], - "path": "/", - "headers": {"Authorization": "invalid_token"}, - "body": { - "method": "Workspace.list_workspace_ids", - "version": "1.1", - "params": [{"perm": "r"}] - }, - "response": { - "status": "500", - "body": { - "version": "1.1", - "error": { - "name": "JSONRPCError", - "code": -32400, - "message": "Token validation failed!", - "error": "..." - } - } - } - }, - { - "methods": ["POST"], - "path": "/", - "headers": {"Authorization": "admin_token"}, - "body": { - "method": "Workspace.list_workspace_ids", - "version": "1.1", - "params": [{"perm": "r"}] - }, - "response": { - "status": "200", - "body": { - "version": "1.1", - "result": [{"workspaces": [99], "pub": []}] - } - } - } -] - diff --git a/spec/test/mock_services/mock_workspace/list_workspace_ids_admin.json b/spec/test/mock_services/mock_workspace/list_workspace_ids_admin.json new file mode 100644 index 00000000..0c4ac18a --- /dev/null +++ b/spec/test/mock_services/mock_workspace/list_workspace_ids_admin.json @@ -0,0 +1,17 @@ +{ + "methods": ["POST"], + "path": "/", + "headers": {"Authorization": "admin_token"}, + "body": { + "method": "Workspace.list_workspace_ids", + "version": "1.1", + "params": [{"perm": "r"}] + }, + "response": { + "status": "200", + "body": { + "version": "1.1", + "result": [{"workspaces": [99], "pub": []}] + } + } +} diff --git a/spec/test/mock_services/mock_workspace/list_workspace_ids_invalid1.json b/spec/test/mock_services/mock_workspace/list_workspace_ids_invalid1.json new file mode 100644 index 00000000..89100454 --- /dev/null +++ b/spec/test/mock_services/mock_workspace/list_workspace_ids_invalid1.json @@ -0,0 +1,22 @@ +{ + "methods": ["POST"], + "path": "/", + "headers": {"Authorization": "invalid_token"}, + "body": { + "method": "Workspace.list_workspace_ids", + "version": "1.1", + "params": [{"perm": "r"}] + }, + "response": { + "status": "500", + "body": { + "version": "1.1", + "error": { + "name": "JSONRPCError", + "code": -32400, + "message": "Token validation failed!", + "error": "..." + } + } + } +} diff --git a/spec/test/mock_services/mock_workspace/list_workspace_ids_valid.json b/spec/test/mock_services/mock_workspace/list_workspace_ids_valid.json new file mode 100644 index 00000000..0c879099 --- /dev/null +++ b/spec/test/mock_services/mock_workspace/list_workspace_ids_valid.json @@ -0,0 +1,22 @@ +{ + "methods": ["POST"], + "path": "/", + "headers": {"Authorization": "valid_token"}, + "body": { + "method": "Workspace.list_workspace_ids", + "version": "1.1", + "params": [{"perm": "r"}] + }, + "response": { + "status": "200", + "body": { + "version": "1.1", + "result": [ + { + "workspaces": [1, 2, 3], + "pub": [] + } + ] + } + } +} diff --git a/spec/test/views/test_list_test_vertices.py b/spec/test/views/test_list_test_vertices.py index e768a26e..90414bb2 100644 --- a/spec/test/views/test_list_test_vertices.py +++ b/spec/test/views/test_list_test_vertices.py @@ -1,6 +1,7 @@ import json import unittest import requests +import time _API_URL = 'http://re_api:5000/api' _VERSION = 'v1' @@ -19,6 +20,24 @@ def create_test_docs(docs): class TestListTestVertices(unittest.TestCase): + @classmethod + def setUpClass(cls): + # Wait for the API to come online + timeout = int(time.time()) + 60 + api_up = False + while not api_up: + try: + requests.get('http://re_api:5000').raise_for_status() + requests.get('http://auth:5000') + requests.get('http://workspace:5000') + api_up = True + except Exception as err: + print(err) + print('Waiting for RE API to come online..') + if int(time.time()) > timeout: + raise RuntimeError("Timed out waiting for RE API.") + time.sleep(2) + def test_valid(self): """Test a valid query.""" print(create_test_docs([ From aa5a93ff5bcc642a8926c6e2d27d8d752dab0b1f Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Mon, 1 Jul 2019 15:49:27 -0700 Subject: [PATCH 295/732] Fix up tests --- api/Makefile | 8 +- api/docker-compose.yaml | 5 + api/scripts/run_tests.sh | 2 + .../utils/bulk_import.py | 2 + .../wait_for_services.py | 32 +++++++ api/src/test/mock_auth/auth_admin.json | 26 +++++ api/src/test/mock_auth/auth_invalid.json | 23 +++++ api/src/test/mock_auth/auth_missing.json | 21 ++++ api/src/test/mock_auth/auth_non_admin.json | 24 +++++ api/src/test/mock_auth/endpoints.json | 95 ------------------- api/src/test/mock_workspace/endpoints.json | 63 ------------ .../list_workspace_ids_invalid.json | 22 +++++ .../list_workspace_ids_valid.json | 22 +++++ .../list_workspace_ids_valid2.json | 17 ++++ api/src/test/test_api_v1.py | 2 +- 15 files changed, 201 insertions(+), 163 deletions(-) create mode 100644 api/src/relation_engine_server/wait_for_services.py create mode 100644 api/src/test/mock_auth/auth_admin.json create mode 100644 api/src/test/mock_auth/auth_invalid.json create mode 100644 api/src/test/mock_auth/auth_missing.json create mode 100644 api/src/test/mock_auth/auth_non_admin.json delete mode 100644 api/src/test/mock_auth/endpoints.json delete mode 100644 api/src/test/mock_workspace/endpoints.json create mode 100644 api/src/test/mock_workspace/list_workspace_ids_invalid.json create mode 100644 api/src/test/mock_workspace/list_workspace_ids_valid.json create mode 100644 api/src/test/mock_workspace/list_workspace_ids_valid2.json diff --git a/api/Makefile b/api/Makefile index 04fabc4b..236f5400 100644 --- a/api/Makefile +++ b/api/Makefile @@ -1,10 +1,10 @@ .PHONY: test reset test: + docker-compose down docker-compose run web sh scripts/run_tests.sh + docker-compose down reset: - docker-compose down - docker-compose rm -vf - docker-compose build --no-cache - docker-compose up + docker-compose --rmi all -v + docker-compose build diff --git a/api/docker-compose.yaml b/api/docker-compose.yaml index da936089..be3a242a 100644 --- a/api/docker-compose.yaml +++ b/api/docker-compose.yaml @@ -14,7 +14,12 @@ services: - 5000:5000 volumes: - ${PWD}:/app + depends_on: + - auth + - workspace + - arangodb environment: + - WORKERS=2 - DEVELOPMENT=1 - FLASK_ENV=development - FLASK_DEBUG=1 diff --git a/api/scripts/run_tests.sh b/api/scripts/run_tests.sh index 70f1ffbf..ebd19e60 100644 --- a/api/scripts/run_tests.sh +++ b/api/scripts/run_tests.sh @@ -5,4 +5,6 @@ set -e flake8 --max-complexity 10 src mypy --ignore-missing-imports src bandit -r src +sh scripts/start_server.sh & +python -m src.relation_engine_server.wait_for_services python -m unittest discover src/test/ diff --git a/api/src/relation_engine_server/utils/bulk_import.py b/api/src/relation_engine_server/utils/bulk_import.py index d41ab850..04db0c58 100644 --- a/api/src/relation_engine_server/utils/bulk_import.py +++ b/api/src/relation_engine_server/utils/bulk_import.py @@ -1,3 +1,4 @@ +import time import os import tempfile import flask @@ -27,6 +28,7 @@ def bulk_import(query_params): json_line = json.loads(line) jsonschema.validate(json_line, schema) json_line = _write_edge_key(json_line) + json_line['updated_at'] = int(time.time() * 1000) temp_fd.write(json.dumps(json_line) + '\n') temp_fd.close() resp_text = import_from_file(temp_fd.name, query_params) diff --git a/api/src/relation_engine_server/wait_for_services.py b/api/src/relation_engine_server/wait_for_services.py new file mode 100644 index 00000000..4f9d7e37 --- /dev/null +++ b/api/src/relation_engine_server/wait_for_services.py @@ -0,0 +1,32 @@ +""" +Block until all dependency services (arango, workspace, auth) to come online. +""" +import requests +import time + +from .utils.config import get_config + +_CONFIG = get_config() + + +def main(): + started = False + timeout = int(time.time()) + 60 + while not started: + try: + requests.get(_CONFIG['workspace_url']) + requests.get(_CONFIG['auth_url']) + auth = (_CONFIG['db_user'], _CONFIG['db_pass']) + requests.get(_CONFIG['db_url'] + '/_admin/cluster/health', auth=auth).raise_for_status() + requests.get('http://localhost:5000').raise_for_status() + started = True + except Exception as err: + print('Waiting for services:', err) + if int(time.time()) > timeout: + raise RuntimeError('Timed out waiting for services.') + time.sleep(3) + print('Services started!') + + +if __name__ == '__main__': + main() diff --git a/api/src/test/mock_auth/auth_admin.json b/api/src/test/mock_auth/auth_admin.json new file mode 100644 index 00000000..631e5bea --- /dev/null +++ b/api/src/test/mock_auth/auth_admin.json @@ -0,0 +1,26 @@ +{ + "methods": [ + "GET" + ], + "path": "/api/V2/me", + "headers": { + "Authorization": "admin_token" + }, + "response": { + "status": "200", + "body": { + "created": 1528306100471, + "lastlogin": 1542068355002, + "display": "Test User", + "roles": [], + "customroles": [ + "RE_ADMIN" + ], + "policyids": [], + "user": "username", + "local": false, + "email": "user@example.com", + "idents": [] + } + } +} diff --git a/api/src/test/mock_auth/auth_invalid.json b/api/src/test/mock_auth/auth_invalid.json new file mode 100644 index 00000000..e74e7269 --- /dev/null +++ b/api/src/test/mock_auth/auth_invalid.json @@ -0,0 +1,23 @@ +{ + "methods": [ + "GET" + ], + "path": "/api/V2/me", + "headers": { + "Authorization": "invalid_token" + }, + "response": { + "status": "401", + "body": { + "error": { + "httpcode": 401, + "httpstatus": "Unauthorized", + "appcode": 10020, + "apperror": "Invalid token", + "message": "10020 Invalid token", + "callid": "1757210147564211", + "time": 1542737889450 + } + } + } +} diff --git a/api/src/test/mock_auth/auth_missing.json b/api/src/test/mock_auth/auth_missing.json new file mode 100644 index 00000000..1661807c --- /dev/null +++ b/api/src/test/mock_auth/auth_missing.json @@ -0,0 +1,21 @@ +{ + "methods": [ + "GET" + ], + "path": "/api/V2/me", + "headers": {"Authorization": ""}, + "response": { + "status": "400", + "body": { + "error": { + "httpcode": 400, + "httpstatus": "Bad Request", + "appcode": 10010, + "apperror": "No authentication token", + "message": "10010 No authentication token: No user token provided", + "callid": "7334881776774415", + "time": 1542737656377 + } + } + } +} diff --git a/api/src/test/mock_auth/auth_non_admin.json b/api/src/test/mock_auth/auth_non_admin.json new file mode 100644 index 00000000..9236f450 --- /dev/null +++ b/api/src/test/mock_auth/auth_non_admin.json @@ -0,0 +1,24 @@ +{ + "methods": [ + "GET" + ], + "path": "/api/V2/me", + "headers": { + "Authorization": "non_admin_token" + }, + "response": { + "status": "200", + "body": { + "created": 1528306100471, + "lastlogin": 1542068355002, + "display": "Test User", + "roles": [], + "customroles": [], + "policyids": [], + "user": "username", + "local": false, + "email": "user@example.com", + "idents": [] + } + } +} diff --git a/api/src/test/mock_auth/endpoints.json b/api/src/test/mock_auth/endpoints.json deleted file mode 100644 index d6adcd5e..00000000 --- a/api/src/test/mock_auth/endpoints.json +++ /dev/null @@ -1,95 +0,0 @@ -[ - { - "methods": [ - "GET" - ], - "path": "/api/V2/me", - "headers": { - "Authorization": "non_admin_token" - }, - "response": { - "status": "200", - "body": { - "created": 1528306100471, - "lastlogin": 1542068355002, - "display": "Test User", - "roles": [], - "customroles": [], - "policyids": [], - "user": "username", - "local": false, - "email": "user@example.com", - "idents": [] - } - } - }, - { - "methods": [ - "GET" - ], - "path": "/api/V2/me", - "headers": { - "Authorization": "admin_token" - }, - "response": { - "status": "200", - "body": { - "created": 1528306100471, - "lastlogin": 1542068355002, - "display": "Test User", - "roles": [], - "customroles": [ - "RE_ADMIN" - ], - "policyids": [], - "user": "username", - "local": false, - "email": "user@example.com", - "idents": [] - } - } - }, - { - "methods": [ - "GET" - ], - "path": "/api/V2/me", - "headers": { - "Authorization": "invalid_token" - }, - "response": { - "status": "401", - "body": { - "error": { - "httpcode": 401, - "httpstatus": "Unauthorized", - "appcode": 10020, - "apperror": "Invalid token", - "message": "10020 Invalid token", - "callid": "1757210147564211", - "time": 1542737889450 - } - } - } - }, - { - "methods": [ - "GET" - ], - "path": "/api/V2/me", - "response": { - "status": "400", - "body": { - "error": { - "httpcode": 400, - "httpstatus": "Bad Request", - "appcode": 10010, - "apperror": "No authentication token", - "message": "10010 No authentication token: No user token provided", - "callid": "7334881776774415", - "time": 1542737656377 - } - } - } - } -] diff --git a/api/src/test/mock_workspace/endpoints.json b/api/src/test/mock_workspace/endpoints.json deleted file mode 100644 index 78de5656..00000000 --- a/api/src/test/mock_workspace/endpoints.json +++ /dev/null @@ -1,63 +0,0 @@ -[ - { - "methods": ["POST"], - "path": "/", - "headers": {"Authorization": "valid_token"}, - "body": { - "method": "Workspace.list_workspace_ids", - "version": "1.1", - "params": [{"perm": "r"}] - }, - "response": { - "status": "200", - "body": { - "version": "1.1", - "result": [ - { - "workspaces": [1, 2, 3], - "pub": [] - } - ] - } - } - }, - { - "methods": ["POST"], - "path": "/", - "headers": {"Authorization": "invalid_token"}, - "body": { - "method": "Workspace.list_workspace_ids", - "version": "1.1", - "params": [{"perm": "r"}] - }, - "response": { - "status": "500", - "body": { - "version": "1.1", - "error": { - "name": "JSONRPCError", - "code": -32400, - "message": "Token validation failed!", - "error": "..." - } - } - } - }, - { - "methods": ["POST"], - "path": "/", - "headers": {"Authorization": "admin_token"}, - "body": { - "method": "Workspace.list_workspace_ids", - "version": "1.1", - "params": [{"perm": "r"}] - }, - "response": { - "status": "200", - "body": { - "version": "1.1", - "result": [{"workspaces": [99], "pub": []}] - } - } - } -] diff --git a/api/src/test/mock_workspace/list_workspace_ids_invalid.json b/api/src/test/mock_workspace/list_workspace_ids_invalid.json new file mode 100644 index 00000000..89100454 --- /dev/null +++ b/api/src/test/mock_workspace/list_workspace_ids_invalid.json @@ -0,0 +1,22 @@ +{ + "methods": ["POST"], + "path": "/", + "headers": {"Authorization": "invalid_token"}, + "body": { + "method": "Workspace.list_workspace_ids", + "version": "1.1", + "params": [{"perm": "r"}] + }, + "response": { + "status": "500", + "body": { + "version": "1.1", + "error": { + "name": "JSONRPCError", + "code": -32400, + "message": "Token validation failed!", + "error": "..." + } + } + } +} diff --git a/api/src/test/mock_workspace/list_workspace_ids_valid.json b/api/src/test/mock_workspace/list_workspace_ids_valid.json new file mode 100644 index 00000000..0c879099 --- /dev/null +++ b/api/src/test/mock_workspace/list_workspace_ids_valid.json @@ -0,0 +1,22 @@ +{ + "methods": ["POST"], + "path": "/", + "headers": {"Authorization": "valid_token"}, + "body": { + "method": "Workspace.list_workspace_ids", + "version": "1.1", + "params": [{"perm": "r"}] + }, + "response": { + "status": "200", + "body": { + "version": "1.1", + "result": [ + { + "workspaces": [1, 2, 3], + "pub": [] + } + ] + } + } +} diff --git a/api/src/test/mock_workspace/list_workspace_ids_valid2.json b/api/src/test/mock_workspace/list_workspace_ids_valid2.json new file mode 100644 index 00000000..0c4ac18a --- /dev/null +++ b/api/src/test/mock_workspace/list_workspace_ids_valid2.json @@ -0,0 +1,17 @@ +{ + "methods": ["POST"], + "path": "/", + "headers": {"Authorization": "admin_token"}, + "body": { + "method": "Workspace.list_workspace_ids", + "version": "1.1", + "params": [{"perm": "r"}] + }, + "response": { + "status": "200", + "body": { + "version": "1.1", + "result": [{"workspaces": [99], "pub": []}] + } + } +} diff --git a/api/src/test/test_api_v1.py b/api/src/test/test_api_v1.py index 46979730..5eba657e 100644 --- a/api/src/test/test_api_v1.py +++ b/api/src/test/test_api_v1.py @@ -14,7 +14,7 @@ INVALID_TOKEN = 'invalid_token' # Use the docker-compose url of the running flask server -URL = os.environ.get('TEST_URL', 'http://web:5000') +URL = os.environ.get('TEST_URL', 'http://localhost:5000') VERSION = 'v1' API_URL = '/'.join([URL, 'api', VERSION]) From 2c5f6b575b83e403b76fe9c8fc6477f43e1a5838 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Mon, 1 Jul 2019 15:57:44 -0700 Subject: [PATCH 296/732] Fix tests --- api/.travis.yml | 2 -- api/README.md | 8 ++------ 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/api/.travis.yml b/api/.travis.yml index 3b2930a9..10dc631b 100644 --- a/api/.travis.yml +++ b/api/.travis.yml @@ -2,6 +2,4 @@ sudo: required services: - docker script: -- docker-compose up --build -d -- sleep 15 - make test diff --git a/api/README.md b/api/README.md index abb748ce..276eb182 100644 --- a/api/README.md +++ b/api/README.md @@ -354,16 +354,12 @@ The following environment variables should be configured: See the [Contribution Guidelines](/.github/CONTRIBUTING.md). -**Start the server** with `docker-compose up --build`. - -**Run tests** with `make test` (the server should be running in another terminal using `docker-compose up --build`). +**Run tests** with `make test` To do a hard reset of your docker build, do: ```sh -docker-compose rm -vf -docker-compose build --no-cache -docker-compose up +docker-compose down --rmi all -v ``` ## Deployment From 34171d313faca4855f3ae133d63cb728f5075c75 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Mon, 1 Jul 2019 15:58:32 -0700 Subject: [PATCH 297/732] Update README.md --- spec/README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/spec/README.md b/spec/README.md index 345d7912..92fb5841 100644 --- a/spec/README.md +++ b/spec/README.md @@ -14,6 +14,4 @@ the database's collections. ### Running tests -The tests will validate JSON schema syntax and will look for any duplicate schema or view names. - -Using python 3.5+, run `make test`. +Run tests with `make test`. From 53afdd4f897ec3ba213664571a35bcbcef6f11db Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Fri, 5 Jul 2019 09:54:41 -0700 Subject: [PATCH 298/732] Add port cmd in dockerfile --- api/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/api/Dockerfile b/api/Dockerfile index 5c8a6543..fbe8588e 100644 --- a/api/Dockerfile +++ b/api/Dockerfile @@ -33,5 +33,6 @@ LABEL org.label-schema.build-date=$BUILD_DATE \ us.kbase.vcs-branch=$BRANCH \ maintainer="KBase Team" +EXPOSE 5000 ENTRYPOINT ["/usr/local/bin/dockerize"] CMD ["sh", "-x", "scripts/start_server.sh"] From 25a0f012e786f6dbdeab7f8fac5af24c6c2155fd Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Fri, 5 Jul 2019 11:43:57 -0700 Subject: [PATCH 299/732] Fix some test config --- api/scripts/run_tests.sh | 2 +- api/scripts/start_server.sh | 2 ++ .../relation_engine_server/utils/config.py | 2 +- .../wait_for_services.py | 1 - api/src/test/wait_for_api.py | 24 +++++++++++++++++++ 5 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 api/src/test/wait_for_api.py diff --git a/api/scripts/run_tests.sh b/api/scripts/run_tests.sh index ebd19e60..11dcf59e 100644 --- a/api/scripts/run_tests.sh +++ b/api/scripts/run_tests.sh @@ -6,5 +6,5 @@ flake8 --max-complexity 10 src mypy --ignore-missing-imports src bandit -r src sh scripts/start_server.sh & -python -m src.relation_engine_server.wait_for_services +python -m src.test.wait_for_api python -m unittest discover src/test/ diff --git a/api/scripts/start_server.sh b/api/scripts/start_server.sh index 9b28288a..1e9238ed 100644 --- a/api/scripts/start_server.sh +++ b/api/scripts/start_server.sh @@ -7,6 +7,8 @@ calc_workers="$(($(nproc) * 2 + 1))" # Use the WORKERS environment variable, if present workers=${WORKERS:-$calc_workers} +python -m src.relation_engine_server.wait_for_services + gunicorn \ --worker-class gevent \ --timeout 1800 \ diff --git a/api/src/relation_engine_server/utils/config.py b/api/src/relation_engine_server/utils/config.py index 1e288b15..48f1efe9 100644 --- a/api/src/relation_engine_server/utils/config.py +++ b/api/src/relation_engine_server/utils/config.py @@ -14,7 +14,7 @@ def get_config(): kbase_endpoint = os.environ.get('KBASE_ENDPOINT', 'https://ci.kbase.us/services') auth_url = os.environ.get('KBASE_AUTH_URL', urljoin(kbase_endpoint + '/', 'auth')) workspace_url = os.environ.get('KBASE_WORKSPACE_URL', urljoin(kbase_endpoint + '/', 'ws')) - db_url = os.environ.get('DB_URL', 'http://localhost:8529') + db_url = os.environ.get('DB_URL', 'http://arangodb:8529') db_name = os.environ.get('DB_NAME', '_system') db_user = os.environ.get('DB_USER', 'root') db_pass = os.environ.get('DB_PASS', '') diff --git a/api/src/relation_engine_server/wait_for_services.py b/api/src/relation_engine_server/wait_for_services.py index 4f9d7e37..87955105 100644 --- a/api/src/relation_engine_server/wait_for_services.py +++ b/api/src/relation_engine_server/wait_for_services.py @@ -18,7 +18,6 @@ def main(): requests.get(_CONFIG['auth_url']) auth = (_CONFIG['db_user'], _CONFIG['db_pass']) requests.get(_CONFIG['db_url'] + '/_admin/cluster/health', auth=auth).raise_for_status() - requests.get('http://localhost:5000').raise_for_status() started = True except Exception as err: print('Waiting for services:', err) diff --git a/api/src/test/wait_for_api.py b/api/src/test/wait_for_api.py new file mode 100644 index 00000000..413024b1 --- /dev/null +++ b/api/src/test/wait_for_api.py @@ -0,0 +1,24 @@ +""" +Block until the api starts up +""" +import requests +import time + + +def main(): + started = False + timeout = int(time.time()) + 60 + while not started: + try: + requests.get('http://localhost:5000').raise_for_status() + started = True + except Exception as err: + print('Waiting for services:', err) + if int(time.time()) > timeout: + raise RuntimeError('Timed out waiting for services.') + time.sleep(3) + print('Services started!') + + +if __name__ == '__main__': + main() From ff9e9bc0e84d0f992f8798ca691c53c9e679d4cd Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Mon, 8 Jul 2019 14:50:52 -0700 Subject: [PATCH 300/732] Update cached spec release --- api/src/test/spec_release/spec.tar.gz | Bin 7519 -> 11528 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/api/src/test/spec_release/spec.tar.g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3uMWwFzM9 z`p;hV{I}iCr+r=j-2`Yzp3rC-m=V4FXKsgA%W!K83-~Q^PMbsiD`_qgO3vLO7MWW+ z!T6rpmdUKS;YAN~WgqA=`(i>4vHNYvcRS1qh!JPal=gnBOq!)shOnS9cz zb;DNZ31Z8XWo{d9R);vTMq3dY6hn1G6P^&cqN~=GG#X zbRy1Bd-T2&U%8Uub+m{V2e}*vMWy#Rc6oJzB#$_LX!F)|w+YYfhioLHT$ijVsbSoC zI>ujEDK;KFI-kPYZA=pU$u-GhvU+E`y}KQ9Xi35^WKlK(k)tzcA;UI^V#9r-1=BY1 z3_>#0AeFTfMf76N4P*0yr4OA`eOq3A$)hwpLLO3Q%I?yXqbMVO9u_|H-JwlWRE}>y z3ejvNs+rV;BT<;?ahCjmWB+)JV`k~WCs$Klm$nsT_0E@p*5rTb`mVFAIu9)4|IU7O z|NriOXTPKTzX5>%$5}j&QTatboEB<+u|PPGIfj|l?9h-&?}V6#SK~A;5>#2(H0q9i zr@~<+Miwfr`|($25@hmaPG++p+AApn%l;1wBbO3Giai!<4!M(;GW8k$=($)#Ah?Q( zsfNgy3D^Xb?10h#=DSd;(VfBoMy{@?C=o)iD?>H6;`0RER)zd{^u&!~%HT97GBSSu!deLSkK p{tAUcp-?Ck3WY+UP$(1%g+ifFC=?2XLZNtn_yf(eA Date: Tue, 9 Jul 2019 13:22:40 -0700 Subject: [PATCH 301/732] Fix type for wsfull_obj_created_with_method --- spec/schemas/edges/wsfull/wsfull_obj_created_with_method.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/schemas/edges/wsfull/wsfull_obj_created_with_method.json b/spec/schemas/edges/wsfull/wsfull_obj_created_with_method.json index 79c4af99..00e7a82d 100644 --- a/spec/schemas/edges/wsfull/wsfull_obj_created_with_method.json +++ b/spec/schemas/edges/wsfull/wsfull_obj_created_with_method.json @@ -19,7 +19,7 @@ "description": "A version of a module with a method." }, "method_params": { - "type": "object", + "type": ["array", "object", "null"], "description": "The input parameters for the method used to create the object." } } From ef2b6f609c2dc92209602a7b3bb499ef9d26e6cb Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 9 Jul 2019 13:26:27 -0700 Subject: [PATCH 302/732] Update cached specs --- api/src/test/spec_release/spec.tar.gz | Bin 11528 -> 11549 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/api/src/test/spec_release/spec.tar.gz b/api/src/test/spec_release/spec.tar.gz index 08ab47d4b25eb47d7f0434f1fc66acc344ecb9a6..de85b63c38be0e654c3f744346a0c676f587c613 100644 GIT binary patch literal 11549 zcmY*-RaBf!(=F~2EVv|Ca0@Pj1cJM}6Wm<}5*&iN6M_eKo!~AB9^Bn^V3_B;-+y=d zqOW>Y_1aan_g+OChk@{a2l-4K?7Aw{_~I*pnru{b-Zj_&Ys!_m++wmfY*zWoux{DV zrdGuG??5i2`$yiOuh3R-#3RWjvp?U@5Q7vBBX{ezYDB`-XDPg~?CnW6p}g78!C!=f z9ggYcR1VPnz?_$Lz_ime+ z{dF~g3(7E`Z)DSclTMeor`;hYmy0ctiyu#>Y*%4p^UX_j2J5pThDv;9l)=NMTF(D{ zT(4f(En8OnVp*gqYR$GYi+i`;w0bG$dx^?I7;N^umGl-Aq;>`FT0Mc!ZV)3)Y^hBH z6T^^$j=O@me@;%~m3WMR5%!3gqX5zFX2sH~Bp0Q_uI5u}B1HClI}LAzCwsCx+3K<~ zakoe2?=SC%XQ!=pNs`D3W*XDHE6i%t19~)qfi?d z_=L=NlG-g!ye7dI?%JGs16g(UVS{raqSf*}7y#`Cr!-h`iH{Gp5aUVr=k0ATUavl} zBt4Ud5n?jqLDb(HWBUtSKjjjRtTo-?ZO9W(n`tmG#zWsA!7qUl)ca7X|AKZ_Ld_i8 za!G(pgvUt|ZrI44?CsFThS}(OG&V2j3Z*vmt)#Ng47**waXs02pslAZWxV=o+MIY> z6#Af#7_>sP#kn2f=9{wdNFIf}WlN8E-&&vxw|jTn=TWm!;ihaQ4l}rU0}bk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temporary tests/paths --- api/scripts/start_server.sh | 2 +- .../{api_modules => api_versions}/__init__.py | 0 .../{api_modules => api_versions}/api_v1.py | 41 +++++++------ .../{server.py => main.py} | 59 +------------------ api/src/test/test_api_v1.py | 27 --------- 5 files changed, 23 insertions(+), 106 deletions(-) rename api/src/relation_engine_server/{api_modules => api_versions}/__init__.py (100%) rename api/src/relation_engine_server/{api_modules => api_versions}/api_v1.py (81%) rename api/src/relation_engine_server/{server.py => main.py} (61%) diff --git a/api/scripts/start_server.sh b/api/scripts/start_server.sh index 1e9238ed..f2b007a7 100644 --- a/api/scripts/start_server.sh +++ b/api/scripts/start_server.sh @@ -15,4 +15,4 @@ gunicorn \ --workers $workers \ --bind :5000 \ ${DEVELOPMENT:+"--reload"} \ - src.relation_engine_server.server:app + src.relation_engine_server.main:app diff --git a/api/src/relation_engine_server/api_modules/__init__.py b/api/src/relation_engine_server/api_versions/__init__.py similarity index 100% rename from api/src/relation_engine_server/api_modules/__init__.py rename to api/src/relation_engine_server/api_versions/__init__.py diff --git a/api/src/relation_engine_server/api_modules/api_v1.py b/api/src/relation_engine_server/api_versions/api_v1.py similarity index 81% rename from api/src/relation_engine_server/api_modules/api_v1.py rename to api/src/relation_engine_server/api_versions/api_v1.py index db55daae..f76d94ae 100644 --- a/api/src/relation_engine_server/api_modules/api_v1.py +++ b/api/src/relation_engine_server/api_versions/api_v1.py @@ -3,22 +3,28 @@ from ..exceptions import InvalidParameters +api_v1 = flask.Blueprint('api_v1', __name__) + + +@api_v1.route('/specs/views', methods=['GET']) def show_views(): - """Handle /views.""" + """Show the current stored query names loaded from the spec.""" name = flask.request.args.get('name') if name: return {'view': spec_loader.get_view(name)} - return spec_loader.get_view_names() + return flask.jsonify(spec_loader.get_view_names()) +@api_v1.route('/specs/schemas', methods=['GET']) def show_schemas(): - """Handle /schemas.""" + """Show the current schema names (edges and vertices) loaded from the spec.""" name = flask.request.args.get('name') if name: return spec_loader.get_schema(name) - return spec_loader.get_schema_names() + return flask.jsonify(spec_loader.get_schema_names()) +@api_v1.route('/query_results', methods=['POST']) def run_query(): """ Run a stored view as a query against the database. @@ -44,7 +50,7 @@ def run_query(): bind_vars=json_body, batch_size=batch_size, full_count=full_count) - return resp_body + return flask.jsonify(resp_body) if 'view' in flask.request.args: # Run a query from a view name view_name = flask.request.args['view'] @@ -53,16 +59,17 @@ def run_query(): bind_vars=json_body, batch_size=batch_size, full_count=full_count) - return resp_body + 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'] resp_body = arango_client.run_query(cursor_id=cursor_id) - return resp_body + return flask.jsonify(resp_body) # No valid options were passed raise InvalidParameters('Pass in a view or a cursor_id') +@api_v1.route('/specs', methods=['PUT']) def update_specs(): """ Manually check for updates, download spec releases, and init new collections. @@ -72,9 +79,10 @@ def update_specs(): init_collections = 'init_collections' in flask.request.args release_url = flask.request.args.get('release_url') pull_spec.download_specs(init_collections, release_url) - return {'status': 'updated'} + return flask.jsonify({'status': 'updated'}) +@api_v1.route('/documents', methods=['PUT']) def save_documents(): """ Create, update, or replace many documents in a batch. @@ -91,27 +99,18 @@ def save_documents(): if flask.request.args.get('overwrite'): query['overwrite'] = 'true' resp_text = bulk_import.bulk_import(query) - return resp_text + return flask.jsonify(resp_text) +@api_v1.route('/config', methods=['GET']) def show_config(): """Show public config data.""" conf = config.get_config() - return { + return flask.jsonify({ 'auth_url': conf['auth_url'], 'workspace_url': conf['workspace_url'], 'kbase_endpoint': conf['kbase_endpoint'], 'db_url': conf['db_url'], 'db_name': conf['db_name'], 'spec_url': conf['spec_url'] - } - - -endpoints = { - 'query_results': {'handler': run_query, 'methods': {'POST'}}, - 'specs/schemas': {'handler': show_schemas}, - 'specs/views': {'handler': show_views}, - 'config': {'handler': show_config}, - 'specs': {'handler': update_specs, 'methods': {'PUT'}}, - 'documents': {'handler': save_documents, 'methods': {'PUT'}} -} + }) diff --git a/api/src/relation_engine_server/server.py b/api/src/relation_engine_server/main.py similarity index 61% rename from api/src/relation_engine_server/server.py rename to api/src/relation_engine_server/main.py index 853f1afc..65181d3a 100644 --- a/api/src/relation_engine_server/server.py +++ b/api/src/relation_engine_server/main.py @@ -1,5 +1,4 @@ """The main entrypoint for running the Flask server.""" -import re import flask import json import os @@ -7,17 +6,15 @@ import traceback from jsonschema.exceptions import ValidationError +from .api_versions.api_v1 import api_v1 from .exceptions import MissingHeader, UnauthorizedAccess, InvalidParameters from .utils import arango_client, spec_loader -from .api_modules import api_v1 - -# All api version modules, from oldest to newest -_API_VERSIONS = [api_v1.endpoints] app = flask.Flask(__name__) app.config['DEBUG'] = os.environ.get('FLASK_DEBUG', True) app.config['SECRET_KEY'] = os.environ.get('FLASK_SECRET_KEY', str(uuid4())) app.url_map.strict_slashes = False # allow both `get /v1/` and `get /v1` +app.register_blueprint(api_v1, url_prefix='/api/v1') @app.route('/', methods=['GET']) @@ -38,58 +35,6 @@ def root(): return flask.jsonify(body) -@app.route('/api/', methods=['GET', 'PUT', 'POST', 'DELETE']) -def api_call(path): - """ - Handle an api request, dispatching it to the appropriate versioned module. - - Versioning system: - - Every API version is a discrete python module that contains an 'endpoints' dictionary. - - Versions are simple incrementing integers. We only need a new version for breaking changes. - """ - # Get the path and version number - path_parts = path.split('/') - (version_int, api_path) = _get_version_and_path(path_parts) - # Find our method in the various versioned modules - # Note: the mypy type checker has difficulties with the endpoints dict, so we ignore type checking below - endpoints = _API_VERSIONS[version_int - 1] # index 0 == version 1 - if api_path not in endpoints: - body = {'error': f'Path not found: {api_path}.'} - return (flask.jsonify(body), 404) - methods = endpoints[api_path].get('methods', {'GET'}) # type: ignore - # Mypy is not able to infer that `methods` will always be a set - if flask.request.method not in methods: # type: ignore - return (flask.jsonify({'error': '405 - Method not allowed.'}), 405) - # We found a matching function for the endpoint and method - # Mypy is not able to infer that this is a function - result = endpoints[api_path]['handler']() # type: ignore - return (flask.jsonify(result), 200) - - -def _get_version_and_path(path_parts): - """ - From a list of path parts, initialize and validate a version int for the api. - Returns pair of (version_int, path_str) - """ - version_str = path_parts[0] - max_version = len(_API_VERSIONS) - # Make sure the version looks like 'v12' - if not re.match(r'^v\d+$', version_str): - # Fallback to v1 for paths like /api/ with no version option - # TODO temporary - return (1, '/'.join(path_parts)) - # raise InvalidParameters('Make a request with the format /api//') - # Parse to an int - version_int = int(version_str.replace('v', '')) - # Make sure the version number is valid - if version_int <= 0: - raise InvalidParameters('API version must be > 0') - if version_int > max_version: - raise InvalidParameters(f'Invalid api version; max is {max_version}') - path_str = '/'.join(path_parts[1:]) - return (version_int, path_str) - - @app.errorhandler(json.decoder.JSONDecodeError) def json_decode_error(err): """A problem parsing json.""" diff --git a/api/src/test/test_api_v1.py b/api/src/test/test_api_v1.py index 5eba657e..0293f859 100644 --- a/api/src/test/test_api_v1.py +++ b/api/src/test/test_api_v1.py @@ -96,11 +96,6 @@ def test_list_views(self): resp = requests.get(API_URL + '/specs/views').json() self.assertTrue('list_test_vertices' in resp) - def test_show_view(self): - """Test the endpoint that displays AQL source code for one view.""" - resp = requests.get(API_URL + '/specs/views?name=list_test_vertices').text - self.assertTrue('test_vertex' in resp) - def test_list_schemas(self): """Test the listing out of registered JSON schemas for vertices and edges.""" resp = requests.get(API_URL + '/specs/schemas').json() @@ -109,13 +104,6 @@ def test_list_schemas(self): self.assertFalse('error' in resp) self.assertTrue(len(resp)) - def test_show_schema(self): - """Test the endpoint that displays the JSON source for one schema.""" - resp = requests.get(API_URL + '/specs/schemas?name=test_edge').text - self.assertTrue('_from' in resp) - resp = requests.get(API_URL + '/specs/schemas?name=test_vertex').text - self.assertTrue('_key' in resp) - def test_save_documents_missing_auth(self): """Test an invalid attempt to save a doc with a missing auth token.""" resp = requests.put( @@ -428,18 +416,3 @@ def test_queries_are_readonly(self): ).json() self.assertTrue(resp['error']) self.assertTrue('read only' in resp['arango_message']) - - def test_no_version_in_path(self): - """Test that leaving out api version in the path falls back to v1""" - # TODO XXX temporary - save_test_docs(1) - query = 'let ws_ids = @ws_ids for v in test_vertex sort rand() limit @count return v._id' - url = '/'.join([URL, 'api']) # Leaving off version - resp = requests.post( - url + '/query_results', - params={}, - headers=HEADERS_ADMIN, - data=json.dumps({'query': query, 'count': 1}) - ).json() - self.assertEqual(resp['count'], 1) - self.assertEqual(len(resp['results']), 1) From 55cdce3110dca1f73d4d7c5d2a310e6bb677e388 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 10 Jul 2019 13:42:16 -0700 Subject: [PATCH 304/732] Update README.md --- api/README.md | 173 ++------------------------------------------------ 1 file changed, 5 insertions(+), 168 deletions(-) diff --git a/api/README.md b/api/README.md index 276eb182..779ddff5 100644 --- a/api/README.md +++ b/api/README.md @@ -13,102 +13,6 @@ The API is a small, rest-ish service where all data is in JSON format. Replace t Returns server status info -### GET /api/views - -Return a list of view names. - -_Example request_ - -```sh -curl -X GET {root_url}/api/views -``` - -_Example response_ - -```json -["example_view1", "example_view1"] -``` - -### GET /api/schemas - -Fetch the registered schema names. - -_Example request_ -```sh -curl -X GET {root_url}/api/schemas -``` - -_Example response_ - -```json -{ - "vertices": ["vertex_examples1", "vertex_examples2"], - "edges": ["edge_example1", "edge_example2"] -} -``` - -### GET /api/v1/specs/views/ - -Get the AQL source code for a view - -_Example request_ - -```sh -curl {root_url}/api/v1/specs/views/example_view1 -``` - -Response has mimetype of text/plain - -_Example response_ - -```json -// This is some AQL source code - -for x in @@collection - return x -``` - -### GET /api/v1/specs/schemas/ - -Get the JSON source for a registered schema by name. - -_Example request_ - -```sh -curl {root_url}/api/v1/specs/schemas/vertex_examples1 -``` - -_Example response_ - -```json -{ - "type": "object", - "required": ["_key"], - "properties": {"_key": {"type": "string"}} -} -``` - -### GET /api/v1/config/ - -Check the current public service configuration. - -_Example_ - -``` -curl {root_url}/api/config -``` - -_Example response_ - -```json -{ "auth_url": "http://auth:5000", - "workspace_url": "http://workspace:5000", - "kbase_endpoint": "https://ci.kbase.us/services", - "db_url": "http://arangodb:8529", - "db_name": "_system", - "spec_url": "https://api.github.com/repos/kbase/relation_engine_spec"} -``` - ### POST /api/v1/query_results Run a query using a view or a cursor ID. Semantically, this is a GET, but it's a POST to allow better support for passing JSON in the request body (eg. Postman doesn't allow request body data in get requests) @@ -272,94 +176,27 @@ _Query params_ Every call to update specs will reset the spec data (do a clean download and overwrite). -## Python client API - -> NOTE: Work in progress -- this is not yet available - -A python client is provided and published on anaconda, installable via pip or conda: - -```sh -$ pip install --extra-index-url https://pypi.anaconda.org/kbase/simple relation_engine_client==0.1 -``` - -Then import it: - -```py -import relation_engine_client as rec -``` - -You can set the environment variable `RELATION_ENGINE_URL` to set the URL of the HTTP API you want to use. - -List out all the current relation engine views: - -```py -views = rec.get_views(show_source=True) -``` - -List out all the current schemas - -```py -schemas = rec.get_schemas(show_source=True) -``` - -Run a query: - -```py -results = rec.query(view=view_name, bind_vars={'@collection': 'genes', 'value': 123}) -``` - -Get more results from a cursor: - -```py -more_results = rec.run_query(cursor_id=results['cursor_id']) -``` - -Save documents from python dictionaries: - -```py -save_results = rec.save_documents( - collection='genes', - on_duplicate='update', - docs=[ - {'_key': 'x', 'name': 'x'}, - {'_key': 'y', 'name': 'y'} - ] -) -``` - -Bulk-save documents from a file: - -```py -save_results = rec.save_documents( - collection='genes', - on_duplicate='update', - from_file='my-file-path.json' -) -``` - -Where the file contains multiple JSON documents separated by line-breaks. - ## Administration The following environment variables should be configured: * `KBASE_AUTH_URL` - url of the KBase authentication (auth2) server to use * `SHARD_COUNT` - number of shards to use when creating new collections -* `KBASE_WORKSPACE_URL` - url of the KBase workspace server to use (for authenticating workspace access) +* `KBASE_WORKSPACE_URL` - url of the KBase workspace server to use (for authorizing workspace access) * `DB_URL` - url of the arangodb database to use for http API access * `DB_USER` - username for the arangodb database * `DB_PASS` - password for the arangodb database +* `DB_READONLY_USER` - read-only username for the arangodb database +* `DB_READONLY_PASS` - read-only password for the arangodb database ## Development See the [Contribution Guidelines](/.github/CONTRIBUTING.md). -**Run tests** with `make test` - -To do a hard reset of your docker build, do: +Run tests with: ```sh -docker-compose down --rmi all -v +make test ``` ## Deployment From b1dd24b0a93fd43cbc97c372cf1d05964afa89b3 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Thu, 11 Jul 2019 13:55:58 -0700 Subject: [PATCH 305/732] Fix some test config --- spec/docker-compose.yaml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/spec/docker-compose.yaml b/spec/docker-compose.yaml index 9da52a5c..260eb135 100644 --- a/spec/docker-compose.yaml +++ b/spec/docker-compose.yaml @@ -22,7 +22,7 @@ services: - auth - workspace environment: - - ARANGO_ROOT_PASSWORD=password + - WORKERS=2 - DEVELOPMENT=1 - FLASK_ENV=development - FLASK_DEBUG=1 @@ -32,15 +32,14 @@ services: - SPEC_RELEASE_PATH=/app/src/test/spec_release/spec.tar.gz - DB_URL=http://arangodb:8529 - DB_USER=root - - DB_PASS=password - # ArangoDB + # Arangodb server in cluster mode arangodb: image: arangodb:3.4 ports: - 8529:8529 - environment: - - ARANGO_ROOT_PASSWORD=password + command: sh -c "arangodb create jwt-secret --secret=jwtSecret && + arangodb --starter.local --auth.jwt-secret=./jwtSecret" # A mock kbase auth server (see src/test/mock_auth/endpoints.json) auth: From a4c67fff95d8b44134dbaa302c3365ae194982ad Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Thu, 11 Jul 2019 13:58:53 -0700 Subject: [PATCH 306/732] Fix test to be a set and not a list --- spec/test/views/test_list_test_vertices.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/test/views/test_list_test_vertices.py b/spec/test/views/test_list_test_vertices.py index 90414bb2..8397254a 100644 --- a/spec/test/views/test_list_test_vertices.py +++ b/spec/test/views/test_list_test_vertices.py @@ -51,7 +51,7 @@ def test_valid(self): ).json() self.assertEqual(resp['count'], 2) # 'c' is inaccessible - self.assertEqual([r['_key'] for r in resp['results']], ['a', 'b']) + self.assertEqual({r['_key'] for r in resp['results']}, {'a', 'b'}) def test_no_auth(self): """Test with blank auth.""" From 84ecd13ff9dead50c54dda73288a217862d27999 Mon Sep 17 00:00:00 2001 From: sean-mccorkle Date: Thu, 11 Jul 2019 17:16:00 -0400 Subject: [PATCH 307/732] added new versions of {ncbi,gtdb}_child_of_taxon and {ncbi,gtdb}_taxon schema (#64) * first pass at generic taxonomy schema * fixed a few typos * added canonicalized list versions for names, fixed more typos * more typos fixed * proposed new schema for taxonomy vertices and edges * make suggested changes * removed source field from required list, changed NCBI key description --- spec/.gitignore | 1 + .../edges/gtdb/gtdb_child_of_taxon.json | 9 ++- .../edges/ncbi/ncbi_child_of_taxon.json | 22 +++++ spec/schemas/vertices/gtdb/gtdb_taxon.json | 29 +++++-- spec/schemas/vertices/ncbi/ncbi_taxon.json | 81 +++++++++++++++++++ 5 files changed, 134 insertions(+), 8 deletions(-) create mode 100644 spec/schemas/edges/ncbi/ncbi_child_of_taxon.json create mode 100644 spec/schemas/vertices/ncbi/ncbi_taxon.json diff --git a/spec/.gitignore b/spec/.gitignore index e818d490..17a31216 100644 --- a/spec/.gitignore +++ b/spec/.gitignore @@ -11,3 +11,4 @@ tmp/* coverage_report/ .coverage *.egg-info/ + diff --git a/spec/schemas/edges/gtdb/gtdb_child_of_taxon.json b/spec/schemas/edges/gtdb/gtdb_child_of_taxon.json index 26ed8fb3..b28d99fc 100644 --- a/spec/schemas/edges/gtdb/gtdb_child_of_taxon.json +++ b/spec/schemas/edges/gtdb/gtdb_child_of_taxon.json @@ -1,8 +1,8 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", - "required": ["_from", "_to"], - "description": "A gtdb_taxon or gtdb_organism is a child of a parent gtdb_taxon in the taxonomy tree.", + "required": ["_from", "_to", "child_type"], + "description": "Edges which create the taxonomy tree for GTDB taxons.", "properties": { "_from": { "type": "string", @@ -11,6 +11,11 @@ "_to": { "type": "string", "description": "The parent gtdb_taxon." + }, + "child_type": { + "type": "string", + "description": "type of child node (taxon or organism)", + "enum": [ "t", "o" ] } } } diff --git a/spec/schemas/edges/ncbi/ncbi_child_of_taxon.json b/spec/schemas/edges/ncbi/ncbi_child_of_taxon.json new file mode 100644 index 00000000..8b2254cd --- /dev/null +++ b/spec/schemas/edges/ncbi/ncbi_child_of_taxon.json @@ -0,0 +1,22 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "required": ["_from", "_to", "child_type"], + "description": "Edges which create the taxonomy tree for NCBI taxons.", + "properties": { + "_from": { + "type": "string", + "description": "The child. A gtdb_taxon or gtdb_organism." + }, + "_to": { + "type": "string", + "description": "The parent gtdb_taxon." + }, + "child_type": { + "type": "string", + "description": "type of child node (taxon or organism)", + "enum": [ "t", "o" ] + } + } +} + diff --git a/spec/schemas/vertices/gtdb/gtdb_taxon.json b/spec/schemas/vertices/gtdb/gtdb_taxon.json index 84a491c9..3c1ad682 100644 --- a/spec/schemas/vertices/gtdb/gtdb_taxon.json +++ b/spec/schemas/vertices/gtdb/gtdb_taxon.json @@ -1,23 +1,40 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", - "description": "A entry in the GTDB taxonomy tree.", - "required": ["_key", "type", "name"], + "description": "Template for a vertex entry in the GTDB taxonomy tree.", + "required": ["_key", "scientific_name", "rank"], "properties": { "_key": { "type": "string", "description": "Taxon type abbreviation plus name", "examples": ["d:Bacteria", "p:Firmicutes"] }, - "name": { + "scientific_name": { "type": "string", "title": "Taxon name.", - "examples": ["Bacteria", "Firmicutes"] + "examples": ["Methylophilus methylotrophus", "Bacteria", "Firmicutes"] }, - "type": { + "canonical_scientific_name": { + "type": "array", + "title": "Canonicalized scientific name", + "examples": [ [ "methylophilus", "methylotrophus" ], + ["Bacteria"], + ["Firmicutes"] + ], + "items": { "type": "string" } + }, + "rank": { "type": "string", - "title": "Taxon type.", + "title": "Taxonomic rank", "examples": ["Domain", "Phylum"] + }, + "numeric_rank": { + "type": "integer", + "title": "Taxonomic level" + }, + "genetic_code": { + "type": "integer", + "title": "genetic code" } } } diff --git a/spec/schemas/vertices/ncbi/ncbi_taxon.json b/spec/schemas/vertices/ncbi/ncbi_taxon.json new file mode 100644 index 00000000..08530851 --- /dev/null +++ b/spec/schemas/vertices/ncbi/ncbi_taxon.json @@ -0,0 +1,81 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "description": "Template for a vertex entry in the NCBI taxonomy tree.", + "required": ["_key", "scientific_name", "rank"], + "properties": { + "_key": { + "type": "string", + "description": "NCBI Taxon id (positive integer)", + "examples": ["1", "2053699"] + }, + "scientific_name": { + "type": "string", + "title": "Taxon name.", + "examples": ["Methylophilus methylotrophus", "Bacteria", "Firmicutes"] + }, + "canonical_scientific_name": { + "type": "array", + "title": "Canonicalized scientific name", + "examples": [ [ "methylophilus", "methylotrophus" ], + ["Bacteria"], + ["Firmicutes"] + ], + "items": { "type": "string" } + }, + "aliases": { + "type": "array", + "description": "Aliases", + "examples": [ + [ {"category": "authority", + "name": "Borreliella burgdorferi (Johnson et al. 1984) Adeolu and Gupta 2015", + "canonical": ["borreliella", "burgdorferi", "johnson", "adeolu", "gupta" ]}, + {"category": "genbank common name", + "name":"Lyme disease spirochet", + "canonical": ["lyme", "disease", "spirochet"] }, + {"category":"synonym", + "name":"Borrelia burgdorferi", + "canonical": [ "borrelia", "burgdorferi" ]} + ], + + [ {"category": "common name", + "name": "E. coli", + "canonical": ["e", "coli"] }, + {"category": "authority", + "name": "\"Bacterium coli commune\" Escherich 1885", + "canonical": ["bacterium", "coli", "commune", "escherich"] }, + {"category": "synonym", + "name": "Bacterium coli", + "canonical": ["bacterium", "coli" ] } + ] + ], + "items": { + "type": "object", + "required": ["category", "name", "canonical"], + "properties": { + "category": {"type": "string"}, + "name": {"type": "string"}, + "canonical": {"type": "array", "items": {"type": "string"}} + } + + } + }, + "rank": { + "type": "string", + "title": "Taxonomic rank", + "examples": ["Domain", "Phylum"] + }, + "numeric_rank": { + "type": "integer", + "title": "Taxonomic level" + }, + "NCBI_taxon_id": { + "type": "integer", + "title": "NCBI_taxon_id" + }, + "genetic_code": { + "type": "integer", + "title": "genetic code" + } + } +} From f21e8a3be810573cdfb093172a7092fcd5483de1 Mon Sep 17 00:00:00 2001 From: kellyhuang21 Date: Mon, 15 Jul 2019 10:16:03 -0700 Subject: [PATCH 308/732] Updated gtdb vertices schema --- spec/schemas/vertices/gtdb/gtdb_vertices.json | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 spec/schemas/vertices/gtdb/gtdb_vertices.json diff --git a/spec/schemas/vertices/gtdb/gtdb_vertices.json b/spec/schemas/vertices/gtdb/gtdb_vertices.json new file mode 100644 index 00000000..fae5ad74 --- /dev/null +++ b/spec/schemas/vertices/gtdb/gtdb_vertices.json @@ -0,0 +1,64 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "description": "A entry for vertices in the GTDB taxonomy tree.", + "required": ["_key", "release", "type", "name"], + "optional": ["domain", "phylum", "class", "order", "family", "genus", "species"] + "properties": { + "_key": { + "type": "string", + "description": "Taxon type abbreviation plus name", + "examples": ["d:bacteria", "s:['salmonella', 'enterica']"] + }, + "release": { + "type": "string", + "description": "Name of the tsv file.", + "examples": ["bac_taxonomy_r83", "bac120_taxonomy_r89"] + }, + "name": { + "type": ["string", "list"], + "title": "Taxon name.", + "examples": ["bacteria", ["streptococcus", "pneumoniae"]] + }, + "type": { + "type": "string", + "title": "Taxon type.", + "examples": ["domain", "species"] + }, + "domain": { + "type": "string", + "title": "Taxon domain.", + "example": ["bacteria"] + }, + "phylum": { + "type": "string", + "title": "Taxon phylum.", + "example": ["firmicutes"] + }, + "class": { + "type": "string", + "title": "Taxon class.", + "example": ["bacilli"] + }, + "order": { + "type": "string", + "title": "Taxon order.", + "example": ["lactobacillales"] + }, + "family": { + "type": "string", + "title": "Taxon family.", + "example": ["streptococcaceae"] + }, + "genus": { + "type": "string", + "title": "Taxon genus.", + "example": ["streptococcus"] + }, + "species": { + "type": ["string", "list"], + "title": "Taxon species.", + "example": ["streptococcus", "pneumoniae"] + } + } +} From 2f9176f87c08fbca7adf7b743f26a2aa108f65bf Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Mon, 15 Jul 2019 10:43:54 -0700 Subject: [PATCH 309/732] Add some example ncbi taxonomy queries --- spec/views/ncbi_taxonomy/get_aliases.yaml | 11 +++++++++++ spec/views/ncbi_taxonomy/get_children.yaml | 12 ++++++++++++ spec/views/ncbi_taxonomy/get_domain.yaml | 13 +++++++++++++ spec/views/ncbi_taxonomy/get_genetic_code.yaml | 11 +++++++++++ spec/views/ncbi_taxonomy/get_kingdom.yaml | 13 +++++++++++++ spec/views/ncbi_taxonomy/get_parent.yaml | 14 ++++++++++++++ .../ncbi_taxonomy/get_scientific_lineage.yaml | 12 ++++++++++++ spec/views/ncbi_taxonomy/get_scientific_name.yaml | 11 +++++++++++ spec/views/ncbi_taxonomy/get_taxonomic_id.yaml | 12 ++++++++++++ 9 files changed, 109 insertions(+) create mode 100644 spec/views/ncbi_taxonomy/get_aliases.yaml create mode 100644 spec/views/ncbi_taxonomy/get_children.yaml create mode 100644 spec/views/ncbi_taxonomy/get_domain.yaml create mode 100644 spec/views/ncbi_taxonomy/get_genetic_code.yaml create mode 100644 spec/views/ncbi_taxonomy/get_kingdom.yaml create mode 100644 spec/views/ncbi_taxonomy/get_parent.yaml create mode 100644 spec/views/ncbi_taxonomy/get_scientific_lineage.yaml create mode 100644 spec/views/ncbi_taxonomy/get_scientific_name.yaml create mode 100644 spec/views/ncbi_taxonomy/get_taxonomic_id.yaml diff --git a/spec/views/ncbi_taxonomy/get_aliases.yaml b/spec/views/ncbi_taxonomy/get_aliases.yaml new file mode 100644 index 00000000..dea8a8d3 --- /dev/null +++ b/spec/views/ncbi_taxonomy/get_aliases.yaml @@ -0,0 +1,11 @@ +params: + type: object + required: [taxon_key] + properties: + taxon_key: {type: string} +query: | + WITH ncbi_child_of_taxon, ncbi_taxon + let taxon_key = @taxon_key + for t in ncbi_taxon + filter t._key == taxon_key + return t.aliases diff --git a/spec/views/ncbi_taxonomy/get_children.yaml b/spec/views/ncbi_taxonomy/get_children.yaml new file mode 100644 index 00000000..c3fc30b1 --- /dev/null +++ b/spec/views/ncbi_taxonomy/get_children.yaml @@ -0,0 +1,12 @@ +params: + type: object + required: [taxon_key] + properties: + taxon_key: {type: string} +query: | + WITH ncbi_child_of_taxon, ncbi_taxon + let taxon_key = @taxon_key + for t in ncbi_taxon + filter t._key == taxon_key + for child in 1..1 inbound t ncbi_child_of_taxon + return child diff --git a/spec/views/ncbi_taxonomy/get_domain.yaml b/spec/views/ncbi_taxonomy/get_domain.yaml new file mode 100644 index 00000000..36b7e73a --- /dev/null +++ b/spec/views/ncbi_taxonomy/get_domain.yaml @@ -0,0 +1,13 @@ +params: + type: object + required: [sci_name] + properties: + sci_name: {type: string} +query: | + WITH ncbi_child_of_taxon, ncbi_taxon + let taxon_key = @taxon_key + for t in ncbi_taxon + filter t._key == taxon_key + for parent in 1..10 outbound t ncbi_child_of_taxon + filter parent.rank == 'domain' || parent.rank == 'superkingdom' + return parent diff --git a/spec/views/ncbi_taxonomy/get_genetic_code.yaml b/spec/views/ncbi_taxonomy/get_genetic_code.yaml new file mode 100644 index 00000000..9f5801e4 --- /dev/null +++ b/spec/views/ncbi_taxonomy/get_genetic_code.yaml @@ -0,0 +1,11 @@ +params: + type: object + required: [taxon_key] + properties: + taxon_key: {type: string} +query: | + WITH ncbi_child_of_taxon, ncbi_taxon + let taxon_key = @taxon_key + for t in ncbi_taxon + filter t._key == taxon_key + return t.gencode diff --git a/spec/views/ncbi_taxonomy/get_kingdom.yaml b/spec/views/ncbi_taxonomy/get_kingdom.yaml new file mode 100644 index 00000000..9ba2158d --- /dev/null +++ b/spec/views/ncbi_taxonomy/get_kingdom.yaml @@ -0,0 +1,13 @@ +params: + type: object + required: [sci_name] + properties: + sci_name: {type: string} +query: | + WITH ncbi_child_of_taxon, ncbi_taxon + let taxon_key = @taxon_key + for t in ncbi_taxon + filter t._key == taxon_key + for parent in 1..10 outbound t ncbi_child_of_taxon + filter parent.rank == 'kingdom' + return parent diff --git a/spec/views/ncbi_taxonomy/get_parent.yaml b/spec/views/ncbi_taxonomy/get_parent.yaml new file mode 100644 index 00000000..53159d8a --- /dev/null +++ b/spec/views/ncbi_taxonomy/get_parent.yaml @@ -0,0 +1,14 @@ +params: + type: object + required: [taxon_key] + properties: + taxon_key: {type: string} +query: | + WITH ncbi_child_of_taxon, ncbi_taxon + let taxon_key = @taxon_key + return FIRST( + for t in ncbi_taxon + filter t._key == taxon_key + for parent in 1..1 outbound t ncbi_child_of_taxon + return parent + ) diff --git a/spec/views/ncbi_taxonomy/get_scientific_lineage.yaml b/spec/views/ncbi_taxonomy/get_scientific_lineage.yaml new file mode 100644 index 00000000..21f62d9f --- /dev/null +++ b/spec/views/ncbi_taxonomy/get_scientific_lineage.yaml @@ -0,0 +1,12 @@ +params: + type: object + required: [taxon_key] + properties: + taxon_key: {type: string} +query: | + WITH ncbi_child_of_taxon, ncbi_taxon + let taxon_key = @taxon_key + for t in ncbi_taxon + filter t._key == taxon_key + for parent in 1..10 outbound t ncbi_child_of_taxon + return parent.scientific_name diff --git a/spec/views/ncbi_taxonomy/get_scientific_name.yaml b/spec/views/ncbi_taxonomy/get_scientific_name.yaml new file mode 100644 index 00000000..dbbd99be --- /dev/null +++ b/spec/views/ncbi_taxonomy/get_scientific_name.yaml @@ -0,0 +1,11 @@ +params: + type: object + required: [taxon_key] + properties: + taxon_key: {type: string} +query: | + WITH ncbi_child_of_taxon, ncbi_taxon + let taxon_key = @taxon_key + for t in ncbi_taxon + filter t._key == taxon_key + return t.scientific_name diff --git a/spec/views/ncbi_taxonomy/get_taxonomic_id.yaml b/spec/views/ncbi_taxonomy/get_taxonomic_id.yaml new file mode 100644 index 00000000..e67acbb5 --- /dev/null +++ b/spec/views/ncbi_taxonomy/get_taxonomic_id.yaml @@ -0,0 +1,12 @@ +params: + type: object + required: [sci_name] + properties: + sci_name: {type: string} +query: | + // Get the taxon ID from scientific name + WITH ncbi_child_of_taxon, ncbi_taxon + let sci_name = @sci_name + for t in ncbi_taxon + filter t.scientific_name == sci_name + return t._key From c33af8d956a379b8288036c66fd95cf27c34c690 Mon Sep 17 00:00:00 2001 From: kellyhuang21 Date: Mon, 15 Jul 2019 11:34:39 -0700 Subject: [PATCH 310/732] Fixed comments on vertices schema --- spec/schemas/vertices/gtdb/gtdb_vertices.json | 70 +++++++++---------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/spec/schemas/vertices/gtdb/gtdb_vertices.json b/spec/schemas/vertices/gtdb/gtdb_vertices.json index fae5ad74..d7af4592 100644 --- a/spec/schemas/vertices/gtdb/gtdb_vertices.json +++ b/spec/schemas/vertices/gtdb/gtdb_vertices.json @@ -3,12 +3,12 @@ "type": "object", "description": "A entry for vertices in the GTDB taxonomy tree.", "required": ["_key", "release", "type", "name"], - "optional": ["domain", "phylum", "class", "order", "family", "genus", "species"] + "optional": ["domain", "phylum", "class", "order", "family", "genus", "species"], "properties": { "_key": { "type": "string", "description": "Taxon type abbreviation plus name", - "examples": ["d:bacteria", "s:['salmonella', 'enterica']"] + "examples": ["d:bacteria", "s:salmonella_enterica"] }, "release": { "type": "string", @@ -16,11 +16,11 @@ "examples": ["bac_taxonomy_r83", "bac120_taxonomy_r89"] }, "name": { - "type": ["string", "list"], + "type": ["list"], "title": "Taxon name.", - "examples": ["bacteria", ["streptococcus", "pneumoniae"]] + "examples": [["bacteria"], ["streptococcus", "pneumoniae"]] }, - "type": { + "rank": { "type": "string", "title": "Taxon type.", "examples": ["domain", "species"] @@ -30,35 +30,35 @@ "title": "Taxon domain.", "example": ["bacteria"] }, - "phylum": { - "type": "string", - "title": "Taxon phylum.", - "example": ["firmicutes"] - }, - "class": { - "type": "string", - "title": "Taxon class.", - "example": ["bacilli"] - }, - "order": { - "type": "string", - "title": "Taxon order.", - "example": ["lactobacillales"] - }, - "family": { - "type": "string", - "title": "Taxon family.", - "example": ["streptococcaceae"] - }, - "genus": { - "type": "string", - "title": "Taxon genus.", - "example": ["streptococcus"] - }, - "species": { - "type": ["string", "list"], - "title": "Taxon species.", - "example": ["streptococcus", "pneumoniae"] - } + "phylum": { + "type": "string", + "title": "Taxon phylum.", + "example": ["firmicutes", "proteobacteria"] + }, + "class": { + "type": "string", + "title": "Taxon class.", + "example": ["bacilli", "gammaproteobacteria"] + }, + "order": { + "type": "string", + "title": "Taxon order.", + "example": ["lactobacillales", "enterobacterales"] + }, + "family": { + "type": "string", + "title": "Taxon family.", + "example": ["streptococcaceae", "enterobacteriaceae"] + }, + "genus": { + "type": "string", + "title": "Taxon genus.", + "example": ["streptococcus", "salmonella"] + }, + "species": { + "type": ["string"], + "title": "Taxon species.", + "example": ["streptococcus_pneumoniae", "salmonella_enterica"] + } } } From a69b6433c172c674a7bfeb6147aea1a4e96bf119 Mon Sep 17 00:00:00 2001 From: kellyhuang21 Date: Mon, 15 Jul 2019 11:48:40 -0700 Subject: [PATCH 311/732] change list to array --- spec/schemas/vertices/gtdb/gtdb_vertices.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/schemas/vertices/gtdb/gtdb_vertices.json b/spec/schemas/vertices/gtdb/gtdb_vertices.json index d7af4592..6b244a34 100644 --- a/spec/schemas/vertices/gtdb/gtdb_vertices.json +++ b/spec/schemas/vertices/gtdb/gtdb_vertices.json @@ -16,7 +16,7 @@ "examples": ["bac_taxonomy_r83", "bac120_taxonomy_r89"] }, "name": { - "type": ["list"], + "type": ["array"], "title": "Taxon name.", "examples": [["bacteria"], ["streptococcus", "pneumoniae"]] }, From c8c24f99fbbed708434c7d4f289607f4fe3728f9 Mon Sep 17 00:00:00 2001 From: kellyhuang21 Date: Mon, 15 Jul 2019 11:54:19 -0700 Subject: [PATCH 312/732] change type to rank --- spec/schemas/vertices/gtdb/gtdb_vertices.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/schemas/vertices/gtdb/gtdb_vertices.json b/spec/schemas/vertices/gtdb/gtdb_vertices.json index 6b244a34..4ee35271 100644 --- a/spec/schemas/vertices/gtdb/gtdb_vertices.json +++ b/spec/schemas/vertices/gtdb/gtdb_vertices.json @@ -2,7 +2,7 @@ "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "description": "A entry for vertices in the GTDB taxonomy tree.", - "required": ["_key", "release", "type", "name"], + "required": ["_key", "release", "rank", "name"], "optional": ["domain", "phylum", "class", "order", "family", "genus", "species"], "properties": { "_key": { From df5c8ad7a71b5b5e14077cc57e14f9a61aa49003 Mon Sep 17 00:00:00 2001 From: Kelly Huang Date: Mon, 15 Jul 2019 15:14:58 -0700 Subject: [PATCH 313/732] fixed schema from comments --- spec/schemas/vertices/gtdb/gtdb_vertices.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/schemas/vertices/gtdb/gtdb_vertices.json b/spec/schemas/vertices/gtdb/gtdb_vertices.json index d7af4592..4ee35271 100644 --- a/spec/schemas/vertices/gtdb/gtdb_vertices.json +++ b/spec/schemas/vertices/gtdb/gtdb_vertices.json @@ -2,7 +2,7 @@ "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "description": "A entry for vertices in the GTDB taxonomy tree.", - "required": ["_key", "release", "type", "name"], + "required": ["_key", "release", "rank", "name"], "optional": ["domain", "phylum", "class", "order", "family", "genus", "species"], "properties": { "_key": { @@ -16,7 +16,7 @@ "examples": ["bac_taxonomy_r83", "bac120_taxonomy_r89"] }, "name": { - "type": ["list"], + "type": ["array"], "title": "Taxon name.", "examples": [["bacteria"], ["streptococcus", "pneumoniae"]] }, From 7a4c57e13d8165e617fc95b9ca0b9594d412e68b Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Mon, 15 Jul 2019 15:23:21 -0700 Subject: [PATCH 314/732] Finalize and clean up the gtdb taxon vertex schema. --- spec/schemas/vertices/gtdb/gtdb_organism.json | 13 ---- spec/schemas/vertices/gtdb/gtdb_taxon.json | 69 +++++++++++++------ spec/schemas/vertices/gtdb/gtdb_vertices.json | 64 ----------------- 3 files changed, 48 insertions(+), 98 deletions(-) delete mode 100644 spec/schemas/vertices/gtdb/gtdb_organism.json delete mode 100644 spec/schemas/vertices/gtdb/gtdb_vertices.json diff --git a/spec/schemas/vertices/gtdb/gtdb_organism.json b/spec/schemas/vertices/gtdb/gtdb_organism.json deleted file mode 100644 index 01881fb8..00000000 --- a/spec/schemas/vertices/gtdb/gtdb_organism.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "description": "An organism in the GTDB taxonomy tree.", - "required": ["_key"], - "properties": { - "_key": { - "type": "string", - "description": "Accession ID (Refseq prefixed with 'RS_' and Genbank prefixed with 'GB_').", - "examples": ["RS_GCF_001300075.1", "GB_GCA_002387705.1"] - } - } -} diff --git a/spec/schemas/vertices/gtdb/gtdb_taxon.json b/spec/schemas/vertices/gtdb/gtdb_taxon.json index 3c1ad682..7d860799 100644 --- a/spec/schemas/vertices/gtdb/gtdb_taxon.json +++ b/spec/schemas/vertices/gtdb/gtdb_taxon.json @@ -1,40 +1,67 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", - "description": "Template for a vertex entry in the GTDB taxonomy tree.", - "required": ["_key", "scientific_name", "rank"], + "description": "A entry for vertices in the GTDB taxonomy tree.", + "required": ["_key", "release", "rank", "name"], + "optional": ["domain", "phylum", "class", "order", "family", "genus", "species"], "properties": { "_key": { "type": "string", "description": "Taxon type abbreviation plus name", - "examples": ["d:Bacteria", "p:Firmicutes"] + "examples": ["d:bacteria", "s:salmonella_enterica"] }, - "scientific_name": { + "release": { "type": "string", - "title": "Taxon name.", - "examples": ["Methylophilus methylotrophus", "Bacteria", "Firmicutes"] + "description": "Name of the tsv file.", + "examples": ["bac_taxonomy_r83", "bac120_taxonomy_r89"] }, - "canonical_scientific_name": { + "name": { "type": "array", - "title": "Canonicalized scientific name", - "examples": [ [ "methylophilus", "methylotrophus" ], - ["Bacteria"], - ["Firmicutes"] - ], - "items": { "type": "string" } + "title": "Taxon name.", + "items": { + "type": "string" + }, + "examples": [["bacteria"], ["streptococcus", "pneumoniae"]] }, "rank": { "type": "string", - "title": "Taxonomic rank", - "examples": ["Domain", "Phylum"] + "title": "Taxon rank.", + "examples": ["domain", "species"] + }, + "domain": { + "type": "string", + "title": "Taxon domain.", + "example": ["bacteria"] }, - "numeric_rank": { - "type": "integer", - "title": "Taxonomic level" + "phylum": { + "type": "string", + "title": "Taxon phylum.", + "example": ["firmicutes", "proteobacteria"] + }, + "class": { + "type": "string", + "title": "Taxon class.", + "example": ["bacilli", "gammaproteobacteria"] + }, + "order": { + "type": "string", + "title": "Taxon order.", + "example": ["lactobacillales", "enterobacterales"] + }, + "family": { + "type": "string", + "title": "Taxon family.", + "example": ["streptococcaceae", "enterobacteriaceae"] + }, + "genus": { + "type": "string", + "title": "Taxon genus.", + "example": ["streptococcus", "salmonella"] }, - "genetic_code": { - "type": "integer", - "title": "genetic code" + "species": { + "type": ["string"], + "title": "Taxon species.", + "example": ["streptococcus_pneumoniae", "salmonella_enterica"] } } } diff --git a/spec/schemas/vertices/gtdb/gtdb_vertices.json b/spec/schemas/vertices/gtdb/gtdb_vertices.json deleted file mode 100644 index 4ee35271..00000000 --- a/spec/schemas/vertices/gtdb/gtdb_vertices.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "description": "A entry for vertices in the GTDB taxonomy tree.", - "required": ["_key", "release", "rank", "name"], - "optional": ["domain", "phylum", "class", "order", "family", "genus", "species"], - "properties": { - "_key": { - "type": "string", - "description": "Taxon type abbreviation plus name", - "examples": ["d:bacteria", "s:salmonella_enterica"] - }, - "release": { - "type": "string", - "description": "Name of the tsv file.", - "examples": ["bac_taxonomy_r83", "bac120_taxonomy_r89"] - }, - "name": { - "type": ["array"], - "title": "Taxon name.", - "examples": [["bacteria"], ["streptococcus", "pneumoniae"]] - }, - "rank": { - "type": "string", - "title": "Taxon type.", - "examples": ["domain", "species"] - }, - "domain": { - "type": "string", - "title": "Taxon domain.", - "example": ["bacteria"] - }, - "phylum": { - "type": "string", - "title": "Taxon phylum.", - "example": ["firmicutes", "proteobacteria"] - }, - "class": { - "type": "string", - "title": "Taxon class.", - "example": ["bacilli", "gammaproteobacteria"] - }, - "order": { - "type": "string", - "title": "Taxon order.", - "example": ["lactobacillales", "enterobacterales"] - }, - "family": { - "type": "string", - "title": "Taxon family.", - "example": ["streptococcaceae", "enterobacteriaceae"] - }, - "genus": { - "type": "string", - "title": "Taxon genus.", - "example": ["streptococcus", "salmonella"] - }, - "species": { - "type": ["string"], - "title": "Taxon species.", - "example": ["streptococcus_pneumoniae", "salmonella_enterica"] - } - } -} From 1d060d7e731b6cc88886ca966d2c33e77433f3c5 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 16 Jul 2019 11:35:31 -0700 Subject: [PATCH 315/732] Bind dev ports only to localhost --- api/docker-compose.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/docker-compose.yaml b/api/docker-compose.yaml index be3a242a..82803817 100644 --- a/api/docker-compose.yaml +++ b/api/docker-compose.yaml @@ -11,7 +11,7 @@ services: args: DEVELOPMENT: 1 ports: - - 5000:5000 + - "127.0.0.1:5000:5000" volumes: - ${PWD}:/app depends_on: @@ -46,6 +46,6 @@ services: arangodb: image: arangodb:3.4 ports: - - 8529:8529 + - "127.0.0.1:8529:8529" command: sh -c "arangodb create jwt-secret --secret=jwtSecret && arangodb --starter.local --auth.jwt-secret=./jwtSecret" From e48c3cf098820a6f98775585afc60468659699bc Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 16 Jul 2019 11:35:52 -0700 Subject: [PATCH 316/732] Bind dev ports only to localhost --- spec/docker-compose.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/docker-compose.yaml b/spec/docker-compose.yaml index 260eb135..a1aa36f2 100644 --- a/spec/docker-compose.yaml +++ b/spec/docker-compose.yaml @@ -16,7 +16,7 @@ services: re_api: image: kbase/relation_engine_api:latest ports: - - 5000:5000 + - "127.0.0.1:5000:5000" depends_on: - arangodb - auth @@ -37,7 +37,7 @@ services: arangodb: image: arangodb:3.4 ports: - - 8529:8529 + - "127.0.0.1:8529:8529" command: sh -c "arangodb create jwt-secret --secret=jwtSecret && arangodb --starter.local --auth.jwt-secret=./jwtSecret" From e9312e5f17669c5b06e87f800298df3d9a7a89ca Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Mon, 22 Jul 2019 14:44:59 -0700 Subject: [PATCH 317/732] Reorganize schema directory structure, and convert them all to yaml --- spec/Dockerfile | 4 +- spec/Makefile | 5 +- spec/schemas/README.md | 13 +- .../edges/gtdb/gtdb_child_of_taxon.json | 22 ---- spec/schemas/edges/mash/README.md | 1 - .../edges/mash/mash_genome_similar_to.json | 18 --- .../edges/ncbi/ncbi_child_of_taxon.json | 22 ---- .../edges/ncbi/ncbi_gene_within_genome.json | 15 --- .../rxn/rxn_compound_linked_to_compound.json | 16 --- .../rxn/rxn_compound_within_reaction.json | 22 ---- .../edges/rxn/rxn_gene_within_complex.json | 15 --- .../rxn/rxn_reaction_linked_to_reaction.json | 16 --- .../rxn/rxn_reaction_within_complex.json | 15 --- .../edges/rxn/rxn_similar_to_reaction.json | 18 --- spec/schemas/edges/test_edge.json | 11 -- .../edges/wsfull/wsfull_copied_from.json | 10 -- .../wsfull/wsfull_latest_version_of.json | 24 ---- .../wsfull/wsfull_module_contains_method.json | 17 --- .../wsfull_obj_created_with_method.json | 26 ---- .../wsfull_obj_created_with_module.json | 18 --- .../wsfull/wsfull_obj_instance_of_type.json | 11 -- .../schemas/edges/wsfull/wsfull_owner_of.json | 24 ---- .../wsfull/wsfull_prov_descendant_of.json | 11 -- .../edges/wsfull/wsfull_refers_to.json | 10 -- .../wsfull_type_consumed_by_method.json | 19 --- .../edges/wsfull/wsfull_version_of.json | 30 ----- .../edges/wsfull/wsfull_ws_contains_obj.json | 17 --- spec/schemas/edges/wsfull/wsfull_ws_perm.json | 28 ----- .../edges/wsprov/wsprov_copied_into.json | 17 --- .../schemas/edges/wsprov/wsprov_input_in.json | 18 --- spec/schemas/edges/wsprov/wsprov_links.json | 17 --- .../schemas/edges/wsprov/wsprov_produced.json | 16 --- spec/schemas/{edges => }/gtdb/README.md | 0 spec/schemas/gtdb/gtdb_child_of_taxon.yaml | 18 +++ spec/schemas/gtdb/gtdb_organism.yaml | 14 +++ spec/schemas/gtdb/gtdb_taxon.yaml | 34 ++++++ spec/schemas/mash/mash_genome_similar_to.yaml | 14 +++ spec/schemas/{edges => }/ncbi/README.md | 0 spec/schemas/ncbi/ncbi_child_of_taxon.yaml | 18 +++ spec/schemas/ncbi/ncbi_gene.yaml | 85 +++++++++++++ .../schemas/ncbi/ncbi_gene_within_genome.yaml | 13 ++ spec/schemas/ncbi/ncbi_genome.yaml | 100 +++++++++++++++ spec/schemas/ncbi/ncbi_taxon.yaml | 104 ++++++++++++++++ spec/schemas/{edges => }/rxn/README.md | 0 spec/schemas/rxn/rxn_compound.yaml | 70 +++++++++++ .../rxn/rxn_compound_linked_to_compound.yaml | 16 +++ .../rxn/rxn_compound_within_reaction.yaml | 18 +++ spec/schemas/rxn/rxn_gene_complex.yaml | 24 ++++ spec/schemas/rxn/rxn_gene_within_complex.yaml | 13 ++ spec/schemas/rxn/rxn_reaction.yaml | 53 ++++++++ .../rxn/rxn_reaction_linked_to_reaction.yaml | 17 +++ .../rxn/rxn_reaction_within_complex.yaml | 13 ++ spec/schemas/rxn/rxn_similar_to_reaction.yaml | 15 +++ spec/schemas/test/test_edge.yaml | 10 ++ spec/schemas/test/test_vertex.yaml | 11 ++ spec/schemas/vertices/README.md | 1 - spec/schemas/vertices/gtdb/README.md | 7 -- spec/schemas/vertices/gtdb/gtdb_organism.json | 13 -- spec/schemas/vertices/gtdb/gtdb_taxon.json | 40 ------ spec/schemas/vertices/ncbi/README.md | 1 - spec/schemas/vertices/ncbi/ncbi_gene.json | 114 ------------------ spec/schemas/vertices/ncbi/ncbi_genome.json | 97 --------------- spec/schemas/vertices/ncbi/ncbi_taxon.json | 81 ------------- spec/schemas/vertices/rxn/README.md | 1 - spec/schemas/vertices/rxn/rxn_compound.json | 88 -------------- .../vertices/rxn/rxn_gene_complex.json | 27 ----- spec/schemas/vertices/rxn/rxn_reaction.json | 64 ---------- spec/schemas/vertices/test_vertex.json | 12 -- spec/schemas/vertices/wsfull/README.md | 5 - .../vertices/wsfull/wsfull_method.json | 17 --- .../wsfull/wsfull_method_version.json | 56 --------- .../vertices/wsfull/wsfull_module.json | 29 ----- .../wsfull/wsfull_module_version.json | 52 -------- .../vertices/wsfull/wsfull_object.json | 34 ------ .../vertices/wsfull/wsfull_object_hash.json | 26 ---- .../wsfull/wsfull_object_version.json | 69 ----------- spec/schemas/vertices/wsfull/wsfull_type.json | 15 --- .../vertices/wsfull/wsfull_type_module.json | 15 --- .../vertices/wsfull/wsfull_type_version.json | 15 --- spec/schemas/vertices/wsfull/wsfull_user.json | 16 --- .../vertices/wsfull/wsfull_workspace.json | 50 -------- spec/schemas/vertices/wsprov/README.md | 1 - .../vertices/wsprov/wsprov_action.json | 26 ---- .../vertices/wsprov/wsprov_object.json | 25 ---- spec/schemas/{edges => }/wsfull/README.md | 0 spec/schemas/wsfull/wsfull_copied_from.yaml | 10 ++ .../wsfull/wsfull_latest_version_of.yaml | 25 ++++ spec/schemas/wsfull/wsfull_method.yaml | 14 +++ .../schemas/wsfull/wsfull_method_version.yaml | 40 ++++++ spec/schemas/wsfull/wsfull_module.yaml | 20 +++ .../wsfull/wsfull_module_contains_method.yaml | 14 +++ .../schemas/wsfull/wsfull_module_version.yaml | 38 ++++++ .../wsfull_obj_created_with_method.yaml | 23 ++++ .../wsfull_obj_created_with_module.yaml | 16 +++ .../wsfull/wsfull_obj_instance_of_type.yaml | 11 ++ spec/schemas/wsfull/wsfull_object.yaml | 23 ++++ spec/schemas/wsfull/wsfull_object_hash.yaml | 16 +++ .../schemas/wsfull/wsfull_object_version.yaml | 54 +++++++++ spec/schemas/wsfull/wsfull_owner_of.yaml | 19 +++ .../wsfull/wsfull_prov_descendant_of.yaml | 10 ++ spec/schemas/wsfull/wsfull_refers_to.yaml | 10 ++ spec/schemas/wsfull/wsfull_type.yaml | 12 ++ .../wsfull_type_consumed_by_method.yaml | 15 +++ spec/schemas/wsfull/wsfull_type_module.yaml | 12 ++ spec/schemas/wsfull/wsfull_type_version.yaml | 12 ++ spec/schemas/wsfull/wsfull_user.yaml | 14 +++ spec/schemas/wsfull/wsfull_version_of.yaml | 28 +++++ spec/schemas/wsfull/wsfull_workspace.yaml | 35 ++++++ .../wsfull/wsfull_ws_contains_obj.yaml | 14 +++ spec/schemas/wsfull/wsfull_ws_perm.yaml | 23 ++++ spec/schemas/{edges => }/wsprov/README.md | 0 spec/schemas/wsprov/wsprov_action.yaml | 18 +++ spec/schemas/wsprov/wsprov_copied_into.yaml | 14 +++ spec/schemas/wsprov/wsprov_input_in.yaml | 14 +++ spec/schemas/wsprov/wsprov_links.yaml | 14 +++ spec/schemas/wsprov/wsprov_object.yaml | 18 +++ spec/schemas/wsprov/wsprov_produced.yaml | 14 +++ spec/test/validate.py | 51 ++++---- .../views/ncbi_taxonomy/get_taxonomic_id.yaml | 3 + 119 files changed, 1302 insertions(+), 1535 deletions(-) delete mode 100644 spec/schemas/edges/gtdb/gtdb_child_of_taxon.json delete mode 100644 spec/schemas/edges/mash/README.md delete mode 100644 spec/schemas/edges/mash/mash_genome_similar_to.json delete mode 100644 spec/schemas/edges/ncbi/ncbi_child_of_taxon.json delete mode 100644 spec/schemas/edges/ncbi/ncbi_gene_within_genome.json delete mode 100644 spec/schemas/edges/rxn/rxn_compound_linked_to_compound.json delete mode 100644 spec/schemas/edges/rxn/rxn_compound_within_reaction.json delete mode 100644 spec/schemas/edges/rxn/rxn_gene_within_complex.json delete mode 100644 spec/schemas/edges/rxn/rxn_reaction_linked_to_reaction.json delete mode 100644 spec/schemas/edges/rxn/rxn_reaction_within_complex.json delete mode 100644 spec/schemas/edges/rxn/rxn_similar_to_reaction.json delete mode 100644 spec/schemas/edges/test_edge.json delete mode 100644 spec/schemas/edges/wsfull/wsfull_copied_from.json delete mode 100644 spec/schemas/edges/wsfull/wsfull_latest_version_of.json delete mode 100644 spec/schemas/edges/wsfull/wsfull_module_contains_method.json delete mode 100644 spec/schemas/edges/wsfull/wsfull_obj_created_with_method.json delete mode 100644 spec/schemas/edges/wsfull/wsfull_obj_created_with_module.json delete mode 100644 spec/schemas/edges/wsfull/wsfull_obj_instance_of_type.json delete mode 100644 spec/schemas/edges/wsfull/wsfull_owner_of.json delete mode 100644 spec/schemas/edges/wsfull/wsfull_prov_descendant_of.json delete mode 100644 spec/schemas/edges/wsfull/wsfull_refers_to.json delete mode 100644 spec/schemas/edges/wsfull/wsfull_type_consumed_by_method.json delete mode 100644 spec/schemas/edges/wsfull/wsfull_version_of.json delete mode 100644 spec/schemas/edges/wsfull/wsfull_ws_contains_obj.json delete mode 100644 spec/schemas/edges/wsfull/wsfull_ws_perm.json delete mode 100644 spec/schemas/edges/wsprov/wsprov_copied_into.json delete mode 100644 spec/schemas/edges/wsprov/wsprov_input_in.json delete mode 100644 spec/schemas/edges/wsprov/wsprov_links.json delete mode 100644 spec/schemas/edges/wsprov/wsprov_produced.json rename spec/schemas/{edges => }/gtdb/README.md (100%) create mode 100644 spec/schemas/gtdb/gtdb_child_of_taxon.yaml create mode 100644 spec/schemas/gtdb/gtdb_organism.yaml create mode 100644 spec/schemas/gtdb/gtdb_taxon.yaml create mode 100644 spec/schemas/mash/mash_genome_similar_to.yaml rename spec/schemas/{edges => }/ncbi/README.md (100%) create mode 100644 spec/schemas/ncbi/ncbi_child_of_taxon.yaml create mode 100644 spec/schemas/ncbi/ncbi_gene.yaml create mode 100644 spec/schemas/ncbi/ncbi_gene_within_genome.yaml create mode 100644 spec/schemas/ncbi/ncbi_genome.yaml create mode 100644 spec/schemas/ncbi/ncbi_taxon.yaml rename spec/schemas/{edges => }/rxn/README.md (100%) create mode 100644 spec/schemas/rxn/rxn_compound.yaml create mode 100644 spec/schemas/rxn/rxn_compound_linked_to_compound.yaml create mode 100644 spec/schemas/rxn/rxn_compound_within_reaction.yaml create mode 100644 spec/schemas/rxn/rxn_gene_complex.yaml create mode 100644 spec/schemas/rxn/rxn_gene_within_complex.yaml create mode 100644 spec/schemas/rxn/rxn_reaction.yaml create mode 100644 spec/schemas/rxn/rxn_reaction_linked_to_reaction.yaml create mode 100644 spec/schemas/rxn/rxn_reaction_within_complex.yaml create mode 100644 spec/schemas/rxn/rxn_similar_to_reaction.yaml create mode 100644 spec/schemas/test/test_edge.yaml create mode 100644 spec/schemas/test/test_vertex.yaml delete mode 100644 spec/schemas/vertices/README.md delete mode 100644 spec/schemas/vertices/gtdb/README.md delete mode 100644 spec/schemas/vertices/gtdb/gtdb_organism.json delete mode 100644 spec/schemas/vertices/gtdb/gtdb_taxon.json delete mode 100644 spec/schemas/vertices/ncbi/README.md delete mode 100644 spec/schemas/vertices/ncbi/ncbi_gene.json delete mode 100644 spec/schemas/vertices/ncbi/ncbi_genome.json delete mode 100644 spec/schemas/vertices/ncbi/ncbi_taxon.json delete mode 100644 spec/schemas/vertices/rxn/README.md delete mode 100644 spec/schemas/vertices/rxn/rxn_compound.json delete mode 100644 spec/schemas/vertices/rxn/rxn_gene_complex.json delete mode 100644 spec/schemas/vertices/rxn/rxn_reaction.json delete mode 100644 spec/schemas/vertices/test_vertex.json delete mode 100644 spec/schemas/vertices/wsfull/README.md delete mode 100644 spec/schemas/vertices/wsfull/wsfull_method.json delete mode 100644 spec/schemas/vertices/wsfull/wsfull_method_version.json delete mode 100644 spec/schemas/vertices/wsfull/wsfull_module.json delete mode 100644 spec/schemas/vertices/wsfull/wsfull_module_version.json delete mode 100644 spec/schemas/vertices/wsfull/wsfull_object.json delete mode 100644 spec/schemas/vertices/wsfull/wsfull_object_hash.json delete mode 100644 spec/schemas/vertices/wsfull/wsfull_object_version.json delete mode 100644 spec/schemas/vertices/wsfull/wsfull_type.json delete mode 100644 spec/schemas/vertices/wsfull/wsfull_type_module.json delete mode 100644 spec/schemas/vertices/wsfull/wsfull_type_version.json delete mode 100644 spec/schemas/vertices/wsfull/wsfull_user.json delete mode 100644 spec/schemas/vertices/wsfull/wsfull_workspace.json delete mode 100644 spec/schemas/vertices/wsprov/README.md delete mode 100644 spec/schemas/vertices/wsprov/wsprov_action.json delete mode 100644 spec/schemas/vertices/wsprov/wsprov_object.json rename spec/schemas/{edges => }/wsfull/README.md (100%) create mode 100644 spec/schemas/wsfull/wsfull_copied_from.yaml create mode 100644 spec/schemas/wsfull/wsfull_latest_version_of.yaml create mode 100644 spec/schemas/wsfull/wsfull_method.yaml create mode 100644 spec/schemas/wsfull/wsfull_method_version.yaml create mode 100644 spec/schemas/wsfull/wsfull_module.yaml create mode 100644 spec/schemas/wsfull/wsfull_module_contains_method.yaml create mode 100644 spec/schemas/wsfull/wsfull_module_version.yaml create mode 100644 spec/schemas/wsfull/wsfull_obj_created_with_method.yaml create mode 100644 spec/schemas/wsfull/wsfull_obj_created_with_module.yaml create mode 100644 spec/schemas/wsfull/wsfull_obj_instance_of_type.yaml create mode 100644 spec/schemas/wsfull/wsfull_object.yaml create mode 100644 spec/schemas/wsfull/wsfull_object_hash.yaml create mode 100644 spec/schemas/wsfull/wsfull_object_version.yaml create mode 100644 spec/schemas/wsfull/wsfull_owner_of.yaml create mode 100644 spec/schemas/wsfull/wsfull_prov_descendant_of.yaml create mode 100644 spec/schemas/wsfull/wsfull_refers_to.yaml create mode 100644 spec/schemas/wsfull/wsfull_type.yaml create mode 100644 spec/schemas/wsfull/wsfull_type_consumed_by_method.yaml create mode 100644 spec/schemas/wsfull/wsfull_type_module.yaml create mode 100644 spec/schemas/wsfull/wsfull_type_version.yaml create mode 100644 spec/schemas/wsfull/wsfull_user.yaml create mode 100644 spec/schemas/wsfull/wsfull_version_of.yaml create mode 100644 spec/schemas/wsfull/wsfull_workspace.yaml create mode 100644 spec/schemas/wsfull/wsfull_ws_contains_obj.yaml create mode 100644 spec/schemas/wsfull/wsfull_ws_perm.yaml rename spec/schemas/{edges => }/wsprov/README.md (100%) create mode 100644 spec/schemas/wsprov/wsprov_action.yaml create mode 100644 spec/schemas/wsprov/wsprov_copied_into.yaml create mode 100644 spec/schemas/wsprov/wsprov_input_in.yaml create mode 100644 spec/schemas/wsprov/wsprov_links.yaml create mode 100644 spec/schemas/wsprov/wsprov_object.yaml create mode 100644 spec/schemas/wsprov/wsprov_produced.yaml diff --git a/spec/Dockerfile b/spec/Dockerfile index 00b007df..cdefd899 100644 --- a/spec/Dockerfile +++ b/spec/Dockerfile @@ -1,5 +1,5 @@ from python:3.7-slim -RUN pip install --upgrade pip requests jsonschema - +RUN pip install --upgrade pip requests jsonschema pyyaml +WORKDIR /app COPY . /app diff --git a/spec/Makefile b/spec/Makefile index 754353f0..a4738038 100644 --- a/spec/Makefile +++ b/spec/Makefile @@ -1,6 +1,7 @@ .PHONY: test test: - python test/validate.py - echo "Running view tests" + echo "Validating files.." + docker-compose run spec python test/validate.py + echo "Running tests.." docker-compose run spec sh -c "python /app/test/views/init_spec.py && python -m unittest discover /app/test/views" diff --git a/spec/schemas/README.md b/spec/schemas/README.md index 9ee36f9f..d9b27976 100644 --- a/spec/schemas/README.md +++ b/spec/schemas/README.md @@ -1,18 +1,13 @@ # Relation Engine Document Schemas Document schemas define a required format for each collection in the database. Schemas use the -[JSON Schema](https://json-schema.org/specification.html) specification and follow the [JSON5 -format](https://json5.org/) +[JSON Schema](https://json-schema.org/specification.html) specification. ## Guidelines -- The filename should be the name of the collection that the schema applies to. -- All schemas should be in [JSON5 format](https://json5.org/) and follow the [JSON - Schema](https://json-schema.org/) specification. -- You can add reusable JSON schema definitions by placing them in the - [`./definitions`](/src/schemas/definitions) directory. -- When writing a new schema, also make a [migration script](/src/migrations) that can update the - database. +- Every schema file should have `name`, `type` ("vertex" or "edge"), and `schema` (JSON schema) fields +- Every JSON schema should have a "$schema" field +- You can add reusable JSON schema definitions by placing them in the [`./definitions`](/src/schemas/definitions) directory. ## Testing your schema format diff --git a/spec/schemas/edges/gtdb/gtdb_child_of_taxon.json b/spec/schemas/edges/gtdb/gtdb_child_of_taxon.json deleted file mode 100644 index b28d99fc..00000000 --- a/spec/schemas/edges/gtdb/gtdb_child_of_taxon.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "required": ["_from", "_to", "child_type"], - "description": "Edges which create the taxonomy tree for GTDB taxons.", - "properties": { - "_from": { - "type": "string", - "description": "The child. A gtdb_taxon or gtdb_organism." - }, - "_to": { - "type": "string", - "description": "The parent gtdb_taxon." - }, - "child_type": { - "type": "string", - "description": "type of child node (taxon or organism)", - "enum": [ "t", "o" ] - } - } -} - diff --git a/spec/schemas/edges/mash/README.md b/spec/schemas/edges/mash/README.md deleted file mode 100644 index bd2f0214..00000000 --- a/spec/schemas/edges/mash/README.md +++ /dev/null @@ -1 +0,0 @@ -# Mash homology diff --git a/spec/schemas/edges/mash/mash_genome_similar_to.json b/spec/schemas/edges/mash/mash_genome_similar_to.json deleted file mode 100644 index 78acd476..00000000 --- a/spec/schemas/edges/mash/mash_genome_similar_to.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "required": ["_from", "_to"], - "description": "The workspace object is similar to another object", - "properties": { - "_from": { - "type": "string", - "examples": ["wsprov_object/1:2:3"] - }, - "_to": { - "type": "string", - "examples": ["wsprov_object/1:2:3"] - } - } -} - - diff --git a/spec/schemas/edges/ncbi/ncbi_child_of_taxon.json b/spec/schemas/edges/ncbi/ncbi_child_of_taxon.json deleted file mode 100644 index 8b2254cd..00000000 --- a/spec/schemas/edges/ncbi/ncbi_child_of_taxon.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "required": ["_from", "_to", "child_type"], - "description": "Edges which create the taxonomy tree for NCBI taxons.", - "properties": { - "_from": { - "type": "string", - "description": "The child. A gtdb_taxon or gtdb_organism." - }, - "_to": { - "type": "string", - "description": "The parent gtdb_taxon." - }, - "child_type": { - "type": "string", - "description": "type of child node (taxon or organism)", - "enum": [ "t", "o" ] - } - } -} - diff --git a/spec/schemas/edges/ncbi/ncbi_gene_within_genome.json b/spec/schemas/edges/ncbi/ncbi_gene_within_genome.json deleted file mode 100644 index 1d706118..00000000 --- a/spec/schemas/edges/ncbi/ncbi_gene_within_genome.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "required": ["_from", "_to"], - "properties": { - "_from": { - "type": "string", - "description": "The ncbi_gene that is part of a genome." - }, - "_to": { - "type": "string", - "description": "The ncbi_genome that contains a gene." - } - } -} diff --git a/spec/schemas/edges/rxn/rxn_compound_linked_to_compound.json b/spec/schemas/edges/rxn/rxn_compound_linked_to_compound.json deleted file mode 100644 index 5008d405..00000000 --- a/spec/schemas/edges/rxn/rxn_compound_linked_to_compound.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "required": ["_from", "_to"], - "description": "Generally these linkages indicate a that one compound has been made obsolete and replaced with the linked compound. This may arise from duplicates in the database or errors in the obsolete entity", - "properties": { - "_from": { - "type": "string", - "description": "A reaction" - }, - "_to": { - "type": "string", - "description": "Another reaction" - } - } -} diff --git a/spec/schemas/edges/rxn/rxn_compound_within_reaction.json b/spec/schemas/edges/rxn/rxn_compound_within_reaction.json deleted file mode 100644 index d4bfd498..00000000 --- a/spec/schemas/edges/rxn/rxn_compound_within_reaction.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "required": ["_from", "_to"], - "description": "A compound is a memeber of a reaction", - "additionalProperties": true, - "properties": { - "_from": { - "type": "string", - "description": "The ID of the compound" - }, - "_to": { - "type": "string", - "description": "The ID of the reaction" - }, - "stoichiometry": { - "type": "number", - "description": "The stochiometry of compound in the reaction" - } - } -} - diff --git a/spec/schemas/edges/rxn/rxn_gene_within_complex.json b/spec/schemas/edges/rxn/rxn_gene_within_complex.json deleted file mode 100644 index 3c96f786..00000000 --- a/spec/schemas/edges/rxn/rxn_gene_within_complex.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "required": ["_from", "_to"], - "properties": { - "_from": { - "type": "string", - "description": "The ncbi_gene contained within a rxn_gene_complex." - }, - "_to": { - "type": "string", - "description": "The rxn_gene_complex that contains the gene." - } - } -} diff --git a/spec/schemas/edges/rxn/rxn_reaction_linked_to_reaction.json b/spec/schemas/edges/rxn/rxn_reaction_linked_to_reaction.json deleted file mode 100644 index 668db047..00000000 --- a/spec/schemas/edges/rxn/rxn_reaction_linked_to_reaction.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "required": ["_from", "_to"], - "description": "Generally these linkages indicate a that one reaction has been made obsolete and replaced with the linked reaction. This may arise from duplicates in the database or errors in the obsolete entity", - "properties": { - "_from": { - "type": "string", - "description": "A reaction" - }, - "_to": { - "type": "string", - "description": "Another reaction" - } - } -} diff --git a/spec/schemas/edges/rxn/rxn_reaction_within_complex.json b/spec/schemas/edges/rxn/rxn_reaction_within_complex.json deleted file mode 100644 index f7f55e88..00000000 --- a/spec/schemas/edges/rxn/rxn_reaction_within_complex.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "required": ["_from", "_to"], - "properties": { - "_from": { - "type": "string", - "description": "The rxn_reaction contained within a rxn_gene_complex." - }, - "_to": { - "type": "string", - "description": "The rxn_gene_complex that produces a reaction." - } - } -} diff --git a/spec/schemas/edges/rxn/rxn_similar_to_reaction.json b/spec/schemas/edges/rxn/rxn_similar_to_reaction.json deleted file mode 100644 index 6bb3f1e1..00000000 --- a/spec/schemas/edges/rxn/rxn_similar_to_reaction.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "required": ["_from", "_to"], - "description": "A generic similarity association.", - "additionalProperties": true, - "properties": { - "_from": { - "type": "string", - "description": "The ID of a vertex" - }, - "_to": { - "type": "string", - "description": "The ID of a vertex" - } - } -} - diff --git a/spec/schemas/edges/test_edge.json b/spec/schemas/edges/test_edge.json deleted file mode 100644 index 68a5fae7..00000000 --- a/spec/schemas/edges/test_edge.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "required": ["_from", "_to"], - "description": "Example edge schema for testing.", - "properties": { - "_from": {"type": "string"}, - "_to": {"type": "string"} - } -} - diff --git a/spec/schemas/edges/wsfull/wsfull_copied_from.json b/spec/schemas/edges/wsfull/wsfull_copied_from.json deleted file mode 100644 index 0ed1e87e..00000000 --- a/spec/schemas/edges/wsfull/wsfull_copied_from.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "required": ["_from", "_to"], - "description": "The _from object was created as an exact copy of the _to object.", - "properties": { - "_from": { "type": "string" }, - "_to": { "type": "string" } - } -} diff --git a/spec/schemas/edges/wsfull/wsfull_latest_version_of.json b/spec/schemas/edges/wsfull/wsfull_latest_version_of.json deleted file mode 100644 index cbfafb0c..00000000 --- a/spec/schemas/edges/wsfull/wsfull_latest_version_of.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "additionalProperties": false, - "required": ["_from", "_to"], - "properties": { - "_from": { - "type": "string", - "examples": [ - "wsfull_type_version/KBaseGenomes.Genome‑9.0", - "wsfull_module_version/kb_uploadmethods:8ebb66e4f2c27bc4a9b7cddff7d7b0f27f4ee433" - ], - "description": "A versioned entity, representing the most recent version of an entity in a group (most likely a workspace object, module, or workspace type)." - }, - "_to": { - "type": "string", - "examples": [ - "wsfull_type/KBaseGenomes.Genome", - "wsfull_module/kb_uploadmethods" - ], - "description": "The non-versioned entity group, where all members of the group are different versions of something (eg. a workspace object, module, or workspace type)" - } - } -} diff --git a/spec/schemas/edges/wsfull/wsfull_module_contains_method.json b/spec/schemas/edges/wsfull/wsfull_module_contains_method.json deleted file mode 100644 index 015d507a..00000000 --- a/spec/schemas/edges/wsfull/wsfull_module_contains_method.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "description": "A module contains an SDK method", - "required": ["_from", "_to"], - "properties": { - "_from": { - "type": "string", - "description": "The module ID." - }, - "_to": { - "type": "string", - "description": "The SDK method ID" - } - } -} - diff --git a/spec/schemas/edges/wsfull/wsfull_obj_created_with_method.json b/spec/schemas/edges/wsfull/wsfull_obj_created_with_method.json deleted file mode 100644 index 00e7a82d..00000000 --- a/spec/schemas/edges/wsfull/wsfull_obj_created_with_method.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "additionalProperties": false, - "required": ["_from", "_to", "method_params"], - "description": "The _from WS versioned object was created by the _to SDK versioned method.", - "properties": { - "_from": { - "type": "string", - "examples": ["wsfull_object_version/35414:73:1"], - "description": "A versioned workspace object." - }, - "_to": { - "type": "string", - "examples": [ - "wsfull_method_version/kb_uploadmethods:8ebb66e4f2c27bc4a9b7cddff7d7b0f27f4ee433.import_genbank_from_staging", - "wsfull_method_version/kb_uploadmethods:UNKNOWN.import_genbank_from_staging" - ], - "description": "A version of a module with a method." - }, - "method_params": { - "type": ["array", "object", "null"], - "description": "The input parameters for the method used to create the object." - } - } -} diff --git a/spec/schemas/edges/wsfull/wsfull_obj_created_with_module.json b/spec/schemas/edges/wsfull/wsfull_obj_created_with_module.json deleted file mode 100644 index 21b65cd7..00000000 --- a/spec/schemas/edges/wsfull/wsfull_obj_created_with_module.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "additionalProperties": false, - "required": ["_from", "_to"], - "description": "The _from WS versioned object was created with the _to SDK versioned module.", - "properties": { - "_from": { - "type": "string", - "description": "The WS versioned object that was created." - }, - "_to": { - "type": "string", - "description": "The SDK versioned module that created the object." - } - } -} - diff --git a/spec/schemas/edges/wsfull/wsfull_obj_instance_of_type.json b/spec/schemas/edges/wsfull/wsfull_obj_instance_of_type.json deleted file mode 100644 index 72ca7b6f..00000000 --- a/spec/schemas/edges/wsfull/wsfull_obj_instance_of_type.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "additionalProperties": false, - "required": ["_from", "_to"], - "description": "The _from WS versioned object is an instance of the _to versioned type.", - "properties": { - "_from": { "type": "string" }, - "_to": { "type": "string" } - } -} diff --git a/spec/schemas/edges/wsfull/wsfull_owner_of.json b/spec/schemas/edges/wsfull/wsfull_owner_of.json deleted file mode 100644 index c2086803..00000000 --- a/spec/schemas/edges/wsfull/wsfull_owner_of.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "additionalProperties": false, - "description": "The user is an owner of a workspace or type module.", - "required": ["_from", "_to"], - "properties": { - "_from": { - "type": "string", - "examples": [ - "wsfull_user/jjeffryes" - ], - "description": "A username" - }, - "_to": { - "type": "string", - "examples": [ - "wsfull_type_module/KBaseGenomes", - "wsfull_workspace/35414" - ], - "description": "A Workspace or Type Module" - } - } -} diff --git a/spec/schemas/edges/wsfull/wsfull_prov_descendant_of.json b/spec/schemas/edges/wsfull/wsfull_prov_descendant_of.json deleted file mode 100644 index efee5d01..00000000 --- a/spec/schemas/edges/wsfull/wsfull_prov_descendant_of.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "required": ["_from", "_to"], - "description": "The _from object is a provenance descendant of the _to object (eg. Assembly->Reads).", - "properties": { - "_from": { "type": "string" }, - "_to": { "type": "string" } - } -} - diff --git a/spec/schemas/edges/wsfull/wsfull_refers_to.json b/spec/schemas/edges/wsfull/wsfull_refers_to.json deleted file mode 100644 index e19ba75f..00000000 --- a/spec/schemas/edges/wsfull/wsfull_refers_to.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "required": ["_from", "_to"], - "description": "The _from object has a reference to the _to object (eg. Genome->Assembly).", - "properties": { - "_from": { "type": "string" }, - "_to": { "type": "string" } - } -} diff --git a/spec/schemas/edges/wsfull/wsfull_type_consumed_by_method.json b/spec/schemas/edges/wsfull/wsfull_type_consumed_by_method.json deleted file mode 100644 index d85da19c..00000000 --- a/spec/schemas/edges/wsfull/wsfull_type_consumed_by_method.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "required": ["_from", "_to"], - "description": "The _from type is consumed by the _to SDK method", - "additionalProperties": true, - "properties": { - "_from": { - "type": "string", - "description": "The ID of the type that is consumed." - }, - "_to": { - "type": "string", - "description": "The ID of the SDK method that consumes the type." - } - } -} - - diff --git a/spec/schemas/edges/wsfull/wsfull_version_of.json b/spec/schemas/edges/wsfull/wsfull_version_of.json deleted file mode 100644 index fabb66c2..00000000 --- a/spec/schemas/edges/wsfull/wsfull_version_of.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "additionalProperties": false, - "description": "The _from entity is a version of a the _to entity (eg. type, method, module).", - "required": ["_from", "_to"], - "properties": { - "_from": { - "type": "string", - "examples": [ - "wsfull_type_version/KBaseGenomes.Genome‑9.0", - "wsfull_method_version/kb_uploadmethods:8ebb66e4f2c27bc4a9b7cddff7d7b0f27f4ee433" - ], - "description": "A versioned entity (eg. a workspace object, module, or workspace type)" - }, - "_to": { - "type": "string", - "examples": [ - "wsfull_type/KBaseGenomes.Genome", - "wsfull_method/kb_uploadmethods" - ], - "description": "The non-versioned entity group, where all members of the group are different versions of something (eg. a workspace object, module, or workspace type)." - }, - "tag": { - "type": "string", - "description": "Tags for entities managed by catalog", - "enum": ["release", "beta", "dev"] - } - } -} diff --git a/spec/schemas/edges/wsfull/wsfull_ws_contains_obj.json b/spec/schemas/edges/wsfull/wsfull_ws_contains_obj.json deleted file mode 100644 index be657c29..00000000 --- a/spec/schemas/edges/wsfull/wsfull_ws_contains_obj.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "description": "A workspace contains an object", - "required": ["_from", "_to"], - "properties": { - "_from": { - "type": "string", - "description": "The ID of the workspace" - }, - "_to": { - "type": "string", - "description": "The ID of the object" - } - } -} - diff --git a/spec/schemas/edges/wsfull/wsfull_ws_perm.json b/spec/schemas/edges/wsfull/wsfull_ws_perm.json deleted file mode 100644 index 75ecaf6c..00000000 --- a/spec/schemas/edges/wsfull/wsfull_ws_perm.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "description": "The user has permissions on a workspace.", - "required": ["_from", "_to", "perm"], - "properties": { - "perm": { - "type": "string", - "enum": ["a", "w", "r"], - "title": "Permissions", - "description": "Represents the permissions a user has on a workspace, where 'a' is 'administrator', 'w' is read/write, 'r' is readonly." - }, - "_from": { - "type": "string", - "examples": [ - "wsfull_user/jjeffryes" - ], - "description": "A username" - }, - "_to": { - "type": "string", - "examples": [ - "wsfull_workspace/35414" - ], - "description": "A workspace" - } - } -} diff --git a/spec/schemas/edges/wsprov/wsprov_copied_into.json b/spec/schemas/edges/wsprov/wsprov_copied_into.json deleted file mode 100644 index 908000bd..00000000 --- a/spec/schemas/edges/wsprov/wsprov_copied_into.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "required": ["_from", "_to"], - "description": "The object was copied into another object", - "properties": { - "_from": { - "type": "string", - "examples": ["wsprov_object/1:2:3"] - }, - "_to": { - "type": "string", - "examples": ["wsprov_object/1:2:3"] - } - } -} - diff --git a/spec/schemas/edges/wsprov/wsprov_input_in.json b/spec/schemas/edges/wsprov/wsprov_input_in.json deleted file mode 100644 index 100a5323..00000000 --- a/spec/schemas/edges/wsprov/wsprov_input_in.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "required": ["_from", "_to"], - "description": "The workspace object was input in a provenance action", - "properties": { - "_from": { - "type": "string", - "examples": ["wsprov_object/1:2:3"] - }, - "_to": { - "type": "string", - "examples": ["wsprov_action/1:2:3"] - } - } -} - - diff --git a/spec/schemas/edges/wsprov/wsprov_links.json b/spec/schemas/edges/wsprov/wsprov_links.json deleted file mode 100644 index 4f8e807c..00000000 --- a/spec/schemas/edges/wsprov/wsprov_links.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "required": ["_from", "_to"], - "description": "The object is linked to another object, through references, provenance, etc", - "properties": { - "_from": { - "type": "string", - "examples": ["wsprov_object/1:2:3"] - }, - "_to": { - "type": "string", - "examples": ["wsprov_object/1:2:3"] - } - } -} - diff --git a/spec/schemas/edges/wsprov/wsprov_produced.json b/spec/schemas/edges/wsprov/wsprov_produced.json deleted file mode 100644 index 6bd39904..00000000 --- a/spec/schemas/edges/wsprov/wsprov_produced.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "required": ["_from", "_to"], - "description": "The provenance action produced the workspace object", - "properties": { - "_from": { - "type": "string", - "examples": ["wsprov_action/1:2:3"] - }, - "_to": { - "type": "string", - "examples": ["wsprov_object/1:2:3"] - } - } -} diff --git a/spec/schemas/edges/gtdb/README.md b/spec/schemas/gtdb/README.md similarity index 100% rename from spec/schemas/edges/gtdb/README.md rename to spec/schemas/gtdb/README.md diff --git a/spec/schemas/gtdb/gtdb_child_of_taxon.yaml b/spec/schemas/gtdb/gtdb_child_of_taxon.yaml new file mode 100644 index 00000000..47f3bff2 --- /dev/null +++ b/spec/schemas/gtdb/gtdb_child_of_taxon.yaml @@ -0,0 +1,18 @@ +name: gtdb_child_of_taxon +type: edge +schema: + "$schema": http://json-schema.org/draft-07/schema# + type: object + required: [_from, _to, child_type] + description: Edges which create the taxonomy tree for GTDB taxons. + properties: + _from: + type: string + description: The child. A gtdb_taxon or gtdb_organism. + _to: + type: string + description: The parent gtdb_taxon. + child_type: + type: string + description: type of child node (taxon or organism) + enum: [t, o] diff --git a/spec/schemas/gtdb/gtdb_organism.yaml b/spec/schemas/gtdb/gtdb_organism.yaml new file mode 100644 index 00000000..4204e82a --- /dev/null +++ b/spec/schemas/gtdb/gtdb_organism.yaml @@ -0,0 +1,14 @@ +name: gtdb_organism +type: vertex +schema: + "$schema": http://json-schema.org/draft-07/schema# + type: object + description: An organism in the GTDB taxonomy tree. + required: [_key] + properties: + _key: + type: string + description: Accession ID (Refseq prefixed with 'RS_' and Genbank prefixed with 'GB_'). + examples: + - RS_GCF_001300075.1 + - GB_GCA_002387705.1 diff --git a/spec/schemas/gtdb/gtdb_taxon.yaml b/spec/schemas/gtdb/gtdb_taxon.yaml new file mode 100644 index 00000000..41808d29 --- /dev/null +++ b/spec/schemas/gtdb/gtdb_taxon.yaml @@ -0,0 +1,34 @@ +name: gtdb_taxon +type: vertex +schema: + "$schema": http://json-schema.org/draft-07/schema# + type: object + description: Template for a vertex entry in the GTDB taxonomy tree. + required: [_key, scientific_name, rank] + properties: + _key: + type: string + description: Taxon type abbreviation plus name + examples: ['d:Bacteria', 'p:Firmicutes'] + scientific_name: + type: string + title: Taxon name. + examples: + - Methylophilus methylotrophus + - Bacteria + - Firmicutes + canonical_scientific_name: + type: array + title: Canonicalized scientific name + examples: [[methylophilus, methylotrophus], [Bacteria], [Firmicutes]] + items: {type: string} + rank: + type: string + title: Taxonomic rank + examples: [Domain, Phylum] + numeric_rank: + type: integer + title: Taxonomic level + genetic_code: + type: integer + title: genetic code diff --git a/spec/schemas/mash/mash_genome_similar_to.yaml b/spec/schemas/mash/mash_genome_similar_to.yaml new file mode 100644 index 00000000..445e23c3 --- /dev/null +++ b/spec/schemas/mash/mash_genome_similar_to.yaml @@ -0,0 +1,14 @@ +name: mash_genome_similar_to +type: edge +schema: + "$schema": http://json-schema.org/draft-07/schema# + type: object + required: [_from, _to] + description: The workspace object is similar to another object + properties: + _from: + type: string + examples: ["wsprov_object/1:2:3"] + _to: + type": string + examples": ["wsprov_object/1:2:3"] diff --git a/spec/schemas/edges/ncbi/README.md b/spec/schemas/ncbi/README.md similarity index 100% rename from spec/schemas/edges/ncbi/README.md rename to spec/schemas/ncbi/README.md diff --git a/spec/schemas/ncbi/ncbi_child_of_taxon.yaml b/spec/schemas/ncbi/ncbi_child_of_taxon.yaml new file mode 100644 index 00000000..44b0cdf3 --- /dev/null +++ b/spec/schemas/ncbi/ncbi_child_of_taxon.yaml @@ -0,0 +1,18 @@ +name: ncbi_child_of_taxon +type: edge +schema: + "$schema": http://json-schema.org/draft-07/schema# + type: object + required: [_from, _to, child_type] + description: Edges which create the taxonomy tree for NCBI taxons. + properties: + _from: + type: string + description: The child. A gtdb_taxon or gtdb_organism. + _to: + type: string + description: The parent gtdb_taxon + child_type: + type: string + description: type of child node (taxon or organism) + enum: [t, o] diff --git a/spec/schemas/ncbi/ncbi_gene.yaml b/spec/schemas/ncbi/ncbi_gene.yaml new file mode 100644 index 00000000..3eef69df --- /dev/null +++ b/spec/schemas/ncbi/ncbi_gene.yaml @@ -0,0 +1,85 @@ +name: ncbi_gene +type: vertex +schema: + "$schema": http://json-schema.org/draft-07/schema# + type: object + additionalProperties: false + description: A component of a DNA sequence, such as a CDS, mRNA, etc. + required: [_key, type, location] + properties: + _key: + type: string + title: Content hash + description: Hash of the DNA sequence for this feature. + protein_translation: + type: string + title: Protein translation + description: Longest coded protein (representative protein for splice variants) + protein_translation_length: + type: integer + description: Length of protein_translation + md5_hash: + type: string + title: DNA content hash + description: md5 hash of the dna sequence that this feature encodes. + note: + type: string + description: Free-text description of this feature + functions: + type: array + title: Gene functions + items: {type: string} + functional_descriptions: + type: array + title: Gene function descriptions + items: {type: string} + type: + type: string + examples: [Gene, ncRNA, repeat, CDS, mRNA] + location: + type: array + description: A list of segments of sequence that comprise this feature + items: + contig: + type: string + description: Contig ID where this segment occurs + strand: + type: string + description: Strand where this segment occurs + enum: [+, -, ?] + start: + type: integer + description: Index in the genome sequence where this segment of the feature starts + length: + type: integer + description: Length of this segment of the feature + flags: + type: array + description: Additional flags about the feature such trans_splicing + items: {type: string} + warnings: + type: array + description: Warnings generated by the uploader about this feature + items: {type: string} + dna_sequence: + type: string + description: Nucleotide sequence for this feature. + dna_sequence_length: + type: integer + description: Total character/nucleotide length of dna_sequence + db_xrefs: + title: Database cross-references + description: IDs for these feature in other databases, grouped by database + type: object + patternProperties: + ".*": + type: array + items: {type: string} + aliases: + description: Aliases for these feature, grouped by alias type + type: object + description: All values are arrays of strings + patternProperties: + ".*": + type: array + items: {type: string} diff --git a/spec/schemas/ncbi/ncbi_gene_within_genome.yaml b/spec/schemas/ncbi/ncbi_gene_within_genome.yaml new file mode 100644 index 00000000..1d897984 --- /dev/null +++ b/spec/schemas/ncbi/ncbi_gene_within_genome.yaml @@ -0,0 +1,13 @@ +name: ncbi_gene_within_genome +type: edge +schema: + "$schema": http://json-schema.org/draft-07/schema# + type: object + required: [_from, _to] + properties: + _from: + type: string + description: The ncbi_gene that is part of a genome. + _to: + type: string + description: The ncbi_genome that contains a gene. diff --git a/spec/schemas/ncbi/ncbi_genome.yaml b/spec/schemas/ncbi/ncbi_genome.yaml new file mode 100644 index 00000000..c22bb697 --- /dev/null +++ b/spec/schemas/ncbi/ncbi_genome.yaml @@ -0,0 +1,100 @@ +name: ncbi_genome +type: vertex +schema: + "$schema": http://json-schema.org/draft-07/schema# + type: object + additionalProperties: false + description: Whole-genome metadata (genes are separate vertices) + required: + - _key + - scientific_name + - domain + properties: + _key: + type: string + description: Hash of the full set of data contained in this genome. + refseq_id: + type: string + examples: + - NC_008270.1 + description: RefSeq database accession id + scientific_name: + type: string + examples: + - Haloferax Volcanii + domain: + type: string + enum: + - Archaea + - Bacteria + - Eukarya + - Unknown + feature_counts: + type: object + additionalProperties: true + description: A count of the number of instances of each feature type such as CDSs, + repeats etc. + patternProperties: + ".*": + type: integer + dna_size: + type: integer + title: Nucleotide count + num_contigs: + type: integer + title: Number of contigs + description: Number of consensus regions of the DNA. + molecule_type: + type: string + title: Molecule type + examples: + - DNA + description: Can include genomic DNA, genomic RNA, precursor RNA, mRNA (cDNA), + ribosomal RNA, transfer RNA, small nuclear RNA, and small cytoplasmic RNA + contig_lengths: + type: array + description: Nucleotide length of each contig + items: + type: integer + contig_ids: + type: array + description: The ids of each contig in the associated assembly + items: + type: string + source: + type: string + description: The tool or database that produced the genome + examples: + - RefSeq + - Ensembl + - Phytozome + - RAST + - Prokka + - User_upload + source_id: + type: string + description: The ID assigned the to the genome by that source + release: + type: string + description: The release version of the source database for this genome if applicable + taxonomy: + type: array + description: Full taxonomy parent-to-child linkage up to the domain + examples: + - - Bacteria + - Actinobacteria + - Corynebacteriales + - Nocardiaceae + - Rhodococcus + items: + type: string + gc_content: + type: number + description: Fraction of GC pairs in the genome + is_suspect: + type: boolean + description: Flag indicating that the genome has failed to pass one or more validation + tests + notes: + type: string + description: Free text notes from the genome upload diff --git a/spec/schemas/ncbi/ncbi_taxon.yaml b/spec/schemas/ncbi/ncbi_taxon.yaml new file mode 100644 index 00000000..e92cce68 --- /dev/null +++ b/spec/schemas/ncbi/ncbi_taxon.yaml @@ -0,0 +1,104 @@ +name: ncbi_taxon +type: vertex +schema: + "$schema": http://json-schema.org/draft-07/schema# + type: object + description: Template for a vertex entry in the NCBI taxonomy tree. + required: + - _key + - scientific_name + - rank + properties: + _key: + type: string + description: NCBI Taxon id (positive integer) + examples: + - '1' + - '2053699' + scientific_name: + type: string + title: Taxon name. + examples: + - Methylophilus methylotrophus + - Bacteria + - Firmicutes + canonical_scientific_name: + type: array + title: Canonicalized scientific name + examples: + - - methylophilus + - methylotrophus + - - Bacteria + - - Firmicutes + items: + type: string + aliases: + type: array + description: Aliases + examples: + - - category: authority + name: Borreliella burgdorferi (Johnson et al. 1984) Adeolu and Gupta 2015 + canonical: + - borreliella + - burgdorferi + - johnson + - adeolu + - gupta + - category: genbank common name + name: Lyme disease spirochet + canonical: + - lyme + - disease + - spirochet + - category: synonym + name: Borrelia burgdorferi + canonical: + - borrelia + - burgdorferi + - - category: common name + name: E. coli + canonical: + - e + - coli + - category: authority + name: '"Bacterium coli commune" Escherich 1885' + canonical: + - bacterium + - coli + - commune + - escherich + - category: synonym + name: Bacterium coli + canonical: + - bacterium + - coli + items: + type: object + required: + - category + - name + - canonical + properties: + category: + type: string + name: + type: string + canonical: + type: array + items: + type: string + rank: + type: string + title: Taxonomic rank + examples: + - Domain + - Phylum + numeric_rank: + type: integer + title: Taxonomic level + NCBI_taxon_id: + type: integer + title: NCBI_taxon_id + genetic_code: + type: integer + title: genetic code diff --git a/spec/schemas/edges/rxn/README.md b/spec/schemas/rxn/README.md similarity index 100% rename from spec/schemas/edges/rxn/README.md rename to spec/schemas/rxn/README.md diff --git a/spec/schemas/rxn/rxn_compound.yaml b/spec/schemas/rxn/rxn_compound.yaml new file mode 100644 index 00000000..216f0c0f --- /dev/null +++ b/spec/schemas/rxn/rxn_compound.yaml @@ -0,0 +1,70 @@ +name: rxn_compound +type: vertex +schema: + "$schema": "http://json-schema.org/draft-07/schema#" + type: object + additionalProperties: true + description: Chemical reactions + required: [_key] + properties: + _key: + examples: [cpd02201] + pattern: ^cpd\d+$ + title: ModelSeed ID + type: string + abbreviation: + examples: [phpyr] + type: string + aliases: + examples: ["AraCyc:PYRUVATE;BiGG:pyr;BrachyCyc:PYRUVATE;KEGG:C00022"] + type: string + charge: + examples: ['-1'] + type: integer + deltag: + description: The change in Free Energy of Formation + type: [number, 'null'] + deltagerr: + description: The error associated with the Free Energy of Formation + type: [number, 'null'] + formula: + examples: [C6H6] + type: string + id: + examples: [cpd02201] + pattern: ^cpd\d+$ + title: ModelSeed ID + type: string + inchikey: + examples: [LCTONWCANYUPML-UHFFFAOYSA-M] + type: string + is_cofactor: + description: The compound is a cofactor + type: integer + is_core: + description: The compound is involved in core metabolism + type: integer + is_obsolete: + description: The compound is a deprecated + type: integer + linked_compound: + description: If the compound is deprecated, the compound that supersedes this entry + type: [string, 'null'] + mass: + description: Molecular mass of compound + type: [number, 'null'] + name: + type: string + pka: + description: Acid dissociation constants of compound + type: string + pkb: + description: Base dissociation constants of compound + type: string + smiles: + description: Structure of the compound in Simplified Molecular Input Line Entry + System + type: string + source: + description: Does this compound come from a primary database or a metabolic model? + type: string diff --git a/spec/schemas/rxn/rxn_compound_linked_to_compound.yaml b/spec/schemas/rxn/rxn_compound_linked_to_compound.yaml new file mode 100644 index 00000000..6fbb3bea --- /dev/null +++ b/spec/schemas/rxn/rxn_compound_linked_to_compound.yaml @@ -0,0 +1,16 @@ +name: rxn_compound_linked_to_compound +type: edge +schema: + "$schema": "http://json-schema.org/draft-07/schema#" + type: object + required: [_from, _to] + description: Generally these linkages indicate a that one compound has been made obsolete + and replaced with the linked compound. This may arise from duplicates in the database + or errors in the obsolete entity + properties: + _from: + type: string + description: A reaction + _to: + type: string + description: Another reaction diff --git a/spec/schemas/rxn/rxn_compound_within_reaction.yaml b/spec/schemas/rxn/rxn_compound_within_reaction.yaml new file mode 100644 index 00000000..3211e562 --- /dev/null +++ b/spec/schemas/rxn/rxn_compound_within_reaction.yaml @@ -0,0 +1,18 @@ +name: rxn_compound_within_reaction +type: edge +schema: + "$schema": "http://json-schema.org/draft-07/schema#" + type: object + required: [_from, _to] + description: A compound is a member of a reaction + additionalProperties: true + properties: + _from: + type: string + description: The ID of the compound + _to: + type: string + description: The ID of the reaction + stoichiometry: + type: number + description: The stochiometry of compound in the reaction diff --git a/spec/schemas/rxn/rxn_gene_complex.yaml b/spec/schemas/rxn/rxn_gene_complex.yaml new file mode 100644 index 00000000..1202772f --- /dev/null +++ b/spec/schemas/rxn/rxn_gene_complex.yaml @@ -0,0 +1,24 @@ +name: rxn_gene_complex +type: vertex +schema: + "$schema": "http://json-schema.org/draft-07/schema#" + type: object + additionalProperties: false + description: Groups of genes that take part in producing a chemical reaction in the + cell. + required: [_key, genes] + properties: + _key: + type: string + description: Hash of the conjunctions. + genes: + type: array + examples: [[SO_0001, SO_0001]] + description: Array of genes. + items: + type: string + description: Gene vertex _key + source: + type: string + examples: [ModelSEED, KEGG] + description: The source of the gene complex information. diff --git a/spec/schemas/rxn/rxn_gene_within_complex.yaml b/spec/schemas/rxn/rxn_gene_within_complex.yaml new file mode 100644 index 00000000..04ba6f32 --- /dev/null +++ b/spec/schemas/rxn/rxn_gene_within_complex.yaml @@ -0,0 +1,13 @@ +name: rxn_gene_within_complex +type: edge +schema: + "$schema": "http://json-schema.org/draft-07/schema#" + type: object + required: [_from, _to] + properties: + _from: + type: string + description: The ncbi_gene contained within a rxn_gene_complex. + _to: + type: string + description: The rxn_gene_complex that contains the gene. diff --git a/spec/schemas/rxn/rxn_reaction.yaml b/spec/schemas/rxn/rxn_reaction.yaml new file mode 100644 index 00000000..a8af663c --- /dev/null +++ b/spec/schemas/rxn/rxn_reaction.yaml @@ -0,0 +1,53 @@ +name: rxn_reaction +type: vertex +schema: + "$schema": "http://json-schema.org/draft-07/schema#" + type: object + additionalProperties: true + required: [_key] + description: Chemical reactions + properties: + _key: + type: string + examples: [rxn02201] + title: ModelSeed ID + pattern: "^rxn\\d+$" + direction: + type: string + enum: [">", "<", "="] + name: + type: string + description: Chemical names + examples: ["trans-2-Methyl-5-isopropylhexa-2,5-dienal dehydrogenase_c0"] + gpr: + type: string + examples: [PGN_RS01070] + ec_number: + type: string + examples: ["2.7.3.7"] + title: Enzyme Commission Number + pattern: "^\\d+\\.\\d+\\.\\d+\\.\\d+$" + bbcwn: + type: number + examples: [-108] + equation: + type: string + description: Reaction formula using compound IDs (eg. cd00443) + examples: + - "(1) cpd00443[c0] + (1) cpd02920[c0] => (1) cpd00012[c0] + (1) cpd00067[c0] + (1) cpd00683[c0]" + definition: + type: string + description: Reaction formula. Same as equation, but with compound IDs replaced with chemical names. + bigg_id: + type: string + examples: [DHPS2] + kegg_id: + type: string + examples: [R03067] + kegg_pathways: + type: string + examples: ["Folate biosynthesis"] + metacyc_pathways: + type: array + items: {type: string} + examples: [["AMINE-DEG", "Creatinine-Degradation", "Degradation"]] diff --git a/spec/schemas/rxn/rxn_reaction_linked_to_reaction.yaml b/spec/schemas/rxn/rxn_reaction_linked_to_reaction.yaml new file mode 100644 index 00000000..44a78778 --- /dev/null +++ b/spec/schemas/rxn/rxn_reaction_linked_to_reaction.yaml @@ -0,0 +1,17 @@ +name: rxn_reaction_linked_to_reaction +type: edge +schema: + "$schema": "http://json-schema.org/draft-07/schema#" + type: object + required: [_from, _to] + description: | + Generally these linkages indicate a that one reaction has been made obsolete + and replaced with the linked reaction. This may arise from duplicates in the database + or errors in the obsolete entity + properties: + _from: + type: string + description: A reaction + _to: + type: string + description: Another reaction diff --git a/spec/schemas/rxn/rxn_reaction_within_complex.yaml b/spec/schemas/rxn/rxn_reaction_within_complex.yaml new file mode 100644 index 00000000..41706aab --- /dev/null +++ b/spec/schemas/rxn/rxn_reaction_within_complex.yaml @@ -0,0 +1,13 @@ +name: rxn_reaction_within_complex +type: edge +schema: + "$schema": "http://json-schema.org/draft-07/schema#" + type: object + required: [_from, _to] + properties: + _from: + type: string + description: The rxn_reaction contained within a rxn_gene_complex. + _to: + type: string + description: The rxn_gene_complex that produces a reaction. diff --git a/spec/schemas/rxn/rxn_similar_to_reaction.yaml b/spec/schemas/rxn/rxn_similar_to_reaction.yaml new file mode 100644 index 00000000..fb13b090 --- /dev/null +++ b/spec/schemas/rxn/rxn_similar_to_reaction.yaml @@ -0,0 +1,15 @@ +name: rxn_similar_to_reaction +type: edge +schema: + "$schema": "http://json-schema.org/draft-07/schema#" + type: object + required: [_from, _to] + description: A generic similarity association between rections. + additionalProperties: true + properties: + _from: + type: string + description: The ID of a vertex + _to: + type: string + description: The ID of a vertex diff --git a/spec/schemas/test/test_edge.yaml b/spec/schemas/test/test_edge.yaml new file mode 100644 index 00000000..fab7ad6e --- /dev/null +++ b/spec/schemas/test/test_edge.yaml @@ -0,0 +1,10 @@ +name: test_edge +type: edge +schema: + "$schema": "http://json-schema.org/draft-07/schema#" + type: object + required: [_from, _to] + description: Example edge schema for testing. + properties: + _from: {type: string} + _to: {type: string} diff --git a/spec/schemas/test/test_vertex.yaml b/spec/schemas/test/test_vertex.yaml new file mode 100644 index 00000000..b2d34668 --- /dev/null +++ b/spec/schemas/test/test_vertex.yaml @@ -0,0 +1,11 @@ +name: test_vertex +type: vertex +schema: + "$schema": "http://json-schema.org/draft-07/schema#" + type: object + required: [_key] + description: An example vertex schema for testing + properties: + _key: {type: string} + is_public: {type: boolean} + ws_id: {type: integer} diff --git a/spec/schemas/vertices/README.md b/spec/schemas/vertices/README.md deleted file mode 100644 index 0bc58d97..00000000 --- a/spec/schemas/vertices/README.md +++ /dev/null @@ -1 +0,0 @@ -# Relation engine vertices diff --git a/spec/schemas/vertices/gtdb/README.md b/spec/schemas/vertices/gtdb/README.md deleted file mode 100644 index 05d97d6c..00000000 --- a/spec/schemas/vertices/gtdb/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# Genome Taxonomy Database - -KBase Relation Engine schemas for GTDB taxonomy data - -References: - -* http://gtdb.ecogenomic.org/ diff --git a/spec/schemas/vertices/gtdb/gtdb_organism.json b/spec/schemas/vertices/gtdb/gtdb_organism.json deleted file mode 100644 index 01881fb8..00000000 --- a/spec/schemas/vertices/gtdb/gtdb_organism.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "description": "An organism in the GTDB taxonomy tree.", - "required": ["_key"], - "properties": { - "_key": { - "type": "string", - "description": "Accession ID (Refseq prefixed with 'RS_' and Genbank prefixed with 'GB_').", - "examples": ["RS_GCF_001300075.1", "GB_GCA_002387705.1"] - } - } -} diff --git a/spec/schemas/vertices/gtdb/gtdb_taxon.json b/spec/schemas/vertices/gtdb/gtdb_taxon.json deleted file mode 100644 index 3c1ad682..00000000 --- a/spec/schemas/vertices/gtdb/gtdb_taxon.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "description": "Template for a vertex entry in the GTDB taxonomy tree.", - "required": ["_key", "scientific_name", "rank"], - "properties": { - "_key": { - "type": "string", - "description": "Taxon type abbreviation plus name", - "examples": ["d:Bacteria", "p:Firmicutes"] - }, - "scientific_name": { - "type": "string", - "title": "Taxon name.", - "examples": ["Methylophilus methylotrophus", "Bacteria", "Firmicutes"] - }, - "canonical_scientific_name": { - "type": "array", - "title": "Canonicalized scientific name", - "examples": [ [ "methylophilus", "methylotrophus" ], - ["Bacteria"], - ["Firmicutes"] - ], - "items": { "type": "string" } - }, - "rank": { - "type": "string", - "title": "Taxonomic rank", - "examples": ["Domain", "Phylum"] - }, - "numeric_rank": { - "type": "integer", - "title": "Taxonomic level" - }, - "genetic_code": { - "type": "integer", - "title": "genetic code" - } - } -} diff --git a/spec/schemas/vertices/ncbi/README.md b/spec/schemas/vertices/ncbi/README.md deleted file mode 100644 index d5dabfab..00000000 --- a/spec/schemas/vertices/ncbi/README.md +++ /dev/null @@ -1 +0,0 @@ -# NCBI genbank data diff --git a/spec/schemas/vertices/ncbi/ncbi_gene.json b/spec/schemas/vertices/ncbi/ncbi_gene.json deleted file mode 100644 index 751a6eae..00000000 --- a/spec/schemas/vertices/ncbi/ncbi_gene.json +++ /dev/null @@ -1,114 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "additionalProperties": false, - "description": "A component of a DNA sequence, such as a CDS, mRNA, etc.", - "required": [ - "_key", - "type", - "location" - ], - "properties": { - "_key": { - "type": "string", - "title": "Content hash", - "description": "Hash of the DNA sequence for this feature." - }, - "protein_translation": { - "type": "string", - "title": "Protein translation", - "description": "Longest coded protein (representative protein for splice variants)" - }, - "protein_translation_length": { - "type": "integer", - "description": "Length of protein_translation" - }, - "md5_hash": { - "type": "string", - "title": "DNA content hash", - "description": "md5 hash of the dna sequence that this feature encodes." - }, - "note": { - "type": "string", - "description": "Free-text description of this feature" - }, - "functions": { - "type": "array", - "title": "Gene functions", - "items": {"type": "string"} - }, - "functional_descriptions": { - "type": "array", - "title": "Gene function descriptions", - "items": {"type": "string"} - }, - "type": { - "type": "string", - "examples": ["Gene", "ncRNA", "repeat", "CDS", "mRNA"] - }, - "location": { - "type": "array", - "description": "A list of segments of sequence that comprise this feature", - "items": { - "contig": { - "type": "string", - "description": "Contig ID where this segment occurs" - }, - "strand": { - "type": "string", - "description": "Strand where this segment occurs", - "enum": ["+", "-", "?"] - }, - "start": { - "type": "integer", - "description": "Index in the genome sequence where this segment of the feature starts" - }, - "length": { - "type": "integer", - "description": "Length of this segment of the feature" - } - } - }, - "flags": { - "type": "array", - "description": "Additional flags about the feature such trans_splicing", - "items": {"type": "string"} - }, - "warnings": { - "type": "array", - "description": "Warnings generated by the uploader about this feature", - "items": {"type": "string"} - }, - "dna_sequence": { - "type": "string", - "description": "Nucleotide sequence for this feature." - }, - "dna_sequence_length": { - "type": "integer", - "description": "Total character/nucleotide length of dna_sequence" - }, - "db_xrefs": { - "title": "Database cross-references", - "description": "IDs for these feature in other databases, grouped by database", - "type": "object", - "patternProperties": { - ".*": { - "type": "array", - "items": {"type": "string"} - } - } - }, - "aliases": { - "description": "Aliases for these feature, grouped by alias type", - "type": "object", - "description": "All values are arrays of strings", - "patternProperties": { - ".*": { - "type": "array", - "items": {"type": "string"} - } - } - } - } -} - diff --git a/spec/schemas/vertices/ncbi/ncbi_genome.json b/spec/schemas/vertices/ncbi/ncbi_genome.json deleted file mode 100644 index 61f9ec73..00000000 --- a/spec/schemas/vertices/ncbi/ncbi_genome.json +++ /dev/null @@ -1,97 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "additionalProperties": false, - "description": "Whole-genome metadata (genes are separate vertices)", - "required": [ - "_key", - "scientific_name", - "domain" - ], - "properties": { - "_key": { - "type": "string", - "description": "Hash of the full set of data contained in this genome." - }, - "refseq_id": { - "type": "string", - "examples": ["NC_008270.1"], - "description": "RefSeq database accession id" - }, - "scientific_name": { - "type": "string", - "examples": ["Haloferax Volcanii"] - }, - "domain": { - "type": "string", - "enum": ["Archaea", "Bacteria", "Eukarya", "Unknown"] - }, - "feature_counts": { - "type": "object", - "additionalProperties": true, - "description": "A count of the number of instances of each feature type such as CDSs, repeats etc.", - "patternProperties": { - ".*": {"type": "integer"} - } - }, - "dna_size": { - "type": "integer", - "title": "Nucleotide count" - }, - "num_contigs": { - "type": "integer", - "title": "Number of contigs", - "description": "Number of consensus regions of the DNA." - }, - "molecule_type": { - "type": "string", - "title": "Molecule type", - "examples": ["DNA"], - "description": "Can include genomic DNA, genomic RNA, precursor RNA, mRNA (cDNA), ribosomal RNA, transfer RNA, small nuclear RNA, and small cytoplasmic RNA" - }, - "contig_lengths": { - "type": "array", - "description": "Nucleotide length of each contig", - "items": {"type": "integer"} - }, - "contig_ids": { - "type": "array", - "description": "The ids of each contig in the associated assembly", - "items": {"type": "string"} - }, - "source": { - "type": "string", - "description": "The tool or database that produced the genome", - "examples": ["RefSeq", "Ensembl", "Phytozome", "RAST", "Prokka", "User_upload"] - }, - "source_id": { - "type": "string", - "description": "The ID assigned the to the genome by that source" - }, - "release": { - "type": "string", - "description": "The release version of the source database for this genome if applicable" - }, - "taxonomy": { - "type": "array", - "description": "Full taxonomy parent-to-child linkage up to the domain", - "examples": [["Bacteria", "Actinobacteria", "Corynebacteriales", "Nocardiaceae", "Rhodococcus"]], - "items": { - "type": "string" - } - }, - "gc_content": { - "type": "number", - "description": "Fraction of GC pairs in the genome" - }, - "is_suspect": { - "type": "boolean", - "description": "Flag indicating that the genome has failed to pass one or more validation tests" - }, - "notes": { - "type": "string", - "description": "Free text notes from the genome upload" - } - } -} - diff --git a/spec/schemas/vertices/ncbi/ncbi_taxon.json b/spec/schemas/vertices/ncbi/ncbi_taxon.json deleted file mode 100644 index 08530851..00000000 --- a/spec/schemas/vertices/ncbi/ncbi_taxon.json +++ /dev/null @@ -1,81 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "description": "Template for a vertex entry in the NCBI taxonomy tree.", - "required": ["_key", "scientific_name", "rank"], - "properties": { - "_key": { - "type": "string", - "description": "NCBI Taxon id (positive integer)", - "examples": ["1", "2053699"] - }, - "scientific_name": { - "type": "string", - "title": "Taxon name.", - "examples": ["Methylophilus methylotrophus", "Bacteria", "Firmicutes"] - }, - "canonical_scientific_name": { - "type": "array", - "title": "Canonicalized scientific name", - "examples": [ [ "methylophilus", "methylotrophus" ], - ["Bacteria"], - ["Firmicutes"] - ], - "items": { "type": "string" } - }, - "aliases": { - "type": "array", - "description": "Aliases", - "examples": [ - [ {"category": "authority", - "name": "Borreliella burgdorferi (Johnson et al. 1984) Adeolu and Gupta 2015", - "canonical": ["borreliella", "burgdorferi", "johnson", "adeolu", "gupta" ]}, - {"category": "genbank common name", - "name":"Lyme disease spirochet", - "canonical": ["lyme", "disease", "spirochet"] }, - {"category":"synonym", - "name":"Borrelia burgdorferi", - "canonical": [ "borrelia", "burgdorferi" ]} - ], - - [ {"category": "common name", - "name": "E. coli", - "canonical": ["e", "coli"] }, - {"category": "authority", - "name": "\"Bacterium coli commune\" Escherich 1885", - "canonical": ["bacterium", "coli", "commune", "escherich"] }, - {"category": "synonym", - "name": "Bacterium coli", - "canonical": ["bacterium", "coli" ] } - ] - ], - "items": { - "type": "object", - "required": ["category", "name", "canonical"], - "properties": { - "category": {"type": "string"}, - "name": {"type": "string"}, - "canonical": {"type": "array", "items": {"type": "string"}} - } - - } - }, - "rank": { - "type": "string", - "title": "Taxonomic rank", - "examples": ["Domain", "Phylum"] - }, - "numeric_rank": { - "type": "integer", - "title": "Taxonomic level" - }, - "NCBI_taxon_id": { - "type": "integer", - "title": "NCBI_taxon_id" - }, - "genetic_code": { - "type": "integer", - "title": "genetic code" - } - } -} diff --git a/spec/schemas/vertices/rxn/README.md b/spec/schemas/vertices/rxn/README.md deleted file mode 100644 index 4bac805e..00000000 --- a/spec/schemas/vertices/rxn/README.md +++ /dev/null @@ -1 +0,0 @@ -# Reaction homology diff --git a/spec/schemas/vertices/rxn/rxn_compound.json b/spec/schemas/vertices/rxn/rxn_compound.json deleted file mode 100644 index ccc71935..00000000 --- a/spec/schemas/vertices/rxn/rxn_compound.json +++ /dev/null @@ -1,88 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "additionalProperties": true, - "required": ["_key"], - "description": "Chemical reactions", - "properties": { - "_key": { - "type": "string", - "examples": ["cpd02201"], - "title": "ModelSeed ID", - "pattern": "^cpd\\d+$" - }, - "abbreviation": { - "type": "string", - "examples": ["phpyr"] - }, - "aliases": { - "type": "string", - "examples": ["AraCyc:PYRUVATE;BiGG:pyr;BrachyCyc:PYRUVATE;KEGG:C00022"] - }, - "charge": { - "type": ["integer"], - "examples": ["-1"] - }, - "deltag": { - "type": ["number", "null"], - "description": "The change in Free Energy of Formation" - }, - "deltagerr": { - "type": ["number", "null"], - "description": "The error associated with the Free Energy of Formation" - }, - "formula": { - "type": "string", - "examples": ["C6H6"] - }, - "id": { - "type": "string", - "examples": ["cpd02201"], - "title": "ModelSeed ID", - "pattern": "^cpd\\d+$" - }, - "inchikey": { - "type": "string", - "examples": ["LCTONWCANYUPML-UHFFFAOYSA-M"] - }, - "is_cofactor": { - "type": "integer", - "description": "The compound is a cofactor" - }, - "is_core": { - "type": "integer", - "description": "The compound is involved in core metabolism" - }, - "is_obsolete": { - "type": "integer", - "description": "The compound is a deprecated" - }, - "linked_compound": { - "type": ["string", "null"], - "description": "If the compound is deprecated, the compound that supersedes this entry" - }, - "mass": { - "type": ["number", "null"], - "description": "Molecular mass of compound" - }, - "name": { - "type": "string" - }, - "pka": { - "type": "string", - "description": "Acid dissociation constants of compound" - }, - "pkb": { - "type": "string", - "description": "Base dissociation constants of compound" - }, - "smiles": { - "type": "string", - "description": "Structure of the compound in Simplified Molecular Input Line Entry System" - }, - "source": { - "type": "string", - "description": "Does this compound come from a primary database or a metabolic model?" - } - } -} diff --git a/spec/schemas/vertices/rxn/rxn_gene_complex.json b/spec/schemas/vertices/rxn/rxn_gene_complex.json deleted file mode 100644 index 888196b4..00000000 --- a/spec/schemas/vertices/rxn/rxn_gene_complex.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "additionalProperties": false, - "description": "Groups of genes that take part in producing a chemical reaction in the cell.", - "required": ["_key", "genes"], - "properties": { - "_key": { - "type": "string", - "description": "Hash of the conjunctions." - }, - "genes": { - "type": "array", - "examples": [["SO_0001", "SO_0001"]], - "description": "Array of genes.", - "items": { - "type": "string", - "description": "Gene vertex _key" - } - }, - "source": { - "type": "string", - "examples": ["ModelSEED", "KEGG"], - "description": "The source of the gene complex information." - } - } -} diff --git a/spec/schemas/vertices/rxn/rxn_reaction.json b/spec/schemas/vertices/rxn/rxn_reaction.json deleted file mode 100644 index 6332ff9a..00000000 --- a/spec/schemas/vertices/rxn/rxn_reaction.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "additionalProperties": true, - "required": ["_key"], - "description": "Chemical reactions", - "properties": { - "_key": { - "type": "string", - "examples": ["rxn02201"], - "title": "ModelSeed ID", - "pattern": "^rxn\\d+$" - }, - "direction": { - "type": "string", - "enum": [">", "<", "="] - }, - "name": { - "type": "string", - "description": "Chemical names", - "examples": ["trans-2-Methyl-5-isopropylhexa-2,5-dienal dehydrogenase_c0"] - }, - "gpr": { - "type": "string", - "examples": ["PGN_RS01070"] - }, - "ec_number": { - "type": "string", - "examples": ["2.7.3.7"], - "title": "Enzyme Commission Number", - "pattern": "^\\d+\\.\\d+\\.\\d+\\.\\d+$" - }, - "bbcwn": { - "type": "number", - "examples": [-108] - }, - "equation": { - "type": "string", - "description": "Reaction formula using compound IDs (eg. cd00443)", - "examples": ["(1) cpd00443[c0] + (1) cpd02920[c0] => (1) cpd00012[c0] + (1) cpd00067[c0] + (1) cpd00683[c0]"] - }, - "definition": { - "type": "string", - "description": "Reaction formula. Same as equation, but with compound IDs replaced with chemical names." - }, - "bigg_id": { - "type": "string", - "examples": ["DHPS2"] - }, - "kegg_id": { - "type": "string", - "examples": ["R03067"] - }, - "kegg_pathways": { - "type": "string", - "examples": ["Folate biosynthesis"] - }, - "metacyc_pathways": { - "type": "array", - "items": {"type": "string"}, - "examples": [["AMINE-DEG", "Creatinine-Degradation", "Degradation"]] - } - } -} diff --git a/spec/schemas/vertices/test_vertex.json b/spec/schemas/vertices/test_vertex.json deleted file mode 100644 index d43d35a7..00000000 --- a/spec/schemas/vertices/test_vertex.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "required": ["_key"], - "description": "An example vertex schema for testing", - "properties": { - "_key": {"type": "string"}, - "is_public": {"type": "boolean"}, - "ws_id": {"type": "integer"} - } -} - diff --git a/spec/schemas/vertices/wsfull/README.md b/spec/schemas/vertices/wsfull/README.md deleted file mode 100644 index a3ba8a8a..00000000 --- a/spec/schemas/vertices/wsfull/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Workspace vertices (full details) - -These schemas comprise a full, detailed sync of all the data from the KBase workspace. - -For import code, see: https://github.com/kbaseapps/relation_engine_sync diff --git a/spec/schemas/vertices/wsfull/wsfull_method.json b/spec/schemas/vertices/wsfull/wsfull_method.json deleted file mode 100644 index 2b2f2396..00000000 --- a/spec/schemas/vertices/wsfull/wsfull_method.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "description": "SDK module method (unversioned).", - "additionalProperties": false, - "required": ["_key"], - "properties": { - "_key": { - "type": "string", - "examples": [ - "kb_uploadmethods.import_fasta_as_assembly_from_staging" - ], - "description": ".", - "pattern": "^\\w+\\.\\w+$" - } - } -} diff --git a/spec/schemas/vertices/wsfull/wsfull_method_version.json b/spec/schemas/vertices/wsfull/wsfull_method_version.json deleted file mode 100644 index e646fd0c..00000000 --- a/spec/schemas/vertices/wsfull/wsfull_method_version.json +++ /dev/null @@ -1,56 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "additionalProperties": false, - "description": "A specific method within a version of an SDK module.", - "required": [ - "_key", - "module_name", - "method_name", - "commit", - "ver", - "code_url" - ], - "properties": { - "_key": { - "type": "string", - "examples": [ - "module_name:version_hash.method_name", - "module_name:UNKNOWN.method_name", - "wsfull_method_version/kb_uploadmethods:8ebb66e4f2c27bc4a9b7cddff7d7b0f27f4ee433.import_genbank_from_staging" - ], - "description": ":.", - "pattern": "^\\w+:\\w+\\.\\w+$" - }, - "module_name": { - "type": "string", - "examples": ["kb_uploadmethods"], - "pattern": "^\\w+$" - }, - "method_name": { - "type": "string", - "examples": ["import_genbank_from_staging"], - "pattern": "^\\w+$" - }, - "commit": { - "type": "string", - "examples": ["8ebb66e4f2c27bc4a9b7cddff7d7b0f27f4ee433"], - "title": "Git commit hash", - "pattern": "^\\w+$" - }, - "ver": { - "type": "string", - "examples": ["1.0.13"], - "title": "Version", - "description": "Semantic version of the module", - "pattern": "^\\d+\\.\\d+\\.\\d+$" - }, - "code_url": { - "type": "string", - "examples": [ - "https://github.com/kbaseapps/kb_uploadmethods" - ], - "title": "URL of source code" - } - } -} diff --git a/spec/schemas/vertices/wsfull/wsfull_module.json b/spec/schemas/vertices/wsfull/wsfull_module.json deleted file mode 100644 index 5442dbc1..00000000 --- a/spec/schemas/vertices/wsfull/wsfull_module.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "description": "SDK module (unversioned).", - "additionalProperties": false, - "required": [ - "_key", - "language", - "dynamic_service" - ], - "properties": { - "_key": { - "type": "string", - "examples": [ - "kb_uploadmethods" - ], - "pattern": "^\\w+$" - }, - "language": { - "type": "string", - "enum": ["python", "perl", "java", "r"], - "description": "The programing language the module is written in" - }, - "dynamic_service": { - "type": "boolean", - "description": "Indicates if the module can be run as a webservice" - } - } -} diff --git a/spec/schemas/vertices/wsfull/wsfull_module_version.json b/spec/schemas/vertices/wsfull/wsfull_module_version.json deleted file mode 100644 index 3070b661..00000000 --- a/spec/schemas/vertices/wsfull/wsfull_module_version.json +++ /dev/null @@ -1,52 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "description": "Versioned SDK Module.", - "additionalProperties": false, - "required": [ - "_key", - "name", - "commit", - "ver", - "code_url" - ], - "properties": { - "_key": { - "type": "string", - "examples": [ - "kb_uploadmethods:8ebb66e4f2c27bc4a9b7cddff7d7b0f27f4ee433" - ], - "description": ":", - "pattern": "^\\w+:\\w+$" - }, - "name": { - "type": "string", - "title": "Module name", - "examples": ["kb_uploadmethods"], - "pattern": "^\\w+$" - }, - "commit": { - "type": "string", - "examples": [ - "8ebb66e4f2c27bc4a9b7cddff7d7b0f27f4ee433" - ], - "description": "Git commit hash", - "pattern": "^\\w+$" - }, - "ver": { - "type": "string", - "examples": [ - "1.0.13" - ], - "description": "Module semantic version", - "pattern": "^\\d+\\.\\d+\\.\\d+$" - }, - "code_url": { - "type": "string", - "examples": [ - "https://github.com/kbaseapps/kb_uploadmethods" - ], - "description": "URL of source code" - } - } -} diff --git a/spec/schemas/vertices/wsfull/wsfull_object.json b/spec/schemas/vertices/wsfull/wsfull_object.json deleted file mode 100644 index 9d7f244a..00000000 --- a/spec/schemas/vertices/wsfull/wsfull_object.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "additionalProperties": false, - "required": [ - "_key", - "workspace_id", - "object_id", - "deleted" - ], - "properties": { - "_key": { - "type": "string", - "description": "The wsid/objectid for this data", - "examples": [ - "35414:73" - ], - "pattern": "^\\d+:\\d+$" - }, - "workspace_id": { - "type": "integer", - "description": "The workspace_id for this object", - "minimum": 1 - }, - "object_id": { - "type": "integer", - "description": "The permanent object id", - "minimum": 1 - }, - "deleted": { - "type": "boolean" - } - } -} diff --git a/spec/schemas/vertices/wsfull/wsfull_object_hash.json b/spec/schemas/vertices/wsfull/wsfull_object_hash.json deleted file mode 100644 index 075a5242..00000000 --- a/spec/schemas/vertices/wsfull/wsfull_object_hash.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "definitions": {}, - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "additionalProperties": false, - "required": [ - "_key", - "type" - ], - "properties": { - "_key": { - "type": "string", - "description": "The key is the hash", - "examples": [ - "2406642b28312b3ccbfb2e17e231e2c7" - ] - }, - "type": { - "type": "string", - "description": "The hashing algorithm used", - "examples": [ - "MD5" - ] - } - } -} diff --git a/spec/schemas/vertices/wsfull/wsfull_object_version.json b/spec/schemas/vertices/wsfull/wsfull_object_version.json deleted file mode 100644 index 9e78fff7..00000000 --- a/spec/schemas/vertices/wsfull/wsfull_object_version.json +++ /dev/null @@ -1,69 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "required": [ - "_key", - "workspace_id", - "object_id", - "version", - "name", - "hash", - "size", - "epoch", - "deleted" - ], - "properties": { - "_key": { - "type": "string", - "description": "The UPA for this data", - "examples": [ - "35414:73:1" - ], - "pattern": "^\\d+:\\d+:\\d+$" - }, - "workspace_id": { - "type": "integer", - "description": "The workspace_id for this object", - "minimum": 1 - }, - "object_id": { - "type": "integer", - "description": "The permanent object id", - "minimum": 1 - }, - "version": { - "type": "integer", - "description": "The object's version", - "minimum": 1 - }, - "name": { - "type": "string", - "description": "The user supplied name for this object", - "examples": [ - "my_awesome_object" - ] - }, - "hash": { - "type": "string", - "description": "The md5 hash of the workspace object", - "examples": [ - "94edd584731298befa53119cb151d82e" - ] - }, - "size": { - "type": "integer", - "description": "Size in bytes", - "default": 0, - "minimum": 0 - }, - "epoch": { - "type": "integer", - "description": "Creation time in UTC epoch", - "default": 0, - "minimum": 0 - }, - "deleted": { - "type": "boolean" - } - } -} diff --git a/spec/schemas/vertices/wsfull/wsfull_type.json b/spec/schemas/vertices/wsfull/wsfull_type.json deleted file mode 100644 index d2d5d183..00000000 --- a/spec/schemas/vertices/wsfull/wsfull_type.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "additionalProperties": false, - "required": ["_key"], - "properties": { - "_key": { - "type": "string", - "examples": [ - "KBaseGenomes.Genome" - ], - "pattern": "^\\w+\\.\\w+$" - } - } -} diff --git a/spec/schemas/vertices/wsfull/wsfull_type_module.json b/spec/schemas/vertices/wsfull/wsfull_type_module.json deleted file mode 100644 index bc33b4f8..00000000 --- a/spec/schemas/vertices/wsfull/wsfull_type_module.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "additionalProperties": false, - "required": ["_key"], - "properties": { - "_key": { - "type": "string", - "examples": [ - "KBaseGenomes" - ], - "pattern": "^\\w+$" - } - } -} diff --git a/spec/schemas/vertices/wsfull/wsfull_type_version.json b/spec/schemas/vertices/wsfull/wsfull_type_version.json deleted file mode 100644 index 86b894d1..00000000 --- a/spec/schemas/vertices/wsfull/wsfull_type_version.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "additionalProperties": false, - "required": ["_key"], - "properties": { - "_key": { - "type": "string", - "examples": [ - "KBaseGenomes.Genome‑9.0" - ], - "pattern": "^\\w+\\.\\w+-\\d+\\.\\d+$" - } - } -} diff --git a/spec/schemas/vertices/wsfull/wsfull_user.json b/spec/schemas/vertices/wsfull/wsfull_user.json deleted file mode 100644 index 7f7d963c..00000000 --- a/spec/schemas/vertices/wsfull/wsfull_user.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "additionalProperties": false, - "required": ["_key"], - "properties": { - "_key": { - "type": "string", - "description": "The username for this user", - "examples": [ - "jjeffryes", - "sean-mccorkle3." - ] - } - } -} diff --git a/spec/schemas/vertices/wsfull/wsfull_workspace.json b/spec/schemas/vertices/wsfull/wsfull_workspace.json deleted file mode 100644 index 767c9b0a..00000000 --- a/spec/schemas/vertices/wsfull/wsfull_workspace.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "required": ["_key"], - "properties": { - "_key": { - "type": "string", - "description": "The workspace ID for this workspace", - "examples": [ - "35414" - ], - "pattern": "^\\d+$" - }, - "narr_name": { - "type": "string", - "title": "Narrative name" - }, - "owner": { - "type": "string", - "title": "Username of workspace owner" - }, - "max_obj_id": { - "type": "integer", - "title": "Maximum object ID in this workspace" - }, - "lock_status": { - "type": "string", - "title": "Status of the workspace lock" - }, - "name": { - "type": "string", - "description": "The workspace name for this workspace", - "examples": [ - "jjeffryes:narrative_1534187093329" - ] - }, - "mod_epoch": { - "type": "integer", - "title": "Modified date epoch", - "description": "Timestamp of when the workspace was last modified", - "minimum": 0 - }, - "is_public": { - "type": "boolean" - }, - "is_deleted": { - "type": "boolean" - } - } -} diff --git a/spec/schemas/vertices/wsprov/README.md b/spec/schemas/vertices/wsprov/README.md deleted file mode 100644 index d6154877..00000000 --- a/spec/schemas/vertices/wsprov/README.md +++ /dev/null @@ -1 +0,0 @@ -# Simple workspace provenance data diff --git a/spec/schemas/vertices/wsprov/wsprov_action.json b/spec/schemas/vertices/wsprov/wsprov_action.json deleted file mode 100644 index fc6f2549..00000000 --- a/spec/schemas/vertices/wsprov/wsprov_action.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "required": [ - "_key", - "workspace_id", - "runner" - ], - "properties": { - "_key": { - "type": "string", - "description": "Slugified name of the action with its timestamp and workspace id", - "examples": [ "copy:123123123:42" ] - }, - "workspace_id": { - "type": "integer", - "description": "The workspace_id in which this action was performed", - "minimum": 1 - }, - "runner": { - "type": "string", - "description": "The person who ran this action" - } - } -} - diff --git a/spec/schemas/vertices/wsprov/wsprov_object.json b/spec/schemas/vertices/wsprov/wsprov_object.json deleted file mode 100644 index 333848f9..00000000 --- a/spec/schemas/vertices/wsprov/wsprov_object.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "required": [ - "_key", - "workspace_id", - "owner" - ], - "properties": { - "_key": { - "type": "string", - "description": "The workspace reference for this object", - "examples": [ "1:2:3" ] - }, - "workspace_id": { - "type": "integer", - "description": "The workspace_id for this object", - "minimum": 1 - }, - "owner": { - "type": "string", - "description": "The owner of this workspace object" - } - } -} diff --git a/spec/schemas/edges/wsfull/README.md b/spec/schemas/wsfull/README.md similarity index 100% rename from spec/schemas/edges/wsfull/README.md rename to spec/schemas/wsfull/README.md diff --git a/spec/schemas/wsfull/wsfull_copied_from.yaml b/spec/schemas/wsfull/wsfull_copied_from.yaml new file mode 100644 index 00000000..056739a8 --- /dev/null +++ b/spec/schemas/wsfull/wsfull_copied_from.yaml @@ -0,0 +1,10 @@ +name: wsfull_copied_from +type: edge +schema: + "$schema": http://json-schema.org/draft-07/schema# + type: object + required: [_from, _to] + description: The _from object was created as an exact copy of the _to object. + properties: + _from: {type: string} + _to: {type: string} diff --git a/spec/schemas/wsfull/wsfull_latest_version_of.yaml b/spec/schemas/wsfull/wsfull_latest_version_of.yaml new file mode 100644 index 00000000..e61adc1c --- /dev/null +++ b/spec/schemas/wsfull/wsfull_latest_version_of.yaml @@ -0,0 +1,25 @@ +name: wsfull_latest_version_of +type: edge +schema: + "$schema": "http://json-schema.org/draft-07/schema#" + type: object + additionalProperties: false + required: [_from, _to] + properties: + _from: + type: string + examples: + - wsfull_type_version/KBaseGenomes.Genome‑9.0 + - wsfull_module_version/kb_uploadmethods:8ebb66e4f2c27bc4a9b7cddff7d7b0f27f4ee433 + description: | + A versioned entity, representing the most recent version of an entity + in a group (most likely a workspace object, module, or workspace type). + _to: + type: string + examples: + - wsfull_type/KBaseGenomes.Genome + - wsfull_module/kb_uploadmethods + description: | + The non-versioned entity group, where all members of the group are + different versions of something (eg. a workspace object, module, or workspace + type) diff --git a/spec/schemas/wsfull/wsfull_method.yaml b/spec/schemas/wsfull/wsfull_method.yaml new file mode 100644 index 00000000..1c301042 --- /dev/null +++ b/spec/schemas/wsfull/wsfull_method.yaml @@ -0,0 +1,14 @@ +name: wsfull_method +type: vertex +schema: + "$schema": "http://json-schema.org/draft-07/schema#" + type: object + description: SDK module method (unversioned). + additionalProperties: false + required: [_key] + properties: + _key: + type: string + examples: ["kb_uploadmethods.import_fasta_as_assembly_from_staging"] + description: "." + pattern: "^\\w+\\.\\w+$" diff --git a/spec/schemas/wsfull/wsfull_method_version.yaml b/spec/schemas/wsfull/wsfull_method_version.yaml new file mode 100644 index 00000000..0b53155b --- /dev/null +++ b/spec/schemas/wsfull/wsfull_method_version.yaml @@ -0,0 +1,40 @@ +name: wsfull_method_version +type: vertex +schema: + "$schema": http://json-schema.org/draft-07/schema# + type: object + additionalProperties: false + description: A specific method within a version of an SDK module. + required: [_key, module_name, method_name, commit, ver, code_url] + properties: + _key: + type: string + examples: + - module_name:version_hash.method_name + - module_name:UNKNOWN.method_name + - wsfull_method_version/kb_uploadmethods:8ebb66e4f2c27bc4a9b7cddff7d7b0f27f4ee433.import_genbank_from_staging + description: ":." + pattern: "^\\w+:\\w+\\.\\w+$" + module_name: + type: string + examples: [kb_uploadmethods] + pattern: "^\\w+$" + method_name: + type: string + examples: [import_genbank_from_staging] + pattern: "^\\w+$" + commit: + type: string + examples: [8ebb66e4f2c27bc4a9b7cddff7d7b0f27f4ee433] + title: Git commit hash + pattern: "^\\w+$" + ver: + type: string + examples: [1.0.13] + title: Version + description: Semantic version of the module + pattern: "^\\d+\\.\\d+\\.\\d+$" + code_url: + type: string + examples: ["https://github.com/kbaseapps/kb_uploadmethods"] + title: URL of source code diff --git a/spec/schemas/wsfull/wsfull_module.yaml b/spec/schemas/wsfull/wsfull_module.yaml new file mode 100644 index 00000000..e680f1ad --- /dev/null +++ b/spec/schemas/wsfull/wsfull_module.yaml @@ -0,0 +1,20 @@ +name: wsfull_module +type: vertex +schema: + "$schema": http://json-schema.org/draft-07/schema# + type: object + description: SDK module (unversioned). + additionalProperties: false + required: [_key, language, dynamic_service] + properties: + _key: + type: string + examples: [kb_uploadmethods] + pattern: "^\\w+$" + language: + type: string + enum: [python, perl, java, r] + description: The programing language the module is written in + dynamic_service: + type: boolean + description: Indicates if the module can be run as a webservice diff --git a/spec/schemas/wsfull/wsfull_module_contains_method.yaml b/spec/schemas/wsfull/wsfull_module_contains_method.yaml new file mode 100644 index 00000000..41f7cf80 --- /dev/null +++ b/spec/schemas/wsfull/wsfull_module_contains_method.yaml @@ -0,0 +1,14 @@ +name: wsfull_module_contains_method +type: edge +schema: + "$schema": http://json-schema.org/draft-07/schema# + type: object + description: A module contains an SDK method + required: [_from, _to] + properties: + _from: + type: string + description: The module ID. + _to: + type: string + description: The SDK method ID diff --git a/spec/schemas/wsfull/wsfull_module_version.yaml b/spec/schemas/wsfull/wsfull_module_version.yaml new file mode 100644 index 00000000..2abe2fe3 --- /dev/null +++ b/spec/schemas/wsfull/wsfull_module_version.yaml @@ -0,0 +1,38 @@ +name: wsfull_module_version +type: vertex +schema: + "$schema": "http://json-schema.org/draft-07/schema#" + type: object + description: Versioned SDK Module. + additionalProperties: false + required: [_key, name, commit, ver, code_url] + properties: + _key: + type: string + examples: + - kb_uploadmethods:8ebb66e4f2c27bc4a9b7cddff7d7b0f27f4ee433 + description: ":" + pattern: "^\\w+:\\w+$" + name: + type: string + title: Module name + examples: + - kb_uploadmethods + pattern: "^\\w+$" + commit: + type: string + examples: + - 8ebb66e4f2c27bc4a9b7cddff7d7b0f27f4ee433 + description: Git commit hash + pattern: "^\\w+$" + ver: + type: string + examples: + - 1.0.13 + description: Module semantic version + pattern: "^\\d+\\.\\d+\\.\\d+$" + code_url: + type: string + examples: + - https://github.com/kbaseapps/kb_uploadmethods + description: URL of source code diff --git a/spec/schemas/wsfull/wsfull_obj_created_with_method.yaml b/spec/schemas/wsfull/wsfull_obj_created_with_method.yaml new file mode 100644 index 00000000..6ca3f7c4 --- /dev/null +++ b/spec/schemas/wsfull/wsfull_obj_created_with_method.yaml @@ -0,0 +1,23 @@ +name: wsfull_obj_created_with_method +type: edge +schema: + "$schema": http://json-schema.org/draft-07/schema# + type: object + additionalProperties: false + required: [_from, _to, method_params] + description: The _from WS versioned object was created by the _to SDK versioned method. + properties: + _from: + type: string + examples: + - wsfull_object_version/35414:73:1 + description: A versioned workspace object. + _to: + type: string + examples: + - wsfull_method_version/kb_uploadmethods:8ebb66e4f2c27bc4a9b7cddff7d7b0f27f4ee433.import_genbank_from_staging + - wsfull_method_version/kb_uploadmethods:UNKNOWN.import_genbank_from_staging + description: A version of a module with a method. + method_params: + type: [array, object, 'null'] + description: The input parameters for the method used to create the object. diff --git a/spec/schemas/wsfull/wsfull_obj_created_with_module.yaml b/spec/schemas/wsfull/wsfull_obj_created_with_module.yaml new file mode 100644 index 00000000..daa01511 --- /dev/null +++ b/spec/schemas/wsfull/wsfull_obj_created_with_module.yaml @@ -0,0 +1,16 @@ +name: wsfull_obj_created_with_module +type: edge +schema: + "$schema": http://json-schema.org/draft-07/schema# + type: object + additionalProperties: false + required: [_from, _to] + description: The _from WS versioned object was created with the _to SDK versioned + module. + properties: + _from: + type: string + description: The WS versioned object that was created. + _to: + type: string + description: The SDK versioned module that created the object. diff --git a/spec/schemas/wsfull/wsfull_obj_instance_of_type.yaml b/spec/schemas/wsfull/wsfull_obj_instance_of_type.yaml new file mode 100644 index 00000000..274c9c73 --- /dev/null +++ b/spec/schemas/wsfull/wsfull_obj_instance_of_type.yaml @@ -0,0 +1,11 @@ +name: wsfull_obj_instance_of_type +type: edge +schema: + "$schema": http://json-schema.org/draft-07/schema# + type: object + additionalProperties: false + required: [_from, _to] + description: The _from WS versioned object is an instance of the _to versioned type. + properties: + _from: {type: string} + _to: {type: string} diff --git a/spec/schemas/wsfull/wsfull_object.yaml b/spec/schemas/wsfull/wsfull_object.yaml new file mode 100644 index 00000000..0327de0f --- /dev/null +++ b/spec/schemas/wsfull/wsfull_object.yaml @@ -0,0 +1,23 @@ +name: wsfull_object +type: vertex +schema: + "$schema": http://json-schema.org/draft-07/schema# + type: object + additionalProperties: false + required: [_key, workspace_id, object_id, deleted] + properties: + _key: + type: string + description: The wsid/objectid for this data + examples: ["35414:73"] + pattern: "^\\d+:\\d+$" + workspace_id: + type: integer + description: The workspace_id for this object + minimum: 1 + object_id: + type: integer + description: The permanent object id + minimum: 1 + deleted: + type: boolean diff --git a/spec/schemas/wsfull/wsfull_object_hash.yaml b/spec/schemas/wsfull/wsfull_object_hash.yaml new file mode 100644 index 00000000..746e0fda --- /dev/null +++ b/spec/schemas/wsfull/wsfull_object_hash.yaml @@ -0,0 +1,16 @@ +name: wsfull_object_hash +type: vertex +schema: + "$schema": "http://json-schema.org/draft-07/schema#" + type: object + additionalProperties: false + required: [_key, type] + properties: + _key: + type: string + description: The key is the hash + examples: [2406642b28312b3ccbfb2e17e231e2c7] + type: + type: string + description: The hashing algorithm used + examples: [MD5] diff --git a/spec/schemas/wsfull/wsfull_object_version.yaml b/spec/schemas/wsfull/wsfull_object_version.yaml new file mode 100644 index 00000000..2ef23d5d --- /dev/null +++ b/spec/schemas/wsfull/wsfull_object_version.yaml @@ -0,0 +1,54 @@ +name: wsfull_object_version +type: vertex +schema: + "$schema": "http://json-schema.org/draft-07/schema#" + type: object + required: + - _key + - workspace_id + - object_id + - version + - name + - hash + - size + - epoch + - deleted + properties: + _key: + type: string + description: The UPA for this data + examples: ["35414:73:1"] + pattern: "^\\d+:\\d+:\\d+$" + workspace_id: + type: integer + description: The workspace_id for this object + minimum: 1 + object_id: + type: integer + description: The permanent object id + minimum: 1 + version: + type: integer + description: The object's version + minimum: 1 + name: + type: string + description: The user supplied name for this object + examples: + - my_awesome_object + hash: + type: string + description: The md5 hash of the workspace object + examples: [94edd584731298befa53119cb151d82e] + size: + type: integer + description: Size in bytes + default: 0 + minimum: 0 + epoch: + type: integer + description: Creation time in UTC epoch + default: 0 + minimum: 0 + deleted: + type: boolean diff --git a/spec/schemas/wsfull/wsfull_owner_of.yaml b/spec/schemas/wsfull/wsfull_owner_of.yaml new file mode 100644 index 00000000..4ada3b72 --- /dev/null +++ b/spec/schemas/wsfull/wsfull_owner_of.yaml @@ -0,0 +1,19 @@ +name: wsfull_owner_of +type: edge +schema: + "$schema": http://json-schema.org/draft-07/schema# + type: object + additionalProperties: false + description: The user is an owner of a workspace or type module. + required: [_from, _to] + properties: + _from: + type: string + examples: ["wsfull_user/jjeffryes"] + description: A username + _to: + type: string + examples: + - wsfull_type_module/KBaseGenomes + - wsfull_workspace/35414 + description: A Workspace or Type Module diff --git a/spec/schemas/wsfull/wsfull_prov_descendant_of.yaml b/spec/schemas/wsfull/wsfull_prov_descendant_of.yaml new file mode 100644 index 00000000..255c8303 --- /dev/null +++ b/spec/schemas/wsfull/wsfull_prov_descendant_of.yaml @@ -0,0 +1,10 @@ +name: wsfull_prov_descendant_of +type: edge +schema: + "$schema": "http://json-schema.org/draft-07/schema#" + type: object + required: [_from, _to] + description: The _from object is a provenance descendant of the _to object (eg. Assembly->Reads). + properties: + _from: {type: string} + _to: {type: string} diff --git a/spec/schemas/wsfull/wsfull_refers_to.yaml b/spec/schemas/wsfull/wsfull_refers_to.yaml new file mode 100644 index 00000000..46fd8264 --- /dev/null +++ b/spec/schemas/wsfull/wsfull_refers_to.yaml @@ -0,0 +1,10 @@ +name: wsfull_refers_to +type: edge +schema: + "$schema": "http://json-schema.org/draft-07/schema#" + type: object + required: [_from, _to] + description: The _from object has a reference to the _to object (eg. Genome->Assembly). + properties: + _from: {type: string} + _to: {type: string} diff --git a/spec/schemas/wsfull/wsfull_type.yaml b/spec/schemas/wsfull/wsfull_type.yaml new file mode 100644 index 00000000..fbfb7e53 --- /dev/null +++ b/spec/schemas/wsfull/wsfull_type.yaml @@ -0,0 +1,12 @@ +name: wsfull_type +type: vertex +schema: + "$schema": "http://json-schema.org/draft-07/schema#" + type: object + additionalProperties: false + required: [_key] + properties: + _key: + type: string + examples: [KBaseGenomes.Genome] + pattern: "^\\w+\\.\\w+$" diff --git a/spec/schemas/wsfull/wsfull_type_consumed_by_method.yaml b/spec/schemas/wsfull/wsfull_type_consumed_by_method.yaml new file mode 100644 index 00000000..be39175d --- /dev/null +++ b/spec/schemas/wsfull/wsfull_type_consumed_by_method.yaml @@ -0,0 +1,15 @@ +name: wsfull_type_consumed_by_method +type: edge +schema: + "$schema": "http://json-schema.org/draft-07/schema#" + type: object + required: [_from, _to] + description: The _from type is consumed by the _to SDK method + additionalProperties: true + properties: + _from: + type: string + description: The ID of the type that is consumed. + _to: + type: string + description: The ID of the SDK method that consumes the type. diff --git a/spec/schemas/wsfull/wsfull_type_module.yaml b/spec/schemas/wsfull/wsfull_type_module.yaml new file mode 100644 index 00000000..6703d08c --- /dev/null +++ b/spec/schemas/wsfull/wsfull_type_module.yaml @@ -0,0 +1,12 @@ +name: wsfull_type_module +type: vertex +schema: + "$schema": "http://json-schema.org/draft-07/schema#" + type: object + additionalProperties: false + required: [_key] + properties: + _key: + type: string + examples: [KBaseGenomes] + pattern: "^\\w+$" diff --git a/spec/schemas/wsfull/wsfull_type_version.yaml b/spec/schemas/wsfull/wsfull_type_version.yaml new file mode 100644 index 00000000..3a351d96 --- /dev/null +++ b/spec/schemas/wsfull/wsfull_type_version.yaml @@ -0,0 +1,12 @@ +name: wsfull_type_version +type: vertex +schema: + "$schema": "http://json-schema.org/draft-07/schema#" + type: object + additionalProperties: false + required: [_key] + properties: + _key: + type: string + examples: [KBaseGenomes.Genome‑9.0] + pattern: "^\\w+\\.\\w+-\\d+\\.\\d+$" diff --git a/spec/schemas/wsfull/wsfull_user.yaml b/spec/schemas/wsfull/wsfull_user.yaml new file mode 100644 index 00000000..5a142fde --- /dev/null +++ b/spec/schemas/wsfull/wsfull_user.yaml @@ -0,0 +1,14 @@ +name: wsfull_user +type: vertex +schema: + "$schema": "http://json-schema.org/draft-07/schema#" + type: object + additionalProperties: false + required: [_key] + properties: + _key: + type: string + description: The username for this user + examples: + - jjeffryes + - sean-mccorkle3 diff --git a/spec/schemas/wsfull/wsfull_version_of.yaml b/spec/schemas/wsfull/wsfull_version_of.yaml new file mode 100644 index 00000000..a0f08e85 --- /dev/null +++ b/spec/schemas/wsfull/wsfull_version_of.yaml @@ -0,0 +1,28 @@ +name: wsfull_version_of +type: edge +schema: + "$schema": "http://json-schema.org/draft-07/schema#" + type: object + additionalProperties: false + description: The _from entity is a version of a the _to entity (eg. type, method, module). + required: [_from, _to] + properties: + _from: + type: string + examples: + - wsfull_type_version/KBaseGenomes.Genome‑9.0 + - wsfull_method_version/kb_uploadmethods:8ebb66e4f2c27bc4a9b7cddff7d7b0f27f4ee433 + description: A versioned entity (eg. a workspace object, module, or workspace type) + _to: + type: string + examples: + - wsfull_type/KBaseGenomes.Genome + - wsfull_method/kb_uploadmethods + description: | + The non-versioned entity group, where all members of the group are + different versions of something (eg. a workspace object, module, or workspace + type). + tag: + type: string + description: Tags for entities managed by catalog + enum: [release, beta, dev] diff --git a/spec/schemas/wsfull/wsfull_workspace.yaml b/spec/schemas/wsfull/wsfull_workspace.yaml new file mode 100644 index 00000000..05dfa24b --- /dev/null +++ b/spec/schemas/wsfull/wsfull_workspace.yaml @@ -0,0 +1,35 @@ +name: wsfull_workspace +type: vertex +schema: + "$schema": "http://json-schema.org/draft-07/schema#" + type: object + required: [_key] + properties: + _key: + type: string + description: The workspace ID for this workspace + examples: ['35414'] + pattern: "^\\d+$" + narr_name: + type: string + title: Narrative name + owner: + type: string + title: Username of workspace owner + max_obj_id: + type: integer + title: Maximum object ID in this workspace + lock_status: + type: string + title: Status of the workspace lock + name: + type: string + description: The workspace name for this workspace + examples: ["jjeffryes:narrative_1534187093329"] + mod_epoch: + type: integer + title: Modified date epoch + description: Timestamp of when the workspace was last modified + minimum: 0 + is_public: {type: boolean} + is_deleted: {type: boolean} diff --git a/spec/schemas/wsfull/wsfull_ws_contains_obj.yaml b/spec/schemas/wsfull/wsfull_ws_contains_obj.yaml new file mode 100644 index 00000000..ad55ad5e --- /dev/null +++ b/spec/schemas/wsfull/wsfull_ws_contains_obj.yaml @@ -0,0 +1,14 @@ +name: wsfull_ws_contains_obj +type: edge +schema: + "$schema": http://json-schema.org/draft-07/schema# + type: object + description: A workspace contains an object + required: [_from, _to] + properties: + _from: + type: string + description: The ID of the workspace + _to: + type: string + description: The ID of the object diff --git a/spec/schemas/wsfull/wsfull_ws_perm.yaml b/spec/schemas/wsfull/wsfull_ws_perm.yaml new file mode 100644 index 00000000..c7806aed --- /dev/null +++ b/spec/schemas/wsfull/wsfull_ws_perm.yaml @@ -0,0 +1,23 @@ +name: wsfull_ws_perm +type: edge +schema: + "$schema": http://json-schema.org/draft-07/schema# + type: object + description: The user has permissions on a workspace. + required: [_from, _to, perm] + properties: + perm: + type: string + enum: [a, w, r] + title: Permissions + description: | + Represents the permissions a user has on a workspace, where 'a' is + 'administrator', 'w' is read/write, 'r' is readonly. + _from: + type: string + examples: ['wsfull_user/jjeffryes'] + description: A username + _to: + type: string + examples: ['wsfull_workspace/35414'] + description: A workspace diff --git a/spec/schemas/edges/wsprov/README.md b/spec/schemas/wsprov/README.md similarity index 100% rename from spec/schemas/edges/wsprov/README.md rename to spec/schemas/wsprov/README.md diff --git a/spec/schemas/wsprov/wsprov_action.yaml b/spec/schemas/wsprov/wsprov_action.yaml new file mode 100644 index 00000000..2ab86c82 --- /dev/null +++ b/spec/schemas/wsprov/wsprov_action.yaml @@ -0,0 +1,18 @@ +name: wsprov_action +type: vertex +schema: + "$schema": http://json-schema.org/draft-07/schema# + type: object + required: [_key, workspace_id, runner] + properties: + _key: + type: string + description: Slugified name of the action with its timestamp and workspace id + examples: ['copy:123123123:42'] + workspace_id: + type: integer + description: The workspace_id in which this action was performed + minimum: 1 + runner: + type: string + description: The person who ran this action diff --git a/spec/schemas/wsprov/wsprov_copied_into.yaml b/spec/schemas/wsprov/wsprov_copied_into.yaml new file mode 100644 index 00000000..8bbc9b98 --- /dev/null +++ b/spec/schemas/wsprov/wsprov_copied_into.yaml @@ -0,0 +1,14 @@ +name: wsprov_copied_into +type: edge +schema: + "$schema": http://json-schema.org/draft-07/schema# + type: object + required: [_from, _to] + description: The object was copied into another object + properties: + _from: + type: string + examples: ['wsprov_object/1:2:3'] + _to: + type: string + examples: ['wsprov_object/1:2:3'] diff --git a/spec/schemas/wsprov/wsprov_input_in.yaml b/spec/schemas/wsprov/wsprov_input_in.yaml new file mode 100644 index 00000000..97912af8 --- /dev/null +++ b/spec/schemas/wsprov/wsprov_input_in.yaml @@ -0,0 +1,14 @@ +name: wsprov_input_in +type: edge +schema: + "$schema": http://json-schema.org/draft-07/schema# + type: object + required: [_from, _to] + description: The workspace object was input in a provenance action + properties: + _from: + type: string + examples: ['wsprov_object/1:2:3'] + _to: + type: string + examples: ['wsprov_action/1:2:3'] diff --git a/spec/schemas/wsprov/wsprov_links.yaml b/spec/schemas/wsprov/wsprov_links.yaml new file mode 100644 index 00000000..a7610c8a --- /dev/null +++ b/spec/schemas/wsprov/wsprov_links.yaml @@ -0,0 +1,14 @@ +name: wsprov_links +type: edge +schema: + "$schema": http://json-schema.org/draft-07/schema# + type: object + required: [_from, _to] + description: The object is linked to another object, through references, provenance, etc + properties: + _from: + type: string + examples: ['wsprov_object/1:2:3'] + _to: + type: string + examples: ['wsprov_object/1:2:3'] diff --git a/spec/schemas/wsprov/wsprov_object.yaml b/spec/schemas/wsprov/wsprov_object.yaml new file mode 100644 index 00000000..b40ead82 --- /dev/null +++ b/spec/schemas/wsprov/wsprov_object.yaml @@ -0,0 +1,18 @@ +name: wsprov_object +type: vertex +schema: + "$schema": http://json-schema.org/draft-07/schema# + type: object + required: [_key, workspace_id, owner] + properties: + _key: + type: string + description: The workspace reference for this object + examples: ['1:2:3'] + workspace_id: + type: integer + description: The workspace_id for this object + minimum: 1 + owner: + type: string + description: The owner of this workspace object diff --git a/spec/schemas/wsprov/wsprov_produced.yaml b/spec/schemas/wsprov/wsprov_produced.yaml new file mode 100644 index 00000000..41c9e0d4 --- /dev/null +++ b/spec/schemas/wsprov/wsprov_produced.yaml @@ -0,0 +1,14 @@ +name: wsprov_produced +type: edge +schema: + "$schema": http://json-schema.org/draft-07/schema# + type: object + required: [_from, _to] + description: The provenance action produced the workspace object + properties: + _from: + type: string + examples: ['wsprov_action/1:2:3'] + _to: + type: string + examples: ['wsprov_object/1:2:3'] diff --git a/spec/test/validate.py b/spec/test/validate.py index 31dfa246..5b4204fe 100644 --- a/spec/test/validate.py +++ b/spec/test/validate.py @@ -1,42 +1,50 @@ """ Validate everything in this repo, such as syntax, structure, etc. """ -import re import os import glob -import json +import yaml import jsonschema from jsonschema.exceptions import ValidationError +# JSON schema for vertex and edge collection schemas found in /schema +schema_schema = { + "type": "object", + "required": ["name", "type", "schema"], + "properties": { + "name": { + 'title': 'Collection name', + "type": "string", + "format": r'^[a-z_]+$' + }, + 'type': { + 'type': 'string', + 'enum': ['vertex', 'edge'] + }, + 'schema': {'type': 'object'} + } +} + def validate_json_schemas(): """Validate the syntax of all the JSON schemas.""" print('Validating JSON schemas..') names = {} # type: dict - for path in glob.iglob('schemas/**/*.json', recursive=True): + for path in glob.iglob('schemas/**/*.yaml', recursive=True): name = os.path.basename(path) - # Make sure collection is lower snake case - if not re.match(r'^[a-z_]+.json$', name): - print('Name must be lowercase, alphabetical, with underscores in ' + path) - exit(1) + print(f' validating {name}..') + with open(path) as fd: + data = yaml.safe_load(fd) + jsonschema.validate(data, schema_schema) # Check for any duplicate schema names if names.get(name): print('Duplicate schemas for name ' + name) exit(1) else: names[name] = True - # Load and parse the schema data as a python dict - with open(path, 'r') as fd: - try: - schema = json.load(fd) - except Exception as err: - print('=' * 80) - print('Unable to parse json in ' + path) - print(str(err)) - exit(1) # Make sure it can be used as a JSON schema try: - jsonschema.validate({}, schema) + jsonschema.validate({}, data['schema']) except ValidationError: pass except Exception as err: @@ -45,17 +53,18 @@ def validate_json_schemas(): print(str(err)) exit(1) # All schemas must be object types - if schema['type'] != 'object': + if data['schema']['type'] != 'object': print('Schemas must be an object. Schema in %s is not an object.' % path) exit(1) - required = schema.get('required', []) + required = data['schema'].get('required', []) # Edges must require _from and _to while vertices must require _key - if '/edges/' in path and ('_from' not in required or '_to' not in required): + if data['type'] == 'edge' and ('_from' not in required or '_to' not in required): print('Edge schemas must require _from and _to attributes in ' + path) exit(1) - elif '/vertices/' in path and '_key' not in required: + elif data['type'] == 'vertex' and '_key' not in required: print('Vertex schemas must require the _key attribute in ' + path) exit(1) + print(f'✓ {name} is valid.') print('..all valid.') diff --git a/spec/views/ncbi_taxonomy/get_taxonomic_id.yaml b/spec/views/ncbi_taxonomy/get_taxonomic_id.yaml index e67acbb5..753f568d 100644 --- a/spec/views/ncbi_taxonomy/get_taxonomic_id.yaml +++ b/spec/views/ncbi_taxonomy/get_taxonomic_id.yaml @@ -4,9 +4,12 @@ params: properties: sci_name: {type: string} query: | + for + let my_docs = (...) // Get the taxon ID from scientific name WITH ncbi_child_of_taxon, ncbi_taxon let sci_name = @sci_name + FILTER doc.somethihng == 'what' for t in ncbi_taxon filter t.scientific_name == sci_name return t._key From c66718480a3e821fda4378732e82ed4f691555f2 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Mon, 22 Jul 2019 14:59:14 -0700 Subject: [PATCH 318/732] Delete views that we dont need here --- spec/views/ncbi_taxonomy/get_aliases.yaml | 11 ----------- spec/views/ncbi_taxonomy/get_children.yaml | 12 ------------ spec/views/ncbi_taxonomy/get_domain.yaml | 13 ------------- spec/views/ncbi_taxonomy/get_genetic_code.yaml | 11 ----------- spec/views/ncbi_taxonomy/get_kingdom.yaml | 13 ------------- spec/views/ncbi_taxonomy/get_parent.yaml | 14 -------------- .../ncbi_taxonomy/get_scientific_lineage.yaml | 12 ------------ spec/views/ncbi_taxonomy/get_scientific_name.yaml | 11 ----------- spec/views/ncbi_taxonomy/get_taxonomic_id.yaml | 15 --------------- 9 files changed, 112 deletions(-) delete mode 100644 spec/views/ncbi_taxonomy/get_aliases.yaml delete mode 100644 spec/views/ncbi_taxonomy/get_children.yaml delete mode 100644 spec/views/ncbi_taxonomy/get_domain.yaml delete mode 100644 spec/views/ncbi_taxonomy/get_genetic_code.yaml delete mode 100644 spec/views/ncbi_taxonomy/get_kingdom.yaml delete mode 100644 spec/views/ncbi_taxonomy/get_parent.yaml delete mode 100644 spec/views/ncbi_taxonomy/get_scientific_lineage.yaml delete mode 100644 spec/views/ncbi_taxonomy/get_scientific_name.yaml delete mode 100644 spec/views/ncbi_taxonomy/get_taxonomic_id.yaml diff --git a/spec/views/ncbi_taxonomy/get_aliases.yaml b/spec/views/ncbi_taxonomy/get_aliases.yaml deleted file mode 100644 index dea8a8d3..00000000 --- a/spec/views/ncbi_taxonomy/get_aliases.yaml +++ /dev/null @@ -1,11 +0,0 @@ -params: - type: object - required: [taxon_key] - properties: - taxon_key: {type: string} -query: | - WITH ncbi_child_of_taxon, ncbi_taxon - let taxon_key = @taxon_key - for t in ncbi_taxon - filter t._key == taxon_key - return t.aliases diff --git a/spec/views/ncbi_taxonomy/get_children.yaml b/spec/views/ncbi_taxonomy/get_children.yaml deleted file mode 100644 index c3fc30b1..00000000 --- a/spec/views/ncbi_taxonomy/get_children.yaml +++ /dev/null @@ -1,12 +0,0 @@ -params: - type: object - required: [taxon_key] - properties: - taxon_key: {type: string} -query: | - WITH ncbi_child_of_taxon, ncbi_taxon - let taxon_key = @taxon_key - for t in ncbi_taxon - filter t._key == taxon_key - for child in 1..1 inbound t ncbi_child_of_taxon - return child diff --git a/spec/views/ncbi_taxonomy/get_domain.yaml b/spec/views/ncbi_taxonomy/get_domain.yaml deleted file mode 100644 index 36b7e73a..00000000 --- a/spec/views/ncbi_taxonomy/get_domain.yaml +++ /dev/null @@ -1,13 +0,0 @@ -params: - type: object - required: [sci_name] - properties: - sci_name: {type: string} -query: | - WITH ncbi_child_of_taxon, ncbi_taxon - let taxon_key = @taxon_key - for t in ncbi_taxon - filter t._key == taxon_key - for parent in 1..10 outbound t ncbi_child_of_taxon - filter parent.rank == 'domain' || parent.rank == 'superkingdom' - return parent diff --git a/spec/views/ncbi_taxonomy/get_genetic_code.yaml b/spec/views/ncbi_taxonomy/get_genetic_code.yaml deleted file mode 100644 index 9f5801e4..00000000 --- a/spec/views/ncbi_taxonomy/get_genetic_code.yaml +++ /dev/null @@ -1,11 +0,0 @@ -params: - type: object - required: [taxon_key] - properties: - taxon_key: {type: string} -query: | - WITH ncbi_child_of_taxon, ncbi_taxon - let taxon_key = @taxon_key - for t in ncbi_taxon - filter t._key == taxon_key - return t.gencode diff --git a/spec/views/ncbi_taxonomy/get_kingdom.yaml b/spec/views/ncbi_taxonomy/get_kingdom.yaml deleted file mode 100644 index 9ba2158d..00000000 --- a/spec/views/ncbi_taxonomy/get_kingdom.yaml +++ /dev/null @@ -1,13 +0,0 @@ -params: - type: object - required: [sci_name] - properties: - sci_name: {type: string} -query: | - WITH ncbi_child_of_taxon, ncbi_taxon - let taxon_key = @taxon_key - for t in ncbi_taxon - filter t._key == taxon_key - for parent in 1..10 outbound t ncbi_child_of_taxon - filter parent.rank == 'kingdom' - return parent diff --git a/spec/views/ncbi_taxonomy/get_parent.yaml b/spec/views/ncbi_taxonomy/get_parent.yaml deleted file mode 100644 index 53159d8a..00000000 --- a/spec/views/ncbi_taxonomy/get_parent.yaml +++ /dev/null @@ -1,14 +0,0 @@ -params: - type: object - required: [taxon_key] - properties: - taxon_key: {type: string} -query: | - WITH ncbi_child_of_taxon, ncbi_taxon - let taxon_key = @taxon_key - return FIRST( - for t in ncbi_taxon - filter t._key == taxon_key - for parent in 1..1 outbound t ncbi_child_of_taxon - return parent - ) diff --git a/spec/views/ncbi_taxonomy/get_scientific_lineage.yaml b/spec/views/ncbi_taxonomy/get_scientific_lineage.yaml deleted file mode 100644 index 21f62d9f..00000000 --- a/spec/views/ncbi_taxonomy/get_scientific_lineage.yaml +++ /dev/null @@ -1,12 +0,0 @@ -params: - type: object - required: [taxon_key] - properties: - taxon_key: {type: string} -query: | - WITH ncbi_child_of_taxon, ncbi_taxon - let taxon_key = @taxon_key - for t in ncbi_taxon - filter t._key == taxon_key - for parent in 1..10 outbound t ncbi_child_of_taxon - return parent.scientific_name diff --git a/spec/views/ncbi_taxonomy/get_scientific_name.yaml b/spec/views/ncbi_taxonomy/get_scientific_name.yaml deleted file mode 100644 index dbbd99be..00000000 --- a/spec/views/ncbi_taxonomy/get_scientific_name.yaml +++ /dev/null @@ -1,11 +0,0 @@ -params: - type: object - required: [taxon_key] - properties: - taxon_key: {type: string} -query: | - WITH ncbi_child_of_taxon, ncbi_taxon - let taxon_key = @taxon_key - for t in ncbi_taxon - filter t._key == taxon_key - return t.scientific_name diff --git a/spec/views/ncbi_taxonomy/get_taxonomic_id.yaml b/spec/views/ncbi_taxonomy/get_taxonomic_id.yaml deleted file mode 100644 index 753f568d..00000000 --- a/spec/views/ncbi_taxonomy/get_taxonomic_id.yaml +++ /dev/null @@ -1,15 +0,0 @@ -params: - type: object - required: [sci_name] - properties: - sci_name: {type: string} -query: | - for - let my_docs = (...) - // Get the taxon ID from scientific name - WITH ncbi_child_of_taxon, ncbi_taxon - let sci_name = @sci_name - FILTER doc.somethihng == 'what' - for t in ncbi_taxon - filter t.scientific_name == sci_name - return t._key From ce912747ef7228644c39af24830c8b0b80d531ec Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Mon, 22 Jul 2019 15:03:28 -0700 Subject: [PATCH 319/732] Reorganize some of the schemas and make them yaml (#66) * Add some example ncbi taxonomy queries * Reorganize schema directory structure, and convert them all to yaml * Delete views that we dont need here --- spec/Dockerfile | 4 +- spec/Makefile | 5 +- spec/schemas/README.md | 13 +- .../edges/gtdb/gtdb_child_of_taxon.json | 22 ---- spec/schemas/edges/mash/README.md | 1 - .../edges/mash/mash_genome_similar_to.json | 18 --- .../edges/ncbi/ncbi_child_of_taxon.json | 22 ---- .../edges/ncbi/ncbi_gene_within_genome.json | 15 --- .../rxn/rxn_compound_linked_to_compound.json | 16 --- .../rxn/rxn_compound_within_reaction.json | 22 ---- .../edges/rxn/rxn_gene_within_complex.json | 15 --- .../rxn/rxn_reaction_linked_to_reaction.json | 16 --- .../rxn/rxn_reaction_within_complex.json | 15 --- .../edges/rxn/rxn_similar_to_reaction.json | 18 --- spec/schemas/edges/test_edge.json | 11 -- .../edges/wsfull/wsfull_copied_from.json | 10 -- .../wsfull/wsfull_latest_version_of.json | 24 ---- .../wsfull/wsfull_module_contains_method.json | 17 --- .../wsfull_obj_created_with_method.json | 26 ---- .../wsfull_obj_created_with_module.json | 18 --- .../wsfull/wsfull_obj_instance_of_type.json | 11 -- .../schemas/edges/wsfull/wsfull_owner_of.json | 24 ---- .../wsfull/wsfull_prov_descendant_of.json | 11 -- .../edges/wsfull/wsfull_refers_to.json | 10 -- .../wsfull_type_consumed_by_method.json | 19 --- .../edges/wsfull/wsfull_version_of.json | 30 ----- .../edges/wsfull/wsfull_ws_contains_obj.json | 17 --- spec/schemas/edges/wsfull/wsfull_ws_perm.json | 28 ----- .../edges/wsprov/wsprov_copied_into.json | 17 --- .../schemas/edges/wsprov/wsprov_input_in.json | 18 --- spec/schemas/edges/wsprov/wsprov_links.json | 17 --- .../schemas/edges/wsprov/wsprov_produced.json | 16 --- spec/schemas/{edges => }/gtdb/README.md | 0 spec/schemas/gtdb/gtdb_child_of_taxon.yaml | 18 +++ spec/schemas/gtdb/gtdb_organism.yaml | 14 +++ spec/schemas/gtdb/gtdb_taxon.yaml | 34 ++++++ spec/schemas/mash/mash_genome_similar_to.yaml | 14 +++ spec/schemas/{edges => }/ncbi/README.md | 0 spec/schemas/ncbi/ncbi_child_of_taxon.yaml | 18 +++ spec/schemas/ncbi/ncbi_gene.yaml | 85 +++++++++++++ .../schemas/ncbi/ncbi_gene_within_genome.yaml | 13 ++ spec/schemas/ncbi/ncbi_genome.yaml | 100 +++++++++++++++ spec/schemas/ncbi/ncbi_taxon.yaml | 104 ++++++++++++++++ spec/schemas/{edges => }/rxn/README.md | 0 spec/schemas/rxn/rxn_compound.yaml | 70 +++++++++++ .../rxn/rxn_compound_linked_to_compound.yaml | 16 +++ .../rxn/rxn_compound_within_reaction.yaml | 18 +++ spec/schemas/rxn/rxn_gene_complex.yaml | 24 ++++ spec/schemas/rxn/rxn_gene_within_complex.yaml | 13 ++ spec/schemas/rxn/rxn_reaction.yaml | 53 ++++++++ .../rxn/rxn_reaction_linked_to_reaction.yaml | 17 +++ .../rxn/rxn_reaction_within_complex.yaml | 13 ++ spec/schemas/rxn/rxn_similar_to_reaction.yaml | 15 +++ spec/schemas/test/test_edge.yaml | 10 ++ spec/schemas/test/test_vertex.yaml | 11 ++ spec/schemas/vertices/README.md | 1 - spec/schemas/vertices/gtdb/README.md | 7 -- spec/schemas/vertices/gtdb/gtdb_taxon.json | 67 ---------- spec/schemas/vertices/ncbi/README.md | 1 - spec/schemas/vertices/ncbi/ncbi_gene.json | 114 ------------------ spec/schemas/vertices/ncbi/ncbi_genome.json | 97 --------------- spec/schemas/vertices/ncbi/ncbi_taxon.json | 81 ------------- spec/schemas/vertices/rxn/README.md | 1 - spec/schemas/vertices/rxn/rxn_compound.json | 88 -------------- .../vertices/rxn/rxn_gene_complex.json | 27 ----- spec/schemas/vertices/rxn/rxn_reaction.json | 64 ---------- spec/schemas/vertices/test_vertex.json | 12 -- spec/schemas/vertices/wsfull/README.md | 5 - .../vertices/wsfull/wsfull_method.json | 17 --- .../wsfull/wsfull_method_version.json | 56 --------- .../vertices/wsfull/wsfull_module.json | 29 ----- .../wsfull/wsfull_module_version.json | 52 -------- .../vertices/wsfull/wsfull_object.json | 34 ------ .../vertices/wsfull/wsfull_object_hash.json | 26 ---- .../wsfull/wsfull_object_version.json | 69 ----------- spec/schemas/vertices/wsfull/wsfull_type.json | 15 --- .../vertices/wsfull/wsfull_type_module.json | 15 --- .../vertices/wsfull/wsfull_type_version.json | 15 --- spec/schemas/vertices/wsfull/wsfull_user.json | 16 --- .../vertices/wsfull/wsfull_workspace.json | 50 -------- spec/schemas/vertices/wsprov/README.md | 1 - .../vertices/wsprov/wsprov_action.json | 26 ---- .../vertices/wsprov/wsprov_object.json | 25 ---- spec/schemas/{edges => }/wsfull/README.md | 0 spec/schemas/wsfull/wsfull_copied_from.yaml | 10 ++ .../wsfull/wsfull_latest_version_of.yaml | 25 ++++ spec/schemas/wsfull/wsfull_method.yaml | 14 +++ .../schemas/wsfull/wsfull_method_version.yaml | 40 ++++++ spec/schemas/wsfull/wsfull_module.yaml | 20 +++ .../wsfull/wsfull_module_contains_method.yaml | 14 +++ .../schemas/wsfull/wsfull_module_version.yaml | 38 ++++++ .../wsfull_obj_created_with_method.yaml | 23 ++++ .../wsfull_obj_created_with_module.yaml | 16 +++ .../wsfull/wsfull_obj_instance_of_type.yaml | 11 ++ spec/schemas/wsfull/wsfull_object.yaml | 23 ++++ spec/schemas/wsfull/wsfull_object_hash.yaml | 16 +++ .../schemas/wsfull/wsfull_object_version.yaml | 54 +++++++++ spec/schemas/wsfull/wsfull_owner_of.yaml | 19 +++ .../wsfull/wsfull_prov_descendant_of.yaml | 10 ++ spec/schemas/wsfull/wsfull_refers_to.yaml | 10 ++ spec/schemas/wsfull/wsfull_type.yaml | 12 ++ .../wsfull_type_consumed_by_method.yaml | 15 +++ spec/schemas/wsfull/wsfull_type_module.yaml | 12 ++ spec/schemas/wsfull/wsfull_type_version.yaml | 12 ++ spec/schemas/wsfull/wsfull_user.yaml | 14 +++ spec/schemas/wsfull/wsfull_version_of.yaml | 28 +++++ spec/schemas/wsfull/wsfull_workspace.yaml | 35 ++++++ .../wsfull/wsfull_ws_contains_obj.yaml | 14 +++ spec/schemas/wsfull/wsfull_ws_perm.yaml | 23 ++++ spec/schemas/{edges => }/wsprov/README.md | 0 spec/schemas/wsprov/wsprov_action.yaml | 18 +++ spec/schemas/wsprov/wsprov_copied_into.yaml | 14 +++ spec/schemas/wsprov/wsprov_input_in.yaml | 14 +++ spec/schemas/wsprov/wsprov_links.yaml | 14 +++ spec/schemas/wsprov/wsprov_object.yaml | 18 +++ spec/schemas/wsprov/wsprov_produced.yaml | 14 +++ spec/test/validate.py | 51 ++++---- 117 files changed, 1299 insertions(+), 1549 deletions(-) delete mode 100644 spec/schemas/edges/gtdb/gtdb_child_of_taxon.json delete mode 100644 spec/schemas/edges/mash/README.md delete mode 100644 spec/schemas/edges/mash/mash_genome_similar_to.json delete mode 100644 spec/schemas/edges/ncbi/ncbi_child_of_taxon.json delete mode 100644 spec/schemas/edges/ncbi/ncbi_gene_within_genome.json delete mode 100644 spec/schemas/edges/rxn/rxn_compound_linked_to_compound.json delete mode 100644 spec/schemas/edges/rxn/rxn_compound_within_reaction.json delete mode 100644 spec/schemas/edges/rxn/rxn_gene_within_complex.json delete mode 100644 spec/schemas/edges/rxn/rxn_reaction_linked_to_reaction.json delete mode 100644 spec/schemas/edges/rxn/rxn_reaction_within_complex.json delete mode 100644 spec/schemas/edges/rxn/rxn_similar_to_reaction.json delete mode 100644 spec/schemas/edges/test_edge.json delete mode 100644 spec/schemas/edges/wsfull/wsfull_copied_from.json delete mode 100644 spec/schemas/edges/wsfull/wsfull_latest_version_of.json delete mode 100644 spec/schemas/edges/wsfull/wsfull_module_contains_method.json delete mode 100644 spec/schemas/edges/wsfull/wsfull_obj_created_with_method.json delete mode 100644 spec/schemas/edges/wsfull/wsfull_obj_created_with_module.json delete mode 100644 spec/schemas/edges/wsfull/wsfull_obj_instance_of_type.json delete mode 100644 spec/schemas/edges/wsfull/wsfull_owner_of.json delete mode 100644 spec/schemas/edges/wsfull/wsfull_prov_descendant_of.json delete mode 100644 spec/schemas/edges/wsfull/wsfull_refers_to.json delete mode 100644 spec/schemas/edges/wsfull/wsfull_type_consumed_by_method.json delete mode 100644 spec/schemas/edges/wsfull/wsfull_version_of.json delete mode 100644 spec/schemas/edges/wsfull/wsfull_ws_contains_obj.json delete mode 100644 spec/schemas/edges/wsfull/wsfull_ws_perm.json delete mode 100644 spec/schemas/edges/wsprov/wsprov_copied_into.json delete mode 100644 spec/schemas/edges/wsprov/wsprov_input_in.json delete mode 100644 spec/schemas/edges/wsprov/wsprov_links.json delete mode 100644 spec/schemas/edges/wsprov/wsprov_produced.json rename spec/schemas/{edges => }/gtdb/README.md (100%) create mode 100644 spec/schemas/gtdb/gtdb_child_of_taxon.yaml create mode 100644 spec/schemas/gtdb/gtdb_organism.yaml create mode 100644 spec/schemas/gtdb/gtdb_taxon.yaml create mode 100644 spec/schemas/mash/mash_genome_similar_to.yaml rename spec/schemas/{edges => }/ncbi/README.md (100%) create mode 100644 spec/schemas/ncbi/ncbi_child_of_taxon.yaml create mode 100644 spec/schemas/ncbi/ncbi_gene.yaml create mode 100644 spec/schemas/ncbi/ncbi_gene_within_genome.yaml create mode 100644 spec/schemas/ncbi/ncbi_genome.yaml create mode 100644 spec/schemas/ncbi/ncbi_taxon.yaml rename spec/schemas/{edges => }/rxn/README.md (100%) create mode 100644 spec/schemas/rxn/rxn_compound.yaml create mode 100644 spec/schemas/rxn/rxn_compound_linked_to_compound.yaml create mode 100644 spec/schemas/rxn/rxn_compound_within_reaction.yaml create mode 100644 spec/schemas/rxn/rxn_gene_complex.yaml create mode 100644 spec/schemas/rxn/rxn_gene_within_complex.yaml create mode 100644 spec/schemas/rxn/rxn_reaction.yaml create mode 100644 spec/schemas/rxn/rxn_reaction_linked_to_reaction.yaml create mode 100644 spec/schemas/rxn/rxn_reaction_within_complex.yaml create mode 100644 spec/schemas/rxn/rxn_similar_to_reaction.yaml create mode 100644 spec/schemas/test/test_edge.yaml create mode 100644 spec/schemas/test/test_vertex.yaml delete mode 100644 spec/schemas/vertices/README.md delete mode 100644 spec/schemas/vertices/gtdb/README.md delete mode 100644 spec/schemas/vertices/gtdb/gtdb_taxon.json delete mode 100644 spec/schemas/vertices/ncbi/README.md delete mode 100644 spec/schemas/vertices/ncbi/ncbi_gene.json delete mode 100644 spec/schemas/vertices/ncbi/ncbi_genome.json delete mode 100644 spec/schemas/vertices/ncbi/ncbi_taxon.json delete mode 100644 spec/schemas/vertices/rxn/README.md delete mode 100644 spec/schemas/vertices/rxn/rxn_compound.json delete mode 100644 spec/schemas/vertices/rxn/rxn_gene_complex.json delete mode 100644 spec/schemas/vertices/rxn/rxn_reaction.json delete mode 100644 spec/schemas/vertices/test_vertex.json delete mode 100644 spec/schemas/vertices/wsfull/README.md delete mode 100644 spec/schemas/vertices/wsfull/wsfull_method.json delete mode 100644 spec/schemas/vertices/wsfull/wsfull_method_version.json delete mode 100644 spec/schemas/vertices/wsfull/wsfull_module.json delete mode 100644 spec/schemas/vertices/wsfull/wsfull_module_version.json delete mode 100644 spec/schemas/vertices/wsfull/wsfull_object.json delete mode 100644 spec/schemas/vertices/wsfull/wsfull_object_hash.json delete mode 100644 spec/schemas/vertices/wsfull/wsfull_object_version.json delete mode 100644 spec/schemas/vertices/wsfull/wsfull_type.json delete mode 100644 spec/schemas/vertices/wsfull/wsfull_type_module.json delete mode 100644 spec/schemas/vertices/wsfull/wsfull_type_version.json delete mode 100644 spec/schemas/vertices/wsfull/wsfull_user.json delete mode 100644 spec/schemas/vertices/wsfull/wsfull_workspace.json delete mode 100644 spec/schemas/vertices/wsprov/README.md delete mode 100644 spec/schemas/vertices/wsprov/wsprov_action.json delete mode 100644 spec/schemas/vertices/wsprov/wsprov_object.json rename spec/schemas/{edges => }/wsfull/README.md (100%) create mode 100644 spec/schemas/wsfull/wsfull_copied_from.yaml create mode 100644 spec/schemas/wsfull/wsfull_latest_version_of.yaml create mode 100644 spec/schemas/wsfull/wsfull_method.yaml create mode 100644 spec/schemas/wsfull/wsfull_method_version.yaml create mode 100644 spec/schemas/wsfull/wsfull_module.yaml create mode 100644 spec/schemas/wsfull/wsfull_module_contains_method.yaml create mode 100644 spec/schemas/wsfull/wsfull_module_version.yaml create mode 100644 spec/schemas/wsfull/wsfull_obj_created_with_method.yaml create mode 100644 spec/schemas/wsfull/wsfull_obj_created_with_module.yaml create mode 100644 spec/schemas/wsfull/wsfull_obj_instance_of_type.yaml create mode 100644 spec/schemas/wsfull/wsfull_object.yaml create mode 100644 spec/schemas/wsfull/wsfull_object_hash.yaml create mode 100644 spec/schemas/wsfull/wsfull_object_version.yaml create mode 100644 spec/schemas/wsfull/wsfull_owner_of.yaml create mode 100644 spec/schemas/wsfull/wsfull_prov_descendant_of.yaml create mode 100644 spec/schemas/wsfull/wsfull_refers_to.yaml create mode 100644 spec/schemas/wsfull/wsfull_type.yaml create mode 100644 spec/schemas/wsfull/wsfull_type_consumed_by_method.yaml create mode 100644 spec/schemas/wsfull/wsfull_type_module.yaml create mode 100644 spec/schemas/wsfull/wsfull_type_version.yaml create mode 100644 spec/schemas/wsfull/wsfull_user.yaml create mode 100644 spec/schemas/wsfull/wsfull_version_of.yaml create mode 100644 spec/schemas/wsfull/wsfull_workspace.yaml create mode 100644 spec/schemas/wsfull/wsfull_ws_contains_obj.yaml create mode 100644 spec/schemas/wsfull/wsfull_ws_perm.yaml rename spec/schemas/{edges => }/wsprov/README.md (100%) create mode 100644 spec/schemas/wsprov/wsprov_action.yaml create mode 100644 spec/schemas/wsprov/wsprov_copied_into.yaml create mode 100644 spec/schemas/wsprov/wsprov_input_in.yaml create mode 100644 spec/schemas/wsprov/wsprov_links.yaml create mode 100644 spec/schemas/wsprov/wsprov_object.yaml create mode 100644 spec/schemas/wsprov/wsprov_produced.yaml diff --git a/spec/Dockerfile b/spec/Dockerfile index 00b007df..cdefd899 100644 --- a/spec/Dockerfile +++ b/spec/Dockerfile @@ -1,5 +1,5 @@ from python:3.7-slim -RUN pip install --upgrade pip requests jsonschema - +RUN pip install --upgrade pip requests jsonschema pyyaml +WORKDIR /app COPY . /app diff --git a/spec/Makefile b/spec/Makefile index 754353f0..a4738038 100644 --- a/spec/Makefile +++ b/spec/Makefile @@ -1,6 +1,7 @@ .PHONY: test test: - python test/validate.py - echo "Running view tests" + echo "Validating files.." + docker-compose run spec python test/validate.py + echo "Running tests.." docker-compose run spec sh -c "python /app/test/views/init_spec.py && python -m unittest discover /app/test/views" diff --git a/spec/schemas/README.md b/spec/schemas/README.md index 9ee36f9f..d9b27976 100644 --- a/spec/schemas/README.md +++ b/spec/schemas/README.md @@ -1,18 +1,13 @@ # Relation Engine Document Schemas Document schemas define a required format for each collection in the database. Schemas use the -[JSON Schema](https://json-schema.org/specification.html) specification and follow the [JSON5 -format](https://json5.org/) +[JSON Schema](https://json-schema.org/specification.html) specification. ## Guidelines -- The filename should be the name of the collection that the schema applies to. -- All schemas should be in [JSON5 format](https://json5.org/) and follow the [JSON - Schema](https://json-schema.org/) specification. -- You can add reusable JSON schema definitions by placing them in the - [`./definitions`](/src/schemas/definitions) directory. -- When writing a new schema, also make a [migration script](/src/migrations) that can update the - database. +- Every schema file should have `name`, `type` ("vertex" or "edge"), and `schema` (JSON schema) fields +- Every JSON schema should have a "$schema" field +- You can add reusable JSON schema definitions by placing them in the [`./definitions`](/src/schemas/definitions) directory. ## Testing your schema format diff --git a/spec/schemas/edges/gtdb/gtdb_child_of_taxon.json b/spec/schemas/edges/gtdb/gtdb_child_of_taxon.json deleted file mode 100644 index b28d99fc..00000000 --- a/spec/schemas/edges/gtdb/gtdb_child_of_taxon.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "required": ["_from", "_to", "child_type"], - "description": "Edges which create the taxonomy tree for GTDB taxons.", - "properties": { - "_from": { - "type": "string", - "description": "The child. A gtdb_taxon or gtdb_organism." - }, - "_to": { - "type": "string", - "description": "The parent gtdb_taxon." - }, - "child_type": { - "type": "string", - "description": "type of child node (taxon or organism)", - "enum": [ "t", "o" ] - } - } -} - diff --git a/spec/schemas/edges/mash/README.md b/spec/schemas/edges/mash/README.md deleted file mode 100644 index bd2f0214..00000000 --- a/spec/schemas/edges/mash/README.md +++ /dev/null @@ -1 +0,0 @@ -# Mash homology diff --git a/spec/schemas/edges/mash/mash_genome_similar_to.json b/spec/schemas/edges/mash/mash_genome_similar_to.json deleted file mode 100644 index 78acd476..00000000 --- a/spec/schemas/edges/mash/mash_genome_similar_to.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "required": ["_from", "_to"], - "description": "The workspace object is similar to another object", - "properties": { - "_from": { - "type": "string", - "examples": ["wsprov_object/1:2:3"] - }, - "_to": { - "type": "string", - "examples": ["wsprov_object/1:2:3"] - } - } -} - - diff --git a/spec/schemas/edges/ncbi/ncbi_child_of_taxon.json b/spec/schemas/edges/ncbi/ncbi_child_of_taxon.json deleted file mode 100644 index 8b2254cd..00000000 --- a/spec/schemas/edges/ncbi/ncbi_child_of_taxon.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "required": ["_from", "_to", "child_type"], - "description": "Edges which create the taxonomy tree for NCBI taxons.", - "properties": { - "_from": { - "type": "string", - "description": "The child. A gtdb_taxon or gtdb_organism." - }, - "_to": { - "type": "string", - "description": "The parent gtdb_taxon." - }, - "child_type": { - "type": "string", - "description": "type of child node (taxon or organism)", - "enum": [ "t", "o" ] - } - } -} - diff --git a/spec/schemas/edges/ncbi/ncbi_gene_within_genome.json b/spec/schemas/edges/ncbi/ncbi_gene_within_genome.json deleted file mode 100644 index 1d706118..00000000 --- a/spec/schemas/edges/ncbi/ncbi_gene_within_genome.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "required": ["_from", "_to"], - "properties": { - "_from": { - "type": "string", - "description": "The ncbi_gene that is part of a genome." - }, - "_to": { - "type": "string", - "description": "The ncbi_genome that contains a gene." - } - } -} diff --git a/spec/schemas/edges/rxn/rxn_compound_linked_to_compound.json b/spec/schemas/edges/rxn/rxn_compound_linked_to_compound.json deleted file mode 100644 index 5008d405..00000000 --- a/spec/schemas/edges/rxn/rxn_compound_linked_to_compound.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "required": ["_from", "_to"], - "description": "Generally these linkages indicate a that one compound has been made obsolete and replaced with the linked compound. This may arise from duplicates in the database or errors in the obsolete entity", - "properties": { - "_from": { - "type": "string", - "description": "A reaction" - }, - "_to": { - "type": "string", - "description": "Another reaction" - } - } -} diff --git a/spec/schemas/edges/rxn/rxn_compound_within_reaction.json b/spec/schemas/edges/rxn/rxn_compound_within_reaction.json deleted file mode 100644 index d4bfd498..00000000 --- a/spec/schemas/edges/rxn/rxn_compound_within_reaction.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "required": ["_from", "_to"], - "description": "A compound is a memeber of a reaction", - "additionalProperties": true, - "properties": { - "_from": { - "type": "string", - "description": "The ID of the compound" - }, - "_to": { - "type": "string", - "description": "The ID of the reaction" - }, - "stoichiometry": { - "type": "number", - "description": "The stochiometry of compound in the reaction" - } - } -} - diff --git a/spec/schemas/edges/rxn/rxn_gene_within_complex.json b/spec/schemas/edges/rxn/rxn_gene_within_complex.json deleted file mode 100644 index 3c96f786..00000000 --- a/spec/schemas/edges/rxn/rxn_gene_within_complex.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "required": ["_from", "_to"], - "properties": { - "_from": { - "type": "string", - "description": "The ncbi_gene contained within a rxn_gene_complex." - }, - "_to": { - "type": "string", - "description": "The rxn_gene_complex that contains the gene." - } - } -} diff --git a/spec/schemas/edges/rxn/rxn_reaction_linked_to_reaction.json b/spec/schemas/edges/rxn/rxn_reaction_linked_to_reaction.json deleted file mode 100644 index 668db047..00000000 --- a/spec/schemas/edges/rxn/rxn_reaction_linked_to_reaction.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "required": ["_from", "_to"], - "description": "Generally these linkages indicate a that one reaction has been made obsolete and replaced with the linked reaction. This may arise from duplicates in the database or errors in the obsolete entity", - "properties": { - "_from": { - "type": "string", - "description": "A reaction" - }, - "_to": { - "type": "string", - "description": "Another reaction" - } - } -} diff --git a/spec/schemas/edges/rxn/rxn_reaction_within_complex.json b/spec/schemas/edges/rxn/rxn_reaction_within_complex.json deleted file mode 100644 index f7f55e88..00000000 --- a/spec/schemas/edges/rxn/rxn_reaction_within_complex.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "required": ["_from", "_to"], - "properties": { - "_from": { - "type": "string", - "description": "The rxn_reaction contained within a rxn_gene_complex." - }, - "_to": { - "type": "string", - "description": "The rxn_gene_complex that produces a reaction." - } - } -} diff --git a/spec/schemas/edges/rxn/rxn_similar_to_reaction.json b/spec/schemas/edges/rxn/rxn_similar_to_reaction.json deleted file mode 100644 index 6bb3f1e1..00000000 --- a/spec/schemas/edges/rxn/rxn_similar_to_reaction.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "required": ["_from", "_to"], - "description": "A generic similarity association.", - "additionalProperties": true, - "properties": { - "_from": { - "type": "string", - "description": "The ID of a vertex" - }, - "_to": { - "type": "string", - "description": "The ID of a vertex" - } - } -} - diff --git a/spec/schemas/edges/test_edge.json b/spec/schemas/edges/test_edge.json deleted file mode 100644 index 68a5fae7..00000000 --- a/spec/schemas/edges/test_edge.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "required": ["_from", "_to"], - "description": "Example edge schema for testing.", - "properties": { - "_from": {"type": "string"}, - "_to": {"type": "string"} - } -} - diff --git a/spec/schemas/edges/wsfull/wsfull_copied_from.json b/spec/schemas/edges/wsfull/wsfull_copied_from.json deleted file mode 100644 index 0ed1e87e..00000000 --- a/spec/schemas/edges/wsfull/wsfull_copied_from.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "required": ["_from", "_to"], - "description": "The _from object was created as an exact copy of the _to object.", - "properties": { - "_from": { "type": "string" }, - "_to": { "type": "string" } - } -} diff --git a/spec/schemas/edges/wsfull/wsfull_latest_version_of.json b/spec/schemas/edges/wsfull/wsfull_latest_version_of.json deleted file mode 100644 index cbfafb0c..00000000 --- a/spec/schemas/edges/wsfull/wsfull_latest_version_of.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "additionalProperties": false, - "required": ["_from", "_to"], - "properties": { - "_from": { - "type": "string", - "examples": [ - "wsfull_type_version/KBaseGenomes.Genome‑9.0", - "wsfull_module_version/kb_uploadmethods:8ebb66e4f2c27bc4a9b7cddff7d7b0f27f4ee433" - ], - "description": "A versioned entity, representing the most recent version of an entity in a group (most likely a workspace object, module, or workspace type)." - }, - "_to": { - "type": "string", - "examples": [ - "wsfull_type/KBaseGenomes.Genome", - "wsfull_module/kb_uploadmethods" - ], - "description": "The non-versioned entity group, where all members of the group are different versions of something (eg. a workspace object, module, or workspace type)" - } - } -} diff --git a/spec/schemas/edges/wsfull/wsfull_module_contains_method.json b/spec/schemas/edges/wsfull/wsfull_module_contains_method.json deleted file mode 100644 index 015d507a..00000000 --- a/spec/schemas/edges/wsfull/wsfull_module_contains_method.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "description": "A module contains an SDK method", - "required": ["_from", "_to"], - "properties": { - "_from": { - "type": "string", - "description": "The module ID." - }, - "_to": { - "type": "string", - "description": "The SDK method ID" - } - } -} - diff --git a/spec/schemas/edges/wsfull/wsfull_obj_created_with_method.json b/spec/schemas/edges/wsfull/wsfull_obj_created_with_method.json deleted file mode 100644 index 00e7a82d..00000000 --- a/spec/schemas/edges/wsfull/wsfull_obj_created_with_method.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "additionalProperties": false, - "required": ["_from", "_to", "method_params"], - "description": "The _from WS versioned object was created by the _to SDK versioned method.", - "properties": { - "_from": { - "type": "string", - "examples": ["wsfull_object_version/35414:73:1"], - "description": "A versioned workspace object." - }, - "_to": { - "type": "string", - "examples": [ - "wsfull_method_version/kb_uploadmethods:8ebb66e4f2c27bc4a9b7cddff7d7b0f27f4ee433.import_genbank_from_staging", - "wsfull_method_version/kb_uploadmethods:UNKNOWN.import_genbank_from_staging" - ], - "description": "A version of a module with a method." - }, - "method_params": { - "type": ["array", "object", "null"], - "description": "The input parameters for the method used to create the object." - } - } -} diff --git a/spec/schemas/edges/wsfull/wsfull_obj_created_with_module.json b/spec/schemas/edges/wsfull/wsfull_obj_created_with_module.json deleted file mode 100644 index 21b65cd7..00000000 --- a/spec/schemas/edges/wsfull/wsfull_obj_created_with_module.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "additionalProperties": false, - "required": ["_from", "_to"], - "description": "The _from WS versioned object was created with the _to SDK versioned module.", - "properties": { - "_from": { - "type": "string", - "description": "The WS versioned object that was created." - }, - "_to": { - "type": "string", - "description": "The SDK versioned module that created the object." - } - } -} - diff --git a/spec/schemas/edges/wsfull/wsfull_obj_instance_of_type.json b/spec/schemas/edges/wsfull/wsfull_obj_instance_of_type.json deleted file mode 100644 index 72ca7b6f..00000000 --- a/spec/schemas/edges/wsfull/wsfull_obj_instance_of_type.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "additionalProperties": false, - "required": ["_from", "_to"], - "description": "The _from WS versioned object is an instance of the _to versioned type.", - "properties": { - "_from": { "type": "string" }, - "_to": { "type": "string" } - } -} diff --git a/spec/schemas/edges/wsfull/wsfull_owner_of.json b/spec/schemas/edges/wsfull/wsfull_owner_of.json deleted file mode 100644 index c2086803..00000000 --- a/spec/schemas/edges/wsfull/wsfull_owner_of.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "additionalProperties": false, - "description": "The user is an owner of a workspace or type module.", - "required": ["_from", "_to"], - "properties": { - "_from": { - "type": "string", - "examples": [ - "wsfull_user/jjeffryes" - ], - "description": "A username" - }, - "_to": { - "type": "string", - "examples": [ - "wsfull_type_module/KBaseGenomes", - "wsfull_workspace/35414" - ], - "description": "A Workspace or Type Module" - } - } -} diff --git a/spec/schemas/edges/wsfull/wsfull_prov_descendant_of.json b/spec/schemas/edges/wsfull/wsfull_prov_descendant_of.json deleted file mode 100644 index efee5d01..00000000 --- a/spec/schemas/edges/wsfull/wsfull_prov_descendant_of.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "required": ["_from", "_to"], - "description": "The _from object is a provenance descendant of the _to object (eg. Assembly->Reads).", - "properties": { - "_from": { "type": "string" }, - "_to": { "type": "string" } - } -} - diff --git a/spec/schemas/edges/wsfull/wsfull_refers_to.json b/spec/schemas/edges/wsfull/wsfull_refers_to.json deleted file mode 100644 index e19ba75f..00000000 --- a/spec/schemas/edges/wsfull/wsfull_refers_to.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "required": ["_from", "_to"], - "description": "The _from object has a reference to the _to object (eg. Genome->Assembly).", - "properties": { - "_from": { "type": "string" }, - "_to": { "type": "string" } - } -} diff --git a/spec/schemas/edges/wsfull/wsfull_type_consumed_by_method.json b/spec/schemas/edges/wsfull/wsfull_type_consumed_by_method.json deleted file mode 100644 index d85da19c..00000000 --- a/spec/schemas/edges/wsfull/wsfull_type_consumed_by_method.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "required": ["_from", "_to"], - "description": "The _from type is consumed by the _to SDK method", - "additionalProperties": true, - "properties": { - "_from": { - "type": "string", - "description": "The ID of the type that is consumed." - }, - "_to": { - "type": "string", - "description": "The ID of the SDK method that consumes the type." - } - } -} - - diff --git a/spec/schemas/edges/wsfull/wsfull_version_of.json b/spec/schemas/edges/wsfull/wsfull_version_of.json deleted file mode 100644 index fabb66c2..00000000 --- a/spec/schemas/edges/wsfull/wsfull_version_of.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "additionalProperties": false, - "description": "The _from entity is a version of a the _to entity (eg. type, method, module).", - "required": ["_from", "_to"], - "properties": { - "_from": { - "type": "string", - "examples": [ - "wsfull_type_version/KBaseGenomes.Genome‑9.0", - "wsfull_method_version/kb_uploadmethods:8ebb66e4f2c27bc4a9b7cddff7d7b0f27f4ee433" - ], - "description": "A versioned entity (eg. a workspace object, module, or workspace type)" - }, - "_to": { - "type": "string", - "examples": [ - "wsfull_type/KBaseGenomes.Genome", - "wsfull_method/kb_uploadmethods" - ], - "description": "The non-versioned entity group, where all members of the group are different versions of something (eg. a workspace object, module, or workspace type)." - }, - "tag": { - "type": "string", - "description": "Tags for entities managed by catalog", - "enum": ["release", "beta", "dev"] - } - } -} diff --git a/spec/schemas/edges/wsfull/wsfull_ws_contains_obj.json b/spec/schemas/edges/wsfull/wsfull_ws_contains_obj.json deleted file mode 100644 index be657c29..00000000 --- a/spec/schemas/edges/wsfull/wsfull_ws_contains_obj.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "description": "A workspace contains an object", - "required": ["_from", "_to"], - "properties": { - "_from": { - "type": "string", - "description": "The ID of the workspace" - }, - "_to": { - "type": "string", - "description": "The ID of the object" - } - } -} - diff --git a/spec/schemas/edges/wsfull/wsfull_ws_perm.json b/spec/schemas/edges/wsfull/wsfull_ws_perm.json deleted file mode 100644 index 75ecaf6c..00000000 --- a/spec/schemas/edges/wsfull/wsfull_ws_perm.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "description": "The user has permissions on a workspace.", - "required": ["_from", "_to", "perm"], - "properties": { - "perm": { - "type": "string", - "enum": ["a", "w", "r"], - "title": "Permissions", - "description": "Represents the permissions a user has on a workspace, where 'a' is 'administrator', 'w' is read/write, 'r' is readonly." - }, - "_from": { - "type": "string", - "examples": [ - "wsfull_user/jjeffryes" - ], - "description": "A username" - }, - "_to": { - "type": "string", - "examples": [ - "wsfull_workspace/35414" - ], - "description": "A workspace" - } - } -} diff --git a/spec/schemas/edges/wsprov/wsprov_copied_into.json b/spec/schemas/edges/wsprov/wsprov_copied_into.json deleted file mode 100644 index 908000bd..00000000 --- a/spec/schemas/edges/wsprov/wsprov_copied_into.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "required": ["_from", "_to"], - "description": "The object was copied into another object", - "properties": { - "_from": { - "type": "string", - "examples": ["wsprov_object/1:2:3"] - }, - "_to": { - "type": "string", - "examples": ["wsprov_object/1:2:3"] - } - } -} - diff --git a/spec/schemas/edges/wsprov/wsprov_input_in.json b/spec/schemas/edges/wsprov/wsprov_input_in.json deleted file mode 100644 index 100a5323..00000000 --- a/spec/schemas/edges/wsprov/wsprov_input_in.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "required": ["_from", "_to"], - "description": "The workspace object was input in a provenance action", - "properties": { - "_from": { - "type": "string", - "examples": ["wsprov_object/1:2:3"] - }, - "_to": { - "type": "string", - "examples": ["wsprov_action/1:2:3"] - } - } -} - - diff --git a/spec/schemas/edges/wsprov/wsprov_links.json b/spec/schemas/edges/wsprov/wsprov_links.json deleted file mode 100644 index 4f8e807c..00000000 --- a/spec/schemas/edges/wsprov/wsprov_links.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "required": ["_from", "_to"], - "description": "The object is linked to another object, through references, provenance, etc", - "properties": { - "_from": { - "type": "string", - "examples": ["wsprov_object/1:2:3"] - }, - "_to": { - "type": "string", - "examples": ["wsprov_object/1:2:3"] - } - } -} - diff --git a/spec/schemas/edges/wsprov/wsprov_produced.json b/spec/schemas/edges/wsprov/wsprov_produced.json deleted file mode 100644 index 6bd39904..00000000 --- a/spec/schemas/edges/wsprov/wsprov_produced.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "required": ["_from", "_to"], - "description": "The provenance action produced the workspace object", - "properties": { - "_from": { - "type": "string", - "examples": ["wsprov_action/1:2:3"] - }, - "_to": { - "type": "string", - "examples": ["wsprov_object/1:2:3"] - } - } -} diff --git a/spec/schemas/edges/gtdb/README.md b/spec/schemas/gtdb/README.md similarity index 100% rename from spec/schemas/edges/gtdb/README.md rename to spec/schemas/gtdb/README.md diff --git a/spec/schemas/gtdb/gtdb_child_of_taxon.yaml b/spec/schemas/gtdb/gtdb_child_of_taxon.yaml new file mode 100644 index 00000000..47f3bff2 --- /dev/null +++ b/spec/schemas/gtdb/gtdb_child_of_taxon.yaml @@ -0,0 +1,18 @@ +name: gtdb_child_of_taxon +type: edge +schema: + "$schema": http://json-schema.org/draft-07/schema# + type: object + required: [_from, _to, child_type] + description: Edges which create the taxonomy tree for GTDB taxons. + properties: + _from: + type: string + description: The child. A gtdb_taxon or gtdb_organism. + _to: + type: string + description: The parent gtdb_taxon. + child_type: + type: string + description: type of child node (taxon or organism) + enum: [t, o] diff --git a/spec/schemas/gtdb/gtdb_organism.yaml b/spec/schemas/gtdb/gtdb_organism.yaml new file mode 100644 index 00000000..4204e82a --- /dev/null +++ b/spec/schemas/gtdb/gtdb_organism.yaml @@ -0,0 +1,14 @@ +name: gtdb_organism +type: vertex +schema: + "$schema": http://json-schema.org/draft-07/schema# + type: object + description: An organism in the GTDB taxonomy tree. + required: [_key] + properties: + _key: + type: string + description: Accession ID (Refseq prefixed with 'RS_' and Genbank prefixed with 'GB_'). + examples: + - RS_GCF_001300075.1 + - GB_GCA_002387705.1 diff --git a/spec/schemas/gtdb/gtdb_taxon.yaml b/spec/schemas/gtdb/gtdb_taxon.yaml new file mode 100644 index 00000000..41808d29 --- /dev/null +++ b/spec/schemas/gtdb/gtdb_taxon.yaml @@ -0,0 +1,34 @@ +name: gtdb_taxon +type: vertex +schema: + "$schema": http://json-schema.org/draft-07/schema# + type: object + description: Template for a vertex entry in the GTDB taxonomy tree. + required: [_key, scientific_name, rank] + properties: + _key: + type: string + description: Taxon type abbreviation plus name + examples: ['d:Bacteria', 'p:Firmicutes'] + scientific_name: + type: string + title: Taxon name. + examples: + - Methylophilus methylotrophus + - Bacteria + - Firmicutes + canonical_scientific_name: + type: array + title: Canonicalized scientific name + examples: [[methylophilus, methylotrophus], [Bacteria], [Firmicutes]] + items: {type: string} + rank: + type: string + title: Taxonomic rank + examples: [Domain, Phylum] + numeric_rank: + type: integer + title: Taxonomic level + genetic_code: + type: integer + title: genetic code diff --git a/spec/schemas/mash/mash_genome_similar_to.yaml b/spec/schemas/mash/mash_genome_similar_to.yaml new file mode 100644 index 00000000..445e23c3 --- /dev/null +++ b/spec/schemas/mash/mash_genome_similar_to.yaml @@ -0,0 +1,14 @@ +name: mash_genome_similar_to +type: edge +schema: + "$schema": http://json-schema.org/draft-07/schema# + type: object + required: [_from, _to] + description: The workspace object is similar to another object + properties: + _from: + type: string + examples: ["wsprov_object/1:2:3"] + _to: + type": string + examples": ["wsprov_object/1:2:3"] diff --git a/spec/schemas/edges/ncbi/README.md b/spec/schemas/ncbi/README.md similarity index 100% rename from spec/schemas/edges/ncbi/README.md rename to spec/schemas/ncbi/README.md diff --git a/spec/schemas/ncbi/ncbi_child_of_taxon.yaml b/spec/schemas/ncbi/ncbi_child_of_taxon.yaml new file mode 100644 index 00000000..44b0cdf3 --- /dev/null +++ b/spec/schemas/ncbi/ncbi_child_of_taxon.yaml @@ -0,0 +1,18 @@ +name: ncbi_child_of_taxon +type: edge +schema: + "$schema": http://json-schema.org/draft-07/schema# + type: object + required: [_from, _to, child_type] + description: Edges which create the taxonomy tree for NCBI taxons. + properties: + _from: + type: string + description: The child. A gtdb_taxon or gtdb_organism. + _to: + type: string + description: The parent gtdb_taxon + child_type: + type: string + description: type of child node (taxon or organism) + enum: [t, o] diff --git a/spec/schemas/ncbi/ncbi_gene.yaml b/spec/schemas/ncbi/ncbi_gene.yaml new file mode 100644 index 00000000..3eef69df --- /dev/null +++ b/spec/schemas/ncbi/ncbi_gene.yaml @@ -0,0 +1,85 @@ +name: ncbi_gene +type: vertex +schema: + "$schema": http://json-schema.org/draft-07/schema# + type: object + additionalProperties: false + description: A component of a DNA sequence, such as a CDS, mRNA, etc. + required: [_key, type, location] + properties: + _key: + type: string + title: Content hash + description: Hash of the DNA sequence for this feature. + protein_translation: + type: string + title: Protein translation + description: Longest coded protein (representative protein for splice variants) + protein_translation_length: + type: integer + description: Length of protein_translation + md5_hash: + type: string + title: DNA content hash + description: md5 hash of the dna sequence that this feature encodes. + note: + type: string + description: Free-text description of this feature + functions: + type: array + title: Gene functions + items: {type: string} + functional_descriptions: + type: array + title: Gene function descriptions + items: {type: string} + type: + type: string + examples: [Gene, ncRNA, repeat, CDS, mRNA] + location: + type: array + description: A list of segments of sequence that comprise this feature + items: + contig: + type: string + description: Contig ID where this segment occurs + strand: + type: string + description: Strand where this segment occurs + enum: [+, -, ?] + start: + type: integer + description: Index in the genome sequence where this segment of the feature starts + length: + type: integer + description: Length of this segment of the feature + flags: + type: array + description: Additional flags about the feature such trans_splicing + items: {type: string} + warnings: + type: array + description: Warnings generated by the uploader about this feature + items: {type: string} + dna_sequence: + type: string + description: Nucleotide sequence for this feature. + dna_sequence_length: + type: integer + description: Total character/nucleotide length of dna_sequence + db_xrefs: + title: Database cross-references + description: IDs for these feature in other databases, grouped by database + type: object + patternProperties: + ".*": + type: array + items: {type: string} + aliases: + description: Aliases for these feature, grouped by alias type + type: object + description: All values are arrays of strings + patternProperties: + ".*": + type: array + items: {type: string} diff --git a/spec/schemas/ncbi/ncbi_gene_within_genome.yaml b/spec/schemas/ncbi/ncbi_gene_within_genome.yaml new file mode 100644 index 00000000..1d897984 --- /dev/null +++ b/spec/schemas/ncbi/ncbi_gene_within_genome.yaml @@ -0,0 +1,13 @@ +name: ncbi_gene_within_genome +type: edge +schema: + "$schema": http://json-schema.org/draft-07/schema# + type: object + required: [_from, _to] + properties: + _from: + type: string + description: The ncbi_gene that is part of a genome. + _to: + type: string + description: The ncbi_genome that contains a gene. diff --git a/spec/schemas/ncbi/ncbi_genome.yaml b/spec/schemas/ncbi/ncbi_genome.yaml new file mode 100644 index 00000000..c22bb697 --- /dev/null +++ b/spec/schemas/ncbi/ncbi_genome.yaml @@ -0,0 +1,100 @@ +name: ncbi_genome +type: vertex +schema: + "$schema": http://json-schema.org/draft-07/schema# + type: object + additionalProperties: false + description: Whole-genome metadata (genes are separate vertices) + required: + - _key + - scientific_name + - domain + properties: + _key: + type: string + description: Hash of the full set of data contained in this genome. + refseq_id: + type: string + examples: + - NC_008270.1 + description: RefSeq database accession id + scientific_name: + type: string + examples: + - Haloferax Volcanii + domain: + type: string + enum: + - Archaea + - Bacteria + - Eukarya + - Unknown + feature_counts: + type: object + additionalProperties: true + description: A count of the number of instances of each feature type such as CDSs, + repeats etc. + patternProperties: + ".*": + type: integer + dna_size: + type: integer + title: Nucleotide count + num_contigs: + type: integer + title: Number of contigs + description: Number of consensus regions of the DNA. + molecule_type: + type: string + title: Molecule type + examples: + - DNA + description: Can include genomic DNA, genomic RNA, precursor RNA, mRNA (cDNA), + ribosomal RNA, transfer RNA, small nuclear RNA, and small cytoplasmic RNA + contig_lengths: + type: array + description: Nucleotide length of each contig + items: + type: integer + contig_ids: + type: array + description: The ids of each contig in the associated assembly + items: + type: string + source: + type: string + description: The tool or database that produced the genome + examples: + - RefSeq + - Ensembl + - Phytozome + - RAST + - Prokka + - User_upload + source_id: + type: string + description: The ID assigned the to the genome by that source + release: + type: string + description: The release version of the source database for this genome if applicable + taxonomy: + type: array + description: Full taxonomy parent-to-child linkage up to the domain + examples: + - - Bacteria + - Actinobacteria + - Corynebacteriales + - Nocardiaceae + - Rhodococcus + items: + type: string + gc_content: + type: number + description: Fraction of GC pairs in the genome + is_suspect: + type: boolean + description: Flag indicating that the genome has failed to pass one or more validation + tests + notes: + type: string + description: Free text notes from the genome upload diff --git a/spec/schemas/ncbi/ncbi_taxon.yaml b/spec/schemas/ncbi/ncbi_taxon.yaml new file mode 100644 index 00000000..e92cce68 --- /dev/null +++ b/spec/schemas/ncbi/ncbi_taxon.yaml @@ -0,0 +1,104 @@ +name: ncbi_taxon +type: vertex +schema: + "$schema": http://json-schema.org/draft-07/schema# + type: object + description: Template for a vertex entry in the NCBI taxonomy tree. + required: + - _key + - scientific_name + - rank + properties: + _key: + type: string + description: NCBI Taxon id (positive integer) + examples: + - '1' + - '2053699' + scientific_name: + type: string + title: Taxon name. + examples: + - Methylophilus methylotrophus + - Bacteria + - Firmicutes + canonical_scientific_name: + type: array + title: Canonicalized scientific name + examples: + - - methylophilus + - methylotrophus + - - Bacteria + - - Firmicutes + items: + type: string + aliases: + type: array + description: Aliases + examples: + - - category: authority + name: Borreliella burgdorferi (Johnson et al. 1984) Adeolu and Gupta 2015 + canonical: + - borreliella + - burgdorferi + - johnson + - adeolu + - gupta + - category: genbank common name + name: Lyme disease spirochet + canonical: + - lyme + - disease + - spirochet + - category: synonym + name: Borrelia burgdorferi + canonical: + - borrelia + - burgdorferi + - - category: common name + name: E. coli + canonical: + - e + - coli + - category: authority + name: '"Bacterium coli commune" Escherich 1885' + canonical: + - bacterium + - coli + - commune + - escherich + - category: synonym + name: Bacterium coli + canonical: + - bacterium + - coli + items: + type: object + required: + - category + - name + - canonical + properties: + category: + type: string + name: + type: string + canonical: + type: array + items: + type: string + rank: + type: string + title: Taxonomic rank + examples: + - Domain + - Phylum + numeric_rank: + type: integer + title: Taxonomic level + NCBI_taxon_id: + type: integer + title: NCBI_taxon_id + genetic_code: + type: integer + title: genetic code diff --git a/spec/schemas/edges/rxn/README.md b/spec/schemas/rxn/README.md similarity index 100% rename from spec/schemas/edges/rxn/README.md rename to spec/schemas/rxn/README.md diff --git a/spec/schemas/rxn/rxn_compound.yaml b/spec/schemas/rxn/rxn_compound.yaml new file mode 100644 index 00000000..216f0c0f --- /dev/null +++ b/spec/schemas/rxn/rxn_compound.yaml @@ -0,0 +1,70 @@ +name: rxn_compound +type: vertex +schema: + "$schema": "http://json-schema.org/draft-07/schema#" + type: object + additionalProperties: true + description: Chemical reactions + required: [_key] + properties: + _key: + examples: [cpd02201] + pattern: ^cpd\d+$ + title: ModelSeed ID + type: string + abbreviation: + examples: [phpyr] + type: string + aliases: + examples: ["AraCyc:PYRUVATE;BiGG:pyr;BrachyCyc:PYRUVATE;KEGG:C00022"] + type: string + charge: + examples: ['-1'] + type: integer + deltag: + description: The change in Free Energy of Formation + type: [number, 'null'] + deltagerr: + description: The error associated with the Free Energy of Formation + type: [number, 'null'] + formula: + examples: [C6H6] + type: string + id: + examples: [cpd02201] + pattern: ^cpd\d+$ + title: ModelSeed ID + type: string + inchikey: + examples: [LCTONWCANYUPML-UHFFFAOYSA-M] + type: string + is_cofactor: + description: The compound is a cofactor + type: integer + is_core: + description: The compound is involved in core metabolism + type: integer + is_obsolete: + description: The compound is a deprecated + type: integer + linked_compound: + description: If the compound is deprecated, the compound that supersedes this entry + type: [string, 'null'] + mass: + description: Molecular mass of compound + type: [number, 'null'] + name: + type: string + pka: + description: Acid dissociation constants of compound + type: string + pkb: + description: Base dissociation constants of compound + type: string + smiles: + description: Structure of the compound in Simplified Molecular Input Line Entry + System + type: string + source: + description: Does this compound come from a primary database or a metabolic model? + type: string diff --git a/spec/schemas/rxn/rxn_compound_linked_to_compound.yaml b/spec/schemas/rxn/rxn_compound_linked_to_compound.yaml new file mode 100644 index 00000000..6fbb3bea --- /dev/null +++ b/spec/schemas/rxn/rxn_compound_linked_to_compound.yaml @@ -0,0 +1,16 @@ +name: rxn_compound_linked_to_compound +type: edge +schema: + "$schema": "http://json-schema.org/draft-07/schema#" + type: object + required: [_from, _to] + description: Generally these linkages indicate a that one compound has been made obsolete + and replaced with the linked compound. This may arise from duplicates in the database + or errors in the obsolete entity + properties: + _from: + type: string + description: A reaction + _to: + type: string + description: Another reaction diff --git a/spec/schemas/rxn/rxn_compound_within_reaction.yaml b/spec/schemas/rxn/rxn_compound_within_reaction.yaml new file mode 100644 index 00000000..3211e562 --- /dev/null +++ b/spec/schemas/rxn/rxn_compound_within_reaction.yaml @@ -0,0 +1,18 @@ +name: rxn_compound_within_reaction +type: edge +schema: + "$schema": "http://json-schema.org/draft-07/schema#" + type: object + required: [_from, _to] + description: A compound is a member of a reaction + additionalProperties: true + properties: + _from: + type: string + description: The ID of the compound + _to: + type: string + description: The ID of the reaction + stoichiometry: + type: number + description: The stochiometry of compound in the reaction diff --git a/spec/schemas/rxn/rxn_gene_complex.yaml b/spec/schemas/rxn/rxn_gene_complex.yaml new file mode 100644 index 00000000..1202772f --- /dev/null +++ b/spec/schemas/rxn/rxn_gene_complex.yaml @@ -0,0 +1,24 @@ +name: rxn_gene_complex +type: vertex +schema: + "$schema": "http://json-schema.org/draft-07/schema#" + type: object + additionalProperties: false + description: Groups of genes that take part in producing a chemical reaction in the + cell. + required: [_key, genes] + properties: + _key: + type: string + description: Hash of the conjunctions. + genes: + type: array + examples: [[SO_0001, SO_0001]] + description: Array of genes. + items: + type: string + description: Gene vertex _key + source: + type: string + examples: [ModelSEED, KEGG] + description: The source of the gene complex information. diff --git a/spec/schemas/rxn/rxn_gene_within_complex.yaml b/spec/schemas/rxn/rxn_gene_within_complex.yaml new file mode 100644 index 00000000..04ba6f32 --- /dev/null +++ b/spec/schemas/rxn/rxn_gene_within_complex.yaml @@ -0,0 +1,13 @@ +name: rxn_gene_within_complex +type: edge +schema: + "$schema": "http://json-schema.org/draft-07/schema#" + type: object + required: [_from, _to] + properties: + _from: + type: string + description: The ncbi_gene contained within a rxn_gene_complex. + _to: + type: string + description: The rxn_gene_complex that contains the gene. diff --git a/spec/schemas/rxn/rxn_reaction.yaml b/spec/schemas/rxn/rxn_reaction.yaml new file mode 100644 index 00000000..a8af663c --- /dev/null +++ b/spec/schemas/rxn/rxn_reaction.yaml @@ -0,0 +1,53 @@ +name: rxn_reaction +type: vertex +schema: + "$schema": "http://json-schema.org/draft-07/schema#" + type: object + additionalProperties: true + required: [_key] + description: Chemical reactions + properties: + _key: + type: string + examples: [rxn02201] + title: ModelSeed ID + pattern: "^rxn\\d+$" + direction: + type: string + enum: [">", "<", "="] + name: + type: string + description: Chemical names + examples: ["trans-2-Methyl-5-isopropylhexa-2,5-dienal dehydrogenase_c0"] + gpr: + type: string + examples: [PGN_RS01070] + ec_number: + type: string + examples: ["2.7.3.7"] + title: Enzyme Commission Number + pattern: "^\\d+\\.\\d+\\.\\d+\\.\\d+$" + bbcwn: + type: number + examples: [-108] + equation: + type: string + description: Reaction formula using compound IDs (eg. cd00443) + examples: + - "(1) cpd00443[c0] + (1) cpd02920[c0] => (1) cpd00012[c0] + (1) cpd00067[c0] + (1) cpd00683[c0]" + definition: + type: string + description: Reaction formula. Same as equation, but with compound IDs replaced with chemical names. + bigg_id: + type: string + examples: [DHPS2] + kegg_id: + type: string + examples: [R03067] + kegg_pathways: + type: string + examples: ["Folate biosynthesis"] + metacyc_pathways: + type: array + items: {type: string} + examples: [["AMINE-DEG", "Creatinine-Degradation", "Degradation"]] diff --git a/spec/schemas/rxn/rxn_reaction_linked_to_reaction.yaml b/spec/schemas/rxn/rxn_reaction_linked_to_reaction.yaml new file mode 100644 index 00000000..44a78778 --- /dev/null +++ b/spec/schemas/rxn/rxn_reaction_linked_to_reaction.yaml @@ -0,0 +1,17 @@ +name: rxn_reaction_linked_to_reaction +type: edge +schema: + "$schema": "http://json-schema.org/draft-07/schema#" + type: object + required: [_from, _to] + description: | + Generally these linkages indicate a that one reaction has been made obsolete + and replaced with the linked reaction. This may arise from duplicates in the database + or errors in the obsolete entity + properties: + _from: + type: string + description: A reaction + _to: + type: string + description: Another reaction diff --git a/spec/schemas/rxn/rxn_reaction_within_complex.yaml b/spec/schemas/rxn/rxn_reaction_within_complex.yaml new file mode 100644 index 00000000..41706aab --- /dev/null +++ b/spec/schemas/rxn/rxn_reaction_within_complex.yaml @@ -0,0 +1,13 @@ +name: rxn_reaction_within_complex +type: edge +schema: + "$schema": "http://json-schema.org/draft-07/schema#" + type: object + required: [_from, _to] + properties: + _from: + type: string + description: The rxn_reaction contained within a rxn_gene_complex. + _to: + type: string + description: The rxn_gene_complex that produces a reaction. diff --git a/spec/schemas/rxn/rxn_similar_to_reaction.yaml b/spec/schemas/rxn/rxn_similar_to_reaction.yaml new file mode 100644 index 00000000..fb13b090 --- /dev/null +++ b/spec/schemas/rxn/rxn_similar_to_reaction.yaml @@ -0,0 +1,15 @@ +name: rxn_similar_to_reaction +type: edge +schema: + "$schema": "http://json-schema.org/draft-07/schema#" + type: object + required: [_from, _to] + description: A generic similarity association between rections. + additionalProperties: true + properties: + _from: + type: string + description: The ID of a vertex + _to: + type: string + description: The ID of a vertex diff --git a/spec/schemas/test/test_edge.yaml b/spec/schemas/test/test_edge.yaml new file mode 100644 index 00000000..fab7ad6e --- /dev/null +++ b/spec/schemas/test/test_edge.yaml @@ -0,0 +1,10 @@ +name: test_edge +type: edge +schema: + "$schema": "http://json-schema.org/draft-07/schema#" + type: object + required: [_from, _to] + description: Example edge schema for testing. + properties: + _from: {type: string} + _to: {type: string} diff --git a/spec/schemas/test/test_vertex.yaml b/spec/schemas/test/test_vertex.yaml new file mode 100644 index 00000000..b2d34668 --- /dev/null +++ b/spec/schemas/test/test_vertex.yaml @@ -0,0 +1,11 @@ +name: test_vertex +type: vertex +schema: + "$schema": "http://json-schema.org/draft-07/schema#" + type: object + required: [_key] + description: An example vertex schema for testing + properties: + _key: {type: string} + is_public: {type: boolean} + ws_id: {type: integer} diff --git a/spec/schemas/vertices/README.md b/spec/schemas/vertices/README.md deleted file mode 100644 index 0bc58d97..00000000 --- a/spec/schemas/vertices/README.md +++ /dev/null @@ -1 +0,0 @@ -# Relation engine vertices diff --git a/spec/schemas/vertices/gtdb/README.md b/spec/schemas/vertices/gtdb/README.md deleted file mode 100644 index 05d97d6c..00000000 --- a/spec/schemas/vertices/gtdb/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# Genome Taxonomy Database - -KBase Relation Engine schemas for GTDB taxonomy data - -References: - -* http://gtdb.ecogenomic.org/ diff --git a/spec/schemas/vertices/gtdb/gtdb_taxon.json b/spec/schemas/vertices/gtdb/gtdb_taxon.json deleted file mode 100644 index 7d860799..00000000 --- a/spec/schemas/vertices/gtdb/gtdb_taxon.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "description": "A entry for vertices in the GTDB taxonomy tree.", - "required": ["_key", "release", "rank", "name"], - "optional": ["domain", "phylum", "class", "order", "family", "genus", "species"], - "properties": { - "_key": { - "type": "string", - "description": "Taxon type abbreviation plus name", - "examples": ["d:bacteria", "s:salmonella_enterica"] - }, - "release": { - "type": "string", - "description": "Name of the tsv file.", - "examples": ["bac_taxonomy_r83", "bac120_taxonomy_r89"] - }, - "name": { - "type": "array", - "title": "Taxon name.", - "items": { - "type": "string" - }, - "examples": [["bacteria"], ["streptococcus", "pneumoniae"]] - }, - "rank": { - "type": "string", - "title": "Taxon rank.", - "examples": ["domain", "species"] - }, - "domain": { - "type": "string", - "title": "Taxon domain.", - "example": ["bacteria"] - }, - "phylum": { - "type": "string", - "title": "Taxon phylum.", - "example": ["firmicutes", "proteobacteria"] - }, - "class": { - "type": "string", - "title": "Taxon class.", - "example": ["bacilli", "gammaproteobacteria"] - }, - "order": { - "type": "string", - "title": "Taxon order.", - "example": ["lactobacillales", "enterobacterales"] - }, - "family": { - "type": "string", - "title": "Taxon family.", - "example": ["streptococcaceae", "enterobacteriaceae"] - }, - "genus": { - "type": "string", - "title": "Taxon genus.", - "example": ["streptococcus", "salmonella"] - }, - "species": { - "type": ["string"], - "title": "Taxon species.", - "example": ["streptococcus_pneumoniae", "salmonella_enterica"] - } - } -} diff --git a/spec/schemas/vertices/ncbi/README.md b/spec/schemas/vertices/ncbi/README.md deleted file mode 100644 index d5dabfab..00000000 --- a/spec/schemas/vertices/ncbi/README.md +++ /dev/null @@ -1 +0,0 @@ -# NCBI genbank data diff --git a/spec/schemas/vertices/ncbi/ncbi_gene.json b/spec/schemas/vertices/ncbi/ncbi_gene.json deleted file mode 100644 index 751a6eae..00000000 --- a/spec/schemas/vertices/ncbi/ncbi_gene.json +++ /dev/null @@ -1,114 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "additionalProperties": false, - "description": "A component of a DNA sequence, such as a CDS, mRNA, etc.", - "required": [ - "_key", - "type", - "location" - ], - "properties": { - "_key": { - "type": "string", - "title": "Content hash", - "description": "Hash of the DNA sequence for this feature." - }, - "protein_translation": { - "type": "string", - "title": "Protein translation", - "description": "Longest coded protein (representative protein for splice variants)" - }, - "protein_translation_length": { - "type": "integer", - "description": "Length of protein_translation" - }, - "md5_hash": { - "type": "string", - "title": "DNA content hash", - "description": "md5 hash of the dna sequence that this feature encodes." - }, - "note": { - "type": "string", - "description": "Free-text description of this feature" - }, - "functions": { - "type": "array", - "title": "Gene functions", - "items": {"type": "string"} - }, - "functional_descriptions": { - "type": "array", - "title": "Gene function descriptions", - "items": {"type": "string"} - }, - "type": { - "type": "string", - "examples": ["Gene", "ncRNA", "repeat", "CDS", "mRNA"] - }, - "location": { - "type": "array", - "description": "A list of segments of sequence that comprise this feature", - "items": { - "contig": { - "type": "string", - "description": "Contig ID where this segment occurs" - }, - "strand": { - "type": "string", - "description": "Strand where this segment occurs", - "enum": ["+", "-", "?"] - }, - "start": { - "type": "integer", - "description": "Index in the genome sequence where this segment of the feature starts" - }, - "length": { - "type": "integer", - "description": "Length of this segment of the feature" - } - } - }, - "flags": { - "type": "array", - "description": "Additional flags about the feature such trans_splicing", - "items": {"type": "string"} - }, - "warnings": { - "type": "array", - "description": "Warnings generated by the uploader about this feature", - "items": {"type": "string"} - }, - "dna_sequence": { - "type": "string", - "description": "Nucleotide sequence for this feature." - }, - "dna_sequence_length": { - "type": "integer", - "description": "Total character/nucleotide length of dna_sequence" - }, - "db_xrefs": { - "title": "Database cross-references", - "description": "IDs for these feature in other databases, grouped by database", - "type": "object", - "patternProperties": { - ".*": { - "type": "array", - "items": {"type": "string"} - } - } - }, - "aliases": { - "description": "Aliases for these feature, grouped by alias type", - "type": "object", - "description": "All values are arrays of strings", - "patternProperties": { - ".*": { - "type": "array", - "items": {"type": "string"} - } - } - } - } -} - diff --git a/spec/schemas/vertices/ncbi/ncbi_genome.json b/spec/schemas/vertices/ncbi/ncbi_genome.json deleted file mode 100644 index 61f9ec73..00000000 --- a/spec/schemas/vertices/ncbi/ncbi_genome.json +++ /dev/null @@ -1,97 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "additionalProperties": false, - "description": "Whole-genome metadata (genes are separate vertices)", - "required": [ - "_key", - "scientific_name", - "domain" - ], - "properties": { - "_key": { - "type": "string", - "description": "Hash of the full set of data contained in this genome." - }, - "refseq_id": { - "type": "string", - "examples": ["NC_008270.1"], - "description": "RefSeq database accession id" - }, - "scientific_name": { - "type": "string", - "examples": ["Haloferax Volcanii"] - }, - "domain": { - "type": "string", - "enum": ["Archaea", "Bacteria", "Eukarya", "Unknown"] - }, - "feature_counts": { - "type": "object", - "additionalProperties": true, - "description": "A count of the number of instances of each feature type such as CDSs, repeats etc.", - "patternProperties": { - ".*": {"type": "integer"} - } - }, - "dna_size": { - "type": "integer", - "title": "Nucleotide count" - }, - "num_contigs": { - "type": "integer", - "title": "Number of contigs", - "description": "Number of consensus regions of the DNA." - }, - "molecule_type": { - "type": "string", - "title": "Molecule type", - "examples": ["DNA"], - "description": "Can include genomic DNA, genomic RNA, precursor RNA, mRNA (cDNA), ribosomal RNA, transfer RNA, small nuclear RNA, and small cytoplasmic RNA" - }, - "contig_lengths": { - "type": "array", - "description": "Nucleotide length of each contig", - "items": {"type": "integer"} - }, - "contig_ids": { - "type": "array", - "description": "The ids of each contig in the associated assembly", - "items": {"type": "string"} - }, - "source": { - "type": "string", - "description": "The tool or database that produced the genome", - "examples": ["RefSeq", "Ensembl", "Phytozome", "RAST", "Prokka", "User_upload"] - }, - "source_id": { - "type": "string", - "description": "The ID assigned the to the genome by that source" - }, - "release": { - "type": "string", - "description": "The release version of the source database for this genome if applicable" - }, - "taxonomy": { - "type": "array", - "description": "Full taxonomy parent-to-child linkage up to the domain", - "examples": [["Bacteria", "Actinobacteria", "Corynebacteriales", "Nocardiaceae", "Rhodococcus"]], - "items": { - "type": "string" - } - }, - "gc_content": { - "type": "number", - "description": "Fraction of GC pairs in the genome" - }, - "is_suspect": { - "type": "boolean", - "description": "Flag indicating that the genome has failed to pass one or more validation tests" - }, - "notes": { - "type": "string", - "description": "Free text notes from the genome upload" - } - } -} - diff --git a/spec/schemas/vertices/ncbi/ncbi_taxon.json b/spec/schemas/vertices/ncbi/ncbi_taxon.json deleted file mode 100644 index 08530851..00000000 --- a/spec/schemas/vertices/ncbi/ncbi_taxon.json +++ /dev/null @@ -1,81 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "description": "Template for a vertex entry in the NCBI taxonomy tree.", - "required": ["_key", "scientific_name", "rank"], - "properties": { - "_key": { - "type": "string", - "description": "NCBI Taxon id (positive integer)", - "examples": ["1", "2053699"] - }, - "scientific_name": { - "type": "string", - "title": "Taxon name.", - "examples": ["Methylophilus methylotrophus", "Bacteria", "Firmicutes"] - }, - "canonical_scientific_name": { - "type": "array", - "title": "Canonicalized scientific name", - "examples": [ [ "methylophilus", "methylotrophus" ], - ["Bacteria"], - ["Firmicutes"] - ], - "items": { "type": "string" } - }, - "aliases": { - "type": "array", - "description": "Aliases", - "examples": [ - [ {"category": "authority", - "name": "Borreliella burgdorferi (Johnson et al. 1984) Adeolu and Gupta 2015", - "canonical": ["borreliella", "burgdorferi", "johnson", "adeolu", "gupta" ]}, - {"category": "genbank common name", - "name":"Lyme disease spirochet", - "canonical": ["lyme", "disease", "spirochet"] }, - {"category":"synonym", - "name":"Borrelia burgdorferi", - "canonical": [ "borrelia", "burgdorferi" ]} - ], - - [ {"category": "common name", - "name": "E. coli", - "canonical": ["e", "coli"] }, - {"category": "authority", - "name": "\"Bacterium coli commune\" Escherich 1885", - "canonical": ["bacterium", "coli", "commune", "escherich"] }, - {"category": "synonym", - "name": "Bacterium coli", - "canonical": ["bacterium", "coli" ] } - ] - ], - "items": { - "type": "object", - "required": ["category", "name", "canonical"], - "properties": { - "category": {"type": "string"}, - "name": {"type": "string"}, - "canonical": {"type": "array", "items": {"type": "string"}} - } - - } - }, - "rank": { - "type": "string", - "title": "Taxonomic rank", - "examples": ["Domain", "Phylum"] - }, - "numeric_rank": { - "type": "integer", - "title": "Taxonomic level" - }, - "NCBI_taxon_id": { - "type": "integer", - "title": "NCBI_taxon_id" - }, - "genetic_code": { - "type": "integer", - "title": "genetic code" - } - } -} diff --git a/spec/schemas/vertices/rxn/README.md b/spec/schemas/vertices/rxn/README.md deleted file mode 100644 index 4bac805e..00000000 --- a/spec/schemas/vertices/rxn/README.md +++ /dev/null @@ -1 +0,0 @@ -# Reaction homology diff --git a/spec/schemas/vertices/rxn/rxn_compound.json b/spec/schemas/vertices/rxn/rxn_compound.json deleted file mode 100644 index ccc71935..00000000 --- a/spec/schemas/vertices/rxn/rxn_compound.json +++ /dev/null @@ -1,88 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "additionalProperties": true, - "required": ["_key"], - "description": "Chemical reactions", - "properties": { - "_key": { - "type": "string", - "examples": ["cpd02201"], - "title": "ModelSeed ID", - "pattern": "^cpd\\d+$" - }, - "abbreviation": { - "type": "string", - "examples": ["phpyr"] - }, - "aliases": { - "type": "string", - "examples": ["AraCyc:PYRUVATE;BiGG:pyr;BrachyCyc:PYRUVATE;KEGG:C00022"] - }, - "charge": { - "type": ["integer"], - "examples": ["-1"] - }, - "deltag": { - "type": ["number", "null"], - "description": "The change in Free Energy of Formation" - }, - "deltagerr": { - "type": ["number", "null"], - "description": "The error associated with the Free Energy of Formation" - }, - "formula": { - "type": "string", - "examples": ["C6H6"] - }, - "id": { - "type": "string", - "examples": ["cpd02201"], - "title": "ModelSeed ID", - "pattern": "^cpd\\d+$" - }, - "inchikey": { - "type": "string", - "examples": ["LCTONWCANYUPML-UHFFFAOYSA-M"] - }, - "is_cofactor": { - "type": "integer", - "description": "The compound is a cofactor" - }, - "is_core": { - "type": "integer", - "description": "The compound is involved in core metabolism" - }, - "is_obsolete": { - "type": "integer", - "description": "The compound is a deprecated" - }, - "linked_compound": { - "type": ["string", "null"], - "description": "If the compound is deprecated, the compound that supersedes this entry" - }, - "mass": { - "type": ["number", "null"], - "description": "Molecular mass of compound" - }, - "name": { - "type": "string" - }, - "pka": { - "type": "string", - "description": "Acid dissociation constants of compound" - }, - "pkb": { - "type": "string", - "description": "Base dissociation constants of compound" - }, - "smiles": { - "type": "string", - "description": "Structure of the compound in Simplified Molecular Input Line Entry System" - }, - "source": { - "type": "string", - "description": "Does this compound come from a primary database or a metabolic model?" - } - } -} diff --git a/spec/schemas/vertices/rxn/rxn_gene_complex.json b/spec/schemas/vertices/rxn/rxn_gene_complex.json deleted file mode 100644 index 888196b4..00000000 --- a/spec/schemas/vertices/rxn/rxn_gene_complex.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "additionalProperties": false, - "description": "Groups of genes that take part in producing a chemical reaction in the cell.", - "required": ["_key", "genes"], - "properties": { - "_key": { - "type": "string", - "description": "Hash of the conjunctions." - }, - "genes": { - "type": "array", - "examples": [["SO_0001", "SO_0001"]], - "description": "Array of genes.", - "items": { - "type": "string", - "description": "Gene vertex _key" - } - }, - "source": { - "type": "string", - "examples": ["ModelSEED", "KEGG"], - "description": "The source of the gene complex information." - } - } -} diff --git a/spec/schemas/vertices/rxn/rxn_reaction.json b/spec/schemas/vertices/rxn/rxn_reaction.json deleted file mode 100644 index 6332ff9a..00000000 --- a/spec/schemas/vertices/rxn/rxn_reaction.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "additionalProperties": true, - "required": ["_key"], - "description": "Chemical reactions", - "properties": { - "_key": { - "type": "string", - "examples": ["rxn02201"], - "title": "ModelSeed ID", - "pattern": "^rxn\\d+$" - }, - "direction": { - "type": "string", - "enum": [">", "<", "="] - }, - "name": { - "type": "string", - "description": "Chemical names", - "examples": ["trans-2-Methyl-5-isopropylhexa-2,5-dienal dehydrogenase_c0"] - }, - "gpr": { - "type": "string", - "examples": ["PGN_RS01070"] - }, - "ec_number": { - "type": "string", - "examples": ["2.7.3.7"], - "title": "Enzyme Commission Number", - "pattern": "^\\d+\\.\\d+\\.\\d+\\.\\d+$" - }, - "bbcwn": { - "type": "number", - "examples": [-108] - }, - "equation": { - "type": "string", - "description": "Reaction formula using compound IDs (eg. cd00443)", - "examples": ["(1) cpd00443[c0] + (1) cpd02920[c0] => (1) cpd00012[c0] + (1) cpd00067[c0] + (1) cpd00683[c0]"] - }, - "definition": { - "type": "string", - "description": "Reaction formula. Same as equation, but with compound IDs replaced with chemical names." - }, - "bigg_id": { - "type": "string", - "examples": ["DHPS2"] - }, - "kegg_id": { - "type": "string", - "examples": ["R03067"] - }, - "kegg_pathways": { - "type": "string", - "examples": ["Folate biosynthesis"] - }, - "metacyc_pathways": { - "type": "array", - "items": {"type": "string"}, - "examples": [["AMINE-DEG", "Creatinine-Degradation", "Degradation"]] - } - } -} diff --git a/spec/schemas/vertices/test_vertex.json b/spec/schemas/vertices/test_vertex.json deleted file mode 100644 index d43d35a7..00000000 --- a/spec/schemas/vertices/test_vertex.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "required": ["_key"], - "description": "An example vertex schema for testing", - "properties": { - "_key": {"type": "string"}, - "is_public": {"type": "boolean"}, - "ws_id": {"type": "integer"} - } -} - diff --git a/spec/schemas/vertices/wsfull/README.md b/spec/schemas/vertices/wsfull/README.md deleted file mode 100644 index a3ba8a8a..00000000 --- a/spec/schemas/vertices/wsfull/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Workspace vertices (full details) - -These schemas comprise a full, detailed sync of all the data from the KBase workspace. - -For import code, see: https://github.com/kbaseapps/relation_engine_sync diff --git a/spec/schemas/vertices/wsfull/wsfull_method.json b/spec/schemas/vertices/wsfull/wsfull_method.json deleted file mode 100644 index 2b2f2396..00000000 --- a/spec/schemas/vertices/wsfull/wsfull_method.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "description": "SDK module method (unversioned).", - "additionalProperties": false, - "required": ["_key"], - "properties": { - "_key": { - "type": "string", - "examples": [ - "kb_uploadmethods.import_fasta_as_assembly_from_staging" - ], - "description": ".", - "pattern": "^\\w+\\.\\w+$" - } - } -} diff --git a/spec/schemas/vertices/wsfull/wsfull_method_version.json b/spec/schemas/vertices/wsfull/wsfull_method_version.json deleted file mode 100644 index e646fd0c..00000000 --- a/spec/schemas/vertices/wsfull/wsfull_method_version.json +++ /dev/null @@ -1,56 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "additionalProperties": false, - "description": "A specific method within a version of an SDK module.", - "required": [ - "_key", - "module_name", - "method_name", - "commit", - "ver", - "code_url" - ], - "properties": { - "_key": { - "type": "string", - "examples": [ - "module_name:version_hash.method_name", - "module_name:UNKNOWN.method_name", - "wsfull_method_version/kb_uploadmethods:8ebb66e4f2c27bc4a9b7cddff7d7b0f27f4ee433.import_genbank_from_staging" - ], - "description": ":.", - "pattern": "^\\w+:\\w+\\.\\w+$" - }, - "module_name": { - "type": "string", - "examples": ["kb_uploadmethods"], - "pattern": "^\\w+$" - }, - "method_name": { - "type": "string", - "examples": ["import_genbank_from_staging"], - "pattern": "^\\w+$" - }, - "commit": { - "type": "string", - "examples": ["8ebb66e4f2c27bc4a9b7cddff7d7b0f27f4ee433"], - "title": "Git commit hash", - "pattern": "^\\w+$" - }, - "ver": { - "type": "string", - "examples": ["1.0.13"], - "title": "Version", - "description": "Semantic version of the module", - "pattern": "^\\d+\\.\\d+\\.\\d+$" - }, - "code_url": { - "type": "string", - "examples": [ - "https://github.com/kbaseapps/kb_uploadmethods" - ], - "title": "URL of source code" - } - } -} diff --git a/spec/schemas/vertices/wsfull/wsfull_module.json b/spec/schemas/vertices/wsfull/wsfull_module.json deleted file mode 100644 index 5442dbc1..00000000 --- a/spec/schemas/vertices/wsfull/wsfull_module.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "description": "SDK module (unversioned).", - "additionalProperties": false, - "required": [ - "_key", - "language", - "dynamic_service" - ], - "properties": { - "_key": { - "type": "string", - "examples": [ - "kb_uploadmethods" - ], - "pattern": "^\\w+$" - }, - "language": { - "type": "string", - "enum": ["python", "perl", "java", "r"], - "description": "The programing language the module is written in" - }, - "dynamic_service": { - "type": "boolean", - "description": "Indicates if the module can be run as a webservice" - } - } -} diff --git a/spec/schemas/vertices/wsfull/wsfull_module_version.json b/spec/schemas/vertices/wsfull/wsfull_module_version.json deleted file mode 100644 index 3070b661..00000000 --- a/spec/schemas/vertices/wsfull/wsfull_module_version.json +++ /dev/null @@ -1,52 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "description": "Versioned SDK Module.", - "additionalProperties": false, - "required": [ - "_key", - "name", - "commit", - "ver", - "code_url" - ], - "properties": { - "_key": { - "type": "string", - "examples": [ - "kb_uploadmethods:8ebb66e4f2c27bc4a9b7cddff7d7b0f27f4ee433" - ], - "description": ":", - "pattern": "^\\w+:\\w+$" - }, - "name": { - "type": "string", - "title": "Module name", - "examples": ["kb_uploadmethods"], - "pattern": "^\\w+$" - }, - "commit": { - "type": "string", - "examples": [ - "8ebb66e4f2c27bc4a9b7cddff7d7b0f27f4ee433" - ], - "description": "Git commit hash", - "pattern": "^\\w+$" - }, - "ver": { - "type": "string", - "examples": [ - "1.0.13" - ], - "description": "Module semantic version", - "pattern": "^\\d+\\.\\d+\\.\\d+$" - }, - "code_url": { - "type": "string", - "examples": [ - "https://github.com/kbaseapps/kb_uploadmethods" - ], - "description": "URL of source code" - } - } -} diff --git a/spec/schemas/vertices/wsfull/wsfull_object.json b/spec/schemas/vertices/wsfull/wsfull_object.json deleted file mode 100644 index 9d7f244a..00000000 --- a/spec/schemas/vertices/wsfull/wsfull_object.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "additionalProperties": false, - "required": [ - "_key", - "workspace_id", - "object_id", - "deleted" - ], - "properties": { - "_key": { - "type": "string", - "description": "The wsid/objectid for this data", - "examples": [ - "35414:73" - ], - "pattern": "^\\d+:\\d+$" - }, - "workspace_id": { - "type": "integer", - "description": "The workspace_id for this object", - "minimum": 1 - }, - "object_id": { - "type": "integer", - "description": "The permanent object id", - "minimum": 1 - }, - "deleted": { - "type": "boolean" - } - } -} diff --git a/spec/schemas/vertices/wsfull/wsfull_object_hash.json b/spec/schemas/vertices/wsfull/wsfull_object_hash.json deleted file mode 100644 index 075a5242..00000000 --- a/spec/schemas/vertices/wsfull/wsfull_object_hash.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "definitions": {}, - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "additionalProperties": false, - "required": [ - "_key", - "type" - ], - "properties": { - "_key": { - "type": "string", - "description": "The key is the hash", - "examples": [ - "2406642b28312b3ccbfb2e17e231e2c7" - ] - }, - "type": { - "type": "string", - "description": "The hashing algorithm used", - "examples": [ - "MD5" - ] - } - } -} diff --git a/spec/schemas/vertices/wsfull/wsfull_object_version.json b/spec/schemas/vertices/wsfull/wsfull_object_version.json deleted file mode 100644 index 9e78fff7..00000000 --- a/spec/schemas/vertices/wsfull/wsfull_object_version.json +++ /dev/null @@ -1,69 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "required": [ - "_key", - "workspace_id", - "object_id", - "version", - "name", - "hash", - "size", - "epoch", - "deleted" - ], - "properties": { - "_key": { - "type": "string", - "description": "The UPA for this data", - "examples": [ - "35414:73:1" - ], - "pattern": "^\\d+:\\d+:\\d+$" - }, - "workspace_id": { - "type": "integer", - "description": "The workspace_id for this object", - "minimum": 1 - }, - "object_id": { - "type": "integer", - "description": "The permanent object id", - "minimum": 1 - }, - "version": { - "type": "integer", - "description": "The object's version", - "minimum": 1 - }, - "name": { - "type": "string", - "description": "The user supplied name for this object", - "examples": [ - "my_awesome_object" - ] - }, - "hash": { - "type": "string", - "description": "The md5 hash of the workspace object", - "examples": [ - "94edd584731298befa53119cb151d82e" - ] - }, - "size": { - "type": "integer", - "description": "Size in bytes", - "default": 0, - "minimum": 0 - }, - "epoch": { - "type": "integer", - "description": "Creation time in UTC epoch", - "default": 0, - "minimum": 0 - }, - "deleted": { - "type": "boolean" - } - } -} diff --git a/spec/schemas/vertices/wsfull/wsfull_type.json b/spec/schemas/vertices/wsfull/wsfull_type.json deleted file mode 100644 index d2d5d183..00000000 --- a/spec/schemas/vertices/wsfull/wsfull_type.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "additionalProperties": false, - "required": ["_key"], - "properties": { - "_key": { - "type": "string", - "examples": [ - "KBaseGenomes.Genome" - ], - "pattern": "^\\w+\\.\\w+$" - } - } -} diff --git a/spec/schemas/vertices/wsfull/wsfull_type_module.json b/spec/schemas/vertices/wsfull/wsfull_type_module.json deleted file mode 100644 index bc33b4f8..00000000 --- a/spec/schemas/vertices/wsfull/wsfull_type_module.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "additionalProperties": false, - "required": ["_key"], - "properties": { - "_key": { - "type": "string", - "examples": [ - "KBaseGenomes" - ], - "pattern": "^\\w+$" - } - } -} diff --git a/spec/schemas/vertices/wsfull/wsfull_type_version.json b/spec/schemas/vertices/wsfull/wsfull_type_version.json deleted file mode 100644 index 86b894d1..00000000 --- a/spec/schemas/vertices/wsfull/wsfull_type_version.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "additionalProperties": false, - "required": ["_key"], - "properties": { - "_key": { - "type": "string", - "examples": [ - "KBaseGenomes.Genome‑9.0" - ], - "pattern": "^\\w+\\.\\w+-\\d+\\.\\d+$" - } - } -} diff --git a/spec/schemas/vertices/wsfull/wsfull_user.json b/spec/schemas/vertices/wsfull/wsfull_user.json deleted file mode 100644 index 7f7d963c..00000000 --- a/spec/schemas/vertices/wsfull/wsfull_user.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "additionalProperties": false, - "required": ["_key"], - "properties": { - "_key": { - "type": "string", - "description": "The username for this user", - "examples": [ - "jjeffryes", - "sean-mccorkle3." - ] - } - } -} diff --git a/spec/schemas/vertices/wsfull/wsfull_workspace.json b/spec/schemas/vertices/wsfull/wsfull_workspace.json deleted file mode 100644 index 767c9b0a..00000000 --- a/spec/schemas/vertices/wsfull/wsfull_workspace.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "required": ["_key"], - "properties": { - "_key": { - "type": "string", - "description": "The workspace ID for this workspace", - "examples": [ - "35414" - ], - "pattern": "^\\d+$" - }, - "narr_name": { - "type": "string", - "title": "Narrative name" - }, - "owner": { - "type": "string", - "title": "Username of workspace owner" - }, - "max_obj_id": { - "type": "integer", - "title": "Maximum object ID in this workspace" - }, - "lock_status": { - "type": "string", - "title": "Status of the workspace lock" - }, - "name": { - "type": "string", - "description": "The workspace name for this workspace", - "examples": [ - "jjeffryes:narrative_1534187093329" - ] - }, - "mod_epoch": { - "type": "integer", - "title": "Modified date epoch", - "description": "Timestamp of when the workspace was last modified", - "minimum": 0 - }, - "is_public": { - "type": "boolean" - }, - "is_deleted": { - "type": "boolean" - } - } -} diff --git a/spec/schemas/vertices/wsprov/README.md b/spec/schemas/vertices/wsprov/README.md deleted file mode 100644 index d6154877..00000000 --- a/spec/schemas/vertices/wsprov/README.md +++ /dev/null @@ -1 +0,0 @@ -# Simple workspace provenance data diff --git a/spec/schemas/vertices/wsprov/wsprov_action.json b/spec/schemas/vertices/wsprov/wsprov_action.json deleted file mode 100644 index fc6f2549..00000000 --- a/spec/schemas/vertices/wsprov/wsprov_action.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "required": [ - "_key", - "workspace_id", - "runner" - ], - "properties": { - "_key": { - "type": "string", - "description": "Slugified name of the action with its timestamp and workspace id", - "examples": [ "copy:123123123:42" ] - }, - "workspace_id": { - "type": "integer", - "description": "The workspace_id in which this action was performed", - "minimum": 1 - }, - "runner": { - "type": "string", - "description": "The person who ran this action" - } - } -} - diff --git a/spec/schemas/vertices/wsprov/wsprov_object.json b/spec/schemas/vertices/wsprov/wsprov_object.json deleted file mode 100644 index 333848f9..00000000 --- a/spec/schemas/vertices/wsprov/wsprov_object.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "required": [ - "_key", - "workspace_id", - "owner" - ], - "properties": { - "_key": { - "type": "string", - "description": "The workspace reference for this object", - "examples": [ "1:2:3" ] - }, - "workspace_id": { - "type": "integer", - "description": "The workspace_id for this object", - "minimum": 1 - }, - "owner": { - "type": "string", - "description": "The owner of this workspace object" - } - } -} diff --git a/spec/schemas/edges/wsfull/README.md b/spec/schemas/wsfull/README.md similarity index 100% rename from spec/schemas/edges/wsfull/README.md rename to spec/schemas/wsfull/README.md diff --git a/spec/schemas/wsfull/wsfull_copied_from.yaml b/spec/schemas/wsfull/wsfull_copied_from.yaml new file mode 100644 index 00000000..056739a8 --- /dev/null +++ b/spec/schemas/wsfull/wsfull_copied_from.yaml @@ -0,0 +1,10 @@ +name: wsfull_copied_from +type: edge +schema: + "$schema": http://json-schema.org/draft-07/schema# + type: object + required: [_from, _to] + description: The _from object was created as an exact copy of the _to object. + properties: + _from: {type: string} + _to: {type: string} diff --git a/spec/schemas/wsfull/wsfull_latest_version_of.yaml b/spec/schemas/wsfull/wsfull_latest_version_of.yaml new file mode 100644 index 00000000..e61adc1c --- /dev/null +++ b/spec/schemas/wsfull/wsfull_latest_version_of.yaml @@ -0,0 +1,25 @@ +name: wsfull_latest_version_of +type: edge +schema: + "$schema": "http://json-schema.org/draft-07/schema#" + type: object + additionalProperties: false + required: [_from, _to] + properties: + _from: + type: string + examples: + - wsfull_type_version/KBaseGenomes.Genome‑9.0 + - wsfull_module_version/kb_uploadmethods:8ebb66e4f2c27bc4a9b7cddff7d7b0f27f4ee433 + description: | + A versioned entity, representing the most recent version of an entity + in a group (most likely a workspace object, module, or workspace type). + _to: + type: string + examples: + - wsfull_type/KBaseGenomes.Genome + - wsfull_module/kb_uploadmethods + description: | + The non-versioned entity group, where all members of the group are + different versions of something (eg. a workspace object, module, or workspace + type) diff --git a/spec/schemas/wsfull/wsfull_method.yaml b/spec/schemas/wsfull/wsfull_method.yaml new file mode 100644 index 00000000..1c301042 --- /dev/null +++ b/spec/schemas/wsfull/wsfull_method.yaml @@ -0,0 +1,14 @@ +name: wsfull_method +type: vertex +schema: + "$schema": "http://json-schema.org/draft-07/schema#" + type: object + description: SDK module method (unversioned). + additionalProperties: false + required: [_key] + properties: + _key: + type: string + examples: ["kb_uploadmethods.import_fasta_as_assembly_from_staging"] + description: "." + pattern: "^\\w+\\.\\w+$" diff --git a/spec/schemas/wsfull/wsfull_method_version.yaml b/spec/schemas/wsfull/wsfull_method_version.yaml new file mode 100644 index 00000000..0b53155b --- /dev/null +++ b/spec/schemas/wsfull/wsfull_method_version.yaml @@ -0,0 +1,40 @@ +name: wsfull_method_version +type: vertex +schema: + "$schema": http://json-schema.org/draft-07/schema# + type: object + additionalProperties: false + description: A specific method within a version of an SDK module. + required: [_key, module_name, method_name, commit, ver, code_url] + properties: + _key: + type: string + examples: + - module_name:version_hash.method_name + - module_name:UNKNOWN.method_name + - wsfull_method_version/kb_uploadmethods:8ebb66e4f2c27bc4a9b7cddff7d7b0f27f4ee433.import_genbank_from_staging + description: ":." + pattern: "^\\w+:\\w+\\.\\w+$" + module_name: + type: string + examples: [kb_uploadmethods] + pattern: "^\\w+$" + method_name: + type: string + examples: [import_genbank_from_staging] + pattern: "^\\w+$" + commit: + type: string + examples: [8ebb66e4f2c27bc4a9b7cddff7d7b0f27f4ee433] + title: Git commit hash + pattern: "^\\w+$" + ver: + type: string + examples: [1.0.13] + title: Version + description: Semantic version of the module + pattern: "^\\d+\\.\\d+\\.\\d+$" + code_url: + type: string + examples: ["https://github.com/kbaseapps/kb_uploadmethods"] + title: URL of source code diff --git a/spec/schemas/wsfull/wsfull_module.yaml b/spec/schemas/wsfull/wsfull_module.yaml new file mode 100644 index 00000000..e680f1ad --- /dev/null +++ b/spec/schemas/wsfull/wsfull_module.yaml @@ -0,0 +1,20 @@ +name: wsfull_module +type: vertex +schema: + "$schema": http://json-schema.org/draft-07/schema# + type: object + description: SDK module (unversioned). + additionalProperties: false + required: [_key, language, dynamic_service] + properties: + _key: + type: string + examples: [kb_uploadmethods] + pattern: "^\\w+$" + language: + type: string + enum: [python, perl, java, r] + description: The programing language the module is written in + dynamic_service: + type: boolean + description: Indicates if the module can be run as a webservice diff --git a/spec/schemas/wsfull/wsfull_module_contains_method.yaml b/spec/schemas/wsfull/wsfull_module_contains_method.yaml new file mode 100644 index 00000000..41f7cf80 --- /dev/null +++ b/spec/schemas/wsfull/wsfull_module_contains_method.yaml @@ -0,0 +1,14 @@ +name: wsfull_module_contains_method +type: edge +schema: + "$schema": http://json-schema.org/draft-07/schema# + type: object + description: A module contains an SDK method + required: [_from, _to] + properties: + _from: + type: string + description: The module ID. + _to: + type: string + description: The SDK method ID diff --git a/spec/schemas/wsfull/wsfull_module_version.yaml b/spec/schemas/wsfull/wsfull_module_version.yaml new file mode 100644 index 00000000..2abe2fe3 --- /dev/null +++ b/spec/schemas/wsfull/wsfull_module_version.yaml @@ -0,0 +1,38 @@ +name: wsfull_module_version +type: vertex +schema: + "$schema": "http://json-schema.org/draft-07/schema#" + type: object + description: Versioned SDK Module. + additionalProperties: false + required: [_key, name, commit, ver, code_url] + properties: + _key: + type: string + examples: + - kb_uploadmethods:8ebb66e4f2c27bc4a9b7cddff7d7b0f27f4ee433 + description: ":" + pattern: "^\\w+:\\w+$" + name: + type: string + title: Module name + examples: + - kb_uploadmethods + pattern: "^\\w+$" + commit: + type: string + examples: + - 8ebb66e4f2c27bc4a9b7cddff7d7b0f27f4ee433 + description: Git commit hash + pattern: "^\\w+$" + ver: + type: string + examples: + - 1.0.13 + description: Module semantic version + pattern: "^\\d+\\.\\d+\\.\\d+$" + code_url: + type: string + examples: + - https://github.com/kbaseapps/kb_uploadmethods + description: URL of source code diff --git a/spec/schemas/wsfull/wsfull_obj_created_with_method.yaml b/spec/schemas/wsfull/wsfull_obj_created_with_method.yaml new file mode 100644 index 00000000..6ca3f7c4 --- /dev/null +++ b/spec/schemas/wsfull/wsfull_obj_created_with_method.yaml @@ -0,0 +1,23 @@ +name: wsfull_obj_created_with_method +type: edge +schema: + "$schema": http://json-schema.org/draft-07/schema# + type: object + additionalProperties: false + required: [_from, _to, method_params] + description: The _from WS versioned object was created by the _to SDK versioned method. + properties: + _from: + type: string + examples: + - wsfull_object_version/35414:73:1 + description: A versioned workspace object. + _to: + type: string + examples: + - wsfull_method_version/kb_uploadmethods:8ebb66e4f2c27bc4a9b7cddff7d7b0f27f4ee433.import_genbank_from_staging + - wsfull_method_version/kb_uploadmethods:UNKNOWN.import_genbank_from_staging + description: A version of a module with a method. + method_params: + type: [array, object, 'null'] + description: The input parameters for the method used to create the object. diff --git a/spec/schemas/wsfull/wsfull_obj_created_with_module.yaml b/spec/schemas/wsfull/wsfull_obj_created_with_module.yaml new file mode 100644 index 00000000..daa01511 --- /dev/null +++ b/spec/schemas/wsfull/wsfull_obj_created_with_module.yaml @@ -0,0 +1,16 @@ +name: wsfull_obj_created_with_module +type: edge +schema: + "$schema": http://json-schema.org/draft-07/schema# + type: object + additionalProperties: false + required: [_from, _to] + description: The _from WS versioned object was created with the _to SDK versioned + module. + properties: + _from: + type: string + description: The WS versioned object that was created. + _to: + type: string + description: The SDK versioned module that created the object. diff --git a/spec/schemas/wsfull/wsfull_obj_instance_of_type.yaml b/spec/schemas/wsfull/wsfull_obj_instance_of_type.yaml new file mode 100644 index 00000000..274c9c73 --- /dev/null +++ b/spec/schemas/wsfull/wsfull_obj_instance_of_type.yaml @@ -0,0 +1,11 @@ +name: wsfull_obj_instance_of_type +type: edge +schema: + "$schema": http://json-schema.org/draft-07/schema# + type: object + additionalProperties: false + required: [_from, _to] + description: The _from WS versioned object is an instance of the _to versioned type. + properties: + _from: {type: string} + _to: {type: string} diff --git a/spec/schemas/wsfull/wsfull_object.yaml b/spec/schemas/wsfull/wsfull_object.yaml new file mode 100644 index 00000000..0327de0f --- /dev/null +++ b/spec/schemas/wsfull/wsfull_object.yaml @@ -0,0 +1,23 @@ +name: wsfull_object +type: vertex +schema: + "$schema": http://json-schema.org/draft-07/schema# + type: object + additionalProperties: false + required: [_key, workspace_id, object_id, deleted] + properties: + _key: + type: string + description: The wsid/objectid for this data + examples: ["35414:73"] + pattern: "^\\d+:\\d+$" + workspace_id: + type: integer + description: The workspace_id for this object + minimum: 1 + object_id: + type: integer + description: The permanent object id + minimum: 1 + deleted: + type: boolean diff --git a/spec/schemas/wsfull/wsfull_object_hash.yaml b/spec/schemas/wsfull/wsfull_object_hash.yaml new file mode 100644 index 00000000..746e0fda --- /dev/null +++ b/spec/schemas/wsfull/wsfull_object_hash.yaml @@ -0,0 +1,16 @@ +name: wsfull_object_hash +type: vertex +schema: + "$schema": "http://json-schema.org/draft-07/schema#" + type: object + additionalProperties: false + required: [_key, type] + properties: + _key: + type: string + description: The key is the hash + examples: [2406642b28312b3ccbfb2e17e231e2c7] + type: + type: string + description: The hashing algorithm used + examples: [MD5] diff --git a/spec/schemas/wsfull/wsfull_object_version.yaml b/spec/schemas/wsfull/wsfull_object_version.yaml new file mode 100644 index 00000000..2ef23d5d --- /dev/null +++ b/spec/schemas/wsfull/wsfull_object_version.yaml @@ -0,0 +1,54 @@ +name: wsfull_object_version +type: vertex +schema: + "$schema": "http://json-schema.org/draft-07/schema#" + type: object + required: + - _key + - workspace_id + - object_id + - version + - name + - hash + - size + - epoch + - deleted + properties: + _key: + type: string + description: The UPA for this data + examples: ["35414:73:1"] + pattern: "^\\d+:\\d+:\\d+$" + workspace_id: + type: integer + description: The workspace_id for this object + minimum: 1 + object_id: + type: integer + description: The permanent object id + minimum: 1 + version: + type: integer + description: The object's version + minimum: 1 + name: + type: string + description: The user supplied name for this object + examples: + - my_awesome_object + hash: + type: string + description: The md5 hash of the workspace object + examples: [94edd584731298befa53119cb151d82e] + size: + type: integer + description: Size in bytes + default: 0 + minimum: 0 + epoch: + type: integer + description: Creation time in UTC epoch + default: 0 + minimum: 0 + deleted: + type: boolean diff --git a/spec/schemas/wsfull/wsfull_owner_of.yaml b/spec/schemas/wsfull/wsfull_owner_of.yaml new file mode 100644 index 00000000..4ada3b72 --- /dev/null +++ b/spec/schemas/wsfull/wsfull_owner_of.yaml @@ -0,0 +1,19 @@ +name: wsfull_owner_of +type: edge +schema: + "$schema": http://json-schema.org/draft-07/schema# + type: object + additionalProperties: false + description: The user is an owner of a workspace or type module. + required: [_from, _to] + properties: + _from: + type: string + examples: ["wsfull_user/jjeffryes"] + description: A username + _to: + type: string + examples: + - wsfull_type_module/KBaseGenomes + - wsfull_workspace/35414 + description: A Workspace or Type Module diff --git a/spec/schemas/wsfull/wsfull_prov_descendant_of.yaml b/spec/schemas/wsfull/wsfull_prov_descendant_of.yaml new file mode 100644 index 00000000..255c8303 --- /dev/null +++ b/spec/schemas/wsfull/wsfull_prov_descendant_of.yaml @@ -0,0 +1,10 @@ +name: wsfull_prov_descendant_of +type: edge +schema: + "$schema": "http://json-schema.org/draft-07/schema#" + type: object + required: [_from, _to] + description: The _from object is a provenance descendant of the _to object (eg. Assembly->Reads). + properties: + _from: {type: string} + _to: {type: string} diff --git a/spec/schemas/wsfull/wsfull_refers_to.yaml b/spec/schemas/wsfull/wsfull_refers_to.yaml new file mode 100644 index 00000000..46fd8264 --- /dev/null +++ b/spec/schemas/wsfull/wsfull_refers_to.yaml @@ -0,0 +1,10 @@ +name: wsfull_refers_to +type: edge +schema: + "$schema": "http://json-schema.org/draft-07/schema#" + type: object + required: [_from, _to] + description: The _from object has a reference to the _to object (eg. Genome->Assembly). + properties: + _from: {type: string} + _to: {type: string} diff --git a/spec/schemas/wsfull/wsfull_type.yaml b/spec/schemas/wsfull/wsfull_type.yaml new file mode 100644 index 00000000..fbfb7e53 --- /dev/null +++ b/spec/schemas/wsfull/wsfull_type.yaml @@ -0,0 +1,12 @@ +name: wsfull_type +type: vertex +schema: + "$schema": "http://json-schema.org/draft-07/schema#" + type: object + additionalProperties: false + required: [_key] + properties: + _key: + type: string + examples: [KBaseGenomes.Genome] + pattern: "^\\w+\\.\\w+$" diff --git a/spec/schemas/wsfull/wsfull_type_consumed_by_method.yaml b/spec/schemas/wsfull/wsfull_type_consumed_by_method.yaml new file mode 100644 index 00000000..be39175d --- /dev/null +++ b/spec/schemas/wsfull/wsfull_type_consumed_by_method.yaml @@ -0,0 +1,15 @@ +name: wsfull_type_consumed_by_method +type: edge +schema: + "$schema": "http://json-schema.org/draft-07/schema#" + type: object + required: [_from, _to] + description: The _from type is consumed by the _to SDK method + additionalProperties: true + properties: + _from: + type: string + description: The ID of the type that is consumed. + _to: + type: string + description: The ID of the SDK method that consumes the type. diff --git a/spec/schemas/wsfull/wsfull_type_module.yaml b/spec/schemas/wsfull/wsfull_type_module.yaml new file mode 100644 index 00000000..6703d08c --- /dev/null +++ b/spec/schemas/wsfull/wsfull_type_module.yaml @@ -0,0 +1,12 @@ +name: wsfull_type_module +type: vertex +schema: + "$schema": "http://json-schema.org/draft-07/schema#" + type: object + additionalProperties: false + required: [_key] + properties: + _key: + type: string + examples: [KBaseGenomes] + pattern: "^\\w+$" diff --git a/spec/schemas/wsfull/wsfull_type_version.yaml b/spec/schemas/wsfull/wsfull_type_version.yaml new file mode 100644 index 00000000..3a351d96 --- /dev/null +++ b/spec/schemas/wsfull/wsfull_type_version.yaml @@ -0,0 +1,12 @@ +name: wsfull_type_version +type: vertex +schema: + "$schema": "http://json-schema.org/draft-07/schema#" + type: object + additionalProperties: false + required: [_key] + properties: + _key: + type: string + examples: [KBaseGenomes.Genome‑9.0] + pattern: "^\\w+\\.\\w+-\\d+\\.\\d+$" diff --git a/spec/schemas/wsfull/wsfull_user.yaml b/spec/schemas/wsfull/wsfull_user.yaml new file mode 100644 index 00000000..5a142fde --- /dev/null +++ b/spec/schemas/wsfull/wsfull_user.yaml @@ -0,0 +1,14 @@ +name: wsfull_user +type: vertex +schema: + "$schema": "http://json-schema.org/draft-07/schema#" + type: object + additionalProperties: false + required: [_key] + properties: + _key: + type: string + description: The username for this user + examples: + - jjeffryes + - sean-mccorkle3 diff --git a/spec/schemas/wsfull/wsfull_version_of.yaml b/spec/schemas/wsfull/wsfull_version_of.yaml new file mode 100644 index 00000000..a0f08e85 --- /dev/null +++ b/spec/schemas/wsfull/wsfull_version_of.yaml @@ -0,0 +1,28 @@ +name: wsfull_version_of +type: edge +schema: + "$schema": "http://json-schema.org/draft-07/schema#" + type: object + additionalProperties: false + description: The _from entity is a version of a the _to entity (eg. type, method, module). + required: [_from, _to] + properties: + _from: + type: string + examples: + - wsfull_type_version/KBaseGenomes.Genome‑9.0 + - wsfull_method_version/kb_uploadmethods:8ebb66e4f2c27bc4a9b7cddff7d7b0f27f4ee433 + description: A versioned entity (eg. a workspace object, module, or workspace type) + _to: + type: string + examples: + - wsfull_type/KBaseGenomes.Genome + - wsfull_method/kb_uploadmethods + description: | + The non-versioned entity group, where all members of the group are + different versions of something (eg. a workspace object, module, or workspace + type). + tag: + type: string + description: Tags for entities managed by catalog + enum: [release, beta, dev] diff --git a/spec/schemas/wsfull/wsfull_workspace.yaml b/spec/schemas/wsfull/wsfull_workspace.yaml new file mode 100644 index 00000000..05dfa24b --- /dev/null +++ b/spec/schemas/wsfull/wsfull_workspace.yaml @@ -0,0 +1,35 @@ +name: wsfull_workspace +type: vertex +schema: + "$schema": "http://json-schema.org/draft-07/schema#" + type: object + required: [_key] + properties: + _key: + type: string + description: The workspace ID for this workspace + examples: ['35414'] + pattern: "^\\d+$" + narr_name: + type: string + title: Narrative name + owner: + type: string + title: Username of workspace owner + max_obj_id: + type: integer + title: Maximum object ID in this workspace + lock_status: + type: string + title: Status of the workspace lock + name: + type: string + description: The workspace name for this workspace + examples: ["jjeffryes:narrative_1534187093329"] + mod_epoch: + type: integer + title: Modified date epoch + description: Timestamp of when the workspace was last modified + minimum: 0 + is_public: {type: boolean} + is_deleted: {type: boolean} diff --git a/spec/schemas/wsfull/wsfull_ws_contains_obj.yaml b/spec/schemas/wsfull/wsfull_ws_contains_obj.yaml new file mode 100644 index 00000000..ad55ad5e --- /dev/null +++ b/spec/schemas/wsfull/wsfull_ws_contains_obj.yaml @@ -0,0 +1,14 @@ +name: wsfull_ws_contains_obj +type: edge +schema: + "$schema": http://json-schema.org/draft-07/schema# + type: object + description: A workspace contains an object + required: [_from, _to] + properties: + _from: + type: string + description: The ID of the workspace + _to: + type: string + description: The ID of the object diff --git a/spec/schemas/wsfull/wsfull_ws_perm.yaml b/spec/schemas/wsfull/wsfull_ws_perm.yaml new file mode 100644 index 00000000..c7806aed --- /dev/null +++ b/spec/schemas/wsfull/wsfull_ws_perm.yaml @@ -0,0 +1,23 @@ +name: wsfull_ws_perm +type: edge +schema: + "$schema": http://json-schema.org/draft-07/schema# + type: object + description: The user has permissions on a workspace. + required: [_from, _to, perm] + properties: + perm: + type: string + enum: [a, w, r] + title: Permissions + description: | + Represents the permissions a user has on a workspace, where 'a' is + 'administrator', 'w' is read/write, 'r' is readonly. + _from: + type: string + examples: ['wsfull_user/jjeffryes'] + description: A username + _to: + type: string + examples: ['wsfull_workspace/35414'] + description: A workspace diff --git a/spec/schemas/edges/wsprov/README.md b/spec/schemas/wsprov/README.md similarity index 100% rename from spec/schemas/edges/wsprov/README.md rename to spec/schemas/wsprov/README.md diff --git a/spec/schemas/wsprov/wsprov_action.yaml b/spec/schemas/wsprov/wsprov_action.yaml new file mode 100644 index 00000000..2ab86c82 --- /dev/null +++ b/spec/schemas/wsprov/wsprov_action.yaml @@ -0,0 +1,18 @@ +name: wsprov_action +type: vertex +schema: + "$schema": http://json-schema.org/draft-07/schema# + type: object + required: [_key, workspace_id, runner] + properties: + _key: + type: string + description: Slugified name of the action with its timestamp and workspace id + examples: ['copy:123123123:42'] + workspace_id: + type: integer + description: The workspace_id in which this action was performed + minimum: 1 + runner: + type: string + description: The person who ran this action diff --git a/spec/schemas/wsprov/wsprov_copied_into.yaml b/spec/schemas/wsprov/wsprov_copied_into.yaml new file mode 100644 index 00000000..8bbc9b98 --- /dev/null +++ b/spec/schemas/wsprov/wsprov_copied_into.yaml @@ -0,0 +1,14 @@ +name: wsprov_copied_into +type: edge +schema: + "$schema": http://json-schema.org/draft-07/schema# + type: object + required: [_from, _to] + description: The object was copied into another object + properties: + _from: + type: string + examples: ['wsprov_object/1:2:3'] + _to: + type: string + examples: ['wsprov_object/1:2:3'] diff --git a/spec/schemas/wsprov/wsprov_input_in.yaml b/spec/schemas/wsprov/wsprov_input_in.yaml new file mode 100644 index 00000000..97912af8 --- /dev/null +++ b/spec/schemas/wsprov/wsprov_input_in.yaml @@ -0,0 +1,14 @@ +name: wsprov_input_in +type: edge +schema: + "$schema": http://json-schema.org/draft-07/schema# + type: object + required: [_from, _to] + description: The workspace object was input in a provenance action + properties: + _from: + type: string + examples: ['wsprov_object/1:2:3'] + _to: + type: string + examples: ['wsprov_action/1:2:3'] diff --git a/spec/schemas/wsprov/wsprov_links.yaml b/spec/schemas/wsprov/wsprov_links.yaml new file mode 100644 index 00000000..a7610c8a --- /dev/null +++ b/spec/schemas/wsprov/wsprov_links.yaml @@ -0,0 +1,14 @@ +name: wsprov_links +type: edge +schema: + "$schema": http://json-schema.org/draft-07/schema# + type: object + required: [_from, _to] + description: The object is linked to another object, through references, provenance, etc + properties: + _from: + type: string + examples: ['wsprov_object/1:2:3'] + _to: + type: string + examples: ['wsprov_object/1:2:3'] diff --git a/spec/schemas/wsprov/wsprov_object.yaml b/spec/schemas/wsprov/wsprov_object.yaml new file mode 100644 index 00000000..b40ead82 --- /dev/null +++ b/spec/schemas/wsprov/wsprov_object.yaml @@ -0,0 +1,18 @@ +name: wsprov_object +type: vertex +schema: + "$schema": http://json-schema.org/draft-07/schema# + type: object + required: [_key, workspace_id, owner] + properties: + _key: + type: string + description: The workspace reference for this object + examples: ['1:2:3'] + workspace_id: + type: integer + description: The workspace_id for this object + minimum: 1 + owner: + type: string + description: The owner of this workspace object diff --git a/spec/schemas/wsprov/wsprov_produced.yaml b/spec/schemas/wsprov/wsprov_produced.yaml new file mode 100644 index 00000000..41c9e0d4 --- /dev/null +++ b/spec/schemas/wsprov/wsprov_produced.yaml @@ -0,0 +1,14 @@ +name: wsprov_produced +type: edge +schema: + "$schema": http://json-schema.org/draft-07/schema# + type: object + required: [_from, _to] + description: The provenance action produced the workspace object + properties: + _from: + type: string + examples: ['wsprov_action/1:2:3'] + _to: + type: string + examples: ['wsprov_object/1:2:3'] diff --git a/spec/test/validate.py b/spec/test/validate.py index 31dfa246..5b4204fe 100644 --- a/spec/test/validate.py +++ b/spec/test/validate.py @@ -1,42 +1,50 @@ """ Validate everything in this repo, such as syntax, structure, etc. """ -import re import os import glob -import json +import yaml import jsonschema from jsonschema.exceptions import ValidationError +# JSON schema for vertex and edge collection schemas found in /schema +schema_schema = { + "type": "object", + "required": ["name", "type", "schema"], + "properties": { + "name": { + 'title': 'Collection name', + "type": "string", + "format": r'^[a-z_]+$' + }, + 'type': { + 'type': 'string', + 'enum': ['vertex', 'edge'] + }, + 'schema': {'type': 'object'} + } +} + def validate_json_schemas(): """Validate the syntax of all the JSON schemas.""" print('Validating JSON schemas..') names = {} # type: dict - for path in glob.iglob('schemas/**/*.json', recursive=True): + for path in glob.iglob('schemas/**/*.yaml', recursive=True): name = os.path.basename(path) - # Make sure collection is lower snake case - if not re.match(r'^[a-z_]+.json$', name): - print('Name must be lowercase, alphabetical, with underscores in ' + path) - exit(1) + print(f' validating {name}..') + with open(path) as fd: + data = yaml.safe_load(fd) + jsonschema.validate(data, schema_schema) # Check for any duplicate schema names if names.get(name): print('Duplicate schemas for name ' + name) exit(1) else: names[name] = True - # Load and parse the schema data as a python dict - with open(path, 'r') as fd: - try: - schema = json.load(fd) - except Exception as err: - print('=' * 80) - print('Unable to parse json in ' + path) - print(str(err)) - exit(1) # Make sure it can be used as a JSON schema try: - jsonschema.validate({}, schema) + jsonschema.validate({}, data['schema']) except ValidationError: pass except Exception as err: @@ -45,17 +53,18 @@ def validate_json_schemas(): print(str(err)) exit(1) # All schemas must be object types - if schema['type'] != 'object': + if data['schema']['type'] != 'object': print('Schemas must be an object. Schema in %s is not an object.' % path) exit(1) - required = schema.get('required', []) + required = data['schema'].get('required', []) # Edges must require _from and _to while vertices must require _key - if '/edges/' in path and ('_from' not in required or '_to' not in required): + if data['type'] == 'edge' and ('_from' not in required or '_to' not in required): print('Edge schemas must require _from and _to attributes in ' + path) exit(1) - elif '/vertices/' in path and '_key' not in required: + elif data['type'] == 'vertex' and '_key' not in required: print('Vertex schemas must require the _key attribute in ' + path) exit(1) + print(f'✓ {name} is valid.') print('..all valid.') From 8b153b614e36bfbc5bfb27e78f124c7c9de3985c Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 23 Jul 2019 13:58:30 -0700 Subject: [PATCH 320/732] Reorganize queries (#67) * Translate views into stored_queries, stored in yaml with JSON schema validation on the params * Barz. * Add checking of AQL syntax and presence of bind variables in every JSON schema for params. * Update many of the stored query params to have more requirements and defaults * Change the names dicts to sets in the validate script; move the config into the environment --- spec/Makefile | 5 +- spec/README.md | 4 +- spec/docker-compose.yaml | 3 + spec/stored_queries/README.md | 15 +++ .../list_genes_for_similar_reactions.yaml | 52 ++++++++++ spec/stored_queries/list_test_vertices.yaml | 6 ++ spec/stored_queries/search_compounds.yaml | 35 +++++++ spec/stored_queries/search_reactions.yaml | 35 +++++++ .../wsprov_count_linked_object_types.yaml | 60 ++++++++++++ spec/stored_queries/wsprov_fetch_copies.yaml | 48 ++++++++++ .../wsprov_fetch_linked_objects.yaml | 95 +++++++++++++++++++ .../wsprov_fetch_obj_field.yaml | 20 ++++ spec/stored_queries/wsprov_fetch_object.yaml | 14 +++ .../wsprov_fetch_paths_between_objects.yaml | 34 +++++++ .../wsprov_fetch_references.yaml | 26 +++++ .../wsprov_list_referencing_type_counts.yaml | 52 ++++++++++ spec/test/helpers.py | 34 +++++++ spec/test/run_tests.sh | 5 + spec/test/validate.py | 84 +++++++++++++--- spec/views/README.md | 13 --- .../list_genes_for_similar_reactions.aql | 41 -------- spec/views/list_test_vertices.aql | 8 -- spec/views/search_compounds.aql | 16 ---- spec/views/search_reactions.aql | 16 ---- .../wsprov_count_linked_object_types.aql | 40 -------- spec/views/wsprov_fetch_copies.aql | 23 ----- spec/views/wsprov_fetch_linked_objects.aql | 66 ------------- spec/views/wsprov_fetch_obj_field.aql | 11 --- spec/views/wsprov_fetch_object.aql | 9 -- .../wsprov_fetch_paths_between_objects.aql | 18 ---- spec/views/wsprov_fetch_references.aql | 17 ---- .../wsprov_list_referencing_type_counts.aql | 33 ------- 32 files changed, 607 insertions(+), 331 deletions(-) create mode 100644 spec/stored_queries/README.md create mode 100644 spec/stored_queries/list_genes_for_similar_reactions.yaml create mode 100644 spec/stored_queries/list_test_vertices.yaml create mode 100644 spec/stored_queries/search_compounds.yaml create mode 100644 spec/stored_queries/search_reactions.yaml create mode 100644 spec/stored_queries/wsprov_count_linked_object_types.yaml create mode 100644 spec/stored_queries/wsprov_fetch_copies.yaml create mode 100644 spec/stored_queries/wsprov_fetch_linked_objects.yaml create mode 100644 spec/stored_queries/wsprov_fetch_obj_field.yaml create mode 100644 spec/stored_queries/wsprov_fetch_object.yaml create mode 100644 spec/stored_queries/wsprov_fetch_paths_between_objects.yaml create mode 100644 spec/stored_queries/wsprov_fetch_references.yaml create mode 100644 spec/stored_queries/wsprov_list_referencing_type_counts.yaml create mode 100644 spec/test/helpers.py create mode 100644 spec/test/run_tests.sh delete mode 100644 spec/views/README.md delete mode 100644 spec/views/list_genes_for_similar_reactions.aql delete mode 100644 spec/views/list_test_vertices.aql delete mode 100644 spec/views/search_compounds.aql delete mode 100644 spec/views/search_reactions.aql delete mode 100644 spec/views/wsprov_count_linked_object_types.aql delete mode 100644 spec/views/wsprov_fetch_copies.aql delete mode 100644 spec/views/wsprov_fetch_linked_objects.aql delete mode 100644 spec/views/wsprov_fetch_obj_field.aql delete mode 100644 spec/views/wsprov_fetch_object.aql delete mode 100644 spec/views/wsprov_fetch_paths_between_objects.aql delete mode 100644 spec/views/wsprov_fetch_references.aql delete mode 100644 spec/views/wsprov_list_referencing_type_counts.aql diff --git a/spec/Makefile b/spec/Makefile index a4738038..c3baa811 100644 --- a/spec/Makefile +++ b/spec/Makefile @@ -1,7 +1,4 @@ .PHONY: test test: - echo "Validating files.." - docker-compose run spec python test/validate.py - echo "Running tests.." - docker-compose run spec sh -c "python /app/test/views/init_spec.py && python -m unittest discover /app/test/views" + docker-compose run spec sh /app/test/run_tests.sh diff --git a/spec/README.md b/spec/README.md index 92fb5841..4f000cff 100644 --- a/spec/README.md +++ b/spec/README.md @@ -1,10 +1,10 @@ # Relation Engine Spec -This repo holds the [views](views), [schemas](schemas), and [migrations](migrations) for the relation engine graph database service. +This repo holds the [stored queries](stored_queries), [schemas](schemas), and [migrations](migrations) for the relation engine graph database service. These specifications are used by the [Relation Engine API]() -* **Views** are stored [AQL queries](https://docs.arangodb.com/3.3/AQL/index.html) that can be used +* **Stored queries** are stored [AQL queries](https://docs.arangodb.com/3.3/AQL/index.html) that can be used by KBase apps to fetch data from the database. * **Schemas** are [JSON schemas](https://json-schema.org/) that define what form of data can be stored in the database's collections. diff --git a/spec/docker-compose.yaml b/spec/docker-compose.yaml index a1aa36f2..d2f7d027 100644 --- a/spec/docker-compose.yaml +++ b/spec/docker-compose.yaml @@ -11,6 +11,9 @@ services: - ${PWD}:/app depends_on: - re_api + environment: + - DB_URL=http://arangodb:8529 + - DB_USER=root # Relation Engine API re_api: diff --git a/spec/stored_queries/README.md b/spec/stored_queries/README.md new file mode 100644 index 00000000..128a1b66 --- /dev/null +++ b/spec/stored_queries/README.md @@ -0,0 +1,15 @@ +# Relation Engine Stored Queries + +Stored queries are templated AQL queries that fetch data from the database. + +Variables in stored queries are prefixed with `@`. + +The params field in each stored query should be a JSON schema of the query's parameters. + +## Required format + +Each stored query file should have a set of comments at the top describing the purpose of the query. + +## Using stored queries from the API + +See the [API docs](https://github.com/kbase/relation_engine_api) to see how to run these queries using the API. diff --git a/spec/stored_queries/list_genes_for_similar_reactions.yaml b/spec/stored_queries/list_genes_for_similar_reactions.yaml new file mode 100644 index 00000000..c508c14b --- /dev/null +++ b/spec/stored_queries/list_genes_for_similar_reactions.yaml @@ -0,0 +1,52 @@ +# Return genes associated with reactions similar to a query reaction + +name: list_genes_for_similar_reactions + +params: + type: object + required: [sf_sim, df_sim, rid] + properties: + rid: + type: string + title: Reaction id (rxn_reaction vertex id) + sf_sim: + type: number + title: Minimum structural fingerprint similarity score + df_sim: + type: number + title: Minimum difference fingerprint similarity score + exclude_self: + type: boolean + description: If true, don't include the query reactions genes + default: false + +query: | + WITH rxn_reaction + LET start = @exclude_self ? 1 : 0 + LET rxns = ( + FOR v, e IN start..1 + ANY @rid rxn_similar_to_reaction + OPTIONS {uniqueVertices: "global", bfs: true} + FILTER !e || e.sf_similarity >= @sf_sim + FILTER !e || e.df_similarity >= @df_sim + RETURN {id: v._id, key: v._key, name: v.name, definition: v.definition, "structural similarity": e.sf_similarity, "difference similarity": e.df_similarity} + ) + LET rxn_ids = rxns[*].id + LET rxn_gene_links = ( + FOR e in rxn_reaction_within_complex + FILTER e._from in rxn_ids + LET linked_gene_ids = FLATTEN( + FOR c in rxn_gene_complex + FILTER c._id == e._to + RETURN c.genes + ) + COLLECT rxn_id = e._from INTO groups KEEP linked_gene_ids + RETURN {rxn_id: rxn_id, linked_gene_ids: UNIQUE(FLATTEN(groups[*].linked_gene_ids))} + ) + LET gene_ids = UNIQUE(FLATTEN(rxn_gene_links[*].linked_gene_ids)) + LET genes = ( + FOR g in ncbi_gene + FILTER g._key IN gene_ids + RETURN {key: g._key, product: g.product, function: CONCAT_SEPARATOR(', ', g.functions), sequence: g.protein_translation} + ) + RETURN {rxns: rxns, rxn_gene_links: rxn_gene_links, genes: genes} diff --git a/spec/stored_queries/list_test_vertices.yaml b/spec/stored_queries/list_test_vertices.yaml new file mode 100644 index 00000000..8d41386d --- /dev/null +++ b/spec/stored_queries/list_test_vertices.yaml @@ -0,0 +1,6 @@ +# Test query - List all test vertices +name: list_test_vertices +query: | + for o in test_vertex + filter o.is_public || o.ws_id IN ws_ids + return o diff --git a/spec/stored_queries/search_compounds.yaml b/spec/stored_queries/search_compounds.yaml new file mode 100644 index 00000000..4f3265a7 --- /dev/null +++ b/spec/stored_queries/search_compounds.yaml @@ -0,0 +1,35 @@ +# Use ArangoSearch to search documents in the compounds index. Returns documents by ascending id. +name: search_compounds +params: + type: object + properties: + search_text: + default: '' + type: string + description: text to match to document fields + all_documents: + default: false + type: boolean + description: Ignore search text and return all documents + include_obsolete: + default: false + type: boolean + description: should obsolete documents be included? + offset: + default: 0 + type: integer + description: how many documents to skip + result_limit: + default: 10 + type: integer + description: maximum documents to return +query: | + FOR doc IN Compounds + SEARCH ANALYZER(PHRASE(doc.id, @search_text) + OR PHRASE(doc.name, @search_text) + OR PHRASE(doc.abbreviation, @search_text) + OR PHRASE(doc.aliases, @search_text), 'text_en') OR @all_documents + FILTER @include_obsolete || doc.is_obsolete == 0 + SORT doc.id + LIMIT @offset, @result_limit + RETURN doc diff --git a/spec/stored_queries/search_reactions.yaml b/spec/stored_queries/search_reactions.yaml new file mode 100644 index 00000000..e92c0a8f --- /dev/null +++ b/spec/stored_queries/search_reactions.yaml @@ -0,0 +1,35 @@ +# Use ArangoSearch to search documents in the Reactions index. Returns documents by ascending id. +name: search_reactions +params: + type: object + properties: + search_text: + default: '' + type: string + description: text to match to document fields + all_documents: + type: string + description: ignore the search_text and return all documents + default: false + include_obsolete: + type: boolean + description: should obsolete documents be included + default: false + offset: + type: integer + description: how many documents to skip + default: 0 + result_limit: + type: integer + description: Maximum documents to return + default: 10 +query: | + FOR doc IN Reactions + SEARCH ANALYZER(PHRASE(doc.id, @search_text) + OR PHRASE(doc.name, @search_text) + OR PHRASE(doc.abbreviation, @search_text) + OR PHRASE(doc.aliases, @search_text), 'text_en') OR @all_documents + FILTER @include_obsolete || doc.is_obsolete == 0 + SORT doc.id + LIMIT @offset, @result_limit + RETURN doc diff --git a/spec/stored_queries/wsprov_count_linked_object_types.yaml b/spec/stored_queries/wsprov_count_linked_object_types.yaml new file mode 100644 index 00000000..0514b94b --- /dev/null +++ b/spec/stored_queries/wsprov_count_linked_object_types.yaml @@ -0,0 +1,60 @@ +# Fetch the counts by type of ws_objects that reference an object +# Note: If both show_private and show_public are true, this will be treated as an OR +name: wsprov_count_linked_object_types +params: + type: object + required: [obj_key, type] + properties: + obj_key: + type: string + description: Key of the wsprov_object to search on + show_private: + type: boolean + description: limit to objects in workspaces that a user has access to + default: true + show_public: + type: boolean + description: limit to objects in public workspaces + default: true + type: + type: string + description: WS type to filter on + owners: + default: null + description: Array of usernames to filter by owner + anyOf: + - {type: "null"} + - type: array + items: + type: string +query: | + WITH wsprov_object + LET obj_id = concat('wsprov_object/', @obj_key) + + let out = ( + for v, e, p in 1..100 + OUTBOUND obj_id wsprov_links, wsprov_copied_into + OPTIONS {bfs: true, uniqueVertices: 'global'} + FILTER (!@type || v.ws_type == @type) + FILTER (!@owners || v.owner IN @owners) + FILTER (@show_private && @show_public) + ? (v.is_public || v.workspace_id IN ws_ids) + : (!@show_private || v.workspace_id IN ws_ids) && (!@show_public || v.is_public) + COLLECT type = v.ws_type with count into type_count + RETURN {type, type_count} + ) + + let inb = ( + for v, e, p in 1..100 + INBOUND obj_id wsprov_links, wsprov_copied_into + OPTIONS {bfs: true, uniqueVertices: 'global'} + FILTER (!@type || v.ws_type == @type) + FILTER (!@owners || v.owner IN @owners) + FILTER (@show_private && @show_public) + ? (v.is_public || v.workspace_id IN ws_ids) + : (!@show_private || v.workspace_id IN ws_ids) && (!@show_public || v.is_public) + COLLECT type = v.ws_type with count into type_count + RETURN {type, type_count} + ) + + return {out, inb} diff --git a/spec/stored_queries/wsprov_fetch_copies.yaml b/spec/stored_queries/wsprov_fetch_copies.yaml new file mode 100644 index 00000000..49d1e1be --- /dev/null +++ b/spec/stored_queries/wsprov_fetch_copies.yaml @@ -0,0 +1,48 @@ +# For a given object, fetch all the objects that it has been copied from or +# to, no matter how many nested times (copies of copies of copies, forward or backward) +# Also returns all linked objects of those copies of any nested level. +# Note: If both show_private and show_public are true, this will be treated as an OR +name: wsprov_fetch_copies +params: + type: object + required: [obj_key] + properties: + obj_key: + type: string + description: wsprov_object key to find links for + show_private: + type: boolean + description: limit to objects in workspaces that a user has access to + default: true + show_public: + type: boolean + description: limit to objects in public workspaces + default: true + result_limit: + default: 10 + type: integer + description: result limit + offset: + default: 0 + type: integer + description: result offset + types: + default: null + description: Optional array of WS types to filter on + anyOf: + - {type: 'null'} + - type: array + items: + type: string +query: | + WITH wsprov_object + LET obj_id = CONCAT('wsprov_object/', @obj_key) + FOR v, e, p IN 1..3 ANY obj_id wsprov_copied_into + OPTIONS {uniqueVertices: 'global', bfs: true} + LET simple_type = SPLIT(SPLIT(v.ws_type, '-', 1)[0], '.')[1] + FILTER (@show_private && @show_public) ? (v.is_public || v.workspace_id IN ws_ids) : + (!@show_private || v.workspace_id IN ws_ids) && (!@show_public || v.is_public) + FILTER (!@types || simple_type IN @types) + FILTER p.vertices[*].ws_type none == "KBaseGenomeAnnotations.Taxon-1.0" + LIMIT @offset, @result_limit + RETURN v diff --git a/spec/stored_queries/wsprov_fetch_linked_objects.yaml b/spec/stored_queries/wsprov_fetch_linked_objects.yaml new file mode 100644 index 00000000..4d1533db --- /dev/null +++ b/spec/stored_queries/wsprov_fetch_linked_objects.yaml @@ -0,0 +1,95 @@ +# Find all linked objects to a given object +# *** if both show_private and show_public are true, this will be treated as an OR *** +name: wsprov_fetch_linked_objects +params: + type: object + required: [obj_key] + properties: + obj_key: + type: string + description: array of private workspace ids the user has access to + show_private: + type: boolean + description: limit to objects in workspaces that a user has access to + default: true + show_public: + type: boolean + description: limit to objects in public workspaces + default: true + types: + description: list of ws types to filter on (set as null to disable) + default: null + anyOf: + - {type: 'null'} + - type: array + items: {type: string} + owners: + description: list of usernames to filter by owner (set as null to disable) + default: null + anyOf: + - {type: 'null'} + - type: array + items: {type: string} + results_limit: + default: 10 + type: integer + description: limit of total results + offset: + default: 0 + type: integer + description: result offset +query: | + WITH wsprov_object + LET obj_id = CONCAT("wsprov_object/", @obj_key) + + let out = ( + FOR v, e, p IN 1..100 + OUTBOUND obj_id wsprov_links, wsprov_copied_into + OPTIONS {uniqueVertices: "global", bfs: true} + FILTER (!@types || v.ws_type IN @types) + FILTER (!@owners || v.owner IN @owners) + FILTER (@show_private && @show_public) + ? (v.is_public || v.workspace_id IN ws_ids) + : (!@show_private || v.workspace_id IN ws_ids) && (!@show_public || v.is_public) + LIMIT @offset, @results_limit + RETURN { + vertex: { + _key: v._key, + is_public: v.is_public, + narr_name: v.narr_name, + obj_name: v.obj_name, + owner: v.owner, + save_date: v.save_date, + workspace_id: v.workspace_id, + ws_type: v.ws_type + }, + path: p + } + ) + + let inb = ( + FOR v, e, p IN 1..100 + INBOUND obj_id wsprov_links, wsprov_copied_into + OPTIONS {uniqueVertices: "global", bfs: true} + FILTER (!@types || v.ws_type IN @types) + FILTER (!@owners || v.owner IN @owners) + FILTER (@show_private && @show_public) + ? (v.is_public || v.workspace_id IN ws_ids) + : (!@show_private || v.workspace_id IN ws_ids) && (!@show_public || v.is_public) + LIMIT @offset, @results_limit + RETURN { + vertex: { + _key: v._key, + is_public: v.is_public, + narr_name: v.narr_name, + obj_name: v.obj_name, + owner: v.owner, + save_date: v.save_date, + workspace_id: v.workspace_id, + ws_type: v.ws_type + }, + path: p + } + ) + + return APPEND(out, inb) diff --git a/spec/stored_queries/wsprov_fetch_obj_field.yaml b/spec/stored_queries/wsprov_fetch_obj_field.yaml new file mode 100644 index 00000000..2d41de92 --- /dev/null +++ b/spec/stored_queries/wsprov_fetch_obj_field.yaml @@ -0,0 +1,20 @@ +# Fetch some object field for an array of object ids +name: wsprov_fetch_obj_field +params: + type: object + required: [prop, obj_ids] + properties: + prop: + type: string + description: property name that you want to fetch + obj_ids: + type: array + items: + type: string + description: array of object ids +query: | + with wsprov_object + for o in wsprov_object + filter o._id in @obj_ids + filter o.is_public || o.workspace_id IN ws_ids + return {key: o._key, @prop: o[@prop]} diff --git a/spec/stored_queries/wsprov_fetch_object.yaml b/spec/stored_queries/wsprov_fetch_object.yaml new file mode 100644 index 00000000..3f25a0b1 --- /dev/null +++ b/spec/stored_queries/wsprov_fetch_object.yaml @@ -0,0 +1,14 @@ +# Fetch a wsprov_object +name: wsprov_fetch_object +params: + type: object + required: [key] + properties: + key: + type: string + description: key of the object to fetch +query: | + for o in wsprov_object + filter o._key == @key + filter o.is_public || (o.workspace_id IN ws_ids) + return o diff --git a/spec/stored_queries/wsprov_fetch_paths_between_objects.yaml b/spec/stored_queries/wsprov_fetch_paths_between_objects.yaml new file mode 100644 index 00000000..cdb6bc06 --- /dev/null +++ b/spec/stored_queries/wsprov_fetch_paths_between_objects.yaml @@ -0,0 +1,34 @@ +# Fetch the counts of a ws_objects in the RE that is linked to a wsprov_object +# *** if both show_private and show_private are true this will be treated as an OR *** +name: wsprov_fetch_paths_between_objects +params: + type: object + required: [start_key, end_key] + properties: + start_key: + type: string + description: key of the object to start from + end_key: + type: string + description: key of the object to terminate with + show_private: + type: boolean + description: if present, limit to objects in workspaces that a user has access to + default: true + show_public: + type: boolean + description: if present, limit to objects in public workspaces + default: true + max_depth: + default: 10 + type: integer + description: longest path to explore +query: | + WITH wsprov_object + FOR v, e, path IN 1..@max_depth + ANY CONCAT('wsprov_object/', @start_key) wsprov_links + OPTIONS {'uniqueVertices': 'path', 'uniqueEdges': 'path'} + FILTER (@show_private && @show_public) ? (v.is_public || v.workspace_id IN ws_ids) : + (!@show_private || v.workspace_id IN ws_ids) && (!@show_public || v.is_public) + filter v._key == @end_key + RETURN path diff --git a/spec/stored_queries/wsprov_fetch_references.yaml b/spec/stored_queries/wsprov_fetch_references.yaml new file mode 100644 index 00000000..50dbf695 --- /dev/null +++ b/spec/stored_queries/wsprov_fetch_references.yaml @@ -0,0 +1,26 @@ +# Fetch inbound references for an object with acl +name: wsprov_fetch_references +params: + type: object + required: [obj_key] + properties: + obj_key: + type: string + description: wsprov_object ._key field that you want to query against + result_limit: + default: 10 + type: integer + description: limit of object results + offset: + default: 0 + type: integer + description: result offset for pagination +query: | + with wsprov_object + let obj_id = concat('wsprov_object/', @obj_key) + for v, e, p in 1..100 inbound obj_id wsprov_links + options {bfs: true, uniqueVertices: 'global'} + filter p.edges[*].type all == 'reference' + filter v.is_public || v.workspace_id IN ws_ids + limit @offset, @result_limit + return v diff --git a/spec/stored_queries/wsprov_list_referencing_type_counts.yaml b/spec/stored_queries/wsprov_list_referencing_type_counts.yaml new file mode 100644 index 00000000..ec6232f2 --- /dev/null +++ b/spec/stored_queries/wsprov_list_referencing_type_counts.yaml @@ -0,0 +1,52 @@ +# Fetch the counts by type of ws_objects that refference an object +# *** if both show_private and show_private are true this will be treated as an OR *** +name: wsprov_list_referencing_type_counts +params: + type: object + required: [key] + properties: + key: + type: string + description: key of the object to start from + show_private: + type: boolean + description: if present, limit to objects in workspaces that a user has access to + default: true + show_public: + type: boolean + description: if present, limit to objects in public workspaces + default: true + owners: + description: if present, limit to objects with owner in list + default: null + anyOf: + - {type: 'null'} + - type: array + items: {type: string} + simplify_type: + type: boolean + description: if true, strip out the module and version before collecting + default: false +query: | + WITH wsprov_object + LET ws_objects = ( + FOR v IN 1..10 + INBOUND CONCAT('wsprov_object/', @key) wsprov_links + OPTIONS {'uniqueVertices': 'global', 'bfs':true} + // If both show_private and show_public, return if either is true + FILTER (@show_private && @show_public) ? (v.is_public || v.workspace_id IN ws_ids) : + (!@show_private || v.workspace_id IN ws_ids) && (!@show_public || v.is_public) + FILTER (!@owners || v.owner IN @owners) + return v + ) + LET types = ( + FOR v in ws_objects + LET ws_type = @simplify_type ? SPLIT(SPLIT(v.ws_type, '-', 1)[0], '.')[1] : v.ws_type + COLLECT type = ws_type WITH COUNT INTO type_count + RETURN {type, type_count} + ) + LET narrs = ( + FOR v in ws_objects + RETURN DISTINCT v.narr_name + ) + RETURN PUSH(types, {'type': 'Narrative', 'type_count': COUNT(narrs)}) diff --git a/spec/test/helpers.py b/spec/test/helpers.py new file mode 100644 index 00000000..c5cd4353 --- /dev/null +++ b/spec/test/helpers.py @@ -0,0 +1,34 @@ +""" +Test helpers +""" +import os +import time +import requests +import functools + + +@functools.lru_cache(maxsize=1) +def get_config(): + """Return configuration data for tests.""" + return { + 'db_url': os.environ['DB_URL'], + 'db_auth': (os.environ['DB_USER'], os.environ.get('DB_PASS', '')) + } + + +def wait_for_arangodb(): + """Wait for arangodb to go live.""" + conf = get_config() + db_url = conf['db_url'] + auth = ('root', '') + timeout = time.time() + 60 + while True: + try: + resp = requests.get(db_url + '/_admin/cluster/health', auth=auth) + resp.raise_for_status() + break + except Exception as err: + print(err) + if time.time() > timeout: + raise RuntimeError('Timed out waiting for arangodb') + time.sleep(3) diff --git a/spec/test/run_tests.sh b/spec/test/run_tests.sh new file mode 100644 index 00000000..33688ca8 --- /dev/null +++ b/spec/test/run_tests.sh @@ -0,0 +1,5 @@ +#!/bin/sh +set -e +python -m test.validate +python /app/test/views/init_spec.py +python -m unittest discover /app/test/views diff --git a/spec/test/validate.py b/spec/test/validate.py index 5b4204fe..c677265f 100644 --- a/spec/test/validate.py +++ b/spec/test/validate.py @@ -1,12 +1,19 @@ """ Validate everything in this repo, such as syntax, structure, etc. """ +import sys import os import glob import yaml import jsonschema +import requests +import json from jsonschema.exceptions import ValidationError +from test.helpers import get_config, wait_for_arangodb + +_CONF = get_config() + # JSON schema for vertex and edge collection schemas found in /schema schema_schema = { "type": "object", @@ -29,20 +36,22 @@ def validate_json_schemas(): """Validate the syntax of all the JSON schemas.""" print('Validating JSON schemas..') - names = {} # type: dict + names = set() # type: set for path in glob.iglob('schemas/**/*.yaml', recursive=True): name = os.path.basename(path) - print(f' validating {name}..') + print(f' validating {path}..') with open(path) as fd: data = yaml.safe_load(fd) jsonschema.validate(data, schema_schema) # Check for any duplicate schema names - if names.get(name): + if name in names: print('Duplicate schemas for name ' + name) exit(1) else: - names[name] = True + names.add(name) # Make sure it can be used as a JSON schema + # If the schema is invalid, a SchemaError will get raised + # Otherwise, the schema will work and a ValidationError will get raised (what we want) try: jsonschema.validate({}, data['schema']) except ValidationError: @@ -68,21 +77,68 @@ def validate_json_schemas(): print('..all valid.') -def validate_aql_syntax(): - """Validate the syntax of all the queries.""" - # TODO check AQL syntax. Unsure how to do this without connecting to a running arango server :/ +stored_query_schema = { + 'type': 'object', + 'required': ['query', 'name'], + 'properties': { + 'name': {'type': 'string'}, + 'params': {'type': 'object'}, + 'query': {'type': 'string'} + } +} + + +def validate_stored_queries(): + """Validate the structure and syntax of all the queries.""" print('Validating AQL queries..') - names = {} # type: dict - for path in glob.iglob('views/**/*.aql', recursive=True): - name = os.path.basename(path) - if names.get(name): - print('Duplicate queries named ' + name) + names = set() # type: set + for path in glob.iglob('stored_queries/**/*.yaml', recursive=True): + print(f' validating {path}..') + with open(path) as fd: + data = yaml.safe_load(fd) + jsonschema.validate(data, stored_query_schema) + name = data['name'] + if name in names: + print(f'Duplicate queries named {name}') exit(1) else: - names[name] = True + names.add(name) + # Make sure `params` can be used as a JSON schema + if data.get('params'): + # Make sure it can be used as a JSON schema + # If the schema is invalid, a SchemaError will get raised + # Otherwise, the schema will work and a ValidationError will get raised (what we want) + try: + jsonschema.validate({}, data['params']) + except ValidationError: + pass + # Params must be of type 'object' + if data['params'].get('type') != 'object': + _fatal("Params schema must have type 'object'") + query = data['query'] + # Parse the AQL query on arangodb + url = _CONF['db_url'] + '/_api/query' + resp = requests.post(url, data=json.dumps({'query': query}), auth=_CONF['db_auth']) + parsed = resp.json() + if parsed['error']: + _fatal(parsed['errorMessage']) + query_bind_vars = set(parsed['bindVars']) + params = set(data.get('params', {}).get('properties', {}).keys()) + if params != query_bind_vars: + _fatal((f"Bind vars are invalid.\n" + f" Extra vars in query: {query_bind_vars - params}.\n" + f" Extra params in schema: {params - query_bind_vars}")) + print(f'✓ {path} is valid.') print('..all valid.') +def _fatal(msg): + """Fatal error.""" + sys.stderr.write(str(msg) + '\n') + sys.exit(1) + + if __name__ == '__main__': + wait_for_arangodb() validate_json_schemas() - validate_aql_syntax() + validate_stored_queries() diff --git a/spec/views/README.md b/spec/views/README.md deleted file mode 100644 index a6dc70d4..00000000 --- a/spec/views/README.md +++ /dev/null @@ -1,13 +0,0 @@ -# Relation Engine Views - -Views are templated AQL queries that fetch data from the database. - -Variables in views are prefixed with `@`. - -## Required format - -Each view file should have a set of comments at the top describing the purpose of the query. - -## Using views from the API - -See the [API docs]() to see how to run these queries using the API. diff --git a/spec/views/list_genes_for_similar_reactions.aql b/spec/views/list_genes_for_similar_reactions.aql deleted file mode 100644 index 33963cb4..00000000 --- a/spec/views/list_genes_for_similar_reactions.aql +++ /dev/null @@ -1,41 +0,0 @@ -// Return genes associated with reactions similar to a query reaction -// Args: -// rid - reaction id -// sf_sim - minimum structural fingerprint similarity score -// df_sim - minimum difference fingerprint similarity score -// exclude_self - if true, don't include the query reactions genes - -WITH rxn_reaction -LET ws_ids = @ws_ids -LET start = @exclude_self ? 1 : 0 -LET rxns = ( - FOR v, e IN start..1 - ANY @rid rxn_similar_to_reaction - OPTIONS {uniqueVertices: "global", bfs: true} - FILTER !e || e.sf_similarity >= @sf_sim - FILTER !e || e.df_similarity >= @df_sim - RETURN {id: v._id, key: v._key, name: v.name, definition: v.definition, "structural similarity": e.sf_similarity, "difference similarity": e.df_similarity} -) -LET rxn_ids = rxns[*].id - -LET rxn_gene_links = ( - FOR e in rxn_reaction_within_complex - FILTER e._from in rxn_ids - LET linked_gene_ids = FLATTEN( - FOR c in rxn_gene_complex - FILTER c._id == e._to - RETURN c.genes - ) - COLLECT rxn_id = e._from INTO groups KEEP linked_gene_ids - RETURN {rxn_id: rxn_id, linked_gene_ids: UNIQUE(FLATTEN(groups[*].linked_gene_ids))} -) - -LET gene_ids = UNIQUE(FLATTEN(rxn_gene_links[*].linked_gene_ids)) - -LET genes = ( - FOR g in ncbi_gene - FILTER g._key IN gene_ids - RETURN {key: g._key, product: g.product, function: CONCAT_SEPARATOR(', ', g.functions), sequence: g.protein_translation} -) - -RETURN {rxns: rxns, rxn_gene_links: rxn_gene_links, genes: genes} diff --git a/spec/views/list_test_vertices.aql b/spec/views/list_test_vertices.aql deleted file mode 100644 index 73439d01..00000000 --- a/spec/views/list_test_vertices.aql +++ /dev/null @@ -1,8 +0,0 @@ -// Test query -- lists all test vertices -// Args: -// ws_ids - list of workspace ids the user has access to -// (this is a special param set by the relation engine API) - -for o in test_vertex - filter o.is_public || o.ws_id IN @ws_ids - return o diff --git a/spec/views/search_compounds.aql b/spec/views/search_compounds.aql deleted file mode 100644 index 2e937a94..00000000 --- a/spec/views/search_compounds.aql +++ /dev/null @@ -1,16 +0,0 @@ -// Use ArangoSearch to search documents in the compounds index. Returns documents by ascending id. -// search_text - text to match to document fields -// all_documents - ignore the search_text and return all documents -// include_obsolete - should obsolete documents be included -// offset - how many documents to skip -// result_limit - Maximum documents to return -LET ws_ids = @ws_ids -FOR doc IN Compounds - SEARCH ANALYZER(PHRASE(doc.id, @search_text) - OR PHRASE(doc.name, @search_text) - OR PHRASE(doc.abbreviation, @search_text) - OR PHRASE(doc.aliases, @search_text), 'text_en') OR @all_documents - FILTER @include_obsolete || doc.is_obsolete == 0 - SORT doc.id - LIMIT @offset, @result_limit - RETURN doc \ No newline at end of file diff --git a/spec/views/search_reactions.aql b/spec/views/search_reactions.aql deleted file mode 100644 index ebb226b4..00000000 --- a/spec/views/search_reactions.aql +++ /dev/null @@ -1,16 +0,0 @@ -// Use ArangoSearch to search documents in the Reactions index. Returns documents by ascending id. -// search_text - text to match to document fields -// all_documents - ignore the search_text and return all documents -// include_obsolete - should obsolete documents be included -// offset - how many documents to skip -// result_limit - Maximum documents to return -LET ws_ids = @ws_ids -FOR doc IN Reactions - SEARCH ANALYZER(PHRASE(doc.id, @search_text) - OR PHRASE(doc.name, @search_text) - OR PHRASE(doc.abbreviation, @search_text) - OR PHRASE(doc.aliases, @search_text), 'text_en') OR @all_documents - FILTER @include_obsolete || doc.is_obsolete == 0 - SORT doc.id - LIMIT @offset, @result_limit - RETURN doc \ No newline at end of file diff --git a/spec/views/wsprov_count_linked_object_types.aql b/spec/views/wsprov_count_linked_object_types.aql deleted file mode 100644 index a8d2fd30..00000000 --- a/spec/views/wsprov_count_linked_object_types.aql +++ /dev/null @@ -1,40 +0,0 @@ -// Fetch the counts by type of ws_objects that refference an object -// Args: -// ws_ids - array of private workspace ids the user has access to -// obj_key - wsprov_object key to count associations for -// show_private - limit to objects in workspaces that a user has access to -// show_public - limit to objects in public workspaces -// *** if both show_private and show_public are true, this will be treated as an OR *** -// type - ws type to filter on -// owners - list of usernames to filter by owner - -WITH wsprov_object -LET obj_id = concat('wsprov_object/', @obj_key) - -let out = ( - for v, e, p in 1..100 - OUTBOUND obj_id wsprov_links, wsprov_copied_into - OPTIONS {bfs: true, uniqueVertices: 'global'} - FILTER (!@type || v.ws_type == @type) - FILTER (!@owners || v.owner IN @owners) - FILTER (@show_private && @show_public) - ? (v.is_public || v.workspace_id IN @ws_ids) - : (!@show_private || v.workspace_id IN @ws_ids) && (!@show_public || v.is_public) - COLLECT type = v.ws_type with count into type_count - RETURN {type, type_count} -) - -let inb = ( - for v, e, p in 1..100 - INBOUND obj_id wsprov_links, wsprov_copied_into - OPTIONS {bfs: true, uniqueVertices: 'global'} - FILTER (!@type || v.ws_type == @type) - FILTER (!@owners || v.owner IN @owners) - FILTER (@show_private && @show_public) - ? (v.is_public || v.workspace_id IN @ws_ids) - : (!@show_private || v.workspace_id IN @ws_ids) && (!@show_public || v.is_public) - COLLECT type = v.ws_type with count into type_count - RETURN {type, type_count} -) - -return {out, inb} diff --git a/spec/views/wsprov_fetch_copies.aql b/spec/views/wsprov_fetch_copies.aql deleted file mode 100644 index 45248686..00000000 --- a/spec/views/wsprov_fetch_copies.aql +++ /dev/null @@ -1,23 +0,0 @@ -// For a given object, fetch all the objects that it has been copied from or -// to, no matter how many nested times (copies of copies of copies, forward or backward) -// Also returns all linked objects of those copies of any nested level. -// Args: -// ws_ids - array of private workspace ids the user has access to -// obj_key - wsprov_object key to find links for -// show_private - limit to objects in workspaces that a user has access to -// show_public - limit to objects in public workspaces -// *** if both show_private and show_public are true this will be treated as an OR *** -// result_limit - result limit -// offset - result offset - -WITH wsprov_object -LET obj_id = CONCAT('wsprov_object/', @obj_key) -FOR v, e, p IN 1..3 ANY obj_id wsprov_copied_into - OPTIONS {uniqueVertices: 'global', bfs: true} - LET simple_type = SPLIT(SPLIT(v.ws_type, '-', 1)[0], '.')[1] - FILTER (@show_private && @show_public) ? (v.is_public || v.workspace_id IN @ws_ids) : - (!@show_private || v.workspace_id IN @ws_ids) && (!@show_public || v.is_public) - FILTER (!@types || simple_type IN @types) - FILTER p.vertices[*].ws_type none == "KBaseGenomeAnnotations.Taxon-1.0" - LIMIT @offset, @result_limit - RETURN v diff --git a/spec/views/wsprov_fetch_linked_objects.aql b/spec/views/wsprov_fetch_linked_objects.aql deleted file mode 100644 index 87987219..00000000 --- a/spec/views/wsprov_fetch_linked_objects.aql +++ /dev/null @@ -1,66 +0,0 @@ -// Find all linked objects to a object -// Args: -// ws_ids - array of private workspace ids the user has access to -// obj_key - wsprov_object key to find links for -// show_private - limit to objects in workspaces that a user has access to -// show_public - limit to objects in public workspaces -// *** if both show_private and show_public are true, this will be treated as an OR *** -// types - list of ws types to filter on (set as false to disable) -// owners - list of usernames to filter by owner (set as false to disable) -// results_limit - limit of total results -// offset - result offset - -WITH wsprov_object -LET obj_id = CONCAT("wsprov_object/", @obj_key) - -let out = ( - FOR v, e, p IN 1..100 - OUTBOUND obj_id wsprov_links, wsprov_copied_into - OPTIONS {uniqueVertices: "global", bfs: true} - FILTER (!@types || v.ws_type IN @types) - FILTER (!@owners || v.owner IN @owners) - FILTER (@show_private && @show_public) - ? (v.is_public || v.workspace_id IN @ws_ids) - : (!@show_private || v.workspace_id IN @ws_ids) && (!@show_public || v.is_public) - LIMIT @offset, @results_limit - RETURN { - vertex: { - _key: v._key, - is_public: v.is_public, - narr_name: v.narr_name, - obj_name: v.obj_name, - owner: v.owner, - save_date: v.save_date, - workspace_id: v.workspace_id, - ws_type: v.ws_type - }, - path: p - } -) - -let inb = ( - FOR v, e, p IN 1..100 - INBOUND obj_id wsprov_links, wsprov_copied_into - OPTIONS {uniqueVertices: "global", bfs: true} - FILTER (!@types || v.ws_type IN @types) - FILTER (!@owners || v.owner IN @owners) - FILTER (@show_private && @show_public) - ? (v.is_public || v.workspace_id IN @ws_ids) - : (!@show_private || v.workspace_id IN @ws_ids) && (!@show_public || v.is_public) - LIMIT @offset, @results_limit - RETURN { - vertex: { - _key: v._key, - is_public: v.is_public, - narr_name: v.narr_name, - obj_name: v.obj_name, - owner: v.owner, - save_date: v.save_date, - workspace_id: v.workspace_id, - ws_type: v.ws_type - }, - path: p - } -) - -return APPEND(out, inb) diff --git a/spec/views/wsprov_fetch_obj_field.aql b/spec/views/wsprov_fetch_obj_field.aql deleted file mode 100644 index fdf82a62..00000000 --- a/spec/views/wsprov_fetch_obj_field.aql +++ /dev/null @@ -1,11 +0,0 @@ -// Fetch some object field for an array of object ids -// Args: -// prop - property name that you want to fetch -// obj_ids - array of object ids -// ws_ids - array of private workspace ids the user has access to - -with wsprov_object -for o in wsprov_object - filter o._id in @obj_ids - filter o.is_public || o.workspace_id IN @ws_ids - return {key: o._key, @prop: o[@prop]} diff --git a/spec/views/wsprov_fetch_object.aql b/spec/views/wsprov_fetch_object.aql deleted file mode 100644 index b56779e2..00000000 --- a/spec/views/wsprov_fetch_object.aql +++ /dev/null @@ -1,9 +0,0 @@ -// Fetch a wsprov_object -// Args: -// ws_ids - array of private workspace ids the user has access to -// key - key of the object to fetch - -for o in wsprov_object - filter o._key == @key - filter o.is_public || (o.workspace_id IN @ws_ids) - return o diff --git a/spec/views/wsprov_fetch_paths_between_objects.aql b/spec/views/wsprov_fetch_paths_between_objects.aql deleted file mode 100644 index 919fe026..00000000 --- a/spec/views/wsprov_fetch_paths_between_objects.aql +++ /dev/null @@ -1,18 +0,0 @@ -// Fetch the counts of a ws_objects in the RE that is linked to a wsprov_object -// Args: -// ws_ids - array of private workspace ids the user has access to (autofilled by RE-API) -// start_key - key of the object to start from -// end_key - key of the object to terminate with -// show_private - if present, limit to objects in workspaces that a user has access to -// show_public - if present, limit to objects in public workspaces -// *** if both show_private and show_private are true this will be treated as an OR *** -// max_depth - longest path to explore - -WITH wsprov_object -FOR v, e, path IN 1..@max_depth - ANY CONCAT('wsprov_object/', @start_key) wsprov_links - OPTIONS {'uniqueVertices': 'path', 'uniqueEdges': 'path'} - FILTER (@show_private && @show_public) ? (v.is_public || v.workspace_id IN @ws_ids) : - (!@show_private || v.workspace_id IN @ws_ids) && (!@show_public || v.is_public) - filter v._key == @end_key - RETURN path \ No newline at end of file diff --git a/spec/views/wsprov_fetch_references.aql b/spec/views/wsprov_fetch_references.aql deleted file mode 100644 index 701027e4..00000000 --- a/spec/views/wsprov_fetch_references.aql +++ /dev/null @@ -1,17 +0,0 @@ -// Fetch inbound references for an object with acl -// Args: -// obj_key - wsprov_object ._key field that you want to query against -// result_limit - limit of object results -// offset - result offset for pagination -// ws_ids - array of private workspace ids the user has access to - -with wsprov_object - -let obj_id = concat('wsprov_object/', @obj_key) - -for v, e, p in 1..100 inbound obj_id wsprov_links - options {bfs: true, uniqueVertices: 'global'} - filter p.edges[*].type all == 'reference' - filter v.is_public || v.workspace_id IN @ws_ids - limit @offset, @result_limit - return v diff --git a/spec/views/wsprov_list_referencing_type_counts.aql b/spec/views/wsprov_list_referencing_type_counts.aql deleted file mode 100644 index 2c5dea51..00000000 --- a/spec/views/wsprov_list_referencing_type_counts.aql +++ /dev/null @@ -1,33 +0,0 @@ -// Fetch the counts by type of ws_objects that refference an object -// Args: -// ws_ids - array of private workspace ids the user has access to (autofilled by RE-API) -// key - key of the object to start from -// show_private - if present, limit to objects in workspaces that a user has access to -// show_public - if present, limit to objects in public workspaces -// *** if both show_private and show_private are true this will be treated as an OR *** -// owners - if truthy, limit to objects with owner in list -// simplify_type - if true, strip out the module and version before collecting - -WITH wsprov_object -LET ws_objects = ( - FOR v IN 1..10 - INBOUND CONCAT('wsprov_object/', @key) wsprov_links - OPTIONS {'uniqueVertices': 'global', 'bfs':true} - // If both show_private and show_public, return if either is true - FILTER (@show_private && @show_public) ? (v.is_public || v.workspace_id IN @ws_ids) : - (!@show_private || v.workspace_id IN @ws_ids) && (!@show_public || v.is_public) - FILTER (!@owners || v.owner IN @owners) - return v -) - -LET types = ( - FOR v in ws_objects - LET ws_type = @simplify_type ? SPLIT(SPLIT(v.ws_type, '-', 1)[0], '.')[1] : v.ws_type - COLLECT type = ws_type WITH COUNT INTO type_count - RETURN {type, type_count} -) -LET narrs = ( - FOR v in ws_objects - RETURN DISTINCT v.narr_name -) -RETURN PUSH(types, {'type': 'Narrative', 'type_count': COUNT(narrs)}) From 63d660bfcae3626ad6813400defa4d2096c1af04 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 24 Jul 2019 15:07:44 -0700 Subject: [PATCH 321/732] Spec compatibility (#52) * Add pyyaml to deps * Update spec_loader to be compatible with new spec conventions * Add the 1.0.0 spec release in the test package * Update API to be compatible with newer spec format * Update README.md to reflect changes --- api/README.md | 12 ++-- api/requirements.txt | 1 + .../api_versions/api_v1.py | 32 +++++---- api/src/relation_engine_server/main.py | 2 +- .../utils/arango_client.py | 57 +++++++-------- .../utils/bulk_import.py | 2 +- .../relation_engine_server/utils/config.py | 8 ++- .../relation_engine_server/utils/pull_spec.py | 5 +- .../utils/spec_loader.py | 66 ++++++++---------- .../wait_for_services.py | 9 ++- api/src/test/spec_release/spec.tar.gz | Bin 11549 -> 12555 bytes api/src/test/test_api_v1.py | 24 +++---- api/src/test/wait_for_api.py | 9 ++- 13 files changed, 113 insertions(+), 114 deletions(-) diff --git a/api/README.md b/api/README.md index 779ddff5..72a95efb 100644 --- a/api/README.md +++ b/api/README.md @@ -15,24 +15,24 @@ Returns server status info ### POST /api/v1/query_results -Run a query using a view or a cursor ID. Semantically, this is a GET, but it's a POST to allow better support for passing JSON in the request body (eg. Postman doesn't allow request body data in get requests) +Run a query using a stored query or a cursor ID. Semantically, this is a GET, but it's a POST to allow better support for passing JSON in the request body (eg. Postman doesn't allow request body data in get requests) _Example rquest_ ```sh -curl -X POST -d '{"argument": "value"}' {root_url}/api/v1/query_results?view=example +curl -X POST -d '{"argument": "value"}' {root_url}/api/v1/query_results?stored_query=example ``` _Query params_ -* `view` - required - string - name of the view to run as a query against the database +* `stored_query` - required - string - name of the stored query to run as a query against the database * `cursor_id` - required - string - ID of a cursor that was returned from a previous query with >100 results * `full_count` - optional - bool - If true, return a count of the total documents before any LIMIT is applied (for example, in pagination). This might make some queries run more slowly -Pass one of `view` or `cursor_id` -- not both. +Pass one of `stored_query` or `cursor_id` -- not both. _Request body_ -When running a new query with a view, the request body should be a JSON object of all bind variables for the query. Anything with a `@name` in the query source should have an entry in the object here. For example, a query with bind vars for `@@collection` and `@value`, you will need to pass: +When running a new query, the request body can be a JSON object of all bind variables for the query. Anything with a `@name` in the query source should have an entry in the object here. For example, a query with bind vars for `@@collection` and `@value`, you will need to pass: ```json { "@collection": "collection_name", "value": "my_value"} @@ -95,7 +95,7 @@ curl -d '{"query": "for v in coll sort rand() limit @count return v", "count": 1 This will return the same form of results as above. -**Note:** Currently, all queries are read-only. This includes view queries and ad-hoc admin queries. Commands like `UPDATE` or `REMOVE` will fail. +**Note:** Currently, all queries are read-only. This includes stored queries and ad-hoc admin queries. Commands like `UPDATE` or `REMOVE` will fail. ### PUT /api/v1/documents diff --git a/api/requirements.txt b/api/requirements.txt index 70e6efe7..17bdf2b5 100644 --- a/api/requirements.txt +++ b/api/requirements.txt @@ -5,3 +5,4 @@ simplejson==3.16.0 python-dotenv==0.9.1 requests==2.20.0 jsonschema==2.6.0 +pyyaml==5.1.1 diff --git a/api/src/relation_engine_server/api_versions/api_v1.py b/api/src/relation_engine_server/api_versions/api_v1.py index f76d94ae..496cc42c 100644 --- a/api/src/relation_engine_server/api_versions/api_v1.py +++ b/api/src/relation_engine_server/api_versions/api_v1.py @@ -1,18 +1,18 @@ import flask +import jsonschema from ..utils import arango_client, spec_loader, auth, bulk_import, pull_spec, config, parse_json from ..exceptions import InvalidParameters - api_v1 = flask.Blueprint('api_v1', __name__) -@api_v1.route('/specs/views', methods=['GET']) -def show_views(): +@api_v1.route('/specs/stored_queries', methods=['GET']) +def show_stored_queries(): """Show the current stored query names loaded from the spec.""" name = flask.request.args.get('name') if name: - return {'view': spec_loader.get_view(name)} - return flask.jsonify(spec_loader.get_view_names()) + return {'stored_query': spec_loader.get_stored_query(name)} + return flask.jsonify(spec_loader.get_stored_query_names()) @api_v1.route('/specs/schemas', methods=['GET']) @@ -27,10 +27,10 @@ def show_schemas(): @api_v1.route('/query_results', methods=['POST']) def run_query(): """ - Run a stored view as a query against the database. + Run a stored query as a query against the database. Auth: - only kbase re admins for ad-hoc queries - - public for views (views will have access controls within them based on params) + - 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 @@ -51,11 +51,17 @@ def run_query(): batch_size=batch_size, full_count=full_count) return flask.jsonify(resp_body) - if 'view' in flask.request.args: - # Run a query from a view name - view_name = flask.request.args['view'] - view_source = spec_loader.get_view(view_name) - resp_body = arango_client.run_query(query_text=view_source, + 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 = 'LET ws_ids = @ws_ids ' + stored_query['query'] + if 'params' in stored_query: + # Validate the user params for the query + jsonschema.validate(json_body, stored_query['params']) + resp_body = arango_client.run_query(query_text=stored_query_source, bind_vars=json_body, batch_size=batch_size, full_count=full_count) @@ -66,7 +72,7 @@ def run_query(): resp_body = arango_client.run_query(cursor_id=cursor_id) return flask.jsonify(resp_body) # No valid options were passed - raise InvalidParameters('Pass in a view or a cursor_id') + raise InvalidParameters('Pass in a query name or a cursor_id') @api_v1.route('/specs', methods=['PUT']) diff --git a/api/src/relation_engine_server/main.py b/api/src/relation_engine_server/main.py index 65181d3a..c94a42a4 100644 --- a/api/src/relation_engine_server/main.py +++ b/api/src/relation_engine_server/main.py @@ -65,7 +65,7 @@ def invalid_params(err): @app.errorhandler(spec_loader.SchemaNonexistent) -@app.errorhandler(spec_loader.ViewNonexistent) +@app.errorhandler(spec_loader.StoredQueryNonexistent) def view_does_not_exist(err): """General error cases.""" resp = {'error': str(err), 'name': err.name} diff --git a/api/src/relation_engine_server/utils/arango_client.py b/api/src/relation_engine_server/utils/arango_client.py index 3943591e..eb330851 100644 --- a/api/src/relation_engine_server/utils/arango_client.py +++ b/api/src/relation_engine_server/utils/arango_client.py @@ -4,15 +4,18 @@ import os import requests import json +import glob +import yaml from .config import get_config +_CONF = get_config() + def server_status(): """Get the status of our connection and authorization to the ArangoDB server.""" - config = get_config() try: - resp = requests.get(config['db_url'] + '/_api/endpoint', auth=(config['db_user'], config['db_pass'])) + resp = requests.get(_CONF['db_url'] + '/_api/endpoint', auth=(_CONF['db_user'], _CONF['db_pass'])) except requests.exceptions.ConnectionError: return 'no_connection' if resp.ok: @@ -25,8 +28,7 @@ def server_status(): def run_query(query_text=None, cursor_id=None, bind_vars=None, batch_size=100, full_count=False): """Run a query using the arangodb http api. Can return a cursor to get more results.""" - config = get_config() - url = config['api_url'] + '/cursor' + url = _CONF['api_url'] + '/cursor' req_json = { 'batchSize': min(5000, batch_size), 'memoryLimit': 16000000000, # 16gb @@ -49,7 +51,7 @@ def run_query(query_text=None, cursor_id=None, bind_vars=None, batch_size=100, f method, url, data=json.dumps(req_json), - auth=(config['db_readonly_user'], config['db_readonly_pass']) + auth=(_CONF['db_readonly_user'], _CONF['db_readonly_pass']) ) resp_json = resp.json() if not resp.ok or resp_json['error']: @@ -63,14 +65,15 @@ def run_query(query_text=None, cursor_id=None, bind_vars=None, batch_size=100, f } -def init_collections(schemas): +def init_collections(): """Initialize any uninitialized collections in the database from a set of schemas.""" - edges = schemas['edges'] - vertices = schemas['vertices'] - for edge_name in edges: - create_collection(edge_name, is_edge=True) - for vertex_name in vertices: - create_collection(vertex_name, is_edge=False) + pattern = os.path.join(_CONF['spec_paths']['schemas'], '**', '*.yaml') + for path in glob.iglob(pattern): + coll_name = os.path.basename(os.path.splitext(path)[0]) + with open(path) as fd: + config = yaml.safe_load(fd) + is_edge = config['type'] == 'edge' + create_collection(coll_name, is_edge=is_edge) def create_collection(name, is_edge): @@ -80,19 +83,19 @@ def create_collection(name, is_edge): Shard the new collection based on the number of db nodes (10 shards for each). """ num_shards = os.environ.get('SHARD_COUNT', 30) - config = get_config() - url = config['api_url'] + '/collection' + url = _CONF['api_url'] + '/collection' # collection types: # 2 is a document collection # 3 is an edge collection collection_type = 3 if is_edge else 2 + print(f"Creating collection {name} (edge: {is_edge})") data = json.dumps({ 'keyOptions': {'allowUserKeys': True}, 'name': name, 'type': collection_type, 'numberOfShards': num_shards }) - resp = requests.post(url, data, auth=(config['db_user'], config['db_pass'])) + resp = requests.post(url, data, auth=(_CONF['db_user'], _CONF['db_pass'])) resp_json = resp.json() if not resp.ok: if 'duplicate' not in resp_json['errorMessage']: @@ -102,12 +105,11 @@ def create_collection(name, is_edge): def import_from_file(file_path, query): """Import documents from a file.""" - config = get_config() with open(file_path, 'rb') as file_desc: resp = requests.post( - config['api_url'] + '/import', + _CONF['api_url'] + '/import', data=file_desc, - auth=(config['db_user'], config['db_pass']), + auth=(_CONF['db_user'], _CONF['db_pass']), params=query ) if not resp.ok: @@ -122,29 +124,28 @@ def _init_readonly_user(): If the user cannot be created, we raise an ArangoServerError If the user already exists, or is successfully created, we return None and do not raise. """ - config = get_config() - user = config['db_readonly_user'] + user = _CONF['db_readonly_user'] # Check if the user exists, in which case this is a no-op resp = requests.get( - config['api_url'] + '/user/' + user, - auth=(config['db_user'], config['db_pass']) + _CONF['api_url'] + '/user/' + user, + auth=(_CONF['db_user'], _CONF['db_pass']) ) if resp.status_code == 200: return # Create the user resp = requests.post( - config['api_url'] + '/user', - data=json.dumps({'user': user, 'passwd': config['db_readonly_user']}), - auth=(config['db_user'], config['db_pass']) + _CONF['api_url'] + '/user', + data=json.dumps({'user': user, 'passwd': _CONF['db_readonly_user']}), + auth=(_CONF['db_user'], _CONF['db_pass']) ) if resp.status_code != 201: raise ArangoServerError(resp.text) - db_grant_path = config['api_url'] + '/user/' + user + '/database/' + config['db_name'] + db_grant_path = _CONF['api_url'] + '/user/' + user + '/database/' + _CONF['db_name'] # Grant read access to the current database resp = requests.put( db_grant_path, data='{"grant": "ro"}', - auth=(config['db_user'], config['db_pass']) + auth=(_CONF['db_user'], _CONF['db_pass']) ) if resp.status_code != 200: raise ArangoServerError(resp.text) @@ -152,7 +153,7 @@ def _init_readonly_user(): resp = requests.put( db_grant_path + '/*', data='{"grant": "ro"}', - auth=(config['db_user'], config['db_pass']) + auth=(_CONF['db_user'], _CONF['db_pass']) ) if not resp.ok: raise ArangoServerError(resp.text) diff --git a/api/src/relation_engine_server/utils/bulk_import.py b/api/src/relation_engine_server/utils/bulk_import.py index 04db0c58..ecc77c03 100644 --- a/api/src/relation_engine_server/utils/bulk_import.py +++ b/api/src/relation_engine_server/utils/bulk_import.py @@ -26,7 +26,7 @@ def bulk_import(query_params): # Parse each line to json, validate the schema, and write to a file for line in flask.request.stream: json_line = json.loads(line) - jsonschema.validate(json_line, schema) + jsonschema.validate(json_line, schema['schema']) json_line = _write_edge_key(json_line) json_line['updated_at'] = int(time.time() * 1000) temp_fd.write(json.dumps(json_line) + '\n') diff --git a/api/src/relation_engine_server/utils/config.py b/api/src/relation_engine_server/utils/config.py index 48f1efe9..df0b53cb 100644 --- a/api/src/relation_engine_server/utils/config.py +++ b/api/src/relation_engine_server/utils/config.py @@ -2,14 +2,17 @@ Load configuration data from environment variables. """ import os +import functools from urllib.parse import urljoin +@functools.lru_cache(maxsize=1) def get_config(): """Load environment configuration data.""" spec_path = os.environ.get('SPEC_PATH', '/spec') spec_repo_path = os.path.join(spec_path, 'repo') # /spec/repo spec_schemas_path = os.path.join(spec_repo_path, 'schemas') # /spec/repo/schemas + stored_queries_path = os.path.join(spec_repo_path, 'stored_queries') # /spec/repo/stored_queries spec_url = 'https://api.github.com/repos/kbase/relation_engine_spec' kbase_endpoint = os.environ.get('KBASE_ENDPOINT', 'https://ci.kbase.us/services') auth_url = os.environ.get('KBASE_AUTH_URL', urljoin(kbase_endpoint + '/', 'auth')) @@ -37,9 +40,8 @@ def get_config(): 'release_id': os.path.join(spec_path, '.release_id'), 'root': spec_path, 'repo': spec_repo_path, - 'views': os.path.join(spec_repo_path, 'views'), 'schemas': spec_schemas_path, - 'vertices': os.path.join(spec_schemas_path, 'vertices'), - 'edges': os.path.join(spec_schemas_path, 'edges') + 'stored_queries': stored_queries_path, + 'vertices': os.path.join(spec_schemas_path, 'vertices') } } diff --git a/api/src/relation_engine_server/utils/pull_spec.py b/api/src/relation_engine_server/utils/pull_spec.py index 50e84aa4..c931bd72 100644 --- a/api/src/relation_engine_server/utils/pull_spec.py +++ b/api/src/relation_engine_server/utils/pull_spec.py @@ -4,7 +4,7 @@ import tempfile import shutil -from . import arango_client, spec_loader +from . import arango_client from .config import get_config @@ -37,8 +37,7 @@ def download_specs(init_collections=True, release_url=None): _rename_directories(config['spec_paths']['root'], config['spec_paths']['repo']) # Initialize all the collections if init_collections: - schemas = spec_loader.get_schema_names() - arango_client.init_collections(schemas) + arango_client.init_collections() def _fetch_github_release_url(): diff --git a/api/src/relation_engine_server/utils/spec_loader.py b/api/src/relation_engine_server/utils/spec_loader.py index 06d1de42..88dec3cd 100644 --- a/api/src/relation_engine_server/utils/spec_loader.py +++ b/api/src/relation_engine_server/utils/spec_loader.py @@ -1,57 +1,49 @@ """ -Utilities for loading views, schemas, and migrations from the spec. +Utilities for loading stored queries, schemas, and migrations from the spec. """ import glob import os -import json +import yaml from .config import get_config +_CONF = get_config() + def get_schema_names(): """Return a dict of vertex and edge base names.""" - config = get_config() - return { - 'vertices': [ - _get_file_name(path) - for path in _find_paths(config['spec_paths']['vertices'], '*.json') - ], - 'edges': [ - _get_file_name(path) - for path in _find_paths(config['spec_paths']['edges'], '*.json') - ] - } - - -def get_view_names(): - """Return an array of all view base names.""" - config = get_config() - return [ - _get_file_name(path) - for path in _find_paths(config['spec_paths']['views'], '*.aql') - ] + names = [] # type: list + for path in _find_paths(_CONF['spec_paths']['schemas'], '*.yaml'): + names.append(_get_file_name(path)) + return names + + +def get_stored_query_names(): + """Return an array of all stored queries base names.""" + names = [] # type: list + for path in _find_paths(_CONF['spec_paths']['stored_queries'], '*.yaml'): + names.append(_get_file_name(path)) + return names def get_schema(name): - """Get JSON content for a specific schema. Throws an error if nonexistent.""" - config = get_config() + """Get YAML content for a specific schema. Throws an error if nonexistent.""" try: - path = _find_paths(config['spec_paths']['schemas'], name + '.json')[0] + path = _find_paths(_CONF['spec_paths']['schemas'], name + '.yaml')[0] except IndexError: raise SchemaNonexistent(name) - with open(path, 'r', encoding='utf8') as fd: - return json.load(fd) + with open(path) as fd: + return yaml.safe_load(fd) -def get_view(name): - """Get AQL content for a specific view. Throws an error if nonexistent.""" - config = get_config() +def get_stored_query(name): + """Get AQL content for a specific stored query. Throws an error if nonexistent.""" try: - path = _find_paths(config['spec_paths']['views'], name + '.aql')[0] + path = _find_paths(_CONF['spec_paths']['stored_queries'], name + '.yaml')[0] except IndexError: - raise ViewNonexistent(name) - with open(path, 'r', encoding='utf8') as fd: - return fd.read() + raise StoredQueryNonexistent(name) + with open(path) as fd: + return yaml.safe_load(fd) def _find_paths(dir_path, file_pattern): @@ -70,14 +62,14 @@ def _get_file_name(path): return os.path.splitext(os.path.basename(path))[0] -class ViewNonexistent(Exception): - """Requested view is not in the spec.""" +class StoredQueryNonexistent(Exception): + """Requested stored query is not in the spec.""" def __init__(self, name): self.name = name def __str__(self): - return 'View does not exist.' + return 'Stored query does not exist.' class SchemaNonexistent(Exception): diff --git a/api/src/relation_engine_server/wait_for_services.py b/api/src/relation_engine_server/wait_for_services.py index 87955105..cb6112e8 100644 --- a/api/src/relation_engine_server/wait_for_services.py +++ b/api/src/relation_engine_server/wait_for_services.py @@ -10,17 +10,16 @@ def main(): - started = False timeout = int(time.time()) + 60 - while not started: + while True: try: requests.get(_CONFIG['workspace_url']) requests.get(_CONFIG['auth_url']) auth = (_CONFIG['db_user'], _CONFIG['db_pass']) requests.get(_CONFIG['db_url'] + '/_admin/cluster/health', auth=auth).raise_for_status() - started = True - except Exception as err: - print('Waiting for services:', err) + break + except Exception: + print('Waiting for services..') if int(time.time()) > timeout: raise RuntimeError('Timed out waiting for services.') time.sleep(3) diff --git a/api/src/test/spec_release/spec.tar.gz b/api/src/test/spec_release/spec.tar.gz index de85b63c38be0e654c3f744346a0c676f587c613..d8f7bce887eab37b15b3ace52a6d996712742695 100644 GIT binary patch literal 12555 zcmYkARaBf!u(fdr4#C~s-5o**9^9P-C%6vo?h@RBy9aj&PH+wGE(627=R5y87k^*W zZSPuZSMR5bG8P5q{~h=X@yj0@LMhlqMe_~GB5uuX^l>W zC@KzS(eNXD|J2;B{fzn?^Gvsbag&>-IFTT>hN9g@hy9Ij?nD6uv->k}nW0>~xLm+` z$!w;1OwB`a%Sks-MhP@H^wg|Sy?Em8H=V(@^3BWO(KeMc=nI3-U>PRg>1tbdmC^jY z`*Cl|(s$gg{OPPiidMgUjqZ6;_{y_O)e_9bqIvsPQ+^ZTdJ*ONc9EV&^Ei`BasHX^ z2k!}U29Hk1?|*V!V!vC=JlK`!)c>ts`l)uhN81t%nLGE$xR>--y9KqcT#B8G$!vt5 zk{$yxuPa88+pZdhfBvX!sNePVq(S3#Smgnml5KnOjY+D&{RhEH{@atV#|i&ERY!ZZ zfQRR*Qtk7r_|;WUGo2I6g6=HgW4A$eBHl&1z7HF?uW8dKCR%0+&cv?SE?!f^D@mwe zV0hU%oA-!eqa$7hdR=-5YTiD-cma`qzgXohczmlhsAo}@*x2ZXc<1jv*!|5_Bjdud zsv8P?4jPbGhJlGf%**zZ1a&}e4=(A2OYgzkw~?`?iYfu1v%o9OK$ZiL>>UU{F07MX z52Nz86DcBO=c1MLJJfmbnH+GY-s1iQ1AaRw^k`^*ChyGuA)Ug_*-Qz+_SJH0iz90eeA;e5mO)a8cGJoU@^5W~lzl20tzeA@$%$3%olrF1W$AL69 z@$bFWD)$hI|ALpQV-OHUa1pa zsb{z_ehnsxyp$jf772j&gBLA!GiikYb6>Sc~B?5H3} z1p`8tdl2`VobqRF#y42HVo~%XLh$8wEh>_vk>2{>Oxp2oO??nJc1MmUT&fTi9nH*? z*D66}nSo8(9kTok@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_ff5WGsulI$^P@tu=WBp#`RcHiFd8~;YAI)jrgZEov8`zZ4I>$XemHNz3=KcB`T z({%7T3w$)Ewj@bl!Yk~Ye_$2Wkzi`+>OfVK82!>eFxy8j65&%l=y8T=iZYm*xcj59 z{B5L8wAKk!8%;mQ5jR2GQJF^CbIn1iz;MAsvh>ZzIcgMdbaWGs(ARAe2e^{!$7^x; z&3D5!6!$JOLh*)(S2?br0q1G39IVdri_JBnLO)>0063N`EXF>$`iJ%dW#WUUb`u}$ zYl#t16RZi-UG(1(L&g&Zd^s{1=o{%E&cD>W=6rhe+YoJR-%OR(^VMIg-eX$2YjyTZ ze5D#wAu!0ZvRbEEh##p?U%~V(TWb+cH=<8_r2lUJ{XO2NYSFpmAO85j@7(z1 zEMlUpDdT;_8d)lN3YjXpa=ANYNF!F5)bQl;mIBtVTu6@Yl+JG6*_vv#L3GdAot}t9 zM9W~1jawCidq&4BF4_vgYF3?vbAmfjg? timeout: raise RuntimeError('Timed out waiting for services.') time.sleep(3) From f08c3b1568a5b3d4b5b77af70ab53b6aabe67e6a Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 24 Jul 2019 15:17:09 -0700 Subject: [PATCH 322/732] Remove need to poke the specs on server start (#53) * Add pyyaml to deps * Update spec_loader to be compatible with new spec conventions * Add the 1.0.0 spec release in the test package * Update API to be compatible with newer spec format * Update README.md to reflect changes * Dont require an explicit spec pull call on server start * Fix some documentation in README.md --- api/README.md | 15 ++++++-- api/scripts/start_server.sh | 1 + .../relation_engine_server/utils/config.py | 4 ++ .../relation_engine_server/utils/pull_spec.py | 38 +++++++++++-------- api/src/test/test_api_v1.py | 10 ----- 5 files changed, 39 insertions(+), 29 deletions(-) diff --git a/api/README.md b/api/README.md index 72a95efb..f9a06625 100644 --- a/api/README.md +++ b/api/README.md @@ -90,7 +90,7 @@ System admins can run ad-hoc queries by specifying a "query" property in the JSO ```sh curl -d '{"query": "for v in coll sort rand() limit @count return v", "count": 1}' \ - {root_url}/api/query_results + {root_url}/api/v1/query_results ``` This will return the same form of results as above. @@ -104,7 +104,7 @@ Bulk-update documents by either creating, replacing, or updating. _Example_ ```sh -curl -X PUT {root_url}/api/documents?collection=genes&on_duplicate=update +curl -X PUT {root_url}/api/v1/documents?collection=genes&on_duplicate=update ``` _Query params_ @@ -167,7 +167,7 @@ Manually check and pull spec updates. Requires sysadmin auth. _Example_ ``` -curl {root_url}/api/update_specs +curl {root_url}/api/v1/update_specs ``` _Query params_ @@ -189,6 +189,15 @@ The following environment variables should be configured: * `DB_READONLY_USER` - read-only username for the arangodb database * `DB_READONLY_PASS` - read-only password for the arangodb database +### Update specs + +To update specs while the server is running, use this curl command with an RE_ADMIN token: + +```sh +curl -X PUT -H "Authorization: " \ + "https://ci.kbase.us/services/relation_engine_api/api/v1/specs?init_collections=1 +``` + ## Development See the [Contribution Guidelines](/.github/CONTRIBUTING.md). diff --git a/api/scripts/start_server.sh b/api/scripts/start_server.sh index f2b007a7..f1127858 100644 --- a/api/scripts/start_server.sh +++ b/api/scripts/start_server.sh @@ -8,6 +8,7 @@ calc_workers="$(($(nproc) * 2 + 1))" workers=${WORKERS:-$calc_workers} python -m src.relation_engine_server.wait_for_services +python -m src.relation_engine_server.utils.pull_spec gunicorn \ --worker-class gevent \ diff --git a/api/src/relation_engine_server/utils/config.py b/api/src/relation_engine_server/utils/config.py index df0b53cb..8ca0e1a6 100644 --- a/api/src/relation_engine_server/utils/config.py +++ b/api/src/relation_engine_server/utils/config.py @@ -10,6 +10,8 @@ def get_config(): """Load environment configuration data.""" spec_path = os.environ.get('SPEC_PATH', '/spec') + spec_release_url = os.environ.get('SPEC_RELEASE_URL') + spec_release_path = os.environ.get('SPEC_RELEASE_PATH') spec_repo_path = os.path.join(spec_path, 'repo') # /spec/repo spec_schemas_path = os.path.join(spec_repo_path, 'schemas') # /spec/repo/schemas stored_queries_path = os.path.join(spec_repo_path, 'stored_queries') # /spec/repo/stored_queries @@ -36,6 +38,8 @@ def get_config(): 'db_readonly_user': db_readonly_user, 'db_readonly_pass': db_readonly_pass, 'spec_url': spec_url, + 'spec_release_url': spec_release_url, + 'spec_release_path': spec_release_path, 'spec_paths': { 'release_id': os.path.join(spec_path, '.release_id'), 'root': spec_path, diff --git a/api/src/relation_engine_server/utils/pull_spec.py b/api/src/relation_engine_server/utils/pull_spec.py index c931bd72..695d327f 100644 --- a/api/src/relation_engine_server/utils/pull_spec.py +++ b/api/src/relation_engine_server/utils/pull_spec.py @@ -1,3 +1,4 @@ +import sys import os import requests import tarfile @@ -7,22 +8,23 @@ from . import arango_client from .config import get_config +_CONF = get_config() + def download_specs(init_collections=True, release_url=None): """Check and download the latest spec and extract it to the spec path.""" - config = get_config() # Remove the spec directory, ignoring if it is already missing - shutil.rmtree(config['spec_paths']['root'], ignore_errors=True) + shutil.rmtree(_CONF['spec_paths']['root'], ignore_errors=True) # Recreate the spec directory so we have a clean slate, avoiding name conflicts - os.makedirs(config['spec_paths']['root']) + os.makedirs(_CONF['spec_paths']['root']) # Download and extract a new release to /spec/repo - if 'SPEC_RELEASE_PATH' in os.environ: - _extract_tarball(os.environ['SPEC_RELEASE_PATH'], config['spec_paths']['root']) + if _CONF['spec_release_path']: + _extract_tarball(_CONF['spec_release_path'], _CONF['spec_paths']['root']) else: if release_url: tarball_url = release_url - if 'SPEC_RELEASE_URL' in os.environ: - tarball_url = os.environ['SPEC_RELEASE_URL'] + if _CONF['spec_release_url']: + tarball_url = _CONF['spec_release_url'] else: tarball_url = _fetch_github_release_url() resp = requests.get(tarball_url, stream=True) @@ -31,10 +33,10 @@ def download_specs(init_collections=True, release_url=None): # Download from the tarball url to the temp file _download_file(resp, temp_file.name) # Extract the downloaded tarball into the spec path - _extract_tarball(temp_file.name, config['spec_paths']['root']) + _extract_tarball(temp_file.name, _CONF['spec_paths']['root']) # The files will be extracted into a directory like /spec/kbase-relation_engine_spec-xyz # We want to move that to /spec/repo - _rename_directories(config['spec_paths']['root'], config['spec_paths']['repo']) + _rename_directories(_CONF['spec_paths']['root'], _CONF['spec_paths']['repo']) # Initialize all the collections if init_collections: arango_client.init_collections() @@ -42,9 +44,8 @@ def download_specs(init_collections=True, release_url=None): def _fetch_github_release_url(): """Find the latest relation engine spec release using the github api.""" - config = get_config() # Download information about the latest release - release_resp = requests.get(config['spec_url'] + '/releases/latest') + release_resp = requests.get(_CONF['spec_url'] + '/releases/latest') release_info = release_resp.json() if release_resp.status_code != 200: # This may be a github API rate usage limit, or some other error @@ -80,10 +81,9 @@ def _rename_directories(dir_path, dest_path): def _has_latest_spec(info): """Check if downloaded release info matches the latest downloaded spec.""" - config = get_config() release_id = str(info['id']) - if os.path.exists(config['spec_paths']['release_id']): - with open(config['spec_paths']['release_id'], 'r') as fd: + if os.path.exists(_CONF['spec_paths']['release_id']): + with open(_CONF['spec_paths']['release_id'], 'r') as fd: current_release_id = fd.read() if release_id == current_release_id: return True @@ -93,7 +93,13 @@ def _has_latest_spec(info): def _save_release_id(info): """Save a release ID as the latest downloaded spec.""" release_id = str(info['id']) - config = get_config() # Write the release ID to /spec/.release_id - with open(config['spec_release_id_path'], 'w') as fd: + with open(_CONF['spec_release_id_path'], 'w') as fd: fd.write(release_id) + + +if __name__ == '__main__': + if len(sys.argv) > 1: + if sys.argv[1] == 'init': + download_specs(init_collections=True) + download_specs() diff --git a/api/src/test/test_api_v1.py b/api/src/test/test_api_v1.py index 4a43446a..4af86398 100644 --- a/api/src/test/test_api_v1.py +++ b/api/src/test/test_api_v1.py @@ -53,16 +53,6 @@ def save_test_docs(count, edges=False): class TestApi(unittest.TestCase): - @classmethod - def setUpClass(cls): - # Initialize collections before running any tests - resp = requests.put( - API_URL + '/specs', - headers=HEADERS_ADMIN, - params={'init_collections': '1'} - ) - print('update_specs response', resp.text) - def test_root(self): """Test root path for api.""" resp = requests.get(URL + '/').json() From a344ff0d68d3580fec57cc3e80f2a61495246484 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 24 Jul 2019 15:30:27 -0700 Subject: [PATCH 323/732] Add some functionality around the /schemas endpoint (#54) * Add pyyaml to deps * Update spec_loader to be compatible with new spec conventions * Add the 1.0.0 spec release in the test package * Update API to be compatible with newer spec format * Update README.md to reflect changes * Dont require an explicit spec pull call on server start * Fix some documentation in README.md * Add some functionality around the GET /schemas endpoint * Update README.md * Update README.md * Update README.md --- api/README.md | 48 +++++++++++++++++++ .../api_versions/api_v1.py | 9 +++- .../utils/spec_loader.py | 7 +++ api/src/test/test_api_v1.py | 19 ++++++-- 4 files changed, 76 insertions(+), 7 deletions(-) diff --git a/api/README.md b/api/README.md index f9a06625..6ca4b5ae 100644 --- a/api/README.md +++ b/api/README.md @@ -176,6 +176,54 @@ _Query params_ Every call to update specs will reset the spec data (do a clean download and overwrite). +### GET /api/v1/schemas + +Get all schema names (returns an array of strings): + +```sh +GET {root_url}/api/v1/schemas +``` + +Example response: + +```json +["test_vertex", "test_edge"] +``` + +Get the contents of a specific schema + +```sh +GET "{root_url}/api/v1/schemas?name=test_vertex" +``` + +Example response: + +```json +{ + "name": "test_vertex", + "type": "vertex", + "schema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "required": ["_key"], + "description": "An example vertex schema for testing", + "properties": { + "_key": {"type": "string"}, + "is_public": {"type": "boolean"}, + "ws_id": {"type": "integer"} + } + } +} +``` + +Get the schema for a particular document by its full ID + +```sh +GET "{root_url}/api/v1/schemas?doc_id=test_vertex/1" +``` + +The response will have the same format as the example response above + ## Administration The following environment variables should be configured: diff --git a/api/src/relation_engine_server/api_versions/api_v1.py b/api/src/relation_engine_server/api_versions/api_v1.py index 496cc42c..24430b1a 100644 --- a/api/src/relation_engine_server/api_versions/api_v1.py +++ b/api/src/relation_engine_server/api_versions/api_v1.py @@ -19,9 +19,13 @@ def show_stored_queries(): def show_schemas(): """Show the current schema names (edges and vertices) loaded from the spec.""" name = flask.request.args.get('name') + doc_id = flask.request.args.get('doc_id') if name: - return spec_loader.get_schema(name) - return flask.jsonify(spec_loader.get_schema_names()) + return flask.jsonify(spec_loader.get_schema(name)) + elif doc_id: + return flask.jsonify(spec_loader.get_schema_for_doc(doc_id)) + else: + return flask.jsonify(spec_loader.get_schema_names()) @api_v1.route('/query_results', methods=['POST']) @@ -45,6 +49,7 @@ def run_query(): # Run an adhoc query for a sysadmin auth.require_auth_token(roles=['RE_ADMIN']) query_text = json_body['query'] + query_text = 'LET ws_ids = @ws_ids ' + query_text del json_body['query'] resp_body = arango_client.run_query(query_text=query_text, bind_vars=json_body, diff --git a/api/src/relation_engine_server/utils/spec_loader.py b/api/src/relation_engine_server/utils/spec_loader.py index 88dec3cd..5694a9a4 100644 --- a/api/src/relation_engine_server/utils/spec_loader.py +++ b/api/src/relation_engine_server/utils/spec_loader.py @@ -36,6 +36,13 @@ def get_schema(name): return yaml.safe_load(fd) +def get_schema_for_doc(doc_id): + """Get the schema for a particular document by its full ID.""" + (coll_name, _) = doc_id.split('/') + ret = get_schema(coll_name) + return ret + + def get_stored_query(name): """Get AQL content for a specific stored query. Throws an error if nonexistent.""" try: diff --git a/api/src/test/test_api_v1.py b/api/src/test/test_api_v1.py index 4af86398..877d7c1b 100644 --- a/api/src/test/test_api_v1.py +++ b/api/src/test/test_api_v1.py @@ -94,6 +94,14 @@ def test_list_schemas(self): self.assertFalse('error' in resp) self.assertTrue(len(resp)) + def test_fetch_schema_for_doc(self): + """Given a document ID, fetch its schema.""" + resp = requests.get(API_URL + '/specs/schemas', params={'doc_id': 'test_vertex/123'}) + resp = resp.json() # type: dict + self.assertEqual(resp['name'], 'test_vertex') + self.assertEqual(resp['type'], 'vertex') + self.assertTrue(resp['schema']) + def test_save_documents_missing_auth(self): """Test an invalid attempt to save a doc with a missing auth token.""" resp = requests.put( @@ -225,19 +233,20 @@ def test_save_documents_ignore_dupes(self): def test_admin_query(self): """Test an ad-hoc query made by an admin.""" save_test_docs(1) - query = 'let ws_ids = @ws_ids for v in test_vertex sort rand() limit @count return v._id' + query = 'for v in test_vertex sort rand() limit @count return v._id' resp = requests.post( API_URL + '/query_results', params={}, headers=HEADERS_ADMIN, data=json.dumps({'query': query, 'count': 1}) ).json() + print('resp!?', resp) self.assertEqual(resp['count'], 1) self.assertEqual(len(resp['results']), 1) def test_admin_query_non_admin(self): """Test an ad-hoc query error as a non-admin.""" - query = 'let ws_ids = @ws_ids for v in test_vertex sort rand() limit @count return v._id' + query = 'for v in test_vertex sort rand() limit @count return v._id' resp = requests.post( API_URL + '/query_results', params={}, @@ -248,7 +257,7 @@ def test_admin_query_non_admin(self): def test_admin_query_invalid_auth(self): """Test the error response for an ad-hoc admin query without auth.""" - query = 'let ws_ids = @ws_ids for v in test_vertex sort rand() limit @count return v._id' + query = 'for v in test_vertex sort rand() limit @count return v._id' resp = requests.post( API_URL + '/query_results', params={}, @@ -387,7 +396,7 @@ def test_auth_adhoc_query(self): headers={'Authorization': 'valid_token'} ) # This is the same query as list_test_vertices.aql in the spec - query = 'for o in test_vertex filter o.is_public || o.ws_id IN @ws_ids return o' + query = 'for o in test_vertex filter o.is_public || o.ws_id IN ws_ids return o' resp = requests.post( API_URL + '/query_results', data=json.dumps({'query': query}), @@ -398,7 +407,7 @@ def test_auth_adhoc_query(self): def test_queries_are_readonly(self): """Test that ad-hoc admin queries cannot do any writing.""" save_test_docs(1) - query = 'let ws_ids = @ws_ids for v in test_vertex remove v in test_vertex' + query = 'for v in test_vertex remove v in test_vertex' resp = requests.post( API_URL + '/query_results', headers=HEADERS_ADMIN, From 0caaf90ecb2544d6e07ef066b4e47f67c3c5c299 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Fri, 26 Jul 2019 10:39:17 -0700 Subject: [PATCH 324/732] Add an option to only overwrite existing specs with a flag. Server will boot and use existing specs --- .../api_versions/api_v1.py | 2 +- .../relation_engine_server/utils/pull_spec.py | 49 ++++++++++--------- 2 files changed, 26 insertions(+), 25 deletions(-) diff --git a/api/src/relation_engine_server/api_versions/api_v1.py b/api/src/relation_engine_server/api_versions/api_v1.py index 24430b1a..6d7b27e2 100644 --- a/api/src/relation_engine_server/api_versions/api_v1.py +++ b/api/src/relation_engine_server/api_versions/api_v1.py @@ -89,7 +89,7 @@ def update_specs(): auth.require_auth_token(['RE_ADMIN']) init_collections = 'init_collections' in flask.request.args release_url = flask.request.args.get('release_url') - pull_spec.download_specs(init_collections, release_url) + pull_spec.download_specs(init_collections, release_url, reset=True) return flask.jsonify({'status': 'updated'}) diff --git a/api/src/relation_engine_server/utils/pull_spec.py b/api/src/relation_engine_server/utils/pull_spec.py index 695d327f..b86ef305 100644 --- a/api/src/relation_engine_server/utils/pull_spec.py +++ b/api/src/relation_engine_server/utils/pull_spec.py @@ -11,32 +11,33 @@ _CONF = get_config() -def download_specs(init_collections=True, release_url=None): +def download_specs(init_collections=True, release_url=None, reset=False): """Check and download the latest spec and extract it to the spec path.""" - # Remove the spec directory, ignoring if it is already missing - shutil.rmtree(_CONF['spec_paths']['root'], ignore_errors=True) - # Recreate the spec directory so we have a clean slate, avoiding name conflicts - os.makedirs(_CONF['spec_paths']['root']) - # Download and extract a new release to /spec/repo - if _CONF['spec_release_path']: - _extract_tarball(_CONF['spec_release_path'], _CONF['spec_paths']['root']) - else: - if release_url: - tarball_url = release_url - if _CONF['spec_release_url']: - tarball_url = _CONF['spec_release_url'] + if reset or not os.path.exists(_CONF['spec_paths']['root']): + # Remove the spec directory, ignoring if it is already missing + shutil.rmtree(_CONF['spec_paths']['root'], ignore_errors=True) + # Recreate the spec directory so we have a clean slate, avoiding name conflicts + os.makedirs(_CONF['spec_paths']['root']) + # Download and extract a new release to /spec/repo + if _CONF['spec_release_path']: + _extract_tarball(_CONF['spec_release_path'], _CONF['spec_paths']['root']) else: - tarball_url = _fetch_github_release_url() - resp = requests.get(tarball_url, stream=True) - with tempfile.NamedTemporaryFile() as temp_file: - # The temp file will be closed/deleted when the context ends - # Download from the tarball url to the temp file - _download_file(resp, temp_file.name) - # Extract the downloaded tarball into the spec path - _extract_tarball(temp_file.name, _CONF['spec_paths']['root']) - # The files will be extracted into a directory like /spec/kbase-relation_engine_spec-xyz - # We want to move that to /spec/repo - _rename_directories(_CONF['spec_paths']['root'], _CONF['spec_paths']['repo']) + if release_url: + tarball_url = release_url + if _CONF['spec_release_url']: + tarball_url = _CONF['spec_release_url'] + else: + tarball_url = _fetch_github_release_url() + resp = requests.get(tarball_url, stream=True) + with tempfile.NamedTemporaryFile() as temp_file: + # The temp file will be closed/deleted when the context ends + # Download from the tarball url to the temp file + _download_file(resp, temp_file.name) + # Extract the downloaded tarball into the spec path + _extract_tarball(temp_file.name, _CONF['spec_paths']['root']) + # The files will be extracted into a directory like /spec/kbase-relation_engine_spec-xyz + # We want to move that to /spec/repo + _rename_directories(_CONF['spec_paths']['root'], _CONF['spec_paths']['repo']) # Initialize all the collections if init_collections: arango_client.init_collections() From 44d17161dc0180b6a563b24f3bf4024c8fc0701f Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Fri, 26 Jul 2019 13:58:14 -0700 Subject: [PATCH 325/732] Add taxa query with tests (#68) * Translate views into stored_queries, stored in yaml with JSON schema validation on the params * Barz. * Add checking of AQL syntax and presence of bind variables in every JSON schema for params. * Update many of the stored query params to have more requirements and defaults * Change the names dicts to sets in the validate script; move the config into the environment * Add a simple ncbi taxonomy query along with a minimal test. Reorganize the way some of the tests run so the RE API can pull queries from this repo. --- spec/docker-compose.yaml | 6 +- spec/schemas/ncbi/ncbi_taxon.yaml | 71 +++++-------------- .../ncbi_tax/ncbi_taxon_get_ancestors.yaml | 15 ++++ spec/test/helpers.py | 25 +++++++ spec/test/run_tests.sh | 4 +- .../{views => stored_queries}/__init__.py | 0 .../test_list_test_vertices.py | 0 spec/test/stored_queries/test_ncbi_tax.py | 61 ++++++++++++++++ spec/test/views/init_spec.py | 12 ---- 9 files changed, 123 insertions(+), 71 deletions(-) create mode 100644 spec/stored_queries/ncbi_tax/ncbi_taxon_get_ancestors.yaml rename spec/test/{views => stored_queries}/__init__.py (100%) rename spec/test/{views => stored_queries}/test_list_test_vertices.py (100%) create mode 100644 spec/test/stored_queries/test_ncbi_tax.py delete mode 100644 spec/test/views/init_spec.py diff --git a/spec/docker-compose.yaml b/spec/docker-compose.yaml index d2f7d027..a2345275 100644 --- a/spec/docker-compose.yaml +++ b/spec/docker-compose.yaml @@ -14,10 +14,11 @@ services: environment: - DB_URL=http://arangodb:8529 - DB_USER=root + - RE_API_URL=http://re_api:5000 # Relation Engine API re_api: - image: kbase/relation_engine_api:latest + image: kbase/relation_engine_api:develop ports: - "127.0.0.1:5000:5000" depends_on: @@ -32,9 +33,10 @@ services: - KBASE_AUTH_URL=http://auth:5000 - KBASE_WORKSPACE_URL=http://workspace:5000 - PYTHONUNBUFFERED=true - - SPEC_RELEASE_PATH=/app/src/test/spec_release/spec.tar.gz - DB_URL=http://arangodb:8529 - DB_USER=root + volumes: + - ".:/spec/repo" # Arangodb server in cluster mode arangodb: diff --git a/spec/schemas/ncbi/ncbi_taxon.yaml b/spec/schemas/ncbi/ncbi_taxon.yaml index e92cce68..8d08e237 100644 --- a/spec/schemas/ncbi/ncbi_taxon.yaml +++ b/spec/schemas/ncbi/ncbi_taxon.yaml @@ -4,95 +4,56 @@ schema: "$schema": http://json-schema.org/draft-07/schema# type: object description: Template for a vertex entry in the NCBI taxonomy tree. - required: - - _key - - scientific_name - - rank + required: [_key, scientific_name, rank] properties: _key: type: string description: NCBI Taxon id (positive integer) - examples: - - '1' - - '2053699' + examples: ['1', '2053699'] scientific_name: type: string title: Taxon name. - examples: - - Methylophilus methylotrophus - - Bacteria - - Firmicutes + examples: ['Methylophilus methylotrophus', 'Bacteria', 'Firmicutes'] canonical_scientific_name: type: array title: Canonicalized scientific name - examples: - - - methylophilus - - methylotrophus - - - Bacteria - - - Firmicutes - items: - type: string + examples: [['methylophilus', 'methylotrophus'], ['Bacteria'], ['Firmicutes']] + items: {type: string} aliases: type: array description: Aliases examples: - - category: authority name: Borreliella burgdorferi (Johnson et al. 1984) Adeolu and Gupta 2015 - canonical: - - borreliella - - burgdorferi - - johnson - - adeolu - - gupta + canonical: ['borreliella', 'burgdorferi', 'johnson', 'adeolu', 'gupta'] - category: genbank common name name: Lyme disease spirochet - canonical: - - lyme - - disease - - spirochet + canonical: ['lyme', 'disease', 'spirochet'] - category: synonym name: Borrelia burgdorferi - canonical: - - borrelia - - burgdorferi + canonical: ['borrelia', 'burgdorferi'] - - category: common name name: E. coli - canonical: - - e - - coli + canonical: ['e', 'coli'] - category: authority name: '"Bacterium coli commune" Escherich 1885' - canonical: - - bacterium - - coli - - commune - - escherich + canonical: ['bacterium', 'coli', 'commune', 'escherich'] - category: synonym name: Bacterium coli - canonical: - - bacterium - - coli + canonical: ['bacterium', 'coli'] items: type: object - required: - - category - - name - - canonical + required: ['category', 'name', 'canonical'] properties: - category: - type: string - name: - type: string + category: {type: string} + name: {type: string} canonical: type: array - items: - type: string + items: {type: string} rank: type: string title: Taxonomic rank - examples: - - Domain - - Phylum + examples: [Domain, Phylum] numeric_rank: type: integer title: Taxonomic level diff --git a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_ancestors.yaml b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_ancestors.yaml new file mode 100644 index 00000000..186c39e7 --- /dev/null +++ b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_ancestors.yaml @@ -0,0 +1,15 @@ +# Get the array of ancestors for any taxon +name: ncbi_taxon_get_ancestors +params: + type: object + required: [key] + properties: + key: + type: string + title: Document key + description: Key of the taxon vertex for which you want to find ancestors +query: | + for t in ncbi_taxon + filter t._key == @key + for p in 1..10 OUTBOUND t ncbi_child_of_taxon + return p diff --git a/spec/test/helpers.py b/spec/test/helpers.py index c5cd4353..4ad8856e 100644 --- a/spec/test/helpers.py +++ b/spec/test/helpers.py @@ -1,6 +1,7 @@ """ Test helpers """ +import sys import os import time import requests @@ -11,6 +12,7 @@ def get_config(): """Return configuration data for tests.""" return { + 're_api_url': os.environ['RE_API_URL'], 'db_url': os.environ['DB_URL'], 'db_auth': (os.environ['DB_USER'], os.environ.get('DB_PASS', '')) } @@ -32,3 +34,26 @@ def wait_for_arangodb(): if time.time() > timeout: raise RuntimeError('Timed out waiting for arangodb') time.sleep(3) + + +def wait_for_api(): + # Wait for the API to come online + conf = get_config() + timeout = int(time.time()) + 60 + while True: + try: + requests.get(conf['re_api_url']).raise_for_status() + requests.get('http://auth:5000') + requests.get('http://workspace:5000') + break + except Exception as err: + print(err) + print('Waiting for RE API to come online..') + if int(time.time()) > timeout: + raise RuntimeError("Timed out waiting for RE API.") + time.sleep(2) + + +if __name__ == '__main__': + if sys.argv[1] == 'wait_for_api': + wait_for_api() diff --git a/spec/test/run_tests.sh b/spec/test/run_tests.sh index 33688ca8..38f31cb0 100644 --- a/spec/test/run_tests.sh +++ b/spec/test/run_tests.sh @@ -1,5 +1,5 @@ #!/bin/sh set -e +python -m test.helpers wait_for_api python -m test.validate -python /app/test/views/init_spec.py -python -m unittest discover /app/test/views +python -m unittest discover /app/test/stored_queries diff --git a/spec/test/views/__init__.py b/spec/test/stored_queries/__init__.py similarity index 100% rename from spec/test/views/__init__.py rename to spec/test/stored_queries/__init__.py diff --git a/spec/test/views/test_list_test_vertices.py b/spec/test/stored_queries/test_list_test_vertices.py similarity index 100% rename from spec/test/views/test_list_test_vertices.py rename to spec/test/stored_queries/test_list_test_vertices.py diff --git a/spec/test/stored_queries/test_ncbi_tax.py b/spec/test/stored_queries/test_ncbi_tax.py new file mode 100644 index 00000000..919ece8f --- /dev/null +++ b/spec/test/stored_queries/test_ncbi_tax.py @@ -0,0 +1,61 @@ +""" +Tests for the ncbi taxonomy stored queries. +""" +import json +import unittest +import requests +# import time + +from test.helpers import get_config + +_CONF = get_config() + + +def create_test_docs(ncbi_taxon, ncbi_child_of_taxon): + """Create edges and vertices we need for tests.""" + body = '\n'.join([json.dumps(d) for d in ncbi_taxon]) + resp = requests.put( + _CONF['re_api_url'] + '/api/v1/documents', + params={'overwrite': True, 'collection': 'ncbi_taxon'}, + data=body, + headers={'Authorization': 'admin_token'} + ) + if not resp.ok: + raise RuntimeError(resp.text) + ncbi_taxon_results = resp.json() + body = '\n'.join([json.dumps(d) for d in ncbi_child_of_taxon]) + resp = requests.put( + _CONF['re_api_url'] + '/api/v1/documents', + params={'overwrite': True, 'collection': 'ncbi_child_of_taxon'}, + data=body, + headers={'Authorization': 'admin_token'} + ) + if not resp.ok: + raise RuntimeError(resp.text) + ncbi_child_of_taxon_results = resp.json() + return { + 'ncbi_taxon': ncbi_taxon_results, + 'ncbi_child_of_taxon': ncbi_child_of_taxon_results + } + + +class TestNcbiTax(unittest.TestCase): + + def test_valid(self): + """Test a valid query.""" + taxon_docs = [ + {'_key': '1', 'scientific_name': 'Bacteria', 'rank': 'Domain'}, + {'_key': '2', 'scientific_name': 'Firmicutes', 'rank': 'Phylum'} + ] + child_docs = [ + {'_from': 'ncbi_taxon/2', '_to': 'ncbi_taxon/1', 'child_type': 't'} + ] + create_test_docs(taxon_docs, child_docs) + resp = requests.post( + _CONF['re_api_url'] + '/api/v1/query_results', + params={'stored_query': 'ncbi_taxon_get_ancestors'}, + data=json.dumps({'key': '2'}), + headers={'Authorization': 'valid_token'} # gives access to workspaces [1,2,3] + ).json() + self.assertEqual(resp['count'], 1) + self.assertEqual(resp['results'][0]['rank'], 'Domain') diff --git a/spec/test/views/init_spec.py b/spec/test/views/init_spec.py deleted file mode 100644 index 53e7a2a6..00000000 --- a/spec/test/views/init_spec.py +++ /dev/null @@ -1,12 +0,0 @@ -import requests - -_API_URL = 'http://re_api:5000/api/v1' - - -if __name__ == '__main__': - resp = requests.put( - _API_URL + '/specs', - headers={'Authorization': 'admin_token'}, - params={'init_collections': '1'} - ) - print(resp.text) From 1322b1f640cc03074008efad7fd3e17f1d81826d Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Fri, 26 Jul 2019 15:53:40 -0700 Subject: [PATCH 326/732] Add json schema value defaults with a simple test (#55) --- api/requirements.txt | 2 +- .../api_versions/api_v1.py | 14 ++++++++-- .../utils/bulk_import.py | 4 +-- .../utils/json_validation.py | 28 +++++++++++++++++++ api/src/test/test_utils.py | 16 +++++++++++ 5 files changed, 58 insertions(+), 6 deletions(-) create mode 100644 api/src/relation_engine_server/utils/json_validation.py create mode 100644 api/src/test/test_utils.py diff --git a/api/requirements.txt b/api/requirements.txt index 17bdf2b5..a286db3a 100644 --- a/api/requirements.txt +++ b/api/requirements.txt @@ -4,5 +4,5 @@ gevent==1.3.7 simplejson==3.16.0 python-dotenv==0.9.1 requests==2.20.0 -jsonschema==2.6.0 +jsonschema==3.0.1 pyyaml==5.1.1 diff --git a/api/src/relation_engine_server/api_versions/api_v1.py b/api/src/relation_engine_server/api_versions/api_v1.py index 6d7b27e2..9350e3bc 100644 --- a/api/src/relation_engine_server/api_versions/api_v1.py +++ b/api/src/relation_engine_server/api_versions/api_v1.py @@ -1,6 +1,14 @@ import flask -import jsonschema -from ..utils import arango_client, spec_loader, auth, bulk_import, pull_spec, config, parse_json +from src.relation_engine_server.utils import ( + json_validation, + arango_client, + spec_loader, + auth, + bulk_import, + pull_spec, + config, + parse_json +) from ..exceptions import InvalidParameters api_v1 = flask.Blueprint('api_v1', __name__) @@ -65,7 +73,7 @@ def run_query(): stored_query_source = 'LET ws_ids = @ws_ids ' + stored_query['query'] if 'params' in stored_query: # Validate the user params for the query - jsonschema.validate(json_body, stored_query['params']) + json_validation.Validator(json_body).validate(stored_query['params']) resp_body = arango_client.run_query(query_text=stored_query_source, bind_vars=json_body, batch_size=batch_size, diff --git a/api/src/relation_engine_server/utils/bulk_import.py b/api/src/relation_engine_server/utils/bulk_import.py index ecc77c03..c643435b 100644 --- a/api/src/relation_engine_server/utils/bulk_import.py +++ b/api/src/relation_engine_server/utils/bulk_import.py @@ -3,9 +3,9 @@ import tempfile import flask import json -import jsonschema import hashlib +from src.relation_engine_server.utils import json_validation from . import spec_loader from .arango_client import import_from_file @@ -26,7 +26,7 @@ def bulk_import(query_params): # Parse each line to json, validate the schema, and write to a file for line in flask.request.stream: json_line = json.loads(line) - jsonschema.validate(json_line, schema['schema']) + json_validation.Validator(schema['schema']).validate(json_line) json_line = _write_edge_key(json_line) json_line['updated_at'] = int(time.time() * 1000) temp_fd.write(json.dumps(json_line) + '\n') diff --git a/api/src/relation_engine_server/utils/json_validation.py b/api/src/relation_engine_server/utils/json_validation.py new file mode 100644 index 00000000..8ee085f7 --- /dev/null +++ b/api/src/relation_engine_server/utils/json_validation.py @@ -0,0 +1,28 @@ +""" +JSON Schema validation + +See the docs on adding default values: https://python-jsonschema.readthedocs.io/en/stable/faq/ + +Example usage: + + schema = {'properties': {'foo': {'default': 'bar'}}} + obj = {} + Validator(schema).validate(obj) + assert obj == {'foo': 'bar'} +""" +from jsonschema import validators, Draft7Validator + + +def extend_with_default(validator_class): + validate_properties = validator_class.VALIDATORS["properties"] + + def set_defaults(validator, properties, instance, schema): + for property, subschema in properties.items(): + if "default" in subschema: + instance.setdefault(property, subschema["default"]) + for error in validate_properties(validator, properties, instance, schema): + yield error + return validators.extend(validator_class, {"properties": set_defaults}) + + +Validator = extend_with_default(Draft7Validator) diff --git a/api/src/test/test_utils.py b/api/src/test/test_utils.py new file mode 100644 index 00000000..0e2ed6d0 --- /dev/null +++ b/api/src/test/test_utils.py @@ -0,0 +1,16 @@ +""" +Test utility functions +""" +from src.relation_engine_server.utils import json_validation + +import unittest + + +class TestUtils(unittest.TestCase): + + def test_json_validation_defaults(self): + """Test that the jsonschema validator sets default values.""" + schema = {'properties': {'foo': {'default': 'bar'}}} + obj = {} # type: dict + json_validation.Validator(schema).validate(obj) + self.assertEqual(obj, {'foo': 'bar'}) From 5202b6394f731a3b0c325b91ac5c305e9c5059bf Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Fri, 26 Jul 2019 16:01:41 -0700 Subject: [PATCH 327/732] Bugfix on jsonschema validation for queries without params --- api/src/relation_engine_server/api_versions/api_v1.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/api/src/relation_engine_server/api_versions/api_v1.py b/api/src/relation_engine_server/api_versions/api_v1.py index 9350e3bc..2397d478 100644 --- a/api/src/relation_engine_server/api_versions/api_v1.py +++ b/api/src/relation_engine_server/api_versions/api_v1.py @@ -73,9 +73,12 @@ def run_query(): stored_query_source = 'LET ws_ids = @ws_ids ' + stored_query['query'] if 'params' in stored_query: # Validate the user params for the query - json_validation.Validator(json_body).validate(stored_query['params']) + params = json_validation.Validator(stored_query).validate(json_body) + else: + # Skip validation if the query doesn't need it + params = json_body resp_body = arango_client.run_query(query_text=stored_query_source, - bind_vars=json_body, + bind_vars=params, batch_size=batch_size, full_count=full_count) return flask.jsonify(resp_body) From 110ef68a4830923cabdf5b1eca94137564a7cf31 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Fri, 26 Jul 2019 16:24:33 -0700 Subject: [PATCH 328/732] Bug fix on ws_ids param --- api/src/relation_engine_server/api_versions/api_v1.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/api/src/relation_engine_server/api_versions/api_v1.py b/api/src/relation_engine_server/api_versions/api_v1.py index 2397d478..9d5d6a60 100644 --- a/api/src/relation_engine_server/api_versions/api_v1.py +++ b/api/src/relation_engine_server/api_versions/api_v1.py @@ -49,7 +49,7 @@ def run_query(): json_body['ws_ids'] = [] auth_token = auth.get_auth_header() # Fetch any authorized workspace IDs using a KBase auth token, if present - json_body['ws_ids'] = auth.get_workspace_ids(auth_token) + ws_ids = auth.get_workspace_ids(auth_token) # fetch number of documents to return batch_size = int(flask.request.args.get('batch_size', 100)) full_count = flask.request.args.get('full_count', False) @@ -59,6 +59,7 @@ def run_query(): query_text = json_body['query'] query_text = 'LET ws_ids = @ws_ids ' + query_text del json_body['query'] + json_body['ws_ids'] = ws_ids resp_body = arango_client.run_query(query_text=query_text, bind_vars=json_body, batch_size=batch_size, @@ -73,10 +74,13 @@ def run_query(): stored_query_source = 'LET ws_ids = @ws_ids ' + stored_query['query'] if 'params' in stored_query: # Validate the user params for the query + print('params before', json_body) params = json_validation.Validator(stored_query).validate(json_body) + print('params after', params) else: - # Skip validation if the query doesn't need it + # Skip validation if the query doesn't require it params = json_body + params['ws_ids'] = ws_ids resp_body = arango_client.run_query(query_text=stored_query_source, bind_vars=params, batch_size=batch_size, From ba426fadfbb1b6831606e36c422c45f424f7c787 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Fri, 26 Jul 2019 16:34:39 -0700 Subject: [PATCH 329/732] Bugfix on params --- api/src/relation_engine_server/api_versions/api_v1.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/api/src/relation_engine_server/api_versions/api_v1.py b/api/src/relation_engine_server/api_versions/api_v1.py index 9d5d6a60..4f7699e7 100644 --- a/api/src/relation_engine_server/api_versions/api_v1.py +++ b/api/src/relation_engine_server/api_versions/api_v1.py @@ -75,14 +75,11 @@ def run_query(): if 'params' in stored_query: # Validate the user params for the query print('params before', json_body) - params = json_validation.Validator(stored_query).validate(json_body) - print('params after', params) - else: - # Skip validation if the query doesn't require it - params = json_body - params['ws_ids'] = ws_ids + json_validation.Validator(stored_query).validate(json_body) + print('params after', json_body) + json_body['ws_ids'] = ws_ids resp_body = arango_client.run_query(query_text=stored_query_source, - bind_vars=params, + bind_vars=json_body, batch_size=batch_size, full_count=full_count) return flask.jsonify(resp_body) From 78e7e09cae6deaec1a6b3251a01d025c99381e3f Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Mon, 29 Jul 2019 10:14:32 -0700 Subject: [PATCH 330/732] Fix type of property in search_reactions query --- spec/stored_queries/search_reactions.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/stored_queries/search_reactions.yaml b/spec/stored_queries/search_reactions.yaml index e92c0a8f..14d43e2d 100644 --- a/spec/stored_queries/search_reactions.yaml +++ b/spec/stored_queries/search_reactions.yaml @@ -8,7 +8,7 @@ params: type: string description: text to match to document fields all_documents: - type: string + type: boolean description: ignore the search_text and return all documents default: false include_obsolete: From d459354101515b5688ccb4829dd80468a6c1525f Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Mon, 29 Jul 2019 10:15:49 -0700 Subject: [PATCH 331/732] Bugfix on the json schema validation in the query execution endpoint. --- api/src/relation_engine_server/api_versions/api_v1.py | 4 +--- api/src/test/test_api_v1.py | 3 +-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/api/src/relation_engine_server/api_versions/api_v1.py b/api/src/relation_engine_server/api_versions/api_v1.py index 4f7699e7..12acf395 100644 --- a/api/src/relation_engine_server/api_versions/api_v1.py +++ b/api/src/relation_engine_server/api_versions/api_v1.py @@ -74,9 +74,7 @@ def run_query(): stored_query_source = 'LET ws_ids = @ws_ids ' + stored_query['query'] if 'params' in stored_query: # Validate the user params for the query - print('params before', json_body) - json_validation.Validator(stored_query).validate(json_body) - print('params after', json_body) + json_validation.Validator(stored_query['params']).validate(json_body) json_body['ws_ids'] = ws_ids resp_body = arango_client.run_query(query_text=stored_query_source, bind_vars=json_body, diff --git a/api/src/test/test_api_v1.py b/api/src/test/test_api_v1.py index 877d7c1b..3cd2d81a 100644 --- a/api/src/test/test_api_v1.py +++ b/api/src/test/test_api_v1.py @@ -96,8 +96,7 @@ def test_list_schemas(self): def test_fetch_schema_for_doc(self): """Given a document ID, fetch its schema.""" - resp = requests.get(API_URL + '/specs/schemas', params={'doc_id': 'test_vertex/123'}) - resp = resp.json() # type: dict + resp = requests.get(API_URL + '/specs/schemas', params={'doc_id': 'test_vertex/123'}).json() self.assertEqual(resp['name'], 'test_vertex') self.assertEqual(resp['type'], 'vertex') self.assertTrue(resp['schema']) From 62007bf442659595bcd6b81e212db7733995e892 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Mon, 29 Jul 2019 17:35:06 -0700 Subject: [PATCH 332/732] Add descendants query with a couple valid test cases (#69) * Add descendants query with a couple valid test cases * Remove auth headers for tax query tests * Remove file accidentally added * Add 10k limit on descendants query * Add comment about limit --- .../ncbi_tax/ncbi_taxon_get_descendants.yaml | 23 +++++++++ spec/test/stored_queries/test_ncbi_tax.py | 47 +++++++++++++++++-- 2 files changed, 65 insertions(+), 5 deletions(-) create mode 100644 spec/stored_queries/ncbi_tax/ncbi_taxon_get_descendants.yaml diff --git a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_descendants.yaml b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_descendants.yaml new file mode 100644 index 00000000..cf0d0531 --- /dev/null +++ b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_descendants.yaml @@ -0,0 +1,23 @@ +# Get the array of descendants for any taxon +# Defaults to immediate children only +# Results are limited to at most 10000 documents +name: ncbi_taxon_get_descendants +params: + type: object + required: [key] + properties: + key: + type: string + title: Document key + description: Key of the taxon vertex for which you want to find descendants + levels: + type: integer + default: 1 + title: Number of levels + description: How many levels of descendants to traverse and aggregate +query: | + for t in ncbi_taxon + filter t._key == @key + for c in 1..@levels INBOUND t ncbi_child_of_taxon + limit 10000 + return c diff --git a/spec/test/stored_queries/test_ncbi_tax.py b/spec/test/stored_queries/test_ncbi_tax.py index 919ece8f..9641d2bc 100644 --- a/spec/test/stored_queries/test_ncbi_tax.py +++ b/spec/test/stored_queries/test_ncbi_tax.py @@ -41,21 +41,58 @@ def create_test_docs(ncbi_taxon, ncbi_child_of_taxon): class TestNcbiTax(unittest.TestCase): - def test_valid(self): - """Test a valid query.""" + @classmethod + def setUpClass(cls): + """Create test documents""" taxon_docs = [ {'_key': '1', 'scientific_name': 'Bacteria', 'rank': 'Domain'}, - {'_key': '2', 'scientific_name': 'Firmicutes', 'rank': 'Phylum'} + {'_key': '2', 'scientific_name': 'Firmicutes', 'rank': 'Phylum'}, + {'_key': '3', 'scientific_name': 'Bacilli', 'rank': 'Class'}, + {'_key': '4', 'scientific_name': 'Proteobacteria', 'rank': 'Phylum'}, + {'_key': '5', 'scientific_name': 'Alphaproteobacteria', 'rank': 'Class'}, + {'_key': '6', 'scientific_name': 'Gammaproteobacteria', 'rank': 'Class'}, ] child_docs = [ - {'_from': 'ncbi_taxon/2', '_to': 'ncbi_taxon/1', 'child_type': 't'} + {'_from': 'ncbi_taxon/2', '_to': 'ncbi_taxon/1', 'child_type': 't'}, + {'_from': 'ncbi_taxon/4', '_to': 'ncbi_taxon/1', 'child_type': 't'}, + {'_from': 'ncbi_taxon/3', '_to': 'ncbi_taxon/2', 'child_type': 't'}, + {'_from': 'ncbi_taxon/5', '_to': 'ncbi_taxon/4', 'child_type': 't'}, + {'_from': 'ncbi_taxon/6', '_to': 'ncbi_taxon/4', 'child_type': 't'}, ] create_test_docs(taxon_docs, child_docs) + + def test_ancestors_valid(self): + """Test a valid query of taxon ancestors.""" resp = requests.post( _CONF['re_api_url'] + '/api/v1/query_results', params={'stored_query': 'ncbi_taxon_get_ancestors'}, data=json.dumps({'key': '2'}), - headers={'Authorization': 'valid_token'} # gives access to workspaces [1,2,3] ).json() self.assertEqual(resp['count'], 1) self.assertEqual(resp['results'][0]['rank'], 'Domain') + + def test_descendants_valid(self): + """Test a valid query of taxon descendants.""" + resp = requests.post( + _CONF['re_api_url'] + '/api/v1/query_results', + params={'stored_query': 'ncbi_taxon_get_descendants'}, + data=json.dumps({'key': '1'}), + ).json() + self.assertEqual(resp['count'], 2) + ranks = {r['rank'] for r in resp['results']} + names = {r['scientific_name'] for r in resp['results']} + self.assertEqual(ranks, {'Phylum'}) + self.assertEqual(names, {'Firmicutes', 'Proteobacteria'}) + + def test_descendants_2levels_valid(self): + """Test a valid query for descendants with 2 levels.""" + resp = requests.post( + _CONF['re_api_url'] + '/api/v1/query_results', + params={'stored_query': 'ncbi_taxon_get_descendants'}, + data=json.dumps({'key': '1', 'levels': 2}), + ).json() + self.assertEqual(resp['count'], 5) + ranks = {r['rank'] for r in resp['results']} + names = {r['scientific_name'] for r in resp['results']} + self.assertEqual(ranks, {'Phylum', 'Class'}) + self.assertEqual(names, {'Firmicutes', 'Proteobacteria', 'Bacilli', 'Alphaproteobacteria', 'Gammaproteobacteria'}) # noqa From af042e26e8e09a2e4bf050cdd4bd7127fb9e4f61 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 30 Jul 2019 13:53:47 -0700 Subject: [PATCH 333/732] Add tax siblings query (#70) * Add descendants query with a couple valid test cases * WIP * Add the query with the simple test; Add a vert and edge to the test data * Fix comment * Add test comment * Remove unneeded auth header * Add tests for root node and nonexistent node * Remove auth header * Optimize the siblings query * Debug travis --- spec/.travis.yml | 8 ++-- .../ncbi_tax/ncbi_taxon_get_siblings.yaml | 22 ++++++++++ spec/test/stored_queries/test_ncbi_tax.py | 44 ++++++++++++++++++- 3 files changed, 67 insertions(+), 7 deletions(-) create mode 100644 spec/stored_queries/ncbi_tax/ncbi_taxon_get_siblings.yaml diff --git a/spec/.travis.yml b/spec/.travis.yml index c7b6fcfe..10dc631b 100644 --- a/spec/.travis.yml +++ b/spec/.travis.yml @@ -1,7 +1,5 @@ -language: python -python: -- 3.6 -before_script: -- pip install jsonschema +sudo: required +services: +- docker script: - make test diff --git a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_siblings.yaml b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_siblings.yaml new file mode 100644 index 00000000..bc7d012e --- /dev/null +++ b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_siblings.yaml @@ -0,0 +1,22 @@ +# Get the array of siblings for a taxon +# Results are limited to 10k +name: ncbi_taxon_get_siblings +params: + type: object + required: [key] + properties: + key: + type: string + title: Document key + description: Key of the taxon vertex for which you want to find siblings +query: | + // First find the taxon in the tree + for t in ncbi_taxon + filter t._key == @key + // Now traverse to the parent + for parent in 1..1 OUTBOUND t ncbi_child_of_taxon + // Then traverse back down to the siblings + for c in 1..1 INBOUND parent ncbi_child_of_taxon + filter c != t + limit 10000 + return c diff --git a/spec/test/stored_queries/test_ncbi_tax.py b/spec/test/stored_queries/test_ncbi_tax.py index 9641d2bc..7e25f978 100644 --- a/spec/test/stored_queries/test_ncbi_tax.py +++ b/spec/test/stored_queries/test_ncbi_tax.py @@ -51,6 +51,7 @@ def setUpClass(cls): {'_key': '4', 'scientific_name': 'Proteobacteria', 'rank': 'Phylum'}, {'_key': '5', 'scientific_name': 'Alphaproteobacteria', 'rank': 'Class'}, {'_key': '6', 'scientific_name': 'Gammaproteobacteria', 'rank': 'Class'}, + {'_key': '7', 'scientific_name': 'Deltaproteobacteria', 'rank': 'Class'}, ] child_docs = [ {'_from': 'ncbi_taxon/2', '_to': 'ncbi_taxon/1', 'child_type': 't'}, @@ -58,6 +59,7 @@ def setUpClass(cls): {'_from': 'ncbi_taxon/3', '_to': 'ncbi_taxon/2', 'child_type': 't'}, {'_from': 'ncbi_taxon/5', '_to': 'ncbi_taxon/4', 'child_type': 't'}, {'_from': 'ncbi_taxon/6', '_to': 'ncbi_taxon/4', 'child_type': 't'}, + {'_from': 'ncbi_taxon/7', '_to': 'ncbi_taxon/4', 'child_type': 't'}, ] create_test_docs(taxon_docs, child_docs) @@ -91,8 +93,46 @@ def test_descendants_2levels_valid(self): params={'stored_query': 'ncbi_taxon_get_descendants'}, data=json.dumps({'key': '1', 'levels': 2}), ).json() - self.assertEqual(resp['count'], 5) + self.assertEqual(resp['count'], 6) ranks = {r['rank'] for r in resp['results']} names = {r['scientific_name'] for r in resp['results']} self.assertEqual(ranks, {'Phylum', 'Class'}) - self.assertEqual(names, {'Firmicutes', 'Proteobacteria', 'Bacilli', 'Alphaproteobacteria', 'Gammaproteobacteria'}) # noqa + self.assertEqual(names, { + 'Firmicutes', + 'Proteobacteria', + 'Bacilli', + 'Alphaproteobacteria', + 'Gammaproteobacteria', + 'Deltaproteobacteria', + }) + + def test_siblings_valid(self): + """Test a valid query for siblings.""" + resp = requests.post( + _CONF['re_api_url'] + '/api/v1/query_results', + params={'stored_query': 'ncbi_taxon_get_siblings'}, + data=json.dumps({'key': '5'}), # Querying from "Alphaproteobacteria" + ).json() + self.assertEqual(resp['count'], 2) + ranks = {r['rank'] for r in resp['results']} + names = {r['scientific_name'] for r in resp['results']} + self.assertEqual(ranks, {'Class'}) + self.assertEqual(names, {'Gammaproteobacteria', 'Deltaproteobacteria'}) + + def test_siblings_root(self): + """Test a query for siblings on the root node with no parent.""" + resp = requests.post( + _CONF['re_api_url'] + '/api/v1/query_results', + params={'stored_query': 'ncbi_taxon_get_siblings'}, + data=json.dumps({'key': '1'}), # Querying from "Bacteria" + ).json() + self.assertEqual(resp['count'], 0) + + def test_siblings_nonexistent_node(self): + """Test a query for siblings on the root node with no parent.""" + resp = requests.post( + _CONF['re_api_url'] + '/api/v1/query_results', + params={'stored_query': 'ncbi_taxon_get_siblings'}, + data=json.dumps({'key': 'xyz'}), # Nonexistent node + ).json() + self.assertEqual(resp['count'], 0) From a168498fd122ec4583a6a11c2175f4d12a8aad35 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 30 Jul 2019 15:41:16 -0700 Subject: [PATCH 334/732] Add functionality to create indexes from the spec --- .../utils/arango_client.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/api/src/relation_engine_server/utils/arango_client.py b/api/src/relation_engine_server/utils/arango_client.py index eb330851..ad4f63e6 100644 --- a/api/src/relation_engine_server/utils/arango_client.py +++ b/api/src/relation_engine_server/utils/arango_client.py @@ -72,16 +72,16 @@ def init_collections(): coll_name = os.path.basename(os.path.splitext(path)[0]) with open(path) as fd: config = yaml.safe_load(fd) - is_edge = config['type'] == 'edge' - create_collection(coll_name, is_edge=is_edge) + create_collection(coll_name, config) -def create_collection(name, is_edge): +def create_collection(name, config): """ Create a single collection by name using some basic defaults. We ignore duplicates. For any other server error, an exception is thrown. Shard the new collection based on the number of db nodes (10 shards for each). """ + is_edge = config['type'] == 'edge' num_shards = os.environ.get('SHARD_COUNT', 30) url = _CONF['api_url'] + '/collection' # collection types: @@ -101,6 +101,19 @@ def create_collection(name, is_edge): if 'duplicate' not in resp_json['errorMessage']: # Unable to create a collection raise ArangoServerError(resp.text) + if config.get('indexes'): + _create_indexes(name, config) + + +def _create_indexes(coll_name, config): + """Create indexes for a collection""" + url = _CONF['api_url'] + '/index' + for (idx_name, idx_conf) in config['indexes'].items(): + idx_type = idx_conf['type'] + idx_url = url + '#' + idx_type + resp = requests.post(idx_url, params={'collection-name': coll_name}, data=json.dumps(idx_conf)) + if not resp.ok: + raise RuntimeError(resp.text) def import_from_file(file_path, query): From 9d1128c9761aeaf819454bdb53a9a1ee5922beb7 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 30 Jul 2019 16:01:34 -0700 Subject: [PATCH 335/732] Add functionality to create indexes from the spec (#56) * Add functionality to create indexes from the spec * Update README.md * Fix param name --- api/README.md | 2 +- .../utils/arango_client.py | 19 ++++++++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/api/README.md b/api/README.md index 6ca4b5ae..fb4e48f7 100644 --- a/api/README.md +++ b/api/README.md @@ -171,7 +171,7 @@ curl {root_url}/api/v1/update_specs ``` _Query params_ -* `init_collections` - optional - boolean - defaults to true - whether to initialize any new collections in arango +* `init_collections` - optional - boolean - defaults to true - whether to initialize any new collections in arango (also creates indexes) * `spec_url` - optional - string - the specific url of the release to download and use (as a tarball). If left blank, then the latest release from github is used (not including any pre-releases or drafts). Every call to update specs will reset the spec data (do a clean download and overwrite). diff --git a/api/src/relation_engine_server/utils/arango_client.py b/api/src/relation_engine_server/utils/arango_client.py index eb330851..362698c4 100644 --- a/api/src/relation_engine_server/utils/arango_client.py +++ b/api/src/relation_engine_server/utils/arango_client.py @@ -72,16 +72,16 @@ def init_collections(): coll_name = os.path.basename(os.path.splitext(path)[0]) with open(path) as fd: config = yaml.safe_load(fd) - is_edge = config['type'] == 'edge' - create_collection(coll_name, is_edge=is_edge) + create_collection(coll_name, config) -def create_collection(name, is_edge): +def create_collection(name, config): """ Create a single collection by name using some basic defaults. We ignore duplicates. For any other server error, an exception is thrown. Shard the new collection based on the number of db nodes (10 shards for each). """ + is_edge = config['type'] == 'edge' num_shards = os.environ.get('SHARD_COUNT', 30) url = _CONF['api_url'] + '/collection' # collection types: @@ -101,6 +101,19 @@ def create_collection(name, is_edge): if 'duplicate' not in resp_json['errorMessage']: # Unable to create a collection raise ArangoServerError(resp.text) + if config.get('indexes'): + _create_indexes(name, config) + + +def _create_indexes(coll_name, config): + """Create indexes for a collection""" + url = _CONF['api_url'] + '/index' + for (idx_name, idx_conf) in config['indexes'].items(): + idx_type = idx_conf['type'] + idx_url = url + '#' + idx_type + resp = requests.post(idx_url, params={'collection': coll_name}, data=json.dumps(idx_conf)) + if not resp.ok: + raise RuntimeError(resp.text) def import_from_file(file_path, query): From c200ac18fd361199394c746a49b4b9b8d2190e25 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 31 Jul 2019 11:35:32 -0700 Subject: [PATCH 336/732] Bugfix on index initializer --- api/src/relation_engine_server/utils/arango_client.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/api/src/relation_engine_server/utils/arango_client.py b/api/src/relation_engine_server/utils/arango_client.py index 362698c4..c707acfb 100644 --- a/api/src/relation_engine_server/utils/arango_client.py +++ b/api/src/relation_engine_server/utils/arango_client.py @@ -108,8 +108,7 @@ def create_collection(name, config): def _create_indexes(coll_name, config): """Create indexes for a collection""" url = _CONF['api_url'] + '/index' - for (idx_name, idx_conf) in config['indexes'].items(): - idx_type = idx_conf['type'] + for (idx_type, idx_conf) in config['indexes'].items(): idx_url = url + '#' + idx_type resp = requests.post(idx_url, params={'collection': coll_name}, data=json.dumps(idx_conf)) if not resp.ok: From 739c538e346ee8292b11c250ae75e0500424048b Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 31 Jul 2019 11:44:28 -0700 Subject: [PATCH 337/732] Another bugfix (auth fix) on index creation --- api/src/relation_engine_server/utils/arango_client.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/api/src/relation_engine_server/utils/arango_client.py b/api/src/relation_engine_server/utils/arango_client.py index c707acfb..f872bad2 100644 --- a/api/src/relation_engine_server/utils/arango_client.py +++ b/api/src/relation_engine_server/utils/arango_client.py @@ -110,7 +110,13 @@ def _create_indexes(coll_name, config): url = _CONF['api_url'] + '/index' for (idx_type, idx_conf) in config['indexes'].items(): idx_url = url + '#' + idx_type - resp = requests.post(idx_url, params={'collection': coll_name}, data=json.dumps(idx_conf)) + idx_conf['type'] = idx_type + resp = requests.post( + idx_url, + params={'collection': coll_name}, + data=json.dumps(idx_conf), + auth=(_CONF['db_user'], _CONF['db_pass']) + ) if not resp.ok: raise RuntimeError(resp.text) From d56bf396aec2c99e6a6f58fe79ab7a89aca7fdee Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Thu, 1 Aug 2019 10:19:02 -0700 Subject: [PATCH 338/732] Change the inde initializer to load an array of index confs --- api/src/relation_engine_server/utils/arango_client.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/api/src/relation_engine_server/utils/arango_client.py b/api/src/relation_engine_server/utils/arango_client.py index f872bad2..ad74483f 100644 --- a/api/src/relation_engine_server/utils/arango_client.py +++ b/api/src/relation_engine_server/utils/arango_client.py @@ -108,7 +108,8 @@ def create_collection(name, config): def _create_indexes(coll_name, config): """Create indexes for a collection""" url = _CONF['api_url'] + '/index' - for (idx_type, idx_conf) in config['indexes'].items(): + for idx_conf in config['indexes']: + idx_type = idx_conf['type'] idx_url = url + '#' + idx_type idx_conf['type'] = idx_type resp = requests.post( From 9e0aae6c291fa5419d8867a4bf0fc48809fa4ec9 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Thu, 1 Aug 2019 13:47:24 -0700 Subject: [PATCH 339/732] Add search with tests for sciname on ncbi taxa (#71) * Add search with tests for searching sciname on ncbi taxa * Remove redundant test * Add a test for missing param * Change format of index config * Add content assertion on search results * Limit offset to 10k * Add test for max offset --- spec/schemas/ncbi/ncbi_taxon.yaml | 5 ++ .../ncbi_tax/ncbi_taxon_search_sci_name.yaml | 22 +++++++ spec/test/stored_queries/test_ncbi_tax.py | 61 +++++++++++++++++++ 3 files changed, 88 insertions(+) create mode 100644 spec/stored_queries/ncbi_tax/ncbi_taxon_search_sci_name.yaml diff --git a/spec/schemas/ncbi/ncbi_taxon.yaml b/spec/schemas/ncbi/ncbi_taxon.yaml index 8d08e237..3462ab2e 100644 --- a/spec/schemas/ncbi/ncbi_taxon.yaml +++ b/spec/schemas/ncbi/ncbi_taxon.yaml @@ -1,5 +1,10 @@ name: ncbi_taxon type: vertex + +indexes: + - type: fulltext + fields: [scientific_name] + schema: "$schema": http://json-schema.org/draft-07/schema# type: object diff --git a/spec/stored_queries/ncbi_tax/ncbi_taxon_search_sci_name.yaml b/spec/stored_queries/ncbi_tax/ncbi_taxon_search_sci_name.yaml new file mode 100644 index 00000000..0913569a --- /dev/null +++ b/spec/stored_queries/ncbi_tax/ncbi_taxon_search_sci_name.yaml @@ -0,0 +1,22 @@ +# Search for an ncbi taxon with a scientific name +# Offset is limited to 10k +name: ncbi_taxon_search_sci_name +params: + type: object + required: [search_text] + properties: + search_text: + type: string + title: Search text + description: Text to search on for the scientific name + offset: + type: integer + default: 0 + maximum: 10000 + limit: + type: integer + default: 20 +query: | + FOR doc in FULLTEXT(ncbi_taxon, "scientific_name", @search_text) + LIMIT @offset, @limit + return doc diff --git a/spec/test/stored_queries/test_ncbi_tax.py b/spec/test/stored_queries/test_ncbi_tax.py index 7e25f978..4d70badb 100644 --- a/spec/test/stored_queries/test_ncbi_tax.py +++ b/spec/test/stored_queries/test_ncbi_tax.py @@ -136,3 +136,64 @@ def test_siblings_nonexistent_node(self): data=json.dumps({'key': 'xyz'}), # Nonexistent node ).json() self.assertEqual(resp['count'], 0) + + def test_search_sciname_prefix(self): + """Test a query to search sciname.""" + resp = requests.post( + _CONF['re_api_url'] + '/api/v1/query_results', + params={'stored_query': 'ncbi_taxon_search_sci_name'}, + data=json.dumps({'search_text': 'prefix:bact'}), + ).json() + self.assertEqual(resp['count'], 1) + self.assertEqual(resp['results'][0]['scientific_name'], 'Bacteria') + + def test_search_sciname_nonexistent(self): + """Test a query to search sciname for empty results.""" + resp = requests.post( + _CONF['re_api_url'] + '/api/v1/query_results', + params={'stored_query': 'ncbi_taxon_search_sci_name'}, + data=json.dumps({'search_text': 'xyzabc'}), + ).json() + self.assertEqual(resp['count'], 0) + + def test_search_sciname_wrong_type(self): + """Test a query to search sciname with the wrong type for the search_text param.""" + resp = requests.post( + _CONF['re_api_url'] + '/api/v1/query_results', + params={'stored_query': 'ncbi_taxon_search_sci_name'}, + data=json.dumps({'search_text': 123}) + ) + self.assertEqual(resp.status_code, 400) + self.assertEqual(resp.json()['error'], "123 is not of type 'string'") + + def test_search_sciname_missing_search(self): + """Test a query to search sciname with the search_text param missing.""" + resp = requests.post( + _CONF['re_api_url'] + '/api/v1/query_results', + params={'stored_query': 'ncbi_taxon_search_sci_name'}, + data=json.dumps({}) + ) + self.assertEqual(resp.status_code, 400) + self.assertEqual(resp.json()['error'], "'search_text' is a required property") + + def test_search_sciname_more_complicated(self): + """Test a query to search sciname with some more keyword options.""" + resp = requests.post( + _CONF['re_api_url'] + '/api/v1/query_results', + params={'stored_query': 'ncbi_taxon_search_sci_name'}, + data=json.dumps({'search_text': "prefix:gamma,|prefix:alpha,|prefix:delta"}) + ).json() + self.assertEqual(resp['count'], 3) + names = {r['scientific_name'] for r in resp['results']} + self.assertEqual(names, {'Gammaproteobacteria', 'Alphaproteobacteria', 'Deltaproteobacteria'}) + + def test_search_sciname_offset_limit(self): + """Test a query to search sciname with an invalid offset (greater than max).""" + resp = requests.post( + _CONF['re_api_url'] + '/api/v1/query_results', + params={'stored_query': 'ncbi_taxon_search_sci_name'}, + data=json.dumps({'search_text': "prefix:bact", "offset": 10001}) + ) + print('resp!', resp) + self.assertEqual(resp.status_code, 400) + self.assertEqual(resp.json()['error'], "10001 is greater than the maximum of 10000") From f07ffbda4002bf4b2f2a37273895603e50f074db Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Fri, 2 Aug 2019 12:32:26 -0700 Subject: [PATCH 340/732] Add a limit max on sciname search; add a query to fetch a taxon; add a test for it. (#74) --- .../ncbi_tax/ncbi_fetch_taxon.yaml | 14 +++++++++++ .../ncbi_tax/ncbi_taxon_search_sci_name.yaml | 1 + spec/test/stored_queries/test_ncbi_tax.py | 23 +++++++++++++++++-- 3 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 spec/stored_queries/ncbi_tax/ncbi_fetch_taxon.yaml diff --git a/spec/stored_queries/ncbi_tax/ncbi_fetch_taxon.yaml b/spec/stored_queries/ncbi_tax/ncbi_fetch_taxon.yaml new file mode 100644 index 00000000..6e85196e --- /dev/null +++ b/spec/stored_queries/ncbi_tax/ncbi_fetch_taxon.yaml @@ -0,0 +1,14 @@ +# Fetch a taxon document by taxonomy ID +name: ncbi_fetch_taxon +params: + type: object + required: [key] + properties: + key: + type: string + title: Document key + description: Taxonomy ID (document _key) for the taxon to fetch +query: | + for t in ncbi_taxon + filter t._key == @key + return t diff --git a/spec/stored_queries/ncbi_tax/ncbi_taxon_search_sci_name.yaml b/spec/stored_queries/ncbi_tax/ncbi_taxon_search_sci_name.yaml index 0913569a..57595448 100644 --- a/spec/stored_queries/ncbi_tax/ncbi_taxon_search_sci_name.yaml +++ b/spec/stored_queries/ncbi_tax/ncbi_taxon_search_sci_name.yaml @@ -16,6 +16,7 @@ params: limit: type: integer default: 20 + maximum: 100 query: | FOR doc in FULLTEXT(ncbi_taxon, "scientific_name", @search_text) LIMIT @offset, @limit diff --git a/spec/test/stored_queries/test_ncbi_tax.py b/spec/test/stored_queries/test_ncbi_tax.py index 4d70badb..a15266ee 100644 --- a/spec/test/stored_queries/test_ncbi_tax.py +++ b/spec/test/stored_queries/test_ncbi_tax.py @@ -187,13 +187,32 @@ def test_search_sciname_more_complicated(self): names = {r['scientific_name'] for r in resp['results']} self.assertEqual(names, {'Gammaproteobacteria', 'Alphaproteobacteria', 'Deltaproteobacteria'}) - def test_search_sciname_offset_limit(self): + def test_search_sciname_offset_max(self): """Test a query to search sciname with an invalid offset (greater than max).""" resp = requests.post( _CONF['re_api_url'] + '/api/v1/query_results', params={'stored_query': 'ncbi_taxon_search_sci_name'}, data=json.dumps({'search_text': "prefix:bact", "offset": 10001}) ) - print('resp!', resp) self.assertEqual(resp.status_code, 400) self.assertEqual(resp.json()['error'], "10001 is greater than the maximum of 10000") + + def test_search_sciname_limit_max(self): + """Test a query to search sciname with an invalid offset (greater than max).""" + resp = requests.post( + _CONF['re_api_url'] + '/api/v1/query_results', + params={'stored_query': 'ncbi_taxon_search_sci_name'}, + data=json.dumps({'search_text': "prefix:bact", "limit": 101}) + ) + self.assertEqual(resp.status_code, 400) + self.assertEqual(resp.json()['error'], "101 is greater than the maximum of 100") + + def test_fetch_taxon(self): + """Test a valid query to fetch a taxon.""" + resp = requests.post( + _CONF['re_api_url'] + '/api/v1/query_results', + params={'stored_query': 'ncbi_fetch_taxon'}, + data=json.dumps({'key': '1'}) + ).json() + self.assertEqual(resp['count'], 1) + self.assertEqual(resp['results'][0]['_id'], 'ncbi_taxon/1') From 505bd02546a735ee12ad44aa7236f6bcb1cb9ff9 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Mon, 5 Aug 2019 14:17:52 -0700 Subject: [PATCH 341/732] Fix tests to work with "from", "to", and "id" for delta collections --- spec/test/validate.py | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/spec/test/validate.py b/spec/test/validate.py index c677265f..06e2e25c 100644 --- a/spec/test/validate.py +++ b/spec/test/validate.py @@ -45,8 +45,7 @@ def validate_json_schemas(): jsonschema.validate(data, schema_schema) # Check for any duplicate schema names if name in names: - print('Duplicate schemas for name ' + name) - exit(1) + _fatal('Duplicate schemas for name ' + name) else: names.add(name) # Make sure it can be used as a JSON schema @@ -63,16 +62,15 @@ def validate_json_schemas(): exit(1) # All schemas must be object types if data['schema']['type'] != 'object': - print('Schemas must be an object. Schema in %s is not an object.' % path) - exit(1) + _fatal('Schemas must be an object. Schema in %s is not an object.' % path) required = data['schema'].get('required', []) # Edges must require _from and _to while vertices must require _key - if data['type'] == 'edge' and ('_from' not in required or '_to' not in required): - print('Edge schemas must require _from and _to attributes in ' + path) - exit(1) - elif data['type'] == 'vertex' and '_key' not in required: - print('Vertex schemas must require the _key attribute in ' + path) - exit(1) + has_from_underscore = ('_from' in required and '_to' in required) + has_from = ('from' in required and 'to' in required) + if data['type'] == 'edge' and not has_from_underscore and not has_from: + _fatal('Edge schemas must require _from and _to attributes in ' + path) + elif data['type'] == 'vertex' and '_key' not in required and 'id' not in required: + _fatal('Vertex schemas must require the _key attribute in ' + path) print(f'✓ {name} is valid.') print('..all valid.') @@ -99,8 +97,7 @@ def validate_stored_queries(): jsonschema.validate(data, stored_query_schema) name = data['name'] if name in names: - print(f'Duplicate queries named {name}') - exit(1) + _fatal(f'Duplicate queries named {name}') else: names.add(name) # Make sure `params` can be used as a JSON schema From 417d2765121565f86be9e7bfd755d8e7d2966dd3 Mon Sep 17 00:00:00 2001 From: kellyhuang21 Date: Mon, 5 Aug 2019 14:24:06 -0700 Subject: [PATCH 342/732] Ontology json spec (#73) * pass make test, all changes made * changed test to set * added edge ID, ID is concatenation of fromID_toID_relationship * changed intersection_of and relationship fields to be array [relationship,GO id] * fixed comments, addededge collections * added consider edges * Temporarily add edge schema without sorting into edge collections * remove obsolete edges * remove obsolete fields, remove redundant edge info, add namespace * remove weird char * remove no collections * removed extra files * remove parser * remove extra files * fixed yaml * change to object * change to object * change to object --- spec/schemas/GO/GO_edges_disjoint_from.yaml | 29 +++++ spec/schemas/GO/GO_edges_intersection_of.yaml | 39 +++++++ spec/schemas/GO/GO_edges_isa.yaml | 29 +++++ spec/schemas/GO/GO_edges_relationship.yaml | 37 ++++++ spec/schemas/GO/GO_term.yaml | 107 ++++++++++++++++++ 5 files changed, 241 insertions(+) create mode 100644 spec/schemas/GO/GO_edges_disjoint_from.yaml create mode 100644 spec/schemas/GO/GO_edges_intersection_of.yaml create mode 100644 spec/schemas/GO/GO_edges_isa.yaml create mode 100644 spec/schemas/GO/GO_edges_relationship.yaml create mode 100644 spec/schemas/GO/GO_term.yaml diff --git a/spec/schemas/GO/GO_edges_disjoint_from.yaml b/spec/schemas/GO/GO_edges_disjoint_from.yaml new file mode 100644 index 00000000..93335b0b --- /dev/null +++ b/spec/schemas/GO/GO_edges_disjoint_from.yaml @@ -0,0 +1,29 @@ +--- +name: GO_edges_disjoint_from +type: edge +schema: + "$schema": http://json-schema.org/draft-07/schema# + title: GO_edges_disjoint_from + type: object + description: A entry for disjoint_from edges in the Gene Ontology (GO) hierarchy + properties: + id: + type: string + description: GO id + examples: + - GO:0000136__GO:0031501__disjoint_from + - GO:0000022__GO:0051231__disjoint_from + from: + type: string + description: GO id + examples: + - GO:0023052 + to: + type: string + title: GO id + examples: + - GO:0008150 + required: + - id + - from + - to diff --git a/spec/schemas/GO/GO_edges_intersection_of.yaml b/spec/schemas/GO/GO_edges_intersection_of.yaml new file mode 100644 index 00000000..4f0672c9 --- /dev/null +++ b/spec/schemas/GO/GO_edges_intersection_of.yaml @@ -0,0 +1,39 @@ +--- +name: GO_edges_intersection_of +type: edge +schema: + "$schema": http://json-schema.org/draft-07/schema# + title: GO_edges_intersection_of + type: object + description: A entry for intersection_of edges in the Gene Ontology (GO) hierarchy + properties: + id: + type: string + description: GO id + examples: + - GO:0000136__GO:0031501__intersection_of + - GO:0000132__GO:0000278__intersection_of:regulates + from: + type: string + description: GO id + examples: + - GO:0023052 + to: + type: string + title: GO id + examples: + - GO:0008150 + intersection_type: + type: string + title: Intersection type + examples: + - '' + - part_of + - occurs_in + - regulates + - has_part + required: + - id + - from + - to + - intersection_type diff --git a/spec/schemas/GO/GO_edges_isa.yaml b/spec/schemas/GO/GO_edges_isa.yaml new file mode 100644 index 00000000..bc6f05f3 --- /dev/null +++ b/spec/schemas/GO/GO_edges_isa.yaml @@ -0,0 +1,29 @@ +--- +name: GO_edges_isa +type: edge +schema: + "$schema": http://json-schema.org/draft-07/schema# + title: GO_edges_isa + type: object + description: A entry for is_a edges in the Gene Ontology (GO) hierarchy + properties: + id: + type: string + description: GO id + examples: + - GO:0000136__GO:0031501__is_a + - GO:0000022__GO:0051231__is_a + from: + type: string + description: GO id + examples: + - GO:0023052 + to: + type: string + title: GO id + examples: + - GO:0008150 + required: + - id + - from + - to diff --git a/spec/schemas/GO/GO_edges_relationship.yaml b/spec/schemas/GO/GO_edges_relationship.yaml new file mode 100644 index 00000000..db015d8b --- /dev/null +++ b/spec/schemas/GO/GO_edges_relationship.yaml @@ -0,0 +1,37 @@ +--- +name: GO_edges_relationship +type: edge +schema: + "$schema": http://json-schema.org/draft-07/schema# + title: GO_edges_relationship + type: object + description: A entry for relationship edges in the Gene Ontology (GO) hierarchy + properties: + id: + type: string + description: GO id + examples: + - GO:0000136__GO:0031501__relationship:part_of + - GO:0000132__GO:0000278__relationship:has_part + from: + type: string + description: GO id + examples: + - GO:0023052 + to: + type: string + title: GO id + examples: + - GO:0008150 + relationship_type: + type: string + title: Relationship type + examples: + - occurs_in + - has_part + - part_of + required: + - id + - from + - to + - relationship_type diff --git a/spec/schemas/GO/GO_term.yaml b/spec/schemas/GO/GO_term.yaml new file mode 100644 index 00000000..1ab0a895 --- /dev/null +++ b/spec/schemas/GO/GO_term.yaml @@ -0,0 +1,107 @@ +--- +name: GO_terms +type: vertex +schema: + "$schema": http://json-schema.org/draft-07/schema# + title: GO_terms + type: object + description: A entry for vertices in the Gene Ontology (GO) hierarchy + properties: + id: + type: string + description: The unique id of the current term. + examples: + - GO:0022609 + - GO:0044848 + name: + type: string + description: The term name. Any term may have only one name defined. + examples: + - mitochondrial genome maintenance + - reproduction + namespace: + type: string + description: Denotes which of the three sub-ontologies the term belongs to. + examples: + - cellular component + - biological process + - molecular function + alt_id: + type: array + description: Defines an alternate id for this term. A term may have any number + of alternate ids. + examples: + - - GO:0019952 + - GO:0050876 + - - GO:0044848 + def: + type: string + description: 'The definition of the current term. ' + examples: + - "'The directed movement of a ribosomal subunit from the nucleus into the cytoplasm.' + [GOC:ai]" + - "'Catalysis of the reaction: adenine + H2O = hypoxanthine + NH3.' [EC:3.5.4.2]" + comment: + type: string + description: A comment for this term. + examples: + - This term was made obsolete because it refers to a class of gene products and + a biological process rather than a molecular function. + subset: + type: array + description: This tag indicates a term subset to which this term belongs. + examples: + - - goslim_yeast + - - goslim_chembl + - goslim_metagenomics + - goslim_pir + - goslim_plant + synonym: + type: array + description: This tag gives a synonym for this term, some xrefs to describe the + origins of the synonym, and may indicate a synonym category or scope information. + examples: + - - "'L-methionine porter activity' RELATED []" + - - "'ribonuclease mitochondrial RNA processing complex' EXACT []" + - "'RNase MRP complex' EXACT []" + xref: + type: array + description: A dbxref that describes an analagous term in another vocabulary + examples: + - - Wikipedia:Reproduction + - - KEGG_REACTION:R05612 + - RHEA:20836 + examples: + - - GO:0042254 + - - GO:0008104 + - GO:0051019 + created_by: + type: string + description: Optional tag added by OBO-Edit to indicate the creator of the term + examples: + - kchris + creation_date: + type: string + description: Optional tag added by OBO-Edit to indicate the creation time and + date of the term + examples: + - '2009-04-28T10:33:25Z' + required: + - id + - name + optional: + - alt_id + - def + - comment + - subset + - synonym + - xref + - is_a + - intersection_of + - disjoint_from + - relationship + - is_obsolete + - replaced_by + - consider + - created_by + - creation_date From 13d4a6156bbbb5c3886c5006089e8a9ad082cf97 Mon Sep 17 00:00:00 2001 From: kellyhuang21 Date: Mon, 5 Aug 2019 14:46:46 -0700 Subject: [PATCH 343/732] Ontology json spec (#75) * pass make test, all changes made * changed test to set * added edge ID, ID is concatenation of fromID_toID_relationship * changed intersection_of and relationship fields to be array [relationship,GO id] * fixed comments, addededge collections * added consider edges * Temporarily add edge schema without sorting into edge collections * remove obsolete edges * remove obsolete fields, remove redundant edge info, add namespace * remove weird char * remove no collections * removed extra files * remove parser * remove extra files * fixed yaml * change to object * change to object * change to object * test schemas * create test schema * created test folder * change file names --- .../GO_test/GO_test_edges_disjoint_from.yaml | 29 +++++ .../GO_test_edges_intersection_of.yaml | 39 +++++++ spec/schemas/GO_test/GO_test_edges_isa.yaml | 29 +++++ .../GO_test/GO_test_edges_relationship.yaml | 37 ++++++ spec/schemas/GO_test/GO_test_term.yaml | 107 ++++++++++++++++++ 5 files changed, 241 insertions(+) create mode 100644 spec/schemas/GO_test/GO_test_edges_disjoint_from.yaml create mode 100644 spec/schemas/GO_test/GO_test_edges_intersection_of.yaml create mode 100644 spec/schemas/GO_test/GO_test_edges_isa.yaml create mode 100644 spec/schemas/GO_test/GO_test_edges_relationship.yaml create mode 100644 spec/schemas/GO_test/GO_test_term.yaml diff --git a/spec/schemas/GO_test/GO_test_edges_disjoint_from.yaml b/spec/schemas/GO_test/GO_test_edges_disjoint_from.yaml new file mode 100644 index 00000000..4caa429b --- /dev/null +++ b/spec/schemas/GO_test/GO_test_edges_disjoint_from.yaml @@ -0,0 +1,29 @@ +--- +name: GO_edges_disjoint_from +type: edge +schema: + "$schema": http://json-schema.org/draft-07/schema# + title: GO_edges_disjoint_from + type: object + description: A entry for disjoint_from edges in the Gene Ontology (GO) hierarchy + properties: + _key: + type: string + description: GO id + examples: + - GO:0000136__GO:0031501__disjoint_from + - GO:0000022__GO:0051231__disjoint_from + _from: + type: string + description: GO id + examples: + - GO:0023052 + _to: + type: string + title: GO id + examples: + - GO:0008150 + required: + - _key + - _from + - _to diff --git a/spec/schemas/GO_test/GO_test_edges_intersection_of.yaml b/spec/schemas/GO_test/GO_test_edges_intersection_of.yaml new file mode 100644 index 00000000..77ac7d44 --- /dev/null +++ b/spec/schemas/GO_test/GO_test_edges_intersection_of.yaml @@ -0,0 +1,39 @@ +--- +name: GO_edges_intersection_of +type: edge +schema: + "$schema": http://json-schema.org/draft-07/schema# + title: GO_edges_intersection_of + type: object + description: A entry for intersection_of edges in the Gene Ontology (GO) hierarchy + properties: + _key: + type: string + description: GO id + examples: + - GO:0000136__GO:0031501__intersection_of + - GO:0000132__GO:0000278__intersection_of:regulates + _from: + type: string + description: GO id + examples: + - GO:0023052 + _to: + type: string + title: GO id + examples: + - GO:0008150 + intersection_type: + type: string + title: Intersection type + examples: + - '' + - part_of + - occurs_in + - regulates + - has_part + required: + - _key + - _from + - _to + - intersection_type diff --git a/spec/schemas/GO_test/GO_test_edges_isa.yaml b/spec/schemas/GO_test/GO_test_edges_isa.yaml new file mode 100644 index 00000000..189837b0 --- /dev/null +++ b/spec/schemas/GO_test/GO_test_edges_isa.yaml @@ -0,0 +1,29 @@ +--- +name: GO_edges_isa +type: edge +schema: + "$schema": http://json-schema.org/draft-07/schema# + title: GO_edges_isa + type: object + description: A entry for is_a edges in the Gene Ontology (GO) hierarchy + properties: + _key: + type: string + description: GO id + examples: + - GO:0000136__GO:0031501__is_a + - GO:0000022__GO:0051231__is_a + _from: + type: string + description: GO id + examples: + - GO:0023052 + _to: + type: string + title: GO id + examples: + - GO:0008150 + required: + - _key + - _from + - _to diff --git a/spec/schemas/GO_test/GO_test_edges_relationship.yaml b/spec/schemas/GO_test/GO_test_edges_relationship.yaml new file mode 100644 index 00000000..d4d8a971 --- /dev/null +++ b/spec/schemas/GO_test/GO_test_edges_relationship.yaml @@ -0,0 +1,37 @@ +--- +name: GO_edges_relationship +type: edge +schema: + "$schema": http://json-schema.org/draft-07/schema# + title: GO_edges_relationship + type: object + description: A entry for relationship edges in the Gene Ontology (GO) hierarchy + properties: + _key: + type: string + description: GO id + examples: + - GO:0000136__GO:0031501__relationship:part_of + - GO:0000132__GO:0000278__relationship:has_part + _from: + type: string + description: GO id + examples: + - GO:0023052 + _to: + type: string + title: GO id + examples: + - GO:0008150 + relationship_type: + type: string + title: Relationship type + examples: + - occurs_in + - has_part + - part_of + required: + - _key + - _from + - _to + - relationship_type diff --git a/spec/schemas/GO_test/GO_test_term.yaml b/spec/schemas/GO_test/GO_test_term.yaml new file mode 100644 index 00000000..b98861c9 --- /dev/null +++ b/spec/schemas/GO_test/GO_test_term.yaml @@ -0,0 +1,107 @@ +--- +name: GO_terms +type: vertex +schema: + "$schema": http://json-schema.org/draft-07/schema# + title: GO_terms + type: object + description: A entry for vertices in the Gene Ontology (GO) hierarchy + properties: + _key: + type: string + description: The unique id of the current term. + examples: + - GO:0022609 + - GO:0044848 + name: + type: string + description: The term name. Any term may have only one name defined. + examples: + - mitochondrial genome maintenance + - reproduction + namespace: + type: string + description: Denotes which of the three sub-ontologies the term belongs to. + examples: + - cellular component + - biological process + - molecular function + alt_id: + type: array + description: Defines an alternate id for this term. A term may have any number + of alternate ids. + examples: + - - GO:0019952 + - GO:0050876 + - - GO:0044848 + def: + type: string + description: 'The definition of the current term. ' + examples: + - "'The directed movement of a ribosomal subunit from the nucleus into the cytoplasm.' + [GOC:ai]" + - "'Catalysis of the reaction: adenine + H2O = hypoxanthine + NH3.' [EC:3.5.4.2]" + comment: + type: string + description: A comment for this term. + examples: + - This term was made obsolete because it refers to a class of gene products and + a biological process rather than a molecular function. + subset: + type: array + description: This tag indicates a term subset to which this term belongs. + examples: + - - goslim_yeast + - - goslim_chembl + - goslim_metagenomics + - goslim_pir + - goslim_plant + synonym: + type: array + description: This tag gives a synonym for this term, some xrefs to describe the + origins of the synonym, and may indicate a synonym category or scope information. + examples: + - - "'L-methionine porter activity' RELATED []" + - - "'ribonuclease mitochondrial RNA processing complex' EXACT []" + - "'RNase MRP complex' EXACT []" + xref: + type: array + description: A dbxref that describes an analagous term in another vocabulary + examples: + - - Wikipedia:Reproduction + - - KEGG_REACTION:R05612 + - RHEA:20836 + examples: + - - GO:0042254 + - - GO:0008104 + - GO:0051019 + created_by: + type: string + description: Optional tag added by OBO-Edit to indicate the creator of the term + examples: + - kchris + creation_date: + type: string + description: Optional tag added by OBO-Edit to indicate the creation time and + date of the term + examples: + - '2009-04-28T10:33:25Z' + required: + - _key + - name + optional: + - alt_id + - def + - comment + - subset + - synonym + - xref + - is_a + - intersection_of + - disjoint_from + - relationship + - is_obsolete + - replaced_by + - consider + - created_by + - creation_date From 9de52495aada80c8e56d85081223f58a6b22c7ea Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Thu, 8 Aug 2019 10:00:21 -0700 Subject: [PATCH 344/732] Make various requested changes for the taxonomy api (#77) * Make various requested changes for the taxonomy api * Fix a few details --- .../ncbi_tax/ncbi_taxon_get_ancestors.yaml | 15 ----- .../ncbi_tax/ncbi_taxon_get_children.yaml | 28 ++++++++++ .../ncbi_tax/ncbi_taxon_get_descendants.yaml | 23 -------- .../ncbi_tax/ncbi_taxon_get_lineage.yaml | 22 ++++++++ .../ncbi_tax/ncbi_taxon_get_siblings.yaml | 13 ++++- .../ncbi_tax/ncbi_taxon_search_sci_name.yaml | 6 +- spec/test/stored_queries/test_ncbi_tax.py | 55 +++++++------------ 7 files changed, 84 insertions(+), 78 deletions(-) delete mode 100644 spec/stored_queries/ncbi_tax/ncbi_taxon_get_ancestors.yaml create mode 100644 spec/stored_queries/ncbi_tax/ncbi_taxon_get_children.yaml delete mode 100644 spec/stored_queries/ncbi_tax/ncbi_taxon_get_descendants.yaml create mode 100644 spec/stored_queries/ncbi_tax/ncbi_taxon_get_lineage.yaml diff --git a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_ancestors.yaml b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_ancestors.yaml deleted file mode 100644 index 186c39e7..00000000 --- a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_ancestors.yaml +++ /dev/null @@ -1,15 +0,0 @@ -# Get the array of ancestors for any taxon -name: ncbi_taxon_get_ancestors -params: - type: object - required: [key] - properties: - key: - type: string - title: Document key - description: Key of the taxon vertex for which you want to find ancestors -query: | - for t in ncbi_taxon - filter t._key == @key - for p in 1..10 OUTBOUND t ncbi_child_of_taxon - return p diff --git a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_children.yaml b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_children.yaml new file mode 100644 index 00000000..63bf591e --- /dev/null +++ b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_children.yaml @@ -0,0 +1,28 @@ +# Get the array of direct descendants for any taxon +name: ncbi_taxon_get_descendants +params: + type: object + required: [key] + properties: + key: + type: string + title: Document key + description: Key of the taxon vertex for which you want to find descendants + limit: + type: integer + default: 20 + description: Maximum result limit + maximum: 1000 + offset: + type: integer + default: 0 + description: Result offset for pagination + maximum: 100000 +query: | + for t in ncbi_taxon + filter t._key == @key + for c in 1..1 INBOUND t ncbi_child_of_taxon + sort c.scientific_name asc + limit @offset, @limit + return c + diff --git a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_descendants.yaml b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_descendants.yaml deleted file mode 100644 index cf0d0531..00000000 --- a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_descendants.yaml +++ /dev/null @@ -1,23 +0,0 @@ -# Get the array of descendants for any taxon -# Defaults to immediate children only -# Results are limited to at most 10000 documents -name: ncbi_taxon_get_descendants -params: - type: object - required: [key] - properties: - key: - type: string - title: Document key - description: Key of the taxon vertex for which you want to find descendants - levels: - type: integer - default: 1 - title: Number of levels - description: How many levels of descendants to traverse and aggregate -query: | - for t in ncbi_taxon - filter t._key == @key - for c in 1..@levels INBOUND t ncbi_child_of_taxon - limit 10000 - return c diff --git a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_lineage.yaml b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_lineage.yaml new file mode 100644 index 00000000..4b87bec1 --- /dev/null +++ b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_lineage.yaml @@ -0,0 +1,22 @@ +# Get the lineage array for a taxon +# Returns an array where the top-most (closest to the root) taxon is at the beginning +name: ncbi_taxon_get_ancestors +params: + type: object + required: [key] + properties: + key: + type: string + title: Document key + description: Key of the taxon vertex for which you want to find ancestors +query: | + let ps = ( + for t in ncbi_taxon + filter t._key == @key + for p in 1..10 outbound t ncbi_child_of_taxon + filter p.rank != 'no rank' + return distinct p + ) + // doing return reverse(ps) returns an array of an array for some reason, + // which we don't want + for d in reverse(ps) return d diff --git a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_siblings.yaml b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_siblings.yaml index bc7d012e..4115f862 100644 --- a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_siblings.yaml +++ b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_siblings.yaml @@ -9,6 +9,16 @@ params: type: string title: Document key description: Key of the taxon vertex for which you want to find siblings + limit: + type: integer + default: 20 + description: Maximum result limit + maximum: 1000 + offset: + type: integer + default: 0 + description: Result offset for pagination + maximum: 100000 query: | // First find the taxon in the tree for t in ncbi_taxon @@ -18,5 +28,6 @@ query: | // Then traverse back down to the siblings for c in 1..1 INBOUND parent ncbi_child_of_taxon filter c != t - limit 10000 + sort c.scientific_name asc + limit @offset, @limit return c diff --git a/spec/stored_queries/ncbi_tax/ncbi_taxon_search_sci_name.yaml b/spec/stored_queries/ncbi_tax/ncbi_taxon_search_sci_name.yaml index 57595448..091820ec 100644 --- a/spec/stored_queries/ncbi_tax/ncbi_taxon_search_sci_name.yaml +++ b/spec/stored_queries/ncbi_tax/ncbi_taxon_search_sci_name.yaml @@ -12,12 +12,12 @@ params: offset: type: integer default: 0 - maximum: 10000 + maximum: 100000 limit: type: integer default: 20 - maximum: 100 + maximum: 1000 query: | FOR doc in FULLTEXT(ncbi_taxon, "scientific_name", @search_text) LIMIT @offset, @limit - return doc + RETURN doc diff --git a/spec/test/stored_queries/test_ncbi_tax.py b/spec/test/stored_queries/test_ncbi_tax.py index a15266ee..38cebf66 100644 --- a/spec/test/stored_queries/test_ncbi_tax.py +++ b/spec/test/stored_queries/test_ncbi_tax.py @@ -63,48 +63,31 @@ def setUpClass(cls): ] create_test_docs(taxon_docs, child_docs) - def test_ancestors_valid(self): - """Test a valid query of taxon ancestors.""" + def test_get_lineage_valid(self): + """Test a valid query of taxon lineage.""" resp = requests.post( _CONF['re_api_url'] + '/api/v1/query_results', - params={'stored_query': 'ncbi_taxon_get_ancestors'}, - data=json.dumps({'key': '2'}), + params={'stored_query': 'ncbi_taxon_get_lineage'}, + data=json.dumps({'key': '7'}), ).json() - self.assertEqual(resp['count'], 1) - self.assertEqual(resp['results'][0]['rank'], 'Domain') + self.assertEqual(resp['count'], 2) + ranks = [r['rank'] for r in resp['results']] + names = [r['scientific_name'] for r in resp['results']] + self.assertEqual(ranks, ['Domain', 'Phylum']) + self.assertEqual(names, ['Bacteria', 'Proteobacteria']) - def test_descendants_valid(self): + def test_get_children(self): """Test a valid query of taxon descendants.""" resp = requests.post( _CONF['re_api_url'] + '/api/v1/query_results', - params={'stored_query': 'ncbi_taxon_get_descendants'}, + params={'stored_query': 'ncbi_taxon_get_children'}, data=json.dumps({'key': '1'}), ).json() self.assertEqual(resp['count'], 2) ranks = {r['rank'] for r in resp['results']} - names = {r['scientific_name'] for r in resp['results']} + names = [r['scientific_name'] for r in resp['results']] self.assertEqual(ranks, {'Phylum'}) - self.assertEqual(names, {'Firmicutes', 'Proteobacteria'}) - - def test_descendants_2levels_valid(self): - """Test a valid query for descendants with 2 levels.""" - resp = requests.post( - _CONF['re_api_url'] + '/api/v1/query_results', - params={'stored_query': 'ncbi_taxon_get_descendants'}, - data=json.dumps({'key': '1', 'levels': 2}), - ).json() - self.assertEqual(resp['count'], 6) - ranks = {r['rank'] for r in resp['results']} - names = {r['scientific_name'] for r in resp['results']} - self.assertEqual(ranks, {'Phylum', 'Class'}) - self.assertEqual(names, { - 'Firmicutes', - 'Proteobacteria', - 'Bacilli', - 'Alphaproteobacteria', - 'Gammaproteobacteria', - 'Deltaproteobacteria', - }) + self.assertEqual(names, ['Firmicutes', 'Proteobacteria']) def test_siblings_valid(self): """Test a valid query for siblings.""" @@ -115,9 +98,9 @@ def test_siblings_valid(self): ).json() self.assertEqual(resp['count'], 2) ranks = {r['rank'] for r in resp['results']} - names = {r['scientific_name'] for r in resp['results']} + names = [r['scientific_name'] for r in resp['results']] self.assertEqual(ranks, {'Class'}) - self.assertEqual(names, {'Gammaproteobacteria', 'Deltaproteobacteria'}) + self.assertEqual(names, ['Deltaproteobacteria', 'Gammaproteobacteria']) def test_siblings_root(self): """Test a query for siblings on the root node with no parent.""" @@ -192,20 +175,20 @@ def test_search_sciname_offset_max(self): resp = requests.post( _CONF['re_api_url'] + '/api/v1/query_results', params={'stored_query': 'ncbi_taxon_search_sci_name'}, - data=json.dumps({'search_text': "prefix:bact", "offset": 10001}) + data=json.dumps({'search_text': "prefix:bact", "offset": 100001}) ) self.assertEqual(resp.status_code, 400) - self.assertEqual(resp.json()['error'], "10001 is greater than the maximum of 10000") + self.assertEqual(resp.json()['error'], "100001 is greater than the maximum of 100000") def test_search_sciname_limit_max(self): """Test a query to search sciname with an invalid offset (greater than max).""" resp = requests.post( _CONF['re_api_url'] + '/api/v1/query_results', params={'stored_query': 'ncbi_taxon_search_sci_name'}, - data=json.dumps({'search_text': "prefix:bact", "limit": 101}) + data=json.dumps({'search_text': "prefix:bact", "limit": 1001}) ) self.assertEqual(resp.status_code, 400) - self.assertEqual(resp.json()['error'], "101 is greater than the maximum of 100") + self.assertEqual(resp.json()['error'], "1001 is greater than the maximum of 1000") def test_fetch_taxon(self): """Test a valid query to fetch a taxon.""" From 8ad0054b43cf426bd3e0cf0c292974bdabf95ba1 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Thu, 8 Aug 2019 10:07:55 -0700 Subject: [PATCH 345/732] Update cached spec release for tests --- api/src/test/spec_release/spec.tar.gz | Bin 12555 -> 15057 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/api/src/test/spec_release/spec.tar.gz b/api/src/test/spec_release/spec.tar.gz index d8f7bce887eab37b15b3ace52a6d996712742695..916862e3f347ca2ab8971ba44c4b3b6e48d7d497 100644 GIT binary patch literal 15057 zcmZ{qRZtymu&!};cb5bwxC96;0fGb#?!nzzXn+90JxFi~65JQ=?(Xici#3P;)TvXo zFZNta&CT@1%-e52-ThHVp}_p#3;y)utLsWb!s`+UvHwhzQCn%g(XM@H^-;>%McF>~ zv~FSKNe~BBq2#?fqx`^e<^yvoL6{5IU6SR^Hr!4CCt%cLu=Vu z%fZo5d)%}Q-dgrp+Fl1KUo2+6>+I2OzjFKBcOJ9PB0J9Iy5bHo1N~P``r_v?ZY>Y1 zf~k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qR4Xe?6nOgI%@@H?!o1NDPH{Gn>RXRQy1|4@Pc+b{f z=4_K5bOE6YX!h1YeD7-AIQPJ%N3J#Wnnr39$Pf>6XIA3JD1yN~^peUnkF)9O7V#OG%F z`zN(h%}KEo?rV{7@TN4atw2eAZGN|UMm}4wD{8p{nM0|4{Ae?S{;P6|DD3h?K2KM% zj8CwVzl$vxR?&)@`-g2?qWK?#;u)tq7>mn&-^Fmt}SI! z4txt~WJuc0ct+~nT6t`m_)_?ZxH?VIqy>|w#m@YqXK3YIJBrq5XDFcB)_&O2BiYw0 z+*in}=?^jq#|43Y_drjRYAw Date: Thu, 8 Aug 2019 13:58:20 -0700 Subject: [PATCH 346/732] Remove filter --- spec/stored_queries/ncbi_tax/ncbi_taxon_get_lineage.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_lineage.yaml b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_lineage.yaml index 4b87bec1..bf70ee0c 100644 --- a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_lineage.yaml +++ b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_lineage.yaml @@ -14,7 +14,6 @@ query: | for t in ncbi_taxon filter t._key == @key for p in 1..10 outbound t ncbi_child_of_taxon - filter p.rank != 'no rank' return distinct p ) // doing return reverse(ps) returns an array of an array for some reason, From ead41cd2c493085c1b9905d372b098ca54a883d7 Mon Sep 17 00:00:00 2001 From: kellyhuang21 Date: Thu, 8 Aug 2019 15:24:57 -0700 Subject: [PATCH 347/732] GO AQL queries (#76) * pass make test, all changes made * changed test to set * added edge ID, ID is concatenation of fromID_toID_relationship * changed intersection_of and relationship fields to be array [relationship,GO id] * fixed comments, addededge collections * added consider edges * Temporarily add edge schema without sorting into edge collections * remove obsolete edges * remove obsolete fields, remove redundant edge info, add namespace * remove weird char * remove no collections * removed extra files * remove parser * remove extra files * fixed yaml * change to object * change to object * change to object * test schemas * create test schema * created test folder * change file names * added AQL queries for GO * remove yaml files from GO * remove yaml files from GO test * fix hierarchicalAncestors * fixed PR comments * made corrections to queries * corrected spelling * remove self as sibling --- spec/GO_stored_queries/GO_get_ancestors.yaml | 26 +++++++++++++ spec/GO_stored_queries/GO_get_children.yaml | 26 +++++++++++++ .../GO_stored_queries/GO_get_descendents.yaml | 25 +++++++++++++ .../GO_get_hierarchicalAncestors.yaml | 37 +++++++++++++++++++ .../GO_get_hierarchicalChildren.yaml | 33 +++++++++++++++++ .../GO_get_hierarchicalDescendents.yaml | 36 ++++++++++++++++++ .../GO_get_hierarchicalParents.yaml | 37 +++++++++++++++++++ spec/GO_stored_queries/GO_get_metadata.yaml | 15 ++++++++ spec/GO_stored_queries/GO_get_parents.yaml | 30 +++++++++++++++ spec/GO_stored_queries/GO_get_related.yaml | 25 +++++++++++++ spec/GO_stored_queries/GO_get_siblings.yaml | 28 ++++++++++++++ 11 files changed, 318 insertions(+) create mode 100644 spec/GO_stored_queries/GO_get_ancestors.yaml create mode 100644 spec/GO_stored_queries/GO_get_children.yaml create mode 100644 spec/GO_stored_queries/GO_get_descendents.yaml create mode 100644 spec/GO_stored_queries/GO_get_hierarchicalAncestors.yaml create mode 100644 spec/GO_stored_queries/GO_get_hierarchicalChildren.yaml create mode 100644 spec/GO_stored_queries/GO_get_hierarchicalDescendents.yaml create mode 100644 spec/GO_stored_queries/GO_get_hierarchicalParents.yaml create mode 100644 spec/GO_stored_queries/GO_get_metadata.yaml create mode 100644 spec/GO_stored_queries/GO_get_parents.yaml create mode 100644 spec/GO_stored_queries/GO_get_related.yaml create mode 100644 spec/GO_stored_queries/GO_get_siblings.yaml diff --git a/spec/GO_stored_queries/GO_get_ancestors.yaml b/spec/GO_stored_queries/GO_get_ancestors.yaml new file mode 100644 index 00000000..c504e358 --- /dev/null +++ b/spec/GO_stored_queries/GO_get_ancestors.yaml @@ -0,0 +1,26 @@ +# Get all ancestors (all parent's parents) for this term + +name: GO_get_ancestors +params: + type: object + required: [key] + properties: + key: + type: string + title: Document key + description: GO id of the term you want to get all the ancestors of + limit: + type: integer + default: 20 + description: Maximum result limit + maximum: 1000 + offset: + type: integer + default: 0 + description: Result offset for pagination + maximum: 100000 +query: | + WITH GO_test_term FOR v, e IN 1..1000000 OUTBOUND CONCAT("GO_test_term/", @key) GO_test_edges_isa + SORT v._key ASC + LIMIT @offset, @limit + RETURN {term: v, edge: e} \ No newline at end of file diff --git a/spec/GO_stored_queries/GO_get_children.yaml b/spec/GO_stored_queries/GO_get_children.yaml new file mode 100644 index 00000000..e82b12be --- /dev/null +++ b/spec/GO_stored_queries/GO_get_children.yaml @@ -0,0 +1,26 @@ +# Get the children of this term + +name: GO_get_children +params: + type: object + required: [key] + properties: + key: + type: string + title: Document key + description: GO id of the term you want to get the children of + limit: + type: integer + default: 20 + description: Maximum result limit + maximum: 1000 + offset: + type: integer + default: 0 + description: Result offset for pagination + maximum: 100000 +query: | + WITH GO_test_term FOR v, e IN 1..1 INBOUND CONCAT("GO_test_term/", @key) GO_test_edges_isa + SORT v._key ASC + LIMIT @offset, @limit + RETURN {term: v, edge: e} \ No newline at end of file diff --git a/spec/GO_stored_queries/GO_get_descendents.yaml b/spec/GO_stored_queries/GO_get_descendents.yaml new file mode 100644 index 00000000..df0ada2f --- /dev/null +++ b/spec/GO_stored_queries/GO_get_descendents.yaml @@ -0,0 +1,25 @@ +# Get all descendents of this term +name: GO_get_descendants +params: + type: object + required: [key] + properties: + key: + type: string + title: Document key + description: GO id of the term you want to get all the descendants of + limit: + type: integer + default: 20 + description: Maximum result limit + maximum: 1000 + offset: + type: integer + default: 0 + description: Result offset for pagination + maximum: 100000 +query: | + WITH GO_test_term FOR v, e IN 1..1000000 INBOUND CONCAT("GO_test_term/", @key) GO_test_edges_isa + SORT v._key ASC + LIMIT @offset, @limit + RETURN {term: v, edge: e} \ No newline at end of file diff --git a/spec/GO_stored_queries/GO_get_hierarchicalAncestors.yaml b/spec/GO_stored_queries/GO_get_hierarchicalAncestors.yaml new file mode 100644 index 00000000..8b3feb20 --- /dev/null +++ b/spec/GO_stored_queries/GO_get_hierarchicalAncestors.yaml @@ -0,0 +1,37 @@ +# Get all hierarchical ancestors +# (all parents’s parents) resources for this term. Hierarchical +# ancestors include is-a and other related parents, such as +# part-of/develops-from, that imply a hierarchical relationship + +name: GO_get_hierarchicalAncestors +params: + type: object + required: [key] + properties: + key: + type: string + title: Document key + description: GO id of the term you want to get all the hierarchical ancestors of + limit: + type: integer + default: 20 + description: Maximum result limit + maximum: 1000 + offset: + type: integer + default: 0 + description: Result offset for pagination + maximum: 100000 +query: | + WITH GO_test_term + LET results1 = ( + FOR v_relationship, e_relationship IN 1..1000000 OUTBOUND CONCAT("GO_test_term/", @key) GO_test_edges_relationship + FILTER e_relationship.relationship_type == 'part_of' OR e_relationship.relationship_type == 'has_part' OR e_relationship.relationship_type == 'occurs_in' + RETURN {term: v_relationship, edge: e_relationship}) + LET results2 = ( + FOR v_isa, e_isa IN 1..1000000 OUTBOUND CONCAT("GO_test_term/", @key) GO_test_edges_isa + RETURN {term: v_isa, edge: e_isa}) + FOR x IN UNION(results1, results2) + SORT x._key ASC + LIMIT @offset, @limit + RETURN DISTINCT x \ No newline at end of file diff --git a/spec/GO_stored_queries/GO_get_hierarchicalChildren.yaml b/spec/GO_stored_queries/GO_get_hierarchicalChildren.yaml new file mode 100644 index 00000000..0c5c052e --- /dev/null +++ b/spec/GO_stored_queries/GO_get_hierarchicalChildren.yaml @@ -0,0 +1,33 @@ +# Get the direct hierarchical children for this term. Hierarchical children include is-a and other related children, such as part-of/develops-from, that imply a hierarchical relationship +name: GO_get_hierarchicalChildren +params: + type: object + required: [key] + properties: + key: + type: string + title: Document key + description: GO id of the term you want to get the direct hierarchical children of + limit: + type: integer + default: 20 + description: Maximum result limit + maximum: 1000 + offset: + type: integer + default: 0 + description: Result offset for pagination + maximum: 100000 +query: | + WITH GO_test_term + LET results1 = ( + FOR v_relationship, e_relationship IN 1..1 INBOUND CONCAT("GO_test_term/", @key) GO_test_edges_relationship + FILTER e_relationship.relationship_type == 'part_of' OR e_relationship.relationship_type == 'has_part' OR e_relationship.relationship_type == 'occurs_in' + RETURN {term: v_relationship, edge: e_relationship}) + LET results2 = ( + FOR v_isa, e_isa IN 1..1 INBOUND CONCAT("GO_test_term/", @key) GO_test_edges_isa + RETURN {term: v_isa, edge: e_isa}) + FOR x IN UNION(results1, results2) + SORT x._key ASC + LIMIT @offset, @limit + RETURN DISTINCT x \ No newline at end of file diff --git a/spec/GO_stored_queries/GO_get_hierarchicalDescendents.yaml b/spec/GO_stored_queries/GO_get_hierarchicalDescendents.yaml new file mode 100644 index 00000000..ec6571da --- /dev/null +++ b/spec/GO_stored_queries/GO_get_hierarchicalDescendents.yaml @@ -0,0 +1,36 @@ +# Get all hierarchical descendents +# resources for this term. Hierarchical children include is-a +# and other related children, such as part-of/develops-from, +# that imply a hierarchical relationship +name: GO_get_hierarchicalDescendants +params: + type: object + required: [key] + properties: + key: + type: string + title: Document key + description: GO id of the term you want to get all the hierarchical descendents of + limit: + type: integer + default: 20 + description: Maximum result limit + maximum: 1000 + offset: + type: integer + default: 0 + description: Result offset for pagination + maximum: 100000 +query: | + WITH GO_test_term + LET results1 = ( + FOR v_relationship, e_relationship IN 1..1000000 INBOUND CONCAT("GO_test_term/", @key) GO_test_edges_relationship + FILTER e_relationship.relationship_type == 'part_of' OR e_relationship.relationship_type == 'has_part' OR e_relationship.relationship_type == 'occurs_in' + RETURN {term: v_relationship, edge: e_relationship}) + LET results2 = ( + FOR v_isa, e_isa IN 1..1000000 INBOUND CONCAT("GO_test_term/", @key) GO_test_edges_isa + RETURN {term: v_isa, edge: e_isa} ) + FOR x IN UNION(results1, results2) + SORT x._key ASC + LIMIT @offset, @limit + RETURN DISTINCT x \ No newline at end of file diff --git a/spec/GO_stored_queries/GO_get_hierarchicalParents.yaml b/spec/GO_stored_queries/GO_get_hierarchicalParents.yaml new file mode 100644 index 00000000..ab5b4096 --- /dev/null +++ b/spec/GO_stored_queries/GO_get_hierarchicalParents.yaml @@ -0,0 +1,37 @@ +# Get the direct hierarchical parent +# resources for this term. Hierarchical parents include is-a and +# other related parents, such as part-of/develops-from, that imply +# a hierarchical relationship. + +name: GO_get_hierarchicalParents +params: + type: object + required: [key] + properties: + key: + type: string + title: Document key + description: GO id of the term you want to get all the hierarchical parents of + limit: + type: integer + default: 20 + description: Maximum result limit + maximum: 1000 + offset: + type: integer + default: 0 + description: Result offset for pagination + maximum: 100000 +query: | + WITH GO_test_term + LET results1 = ( + FOR v_relationship, e_relationship IN 1..1 OUTBOUND CONCAT("GO_test_term/", @key) GO_test_edges_relationship + FILTER e_relationship.relationship_type == 'part_of' OR e_relationship.relationship_type == 'has_part' OR e_relationship.relationship_type == 'occurs_in' + RETURN {term: v_relationship, edge: e_relationship}) + LET results2 = ( + FOR v_isa, e_isa IN 1..1 OUTBOUND CONCAT("GO_test_term/", @key) GO_test_edges_isa + RETURN {term: v_isa, edge: e_isa} ) + FOR x IN UNION(results1, results2) + SORT x._key ASC + LIMIT @offset, @limit + RETURN DISTINCT x \ No newline at end of file diff --git a/spec/GO_stored_queries/GO_get_metadata.yaml b/spec/GO_stored_queries/GO_get_metadata.yaml new file mode 100644 index 00000000..860300a2 --- /dev/null +++ b/spec/GO_stored_queries/GO_get_metadata.yaml @@ -0,0 +1,15 @@ +# Get information/metadata of a particular ontology term (see spec for available fields) + +name: GO_get_metadata +params: + type: object + required: [key] + properties: + key: + type: string + title: Document key + description: Get information/metadata of a particular ontology term +query: | + FOR v IN GO_test_term + FILTER v._key == @key + RETURN v \ No newline at end of file diff --git a/spec/GO_stored_queries/GO_get_parents.yaml b/spec/GO_stored_queries/GO_get_parents.yaml new file mode 100644 index 00000000..0ce1c010 --- /dev/null +++ b/spec/GO_stored_queries/GO_get_parents.yaml @@ -0,0 +1,30 @@ +# Get the direct parents for a specific term + +name: GO_get_parents +params: + type: object + required: [key] + properties: + key: + type: string + title: Document key + description: GO id of the term you want to get all the direct parents of + limit: + type: integer + default: 20 + description: Maximum result limit + maximum: 1000 + offset: + type: integer + default: 0 + description: Result offset for pagination + maximum: 100000 +query: | + WITH GO_test_term FOR v, e IN 1..1 OUTBOUND CONCAT("GO_test_term/", @key) GO_test_edges_isa + SORT v._key ASC + LIMIT @offset, @limit + RETURN {term: v, edge: e} + + + + diff --git a/spec/GO_stored_queries/GO_get_related.yaml b/spec/GO_stored_queries/GO_get_related.yaml new file mode 100644 index 00000000..73a3a37e --- /dev/null +++ b/spec/GO_stored_queries/GO_get_related.yaml @@ -0,0 +1,25 @@ +# Get all immediate related terms for this term +name: GO_get_related +params: + type: object + required: [key] + properties: + key: + type: string + title: Document key + description: GO id of the term you want to get all the directly related nodes of + limit: + type: integer + default: 20 + description: Maximum result limit + maximum: 1000 + offset: + type: integer + default: 0 + description: Result offset for pagination + maximum: 100000 +query: | + WITH GO_test_term FOR v, e IN 1 ANY CONCAT("GO_test_term/", @key) GO_test_edges_isa, GO_test_edges_relationship + SORT v._key ASC + LIMIT @offset, @limit + RETURN {term: v, edge: e} \ No newline at end of file diff --git a/spec/GO_stored_queries/GO_get_siblings.yaml b/spec/GO_stored_queries/GO_get_siblings.yaml new file mode 100644 index 00000000..a81c9841 --- /dev/null +++ b/spec/GO_stored_queries/GO_get_siblings.yaml @@ -0,0 +1,28 @@ +# Get all siblings of this term +name: GO_get_siblings +params: + type: object + required: [key] + properties: + key: + type: string + title: Document key + description: Get all siblings of this term + limit: + type: integer + default: 20 + description: Maximum result limit + maximum: 1000 + offset: + type: integer + default: 0 + description: Result offset for pagination + maximum: 100000 +query: | + WITH GO_test_term + FOR v_parent, e_parent IN 1..1 OUTBOUND CONCAT("GO_test_term/", @key) GO_test_edges_isa + FOR v_child, e_child in 1..1 INBOUND e_parent._to GO_test_edges_isa + FILTER e_child._from != CONCAT("GO_test_term/", @key) + SORT v_child._key ASC + LIMIT @offset, @limit + RETURN v_child._key \ No newline at end of file From ed6f67cb7d877ae0f39eed079e1c297070fd8f2d Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Mon, 12 Aug 2019 09:38:39 -0700 Subject: [PATCH 348/732] =?UTF-8?q?Optimize=20taxonomy=20queries;=20return?= =?UTF-8?q?=20total=20count=20for=20siblings,=20children,=E2=80=A6=20(#78)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Optimize taxonomy queries; return total count for siblings, children, and search * Clean up some comments --- .../ncbi_tax/ncbi_taxon_get_children.yaml | 21 +++++++---- .../ncbi_tax/ncbi_taxon_get_siblings.yaml | 35 +++++++++++++------ .../ncbi_tax/ncbi_taxon_search_sci_name.yaml | 16 +++++++-- spec/test/stored_queries/test_ncbi_tax.py | 30 +++++++++------- 4 files changed, 69 insertions(+), 33 deletions(-) diff --git a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_children.yaml b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_children.yaml index 63bf591e..587085c4 100644 --- a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_children.yaml +++ b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_children.yaml @@ -19,10 +19,19 @@ params: description: Result offset for pagination maximum: 100000 query: | - for t in ncbi_taxon - filter t._key == @key - for c in 1..1 INBOUND t ncbi_child_of_taxon - sort c.scientific_name asc + let tax_id = CONCAT("ncbi_taxon/", @key) + // Fetch the child IDs using the edge attributes + let child_ids = ( + for e in ncbi_child_of_taxon + filter e._to == tax_id + return e._from + ) + // Sort and filter the children + let sorted = ( + for tax in ncbi_taxon + sort tax.scientific_name asc + filter tax._id in child_ids limit @offset, @limit - return c - + return tax + ) + return {total_count: COUNT(child_ids), results: sorted} diff --git a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_siblings.yaml b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_siblings.yaml index 4115f862..aa6cab51 100644 --- a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_siblings.yaml +++ b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_siblings.yaml @@ -20,14 +20,27 @@ params: description: Result offset for pagination maximum: 100000 query: | - // First find the taxon in the tree - for t in ncbi_taxon - filter t._key == @key - // Now traverse to the parent - for parent in 1..1 OUTBOUND t ncbi_child_of_taxon - // Then traverse back down to the siblings - for c in 1..1 INBOUND parent ncbi_child_of_taxon - filter c != t - sort c.scientific_name asc - limit @offset, @limit - return c + let tax_id = CONCAT('ncbi_taxon/', @key) + // First fetch the ID of the parent document + let parent_id = first( + for t in ncbi_taxon + filter t._key == @key + for parent in 1..1 outbound t ncbi_child_of_taxon + limit 1 + return parent._id + ) + // Then find the child IDs through the edge fields + let child_ids = ( + for e in ncbi_child_of_taxon + filter e._to == parent_id AND e._from != tax_id + return e._from + ) + // Sort and filter the children + let sorted = ( + for tax in ncbi_taxon + filter tax._id in child_ids + sort tax.scientific_name asc + limit @offset, @limit + return tax + ) + return {total_count: COUNT(child_ids), results: sorted} diff --git a/spec/stored_queries/ncbi_tax/ncbi_taxon_search_sci_name.yaml b/spec/stored_queries/ncbi_tax/ncbi_taxon_search_sci_name.yaml index 091820ec..0c029468 100644 --- a/spec/stored_queries/ncbi_tax/ncbi_taxon_search_sci_name.yaml +++ b/spec/stored_queries/ncbi_tax/ncbi_taxon_search_sci_name.yaml @@ -18,6 +18,16 @@ params: default: 20 maximum: 1000 query: | - FOR doc in FULLTEXT(ncbi_taxon, "scientific_name", @search_text) - LIMIT @offset, @limit - RETURN doc + // Search using the fulltext index on scientific_name + // Don't limit the results yet so we can get the total_count below + let results = ( + FOR doc in FULLTEXT(ncbi_taxon, "scientific_name", @search_text) + return doc + ) + // Limit the results + let limited = ( + for r in results + limit @offset, @limit + return r + ) + return {results: limited, total_count: COUNT(results)} diff --git a/spec/test/stored_queries/test_ncbi_tax.py b/spec/test/stored_queries/test_ncbi_tax.py index 38cebf66..3bca6354 100644 --- a/spec/test/stored_queries/test_ncbi_tax.py +++ b/spec/test/stored_queries/test_ncbi_tax.py @@ -83,9 +83,10 @@ def test_get_children(self): params={'stored_query': 'ncbi_taxon_get_children'}, data=json.dumps({'key': '1'}), ).json() - self.assertEqual(resp['count'], 2) - ranks = {r['rank'] for r in resp['results']} - names = [r['scientific_name'] for r in resp['results']] + result = resp['results'][0] + self.assertEqual(result['total_count'], 2) + ranks = {r['rank'] for r in result['results']} + names = [r['scientific_name'] for r in result['results']] self.assertEqual(ranks, {'Phylum'}) self.assertEqual(names, ['Firmicutes', 'Proteobacteria']) @@ -96,9 +97,10 @@ def test_siblings_valid(self): params={'stored_query': 'ncbi_taxon_get_siblings'}, data=json.dumps({'key': '5'}), # Querying from "Alphaproteobacteria" ).json() - self.assertEqual(resp['count'], 2) - ranks = {r['rank'] for r in resp['results']} - names = [r['scientific_name'] for r in resp['results']] + result = resp['results'][0] + self.assertEqual(result['total_count'], 2) + ranks = {r['rank'] for r in result['results']} + names = [r['scientific_name'] for r in result['results']] self.assertEqual(ranks, {'Class'}) self.assertEqual(names, ['Deltaproteobacteria', 'Gammaproteobacteria']) @@ -109,7 +111,7 @@ def test_siblings_root(self): params={'stored_query': 'ncbi_taxon_get_siblings'}, data=json.dumps({'key': '1'}), # Querying from "Bacteria" ).json() - self.assertEqual(resp['count'], 0) + self.assertEqual(resp['results'][0]['total_count'], 0) def test_siblings_nonexistent_node(self): """Test a query for siblings on the root node with no parent.""" @@ -118,7 +120,7 @@ def test_siblings_nonexistent_node(self): params={'stored_query': 'ncbi_taxon_get_siblings'}, data=json.dumps({'key': 'xyz'}), # Nonexistent node ).json() - self.assertEqual(resp['count'], 0) + self.assertEqual(resp['results'][0]['total_count'], 0) def test_search_sciname_prefix(self): """Test a query to search sciname.""" @@ -127,8 +129,9 @@ def test_search_sciname_prefix(self): params={'stored_query': 'ncbi_taxon_search_sci_name'}, data=json.dumps({'search_text': 'prefix:bact'}), ).json() - self.assertEqual(resp['count'], 1) - self.assertEqual(resp['results'][0]['scientific_name'], 'Bacteria') + result = resp['results'][0] + self.assertEqual(result['total_count'], 1) + self.assertEqual(result['results'][0]['scientific_name'], 'Bacteria') def test_search_sciname_nonexistent(self): """Test a query to search sciname for empty results.""" @@ -137,7 +140,7 @@ def test_search_sciname_nonexistent(self): params={'stored_query': 'ncbi_taxon_search_sci_name'}, data=json.dumps({'search_text': 'xyzabc'}), ).json() - self.assertEqual(resp['count'], 0) + self.assertEqual(resp['results'][0]['total_count'], 0) def test_search_sciname_wrong_type(self): """Test a query to search sciname with the wrong type for the search_text param.""" @@ -166,8 +169,9 @@ def test_search_sciname_more_complicated(self): params={'stored_query': 'ncbi_taxon_search_sci_name'}, data=json.dumps({'search_text': "prefix:gamma,|prefix:alpha,|prefix:delta"}) ).json() - self.assertEqual(resp['count'], 3) - names = {r['scientific_name'] for r in resp['results']} + result = resp['results'][0] + self.assertEqual(result['total_count'], 3) + names = {r['scientific_name'] for r in result['results']} self.assertEqual(names, {'Gammaproteobacteria', 'Alphaproteobacteria', 'Deltaproteobacteria'}) def test_search_sciname_offset_max(self): From 3146f7cc44075c8a698c512eacfddef325ea8c23 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 13 Aug 2019 10:01:18 -0700 Subject: [PATCH 349/732] Fix directory structure --- .../GO}/GO_get_ancestors.yaml | 0 .../{GO_stored_queries => stored_queries/GO}/GO_get_children.yaml | 0 .../GO}/GO_get_descendents.yaml | 0 .../GO}/GO_get_hierarchicalAncestors.yaml | 0 .../GO}/GO_get_hierarchicalChildren.yaml | 0 .../GO}/GO_get_hierarchicalDescendents.yaml | 0 .../GO}/GO_get_hierarchicalParents.yaml | 0 .../{GO_stored_queries => stored_queries/GO}/GO_get_metadata.yaml | 0 spec/{GO_stored_queries => stored_queries/GO}/GO_get_parents.yaml | 0 spec/{GO_stored_queries => stored_queries/GO}/GO_get_related.yaml | 0 .../{GO_stored_queries => stored_queries/GO}/GO_get_siblings.yaml | 0 11 files changed, 0 insertions(+), 0 deletions(-) rename spec/{GO_stored_queries => stored_queries/GO}/GO_get_ancestors.yaml (100%) rename spec/{GO_stored_queries => stored_queries/GO}/GO_get_children.yaml (100%) rename spec/{GO_stored_queries => stored_queries/GO}/GO_get_descendents.yaml (100%) rename spec/{GO_stored_queries => stored_queries/GO}/GO_get_hierarchicalAncestors.yaml (100%) rename spec/{GO_stored_queries => stored_queries/GO}/GO_get_hierarchicalChildren.yaml (100%) rename spec/{GO_stored_queries => stored_queries/GO}/GO_get_hierarchicalDescendents.yaml (100%) rename spec/{GO_stored_queries => stored_queries/GO}/GO_get_hierarchicalParents.yaml (100%) rename spec/{GO_stored_queries => stored_queries/GO}/GO_get_metadata.yaml (100%) rename spec/{GO_stored_queries => stored_queries/GO}/GO_get_parents.yaml (100%) rename spec/{GO_stored_queries => stored_queries/GO}/GO_get_related.yaml (100%) rename spec/{GO_stored_queries => stored_queries/GO}/GO_get_siblings.yaml (100%) diff --git a/spec/GO_stored_queries/GO_get_ancestors.yaml b/spec/stored_queries/GO/GO_get_ancestors.yaml similarity index 100% rename from spec/GO_stored_queries/GO_get_ancestors.yaml rename to spec/stored_queries/GO/GO_get_ancestors.yaml diff --git a/spec/GO_stored_queries/GO_get_children.yaml b/spec/stored_queries/GO/GO_get_children.yaml similarity index 100% rename from spec/GO_stored_queries/GO_get_children.yaml rename to spec/stored_queries/GO/GO_get_children.yaml diff --git a/spec/GO_stored_queries/GO_get_descendents.yaml b/spec/stored_queries/GO/GO_get_descendents.yaml similarity index 100% rename from spec/GO_stored_queries/GO_get_descendents.yaml rename to spec/stored_queries/GO/GO_get_descendents.yaml diff --git a/spec/GO_stored_queries/GO_get_hierarchicalAncestors.yaml b/spec/stored_queries/GO/GO_get_hierarchicalAncestors.yaml similarity index 100% rename from spec/GO_stored_queries/GO_get_hierarchicalAncestors.yaml rename to spec/stored_queries/GO/GO_get_hierarchicalAncestors.yaml diff --git a/spec/GO_stored_queries/GO_get_hierarchicalChildren.yaml b/spec/stored_queries/GO/GO_get_hierarchicalChildren.yaml similarity index 100% rename from spec/GO_stored_queries/GO_get_hierarchicalChildren.yaml rename to spec/stored_queries/GO/GO_get_hierarchicalChildren.yaml diff --git a/spec/GO_stored_queries/GO_get_hierarchicalDescendents.yaml b/spec/stored_queries/GO/GO_get_hierarchicalDescendents.yaml similarity index 100% rename from spec/GO_stored_queries/GO_get_hierarchicalDescendents.yaml rename to spec/stored_queries/GO/GO_get_hierarchicalDescendents.yaml diff --git a/spec/GO_stored_queries/GO_get_hierarchicalParents.yaml b/spec/stored_queries/GO/GO_get_hierarchicalParents.yaml similarity index 100% rename from spec/GO_stored_queries/GO_get_hierarchicalParents.yaml rename to spec/stored_queries/GO/GO_get_hierarchicalParents.yaml diff --git a/spec/GO_stored_queries/GO_get_metadata.yaml b/spec/stored_queries/GO/GO_get_metadata.yaml similarity index 100% rename from spec/GO_stored_queries/GO_get_metadata.yaml rename to spec/stored_queries/GO/GO_get_metadata.yaml diff --git a/spec/GO_stored_queries/GO_get_parents.yaml b/spec/stored_queries/GO/GO_get_parents.yaml similarity index 100% rename from spec/GO_stored_queries/GO_get_parents.yaml rename to spec/stored_queries/GO/GO_get_parents.yaml diff --git a/spec/GO_stored_queries/GO_get_related.yaml b/spec/stored_queries/GO/GO_get_related.yaml similarity index 100% rename from spec/GO_stored_queries/GO_get_related.yaml rename to spec/stored_queries/GO/GO_get_related.yaml diff --git a/spec/GO_stored_queries/GO_get_siblings.yaml b/spec/stored_queries/GO/GO_get_siblings.yaml similarity index 100% rename from spec/GO_stored_queries/GO_get_siblings.yaml rename to spec/stored_queries/GO/GO_get_siblings.yaml From e3c659cd1586ba88875bf3042087cb4b2ed7d1f2 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 13 Aug 2019 11:13:15 -0700 Subject: [PATCH 350/732] Add support for a query prefix from the spec, plus increase the cursor batch size to 10k --- api/src/relation_engine_server/api_versions/api_v1.py | 6 +++--- api/src/relation_engine_server/utils/arango_client.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/api/src/relation_engine_server/api_versions/api_v1.py b/api/src/relation_engine_server/api_versions/api_v1.py index 12acf395..8c8beaa9 100644 --- a/api/src/relation_engine_server/api_versions/api_v1.py +++ b/api/src/relation_engine_server/api_versions/api_v1.py @@ -51,13 +51,13 @@ def run_query(): # 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', 100)) + 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 = json_body['query'] - query_text = 'LET ws_ids = @ws_ids ' + query_text + query_text = json_body.get('query_prefix', '') + ' LET ws_ids = @ws_ids ' + query_text del json_body['query'] json_body['ws_ids'] = ws_ids resp_body = arango_client.run_query(query_text=query_text, @@ -71,7 +71,7 @@ def run_query(): # "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 = 'LET ws_ids = @ws_ids ' + stored_query['query'] + stored_query_source = json_body.get('query_prefix', '') + ' LET ws_ids = @ws_ids ' + stored_query['query'] if 'params' in stored_query: # Validate the user params for the query json_validation.Validator(stored_query['params']).validate(json_body) diff --git a/api/src/relation_engine_server/utils/arango_client.py b/api/src/relation_engine_server/utils/arango_client.py index ad74483f..d01ab0c0 100644 --- a/api/src/relation_engine_server/utils/arango_client.py +++ b/api/src/relation_engine_server/utils/arango_client.py @@ -26,7 +26,7 @@ def server_status(): return 'unknown_failure' -def run_query(query_text=None, cursor_id=None, bind_vars=None, batch_size=100, full_count=False): +def run_query(query_text=None, cursor_id=None, bind_vars=None, batch_size=10000, full_count=False): """Run a query using the arangodb http api. Can return a cursor to get more results.""" url = _CONF['api_url'] + '/cursor' req_json = { From e1dc6ed58a8227699165d5a462e9bd28462e6842 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 13 Aug 2019 11:37:32 -0700 Subject: [PATCH 351/732] Move "WITH" statements to prefixes and clean up formatting (#79) --- spec/stored_queries/GO/GO_get_ancestors.yaml | 5 ++- spec/stored_queries/GO/GO_get_children.yaml | 5 ++- ...scendents.yaml => GO_get_descendants.yaml} | 5 ++- .../GO/GO_get_hierarchicalAncestors.yaml | 29 ++++++++------ .../GO/GO_get_hierarchicalChildren.yaml | 29 ++++++++------ .../GO/GO_get_hierarchicalDescendents.yaml | 37 ++++++++++-------- .../GO/GO_get_hierarchicalParents.yaml | 39 +++++++++++-------- spec/stored_queries/GO/GO_get_metadata.yaml | 8 ++-- spec/stored_queries/GO/GO_get_parents.yaml | 19 ++++----- spec/stored_queries/GO/GO_get_related.yaml | 13 ++++--- spec/stored_queries/GO/GO_get_siblings.yaml | 19 ++++----- spec/test/validate.py | 1 + 12 files changed, 116 insertions(+), 93 deletions(-) rename spec/stored_queries/GO/{GO_get_descendents.yaml => GO_get_descendants.yaml} (79%) diff --git a/spec/stored_queries/GO/GO_get_ancestors.yaml b/spec/stored_queries/GO/GO_get_ancestors.yaml index c504e358..f3842c69 100644 --- a/spec/stored_queries/GO/GO_get_ancestors.yaml +++ b/spec/stored_queries/GO/GO_get_ancestors.yaml @@ -19,8 +19,9 @@ params: default: 0 description: Result offset for pagination maximum: 100000 +query_prefix: WITH GO_test_term query: | - WITH GO_test_term FOR v, e IN 1..1000000 OUTBOUND CONCAT("GO_test_term/", @key) GO_test_edges_isa + FOR v, e IN 1..1000000 OUTBOUND CONCAT("GO_test_term/", @key) GO_test_edges_isa SORT v._key ASC LIMIT @offset, @limit - RETURN {term: v, edge: e} \ No newline at end of file + RETURN {term: v, edge: e} diff --git a/spec/stored_queries/GO/GO_get_children.yaml b/spec/stored_queries/GO/GO_get_children.yaml index e82b12be..e0155a30 100644 --- a/spec/stored_queries/GO/GO_get_children.yaml +++ b/spec/stored_queries/GO/GO_get_children.yaml @@ -19,8 +19,9 @@ params: default: 0 description: Result offset for pagination maximum: 100000 +query_prefix: WITH GO_test_term query: | - WITH GO_test_term FOR v, e IN 1..1 INBOUND CONCAT("GO_test_term/", @key) GO_test_edges_isa + FOR v, e IN 1..1 INBOUND CONCAT("GO_test_term/", @key) GO_test_edges_isa SORT v._key ASC LIMIT @offset, @limit - RETURN {term: v, edge: e} \ No newline at end of file + RETURN {term: v, edge: e} diff --git a/spec/stored_queries/GO/GO_get_descendents.yaml b/spec/stored_queries/GO/GO_get_descendants.yaml similarity index 79% rename from spec/stored_queries/GO/GO_get_descendents.yaml rename to spec/stored_queries/GO/GO_get_descendants.yaml index df0ada2f..156ada75 100644 --- a/spec/stored_queries/GO/GO_get_descendents.yaml +++ b/spec/stored_queries/GO/GO_get_descendants.yaml @@ -18,8 +18,9 @@ params: default: 0 description: Result offset for pagination maximum: 100000 +query_prefix: WITH GO_test_term query: | - WITH GO_test_term FOR v, e IN 1..1000000 INBOUND CONCAT("GO_test_term/", @key) GO_test_edges_isa + FOR v, e IN 1..1000000 INBOUND CONCAT("GO_test_term/", @key) GO_test_edges_isa SORT v._key ASC LIMIT @offset, @limit - RETURN {term: v, edge: e} \ No newline at end of file + RETURN {term: v, edge: e} diff --git a/spec/stored_queries/GO/GO_get_hierarchicalAncestors.yaml b/spec/stored_queries/GO/GO_get_hierarchicalAncestors.yaml index 8b3feb20..1b9db359 100644 --- a/spec/stored_queries/GO/GO_get_hierarchicalAncestors.yaml +++ b/spec/stored_queries/GO/GO_get_hierarchicalAncestors.yaml @@ -22,16 +22,21 @@ params: default: 0 description: Result offset for pagination maximum: 100000 +query_prefix: WITH GO_test_term query: | - WITH GO_test_term - LET results1 = ( - FOR v_relationship, e_relationship IN 1..1000000 OUTBOUND CONCAT("GO_test_term/", @key) GO_test_edges_relationship - FILTER e_relationship.relationship_type == 'part_of' OR e_relationship.relationship_type == 'has_part' OR e_relationship.relationship_type == 'occurs_in' - RETURN {term: v_relationship, edge: e_relationship}) - LET results2 = ( - FOR v_isa, e_isa IN 1..1000000 OUTBOUND CONCAT("GO_test_term/", @key) GO_test_edges_isa - RETURN {term: v_isa, edge: e_isa}) - FOR x IN UNION(results1, results2) - SORT x._key ASC - LIMIT @offset, @limit - RETURN DISTINCT x \ No newline at end of file + LET term_id = CONCAT("GO_test_term/", @key) + LET results1 = ( + FOR v_relationship, e_relationship IN 1..1000000 OUTBOUND term_id GO_test_edges_relationship + FILTER e_relationship.relationship_type == 'part_of' + OR e_relationship.relationship_type == 'has_part' + OR e_relationship.relationship_type == 'occurs_in' + RETURN {term: v_relationship, edge: e_relationship} + ) + LET results2 = ( + FOR v_isa, e_isa IN 1..1000000 OUTBOUND term_id GO_test_edges_isa + RETURN {term: v_isa, edge: e_isa} + ) + FOR x IN UNION(results1, results2) + SORT x._key ASC + LIMIT @offset, @limit + RETURN DISTINCT x diff --git a/spec/stored_queries/GO/GO_get_hierarchicalChildren.yaml b/spec/stored_queries/GO/GO_get_hierarchicalChildren.yaml index 0c5c052e..53b615da 100644 --- a/spec/stored_queries/GO/GO_get_hierarchicalChildren.yaml +++ b/spec/stored_queries/GO/GO_get_hierarchicalChildren.yaml @@ -18,16 +18,21 @@ params: default: 0 description: Result offset for pagination maximum: 100000 +query_prefix: WITH GO_test_term query: | - WITH GO_test_term - LET results1 = ( - FOR v_relationship, e_relationship IN 1..1 INBOUND CONCAT("GO_test_term/", @key) GO_test_edges_relationship - FILTER e_relationship.relationship_type == 'part_of' OR e_relationship.relationship_type == 'has_part' OR e_relationship.relationship_type == 'occurs_in' - RETURN {term: v_relationship, edge: e_relationship}) - LET results2 = ( - FOR v_isa, e_isa IN 1..1 INBOUND CONCAT("GO_test_term/", @key) GO_test_edges_isa - RETURN {term: v_isa, edge: e_isa}) - FOR x IN UNION(results1, results2) - SORT x._key ASC - LIMIT @offset, @limit - RETURN DISTINCT x \ No newline at end of file + LET term_id = CONCAT("GO_test_term/", @key) + LET results1 = ( + FOR v_relationship, e_relationship IN 1..1 INBOUND term_id GO_test_edges_relationship + FILTER e_relationship.relationship_type == 'part_of' + OR e_relationship.relationship_type == 'has_part' + OR e_relationship.relationship_type == 'occurs_in' + RETURN {term: v_relationship, edge: e_relationship} + ) + LET results2 = ( + FOR v_isa, e_isa IN 1..1 INBOUND term_id GO_test_edges_isa + RETURN {term: v_isa, edge: e_isa} + ) + FOR x IN UNION(results1, results2) + SORT x._key ASC + LIMIT @offset, @limit + RETURN DISTINCT x diff --git a/spec/stored_queries/GO/GO_get_hierarchicalDescendents.yaml b/spec/stored_queries/GO/GO_get_hierarchicalDescendents.yaml index ec6571da..3a7ef0cd 100644 --- a/spec/stored_queries/GO/GO_get_hierarchicalDescendents.yaml +++ b/spec/stored_queries/GO/GO_get_hierarchicalDescendents.yaml @@ -1,6 +1,6 @@ # Get all hierarchical descendents -# resources for this term. Hierarchical children include is-a -# and other related children, such as part-of/develops-from, +# resources for this term. Hierarchical children include is-a +# and other related children, such as part-of/develops-from, # that imply a hierarchical relationship name: GO_get_hierarchicalDescendants params: @@ -10,27 +10,32 @@ params: key: type: string title: Document key - description: GO id of the term you want to get all the hierarchical descendents of + description: GO id of the term you want to get all the hierarchical descendents of limit: type: integer default: 20 - description: Maximum result limit + description: Maximum result limit maximum: 1000 offset: type: integer default: 0 description: Result offset for pagination maximum: 100000 +query_prefix: WITH GO_test_term query: | - WITH GO_test_term - LET results1 = ( - FOR v_relationship, e_relationship IN 1..1000000 INBOUND CONCAT("GO_test_term/", @key) GO_test_edges_relationship - FILTER e_relationship.relationship_type == 'part_of' OR e_relationship.relationship_type == 'has_part' OR e_relationship.relationship_type == 'occurs_in' - RETURN {term: v_relationship, edge: e_relationship}) - LET results2 = ( - FOR v_isa, e_isa IN 1..1000000 INBOUND CONCAT("GO_test_term/", @key) GO_test_edges_isa - RETURN {term: v_isa, edge: e_isa} ) - FOR x IN UNION(results1, results2) - SORT x._key ASC - LIMIT @offset, @limit - RETURN DISTINCT x \ No newline at end of file + LET term_id = CONCAT("GO_test_term/", @key) + LET results1 = ( + FOR v_relationship, e_relationship IN 1..1000000 INBOUND term_id GO_test_edges_relationship + FILTER e_relationship.relationship_type == 'part_of' + OR e_relationship.relationship_type == 'has_part' + OR e_relationship.relationship_type == 'occurs_in' + RETURN {term: v_relationship, edge: e_relationship} + ) + LET results2 = ( + FOR v_isa, e_isa IN 1..1000000 INBOUND term_id GO_test_edges_isa + RETURN {term: v_isa, edge: e_isa} + ) + FOR x IN UNION(results1, results2) + SORT x._key ASC + LIMIT @offset, @limit + RETURN DISTINCT x diff --git a/spec/stored_queries/GO/GO_get_hierarchicalParents.yaml b/spec/stored_queries/GO/GO_get_hierarchicalParents.yaml index ab5b4096..184e8dbd 100644 --- a/spec/stored_queries/GO/GO_get_hierarchicalParents.yaml +++ b/spec/stored_queries/GO/GO_get_hierarchicalParents.yaml @@ -1,6 +1,6 @@ -# Get the direct hierarchical parent -# resources for this term. Hierarchical parents include is-a and -# other related parents, such as part-of/develops-from, that imply +# Get the direct hierarchical parent +# resources for this term. Hierarchical parents include is-a and +# other related parents, such as part-of/develops-from, that imply # a hierarchical relationship. name: GO_get_hierarchicalParents @@ -11,27 +11,32 @@ params: key: type: string title: Document key - description: GO id of the term you want to get all the hierarchical parents of + description: GO id of the term you want to get all the hierarchical parents of limit: type: integer default: 20 - description: Maximum result limit + description: Maximum result limit maximum: 1000 offset: type: integer default: 0 description: Result offset for pagination maximum: 100000 +query_prefix: WITH GO_test_term query: | - WITH GO_test_term - LET results1 = ( - FOR v_relationship, e_relationship IN 1..1 OUTBOUND CONCAT("GO_test_term/", @key) GO_test_edges_relationship - FILTER e_relationship.relationship_type == 'part_of' OR e_relationship.relationship_type == 'has_part' OR e_relationship.relationship_type == 'occurs_in' - RETURN {term: v_relationship, edge: e_relationship}) - LET results2 = ( - FOR v_isa, e_isa IN 1..1 OUTBOUND CONCAT("GO_test_term/", @key) GO_test_edges_isa - RETURN {term: v_isa, edge: e_isa} ) - FOR x IN UNION(results1, results2) - SORT x._key ASC - LIMIT @offset, @limit - RETURN DISTINCT x \ No newline at end of file + LET term_id = CONCAT("GO_test_term/", @key) + LET results1 = ( + FOR v_relationship, e_relationship IN 1..1 OUTBOUND term_id GO_test_edges_relationship + FILTER e_relationship.relationship_type == 'part_of' + OR e_relationship.relationship_type == 'has_part' + OR e_relationship.relationship_type == 'occurs_in' + RETURN {term: v_relationship, edge: e_relationship} + ) + LET results2 = ( + FOR v_isa, e_isa IN 1..1 OUTBOUND term_id GO_test_edges_isa + RETURN {term: v_isa, edge: e_isa} + ) + FOR x IN UNION(results1, results2) + SORT x._key ASC + LIMIT @offset, @limit + RETURN DISTINCT x diff --git a/spec/stored_queries/GO/GO_get_metadata.yaml b/spec/stored_queries/GO/GO_get_metadata.yaml index 860300a2..ab2e0f94 100644 --- a/spec/stored_queries/GO/GO_get_metadata.yaml +++ b/spec/stored_queries/GO/GO_get_metadata.yaml @@ -1,4 +1,4 @@ -# Get information/metadata of a particular ontology term (see spec for available fields) +# Get information/metadata of a particular ontology term (see spec for available fields) name: GO_get_metadata params: @@ -8,8 +8,8 @@ params: key: type: string title: Document key - description: Get information/metadata of a particular ontology term + description: Get information/metadata of a particular ontology term query: | FOR v IN GO_test_term - FILTER v._key == @key - RETURN v \ No newline at end of file + FILTER v._key == @key + RETURN v diff --git a/spec/stored_queries/GO/GO_get_parents.yaml b/spec/stored_queries/GO/GO_get_parents.yaml index 0ce1c010..bb2ae0b2 100644 --- a/spec/stored_queries/GO/GO_get_parents.yaml +++ b/spec/stored_queries/GO/GO_get_parents.yaml @@ -1,4 +1,4 @@ -# Get the direct parents for a specific term +# Get the direct parents for a specific term name: GO_get_parents params: @@ -8,23 +8,20 @@ params: key: type: string title: Document key - description: GO id of the term you want to get all the direct parents of + description: GO id of the term you want to get all the direct parents of limit: type: integer default: 20 - description: Maximum result limit + description: Maximum result limit maximum: 1000 offset: type: integer default: 0 description: Result offset for pagination maximum: 100000 +query_prefix: WITH GO_test_term query: | - WITH GO_test_term FOR v, e IN 1..1 OUTBOUND CONCAT("GO_test_term/", @key) GO_test_edges_isa - SORT v._key ASC - LIMIT @offset, @limit - RETURN {term: v, edge: e} - - - - + FOR v, e IN 1..1 OUTBOUND CONCAT("GO_test_term/", @key) GO_test_edges_isa + SORT v._key ASC + LIMIT @offset, @limit + RETURN {term: v, edge: e} diff --git a/spec/stored_queries/GO/GO_get_related.yaml b/spec/stored_queries/GO/GO_get_related.yaml index 73a3a37e..73ffab25 100644 --- a/spec/stored_queries/GO/GO_get_related.yaml +++ b/spec/stored_queries/GO/GO_get_related.yaml @@ -7,19 +7,20 @@ params: key: type: string title: Document key - description: GO id of the term you want to get all the directly related nodes of + description: GO id of the term you want to get all the directly related nodes of limit: type: integer default: 20 - description: Maximum result limit + description: Maximum result limit maximum: 1000 offset: type: integer default: 0 description: Result offset for pagination maximum: 100000 +query_prefix: WITH GO_test_term query: | - WITH GO_test_term FOR v, e IN 1 ANY CONCAT("GO_test_term/", @key) GO_test_edges_isa, GO_test_edges_relationship - SORT v._key ASC - LIMIT @offset, @limit - RETURN {term: v, edge: e} \ No newline at end of file + FOR v, e IN 1 ANY CONCAT("GO_test_term/", @key) GO_test_edges_isa, GO_test_edges_relationship + SORT v._key ASC + LIMIT @offset, @limit + RETURN {term: v, edge: e} diff --git a/spec/stored_queries/GO/GO_get_siblings.yaml b/spec/stored_queries/GO/GO_get_siblings.yaml index a81c9841..c56a978d 100644 --- a/spec/stored_queries/GO/GO_get_siblings.yaml +++ b/spec/stored_queries/GO/GO_get_siblings.yaml @@ -1,4 +1,4 @@ -# Get all siblings of this term +# Get all siblings of this term name: GO_get_siblings params: type: object @@ -11,18 +11,19 @@ params: limit: type: integer default: 20 - description: Maximum result limit + description: Maximum result limit maximum: 1000 offset: type: integer default: 0 description: Result offset for pagination maximum: 100000 +query_prefix: WITH GO_test_term query: | - WITH GO_test_term - FOR v_parent, e_parent IN 1..1 OUTBOUND CONCAT("GO_test_term/", @key) GO_test_edges_isa - FOR v_child, e_child in 1..1 INBOUND e_parent._to GO_test_edges_isa - FILTER e_child._from != CONCAT("GO_test_term/", @key) - SORT v_child._key ASC - LIMIT @offset, @limit - RETURN v_child._key \ No newline at end of file + LET term_id = CONCAT("GO_test_term/", @key) + FOR v_parent, e_parent IN 1..1 OUTBOUND term_id GO_test_edges_isa + FOR v_child, e_child in 1..1 INBOUND e_parent._to GO_test_edges_isa + FILTER e_child._from != term_id + SORT v_child._key ASC + LIMIT @offset, @limit + RETURN v_child._key diff --git a/spec/test/validate.py b/spec/test/validate.py index 06e2e25c..a3ee4cd2 100644 --- a/spec/test/validate.py +++ b/spec/test/validate.py @@ -81,6 +81,7 @@ def validate_json_schemas(): 'properties': { 'name': {'type': 'string'}, 'params': {'type': 'object'}, + 'query_prefix': {'type': 'string'}, 'query': {'type': 'string'} } } From b1e4f0f9cbd087621d69101f9159355c1974cc45 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 13 Aug 2019 11:55:02 -0700 Subject: [PATCH 352/732] Bugfix on query prefix --- api/src/relation_engine_server/api_versions/api_v1.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/src/relation_engine_server/api_versions/api_v1.py b/api/src/relation_engine_server/api_versions/api_v1.py index 8c8beaa9..efef8588 100644 --- a/api/src/relation_engine_server/api_versions/api_v1.py +++ b/api/src/relation_engine_server/api_versions/api_v1.py @@ -71,7 +71,7 @@ def run_query(): # "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 = json_body.get('query_prefix', '') + ' LET ws_ids = @ws_ids ' + stored_query['query'] + stored_query_source = stored_query.get('query_prefix', '') + ' LET ws_ids = @ws_ids ' + stored_query['query'] if 'params' in stored_query: # Validate the user params for the query json_validation.Validator(stored_query['params']).validate(json_body) From 2199838ca5d67a875e2743be7fc7bb95c55a804f Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 13 Aug 2019 13:01:48 -0700 Subject: [PATCH 353/732] Taxon search children (#80) * Move "WITH" statements to prefixes and clean up formatting * Add ability to search taxon children; add children query with cursor --- spec/stored_queries/GO/GO_get_children.yaml | 16 ++++++------ ...ml => GO_get_hierarchicalDescendants.yaml} | 4 +-- .../ncbi_tax/ncbi_taxon_get_children.yaml | 26 ++++++++++++++----- .../ncbi_taxon_get_children_cursor.yaml | 21 +++++++++++++++ .../ncbi_tax/ncbi_taxon_get_lineage.yaml | 2 +- spec/test/stored_queries/test_ncbi_tax.py | 11 +++++++- spec/test/validate.py | 3 +++ 7 files changed, 65 insertions(+), 18 deletions(-) rename spec/stored_queries/GO/{GO_get_hierarchicalDescendents.yaml => GO_get_hierarchicalDescendants.yaml} (95%) create mode 100644 spec/stored_queries/ncbi_tax/ncbi_taxon_get_children_cursor.yaml diff --git a/spec/stored_queries/GO/GO_get_children.yaml b/spec/stored_queries/GO/GO_get_children.yaml index e0155a30..1ea86860 100644 --- a/spec/stored_queries/GO/GO_get_children.yaml +++ b/spec/stored_queries/GO/GO_get_children.yaml @@ -10,15 +10,15 @@ params: title: Document key description: GO id of the term you want to get the children of limit: - type: integer - default: 20 - description: Maximum result limit - maximum: 1000 + type: integer + default: 20 + description: Maximum result limit + maximum: 1000 offset: - type: integer - default: 0 - description: Result offset for pagination - maximum: 100000 + type: integer + default: 0 + description: Result offset for pagination + maximum: 100000 query_prefix: WITH GO_test_term query: | FOR v, e IN 1..1 INBOUND CONCAT("GO_test_term/", @key) GO_test_edges_isa diff --git a/spec/stored_queries/GO/GO_get_hierarchicalDescendents.yaml b/spec/stored_queries/GO/GO_get_hierarchicalDescendants.yaml similarity index 95% rename from spec/stored_queries/GO/GO_get_hierarchicalDescendents.yaml rename to spec/stored_queries/GO/GO_get_hierarchicalDescendants.yaml index 3a7ef0cd..dd9bc3d7 100644 --- a/spec/stored_queries/GO/GO_get_hierarchicalDescendents.yaml +++ b/spec/stored_queries/GO/GO_get_hierarchicalDescendants.yaml @@ -1,4 +1,4 @@ -# Get all hierarchical descendents +# Get all hierarchical descendants # resources for this term. Hierarchical children include is-a # and other related children, such as part-of/develops-from, # that imply a hierarchical relationship @@ -10,7 +10,7 @@ params: key: type: string title: Document key - description: GO id of the term you want to get all the hierarchical descendents of + description: GO id of the term you want to get all the hierarchical descendants of limit: type: integer default: 20 diff --git a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_children.yaml b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_children.yaml index 587085c4..9fcf3318 100644 --- a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_children.yaml +++ b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_children.yaml @@ -1,5 +1,5 @@ # Get the array of direct descendants for any taxon -name: ncbi_taxon_get_descendants +name: ncbi_taxon_get_children params: type: object required: [key] @@ -11,13 +11,17 @@ params: limit: type: integer default: 20 - description: Maximum result limit + description: Maximum result limit maximum: 1000 offset: type: integer default: 0 description: Result offset for pagination maximum: 100000 + search_text: + type: string + description: Search scientific name + default: '' query: | let tax_id = CONCAT("ncbi_taxon/", @key) // Fetch the child IDs using the edge attributes @@ -27,11 +31,21 @@ query: | return e._from ) // Sort and filter the children - let sorted = ( + let searched = ( + for tax in FULLTEXT(ncbi_taxon, "scientific_name", @search_text) + filter tax._id in child_ids + return tax + ) + let not_searched = ( for tax in ncbi_taxon - sort tax.scientific_name asc filter tax._id in child_ids - limit @offset, @limit return tax ) - return {total_count: COUNT(child_ids), results: sorted} + let filtered = @search_text ? searched : not_searched + let results = ( + for tax in filtered + sort tax.scientific_name asc + limit @offset, @limit + return tax + ) + return {total_count: COUNT(filtered), results: results} diff --git a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_children_cursor.yaml b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_children_cursor.yaml new file mode 100644 index 00000000..1ae8bee7 --- /dev/null +++ b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_children_cursor.yaml @@ -0,0 +1,21 @@ +# Get all children for a taxon, using a cursor +name: ncbi_taxon_get_children_cursor +params: + type: object + required: [key] + properties: + key: + type: string + title: Document key + description: Key of the taxon vertex for which you want to find descendants +query: | + let tax_id = CONCAT("ncbi_taxon/", @key) + // Fetch the child IDs using the edge attributes + let child_ids = ( + for e in ncbi_child_of_taxon + filter e._to == tax_id + return e._from + ) + for tax in ncbi_taxon + filter tax._id in child_ids + return tax diff --git a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_lineage.yaml b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_lineage.yaml index bf70ee0c..2323209d 100644 --- a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_lineage.yaml +++ b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_lineage.yaml @@ -1,6 +1,6 @@ # Get the lineage array for a taxon # Returns an array where the top-most (closest to the root) taxon is at the beginning -name: ncbi_taxon_get_ancestors +name: ncbi_taxon_get_lineage params: type: object required: [key] diff --git a/spec/test/stored_queries/test_ncbi_tax.py b/spec/test/stored_queries/test_ncbi_tax.py index 3bca6354..ce303f14 100644 --- a/spec/test/stored_queries/test_ncbi_tax.py +++ b/spec/test/stored_queries/test_ncbi_tax.py @@ -81,7 +81,7 @@ def test_get_children(self): resp = requests.post( _CONF['re_api_url'] + '/api/v1/query_results', params={'stored_query': 'ncbi_taxon_get_children'}, - data=json.dumps({'key': '1'}), + data=json.dumps({'key': '1', 'search_text': 'firmicutes,|proteobacteria'}), ).json() result = resp['results'][0] self.assertEqual(result['total_count'], 2) @@ -90,6 +90,15 @@ def test_get_children(self): self.assertEqual(ranks, {'Phylum'}) self.assertEqual(names, ['Firmicutes', 'Proteobacteria']) + def test_get_children_cursor(self): + """Test a valid query to get children with a cursor.""" + resp = requests.post( + _CONF['re_api_url'] + '/api/v1/query_results', + params={'stored_query': 'ncbi_taxon_get_children_cursor'}, + data=json.dumps({'key': '1'}) + ).json() + self.assertEqual(len(resp['results']), 2) + def test_siblings_valid(self): """Test a valid query for siblings.""" resp = requests.post( diff --git a/spec/test/validate.py b/spec/test/validate.py index a3ee4cd2..fc30a811 100644 --- a/spec/test/validate.py +++ b/spec/test/validate.py @@ -97,6 +97,9 @@ def validate_stored_queries(): data = yaml.safe_load(fd) jsonschema.validate(data, stored_query_schema) name = data['name'] + filename = os.path.splitext(os.path.basename(path))[0] + if name != filename: + _fatal(f'Name key should match filename: {name} vs {filename}') if name in names: _fatal(f'Duplicate queries named {name}') else: From a51212e79c5ad5f9156ee0047670e03a97d1b266 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 14 Aug 2019 11:09:56 -0700 Subject: [PATCH 354/732] Add edge with query from workspace object version to taxon vertex (#81) * Add edge from workspace object version to taxon vertex * Fix typo * Add query with test --- .../wsfull/wsfull_obj_version_has_taxon.yaml | 17 ++++++ .../wsfull/wsfull_get_associated_taxa.yaml | 33 +++++++++++ spec/test/stored_queries/helpers.py | 18 ++++++ spec/test/stored_queries/test_ncbi_tax.py | 33 +---------- spec/test/stored_queries/test_wsfull.py | 55 +++++++++++++++++++ 5 files changed, 126 insertions(+), 30 deletions(-) create mode 100644 spec/schemas/wsfull/wsfull_obj_version_has_taxon.yaml create mode 100644 spec/stored_queries/wsfull/wsfull_get_associated_taxa.yaml create mode 100644 spec/test/stored_queries/helpers.py create mode 100644 spec/test/stored_queries/test_wsfull.py diff --git a/spec/schemas/wsfull/wsfull_obj_version_has_taxon.yaml b/spec/schemas/wsfull/wsfull_obj_version_has_taxon.yaml new file mode 100644 index 00000000..ddb78d67 --- /dev/null +++ b/spec/schemas/wsfull/wsfull_obj_version_has_taxon.yaml @@ -0,0 +1,17 @@ +name: wsfull_obj_version_has_taxon +type: edge +schema: + "$schema": http://json-schema.org/draft-07/schema# + type: object + required: [_from, _to, assigned_by] + description: The _from WS versioned object is associated with the _to taxon. + properties: + assigned_by: + type: string + description: Who made this taxon assignment? + _from: + type: string + description: The WS versioned object that was created. + _to: + type: string + description: The _id of a taxon vertex, such as from NCBI, GTDB, etc. diff --git a/spec/stored_queries/wsfull/wsfull_get_associated_taxa.yaml b/spec/stored_queries/wsfull/wsfull_get_associated_taxa.yaml new file mode 100644 index 00000000..c225ef66 --- /dev/null +++ b/spec/stored_queries/wsfull/wsfull_get_associated_taxa.yaml @@ -0,0 +1,33 @@ +# Get the taxon vertex associated with a versioned workspace object + +name: wsfull_get_associated_taxa + +params: + type: object + required: [id] + properties: + id: + type: string + title: Object ID + description: ID of the wsfull versioned object to find associated taxa + limit: + type: integer + default: 20 + description: Maximum result limit + maximum: 1000 + offset: + type: integer + default: 0 + description: Result offset for pagination + maximum: 100000 + +query_prefix: WITH ncbi_taxon +query: | + for obj in wsfull_object_version + filter obj._id == @id + for tax, e in 1..1 outbound obj wsfull_obj_version_has_taxon + limit @offset, @limit + return { + taxon: UNSET(tax, "_key", "_rev"), + edge: UNSET(e, "_key", "_from", "_to", "_rev") + } diff --git a/spec/test/stored_queries/helpers.py b/spec/test/stored_queries/helpers.py new file mode 100644 index 00000000..35924555 --- /dev/null +++ b/spec/test/stored_queries/helpers.py @@ -0,0 +1,18 @@ +import requests +import json +from test.helpers import get_config + +_CONF = get_config() + + +def create_test_docs(coll_name, docs): + """Create a set of documents for use in tests.""" + body = '\n'.join([json.dumps(d) for d in docs]) + resp = requests.put( + _CONF['re_api_url'] + '/api/v1/documents', + params={'overwrite': True, 'collection': coll_name}, + data=body, + headers={'Authorization': 'admin_token'} + ) + if not resp.ok: + raise RuntimeError(resp.text) diff --git a/spec/test/stored_queries/test_ncbi_tax.py b/spec/test/stored_queries/test_ncbi_tax.py index ce303f14..2479b795 100644 --- a/spec/test/stored_queries/test_ncbi_tax.py +++ b/spec/test/stored_queries/test_ncbi_tax.py @@ -4,41 +4,13 @@ import json import unittest import requests -# import time from test.helpers import get_config +from test.stored_queries.helpers import create_test_docs _CONF = get_config() -def create_test_docs(ncbi_taxon, ncbi_child_of_taxon): - """Create edges and vertices we need for tests.""" - body = '\n'.join([json.dumps(d) for d in ncbi_taxon]) - resp = requests.put( - _CONF['re_api_url'] + '/api/v1/documents', - params={'overwrite': True, 'collection': 'ncbi_taxon'}, - data=body, - headers={'Authorization': 'admin_token'} - ) - if not resp.ok: - raise RuntimeError(resp.text) - ncbi_taxon_results = resp.json() - body = '\n'.join([json.dumps(d) for d in ncbi_child_of_taxon]) - resp = requests.put( - _CONF['re_api_url'] + '/api/v1/documents', - params={'overwrite': True, 'collection': 'ncbi_child_of_taxon'}, - data=body, - headers={'Authorization': 'admin_token'} - ) - if not resp.ok: - raise RuntimeError(resp.text) - ncbi_child_of_taxon_results = resp.json() - return { - 'ncbi_taxon': ncbi_taxon_results, - 'ncbi_child_of_taxon': ncbi_child_of_taxon_results - } - - class TestNcbiTax(unittest.TestCase): @classmethod @@ -61,7 +33,8 @@ def setUpClass(cls): {'_from': 'ncbi_taxon/6', '_to': 'ncbi_taxon/4', 'child_type': 't'}, {'_from': 'ncbi_taxon/7', '_to': 'ncbi_taxon/4', 'child_type': 't'}, ] - create_test_docs(taxon_docs, child_docs) + create_test_docs('ncbi_taxon', taxon_docs) + create_test_docs('ncbi_child_of_taxon', child_docs) def test_get_lineage_valid(self): """Test a valid query of taxon lineage.""" diff --git a/spec/test/stored_queries/test_wsfull.py b/spec/test/stored_queries/test_wsfull.py new file mode 100644 index 00000000..594fb122 --- /dev/null +++ b/spec/test/stored_queries/test_wsfull.py @@ -0,0 +1,55 @@ +""" +Tests queries related to wsfull objects +""" +import json +import unittest +import requests + +from test.stored_queries.helpers import create_test_docs +from test.helpers import get_config + +_CONF = get_config() + + +class TestWsfull(unittest.TestCase): + + @classmethod + def setUpClass(cls): + """Create test documents""" + wsfull_object_versions = [ + { + '_key': '1:1:2', + 'workspace_id': 1, + 'object_id': 1, + 'version': 2, + 'name': 'obj_name', + 'hash': 'xyz', + 'size': 100, + 'epoch': 0, + 'deleted': False + } + ] + taxa = [ + {'_key': '1', 'scientific_name': 'sciname1', 'rank': 'rank1'}, + {'_key': '2', 'scientific_name': 'sciname2', 'rank': 'rank2'}, + ] + edges = [ + {'_from': 'wsfull_object_version/1:1:2', '_to': 'ncbi_taxon/1', 'assigned_by': 'assn1'}, + {'_from': 'wsfull_object_version/1:1:2', '_to': 'ncbi_taxon/2', 'assigned_by': 'assn2'}, + ] + create_test_docs('wsfull_object_version', wsfull_object_versions) + create_test_docs('ncbi_taxon', taxa) + create_test_docs('wsfull_obj_version_has_taxon', edges) + + def test_valid_query(self): + """Test a valid query to get associated taxa.""" + resp = requests.post( + _CONF['re_api_url'] + '/api/v1/query_results', + params={'stored_query': 'wsfull_get_associated_taxa'}, + data=json.dumps({'id': 'wsfull_object_version/1:1:2'}), + ).json() + self.assertEqual(resp['count'], 2) + assignments = [ret['edge']['assigned_by'] for ret in resp['results']] + scinames = [ret['taxon']['scientific_name'] for ret in resp['results']] + self.assertEqual(assignments, ['assn1', 'assn2']) + self.assertEqual(scinames, ['sciname1', 'sciname2']) From 9431b480d08e8eee5efcd1432b706098e0e30f65 Mon Sep 17 00:00:00 2001 From: kellyhuang21 Date: Wed, 14 Aug 2019 11:17:03 -0700 Subject: [PATCH 355/732] Add obsolete edges (#82) * pass make test, all changes made * changed test to set * added edge ID, ID is concatenation of fromID_toID_relationship * changed intersection_of and relationship fields to be array [relationship,GO id] * fixed comments, addededge collections * added consider edges * Temporarily add edge schema without sorting into edge collections * remove obsolete edges * remove obsolete fields, remove redundant edge info, add namespace * remove weird char * remove no collections * removed extra files * remove parser * remove extra files * fixed yaml * change to object * change to object * change to object * test schemas * create test schema * created test folder * change file names * add consider and replaced_by edges * add is_obsolete to node * Fix type of is_obsolete.yaml --- spec/schemas/GO/GO_edges_consider.yaml | 29 +++++++++++++++++++++++ spec/schemas/GO/GO_edges_replaced_by.yaml | 29 +++++++++++++++++++++++ spec/schemas/GO/GO_term.yaml | 5 ++++ 3 files changed, 63 insertions(+) create mode 100644 spec/schemas/GO/GO_edges_consider.yaml create mode 100644 spec/schemas/GO/GO_edges_replaced_by.yaml diff --git a/spec/schemas/GO/GO_edges_consider.yaml b/spec/schemas/GO/GO_edges_consider.yaml new file mode 100644 index 00000000..77c40309 --- /dev/null +++ b/spec/schemas/GO/GO_edges_consider.yaml @@ -0,0 +1,29 @@ +--- +name: GO_edges_consider +type: edge +schema: + "$schema": http://json-schema.org/draft-07/schema# + title: GO_edges_consider + type: object + description: A entry for consider edges in the Gene Ontology (GO) hierarchy + properties: + id: + type: string + description: GO id + examples: + - GO:0000005__GO:0042254__consider + - GO:0000005__GO:0044183__consider + from: + type: string + description: GO id + examples: + - GO:0023052 + to: + type: string + title: GO id + examples: + - GO:0008150 + required: + - id + - from + - to diff --git a/spec/schemas/GO/GO_edges_replaced_by.yaml b/spec/schemas/GO/GO_edges_replaced_by.yaml new file mode 100644 index 00000000..5ab731a5 --- /dev/null +++ b/spec/schemas/GO/GO_edges_replaced_by.yaml @@ -0,0 +1,29 @@ +--- +name: GO_edges_replaced_by +type: edge +schema: + "$schema": http://json-schema.org/draft-07/schema# + title: GO_edges_replaced_by + type: object + description: A entry for replaced_by edges in the Gene Ontology (GO) hierarchy + properties: + id: + type: string + description: GO id + examples: + - GO:0000108__GO:0000109__replaced_by + - GO:0000174__GO:0000750__replaced_by + from: + type: string + description: GO id + examples: + - GO:0023052 + to: + type: string + title: GO id + examples: + - GO:0008150 + required: + - id + - from + - to diff --git a/spec/schemas/GO/GO_term.yaml b/spec/schemas/GO/GO_term.yaml index 1ab0a895..1273e46c 100644 --- a/spec/schemas/GO/GO_term.yaml +++ b/spec/schemas/GO/GO_term.yaml @@ -75,6 +75,11 @@ schema: - - GO:0042254 - - GO:0008104 - GO:0051019 + is_obsolete: + type: boolean + description: Whether or not this term is obsolete. + examples: [true] + default: false created_by: type: string description: Optional tag added by OBO-Edit to indicate the creator of the term From b44d1afd0dc8719d8d36cdc35167a631de8994b1 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 14 Aug 2019 18:20:46 -0700 Subject: [PATCH 356/732] Fix the query to go from taxon to ws objects (#83) * Fix the query to go from taxon to ws objects * Fix comment --- .../ncbi_taxon_get_associated_ws_objects.yaml | 44 +++++++++++++++ .../wsfull/wsfull_get_associated_taxa.yaml | 33 ----------- spec/test/stored_queries/test_ncbi_tax.py | 54 ++++++++++++++++++ spec/test/stored_queries/test_wsfull.py | 55 ------------------- 4 files changed, 98 insertions(+), 88 deletions(-) create mode 100644 spec/stored_queries/ncbi_tax/ncbi_taxon_get_associated_ws_objects.yaml delete mode 100644 spec/stored_queries/wsfull/wsfull_get_associated_taxa.yaml delete mode 100644 spec/test/stored_queries/test_wsfull.py diff --git a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_associated_ws_objects.yaml b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_associated_ws_objects.yaml new file mode 100644 index 00000000..413bacd6 --- /dev/null +++ b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_associated_ws_objects.yaml @@ -0,0 +1,44 @@ +# Get the workspace objects associated with a taxon + +name: ncbi_taxon_get_associated_ws_objects + +params: + type: object + required: [id] + properties: + id: + type: string + title: Taxon ID + description: ID of the taxon vertex to find associated taxa + limit: + type: integer + default: 20 + description: Maximum result limit + maximum: 1000 + offset: + type: integer + default: 0 + description: Result offset for pagination + maximum: 100000 + +query_prefix: WITH ncbi_taxon, wsfull_object_version, wsfull_workspace +query: | + let count = COUNT( + for tax in ncbi_taxon + filter tax._id == @id + for obj in 1..1 inbound tax wsfull_obj_version_has_taxon + return 1 + ) + let results = ( + for tax in ncbi_taxon + filter tax._id == @id + for obj, e in 1..1 inbound tax wsfull_obj_version_has_taxon + for ws in 1..1 inbound obj wsfull_ws_contains_obj + filter ws.is_public or ws._key IN ws_ids + limit @offset, @limit + return { + ws_obj: UNSET(obj, "_key", "_rev"), + edge: UNSET(e, "_key", "_from", "_to", "_rev") + } + ) + return {results, total_count: count} diff --git a/spec/stored_queries/wsfull/wsfull_get_associated_taxa.yaml b/spec/stored_queries/wsfull/wsfull_get_associated_taxa.yaml deleted file mode 100644 index c225ef66..00000000 --- a/spec/stored_queries/wsfull/wsfull_get_associated_taxa.yaml +++ /dev/null @@ -1,33 +0,0 @@ -# Get the taxon vertex associated with a versioned workspace object - -name: wsfull_get_associated_taxa - -params: - type: object - required: [id] - properties: - id: - type: string - title: Object ID - description: ID of the wsfull versioned object to find associated taxa - limit: - type: integer - default: 20 - description: Maximum result limit - maximum: 1000 - offset: - type: integer - default: 0 - description: Result offset for pagination - maximum: 100000 - -query_prefix: WITH ncbi_taxon -query: | - for obj in wsfull_object_version - filter obj._id == @id - for tax, e in 1..1 outbound obj wsfull_obj_version_has_taxon - limit @offset, @limit - return { - taxon: UNSET(tax, "_key", "_rev"), - edge: UNSET(e, "_key", "_from", "_to", "_rev") - } diff --git a/spec/test/stored_queries/test_ncbi_tax.py b/spec/test/stored_queries/test_ncbi_tax.py index 2479b795..3b7cad46 100644 --- a/spec/test/stored_queries/test_ncbi_tax.py +++ b/spec/test/stored_queries/test_ncbi_tax.py @@ -11,6 +11,21 @@ _CONF = get_config() +def _construct_ws_obj(wsid, objid, ver): + """Test helper to create a wsfull_object_version vertex.""" + return { + '_key': f"{wsid}:{objid}:{ver}", + 'workspace_id': wsid, + 'object_id': objid, + 'version': ver, + 'name': f'obj_name{objid}', + 'hash': 'xyz', + 'size': 100, + 'epoch': 0, + 'deleted': False + } + + class TestNcbiTax(unittest.TestCase): @classmethod @@ -33,8 +48,28 @@ def setUpClass(cls): {'_from': 'ncbi_taxon/6', '_to': 'ncbi_taxon/4', 'child_type': 't'}, {'_from': 'ncbi_taxon/7', '_to': 'ncbi_taxon/4', 'child_type': 't'}, ] + obj_docs = [ + _construct_ws_obj(1, 1, 1), + _construct_ws_obj(1, 1, 2), + _construct_ws_obj(2, 1, 1), + ] + obj_to_taxa_docs = [ + {'_from': 'wsfull_object_version/1:1:1', '_to': 'ncbi_taxon/1', 'assigned_by': 'assn1'}, + {'_from': 'wsfull_object_version/1:1:2', '_to': 'ncbi_taxon/1', 'assigned_by': 'assn2'}, + {'_from': 'wsfull_object_version/2:1:1', '_to': 'ncbi_taxon/1', 'assigned_by': 'assn2'}, + ] + ws_docs = [{'_key': '1', 'is_public': True}, {'_key': '2', 'is_public': False}] + ws_to_obj = [ + {'_from': 'wsfull_workspace/1', '_to': 'wsfull_object_version/1:1:1'}, + {'_from': 'wsfull_workspace/1', '_to': 'wsfull_object_version/1:1:2'}, + {'_from': 'wsfull_workspace/2', '_to': 'wsfull_object_version/2:1:1'}, + ] create_test_docs('ncbi_taxon', taxon_docs) create_test_docs('ncbi_child_of_taxon', child_docs) + create_test_docs('wsfull_object_version', obj_docs) + create_test_docs('wsfull_obj_version_has_taxon', obj_to_taxa_docs) + create_test_docs('wsfull_workspace', ws_docs) + create_test_docs('wsfull_ws_contains_obj', ws_to_obj) def test_get_lineage_valid(self): """Test a valid query of taxon lineage.""" @@ -185,3 +220,22 @@ def test_fetch_taxon(self): ).json() self.assertEqual(resp['count'], 1) self.assertEqual(resp['results'][0]['_id'], 'ncbi_taxon/1') + + def test_get_associated_objs(self): + """ + Test a valid query to get associated objects for a taxon. + Two objects are public and one is private, so total_count will be 3 while only the public objects are returned. + """ + resp = requests.post( + _CONF['re_api_url'] + '/api/v1/query_results', + params={'stored_query': 'ncbi_taxon_get_associated_ws_objects'}, + data=json.dumps({'id': 'ncbi_taxon/1'}), + ).json() + self.assertEqual(resp['count'], 1) + results = resp['results'][0] + self.assertEqual(results['total_count'], 3) + self.assertEqual(len(results['results']), 2) + assignments = {ret['edge']['assigned_by'] for ret in results['results']} + ids = {ret['ws_obj']['_id'] for ret in results['results']} + self.assertEqual(assignments, {'assn1', 'assn2'}) + self.assertEqual(ids, {'wsfull_object_version/1:1:1', 'wsfull_object_version/1:1:2'}) diff --git a/spec/test/stored_queries/test_wsfull.py b/spec/test/stored_queries/test_wsfull.py deleted file mode 100644 index 594fb122..00000000 --- a/spec/test/stored_queries/test_wsfull.py +++ /dev/null @@ -1,55 +0,0 @@ -""" -Tests queries related to wsfull objects -""" -import json -import unittest -import requests - -from test.stored_queries.helpers import create_test_docs -from test.helpers import get_config - -_CONF = get_config() - - -class TestWsfull(unittest.TestCase): - - @classmethod - def setUpClass(cls): - """Create test documents""" - wsfull_object_versions = [ - { - '_key': '1:1:2', - 'workspace_id': 1, - 'object_id': 1, - 'version': 2, - 'name': 'obj_name', - 'hash': 'xyz', - 'size': 100, - 'epoch': 0, - 'deleted': False - } - ] - taxa = [ - {'_key': '1', 'scientific_name': 'sciname1', 'rank': 'rank1'}, - {'_key': '2', 'scientific_name': 'sciname2', 'rank': 'rank2'}, - ] - edges = [ - {'_from': 'wsfull_object_version/1:1:2', '_to': 'ncbi_taxon/1', 'assigned_by': 'assn1'}, - {'_from': 'wsfull_object_version/1:1:2', '_to': 'ncbi_taxon/2', 'assigned_by': 'assn2'}, - ] - create_test_docs('wsfull_object_version', wsfull_object_versions) - create_test_docs('ncbi_taxon', taxa) - create_test_docs('wsfull_obj_version_has_taxon', edges) - - def test_valid_query(self): - """Test a valid query to get associated taxa.""" - resp = requests.post( - _CONF['re_api_url'] + '/api/v1/query_results', - params={'stored_query': 'wsfull_get_associated_taxa'}, - data=json.dumps({'id': 'wsfull_object_version/1:1:2'}), - ).json() - self.assertEqual(resp['count'], 2) - assignments = [ret['edge']['assigned_by'] for ret in resp['results']] - scinames = [ret['taxon']['scientific_name'] for ret in resp['results']] - self.assertEqual(assignments, ['assn1', 'assn2']) - self.assertEqual(scinames, ['sciname1', 'sciname2']) From 506e5f4d5e4c9d3234409d1004f94230908902ee Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Fri, 23 Aug 2019 13:05:53 -0700 Subject: [PATCH 357/732] Rename "wsfull" to "ws", add "is_public" flag, update queries and tests (#84) --- spec/schemas/{wsfull => ws}/README.md | 2 +- .../ws_copied_from.yaml} | 2 +- .../ws_has_perm.yaml} | 6 ++-- .../ws_latest_version_of.yaml} | 10 +++--- .../wsfull_method.yaml => ws/ws_method.yaml} | 2 +- .../ws_method_version.yaml} | 4 +-- .../wsfull_module.yaml => ws/ws_module.yaml} | 2 +- .../ws_module_contains_method.yaml} | 2 +- .../ws_module_version.yaml} | 2 +- .../ws_obj_created_with_method.yaml} | 8 ++--- .../ws_obj_created_with_module.yaml} | 2 +- .../ws_obj_instance_of_type.yaml} | 2 +- .../ws_obj_version_has_taxon.yaml} | 2 +- .../wsfull_object.yaml => ws/ws_object.yaml} | 5 ++- .../ws_object_hash.yaml} | 2 +- .../ws_object_version.yaml} | 7 ++-- .../ws_owner_of.yaml} | 8 ++--- .../ws_prov_descendant_of.yaml} | 2 +- .../ws_refers_to.yaml} | 2 +- .../wsfull_type.yaml => ws/ws_type.yaml} | 2 +- .../ws_type_consumed_by_method.yaml} | 2 +- .../ws_type_module.yaml} | 2 +- .../ws_type_version.yaml} | 2 +- .../wsfull_user.yaml => ws/ws_user.yaml} | 2 +- .../ws_version_of.yaml} | 10 +++--- .../ws_workspace.yaml} | 2 +- .../ws_workspace_contains_obj.yaml} | 2 +- .../ncbi_taxon_get_associated_ws_objects.yaml | 19 +++++----- .../wsprov_count_linked_object_types.yaml | 0 .../{ => wsprov}/wsprov_fetch_copies.yaml | 0 .../wsprov_fetch_linked_objects.yaml | 0 .../{ => wsprov}/wsprov_fetch_obj_field.yaml | 0 .../{ => wsprov}/wsprov_fetch_object.yaml | 0 .../wsprov_fetch_paths_between_objects.yaml | 0 .../{ => wsprov}/wsprov_fetch_references.yaml | 0 .../wsprov_list_referencing_type_counts.yaml | 0 spec/test/stored_queries/test_ncbi_tax.py | 35 ++++++++++--------- 37 files changed, 77 insertions(+), 73 deletions(-) rename spec/schemas/{wsfull => ws}/README.md (82%) rename spec/schemas/{wsfull/wsfull_copied_from.yaml => ws/ws_copied_from.yaml} (91%) rename spec/schemas/{wsfull/wsfull_ws_perm.yaml => ws/ws_has_perm.yaml} (83%) rename spec/schemas/{wsfull/wsfull_latest_version_of.yaml => ws/ws_latest_version_of.yaml} (71%) rename spec/schemas/{wsfull/wsfull_method.yaml => ws/ws_method.yaml} (95%) rename spec/schemas/{wsfull/wsfull_method_version.yaml => ws/ws_method_version.yaml} (88%) rename spec/schemas/{wsfull/wsfull_module.yaml => ws/ws_module.yaml} (96%) rename spec/schemas/{wsfull/wsfull_module_contains_method.yaml => ws/ws_module_contains_method.yaml} (89%) rename spec/schemas/{wsfull/wsfull_module_version.yaml => ws/ws_module_version.yaml} (97%) rename spec/schemas/{wsfull/wsfull_obj_created_with_method.yaml => ws/ws_obj_created_with_method.yaml} (68%) rename spec/schemas/{wsfull/wsfull_obj_created_with_module.yaml => ws/ws_obj_created_with_module.yaml} (92%) rename spec/schemas/{wsfull/wsfull_obj_instance_of_type.yaml => ws/ws_obj_instance_of_type.yaml} (89%) rename spec/schemas/{wsfull/wsfull_obj_version_has_taxon.yaml => ws/ws_obj_version_has_taxon.yaml} (93%) rename spec/schemas/{wsfull/wsfull_object.yaml => ws/ws_object.yaml} (88%) rename spec/schemas/{wsfull/wsfull_object_hash.yaml => ws/ws_object_hash.yaml} (93%) rename spec/schemas/{wsfull/wsfull_object_version.yaml => ws/ws_object_version.yaml} (93%) rename spec/schemas/{wsfull/wsfull_owner_of.yaml => ws/ws_owner_of.yaml} (73%) rename spec/schemas/{wsfull/wsfull_prov_descendant_of.yaml => ws/ws_prov_descendant_of.yaml} (89%) rename spec/schemas/{wsfull/wsfull_refers_to.yaml => ws/ws_refers_to.yaml} (92%) rename spec/schemas/{wsfull/wsfull_type.yaml => ws/ws_type.yaml} (93%) rename spec/schemas/{wsfull/wsfull_type_consumed_by_method.yaml => ws/ws_type_consumed_by_method.yaml} (91%) rename spec/schemas/{wsfull/wsfull_type_module.yaml => ws/ws_type_module.yaml} (90%) rename spec/schemas/{wsfull/wsfull_type_version.yaml => ws/ws_type_version.yaml} (91%) rename spec/schemas/{wsfull/wsfull_user.yaml => ws/ws_user.yaml} (94%) rename spec/schemas/{wsfull/wsfull_version_of.yaml => ws/ws_version_of.yaml} (75%) rename spec/schemas/{wsfull/wsfull_workspace.yaml => ws/ws_workspace.yaml} (97%) rename spec/schemas/{wsfull/wsfull_ws_contains_obj.yaml => ws/ws_workspace_contains_obj.yaml} (90%) rename spec/stored_queries/{ => wsprov}/wsprov_count_linked_object_types.yaml (100%) rename spec/stored_queries/{ => wsprov}/wsprov_fetch_copies.yaml (100%) rename spec/stored_queries/{ => wsprov}/wsprov_fetch_linked_objects.yaml (100%) rename spec/stored_queries/{ => wsprov}/wsprov_fetch_obj_field.yaml (100%) rename spec/stored_queries/{ => wsprov}/wsprov_fetch_object.yaml (100%) rename spec/stored_queries/{ => wsprov}/wsprov_fetch_paths_between_objects.yaml (100%) rename spec/stored_queries/{ => wsprov}/wsprov_fetch_references.yaml (100%) rename spec/stored_queries/{ => wsprov}/wsprov_list_referencing_type_counts.yaml (100%) diff --git a/spec/schemas/wsfull/README.md b/spec/schemas/ws/README.md similarity index 82% rename from spec/schemas/wsfull/README.md rename to spec/schemas/ws/README.md index cec182df..a276aecb 100644 --- a/spec/schemas/wsfull/README.md +++ b/spec/schemas/ws/README.md @@ -1,4 +1,4 @@ -# Workspace edges (full details) +# Workspace schemas (full details) These schemas comprise a full, detailed sync of all the data from the KBase workspace. diff --git a/spec/schemas/wsfull/wsfull_copied_from.yaml b/spec/schemas/ws/ws_copied_from.yaml similarity index 91% rename from spec/schemas/wsfull/wsfull_copied_from.yaml rename to spec/schemas/ws/ws_copied_from.yaml index 056739a8..2595db32 100644 --- a/spec/schemas/wsfull/wsfull_copied_from.yaml +++ b/spec/schemas/ws/ws_copied_from.yaml @@ -1,4 +1,4 @@ -name: wsfull_copied_from +name: ws_copied_from type: edge schema: "$schema": http://json-schema.org/draft-07/schema# diff --git a/spec/schemas/wsfull/wsfull_ws_perm.yaml b/spec/schemas/ws/ws_has_perm.yaml similarity index 83% rename from spec/schemas/wsfull/wsfull_ws_perm.yaml rename to spec/schemas/ws/ws_has_perm.yaml index c7806aed..8bfda1c3 100644 --- a/spec/schemas/wsfull/wsfull_ws_perm.yaml +++ b/spec/schemas/ws/ws_has_perm.yaml @@ -1,4 +1,4 @@ -name: wsfull_ws_perm +name: ws_has_perm type: edge schema: "$schema": http://json-schema.org/draft-07/schema# @@ -15,9 +15,9 @@ schema: 'administrator', 'w' is read/write, 'r' is readonly. _from: type: string - examples: ['wsfull_user/jjeffryes'] + examples: ['ws_user/jjeffryes'] description: A username _to: type: string - examples: ['wsfull_workspace/35414'] + examples: ['ws_workspace/35414'] description: A workspace diff --git a/spec/schemas/wsfull/wsfull_latest_version_of.yaml b/spec/schemas/ws/ws_latest_version_of.yaml similarity index 71% rename from spec/schemas/wsfull/wsfull_latest_version_of.yaml rename to spec/schemas/ws/ws_latest_version_of.yaml index e61adc1c..f461be94 100644 --- a/spec/schemas/wsfull/wsfull_latest_version_of.yaml +++ b/spec/schemas/ws/ws_latest_version_of.yaml @@ -1,4 +1,4 @@ -name: wsfull_latest_version_of +name: ws_latest_version_of type: edge schema: "$schema": "http://json-schema.org/draft-07/schema#" @@ -9,16 +9,16 @@ schema: _from: type: string examples: - - wsfull_type_version/KBaseGenomes.Genome‑9.0 - - wsfull_module_version/kb_uploadmethods:8ebb66e4f2c27bc4a9b7cddff7d7b0f27f4ee433 + - ws_type_version/KBaseGenomes.Genome‑9.0 + - ws_module_version/kb_uploadmethods:8ebb66e4f2c27bc4a9b7cddff7d7b0f27f4ee433 description: | A versioned entity, representing the most recent version of an entity in a group (most likely a workspace object, module, or workspace type). _to: type: string examples: - - wsfull_type/KBaseGenomes.Genome - - wsfull_module/kb_uploadmethods + - ws_type/KBaseGenomes.Genome + - ws_module/kb_uploadmethods description: | The non-versioned entity group, where all members of the group are different versions of something (eg. a workspace object, module, or workspace diff --git a/spec/schemas/wsfull/wsfull_method.yaml b/spec/schemas/ws/ws_method.yaml similarity index 95% rename from spec/schemas/wsfull/wsfull_method.yaml rename to spec/schemas/ws/ws_method.yaml index 1c301042..db6b4360 100644 --- a/spec/schemas/wsfull/wsfull_method.yaml +++ b/spec/schemas/ws/ws_method.yaml @@ -1,4 +1,4 @@ -name: wsfull_method +name: ws_method type: vertex schema: "$schema": "http://json-schema.org/draft-07/schema#" diff --git a/spec/schemas/wsfull/wsfull_method_version.yaml b/spec/schemas/ws/ws_method_version.yaml similarity index 88% rename from spec/schemas/wsfull/wsfull_method_version.yaml rename to spec/schemas/ws/ws_method_version.yaml index 0b53155b..59e02dc2 100644 --- a/spec/schemas/wsfull/wsfull_method_version.yaml +++ b/spec/schemas/ws/ws_method_version.yaml @@ -1,4 +1,4 @@ -name: wsfull_method_version +name: ws_method_version type: vertex schema: "$schema": http://json-schema.org/draft-07/schema# @@ -12,7 +12,7 @@ schema: examples: - module_name:version_hash.method_name - module_name:UNKNOWN.method_name - - wsfull_method_version/kb_uploadmethods:8ebb66e4f2c27bc4a9b7cddff7d7b0f27f4ee433.import_genbank_from_staging + - ws_method_version/kb_uploadmethods:8ebb66e4f2c27bc4a9b7cddff7d7b0f27f4ee433.import_genbank_from_staging description: ":." pattern: "^\\w+:\\w+\\.\\w+$" module_name: diff --git a/spec/schemas/wsfull/wsfull_module.yaml b/spec/schemas/ws/ws_module.yaml similarity index 96% rename from spec/schemas/wsfull/wsfull_module.yaml rename to spec/schemas/ws/ws_module.yaml index e680f1ad..26c3dd17 100644 --- a/spec/schemas/wsfull/wsfull_module.yaml +++ b/spec/schemas/ws/ws_module.yaml @@ -1,4 +1,4 @@ -name: wsfull_module +name: ws_module type: vertex schema: "$schema": http://json-schema.org/draft-07/schema# diff --git a/spec/schemas/wsfull/wsfull_module_contains_method.yaml b/spec/schemas/ws/ws_module_contains_method.yaml similarity index 89% rename from spec/schemas/wsfull/wsfull_module_contains_method.yaml rename to spec/schemas/ws/ws_module_contains_method.yaml index 41f7cf80..b254b7c8 100644 --- a/spec/schemas/wsfull/wsfull_module_contains_method.yaml +++ b/spec/schemas/ws/ws_module_contains_method.yaml @@ -1,4 +1,4 @@ -name: wsfull_module_contains_method +name: ws_module_contains_method type: edge schema: "$schema": http://json-schema.org/draft-07/schema# diff --git a/spec/schemas/wsfull/wsfull_module_version.yaml b/spec/schemas/ws/ws_module_version.yaml similarity index 97% rename from spec/schemas/wsfull/wsfull_module_version.yaml rename to spec/schemas/ws/ws_module_version.yaml index 2abe2fe3..e8a25e70 100644 --- a/spec/schemas/wsfull/wsfull_module_version.yaml +++ b/spec/schemas/ws/ws_module_version.yaml @@ -1,4 +1,4 @@ -name: wsfull_module_version +name: ws_module_version type: vertex schema: "$schema": "http://json-schema.org/draft-07/schema#" diff --git a/spec/schemas/wsfull/wsfull_obj_created_with_method.yaml b/spec/schemas/ws/ws_obj_created_with_method.yaml similarity index 68% rename from spec/schemas/wsfull/wsfull_obj_created_with_method.yaml rename to spec/schemas/ws/ws_obj_created_with_method.yaml index 6ca3f7c4..4ab80b0d 100644 --- a/spec/schemas/wsfull/wsfull_obj_created_with_method.yaml +++ b/spec/schemas/ws/ws_obj_created_with_method.yaml @@ -1,4 +1,4 @@ -name: wsfull_obj_created_with_method +name: ws_obj_created_with_method type: edge schema: "$schema": http://json-schema.org/draft-07/schema# @@ -10,13 +10,13 @@ schema: _from: type: string examples: - - wsfull_object_version/35414:73:1 + - ws_object_version/35414:73:1 description: A versioned workspace object. _to: type: string examples: - - wsfull_method_version/kb_uploadmethods:8ebb66e4f2c27bc4a9b7cddff7d7b0f27f4ee433.import_genbank_from_staging - - wsfull_method_version/kb_uploadmethods:UNKNOWN.import_genbank_from_staging + - ws_method_version/kb_uploadmethods:8ebb66e4f2c27bc4a9b7cddff7d7b0f27f4ee433.import_genbank_from_staging + - ws_method_version/kb_uploadmethods:UNKNOWN.import_genbank_from_staging description: A version of a module with a method. method_params: type: [array, object, 'null'] diff --git a/spec/schemas/wsfull/wsfull_obj_created_with_module.yaml b/spec/schemas/ws/ws_obj_created_with_module.yaml similarity index 92% rename from spec/schemas/wsfull/wsfull_obj_created_with_module.yaml rename to spec/schemas/ws/ws_obj_created_with_module.yaml index daa01511..2d00353b 100644 --- a/spec/schemas/wsfull/wsfull_obj_created_with_module.yaml +++ b/spec/schemas/ws/ws_obj_created_with_module.yaml @@ -1,4 +1,4 @@ -name: wsfull_obj_created_with_module +name: ws_obj_created_with_module type: edge schema: "$schema": http://json-schema.org/draft-07/schema# diff --git a/spec/schemas/wsfull/wsfull_obj_instance_of_type.yaml b/spec/schemas/ws/ws_obj_instance_of_type.yaml similarity index 89% rename from spec/schemas/wsfull/wsfull_obj_instance_of_type.yaml rename to spec/schemas/ws/ws_obj_instance_of_type.yaml index 274c9c73..8adf6553 100644 --- a/spec/schemas/wsfull/wsfull_obj_instance_of_type.yaml +++ b/spec/schemas/ws/ws_obj_instance_of_type.yaml @@ -1,4 +1,4 @@ -name: wsfull_obj_instance_of_type +name: ws_obj_instance_of_type type: edge schema: "$schema": http://json-schema.org/draft-07/schema# diff --git a/spec/schemas/wsfull/wsfull_obj_version_has_taxon.yaml b/spec/schemas/ws/ws_obj_version_has_taxon.yaml similarity index 93% rename from spec/schemas/wsfull/wsfull_obj_version_has_taxon.yaml rename to spec/schemas/ws/ws_obj_version_has_taxon.yaml index ddb78d67..529141c0 100644 --- a/spec/schemas/wsfull/wsfull_obj_version_has_taxon.yaml +++ b/spec/schemas/ws/ws_obj_version_has_taxon.yaml @@ -1,4 +1,4 @@ -name: wsfull_obj_version_has_taxon +name: ws_obj_version_has_taxon type: edge schema: "$schema": http://json-schema.org/draft-07/schema# diff --git a/spec/schemas/wsfull/wsfull_object.yaml b/spec/schemas/ws/ws_object.yaml similarity index 88% rename from spec/schemas/wsfull/wsfull_object.yaml rename to spec/schemas/ws/ws_object.yaml index 0327de0f..bfbbf553 100644 --- a/spec/schemas/wsfull/wsfull_object.yaml +++ b/spec/schemas/ws/ws_object.yaml @@ -1,4 +1,4 @@ -name: wsfull_object +name: ws_object type: vertex schema: "$schema": http://json-schema.org/draft-07/schema# @@ -21,3 +21,6 @@ schema: minimum: 1 deleted: type: boolean + is_public: + type: boolean + deafult: false diff --git a/spec/schemas/wsfull/wsfull_object_hash.yaml b/spec/schemas/ws/ws_object_hash.yaml similarity index 93% rename from spec/schemas/wsfull/wsfull_object_hash.yaml rename to spec/schemas/ws/ws_object_hash.yaml index 746e0fda..5db8b511 100644 --- a/spec/schemas/wsfull/wsfull_object_hash.yaml +++ b/spec/schemas/ws/ws_object_hash.yaml @@ -1,4 +1,4 @@ -name: wsfull_object_hash +name: ws_object_hash type: vertex schema: "$schema": "http://json-schema.org/draft-07/schema#" diff --git a/spec/schemas/wsfull/wsfull_object_version.yaml b/spec/schemas/ws/ws_object_version.yaml similarity index 93% rename from spec/schemas/wsfull/wsfull_object_version.yaml rename to spec/schemas/ws/ws_object_version.yaml index 2ef23d5d..ed647df7 100644 --- a/spec/schemas/wsfull/wsfull_object_version.yaml +++ b/spec/schemas/ws/ws_object_version.yaml @@ -1,4 +1,4 @@ -name: wsfull_object_version +name: ws_object_version type: vertex schema: "$schema": "http://json-schema.org/draft-07/schema#" @@ -34,8 +34,6 @@ schema: name: type: string description: The user supplied name for this object - examples: - - my_awesome_object hash: type: string description: The md5 hash of the workspace object @@ -52,3 +50,6 @@ schema: minimum: 0 deleted: type: boolean + is_public: + type: boolean + default: false diff --git a/spec/schemas/wsfull/wsfull_owner_of.yaml b/spec/schemas/ws/ws_owner_of.yaml similarity index 73% rename from spec/schemas/wsfull/wsfull_owner_of.yaml rename to spec/schemas/ws/ws_owner_of.yaml index 4ada3b72..3c3976fd 100644 --- a/spec/schemas/wsfull/wsfull_owner_of.yaml +++ b/spec/schemas/ws/ws_owner_of.yaml @@ -1,4 +1,4 @@ -name: wsfull_owner_of +name: ws_owner_of type: edge schema: "$schema": http://json-schema.org/draft-07/schema# @@ -9,11 +9,11 @@ schema: properties: _from: type: string - examples: ["wsfull_user/jjeffryes"] + examples: ["ws_user/jjeffryes"] description: A username _to: type: string examples: - - wsfull_type_module/KBaseGenomes - - wsfull_workspace/35414 + - ws_type_module/KBaseGenomes + - ws_workspace/35414 description: A Workspace or Type Module diff --git a/spec/schemas/wsfull/wsfull_prov_descendant_of.yaml b/spec/schemas/ws/ws_prov_descendant_of.yaml similarity index 89% rename from spec/schemas/wsfull/wsfull_prov_descendant_of.yaml rename to spec/schemas/ws/ws_prov_descendant_of.yaml index 255c8303..bc546eb6 100644 --- a/spec/schemas/wsfull/wsfull_prov_descendant_of.yaml +++ b/spec/schemas/ws/ws_prov_descendant_of.yaml @@ -1,4 +1,4 @@ -name: wsfull_prov_descendant_of +name: ws_prov_descendant_of type: edge schema: "$schema": "http://json-schema.org/draft-07/schema#" diff --git a/spec/schemas/wsfull/wsfull_refers_to.yaml b/spec/schemas/ws/ws_refers_to.yaml similarity index 92% rename from spec/schemas/wsfull/wsfull_refers_to.yaml rename to spec/schemas/ws/ws_refers_to.yaml index 46fd8264..8865ae80 100644 --- a/spec/schemas/wsfull/wsfull_refers_to.yaml +++ b/spec/schemas/ws/ws_refers_to.yaml @@ -1,4 +1,4 @@ -name: wsfull_refers_to +name: ws_refers_to type: edge schema: "$schema": "http://json-schema.org/draft-07/schema#" diff --git a/spec/schemas/wsfull/wsfull_type.yaml b/spec/schemas/ws/ws_type.yaml similarity index 93% rename from spec/schemas/wsfull/wsfull_type.yaml rename to spec/schemas/ws/ws_type.yaml index fbfb7e53..f9795a4e 100644 --- a/spec/schemas/wsfull/wsfull_type.yaml +++ b/spec/schemas/ws/ws_type.yaml @@ -1,4 +1,4 @@ -name: wsfull_type +name: ws_type type: vertex schema: "$schema": "http://json-schema.org/draft-07/schema#" diff --git a/spec/schemas/wsfull/wsfull_type_consumed_by_method.yaml b/spec/schemas/ws/ws_type_consumed_by_method.yaml similarity index 91% rename from spec/schemas/wsfull/wsfull_type_consumed_by_method.yaml rename to spec/schemas/ws/ws_type_consumed_by_method.yaml index be39175d..6ee25fc8 100644 --- a/spec/schemas/wsfull/wsfull_type_consumed_by_method.yaml +++ b/spec/schemas/ws/ws_type_consumed_by_method.yaml @@ -1,4 +1,4 @@ -name: wsfull_type_consumed_by_method +name: ws_type_consumed_by_method type: edge schema: "$schema": "http://json-schema.org/draft-07/schema#" diff --git a/spec/schemas/wsfull/wsfull_type_module.yaml b/spec/schemas/ws/ws_type_module.yaml similarity index 90% rename from spec/schemas/wsfull/wsfull_type_module.yaml rename to spec/schemas/ws/ws_type_module.yaml index 6703d08c..ac5f527e 100644 --- a/spec/schemas/wsfull/wsfull_type_module.yaml +++ b/spec/schemas/ws/ws_type_module.yaml @@ -1,4 +1,4 @@ -name: wsfull_type_module +name: ws_type_module type: vertex schema: "$schema": "http://json-schema.org/draft-07/schema#" diff --git a/spec/schemas/wsfull/wsfull_type_version.yaml b/spec/schemas/ws/ws_type_version.yaml similarity index 91% rename from spec/schemas/wsfull/wsfull_type_version.yaml rename to spec/schemas/ws/ws_type_version.yaml index 3a351d96..ba2c9aed 100644 --- a/spec/schemas/wsfull/wsfull_type_version.yaml +++ b/spec/schemas/ws/ws_type_version.yaml @@ -1,4 +1,4 @@ -name: wsfull_type_version +name: ws_type_version type: vertex schema: "$schema": "http://json-schema.org/draft-07/schema#" diff --git a/spec/schemas/wsfull/wsfull_user.yaml b/spec/schemas/ws/ws_user.yaml similarity index 94% rename from spec/schemas/wsfull/wsfull_user.yaml rename to spec/schemas/ws/ws_user.yaml index 5a142fde..4bf96834 100644 --- a/spec/schemas/wsfull/wsfull_user.yaml +++ b/spec/schemas/ws/ws_user.yaml @@ -1,4 +1,4 @@ -name: wsfull_user +name: ws_user type: vertex schema: "$schema": "http://json-schema.org/draft-07/schema#" diff --git a/spec/schemas/wsfull/wsfull_version_of.yaml b/spec/schemas/ws/ws_version_of.yaml similarity index 75% rename from spec/schemas/wsfull/wsfull_version_of.yaml rename to spec/schemas/ws/ws_version_of.yaml index a0f08e85..573d6943 100644 --- a/spec/schemas/wsfull/wsfull_version_of.yaml +++ b/spec/schemas/ws/ws_version_of.yaml @@ -1,4 +1,4 @@ -name: wsfull_version_of +name: ws_version_of type: edge schema: "$schema": "http://json-schema.org/draft-07/schema#" @@ -10,14 +10,14 @@ schema: _from: type: string examples: - - wsfull_type_version/KBaseGenomes.Genome‑9.0 - - wsfull_method_version/kb_uploadmethods:8ebb66e4f2c27bc4a9b7cddff7d7b0f27f4ee433 + - ws_type_version/KBaseGenomes.Genome‑9.0 + - ws_method_version/kb_uploadmethods:8ebb66e4f2c27bc4a9b7cddff7d7b0f27f4ee433 description: A versioned entity (eg. a workspace object, module, or workspace type) _to: type: string examples: - - wsfull_type/KBaseGenomes.Genome - - wsfull_method/kb_uploadmethods + - ws_type/KBaseGenomes.Genome + - ws_method/kb_uploadmethods description: | The non-versioned entity group, where all members of the group are different versions of something (eg. a workspace object, module, or workspace diff --git a/spec/schemas/wsfull/wsfull_workspace.yaml b/spec/schemas/ws/ws_workspace.yaml similarity index 97% rename from spec/schemas/wsfull/wsfull_workspace.yaml rename to spec/schemas/ws/ws_workspace.yaml index 05dfa24b..0f2d6ed1 100644 --- a/spec/schemas/wsfull/wsfull_workspace.yaml +++ b/spec/schemas/ws/ws_workspace.yaml @@ -1,4 +1,4 @@ -name: wsfull_workspace +name: ws_workspace type: vertex schema: "$schema": "http://json-schema.org/draft-07/schema#" diff --git a/spec/schemas/wsfull/wsfull_ws_contains_obj.yaml b/spec/schemas/ws/ws_workspace_contains_obj.yaml similarity index 90% rename from spec/schemas/wsfull/wsfull_ws_contains_obj.yaml rename to spec/schemas/ws/ws_workspace_contains_obj.yaml index ad55ad5e..45b41339 100644 --- a/spec/schemas/wsfull/wsfull_ws_contains_obj.yaml +++ b/spec/schemas/ws/ws_workspace_contains_obj.yaml @@ -1,4 +1,4 @@ -name: wsfull_ws_contains_obj +name: ws_workspace_contains_obj type: edge schema: "$schema": http://json-schema.org/draft-07/schema# diff --git a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_associated_ws_objects.yaml b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_associated_ws_objects.yaml index 413bacd6..0691b05a 100644 --- a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_associated_ws_objects.yaml +++ b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_associated_ws_objects.yaml @@ -21,24 +21,23 @@ params: description: Result offset for pagination maximum: 100000 -query_prefix: WITH ncbi_taxon, wsfull_object_version, wsfull_workspace +query_prefix: WITH ncbi_taxon, ws_object_version, ws_workspace query: | let count = COUNT( for tax in ncbi_taxon filter tax._id == @id - for obj in 1..1 inbound tax wsfull_obj_version_has_taxon + for obj in 1..1 inbound tax ws_obj_version_has_taxon return 1 ) let results = ( for tax in ncbi_taxon filter tax._id == @id - for obj, e in 1..1 inbound tax wsfull_obj_version_has_taxon - for ws in 1..1 inbound obj wsfull_ws_contains_obj - filter ws.is_public or ws._key IN ws_ids - limit @offset, @limit - return { - ws_obj: UNSET(obj, "_key", "_rev"), - edge: UNSET(e, "_key", "_from", "_to", "_rev") - } + for obj, e in 1..1 inbound tax ws_obj_version_has_taxon + filter obj.is_public or obj.workspace_id IN ws_ids + limit @offset, @limit + return { + ws_obj: UNSET(obj, "_key", "_rev"), + edge: UNSET(e, "_key", "_from", "_to", "_rev") + } ) return {results, total_count: count} diff --git a/spec/stored_queries/wsprov_count_linked_object_types.yaml b/spec/stored_queries/wsprov/wsprov_count_linked_object_types.yaml similarity index 100% rename from spec/stored_queries/wsprov_count_linked_object_types.yaml rename to spec/stored_queries/wsprov/wsprov_count_linked_object_types.yaml diff --git a/spec/stored_queries/wsprov_fetch_copies.yaml b/spec/stored_queries/wsprov/wsprov_fetch_copies.yaml similarity index 100% rename from spec/stored_queries/wsprov_fetch_copies.yaml rename to spec/stored_queries/wsprov/wsprov_fetch_copies.yaml diff --git a/spec/stored_queries/wsprov_fetch_linked_objects.yaml b/spec/stored_queries/wsprov/wsprov_fetch_linked_objects.yaml similarity index 100% rename from spec/stored_queries/wsprov_fetch_linked_objects.yaml rename to spec/stored_queries/wsprov/wsprov_fetch_linked_objects.yaml diff --git a/spec/stored_queries/wsprov_fetch_obj_field.yaml b/spec/stored_queries/wsprov/wsprov_fetch_obj_field.yaml similarity index 100% rename from spec/stored_queries/wsprov_fetch_obj_field.yaml rename to spec/stored_queries/wsprov/wsprov_fetch_obj_field.yaml diff --git a/spec/stored_queries/wsprov_fetch_object.yaml b/spec/stored_queries/wsprov/wsprov_fetch_object.yaml similarity index 100% rename from spec/stored_queries/wsprov_fetch_object.yaml rename to spec/stored_queries/wsprov/wsprov_fetch_object.yaml diff --git a/spec/stored_queries/wsprov_fetch_paths_between_objects.yaml b/spec/stored_queries/wsprov/wsprov_fetch_paths_between_objects.yaml similarity index 100% rename from spec/stored_queries/wsprov_fetch_paths_between_objects.yaml rename to spec/stored_queries/wsprov/wsprov_fetch_paths_between_objects.yaml diff --git a/spec/stored_queries/wsprov_fetch_references.yaml b/spec/stored_queries/wsprov/wsprov_fetch_references.yaml similarity index 100% rename from spec/stored_queries/wsprov_fetch_references.yaml rename to spec/stored_queries/wsprov/wsprov_fetch_references.yaml diff --git a/spec/stored_queries/wsprov_list_referencing_type_counts.yaml b/spec/stored_queries/wsprov/wsprov_list_referencing_type_counts.yaml similarity index 100% rename from spec/stored_queries/wsprov_list_referencing_type_counts.yaml rename to spec/stored_queries/wsprov/wsprov_list_referencing_type_counts.yaml diff --git a/spec/test/stored_queries/test_ncbi_tax.py b/spec/test/stored_queries/test_ncbi_tax.py index 3b7cad46..4496ff7c 100644 --- a/spec/test/stored_queries/test_ncbi_tax.py +++ b/spec/test/stored_queries/test_ncbi_tax.py @@ -11,8 +11,8 @@ _CONF = get_config() -def _construct_ws_obj(wsid, objid, ver): - """Test helper to create a wsfull_object_version vertex.""" +def _construct_ws_obj(wsid, objid, ver, is_public=False): + """Test helper to create a ws_object_version vertex.""" return { '_key': f"{wsid}:{objid}:{ver}", 'workspace_id': wsid, @@ -22,7 +22,8 @@ def _construct_ws_obj(wsid, objid, ver): 'hash': 'xyz', 'size': 100, 'epoch': 0, - 'deleted': False + 'deleted': False, + 'is_public': is_public, } @@ -49,27 +50,27 @@ def setUpClass(cls): {'_from': 'ncbi_taxon/7', '_to': 'ncbi_taxon/4', 'child_type': 't'}, ] obj_docs = [ - _construct_ws_obj(1, 1, 1), - _construct_ws_obj(1, 1, 2), - _construct_ws_obj(2, 1, 1), + _construct_ws_obj(1, 1, 1, is_public=True), + _construct_ws_obj(1, 1, 2, is_public=True), + _construct_ws_obj(2, 1, 1, is_public=False), ] obj_to_taxa_docs = [ - {'_from': 'wsfull_object_version/1:1:1', '_to': 'ncbi_taxon/1', 'assigned_by': 'assn1'}, - {'_from': 'wsfull_object_version/1:1:2', '_to': 'ncbi_taxon/1', 'assigned_by': 'assn2'}, - {'_from': 'wsfull_object_version/2:1:1', '_to': 'ncbi_taxon/1', 'assigned_by': 'assn2'}, + {'_from': 'ws_object_version/1:1:1', '_to': 'ncbi_taxon/1', 'assigned_by': 'assn1'}, + {'_from': 'ws_object_version/1:1:2', '_to': 'ncbi_taxon/1', 'assigned_by': 'assn2'}, + {'_from': 'ws_object_version/2:1:1', '_to': 'ncbi_taxon/1', 'assigned_by': 'assn2'}, ] ws_docs = [{'_key': '1', 'is_public': True}, {'_key': '2', 'is_public': False}] ws_to_obj = [ - {'_from': 'wsfull_workspace/1', '_to': 'wsfull_object_version/1:1:1'}, - {'_from': 'wsfull_workspace/1', '_to': 'wsfull_object_version/1:1:2'}, - {'_from': 'wsfull_workspace/2', '_to': 'wsfull_object_version/2:1:1'}, + {'_from': 'ws_workspace/1', '_to': 'ws_object_version/1:1:1'}, + {'_from': 'ws_workspace/1', '_to': 'ws_object_version/1:1:2'}, + {'_from': 'ws_workspace/2', '_to': 'ws_object_version/2:1:1'}, ] create_test_docs('ncbi_taxon', taxon_docs) create_test_docs('ncbi_child_of_taxon', child_docs) - create_test_docs('wsfull_object_version', obj_docs) - create_test_docs('wsfull_obj_version_has_taxon', obj_to_taxa_docs) - create_test_docs('wsfull_workspace', ws_docs) - create_test_docs('wsfull_ws_contains_obj', ws_to_obj) + create_test_docs('ws_object_version', obj_docs) + create_test_docs('ws_obj_version_has_taxon', obj_to_taxa_docs) + create_test_docs('ws_workspace', ws_docs) + create_test_docs('ws_workspace_contains_obj', ws_to_obj) def test_get_lineage_valid(self): """Test a valid query of taxon lineage.""" @@ -238,4 +239,4 @@ def test_get_associated_objs(self): assignments = {ret['edge']['assigned_by'] for ret in results['results']} ids = {ret['ws_obj']['_id'] for ret in results['results']} self.assertEqual(assignments, {'assn1', 'assn2'}) - self.assertEqual(ids, {'wsfull_object_version/1:1:1', 'wsfull_object_version/1:1:2'}) + self.assertEqual(ids, {'ws_object_version/1:1:1', 'ws_object_version/1:1:2'}) From 2b52b17d94f7267cbf9ee48c17c0f8ef7013e2d4 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Thu, 5 Sep 2019 15:02:03 -0700 Subject: [PATCH 358/732] Update delta-related schema fields, tests, and validation (#87) * Update delta schema fields - Update ncbi taxon schemas to have delta fields (from, to, id) - Update ncbi taxon tests to work with these fields - Update the schema validator to more specifically validate delta vs non-delta schemas * Fix typo --- spec/schemas/GO/GO_edges_consider.yaml | 3 ++- spec/schemas/GO/GO_edges_disjoint_from.yaml | 3 ++- spec/schemas/GO/GO_edges_intersection_of.yaml | 3 ++- spec/schemas/GO/GO_edges_isa.yaml | 3 ++- spec/schemas/GO/GO_edges_relationship.yaml | 3 ++- spec/schemas/GO/GO_edges_replaced_by.yaml | 3 ++- spec/schemas/GO/GO_term.yaml | 3 ++- spec/schemas/ncbi/ncbi_child_of_taxon.yaml | 8 ++++--- spec/schemas/ncbi/ncbi_taxon.yaml | 21 ++++------------ spec/test/stored_queries/test_ncbi_tax.py | 24 ++++++++++++++----- spec/test/validate.py | 16 ++++++++----- 11 files changed, 51 insertions(+), 39 deletions(-) diff --git a/spec/schemas/GO/GO_edges_consider.yaml b/spec/schemas/GO/GO_edges_consider.yaml index 77c40309..d8b6be42 100644 --- a/spec/schemas/GO/GO_edges_consider.yaml +++ b/spec/schemas/GO/GO_edges_consider.yaml @@ -1,6 +1,7 @@ ---- name: GO_edges_consider type: edge +delta: true + schema: "$schema": http://json-schema.org/draft-07/schema# title: GO_edges_consider diff --git a/spec/schemas/GO/GO_edges_disjoint_from.yaml b/spec/schemas/GO/GO_edges_disjoint_from.yaml index 93335b0b..515365b4 100644 --- a/spec/schemas/GO/GO_edges_disjoint_from.yaml +++ b/spec/schemas/GO/GO_edges_disjoint_from.yaml @@ -1,6 +1,7 @@ ---- name: GO_edges_disjoint_from type: edge +delta: true + schema: "$schema": http://json-schema.org/draft-07/schema# title: GO_edges_disjoint_from diff --git a/spec/schemas/GO/GO_edges_intersection_of.yaml b/spec/schemas/GO/GO_edges_intersection_of.yaml index 4f0672c9..a6143751 100644 --- a/spec/schemas/GO/GO_edges_intersection_of.yaml +++ b/spec/schemas/GO/GO_edges_intersection_of.yaml @@ -1,6 +1,7 @@ ---- name: GO_edges_intersection_of type: edge +delta: true + schema: "$schema": http://json-schema.org/draft-07/schema# title: GO_edges_intersection_of diff --git a/spec/schemas/GO/GO_edges_isa.yaml b/spec/schemas/GO/GO_edges_isa.yaml index bc6f05f3..18555ff1 100644 --- a/spec/schemas/GO/GO_edges_isa.yaml +++ b/spec/schemas/GO/GO_edges_isa.yaml @@ -1,6 +1,7 @@ ---- name: GO_edges_isa type: edge +delta: true + schema: "$schema": http://json-schema.org/draft-07/schema# title: GO_edges_isa diff --git a/spec/schemas/GO/GO_edges_relationship.yaml b/spec/schemas/GO/GO_edges_relationship.yaml index db015d8b..4de4886a 100644 --- a/spec/schemas/GO/GO_edges_relationship.yaml +++ b/spec/schemas/GO/GO_edges_relationship.yaml @@ -1,6 +1,7 @@ ---- name: GO_edges_relationship type: edge +delta: true + schema: "$schema": http://json-schema.org/draft-07/schema# title: GO_edges_relationship diff --git a/spec/schemas/GO/GO_edges_replaced_by.yaml b/spec/schemas/GO/GO_edges_replaced_by.yaml index 5ab731a5..eb55f51d 100644 --- a/spec/schemas/GO/GO_edges_replaced_by.yaml +++ b/spec/schemas/GO/GO_edges_replaced_by.yaml @@ -1,6 +1,7 @@ ---- name: GO_edges_replaced_by type: edge +delta: true + schema: "$schema": http://json-schema.org/draft-07/schema# title: GO_edges_replaced_by diff --git a/spec/schemas/GO/GO_term.yaml b/spec/schemas/GO/GO_term.yaml index 1273e46c..4e6c199c 100644 --- a/spec/schemas/GO/GO_term.yaml +++ b/spec/schemas/GO/GO_term.yaml @@ -1,6 +1,7 @@ ---- name: GO_terms type: vertex +delta: true + schema: "$schema": http://json-schema.org/draft-07/schema# title: GO_terms diff --git a/spec/schemas/ncbi/ncbi_child_of_taxon.yaml b/spec/schemas/ncbi/ncbi_child_of_taxon.yaml index 44b0cdf3..d38e6e84 100644 --- a/spec/schemas/ncbi/ncbi_child_of_taxon.yaml +++ b/spec/schemas/ncbi/ncbi_child_of_taxon.yaml @@ -1,15 +1,17 @@ name: ncbi_child_of_taxon type: edge +delta: true + schema: "$schema": http://json-schema.org/draft-07/schema# type: object - required: [_from, _to, child_type] + required: [from, to, child_type] description: Edges which create the taxonomy tree for NCBI taxons. properties: - _from: + from: type: string description: The child. A gtdb_taxon or gtdb_organism. - _to: + to: type: string description: The parent gtdb_taxon child_type: diff --git a/spec/schemas/ncbi/ncbi_taxon.yaml b/spec/schemas/ncbi/ncbi_taxon.yaml index 3462ab2e..7d29e5db 100644 --- a/spec/schemas/ncbi/ncbi_taxon.yaml +++ b/spec/schemas/ncbi/ncbi_taxon.yaml @@ -1,5 +1,6 @@ name: ncbi_taxon type: vertex +delta: true indexes: - type: fulltext @@ -9,9 +10,9 @@ schema: "$schema": http://json-schema.org/draft-07/schema# type: object description: Template for a vertex entry in the NCBI taxonomy tree. - required: [_key, scientific_name, rank] + required: [id, scientific_name, rank] properties: - _key: + id: type: string description: NCBI Taxon id (positive integer) examples: ['1', '2053699'] @@ -19,42 +20,28 @@ schema: type: string title: Taxon name. examples: ['Methylophilus methylotrophus', 'Bacteria', 'Firmicutes'] - canonical_scientific_name: - type: array - title: Canonicalized scientific name - examples: [['methylophilus', 'methylotrophus'], ['Bacteria'], ['Firmicutes']] - items: {type: string} aliases: type: array description: Aliases examples: - - category: authority name: Borreliella burgdorferi (Johnson et al. 1984) Adeolu and Gupta 2015 - canonical: ['borreliella', 'burgdorferi', 'johnson', 'adeolu', 'gupta'] - category: genbank common name name: Lyme disease spirochet - canonical: ['lyme', 'disease', 'spirochet'] - category: synonym name: Borrelia burgdorferi - canonical: ['borrelia', 'burgdorferi'] - - category: common name name: E. coli - canonical: ['e', 'coli'] - category: authority name: '"Bacterium coli commune" Escherich 1885' - canonical: ['bacterium', 'coli', 'commune', 'escherich'] - category: synonym name: Bacterium coli - canonical: ['bacterium', 'coli'] items: type: object - required: ['category', 'name', 'canonical'] + required: ['category', 'name'] properties: category: {type: string} name: {type: string} - canonical: - type: array - items: {type: string} rank: type: string title: Taxonomic rank diff --git a/spec/test/stored_queries/test_ncbi_tax.py b/spec/test/stored_queries/test_ncbi_tax.py index 4496ff7c..9a049276 100644 --- a/spec/test/stored_queries/test_ncbi_tax.py +++ b/spec/test/stored_queries/test_ncbi_tax.py @@ -27,6 +27,18 @@ def _construct_ws_obj(wsid, objid, ver, is_public=False): } +def _create_delta_test_docs(coll_name, docs, edge=False): + """Add in delta required fields.""" + if edge: + for doc in docs: + doc['from'] = doc['_from'] + doc['to'] = doc['_to'] + else: + for doc in docs: + doc['id'] = doc['_key'] + create_test_docs(coll_name, docs) + + class TestNcbiTax(unittest.TestCase): @classmethod @@ -65,12 +77,12 @@ def setUpClass(cls): {'_from': 'ws_workspace/1', '_to': 'ws_object_version/1:1:2'}, {'_from': 'ws_workspace/2', '_to': 'ws_object_version/2:1:1'}, ] - create_test_docs('ncbi_taxon', taxon_docs) - create_test_docs('ncbi_child_of_taxon', child_docs) - create_test_docs('ws_object_version', obj_docs) - create_test_docs('ws_obj_version_has_taxon', obj_to_taxa_docs) - create_test_docs('ws_workspace', ws_docs) - create_test_docs('ws_workspace_contains_obj', ws_to_obj) + _create_delta_test_docs('ncbi_taxon', taxon_docs) + _create_delta_test_docs('ncbi_child_of_taxon', child_docs, edge=True) + _create_delta_test_docs('ws_object_version', obj_docs) + _create_delta_test_docs('ws_obj_version_has_taxon', obj_to_taxa_docs, edge=True) + _create_delta_test_docs('ws_workspace', ws_docs) + _create_delta_test_docs('ws_workspace_contains_obj', ws_to_obj, edge=True) def test_get_lineage_valid(self): """Test a valid query of taxon lineage.""" diff --git a/spec/test/validate.py b/spec/test/validate.py index fc30a811..1fb9de47 100644 --- a/spec/test/validate.py +++ b/spec/test/validate.py @@ -65,12 +65,16 @@ def validate_json_schemas(): _fatal('Schemas must be an object. Schema in %s is not an object.' % path) required = data['schema'].get('required', []) # Edges must require _from and _to while vertices must require _key - has_from_underscore = ('_from' in required and '_to' in required) - has_from = ('from' in required and 'to' in required) - if data['type'] == 'edge' and not has_from_underscore and not has_from: - _fatal('Edge schemas must require _from and _to attributes in ' + path) - elif data['type'] == 'vertex' and '_key' not in required and 'id' not in required: - _fatal('Vertex schemas must require the _key attribute in ' + path) + has_edge_fields = ('_from' in required and '_to' in required) + has_delta_edge_fields = ('from' in required and 'to' in required) + if data['type'] == 'edge' and data.get('delta') and not has_delta_edge_fields: + _fatal('Time-travel edge schemas must require "from" and "to" attributes in ' + path) + elif data['type'] == 'edge' and not data.get('delta') and not has_edge_fields: + _fatal('Edge schemas must require "_from" and "_to" attributes in ' + path) + elif data['type'] == 'vertex' and data.get('delta') and 'id' not in required: + _fatal('Time-travel vertex schemas must require the "id" attribute in ' + path) + elif data['type'] == 'vertex' and not data.get('delta') and '_key' not in required: + _fatal('Vertex schemas must require the "_key" attribute in ' + path) print(f'✓ {name} is valid.') print('..all valid.') From 5e1a107ada0c3a728b4ed4a8fc5b99df1bfe40b3 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Mon, 9 Sep 2019 13:16:29 -0700 Subject: [PATCH 359/732] Change database healthcheck to require db-only admin perms --- api/src/relation_engine_server/utils/arango_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/src/relation_engine_server/utils/arango_client.py b/api/src/relation_engine_server/utils/arango_client.py index d01ab0c0..b843f950 100644 --- a/api/src/relation_engine_server/utils/arango_client.py +++ b/api/src/relation_engine_server/utils/arango_client.py @@ -15,7 +15,7 @@ def server_status(): """Get the status of our connection and authorization to the ArangoDB server.""" try: - resp = requests.get(_CONF['db_url'] + '/_api/endpoint', auth=(_CONF['db_user'], _CONF['db_pass'])) + resp = requests.get(_CONF['db_url'] + '/_api/database/current', auth=(_CONF['db_user'], _CONF['db_pass'])) except requests.exceptions.ConnectionError: return 'no_connection' if resp.ok: From 2372b4ec049d4db8760b6cbf3fd8f7faa94c52db Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Mon, 9 Sep 2019 13:33:27 -0700 Subject: [PATCH 360/732] Fix wait_for_services arangodb health request --- api/src/relation_engine_server/wait_for_services.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/src/relation_engine_server/wait_for_services.py b/api/src/relation_engine_server/wait_for_services.py index cb6112e8..f1c70a23 100644 --- a/api/src/relation_engine_server/wait_for_services.py +++ b/api/src/relation_engine_server/wait_for_services.py @@ -16,7 +16,7 @@ def main(): requests.get(_CONFIG['workspace_url']) requests.get(_CONFIG['auth_url']) auth = (_CONFIG['db_user'], _CONFIG['db_pass']) - requests.get(_CONFIG['db_url'] + '/_admin/cluster/health', auth=auth).raise_for_status() + requests.get(_CONFIG['db_url'] + '/_api/database/current', auth=auth).raise_for_status() break except Exception: print('Waiting for services..') From 3ca6c3b29e0bb2e7c75766170ac44c86ce69eba5 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Mon, 9 Sep 2019 13:55:08 -0700 Subject: [PATCH 361/732] Try another endpoint for the RE status test with less perms --- api/src/relation_engine_server/utils/arango_client.py | 4 +++- api/src/relation_engine_server/wait_for_services.py | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/api/src/relation_engine_server/utils/arango_client.py b/api/src/relation_engine_server/utils/arango_client.py index b843f950..d2d37c38 100644 --- a/api/src/relation_engine_server/utils/arango_client.py +++ b/api/src/relation_engine_server/utils/arango_client.py @@ -14,8 +14,10 @@ def server_status(): """Get the status of our connection and authorization to the ArangoDB server.""" + auth = (_CONF['db_user'], _CONF['db_pass']) + adb_url = f"{_CONF['api_url']}/version" try: - resp = requests.get(_CONF['db_url'] + '/_api/database/current', auth=(_CONF['db_user'], _CONF['db_pass'])) + resp = requests.get(adb_url, auth=auth) except requests.exceptions.ConnectionError: return 'no_connection' if resp.ok: diff --git a/api/src/relation_engine_server/wait_for_services.py b/api/src/relation_engine_server/wait_for_services.py index f1c70a23..51a9a546 100644 --- a/api/src/relation_engine_server/wait_for_services.py +++ b/api/src/relation_engine_server/wait_for_services.py @@ -11,12 +11,13 @@ def main(): timeout = int(time.time()) + 60 + adb_url = f"{_CONFIG['api_url']}/version" while True: try: requests.get(_CONFIG['workspace_url']) requests.get(_CONFIG['auth_url']) auth = (_CONFIG['db_user'], _CONFIG['db_pass']) - requests.get(_CONFIG['db_url'] + '/_api/database/current', auth=auth).raise_for_status() + requests.get(adb_url, auth=auth).raise_for_status() break except Exception: print('Waiting for services..') From eb46d8ad45483493b0c2f9563e45795d5ecfb2c9 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 10 Sep 2019 16:36:48 -0700 Subject: [PATCH 362/732] Add a query global for "maxint" --- .../relation_engine_server/api_versions/api_v1.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/api/src/relation_engine_server/api_versions/api_v1.py b/api/src/relation_engine_server/api_versions/api_v1.py index efef8588..480318fd 100644 --- a/api/src/relation_engine_server/api_versions/api_v1.py +++ b/api/src/relation_engine_server/api_versions/api_v1.py @@ -57,7 +57,7 @@ def run_query(): # Run an adhoc query for a sysadmin auth.require_auth_token(roles=['RE_ADMIN']) query_text = json_body['query'] - query_text = json_body.get('query_prefix', '') + ' LET ws_ids = @ws_ids ' + query_text + query_text = _preprocess_stored_query(json_body['query'], json_body) del json_body['query'] json_body['ws_ids'] = ws_ids resp_body = arango_client.run_query(query_text=query_text, @@ -71,7 +71,7 @@ def run_query(): # "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 = stored_query.get('query_prefix', '') + ' LET ws_ids = @ws_ids ' + stored_query['query'] + stored_query_source = _preprocess_stored_query(stored_query['query'], stored_query) if 'params' in stored_query: # Validate the user params for the query json_validation.Validator(stored_query['params']).validate(json_body) @@ -135,3 +135,13 @@ def show_config(): 'db_name': conf['db_name'], 'spec_url': conf['spec_url'] }) + + +def _preprocess_stored_query(query_text, config): + """Inject some default code into each stored query.""" + return ( + config.get('query_prefix', '') + + " LET ws_ids = @ws_ids " + + " LET maxint = 9007199254740991 " + + query_text + ) From 735a740518f703b2e47bc8bb681908bb9619d410 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 11 Sep 2019 13:58:55 -0700 Subject: [PATCH 363/732] Comment out maxint for now --- api/src/relation_engine_server/api_versions/api_v1.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/src/relation_engine_server/api_versions/api_v1.py b/api/src/relation_engine_server/api_versions/api_v1.py index 480318fd..0b99b477 100644 --- a/api/src/relation_engine_server/api_versions/api_v1.py +++ b/api/src/relation_engine_server/api_versions/api_v1.py @@ -142,6 +142,6 @@ def _preprocess_stored_query(query_text, config): return ( config.get('query_prefix', '') + " LET ws_ids = @ws_ids " + - " LET maxint = 9007199254740991 " + + # " LET maxint = 9007199254740991 " + query_text ) From 88f38f0aaff3143c12748506ea4ea2930a7fbd1f Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Thu, 12 Sep 2019 12:12:30 -0700 Subject: [PATCH 364/732] Update NCBI queries to be compatible with time-travel stuff (#88) * Update NCBI queries to be compatible with time-travel stuff * Fix expired filters * Update to use different timestamp query strategy * Add `ts` as a required param on each stored query --- .../ncbi_tax/ncbi_fetch_taxon.yaml | 14 +++--- .../ncbi_taxon_get_associated_ws_objects.yaml | 20 ++++++--- .../ncbi_tax/ncbi_taxon_get_children.yaml | 33 +++++++------- .../ncbi_taxon_get_children_cursor.yaml | 25 +++++------ .../ncbi_tax/ncbi_taxon_get_lineage.yaml | 19 +++++--- .../ncbi_tax/ncbi_taxon_get_siblings.yaml | 44 +++++++++---------- .../ncbi_tax/ncbi_taxon_search_sci_name.yaml | 7 ++- spec/test/stored_queries/test_ncbi_tax.py | 36 ++++++++------- 8 files changed, 113 insertions(+), 85 deletions(-) diff --git a/spec/stored_queries/ncbi_tax/ncbi_fetch_taxon.yaml b/spec/stored_queries/ncbi_tax/ncbi_fetch_taxon.yaml index 6e85196e..3a9c4170 100644 --- a/spec/stored_queries/ncbi_tax/ncbi_fetch_taxon.yaml +++ b/spec/stored_queries/ncbi_tax/ncbi_fetch_taxon.yaml @@ -2,13 +2,17 @@ name: ncbi_fetch_taxon params: type: object - required: [key] + required: [id, ts] properties: - key: + id: type: string - title: Document key - description: Taxonomy ID (document _key) for the taxon to fetch + title: NCBI Taxonomy ID + ts: + type: integer + title: Versioning timestamp query: | for t in ncbi_taxon - filter t._key == @key + filter t.id == @id + filter t.created <= @ts AND t.expired >= @ts + limit 1 return t diff --git a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_associated_ws_objects.yaml b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_associated_ws_objects.yaml index 0691b05a..19136bbe 100644 --- a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_associated_ws_objects.yaml +++ b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_associated_ws_objects.yaml @@ -4,11 +4,11 @@ name: ncbi_taxon_get_associated_ws_objects params: type: object - required: [id] + required: [taxon_id, ts] properties: - id: + taxon_id: type: string - title: Taxon ID + title: NCBI Taxon ID description: ID of the taxon vertex to find associated taxa limit: type: integer @@ -20,18 +20,24 @@ params: default: 0 description: Result offset for pagination maximum: 100000 - -query_prefix: WITH ncbi_taxon, ws_object_version, ws_workspace + ts: + type: integer + title: Versioning timestamp +query_prefix: WITH ws_object_version query: | let count = COUNT( for tax in ncbi_taxon - filter tax._id == @id + filter tax.id == @taxon_id + filter tax.created <= @ts AND tax.expired >= @ts + limit 1 for obj in 1..1 inbound tax ws_obj_version_has_taxon return 1 ) let results = ( for tax in ncbi_taxon - filter tax._id == @id + filter tax.id == @taxon_id + filter tax.created <= @ts AND tax.expired >= @ts + limit 1 for obj, e in 1..1 inbound tax ws_obj_version_has_taxon filter obj.is_public or obj.workspace_id IN ws_ids limit @offset, @limit diff --git a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_children.yaml b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_children.yaml index 9fcf3318..d3cc30c3 100644 --- a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_children.yaml +++ b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_children.yaml @@ -2,12 +2,12 @@ name: ncbi_taxon_get_children params: type: object - required: [key] + required: [id, ts] properties: - key: + id: type: string - title: Document key - description: Key of the taxon vertex for which you want to find descendants + title: Document ID + description: ID of the taxon vertex for which you want to find descendants limit: type: integer default: 20 @@ -22,26 +22,27 @@ params: type: string description: Search scientific name default: '' + ts: + type: integer + title: Versioning timestamp query: | - let tax_id = CONCAT("ncbi_taxon/", @key) // Fetch the child IDs using the edge attributes - let child_ids = ( - for e in ncbi_child_of_taxon - filter e._to == tax_id - return e._from + let children = ( + for parent in ncbi_taxon + filter parent.id == @id + filter parent.created <= @ts AND parent.expired >= @ts + limit 1 + for tax in 1..1 inbound parent ncbi_child_of_taxon + return tax ) // Sort and filter the children + // Should only get evaluated if search_text is truthy let searched = ( for tax in FULLTEXT(ncbi_taxon, "scientific_name", @search_text) - filter tax._id in child_ids - return tax - ) - let not_searched = ( - for tax in ncbi_taxon - filter tax._id in child_ids + filter tax in children return tax ) - let filtered = @search_text ? searched : not_searched + let filtered = @search_text ? searched : children let results = ( for tax in filtered sort tax.scientific_name asc diff --git a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_children_cursor.yaml b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_children_cursor.yaml index 1ae8bee7..057f0c15 100644 --- a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_children_cursor.yaml +++ b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_children_cursor.yaml @@ -2,20 +2,19 @@ name: ncbi_taxon_get_children_cursor params: type: object - required: [key] + required: [id, ts] properties: - key: + id: type: string - title: Document key - description: Key of the taxon vertex for which you want to find descendants + title: Document ID + description: ID of the taxon vertex for which you want to find descendants + ts: + type: integer + title: Versioning timestamp query: | - let tax_id = CONCAT("ncbi_taxon/", @key) - // Fetch the child IDs using the edge attributes - let child_ids = ( - for e in ncbi_child_of_taxon - filter e._to == tax_id - return e._from - ) for tax in ncbi_taxon - filter tax._id in child_ids - return tax + filter tax.id == @id + filter tax.created <= @ts AND tax.expired >= @ts + limit 1 + for child in 1..1 inbound tax ncbi_child_of_taxon + return tax diff --git a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_lineage.yaml b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_lineage.yaml index 2323209d..b2885751 100644 --- a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_lineage.yaml +++ b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_lineage.yaml @@ -3,17 +3,24 @@ name: ncbi_taxon_get_lineage params: type: object - required: [key] + required: [id, ts] properties: - key: + id: type: string - title: Document key - description: Key of the taxon vertex for which you want to find ancestors + title: Document id + description: ID of the taxon vertex for which you want to find ancestors + ts: + type: integer + title: Versioning timestamp query: | let ps = ( for t in ncbi_taxon - filter t._key == @key - for p in 1..10 outbound t ncbi_child_of_taxon + filter t.id == @id + filter t.created <= @ts AND t.expired >= @ts + limit 1 + for p, e in 1..10 outbound t ncbi_child_of_taxon + options {bfs: true} + filter p.created <= @ts AND p.expired >= @ts return distinct p ) // doing return reverse(ps) returns an array of an array for some reason, diff --git a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_siblings.yaml b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_siblings.yaml index aa6cab51..72533b2a 100644 --- a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_siblings.yaml +++ b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_siblings.yaml @@ -3,12 +3,12 @@ name: ncbi_taxon_get_siblings params: type: object - required: [key] + required: [id, ts] properties: - key: + id: type: string - title: Document key - description: Key of the taxon vertex for which you want to find siblings + title: Document id + description: ID of the taxon vertex for which you want to find siblings limit: type: integer default: 20 @@ -19,28 +19,28 @@ params: default: 0 description: Result offset for pagination maximum: 100000 + ts: + type: integer + title: Versioning timestamp query: | - let tax_id = CONCAT('ncbi_taxon/', @key) - // First fetch the ID of the parent document - let parent_id = first( + // Fetch the siblings + let siblings = ( for t in ncbi_taxon - filter t._key == @key + filter t.id == @id + filter t.created <= @ts AND t.expired >= @ts + limit 1 for parent in 1..1 outbound t ncbi_child_of_taxon - limit 1 - return parent._id - ) - // Then find the child IDs through the edge fields - let child_ids = ( - for e in ncbi_child_of_taxon - filter e._to == parent_id AND e._from != tax_id - return e._from + filter parent.created <= @ts AND parent.expired >= @ts + for child in 1..1 inbound parent ncbi_child_of_taxon + filter child != t + filter child.created <= @ts AND child.expired >= @ts + sort child.scientific_name asc + return child ) - // Sort and filter the children - let sorted = ( - for tax in ncbi_taxon - filter tax._id in child_ids - sort tax.scientific_name asc + // Apply limits to the results + let limited = ( + for tax in siblings limit @offset, @limit return tax ) - return {total_count: COUNT(child_ids), results: sorted} + return {total_count: COUNT(siblings), results: limited} diff --git a/spec/stored_queries/ncbi_tax/ncbi_taxon_search_sci_name.yaml b/spec/stored_queries/ncbi_tax/ncbi_taxon_search_sci_name.yaml index 0c029468..2a047917 100644 --- a/spec/stored_queries/ncbi_tax/ncbi_taxon_search_sci_name.yaml +++ b/spec/stored_queries/ncbi_tax/ncbi_taxon_search_sci_name.yaml @@ -3,7 +3,7 @@ name: ncbi_taxon_search_sci_name params: type: object - required: [search_text] + required: [search_text, ts] properties: search_text: type: string @@ -17,11 +17,16 @@ params: type: integer default: 20 maximum: 1000 + ts: + type: integer + title: Versioning timestamp query: | // Search using the fulltext index on scientific_name // Don't limit the results yet so we can get the total_count below let results = ( FOR doc in FULLTEXT(ncbi_taxon, "scientific_name", @search_text) + // Filter non-expired docs + filter doc.created <= @ts AND doc.expired >= @ts return doc ) // Limit the results diff --git a/spec/test/stored_queries/test_ncbi_tax.py b/spec/test/stored_queries/test_ncbi_tax.py index 9a049276..de759356 100644 --- a/spec/test/stored_queries/test_ncbi_tax.py +++ b/spec/test/stored_queries/test_ncbi_tax.py @@ -2,6 +2,7 @@ Tests for the ncbi taxonomy stored queries. """ import json +import time import unittest import requests @@ -9,6 +10,7 @@ from test.stored_queries.helpers import create_test_docs _CONF = get_config() +_NOW = int(time.time() * 1000) def _construct_ws_obj(wsid, objid, ver, is_public=False): @@ -36,6 +38,9 @@ def _create_delta_test_docs(coll_name, docs, edge=False): else: for doc in docs: doc['id'] = doc['_key'] + for doc in docs: + doc['expired'] = 9007199254740991 + doc['created'] = 0 create_test_docs(coll_name, docs) @@ -71,6 +76,7 @@ def setUpClass(cls): {'_from': 'ws_object_version/1:1:2', '_to': 'ncbi_taxon/1', 'assigned_by': 'assn2'}, {'_from': 'ws_object_version/2:1:1', '_to': 'ncbi_taxon/1', 'assigned_by': 'assn2'}, ] + # Create workspace objects associated to taxa ws_docs = [{'_key': '1', 'is_public': True}, {'_key': '2', 'is_public': False}] ws_to_obj = [ {'_from': 'ws_workspace/1', '_to': 'ws_object_version/1:1:1'}, @@ -89,7 +95,7 @@ def test_get_lineage_valid(self): resp = requests.post( _CONF['re_api_url'] + '/api/v1/query_results', params={'stored_query': 'ncbi_taxon_get_lineage'}, - data=json.dumps({'key': '7'}), + data=json.dumps({'ts': _NOW, 'id': '7'}), ).json() self.assertEqual(resp['count'], 2) ranks = [r['rank'] for r in resp['results']] @@ -102,7 +108,7 @@ def test_get_children(self): resp = requests.post( _CONF['re_api_url'] + '/api/v1/query_results', params={'stored_query': 'ncbi_taxon_get_children'}, - data=json.dumps({'key': '1', 'search_text': 'firmicutes,|proteobacteria'}), + data=json.dumps({'id': '1', 'ts': _NOW, 'search_text': 'firmicutes,|proteobacteria'}), ).json() result = resp['results'][0] self.assertEqual(result['total_count'], 2) @@ -116,7 +122,7 @@ def test_get_children_cursor(self): resp = requests.post( _CONF['re_api_url'] + '/api/v1/query_results', params={'stored_query': 'ncbi_taxon_get_children_cursor'}, - data=json.dumps({'key': '1'}) + data=json.dumps({'ts': _NOW, 'id': '1'}) ).json() self.assertEqual(len(resp['results']), 2) @@ -125,7 +131,7 @@ def test_siblings_valid(self): resp = requests.post( _CONF['re_api_url'] + '/api/v1/query_results', params={'stored_query': 'ncbi_taxon_get_siblings'}, - data=json.dumps({'key': '5'}), # Querying from "Alphaproteobacteria" + data=json.dumps({'ts': _NOW, 'id': '5'}), # Querying from "Alphaproteobacteria" ).json() result = resp['results'][0] self.assertEqual(result['total_count'], 2) @@ -139,7 +145,7 @@ def test_siblings_root(self): resp = requests.post( _CONF['re_api_url'] + '/api/v1/query_results', params={'stored_query': 'ncbi_taxon_get_siblings'}, - data=json.dumps({'key': '1'}), # Querying from "Bacteria" + data=json.dumps({'ts': _NOW, 'id': '1'}), # Querying from "Bacteria" ).json() self.assertEqual(resp['results'][0]['total_count'], 0) @@ -148,7 +154,7 @@ def test_siblings_nonexistent_node(self): resp = requests.post( _CONF['re_api_url'] + '/api/v1/query_results', params={'stored_query': 'ncbi_taxon_get_siblings'}, - data=json.dumps({'key': 'xyz'}), # Nonexistent node + data=json.dumps({'ts': _NOW, 'id': 'xyz'}), # Nonexistent node ).json() self.assertEqual(resp['results'][0]['total_count'], 0) @@ -157,7 +163,7 @@ def test_search_sciname_prefix(self): resp = requests.post( _CONF['re_api_url'] + '/api/v1/query_results', params={'stored_query': 'ncbi_taxon_search_sci_name'}, - data=json.dumps({'search_text': 'prefix:bact'}), + data=json.dumps({'ts': _NOW, 'search_text': 'prefix:bact'}), ).json() result = resp['results'][0] self.assertEqual(result['total_count'], 1) @@ -168,7 +174,7 @@ def test_search_sciname_nonexistent(self): resp = requests.post( _CONF['re_api_url'] + '/api/v1/query_results', params={'stored_query': 'ncbi_taxon_search_sci_name'}, - data=json.dumps({'search_text': 'xyzabc'}), + data=json.dumps({'ts': _NOW, 'search_text': 'xyzabc'}), ).json() self.assertEqual(resp['results'][0]['total_count'], 0) @@ -177,7 +183,7 @@ def test_search_sciname_wrong_type(self): resp = requests.post( _CONF['re_api_url'] + '/api/v1/query_results', params={'stored_query': 'ncbi_taxon_search_sci_name'}, - data=json.dumps({'search_text': 123}) + data=json.dumps({'ts': _NOW, 'search_text': 123}) ) self.assertEqual(resp.status_code, 400) self.assertEqual(resp.json()['error'], "123 is not of type 'string'") @@ -187,7 +193,7 @@ def test_search_sciname_missing_search(self): resp = requests.post( _CONF['re_api_url'] + '/api/v1/query_results', params={'stored_query': 'ncbi_taxon_search_sci_name'}, - data=json.dumps({}) + data=json.dumps({'ts': _NOW}) ) self.assertEqual(resp.status_code, 400) self.assertEqual(resp.json()['error'], "'search_text' is a required property") @@ -197,7 +203,7 @@ def test_search_sciname_more_complicated(self): resp = requests.post( _CONF['re_api_url'] + '/api/v1/query_results', params={'stored_query': 'ncbi_taxon_search_sci_name'}, - data=json.dumps({'search_text': "prefix:gamma,|prefix:alpha,|prefix:delta"}) + data=json.dumps({'ts': _NOW, 'search_text': "prefix:gamma,|prefix:alpha,|prefix:delta"}) ).json() result = resp['results'][0] self.assertEqual(result['total_count'], 3) @@ -209,7 +215,7 @@ def test_search_sciname_offset_max(self): resp = requests.post( _CONF['re_api_url'] + '/api/v1/query_results', params={'stored_query': 'ncbi_taxon_search_sci_name'}, - data=json.dumps({'search_text': "prefix:bact", "offset": 100001}) + data=json.dumps({'ts': _NOW, 'search_text': "prefix:bact", "offset": 100001}) ) self.assertEqual(resp.status_code, 400) self.assertEqual(resp.json()['error'], "100001 is greater than the maximum of 100000") @@ -219,7 +225,7 @@ def test_search_sciname_limit_max(self): resp = requests.post( _CONF['re_api_url'] + '/api/v1/query_results', params={'stored_query': 'ncbi_taxon_search_sci_name'}, - data=json.dumps({'search_text': "prefix:bact", "limit": 1001}) + data=json.dumps({'ts': _NOW, 'search_text': "prefix:bact", "limit": 1001}) ) self.assertEqual(resp.status_code, 400) self.assertEqual(resp.json()['error'], "1001 is greater than the maximum of 1000") @@ -229,7 +235,7 @@ def test_fetch_taxon(self): resp = requests.post( _CONF['re_api_url'] + '/api/v1/query_results', params={'stored_query': 'ncbi_fetch_taxon'}, - data=json.dumps({'key': '1'}) + data=json.dumps({'ts': _NOW, 'id': '1'}) ).json() self.assertEqual(resp['count'], 1) self.assertEqual(resp['results'][0]['_id'], 'ncbi_taxon/1') @@ -242,7 +248,7 @@ def test_get_associated_objs(self): resp = requests.post( _CONF['re_api_url'] + '/api/v1/query_results', params={'stored_query': 'ncbi_taxon_get_associated_ws_objects'}, - data=json.dumps({'id': 'ncbi_taxon/1'}), + data=json.dumps({'ts': _NOW, 'taxon_id': '1'}), ).json() self.assertEqual(resp['count'], 1) results = resp['results'][0] From f24c30c7861fc0a5d0253a17a32b092c45895545 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Thu, 12 Sep 2019 12:33:50 -0700 Subject: [PATCH 365/732] Cache the latest spec release for tests --- api/src/test/spec_release/spec.tar.gz | Bin 15057 -> 17295 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/api/src/test/spec_release/spec.tar.gz b/api/src/test/spec_release/spec.tar.gz index 916862e3f347ca2ab8971ba44c4b3b6e48d7d497..bac0d852fd145070bd12ddd112fccfdb807f9dbe 100644 GIT binary patch literal 17295 zcmYhCWl$Vl(}r<(clY4#i%SR)AOr#g2`)i{%i``32m}cp+=9#EuE8Z)+}&Ye=gaf{ z`lf2CrlzX9&yPNR`nr3DJ`Mxne;4wJ%!|ibbLz_q75pNFvA+({!ShXzkof@{;PV)xX2dvn#*o5Om7+d_S`hO}#J2`c>5{u^{7M(Jb>s3?z$t%>~X zPOmMZC307d^QR&qG!Xh!8OiUTX>)S{t?Z-gr99h@W8+6Jwexbwo#9!p42efO+2ToI zX3+EIYna)2$eW+{z+9&B9wq}g|KyiAe7!|?g4ZvURJp?GaRTiUP zMImorJO{QnA}yRF8T_=z@0U?UbDt)(!@sok@`yRKlF_y<(cb?3YLWb2S%A#dXpI6qC?h8BWK z6z->0hR}`e`6hxe3Zrbotue30#?Za!;%DtynlPz4Wth?%wSJbhS+#*1id)LZ?Kmg_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8n_$mIm{eL}v(;d!g-;X}XfX;}*%#cqqtgd5RTi zKghstz4YAr8HPyi^hU)kE_D*4;y?Uc{F?mkb)q+JQEKWm6Ah5`Xz)#ehP{mv-XjhW zqtG94p>X`X34Vi(p9`SxTN8zV5pJ~$q>%;2@5QRa;>A9dtaR{-BNg7*q_}z;+eFFl zIK@Nqk<>k}^R;VRuJv7S)UT#4{he?V(LDdBTQwpS<*`U~GP{g)GqxfEMj8!10$S>H zGkMAak(u`a_TC#|3Ag4~F^OD!+s5?YYzeaYhKeT&T$wv-YKtQ(ON@1Mr(=Z|+kBGW zL&}D|KV&Q6Umz|b8&+2=uGl}IpjY!fq|dGW2#v!da4Qm1oZ4ercKU;ZPG;O1D$_s_ zcF&((aQcTs{wxR&_3OStJmm}4MT4y#nuuKP2TGC03v*xn`Q@vlxw|7Fs`%ZP8#>L$ zrW3jVtt-nP*wtYZK@yMiS*WdoBua&mq5^v LMmG!>9L)a#jXF1M From 890193f5d0a6efe7cd63a5893aebcf7f8c795ba3 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Thu, 12 Sep 2019 13:49:03 -0700 Subject: [PATCH 366/732] Update to work with arangodb 3.5 --- api/docker-compose.yaml | 5 +- .../utils/arango_client.py | 81 +++++++++---------- .../relation_engine_server/utils/config.py | 4 +- api/src/test/test_api_v1.py | 12 --- 4 files changed, 44 insertions(+), 58 deletions(-) diff --git a/api/docker-compose.yaml b/api/docker-compose.yaml index 82803817..50bd90b2 100644 --- a/api/docker-compose.yaml +++ b/api/docker-compose.yaml @@ -44,8 +44,7 @@ services: # Arangodb server in cluster mode arangodb: - image: arangodb:3.4 + image: arangodb:3.5 ports: - "127.0.0.1:8529:8529" - command: sh -c "arangodb create jwt-secret --secret=jwtSecret && - arangodb --starter.local --auth.jwt-secret=./jwtSecret" + command: sh -c "arangodb --starter.local" diff --git a/api/src/relation_engine_server/utils/arango_client.py b/api/src/relation_engine_server/utils/arango_client.py index d2d37c38..15deb6c8 100644 --- a/api/src/relation_engine_server/utils/arango_client.py +++ b/api/src/relation_engine_server/utils/arango_client.py @@ -47,7 +47,7 @@ def run_query(query_text=None, cursor_id=None, bind_vars=None, batch_size=10000, if bind_vars: req_json['bindVars'] = bind_vars # Initialize the readonly user - _init_readonly_user() + # _init_readonly_user() # Run the query as the readonly user resp = requests.request( method, @@ -138,46 +138,45 @@ def import_from_file(file_path, query): return resp.text -def _init_readonly_user(): - """ - Using the admin user, initialize an admin readonly user for use with ad-hoc queries. - - If the user cannot be created, we raise an ArangoServerError - If the user already exists, or is successfully created, we return None and do not raise. - """ - user = _CONF['db_readonly_user'] - # Check if the user exists, in which case this is a no-op - resp = requests.get( - _CONF['api_url'] + '/user/' + user, - auth=(_CONF['db_user'], _CONF['db_pass']) - ) - if resp.status_code == 200: - return - # Create the user - resp = requests.post( - _CONF['api_url'] + '/user', - data=json.dumps({'user': user, 'passwd': _CONF['db_readonly_user']}), - auth=(_CONF['db_user'], _CONF['db_pass']) - ) - if resp.status_code != 201: - raise ArangoServerError(resp.text) - db_grant_path = _CONF['api_url'] + '/user/' + user + '/database/' + _CONF['db_name'] - # Grant read access to the current database - resp = requests.put( - db_grant_path, - data='{"grant": "ro"}', - auth=(_CONF['db_user'], _CONF['db_pass']) - ) - if resp.status_code != 200: - raise ArangoServerError(resp.text) - # Grant read access to all collections - resp = requests.put( - db_grant_path + '/*', - data='{"grant": "ro"}', - auth=(_CONF['db_user'], _CONF['db_pass']) - ) - if not resp.ok: - raise ArangoServerError(resp.text) +# def _init_readonly_user(): +# """ +# Using the admin user, initialize an admin readonly user for use with ad-hoc queries. +# If the user cannot be created, we raise an ArangoServerError +# If the user already exists, or is successfully created, we return None and do not raise. +# """ +# user = _CONF['db_readonly_user'] +# # Check if the user exists, in which case this is a no-op +# resp = requests.get( +# _CONF['api_url'] + '/user/' + user, +# auth=(_CONF['db_user'], _CONF['db_pass']) +# ) +# if resp.status_code == 200: +# return +# # Create the user +# resp = requests.post( +# _CONF['api_url'] + '/user', +# data=json.dumps({'user': user, 'passwd': _CONF['db_readonly_user']}), +# auth=(_CONF['db_user'], _CONF['db_pass']) +# ) +# if resp.status_code != 201: +# raise ArangoServerError(resp.text) +# db_grant_path = _CONF['api_url'] + '/user/' + user + '/database/' + _CONF['db_name'] +# # Grant read access to the current database +# resp = requests.put( +# db_grant_path, +# data='{"grant": "ro"}', +# auth=(_CONF['db_user'], _CONF['db_pass']) +# ) +# if resp.status_code != 200: +# raise ArangoServerError(resp.text) +# # Grant read access to all collections +# resp = requests.put( +# db_grant_path + '/*', +# data='{"grant": "ro"}', +# auth=(_CONF['db_user'], _CONF['db_pass']) +# ) +# if not resp.ok: +# raise ArangoServerError(resp.text) class ArangoServerError(Exception): diff --git a/api/src/relation_engine_server/utils/config.py b/api/src/relation_engine_server/utils/config.py index 8ca0e1a6..945ea27d 100644 --- a/api/src/relation_engine_server/utils/config.py +++ b/api/src/relation_engine_server/utils/config.py @@ -24,8 +24,8 @@ def get_config(): db_user = os.environ.get('DB_USER', 'root') db_pass = os.environ.get('DB_PASS', '') api_url = db_url + '/_db/' + db_name + '/_api' - db_readonly_user = os.environ.get('DB_READONLY_USER', 'readonly') - db_readonly_pass = os.environ.get('DB_READONLY_PASS', 'readonly') + db_readonly_user = os.environ.get('DB_READONLY_USER', db_user) + db_readonly_pass = os.environ.get('DB_READONLY_PASS', db_pass) return { 'auth_url': auth_url, 'workspace_url': workspace_url, diff --git a/api/src/test/test_api_v1.py b/api/src/test/test_api_v1.py index 3cd2d81a..9cab54ae 100644 --- a/api/src/test/test_api_v1.py +++ b/api/src/test/test_api_v1.py @@ -402,15 +402,3 @@ def test_auth_adhoc_query(self): headers={'Authorization': ADMIN_TOKEN} # see ./mock_workspace/endpoints.json ).json() self.assertEqual(resp['count'], 1) - - def test_queries_are_readonly(self): - """Test that ad-hoc admin queries cannot do any writing.""" - save_test_docs(1) - query = 'for v in test_vertex remove v in test_vertex' - resp = requests.post( - API_URL + '/query_results', - headers=HEADERS_ADMIN, - data=json.dumps({'query': query}) - ).json() - self.assertTrue(resp['error']) - self.assertTrue('read only' in resp['arango_message']) From 09919d35f91e1a8b106e15a671f906814c112e08 Mon Sep 17 00:00:00 2001 From: Gavin Date: Thu, 12 Sep 2019 17:54:18 -0700 Subject: [PATCH 367/732] Add preliminary schemas for genome feature nodes and edges --- spec/schemas/ws/ws_genome_features.yaml | 34 ++++++++++++++++++++++ spec/schemas/ws/ws_genome_has_feature.yaml | 16 ++++++++++ 2 files changed, 50 insertions(+) create mode 100644 spec/schemas/ws/ws_genome_features.yaml create mode 100644 spec/schemas/ws/ws_genome_has_feature.yaml diff --git a/spec/schemas/ws/ws_genome_features.yaml b/spec/schemas/ws/ws_genome_features.yaml new file mode 100644 index 00000000..5e41564f --- /dev/null +++ b/spec/schemas/ws/ws_genome_features.yaml @@ -0,0 +1,34 @@ +name: ws_genome_features +type: vertex +schema: + "$schema": "http://json-schema.org/draft-07/schema#" + type: object + required: + - _key + - feature_id + - workspace_id + - object_id + - version + properties: + _key: + type: string + description: The UPA and feature ID for this data + examples: ["35414:73:1_RSP_4039"] + pattern: "^\\d+:\\d+:\\d+_\w*$" # may need to expand the feature ID part + feature_id: + type: string + description: The unique ID of the feature within the genome + examples: ["RSP_4039"] + pattern: "^\w*$" # may need to expand + workspace_id: + type: integer + description: The workspace ID for the genome containing this feature + minimum: 1 + object_id: + type: integer + description: The permanent object id for the genome containing this feature + minimum: 1 + version: + type: integer + description: The version of the object containing this feature + minimum: 1 diff --git a/spec/schemas/ws/ws_genome_has_feature.yaml b/spec/schemas/ws/ws_genome_has_feature.yaml new file mode 100644 index 00000000..0942abe3 --- /dev/null +++ b/spec/schemas/ws/ws_genome_has_feature.yaml @@ -0,0 +1,16 @@ +name: ws_genome_has_feature +type: edge +schema: + "$schema": http://json-schema.org/draft-07/schema# + type: object + description: A workspace genome has a feature. + required: [_from, _to] + properties: + _from: + type: string + examples: ['ws_object_version/75:82:3'] + description: The unique, permanent ID of a version of a workspace object. + _to: + type: string + examples: ['ws_genome_feature/75:82:3_RSP_4039'] + description: A genome feature \ No newline at end of file From ed4b071a97feec62bb0695e002253068d6b82697 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Thu, 12 Sep 2019 18:01:19 -0700 Subject: [PATCH 368/732] Upgrade to arango 3.5 --- spec/docker-compose.yaml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/spec/docker-compose.yaml b/spec/docker-compose.yaml index a2345275..f7c17b97 100644 --- a/spec/docker-compose.yaml +++ b/spec/docker-compose.yaml @@ -40,11 +40,10 @@ services: # Arangodb server in cluster mode arangodb: - image: arangodb:3.4 + image: arangodb:3.5 ports: - "127.0.0.1:8529:8529" - command: sh -c "arangodb create jwt-secret --secret=jwtSecret && - arangodb --starter.local --auth.jwt-secret=./jwtSecret" + command: sh -c "arangodb --starter.local" # A mock kbase auth server (see src/test/mock_auth/endpoints.json) auth: From d1b786a1eda0c3f7a848a39f2236a96813518caf Mon Sep 17 00:00:00 2001 From: Gavin Date: Thu, 12 Sep 2019 18:06:31 -0700 Subject: [PATCH 369/732] fix regex --- spec/schemas/ws/ws_genome_features.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/schemas/ws/ws_genome_features.yaml b/spec/schemas/ws/ws_genome_features.yaml index 5e41564f..49ab4bbf 100644 --- a/spec/schemas/ws/ws_genome_features.yaml +++ b/spec/schemas/ws/ws_genome_features.yaml @@ -14,12 +14,12 @@ schema: type: string description: The UPA and feature ID for this data examples: ["35414:73:1_RSP_4039"] - pattern: "^\\d+:\\d+:\\d+_\w*$" # may need to expand the feature ID part + pattern: "^\\d+:\\d+:\\d+_\\w*$" # may need to expand the feature ID part feature_id: type: string description: The unique ID of the feature within the genome examples: ["RSP_4039"] - pattern: "^\w*$" # may need to expand + pattern: "^\\w*$" # may need to expand workspace_id: type: integer description: The workspace ID for the genome containing this feature From 648e882d3b45c787b49af2a4434ec081c9f17cbb Mon Sep 17 00:00:00 2001 From: Zhenyuan Lu Date: Fri, 13 Sep 2019 03:41:15 -0400 Subject: [PATCH 370/732] update go queries --- spec/stored_queries/GO/GO_get_ancestors.yaml | 21 +++++--- spec/stored_queries/GO/GO_get_children.yaml | 25 +++++++--- .../stored_queries/GO/GO_get_descendants.yaml | 19 +++++-- .../GO/GO_get_hierarchicalAncestors.yaml | 49 +++++++++++-------- .../GO/GO_get_hierarchicalChildren.yaml | 41 ++++++++++------ .../GO/GO_get_hierarchicalDescendants.yaml | 41 ++++++++++------ .../GO/GO_get_hierarchicalParents.yaml | 49 +++++++++++-------- spec/stored_queries/GO/GO_get_metadata.yaml | 18 ++++--- spec/stored_queries/GO/GO_get_parents.yaml | 25 +++++++--- spec/stored_queries/GO/GO_get_related.yaml | 26 +++++++--- spec/stored_queries/GO/GO_get_siblings.yaml | 32 +++++++----- 11 files changed, 222 insertions(+), 124 deletions(-) diff --git a/spec/stored_queries/GO/GO_get_ancestors.yaml b/spec/stored_queries/GO/GO_get_ancestors.yaml index f3842c69..42a52719 100644 --- a/spec/stored_queries/GO/GO_get_ancestors.yaml +++ b/spec/stored_queries/GO/GO_get_ancestors.yaml @@ -3,11 +3,11 @@ name: GO_get_ancestors params: type: object - required: [key] + required: [id, ts] properties: - key: + id: type: string - title: Document key + title: Document ID description: GO id of the term you want to get all the ancestors of limit: type: integer @@ -19,9 +19,18 @@ params: default: 0 description: Result offset for pagination maximum: 100000 -query_prefix: WITH GO_test_term + ts: + type: integer + title: Versioning timestamp +query_prefix: WITH GO_terms query: | - FOR v, e IN 1..1000000 OUTBOUND CONCAT("GO_test_term/", @key) GO_test_edges_isa - SORT v._key ASC + FOR t in GO_terms + FILTER t.id == @id + FILTER t.created <= @ts AND t.expired >= @ts + limit 1 + FOR v, e IN 1..100 OUTBOUND t GO_edges + FILTER e.type == "is_a" + FILTER e.created <= @ts AND e.expired >= @ts + SORT v.id ASC LIMIT @offset, @limit RETURN {term: v, edge: e} diff --git a/spec/stored_queries/GO/GO_get_children.yaml b/spec/stored_queries/GO/GO_get_children.yaml index 1ea86860..6cdf52d7 100644 --- a/spec/stored_queries/GO/GO_get_children.yaml +++ b/spec/stored_queries/GO/GO_get_children.yaml @@ -3,11 +3,11 @@ name: GO_get_children params: type: object - required: [key] + required: [id, ts] properties: - key: + id: type: string - title: Document key + title: Document ID description: GO id of the term you want to get the children of limit: type: integer @@ -19,9 +19,18 @@ params: default: 0 description: Result offset for pagination maximum: 100000 -query_prefix: WITH GO_test_term + ts: + type: integer + title: Versioning timestamp +query_prefix: WITH GO_terms query: | - FOR v, e IN 1..1 INBOUND CONCAT("GO_test_term/", @key) GO_test_edges_isa - SORT v._key ASC - LIMIT @offset, @limit - RETURN {term: v, edge: e} + FOR t in GO_terms + FILTER t.id == @id + FILTER t.created <= @ts AND t.expired >= @ts + limit 1 + FOR v, e IN 1..1 INBOUND t GO_edges + FILTER e.type == "is_a" + FILTER e.created <= @ts AND e.expired >= @ts + SORT v.id ASC + LIMIT @offset, @limit + RETURN {term: v, edge: e} diff --git a/spec/stored_queries/GO/GO_get_descendants.yaml b/spec/stored_queries/GO/GO_get_descendants.yaml index 156ada75..8f3f25dc 100644 --- a/spec/stored_queries/GO/GO_get_descendants.yaml +++ b/spec/stored_queries/GO/GO_get_descendants.yaml @@ -2,11 +2,11 @@ name: GO_get_descendants params: type: object - required: [key] + required: [id, ts] properties: - key: + id: type: string - title: Document key + title: Document ID description: GO id of the term you want to get all the descendants of limit: type: integer @@ -18,9 +18,18 @@ params: default: 0 description: Result offset for pagination maximum: 100000 -query_prefix: WITH GO_test_term + ts: + type: integer + title: Versioning timestamp +query_prefix: WITH GO_terms query: | - FOR v, e IN 1..1000000 INBOUND CONCAT("GO_test_term/", @key) GO_test_edges_isa + FOR t in GO_terms + FILTER t.id == @id + FILTER t.created <= @ts AND t.expired >= @ts + limit 1 + FOR v, e IN 1..100 INBOUND t GO_edges + FILTER e.type == "is_a" + FILTER e.created <= @ts AND e.expired >= @ts SORT v._key ASC LIMIT @offset, @limit RETURN {term: v, edge: e} diff --git a/spec/stored_queries/GO/GO_get_hierarchicalAncestors.yaml b/spec/stored_queries/GO/GO_get_hierarchicalAncestors.yaml index 1b9db359..3d9cfe50 100644 --- a/spec/stored_queries/GO/GO_get_hierarchicalAncestors.yaml +++ b/spec/stored_queries/GO/GO_get_hierarchicalAncestors.yaml @@ -6,11 +6,11 @@ name: GO_get_hierarchicalAncestors params: type: object - required: [key] + required: [id, ts] properties: - key: + id: type: string - title: Document key + title: Document ID description: GO id of the term you want to get all the hierarchical ancestors of limit: type: integer @@ -22,21 +22,30 @@ params: default: 0 description: Result offset for pagination maximum: 100000 -query_prefix: WITH GO_test_term + ts: + type: integer + title: Versioning timestamp +query_prefix: WITH GO_terms query: | - LET term_id = CONCAT("GO_test_term/", @key) - LET results1 = ( - FOR v_relationship, e_relationship IN 1..1000000 OUTBOUND term_id GO_test_edges_relationship - FILTER e_relationship.relationship_type == 'part_of' - OR e_relationship.relationship_type == 'has_part' - OR e_relationship.relationship_type == 'occurs_in' - RETURN {term: v_relationship, edge: e_relationship} - ) - LET results2 = ( - FOR v_isa, e_isa IN 1..1000000 OUTBOUND term_id GO_test_edges_isa - RETURN {term: v_isa, edge: e_isa} - ) - FOR x IN UNION(results1, results2) - SORT x._key ASC - LIMIT @offset, @limit - RETURN DISTINCT x + FOR t in GO_terms + FILTER t.id == @id + FILTER t.created <= @ts AND t.expired >= @ts + limit 1 + LET results1 = ( + FOR v_relationship, e_relationship IN 1..100 OUTBOUND t GO_edges_relationship + FILTER e_relationship.relationship_type == 'part_of' + OR e_relationship.relationship_type == 'has_part' + OR e_relationship.relationship_type == 'occurs_in' + FILTER e_relationship.created <= @ts AND e_relationship.expired >= @ts + RETURN {term: v_relationship, edge: e_relationship} + ) + LET results2 = ( + FOR v_isa, e_isa IN 1..100 OUTBOUND t GO_edges + FILTER e_isa.type == "is_a" + FILTER e_isa.created <= @ts AND e_isa.expired >= @ts + RETURN {term: v_isa, edge: e_isa} + ) + FOR x IN UNION(results1, results2) + SORT x.id ASC + LIMIT @offset, @limit + RETURN DISTINCT x diff --git a/spec/stored_queries/GO/GO_get_hierarchicalChildren.yaml b/spec/stored_queries/GO/GO_get_hierarchicalChildren.yaml index 53b615da..5eaa142d 100644 --- a/spec/stored_queries/GO/GO_get_hierarchicalChildren.yaml +++ b/spec/stored_queries/GO/GO_get_hierarchicalChildren.yaml @@ -2,11 +2,11 @@ name: GO_get_hierarchicalChildren params: type: object - required: [key] + required: [id, ts] properties: - key: + id: type: string - title: Document key + title: Document ID description: GO id of the term you want to get the direct hierarchical children of limit: type: integer @@ -18,21 +18,30 @@ params: default: 0 description: Result offset for pagination maximum: 100000 -query_prefix: WITH GO_test_term + ts: + type: integer + title: Versioning timestamp +query_prefix: WITH GO_terms query: | - LET term_id = CONCAT("GO_test_term/", @key) - LET results1 = ( - FOR v_relationship, e_relationship IN 1..1 INBOUND term_id GO_test_edges_relationship + FOR t in GO_terms + FILTER t.id == @id + FILTER t.created <= @ts AND t.expired >= @ts + limit 1 + LET results1 = ( + FOR v_relationship, e_relationship IN 1..1 INBOUND t GO_edges_relationship FILTER e_relationship.relationship_type == 'part_of' OR e_relationship.relationship_type == 'has_part' OR e_relationship.relationship_type == 'occurs_in' + FILTER e_relationship.created <= @ts AND e_relationship.expired >= @ts RETURN {term: v_relationship, edge: e_relationship} - ) - LET results2 = ( - FOR v_isa, e_isa IN 1..1 INBOUND term_id GO_test_edges_isa - RETURN {term: v_isa, edge: e_isa} - ) - FOR x IN UNION(results1, results2) - SORT x._key ASC - LIMIT @offset, @limit - RETURN DISTINCT x + ) + LET results2 = ( + FOR v_isa, e_isa IN 1..1 INBOUND t GO_edges + FILTER e_isa.type == "is_a" + FILTER e_isa.created <= @ts AND e_isa.expired >= @ts + RETURN {term: v_isa, edge: e_isa} + ) + FOR x IN UNION(results1, results2) + SORT x.id ASC + LIMIT @offset, @limit + RETURN DISTINCT x diff --git a/spec/stored_queries/GO/GO_get_hierarchicalDescendants.yaml b/spec/stored_queries/GO/GO_get_hierarchicalDescendants.yaml index dd9bc3d7..845d157e 100644 --- a/spec/stored_queries/GO/GO_get_hierarchicalDescendants.yaml +++ b/spec/stored_queries/GO/GO_get_hierarchicalDescendants.yaml @@ -5,11 +5,11 @@ name: GO_get_hierarchicalDescendants params: type: object - required: [key] + required: [id, ts] properties: - key: + id: type: string - title: Document key + title: Document ID description: GO id of the term you want to get all the hierarchical descendants of limit: type: integer @@ -21,21 +21,30 @@ params: default: 0 description: Result offset for pagination maximum: 100000 -query_prefix: WITH GO_test_term + ts: + type: integer + title: Versioning timestamp +query_prefix: WITH GO_terms query: | - LET term_id = CONCAT("GO_test_term/", @key) - LET results1 = ( - FOR v_relationship, e_relationship IN 1..1000000 INBOUND term_id GO_test_edges_relationship + FOR t in GO_terms + FILTER t.id == @id + FILTER t.created <= @ts AND t.expired >= @ts + limit 1 + LET results1 = ( + FOR v_relationship, e_relationship IN 1..100 INBOUND t GO_edges_relationship FILTER e_relationship.relationship_type == 'part_of' OR e_relationship.relationship_type == 'has_part' OR e_relationship.relationship_type == 'occurs_in' + FILTER e_relationship.created <= @ts AND e_relationship.expired >= @ts RETURN {term: v_relationship, edge: e_relationship} - ) - LET results2 = ( - FOR v_isa, e_isa IN 1..1000000 INBOUND term_id GO_test_edges_isa - RETURN {term: v_isa, edge: e_isa} - ) - FOR x IN UNION(results1, results2) - SORT x._key ASC - LIMIT @offset, @limit - RETURN DISTINCT x + ) + LET results2 = ( + FOR v_isa, e_isa IN 1..100 INBOUND t GO_edges + FILTER e_isa.type == "is_a" + FILTER e_isa.created <= @ts AND e_isa.expired >= @ts + RETURN {term: v_isa, edge: e_isa} + ) + FOR x IN UNION(results1, results2) + SORT x.id ASC + LIMIT @offset, @limit + RETURN DISTINCT x diff --git a/spec/stored_queries/GO/GO_get_hierarchicalParents.yaml b/spec/stored_queries/GO/GO_get_hierarchicalParents.yaml index 184e8dbd..7c0c14bd 100644 --- a/spec/stored_queries/GO/GO_get_hierarchicalParents.yaml +++ b/spec/stored_queries/GO/GO_get_hierarchicalParents.yaml @@ -6,11 +6,11 @@ name: GO_get_hierarchicalParents params: type: object - required: [key] + required: [id, ts] properties: - key: + id: type: string - title: Document key + title: Document ID description: GO id of the term you want to get all the hierarchical parents of limit: type: integer @@ -22,21 +22,30 @@ params: default: 0 description: Result offset for pagination maximum: 100000 -query_prefix: WITH GO_test_term + ts: + type: integer + title: Versioning timestamp +query_prefix: WITH GO_terms query: | - LET term_id = CONCAT("GO_test_term/", @key) - LET results1 = ( - FOR v_relationship, e_relationship IN 1..1 OUTBOUND term_id GO_test_edges_relationship - FILTER e_relationship.relationship_type == 'part_of' - OR e_relationship.relationship_type == 'has_part' - OR e_relationship.relationship_type == 'occurs_in' - RETURN {term: v_relationship, edge: e_relationship} - ) - LET results2 = ( - FOR v_isa, e_isa IN 1..1 OUTBOUND term_id GO_test_edges_isa - RETURN {term: v_isa, edge: e_isa} - ) - FOR x IN UNION(results1, results2) - SORT x._key ASC - LIMIT @offset, @limit - RETURN DISTINCT x + FOR t in GO_terms + FILTER t.id == @id + FILTER t.created <= @ts AND t.expired >= @ts + limit 1 + LET results1 = ( + FOR v_relationship, e_relationship IN 1..1 OUTBOUND t GO_edges_relationship + FILTER e_relationship.relationship_type == 'part_of' + OR e_relationship.relationship_type == 'has_part' + OR e_relationship.relationship_type == 'occurs_in' + FILTER e_relationship.created <= @ts AND e_relationship.expired >= @ts + RETURN {term: v_relationship, edge: e_relationship} + ) + LET results2 = ( + FOR v_isa, e_isa IN 1..1 OUTBOUND t GO_edges + FILTER e_isa.type == "is_a" + FILTER e_isa.created <= @ts AND e_isa.expired >= @ts + RETURN {term: v_isa, edge: e_isa} + ) + FOR x IN UNION(results1, results2) + SORT x.id ASC + LIMIT @offset, @limit + RETURN DISTINCT x diff --git a/spec/stored_queries/GO/GO_get_metadata.yaml b/spec/stored_queries/GO/GO_get_metadata.yaml index ab2e0f94..f09047d3 100644 --- a/spec/stored_queries/GO/GO_get_metadata.yaml +++ b/spec/stored_queries/GO/GO_get_metadata.yaml @@ -3,13 +3,19 @@ name: GO_get_metadata params: type: object - required: [key] + required: [id, ts] properties: - key: + id: type: string - title: Document key + title: Document ID description: Get information/metadata of a particular ontology term + ts: + type: integer + title: Versioning timestamp +query_prefix: WITH GO_terms query: | - FOR v IN GO_test_term - FILTER v._key == @key - RETURN v + FOR t IN GO_terms + FILTER t.id == @id + FILTER t.created <= @ts AND t.expired >= @ts + limit 1 + RETURN t diff --git a/spec/stored_queries/GO/GO_get_parents.yaml b/spec/stored_queries/GO/GO_get_parents.yaml index bb2ae0b2..ca6c6326 100644 --- a/spec/stored_queries/GO/GO_get_parents.yaml +++ b/spec/stored_queries/GO/GO_get_parents.yaml @@ -3,11 +3,11 @@ name: GO_get_parents params: type: object - required: [key] + required: [id, ts] properties: - key: + id: type: string - title: Document key + title: Document ID description: GO id of the term you want to get all the direct parents of limit: type: integer @@ -19,9 +19,18 @@ params: default: 0 description: Result offset for pagination maximum: 100000 -query_prefix: WITH GO_test_term + ts: + type: integer + title: Versioning timestamp +query_prefix: WITH GO_terms query: | - FOR v, e IN 1..1 OUTBOUND CONCAT("GO_test_term/", @key) GO_test_edges_isa - SORT v._key ASC - LIMIT @offset, @limit - RETURN {term: v, edge: e} + FOR t in GO_terms + FILTER t.id == @id + FILTER t.created <= @ts AND t.expired >= @ts + limit 1 + FOR v, e IN 1..1 OUTBOUND t GO_edges + FILTER e.type == "is_a" + FILTER e.created <= @ts AND e.expired >= @ts + SORT v.id ASC + LIMIT @offset, @limit + RETURN {term: v, edge: e} diff --git a/spec/stored_queries/GO/GO_get_related.yaml b/spec/stored_queries/GO/GO_get_related.yaml index 73ffab25..a2fbff20 100644 --- a/spec/stored_queries/GO/GO_get_related.yaml +++ b/spec/stored_queries/GO/GO_get_related.yaml @@ -2,11 +2,11 @@ name: GO_get_related params: type: object - required: [key] + required: [id, ts] properties: - key: + id: type: string - title: Document key + title: Document ID description: GO id of the term you want to get all the directly related nodes of limit: type: integer @@ -18,9 +18,19 @@ params: default: 0 description: Result offset for pagination maximum: 100000 -query_prefix: WITH GO_test_term + ts: + type: integer + title: Versioning timestamp +query_prefix: WITH GO_terms query: | - FOR v, e IN 1 ANY CONCAT("GO_test_term/", @key) GO_test_edges_isa, GO_test_edges_relationship - SORT v._key ASC - LIMIT @offset, @limit - RETURN {term: v, edge: e} + FOR t in GO_terms + FILTER t.id == @id + FILTER t.created <= @ts AND t.expired >= @ts + limit 1 + FOR v, e IN 1 ANY t GO_edges, GO_edges_relationship + FILTER e.type == "is_a" + OR e.relationship_type != null + FILTER e.created <= @ts AND e.expired >= @ts + SORT v.id ASC + LIMIT @offset, @limit + RETURN {term: v, edge: e} diff --git a/spec/stored_queries/GO/GO_get_siblings.yaml b/spec/stored_queries/GO/GO_get_siblings.yaml index c56a978d..f80ba3eb 100644 --- a/spec/stored_queries/GO/GO_get_siblings.yaml +++ b/spec/stored_queries/GO/GO_get_siblings.yaml @@ -2,11 +2,11 @@ name: GO_get_siblings params: type: object - required: [key] + required: [id, ts] properties: - key: + id: type: string - title: Document key + title: Document ID description: Get all siblings of this term limit: type: integer @@ -18,12 +18,22 @@ params: default: 0 description: Result offset for pagination maximum: 100000 -query_prefix: WITH GO_test_term + ts: + type: integer + title: Versioning timestamp +query_prefix: WITH GO_terms query: | - LET term_id = CONCAT("GO_test_term/", @key) - FOR v_parent, e_parent IN 1..1 OUTBOUND term_id GO_test_edges_isa - FOR v_child, e_child in 1..1 INBOUND e_parent._to GO_test_edges_isa - FILTER e_child._from != term_id - SORT v_child._key ASC - LIMIT @offset, @limit - RETURN v_child._key + FOR t in GO_terms + FILTER t.id == @id + FILTER t.created <= @ts AND t.expired >= @ts + limit 1 + FOR v_parent, e_parent IN 1..1 OUTBOUND t GO_edges + FILTER e_parent.type == "is_a" + FILTER e_parent.created <= @ts AND e_parent.expired >= @ts + FOR v_child, e_child in 1..1 INBOUND e_parent._to GO_edges + FILTER e_child._from != t._id + FILTER e_child.type == "is_a" + FILTER e_child.created <= @ts AND e_child.expired >= @ts + SORT v_child.id ASC + LIMIT @offset, @limit + RETURN v_child.id From 6be1ee2da5e2a03f4e2fae154c311bf7d527dfe6 Mon Sep 17 00:00:00 2001 From: Gavin Date: Fri, 13 Sep 2019 13:33:26 -0700 Subject: [PATCH 371/732] GO schema part 1 - moved terms to new file name without any other changes. This will make the changes easier to review in the next PR. - deleted the old edges schemas and added the new one. Do we need a merges schema? --- spec/schemas/GO/GO_edges.yaml | 37 +++++++++++++++++ spec/schemas/GO/GO_edges_consider.yaml | 30 -------------- spec/schemas/GO/GO_edges_disjoint_from.yaml | 30 -------------- spec/schemas/GO/GO_edges_intersection_of.yaml | 40 ------------------- spec/schemas/GO/GO_edges_isa.yaml | 30 -------------- spec/schemas/GO/GO_edges_relationship.yaml | 38 ------------------ spec/schemas/GO/GO_edges_replaced_by.yaml | 30 -------------- .../GO/{GO_term.yaml => GO_terms.yaml} | 0 8 files changed, 37 insertions(+), 198 deletions(-) create mode 100644 spec/schemas/GO/GO_edges.yaml delete mode 100644 spec/schemas/GO/GO_edges_consider.yaml delete mode 100644 spec/schemas/GO/GO_edges_disjoint_from.yaml delete mode 100644 spec/schemas/GO/GO_edges_intersection_of.yaml delete mode 100644 spec/schemas/GO/GO_edges_isa.yaml delete mode 100644 spec/schemas/GO/GO_edges_relationship.yaml delete mode 100644 spec/schemas/GO/GO_edges_replaced_by.yaml rename spec/schemas/GO/{GO_term.yaml => GO_terms.yaml} (100%) diff --git a/spec/schemas/GO/GO_edges.yaml b/spec/schemas/GO/GO_edges.yaml new file mode 100644 index 00000000..eb66c70c --- /dev/null +++ b/spec/schemas/GO/GO_edges.yaml @@ -0,0 +1,37 @@ +name: GO_edges +type: edge +delta: true + +schema: + "$schema": http://json-schema.org/draft-07/schema# + title: GO_edges + type: object + description: A entry for edges in the Gene Ontology (GO) hierarchy + properties: + id: + type: string + description: an edge ID, consisting of from::to::type + examples: + - GO:0000136::GO:0031501::is_a + - GO:0000022::GO:0051231::is_a + type: + type: string + description: GO edge type + examples: + - is_a + - part_of + from: + type: string + description: GO id + examples: + - GO:0023052 + to: + type: string + title: GO id + examples: + - GO:0008150 + required: + - id + - type + - from + - to diff --git a/spec/schemas/GO/GO_edges_consider.yaml b/spec/schemas/GO/GO_edges_consider.yaml deleted file mode 100644 index d8b6be42..00000000 --- a/spec/schemas/GO/GO_edges_consider.yaml +++ /dev/null @@ -1,30 +0,0 @@ -name: GO_edges_consider -type: edge -delta: true - -schema: - "$schema": http://json-schema.org/draft-07/schema# - title: GO_edges_consider - type: object - description: A entry for consider edges in the Gene Ontology (GO) hierarchy - properties: - id: - type: string - description: GO id - examples: - - GO:0000005__GO:0042254__consider - - GO:0000005__GO:0044183__consider - from: - type: string - description: GO id - examples: - - GO:0023052 - to: - type: string - title: GO id - examples: - - GO:0008150 - required: - - id - - from - - to diff --git a/spec/schemas/GO/GO_edges_disjoint_from.yaml b/spec/schemas/GO/GO_edges_disjoint_from.yaml deleted file mode 100644 index 515365b4..00000000 --- a/spec/schemas/GO/GO_edges_disjoint_from.yaml +++ /dev/null @@ -1,30 +0,0 @@ -name: GO_edges_disjoint_from -type: edge -delta: true - -schema: - "$schema": http://json-schema.org/draft-07/schema# - title: GO_edges_disjoint_from - type: object - description: A entry for disjoint_from edges in the Gene Ontology (GO) hierarchy - properties: - id: - type: string - description: GO id - examples: - - GO:0000136__GO:0031501__disjoint_from - - GO:0000022__GO:0051231__disjoint_from - from: - type: string - description: GO id - examples: - - GO:0023052 - to: - type: string - title: GO id - examples: - - GO:0008150 - required: - - id - - from - - to diff --git a/spec/schemas/GO/GO_edges_intersection_of.yaml b/spec/schemas/GO/GO_edges_intersection_of.yaml deleted file mode 100644 index a6143751..00000000 --- a/spec/schemas/GO/GO_edges_intersection_of.yaml +++ /dev/null @@ -1,40 +0,0 @@ -name: GO_edges_intersection_of -type: edge -delta: true - -schema: - "$schema": http://json-schema.org/draft-07/schema# - title: GO_edges_intersection_of - type: object - description: A entry for intersection_of edges in the Gene Ontology (GO) hierarchy - properties: - id: - type: string - description: GO id - examples: - - GO:0000136__GO:0031501__intersection_of - - GO:0000132__GO:0000278__intersection_of:regulates - from: - type: string - description: GO id - examples: - - GO:0023052 - to: - type: string - title: GO id - examples: - - GO:0008150 - intersection_type: - type: string - title: Intersection type - examples: - - '' - - part_of - - occurs_in - - regulates - - has_part - required: - - id - - from - - to - - intersection_type diff --git a/spec/schemas/GO/GO_edges_isa.yaml b/spec/schemas/GO/GO_edges_isa.yaml deleted file mode 100644 index 18555ff1..00000000 --- a/spec/schemas/GO/GO_edges_isa.yaml +++ /dev/null @@ -1,30 +0,0 @@ -name: GO_edges_isa -type: edge -delta: true - -schema: - "$schema": http://json-schema.org/draft-07/schema# - title: GO_edges_isa - type: object - description: A entry for is_a edges in the Gene Ontology (GO) hierarchy - properties: - id: - type: string - description: GO id - examples: - - GO:0000136__GO:0031501__is_a - - GO:0000022__GO:0051231__is_a - from: - type: string - description: GO id - examples: - - GO:0023052 - to: - type: string - title: GO id - examples: - - GO:0008150 - required: - - id - - from - - to diff --git a/spec/schemas/GO/GO_edges_relationship.yaml b/spec/schemas/GO/GO_edges_relationship.yaml deleted file mode 100644 index 4de4886a..00000000 --- a/spec/schemas/GO/GO_edges_relationship.yaml +++ /dev/null @@ -1,38 +0,0 @@ -name: GO_edges_relationship -type: edge -delta: true - -schema: - "$schema": http://json-schema.org/draft-07/schema# - title: GO_edges_relationship - type: object - description: A entry for relationship edges in the Gene Ontology (GO) hierarchy - properties: - id: - type: string - description: GO id - examples: - - GO:0000136__GO:0031501__relationship:part_of - - GO:0000132__GO:0000278__relationship:has_part - from: - type: string - description: GO id - examples: - - GO:0023052 - to: - type: string - title: GO id - examples: - - GO:0008150 - relationship_type: - type: string - title: Relationship type - examples: - - occurs_in - - has_part - - part_of - required: - - id - - from - - to - - relationship_type diff --git a/spec/schemas/GO/GO_edges_replaced_by.yaml b/spec/schemas/GO/GO_edges_replaced_by.yaml deleted file mode 100644 index eb55f51d..00000000 --- a/spec/schemas/GO/GO_edges_replaced_by.yaml +++ /dev/null @@ -1,30 +0,0 @@ -name: GO_edges_replaced_by -type: edge -delta: true - -schema: - "$schema": http://json-schema.org/draft-07/schema# - title: GO_edges_replaced_by - type: object - description: A entry for replaced_by edges in the Gene Ontology (GO) hierarchy - properties: - id: - type: string - description: GO id - examples: - - GO:0000108__GO:0000109__replaced_by - - GO:0000174__GO:0000750__replaced_by - from: - type: string - description: GO id - examples: - - GO:0023052 - to: - type: string - title: GO id - examples: - - GO:0008150 - required: - - id - - from - - to diff --git a/spec/schemas/GO/GO_term.yaml b/spec/schemas/GO/GO_terms.yaml similarity index 100% rename from spec/schemas/GO/GO_term.yaml rename to spec/schemas/GO/GO_terms.yaml From 92c66c7567d8937d18f11b142ba39431518ba87a Mon Sep 17 00:00:00 2001 From: Gavin Date: Fri, 13 Sep 2019 13:41:19 -0700 Subject: [PATCH 372/732] Add GO merge edge schema --- spec/schemas/GO/GO_merges.yaml | 37 ++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 spec/schemas/GO/GO_merges.yaml diff --git a/spec/schemas/GO/GO_merges.yaml b/spec/schemas/GO/GO_merges.yaml new file mode 100644 index 00000000..bbb9224d --- /dev/null +++ b/spec/schemas/GO/GO_merges.yaml @@ -0,0 +1,37 @@ +name: GO_merges +type: edge +delta: true + +schema: + "$schema": http://json-schema.org/draft-07/schema# + title: GO_edges + type: object + description: A entry for merge edges in the Gene Ontology (GO) hierarchy + properties: + id: + type: string + description: an edge ID, consisting of from::to::type + examples: + - GO:0000136::GO:0031501::consider + - GO:0000022::GO:0051231::replaced_by + type: + type: string + description: GO merge edge type + examples: + - consider + - replaced_by + from: + type: string + description: GO id + examples: + - GO:0023052 + to: + type: string + title: GO id + examples: + - GO:0008150 + required: + - id + - type + - from + - to From ab7cd658fa37b23276bc367df3737fd1d48ef238 Mon Sep 17 00:00:00 2001 From: Gavin Date: Fri, 13 Sep 2019 13:50:28 -0700 Subject: [PATCH 373/732] whoops --- spec/schemas/GO/GO_merges.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/schemas/GO/GO_merges.yaml b/spec/schemas/GO/GO_merges.yaml index bbb9224d..2b05de03 100644 --- a/spec/schemas/GO/GO_merges.yaml +++ b/spec/schemas/GO/GO_merges.yaml @@ -4,7 +4,7 @@ delta: true schema: "$schema": http://json-schema.org/draft-07/schema# - title: GO_edges + title: GO_merges type: object description: A entry for merge edges in the Gene Ontology (GO) hierarchy properties: From 06610bda931ab5634aa30004a258d05ed4261a15 Mon Sep 17 00:00:00 2001 From: Gavin Date: Fri, 13 Sep 2019 15:16:08 -0700 Subject: [PATCH 374/732] GO specs pt2: terms --- spec/schemas/GO/GO_terms.yaml | 185 ++++++++++++++++++++-------------- 1 file changed, 110 insertions(+), 75 deletions(-) diff --git a/spec/schemas/GO/GO_terms.yaml b/spec/schemas/GO/GO_terms.yaml index 4e6c199c..d6bc3f76 100644 --- a/spec/schemas/GO/GO_terms.yaml +++ b/spec/schemas/GO/GO_terms.yaml @@ -12,102 +12,137 @@ schema: type: string description: The unique id of the current term. examples: - - GO:0022609 - - GO:0044848 - name: + - GO:0022609 + - GO:0044848 + type: type: string - description: The term name. Any term may have only one name defined. + description: The type of the node. + examples: + - CLASS + - INDIVIDUAL + name: + type: ["null", "string"] # some OBO classes have no label + description: The term name. examples: - - mitochondrial genome maintenance - - reproduction + - mitochondrial genome maintenance + - reproduction namespace: - type: string + type: ["null", "string"] # some OBO classes have no namespace description: Denotes which of the three sub-ontologies the term belongs to. examples: - cellular component - biological process - molecular function - alt_id: + alt_ids: type: array + items: + type: string description: Defines an alternate id for this term. A term may have any number of alternate ids. examples: - - - GO:0019952 - - GO:0050876 - - - GO:0044848 + - ["GO:0019952"] + - ["GO:0050876"] + - ["GO:0044848"] def: - type: string - description: 'The definition of the current term. ' - examples: - - "'The directed movement of a ribosomal subunit from the nucleus into the cytoplasm.' - [GOC:ai]" - - "'Catalysis of the reaction: adenine + H2O = hypoxanthine + NH3.' [EC:3.5.4.2]" - comment: - type: string - description: A comment for this term. + type: ["null", "object"] # some OBO classes have no definition + description: The definition of the current term. + required: + - val + properties: + pred: + type: string + description: The definition predicate + val: + type: string + description: The definition value + examples: + - Any process that modulates the frequency, rate or extent of glycolysis. + xrefs: + type: array + description: A dbxref that describes an analagous term in another vocabulary + items: + type: string + examples: + - ["GOC:go_curators"] + - ["ISBN:0815340729"] + comments: + type: array + items: + type: string + description: Comments for this term. examples: - - This term was made obsolete because it refers to a class of gene products and - a biological process rather than a molecular function. - subset: + - ["This term was made obsolete because it refers to a class of gene products and + a biological process rather than a molecular function."] + subsets: type: array + items: + type: string description: This tag indicates a term subset to which this term belongs. examples: - - - goslim_yeast - - - goslim_chembl - - goslim_metagenomics - - goslim_pir - - goslim_plant - synonym: - type: array + - ["goslim_yeast"] + - ["goslim_chembl"] + - ["goslim_metagenomics"] + - ["goslim_pir"] + - ["goslim_plant"] + synonyms: description: This tag gives a synonym for this term, some xrefs to describe the origins of the synonym, and may indicate a synonym category or scope information. - examples: - - - "'L-methionine porter activity' RELATED []" - - - "'ribonuclease mitochondrial RNA processing complex' EXACT []" - - "'RNase MRP complex' EXACT []" - xref: type: array - description: A dbxref that describes an analagous term in another vocabulary - examples: - - - Wikipedia:Reproduction - - - KEGG_REACTION:R05612 - - RHEA:20836 - examples: - - - GO:0042254 - - - GO:0008104 - - GO:0051019 - is_obsolete: - type: boolean - description: Whether or not this term is obsolete. - examples: [true] - default: false - created_by: - type: string - description: Optional tag added by OBO-Edit to indicate the creator of the term - examples: - - kchris - creation_date: - type: string - description: Optional tag added by OBO-Edit to indicate the creation time and - date of the term - examples: - - '2009-04-28T10:33:25Z' + items: + type: object + required: + - val + properties: + pred: + type: string + description: The synonym predicate + examples: + - hasBroadSynonym + - hasNarrowSynonym + val: + type: string + description: The synonym value + examples: + - regulation of blood angiotensin level + xrefs: + type: array + description: A dbxref that describes an analagous term in another vocabulary + items: + type: string + examples: + - ["GOC:TermGenie"] + xrefs: + description: DBxrefs that describes an analagous term in another vocabulary + type: array + items: + type: object + required: + - val + properties: + pred: + type: string + description: The xref predicate + val: + type: string + description: The xref value + examples: + - EC:2.3.1 + - Reactome:REACT_10010 + xrefs: + type: array + description: A dbxref that describes an analagous term in another vocabulary + items: + type: string + examples: + - ["GOC:TermGenie"] required: - id + - type - name - optional: - - alt_id + - namespace + - alt_ids - def - - comment - - subset - - synonym - - xref - - is_a - - intersection_of - - disjoint_from - - relationship - - is_obsolete - - replaced_by - - consider - - created_by - - creation_date + - comments + - subsets + - synonyms + - xrefs \ No newline at end of file From 146655ba8ce370cd404bfbe19e0fb3f40e166bd8 Mon Sep 17 00:00:00 2001 From: MrCreosote Date: Fri, 13 Sep 2019 15:22:42 -0700 Subject: [PATCH 375/732] GO specs pt2: terms (#93) --- spec/schemas/GO/GO_terms.yaml | 185 ++++++++++++++++++++-------------- 1 file changed, 110 insertions(+), 75 deletions(-) diff --git a/spec/schemas/GO/GO_terms.yaml b/spec/schemas/GO/GO_terms.yaml index 4e6c199c..d6bc3f76 100644 --- a/spec/schemas/GO/GO_terms.yaml +++ b/spec/schemas/GO/GO_terms.yaml @@ -12,102 +12,137 @@ schema: type: string description: The unique id of the current term. examples: - - GO:0022609 - - GO:0044848 - name: + - GO:0022609 + - GO:0044848 + type: type: string - description: The term name. Any term may have only one name defined. + description: The type of the node. + examples: + - CLASS + - INDIVIDUAL + name: + type: ["null", "string"] # some OBO classes have no label + description: The term name. examples: - - mitochondrial genome maintenance - - reproduction + - mitochondrial genome maintenance + - reproduction namespace: - type: string + type: ["null", "string"] # some OBO classes have no namespace description: Denotes which of the three sub-ontologies the term belongs to. examples: - cellular component - biological process - molecular function - alt_id: + alt_ids: type: array + items: + type: string description: Defines an alternate id for this term. A term may have any number of alternate ids. examples: - - - GO:0019952 - - GO:0050876 - - - GO:0044848 + - ["GO:0019952"] + - ["GO:0050876"] + - ["GO:0044848"] def: - type: string - description: 'The definition of the current term. ' - examples: - - "'The directed movement of a ribosomal subunit from the nucleus into the cytoplasm.' - [GOC:ai]" - - "'Catalysis of the reaction: adenine + H2O = hypoxanthine + NH3.' [EC:3.5.4.2]" - comment: - type: string - description: A comment for this term. + type: ["null", "object"] # some OBO classes have no definition + description: The definition of the current term. + required: + - val + properties: + pred: + type: string + description: The definition predicate + val: + type: string + description: The definition value + examples: + - Any process that modulates the frequency, rate or extent of glycolysis. + xrefs: + type: array + description: A dbxref that describes an analagous term in another vocabulary + items: + type: string + examples: + - ["GOC:go_curators"] + - ["ISBN:0815340729"] + comments: + type: array + items: + type: string + description: Comments for this term. examples: - - This term was made obsolete because it refers to a class of gene products and - a biological process rather than a molecular function. - subset: + - ["This term was made obsolete because it refers to a class of gene products and + a biological process rather than a molecular function."] + subsets: type: array + items: + type: string description: This tag indicates a term subset to which this term belongs. examples: - - - goslim_yeast - - - goslim_chembl - - goslim_metagenomics - - goslim_pir - - goslim_plant - synonym: - type: array + - ["goslim_yeast"] + - ["goslim_chembl"] + - ["goslim_metagenomics"] + - ["goslim_pir"] + - ["goslim_plant"] + synonyms: description: This tag gives a synonym for this term, some xrefs to describe the origins of the synonym, and may indicate a synonym category or scope information. - examples: - - - "'L-methionine porter activity' RELATED []" - - - "'ribonuclease mitochondrial RNA processing complex' EXACT []" - - "'RNase MRP complex' EXACT []" - xref: type: array - description: A dbxref that describes an analagous term in another vocabulary - examples: - - - Wikipedia:Reproduction - - - KEGG_REACTION:R05612 - - RHEA:20836 - examples: - - - GO:0042254 - - - GO:0008104 - - GO:0051019 - is_obsolete: - type: boolean - description: Whether or not this term is obsolete. - examples: [true] - default: false - created_by: - type: string - description: Optional tag added by OBO-Edit to indicate the creator of the term - examples: - - kchris - creation_date: - type: string - description: Optional tag added by OBO-Edit to indicate the creation time and - date of the term - examples: - - '2009-04-28T10:33:25Z' + items: + type: object + required: + - val + properties: + pred: + type: string + description: The synonym predicate + examples: + - hasBroadSynonym + - hasNarrowSynonym + val: + type: string + description: The synonym value + examples: + - regulation of blood angiotensin level + xrefs: + type: array + description: A dbxref that describes an analagous term in another vocabulary + items: + type: string + examples: + - ["GOC:TermGenie"] + xrefs: + description: DBxrefs that describes an analagous term in another vocabulary + type: array + items: + type: object + required: + - val + properties: + pred: + type: string + description: The xref predicate + val: + type: string + description: The xref value + examples: + - EC:2.3.1 + - Reactome:REACT_10010 + xrefs: + type: array + description: A dbxref that describes an analagous term in another vocabulary + items: + type: string + examples: + - ["GOC:TermGenie"] required: - id + - type - name - optional: - - alt_id + - namespace + - alt_ids - def - - comment - - subset - - synonym - - xref - - is_a - - intersection_of - - disjoint_from - - relationship - - is_obsolete - - replaced_by - - consider - - created_by - - creation_date + - comments + - subsets + - synonyms + - xrefs \ No newline at end of file From c66ca3efe4d16a52f149bfc2a2c2675815171cb6 Mon Sep 17 00:00:00 2001 From: Gavin Date: Fri, 13 Sep 2019 15:46:16 -0700 Subject: [PATCH 376/732] Add ENVO schemas Basically a C&P from go with names and examples updated --- spec/schemas/ENVO/ENVO_edges.yaml | 37 ++++++++ spec/schemas/ENVO/ENVO_merges.yaml | 37 ++++++++ spec/schemas/ENVO/ENVO_terms.yaml | 141 +++++++++++++++++++++++++++++ 3 files changed, 215 insertions(+) create mode 100644 spec/schemas/ENVO/ENVO_edges.yaml create mode 100644 spec/schemas/ENVO/ENVO_merges.yaml create mode 100644 spec/schemas/ENVO/ENVO_terms.yaml diff --git a/spec/schemas/ENVO/ENVO_edges.yaml b/spec/schemas/ENVO/ENVO_edges.yaml new file mode 100644 index 00000000..0a666d98 --- /dev/null +++ b/spec/schemas/ENVO/ENVO_edges.yaml @@ -0,0 +1,37 @@ +name: ENVO_edges +type: edge +delta: true + +schema: + "$schema": http://json-schema.org/draft-07/schema# + title: ENVO_edges + type: object + description: A entry for edges in the Environment Ontology (ENVO) hierarchy + properties: + id: + type: string + description: an edge ID, consisting of from::to::type + examples: + - ENVO:0000136::ENVO:0031501::is_a + - ENVO:0000022::ENVO:0051231::is_a + type: + type: string + description: ENVO edge type + examples: + - is_a + - causally_upstream_of_or_within + from: + type: string + description: ENVO id + examples: + - ENVO:0023052 + to: + type: string + title: ENVO id + examples: + - ENVO:0008150 + required: + - id + - type + - from + - to diff --git a/spec/schemas/ENVO/ENVO_merges.yaml b/spec/schemas/ENVO/ENVO_merges.yaml new file mode 100644 index 00000000..b05b013f --- /dev/null +++ b/spec/schemas/ENVO/ENVO_merges.yaml @@ -0,0 +1,37 @@ +name: ENVO_merges +type: edge +delta: true + +schema: + "$schema": http://json-schema.org/draft-07/schema# + title: ENVO_merges + type: object + description: A entry for merge edges in the Enviroment Ontology (ENVO) hierarchy + properties: + id: + type: string + description: an edge ID, consisting of from::to::type + examples: + - ENVO:0000136::ENVO:0031501::consider + - ENVO:0000022::ENVO:0051231::replaced_by + type: + type: string + description: ENVO merge edge type + examples: + - consider + - replaced_by + from: + type: string + description: ENVO id + examples: + - ENVO:0023052 + to: + type: string + title: ENVO id + examples: + - ENVO:0008150 + required: + - id + - type + - from + - to diff --git a/spec/schemas/ENVO/ENVO_terms.yaml b/spec/schemas/ENVO/ENVO_terms.yaml new file mode 100644 index 00000000..73fe587c --- /dev/null +++ b/spec/schemas/ENVO/ENVO_terms.yaml @@ -0,0 +1,141 @@ +name: ENVO_terms +type: vertex +delta: true + +schema: + "$schema": http://json-schema.org/draft-07/schema# + title: ENVO_terms + type: object + description: A entry for vertices in the Environment Ontology (ENVO) hierarchy + properties: + id: + type: string + description: The unique id of the current term. + examples: + - ENVO:0022609 + - ENVO:0044848 + type: + type: string + description: The type of the node. + examples: + - CLASS + - INDIVIDUAL + name: + type: ["null", "string"] # some OBO classes have no label + description: The term name. + examples: + - ice cap dome + - horse manure + namespace: + type: ["null", "string"] # some OBO classes have no namespace + description: The namespace of the term. + examples: + - ENVO + alt_ids: + type: array + items: + type: string + description: Defines an alternate id for this term. A term may have any number + of alternate ids. + examples: + - ["ENVO:0019952"] + - ["ENVO:0050876"] + - ["ENVO:0044848"] + def: + type: ["null", "object"] # some OBO classes have no definition + description: The definition of the current term. + required: + - val + properties: + pred: + type: string + description: The definition predicate + val: + type: string + description: The definition value + examples: + - A natural/cultural feature of outstanding or unique value because of its inherent + rarity, representative of aesthetic qualities or cultural significance. + xrefs: + type: array + description: A dbxref that describes an analagous term in another vocabulary + items: + type: string + examples: + - ["Geonames:feature"] + - ["https://en.wikipedia.org/wiki/Natural_Monument"] + comments: + type: array + items: + type: string + description: Comments for this term. + examples: + - ["This class refers to strictly sealed enclosures such as Biosphere 2 (https://en.wikipedia.org/wiki/Biosphere_2), rather than vivaria which allow matter exchange with external environmental systems."] + subsets: + type: array + items: + type: string + description: This tag indicates a term subset to which this term belongs. + examples: + - ["wwfBiome"] + - ["environmental_hazards"] + synonyms: + description: This tag gives a synonym for this term, some xrefs to describe the + origins of the synonym, and may indicate a synonym category or scope information. + type: array + items: + type: object + required: + - val + properties: + pred: + type: string + description: The synonym predicate + examples: + - hasBroadSynonym + - hasNarrowSynonym + val: + type: string + description: The synonym value + examples: + - HydrothermalVents + xrefs: + type: array + description: A dbxref that describes an analagous term in another vocabulary + items: + type: string + examples: + - ["NASA:earthrealm"] + xrefs: + description: DBxrefs that describes an analagous term in another vocabulary + type: array + items: + type: object + required: + - val + properties: + pred: + type: string + description: The xref predicate + val: + type: string + description: The xref value + examples: + - SPIRE:Soil + - https://en.wikipedia.org/wiki/Soil + xrefs: + type: array + description: A dbxref that describes an analagous term in another vocabulary + items: + type: string + required: + - id + - type + - name + - namespace + - alt_ids + - def + - comments + - subsets + - synonyms + - xrefs \ No newline at end of file From f40b9ea8f73d72544cdfc54931d7a18a0932aa4b Mon Sep 17 00:00:00 2001 From: MrCreosote Date: Mon, 16 Sep 2019 12:09:55 -0700 Subject: [PATCH 377/732] Add ENVO schemas (#94) * GO specs pt2: terms * Add ENVO schemas Basically a C&P from go with names and examples updated --- spec/schemas/ENVO/ENVO_edges.yaml | 37 ++++++++ spec/schemas/ENVO/ENVO_merges.yaml | 37 ++++++++ spec/schemas/ENVO/ENVO_terms.yaml | 141 +++++++++++++++++++++++++++++ 3 files changed, 215 insertions(+) create mode 100644 spec/schemas/ENVO/ENVO_edges.yaml create mode 100644 spec/schemas/ENVO/ENVO_merges.yaml create mode 100644 spec/schemas/ENVO/ENVO_terms.yaml diff --git a/spec/schemas/ENVO/ENVO_edges.yaml b/spec/schemas/ENVO/ENVO_edges.yaml new file mode 100644 index 00000000..0a666d98 --- /dev/null +++ b/spec/schemas/ENVO/ENVO_edges.yaml @@ -0,0 +1,37 @@ +name: ENVO_edges +type: edge +delta: true + +schema: + "$schema": http://json-schema.org/draft-07/schema# + title: ENVO_edges + type: object + description: A entry for edges in the Environment Ontology (ENVO) hierarchy + properties: + id: + type: string + description: an edge ID, consisting of from::to::type + examples: + - ENVO:0000136::ENVO:0031501::is_a + - ENVO:0000022::ENVO:0051231::is_a + type: + type: string + description: ENVO edge type + examples: + - is_a + - causally_upstream_of_or_within + from: + type: string + description: ENVO id + examples: + - ENVO:0023052 + to: + type: string + title: ENVO id + examples: + - ENVO:0008150 + required: + - id + - type + - from + - to diff --git a/spec/schemas/ENVO/ENVO_merges.yaml b/spec/schemas/ENVO/ENVO_merges.yaml new file mode 100644 index 00000000..b05b013f --- /dev/null +++ b/spec/schemas/ENVO/ENVO_merges.yaml @@ -0,0 +1,37 @@ +name: ENVO_merges +type: edge +delta: true + +schema: + "$schema": http://json-schema.org/draft-07/schema# + title: ENVO_merges + type: object + description: A entry for merge edges in the Enviroment Ontology (ENVO) hierarchy + properties: + id: + type: string + description: an edge ID, consisting of from::to::type + examples: + - ENVO:0000136::ENVO:0031501::consider + - ENVO:0000022::ENVO:0051231::replaced_by + type: + type: string + description: ENVO merge edge type + examples: + - consider + - replaced_by + from: + type: string + description: ENVO id + examples: + - ENVO:0023052 + to: + type: string + title: ENVO id + examples: + - ENVO:0008150 + required: + - id + - type + - from + - to diff --git a/spec/schemas/ENVO/ENVO_terms.yaml b/spec/schemas/ENVO/ENVO_terms.yaml new file mode 100644 index 00000000..73fe587c --- /dev/null +++ b/spec/schemas/ENVO/ENVO_terms.yaml @@ -0,0 +1,141 @@ +name: ENVO_terms +type: vertex +delta: true + +schema: + "$schema": http://json-schema.org/draft-07/schema# + title: ENVO_terms + type: object + description: A entry for vertices in the Environment Ontology (ENVO) hierarchy + properties: + id: + type: string + description: The unique id of the current term. + examples: + - ENVO:0022609 + - ENVO:0044848 + type: + type: string + description: The type of the node. + examples: + - CLASS + - INDIVIDUAL + name: + type: ["null", "string"] # some OBO classes have no label + description: The term name. + examples: + - ice cap dome + - horse manure + namespace: + type: ["null", "string"] # some OBO classes have no namespace + description: The namespace of the term. + examples: + - ENVO + alt_ids: + type: array + items: + type: string + description: Defines an alternate id for this term. A term may have any number + of alternate ids. + examples: + - ["ENVO:0019952"] + - ["ENVO:0050876"] + - ["ENVO:0044848"] + def: + type: ["null", "object"] # some OBO classes have no definition + description: The definition of the current term. + required: + - val + properties: + pred: + type: string + description: The definition predicate + val: + type: string + description: The definition value + examples: + - A natural/cultural feature of outstanding or unique value because of its inherent + rarity, representative of aesthetic qualities or cultural significance. + xrefs: + type: array + description: A dbxref that describes an analagous term in another vocabulary + items: + type: string + examples: + - ["Geonames:feature"] + - ["https://en.wikipedia.org/wiki/Natural_Monument"] + comments: + type: array + items: + type: string + description: Comments for this term. + examples: + - ["This class refers to strictly sealed enclosures such as Biosphere 2 (https://en.wikipedia.org/wiki/Biosphere_2), rather than vivaria which allow matter exchange with external environmental systems."] + subsets: + type: array + items: + type: string + description: This tag indicates a term subset to which this term belongs. + examples: + - ["wwfBiome"] + - ["environmental_hazards"] + synonyms: + description: This tag gives a synonym for this term, some xrefs to describe the + origins of the synonym, and may indicate a synonym category or scope information. + type: array + items: + type: object + required: + - val + properties: + pred: + type: string + description: The synonym predicate + examples: + - hasBroadSynonym + - hasNarrowSynonym + val: + type: string + description: The synonym value + examples: + - HydrothermalVents + xrefs: + type: array + description: A dbxref that describes an analagous term in another vocabulary + items: + type: string + examples: + - ["NASA:earthrealm"] + xrefs: + description: DBxrefs that describes an analagous term in another vocabulary + type: array + items: + type: object + required: + - val + properties: + pred: + type: string + description: The xref predicate + val: + type: string + description: The xref value + examples: + - SPIRE:Soil + - https://en.wikipedia.org/wiki/Soil + xrefs: + type: array + description: A dbxref that describes an analagous term in another vocabulary + items: + type: string + required: + - id + - type + - name + - namespace + - alt_ids + - def + - comments + - subsets + - synonyms + - xrefs \ No newline at end of file From 117b46a0925c3d2c11da5313b1dfca079cf84596 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 17 Sep 2019 11:53:18 -0700 Subject: [PATCH 378/732] Update spec release cache --- api/src/test/spec_release/spec.tar.gz | Bin 17295 -> 18389 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/api/src/test/spec_release/spec.tar.gz b/api/src/test/spec_release/spec.tar.gz index bac0d852fd145070bd12ddd112fccfdb807f9dbe..0a68246a95e8a482e629afcb49791528e63cc096 100644 GIT binary patch literal 18389 zcmW(*byO8k8>YLvJEgn1bV!2&(k0#9mz0zS>5xWgr14VH-6fsUAbq*}`TO>q*}ryn z-*fhvd7l{C1T?t+Ux;T?PHyX>t*>Y1vi>A0LCd~SU&rEhcYuNi~QE5OgAlt8uCkE|ZK)v-AXUmr#H18%NTjAl?jIvNr>vI!^&*+K%I-^DDP z`~HHYqyhco_jyX+=KtJ@_XPGJKYjMCTn!ZnK{3=FJ;3=_=v9AHV2xt%m)xn>;(`3Zf~a=x$pwyw_MVY_wmX75!u(>^P3{EWcB zC1l59D1VcGm-m8*V%sf!=?bXs1wOkrDBm~60ey2SV}M!PI{PCS_hhK`(5BJbHfz;w zG4Q?X@vW`{^e&(CFY>HLHuV7AVog`}T7x8B2OF0RhWia_n|j^UO1>PSnz+bYh`OKw(Kb-)JHp3I{U`ucaje|r2~n~V+JIulNVZaKFEoksu< zDHqw3@UJ1BGvaKSq4diF1?i%P==&Rn!m}&X0^gCFEq~c>^6A-CjG+k$SrQ%}w#ccE z<14x>3(_O*qkdS)I;>H#`k_16&4z!2NzRwPx^T6RD}1U=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;W>pxqz)N7YyyG*~}kvkYzb5N+aeb zcFx~W>9c@`DUSkZ^lm9`wBtFml9;!7z9UMGf8`WiTg5%6r2U8=)5b zG;Rh*D*x2XCMzGtMab1w;6PR)&TdUlZaWlygvmf?8!b7l-GOJJFWA$T&`k0o!ZTdmM#-fa1bMq#C{6|y} zzU~sD%BNG-!9dwOWH;9ecA46+qNtV-yKUG)^Rgx^+433b(uh0%RYZFng1*G&NQJ`thQ?l`OM_0ke<%EtGHSgCA zwY3oy_em|RFQbXG1Ovzh?hoIaK}uuTY%mh%%W{sWVXn7Aux!Gc#JKsI4~cdKaV*(E zFnj~ z^u57W_&+}urj7y5v;Xu``5(Gwr>pZn)B%kDvwWoSQZfS&Iw^T~85TNOiks8DF>|{fEdHj{XQq zNAV$}m>1;G|88%Xs{hy>c6Iz;9Z>rGx9R}+{p)<|_Sr*Pq$KsOQUG9WT3G!`*qWHS zwVhyoMuI3%f3Wy+7qvvu;V^i2dN)d+XkR~lgatxVOB{j*n`YrpR&#<9w8S#n`cp_9 zW&86v`fPFEC6Y81iH#F5RSK}-p*4!gnr!VeOYa0&r+f0#6%8Z{G!Endn^&(29lvTa zo{Z+wL3;uAK^Si<`gQlK!UEh|_)Ph*AugnlOu(?_Bt}VIZfp(b2C=vSx=ZNEme+~B zjV7u1Q5QoUfg&AMW?kVOi}Mkq54$?Aa!{F!9pZP2eJyS6`1JDX^bCzii2b4M(I-B9 zy!>ew&tem8X7~lR@EH(@$h~o37sq31u(Zl}AbWr4SQ!l(G-%MEL4yVj8Z>Coph1HM g4H`6P(4aws1`QfCXwaZR!{dPe588WKQvj#}0LanA=l}o! From b64a9736d7fb09589c168107a06b36ec3faeecff Mon Sep 17 00:00:00 2001 From: Gavin Date: Tue, 17 Sep 2019 12:12:04 -0700 Subject: [PATCH 379/732] Add feature -> Go term edge collection --- .../schemas/ws/ws_feature_has_GO_annotation.yaml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 spec/schemas/ws/ws_feature_has_GO_annotation.yaml diff --git a/spec/schemas/ws/ws_feature_has_GO_annotation.yaml b/spec/schemas/ws/ws_feature_has_GO_annotation.yaml new file mode 100644 index 00000000..4f068b8f --- /dev/null +++ b/spec/schemas/ws/ws_feature_has_GO_annotation.yaml @@ -0,0 +1,16 @@ +name: ws_feature_has_GO_annotation +type: edge +schema: + "$schema": http://json-schema.org/draft-07/schema# + type: object + description: A feature in a workspace genome has a Gene Ontology annotation. + required: [_from, _to] + properties: + _from: + type: string + examples: ['ws_genome_feature/75:82:3_RSP_4039'] + description: The unique, permanent ID of a genome feature in a version of a workspace object. + _to: + type: string + examples: ['GO_terms/GO:0000002_v2018-03-06'] + description: A Gene Ontology term. \ No newline at end of file From dc6074edf9fefd6f5670af2035efbc8477c35b50 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 17 Sep 2019 12:42:20 -0700 Subject: [PATCH 380/732] Update cached spec release --- api/src/test/spec_release/spec.tar.gz | Bin 18389 -> 18574 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/api/src/test/spec_release/spec.tar.gz b/api/src/test/spec_release/spec.tar.gz index 0a68246a95e8a482e629afcb49791528e63cc096..ac5fc026f8e554822de131c5d5ecca7949deaf46 100644 GIT binary patch literal 18574 zcmXV0b8ueI*N<)6ZeyEm?50f`+cuxrM&qPO8r!xSG;VC$&Xec9{r=|NnY(}N+`0G6 z&YttZS;`nBsQ(SvbJ2I#)wY)R%wDOKZf@%>co+n!38f=tF{VFu*=BMbZmvL0_yE;h!@1?%L%@=?J$k zpUfg6(0s|U<}KbV^LZ;UiwP8nhkN z8yuwryrUVNUZ$TNiJXZ&6;ZF}Q(%?t-m zO^)Xi4sNMVhwleY9i^rGi#VwR{Jy^TQ89p-3Yf!KFv{d;6|AJqXwgY zARg%P$CNZj!*TeL%3zG}TKkS`Mg0M87)h^qmrt$C{2WjOob2AZ0^nDF?yk3;`Psi$ zHUK!`N$hf2`SipZc%GnIJbc&l3@t@5aD=_nFtZ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=;Y$^Gkky}d Date: Wed, 18 Sep 2019 13:20:50 -0400 Subject: [PATCH 381/732] update Go queries, add PRUNE step --- spec/stored_queries/GO/GO_get_ancestors.yaml | 7 +++--- spec/stored_queries/GO/GO_get_children.yaml | 2 +- .../stored_queries/GO/GO_get_descendants.yaml | 7 +++--- .../GO/GO_get_hierarchicalAncestors.yaml | 23 +++++-------------- .../GO/GO_get_hierarchicalChildren.yaml | 22 ++++-------------- .../GO/GO_get_hierarchicalDescendants.yaml | 23 +++++-------------- .../GO/GO_get_hierarchicalParents.yaml | 22 ++++-------------- spec/stored_queries/GO/GO_get_parents.yaml | 2 +- spec/stored_queries/GO/GO_get_related.yaml | 4 +--- spec/stored_queries/GO/GO_get_siblings.yaml | 8 +++---- 10 files changed, 37 insertions(+), 83 deletions(-) diff --git a/spec/stored_queries/GO/GO_get_ancestors.yaml b/spec/stored_queries/GO/GO_get_ancestors.yaml index 42a52719..b6a39285 100644 --- a/spec/stored_queries/GO/GO_get_ancestors.yaml +++ b/spec/stored_queries/GO/GO_get_ancestors.yaml @@ -28,9 +28,10 @@ query: | FILTER t.id == @id FILTER t.created <= @ts AND t.expired >= @ts limit 1 - FOR v, e IN 1..100 OUTBOUND t GO_edges - FILTER e.type == "is_a" - FILTER e.created <= @ts AND e.expired >= @ts + FOR v, e, p IN 1..100 OUTBOUND t GO_edges + PRUNE e != NULL AND (e.created > @ts OR e.expired < @ts) + FILTER p.edges[*].created ALL <= @ts AND p.edges[*].expired ALL >= @ts + FILTER p.edges[*].type ALL == "is_a" SORT v.id ASC LIMIT @offset, @limit RETURN {term: v, edge: e} diff --git a/spec/stored_queries/GO/GO_get_children.yaml b/spec/stored_queries/GO/GO_get_children.yaml index 6cdf52d7..93720e80 100644 --- a/spec/stored_queries/GO/GO_get_children.yaml +++ b/spec/stored_queries/GO/GO_get_children.yaml @@ -29,8 +29,8 @@ query: | FILTER t.created <= @ts AND t.expired >= @ts limit 1 FOR v, e IN 1..1 INBOUND t GO_edges - FILTER e.type == "is_a" FILTER e.created <= @ts AND e.expired >= @ts + FILTER e.type == "is_a" SORT v.id ASC LIMIT @offset, @limit RETURN {term: v, edge: e} diff --git a/spec/stored_queries/GO/GO_get_descendants.yaml b/spec/stored_queries/GO/GO_get_descendants.yaml index 8f3f25dc..35a21565 100644 --- a/spec/stored_queries/GO/GO_get_descendants.yaml +++ b/spec/stored_queries/GO/GO_get_descendants.yaml @@ -27,9 +27,10 @@ query: | FILTER t.id == @id FILTER t.created <= @ts AND t.expired >= @ts limit 1 - FOR v, e IN 1..100 INBOUND t GO_edges - FILTER e.type == "is_a" - FILTER e.created <= @ts AND e.expired >= @ts + FOR v, e, p IN 1..100 INBOUND t GO_edges + PRUNE e != NULL AND (e.created > @ts OR e.expired < @ts) + FILTER p.edges[*].created ALL <= @ts AND p.edges[*].expired ALL >= @ts + FILTER p.edges[*].type ALL == "is_a" SORT v._key ASC LIMIT @offset, @limit RETURN {term: v, edge: e} diff --git a/spec/stored_queries/GO/GO_get_hierarchicalAncestors.yaml b/spec/stored_queries/GO/GO_get_hierarchicalAncestors.yaml index 3d9cfe50..3bef44de 100644 --- a/spec/stored_queries/GO/GO_get_hierarchicalAncestors.yaml +++ b/spec/stored_queries/GO/GO_get_hierarchicalAncestors.yaml @@ -31,21 +31,10 @@ query: | FILTER t.id == @id FILTER t.created <= @ts AND t.expired >= @ts limit 1 - LET results1 = ( - FOR v_relationship, e_relationship IN 1..100 OUTBOUND t GO_edges_relationship - FILTER e_relationship.relationship_type == 'part_of' - OR e_relationship.relationship_type == 'has_part' - OR e_relationship.relationship_type == 'occurs_in' - FILTER e_relationship.created <= @ts AND e_relationship.expired >= @ts - RETURN {term: v_relationship, edge: e_relationship} - ) - LET results2 = ( - FOR v_isa, e_isa IN 1..100 OUTBOUND t GO_edges - FILTER e_isa.type == "is_a" - FILTER e_isa.created <= @ts AND e_isa.expired >= @ts - RETURN {term: v_isa, edge: e_isa} - ) - FOR x IN UNION(results1, results2) - SORT x.id ASC + FOR v, e, p IN 1..100 OUTBOUND t GO_edges + PRUNE e != NULL AND (e.created > @ts OR e.expired < @ts) + FILTER p.edges[*].created ALL <= @ts AND p.edges[*].expired ALL >= @ts + FILTER p.edges[*].type ALL != NULL + SORT v.id ASC LIMIT @offset, @limit - RETURN DISTINCT x + RETURN {term: v, edge: e} diff --git a/spec/stored_queries/GO/GO_get_hierarchicalChildren.yaml b/spec/stored_queries/GO/GO_get_hierarchicalChildren.yaml index 5eaa142d..af8f731c 100644 --- a/spec/stored_queries/GO/GO_get_hierarchicalChildren.yaml +++ b/spec/stored_queries/GO/GO_get_hierarchicalChildren.yaml @@ -27,21 +27,9 @@ query: | FILTER t.id == @id FILTER t.created <= @ts AND t.expired >= @ts limit 1 - LET results1 = ( - FOR v_relationship, e_relationship IN 1..1 INBOUND t GO_edges_relationship - FILTER e_relationship.relationship_type == 'part_of' - OR e_relationship.relationship_type == 'has_part' - OR e_relationship.relationship_type == 'occurs_in' - FILTER e_relationship.created <= @ts AND e_relationship.expired >= @ts - RETURN {term: v_relationship, edge: e_relationship} - ) - LET results2 = ( - FOR v_isa, e_isa IN 1..1 INBOUND t GO_edges - FILTER e_isa.type == "is_a" - FILTER e_isa.created <= @ts AND e_isa.expired >= @ts - RETURN {term: v_isa, edge: e_isa} - ) - FOR x IN UNION(results1, results2) - SORT x.id ASC + FOR v, e IN 1..1 INBOUND t GO_edges + FILTER e.created <= @ts AND e.expired >= @ts + FILTER e.type != NULL + SORT v.id ASC LIMIT @offset, @limit - RETURN DISTINCT x + RETURN {term: v, edge: e} diff --git a/spec/stored_queries/GO/GO_get_hierarchicalDescendants.yaml b/spec/stored_queries/GO/GO_get_hierarchicalDescendants.yaml index 845d157e..06c113a2 100644 --- a/spec/stored_queries/GO/GO_get_hierarchicalDescendants.yaml +++ b/spec/stored_queries/GO/GO_get_hierarchicalDescendants.yaml @@ -30,21 +30,10 @@ query: | FILTER t.id == @id FILTER t.created <= @ts AND t.expired >= @ts limit 1 - LET results1 = ( - FOR v_relationship, e_relationship IN 1..100 INBOUND t GO_edges_relationship - FILTER e_relationship.relationship_type == 'part_of' - OR e_relationship.relationship_type == 'has_part' - OR e_relationship.relationship_type == 'occurs_in' - FILTER e_relationship.created <= @ts AND e_relationship.expired >= @ts - RETURN {term: v_relationship, edge: e_relationship} - ) - LET results2 = ( - FOR v_isa, e_isa IN 1..100 INBOUND t GO_edges - FILTER e_isa.type == "is_a" - FILTER e_isa.created <= @ts AND e_isa.expired >= @ts - RETURN {term: v_isa, edge: e_isa} - ) - FOR x IN UNION(results1, results2) - SORT x.id ASC + FOR v, e, p IN 1..100 INBOUND t GO_edges + PRUNE e != NULL AND (e.created > @ts OR e.expired < @ts) + FILTER p.edges[*].created ALL <= @ts AND p.edges[*].expired ALL >= @ts + FILTER p.edges[*].type ALL != NULL + SORT v.id ASC LIMIT @offset, @limit - RETURN DISTINCT x + RETURN {term: v, edge: e} diff --git a/spec/stored_queries/GO/GO_get_hierarchicalParents.yaml b/spec/stored_queries/GO/GO_get_hierarchicalParents.yaml index 7c0c14bd..f8621c6f 100644 --- a/spec/stored_queries/GO/GO_get_hierarchicalParents.yaml +++ b/spec/stored_queries/GO/GO_get_hierarchicalParents.yaml @@ -31,21 +31,9 @@ query: | FILTER t.id == @id FILTER t.created <= @ts AND t.expired >= @ts limit 1 - LET results1 = ( - FOR v_relationship, e_relationship IN 1..1 OUTBOUND t GO_edges_relationship - FILTER e_relationship.relationship_type == 'part_of' - OR e_relationship.relationship_type == 'has_part' - OR e_relationship.relationship_type == 'occurs_in' - FILTER e_relationship.created <= @ts AND e_relationship.expired >= @ts - RETURN {term: v_relationship, edge: e_relationship} - ) - LET results2 = ( - FOR v_isa, e_isa IN 1..1 OUTBOUND t GO_edges - FILTER e_isa.type == "is_a" - FILTER e_isa.created <= @ts AND e_isa.expired >= @ts - RETURN {term: v_isa, edge: e_isa} - ) - FOR x IN UNION(results1, results2) - SORT x.id ASC + FOR v, e IN 1..1 OUTBOUND t GO_edges + FILTER e.created <= @ts AND e.expired >= @ts + FILTER e.type != NULL + SORT v.id ASC LIMIT @offset, @limit - RETURN DISTINCT x + RETURN {term: v, edge: e} diff --git a/spec/stored_queries/GO/GO_get_parents.yaml b/spec/stored_queries/GO/GO_get_parents.yaml index ca6c6326..ec63c4eb 100644 --- a/spec/stored_queries/GO/GO_get_parents.yaml +++ b/spec/stored_queries/GO/GO_get_parents.yaml @@ -29,8 +29,8 @@ query: | FILTER t.created <= @ts AND t.expired >= @ts limit 1 FOR v, e IN 1..1 OUTBOUND t GO_edges - FILTER e.type == "is_a" FILTER e.created <= @ts AND e.expired >= @ts + FILTER e.type == "is_a" SORT v.id ASC LIMIT @offset, @limit RETURN {term: v, edge: e} diff --git a/spec/stored_queries/GO/GO_get_related.yaml b/spec/stored_queries/GO/GO_get_related.yaml index a2fbff20..ceee04e4 100644 --- a/spec/stored_queries/GO/GO_get_related.yaml +++ b/spec/stored_queries/GO/GO_get_related.yaml @@ -27,9 +27,7 @@ query: | FILTER t.id == @id FILTER t.created <= @ts AND t.expired >= @ts limit 1 - FOR v, e IN 1 ANY t GO_edges, GO_edges_relationship - FILTER e.type == "is_a" - OR e.relationship_type != null + FOR v, e IN 1 ANY t GO_edges FILTER e.created <= @ts AND e.expired >= @ts SORT v.id ASC LIMIT @offset, @limit diff --git a/spec/stored_queries/GO/GO_get_siblings.yaml b/spec/stored_queries/GO/GO_get_siblings.yaml index f80ba3eb..679af15a 100644 --- a/spec/stored_queries/GO/GO_get_siblings.yaml +++ b/spec/stored_queries/GO/GO_get_siblings.yaml @@ -28,12 +28,12 @@ query: | FILTER t.created <= @ts AND t.expired >= @ts limit 1 FOR v_parent, e_parent IN 1..1 OUTBOUND t GO_edges - FILTER e_parent.type == "is_a" FILTER e_parent.created <= @ts AND e_parent.expired >= @ts - FOR v_child, e_child in 1..1 INBOUND e_parent._to GO_edges - FILTER e_child._from != t._id - FILTER e_child.type == "is_a" + FILTER e_parent.type == "is_a" + FOR v_child, e_child in 1..1 INBOUND v_parent GO_edges FILTER e_child.created <= @ts AND e_child.expired >= @ts + FILTER e_child.type == "is_a" + FILTER v_child != t SORT v_child.id ASC LIMIT @offset, @limit RETURN v_child.id From 4df8e514b137b96cec6493e01e514f1ce8fa20c8 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 18 Sep 2019 17:29:25 -0700 Subject: [PATCH 382/732] Add explicit field-name selection for bulk result ncbi taxa queries (#96) --- .../ncbi_taxon_get_associated_ws_objects.yaml | 14 ++++++++-- .../ncbi_tax/ncbi_taxon_get_children.yaml | 7 ++++- .../ncbi_taxon_get_children_cursor.yaml | 7 ++++- .../ncbi_tax/ncbi_taxon_get_lineage.yaml | 7 ++++- .../ncbi_tax/ncbi_taxon_get_siblings.yaml | 10 +++++-- .../ncbi_tax/ncbi_taxon_search_sci_name.yaml | 7 ++++- spec/test/stored_queries/test_ncbi_tax.py | 28 ++++++++++++++----- 7 files changed, 64 insertions(+), 16 deletions(-) diff --git a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_associated_ws_objects.yaml b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_associated_ws_objects.yaml index 19136bbe..3daa1c1e 100644 --- a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_associated_ws_objects.yaml +++ b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_associated_ws_objects.yaml @@ -23,6 +23,16 @@ params: ts: type: integer title: Versioning timestamp + select_obj: + type: array + items: {type: string} + title: WS obj fields to keep in the results + default: [] + select_edge: + type: array + items: {type: string} + description: Taxon edge fields to keep in the results + default: [] query_prefix: WITH ws_object_version query: | let count = COUNT( @@ -42,8 +52,8 @@ query: | filter obj.is_public or obj.workspace_id IN ws_ids limit @offset, @limit return { - ws_obj: UNSET(obj, "_key", "_rev"), - edge: UNSET(e, "_key", "_from", "_to", "_rev") + ws_obj: KEEP(obj, @select_obj), + edge: KEEP(e, @select_edge) } ) return {results, total_count: count} diff --git a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_children.yaml b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_children.yaml index d3cc30c3..718ee85e 100644 --- a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_children.yaml +++ b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_children.yaml @@ -25,6 +25,11 @@ params: ts: type: integer title: Versioning timestamp + select: + type: array + items: {type: string} + description: Taxon fields to keep in the results + default: [] query: | // Fetch the child IDs using the edge attributes let children = ( @@ -47,6 +52,6 @@ query: | for tax in filtered sort tax.scientific_name asc limit @offset, @limit - return tax + return KEEP(tax, @select) ) return {total_count: COUNT(filtered), results: results} diff --git a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_children_cursor.yaml b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_children_cursor.yaml index 057f0c15..189addbf 100644 --- a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_children_cursor.yaml +++ b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_children_cursor.yaml @@ -11,10 +11,15 @@ params: ts: type: integer title: Versioning timestamp + select: + type: array + items: {type: string} + description: Taxon fields to keep in the results + default: [] query: | for tax in ncbi_taxon filter tax.id == @id filter tax.created <= @ts AND tax.expired >= @ts limit 1 for child in 1..1 inbound tax ncbi_child_of_taxon - return tax + return KEEP(tax, @select) diff --git a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_lineage.yaml b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_lineage.yaml index b2885751..e25b88e2 100644 --- a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_lineage.yaml +++ b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_lineage.yaml @@ -12,6 +12,11 @@ params: ts: type: integer title: Versioning timestamp + select: + type: array + items: {type: string} + description: Taxon fields to keep in the results + default: [] query: | let ps = ( for t in ncbi_taxon @@ -21,7 +26,7 @@ query: | for p, e in 1..10 outbound t ncbi_child_of_taxon options {bfs: true} filter p.created <= @ts AND p.expired >= @ts - return distinct p + return distinct KEEP(p, @select) ) // doing return reverse(ps) returns an array of an array for some reason, // which we don't want diff --git a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_siblings.yaml b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_siblings.yaml index 72533b2a..f0741c6b 100644 --- a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_siblings.yaml +++ b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_siblings.yaml @@ -22,10 +22,14 @@ params: ts: type: integer title: Versioning timestamp + select: + type: array + items: {type: string} + description: Taxon fields to keep in the results + default: [] query: | // Fetch the siblings - let siblings = ( - for t in ncbi_taxon + let siblings = ( for t in ncbi_taxon filter t.id == @id filter t.created <= @ts AND t.expired >= @ts limit 1 @@ -41,6 +45,6 @@ query: | let limited = ( for tax in siblings limit @offset, @limit - return tax + return KEEP(tax, @select) ) return {total_count: COUNT(siblings), results: limited} diff --git a/spec/stored_queries/ncbi_tax/ncbi_taxon_search_sci_name.yaml b/spec/stored_queries/ncbi_tax/ncbi_taxon_search_sci_name.yaml index 2a047917..0e0ee225 100644 --- a/spec/stored_queries/ncbi_tax/ncbi_taxon_search_sci_name.yaml +++ b/spec/stored_queries/ncbi_tax/ncbi_taxon_search_sci_name.yaml @@ -20,6 +20,11 @@ params: ts: type: integer title: Versioning timestamp + select: + type: array + items: {type: string} + description: Taxon fields to keep in the results + default: [] query: | // Search using the fulltext index on scientific_name // Don't limit the results yet so we can get the total_count below @@ -33,6 +38,6 @@ query: | let limited = ( for r in results limit @offset, @limit - return r + return KEEP(r, @select) ) return {results: limited, total_count: COUNT(results)} diff --git a/spec/test/stored_queries/test_ncbi_tax.py b/spec/test/stored_queries/test_ncbi_tax.py index de759356..deeaf396 100644 --- a/spec/test/stored_queries/test_ncbi_tax.py +++ b/spec/test/stored_queries/test_ncbi_tax.py @@ -95,7 +95,7 @@ def test_get_lineage_valid(self): resp = requests.post( _CONF['re_api_url'] + '/api/v1/query_results', params={'stored_query': 'ncbi_taxon_get_lineage'}, - data=json.dumps({'ts': _NOW, 'id': '7'}), + data=json.dumps({'ts': _NOW, 'id': '7', 'select': ['rank', 'scientific_name']}), ).json() self.assertEqual(resp['count'], 2) ranks = [r['rank'] for r in resp['results']] @@ -108,7 +108,12 @@ def test_get_children(self): resp = requests.post( _CONF['re_api_url'] + '/api/v1/query_results', params={'stored_query': 'ncbi_taxon_get_children'}, - data=json.dumps({'id': '1', 'ts': _NOW, 'search_text': 'firmicutes,|proteobacteria'}), + data=json.dumps({ + 'id': '1', + 'ts': _NOW, + 'search_text': 'firmicutes,|proteobacteria', + 'select': ['rank', 'scientific_name'] + }), ).json() result = resp['results'][0] self.assertEqual(result['total_count'], 2) @@ -128,10 +133,15 @@ def test_get_children_cursor(self): def test_siblings_valid(self): """Test a valid query for siblings.""" + # Querying from "Alphaproteobacteria" resp = requests.post( _CONF['re_api_url'] + '/api/v1/query_results', params={'stored_query': 'ncbi_taxon_get_siblings'}, - data=json.dumps({'ts': _NOW, 'id': '5'}), # Querying from "Alphaproteobacteria" + data=json.dumps({ + 'ts': _NOW, + 'id': '5', + 'select': ['rank', 'scientific_name'] + }) ).json() result = resp['results'][0] self.assertEqual(result['total_count'], 2) @@ -163,7 +173,7 @@ def test_search_sciname_prefix(self): resp = requests.post( _CONF['re_api_url'] + '/api/v1/query_results', params={'stored_query': 'ncbi_taxon_search_sci_name'}, - data=json.dumps({'ts': _NOW, 'search_text': 'prefix:bact'}), + data=json.dumps({'ts': _NOW, 'search_text': 'prefix:bact', 'select': ['scientific_name']}), ).json() result = resp['results'][0] self.assertEqual(result['total_count'], 1) @@ -203,7 +213,11 @@ def test_search_sciname_more_complicated(self): resp = requests.post( _CONF['re_api_url'] + '/api/v1/query_results', params={'stored_query': 'ncbi_taxon_search_sci_name'}, - data=json.dumps({'ts': _NOW, 'search_text': "prefix:gamma,|prefix:alpha,|prefix:delta"}) + data=json.dumps({ + 'ts': _NOW, + 'search_text': "prefix:gamma,|prefix:alpha,|prefix:delta", + 'select': ['scientific_name'], + }) ).json() result = resp['results'][0] self.assertEqual(result['total_count'], 3) @@ -238,7 +252,7 @@ def test_fetch_taxon(self): data=json.dumps({'ts': _NOW, 'id': '1'}) ).json() self.assertEqual(resp['count'], 1) - self.assertEqual(resp['results'][0]['_id'], 'ncbi_taxon/1') + self.assertEqual(resp['results'][0]['id'], '1') def test_get_associated_objs(self): """ @@ -248,7 +262,7 @@ def test_get_associated_objs(self): resp = requests.post( _CONF['re_api_url'] + '/api/v1/query_results', params={'stored_query': 'ncbi_taxon_get_associated_ws_objects'}, - data=json.dumps({'ts': _NOW, 'taxon_id': '1'}), + data=json.dumps({'ts': _NOW, 'taxon_id': '1', 'select_obj': ['_id'], 'select_edge': ['assigned_by']}), ).json() self.assertEqual(resp['count'], 1) results = resp['results'][0] From b48e49bdf8240b34e974967a91806db64676cfae Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 18 Sep 2019 17:41:43 -0700 Subject: [PATCH 383/732] Remove GO_test schemas (#97) --- .../GO_test/GO_test_edges_disjoint_from.yaml | 29 ----- .../GO_test_edges_intersection_of.yaml | 39 ------- spec/schemas/GO_test/GO_test_edges_isa.yaml | 29 ----- .../GO_test/GO_test_edges_relationship.yaml | 37 ------ spec/schemas/GO_test/GO_test_term.yaml | 107 ------------------ 5 files changed, 241 deletions(-) delete mode 100644 spec/schemas/GO_test/GO_test_edges_disjoint_from.yaml delete mode 100644 spec/schemas/GO_test/GO_test_edges_intersection_of.yaml delete mode 100644 spec/schemas/GO_test/GO_test_edges_isa.yaml delete mode 100644 spec/schemas/GO_test/GO_test_edges_relationship.yaml delete mode 100644 spec/schemas/GO_test/GO_test_term.yaml diff --git a/spec/schemas/GO_test/GO_test_edges_disjoint_from.yaml b/spec/schemas/GO_test/GO_test_edges_disjoint_from.yaml deleted file mode 100644 index 4caa429b..00000000 --- a/spec/schemas/GO_test/GO_test_edges_disjoint_from.yaml +++ /dev/null @@ -1,29 +0,0 @@ ---- -name: GO_edges_disjoint_from -type: edge -schema: - "$schema": http://json-schema.org/draft-07/schema# - title: GO_edges_disjoint_from - type: object - description: A entry for disjoint_from edges in the Gene Ontology (GO) hierarchy - properties: - _key: - type: string - description: GO id - examples: - - GO:0000136__GO:0031501__disjoint_from - - GO:0000022__GO:0051231__disjoint_from - _from: - type: string - description: GO id - examples: - - GO:0023052 - _to: - type: string - title: GO id - examples: - - GO:0008150 - required: - - _key - - _from - - _to diff --git a/spec/schemas/GO_test/GO_test_edges_intersection_of.yaml b/spec/schemas/GO_test/GO_test_edges_intersection_of.yaml deleted file mode 100644 index 77ac7d44..00000000 --- a/spec/schemas/GO_test/GO_test_edges_intersection_of.yaml +++ /dev/null @@ -1,39 +0,0 @@ ---- -name: GO_edges_intersection_of -type: edge -schema: - "$schema": http://json-schema.org/draft-07/schema# - title: GO_edges_intersection_of - type: object - description: A entry for intersection_of edges in the Gene Ontology (GO) hierarchy - properties: - _key: - type: string - description: GO id - examples: - - GO:0000136__GO:0031501__intersection_of - - GO:0000132__GO:0000278__intersection_of:regulates - _from: - type: string - description: GO id - examples: - - GO:0023052 - _to: - type: string - title: GO id - examples: - - GO:0008150 - intersection_type: - type: string - title: Intersection type - examples: - - '' - - part_of - - occurs_in - - regulates - - has_part - required: - - _key - - _from - - _to - - intersection_type diff --git a/spec/schemas/GO_test/GO_test_edges_isa.yaml b/spec/schemas/GO_test/GO_test_edges_isa.yaml deleted file mode 100644 index 189837b0..00000000 --- a/spec/schemas/GO_test/GO_test_edges_isa.yaml +++ /dev/null @@ -1,29 +0,0 @@ ---- -name: GO_edges_isa -type: edge -schema: - "$schema": http://json-schema.org/draft-07/schema# - title: GO_edges_isa - type: object - description: A entry for is_a edges in the Gene Ontology (GO) hierarchy - properties: - _key: - type: string - description: GO id - examples: - - GO:0000136__GO:0031501__is_a - - GO:0000022__GO:0051231__is_a - _from: - type: string - description: GO id - examples: - - GO:0023052 - _to: - type: string - title: GO id - examples: - - GO:0008150 - required: - - _key - - _from - - _to diff --git a/spec/schemas/GO_test/GO_test_edges_relationship.yaml b/spec/schemas/GO_test/GO_test_edges_relationship.yaml deleted file mode 100644 index d4d8a971..00000000 --- a/spec/schemas/GO_test/GO_test_edges_relationship.yaml +++ /dev/null @@ -1,37 +0,0 @@ ---- -name: GO_edges_relationship -type: edge -schema: - "$schema": http://json-schema.org/draft-07/schema# - title: GO_edges_relationship - type: object - description: A entry for relationship edges in the Gene Ontology (GO) hierarchy - properties: - _key: - type: string - description: GO id - examples: - - GO:0000136__GO:0031501__relationship:part_of - - GO:0000132__GO:0000278__relationship:has_part - _from: - type: string - description: GO id - examples: - - GO:0023052 - _to: - type: string - title: GO id - examples: - - GO:0008150 - relationship_type: - type: string - title: Relationship type - examples: - - occurs_in - - has_part - - part_of - required: - - _key - - _from - - _to - - relationship_type diff --git a/spec/schemas/GO_test/GO_test_term.yaml b/spec/schemas/GO_test/GO_test_term.yaml deleted file mode 100644 index b98861c9..00000000 --- a/spec/schemas/GO_test/GO_test_term.yaml +++ /dev/null @@ -1,107 +0,0 @@ ---- -name: GO_terms -type: vertex -schema: - "$schema": http://json-schema.org/draft-07/schema# - title: GO_terms - type: object - description: A entry for vertices in the Gene Ontology (GO) hierarchy - properties: - _key: - type: string - description: The unique id of the current term. - examples: - - GO:0022609 - - GO:0044848 - name: - type: string - description: The term name. Any term may have only one name defined. - examples: - - mitochondrial genome maintenance - - reproduction - namespace: - type: string - description: Denotes which of the three sub-ontologies the term belongs to. - examples: - - cellular component - - biological process - - molecular function - alt_id: - type: array - description: Defines an alternate id for this term. A term may have any number - of alternate ids. - examples: - - - GO:0019952 - - GO:0050876 - - - GO:0044848 - def: - type: string - description: 'The definition of the current term. ' - examples: - - "'The directed movement of a ribosomal subunit from the nucleus into the cytoplasm.' - [GOC:ai]" - - "'Catalysis of the reaction: adenine + H2O = hypoxanthine + NH3.' [EC:3.5.4.2]" - comment: - type: string - description: A comment for this term. - examples: - - This term was made obsolete because it refers to a class of gene products and - a biological process rather than a molecular function. - subset: - type: array - description: This tag indicates a term subset to which this term belongs. - examples: - - - goslim_yeast - - - goslim_chembl - - goslim_metagenomics - - goslim_pir - - goslim_plant - synonym: - type: array - description: This tag gives a synonym for this term, some xrefs to describe the - origins of the synonym, and may indicate a synonym category or scope information. - examples: - - - "'L-methionine porter activity' RELATED []" - - - "'ribonuclease mitochondrial RNA processing complex' EXACT []" - - "'RNase MRP complex' EXACT []" - xref: - type: array - description: A dbxref that describes an analagous term in another vocabulary - examples: - - - Wikipedia:Reproduction - - - KEGG_REACTION:R05612 - - RHEA:20836 - examples: - - - GO:0042254 - - - GO:0008104 - - GO:0051019 - created_by: - type: string - description: Optional tag added by OBO-Edit to indicate the creator of the term - examples: - - kchris - creation_date: - type: string - description: Optional tag added by OBO-Edit to indicate the creation time and - date of the term - examples: - - '2009-04-28T10:33:25Z' - required: - - _key - - name - optional: - - alt_id - - def - - comment - - subset - - synonym - - xref - - is_a - - intersection_of - - disjoint_from - - relationship - - is_obsolete - - replaced_by - - consider - - created_by - - creation_date From e8d515fa799b12f43d4974135932dafd285bc4ab Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 18 Sep 2019 18:04:24 -0700 Subject: [PATCH 384/732] Allow "select" options to be null, which selects all. Add a minimal test (#98) --- .../ncbi_taxon_get_associated_ws_objects.yaml | 12 ++++++------ .../ncbi_tax/ncbi_taxon_get_children.yaml | 6 +++--- .../ncbi_tax/ncbi_taxon_get_children_cursor.yaml | 6 +++--- .../ncbi_tax/ncbi_taxon_get_lineage.yaml | 6 +++--- .../ncbi_tax/ncbi_taxon_get_siblings.yaml | 6 +++--- .../ncbi_tax/ncbi_taxon_search_sci_name.yaml | 6 +++--- spec/test/stored_queries/test_ncbi_tax.py | 16 ++++++++++++++-- 7 files changed, 35 insertions(+), 23 deletions(-) diff --git a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_associated_ws_objects.yaml b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_associated_ws_objects.yaml index 3daa1c1e..679af9ec 100644 --- a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_associated_ws_objects.yaml +++ b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_associated_ws_objects.yaml @@ -24,15 +24,15 @@ params: type: integer title: Versioning timestamp select_obj: - type: array + type: [array, "null"] items: {type: string} title: WS obj fields to keep in the results - default: [] + default: null select_edge: - type: array + type: [array, "null"] items: {type: string} description: Taxon edge fields to keep in the results - default: [] + default: null query_prefix: WITH ws_object_version query: | let count = COUNT( @@ -52,8 +52,8 @@ query: | filter obj.is_public or obj.workspace_id IN ws_ids limit @offset, @limit return { - ws_obj: KEEP(obj, @select_obj), - edge: KEEP(e, @select_edge) + ws_obj: @select_obj ? KEEP(obj, @select_obj) : obj, + edge: @select_edge ? KEEP(e, @select_edge) : e } ) return {results, total_count: count} diff --git a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_children.yaml b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_children.yaml index 718ee85e..8056ea27 100644 --- a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_children.yaml +++ b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_children.yaml @@ -26,10 +26,10 @@ params: type: integer title: Versioning timestamp select: - type: array + type: [array, "null"] items: {type: string} description: Taxon fields to keep in the results - default: [] + default: null query: | // Fetch the child IDs using the edge attributes let children = ( @@ -52,6 +52,6 @@ query: | for tax in filtered sort tax.scientific_name asc limit @offset, @limit - return KEEP(tax, @select) + return @select ? KEEP(tax, @select) : tax ) return {total_count: COUNT(filtered), results: results} diff --git a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_children_cursor.yaml b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_children_cursor.yaml index 189addbf..75248c86 100644 --- a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_children_cursor.yaml +++ b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_children_cursor.yaml @@ -12,14 +12,14 @@ params: type: integer title: Versioning timestamp select: - type: array + type: [array, "null"] items: {type: string} description: Taxon fields to keep in the results - default: [] + default: null query: | for tax in ncbi_taxon filter tax.id == @id filter tax.created <= @ts AND tax.expired >= @ts limit 1 for child in 1..1 inbound tax ncbi_child_of_taxon - return KEEP(tax, @select) + return @select ? KEEP(tax, @select) : tax diff --git a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_lineage.yaml b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_lineage.yaml index e25b88e2..06cfd3d2 100644 --- a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_lineage.yaml +++ b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_lineage.yaml @@ -13,10 +13,10 @@ params: type: integer title: Versioning timestamp select: - type: array + type: [array, "null"] items: {type: string} description: Taxon fields to keep in the results - default: [] + default: null query: | let ps = ( for t in ncbi_taxon @@ -26,7 +26,7 @@ query: | for p, e in 1..10 outbound t ncbi_child_of_taxon options {bfs: true} filter p.created <= @ts AND p.expired >= @ts - return distinct KEEP(p, @select) + return distinct (@select ? KEEP(p, @select) : p) ) // doing return reverse(ps) returns an array of an array for some reason, // which we don't want diff --git a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_siblings.yaml b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_siblings.yaml index f0741c6b..2821c741 100644 --- a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_siblings.yaml +++ b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_siblings.yaml @@ -23,10 +23,10 @@ params: type: integer title: Versioning timestamp select: - type: array + type: [array, "null"] items: {type: string} description: Taxon fields to keep in the results - default: [] + default: null query: | // Fetch the siblings let siblings = ( for t in ncbi_taxon @@ -45,6 +45,6 @@ query: | let limited = ( for tax in siblings limit @offset, @limit - return KEEP(tax, @select) + return @select ? KEEP(tax, @select) : tax ) return {total_count: COUNT(siblings), results: limited} diff --git a/spec/stored_queries/ncbi_tax/ncbi_taxon_search_sci_name.yaml b/spec/stored_queries/ncbi_tax/ncbi_taxon_search_sci_name.yaml index 0e0ee225..6406bccb 100644 --- a/spec/stored_queries/ncbi_tax/ncbi_taxon_search_sci_name.yaml +++ b/spec/stored_queries/ncbi_tax/ncbi_taxon_search_sci_name.yaml @@ -21,10 +21,10 @@ params: type: integer title: Versioning timestamp select: - type: array + type: [array, "null"] items: {type: string} description: Taxon fields to keep in the results - default: [] + default: null query: | // Search using the fulltext index on scientific_name // Don't limit the results yet so we can get the total_count below @@ -38,6 +38,6 @@ query: | let limited = ( for r in results limit @offset, @limit - return KEEP(r, @select) + return @select ? KEEP(r, @select) : r ) return {results: limited, total_count: COUNT(results)} diff --git a/spec/test/stored_queries/test_ncbi_tax.py b/spec/test/stored_queries/test_ncbi_tax.py index deeaf396..c1ca85cc 100644 --- a/spec/test/stored_queries/test_ncbi_tax.py +++ b/spec/test/stored_queries/test_ncbi_tax.py @@ -215,8 +215,7 @@ def test_search_sciname_more_complicated(self): params={'stored_query': 'ncbi_taxon_search_sci_name'}, data=json.dumps({ 'ts': _NOW, - 'search_text': "prefix:gamma,|prefix:alpha,|prefix:delta", - 'select': ['scientific_name'], + 'search_text': "prefix:gamma,|prefix:alpha,|prefix:delta" }) ).json() result = resp['results'][0] @@ -244,6 +243,19 @@ def test_search_sciname_limit_max(self): self.assertEqual(resp.status_code, 400) self.assertEqual(resp.json()['error'], "1001 is greater than the maximum of 1000") + def test_select_fields(self): + """Test that the 'select' works properly for one query.""" + resp = requests.post( + _CONF['re_api_url'] + '/api/v1/query_results', + params={'stored_query': 'ncbi_taxon_get_lineage'}, + data=json.dumps({'ts': _NOW, 'id': '7', 'select': ['rank']}) + ).json() + self.assertEqual(resp['count'], 2) + self.assertEqual(resp['results'], [ + {'rank': 'Domain'}, + {'rank': 'Phylum'} + ]) + def test_fetch_taxon(self): """Test a valid query to fetch a taxon.""" resp = requests.post( From d66d8f936b6f46183140d1225c3f9a7cb86392d0 Mon Sep 17 00:00:00 2001 From: Gavin Date: Wed, 18 Sep 2019 18:10:48 -0700 Subject: [PATCH 385/732] Add query to get a set of GO terms --- spec/stored_queries/GO/GO_get_terms.yaml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 spec/stored_queries/GO/GO_get_terms.yaml diff --git a/spec/stored_queries/GO/GO_get_terms.yaml b/spec/stored_queries/GO/GO_get_terms.yaml new file mode 100644 index 00000000..ce7307e3 --- /dev/null +++ b/spec/stored_queries/GO/GO_get_terms.yaml @@ -0,0 +1,22 @@ +# Get a set of terms by the term ID and a timestamp, maximum 10000 + +name: GO_get_terms +params: + type: object + required: [ids, ts] + properties: + ids: + type: list + items: + type: string + title: GO term IDs + description: The list of Go term IDs to be fetched + maxItems: 10000 + ts: + type: integer + title: Versioning timestamp in milliseconds since the Unix epoch +query: | + FOR d IN GO_terms + FILTER d.id in @ids + FILTER d.expired >= @ts AND d.created <= @ts + RETURN d From d1a723a4f0cf06f3874ce81d7a5bc791592dc6b9 Mon Sep 17 00:00:00 2001 From: Gavin Date: Wed, 18 Sep 2019 18:22:01 -0700 Subject: [PATCH 386/732] list -> array --- spec/stored_queries/GO/GO_get_terms.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/stored_queries/GO/GO_get_terms.yaml b/spec/stored_queries/GO/GO_get_terms.yaml index ce7307e3..79efc1d0 100644 --- a/spec/stored_queries/GO/GO_get_terms.yaml +++ b/spec/stored_queries/GO/GO_get_terms.yaml @@ -6,7 +6,7 @@ params: required: [ids, ts] properties: ids: - type: list + type: array items: type: string title: GO term IDs From 8343dd9c70aafa04657b5bc49503bfa3de4d0db8 Mon Sep 17 00:00:00 2001 From: Gavin Date: Wed, 18 Sep 2019 18:36:29 -0700 Subject: [PATCH 387/732] Add GO query to get merge edges from terms --- .../stored_queries/GO/GO_get_merges_from.yaml | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 spec/stored_queries/GO/GO_get_merges_from.yaml diff --git a/spec/stored_queries/GO/GO_get_merges_from.yaml b/spec/stored_queries/GO/GO_get_merges_from.yaml new file mode 100644 index 00000000..2d7d32ca --- /dev/null +++ b/spec/stored_queries/GO/GO_get_merges_from.yaml @@ -0,0 +1,24 @@ +# Get a set of 'replaced_by' merge edges from a term by the term ID and a timestamp, maximum 10000 + +name: GO_get_merges_from +params: + type: object + required: [froms] + properties: + froms: + type: array + items: + type: string + title: GO term IDs + description: The list of Go term IDs from which merge edges should emanate + maxItems: 10000 +# It'd be nice if there was a way to get the most recent edge for each from +# But that seems like something that's easy to do client side and removes load from the db, if +# it's even possible +# In any case, having more than one replace by edge per term is going to be extremely unlikely +query: | + FOR d IN GO_merges + FILTER d.from in @froms + FILTER d.type == 'replaced_by' + SORT d.from + RETURN d From 17b4a354987468570b0914391e88639e7bc77b70 Mon Sep 17 00:00:00 2001 From: Gavin Date: Wed, 18 Sep 2019 18:38:59 -0700 Subject: [PATCH 388/732] fix comment --- spec/stored_queries/GO/GO_get_merges_from.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/stored_queries/GO/GO_get_merges_from.yaml b/spec/stored_queries/GO/GO_get_merges_from.yaml index 2d7d32ca..91db43f7 100644 --- a/spec/stored_queries/GO/GO_get_merges_from.yaml +++ b/spec/stored_queries/GO/GO_get_merges_from.yaml @@ -1,4 +1,4 @@ -# Get a set of 'replaced_by' merge edges from a term by the term ID and a timestamp, maximum 10000 +# Get a set of 'replaced_by' merge edges from a set of terms by the term IDs , maximum 10000 name: GO_get_merges_from params: From 6743a60f915d611be6ed2089df0cc04ec696120a Mon Sep 17 00:00:00 2001 From: Gavin Date: Wed, 18 Sep 2019 18:39:45 -0700 Subject: [PATCH 389/732] *&F)^**(_*(& --- spec/stored_queries/GO/GO_get_merges_from.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/stored_queries/GO/GO_get_merges_from.yaml b/spec/stored_queries/GO/GO_get_merges_from.yaml index 91db43f7..84a65a4a 100644 --- a/spec/stored_queries/GO/GO_get_merges_from.yaml +++ b/spec/stored_queries/GO/GO_get_merges_from.yaml @@ -1,4 +1,4 @@ -# Get a set of 'replaced_by' merge edges from a set of terms by the term IDs , maximum 10000 +# Get a set of 'replaced_by' merge edges for a set of terms by the term IDs, maximum 10000 name: GO_get_merges_from params: From 158ab596cb679647e724c664eba7db74964116d3 Mon Sep 17 00:00:00 2001 From: Zhenyuan Lu Date: Thu, 19 Sep 2019 10:53:10 -0400 Subject: [PATCH 390/732] update go queries, using FILTER path.edges[*] ALL instead of PRUNE --- spec/stored_queries/GO/GO_get_ancestors.yaml | 6 +++--- spec/stored_queries/GO/GO_get_descendants.yaml | 6 +++--- spec/stored_queries/GO/GO_get_hierarchicalAncestors.yaml | 6 +++--- spec/stored_queries/GO/GO_get_hierarchicalDescendants.yaml | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/spec/stored_queries/GO/GO_get_ancestors.yaml b/spec/stored_queries/GO/GO_get_ancestors.yaml index b6a39285..c29f746a 100644 --- a/spec/stored_queries/GO/GO_get_ancestors.yaml +++ b/spec/stored_queries/GO/GO_get_ancestors.yaml @@ -29,9 +29,9 @@ query: | FILTER t.created <= @ts AND t.expired >= @ts limit 1 FOR v, e, p IN 1..100 OUTBOUND t GO_edges - PRUNE e != NULL AND (e.created > @ts OR e.expired < @ts) - FILTER p.edges[*].created ALL <= @ts AND p.edges[*].expired ALL >= @ts - FILTER p.edges[*].type ALL == "is_a" + FILTER p.edges[*].created ALL <= @ts + AND p.edges[*].expired ALL >= @ts + AND p.edges[*].type ALL == "is_a" SORT v.id ASC LIMIT @offset, @limit RETURN {term: v, edge: e} diff --git a/spec/stored_queries/GO/GO_get_descendants.yaml b/spec/stored_queries/GO/GO_get_descendants.yaml index 35a21565..6d36a174 100644 --- a/spec/stored_queries/GO/GO_get_descendants.yaml +++ b/spec/stored_queries/GO/GO_get_descendants.yaml @@ -28,9 +28,9 @@ query: | FILTER t.created <= @ts AND t.expired >= @ts limit 1 FOR v, e, p IN 1..100 INBOUND t GO_edges - PRUNE e != NULL AND (e.created > @ts OR e.expired < @ts) - FILTER p.edges[*].created ALL <= @ts AND p.edges[*].expired ALL >= @ts - FILTER p.edges[*].type ALL == "is_a" + FILTER p.edges[*].created ALL <= @ts + AND p.edges[*].expired ALL >= @ts + AND p.edges[*].type ALL == "is_a" SORT v._key ASC LIMIT @offset, @limit RETURN {term: v, edge: e} diff --git a/spec/stored_queries/GO/GO_get_hierarchicalAncestors.yaml b/spec/stored_queries/GO/GO_get_hierarchicalAncestors.yaml index 3bef44de..26e0c33c 100644 --- a/spec/stored_queries/GO/GO_get_hierarchicalAncestors.yaml +++ b/spec/stored_queries/GO/GO_get_hierarchicalAncestors.yaml @@ -32,9 +32,9 @@ query: | FILTER t.created <= @ts AND t.expired >= @ts limit 1 FOR v, e, p IN 1..100 OUTBOUND t GO_edges - PRUNE e != NULL AND (e.created > @ts OR e.expired < @ts) - FILTER p.edges[*].created ALL <= @ts AND p.edges[*].expired ALL >= @ts - FILTER p.edges[*].type ALL != NULL + FILTER p.edges[*].created ALL <= @ts + AND p.edges[*].expired ALL >= @ts + AND p.edges[*].type ALL != NULL SORT v.id ASC LIMIT @offset, @limit RETURN {term: v, edge: e} diff --git a/spec/stored_queries/GO/GO_get_hierarchicalDescendants.yaml b/spec/stored_queries/GO/GO_get_hierarchicalDescendants.yaml index 06c113a2..fd2f555d 100644 --- a/spec/stored_queries/GO/GO_get_hierarchicalDescendants.yaml +++ b/spec/stored_queries/GO/GO_get_hierarchicalDescendants.yaml @@ -31,9 +31,9 @@ query: | FILTER t.created <= @ts AND t.expired >= @ts limit 1 FOR v, e, p IN 1..100 INBOUND t GO_edges - PRUNE e != NULL AND (e.created > @ts OR e.expired < @ts) - FILTER p.edges[*].created ALL <= @ts AND p.edges[*].expired ALL >= @ts - FILTER p.edges[*].type ALL != NULL + FILTER p.edges[*].created ALL <= @ts + AND p.edges[*].expired ALL >= @ts + AND p.edges[*].type ALL != NULL SORT v.id ASC LIMIT @offset, @limit RETURN {term: v, edge: e} From 677847d185702a562fb19f4466224349975bed26 Mon Sep 17 00:00:00 2001 From: Zhenyuan Lu Date: Thu, 19 Sep 2019 13:10:00 -0400 Subject: [PATCH 391/732] update go queries (#91) * update go queries * update Go queries, add PRUNE step * update go queries, using FILTER path.edges[*] ALL instead of PRUNE --- spec/stored_queries/GO/GO_get_ancestors.yaml | 22 ++++++++--- spec/stored_queries/GO/GO_get_children.yaml | 25 ++++++++---- .../stored_queries/GO/GO_get_descendants.yaml | 20 +++++++--- .../GO/GO_get_hierarchicalAncestors.yaml | 38 +++++++++---------- .../GO/GO_get_hierarchicalChildren.yaml | 37 +++++++++--------- .../GO/GO_get_hierarchicalDescendants.yaml | 38 +++++++++---------- .../GO/GO_get_hierarchicalParents.yaml | 37 +++++++++--------- spec/stored_queries/GO/GO_get_metadata.yaml | 18 ++++++--- spec/stored_queries/GO/GO_get_parents.yaml | 25 ++++++++---- spec/stored_queries/GO/GO_get_related.yaml | 24 ++++++++---- spec/stored_queries/GO/GO_get_siblings.yaml | 32 ++++++++++------ 11 files changed, 184 insertions(+), 132 deletions(-) diff --git a/spec/stored_queries/GO/GO_get_ancestors.yaml b/spec/stored_queries/GO/GO_get_ancestors.yaml index f3842c69..c29f746a 100644 --- a/spec/stored_queries/GO/GO_get_ancestors.yaml +++ b/spec/stored_queries/GO/GO_get_ancestors.yaml @@ -3,11 +3,11 @@ name: GO_get_ancestors params: type: object - required: [key] + required: [id, ts] properties: - key: + id: type: string - title: Document key + title: Document ID description: GO id of the term you want to get all the ancestors of limit: type: integer @@ -19,9 +19,19 @@ params: default: 0 description: Result offset for pagination maximum: 100000 -query_prefix: WITH GO_test_term + ts: + type: integer + title: Versioning timestamp +query_prefix: WITH GO_terms query: | - FOR v, e IN 1..1000000 OUTBOUND CONCAT("GO_test_term/", @key) GO_test_edges_isa - SORT v._key ASC + FOR t in GO_terms + FILTER t.id == @id + FILTER t.created <= @ts AND t.expired >= @ts + limit 1 + FOR v, e, p IN 1..100 OUTBOUND t GO_edges + FILTER p.edges[*].created ALL <= @ts + AND p.edges[*].expired ALL >= @ts + AND p.edges[*].type ALL == "is_a" + SORT v.id ASC LIMIT @offset, @limit RETURN {term: v, edge: e} diff --git a/spec/stored_queries/GO/GO_get_children.yaml b/spec/stored_queries/GO/GO_get_children.yaml index 1ea86860..93720e80 100644 --- a/spec/stored_queries/GO/GO_get_children.yaml +++ b/spec/stored_queries/GO/GO_get_children.yaml @@ -3,11 +3,11 @@ name: GO_get_children params: type: object - required: [key] + required: [id, ts] properties: - key: + id: type: string - title: Document key + title: Document ID description: GO id of the term you want to get the children of limit: type: integer @@ -19,9 +19,18 @@ params: default: 0 description: Result offset for pagination maximum: 100000 -query_prefix: WITH GO_test_term + ts: + type: integer + title: Versioning timestamp +query_prefix: WITH GO_terms query: | - FOR v, e IN 1..1 INBOUND CONCAT("GO_test_term/", @key) GO_test_edges_isa - SORT v._key ASC - LIMIT @offset, @limit - RETURN {term: v, edge: e} + FOR t in GO_terms + FILTER t.id == @id + FILTER t.created <= @ts AND t.expired >= @ts + limit 1 + FOR v, e IN 1..1 INBOUND t GO_edges + FILTER e.created <= @ts AND e.expired >= @ts + FILTER e.type == "is_a" + SORT v.id ASC + LIMIT @offset, @limit + RETURN {term: v, edge: e} diff --git a/spec/stored_queries/GO/GO_get_descendants.yaml b/spec/stored_queries/GO/GO_get_descendants.yaml index 156ada75..6d36a174 100644 --- a/spec/stored_queries/GO/GO_get_descendants.yaml +++ b/spec/stored_queries/GO/GO_get_descendants.yaml @@ -2,11 +2,11 @@ name: GO_get_descendants params: type: object - required: [key] + required: [id, ts] properties: - key: + id: type: string - title: Document key + title: Document ID description: GO id of the term you want to get all the descendants of limit: type: integer @@ -18,9 +18,19 @@ params: default: 0 description: Result offset for pagination maximum: 100000 -query_prefix: WITH GO_test_term + ts: + type: integer + title: Versioning timestamp +query_prefix: WITH GO_terms query: | - FOR v, e IN 1..1000000 INBOUND CONCAT("GO_test_term/", @key) GO_test_edges_isa + FOR t in GO_terms + FILTER t.id == @id + FILTER t.created <= @ts AND t.expired >= @ts + limit 1 + FOR v, e, p IN 1..100 INBOUND t GO_edges + FILTER p.edges[*].created ALL <= @ts + AND p.edges[*].expired ALL >= @ts + AND p.edges[*].type ALL == "is_a" SORT v._key ASC LIMIT @offset, @limit RETURN {term: v, edge: e} diff --git a/spec/stored_queries/GO/GO_get_hierarchicalAncestors.yaml b/spec/stored_queries/GO/GO_get_hierarchicalAncestors.yaml index 1b9db359..26e0c33c 100644 --- a/spec/stored_queries/GO/GO_get_hierarchicalAncestors.yaml +++ b/spec/stored_queries/GO/GO_get_hierarchicalAncestors.yaml @@ -6,11 +6,11 @@ name: GO_get_hierarchicalAncestors params: type: object - required: [key] + required: [id, ts] properties: - key: + id: type: string - title: Document key + title: Document ID description: GO id of the term you want to get all the hierarchical ancestors of limit: type: integer @@ -22,21 +22,19 @@ params: default: 0 description: Result offset for pagination maximum: 100000 -query_prefix: WITH GO_test_term + ts: + type: integer + title: Versioning timestamp +query_prefix: WITH GO_terms query: | - LET term_id = CONCAT("GO_test_term/", @key) - LET results1 = ( - FOR v_relationship, e_relationship IN 1..1000000 OUTBOUND term_id GO_test_edges_relationship - FILTER e_relationship.relationship_type == 'part_of' - OR e_relationship.relationship_type == 'has_part' - OR e_relationship.relationship_type == 'occurs_in' - RETURN {term: v_relationship, edge: e_relationship} - ) - LET results2 = ( - FOR v_isa, e_isa IN 1..1000000 OUTBOUND term_id GO_test_edges_isa - RETURN {term: v_isa, edge: e_isa} - ) - FOR x IN UNION(results1, results2) - SORT x._key ASC - LIMIT @offset, @limit - RETURN DISTINCT x + FOR t in GO_terms + FILTER t.id == @id + FILTER t.created <= @ts AND t.expired >= @ts + limit 1 + FOR v, e, p IN 1..100 OUTBOUND t GO_edges + FILTER p.edges[*].created ALL <= @ts + AND p.edges[*].expired ALL >= @ts + AND p.edges[*].type ALL != NULL + SORT v.id ASC + LIMIT @offset, @limit + RETURN {term: v, edge: e} diff --git a/spec/stored_queries/GO/GO_get_hierarchicalChildren.yaml b/spec/stored_queries/GO/GO_get_hierarchicalChildren.yaml index 53b615da..af8f731c 100644 --- a/spec/stored_queries/GO/GO_get_hierarchicalChildren.yaml +++ b/spec/stored_queries/GO/GO_get_hierarchicalChildren.yaml @@ -2,11 +2,11 @@ name: GO_get_hierarchicalChildren params: type: object - required: [key] + required: [id, ts] properties: - key: + id: type: string - title: Document key + title: Document ID description: GO id of the term you want to get the direct hierarchical children of limit: type: integer @@ -18,21 +18,18 @@ params: default: 0 description: Result offset for pagination maximum: 100000 -query_prefix: WITH GO_test_term + ts: + type: integer + title: Versioning timestamp +query_prefix: WITH GO_terms query: | - LET term_id = CONCAT("GO_test_term/", @key) - LET results1 = ( - FOR v_relationship, e_relationship IN 1..1 INBOUND term_id GO_test_edges_relationship - FILTER e_relationship.relationship_type == 'part_of' - OR e_relationship.relationship_type == 'has_part' - OR e_relationship.relationship_type == 'occurs_in' - RETURN {term: v_relationship, edge: e_relationship} - ) - LET results2 = ( - FOR v_isa, e_isa IN 1..1 INBOUND term_id GO_test_edges_isa - RETURN {term: v_isa, edge: e_isa} - ) - FOR x IN UNION(results1, results2) - SORT x._key ASC - LIMIT @offset, @limit - RETURN DISTINCT x + FOR t in GO_terms + FILTER t.id == @id + FILTER t.created <= @ts AND t.expired >= @ts + limit 1 + FOR v, e IN 1..1 INBOUND t GO_edges + FILTER e.created <= @ts AND e.expired >= @ts + FILTER e.type != NULL + SORT v.id ASC + LIMIT @offset, @limit + RETURN {term: v, edge: e} diff --git a/spec/stored_queries/GO/GO_get_hierarchicalDescendants.yaml b/spec/stored_queries/GO/GO_get_hierarchicalDescendants.yaml index dd9bc3d7..fd2f555d 100644 --- a/spec/stored_queries/GO/GO_get_hierarchicalDescendants.yaml +++ b/spec/stored_queries/GO/GO_get_hierarchicalDescendants.yaml @@ -5,11 +5,11 @@ name: GO_get_hierarchicalDescendants params: type: object - required: [key] + required: [id, ts] properties: - key: + id: type: string - title: Document key + title: Document ID description: GO id of the term you want to get all the hierarchical descendants of limit: type: integer @@ -21,21 +21,19 @@ params: default: 0 description: Result offset for pagination maximum: 100000 -query_prefix: WITH GO_test_term + ts: + type: integer + title: Versioning timestamp +query_prefix: WITH GO_terms query: | - LET term_id = CONCAT("GO_test_term/", @key) - LET results1 = ( - FOR v_relationship, e_relationship IN 1..1000000 INBOUND term_id GO_test_edges_relationship - FILTER e_relationship.relationship_type == 'part_of' - OR e_relationship.relationship_type == 'has_part' - OR e_relationship.relationship_type == 'occurs_in' - RETURN {term: v_relationship, edge: e_relationship} - ) - LET results2 = ( - FOR v_isa, e_isa IN 1..1000000 INBOUND term_id GO_test_edges_isa - RETURN {term: v_isa, edge: e_isa} - ) - FOR x IN UNION(results1, results2) - SORT x._key ASC - LIMIT @offset, @limit - RETURN DISTINCT x + FOR t in GO_terms + FILTER t.id == @id + FILTER t.created <= @ts AND t.expired >= @ts + limit 1 + FOR v, e, p IN 1..100 INBOUND t GO_edges + FILTER p.edges[*].created ALL <= @ts + AND p.edges[*].expired ALL >= @ts + AND p.edges[*].type ALL != NULL + SORT v.id ASC + LIMIT @offset, @limit + RETURN {term: v, edge: e} diff --git a/spec/stored_queries/GO/GO_get_hierarchicalParents.yaml b/spec/stored_queries/GO/GO_get_hierarchicalParents.yaml index 184e8dbd..f8621c6f 100644 --- a/spec/stored_queries/GO/GO_get_hierarchicalParents.yaml +++ b/spec/stored_queries/GO/GO_get_hierarchicalParents.yaml @@ -6,11 +6,11 @@ name: GO_get_hierarchicalParents params: type: object - required: [key] + required: [id, ts] properties: - key: + id: type: string - title: Document key + title: Document ID description: GO id of the term you want to get all the hierarchical parents of limit: type: integer @@ -22,21 +22,18 @@ params: default: 0 description: Result offset for pagination maximum: 100000 -query_prefix: WITH GO_test_term + ts: + type: integer + title: Versioning timestamp +query_prefix: WITH GO_terms query: | - LET term_id = CONCAT("GO_test_term/", @key) - LET results1 = ( - FOR v_relationship, e_relationship IN 1..1 OUTBOUND term_id GO_test_edges_relationship - FILTER e_relationship.relationship_type == 'part_of' - OR e_relationship.relationship_type == 'has_part' - OR e_relationship.relationship_type == 'occurs_in' - RETURN {term: v_relationship, edge: e_relationship} - ) - LET results2 = ( - FOR v_isa, e_isa IN 1..1 OUTBOUND term_id GO_test_edges_isa - RETURN {term: v_isa, edge: e_isa} - ) - FOR x IN UNION(results1, results2) - SORT x._key ASC - LIMIT @offset, @limit - RETURN DISTINCT x + FOR t in GO_terms + FILTER t.id == @id + FILTER t.created <= @ts AND t.expired >= @ts + limit 1 + FOR v, e IN 1..1 OUTBOUND t GO_edges + FILTER e.created <= @ts AND e.expired >= @ts + FILTER e.type != NULL + SORT v.id ASC + LIMIT @offset, @limit + RETURN {term: v, edge: e} diff --git a/spec/stored_queries/GO/GO_get_metadata.yaml b/spec/stored_queries/GO/GO_get_metadata.yaml index ab2e0f94..f09047d3 100644 --- a/spec/stored_queries/GO/GO_get_metadata.yaml +++ b/spec/stored_queries/GO/GO_get_metadata.yaml @@ -3,13 +3,19 @@ name: GO_get_metadata params: type: object - required: [key] + required: [id, ts] properties: - key: + id: type: string - title: Document key + title: Document ID description: Get information/metadata of a particular ontology term + ts: + type: integer + title: Versioning timestamp +query_prefix: WITH GO_terms query: | - FOR v IN GO_test_term - FILTER v._key == @key - RETURN v + FOR t IN GO_terms + FILTER t.id == @id + FILTER t.created <= @ts AND t.expired >= @ts + limit 1 + RETURN t diff --git a/spec/stored_queries/GO/GO_get_parents.yaml b/spec/stored_queries/GO/GO_get_parents.yaml index bb2ae0b2..ec63c4eb 100644 --- a/spec/stored_queries/GO/GO_get_parents.yaml +++ b/spec/stored_queries/GO/GO_get_parents.yaml @@ -3,11 +3,11 @@ name: GO_get_parents params: type: object - required: [key] + required: [id, ts] properties: - key: + id: type: string - title: Document key + title: Document ID description: GO id of the term you want to get all the direct parents of limit: type: integer @@ -19,9 +19,18 @@ params: default: 0 description: Result offset for pagination maximum: 100000 -query_prefix: WITH GO_test_term + ts: + type: integer + title: Versioning timestamp +query_prefix: WITH GO_terms query: | - FOR v, e IN 1..1 OUTBOUND CONCAT("GO_test_term/", @key) GO_test_edges_isa - SORT v._key ASC - LIMIT @offset, @limit - RETURN {term: v, edge: e} + FOR t in GO_terms + FILTER t.id == @id + FILTER t.created <= @ts AND t.expired >= @ts + limit 1 + FOR v, e IN 1..1 OUTBOUND t GO_edges + FILTER e.created <= @ts AND e.expired >= @ts + FILTER e.type == "is_a" + SORT v.id ASC + LIMIT @offset, @limit + RETURN {term: v, edge: e} diff --git a/spec/stored_queries/GO/GO_get_related.yaml b/spec/stored_queries/GO/GO_get_related.yaml index 73ffab25..ceee04e4 100644 --- a/spec/stored_queries/GO/GO_get_related.yaml +++ b/spec/stored_queries/GO/GO_get_related.yaml @@ -2,11 +2,11 @@ name: GO_get_related params: type: object - required: [key] + required: [id, ts] properties: - key: + id: type: string - title: Document key + title: Document ID description: GO id of the term you want to get all the directly related nodes of limit: type: integer @@ -18,9 +18,17 @@ params: default: 0 description: Result offset for pagination maximum: 100000 -query_prefix: WITH GO_test_term + ts: + type: integer + title: Versioning timestamp +query_prefix: WITH GO_terms query: | - FOR v, e IN 1 ANY CONCAT("GO_test_term/", @key) GO_test_edges_isa, GO_test_edges_relationship - SORT v._key ASC - LIMIT @offset, @limit - RETURN {term: v, edge: e} + FOR t in GO_terms + FILTER t.id == @id + FILTER t.created <= @ts AND t.expired >= @ts + limit 1 + FOR v, e IN 1 ANY t GO_edges + FILTER e.created <= @ts AND e.expired >= @ts + SORT v.id ASC + LIMIT @offset, @limit + RETURN {term: v, edge: e} diff --git a/spec/stored_queries/GO/GO_get_siblings.yaml b/spec/stored_queries/GO/GO_get_siblings.yaml index c56a978d..679af15a 100644 --- a/spec/stored_queries/GO/GO_get_siblings.yaml +++ b/spec/stored_queries/GO/GO_get_siblings.yaml @@ -2,11 +2,11 @@ name: GO_get_siblings params: type: object - required: [key] + required: [id, ts] properties: - key: + id: type: string - title: Document key + title: Document ID description: Get all siblings of this term limit: type: integer @@ -18,12 +18,22 @@ params: default: 0 description: Result offset for pagination maximum: 100000 -query_prefix: WITH GO_test_term + ts: + type: integer + title: Versioning timestamp +query_prefix: WITH GO_terms query: | - LET term_id = CONCAT("GO_test_term/", @key) - FOR v_parent, e_parent IN 1..1 OUTBOUND term_id GO_test_edges_isa - FOR v_child, e_child in 1..1 INBOUND e_parent._to GO_test_edges_isa - FILTER e_child._from != term_id - SORT v_child._key ASC - LIMIT @offset, @limit - RETURN v_child._key + FOR t in GO_terms + FILTER t.id == @id + FILTER t.created <= @ts AND t.expired >= @ts + limit 1 + FOR v_parent, e_parent IN 1..1 OUTBOUND t GO_edges + FILTER e_parent.created <= @ts AND e_parent.expired >= @ts + FILTER e_parent.type == "is_a" + FOR v_child, e_child in 1..1 INBOUND v_parent GO_edges + FILTER e_child.created <= @ts AND e_child.expired >= @ts + FILTER e_child.type == "is_a" + FILTER v_child != t + SORT v_child.id ASC + LIMIT @offset, @limit + RETURN v_child.id From 66477379b742a729db7b76f6738e19c7cb8e994d Mon Sep 17 00:00:00 2001 From: Gavin Date: Thu, 19 Sep 2019 12:02:25 -0700 Subject: [PATCH 392/732] Add GO_merges from index, _key for obj->feature edges Will need the former for edge lookups, the latter to ensure reindexes don't duplicate edges --- spec/schemas/GO/GO_merges.yaml | 4 ++++ spec/schemas/ws/ws_genome_has_feature.yaml | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/spec/schemas/GO/GO_merges.yaml b/spec/schemas/GO/GO_merges.yaml index 2b05de03..3dabad47 100644 --- a/spec/schemas/GO/GO_merges.yaml +++ b/spec/schemas/GO/GO_merges.yaml @@ -2,6 +2,10 @@ name: GO_merges type: edge delta: true +indexes: + - type: hash # odn't think this needs to be a skiplist / persistent index + fields: [from] + schema: "$schema": http://json-schema.org/draft-07/schema# title: GO_merges diff --git a/spec/schemas/ws/ws_genome_has_feature.yaml b/spec/schemas/ws/ws_genome_has_feature.yaml index 0942abe3..e86df6d0 100644 --- a/spec/schemas/ws/ws_genome_has_feature.yaml +++ b/spec/schemas/ws/ws_genome_has_feature.yaml @@ -4,8 +4,13 @@ schema: "$schema": http://json-schema.org/draft-07/schema# type: object description: A workspace genome has a feature. - required: [_from, _to] + required: [_from, _to, _key] properties: + _key: + type: string + examples: ['75:82:3_RSP_4039'] + description: The unique, permanent ID of this edge. Identical to the feature _key entry. + pattern: "^\\d+:\\d+:\\d+_\\w*$" # may need to expand the feature ID part _from: type: string examples: ['ws_object_version/75:82:3'] From cde4e7850c03e1a62da59915bf9eb15ba3e6f192 Mon Sep 17 00:00:00 2001 From: Gavin Date: Thu, 19 Sep 2019 12:04:16 -0700 Subject: [PATCH 393/732] typo --- spec/schemas/GO/GO_merges.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/schemas/GO/GO_merges.yaml b/spec/schemas/GO/GO_merges.yaml index 3dabad47..8b55db71 100644 --- a/spec/schemas/GO/GO_merges.yaml +++ b/spec/schemas/GO/GO_merges.yaml @@ -3,7 +3,7 @@ type: edge delta: true indexes: - - type: hash # odn't think this needs to be a skiplist / persistent index + - type: hash # don't think this needs to be a skiplist / persistent index fields: [from] schema: From 1833a257a81b9862cd898d03b32930f7edff39c9 Mon Sep 17 00:00:00 2001 From: Gavin Date: Thu, 19 Sep 2019 18:24:34 -0700 Subject: [PATCH 394/732] Add source to feature->GO edge --- spec/schemas/ws/ws_feature_has_GO_annotation.yaml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/spec/schemas/ws/ws_feature_has_GO_annotation.yaml b/spec/schemas/ws/ws_feature_has_GO_annotation.yaml index 4f068b8f..aa603634 100644 --- a/spec/schemas/ws/ws_feature_has_GO_annotation.yaml +++ b/spec/schemas/ws/ws_feature_has_GO_annotation.yaml @@ -4,7 +4,7 @@ schema: "$schema": http://json-schema.org/draft-07/schema# type: object description: A feature in a workspace genome has a Gene Ontology annotation. - required: [_from, _to] + required: [_from, _to, source] properties: _from: type: string @@ -13,4 +13,8 @@ schema: _to: type: string examples: ['GO_terms/GO:0000002_v2018-03-06'] - description: A Gene Ontology term. \ No newline at end of file + description: A Gene Ontology term. + source: + type: string + examples: ['kbase_RE_indexer', 'user_name', 'user_name:app_name'] + description: The source that created this edge \ No newline at end of file From 13f6ce93885d2f3db26e1710afa75ca764b16a2c Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Fri, 20 Sep 2019 11:54:02 -0700 Subject: [PATCH 395/732] Optimize and fix details of ncbi queries (#101) * Optimize get_children and get_siblings; return distinct both those queries; better ts filter on lineage query * Fix tests * Fix query filter syntax --- .../ncbi_tax/ncbi_taxon_get_children.yaml | 25 +++++++------- .../ncbi_taxon_get_children_cursor.yaml | 2 +- .../ncbi_tax/ncbi_taxon_get_lineage.yaml | 6 ++-- .../ncbi_tax/ncbi_taxon_get_siblings.yaml | 34 +++++++++++-------- spec/test/stored_queries/test_ncbi_tax.py | 5 +-- 5 files changed, 38 insertions(+), 34 deletions(-) diff --git a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_children.yaml b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_children.yaml index 8056ea27..64d82e57 100644 --- a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_children.yaml +++ b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_children.yaml @@ -32,26 +32,25 @@ params: default: null query: | // Fetch the child IDs using the edge attributes - let children = ( - for parent in ncbi_taxon - filter parent.id == @id - filter parent.created <= @ts AND parent.expired >= @ts - limit 1 - for tax in 1..1 inbound parent ncbi_child_of_taxon - return tax + let child_ids = ( + for e in ncbi_child_of_taxon + filter e.to == @id + filter e.created <= @ts AND e.expired >= @ts + return e.from ) // Sort and filter the children // Should only get evaluated if search_text is truthy let searched = ( - for tax in FULLTEXT(ncbi_taxon, "scientific_name", @search_text) - filter tax in children - return tax + for tax in FULLTEXT(ncbi_taxon, "scientific_name", @search_text) + filter tax.id in child_ids + return tax.id ) - let filtered = @search_text ? searched : children + let filtered = @search_text ? searched : child_ids let results = ( - for tax in filtered + for tax in ncbi_taxon + filter tax.id in filtered sort tax.scientific_name asc limit @offset, @limit - return @select ? KEEP(tax, @select) : tax + return distinct (@select ? KEEP(tax, @select) : tax) ) return {total_count: COUNT(filtered), results: results} diff --git a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_children_cursor.yaml b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_children_cursor.yaml index 75248c86..9aefb751 100644 --- a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_children_cursor.yaml +++ b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_children_cursor.yaml @@ -22,4 +22,4 @@ query: | filter tax.created <= @ts AND tax.expired >= @ts limit 1 for child in 1..1 inbound tax ncbi_child_of_taxon - return @select ? KEEP(tax, @select) : tax + return @select ? KEEP(tax, @select) : tax diff --git a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_lineage.yaml b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_lineage.yaml index 06cfd3d2..f768df7d 100644 --- a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_lineage.yaml +++ b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_lineage.yaml @@ -23,10 +23,10 @@ query: | filter t.id == @id filter t.created <= @ts AND t.expired >= @ts limit 1 - for p, e in 1..10 outbound t ncbi_child_of_taxon + for ancestor, e, path in 1..10 outbound t ncbi_child_of_taxon options {bfs: true} - filter p.created <= @ts AND p.expired >= @ts - return distinct (@select ? KEEP(p, @select) : p) + filter path.edges[*].created ALL <= @ts AND path.edges[*].expired ALL >= @ts + return distinct (@select ? KEEP(ancestor, @select) : ancestor) ) // doing return reverse(ps) returns an array of an array for some reason, // which we don't want diff --git a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_siblings.yaml b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_siblings.yaml index 2821c741..438ccd8e 100644 --- a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_siblings.yaml +++ b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_siblings.yaml @@ -29,22 +29,26 @@ params: default: null query: | // Fetch the siblings - let siblings = ( for t in ncbi_taxon - filter t.id == @id - filter t.created <= @ts AND t.expired >= @ts + let parent_id = first( + for e in ncbi_child_of_taxon + filter e.from == @id + filter e.created <= @ts and e.expired >= @ts limit 1 - for parent in 1..1 outbound t ncbi_child_of_taxon - filter parent.created <= @ts AND parent.expired >= @ts - for child in 1..1 inbound parent ncbi_child_of_taxon - filter child != t - filter child.created <= @ts AND child.expired >= @ts - sort child.scientific_name asc - return child + return e.to ) - // Apply limits to the results - let limited = ( - for tax in siblings + let sibling_ids = ( + for e in ncbi_child_of_taxon + filter e.to == parent_id + filter e.created <= @ts and e.expired >= @ts + filter e.from != @id + return e.from + ) + // Apply sort and limits to the results + let siblings = ( + for tax in ncbi_taxon + filter tax.id in sibling_ids + sort tax.scientific_name asc limit @offset, @limit - return @select ? KEEP(tax, @select) : tax + return distinct (@select ? KEEP(tax, @select) : tax) ) - return {total_count: COUNT(siblings), results: limited} + return {total_count: COUNT(sibling_ids), results: siblings} diff --git a/spec/test/stored_queries/test_ncbi_tax.py b/spec/test/stored_queries/test_ncbi_tax.py index c1ca85cc..bf818110 100644 --- a/spec/test/stored_queries/test_ncbi_tax.py +++ b/spec/test/stored_queries/test_ncbi_tax.py @@ -33,8 +33,9 @@ def _create_delta_test_docs(coll_name, docs, edge=False): """Add in delta required fields.""" if edge: for doc in docs: - doc['from'] = doc['_from'] - doc['to'] = doc['_to'] + # Replicate the time-travel system by just setting 'from' and 'to' to the keys + doc['from'] = doc['_from'].split('/')[1] + doc['to'] = doc['_to'].split('/')[1] else: for doc in docs: doc['id'] = doc['_key'] From 0b14191e360ef76cd9d57c75adf5e6c684564282 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Fri, 20 Sep 2019 12:18:51 -0700 Subject: [PATCH 396/732] Update cached spec release --- api/src/test/spec_release/spec.tar.gz | Bin 18574 -> 18131 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/api/src/test/spec_release/spec.tar.gz b/api/src/test/spec_release/spec.tar.gz index ac5fc026f8e554822de131c5d5ecca7949deaf46..b78ce7782fc297b4a700a6741504d832e5c3d0a9 100644 GIT binary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r;~9&Clilee6rDuHo9GwW zov_8&jqJ1ZK3L8%TVdH9fpKF^X25dLUHpsePH`E=iDi-APxj$B+LDQz{!Bi#GQ#Vz zwi15b;Fick#~rvO6gDbsRM;rolJNW-zJGsmcD&F0KL<+1{=#54`ahry4y2a4fO7PI zMD$bnAN9^q`G4vF7XO74AyMxEUP*Q!oNL4MB4l-!XzY9k6jIhfLvK>PEq)%!xyiQv3f>0?97&E%# zH63vLVzP`{cIJKN-p35pqvaJ}lezVN!5@B8F8?nYc1Hiv9> z>VL(_k(|WCl_K;#!w_4-2>UULvW>!P2_=`+oZLi9p(%(dLw`3A()}z-dLWY0&#o}# zZtx!zjbJjh!duI7Q*NLf{6|=yj{hI%3jgZ>N&G(q&xn!#?Cj?W4FC$5rwDt9;+R*+ zMZ|ufKB8(aBI%YZmS6~~$`e`0a%WjiBYsz5F;q&ja5FeU3O_ zg<#o)Cy89gFz*@&As8)K~jeL_`qa^+;U5PoLX&Ziit zLK*i>#L_7`(d*RK2=Dp1vFUq*-SB^YE=(E&oM->(r}97a^j=5hf2ac(|7ZC~qm^U^ zAj)@0HbB#n@#5&A2aS3qbb(l}QdS^R;oevnwi|?kk9>D7ayp88^N}aB`Q{m#u>ZTn zF|&+wLVRmT+;DWv>0Iv{P646&oD z4nc!Wv-DP@q780tE^bC{Un4fdT~z6ev)jK!E}U3KS?%pg=+W@c#j{ K#GXO`&;kH-As Date: Fri, 20 Sep 2019 13:22:09 -0700 Subject: [PATCH 397/732] Add _key description to feature->GO edge --- spec/schemas/ws/ws_feature_has_GO_annotation.yaml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/spec/schemas/ws/ws_feature_has_GO_annotation.yaml b/spec/schemas/ws/ws_feature_has_GO_annotation.yaml index aa603634..f59b246f 100644 --- a/spec/schemas/ws/ws_feature_has_GO_annotation.yaml +++ b/spec/schemas/ws/ws_feature_has_GO_annotation.yaml @@ -4,8 +4,14 @@ schema: "$schema": http://json-schema.org/draft-07/schema# type: object description: A feature in a workspace genome has a Gene Ontology annotation. - required: [_from, _to, source] + required: [_key, _from, _to, source] properties: + _key: + type: string + examples: ['75:82:3_RSP_4039::GO:0000002_v2018-03-06::kbase_RE_indexer'] + description: a unique ID for this edge, consisting of the keys of the feature and term + vertices and the source of the edge data. The latter allows other sources to add + the same edge with potentially different fields. _from: type: string examples: ['ws_genome_feature/75:82:3_RSP_4039'] From e65aed7d62d133e949931878af8f59d0d1c76622 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Mon, 23 Sep 2019 10:12:48 -0700 Subject: [PATCH 398/732] Bugfix on fetching results for get_children and get_siblings. Return distinct unnecessary on lineage --- spec/stored_queries/ncbi_tax/ncbi_taxon_get_children.yaml | 5 +++-- spec/stored_queries/ncbi_tax/ncbi_taxon_get_lineage.yaml | 2 +- spec/stored_queries/ncbi_tax/ncbi_taxon_get_siblings.yaml | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_children.yaml b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_children.yaml index 64d82e57..0b50a635 100644 --- a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_children.yaml +++ b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_children.yaml @@ -38,7 +38,7 @@ query: | filter e.created <= @ts AND e.expired >= @ts return e.from ) - // Sort and filter the children + // Sort and filter the childrenj // Should only get evaluated if search_text is truthy let searched = ( for tax in FULLTEXT(ncbi_taxon, "scientific_name", @search_text) @@ -49,8 +49,9 @@ query: | let results = ( for tax in ncbi_taxon filter tax.id in filtered + filter tax.created <= @ts AND tax.expired >= @ts sort tax.scientific_name asc limit @offset, @limit - return distinct (@select ? KEEP(tax, @select) : tax) + return (@select ? KEEP(tax, @select) : tax) ) return {total_count: COUNT(filtered), results: results} diff --git a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_lineage.yaml b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_lineage.yaml index f768df7d..99bff280 100644 --- a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_lineage.yaml +++ b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_lineage.yaml @@ -26,7 +26,7 @@ query: | for ancestor, e, path in 1..10 outbound t ncbi_child_of_taxon options {bfs: true} filter path.edges[*].created ALL <= @ts AND path.edges[*].expired ALL >= @ts - return distinct (@select ? KEEP(ancestor, @select) : ancestor) + return (@select ? KEEP(ancestor, @select) : ancestor) ) // doing return reverse(ps) returns an array of an array for some reason, // which we don't want diff --git a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_siblings.yaml b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_siblings.yaml index 438ccd8e..36ade8d5 100644 --- a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_siblings.yaml +++ b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_siblings.yaml @@ -47,8 +47,9 @@ query: | let siblings = ( for tax in ncbi_taxon filter tax.id in sibling_ids + filter tax.created <= @ts AND tax.expired >= @ts sort tax.scientific_name asc limit @offset, @limit - return distinct (@select ? KEEP(tax, @select) : tax) + return (@select ? KEEP(tax, @select) : tax) ) return {total_count: COUNT(sibling_ids), results: siblings} From 3d5d1eed22066dfb08c3837a2348b3f1648ff7bc Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Mon, 23 Sep 2019 10:13:29 -0700 Subject: [PATCH 399/732] Remove typo --- spec/stored_queries/ncbi_tax/ncbi_taxon_get_children.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_children.yaml b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_children.yaml index 0b50a635..eaf5b9cc 100644 --- a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_children.yaml +++ b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_children.yaml @@ -38,7 +38,7 @@ query: | filter e.created <= @ts AND e.expired >= @ts return e.from ) - // Sort and filter the childrenj + // Sort and filter the children // Should only get evaluated if search_text is truthy let searched = ( for tax in FULLTEXT(ncbi_taxon, "scientific_name", @search_text) From 8275ad0101610f39a4b6fc91d8b5f1345589b5d6 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 24 Sep 2019 14:26:33 -0700 Subject: [PATCH 400/732] Add object type information for ncbi taxon->object query (#104) * Add some useful fields in the ws type docs. Expand the ncbi_taxon_get_associated_ws_objects query to include type info for the object. Adapt the tests to have this additional info. * Add test and fix for object type in ncbi_taxon-get_associated_ws_objects * Move filter and limit line outside inner traversal * Better test on genome type return data --- spec/schemas/ws/ws_type.yaml | 6 ++++++ spec/schemas/ws/ws_type_version.yaml | 14 ++++++++++++- .../ncbi_taxon_get_associated_ws_objects.yaml | 15 ++++++++------ spec/test/stored_queries/test_ncbi_tax.py | 20 ++++++++++++++++++- 4 files changed, 47 insertions(+), 8 deletions(-) diff --git a/spec/schemas/ws/ws_type.yaml b/spec/schemas/ws/ws_type.yaml index f9795a4e..f8026cc8 100644 --- a/spec/schemas/ws/ws_type.yaml +++ b/spec/schemas/ws/ws_type.yaml @@ -10,3 +10,9 @@ schema: type: string examples: [KBaseGenomes.Genome] pattern: "^\\w+\\.\\w+$" + module_name: + type: string + examples: ['KBaseGenomes'] + type_name: + type: string + examples: ['Genome'] diff --git a/spec/schemas/ws/ws_type_version.yaml b/spec/schemas/ws/ws_type_version.yaml index ba2c9aed..8595de34 100644 --- a/spec/schemas/ws/ws_type_version.yaml +++ b/spec/schemas/ws/ws_type_version.yaml @@ -8,5 +8,17 @@ schema: properties: _key: type: string - examples: [KBaseGenomes.Genome‑9.0] + examples: ['KBaseGenomes.Genome‑9.0'] pattern: "^\\w+\\.\\w+-\\d+\\.\\d+$" + module_name: + type: string + examples: ['KBaseGenomes'] + type_name: + type: string + examples: ['Genome'] + maj_ver: + type: integer + min: 0 + min_ver: + type: integer + min: 0 diff --git a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_associated_ws_objects.yaml b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_associated_ws_objects.yaml index 679af9ec..abae3ec1 100644 --- a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_associated_ws_objects.yaml +++ b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_associated_ws_objects.yaml @@ -33,7 +33,7 @@ params: items: {type: string} description: Taxon edge fields to keep in the results default: null -query_prefix: WITH ws_object_version +query_prefix: WITH ws_object_version, ws_type_version query: | let count = COUNT( for tax in ncbi_taxon @@ -48,12 +48,15 @@ query: | filter tax.id == @taxon_id filter tax.created <= @ts AND tax.expired >= @ts limit 1 - for obj, e in 1..1 inbound tax ws_obj_version_has_taxon + for obj, e in 1 inbound tax ws_obj_version_has_taxon filter obj.is_public or obj.workspace_id IN ws_ids limit @offset, @limit - return { - ws_obj: @select_obj ? KEEP(obj, @select_obj) : obj, - edge: @select_edge ? KEEP(e, @select_edge) : e - } + for type in 1 outbound obj ws_obj_instance_of_type + let t = KEEP(type, ['_key', 'module_name', 'type_name', 'maj_ver', 'min_ver']) + let o = MERGE(obj, {type: t}) + return { + ws_obj: @select_obj ? KEEP(o, @select_obj) : o, + edge: @select_edge ? KEEP(e, @select_edge) : e + } ) return {results, total_count: count} diff --git a/spec/test/stored_queries/test_ncbi_tax.py b/spec/test/stored_queries/test_ncbi_tax.py index bf818110..62c5f991 100644 --- a/spec/test/stored_queries/test_ncbi_tax.py +++ b/spec/test/stored_queries/test_ncbi_tax.py @@ -84,12 +84,22 @@ def setUpClass(cls): {'_from': 'ws_workspace/1', '_to': 'ws_object_version/1:1:2'}, {'_from': 'ws_workspace/2', '_to': 'ws_object_version/2:1:1'}, ] + ws_type_version_docs = [ + {'_key': 'KBaseGenomes.Genome-99.77', 'module_name': 'KBaseGenomes', + 'type_name': 'Genome', 'maj_ver': 99, 'min_ver': 77} + ] + ws_obj_instance_of_type_docs = [ + {'_from': 'ws_object_version/1:1:1', '_to': 'ws_type_version/KBaseGenomes.Genome-99.77'}, + {'_from': 'ws_object_version/1:1:2', '_to': 'ws_type_version/KBaseGenomes.Genome-99.77'} + ] _create_delta_test_docs('ncbi_taxon', taxon_docs) _create_delta_test_docs('ncbi_child_of_taxon', child_docs, edge=True) _create_delta_test_docs('ws_object_version', obj_docs) _create_delta_test_docs('ws_obj_version_has_taxon', obj_to_taxa_docs, edge=True) _create_delta_test_docs('ws_workspace', ws_docs) _create_delta_test_docs('ws_workspace_contains_obj', ws_to_obj, edge=True) + create_test_docs('ws_obj_instance_of_type', ws_obj_instance_of_type_docs) + create_test_docs('ws_type_version', ws_type_version_docs) def test_get_lineage_valid(self): """Test a valid query of taxon lineage.""" @@ -275,7 +285,8 @@ def test_get_associated_objs(self): resp = requests.post( _CONF['re_api_url'] + '/api/v1/query_results', params={'stored_query': 'ncbi_taxon_get_associated_ws_objects'}, - data=json.dumps({'ts': _NOW, 'taxon_id': '1', 'select_obj': ['_id'], 'select_edge': ['assigned_by']}), + data=json.dumps({'ts': _NOW, 'taxon_id': '1', 'select_obj': ['_id', 'type'], + 'select_edge': ['assigned_by']}), ).json() self.assertEqual(resp['count'], 1) results = resp['results'][0] @@ -285,3 +296,10 @@ def test_get_associated_objs(self): ids = {ret['ws_obj']['_id'] for ret in results['results']} self.assertEqual(assignments, {'assn1', 'assn2'}) self.assertEqual(ids, {'ws_object_version/1:1:1', 'ws_object_version/1:1:2'}) + self.assertEqual(results['results'][0]['ws_obj']['type'], { + 'type_name': 'Genome', + 'module_name': 'KBaseGenomes', + 'maj_ver': 99, + 'min_ver': 77, + '_key': 'KBaseGenomes.Genome-99.77' + }) From 79222a0617a45228e684287d4b81e9312a451f13 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 24 Sep 2019 14:30:31 -0700 Subject: [PATCH 401/732] Update cached spec release for docker image and testing --- api/src/test/spec_release/spec.tar.gz | Bin 18131 -> 18368 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/api/src/test/spec_release/spec.tar.gz b/api/src/test/spec_release/spec.tar.gz index b78ce7782fc297b4a700a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%bF{E>V!HAQ=5b~hc*y;5lf4BALOqm7aHz4?v>4g&_bVOp85P6p5N9x#|Adzs<5>okAG^438sHa zr-x*x=^t=XgoMwdN!5kxbL{O4F43;zJ=OFIb`N4U<4$^C*%gM=z5VL&?WrK(hd3s5 zjIzHtB{sP6no*$CzTao3&N)U2D!jnG&6h)**~zEp0Kxx7S{8pLg#w849Tp98G}G~7|Dy->dS!HhX|Ez$AWE`{F*PjP^%NWV z=1k7>WNF+StEkBzZvs{cp85Wl+aaW(G=aW zG{!Rw?BX=fMP*#pcl6&$H(FlX!O{7}(FycO@%`cT@e-dd&wt#evsi`AjKAO(K0yNE zSvMx`V!tmH5vrPYWaqEaSEhs#N+_X(5=tncgc3?9p@b4jD4~SM5C0!8c&1zcr~&{d CO%)aZ From f89c301c24ac113b07290d1c0b321f169210fb77 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Thu, 26 Sep 2019 14:20:29 -0700 Subject: [PATCH 402/732] Get taxon doc from object ref (#105) --- .../ncbi_taxon_get_taxon_from_ws_obj.yaml | 22 +++++++++++++++++++ spec/test/stored_queries/test_ncbi_tax.py | 14 ++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 spec/stored_queries/ncbi_tax/ncbi_taxon_get_taxon_from_ws_obj.yaml diff --git a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_taxon_from_ws_obj.yaml b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_taxon_from_ws_obj.yaml new file mode 100644 index 00000000..c25450cc --- /dev/null +++ b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_taxon_from_ws_obj.yaml @@ -0,0 +1,22 @@ +# Fetch a taxon document from a workspace object reference +name: ncbi_taxon_get_taxon_from_ws_obj +params: + type: object + required: [obj_ref, ts] + properties: + obj_ref: + type: string + title: Workspace versioned object reference + ts: + type: integer + title: Versioning timestamp +query_prefix: with ncbi_taxon +query: | + for obj in ws_object_version + filter obj._key == @obj_ref + filter obj.is_public or obj.workspace_id IN ws_ids + for tax in 1 outbound obj ws_obj_version_has_taxon + filter tax.created <= @ts AND tax.expired >= @ts + limit 1 + return tax + diff --git a/spec/test/stored_queries/test_ncbi_tax.py b/spec/test/stored_queries/test_ncbi_tax.py index 62c5f991..e7d4373f 100644 --- a/spec/test/stored_queries/test_ncbi_tax.py +++ b/spec/test/stored_queries/test_ncbi_tax.py @@ -303,3 +303,17 @@ def test_get_associated_objs(self): 'min_ver': 77, '_key': 'KBaseGenomes.Genome-99.77' }) + + def test_get_taxon_from_ws_obj(self): + """Fetch the taxon vertex from a workspace versioned id.""" + resp = requests.post( + _CONF['re_api_url'] + '/api/v1/query_results', + params={'stored_query': 'ncbi_taxon_get_taxon_from_ws_obj'}, + data=json.dumps({'ts': _NOW, 'obj_ref': '1:1:1'}) + ).json() + self.assertEqual(resp['count'], 1) + self.assertDictContainsSubset({ + 'id': '1', + 'scientific_name': 'Bacteria', + 'rank': 'Domain' + }, resp['result'][0]) From 768bdc495aa03bcccef39d27d849b11d5735eb34 Mon Sep 17 00:00:00 2001 From: Gavin Date: Fri, 27 Sep 2019 12:25:48 -0700 Subject: [PATCH 403/732] Update feature key regex Some features have non-word characters. Update the feature key regex to allow any ADB allowed characters. Also remove the regex for the feature ID so the original feature ID can be included. --- spec/schemas/ws/ws_genome_features.yaml | 3 +-- spec/schemas/ws/ws_genome_has_feature.yaml | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/spec/schemas/ws/ws_genome_features.yaml b/spec/schemas/ws/ws_genome_features.yaml index 49ab4bbf..4cc17253 100644 --- a/spec/schemas/ws/ws_genome_features.yaml +++ b/spec/schemas/ws/ws_genome_features.yaml @@ -14,12 +14,11 @@ schema: type: string description: The UPA and feature ID for this data examples: ["35414:73:1_RSP_4039"] - pattern: "^\\d+:\\d+:\\d+_\\w*$" # may need to expand the feature ID part + pattern: "^\\d+:\\d+:\\d+_[a-zA-Z0-9_\-:\.@\(\)\+,=;\$!\*'%]*$" feature_id: type: string description: The unique ID of the feature within the genome examples: ["RSP_4039"] - pattern: "^\\w*$" # may need to expand workspace_id: type: integer description: The workspace ID for the genome containing this feature diff --git a/spec/schemas/ws/ws_genome_has_feature.yaml b/spec/schemas/ws/ws_genome_has_feature.yaml index e86df6d0..2e952bd3 100644 --- a/spec/schemas/ws/ws_genome_has_feature.yaml +++ b/spec/schemas/ws/ws_genome_has_feature.yaml @@ -10,7 +10,7 @@ schema: type: string examples: ['75:82:3_RSP_4039'] description: The unique, permanent ID of this edge. Identical to the feature _key entry. - pattern: "^\\d+:\\d+:\\d+_\\w*$" # may need to expand the feature ID part + pattern: "^\\d+:\\d+:\\d+_[a-zA-Z0-9_\-:\.@\(\)\+,=;\$!\*'%]*$" _from: type: string examples: ['ws_object_version/75:82:3'] From fa6facbbf3b409d38277ad559c535cbadbb29d7c Mon Sep 17 00:00:00 2001 From: Gavin Date: Fri, 27 Sep 2019 13:20:52 -0700 Subject: [PATCH 404/732] Fix regex escapes --- spec/schemas/ws/ws_genome_features.yaml | 2 +- spec/schemas/ws/ws_genome_has_feature.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/schemas/ws/ws_genome_features.yaml b/spec/schemas/ws/ws_genome_features.yaml index 4cc17253..f75851a1 100644 --- a/spec/schemas/ws/ws_genome_features.yaml +++ b/spec/schemas/ws/ws_genome_features.yaml @@ -14,7 +14,7 @@ schema: type: string description: The UPA and feature ID for this data examples: ["35414:73:1_RSP_4039"] - pattern: "^\\d+:\\d+:\\d+_[a-zA-Z0-9_\-:\.@\(\)\+,=;\$!\*'%]*$" + pattern: "^\\d+:\\d+:\\d+_[a-zA-Z0-9_\\-:\\.@\\(\\)\\+,=;\\$!\\*'%]*$" feature_id: type: string description: The unique ID of the feature within the genome diff --git a/spec/schemas/ws/ws_genome_has_feature.yaml b/spec/schemas/ws/ws_genome_has_feature.yaml index 2e952bd3..52e3563a 100644 --- a/spec/schemas/ws/ws_genome_has_feature.yaml +++ b/spec/schemas/ws/ws_genome_has_feature.yaml @@ -10,7 +10,7 @@ schema: type: string examples: ['75:82:3_RSP_4039'] description: The unique, permanent ID of this edge. Identical to the feature _key entry. - pattern: "^\\d+:\\d+:\\d+_[a-zA-Z0-9_\-:\.@\(\)\+,=;\$!\*'%]*$" + pattern: "^\\d+:\\d+:\\d+_[a-zA-Z0-9_\\-:\\.@\\(\\)\\+,=;\\$!\\*'%]*$" _from: type: string examples: ['ws_object_version/75:82:3'] From d1c0b1e6ee1e7a57d71dd7850219814094e65028 Mon Sep 17 00:00:00 2001 From: Gavin Date: Fri, 27 Sep 2019 13:36:51 -0700 Subject: [PATCH 405/732] Add comment re source of regex --- spec/schemas/ws/ws_genome_features.yaml | 1 + spec/schemas/ws/ws_genome_has_feature.yaml | 1 + 2 files changed, 2 insertions(+) diff --git a/spec/schemas/ws/ws_genome_features.yaml b/spec/schemas/ws/ws_genome_features.yaml index f75851a1..be7d320a 100644 --- a/spec/schemas/ws/ws_genome_features.yaml +++ b/spec/schemas/ws/ws_genome_features.yaml @@ -14,6 +14,7 @@ schema: type: string description: The UPA and feature ID for this data examples: ["35414:73:1_RSP_4039"] + # see https://www.arangodb.com/docs/stable/data-modeling-naming-conventions-document-keys.html pattern: "^\\d+:\\d+:\\d+_[a-zA-Z0-9_\\-:\\.@\\(\\)\\+,=;\\$!\\*'%]*$" feature_id: type: string diff --git a/spec/schemas/ws/ws_genome_has_feature.yaml b/spec/schemas/ws/ws_genome_has_feature.yaml index 52e3563a..4fe3da88 100644 --- a/spec/schemas/ws/ws_genome_has_feature.yaml +++ b/spec/schemas/ws/ws_genome_has_feature.yaml @@ -10,6 +10,7 @@ schema: type: string examples: ['75:82:3_RSP_4039'] description: The unique, permanent ID of this edge. Identical to the feature _key entry. + # see https://www.arangodb.com/docs/stable/data-modeling-naming-conventions-document-keys.html pattern: "^\\d+:\\d+:\\d+_[a-zA-Z0-9_\\-:\\.@\\(\\)\\+,=;\\$!\\*'%]*$" _from: type: string From 79649eda4e6c3d18f3612762011a6e4d2843914d Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Mon, 30 Sep 2019 09:43:01 -0700 Subject: [PATCH 406/732] Update cached test specs --- api/src/test/spec_release/spec.tar.gz | Bin 18368 -> 18579 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/api/src/test/spec_release/spec.tar.gz b/api/src/test/spec_release/spec.tar.gz index 9b2774976a1a9fd48cf245470046f38b4efd7781..4059a2a8affae812b186d35d543793e8d5f2b114 100644 GIT binary patch delta 18223 zcmW(+RZv|`v&Eg@?oMzgxI2L)I0V-a+f&(>2y9T=OJuMnL9R-&~%8 z5%7Y}1lB?zRbUv;3upW3>y(|R$eBaY!g>9scipT#e*kd@3`ZDlX`nL9`!E#3IfMHE z52p>qqsB;fM!bE*3#{di`|iYsoLsepTKTfM8odj{s)hBYHaD z-cz&%2WImn+kRa0Aln`<&^BKxcpOLS{>EMLaG!?(|5UheGI0PriuQsXR%LH84I2f$&dt`WL$0WFe90 zVG#%3xs4JWg~cY-b7lhNN!J6^Tb5AxpVwUn?PfbBz%O-g#d3G>7a4vDtAfXtAFjv`r6V{($|C*TJLB)FBdv`=S2$Fuu1w;;tr90 z=l!MFPm|LEun+QD+fkA_X@v*f@QGA?89k`>U(N1vW4&u+h7v5gL>WuShN(^k3aU|l zpNEKXiS#+RKcJCrE}!;7LNR2{h5f%Q7@vodsa320Q~}~%cQ%M1xv#}ld+)@ZGbcqA z^ti@;#aj^GwLnMOML5DDd^d03hLi4|u6JIXu^-<$#8^rMaVM&QDf^DmxfbCLzXTOJ zZ!d3K3ZoyEWMrS-ILgs@Pe&sUhD!E@;O@4(H9vaxF}d|U?|LW_tmIgJE+?3l*0~SE z;3=x&GXTVPH+(cg{sAnm2Q-v=&(s(L!x_Fbj%n)l0>IBt+xbRD9ge?eU7k;l2Gxlm zKk|$rj*RLOexmKqOTuE{oqwo^2k*`O?(N|X_3ZvZQ7>!e#N>j+UL-7W_R`pbjA|vv zy9D*Rv=p3OgRidvZ?nZWlLrd<5`G^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~>A6)lCTz^9D-TtP^;lPKwqN=lzxV(QJ{KO8jt z(HI9e7`vJoCDqrj9V^SfGM)z0h5KWJAX|w8p%?b#ZV*3qSYWC6%UC9*Q=9IuPX@Y$h<&x%Tu)S zRaaNR#)WiszsJS;PF{xfc-9oJN@@J;7h*4k3oA)(SY25mxuM)u|a;(t@i$3olr7#&qO zW{-#MG?cNp+N0y;EP0vdrj`DTAco8Vo3a>csN6Ye<45H zJxl+>b?HC2#z_2!V8!7rBgqR==zpg>=xXP`!JzX0D+6-h|2AC!zxy-as%>_k8mZXv zu8;#@X{WIA4`C~O>Q**F`5AMfAnn28$D1g{i;lX%+q2t|et)BV_4F|o2vyCg3mR;i zD{s1V7)o5Tpv+|J&meTv#B(5cuDb6cL7KAo#wnN@bFh)FH3rX`;>2dez>jp=#d*E5n*IAEo$m zQ*F3Zh=mpKU3kK8w!De#Z8AyOueu3M#0ef(jlF{0}_a%lZJQ0st>8B)tFt From e9b413a681d12176b4e4956e8869b52d4d56fb91 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Mon, 30 Sep 2019 09:47:43 -0700 Subject: [PATCH 407/732] Add a function in index creation to check for existence first. Add a test case. (#58) --- .../utils/arango_client.py | 62 +++++++------------ api/src/test/test_api_v1.py | 13 +++- 2 files changed, 33 insertions(+), 42 deletions(-) diff --git a/api/src/relation_engine_server/utils/arango_client.py b/api/src/relation_engine_server/utils/arango_client.py index 15deb6c8..c7df3745 100644 --- a/api/src/relation_engine_server/utils/arango_client.py +++ b/api/src/relation_engine_server/utils/arango_client.py @@ -110,7 +110,15 @@ def create_collection(name, config): def _create_indexes(coll_name, config): """Create indexes for a collection""" url = _CONF['api_url'] + '/index' + # Fetch existing indexes + auth = (_CONF['db_user'], _CONF['db_pass']) + resp = requests.get(url, params={'collection': coll_name}, auth=auth) + if not resp.ok: + raise RuntimeError(resp.text) + indexes = resp.json()['indexes'] for idx_conf in config['indexes']: + if _index_exists(idx_conf, indexes): + continue idx_type = idx_conf['type'] idx_url = url + '#' + idx_type idx_conf['type'] = idx_type @@ -122,6 +130,19 @@ def _create_indexes(coll_name, config): ) if not resp.ok: raise RuntimeError(resp.text) + print(f'Created new {idx_type} index on {idx_conf["fields"]} for {coll_name}.') + + +def _index_exists(idx_conf, indexes): + """ + Check if an index for a collection was already created in the database. + idx_conf - index config object from a collection schema + indexes - result of request to arangodb's /_api/index?collection=coll_name + """ + for idx in indexes: + if idx_conf['fields'] == idx['fields'] and idx_conf['type'] == idx['type']: + return True + return False def import_from_file(file_path, query): @@ -138,47 +159,6 @@ def import_from_file(file_path, query): return resp.text -# def _init_readonly_user(): -# """ -# Using the admin user, initialize an admin readonly user for use with ad-hoc queries. -# If the user cannot be created, we raise an ArangoServerError -# If the user already exists, or is successfully created, we return None and do not raise. -# """ -# user = _CONF['db_readonly_user'] -# # Check if the user exists, in which case this is a no-op -# resp = requests.get( -# _CONF['api_url'] + '/user/' + user, -# auth=(_CONF['db_user'], _CONF['db_pass']) -# ) -# if resp.status_code == 200: -# return -# # Create the user -# resp = requests.post( -# _CONF['api_url'] + '/user', -# data=json.dumps({'user': user, 'passwd': _CONF['db_readonly_user']}), -# auth=(_CONF['db_user'], _CONF['db_pass']) -# ) -# if resp.status_code != 201: -# raise ArangoServerError(resp.text) -# db_grant_path = _CONF['api_url'] + '/user/' + user + '/database/' + _CONF['db_name'] -# # Grant read access to the current database -# resp = requests.put( -# db_grant_path, -# data='{"grant": "ro"}', -# auth=(_CONF['db_user'], _CONF['db_pass']) -# ) -# if resp.status_code != 200: -# raise ArangoServerError(resp.text) -# # Grant read access to all collections -# resp = requests.put( -# db_grant_path + '/*', -# data='{"grant": "ro"}', -# auth=(_CONF['db_user'], _CONF['db_pass']) -# ) -# if not resp.ok: -# raise ArangoServerError(resp.text) - - class ArangoServerError(Exception): """A request to the ArangoDB server has failed (non-2xx).""" diff --git a/api/src/test/test_api_v1.py b/api/src/test/test_api_v1.py index 9cab54ae..2919b927 100644 --- a/api/src/test/test_api_v1.py +++ b/api/src/test/test_api_v1.py @@ -8,6 +8,10 @@ import json import os +from src.relation_engine_server.utils.config import get_config + +_CONF = get_config() + # Use the mock auth tokens NON_ADMIN_TOKEN = 'non_admin_token' ADMIN_TOKEN = 'admin_token' @@ -80,6 +84,14 @@ def test_update_specs(self): resp_json = resp.json() self.assertEqual(resp.status_code, 200) self.assertTrue(len(resp_json['status'])) + # Test that the indexes get created and not duplicated + url = _CONF['db_url'] + '/_api/index' + auth = (_CONF['db_user'], _CONF['db_pass']) + resp = requests.get(url, params={'collection': 'ncbi_taxon'}, auth=auth).json() + indexes = resp['indexes'] + self.assertEqual(len(indexes), 2) + fields = [i['fields'] for i in indexes] + self.assertEqual(fields, [['_key'], ['scientific_name']]) def test_list_stored_queries(self): """Test the listing out of saved AQL stored queries.""" @@ -239,7 +251,6 @@ def test_admin_query(self): headers=HEADERS_ADMIN, data=json.dumps({'query': query, 'count': 1}) ).json() - print('resp!?', resp) self.assertEqual(resp['count'], 1) self.assertEqual(len(resp['results']), 1) From 255fcd40747bd5a5905d4f838b0e8c36a0c2cff4 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Mon, 30 Sep 2019 16:54:26 -0700 Subject: [PATCH 408/732] Give response status 400 on errors saving documents --- .../api_versions/api_v1.py | 7 +++-- .../utils/arango_client.py | 10 ++++++- .../utils/bulk_import.py | 3 +-- api/src/test/test_api_v1.py | 26 +++++++++++++++++-- 4 files changed, 39 insertions(+), 7 deletions(-) diff --git a/api/src/relation_engine_server/api_versions/api_v1.py b/api/src/relation_engine_server/api_versions/api_v1.py index 0b99b477..7c91b5d3 100644 --- a/api/src/relation_engine_server/api_versions/api_v1.py +++ b/api/src/relation_engine_server/api_versions/api_v1.py @@ -119,8 +119,11 @@ def save_documents(): query['onDuplicate'] = flask.request.args['on_duplicate'] if flask.request.args.get('overwrite'): query['overwrite'] = 'true' - resp_text = bulk_import.bulk_import(query) - return flask.jsonify(resp_text) + resp = bulk_import.bulk_import(query) + if resp.get('errors') > 0: + return (flask.jsonify(resp), 400) + else: + return flask.jsonify(resp) @api_v1.route('/config', methods=['GET']) diff --git a/api/src/relation_engine_server/utils/arango_client.py b/api/src/relation_engine_server/utils/arango_client.py index c7df3745..89b3016e 100644 --- a/api/src/relation_engine_server/utils/arango_client.py +++ b/api/src/relation_engine_server/utils/arango_client.py @@ -1,6 +1,7 @@ """ Make ajax requests to the ArangoDB server. """ +import sys import os import requests import json @@ -156,7 +157,14 @@ def import_from_file(file_path, query): ) if not resp.ok: raise ArangoServerError(resp.text) - return resp.text + resp_json = resp.json() + if resp_json.get('errors', 0) > 0: + err_msg = f"{resp_json['errors']} errors creating documents\n" + sys.stderr.write(err_msg) + details = resp_json.get('details') + if details: + sys.stderr.write(f"Error details:\n{details[0]}\n") + return resp_json class ArangoServerError(Exception): diff --git a/api/src/relation_engine_server/utils/bulk_import.py b/api/src/relation_engine_server/utils/bulk_import.py index c643435b..3faa0c25 100644 --- a/api/src/relation_engine_server/utils/bulk_import.py +++ b/api/src/relation_engine_server/utils/bulk_import.py @@ -31,8 +31,7 @@ def bulk_import(query_params): json_line['updated_at'] = int(time.time() * 1000) temp_fd.write(json.dumps(json_line) + '\n') temp_fd.close() - resp_text = import_from_file(temp_fd.name, query_params) - resp_json = json.loads(resp_text) + resp_json = import_from_file(temp_fd.name, query_params) finally: # Always remove the temp file os.remove(temp_fd.name) diff --git a/api/src/test/test_api_v1.py b/api/src/test/test_api_v1.py index 2919b927..689fba84 100644 --- a/api/src/test/test_api_v1.py +++ b/api/src/test/test_api_v1.py @@ -87,8 +87,9 @@ def test_update_specs(self): # Test that the indexes get created and not duplicated url = _CONF['db_url'] + '/_api/index' auth = (_CONF['db_user'], _CONF['db_pass']) - resp = requests.get(url, params={'collection': 'ncbi_taxon'}, auth=auth).json() - indexes = resp['indexes'] + resp = requests.get(url, params={'collection': 'ncbi_taxon'}, auth=auth) + resp_json = resp.json() + indexes = resp_json['indexes'] self.assertEqual(len(indexes), 2) fields = [i['fields'] for i in indexes] self.assertEqual(fields, [['_key'], ['scientific_name']]) @@ -197,11 +198,19 @@ def test_update_documents(self): def test_update_edge(self): """Test updating existing edge.""" + edges = create_test_edges(3) resp = requests.put( API_URL + '/documents', params={'on_duplicate': 'update', 'collection': 'test_edge'}, data=create_test_edges(3), headers=HEADERS_ADMIN + ) + self.assertTrue(resp.ok) + resp = requests.put( + API_URL + '/documents', + params={'on_duplicate': 'update', 'collection': 'test_edge'}, + data=edges, + headers=HEADERS_ADMIN ).json() expected = {'created': 0, 'errors': 0, 'empty': 0, 'updated': 3, 'ignored': 0, 'error': False} self.assertEqual(resp, expected) @@ -413,3 +422,16 @@ def test_auth_adhoc_query(self): headers={'Authorization': ADMIN_TOKEN} # see ./mock_workspace/endpoints.json ).json() self.assertEqual(resp['count'], 1) + + def test_save_docs_invalid(self): + """Test that an invalid bulk save returns a 400 response""" + doc = {'_from': '|||', '_to': '|||'} + resp = requests.put( + API_URL + '/documents', + params={'overwrite': True, 'collection': 'test_edge', 'display_errors': 1}, + data=json.dumps(doc), + headers=HEADERS_ADMIN + ) + self.assertEqual(resp.status_code, 400) + resp_json = resp.json() + self.assertEqual(resp_json['errors'], 1) From 6641d1b69f931b1a9543c242b0cdd8b0549c0827 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 1 Oct 2019 14:59:17 -0700 Subject: [PATCH 409/732] Add metadata to ws_workspace; add more required fields; fix tests (#107) --- spec/schemas/ws/ws_workspace.yaml | 3 ++- spec/test/stored_queries/test_ncbi_tax.py | 21 ++++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/spec/schemas/ws/ws_workspace.yaml b/spec/schemas/ws/ws_workspace.yaml index 0f2d6ed1..49e83438 100644 --- a/spec/schemas/ws/ws_workspace.yaml +++ b/spec/schemas/ws/ws_workspace.yaml @@ -3,7 +3,7 @@ type: vertex schema: "$schema": "http://json-schema.org/draft-07/schema#" type: object - required: [_key] + required: [_key, owner, max_obj_id, lock_status, name, mod_epoch, is_public, is_deleted, metadata] properties: _key: type: string @@ -33,3 +33,4 @@ schema: minimum: 0 is_public: {type: boolean} is_deleted: {type: boolean} + metadata: {type: object} diff --git a/spec/test/stored_queries/test_ncbi_tax.py b/spec/test/stored_queries/test_ncbi_tax.py index e7d4373f..0ddffcb7 100644 --- a/spec/test/stored_queries/test_ncbi_tax.py +++ b/spec/test/stored_queries/test_ncbi_tax.py @@ -13,6 +13,22 @@ _NOW = int(time.time() * 1000) +def _ws_defaults(data): + """Set some defaults for the required workspace fields.""" + defaults = { + 'owner': 'owner', + 'max_obj_id': 1, + 'lock_status': 'n', + 'name': 'wsname', + 'mod_epoch': 1, + 'is_public': True, + 'is_deleted': False, + 'metadata': {}, + } + # Merge the data with the above defaults + return dict(defaults, **data) + + def _construct_ws_obj(wsid, objid, ver, is_public=False): """Test helper to create a ws_object_version vertex.""" return { @@ -78,7 +94,10 @@ def setUpClass(cls): {'_from': 'ws_object_version/2:1:1', '_to': 'ncbi_taxon/1', 'assigned_by': 'assn2'}, ] # Create workspace objects associated to taxa - ws_docs = [{'_key': '1', 'is_public': True}, {'_key': '2', 'is_public': False}] + ws_docs = [ + _ws_defaults({'_key': '1', 'is_public': True}), + _ws_defaults({'_key': '2', 'is_public': False}), + ] ws_to_obj = [ {'_from': 'ws_workspace/1', '_to': 'ws_object_version/1:1:1'}, {'_from': 'ws_workspace/1', '_to': 'ws_object_version/1:1:2'}, From ddf9b770555427f7f8c6da02d0c3d0a156f00fdf Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 2 Oct 2019 17:32:51 -0700 Subject: [PATCH 410/732] Return workspace info for ncbi_taxon_get_associated_ws_objects; fix other stuff --- spec/schemas/ws/ws_workspace.yaml | 3 - .../ncbi_taxon_get_associated_ws_objects.yaml | 23 ++++-- spec/test/helpers.py | 6 ++ spec/test/stored_queries/helpers.py | 2 +- spec/test/stored_queries/test_ncbi_tax.py | 76 ++++++++++++------- 5 files changed, 71 insertions(+), 39 deletions(-) diff --git a/spec/schemas/ws/ws_workspace.yaml b/spec/schemas/ws/ws_workspace.yaml index 49e83438..4ed3f5c2 100644 --- a/spec/schemas/ws/ws_workspace.yaml +++ b/spec/schemas/ws/ws_workspace.yaml @@ -10,9 +10,6 @@ schema: description: The workspace ID for this workspace examples: ['35414'] pattern: "^\\d+$" - narr_name: - type: string - title: Narrative name owner: type: string title: Username of workspace owner diff --git a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_associated_ws_objects.yaml b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_associated_ws_objects.yaml index abae3ec1..5fb04953 100644 --- a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_associated_ws_objects.yaml +++ b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_associated_ws_objects.yaml @@ -33,7 +33,7 @@ params: items: {type: string} description: Taxon edge fields to keep in the results default: null -query_prefix: WITH ws_object_version, ws_type_version +query_prefix: WITH ws_object_version, ws_type_version, ws_workspace query: | let count = COUNT( for tax in ncbi_taxon @@ -51,12 +51,19 @@ query: | for obj, e in 1 inbound tax ws_obj_version_has_taxon filter obj.is_public or obj.workspace_id IN ws_ids limit @offset, @limit - for type in 1 outbound obj ws_obj_instance_of_type - let t = KEEP(type, ['_key', 'module_name', 'type_name', 'maj_ver', 'min_ver']) - let o = MERGE(obj, {type: t}) - return { - ws_obj: @select_obj ? KEEP(o, @select_obj) : o, - edge: @select_edge ? KEEP(e, @select_edge) : e - } + let type = first( + for type in 1 outbound obj ws_obj_instance_of_type + return KEEP(type, ['_key', 'module_name', 'type_name', 'maj_ver', 'min_ver']) + ) + let unver_id = CONCAT("ws_object/", TO_STRING(obj.workspace_id), ':', TO_STRING(obj.object_id)) + let ws_info = first( + for ws in 1 inbound unver_id ws_workspace_contains_obj + return KEEP(ws, ['owner', 'metadata', 'is_public', 'is_deleted', 'mod_epoch']) + ) + let o = MERGE(obj, {type, ws_info}) + return { + ws_obj: @select_obj ? KEEP(o, @select_obj) : o, + edge: @select_edge ? KEEP(e, @select_edge) : e + } ) return {results, total_count: count} diff --git a/spec/test/helpers.py b/spec/test/helpers.py index 4ad8856e..0d362dca 100644 --- a/spec/test/helpers.py +++ b/spec/test/helpers.py @@ -54,6 +54,12 @@ def wait_for_api(): time.sleep(2) +def assert_subset(testCls, subset, _dict): + """Replacement for the deprecated `assertDictContainsSubset` method.""" + for (key, val) in subset.items(): + testCls.assertEqual(subset.get(key), _dict.get(key)) + + if __name__ == '__main__': if sys.argv[1] == 'wait_for_api': wait_for_api() diff --git a/spec/test/stored_queries/helpers.py b/spec/test/stored_queries/helpers.py index 35924555..e873aa47 100644 --- a/spec/test/stored_queries/helpers.py +++ b/spec/test/stored_queries/helpers.py @@ -10,7 +10,7 @@ def create_test_docs(coll_name, docs): body = '\n'.join([json.dumps(d) for d in docs]) resp = requests.put( _CONF['re_api_url'] + '/api/v1/documents', - params={'overwrite': True, 'collection': coll_name}, + params={'overwrite': True, 'collection': coll_name, 'display_errors': '1'}, data=body, headers={'Authorization': 'admin_token'} ) diff --git a/spec/test/stored_queries/test_ncbi_tax.py b/spec/test/stored_queries/test_ncbi_tax.py index 0ddffcb7..b4e1c5e2 100644 --- a/spec/test/stored_queries/test_ncbi_tax.py +++ b/spec/test/stored_queries/test_ncbi_tax.py @@ -6,7 +6,7 @@ import unittest import requests -from test.helpers import get_config +from test.helpers import get_config, assert_subset from test.stored_queries.helpers import create_test_docs _CONF = get_config() @@ -23,13 +23,13 @@ def _ws_defaults(data): 'mod_epoch': 1, 'is_public': True, 'is_deleted': False, - 'metadata': {}, + 'metadata': {'narrative_nice_name': 'narrname'}, } # Merge the data with the above defaults return dict(defaults, **data) -def _construct_ws_obj(wsid, objid, ver, is_public=False): +def _construct_ws_obj_ver(wsid, objid, ver, is_public=False): """Test helper to create a ws_object_version vertex.""" return { '_key': f"{wsid}:{objid}:{ver}", @@ -45,6 +45,17 @@ def _construct_ws_obj(wsid, objid, ver, is_public=False): } +def _construct_ws_obj(wsid, objid, is_public=False): + """Test helper to create a ws_object vertex.""" + return { + '_key': f"{wsid}:{objid}", + 'workspace_id': wsid, + 'object_id': objid, + 'deleted': False, + 'is_public': is_public, + } + + def _create_delta_test_docs(coll_name, docs, edge=False): """Add in delta required fields.""" if edge: @@ -83,10 +94,14 @@ def setUpClass(cls): {'_from': 'ncbi_taxon/6', '_to': 'ncbi_taxon/4', 'child_type': 't'}, {'_from': 'ncbi_taxon/7', '_to': 'ncbi_taxon/4', 'child_type': 't'}, ] + obj_ver_docs = [ + _construct_ws_obj_ver(1, 1, 1, is_public=True), + _construct_ws_obj_ver(1, 1, 2, is_public=True), + _construct_ws_obj_ver(2, 1, 1, is_public=False), + ] obj_docs = [ - _construct_ws_obj(1, 1, 1, is_public=True), - _construct_ws_obj(1, 1, 2, is_public=True), - _construct_ws_obj(2, 1, 1, is_public=False), + _construct_ws_obj(1, 1, is_public=True), + _construct_ws_obj(2, 1, is_public=False), ] obj_to_taxa_docs = [ {'_from': 'ws_object_version/1:1:1', '_to': 'ncbi_taxon/1', 'assigned_by': 'assn1'}, @@ -99,9 +114,8 @@ def setUpClass(cls): _ws_defaults({'_key': '2', 'is_public': False}), ] ws_to_obj = [ - {'_from': 'ws_workspace/1', '_to': 'ws_object_version/1:1:1'}, - {'_from': 'ws_workspace/1', '_to': 'ws_object_version/1:1:2'}, - {'_from': 'ws_workspace/2', '_to': 'ws_object_version/2:1:1'}, + {'_from': 'ws_workspace/1', '_to': 'ws_object/1:1'}, + {'_from': 'ws_workspace/2', '_to': 'ws_object/2:1'}, ] ws_type_version_docs = [ {'_key': 'KBaseGenomes.Genome-99.77', 'module_name': 'KBaseGenomes', @@ -113,10 +127,11 @@ def setUpClass(cls): ] _create_delta_test_docs('ncbi_taxon', taxon_docs) _create_delta_test_docs('ncbi_child_of_taxon', child_docs, edge=True) - _create_delta_test_docs('ws_object_version', obj_docs) - _create_delta_test_docs('ws_obj_version_has_taxon', obj_to_taxa_docs, edge=True) - _create_delta_test_docs('ws_workspace', ws_docs) - _create_delta_test_docs('ws_workspace_contains_obj', ws_to_obj, edge=True) + create_test_docs('ws_obj_version_has_taxon', obj_to_taxa_docs) + create_test_docs('ws_object', obj_docs) + create_test_docs('ws_workspace', ws_docs) + create_test_docs('ws_workspace_contains_obj', ws_to_obj) + create_test_docs('ws_object_version', obj_ver_docs) create_test_docs('ws_obj_instance_of_type', ws_obj_instance_of_type_docs) create_test_docs('ws_type_version', ws_type_version_docs) @@ -304,7 +319,7 @@ def test_get_associated_objs(self): resp = requests.post( _CONF['re_api_url'] + '/api/v1/query_results', params={'stored_query': 'ncbi_taxon_get_associated_ws_objects'}, - data=json.dumps({'ts': _NOW, 'taxon_id': '1', 'select_obj': ['_id', 'type'], + data=json.dumps({'ts': _NOW, 'taxon_id': '1', 'select_obj': ['_id', 'type', 'ws_info'], 'select_edge': ['assigned_by']}), ).json() self.assertEqual(resp['count'], 1) @@ -322,17 +337,24 @@ def test_get_associated_objs(self): 'min_ver': 77, '_key': 'KBaseGenomes.Genome-99.77' }) + self.assertEqual(results['results'][0]['ws_obj']['ws_info'], { + 'owner': 'owner', + 'metadata': {'narrative_nice_name': 'narrname'}, + 'is_public': True, + 'is_deleted': False, + 'mod_epoch': 1 + }) - def test_get_taxon_from_ws_obj(self): - """Fetch the taxon vertex from a workspace versioned id.""" - resp = requests.post( - _CONF['re_api_url'] + '/api/v1/query_results', - params={'stored_query': 'ncbi_taxon_get_taxon_from_ws_obj'}, - data=json.dumps({'ts': _NOW, 'obj_ref': '1:1:1'}) - ).json() - self.assertEqual(resp['count'], 1) - self.assertDictContainsSubset({ - 'id': '1', - 'scientific_name': 'Bacteria', - 'rank': 'Domain' - }, resp['result'][0]) + def test_get_taxon_from_ws_obj(self): + """Fetch the taxon vertex from a workspace versioned id.""" + resp = requests.post( + _CONF['re_api_url'] + '/api/v1/query_results', + params={'stored_query': 'ncbi_taxon_get_taxon_from_ws_obj'}, + data=json.dumps({'ts': _NOW, 'obj_ref': '1:1:1'}) + ).json() + self.assertEqual(resp['count'], 1) + assert_subset(self, { + 'id': '1', + 'scientific_name': 'Bacteria', + 'rank': 'Domain' + }, resp['results'][0]) From 4cbfbb4ffe34f15a6340463cfb37688ac0715ee8 Mon Sep 17 00:00:00 2001 From: Zhenyuan Lu Date: Thu, 3 Oct 2019 10:44:08 -0400 Subject: [PATCH 411/732] add new GO queries --- .../GO/GO_get_associated_ws_objects.yaml | 47 +++++++++++++++++++ .../GO/GO_get_terms_from_ws_obj.yaml | 40 ++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 spec/stored_queries/GO/GO_get_associated_ws_objects.yaml create mode 100644 spec/stored_queries/GO/GO_get_terms_from_ws_obj.yaml diff --git a/spec/stored_queries/GO/GO_get_associated_ws_objects.yaml b/spec/stored_queries/GO/GO_get_associated_ws_objects.yaml new file mode 100644 index 00000000..3c13e18d --- /dev/null +++ b/spec/stored_queries/GO/GO_get_associated_ws_objects.yaml @@ -0,0 +1,47 @@ +# Get the associated ws objects of this term + +name: GO_get_associated_ws_objects +params: + type: object + required: [id, ts] + properties: + id: + type: string + title: Document ID + description: GO id of the term you want to get the children of + limit: + type: integer + title: Maximum result limit + default: 20 + maximum: 1000 + offset: + type: integer + title: Result offset for pagination + default: 0 + maximum: 100000 + ts: + type: integer + title: Versioning timestamp +query_prefix: ws_genome_features, ws_object_version +query: | + FOR t in GO_terms + FILTER t.id == @id + FILTER t.created <= @ts AND t.expired >= @ts + limit 1 + FOR v, e, p IN 2 INBOUND t ws_feature_has_GO_annotation, ws_genome_has_feature + FILTER p.edges[0].created <= @ts AND p.edges[0].expired >= @ts + FILTER v.is_public + SORT v.workspace_id ASC + LIMIT @offset, @limit + RETURN DISTINCT { + ws_obj: { + workspace_id: v.workspace_id, + object_id: v.object_id, + version: v.version, + name: v.name + }, + feature: { + feature_id: p.vertices[1].feature_id, + updated_at: p.vertices[1].updated_at + } + } diff --git a/spec/stored_queries/GO/GO_get_terms_from_ws_obj.yaml b/spec/stored_queries/GO/GO_get_terms_from_ws_obj.yaml new file mode 100644 index 00000000..c3fc5fcc --- /dev/null +++ b/spec/stored_queries/GO/GO_get_terms_from_ws_obj.yaml @@ -0,0 +1,40 @@ +# Get the terms from a workspace object reference + +name: GO_get_terms_from_ws_obj +params: + type: object + required: [obj_ref, ts] + properties: + obj_ref: + type: string + title: Workspace versioned object reference + limit: + type: integer + title: Maximum result limit + default: 20 + maximum: 1000 + offset: + type: integer + title: Result offset for pagination + default: 0 + maximum: 100000 + ts: + type: integer + title: Versioning timestamp +query_prefix: ws_genome_features, GO_terms +query: | + FOR o in ws_object_version + FILTER o._key == @obj_ref + FILTER o.is_public + LIMIT 1 + FOR v, e, p IN 2 OUTBOUND o ws_genome_has_feature, ws_feature_has_GO_annotation + FILTER p.edges[1].created <= @ts AND p.edges[1].expired >= @ts + FILTER v.created <= @ts AND v.expired >= @ts + LIMIT @offset, @limit + RETURN DISTINCT { + term: v, + feature: { + feature_id: p.vertices[1].feature_id, + updated_at: p.vertices[1].updated_at + } + } From 640a21e4ee81ae79d8fcdd6799f84251a08cdcd1 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Thu, 3 Oct 2019 09:38:49 -0700 Subject: [PATCH 412/732] Capitalize the stuff in the query --- .../ncbi_taxon_get_associated_ws_objects.yaml | 50 +++++++++---------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_associated_ws_objects.yaml b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_associated_ws_objects.yaml index 5fb04953..c26ebf2e 100644 --- a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_associated_ws_objects.yaml +++ b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_associated_ws_objects.yaml @@ -35,35 +35,35 @@ params: default: null query_prefix: WITH ws_object_version, ws_type_version, ws_workspace query: | - let count = COUNT( - for tax in ncbi_taxon - filter tax.id == @taxon_id - filter tax.created <= @ts AND tax.expired >= @ts - limit 1 - for obj in 1..1 inbound tax ws_obj_version_has_taxon - return 1 + LET count = COUNT( + FOR tax IN ncbi_taxon + FILTER tax.id == @taxon_id + FILTER tax.created <= @ts AND tax.expired >= @ts + LIMIT 1 + FOR obj IN 1..1 INBOUND tax ws_obj_version_has_taxon + RETURN 1 ) - let results = ( - for tax in ncbi_taxon - filter tax.id == @taxon_id - filter tax.created <= @ts AND tax.expired >= @ts - limit 1 - for obj, e in 1 inbound tax ws_obj_version_has_taxon - filter obj.is_public or obj.workspace_id IN ws_ids - limit @offset, @limit - let type = first( - for type in 1 outbound obj ws_obj_instance_of_type - return KEEP(type, ['_key', 'module_name', 'type_name', 'maj_ver', 'min_ver']) + LET results = ( + FOR tax IN ncbi_taxon + FILTER tax.id == @taxon_id + FILTER tax.created <= @ts AND tax.expired >= @ts + LIMIT 1 + FOR obj, e IN 1 INBOUND tax ws_obj_version_has_taxon + FILTER obj.is_public OR obj.workspace_id IN ws_ids + LIMIT @offset, @limit + LET type = first( + FOR type IN 1 OUTBOUND obj ws_obj_instance_of_type + RETURN KEEP(type, ['_key', 'module_name', 'type_name', 'maj_ver', 'min_ver']) ) - let unver_id = CONCAT("ws_object/", TO_STRING(obj.workspace_id), ':', TO_STRING(obj.object_id)) - let ws_info = first( - for ws in 1 inbound unver_id ws_workspace_contains_obj - return KEEP(ws, ['owner', 'metadata', 'is_public', 'is_deleted', 'mod_epoch']) + LET unver_id = CONCAT("ws_object/", TO_STRING(obj.workspace_id), ':', TO_STRING(obj.object_id)) + LET ws_info = FIRST( + FOR ws IN 1 INBOUND unver_id ws_workspace_contains_obj + RETURN KEEP(ws, ['owner', 'metadata', 'is_public', 'is_deleted', 'mod_epoch']) ) - let o = MERGE(obj, {type, ws_info}) - return { + LET o = MERGE(obj, {type, ws_info}) + RETURN { ws_obj: @select_obj ? KEEP(o, @select_obj) : o, edge: @select_edge ? KEEP(e, @select_edge) : e } ) - return {results, total_count: count} + RETURN {results, total_count: count} From 9067ee34da3804d5d0ec1300f9e93e2a81800fb8 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Thu, 3 Oct 2019 09:50:51 -0700 Subject: [PATCH 413/732] Filter out deleted workspaces and remove "is_delted" from return fields --- .../ncbi_tax/ncbi_taxon_get_associated_ws_objects.yaml | 3 ++- spec/test/stored_queries/test_ncbi_tax.py | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_associated_ws_objects.yaml b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_associated_ws_objects.yaml index c26ebf2e..5360d49d 100644 --- a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_associated_ws_objects.yaml +++ b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_associated_ws_objects.yaml @@ -58,7 +58,8 @@ query: | LET unver_id = CONCAT("ws_object/", TO_STRING(obj.workspace_id), ':', TO_STRING(obj.object_id)) LET ws_info = FIRST( FOR ws IN 1 INBOUND unver_id ws_workspace_contains_obj - RETURN KEEP(ws, ['owner', 'metadata', 'is_public', 'is_deleted', 'mod_epoch']) + FILTER !ws.is_deleted + RETURN KEEP(ws, ['owner', 'metadata', 'is_public', 'mod_epoch']) ) LET o = MERGE(obj, {type, ws_info}) RETURN { diff --git a/spec/test/stored_queries/test_ncbi_tax.py b/spec/test/stored_queries/test_ncbi_tax.py index b4e1c5e2..85fb1884 100644 --- a/spec/test/stored_queries/test_ncbi_tax.py +++ b/spec/test/stored_queries/test_ncbi_tax.py @@ -341,7 +341,6 @@ def test_get_associated_objs(self): 'owner': 'owner', 'metadata': {'narrative_nice_name': 'narrname'}, 'is_public': True, - 'is_deleted': False, 'mod_epoch': 1 }) From 56601954ea26b6147ba2949e9b1aefcc2d46e405 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Thu, 3 Oct 2019 09:52:27 -0700 Subject: [PATCH 414/732] Return workspace info for ncbi_taxon_get_associated_ws_objects (#108) * Return workspace info for ncbi_taxon_get_associated_ws_objects; fix other stuff * Capitalize the stuff in the query * Filter out deleted workspaces and remove "is_delted" from return fields --- spec/schemas/ws/ws_workspace.yaml | 3 - .../ncbi_taxon_get_associated_ws_objects.yaml | 56 ++++++++------ spec/test/helpers.py | 6 ++ spec/test/stored_queries/helpers.py | 2 +- spec/test/stored_queries/test_ncbi_tax.py | 75 ++++++++++++------- 5 files changed, 87 insertions(+), 55 deletions(-) diff --git a/spec/schemas/ws/ws_workspace.yaml b/spec/schemas/ws/ws_workspace.yaml index 49e83438..4ed3f5c2 100644 --- a/spec/schemas/ws/ws_workspace.yaml +++ b/spec/schemas/ws/ws_workspace.yaml @@ -10,9 +10,6 @@ schema: description: The workspace ID for this workspace examples: ['35414'] pattern: "^\\d+$" - narr_name: - type: string - title: Narrative name owner: type: string title: Username of workspace owner diff --git a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_associated_ws_objects.yaml b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_associated_ws_objects.yaml index abae3ec1..5360d49d 100644 --- a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_associated_ws_objects.yaml +++ b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_associated_ws_objects.yaml @@ -33,30 +33,38 @@ params: items: {type: string} description: Taxon edge fields to keep in the results default: null -query_prefix: WITH ws_object_version, ws_type_version +query_prefix: WITH ws_object_version, ws_type_version, ws_workspace query: | - let count = COUNT( - for tax in ncbi_taxon - filter tax.id == @taxon_id - filter tax.created <= @ts AND tax.expired >= @ts - limit 1 - for obj in 1..1 inbound tax ws_obj_version_has_taxon - return 1 + LET count = COUNT( + FOR tax IN ncbi_taxon + FILTER tax.id == @taxon_id + FILTER tax.created <= @ts AND tax.expired >= @ts + LIMIT 1 + FOR obj IN 1..1 INBOUND tax ws_obj_version_has_taxon + RETURN 1 ) - let results = ( - for tax in ncbi_taxon - filter tax.id == @taxon_id - filter tax.created <= @ts AND tax.expired >= @ts - limit 1 - for obj, e in 1 inbound tax ws_obj_version_has_taxon - filter obj.is_public or obj.workspace_id IN ws_ids - limit @offset, @limit - for type in 1 outbound obj ws_obj_instance_of_type - let t = KEEP(type, ['_key', 'module_name', 'type_name', 'maj_ver', 'min_ver']) - let o = MERGE(obj, {type: t}) - return { - ws_obj: @select_obj ? KEEP(o, @select_obj) : o, - edge: @select_edge ? KEEP(e, @select_edge) : e - } + LET results = ( + FOR tax IN ncbi_taxon + FILTER tax.id == @taxon_id + FILTER tax.created <= @ts AND tax.expired >= @ts + LIMIT 1 + FOR obj, e IN 1 INBOUND tax ws_obj_version_has_taxon + FILTER obj.is_public OR obj.workspace_id IN ws_ids + LIMIT @offset, @limit + LET type = first( + FOR type IN 1 OUTBOUND obj ws_obj_instance_of_type + RETURN KEEP(type, ['_key', 'module_name', 'type_name', 'maj_ver', 'min_ver']) + ) + LET unver_id = CONCAT("ws_object/", TO_STRING(obj.workspace_id), ':', TO_STRING(obj.object_id)) + LET ws_info = FIRST( + FOR ws IN 1 INBOUND unver_id ws_workspace_contains_obj + FILTER !ws.is_deleted + RETURN KEEP(ws, ['owner', 'metadata', 'is_public', 'mod_epoch']) + ) + LET o = MERGE(obj, {type, ws_info}) + RETURN { + ws_obj: @select_obj ? KEEP(o, @select_obj) : o, + edge: @select_edge ? KEEP(e, @select_edge) : e + } ) - return {results, total_count: count} + RETURN {results, total_count: count} diff --git a/spec/test/helpers.py b/spec/test/helpers.py index 4ad8856e..0d362dca 100644 --- a/spec/test/helpers.py +++ b/spec/test/helpers.py @@ -54,6 +54,12 @@ def wait_for_api(): time.sleep(2) +def assert_subset(testCls, subset, _dict): + """Replacement for the deprecated `assertDictContainsSubset` method.""" + for (key, val) in subset.items(): + testCls.assertEqual(subset.get(key), _dict.get(key)) + + if __name__ == '__main__': if sys.argv[1] == 'wait_for_api': wait_for_api() diff --git a/spec/test/stored_queries/helpers.py b/spec/test/stored_queries/helpers.py index 35924555..e873aa47 100644 --- a/spec/test/stored_queries/helpers.py +++ b/spec/test/stored_queries/helpers.py @@ -10,7 +10,7 @@ def create_test_docs(coll_name, docs): body = '\n'.join([json.dumps(d) for d in docs]) resp = requests.put( _CONF['re_api_url'] + '/api/v1/documents', - params={'overwrite': True, 'collection': coll_name}, + params={'overwrite': True, 'collection': coll_name, 'display_errors': '1'}, data=body, headers={'Authorization': 'admin_token'} ) diff --git a/spec/test/stored_queries/test_ncbi_tax.py b/spec/test/stored_queries/test_ncbi_tax.py index 0ddffcb7..85fb1884 100644 --- a/spec/test/stored_queries/test_ncbi_tax.py +++ b/spec/test/stored_queries/test_ncbi_tax.py @@ -6,7 +6,7 @@ import unittest import requests -from test.helpers import get_config +from test.helpers import get_config, assert_subset from test.stored_queries.helpers import create_test_docs _CONF = get_config() @@ -23,13 +23,13 @@ def _ws_defaults(data): 'mod_epoch': 1, 'is_public': True, 'is_deleted': False, - 'metadata': {}, + 'metadata': {'narrative_nice_name': 'narrname'}, } # Merge the data with the above defaults return dict(defaults, **data) -def _construct_ws_obj(wsid, objid, ver, is_public=False): +def _construct_ws_obj_ver(wsid, objid, ver, is_public=False): """Test helper to create a ws_object_version vertex.""" return { '_key': f"{wsid}:{objid}:{ver}", @@ -45,6 +45,17 @@ def _construct_ws_obj(wsid, objid, ver, is_public=False): } +def _construct_ws_obj(wsid, objid, is_public=False): + """Test helper to create a ws_object vertex.""" + return { + '_key': f"{wsid}:{objid}", + 'workspace_id': wsid, + 'object_id': objid, + 'deleted': False, + 'is_public': is_public, + } + + def _create_delta_test_docs(coll_name, docs, edge=False): """Add in delta required fields.""" if edge: @@ -83,10 +94,14 @@ def setUpClass(cls): {'_from': 'ncbi_taxon/6', '_to': 'ncbi_taxon/4', 'child_type': 't'}, {'_from': 'ncbi_taxon/7', '_to': 'ncbi_taxon/4', 'child_type': 't'}, ] + obj_ver_docs = [ + _construct_ws_obj_ver(1, 1, 1, is_public=True), + _construct_ws_obj_ver(1, 1, 2, is_public=True), + _construct_ws_obj_ver(2, 1, 1, is_public=False), + ] obj_docs = [ - _construct_ws_obj(1, 1, 1, is_public=True), - _construct_ws_obj(1, 1, 2, is_public=True), - _construct_ws_obj(2, 1, 1, is_public=False), + _construct_ws_obj(1, 1, is_public=True), + _construct_ws_obj(2, 1, is_public=False), ] obj_to_taxa_docs = [ {'_from': 'ws_object_version/1:1:1', '_to': 'ncbi_taxon/1', 'assigned_by': 'assn1'}, @@ -99,9 +114,8 @@ def setUpClass(cls): _ws_defaults({'_key': '2', 'is_public': False}), ] ws_to_obj = [ - {'_from': 'ws_workspace/1', '_to': 'ws_object_version/1:1:1'}, - {'_from': 'ws_workspace/1', '_to': 'ws_object_version/1:1:2'}, - {'_from': 'ws_workspace/2', '_to': 'ws_object_version/2:1:1'}, + {'_from': 'ws_workspace/1', '_to': 'ws_object/1:1'}, + {'_from': 'ws_workspace/2', '_to': 'ws_object/2:1'}, ] ws_type_version_docs = [ {'_key': 'KBaseGenomes.Genome-99.77', 'module_name': 'KBaseGenomes', @@ -113,10 +127,11 @@ def setUpClass(cls): ] _create_delta_test_docs('ncbi_taxon', taxon_docs) _create_delta_test_docs('ncbi_child_of_taxon', child_docs, edge=True) - _create_delta_test_docs('ws_object_version', obj_docs) - _create_delta_test_docs('ws_obj_version_has_taxon', obj_to_taxa_docs, edge=True) - _create_delta_test_docs('ws_workspace', ws_docs) - _create_delta_test_docs('ws_workspace_contains_obj', ws_to_obj, edge=True) + create_test_docs('ws_obj_version_has_taxon', obj_to_taxa_docs) + create_test_docs('ws_object', obj_docs) + create_test_docs('ws_workspace', ws_docs) + create_test_docs('ws_workspace_contains_obj', ws_to_obj) + create_test_docs('ws_object_version', obj_ver_docs) create_test_docs('ws_obj_instance_of_type', ws_obj_instance_of_type_docs) create_test_docs('ws_type_version', ws_type_version_docs) @@ -304,7 +319,7 @@ def test_get_associated_objs(self): resp = requests.post( _CONF['re_api_url'] + '/api/v1/query_results', params={'stored_query': 'ncbi_taxon_get_associated_ws_objects'}, - data=json.dumps({'ts': _NOW, 'taxon_id': '1', 'select_obj': ['_id', 'type'], + data=json.dumps({'ts': _NOW, 'taxon_id': '1', 'select_obj': ['_id', 'type', 'ws_info'], 'select_edge': ['assigned_by']}), ).json() self.assertEqual(resp['count'], 1) @@ -322,17 +337,23 @@ def test_get_associated_objs(self): 'min_ver': 77, '_key': 'KBaseGenomes.Genome-99.77' }) + self.assertEqual(results['results'][0]['ws_obj']['ws_info'], { + 'owner': 'owner', + 'metadata': {'narrative_nice_name': 'narrname'}, + 'is_public': True, + 'mod_epoch': 1 + }) - def test_get_taxon_from_ws_obj(self): - """Fetch the taxon vertex from a workspace versioned id.""" - resp = requests.post( - _CONF['re_api_url'] + '/api/v1/query_results', - params={'stored_query': 'ncbi_taxon_get_taxon_from_ws_obj'}, - data=json.dumps({'ts': _NOW, 'obj_ref': '1:1:1'}) - ).json() - self.assertEqual(resp['count'], 1) - self.assertDictContainsSubset({ - 'id': '1', - 'scientific_name': 'Bacteria', - 'rank': 'Domain' - }, resp['result'][0]) + def test_get_taxon_from_ws_obj(self): + """Fetch the taxon vertex from a workspace versioned id.""" + resp = requests.post( + _CONF['re_api_url'] + '/api/v1/query_results', + params={'stored_query': 'ncbi_taxon_get_taxon_from_ws_obj'}, + data=json.dumps({'ts': _NOW, 'obj_ref': '1:1:1'}) + ).json() + self.assertEqual(resp['count'], 1) + assert_subset(self, { + 'id': '1', + 'scientific_name': 'Bacteria', + 'rank': 'Domain' + }, resp['results'][0]) From e053dcd4b2ac20a428b6c76722b13e5c788149dc Mon Sep 17 00:00:00 2001 From: Zhenyuan Lu Date: Thu, 3 Oct 2019 15:04:07 -0400 Subject: [PATCH 415/732] add new GO queries --- .../GO/GO_get_terms_from_ws_feature.yaml | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 spec/stored_queries/GO/GO_get_terms_from_ws_feature.yaml diff --git a/spec/stored_queries/GO/GO_get_terms_from_ws_feature.yaml b/spec/stored_queries/GO/GO_get_terms_from_ws_feature.yaml new file mode 100644 index 00000000..68f07ccf --- /dev/null +++ b/spec/stored_queries/GO/GO_get_terms_from_ws_feature.yaml @@ -0,0 +1,39 @@ +# Get the terms from a feature + +name: GO_get_terms_from_feature +params: + type: object + required: [feature_id, ts] + properties: + obj_ref: + type: string + title: Workspace versioned object reference + limit: + type: integer + title: Maximum result limit + default: 20 + maximum: 1000 + offset: + type: integer + title: Result offset for pagination + default: 0 + maximum: 100000 + ts: + type: integer + title: Versioning timestamp +query_prefix: GO_terms +query: | + FOR f in ws_genome_features + FILTER f.feature_id == @feature_id + LIMIT 1 + FOR v, e, p IN 1 OUTBOUND f ws_feature_has_GO_annotation + FILTER e.created <= @ts AND e.expired >= @ts + FILTER v.created <= @ts AND v.expired >= @ts + LIMIT @offset, @limit + RETURN DISTINCT { + term: v, + feature: { + feature_id: f.feature_id, + updated_at: f.updated_at + } + } From 70404b7bbb414de97d8c89725398a2ce8cf7e0aa Mon Sep 17 00:00:00 2001 From: Zhenyuan Lu Date: Fri, 4 Oct 2019 00:30:24 -0400 Subject: [PATCH 416/732] update GO queries --- .../GO/GO_get_associated_ws_objects.yaml | 42 +++++++++---------- .../GO/GO_get_terms_from_ws_feature.yaml | 37 +++++++++------- .../GO/GO_get_terms_from_ws_obj.yaml | 35 +++++++++------- 3 files changed, 62 insertions(+), 52 deletions(-) diff --git a/spec/stored_queries/GO/GO_get_associated_ws_objects.yaml b/spec/stored_queries/GO/GO_get_associated_ws_objects.yaml index 3c13e18d..0d79e2bf 100644 --- a/spec/stored_queries/GO/GO_get_associated_ws_objects.yaml +++ b/spec/stored_queries/GO/GO_get_associated_ws_objects.yaml @@ -22,26 +22,26 @@ params: ts: type: integer title: Versioning timestamp -query_prefix: ws_genome_features, ws_object_version +query_prefix: WITH ws_genome_features, ws_object_version query: | - FOR t in GO_terms - FILTER t.id == @id - FILTER t.created <= @ts AND t.expired >= @ts - limit 1 - FOR v, e, p IN 2 INBOUND t ws_feature_has_GO_annotation, ws_genome_has_feature - FILTER p.edges[0].created <= @ts AND p.edges[0].expired >= @ts - FILTER v.is_public - SORT v.workspace_id ASC - LIMIT @offset, @limit - RETURN DISTINCT { - ws_obj: { - workspace_id: v.workspace_id, - object_id: v.object_id, - version: v.version, - name: v.name - }, - feature: { - feature_id: p.vertices[1].feature_id, - updated_at: p.vertices[1].updated_at + LET results=( + FOR t in GO_terms + FILTER t.id == @id + FILTER t.created <= @ts AND t.expired >= @ts + limit 1 + FOR v, e, p IN 2 INBOUND t ws_feature_has_GO_annotation, ws_genome_has_feature + FILTER p.edges[0].created <= @ts AND p.edges[0].expired >= @ts + FILTER v.is_public OR v.workspace_id IN ws_ids + SORT v.workspace_id ASC + LIMIT @offset, @limit + RETURN DISTINCT { + ws_obj: KEEP(v, ['workspace_id', 'object_id', 'version', 'name']), + feature: KEEP(p.vertices[1], ['feature_id', 'updated_at']) } - } + ) + FOR r IN results + COLLECT ws_obj=r.ws_obj INTO features=r.feature + return { + ws_obj: ws_obj, + features: features + } diff --git a/spec/stored_queries/GO/GO_get_terms_from_ws_feature.yaml b/spec/stored_queries/GO/GO_get_terms_from_ws_feature.yaml index 68f07ccf..fb176574 100644 --- a/spec/stored_queries/GO/GO_get_terms_from_ws_feature.yaml +++ b/spec/stored_queries/GO/GO_get_terms_from_ws_feature.yaml @@ -1,11 +1,11 @@ # Get the terms from a feature -name: GO_get_terms_from_feature +name: GO_get_terms_from_ws_feature params: type: object required: [feature_id, ts] properties: - obj_ref: + feature_id: type: string title: Workspace versioned object reference limit: @@ -21,19 +21,24 @@ params: ts: type: integer title: Versioning timestamp -query_prefix: GO_terms +query_prefix: WITH GO_terms query: | - FOR f in ws_genome_features - FILTER f.feature_id == @feature_id - LIMIT 1 - FOR v, e, p IN 1 OUTBOUND f ws_feature_has_GO_annotation - FILTER e.created <= @ts AND e.expired >= @ts - FILTER v.created <= @ts AND v.expired >= @ts - LIMIT @offset, @limit - RETURN DISTINCT { - term: v, - feature: { - feature_id: f.feature_id, - updated_at: f.updated_at + LET results=( + FOR f in ws_genome_features + FILTER f.feature_id == @feature_id + LIMIT 1 + FOR v, e, p IN 1 OUTBOUND f ws_feature_has_GO_annotation + FILTER e.created <= @ts AND e.expired >= @ts + FILTER v.created <= @ts AND v.expired >= @ts + LIMIT @offset, @limit + RETURN DISTINCT { + term: v, + feature: KEEP(f, ['feature_id', 'updated_at']) } - } + ) + FOR r IN results + COLLECT feature=r.feature INTO terms=r.term + RETURN { + feature: feature, + terms: terms + } diff --git a/spec/stored_queries/GO/GO_get_terms_from_ws_obj.yaml b/spec/stored_queries/GO/GO_get_terms_from_ws_obj.yaml index c3fc5fcc..900520c5 100644 --- a/spec/stored_queries/GO/GO_get_terms_from_ws_obj.yaml +++ b/spec/stored_queries/GO/GO_get_terms_from_ws_obj.yaml @@ -21,20 +21,25 @@ params: ts: type: integer title: Versioning timestamp -query_prefix: ws_genome_features, GO_terms +query_prefix: WITH ws_genome_features, GO_terms query: | - FOR o in ws_object_version - FILTER o._key == @obj_ref - FILTER o.is_public - LIMIT 1 - FOR v, e, p IN 2 OUTBOUND o ws_genome_has_feature, ws_feature_has_GO_annotation - FILTER p.edges[1].created <= @ts AND p.edges[1].expired >= @ts - FILTER v.created <= @ts AND v.expired >= @ts - LIMIT @offset, @limit - RETURN DISTINCT { - term: v, - feature: { - feature_id: p.vertices[1].feature_id, - updated_at: p.vertices[1].updated_at + LET results=( + FOR o in ws_object_version + FILTER o._key == @obj_ref + FILTER o.is_public OR o.workspace_id IN ws_ids + LIMIT 1 + FOR v, e, p IN 2 OUTBOUND o ws_genome_has_feature, ws_feature_has_GO_annotation + FILTER p.edges[1].created <= @ts AND p.edges[1].expired >= @ts + FILTER v.created <= @ts AND v.expired >= @ts + LIMIT @offset, @limit + RETURN DISTINCT { + term: v, + feature: KEEP(p.vertices[1], ['feature_id', 'updated_at']) } - } + ) + FOR r IN results + COLLECT feature=r.feature INTO terms=r.term + RETURN { + feature: feature, + terms: terms + } From ca1a3ef5e08c76e448a3062d16d80698ac517928 Mon Sep 17 00:00:00 2001 From: Gavin Date: Fri, 4 Oct 2019 16:44:54 -0700 Subject: [PATCH 417/732] Update the GTDB schemas to reflect what's actually loaded. Also update the NCBI schemas for the same reason. --- spec/schemas/gtdb/gtdb_child_of_taxon.yaml | 17 ++++++----- spec/schemas/gtdb/gtdb_organism.yaml | 14 --------- spec/schemas/gtdb/gtdb_taxon.yaml | 34 ++++++++-------------- spec/schemas/ncbi/ncbi_child_of_taxon.yaml | 13 ++++----- spec/schemas/ncbi/ncbi_taxon.yaml | 11 +++---- 5 files changed, 31 insertions(+), 58 deletions(-) delete mode 100644 spec/schemas/gtdb/gtdb_organism.yaml diff --git a/spec/schemas/gtdb/gtdb_child_of_taxon.yaml b/spec/schemas/gtdb/gtdb_child_of_taxon.yaml index 47f3bff2..c7bed134 100644 --- a/spec/schemas/gtdb/gtdb_child_of_taxon.yaml +++ b/spec/schemas/gtdb/gtdb_child_of_taxon.yaml @@ -1,18 +1,19 @@ name: gtdb_child_of_taxon type: edge +delta: true + schema: "$schema": http://json-schema.org/draft-07/schema# type: object - required: [_from, _to, child_type] + required: [from, to, id] description: Edges which create the taxonomy tree for GTDB taxons. properties: - _from: + id: type: string - description: The child. A gtdb_taxon or gtdb_organism. - _to: + description: The id of the edge. This is the same as the from ID for GTDB. + from: type: string - description: The parent gtdb_taxon. - child_type: + description: The child taxon. + to: type: string - description: type of child node (taxon or organism) - enum: [t, o] + description: The parent taxon. diff --git a/spec/schemas/gtdb/gtdb_organism.yaml b/spec/schemas/gtdb/gtdb_organism.yaml deleted file mode 100644 index 4204e82a..00000000 --- a/spec/schemas/gtdb/gtdb_organism.yaml +++ /dev/null @@ -1,14 +0,0 @@ -name: gtdb_organism -type: vertex -schema: - "$schema": http://json-schema.org/draft-07/schema# - type: object - description: An organism in the GTDB taxonomy tree. - required: [_key] - properties: - _key: - type: string - description: Accession ID (Refseq prefixed with 'RS_' and Genbank prefixed with 'GB_'). - examples: - - RS_GCF_001300075.1 - - GB_GCA_002387705.1 diff --git a/spec/schemas/gtdb/gtdb_taxon.yaml b/spec/schemas/gtdb/gtdb_taxon.yaml index 41808d29..ee96f4f2 100644 --- a/spec/schemas/gtdb/gtdb_taxon.yaml +++ b/spec/schemas/gtdb/gtdb_taxon.yaml @@ -1,34 +1,24 @@ name: gtdb_taxon type: vertex +delta: true + schema: "$schema": http://json-schema.org/draft-07/schema# type: object description: Template for a vertex entry in the GTDB taxonomy tree. - required: [_key, scientific_name, rank] + required: [id, name, rank] properties: - _key: + id: type: string - description: Taxon type abbreviation plus name - examples: ['d:Bacteria', 'p:Firmicutes'] - scientific_name: + description: GTDB Taxon id. For a non-organism node, this is the rank abbreviation joined + with ':' and the rank name with spaces replaced by underscores. For an organism node, + it is the accession ID. + examples: ['p:Firmicutes', 's:Sediminibacterium_sp002786355', 'RS_GCF_000169355.1'] + name: type: string - title: Taxon name. - examples: - - Methylophilus methylotrophus - - Bacteria - - Firmicutes - canonical_scientific_name: - type: array - title: Canonicalized scientific name - examples: [[methylophilus, methylotrophus], [Bacteria], [Firmicutes]] - items: {type: string} + description: The name of the taxon. For organisms this is the species name. + examples: ['Firmicutes', 'Sediminibacterium sp002786355'] rank: type: string title: Taxonomic rank - examples: [Domain, Phylum] - numeric_rank: - type: integer - title: Taxonomic level - genetic_code: - type: integer - title: genetic code + examples: [domain, phylum] diff --git a/spec/schemas/ncbi/ncbi_child_of_taxon.yaml b/spec/schemas/ncbi/ncbi_child_of_taxon.yaml index d38e6e84..a64a5cb6 100644 --- a/spec/schemas/ncbi/ncbi_child_of_taxon.yaml +++ b/spec/schemas/ncbi/ncbi_child_of_taxon.yaml @@ -5,16 +5,15 @@ delta: true schema: "$schema": http://json-schema.org/draft-07/schema# type: object - required: [from, to, child_type] + required: [from, to, id] description: Edges which create the taxonomy tree for NCBI taxons. properties: + id: + type: string + description: The id of the edge. This is the same as the from ID for NCBI. from: type: string - description: The child. A gtdb_taxon or gtdb_organism. + description: The child taxon. to: type: string - description: The parent gtdb_taxon - child_type: - type: string - description: type of child node (taxon or organism) - enum: [t, o] + description: The parent taxon. diff --git a/spec/schemas/ncbi/ncbi_taxon.yaml b/spec/schemas/ncbi/ncbi_taxon.yaml index 7d29e5db..fec9acec 100644 --- a/spec/schemas/ncbi/ncbi_taxon.yaml +++ b/spec/schemas/ncbi/ncbi_taxon.yaml @@ -46,12 +46,9 @@ schema: type: string title: Taxonomic rank examples: [Domain, Phylum] - numeric_rank: + ncbi_taxon_id: type: integer - title: Taxonomic level - NCBI_taxon_id: + title: The NCBI taxon ID as a number + gencode: type: integer - title: NCBI_taxon_id - genetic_code: - type: integer - title: genetic code + title: The numerc ID of the genetic code for this organism. From 2cac8498021602fe8d7f2a0fb71babb9ec8c9193 Mon Sep 17 00:00:00 2001 From: Gavin Date: Fri, 4 Oct 2019 16:48:06 -0700 Subject: [PATCH 418/732] minor fix --- spec/schemas/gtdb/gtdb_taxon.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/schemas/gtdb/gtdb_taxon.yaml b/spec/schemas/gtdb/gtdb_taxon.yaml index ee96f4f2..50dd5ef0 100644 --- a/spec/schemas/gtdb/gtdb_taxon.yaml +++ b/spec/schemas/gtdb/gtdb_taxon.yaml @@ -11,7 +11,7 @@ schema: id: type: string description: GTDB Taxon id. For a non-organism node, this is the rank abbreviation joined - with ':' and the rank name with spaces replaced by underscores. For an organism node, + with ':' and the taxon name with spaces replaced by underscores. For an organism node, it is the accession ID. examples: ['p:Firmicutes', 's:Sediminibacterium_sp002786355', 'RS_GCF_000169355.1'] name: From a2c37489d3e207f4e444821be1cf96318e5e1150 Mon Sep 17 00:00:00 2001 From: Gavin Date: Fri, 4 Oct 2019 17:18:17 -0700 Subject: [PATCH 419/732] Fix tests --- spec/test/stored_queries/test_ncbi_tax.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/spec/test/stored_queries/test_ncbi_tax.py b/spec/test/stored_queries/test_ncbi_tax.py index 85fb1884..011cbc15 100644 --- a/spec/test/stored_queries/test_ncbi_tax.py +++ b/spec/test/stored_queries/test_ncbi_tax.py @@ -87,12 +87,12 @@ def setUpClass(cls): {'_key': '7', 'scientific_name': 'Deltaproteobacteria', 'rank': 'Class'}, ] child_docs = [ - {'_from': 'ncbi_taxon/2', '_to': 'ncbi_taxon/1', 'child_type': 't'}, - {'_from': 'ncbi_taxon/4', '_to': 'ncbi_taxon/1', 'child_type': 't'}, - {'_from': 'ncbi_taxon/3', '_to': 'ncbi_taxon/2', 'child_type': 't'}, - {'_from': 'ncbi_taxon/5', '_to': 'ncbi_taxon/4', 'child_type': 't'}, - {'_from': 'ncbi_taxon/6', '_to': 'ncbi_taxon/4', 'child_type': 't'}, - {'_from': 'ncbi_taxon/7', '_to': 'ncbi_taxon/4', 'child_type': 't'}, + {'_from': 'ncbi_taxon/2', '_to': 'ncbi_taxon/1', 'from': '2', 'to': '1', 'id': '2'}, + {'_from': 'ncbi_taxon/4', '_to': 'ncbi_taxon/1', 'from': '4', 'to': '1', 'id': '4'}, + {'_from': 'ncbi_taxon/3', '_to': 'ncbi_taxon/2', 'from': '3', 'to': '2', 'id': '3'}, + {'_from': 'ncbi_taxon/5', '_to': 'ncbi_taxon/4', 'from': '5', 'to': '4', 'id': '5'}, + {'_from': 'ncbi_taxon/6', '_to': 'ncbi_taxon/4', 'from': '6', 'to': '4', 'id': '6'}, + {'_from': 'ncbi_taxon/7', '_to': 'ncbi_taxon/4', 'from': '7', 'to': '4', 'id': '7'}, ] obj_ver_docs = [ _construct_ws_obj_ver(1, 1, 1, is_public=True), From 7a43361a85c9268c9463cc0a26daf9396b05244f Mon Sep 17 00:00:00 2001 From: Zhenyuan Lu Date: Mon, 7 Oct 2019 13:37:03 -0400 Subject: [PATCH 420/732] update GO queries --- .../GO/GO_get_terms_from_ws_feature.yaml | 10 +++++----- spec/stored_queries/GO/GO_get_terms_from_ws_obj.yaml | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/spec/stored_queries/GO/GO_get_terms_from_ws_feature.yaml b/spec/stored_queries/GO/GO_get_terms_from_ws_feature.yaml index fb176574..22255592 100644 --- a/spec/stored_queries/GO/GO_get_terms_from_ws_feature.yaml +++ b/spec/stored_queries/GO/GO_get_terms_from_ws_feature.yaml @@ -7,7 +7,7 @@ params: properties: feature_id: type: string - title: Workspace versioned object reference + title: Workspace feature id limit: type: integer title: Maximum result limit @@ -23,7 +23,7 @@ params: title: Versioning timestamp query_prefix: WITH GO_terms query: | - LET results=( + LET go_term_results=( FOR f in ws_genome_features FILTER f.feature_id == @feature_id LIMIT 1 @@ -32,11 +32,11 @@ query: | FILTER v.created <= @ts AND v.expired >= @ts LIMIT @offset, @limit RETURN DISTINCT { - term: v, - feature: KEEP(f, ['feature_id', 'updated_at']) + term: KEEP(v, 'id', 'name', 'namespace', 'alt_ids', 'def', 'comments', 'synonyms', 'xrefs', 'created', 'expired'), + feature: KEEP(f, ['feature_id', 'updated_at', 'workspace_id', 'object_id', 'version']) } ) - FOR r IN results + FOR r IN go_term_results COLLECT feature=r.feature INTO terms=r.term RETURN { feature: feature, diff --git a/spec/stored_queries/GO/GO_get_terms_from_ws_obj.yaml b/spec/stored_queries/GO/GO_get_terms_from_ws_obj.yaml index 900520c5..f4c91999 100644 --- a/spec/stored_queries/GO/GO_get_terms_from_ws_obj.yaml +++ b/spec/stored_queries/GO/GO_get_terms_from_ws_obj.yaml @@ -33,8 +33,8 @@ query: | FILTER v.created <= @ts AND v.expired >= @ts LIMIT @offset, @limit RETURN DISTINCT { - term: v, - feature: KEEP(p.vertices[1], ['feature_id', 'updated_at']) + term: KEEP(v, 'id', 'name', 'namespace', 'alt_ids', 'def', 'comments', 'synonyms', 'xrefs', 'created', 'expired'), + feature: KEEP(p.vertices[1], ['feature_id', 'updated_at', 'workspace_id', 'object_id', 'version']) } ) FOR r IN results From 94b29e747865f0cc5252ee402b57d6cba907f2ad Mon Sep 17 00:00:00 2001 From: Zhenyuan Lu Date: Mon, 7 Oct 2019 13:53:23 -0400 Subject: [PATCH 421/732] update GO queries --- spec/stored_queries/GO/GO_get_terms_from_ws_feature.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/stored_queries/GO/GO_get_terms_from_ws_feature.yaml b/spec/stored_queries/GO/GO_get_terms_from_ws_feature.yaml index 22255592..cf91216b 100644 --- a/spec/stored_queries/GO/GO_get_terms_from_ws_feature.yaml +++ b/spec/stored_queries/GO/GO_get_terms_from_ws_feature.yaml @@ -25,7 +25,7 @@ query_prefix: WITH GO_terms query: | LET go_term_results=( FOR f in ws_genome_features - FILTER f.feature_id == @feature_id + FILTER f._key == @feature_id LIMIT 1 FOR v, e, p IN 1 OUTBOUND f ws_feature_has_GO_annotation FILTER e.created <= @ts AND e.expired >= @ts From 64a2407212433bf380fe5fa1c7994c526c75cfcf Mon Sep 17 00:00:00 2001 From: Zhenyuan Lu Date: Mon, 7 Oct 2019 14:44:44 -0400 Subject: [PATCH 422/732] update GO queries --- .../GO/GO_get_terms_from_ws_feature.yaml | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/spec/stored_queries/GO/GO_get_terms_from_ws_feature.yaml b/spec/stored_queries/GO/GO_get_terms_from_ws_feature.yaml index cf91216b..27fc6ad8 100644 --- a/spec/stored_queries/GO/GO_get_terms_from_ws_feature.yaml +++ b/spec/stored_queries/GO/GO_get_terms_from_ws_feature.yaml @@ -21,20 +21,23 @@ params: ts: type: integer title: Versioning timestamp -query_prefix: WITH GO_terms +query_prefix: WITH ws_genome_features, GO_terms query: | LET go_term_results=( FOR f in ws_genome_features FILTER f._key == @feature_id LIMIT 1 - FOR v, e, p IN 1 OUTBOUND f ws_feature_has_GO_annotation - FILTER e.created <= @ts AND e.expired >= @ts - FILTER v.created <= @ts AND v.expired >= @ts - LIMIT @offset, @limit - RETURN DISTINCT { - term: KEEP(v, 'id', 'name', 'namespace', 'alt_ids', 'def', 'comments', 'synonyms', 'xrefs', 'created', 'expired'), - feature: KEEP(f, ['feature_id', 'updated_at', 'workspace_id', 'object_id', 'version']) - } + FOR o, oe, op IN 1 INBOUND f ws_genome_has_feature + FILTER o.is_public OR o.workspace_id IN ws_ids + LIMIT 1 + FOR t, te, tp IN 1 OUTBOUND op.vertices[0] ws_feature_has_GO_annotation + FILTER te.created <= @ts AND te.expired >= @ts + FILTER t.created <= @ts AND t.expired >= @ts + LIMIT @offset, @limit + RETURN DISTINCT { + term: KEEP(t, 'id', 'name', 'namespace', 'alt_ids', 'def', 'comments', 'synonyms', 'xrefs', 'created', 'expired'), + feature: KEEP(f, ['feature_id', 'updated_at', 'workspace_id', 'object_id', 'version']) + } ) FOR r IN go_term_results COLLECT feature=r.feature INTO terms=r.term From b056596ca5155ea6ad312aa50ee82302cf5a7ecd Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 8 Oct 2019 12:19:42 -0700 Subject: [PATCH 423/732] Add some test helper code improvements to prevent intermittent test failures --- spec/test/helpers.py | 24 ++++++++++++++++-------- spec/test/run_tests.sh | 4 ++-- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/spec/test/helpers.py b/spec/test/helpers.py index 0d362dca..02a013c3 100644 --- a/spec/test/helpers.py +++ b/spec/test/helpers.py @@ -30,27 +30,35 @@ def wait_for_arangodb(): resp.raise_for_status() break except Exception as err: - print(err) + print('Waiting for arangodb to come online') if time.time() > timeout: + sys.stderr.write(str(err) + '\n') raise RuntimeError('Timed out waiting for arangodb') time.sleep(3) def wait_for_api(): - # Wait for the API to come online + wait_for_arangodb() + # Wait for other dependent services to come online conf = get_config() timeout = int(time.time()) + 60 + auth_url = 'http://auth:5000' + ws_url = 'http://workspace:5000' while True: try: - requests.get(conf['re_api_url']).raise_for_status() - requests.get('http://auth:5000') - requests.get('http://workspace:5000') + # Reassign the `url` variable so we can print which service errored + url = conf['re_api_url'] + requests.get(url).raise_for_status() + url = auth_url + requests.get(url) + url = ws_url + requests.get(url) break except Exception as err: - print(err) - print('Waiting for RE API to come online..') + print(f"Waiting for dependent service to come online: {url}") if int(time.time()) > timeout: - raise RuntimeError("Timed out waiting for RE API.") + sys.stderr.write(str(err) + "\n") + raise RuntimeError(f"Timed out waiting for {url}") time.sleep(2) diff --git a/spec/test/run_tests.sh b/spec/test/run_tests.sh index 38f31cb0..9f63e2ac 100644 --- a/spec/test/run_tests.sh +++ b/spec/test/run_tests.sh @@ -1,5 +1,5 @@ #!/bin/sh set -e -python -m test.helpers wait_for_api -python -m test.validate +python -m test.helpers wait_for_api && \ +python -m test.validate && \ python -m unittest discover /app/test/stored_queries From 34f05c7da2690769440341980ffa4bcc3f340730 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 8 Oct 2019 12:27:57 -0700 Subject: [PATCH 424/732] Fix test mock --- spec/test/mock_services/mock_auth/invalid2.json | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/test/mock_services/mock_auth/invalid2.json b/spec/test/mock_services/mock_auth/invalid2.json index d588d613..785369ac 100644 --- a/spec/test/mock_services/mock_auth/invalid2.json +++ b/spec/test/mock_services/mock_auth/invalid2.json @@ -3,6 +3,7 @@ "GET" ], "path": "/api/V2/me", + "absent_headers": ["Authorization"], "response": { "status": "400", "body": { From 020356e417a5eff319958ebe227b5888bd8ac40b Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Thu, 10 Oct 2019 14:35:13 -0700 Subject: [PATCH 425/732] Improve the json schema error response --- api/src/relation_engine_server/main.py | 8 ++++---- api/src/test/test_api_v1.py | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/api/src/relation_engine_server/main.py b/api/src/relation_engine_server/main.py index c94a42a4..5587651b 100644 --- a/api/src/relation_engine_server/main.py +++ b/api/src/relation_engine_server/main.py @@ -76,11 +76,11 @@ def view_does_not_exist(err): def validation_error(err): """Json Schema validation error.""" resp = { - 'error': str(err).split('\n')[0], - 'instance': err.instance, - 'validator': err.validator, + 'error': err.message, + 'failed_validator': err.validator, 'validator_value': err.validator_value, - 'schema': err.schema + 'path': list(err.absolute_path), + 'schema_path': list(err.schema_path) } return (flask.jsonify(resp), 400) diff --git a/api/src/test/test_api_v1.py b/api/src/test/test_api_v1.py index 689fba84..2d807d95 100644 --- a/api/src/test/test_api_v1.py +++ b/api/src/test/test_api_v1.py @@ -146,9 +146,9 @@ def test_save_documents_invalid_schema(self): headers=HEADERS_ADMIN ).json() self.assertEqual(resp['error'], "'_key' is a required property") - self.assertEqual(resp['instance'], {'name': 'x'}) - self.assertTrue(resp['schema']) - self.assertEqual(resp['validator'], 'required') + self.assertEqual(resp['failed_validator'], 'required') + self.assertEqual(resp['path'], []) + self.assertEqual(resp['schema_path'], ['required']) self.assertEqual(resp['validator_value'], ['_key']) def test_save_documents_missing_schema(self): From a75a244c85986993e41669faa8be9b8e26530489 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Fri, 11 Oct 2019 12:03:17 -0700 Subject: [PATCH 426/732] Add docs about the json schema validation error response and simplify the response itself --- api/README.md | 11 ++++++++++- api/src/relation_engine_server/main.py | 2 ++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/api/README.md b/api/README.md index fb4e48f7..a06012e4 100644 --- a/api/README.md +++ b/api/README.md @@ -17,7 +17,7 @@ Returns server status info Run a query using a stored query or a cursor ID. Semantically, this is a GET, but it's a POST to allow better support for passing JSON in the request body (eg. Postman doesn't allow request body data in get requests) -_Example rquest_ +_Example request_ ```sh curl -X POST -d '{"argument": "value"}' {root_url}/api/v1/query_results?stored_query=example @@ -160,6 +160,15 @@ _Response JSON schema_ } ``` +#### JSON Schema error responses + +If you try to update a collection and it fails validation against a JSON schema found in the [relation_engine_spec](https://github.com/kbase/relation_engine_spec/), then you will get a JSON error response with the following fields: + +* `"error"` - Human readable message explaining the error +* `"failed_validator"` - The name of the validator that failed (eg. "required") +* `"value"` - The (possibly nested) value in your data that failed validation +* `"path"` - The path into your data where you can find the value that failed validation + ### PUT /api/v1/specs/ Manually check and pull spec updates. Requires sysadmin auth. diff --git a/api/src/relation_engine_server/main.py b/api/src/relation_engine_server/main.py index 5587651b..8f9952b6 100644 --- a/api/src/relation_engine_server/main.py +++ b/api/src/relation_engine_server/main.py @@ -75,6 +75,8 @@ def view_does_not_exist(err): @app.errorhandler(ValidationError) def validation_error(err): """Json Schema validation error.""" + # Refer to the documentation on jsonschema.exceptions.ValidationError: + # https://python-jsonschema.readthedocs.io/en/stable/errors/ resp = { 'error': err.message, 'failed_validator': err.validator, From 5013389d6b5f7aae4a2447d2137e273d681f84c4 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Fri, 11 Oct 2019 12:06:26 -0700 Subject: [PATCH 427/732] Improve the json schema error response (#59) * Improve the json schema error response * Add docs about the json schema validation error response and simplify the response itself --- api/README.md | 11 ++++++++++- api/src/relation_engine_server/main.py | 10 ++++++---- api/src/test/test_api_v1.py | 6 +++--- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/api/README.md b/api/README.md index fb4e48f7..a06012e4 100644 --- a/api/README.md +++ b/api/README.md @@ -17,7 +17,7 @@ Returns server status info Run a query using a stored query or a cursor ID. Semantically, this is a GET, but it's a POST to allow better support for passing JSON in the request body (eg. Postman doesn't allow request body data in get requests) -_Example rquest_ +_Example request_ ```sh curl -X POST -d '{"argument": "value"}' {root_url}/api/v1/query_results?stored_query=example @@ -160,6 +160,15 @@ _Response JSON schema_ } ``` +#### JSON Schema error responses + +If you try to update a collection and it fails validation against a JSON schema found in the [relation_engine_spec](https://github.com/kbase/relation_engine_spec/), then you will get a JSON error response with the following fields: + +* `"error"` - Human readable message explaining the error +* `"failed_validator"` - The name of the validator that failed (eg. "required") +* `"value"` - The (possibly nested) value in your data that failed validation +* `"path"` - The path into your data where you can find the value that failed validation + ### PUT /api/v1/specs/ Manually check and pull spec updates. Requires sysadmin auth. diff --git a/api/src/relation_engine_server/main.py b/api/src/relation_engine_server/main.py index c94a42a4..8f9952b6 100644 --- a/api/src/relation_engine_server/main.py +++ b/api/src/relation_engine_server/main.py @@ -75,12 +75,14 @@ def view_does_not_exist(err): @app.errorhandler(ValidationError) def validation_error(err): """Json Schema validation error.""" + # Refer to the documentation on jsonschema.exceptions.ValidationError: + # https://python-jsonschema.readthedocs.io/en/stable/errors/ resp = { - 'error': str(err).split('\n')[0], - 'instance': err.instance, - 'validator': err.validator, + 'error': err.message, + 'failed_validator': err.validator, 'validator_value': err.validator_value, - 'schema': err.schema + 'path': list(err.absolute_path), + 'schema_path': list(err.schema_path) } return (flask.jsonify(resp), 400) diff --git a/api/src/test/test_api_v1.py b/api/src/test/test_api_v1.py index 689fba84..2d807d95 100644 --- a/api/src/test/test_api_v1.py +++ b/api/src/test/test_api_v1.py @@ -146,9 +146,9 @@ def test_save_documents_invalid_schema(self): headers=HEADERS_ADMIN ).json() self.assertEqual(resp['error'], "'_key' is a required property") - self.assertEqual(resp['instance'], {'name': 'x'}) - self.assertTrue(resp['schema']) - self.assertEqual(resp['validator'], 'required') + self.assertEqual(resp['failed_validator'], 'required') + self.assertEqual(resp['path'], []) + self.assertEqual(resp['schema_path'], ['required']) self.assertEqual(resp['validator_value'], ['_key']) def test_save_documents_missing_schema(self): From 84c1bd7d0cd223f80f4121dcfa22165441ead68c Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Fri, 11 Oct 2019 12:08:07 -0700 Subject: [PATCH 428/732] Add query and test to fetch a taxon by scientific name (#112) --- .../ncbi_tax/ncbi_fetch_taxon_by_sciname.yaml | 18 ++++++++ spec/test/stored_queries/test_ncbi_tax.py | 41 +++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 spec/stored_queries/ncbi_tax/ncbi_fetch_taxon_by_sciname.yaml diff --git a/spec/stored_queries/ncbi_tax/ncbi_fetch_taxon_by_sciname.yaml b/spec/stored_queries/ncbi_tax/ncbi_fetch_taxon_by_sciname.yaml new file mode 100644 index 00000000..647495fd --- /dev/null +++ b/spec/stored_queries/ncbi_tax/ncbi_fetch_taxon_by_sciname.yaml @@ -0,0 +1,18 @@ +# Fetch a taxon document by exact match on sciname +name: ncbi_fetch_taxon_by_sciname +params: + type: object + required: [sciname, ts] + properties: + sciname: + type: string + title: NCBI scientific name + ts: + type: integer + title: Versioning timestamp +query: | + for t in ncbi_taxon + filter t.scientific_name == @sciname + filter t.created <= @ts AND t.expired >= @ts + limit 1 + return t diff --git a/spec/test/stored_queries/test_ncbi_tax.py b/spec/test/stored_queries/test_ncbi_tax.py index 011cbc15..34e8e50a 100644 --- a/spec/test/stored_queries/test_ncbi_tax.py +++ b/spec/test/stored_queries/test_ncbi_tax.py @@ -85,6 +85,7 @@ def setUpClass(cls): {'_key': '5', 'scientific_name': 'Alphaproteobacteria', 'rank': 'Class'}, {'_key': '6', 'scientific_name': 'Gammaproteobacteria', 'rank': 'Class'}, {'_key': '7', 'scientific_name': 'Deltaproteobacteria', 'rank': 'Class'}, + ] child_docs = [ {'_from': 'ncbi_taxon/2', '_to': 'ncbi_taxon/1', 'from': '2', 'to': '1', 'id': '2'}, @@ -357,3 +358,43 @@ def test_get_taxon_from_ws_obj(self): 'scientific_name': 'Bacteria', 'rank': 'Domain' }, resp['results'][0]) + + def test_fetch_taxon_by_sciname(self): + """Test the ncbi_fetch_taxon_by_sciname query.""" + sciname = 'Deltaproteobacteria' + resp = requests.post( + _CONF['re_api_url'] + '/api/v1/query_results', + params={'stored_query': 'ncbi_fetch_taxon_by_sciname'}, + data=json.dumps({'ts': _NOW, 'sciname': 'Deltaproteobacteria'}) + ).json() + self.assertEqual(resp['count'], 1) + assert_subset(self, { + 'id': '7', + 'scientific_name': sciname, + 'rank': 'Class', + }, resp['results'][0]) + + def test_fetch_taxon_by_sciname_failures(self): + """Test invalid cases for ncbi_fetch_taxon_by_sciname.""" + # No sciname + resp = requests.post( + _CONF['re_api_url'] + '/api/v1/query_results', + params={'stored_query': 'ncbi_fetch_taxon_by_sciname'}, + data=json.dumps({'ts': _NOW}) + ).json() + self.assertEqual(resp['error'], "'sciname' is a required property") + # No ts + resp = requests.post( + _CONF['re_api_url'] + '/api/v1/query_results', + params={'stored_query': 'ncbi_fetch_taxon_by_sciname'}, + data=json.dumps({'sciname': 'Deltaproteobacteria'}) + ).json() + self.assertEqual(resp['error'], "'ts' is a required property") + # sciname not found + resp = requests.post( + _CONF['re_api_url'] + '/api/v1/query_results', + params={'stored_query': 'ncbi_fetch_taxon_by_sciname'}, + data=json.dumps({'ts': _NOW, 'sciname': 'xyzabc'}) + ).json() + self.assertEqual(resp['count'], 0) + self.assertEqual(len(resp['results']), 0) From 5217718ede16688ab21f29ad9210081b8beef25f Mon Sep 17 00:00:00 2001 From: Gavin Date: Fri, 11 Oct 2019 16:12:55 -0700 Subject: [PATCH 429/732] Add strain field to ncbi_taxon --- spec/schemas/ncbi/ncbi_taxon.yaml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/spec/schemas/ncbi/ncbi_taxon.yaml b/spec/schemas/ncbi/ncbi_taxon.yaml index fec9acec..9c02ae21 100644 --- a/spec/schemas/ncbi/ncbi_taxon.yaml +++ b/spec/schemas/ncbi/ncbi_taxon.yaml @@ -10,7 +10,7 @@ schema: "$schema": http://json-schema.org/draft-07/schema# type: object description: Template for a vertex entry in the NCBI taxonomy tree. - required: [id, scientific_name, rank] + required: [id, scientific_name, rank, strain] properties: id: type: string @@ -45,7 +45,13 @@ schema: rank: type: string title: Taxonomic rank - examples: [Domain, Phylum] + examples: ["Domain", "Phylum", "no rank"] + strain: + type: boolean + title: Strain flag + description: Whether this node corresponds to a strain. Strains are considered to be nodes + that have a rank of "no rank" and whose parents' rank is either species or subspecies or + where the parent's strain flag is true. ncbi_taxon_id: type: integer title: The NCBI taxon ID as a number From c69013cc9fb5e033bf395f5143bc151d9a5691b9 Mon Sep 17 00:00:00 2001 From: Gavin Date: Fri, 11 Oct 2019 16:27:21 -0700 Subject: [PATCH 430/732] Fix tests --- spec/test/stored_queries/test_ncbi_tax.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/spec/test/stored_queries/test_ncbi_tax.py b/spec/test/stored_queries/test_ncbi_tax.py index 34e8e50a..4321b451 100644 --- a/spec/test/stored_queries/test_ncbi_tax.py +++ b/spec/test/stored_queries/test_ncbi_tax.py @@ -78,13 +78,16 @@ class TestNcbiTax(unittest.TestCase): def setUpClass(cls): """Create test documents""" taxon_docs = [ - {'_key': '1', 'scientific_name': 'Bacteria', 'rank': 'Domain'}, - {'_key': '2', 'scientific_name': 'Firmicutes', 'rank': 'Phylum'}, - {'_key': '3', 'scientific_name': 'Bacilli', 'rank': 'Class'}, - {'_key': '4', 'scientific_name': 'Proteobacteria', 'rank': 'Phylum'}, - {'_key': '5', 'scientific_name': 'Alphaproteobacteria', 'rank': 'Class'}, - {'_key': '6', 'scientific_name': 'Gammaproteobacteria', 'rank': 'Class'}, - {'_key': '7', 'scientific_name': 'Deltaproteobacteria', 'rank': 'Class'}, + {'_key': '1', 'scientific_name': 'Bacteria', 'rank': 'Domain', 'strain': False}, + {'_key': '2', 'scientific_name': 'Firmicutes', 'rank': 'Phylum', 'strain': False}, + {'_key': '3', 'scientific_name': 'Bacilli', 'rank': 'Class', 'strain': False}, + {'_key': '4', 'scientific_name': 'Proteobacteria', 'rank': 'Phylum', 'strain': False}, + {'_key': '5', 'scientific_name': 'Alphaproteobacteria', + 'rank': 'Class', 'strain': False}, + {'_key': '6', 'scientific_name': 'Gammaproteobacteria', 'rank': 'Class', + 'strain': False}, + {'_key': '7', 'scientific_name': 'Deltaproteobacteria', 'rank': 'Class', + 'strain': False}, ] child_docs = [ From 3f45dfee71ae0bbca07c4010f0023998824f886c Mon Sep 17 00:00:00 2001 From: Gavin Date: Fri, 11 Oct 2019 17:21:16 -0700 Subject: [PATCH 431/732] Add rank / strain filters to search ncbi taxa sci name --- .../ncbi_tax/ncbi_taxon_search_sci_name.yaml | 31 ++++++++---- spec/test/stored_queries/test_ncbi_tax.py | 48 +++++++++++++++++++ 2 files changed, 70 insertions(+), 9 deletions(-) diff --git a/spec/stored_queries/ncbi_tax/ncbi_taxon_search_sci_name.yaml b/spec/stored_queries/ncbi_tax/ncbi_taxon_search_sci_name.yaml index 6406bccb..e81f74c0 100644 --- a/spec/stored_queries/ncbi_tax/ncbi_taxon_search_sci_name.yaml +++ b/spec/stored_queries/ncbi_tax/ncbi_taxon_search_sci_name.yaml @@ -9,6 +9,17 @@ params: type: string title: Search text description: Text to search on for the scientific name + ranks: + description: Filter the query to include only these ranks. An empty array is ignored. + type: array + default: [] + items: + type: string + include_strains: + description: true to include strains in the result, regardless of the ranks field. false + to perform no special filtering on strains. + type: boolean + default: false offset: type: integer default: 0 @@ -28,16 +39,18 @@ params: query: | // Search using the fulltext index on scientific_name // Don't limit the results yet so we can get the total_count below - let results = ( - FOR doc in FULLTEXT(ncbi_taxon, "scientific_name", @search_text) + LET results = ( + FOR doc IN FULLTEXT(ncbi_taxon, "scientific_name", @search_text) // Filter non-expired docs - filter doc.created <= @ts AND doc.expired >= @ts - return doc + FILTER doc.created <= @ts AND doc.expired >= @ts + FILTER LENGTH(@ranks) > 0 ? + (@include_strains ? (doc.rank in @ranks OR doc.strain) : doc.rank in @ranks) : true + RETURN doc ) // Limit the results - let limited = ( - for r in results - limit @offset, @limit - return @select ? KEEP(r, @select) : r + LET limited = ( + FOR r IN results + LIMIT @offset, @limit + RETURN @select ? KEEP(r, @select) : r ) - return {results: limited, total_count: COUNT(results)} + RETURN {results: limited, total_count: COUNT(results)} diff --git a/spec/test/stored_queries/test_ncbi_tax.py b/spec/test/stored_queries/test_ncbi_tax.py index 4321b451..4101afd9 100644 --- a/spec/test/stored_queries/test_ncbi_tax.py +++ b/spec/test/stored_queries/test_ncbi_tax.py @@ -88,6 +88,8 @@ def setUpClass(cls): 'strain': False}, {'_key': '7', 'scientific_name': 'Deltaproteobacteria', 'rank': 'Class', 'strain': False}, + {'_key': '8', 'scientific_name': 'Bacillus subtilis 168', 'rank': 'no rank', + 'strain': True}, ] child_docs = [ @@ -97,6 +99,8 @@ def setUpClass(cls): {'_from': 'ncbi_taxon/5', '_to': 'ncbi_taxon/4', 'from': '5', 'to': '4', 'id': '5'}, {'_from': 'ncbi_taxon/6', '_to': 'ncbi_taxon/4', 'from': '6', 'to': '4', 'id': '6'}, {'_from': 'ncbi_taxon/7', '_to': 'ncbi_taxon/4', 'from': '7', 'to': '4', 'id': '7'}, + # a few levels missing here + {'_from': 'ncbi_taxon/8', '_to': 'ncbi_taxon/3', 'from': '8', 'to': '3', 'id': '8'}, ] obj_ver_docs = [ _construct_ws_obj_ver(1, 1, 1, is_public=True), @@ -292,6 +296,50 @@ def test_search_sciname_limit_max(self): self.assertEqual(resp.status_code, 400) self.assertEqual(resp.json()['error'], "1001 is greater than the maximum of 1000") + def test_search_sciname_limit_ranks_implicit_defaults(self): + """ Test queries where the results are limited by the rank or strain flag. """ + self._run_search_sciname(None, None, 3, {'Bacteria', 'Bacilli', 'Bacillus subtilis 168'}) + + def test_search_sciname_limit_ranks_explicit_defaults(self): + """ Test queries where the results are limited by the rank or strain flag. """ + self._run_search_sciname([], False, 3, {'Bacteria', 'Bacilli', 'Bacillus subtilis 168'}) + + def test_search_sciname_limit_ranks_2(self): + """ Test queries where the results are limited by the rank or strain flag. """ + self._run_search_sciname(['Domain', 'Class'], None, 2, {'Bacteria', 'Bacilli'}) + + def test_search_sciname_limit_ranks_1(self): + """ Test queries where the results are limited by the rank or strain flag. """ + self._run_search_sciname(['Class'], None, 1, {'Bacilli'}) + + def test_search_sciname_limit_ranks_1_with_strain(self): + """ Test queries where the results are limited by the rank or strain flag. """ + self._run_search_sciname(['Class'], True, 2, {'Bacilli', 'Bacillus subtilis 168'}) + + def test_search_sciname_limit_ranks_1_with_false_strain(self): + """ Test queries where the results are limited by the rank or strain flag. """ + self._run_search_sciname(['Class'], False, 1, {'Bacilli'}) + + def _run_search_sciname(self, ranks, include_strains, expected_count, expected_sci_names): + data = { + 'ts': _NOW, + 'search_text': "prefix:bac" + } + if ranks is not None: + data['ranks'] = ranks + if include_strains is not None: + data['include_strains'] = include_strains + resp = requests.post( + _CONF['re_api_url'] + '/api/v1/query_results', + params={'stored_query': 'ncbi_taxon_search_sci_name'}, + data=json.dumps(data) + ).json() + result = resp['results'][0] + self.assertEqual(result['total_count'], expected_count) + names = {r['scientific_name'] for r in result['results']} + self.assertEqual(names, expected_sci_names) + + def test_select_fields(self): """Test that the 'select' works properly for one query.""" resp = requests.post( From 6873489cc15cd750c2295f071746ff64dfc28f1d Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Mon, 14 Oct 2019 10:15:09 -0700 Subject: [PATCH 432/732] Simplify json schema error response --- api/src/relation_engine_server/main.py | 3 +-- api/src/test/test_api_v1.py | 5 ++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/api/src/relation_engine_server/main.py b/api/src/relation_engine_server/main.py index 8f9952b6..5af1d2b2 100644 --- a/api/src/relation_engine_server/main.py +++ b/api/src/relation_engine_server/main.py @@ -80,9 +80,8 @@ def validation_error(err): resp = { 'error': err.message, 'failed_validator': err.validator, - 'validator_value': err.validator_value, + 'value': err.instance, 'path': list(err.absolute_path), - 'schema_path': list(err.schema_path) } return (flask.jsonify(resp), 400) diff --git a/api/src/test/test_api_v1.py b/api/src/test/test_api_v1.py index 2d807d95..5b5511dc 100644 --- a/api/src/test/test_api_v1.py +++ b/api/src/test/test_api_v1.py @@ -146,10 +146,9 @@ def test_save_documents_invalid_schema(self): headers=HEADERS_ADMIN ).json() self.assertEqual(resp['error'], "'_key' is a required property") - self.assertEqual(resp['failed_validator'], 'required') + self.assertEqual(resp['value'], {'name': 'y'}) self.assertEqual(resp['path'], []) - self.assertEqual(resp['schema_path'], ['required']) - self.assertEqual(resp['validator_value'], ['_key']) + self.assertEqual(resp['failed_validator'], ['required']) def test_save_documents_missing_schema(self): """Test the case where the collection/schema does not exist.""" From b5e9d69fcbe4b76140ff62ec99fa6e5449ceeda7 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Mon, 14 Oct 2019 10:18:35 -0700 Subject: [PATCH 433/732] Fix test --- api/src/test/test_api_v1.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/src/test/test_api_v1.py b/api/src/test/test_api_v1.py index 5b5511dc..6b133fba 100644 --- a/api/src/test/test_api_v1.py +++ b/api/src/test/test_api_v1.py @@ -146,9 +146,9 @@ def test_save_documents_invalid_schema(self): headers=HEADERS_ADMIN ).json() self.assertEqual(resp['error'], "'_key' is a required property") - self.assertEqual(resp['value'], {'name': 'y'}) + self.assertEqual(resp['value'], {'name': 'x'}) self.assertEqual(resp['path'], []) - self.assertEqual(resp['failed_validator'], ['required']) + self.assertEqual(resp['failed_validator'], 'required') def test_save_documents_missing_schema(self): """Test the case where the collection/schema does not exist.""" From f9d0706405fca65d5a50d64aa57a4f0de606ce31 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Mon, 14 Oct 2019 10:46:12 -0700 Subject: [PATCH 434/732] Reorganize a bit for maintainability --- spec/test/stored_queries/test_ncbi_tax.py | 221 ++++++++++++---------- 1 file changed, 126 insertions(+), 95 deletions(-) diff --git a/spec/test/stored_queries/test_ncbi_tax.py b/spec/test/stored_queries/test_ncbi_tax.py index 4101afd9..0c3e2fe7 100644 --- a/spec/test/stored_queries/test_ncbi_tax.py +++ b/spec/test/stored_queries/test_ncbi_tax.py @@ -13,65 +13,6 @@ _NOW = int(time.time() * 1000) -def _ws_defaults(data): - """Set some defaults for the required workspace fields.""" - defaults = { - 'owner': 'owner', - 'max_obj_id': 1, - 'lock_status': 'n', - 'name': 'wsname', - 'mod_epoch': 1, - 'is_public': True, - 'is_deleted': False, - 'metadata': {'narrative_nice_name': 'narrname'}, - } - # Merge the data with the above defaults - return dict(defaults, **data) - - -def _construct_ws_obj_ver(wsid, objid, ver, is_public=False): - """Test helper to create a ws_object_version vertex.""" - return { - '_key': f"{wsid}:{objid}:{ver}", - 'workspace_id': wsid, - 'object_id': objid, - 'version': ver, - 'name': f'obj_name{objid}', - 'hash': 'xyz', - 'size': 100, - 'epoch': 0, - 'deleted': False, - 'is_public': is_public, - } - - -def _construct_ws_obj(wsid, objid, is_public=False): - """Test helper to create a ws_object vertex.""" - return { - '_key': f"{wsid}:{objid}", - 'workspace_id': wsid, - 'object_id': objid, - 'deleted': False, - 'is_public': is_public, - } - - -def _create_delta_test_docs(coll_name, docs, edge=False): - """Add in delta required fields.""" - if edge: - for doc in docs: - # Replicate the time-travel system by just setting 'from' and 'to' to the keys - doc['from'] = doc['_from'].split('/')[1] - doc['to'] = doc['_to'].split('/')[1] - else: - for doc in docs: - doc['id'] = doc['_key'] - for doc in docs: - doc['expired'] = 9007199254740991 - doc['created'] = 0 - create_test_docs(coll_name, docs) - - class TestNcbiTax(unittest.TestCase): @classmethod @@ -82,15 +23,10 @@ def setUpClass(cls): {'_key': '2', 'scientific_name': 'Firmicutes', 'rank': 'Phylum', 'strain': False}, {'_key': '3', 'scientific_name': 'Bacilli', 'rank': 'Class', 'strain': False}, {'_key': '4', 'scientific_name': 'Proteobacteria', 'rank': 'Phylum', 'strain': False}, - {'_key': '5', 'scientific_name': 'Alphaproteobacteria', - 'rank': 'Class', 'strain': False}, - {'_key': '6', 'scientific_name': 'Gammaproteobacteria', 'rank': 'Class', - 'strain': False}, - {'_key': '7', 'scientific_name': 'Deltaproteobacteria', 'rank': 'Class', - 'strain': False}, - {'_key': '8', 'scientific_name': 'Bacillus subtilis 168', 'rank': 'no rank', - 'strain': True}, - + {'_key': '5', 'scientific_name': 'Alphaproteobacteria', 'rank': 'Class', 'strain': False}, + {'_key': '6', 'scientific_name': 'Gammaproteobacteria', 'rank': 'Class', 'strain': False}, + {'_key': '7', 'scientific_name': 'Deltaproteobacteria', 'rank': 'Class', 'strain': False}, + {'_key': '8', 'scientific_name': 'Bacillus subtilis 168', 'rank': 'no rank', 'strain': True}, ] child_docs = [ {'_from': 'ncbi_taxon/2', '_to': 'ncbi_taxon/1', 'from': '2', 'to': '1', 'id': '2'}, @@ -298,47 +234,57 @@ def test_search_sciname_limit_max(self): def test_search_sciname_limit_ranks_implicit_defaults(self): """ Test queries where the results are limited by the rank or strain flag. """ - self._run_search_sciname(None, None, 3, {'Bacteria', 'Bacilli', 'Bacillus subtilis 168'}) - + _run_search_sciname( + self, + ranks=None, + include_strains=None, + expected_count=3, + expected_sci_names={'Bacteria', 'Bacilli', 'Bacillus subtilis 168'}) + def test_search_sciname_limit_ranks_explicit_defaults(self): """ Test queries where the results are limited by the rank or strain flag. """ - self._run_search_sciname([], False, 3, {'Bacteria', 'Bacilli', 'Bacillus subtilis 168'}) + _run_search_sciname( + self, + ranks=[], + include_strains=False, + expected_count=3, + expected_sci_names={'Bacteria', 'Bacilli', 'Bacillus subtilis 168'}) def test_search_sciname_limit_ranks_2(self): """ Test queries where the results are limited by the rank or strain flag. """ - self._run_search_sciname(['Domain', 'Class'], None, 2, {'Bacteria', 'Bacilli'}) + _run_search_sciname( + self, + ranks=['Domain', 'Class'], + include_strains=None, + expected_count=2, + expected_sci_names={'Bacteria', 'Bacilli'}) def test_search_sciname_limit_ranks_1(self): """ Test queries where the results are limited by the rank or strain flag. """ - self._run_search_sciname(['Class'], None, 1, {'Bacilli'}) + _run_search_sciname( + self, + ranks=['Class'], + include_strains=None, + expected_count=1, + expected_sci_names={'Bacilli'}) def test_search_sciname_limit_ranks_1_with_strain(self): """ Test queries where the results are limited by the rank or strain flag. """ - self._run_search_sciname(['Class'], True, 2, {'Bacilli', 'Bacillus subtilis 168'}) + _run_search_sciname( + self, + ranks=['Class'], + include_strains=True, + expected_count=2, + expected_sci_names={'Bacilli', 'Bacillus subtilis 168'}) def test_search_sciname_limit_ranks_1_with_false_strain(self): """ Test queries where the results are limited by the rank or strain flag. """ - self._run_search_sciname(['Class'], False, 1, {'Bacilli'}) - - def _run_search_sciname(self, ranks, include_strains, expected_count, expected_sci_names): - data = { - 'ts': _NOW, - 'search_text': "prefix:bac" - } - if ranks is not None: - data['ranks'] = ranks - if include_strains is not None: - data['include_strains'] = include_strains - resp = requests.post( - _CONF['re_api_url'] + '/api/v1/query_results', - params={'stored_query': 'ncbi_taxon_search_sci_name'}, - data=json.dumps(data) - ).json() - result = resp['results'][0] - self.assertEqual(result['total_count'], expected_count) - names = {r['scientific_name'] for r in result['results']} - self.assertEqual(names, expected_sci_names) - + _run_search_sciname( + self, + ranks=['Class'], + include_strains=False, + expected_count=1, + expected_sci_names={'Bacilli'}) def test_select_fields(self): """Test that the 'select' works properly for one query.""" @@ -449,3 +395,88 @@ def test_fetch_taxon_by_sciname_failures(self): ).json() self.assertEqual(resp['count'], 0) self.assertEqual(len(resp['results']), 0) + + +# -- Test helpers + +def _run_search_sciname(self, ranks, include_strains, expected_count, expected_sci_names): + """ + Helper to run the ncbi_taxon_search_sci_name query and make some standard + assertions on the response. + """ + data = { + 'ts': _NOW, + 'search_text': "prefix:bac" + } + if ranks is not None: + data['ranks'] = ranks + if include_strains is not None: + data['include_strains'] = include_strains + resp = requests.post( + _CONF['re_api_url'] + '/api/v1/query_results', + params={'stored_query': 'ncbi_taxon_search_sci_name'}, + data=json.dumps(data) + ).json() + result = resp['results'][0] + self.assertEqual(result['total_count'], expected_count) + names = {r['scientific_name'] for r in result['results']} + self.assertEqual(names, expected_sci_names) + + +def _ws_defaults(data): + """Set some defaults for the required workspace fields.""" + defaults = { + 'owner': 'owner', + 'max_obj_id': 1, + 'lock_status': 'n', + 'name': 'wsname', + 'mod_epoch': 1, + 'is_public': True, + 'is_deleted': False, + 'metadata': {'narrative_nice_name': 'narrname'}, + } + # Merge the data with the above defaults + return dict(defaults, **data) + + +def _construct_ws_obj_ver(wsid, objid, ver, is_public=False): + """Test helper to create a ws_object_version vertex.""" + return { + '_key': f"{wsid}:{objid}:{ver}", + 'workspace_id': wsid, + 'object_id': objid, + 'version': ver, + 'name': f'obj_name{objid}', + 'hash': 'xyz', + 'size': 100, + 'epoch': 0, + 'deleted': False, + 'is_public': is_public, + } + + +def _construct_ws_obj(wsid, objid, is_public=False): + """Test helper to create a ws_object vertex.""" + return { + '_key': f"{wsid}:{objid}", + 'workspace_id': wsid, + 'object_id': objid, + 'deleted': False, + 'is_public': is_public, + } + + +def _create_delta_test_docs(coll_name, docs, edge=False): + """Add in delta required fields.""" + if edge: + for doc in docs: + # Replicate the time-travel system by just setting 'from' and 'to' to the keys + doc['from'] = doc['_from'].split('/')[1] + doc['to'] = doc['_to'].split('/')[1] + else: + for doc in docs: + doc['id'] = doc['_key'] + for doc in docs: + doc['expired'] = 9007199254740991 + doc['created'] = 0 + create_test_docs(coll_name, docs) From 8ef459f8f3d2ba02d13fe17de59036a122761de0 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 15 Oct 2019 11:12:36 -0700 Subject: [PATCH 435/732] Add another test query; clean up AQL syntax; move into test subdir (#114) --- spec/stored_queries/list_test_vertices.yaml | 6 ------ spec/stored_queries/test/fetch_test_vertex.yaml | 13 +++++++++++++ spec/stored_queries/test/list_test_vertices.yaml | 7 +++++++ 3 files changed, 20 insertions(+), 6 deletions(-) delete mode 100644 spec/stored_queries/list_test_vertices.yaml create mode 100644 spec/stored_queries/test/fetch_test_vertex.yaml create mode 100644 spec/stored_queries/test/list_test_vertices.yaml diff --git a/spec/stored_queries/list_test_vertices.yaml b/spec/stored_queries/list_test_vertices.yaml deleted file mode 100644 index 8d41386d..00000000 --- a/spec/stored_queries/list_test_vertices.yaml +++ /dev/null @@ -1,6 +0,0 @@ -# Test query - List all test vertices -name: list_test_vertices -query: | - for o in test_vertex - filter o.is_public || o.ws_id IN ws_ids - return o diff --git a/spec/stored_queries/test/fetch_test_vertex.yaml b/spec/stored_queries/test/fetch_test_vertex.yaml new file mode 100644 index 00000000..8845f4a1 --- /dev/null +++ b/spec/stored_queries/test/fetch_test_vertex.yaml @@ -0,0 +1,13 @@ +# Test query - fetch a single test vertex by ID +name: fetch_test_vertex +params: + type: object + required: [key] + properties: + key: + type: string + title: _key to match on +query: | + FOR o IN test_vertex + FILTER o._key == @key + RETURN o diff --git a/spec/stored_queries/test/list_test_vertices.yaml b/spec/stored_queries/test/list_test_vertices.yaml new file mode 100644 index 00000000..5d027d78 --- /dev/null +++ b/spec/stored_queries/test/list_test_vertices.yaml @@ -0,0 +1,7 @@ +# Test query - List all test vertices +# Has some simple auth against ws_ids +name: list_test_vertices +query: | + FOR o IN test_vertex + FILTER o.is_public || o.ws_id IN ws_ids + RETURN o From 768a0ecaeaaf61ab4c682cbb4f8915e4face6334 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 15 Oct 2019 11:41:27 -0700 Subject: [PATCH 436/732] WIP full client code plus partial tests --- api/README.md | 1 + api/src/relation_engine_client/__init__.py | 4 +- api/src/relation_engine_client/exceptions.py | 39 +++++ api/src/relation_engine_client/main.py | 146 ++++++++++++++++++ api/src/test/__init__.py | 0 .../test/relation_engine_client/__init__.py | 0 .../test_integration.py | 116 ++++++++++++++ 7 files changed, 305 insertions(+), 1 deletion(-) create mode 100644 api/src/relation_engine_client/exceptions.py create mode 100644 api/src/relation_engine_client/main.py create mode 100644 api/src/test/__init__.py create mode 100644 api/src/test/relation_engine_client/__init__.py create mode 100644 api/src/test/relation_engine_client/test_integration.py diff --git a/api/README.md b/api/README.md index a06012e4..247a46c5 100644 --- a/api/README.md +++ b/api/README.md @@ -110,6 +110,7 @@ curl -X PUT {root_url}/api/v1/documents?collection=genes&on_duplicate=update _Query params_ * `collection` - required - string - name of the collection that we want to bulk-import into. * `on_duplicate` - optional - "replace", "update", "ignore", "error" - Action to take when we find a duplicate document by `_key`. "replace" replaces the whole document. "update" merges in the new values. "ignore" takes no action. "error" cancels the entire transaction. +* `display_errors` - optional - bool - whether to return error messages for each document that failed to save in the response. This is disabled by default as it will slow down the response time. * `overwrite` - optional - boolean - whether to overwrite the whole collection (that is, delete all documents currently in the collection before creating the documents you provide) _Request body_ diff --git a/api/src/relation_engine_client/__init__.py b/api/src/relation_engine_client/__init__.py index 46409041..939f6d1b 100644 --- a/api/src/relation_engine_client/__init__.py +++ b/api/src/relation_engine_client/__init__.py @@ -1 +1,3 @@ -# TODO +from .main import REClient + +__all__ = ['REClient'] diff --git a/api/src/relation_engine_client/exceptions.py b/api/src/relation_engine_client/exceptions.py new file mode 100644 index 00000000..1e68dcba --- /dev/null +++ b/api/src/relation_engine_client/exceptions.py @@ -0,0 +1,39 @@ + +class REServerError(Exception): + + def __init__(self, resp): + self.resp = resp + + def __repr__(self): + return ( + f"Relation engine API server error:\n" + f"Request URL: {self.resp.method}\n" + f"Response: {self.resp.json()}" + ) + + +class RERequestError(Exception): + + def __init__(self, resp): + self.resp = resp + + def __repr__(self): + return ( + f"Relation engine API client request error:\n" + f"Request URL: {self.resp.method}\n" + f"Response: {self.resp.json()}" + ) + + +class RENotFound(Exception): + + def __init__(self, req_body, req_params): + self.req_body = req_body + self.req_params = req_params + + def __repr__(self): + return ( + f"Documents not found in the Relation Engine:\n" + f"Request body: {self.req_body}\n" + f"URL params: {self.req_params}" + ) diff --git a/api/src/relation_engine_client/main.py b/api/src/relation_engine_client/main.py new file mode 100644 index 00000000..abd79a4f --- /dev/null +++ b/api/src/relation_engine_client/main.py @@ -0,0 +1,146 @@ +import os +import json +import requests +from typing import Optional, List, Dict, Union +from dataclasses import dataclass + +from src.relation_engine_client.exceptions import REServerError, RERequestError, RENotFound + +_QUERY_METHOD = 'POST' +_QUERY_ENDPOINT = '/api/v1/query_results' +_SAVE_METHOD = 'PUT' +_SAVE_ENDPOINT = '/api/v1/documents' + + +@dataclass +class REClient: + # The `api_url` can be set with the RE_API_URL env var if provided. + # We can also use the KBASE_ENDPOINT env var (eg. "https://ci.kbase.us/services/"). + api_url: Optional[str] = None + # Set to the KBASE_TOKEN env var if not provided + token: Optional[str] = None + + def __post_init__(self): + if self.token is None: + self.token = os.environ.get('KBASE_TOKEN') + if self.api_url is None: + if 'RE_API_URL' in os.environ: + self.api_url = os.environ['RE_API_URL'] + elif 'KBASE_ENDPOINT' in os.environ: + # eg. https://ci.kbase.us/services/ + # Remove any trailing slash and append the RE API service name + self.api_url = os.environ['KBASE_ENDPOINT'].strip('/') + '/relation_engine_api' + if not self.api_url: + raise RuntimeError("The Relation Engine API URL was not provided. " + "Set the `api_url` constructor parameter, the " + "RE_API_URL environment variable, or the " + "KBASE_ENDPOINT environment variable.") + # Remove any trailing slash + self.api_url = self.api_url.strip('/') + + def admin_query(self, query: str, bind_vars: dict, raise_not_found=False): + """ + Run an ad-hoc query using admin privs. + Params: + query - string - AQL query to execute + bind_vars - dict - JSON serializable bind variables for the query + raise_not_found - bool - Whether to raise an error if there are zero results. Defaults to False + Exceptions raised: + REParamError - raised on invalid parameters to the RE API + REServerError - raised on a 500 from the RE API + RENotFound - raised when raise_not_found is True and there are 0 results + """ + req_body = dict(bind_vars) + req_body['query'] = query + url = str(self.api_url) + _QUERY_ENDPOINT + resp = self._make_request( + method=_QUERY_METHOD, + url=url, + data=json.dumps(req_body), + params={}, + raise_not_found=raise_not_found) + return resp + + def stored_query(self, stored_query: str, bind_vars: dict, raise_not_found=False): + """ + Run a stored query. + Params: + stored_query - string - name of the stored query to execute + bind_vars - JSON serializable - bind variables for the query (JSON serializable) + raise_not_found - bool - Whether to raise an error if there are zero results. Defaults to False + Exceptions raised: + REParamError - raised on invalid parameters to the RE API + REServerError - raised on a 500 from the RE API + RENotFound - raised when raise_not_found is True and there are 0 results + """ + req_body = dict(bind_vars) + url = str(self.api_url) + _QUERY_ENDPOINT + return self._make_request( + method=_QUERY_METHOD, + url=url, + data=json.dumps(req_body), + params={'stored_query': stored_query}, + raise_not_found=raise_not_found) + + def save_docs( + self, + coll: str, + docs: Union[Dict, List[Dict]], + on_duplicate: Optional[str] = None, + overwrite=False, + display_errors=False): + """ + Save documents to a collection in the relation engine. + Params: + coll - str - collection name to save to + docs - a single dict or list of dicts - json-serializable documents to save + on_duplicate - str (defaults to 'error') - what to do when a provided document + already exists in the collection. See options here: + https://github.com/kbase/relation_engine_api#put-apiv1documents + overwrite - bool (defaults to False) - whether to overwrite + everything in the collection (ie. remove all contents of the + collection before writing new documents) + display_errors - bool (defaults to False) - whether to respond with + document save errors (the response will give you an error for every + document that failed to save). + """ + if isinstance(docs, dict): + docs = [docs] + params = {'collection': coll} + if display_errors: + params['display_errors'] = '1' + if overwrite: + params['overwrite'] = '1' + params['on_duplicate'] = on_duplicate or 'error' + req_body = '\n'.join(json.dumps(d) for d in docs) + url = str(self.api_url) + _SAVE_ENDPOINT + return self._make_request( + method=_SAVE_METHOD, + url=url, + data=req_body, + params=params, + raise_not_found=False) + + def _make_request(self, method, url, data, params, raise_not_found): + """ + Internal utility to make a generic request to the RE API and handle the + response. + """ + headers = {} + if self.token: + headers['Authorization'] = self.token + resp = requests.request(method=method, url=url, data=data, params=params, headers=headers) + if resp.status_code >= 500: + # Server error + raise REServerError(resp) + elif resp.status_code >= 400 and resp.status_code < 500: + # Client error + raise RERequestError(resp) + elif not resp.ok: + raise RuntimeError( + f"Unknown RE API error:\nURL: {resp.url}\nMethod: {method}\n{resp.text}") + resp_json = resp.json() + if raise_not_found and not len(resp_json['results']): + # Results were required to be non-empty + raise RENotFound(req_body=data, req_params=params) + return resp_json diff --git a/api/src/test/__init__.py b/api/src/test/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/api/src/test/relation_engine_client/__init__.py b/api/src/test/relation_engine_client/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/api/src/test/relation_engine_client/test_integration.py b/api/src/test/relation_engine_client/test_integration.py new file mode 100644 index 00000000..9fb63603 --- /dev/null +++ b/api/src/test/relation_engine_client/test_integration.py @@ -0,0 +1,116 @@ +import unittest +import os +from uuid import uuid4 + +from src.relation_engine_client import REClient +from src.relation_engine_client.exceptions import RERequestError, RENotFound + +_API_URL = os.environ.get('RE_API_URL', 'http://localhost:5000') +_VERT_COLL = 'test_vertex' +_EDGE_COLL = 'test_edge' +_TOK_ADMIN = 'admin_token' +_TOK_USER = 'non_admin_token' +_TOK_INVALID = 'invalid_token' + + +class TestREClientIntegration(unittest.TestCase): + """Integration tests for the REClient package.""" + + @classmethod + def setUpClass(cls): + cls.client = REClient(_API_URL, _TOK_ADMIN) + pass + + def test_admin_query_ok(self): + _id = self._save_test_vert() + bind_vars = {'id': _id} + query = f"FOR vert IN {_VERT_COLL} FILTER vert._key == @id RETURN vert" + result = self.client.admin_query(query, bind_vars) + self.assertEqual(result['count'], 1) + self.assertEqual(result['results'][0]['_key'], _id) + + def test_admin_empty_query(self): + bind_vars = {'id': 'xyz'} + with self.assertRaises(RERequestError) as err: + self.client.admin_query("", bind_vars) + self.assertEqual(err.resp.status_code, 400) + + def test_admin_missing_param(self): + query = f"FOR vert IN {_VERT_COLL} FILTER vert._key == @id RETURN vert" + with self.assertRaises(RERequestError) as err: + self.client.admin_query(query, bind_vars={}) + self.assertEqual(err.resp.status_code, 400) + + def test_admin_raise_not_found(self): + query = f"FOR vert IN {_VERT_COLL} FILTER vert._key == @id RETURN vert" + _id = str(uuid4()) + bind_vars = {'id': _id} + with self.assertRaises(RENotFound) as err: + self.client.admin_query(query, bind_vars, raise_not_found=True) + self.assertTrue(_id in err.req_body) + + def test_admin_bad_params(self): + # No params + with self.assertRaises(TypeError): + self.client.admin_query() + # Wrong type for query + with self.assertRaises(TypeError): + self.client.admin_query(123) + # Wrong type for bind_vars + with self.assertRaises(TypeError): + self.client.admin_query("", 123) + + def test_stored_query_ok(self): + _id = self._save_test_vert() + bind_vars = {'id': _id} + qname = 'fetch_test_vertex' + result = self.client.stored_query(qname, bind_vars) + self.assertEqual(result['count'], 1) + self.assertEqual(result['results'][0]['_key'], _id) + + def test_stored_query_invalid_args(self): + # TODO + pass + + def test_stored_query_unknown_query(self): + # TODO + pass + + def test_stored_query_missing_bind_vars(self): + # TODO + pass + + def test_stored_query_raise_not_found(self): + # TODO + pass + + def test_save_docs_ok(self): + # TODO + pass + + def test_save_docs_invalid_args(self): + # TODO + pass + + def test_save_docs_unknown_coll(self): + # TODO + pass + + def test_save_docs_empty_docs(self): + # TODO + pass + + def test_save_docs_invalid_docs(self): + # TODO + pass + + # -- Test helpers + + def _save_test_vert(self): + """Create a test vertex with a random & unique id.""" + _id = str(uuid4()) + docs = [{'_key': _id}] + results = self.client.save_docs(coll=_VERT_COLL, docs=docs) + if results['error']: + raise RuntimeError(results) + return _id From 9d2cf8d599f9629f9336e40a113644858ca3f2d0 Mon Sep 17 00:00:00 2001 From: Gavin Date: Tue, 15 Oct 2019 15:29:26 -0700 Subject: [PATCH 437/732] Add RDP schemas --- spec/schemas/rdp/README.md | 7 ++++ spec/schemas/rdp/rdp_child_of_taxon.yaml | 20 +++++++++++ spec/schemas/rdp/rdp_taxon.yaml | 44 ++++++++++++++++++++++++ 3 files changed, 71 insertions(+) create mode 100644 spec/schemas/rdp/README.md create mode 100644 spec/schemas/rdp/rdp_child_of_taxon.yaml create mode 100644 spec/schemas/rdp/rdp_taxon.yaml diff --git a/spec/schemas/rdp/README.md b/spec/schemas/rdp/README.md new file mode 100644 index 00000000..1ac639d1 --- /dev/null +++ b/spec/schemas/rdp/README.md @@ -0,0 +1,7 @@ +# Ribosomal Database Project + +KBase Relation Engine schemas for RDP taxonomy data + +References: + +* https://rdp.cme.msu.edu/ diff --git a/spec/schemas/rdp/rdp_child_of_taxon.yaml b/spec/schemas/rdp/rdp_child_of_taxon.yaml new file mode 100644 index 00000000..c86d64ef --- /dev/null +++ b/spec/schemas/rdp/rdp_child_of_taxon.yaml @@ -0,0 +1,20 @@ +name: rdp_child_of_taxon +type: edge +delta: true + +schema: + "$schema": http://json-schema.org/draft-07/schema# + type: object + required: [from, to, id] + description: Edges which create the taxonomy tree for RDP taxons. + properties: + id: + type: string + description: The id of the edge. This is the id of the from node (e.g. the child node in + the tree) for the edge. + from: + type: string + description: The child taxon. The id of the from node for the edge. + to: + type: string + description: The parent taxon. The id of the to node for the edge. diff --git a/spec/schemas/rdp/rdp_taxon.yaml b/spec/schemas/rdp/rdp_taxon.yaml new file mode 100644 index 00000000..3317b3fa --- /dev/null +++ b/spec/schemas/rdp/rdp_taxon.yaml @@ -0,0 +1,44 @@ +name: rdp_taxon +type: vertex +delta: true + +schema: + "$schema": http://json-schema.org/draft-07/schema# + type: object + description: Template for a vertex entry in the RDP taxonomy tree. + required: [id, name, rank, molecule, unclassified, incertae_sedis] + properties: + id: + type: string + description: RDP Taxon id. For a non-sequence node, this is the rank joined + with ':' and the taxon name with spaces and slashes replaced by underscores. + If the node is an incertae sedis insertion, ':is' is appended. For a sequence (e.g. leaf) + node, it is the locus ID. + examples: ['phylum:Actinobacteria', 'S000494589'] + name: + type: string + description: The name of the taxon. For sequences this is the strain name. Some sequences + in RDP have no name, in which case the name will be an empty string. + If '[ _][Ii]ncertae[ _][Ss]edis' exists in the name for internal nodes, that + text is removed and the node is marked as an incertae sedis node (see below). + examples: ['Acidimicrobium', 'uncultured bacterium; YRM60L1D06060904'] + rank: + type: string + title: Taxonomic rank. Sequence node rank is always 'sequence_example'. + examples: [domain, sequence_example] + molecule: + type: ['string', 'null'] + description: The type of molecule for the RDP sequence. Either 16S or 28S. Null + for non-leaf nodes. + examples: [16S, 28S] + unclassified: + type: boolean + description: Denotes an sequence that does not have a full lineage. In the RDP files, + these sequence are denoted via a truncated linage string where the last entry starts + with the string 'unclassified_'. The lineage string is a list of tuples of rank and name + all separated by semicolons, so if there are an odd number of entries in the lineage + string an unclassified organism is expected. Always false for internal nodes. + incertae_sedis: + type: ['boolean', 'null'] + description: Denotes a taxa node that is an inceratae sedis insertion. Always null for + sequence (e.g. leaf) nodes. From 498605bb8d79af9fddb64651cf21d6c1bcb634bd Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 16 Oct 2019 10:31:48 -0700 Subject: [PATCH 438/732] More tests --- api/src/relation_engine_client/exceptions.py | 22 +++-- api/src/relation_engine_client/main.py | 2 + .../test_integration.py | 77 +++++++++++------- api/src/test/spec_release/spec.tar.gz | Bin 18579 -> 20677 bytes 4 files changed, 65 insertions(+), 36 deletions(-) diff --git a/api/src/relation_engine_client/exceptions.py b/api/src/relation_engine_client/exceptions.py index 1e68dcba..beffa43f 100644 --- a/api/src/relation_engine_client/exceptions.py +++ b/api/src/relation_engine_client/exceptions.py @@ -1,10 +1,12 @@ +import json + class REServerError(Exception): def __init__(self, resp): self.resp = resp - def __repr__(self): + def __str__(self): return ( f"Relation engine API server error:\n" f"Request URL: {self.resp.method}\n" @@ -17,12 +19,16 @@ class RERequestError(Exception): def __init__(self, resp): self.resp = resp - def __repr__(self): - return ( - f"Relation engine API client request error:\n" - f"Request URL: {self.resp.method}\n" - f"Response: {self.resp.json()}" - ) + def __str__(self): + try: + return ( + f"Relation engine API client request error:\n" + f"Request URL: {self.resp.method}\n" + f"Response: {json.dumps(self.resp.json(), indent=2)}" + ) + except Exception as err: + print(err) + return self.resp.text class RENotFound(Exception): @@ -31,7 +37,7 @@ def __init__(self, req_body, req_params): self.req_body = req_body self.req_params = req_params - def __repr__(self): + def __str__(self): return ( f"Documents not found in the Relation Engine:\n" f"Request body: {self.req_body}\n" diff --git a/api/src/relation_engine_client/main.py b/api/src/relation_engine_client/main.py index abd79a4f..23f9196e 100644 --- a/api/src/relation_engine_client/main.py +++ b/api/src/relation_engine_client/main.py @@ -106,6 +106,8 @@ def save_docs( """ if isinstance(docs, dict): docs = [docs] + if not docs: + raise TypeError("No documents provided to save") params = {'collection': coll} if display_errors: params['display_errors'] = '1' diff --git a/api/src/test/relation_engine_client/test_integration.py b/api/src/test/relation_engine_client/test_integration.py index 9fb63603..aa0694cb 100644 --- a/api/src/test/relation_engine_client/test_integration.py +++ b/api/src/test/relation_engine_client/test_integration.py @@ -31,25 +31,25 @@ def test_admin_query_ok(self): def test_admin_empty_query(self): bind_vars = {'id': 'xyz'} - with self.assertRaises(RERequestError) as err: + with self.assertRaises(RERequestError) as ctx: self.client.admin_query("", bind_vars) - self.assertEqual(err.resp.status_code, 400) + self.assertEqual(ctx.exception.resp.status_code, 400) def test_admin_missing_param(self): query = f"FOR vert IN {_VERT_COLL} FILTER vert._key == @id RETURN vert" - with self.assertRaises(RERequestError) as err: + with self.assertRaises(RERequestError) as ctx: self.client.admin_query(query, bind_vars={}) - self.assertEqual(err.resp.status_code, 400) + self.assertEqual(ctx.exception.resp.status_code, 400) def test_admin_raise_not_found(self): query = f"FOR vert IN {_VERT_COLL} FILTER vert._key == @id RETURN vert" _id = str(uuid4()) bind_vars = {'id': _id} - with self.assertRaises(RENotFound) as err: + with self.assertRaises(RENotFound) as ctx: self.client.admin_query(query, bind_vars, raise_not_found=True) - self.assertTrue(_id in err.req_body) + self.assertTrue(_id in ctx.exception.req_body) - def test_admin_bad_params(self): + def test_admin_invalid_args(self): # No params with self.assertRaises(TypeError): self.client.admin_query() @@ -62,47 +62,68 @@ def test_admin_bad_params(self): def test_stored_query_ok(self): _id = self._save_test_vert() - bind_vars = {'id': _id} + bind_vars = {'key': _id} qname = 'fetch_test_vertex' result = self.client.stored_query(qname, bind_vars) self.assertEqual(result['count'], 1) self.assertEqual(result['results'][0]['_key'], _id) def test_stored_query_invalid_args(self): - # TODO - pass + with self.assertRaises(TypeError): + self.client.stored_query() + with self.assertRaises(TypeError): + self.client.stored_query(123, 123) + with self.assertRaises(TypeError): + self.client.stored_query("") def test_stored_query_unknown_query(self): - # TODO - pass + qname = 'xyz123' + with self.assertRaises(RERequestError) as ctx: + self.client.admin_query(qname, bind_vars={'key': 0}) + self.assertEqual(ctx.exception.resp.status_code, 400) def test_stored_query_missing_bind_vars(self): - # TODO - pass + qname = 'fetch_test_vertex' + with self.assertRaises(RERequestError) as ctx: + self.client.admin_query(qname, bind_vars={'x': 'y'}) + self.assertEqual(ctx.exception.resp.status_code, 400) def test_stored_query_raise_not_found(self): - # TODO - pass + _id = str(uuid4()) + bind_vars = {'key': _id} + qname = 'fetch_test_vertex' + with self.assertRaises(RENotFound) as ctx: + self.client.stored_query(qname, bind_vars, raise_not_found=True) + self.assertTrue(_id in ctx.exception.req_body) def test_save_docs_ok(self): - # TODO - pass + _id = str(uuid4()) + docs = [{'_key': _id}] + results = self.client.save_docs(coll=_VERT_COLL, docs=docs) + self.assertEqual(results['created'], 1) + self.assertFalse(results['error']) + self.assertEqual(results['errors'], 0) + self.assertEqual(results['ignored'], 0) + self.assertEqual(results['updated'], 0) def test_save_docs_invalid_args(self): - # TODO - pass + with self.assertRaises(TypeError): + self.client.save_docs() + with self.assertRaises(TypeError): + self.client.save_docs(123, 456) + # Empty docs list + with self.assertRaises(TypeError): + self.client.save_docs(_VERT_COLL, []) def test_save_docs_unknown_coll(self): - # TODO - pass - - def test_save_docs_empty_docs(self): - # TODO - pass + with self.assertRaises(RERequestError) as ctx: + self.client.save_docs('xyz123', [{'_key': 0}]) + self.assertEqual(ctx.exception.resp.status_code, 400) def test_save_docs_invalid_docs(self): - # TODO - pass + with self.assertRaises(RERequestError) as ctx: + self.client.save_docs(_VERT_COLL, [{'hi': 0}]) + self.assertEqual(ctx.exception.resp.status_code, 400) # -- Test helpers diff --git a/api/src/test/spec_release/spec.tar.gz b/api/src/test/spec_release/spec.tar.gz index 4059a2a8affae812b186d35d543793e8d5f2b114..27244be9b3dcc4aa90db95b3a87c0c98ea72dbe1 100644 GIT binary patch literal 20677 zcmV)jK%u`MiwFP!000001MEF(Z`-)C{hVJxamz0uv56*wTGo+rDY|D8#+pUS+)RHL9kn`klNX_UsYwU_4b*%}b4wJ8* zzSN;~IvxEll*NDH;nAx`tKDuK9UXO#+Hk*d)NXcOjh_LRTnUs~_LE_-qWs|Uzk>cX zU(!3SYV)c4I2cC%AFa^;odx{OzABnK2!eA0{m^t3isFP^r+a%>pD)Oa&j|NmbX=EItHEq6VS1qNqP74npvdn^c*>rzDTOBHbn5Q? z_UY>9{`nO-q_f%H>8HzolbZSc(*4|(;<7^ijsCB~^k60wt08?K24ju`-ap9Age#JzJb^nSA&JB8m@8&X!i>?oV;*Oo%?R}z?Gtcs zTp^zDbyXR79^3%^L1t1ofsHIy+e^6@dxZRh44B6xbwmAw&H5CWQ0g|=H)aRetZrVx z3&@*2_?M7jz+IqutN8P}K0 zyW>)LI0sIi_fM?PS0CR`e1FzEJfxC(W8n;YZ`;jxnL5{JSMQNE;+t1z*74&U$g)7dnbC<(ymARx92DhPf~ zg@YKx(9(<$-)z;|YiN#0>OY3&7~BC7?GZI0Rh#TbErCf##Rq_EuCS>a;Rk5gw}$aF zD@2ICR*VrP?L!pCL#$-s<3nJmnc$wU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QGA9i+}=b$njJH+p#`&!o8-ofeF z!4V#j6#K*4V^6&QaQf3WnZ+vJ% Date: Wed, 16 Oct 2019 10:34:25 -0700 Subject: [PATCH 439/732] Add exception comments --- api/src/relation_engine_client/exceptions.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/api/src/relation_engine_client/exceptions.py b/api/src/relation_engine_client/exceptions.py index beffa43f..d3930782 100644 --- a/api/src/relation_engine_client/exceptions.py +++ b/api/src/relation_engine_client/exceptions.py @@ -2,6 +2,7 @@ class REServerError(Exception): + """Server-originated error from RE API (ie. 500+)""" def __init__(self, resp): self.resp = resp @@ -15,6 +16,7 @@ def __str__(self): class RERequestError(Exception): + """Error in the request format or data from the client (ie. 400)""" def __init__(self, resp): self.resp = resp @@ -32,6 +34,7 @@ def __str__(self): class RENotFound(Exception): + """The user required some results to be returned, but there were none.""" def __init__(self, req_body, req_params): self.req_body = req_body From 42d24c0b0f5a163fb3cc0efa0b63c3310a6730c2 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 16 Oct 2019 10:36:54 -0700 Subject: [PATCH 440/732] Add comment about exceptions --- api/src/relation_engine_client/main.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/api/src/relation_engine_client/main.py b/api/src/relation_engine_client/main.py index 23f9196e..af2569d7 100644 --- a/api/src/relation_engine_client/main.py +++ b/api/src/relation_engine_client/main.py @@ -103,6 +103,9 @@ def save_docs( display_errors - bool (defaults to False) - whether to respond with document save errors (the response will give you an error for every document that failed to save). + Exceptions raised: + REServerError - 500 from the RE API + RERequestError - 400 from the RE API (client error) """ if isinstance(docs, dict): docs = [docs] From ec007169f2765408a5ec754f894a8c260409c26a Mon Sep 17 00:00:00 2001 From: Zhenyuan Lu Date: Wed, 23 Oct 2019 17:30:07 -0400 Subject: [PATCH 441/732] update GO queries --- spec/stored_queries/GO/GO_get_associated_ws_objects.yaml | 2 +- spec/stored_queries/GO/GO_get_terms_from_ws_feature.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/stored_queries/GO/GO_get_associated_ws_objects.yaml b/spec/stored_queries/GO/GO_get_associated_ws_objects.yaml index 0d79e2bf..d4051527 100644 --- a/spec/stored_queries/GO/GO_get_associated_ws_objects.yaml +++ b/spec/stored_queries/GO/GO_get_associated_ws_objects.yaml @@ -8,7 +8,7 @@ params: id: type: string title: Document ID - description: GO id of the term you want to get the children of + description: GO id of the term you want to get the ws object of limit: type: integer title: Maximum result limit diff --git a/spec/stored_queries/GO/GO_get_terms_from_ws_feature.yaml b/spec/stored_queries/GO/GO_get_terms_from_ws_feature.yaml index 27fc6ad8..531c23b6 100644 --- a/spec/stored_queries/GO/GO_get_terms_from_ws_feature.yaml +++ b/spec/stored_queries/GO/GO_get_terms_from_ws_feature.yaml @@ -21,7 +21,7 @@ params: ts: type: integer title: Versioning timestamp -query_prefix: WITH ws_genome_features, GO_terms +query_prefix: WITH ws_object_version, GO_terms query: | LET go_term_results=( FOR f in ws_genome_features From 5d60a1cc0cbb6813cd5528eee34e209f2059e0de Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 23 Oct 2019 17:01:52 -0700 Subject: [PATCH 442/732] Add docs for client; address PR comments --- api/README.md | 5 +- api/src/relation_engine_client/README.md | 98 +++++++++++++++++++ api/src/relation_engine_client/exceptions.py | 20 ++-- api/src/relation_engine_client/main.py | 66 +++++++------ .../test_integration.py | 57 ++++++++++- 5 files changed, 199 insertions(+), 47 deletions(-) create mode 100644 api/src/relation_engine_client/README.md diff --git a/api/README.md b/api/README.md index 247a46c5..3703818b 100644 --- a/api/README.md +++ b/api/README.md @@ -2,6 +2,10 @@ A simple API that allows KBase community developers to interact with the Relation Engine graph database. You can run stored queries or do bulk updates on documents. +## Python client + +There is a [pip-installable python client](src/relation_engine_client/README.md) that can be used to access the RE API. + ## HTTP API v1 The API is a small, rest-ish service where all data is in JSON format. Replace the `{root_url}` in the examples below with one of: @@ -111,7 +115,6 @@ _Query params_ * `collection` - required - string - name of the collection that we want to bulk-import into. * `on_duplicate` - optional - "replace", "update", "ignore", "error" - Action to take when we find a duplicate document by `_key`. "replace" replaces the whole document. "update" merges in the new values. "ignore" takes no action. "error" cancels the entire transaction. * `display_errors` - optional - bool - whether to return error messages for each document that failed to save in the response. This is disabled by default as it will slow down the response time. -* `overwrite` - optional - boolean - whether to overwrite the whole collection (that is, delete all documents currently in the collection before creating the documents you provide) _Request body_ diff --git a/api/src/relation_engine_client/README.md b/api/src/relation_engine_client/README.md new file mode 100644 index 00000000..446d30ad --- /dev/null +++ b/api/src/relation_engine_client/README.md @@ -0,0 +1,98 @@ +# Relation engine client + +A pip-installable Python client module for accessing the methods of the Relation Engine API. + +## Installation + +Install via pip using the KBase pip server: + +``` +pip install releng-client --extra-index-url=https://anaconda.org/kbase +``` + +## Usage + +### Initialize the client + +Pass in the URL of the Relation Engine API server you want to use, which is most likely one of the following: + +* `https://kbase.us/services/relation_engine_api` +* `https://ci.kbase.us/services/relation_engine_api` +* `https://appdev.kbase.us/services/relation_engine_api` + +Additionally, pass in a KBase auth token you would like to use for access control and document saving permissions when making requests to the API. + +```py +from releng_client import REClient + +re_client = REClient("https://ci.kbase.us/services/relation_engine_api", "xyz_my_token") +``` + +You can leave off the token if you want to do unauthenticated queries for public data. + +### Basic calls + +#### Stored queries + +To execute a stored/named query, run the following: + +``` +re_client.stored_query(query_name, bind_vars, raise_not_found=False) +``` + +Where: + +* `bind_vars`: required - dict - variables to use in the query. +* `raise_not_found`: options - bool - defaults to False - whether to raise an RENotFound error if 0 docs are returned. + +### Saving documents + +``` +re_client.save_docs(collection_name, docs, on_duplicate='error', display_errors=False) +``` + +Where: + +* `collection_name`: required - str - name of the collection you are saving documents into +* `docs`: required - list of dict or single dict - json-serializable list of + documents to save to the above collection +* `on_duplicate`: optional - one of 'replace', 'update', 'ignore', or 'error' defaults to 'error' - action to take when we have a duplicate document by + `_key` while saving. +* `display_errors`: optional - bool - defaults to False - whether to return + error messages for every document that failed to save. + +#### Admin queries + +To run an ad-hoc admin query, run: + +```py +re_client.admin_query(aql_query_text, bind_vars) +``` + +You must have an auth token set in the client with the RE admin role. + +### Exceptions + +A few different exceptions can be thrown from each method, which you can import: + +```py +from releng_client.exceptions import REServerError, RERequestError, RENotFound +``` + +#### REServerError + +An error was thrown by the server (status code 500). + +Access the `.resp.text` property on the error object to see the response body from the API, or simply print the error to debug. + +#### RERequestError + +There was an invalid or missing parameter or header in the request. + +Access the `.resp.text` property on the error object to see the response body from the API, or simply print the error to debug. + +#### RENotFound + +The `raise_not_found` argument was set to `True` and no documents were found in the query. + +Access the `.req_body` and `.req_params` properties of the error object to see the request data, or simply print the error to debug. diff --git a/api/src/relation_engine_client/exceptions.py b/api/src/relation_engine_client/exceptions.py index d3930782..c963acf4 100644 --- a/api/src/relation_engine_client/exceptions.py +++ b/api/src/relation_engine_client/exceptions.py @@ -1,5 +1,3 @@ -import json - class REServerError(Exception): """Server-originated error from RE API (ie. 500+)""" @@ -10,8 +8,8 @@ def __init__(self, resp): def __str__(self): return ( f"Relation engine API server error:\n" - f"Request URL: {self.resp.method}\n" - f"Response: {self.resp.json()}" + f"Status: {self.resp.status_code}\n" + f"Response: {self.resp.text}" ) @@ -22,15 +20,11 @@ def __init__(self, resp): self.resp = resp def __str__(self): - try: - return ( - f"Relation engine API client request error:\n" - f"Request URL: {self.resp.method}\n" - f"Response: {json.dumps(self.resp.json(), indent=2)}" - ) - except Exception as err: - print(err) - return self.resp.text + return ( + f"Relation engine API client request error:\n" + f"Status: {self.resp.status_code}\n" + f"Response: {self.resp.text}" + ) class RENotFound(Exception): diff --git a/api/src/relation_engine_client/main.py b/api/src/relation_engine_client/main.py index af2569d7..a7253dd5 100644 --- a/api/src/relation_engine_client/main.py +++ b/api/src/relation_engine_client/main.py @@ -1,4 +1,3 @@ -import os import json import requests from typing import Optional, List, Dict, Union @@ -14,28 +13,14 @@ @dataclass class REClient: - # The `api_url` can be set with the RE_API_URL env var if provided. - # We can also use the KBASE_ENDPOINT env var (eg. "https://ci.kbase.us/services/"). - api_url: Optional[str] = None - # Set to the KBASE_TOKEN env var if not provided + api_url: str token: Optional[str] = None def __post_init__(self): - if self.token is None: - self.token = os.environ.get('KBASE_TOKEN') - if self.api_url is None: - if 'RE_API_URL' in os.environ: - self.api_url = os.environ['RE_API_URL'] - elif 'KBASE_ENDPOINT' in os.environ: - # eg. https://ci.kbase.us/services/ - # Remove any trailing slash and append the RE API service name - self.api_url = os.environ['KBASE_ENDPOINT'].strip('/') + '/relation_engine_api' - if not self.api_url: - raise RuntimeError("The Relation Engine API URL was not provided. " - "Set the `api_url` constructor parameter, the " - "RE_API_URL environment variable, or the " - "KBASE_ENDPOINT environment variable.") - # Remove any trailing slash + # Type check the constructor parameters + if not self.api_url or not isinstance(self.api_url, str): + raise TypeError("The Relation Engine API URL was not provided.") + # Remove any trailing slash in the API URL so we can append paths self.api_url = self.api_url.strip('/') def admin_query(self, query: str, bind_vars: dict, raise_not_found=False): @@ -46,10 +31,18 @@ def admin_query(self, query: str, bind_vars: dict, raise_not_found=False): bind_vars - dict - JSON serializable bind variables for the query raise_not_found - bool - Whether to raise an error if there are zero results. Defaults to False Exceptions raised: - REParamError - raised on invalid parameters to the RE API - REServerError - raised on a 500 from the RE API + RERequestError - 400-499 error from the RE API + REServerError - 500+ error from the RE API RENotFound - raised when raise_not_found is True and there are 0 results """ + # Type-check the parameters + if not isinstance(query, str): + raise TypeError("`query` argument must be a str") + if not isinstance(bind_vars, dict): + raise TypeError("`bind_vars` argument must be a dict") + if not isinstance(raise_not_found, bool): + raise TypeError("`raise_not_found` argument must be a bool") + # Construct and execute the request req_body = dict(bind_vars) req_body['query'] = query url = str(self.api_url) + _QUERY_ENDPOINT @@ -69,10 +62,18 @@ def stored_query(self, stored_query: str, bind_vars: dict, raise_not_found=False bind_vars - JSON serializable - bind variables for the query (JSON serializable) raise_not_found - bool - Whether to raise an error if there are zero results. Defaults to False Exceptions raised: - REParamError - raised on invalid parameters to the RE API - REServerError - raised on a 500 from the RE API + RERequestError - 400-499 from the RE API (client error) + REServerError - 500+ error from the RE API RENotFound - raised when raise_not_found is True and there are 0 results """ + # Type-check the parameters + if not isinstance(stored_query, str): + raise TypeError("`stored_query` argument must be a str") + if not isinstance(bind_vars, dict): + raise TypeError("`bind_vars` argument must be a dict") + if not isinstance(raise_not_found, bool): + raise TypeError("`raise_not_found` argument must be a bool`") + # Construct and execute the request req_body = dict(bind_vars) url = str(self.api_url) + _QUERY_ENDPOINT return self._make_request( @@ -87,35 +88,36 @@ def save_docs( coll: str, docs: Union[Dict, List[Dict]], on_duplicate: Optional[str] = None, - overwrite=False, display_errors=False): """ Save documents to a collection in the relation engine. + Requires an auth token with RE admin privileges. Params: coll - str - collection name to save to docs - a single dict or list of dicts - json-serializable documents to save on_duplicate - str (defaults to 'error') - what to do when a provided document already exists in the collection. See options here: https://github.com/kbase/relation_engine_api#put-apiv1documents - overwrite - bool (defaults to False) - whether to overwrite - everything in the collection (ie. remove all contents of the - collection before writing new documents) display_errors - bool (defaults to False) - whether to respond with document save errors (the response will give you an error for every document that failed to save). Exceptions raised: - REServerError - 500 from the RE API - RERequestError - 400 from the RE API (client error) + RERequestError - 400-499 from the RE API (client error) + REServerError - 500+ error from the RE API """ if isinstance(docs, dict): docs = [docs] if not docs: raise TypeError("No documents provided to save") + if not isinstance(docs, list): + raise TypeError("`docs` argument must be a list") + if on_duplicate and not isinstance(on_duplicate, str): + raise TypeError("`on_duplicate` argument must bea str") + if not isinstance(display_errors, bool): + raise TypeError("`display_errors` argument must be a bool") params = {'collection': coll} if display_errors: params['display_errors'] = '1' - if overwrite: - params['overwrite'] = '1' params['on_duplicate'] = on_duplicate or 'error' req_body = '\n'.join(json.dumps(d) for d in docs) url = str(self.api_url) + _SAVE_ENDPOINT diff --git a/api/src/test/relation_engine_client/test_integration.py b/api/src/test/relation_engine_client/test_integration.py index aa0694cb..8df3f21f 100644 --- a/api/src/test/relation_engine_client/test_integration.py +++ b/api/src/test/relation_engine_client/test_integration.py @@ -6,8 +6,12 @@ from src.relation_engine_client.exceptions import RERequestError, RENotFound _API_URL = os.environ.get('RE_API_URL', 'http://localhost:5000') +# See the test schemas here: +# https://github.com/kbase/relation_engine_spec/tree/develop/schemas/test _VERT_COLL = 'test_vertex' _EDGE_COLL = 'test_edge' +# See the docker-compose.yaml file in the root of this repo +# See the mock auth endpoints in src/test/mock_auth/*.json _TOK_ADMIN = 'admin_token' _TOK_USER = 'non_admin_token' _TOK_INVALID = 'invalid_token' @@ -19,7 +23,6 @@ class TestREClientIntegration(unittest.TestCase): @classmethod def setUpClass(cls): cls.client = REClient(_API_URL, _TOK_ADMIN) - pass def test_admin_query_ok(self): _id = self._save_test_vert() @@ -29,17 +32,39 @@ def test_admin_query_ok(self): self.assertEqual(result['count'], 1) self.assertEqual(result['results'][0]['_key'], _id) + def test_admin_query_empty_auth(self): + client2 = REClient(_API_URL) + query = f"FOR vert IN {_VERT_COLL} FILTER vert._key == @id RETURN vert" + with self.assertRaises(RERequestError) as ctx: + client2.admin_query(query, {'id': 'xyz'}) + self.assertEqual(ctx.exception.resp.status_code, 400) + # Mostly make sure that the __str__ method does not throw any errs + self.assertTrue('Missing header: Authorization' in str(ctx.exception)) + + def test_admin_query_invalid_auth(self): + client2 = REClient(_API_URL, 'xyz') + query = f"FOR vert IN {_VERT_COLL} FILTER vert._key == @id RETURN vert" + with self.assertRaises(RERequestError) as ctx: + client2.admin_query(query, {'id': 'xyz'}) + self.assertEqual(ctx.exception.resp.status_code, 403) + # Mostly make sure that the __str__ method does not throw any errs + self.assertTrue('Unauthorized' in str(ctx.exception)) + def test_admin_empty_query(self): bind_vars = {'id': 'xyz'} with self.assertRaises(RERequestError) as ctx: self.client.admin_query("", bind_vars) self.assertEqual(ctx.exception.resp.status_code, 400) + # Mostly make sure that the __str__ method does not throw any errs + self.assertTrue('Response:' in str(ctx.exception)) def test_admin_missing_param(self): query = f"FOR vert IN {_VERT_COLL} FILTER vert._key == @id RETURN vert" with self.assertRaises(RERequestError) as ctx: self.client.admin_query(query, bind_vars={}) self.assertEqual(ctx.exception.resp.status_code, 400) + # Mostly make sure that the __str__ method does not throw any errs + self.assertTrue('Response:' in str(ctx.exception)) def test_admin_raise_not_found(self): query = f"FOR vert IN {_VERT_COLL} FILTER vert._key == @id RETURN vert" @@ -48,6 +73,8 @@ def test_admin_raise_not_found(self): with self.assertRaises(RENotFound) as ctx: self.client.admin_query(query, bind_vars, raise_not_found=True) self.assertTrue(_id in ctx.exception.req_body) + # Mostly make sure that the __str__ method does not throw any errs + self.assertTrue('Request body:' in str(ctx.exception)) def test_admin_invalid_args(self): # No params @@ -81,12 +108,16 @@ def test_stored_query_unknown_query(self): with self.assertRaises(RERequestError) as ctx: self.client.admin_query(qname, bind_vars={'key': 0}) self.assertEqual(ctx.exception.resp.status_code, 400) + # Mostly make sure that the __str__ method does not throw any errs + self.assertTrue('Response:' in str(ctx.exception)) def test_stored_query_missing_bind_vars(self): qname = 'fetch_test_vertex' with self.assertRaises(RERequestError) as ctx: self.client.admin_query(qname, bind_vars={'x': 'y'}) self.assertEqual(ctx.exception.resp.status_code, 400) + # Mostly make sure that the __str__ method does not throw any errs + self.assertTrue('Response:' in str(ctx.exception)) def test_stored_query_raise_not_found(self): _id = str(uuid4()) @@ -95,6 +126,8 @@ def test_stored_query_raise_not_found(self): with self.assertRaises(RENotFound) as ctx: self.client.stored_query(qname, bind_vars, raise_not_found=True) self.assertTrue(_id in ctx.exception.req_body) + # Mostly make sure that the __str__ method does not throw any errs + self.assertTrue('Request body:' in str(ctx.exception)) def test_save_docs_ok(self): _id = str(uuid4()) @@ -106,6 +139,24 @@ def test_save_docs_ok(self): self.assertEqual(results['ignored'], 0) self.assertEqual(results['updated'], 0) + def test_save_docs_empty_auth(self): + client2 = REClient(_API_URL) + docs = [{'_key': 'xyz'}] + with self.assertRaises(RERequestError) as ctx: + client2.save_docs(coll=_VERT_COLL, docs=docs) + self.assertEqual(ctx.exception.resp.status_code, 400) + # Mostly make sure that the __str__ method does not throw any errs + self.assertTrue('Missing header: Authorization' in str(ctx.exception)) + + def test_save_docs_invalid_auth(self): + client2 = REClient(_API_URL, 'xyz') + docs = [{'_key': 'xyz'}] + with self.assertRaises(RERequestError) as ctx: + client2.save_docs(coll=_VERT_COLL, docs=docs) + self.assertEqual(ctx.exception.resp.status_code, 403) + # Mostly make sure that the __str__ method does not throw any errs + self.assertTrue('Unauthorized' in str(ctx.exception)) + def test_save_docs_invalid_args(self): with self.assertRaises(TypeError): self.client.save_docs() @@ -119,11 +170,15 @@ def test_save_docs_unknown_coll(self): with self.assertRaises(RERequestError) as ctx: self.client.save_docs('xyz123', [{'_key': 0}]) self.assertEqual(ctx.exception.resp.status_code, 400) + # Mostly make sure that the __str__ method does not throw any errs + self.assertTrue('Response:' in str(ctx.exception)) def test_save_docs_invalid_docs(self): with self.assertRaises(RERequestError) as ctx: self.client.save_docs(_VERT_COLL, [{'hi': 0}]) self.assertEqual(ctx.exception.resp.status_code, 400) + # Mostly make sure that the __str__ method does not throw any errs + self.assertTrue('Response:' in str(ctx.exception)) # -- Test helpers From 9d797bfb91437b90f6360dfca0d973ef64772a51 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Thu, 24 Oct 2019 09:54:19 -0700 Subject: [PATCH 443/732] Add client_setup.py, dockerignore, and MANIFEST --- api/.dockerignore | 39 +++++++++++++++++++++++++++++++++++++++ api/MANIFEST | 5 +++++ api/client_setup.py | 13 +++++++++++++ 3 files changed, 57 insertions(+) create mode 100644 api/.dockerignore create mode 100644 api/MANIFEST create mode 100644 api/client_setup.py diff --git a/api/.dockerignore b/api/.dockerignore new file mode 100644 index 00000000..9b32afcf --- /dev/null +++ b/api/.dockerignore @@ -0,0 +1,39 @@ +__pycache__ +*.pyc +*.pyo +*.pyd +.Python +.tox +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*,cover +*.log +.git + +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +/dist/ +eggs/ +.eggs/ +*.egg-info/ +*.egg +MANIFEST + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json diff --git a/api/MANIFEST b/api/MANIFEST new file mode 100644 index 00000000..2d6e6ac3 --- /dev/null +++ b/api/MANIFEST @@ -0,0 +1,5 @@ +# file GENERATED by distutils, do NOT edit +client_setup.py +src/relation_engine_client/__init__.py +src/relation_engine_client/exceptions.py +src/relation_engine_client/main.py diff --git a/api/client_setup.py b/api/client_setup.py new file mode 100644 index 00000000..4225583f --- /dev/null +++ b/api/client_setup.py @@ -0,0 +1,13 @@ +from distutils.core import setup + + +setup( + name='releng-client', + version='0.0.1', + description='KBase Relation Engine API Client Module', + author='KBase Team', + url='https://github.com/kbase/relation_engine_api', + packages=['relation_engine_client'], + package_dir={'': 'src'}, + install_requires=['requests>=2'], +) From 21c44ecf3834457b66e6569c832d33457d17ad1e Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Thu, 24 Oct 2019 10:22:02 -0700 Subject: [PATCH 444/732] Get the setup.py working for pypi. Move the client code into its own subdirectory to make setuptools happy. --- api/.dockerignore | 1 + api/.gitignore | 1 + api/MANIFEST | 5 ----- api/README.md | 2 +- .../relation_engine_client => client_src}/README.md | 2 ++ .../relation_engine_client/__init__.py | 0 .../relation_engine_client/exceptions.py | 0 api/{src => client_src}/relation_engine_client/main.py | 2 +- api/client_src/releng_client.egg-info/PKG-INFO | 10 ++++++++++ api/client_src/releng_client.egg-info/SOURCES.txt | 10 ++++++++++ .../releng_client.egg-info/dependency_links.txt | 1 + api/client_src/releng_client.egg-info/requires.txt | 1 + api/client_src/releng_client.egg-info/top_level.txt | 1 + api/{client_setup.py => client_src/setup.py} | 4 +--- .../test}/__init__.py | 0 .../test}/test_integration.py | 4 ++-- api/scripts/run_tests.sh | 5 +++-- 17 files changed, 35 insertions(+), 14 deletions(-) delete mode 100644 api/MANIFEST rename api/{src/relation_engine_client => client_src}/README.md (99%) rename api/{src => client_src}/relation_engine_client/__init__.py (100%) rename api/{src => client_src}/relation_engine_client/exceptions.py (100%) rename api/{src => client_src}/relation_engine_client/main.py (98%) create mode 100644 api/client_src/releng_client.egg-info/PKG-INFO create mode 100644 api/client_src/releng_client.egg-info/SOURCES.txt create mode 100644 api/client_src/releng_client.egg-info/dependency_links.txt create mode 100644 api/client_src/releng_client.egg-info/requires.txt create mode 100644 api/client_src/releng_client.egg-info/top_level.txt rename api/{client_setup.py => client_src/setup.py} (74%) rename api/{src/test/relation_engine_client => client_src/test}/__init__.py (100%) rename api/{src/test/relation_engine_client => client_src/test}/test_integration.py (98%) diff --git a/api/.dockerignore b/api/.dockerignore index 9b32afcf..1648d981 100644 --- a/api/.dockerignore +++ b/api/.dockerignore @@ -23,6 +23,7 @@ __pycache__/ # Distribution / packaging /dist/ +/client_src/dist/ eggs/ .eggs/ *.egg-info/ diff --git a/api/.gitignore b/api/.gitignore index 8d6440a4..1a9044e9 100644 --- a/api/.gitignore +++ b/api/.gitignore @@ -4,6 +4,7 @@ # Caches and temp dirs /build/ /dist/ +/client_src/dist/ *.pyc .mypy_cache/ .cache/ diff --git a/api/MANIFEST b/api/MANIFEST deleted file mode 100644 index 2d6e6ac3..00000000 --- a/api/MANIFEST +++ /dev/null @@ -1,5 +0,0 @@ -# file GENERATED by distutils, do NOT edit -client_setup.py -src/relation_engine_client/__init__.py -src/relation_engine_client/exceptions.py -src/relation_engine_client/main.py diff --git a/api/README.md b/api/README.md index 3703818b..8cdfaa42 100644 --- a/api/README.md +++ b/api/README.md @@ -4,7 +4,7 @@ A simple API that allows KBase community developers to interact with the Relatio ## Python client -There is a [pip-installable python client](src/relation_engine_client/README.md) that can be used to access the RE API. +There is a [pip-installable python client](client_src/README.md) that can be used to access the RE API. ## HTTP API v1 diff --git a/api/src/relation_engine_client/README.md b/api/client_src/README.md similarity index 99% rename from api/src/relation_engine_client/README.md rename to api/client_src/README.md index 446d30ad..ace14f44 100644 --- a/api/src/relation_engine_client/README.md +++ b/api/client_src/README.md @@ -96,3 +96,5 @@ Access the `.resp.text` property on the error object to see the response body fr The `raise_not_found` argument was set to `True` and no documents were found in the query. Access the `.req_body` and `.req_params` properties of the error object to see the request data, or simply print the error to debug. + +## Development diff --git a/api/src/relation_engine_client/__init__.py b/api/client_src/relation_engine_client/__init__.py similarity index 100% rename from api/src/relation_engine_client/__init__.py rename to api/client_src/relation_engine_client/__init__.py diff --git a/api/src/relation_engine_client/exceptions.py b/api/client_src/relation_engine_client/exceptions.py similarity index 100% rename from api/src/relation_engine_client/exceptions.py rename to api/client_src/relation_engine_client/exceptions.py diff --git a/api/src/relation_engine_client/main.py b/api/client_src/relation_engine_client/main.py similarity index 98% rename from api/src/relation_engine_client/main.py rename to api/client_src/relation_engine_client/main.py index a7253dd5..779d36a6 100644 --- a/api/src/relation_engine_client/main.py +++ b/api/client_src/relation_engine_client/main.py @@ -3,7 +3,7 @@ from typing import Optional, List, Dict, Union from dataclasses import dataclass -from src.relation_engine_client.exceptions import REServerError, RERequestError, RENotFound +from .exceptions import REServerError, RERequestError, RENotFound _QUERY_METHOD = 'POST' _QUERY_ENDPOINT = '/api/v1/query_results' diff --git a/api/client_src/releng_client.egg-info/PKG-INFO b/api/client_src/releng_client.egg-info/PKG-INFO new file mode 100644 index 00000000..1f91b5fc --- /dev/null +++ b/api/client_src/releng_client.egg-info/PKG-INFO @@ -0,0 +1,10 @@ +Metadata-Version: 1.0 +Name: releng-client +Version: 0.0.1 +Summary: KBase Relation Engine API Client Module +Home-page: https://github.com/kbase/relation_engine_api +Author: UNKNOWN +Author-email: UNKNOWN +License: UNKNOWN +Description: UNKNOWN +Platform: UNKNOWN diff --git a/api/client_src/releng_client.egg-info/SOURCES.txt b/api/client_src/releng_client.egg-info/SOURCES.txt new file mode 100644 index 00000000..526735a9 --- /dev/null +++ b/api/client_src/releng_client.egg-info/SOURCES.txt @@ -0,0 +1,10 @@ +README.md +setup.py +relation_engine_client/__init__.py +relation_engine_client/exceptions.py +relation_engine_client/main.py +releng_client.egg-info/PKG-INFO +releng_client.egg-info/SOURCES.txt +releng_client.egg-info/dependency_links.txt +releng_client.egg-info/requires.txt +releng_client.egg-info/top_level.txt \ No newline at end of file diff --git a/api/client_src/releng_client.egg-info/dependency_links.txt b/api/client_src/releng_client.egg-info/dependency_links.txt new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/api/client_src/releng_client.egg-info/dependency_links.txt @@ -0,0 +1 @@ + diff --git a/api/client_src/releng_client.egg-info/requires.txt b/api/client_src/releng_client.egg-info/requires.txt new file mode 100644 index 00000000..cf56d5b7 --- /dev/null +++ b/api/client_src/releng_client.egg-info/requires.txt @@ -0,0 +1 @@ +requests>=2 diff --git a/api/client_src/releng_client.egg-info/top_level.txt b/api/client_src/releng_client.egg-info/top_level.txt new file mode 100644 index 00000000..3a78f3fa --- /dev/null +++ b/api/client_src/releng_client.egg-info/top_level.txt @@ -0,0 +1 @@ +relation_engine_client diff --git a/api/client_setup.py b/api/client_src/setup.py similarity index 74% rename from api/client_setup.py rename to api/client_src/setup.py index 4225583f..7a9d33d7 100644 --- a/api/client_setup.py +++ b/api/client_src/setup.py @@ -1,13 +1,11 @@ -from distutils.core import setup +from setuptools import setup setup( name='releng-client', version='0.0.1', description='KBase Relation Engine API Client Module', - author='KBase Team', url='https://github.com/kbase/relation_engine_api', packages=['relation_engine_client'], - package_dir={'': 'src'}, install_requires=['requests>=2'], ) diff --git a/api/src/test/relation_engine_client/__init__.py b/api/client_src/test/__init__.py similarity index 100% rename from api/src/test/relation_engine_client/__init__.py rename to api/client_src/test/__init__.py diff --git a/api/src/test/relation_engine_client/test_integration.py b/api/client_src/test/test_integration.py similarity index 98% rename from api/src/test/relation_engine_client/test_integration.py rename to api/client_src/test/test_integration.py index 8df3f21f..31905775 100644 --- a/api/src/test/relation_engine_client/test_integration.py +++ b/api/client_src/test/test_integration.py @@ -2,8 +2,8 @@ import os from uuid import uuid4 -from src.relation_engine_client import REClient -from src.relation_engine_client.exceptions import RERequestError, RENotFound +from relation_engine_client import REClient +from relation_engine_client.exceptions import RERequestError, RENotFound _API_URL = os.environ.get('RE_API_URL', 'http://localhost:5000') # See the test schemas here: diff --git a/api/scripts/run_tests.sh b/api/scripts/run_tests.sh index 11dcf59e..c60d73af 100644 --- a/api/scripts/run_tests.sh +++ b/api/scripts/run_tests.sh @@ -6,5 +6,6 @@ flake8 --max-complexity 10 src mypy --ignore-missing-imports src bandit -r src sh scripts/start_server.sh & -python -m src.test.wait_for_api -python -m unittest discover src/test/ +python -m src.test.wait_for_api && +python -m unittest discover src/test/ && +PYTHONPATH=client_src python -m unittest discover client_src/test/ From 4e27af2340a409625cc474c177ed31a9ebbb8c72 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Thu, 24 Oct 2019 10:45:43 -0700 Subject: [PATCH 445/732] Remove egg-info directory; gitignore it; fix README examples --- api/.gitignore | 1 + api/client_src/README.md | 11 ++++++----- api/client_src/releng_client.egg-info/PKG-INFO | 10 ---------- api/client_src/releng_client.egg-info/SOURCES.txt | 10 ---------- .../releng_client.egg-info/dependency_links.txt | 1 - api/client_src/releng_client.egg-info/requires.txt | 1 - api/client_src/releng_client.egg-info/top_level.txt | 1 - 7 files changed, 7 insertions(+), 28 deletions(-) delete mode 100644 api/client_src/releng_client.egg-info/PKG-INFO delete mode 100644 api/client_src/releng_client.egg-info/SOURCES.txt delete mode 100644 api/client_src/releng_client.egg-info/dependency_links.txt delete mode 100644 api/client_src/releng_client.egg-info/requires.txt delete mode 100644 api/client_src/releng_client.egg-info/top_level.txt diff --git a/api/.gitignore b/api/.gitignore index 1a9044e9..4a0a770f 100644 --- a/api/.gitignore +++ b/api/.gitignore @@ -11,3 +11,4 @@ /tmp/ coverage_report/ .coverage +*.egg-info/ diff --git a/api/client_src/README.md b/api/client_src/README.md index ace14f44..22c61c78 100644 --- a/api/client_src/README.md +++ b/api/client_src/README.md @@ -4,10 +4,11 @@ A pip-installable Python client module for accessing the methods of the Relation ## Installation -Install via pip using the KBase pip server: +Install with pip: -``` -pip install releng-client --extra-index-url=https://anaconda.org/kbase +```sh +pip install --extra-index-url https://pypi.anaconda.org/kbase/simple \ + releng-client==0.0.1 ``` ## Usage @@ -23,7 +24,7 @@ Pass in the URL of the Relation Engine API server you want to use, which is most Additionally, pass in a KBase auth token you would like to use for access control and document saving permissions when making requests to the API. ```py -from releng_client import REClient +from relation_engine_client import REClient re_client = REClient("https://ci.kbase.us/services/relation_engine_api", "xyz_my_token") ``` @@ -76,7 +77,7 @@ You must have an auth token set in the client with the RE admin role. A few different exceptions can be thrown from each method, which you can import: ```py -from releng_client.exceptions import REServerError, RERequestError, RENotFound +from relation_engine_client.exceptions import REServerError, RERequestError, RENotFound ``` #### REServerError diff --git a/api/client_src/releng_client.egg-info/PKG-INFO b/api/client_src/releng_client.egg-info/PKG-INFO deleted file mode 100644 index 1f91b5fc..00000000 --- a/api/client_src/releng_client.egg-info/PKG-INFO +++ /dev/null @@ -1,10 +0,0 @@ -Metadata-Version: 1.0 -Name: releng-client -Version: 0.0.1 -Summary: KBase Relation Engine API Client Module -Home-page: https://github.com/kbase/relation_engine_api -Author: UNKNOWN -Author-email: UNKNOWN -License: UNKNOWN -Description: UNKNOWN -Platform: UNKNOWN diff --git a/api/client_src/releng_client.egg-info/SOURCES.txt b/api/client_src/releng_client.egg-info/SOURCES.txt deleted file mode 100644 index 526735a9..00000000 --- a/api/client_src/releng_client.egg-info/SOURCES.txt +++ /dev/null @@ -1,10 +0,0 @@ -README.md -setup.py -relation_engine_client/__init__.py -relation_engine_client/exceptions.py -relation_engine_client/main.py -releng_client.egg-info/PKG-INFO -releng_client.egg-info/SOURCES.txt -releng_client.egg-info/dependency_links.txt -releng_client.egg-info/requires.txt -releng_client.egg-info/top_level.txt \ No newline at end of file diff --git a/api/client_src/releng_client.egg-info/dependency_links.txt b/api/client_src/releng_client.egg-info/dependency_links.txt deleted file mode 100644 index 8b137891..00000000 --- a/api/client_src/releng_client.egg-info/dependency_links.txt +++ /dev/null @@ -1 +0,0 @@ - diff --git a/api/client_src/releng_client.egg-info/requires.txt b/api/client_src/releng_client.egg-info/requires.txt deleted file mode 100644 index cf56d5b7..00000000 --- a/api/client_src/releng_client.egg-info/requires.txt +++ /dev/null @@ -1 +0,0 @@ -requests>=2 diff --git a/api/client_src/releng_client.egg-info/top_level.txt b/api/client_src/releng_client.egg-info/top_level.txt deleted file mode 100644 index 3a78f3fa..00000000 --- a/api/client_src/releng_client.egg-info/top_level.txt +++ /dev/null @@ -1 +0,0 @@ -relation_engine_client From 26bfb9e1df3539852b6ea9a89d8955b2cc64ec4a Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Thu, 24 Oct 2019 10:51:09 -0700 Subject: [PATCH 446/732] Update docs --- api/client_src/README.md | 14 ++++++++++++++ api/src/test/spec_release/README.md | 8 ++++++++ 2 files changed, 22 insertions(+) create mode 100644 api/src/test/spec_release/README.md diff --git a/api/client_src/README.md b/api/client_src/README.md index 22c61c78..1eacc4da 100644 --- a/api/client_src/README.md +++ b/api/client_src/README.md @@ -99,3 +99,17 @@ The `raise_not_found` argument was set to `True` and no documents were found in Access the `.req_body` and `.req_params` properties of the error object to see the request data, or simply print the error to debug. ## Development + +### Publishing + +Increment the semantic version inside `client_src/setup.py`, then build the package with: + +```sh +python setup.py sdist +``` + +Publish to the anaconda pypi repository with: + +```sh +anaconda upload -i -u kbase dist/releng-client-{version}.tar.gz +``` diff --git a/api/src/test/spec_release/README.md b/api/src/test/spec_release/README.md new file mode 100644 index 00000000..8419f925 --- /dev/null +++ b/api/src/test/spec_release/README.md @@ -0,0 +1,8 @@ + +The file in this directory, `spec.tar.gz` is a cached release of the `relation_engine_spec` repo, found here: + +https://github.com/kbase/relation_engine_spec + +It is cached here to avoid Github API usage limits when running tests on Travis. + +It is also stored in the docker image for the RE API for use in tests in other codebases that depend on this one. From c1ca967bb4b95539253c7873c8d8ad50885f8b05 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Thu, 24 Oct 2019 10:53:12 -0700 Subject: [PATCH 447/732] Python client module (#61) * WIP full client code plus partial tests * More tests * Add exception comments * Add comment about exceptions * Add docs for client; address PR comments * Add client_setup.py, dockerignore, and MANIFEST * Get the setup.py working for pypi. Move the client code into its own subdirectory to make setuptools happy. * Remove egg-info directory; gitignore it; fix README examples * Update docs --- api/.dockerignore | 40 ++++ api/.gitignore | 2 + api/README.md | 6 +- api/client_src/README.md | 115 +++++++++++ .../relation_engine_client/__init__.py | 3 + .../relation_engine_client/exceptions.py | 42 ++++ api/client_src/relation_engine_client/main.py | 153 ++++++++++++++ api/client_src/setup.py | 11 + api/client_src/test/__init__.py | 0 api/client_src/test/test_integration.py | 192 ++++++++++++++++++ api/scripts/run_tests.sh | 5 +- api/src/relation_engine_client/__init__.py | 1 - api/src/test/__init__.py | 0 api/src/test/spec_release/README.md | 8 + api/src/test/spec_release/spec.tar.gz | Bin 18579 -> 20677 bytes 15 files changed, 574 insertions(+), 4 deletions(-) create mode 100644 api/.dockerignore create mode 100644 api/client_src/README.md create mode 100644 api/client_src/relation_engine_client/__init__.py create mode 100644 api/client_src/relation_engine_client/exceptions.py create mode 100644 api/client_src/relation_engine_client/main.py create mode 100644 api/client_src/setup.py create mode 100644 api/client_src/test/__init__.py create mode 100644 api/client_src/test/test_integration.py delete mode 100644 api/src/relation_engine_client/__init__.py create mode 100644 api/src/test/__init__.py create mode 100644 api/src/test/spec_release/README.md diff --git a/api/.dockerignore b/api/.dockerignore new file mode 100644 index 00000000..1648d981 --- /dev/null +++ b/api/.dockerignore @@ -0,0 +1,40 @@ +__pycache__ +*.pyc +*.pyo +*.pyd +.Python +.tox +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*,cover +*.log +.git + +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +/dist/ +/client_src/dist/ +eggs/ +.eggs/ +*.egg-info/ +*.egg +MANIFEST + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json diff --git a/api/.gitignore b/api/.gitignore index 8d6440a4..4a0a770f 100644 --- a/api/.gitignore +++ b/api/.gitignore @@ -4,9 +4,11 @@ # Caches and temp dirs /build/ /dist/ +/client_src/dist/ *.pyc .mypy_cache/ .cache/ /tmp/ coverage_report/ .coverage +*.egg-info/ diff --git a/api/README.md b/api/README.md index a06012e4..8cdfaa42 100644 --- a/api/README.md +++ b/api/README.md @@ -2,6 +2,10 @@ A simple API that allows KBase community developers to interact with the Relation Engine graph database. You can run stored queries or do bulk updates on documents. +## Python client + +There is a [pip-installable python client](client_src/README.md) that can be used to access the RE API. + ## HTTP API v1 The API is a small, rest-ish service where all data is in JSON format. Replace the `{root_url}` in the examples below with one of: @@ -110,7 +114,7 @@ curl -X PUT {root_url}/api/v1/documents?collection=genes&on_duplicate=update _Query params_ * `collection` - required - string - name of the collection that we want to bulk-import into. * `on_duplicate` - optional - "replace", "update", "ignore", "error" - Action to take when we find a duplicate document by `_key`. "replace" replaces the whole document. "update" merges in the new values. "ignore" takes no action. "error" cancels the entire transaction. -* `overwrite` - optional - boolean - whether to overwrite the whole collection (that is, delete all documents currently in the collection before creating the documents you provide) +* `display_errors` - optional - bool - whether to return error messages for each document that failed to save in the response. This is disabled by default as it will slow down the response time. _Request body_ diff --git a/api/client_src/README.md b/api/client_src/README.md new file mode 100644 index 00000000..1eacc4da --- /dev/null +++ b/api/client_src/README.md @@ -0,0 +1,115 @@ +# Relation engine client + +A pip-installable Python client module for accessing the methods of the Relation Engine API. + +## Installation + +Install with pip: + +```sh +pip install --extra-index-url https://pypi.anaconda.org/kbase/simple \ + releng-client==0.0.1 +``` + +## Usage + +### Initialize the client + +Pass in the URL of the Relation Engine API server you want to use, which is most likely one of the following: + +* `https://kbase.us/services/relation_engine_api` +* `https://ci.kbase.us/services/relation_engine_api` +* `https://appdev.kbase.us/services/relation_engine_api` + +Additionally, pass in a KBase auth token you would like to use for access control and document saving permissions when making requests to the API. + +```py +from relation_engine_client import REClient + +re_client = REClient("https://ci.kbase.us/services/relation_engine_api", "xyz_my_token") +``` + +You can leave off the token if you want to do unauthenticated queries for public data. + +### Basic calls + +#### Stored queries + +To execute a stored/named query, run the following: + +``` +re_client.stored_query(query_name, bind_vars, raise_not_found=False) +``` + +Where: + +* `bind_vars`: required - dict - variables to use in the query. +* `raise_not_found`: options - bool - defaults to False - whether to raise an RENotFound error if 0 docs are returned. + +### Saving documents + +``` +re_client.save_docs(collection_name, docs, on_duplicate='error', display_errors=False) +``` + +Where: + +* `collection_name`: required - str - name of the collection you are saving documents into +* `docs`: required - list of dict or single dict - json-serializable list of + documents to save to the above collection +* `on_duplicate`: optional - one of 'replace', 'update', 'ignore', or 'error' defaults to 'error' - action to take when we have a duplicate document by + `_key` while saving. +* `display_errors`: optional - bool - defaults to False - whether to return + error messages for every document that failed to save. + +#### Admin queries + +To run an ad-hoc admin query, run: + +```py +re_client.admin_query(aql_query_text, bind_vars) +``` + +You must have an auth token set in the client with the RE admin role. + +### Exceptions + +A few different exceptions can be thrown from each method, which you can import: + +```py +from relation_engine_client.exceptions import REServerError, RERequestError, RENotFound +``` + +#### REServerError + +An error was thrown by the server (status code 500). + +Access the `.resp.text` property on the error object to see the response body from the API, or simply print the error to debug. + +#### RERequestError + +There was an invalid or missing parameter or header in the request. + +Access the `.resp.text` property on the error object to see the response body from the API, or simply print the error to debug. + +#### RENotFound + +The `raise_not_found` argument was set to `True` and no documents were found in the query. + +Access the `.req_body` and `.req_params` properties of the error object to see the request data, or simply print the error to debug. + +## Development + +### Publishing + +Increment the semantic version inside `client_src/setup.py`, then build the package with: + +```sh +python setup.py sdist +``` + +Publish to the anaconda pypi repository with: + +```sh +anaconda upload -i -u kbase dist/releng-client-{version}.tar.gz +``` diff --git a/api/client_src/relation_engine_client/__init__.py b/api/client_src/relation_engine_client/__init__.py new file mode 100644 index 00000000..939f6d1b --- /dev/null +++ b/api/client_src/relation_engine_client/__init__.py @@ -0,0 +1,3 @@ +from .main import REClient + +__all__ = ['REClient'] diff --git a/api/client_src/relation_engine_client/exceptions.py b/api/client_src/relation_engine_client/exceptions.py new file mode 100644 index 00000000..c963acf4 --- /dev/null +++ b/api/client_src/relation_engine_client/exceptions.py @@ -0,0 +1,42 @@ + +class REServerError(Exception): + """Server-originated error from RE API (ie. 500+)""" + + def __init__(self, resp): + self.resp = resp + + def __str__(self): + return ( + f"Relation engine API server error:\n" + f"Status: {self.resp.status_code}\n" + f"Response: {self.resp.text}" + ) + + +class RERequestError(Exception): + """Error in the request format or data from the client (ie. 400)""" + + def __init__(self, resp): + self.resp = resp + + def __str__(self): + return ( + f"Relation engine API client request error:\n" + f"Status: {self.resp.status_code}\n" + f"Response: {self.resp.text}" + ) + + +class RENotFound(Exception): + """The user required some results to be returned, but there were none.""" + + def __init__(self, req_body, req_params): + self.req_body = req_body + self.req_params = req_params + + def __str__(self): + return ( + f"Documents not found in the Relation Engine:\n" + f"Request body: {self.req_body}\n" + f"URL params: {self.req_params}" + ) diff --git a/api/client_src/relation_engine_client/main.py b/api/client_src/relation_engine_client/main.py new file mode 100644 index 00000000..779d36a6 --- /dev/null +++ b/api/client_src/relation_engine_client/main.py @@ -0,0 +1,153 @@ +import json +import requests +from typing import Optional, List, Dict, Union +from dataclasses import dataclass + +from .exceptions import REServerError, RERequestError, RENotFound + +_QUERY_METHOD = 'POST' +_QUERY_ENDPOINT = '/api/v1/query_results' +_SAVE_METHOD = 'PUT' +_SAVE_ENDPOINT = '/api/v1/documents' + + +@dataclass +class REClient: + api_url: str + token: Optional[str] = None + + def __post_init__(self): + # Type check the constructor parameters + if not self.api_url or not isinstance(self.api_url, str): + raise TypeError("The Relation Engine API URL was not provided.") + # Remove any trailing slash in the API URL so we can append paths + self.api_url = self.api_url.strip('/') + + def admin_query(self, query: str, bind_vars: dict, raise_not_found=False): + """ + Run an ad-hoc query using admin privs. + Params: + query - string - AQL query to execute + bind_vars - dict - JSON serializable bind variables for the query + raise_not_found - bool - Whether to raise an error if there are zero results. Defaults to False + Exceptions raised: + RERequestError - 400-499 error from the RE API + REServerError - 500+ error from the RE API + RENotFound - raised when raise_not_found is True and there are 0 results + """ + # Type-check the parameters + if not isinstance(query, str): + raise TypeError("`query` argument must be a str") + if not isinstance(bind_vars, dict): + raise TypeError("`bind_vars` argument must be a dict") + if not isinstance(raise_not_found, bool): + raise TypeError("`raise_not_found` argument must be a bool") + # Construct and execute the request + req_body = dict(bind_vars) + req_body['query'] = query + url = str(self.api_url) + _QUERY_ENDPOINT + resp = self._make_request( + method=_QUERY_METHOD, + url=url, + data=json.dumps(req_body), + params={}, + raise_not_found=raise_not_found) + return resp + + def stored_query(self, stored_query: str, bind_vars: dict, raise_not_found=False): + """ + Run a stored query. + Params: + stored_query - string - name of the stored query to execute + bind_vars - JSON serializable - bind variables for the query (JSON serializable) + raise_not_found - bool - Whether to raise an error if there are zero results. Defaults to False + Exceptions raised: + RERequestError - 400-499 from the RE API (client error) + REServerError - 500+ error from the RE API + RENotFound - raised when raise_not_found is True and there are 0 results + """ + # Type-check the parameters + if not isinstance(stored_query, str): + raise TypeError("`stored_query` argument must be a str") + if not isinstance(bind_vars, dict): + raise TypeError("`bind_vars` argument must be a dict") + if not isinstance(raise_not_found, bool): + raise TypeError("`raise_not_found` argument must be a bool`") + # Construct and execute the request + req_body = dict(bind_vars) + url = str(self.api_url) + _QUERY_ENDPOINT + return self._make_request( + method=_QUERY_METHOD, + url=url, + data=json.dumps(req_body), + params={'stored_query': stored_query}, + raise_not_found=raise_not_found) + + def save_docs( + self, + coll: str, + docs: Union[Dict, List[Dict]], + on_duplicate: Optional[str] = None, + display_errors=False): + """ + Save documents to a collection in the relation engine. + Requires an auth token with RE admin privileges. + Params: + coll - str - collection name to save to + docs - a single dict or list of dicts - json-serializable documents to save + on_duplicate - str (defaults to 'error') - what to do when a provided document + already exists in the collection. See options here: + https://github.com/kbase/relation_engine_api#put-apiv1documents + display_errors - bool (defaults to False) - whether to respond with + document save errors (the response will give you an error for every + document that failed to save). + Exceptions raised: + RERequestError - 400-499 from the RE API (client error) + REServerError - 500+ error from the RE API + """ + if isinstance(docs, dict): + docs = [docs] + if not docs: + raise TypeError("No documents provided to save") + if not isinstance(docs, list): + raise TypeError("`docs` argument must be a list") + if on_duplicate and not isinstance(on_duplicate, str): + raise TypeError("`on_duplicate` argument must bea str") + if not isinstance(display_errors, bool): + raise TypeError("`display_errors` argument must be a bool") + params = {'collection': coll} + if display_errors: + params['display_errors'] = '1' + params['on_duplicate'] = on_duplicate or 'error' + req_body = '\n'.join(json.dumps(d) for d in docs) + url = str(self.api_url) + _SAVE_ENDPOINT + return self._make_request( + method=_SAVE_METHOD, + url=url, + data=req_body, + params=params, + raise_not_found=False) + + def _make_request(self, method, url, data, params, raise_not_found): + """ + Internal utility to make a generic request to the RE API and handle the + response. + """ + headers = {} + if self.token: + headers['Authorization'] = self.token + resp = requests.request(method=method, url=url, data=data, params=params, headers=headers) + if resp.status_code >= 500: + # Server error + raise REServerError(resp) + elif resp.status_code >= 400 and resp.status_code < 500: + # Client error + raise RERequestError(resp) + elif not resp.ok: + raise RuntimeError( + f"Unknown RE API error:\nURL: {resp.url}\nMethod: {method}\n{resp.text}") + resp_json = resp.json() + if raise_not_found and not len(resp_json['results']): + # Results were required to be non-empty + raise RENotFound(req_body=data, req_params=params) + return resp_json diff --git a/api/client_src/setup.py b/api/client_src/setup.py new file mode 100644 index 00000000..7a9d33d7 --- /dev/null +++ b/api/client_src/setup.py @@ -0,0 +1,11 @@ +from setuptools import setup + + +setup( + name='releng-client', + version='0.0.1', + description='KBase Relation Engine API Client Module', + url='https://github.com/kbase/relation_engine_api', + packages=['relation_engine_client'], + install_requires=['requests>=2'], +) diff --git a/api/client_src/test/__init__.py b/api/client_src/test/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/api/client_src/test/test_integration.py b/api/client_src/test/test_integration.py new file mode 100644 index 00000000..31905775 --- /dev/null +++ b/api/client_src/test/test_integration.py @@ -0,0 +1,192 @@ +import unittest +import os +from uuid import uuid4 + +from relation_engine_client import REClient +from relation_engine_client.exceptions import RERequestError, RENotFound + +_API_URL = os.environ.get('RE_API_URL', 'http://localhost:5000') +# See the test schemas here: +# https://github.com/kbase/relation_engine_spec/tree/develop/schemas/test +_VERT_COLL = 'test_vertex' +_EDGE_COLL = 'test_edge' +# See the docker-compose.yaml file in the root of this repo +# See the mock auth endpoints in src/test/mock_auth/*.json +_TOK_ADMIN = 'admin_token' +_TOK_USER = 'non_admin_token' +_TOK_INVALID = 'invalid_token' + + +class TestREClientIntegration(unittest.TestCase): + """Integration tests for the REClient package.""" + + @classmethod + def setUpClass(cls): + cls.client = REClient(_API_URL, _TOK_ADMIN) + + def test_admin_query_ok(self): + _id = self._save_test_vert() + bind_vars = {'id': _id} + query = f"FOR vert IN {_VERT_COLL} FILTER vert._key == @id RETURN vert" + result = self.client.admin_query(query, bind_vars) + self.assertEqual(result['count'], 1) + self.assertEqual(result['results'][0]['_key'], _id) + + def test_admin_query_empty_auth(self): + client2 = REClient(_API_URL) + query = f"FOR vert IN {_VERT_COLL} FILTER vert._key == @id RETURN vert" + with self.assertRaises(RERequestError) as ctx: + client2.admin_query(query, {'id': 'xyz'}) + self.assertEqual(ctx.exception.resp.status_code, 400) + # Mostly make sure that the __str__ method does not throw any errs + self.assertTrue('Missing header: Authorization' in str(ctx.exception)) + + def test_admin_query_invalid_auth(self): + client2 = REClient(_API_URL, 'xyz') + query = f"FOR vert IN {_VERT_COLL} FILTER vert._key == @id RETURN vert" + with self.assertRaises(RERequestError) as ctx: + client2.admin_query(query, {'id': 'xyz'}) + self.assertEqual(ctx.exception.resp.status_code, 403) + # Mostly make sure that the __str__ method does not throw any errs + self.assertTrue('Unauthorized' in str(ctx.exception)) + + def test_admin_empty_query(self): + bind_vars = {'id': 'xyz'} + with self.assertRaises(RERequestError) as ctx: + self.client.admin_query("", bind_vars) + self.assertEqual(ctx.exception.resp.status_code, 400) + # Mostly make sure that the __str__ method does not throw any errs + self.assertTrue('Response:' in str(ctx.exception)) + + def test_admin_missing_param(self): + query = f"FOR vert IN {_VERT_COLL} FILTER vert._key == @id RETURN vert" + with self.assertRaises(RERequestError) as ctx: + self.client.admin_query(query, bind_vars={}) + self.assertEqual(ctx.exception.resp.status_code, 400) + # Mostly make sure that the __str__ method does not throw any errs + self.assertTrue('Response:' in str(ctx.exception)) + + def test_admin_raise_not_found(self): + query = f"FOR vert IN {_VERT_COLL} FILTER vert._key == @id RETURN vert" + _id = str(uuid4()) + bind_vars = {'id': _id} + with self.assertRaises(RENotFound) as ctx: + self.client.admin_query(query, bind_vars, raise_not_found=True) + self.assertTrue(_id in ctx.exception.req_body) + # Mostly make sure that the __str__ method does not throw any errs + self.assertTrue('Request body:' in str(ctx.exception)) + + def test_admin_invalid_args(self): + # No params + with self.assertRaises(TypeError): + self.client.admin_query() + # Wrong type for query + with self.assertRaises(TypeError): + self.client.admin_query(123) + # Wrong type for bind_vars + with self.assertRaises(TypeError): + self.client.admin_query("", 123) + + def test_stored_query_ok(self): + _id = self._save_test_vert() + bind_vars = {'key': _id} + qname = 'fetch_test_vertex' + result = self.client.stored_query(qname, bind_vars) + self.assertEqual(result['count'], 1) + self.assertEqual(result['results'][0]['_key'], _id) + + def test_stored_query_invalid_args(self): + with self.assertRaises(TypeError): + self.client.stored_query() + with self.assertRaises(TypeError): + self.client.stored_query(123, 123) + with self.assertRaises(TypeError): + self.client.stored_query("") + + def test_stored_query_unknown_query(self): + qname = 'xyz123' + with self.assertRaises(RERequestError) as ctx: + self.client.admin_query(qname, bind_vars={'key': 0}) + self.assertEqual(ctx.exception.resp.status_code, 400) + # Mostly make sure that the __str__ method does not throw any errs + self.assertTrue('Response:' in str(ctx.exception)) + + def test_stored_query_missing_bind_vars(self): + qname = 'fetch_test_vertex' + with self.assertRaises(RERequestError) as ctx: + self.client.admin_query(qname, bind_vars={'x': 'y'}) + self.assertEqual(ctx.exception.resp.status_code, 400) + # Mostly make sure that the __str__ method does not throw any errs + self.assertTrue('Response:' in str(ctx.exception)) + + def test_stored_query_raise_not_found(self): + _id = str(uuid4()) + bind_vars = {'key': _id} + qname = 'fetch_test_vertex' + with self.assertRaises(RENotFound) as ctx: + self.client.stored_query(qname, bind_vars, raise_not_found=True) + self.assertTrue(_id in ctx.exception.req_body) + # Mostly make sure that the __str__ method does not throw any errs + self.assertTrue('Request body:' in str(ctx.exception)) + + def test_save_docs_ok(self): + _id = str(uuid4()) + docs = [{'_key': _id}] + results = self.client.save_docs(coll=_VERT_COLL, docs=docs) + self.assertEqual(results['created'], 1) + self.assertFalse(results['error']) + self.assertEqual(results['errors'], 0) + self.assertEqual(results['ignored'], 0) + self.assertEqual(results['updated'], 0) + + def test_save_docs_empty_auth(self): + client2 = REClient(_API_URL) + docs = [{'_key': 'xyz'}] + with self.assertRaises(RERequestError) as ctx: + client2.save_docs(coll=_VERT_COLL, docs=docs) + self.assertEqual(ctx.exception.resp.status_code, 400) + # Mostly make sure that the __str__ method does not throw any errs + self.assertTrue('Missing header: Authorization' in str(ctx.exception)) + + def test_save_docs_invalid_auth(self): + client2 = REClient(_API_URL, 'xyz') + docs = [{'_key': 'xyz'}] + with self.assertRaises(RERequestError) as ctx: + client2.save_docs(coll=_VERT_COLL, docs=docs) + self.assertEqual(ctx.exception.resp.status_code, 403) + # Mostly make sure that the __str__ method does not throw any errs + self.assertTrue('Unauthorized' in str(ctx.exception)) + + def test_save_docs_invalid_args(self): + with self.assertRaises(TypeError): + self.client.save_docs() + with self.assertRaises(TypeError): + self.client.save_docs(123, 456) + # Empty docs list + with self.assertRaises(TypeError): + self.client.save_docs(_VERT_COLL, []) + + def test_save_docs_unknown_coll(self): + with self.assertRaises(RERequestError) as ctx: + self.client.save_docs('xyz123', [{'_key': 0}]) + self.assertEqual(ctx.exception.resp.status_code, 400) + # Mostly make sure that the __str__ method does not throw any errs + self.assertTrue('Response:' in str(ctx.exception)) + + def test_save_docs_invalid_docs(self): + with self.assertRaises(RERequestError) as ctx: + self.client.save_docs(_VERT_COLL, [{'hi': 0}]) + self.assertEqual(ctx.exception.resp.status_code, 400) + # Mostly make sure that the __str__ method does not throw any errs + self.assertTrue('Response:' in str(ctx.exception)) + + # -- Test helpers + + def _save_test_vert(self): + """Create a test vertex with a random & unique id.""" + _id = str(uuid4()) + docs = [{'_key': _id}] + results = self.client.save_docs(coll=_VERT_COLL, docs=docs) + if results['error']: + raise RuntimeError(results) + return _id diff --git a/api/scripts/run_tests.sh b/api/scripts/run_tests.sh index 11dcf59e..c60d73af 100644 --- a/api/scripts/run_tests.sh +++ b/api/scripts/run_tests.sh @@ -6,5 +6,6 @@ flake8 --max-complexity 10 src mypy --ignore-missing-imports src bandit -r src sh scripts/start_server.sh & -python -m src.test.wait_for_api -python -m unittest discover src/test/ +python -m src.test.wait_for_api && +python -m unittest discover src/test/ && +PYTHONPATH=client_src python -m unittest discover client_src/test/ diff --git a/api/src/relation_engine_client/__init__.py b/api/src/relation_engine_client/__init__.py deleted file mode 100644 index 46409041..00000000 --- a/api/src/relation_engine_client/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# TODO diff --git a/api/src/test/__init__.py b/api/src/test/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/api/src/test/spec_release/README.md b/api/src/test/spec_release/README.md new file mode 100644 index 00000000..8419f925 --- /dev/null +++ b/api/src/test/spec_release/README.md @@ -0,0 +1,8 @@ + +The file in this directory, `spec.tar.gz` is a cached release of the `relation_engine_spec` repo, found here: + +https://github.com/kbase/relation_engine_spec + +It is cached here to avoid Github API usage limits when running tests on Travis. + +It is also stored in the docker image for the RE API for use in tests in other codebases that depend on this one. diff --git a/api/src/test/spec_release/spec.tar.gz b/api/src/test/spec_release/spec.tar.gz index 4059a2a8affae812b186d35d543793e8d5f2b114..27244be9b3dcc4aa90db95b3a87c0c98ea72dbe1 100644 GIT binary patch literal 20677 zcmV)jK%u`MiwFP!000001MEF(Z`-)C{hVJxamz0uv56*wTGo+rDY|D8#+pUS+)RHL9kn`klNX_UsYwU_4b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9xD&B_vUi1rvl2CNRtBg7eL{g=dS@T%6Nt;)+W8Oz zRT$&G3RyZsCw8CN8sR%18=Jm0*bM&{=faFJz)AL>j+XzS-E23@{0~I{=l{GcSGbbg z0L1tX%?3H1nRs#d(w#=VQo2B`SDF=wkZfd~TTm5U@{w=OMJ^Hz-;$49&E}tEXd?da z49Co3&IyUFVQ|B-G3)hoR-6LD&qwL`JS?F@{A>`5go%4a?5c`N|5Gs}_L7>;&=6n9 zbh{@RU$`#)htL>-|B$RcJY^(!K?416cluiX_fDf(#{U%ona_Wl4uIdj&bMlt-K9lJ zQSWjE02Zc&6|aP?h^brI3E^inhywQqi?4Q3NE96jgLkGkL;Xbi>gl5_5Sp5k5H#2{ zm)>MKqbR{L@Z+sNh15}FZwAS8<$V`P(v&7PPQp|rz($1D7$R%pwa+-c6JV9@DNa{Z zuq;p+r~x)FUZgsHRpmSx&!vs`0_+1n+*a)CZdZi`xV7+^>|sMfNTJ!4Va;iblDgb- zy$N~M*e+owTV6-@HlC#PM_rIP0!2Bh%)25xmgIQGA9i+}=b$njJH+p#`&!o8-ofeF z!4V#j6#K*4V^6&QaQf3WnZ+vJ% Date: Thu, 24 Oct 2019 13:01:00 -0700 Subject: [PATCH 448/732] Remove dataclasses dependency in the client for compatibility with 3.{0-6} --- api/client_src/relation_engine_client/main.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/api/client_src/relation_engine_client/main.py b/api/client_src/relation_engine_client/main.py index 779d36a6..98d7400d 100644 --- a/api/client_src/relation_engine_client/main.py +++ b/api/client_src/relation_engine_client/main.py @@ -1,7 +1,6 @@ import json import requests from typing import Optional, List, Dict, Union -from dataclasses import dataclass from .exceptions import REServerError, RERequestError, RENotFound @@ -11,12 +10,11 @@ _SAVE_ENDPOINT = '/api/v1/documents' -@dataclass class REClient: - api_url: str - token: Optional[str] = None - def __post_init__(self): + def __init__(self, api_url: str, token: str = None): + self.api_url = api_url + self.token = token # Type check the constructor parameters if not self.api_url or not isinstance(self.api_url, str): raise TypeError("The Relation Engine API URL was not provided.") From 3c72636198d2f6e7a415c924521a700c07602f2b Mon Sep 17 00:00:00 2001 From: Gavin Date: Fri, 25 Oct 2019 12:10:38 -0700 Subject: [PATCH 449/732] Add delta loader indexes to delta schemas --- spec/schemas/ENVO/ENVO_edges.yaml | 6 ++++++ spec/schemas/ENVO/ENVO_merges.yaml | 6 ++++++ spec/schemas/ENVO/ENVO_terms.yaml | 6 ++++++ spec/schemas/GO/GO_edges.yaml | 6 ++++++ spec/schemas/GO/GO_merges.yaml | 4 ++++ spec/schemas/GO/GO_terms.yaml | 6 ++++++ spec/schemas/gtdb/gtdb_child_of_taxon.yaml | 6 ++++++ spec/schemas/gtdb/gtdb_taxon.yaml | 6 ++++++ spec/schemas/ncbi/ncbi_child_of_taxon.yaml | 6 ++++++ spec/schemas/ncbi/ncbi_taxon.yaml | 4 ++++ spec/schemas/rdp/rdp_child_of_taxon.yaml | 6 ++++++ spec/schemas/rdp/rdp_taxon.yaml | 6 ++++++ 12 files changed, 68 insertions(+) diff --git a/spec/schemas/ENVO/ENVO_edges.yaml b/spec/schemas/ENVO/ENVO_edges.yaml index 0a666d98..ccc7e554 100644 --- a/spec/schemas/ENVO/ENVO_edges.yaml +++ b/spec/schemas/ENVO/ENVO_edges.yaml @@ -2,6 +2,12 @@ name: ENVO_edges type: edge delta: true +indexes: + - type: persistent + fields: [id, created, expired] + - type: persistent + fields: [created, expired, last_version] + schema: "$schema": http://json-schema.org/draft-07/schema# title: ENVO_edges diff --git a/spec/schemas/ENVO/ENVO_merges.yaml b/spec/schemas/ENVO/ENVO_merges.yaml index b05b013f..863e412a 100644 --- a/spec/schemas/ENVO/ENVO_merges.yaml +++ b/spec/schemas/ENVO/ENVO_merges.yaml @@ -2,6 +2,12 @@ name: ENVO_merges type: edge delta: true +indexes: + - type: persistent + fields: [id, created, expired] + - type: persistent + fields: [created, expired, last_version] + schema: "$schema": http://json-schema.org/draft-07/schema# title: ENVO_merges diff --git a/spec/schemas/ENVO/ENVO_terms.yaml b/spec/schemas/ENVO/ENVO_terms.yaml index 73fe587c..227d44b5 100644 --- a/spec/schemas/ENVO/ENVO_terms.yaml +++ b/spec/schemas/ENVO/ENVO_terms.yaml @@ -2,6 +2,12 @@ name: ENVO_terms type: vertex delta: true +indexes: + - type: persistent + fields: [id, created, expired] + - type: persistent + fields: [created, expired, last_version] + schema: "$schema": http://json-schema.org/draft-07/schema# title: ENVO_terms diff --git a/spec/schemas/GO/GO_edges.yaml b/spec/schemas/GO/GO_edges.yaml index eb66c70c..b6abada1 100644 --- a/spec/schemas/GO/GO_edges.yaml +++ b/spec/schemas/GO/GO_edges.yaml @@ -2,6 +2,12 @@ name: GO_edges type: edge delta: true +indexes: + - type: persistent + fields: [id, created, expired] + - type: persistent + fields: [created, expired, last_version] + schema: "$schema": http://json-schema.org/draft-07/schema# title: GO_edges diff --git a/spec/schemas/GO/GO_merges.yaml b/spec/schemas/GO/GO_merges.yaml index 8b55db71..493c64f9 100644 --- a/spec/schemas/GO/GO_merges.yaml +++ b/spec/schemas/GO/GO_merges.yaml @@ -5,6 +5,10 @@ delta: true indexes: - type: hash # don't think this needs to be a skiplist / persistent index fields: [from] + - type: persistent + fields: [id, created, expired] + - type: persistent + fields: [created, expired, last_version] schema: "$schema": http://json-schema.org/draft-07/schema# diff --git a/spec/schemas/GO/GO_terms.yaml b/spec/schemas/GO/GO_terms.yaml index d6bc3f76..f81466de 100644 --- a/spec/schemas/GO/GO_terms.yaml +++ b/spec/schemas/GO/GO_terms.yaml @@ -2,6 +2,12 @@ name: GO_terms type: vertex delta: true +indexes: + - type: persistent + fields: [id, created, expired] + - type: persistent + fields: [created, expired, last_version] + schema: "$schema": http://json-schema.org/draft-07/schema# title: GO_terms diff --git a/spec/schemas/gtdb/gtdb_child_of_taxon.yaml b/spec/schemas/gtdb/gtdb_child_of_taxon.yaml index c7bed134..63094580 100644 --- a/spec/schemas/gtdb/gtdb_child_of_taxon.yaml +++ b/spec/schemas/gtdb/gtdb_child_of_taxon.yaml @@ -2,6 +2,12 @@ name: gtdb_child_of_taxon type: edge delta: true +indexes: + - type: persistent + fields: [id, created, expired] + - type: persistent + fields: [created, expired, last_version] + schema: "$schema": http://json-schema.org/draft-07/schema# type: object diff --git a/spec/schemas/gtdb/gtdb_taxon.yaml b/spec/schemas/gtdb/gtdb_taxon.yaml index 50dd5ef0..c3fade4a 100644 --- a/spec/schemas/gtdb/gtdb_taxon.yaml +++ b/spec/schemas/gtdb/gtdb_taxon.yaml @@ -2,6 +2,12 @@ name: gtdb_taxon type: vertex delta: true +indexes: + - type: persistent + fields: [id, created, expired] + - type: persistent + fields: [created, expired, last_version] + schema: "$schema": http://json-schema.org/draft-07/schema# type: object diff --git a/spec/schemas/ncbi/ncbi_child_of_taxon.yaml b/spec/schemas/ncbi/ncbi_child_of_taxon.yaml index a64a5cb6..11bd6b38 100644 --- a/spec/schemas/ncbi/ncbi_child_of_taxon.yaml +++ b/spec/schemas/ncbi/ncbi_child_of_taxon.yaml @@ -2,6 +2,12 @@ name: ncbi_child_of_taxon type: edge delta: true +indexes: + - type: persistent + fields: [id, created, expired] + - type: persistent + fields: [created, expired, last_version] + schema: "$schema": http://json-schema.org/draft-07/schema# type: object diff --git a/spec/schemas/ncbi/ncbi_taxon.yaml b/spec/schemas/ncbi/ncbi_taxon.yaml index 9c02ae21..9d522281 100644 --- a/spec/schemas/ncbi/ncbi_taxon.yaml +++ b/spec/schemas/ncbi/ncbi_taxon.yaml @@ -5,6 +5,10 @@ delta: true indexes: - type: fulltext fields: [scientific_name] + - type: persistent + fields: [id, created, expired] + - type: persistent + fields: [created, expired, last_version] schema: "$schema": http://json-schema.org/draft-07/schema# diff --git a/spec/schemas/rdp/rdp_child_of_taxon.yaml b/spec/schemas/rdp/rdp_child_of_taxon.yaml index c86d64ef..c6f0634d 100644 --- a/spec/schemas/rdp/rdp_child_of_taxon.yaml +++ b/spec/schemas/rdp/rdp_child_of_taxon.yaml @@ -2,6 +2,12 @@ name: rdp_child_of_taxon type: edge delta: true +indexes: + - type: persistent + fields: [id, created, expired] + - type: persistent + fields: [created, expired, last_version] + schema: "$schema": http://json-schema.org/draft-07/schema# type: object diff --git a/spec/schemas/rdp/rdp_taxon.yaml b/spec/schemas/rdp/rdp_taxon.yaml index 3317b3fa..d8d2144e 100644 --- a/spec/schemas/rdp/rdp_taxon.yaml +++ b/spec/schemas/rdp/rdp_taxon.yaml @@ -2,6 +2,12 @@ name: rdp_taxon type: vertex delta: true +indexes: + - type: persistent + fields: [id, created, expired] + - type: persistent + fields: [created, expired, last_version] + schema: "$schema": http://json-schema.org/draft-07/schema# type: object From 03e95b4c0a6c9607482ab46a73bc3130b4e7b0f0 Mon Sep 17 00:00:00 2001 From: Gavin Date: Fri, 25 Oct 2019 12:39:16 -0700 Subject: [PATCH 450/732] Add NCBI merge collection --- spec/schemas/ncbi/ncbi_taxon_merges.yaml | 35 ++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 spec/schemas/ncbi/ncbi_taxon_merges.yaml diff --git a/spec/schemas/ncbi/ncbi_taxon_merges.yaml b/spec/schemas/ncbi/ncbi_taxon_merges.yaml new file mode 100644 index 00000000..26713e35 --- /dev/null +++ b/spec/schemas/ncbi/ncbi_taxon_merges.yaml @@ -0,0 +1,35 @@ +name: ncbi_taxon_merges +type: edge +delta: true + +indexes: + - type: persistent + fields: [id, created, expired] + - type: persistent + fields: [created, expired, last_version] + +schema: + "$schema": http://json-schema.org/draft-07/schema# + title: ncbi_taxon_merges + type: object + description: A entry for merge edges in the NCBI hierarchy + properties: + id: + type: string + description: an edge ID, consisting of the ID of the child node + examples: + - '51633' + from: + type: string + description: NCBI id + examples: + - '51633' + to: + type: string + title: NCBI id + examples: + - '5467' + required: + - id + - from + - to From ec23f2ae0f843e5f5b87a4d17807eb91441a6395 Mon Sep 17 00:00:00 2001 From: Gavin Date: Fri, 25 Oct 2019 14:35:48 -0700 Subject: [PATCH 451/732] Add delta load registry collection --- spec/schemas/deltaloader/delta_load_registry.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 spec/schemas/deltaloader/delta_load_registry.yaml diff --git a/spec/schemas/deltaloader/delta_load_registry.yaml b/spec/schemas/deltaloader/delta_load_registry.yaml new file mode 100644 index 00000000..26303536 --- /dev/null +++ b/spec/schemas/deltaloader/delta_load_registry.yaml @@ -0,0 +1,8 @@ +name: delta_load_registry +type: vertex + +schema: + "$schema": http://json-schema.org/draft-07/schema# + title: delta_load_registry + type: object + description: Don't touch this. It's for the exlusive use of delta loaders. \ No newline at end of file From 82a00b3730aad20a5db7b16f9f2125defecb13bf Mon Sep 17 00:00:00 2001 From: Gavin Date: Fri, 25 Oct 2019 15:07:58 -0700 Subject: [PATCH 452/732] schema has to require _key --- spec/schemas/deltaloader/delta_load_registry.yaml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/spec/schemas/deltaloader/delta_load_registry.yaml b/spec/schemas/deltaloader/delta_load_registry.yaml index 26303536..dc9c7f86 100644 --- a/spec/schemas/deltaloader/delta_load_registry.yaml +++ b/spec/schemas/deltaloader/delta_load_registry.yaml @@ -5,4 +5,10 @@ schema: "$schema": http://json-schema.org/draft-07/schema# title: delta_load_registry type: object - description: Don't touch this. It's for the exlusive use of delta loaders. \ No newline at end of file + description: Don't touch this. It's for the exlusive use of delta loaders. + properties: + _key: + type: string + description: required to pass validator. + required: + - _key \ No newline at end of file From ade5c79963ce5387c7266a1356a83e6fe795bd77 Mon Sep 17 00:00:00 2001 From: Gavin Date: Fri, 25 Oct 2019 15:47:27 -0700 Subject: [PATCH 453/732] Fix index order --- spec/schemas/ENVO/ENVO_edges.yaml | 4 ++-- spec/schemas/ENVO/ENVO_merges.yaml | 4 ++-- spec/schemas/ENVO/ENVO_terms.yaml | 4 ++-- spec/schemas/GO/GO_edges.yaml | 4 ++-- spec/schemas/GO/GO_merges.yaml | 4 ++-- spec/schemas/GO/GO_terms.yaml | 4 ++-- spec/schemas/gtdb/gtdb_child_of_taxon.yaml | 4 ++-- spec/schemas/gtdb/gtdb_taxon.yaml | 4 ++-- spec/schemas/ncbi/ncbi_child_of_taxon.yaml | 4 ++-- spec/schemas/ncbi/ncbi_taxon.yaml | 4 ++-- spec/schemas/ncbi/ncbi_taxon_merges.yaml | 4 ++-- spec/schemas/rdp/rdp_child_of_taxon.yaml | 4 ++-- spec/schemas/rdp/rdp_taxon.yaml | 4 ++-- 13 files changed, 26 insertions(+), 26 deletions(-) diff --git a/spec/schemas/ENVO/ENVO_edges.yaml b/spec/schemas/ENVO/ENVO_edges.yaml index ccc7e554..b0e22639 100644 --- a/spec/schemas/ENVO/ENVO_edges.yaml +++ b/spec/schemas/ENVO/ENVO_edges.yaml @@ -4,9 +4,9 @@ delta: true indexes: - type: persistent - fields: [id, created, expired] + fields: [id, expired, created] - type: persistent - fields: [created, expired, last_version] + fields: [expired, created, last_version] schema: "$schema": http://json-schema.org/draft-07/schema# diff --git a/spec/schemas/ENVO/ENVO_merges.yaml b/spec/schemas/ENVO/ENVO_merges.yaml index 863e412a..c0c59bdc 100644 --- a/spec/schemas/ENVO/ENVO_merges.yaml +++ b/spec/schemas/ENVO/ENVO_merges.yaml @@ -4,9 +4,9 @@ delta: true indexes: - type: persistent - fields: [id, created, expired] + fields: [id, expired, created] - type: persistent - fields: [created, expired, last_version] + fields: [expired, created, last_version] schema: "$schema": http://json-schema.org/draft-07/schema# diff --git a/spec/schemas/ENVO/ENVO_terms.yaml b/spec/schemas/ENVO/ENVO_terms.yaml index 227d44b5..1e6e3553 100644 --- a/spec/schemas/ENVO/ENVO_terms.yaml +++ b/spec/schemas/ENVO/ENVO_terms.yaml @@ -4,9 +4,9 @@ delta: true indexes: - type: persistent - fields: [id, created, expired] + fields: [id, expired, created] - type: persistent - fields: [created, expired, last_version] + fields: [expired, created, last_version] schema: "$schema": http://json-schema.org/draft-07/schema# diff --git a/spec/schemas/GO/GO_edges.yaml b/spec/schemas/GO/GO_edges.yaml index b6abada1..f2d5a1ee 100644 --- a/spec/schemas/GO/GO_edges.yaml +++ b/spec/schemas/GO/GO_edges.yaml @@ -4,9 +4,9 @@ delta: true indexes: - type: persistent - fields: [id, created, expired] + fields: [id, expired, created] - type: persistent - fields: [created, expired, last_version] + fields: [expired, created, last_version] schema: "$schema": http://json-schema.org/draft-07/schema# diff --git a/spec/schemas/GO/GO_merges.yaml b/spec/schemas/GO/GO_merges.yaml index 493c64f9..80ad08ee 100644 --- a/spec/schemas/GO/GO_merges.yaml +++ b/spec/schemas/GO/GO_merges.yaml @@ -6,9 +6,9 @@ indexes: - type: hash # don't think this needs to be a skiplist / persistent index fields: [from] - type: persistent - fields: [id, created, expired] + fields: [id, expired, created] - type: persistent - fields: [created, expired, last_version] + fields: [expired, created, last_version] schema: "$schema": http://json-schema.org/draft-07/schema# diff --git a/spec/schemas/GO/GO_terms.yaml b/spec/schemas/GO/GO_terms.yaml index f81466de..88804755 100644 --- a/spec/schemas/GO/GO_terms.yaml +++ b/spec/schemas/GO/GO_terms.yaml @@ -4,9 +4,9 @@ delta: true indexes: - type: persistent - fields: [id, created, expired] + fields: [id, expired, created] - type: persistent - fields: [created, expired, last_version] + fields: [expired, created, last_version] schema: "$schema": http://json-schema.org/draft-07/schema# diff --git a/spec/schemas/gtdb/gtdb_child_of_taxon.yaml b/spec/schemas/gtdb/gtdb_child_of_taxon.yaml index 63094580..78261151 100644 --- a/spec/schemas/gtdb/gtdb_child_of_taxon.yaml +++ b/spec/schemas/gtdb/gtdb_child_of_taxon.yaml @@ -4,9 +4,9 @@ delta: true indexes: - type: persistent - fields: [id, created, expired] + fields: [id, expired, created] - type: persistent - fields: [created, expired, last_version] + fields: [expired, created, last_version] schema: "$schema": http://json-schema.org/draft-07/schema# diff --git a/spec/schemas/gtdb/gtdb_taxon.yaml b/spec/schemas/gtdb/gtdb_taxon.yaml index c3fade4a..04c8ba72 100644 --- a/spec/schemas/gtdb/gtdb_taxon.yaml +++ b/spec/schemas/gtdb/gtdb_taxon.yaml @@ -4,9 +4,9 @@ delta: true indexes: - type: persistent - fields: [id, created, expired] + fields: [id, expired, created] - type: persistent - fields: [created, expired, last_version] + fields: [expired, created, last_version] schema: "$schema": http://json-schema.org/draft-07/schema# diff --git a/spec/schemas/ncbi/ncbi_child_of_taxon.yaml b/spec/schemas/ncbi/ncbi_child_of_taxon.yaml index 11bd6b38..77210a1b 100644 --- a/spec/schemas/ncbi/ncbi_child_of_taxon.yaml +++ b/spec/schemas/ncbi/ncbi_child_of_taxon.yaml @@ -4,9 +4,9 @@ delta: true indexes: - type: persistent - fields: [id, created, expired] + fields: [id, expired, created] - type: persistent - fields: [created, expired, last_version] + fields: [expired, created, last_version] schema: "$schema": http://json-schema.org/draft-07/schema# diff --git a/spec/schemas/ncbi/ncbi_taxon.yaml b/spec/schemas/ncbi/ncbi_taxon.yaml index 9d522281..39c97168 100644 --- a/spec/schemas/ncbi/ncbi_taxon.yaml +++ b/spec/schemas/ncbi/ncbi_taxon.yaml @@ -6,9 +6,9 @@ indexes: - type: fulltext fields: [scientific_name] - type: persistent - fields: [id, created, expired] + fields: [id, expired, created] - type: persistent - fields: [created, expired, last_version] + fields: [expired, created, last_version] schema: "$schema": http://json-schema.org/draft-07/schema# diff --git a/spec/schemas/ncbi/ncbi_taxon_merges.yaml b/spec/schemas/ncbi/ncbi_taxon_merges.yaml index 26713e35..18d6b0fb 100644 --- a/spec/schemas/ncbi/ncbi_taxon_merges.yaml +++ b/spec/schemas/ncbi/ncbi_taxon_merges.yaml @@ -4,9 +4,9 @@ delta: true indexes: - type: persistent - fields: [id, created, expired] + fields: [id, expired, created] - type: persistent - fields: [created, expired, last_version] + fields: [expired, created, last_version] schema: "$schema": http://json-schema.org/draft-07/schema# diff --git a/spec/schemas/rdp/rdp_child_of_taxon.yaml b/spec/schemas/rdp/rdp_child_of_taxon.yaml index c6f0634d..d3d211a9 100644 --- a/spec/schemas/rdp/rdp_child_of_taxon.yaml +++ b/spec/schemas/rdp/rdp_child_of_taxon.yaml @@ -4,9 +4,9 @@ delta: true indexes: - type: persistent - fields: [id, created, expired] + fields: [id, expired, created] - type: persistent - fields: [created, expired, last_version] + fields: [expired, created, last_version] schema: "$schema": http://json-schema.org/draft-07/schema# diff --git a/spec/schemas/rdp/rdp_taxon.yaml b/spec/schemas/rdp/rdp_taxon.yaml index d8d2144e..42234447 100644 --- a/spec/schemas/rdp/rdp_taxon.yaml +++ b/spec/schemas/rdp/rdp_taxon.yaml @@ -4,9 +4,9 @@ delta: true indexes: - type: persistent - fields: [id, created, expired] + fields: [id, expired, created] - type: persistent - fields: [created, expired, last_version] + fields: [expired, created, last_version] schema: "$schema": http://json-schema.org/draft-07/schema# From 5b284a619d7ead5913a63daacdf176eccb53d3a2 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 29 Oct 2019 10:16:15 -0700 Subject: [PATCH 454/732] Fix SHARD_COUNT env var --- api/src/relation_engine_server/utils/arango_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/src/relation_engine_server/utils/arango_client.py b/api/src/relation_engine_server/utils/arango_client.py index 89b3016e..462e1f55 100644 --- a/api/src/relation_engine_server/utils/arango_client.py +++ b/api/src/relation_engine_server/utils/arango_client.py @@ -85,7 +85,7 @@ def create_collection(name, config): Shard the new collection based on the number of db nodes (10 shards for each). """ is_edge = config['type'] == 'edge' - num_shards = os.environ.get('SHARD_COUNT', 30) + num_shards = int(os.environ.get('SHARD_COUNT', 30)) url = _CONF['api_url'] + '/collection' # collection types: # 2 is a document collection From a5a5f1adc47a03811c5fd2f4e3bf90758506f9d3 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Fri, 1 Nov 2019 14:50:21 -0700 Subject: [PATCH 455/732] Add a set of yaml files that describe RE import data sources for UI and documentation purposes --- spec/README.md | 1 + spec/data_sources/envo_ontology.yaml | 5 +++++ spec/data_sources/go_ontology.yaml | 5 +++++ spec/data_sources/gtdb_taxonomy.yaml | 5 +++++ spec/data_sources/img/ncbi_taxonomy.png | Bin 0 -> 79970 bytes spec/data_sources/ncbi_taxonomy.yaml | 5 +++++ spec/data_sources/rdp_taxonomy.yaml | 5 +++++ 7 files changed, 26 insertions(+) create mode 100644 spec/data_sources/envo_ontology.yaml create mode 100644 spec/data_sources/go_ontology.yaml create mode 100644 spec/data_sources/gtdb_taxonomy.yaml create mode 100644 spec/data_sources/img/ncbi_taxonomy.png create mode 100644 spec/data_sources/ncbi_taxonomy.yaml create mode 100644 spec/data_sources/rdp_taxonomy.yaml diff --git a/spec/README.md b/spec/README.md index 4f000cff..c65a02db 100644 --- a/spec/README.md +++ b/spec/README.md @@ -9,6 +9,7 @@ by KBase apps to fetch data from the database. * **Schemas** are [JSON schemas](https://json-schema.org/) that define what form of data can be stored in the database's collections. * **Migrations** are python modules that connect to the database and are responsible for transitioning the data in a collection from an old schema to a newer one. +* **Data sources** (in `data_sources/`) contains some general information about where some of our imported data comes from. ## Development diff --git a/spec/data_sources/envo_ontology.yaml b/spec/data_sources/envo_ontology.yaml new file mode 100644 index 00000000..7e579a6f --- /dev/null +++ b/spec/data_sources/envo_ontology.yaml @@ -0,0 +1,5 @@ +name: envo_ontology +category: ontology +namespace_title: Environment Ontology +home_url: http://www.obofoundry.org/ontology/envo.html +data_url: http://www.obofoundry.org/ontology/envo.html diff --git a/spec/data_sources/go_ontology.yaml b/spec/data_sources/go_ontology.yaml new file mode 100644 index 00000000..5068ebc5 --- /dev/null +++ b/spec/data_sources/go_ontology.yaml @@ -0,0 +1,5 @@ +name: go_ontology +category: ontology +namespace_title: Gene Ontology +home_url: http://geneontology.org/ +data_url: http://release.geneontology.org/ diff --git a/spec/data_sources/gtdb_taxonomy.yaml b/spec/data_sources/gtdb_taxonomy.yaml new file mode 100644 index 00000000..6317e737 --- /dev/null +++ b/spec/data_sources/gtdb_taxonomy.yaml @@ -0,0 +1,5 @@ +name: gtdb_taxonomy +category: taxonomy +namespace_title: GTDB Taxonomy +home_url: https://gtdb.ecogenomic.org +data_url: https://data.ace.uq.edu.au/public/gtdb/data/releases/ diff --git a/spec/data_sources/img/ncbi_taxonomy.png b/spec/data_sources/img/ncbi_taxonomy.png new file mode 100644 index 0000000000000000000000000000000000000000..56fa82851fef367a51b70c6cc43945b69967a750 GIT binary patch literal 79970 zcmeFZ_g9nY7B>6^aQAHX5# zw@(msruTP7@W~1>X&U^+_)J^l0dz|H^S&uR9(=;&qowKx&~=I z_}efbePhNyea1g{<#5k&I6@{zYOTq{eDhMIWM`X=#GjY%UHjuLZuX{jMVeP7is$f>0jFRJj_fX$L|EG@&sxs zuK44K(x*Dee&XSA;#lzf057aU2%HIeq|BDQu0luqXXBrA%;2xkdl$fEAn3Nt|9cyA$Q z57*Gn^Q}cVnXLCblHIl|rna>xnO(_JIjKGUQAB?kYUMl+@_=5pg%}3$%-lh5v%9Z{ zdmya9(UP#b>V#eTL$ttnqZ5K8czzRs<{L*J71?#>QuCPq#r~c-3=^pTJJcHS7w!9d`X=TM`h>p5%-1PX($~FF zx9s%v5qUb#OZJ|F)N~IV$YboI5jI5@L!P)RTZ_22ysOifUXbDFSU8GOhM>;>gr0#e z>fJAiI~cy@un<|=mqj@iF3i*Ij?^L)BoMUEKpxGst?E-%3sji%{q4asBB>J@ucYgx zP)^~G&Ooh|;3hT}RkCt+wC~={CU#WnF&2Rbh9*ZI5eGXvy1O--G$2Uc8A!49qfla8 zO1x5q4<#2-_R&l}M|iklYF)+5l9hYXnD`e2;ml~K?u23N#+Gm*8PbAS2YuYoL_F;` zs%q1DO^oOu300c(_yrT=ObryXSdFmD>5)dR{m(8zkgawrJ(QVmA!I+6fJ59LWqUSy zP+<+e=(u4+2dzGL?OQuAsC>4WP;4q8E4-|Gxdz?w=mD6L=C z$G(clLlC}XR@HuY;RfnW1IjsLESLma|YOIhytryeNrw6N}FQ zW?~jHqRy9ha_a_@oq-J9oB0?+70o4@gp6M`4a)>Y0!(8W}+u5GcgC}Q_0)1oHGLCjoLTHC=N$a54WLet^zPap}# zWr|KWKh|OC&814Og&&TNj#b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*1&u|`*P?W0{QXI52yjJm9P&?#N!e(+ac#oX1o0m;R)m)P#! zG->kWDf5IvfUO~5YM&~W`ugwI+mZXa_`La8NI zxufsb@-72cK)rZ7HTuiFTe-kR;j{HlTkVVl4aDW-8+^UV|H!QLD{xj#>(tqh?T6m< zJFnFNjs&jWV&HyM{(o_u-=j5R7IT0tAkk3kFXvvZjoOpd4O(>$9_N0VozC}i?Kh8< z{SMnzQ~qy$(Fk1dpamRkzBzMcb@MtCw(w+~jPgl8LkNNuQn(JP# zU7+E`s`Asp=O^i%I_qN`d(Y8yd)wEG&!pC_y0sGM!Y!+^mIM2Io;MO$7zE1S|J=S@ zj)CDv5U?2xEQr5ZUp2B62-x0~Gqv<=VE>|+sbWu8WXCN7E-U{2$JX2#IRCZonpCgX zZmFn{y{jF8J>M;r?#-)KmA^jhYrS<-)^cEij#0+p)ZOb#-Fjsji|a^Ct^lf46qmv9Px*vV(kMH*b5Nb?MpM(py{h#)aN4Ukx0o zw=Oe3`t}|JLq7O|y9vM!bH?R9tK3_G%UN%g9QY5cO#>YL+BO*lO_@4x6|m_F97xpE zwhfJZsR`UX<9+M$)6x}pqk*Zzb@BW^#jBkje%t#yG0N%TUTfZR^DSCJsn7YXo=?8- z4s1%>KdATTV*xs89dNco^jX>}1@+|jato(Cd17nbVRw0oL|*@jm8t&iAzvQkPd9h0IxP(2&`6t+pU+z0*myd>p(XH*Mk68Q!U}& zTF)-dz+mP%#}#;g8VG!VT)YWnML;ec2C~B7Hz+}_RtE|tn8L3l8&w7jkI?`D-4YGF zd2Td?fWu)l%YcJnvJDAN=2*d>mX5H2+zzopr0K}`km;e9( From d667252922877c122e6f6b896f0d87c1bed1f60b Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Mon, 4 Nov 2019 10:25:51 -0800 Subject: [PATCH 457/732] Fix envo data sources --- spec/data_sources/envo_ontology.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/data_sources/envo_ontology.yaml b/spec/data_sources/envo_ontology.yaml index 7e579a6f..9c866999 100644 --- a/spec/data_sources/envo_ontology.yaml +++ b/spec/data_sources/envo_ontology.yaml @@ -2,4 +2,4 @@ name: envo_ontology category: ontology namespace_title: Environment Ontology home_url: http://www.obofoundry.org/ontology/envo.html -data_url: http://www.obofoundry.org/ontology/envo.html +data_url: https://github.com/EnvironmentOntology/envo/releases From b61690d633a602c1cbc033763393bd680a36a7d1 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Mon, 4 Nov 2019 14:48:13 -0800 Subject: [PATCH 458/732] Add logo_url entries using the ui-assets server paths --- spec/data_sources/envo_ontology.yaml | 1 + spec/data_sources/go_ontology.yaml | 1 + spec/data_sources/gtdb_taxonomy.yaml | 1 + spec/data_sources/ncbi_taxonomy.yaml | 1 + spec/data_sources/rdp_taxonomy.yaml | 1 + 5 files changed, 5 insertions(+) diff --git a/spec/data_sources/envo_ontology.yaml b/spec/data_sources/envo_ontology.yaml index 9c866999..7c0dd09e 100644 --- a/spec/data_sources/envo_ontology.yaml +++ b/spec/data_sources/envo_ontology.yaml @@ -3,3 +3,4 @@ category: ontology namespace_title: Environment Ontology home_url: http://www.obofoundry.org/ontology/envo.html data_url: https://github.com/EnvironmentOntology/envo/releases +logo_path: /images/third-party-data-sources/envo/logo-119-64.png diff --git a/spec/data_sources/go_ontology.yaml b/spec/data_sources/go_ontology.yaml index 5068ebc5..f0eed0b7 100644 --- a/spec/data_sources/go_ontology.yaml +++ b/spec/data_sources/go_ontology.yaml @@ -3,3 +3,4 @@ category: ontology namespace_title: Gene Ontology home_url: http://geneontology.org/ data_url: http://release.geneontology.org/ +logo_path: /images/third-party-data-sources/go/logo-248-64.png diff --git a/spec/data_sources/gtdb_taxonomy.yaml b/spec/data_sources/gtdb_taxonomy.yaml index 6317e737..75918c58 100644 --- a/spec/data_sources/gtdb_taxonomy.yaml +++ b/spec/data_sources/gtdb_taxonomy.yaml @@ -3,3 +3,4 @@ category: taxonomy namespace_title: GTDB Taxonomy home_url: https://gtdb.ecogenomic.org data_url: https://data.ace.uq.edu.au/public/gtdb/data/releases/ +logo_path: /images/third-party-data-sources/gtdb/logo-128-64.png diff --git a/spec/data_sources/ncbi_taxonomy.yaml b/spec/data_sources/ncbi_taxonomy.yaml index c94c3f28..e3b2f569 100644 --- a/spec/data_sources/ncbi_taxonomy.yaml +++ b/spec/data_sources/ncbi_taxonomy.yaml @@ -3,3 +3,4 @@ category: taxonomy namespace_title: NCBI Taxonomy home_url: https://www.ncbi.nlm.nih.gov/taxonomy data_url: ftp://ftp.ncbi.nlm.nih.gov/pub/taxonomy/ +logo_path: /images/third-party-data-sources/ncbi/logo-51-64.png diff --git a/spec/data_sources/rdp_taxonomy.yaml b/spec/data_sources/rdp_taxonomy.yaml index 1d7cf12f..57fb8864 100644 --- a/spec/data_sources/rdp_taxonomy.yaml +++ b/spec/data_sources/rdp_taxonomy.yaml @@ -3,3 +3,4 @@ category: taxonomy namespace_title: Ribosomal Database Project home_url: http://rdp.cme.msu.edu/taxomatic/main.spr data_url: http://rdp.cme.msu.edu/misc/resources.jsp +logo_url: /images/third-party-data-sources/ncbi/logo-51-64.png From 3261c944e35965c68c97654f6fd6ed3836e076ce Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Mon, 4 Nov 2019 15:45:13 -0800 Subject: [PATCH 459/732] Rename namespace_title->title --- spec/data_sources/envo_ontology.yaml | 2 +- spec/data_sources/go_ontology.yaml | 2 +- spec/data_sources/gtdb_taxonomy.yaml | 2 +- spec/data_sources/ncbi_taxonomy.yaml | 2 +- spec/data_sources/rdp_taxonomy.yaml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/spec/data_sources/envo_ontology.yaml b/spec/data_sources/envo_ontology.yaml index 7c0dd09e..0b138c35 100644 --- a/spec/data_sources/envo_ontology.yaml +++ b/spec/data_sources/envo_ontology.yaml @@ -1,6 +1,6 @@ name: envo_ontology category: ontology -namespace_title: Environment Ontology +title: Environment Ontology home_url: http://www.obofoundry.org/ontology/envo.html data_url: https://github.com/EnvironmentOntology/envo/releases logo_path: /images/third-party-data-sources/envo/logo-119-64.png diff --git a/spec/data_sources/go_ontology.yaml b/spec/data_sources/go_ontology.yaml index f0eed0b7..21cbfadf 100644 --- a/spec/data_sources/go_ontology.yaml +++ b/spec/data_sources/go_ontology.yaml @@ -1,6 +1,6 @@ name: go_ontology category: ontology -namespace_title: Gene Ontology +title: Gene Ontology home_url: http://geneontology.org/ data_url: http://release.geneontology.org/ logo_path: /images/third-party-data-sources/go/logo-248-64.png diff --git a/spec/data_sources/gtdb_taxonomy.yaml b/spec/data_sources/gtdb_taxonomy.yaml index 75918c58..8dd8e5af 100644 --- a/spec/data_sources/gtdb_taxonomy.yaml +++ b/spec/data_sources/gtdb_taxonomy.yaml @@ -1,6 +1,6 @@ name: gtdb_taxonomy category: taxonomy -namespace_title: GTDB Taxonomy +title: GTDB Taxonomy home_url: https://gtdb.ecogenomic.org data_url: https://data.ace.uq.edu.au/public/gtdb/data/releases/ logo_path: /images/third-party-data-sources/gtdb/logo-128-64.png diff --git a/spec/data_sources/ncbi_taxonomy.yaml b/spec/data_sources/ncbi_taxonomy.yaml index e3b2f569..37a88195 100644 --- a/spec/data_sources/ncbi_taxonomy.yaml +++ b/spec/data_sources/ncbi_taxonomy.yaml @@ -1,6 +1,6 @@ name: ncbi_taxonomy category: taxonomy -namespace_title: NCBI Taxonomy +title: NCBI Taxonomy home_url: https://www.ncbi.nlm.nih.gov/taxonomy data_url: ftp://ftp.ncbi.nlm.nih.gov/pub/taxonomy/ logo_path: /images/third-party-data-sources/ncbi/logo-51-64.png diff --git a/spec/data_sources/rdp_taxonomy.yaml b/spec/data_sources/rdp_taxonomy.yaml index 57fb8864..ffef460c 100644 --- a/spec/data_sources/rdp_taxonomy.yaml +++ b/spec/data_sources/rdp_taxonomy.yaml @@ -1,6 +1,6 @@ name: rdp_taxonomy category: taxonomy -namespace_title: Ribosomal Database Project +title: Ribosomal Database Project home_url: http://rdp.cme.msu.edu/taxomatic/main.spr data_url: http://rdp.cme.msu.edu/misc/resources.jsp logo_url: /images/third-party-data-sources/ncbi/logo-51-64.png From 512df4816b76f2865cfb0dfb707799c1e56868ce Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Mon, 4 Nov 2019 16:09:16 -0800 Subject: [PATCH 460/732] Fix limit on lineage query --- spec/stored_queries/ncbi_tax/ncbi_taxon_get_lineage.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_lineage.yaml b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_lineage.yaml index 99bff280..7d2f9544 100644 --- a/spec/stored_queries/ncbi_tax/ncbi_taxon_get_lineage.yaml +++ b/spec/stored_queries/ncbi_tax/ncbi_taxon_get_lineage.yaml @@ -23,7 +23,7 @@ query: | filter t.id == @id filter t.created <= @ts AND t.expired >= @ts limit 1 - for ancestor, e, path in 1..10 outbound t ncbi_child_of_taxon + for ancestor, e, path in 1..100 outbound t ncbi_child_of_taxon options {bfs: true} filter path.edges[*].created ALL <= @ts AND path.edges[*].expired ALL >= @ts return (@select ? KEEP(ancestor, @select) : ancestor) From 77184f245750cd7fba5de78e2844c2dde83b2061 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 5 Nov 2019 11:04:42 -0800 Subject: [PATCH 461/732] Add endpoints and tests for showing data source information --- .../api_versions/api_v1.py | 15 ++++- api/src/relation_engine_server/exceptions.py | 16 ++++- api/src/relation_engine_server/main.py | 33 +++++++---- .../relation_engine_server/utils/config.py | 3 +- .../utils/load_data_sources.py | 38 ++++++++++++ api/src/test/spec_release/spec.tar.gz | Bin 20677 -> 21465 bytes api/src/test/test_api_v1.py | 56 +++++++++++++++--- 7 files changed, 140 insertions(+), 21 deletions(-) create mode 100644 api/src/relation_engine_server/utils/load_data_sources.py diff --git a/api/src/relation_engine_server/api_versions/api_v1.py b/api/src/relation_engine_server/api_versions/api_v1.py index 7c91b5d3..275415ac 100644 --- a/api/src/relation_engine_server/api_versions/api_v1.py +++ b/api/src/relation_engine_server/api_versions/api_v1.py @@ -3,17 +3,30 @@ json_validation, arango_client, spec_loader, + load_data_sources, auth, bulk_import, pull_spec, config, parse_json ) -from ..exceptions import InvalidParameters +from src.relation_engine_server.exceptions import InvalidParameters api_v1 = flask.Blueprint('api_v1', __name__) +@api_v1.route("/data_sources", methods=["GET"]) +def list_data_sources(): + data_sources = load_data_sources.list_all() + return flask.jsonify({'data_sources': data_sources}) + + +@api_v1.route("/data_sources/", methods=["GET"]) +def show_data_source(name): + data_source = load_data_sources.fetch_one(name) + return flask.jsonify({'data_source': data_source}) + + @api_v1.route('/specs/stored_queries', methods=['GET']) def show_stored_queries(): """Show the current stored query names loaded from the spec.""" diff --git a/api/src/relation_engine_server/exceptions.py b/api/src/relation_engine_server/exceptions.py index ed0b0a20..095c2dc4 100644 --- a/api/src/relation_engine_server/exceptions.py +++ b/api/src/relation_engine_server/exceptions.py @@ -6,9 +6,11 @@ class InvalidParameters(Exception): """Invalid request parameters.""" - def __init__(self, msg): self.msg = msg + def __init__(self, msg): + self.msg = msg - def __str__(self): return self.msg + def __str__(self): + return self.msg class MissingHeader(Exception): @@ -27,3 +29,13 @@ class UnauthorizedAccess(Exception): def __init__(self, auth_url, response): self.auth_url = auth_url self.response = response + + +class NotFound(Exception): + """A resource was not found (yields a 404 response).""" + + def __init__(self, details): + self.details = details + + def __str__(self): + return self.details diff --git a/api/src/relation_engine_server/main.py b/api/src/relation_engine_server/main.py index 5af1d2b2..0a83467b 100644 --- a/api/src/relation_engine_server/main.py +++ b/api/src/relation_engine_server/main.py @@ -7,7 +7,7 @@ from jsonschema.exceptions import ValidationError from .api_versions.api_v1 import api_v1 -from .exceptions import MissingHeader, UnauthorizedAccess, InvalidParameters +from .exceptions import MissingHeader, UnauthorizedAccess, InvalidParameters, NotFound from .utils import arango_client, spec_loader app = flask.Flask(__name__) @@ -89,26 +89,38 @@ def validation_error(err): @app.errorhandler(UnauthorizedAccess) def unauthorized_access(err): resp = { - 'error': '403 - Unauthorized', - 'auth_url': err.auth_url, - 'auth_response': err.response + 'error': { + 'status': 403, + 'message': 'Unauthorized', + 'auth_url': err.auth_url, + 'auth_response': err.response, + }, } return (flask.jsonify(resp), 403) +@app.errorhandler(NotFound) @app.errorhandler(404) def page_not_found(err): - return (flask.jsonify({'error': '404 - Not found.'}), 404) + resp = { + 'error': { + 'message': 'Not found', + 'status': 404, + } + } + if hasattr(err, 'details'): + resp['error']['details'] = err.details + return (flask.jsonify(resp), 404) @app.errorhandler(405) def method_not_allowed(err): - return (flask.jsonify({'error': '405 - Method not allowed.'}), 405) + return (flask.jsonify({'error': {'message': 'Method not allowed', 'status': 405}}), 405) @app.errorhandler(MissingHeader) def generic_400(err): - return (flask.jsonify({'error': str(err)}), 400) + return (flask.jsonify({'error': {'message': str(err), 'status': 400}}), 400) # Any other unhandled exceptions -> 500 @@ -120,9 +132,10 @@ def server_error(err): print('-' * 80) traceback.print_exc() print('=' * 80) - resp = {'error': '500 - Unexpected server error'} - resp['error_class'] = err.__class__.__name__ - resp['error_details'] = str(err) + resp = {'error': {'status': 500, 'message': 'Unexpected server error'}} + # TODO only set below two fields in dev mode + resp['error']['class'] = err.__class__.__name__ + resp['error']['details'] = str(err) return (flask.jsonify(resp), 500) diff --git a/api/src/relation_engine_server/utils/config.py b/api/src/relation_engine_server/utils/config.py index 945ea27d..e329ff7b 100644 --- a/api/src/relation_engine_server/utils/config.py +++ b/api/src/relation_engine_server/utils/config.py @@ -46,6 +46,7 @@ def get_config(): 'repo': spec_repo_path, 'schemas': spec_schemas_path, 'stored_queries': stored_queries_path, - 'vertices': os.path.join(spec_schemas_path, 'vertices') + 'vertices': os.path.join(spec_schemas_path, 'vertices'), + 'data_sources': os.path.join(spec_repo_path, 'data_sources'), } } diff --git a/api/src/relation_engine_server/utils/load_data_sources.py b/api/src/relation_engine_server/utils/load_data_sources.py new file mode 100644 index 00000000..19498926 --- /dev/null +++ b/api/src/relation_engine_server/utils/load_data_sources.py @@ -0,0 +1,38 @@ +""" +Load the `data_sources` info from the relation engine spec. + +The spec holds some information about some of the source data for the RE, such +as NCBI taxonomy, Gene Ontology, etc. This info may be used in the UI. +""" +import yaml +import os +import glob + +from src.relation_engine_server.utils.config import get_config +from src.relation_engine_server.exceptions import NotFound + +_CONF = get_config() +_PATH = _CONF['spec_paths']['data_sources'] +print('_PATH is', _PATH) + + +def list_all(): + """ + List the names of all data sources. + """ + names = [] + for path in glob.iglob(os.path.join(_PATH + '/*.yaml')): + with open(path) as fd: + contents = yaml.safe_load(fd) + names.append(contents['name']) + return names + + +def fetch_one(name): + # Try .yaml or .yml + try: + with open(os.path.join(_PATH, f"{name}.yaml")) as fd: + contents = yaml.safe_load(fd) + except FileNotFoundError: + raise NotFound(f"The data source with name '{name}' does not exist.") + return contents diff --git a/api/src/test/spec_release/spec.tar.gz b/api/src/test/spec_release/spec.tar.gz index 27244be9b3dcc4aa90db95b3a87c0c98ea72dbe1..9187ff78f6ba24dfe3ac5d93eb23336dfb2da3e2 100644 GIT binary patch literal 21465 zcmV)-K!?8{iwFP!000001MEF(Z`-)C``N#O$R42Wy|LrBTLZ;KUd;yEO@bud#X(UB zv_#w7NTMoANxcW>zuy^BPfNDtBz3o24bar0_!x3t?`0>fKUe1hbDa?f_3>eyF7;=+U<=dqahud?O|`wZ+vTw}{7lUWRU=94>^1p`ut-z=ET(%aD z{j@f;{_n5R|HCEvcOkL!(@qBQ2dBRbEiooO`y6tgSq;hjdu}p0ZZwG{%sb{cr0H`n zzyychF%mEt)E3|$18d~}MA3iBZT7@AHpzcyP|*LQ;h&rh^@j`MagT5pM#r{Evl)6bAC?Cy6}1Iu0ZIOp!jCfDIVF))6 zwwNtiDC^bR*rfk^qwX^O`<-4r|Jwz))L~YKx?xs{GF$E&Ubbzdc%(e|Q?y^1lPn@;|F2{b$T&Ys7vAuM-|Yp%`7)sTr`m zHuT+EH&lVD^6#1x{?+8aSFr!^f47$Z9e|e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>cZrRZ|2 z`R3GB 0) + self.assertEqual(set(type(x) for x in resp_json['data_sources']), {str}) + + def test_show_data_source(self): + resp = requests.get(API_URL + '/data_sources/ncbi_taxonomy') + print('xyz test_show_data_source', resp.text) + self.assertTrue(resp.ok) + resp_json = resp.json() + self.assertEqual(type(resp_json['data_source']), dict) + self.assertEqual(set(resp_json['data_source'].keys()), { + 'name', 'category', 'title', 'home_url', 'data_url', 'logo_path' + }) + + def test_show_data_source_unknown(self): + """Unknown data source name should yield 404 status.""" + name = 'xyzyxz' + resp = requests.get(f"{API_URL}/data_sources/{name}") + self.assertEqual(resp.status_code, 404) + resp_json = resp.json() + # Just assert that it returns any json in the body + self.assertEqual(resp_json, { + 'error': { + 'message': 'Not found', + 'status': 404, + 'details': f"The data source with name '{name}' does not exist.", + } + }) From 15188c0ab1ecba26e7799fef165e8a35ef78cf8a Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 5 Nov 2019 11:21:41 -0800 Subject: [PATCH 462/732] Add documentation and convert logo_path -> logo_url using the kbase_endpoint env var --- api/README.md | 75 +++++++++++++++++++ .../utils/load_data_sources.py | 3 + api/src/test/test_api_v1.py | 9 ++- 3 files changed, 84 insertions(+), 3 deletions(-) diff --git a/api/README.md b/api/README.md index 8cdfaa42..e894e5ef 100644 --- a/api/README.md +++ b/api/README.md @@ -173,6 +173,81 @@ If you try to update a collection and it fails validation against a JSON schema * `"value"` - The (possibly nested) value in your data that failed validation * `"path"` - The path into your data where you can find the value that failed validation +### GET /api/v1/data_sources + +Fetch a list of data source names. Will return an array of strings. + +Example response body: + +```json +{"data_sources": ["x", "y", "z"]} +``` + +Response JSON schema: + +```json +{ "type": "object", + "properties": { + "data_sources": { + "type: "array", + "items": { "type": "string" } + } + } +} +``` + +### GET /api/v1/data_sources/ + +Fetch the details for a data source by name. Will return an object of key/value details. + +Example response body: + +```json +{ + "data_source": { + "name": "envo_ontology", + "category": "ontology", + "title": "Environment Ontology", + "home_url": "http://www.obofoundry.org/ontology/envo.html", + "data_url": "https://github.com/EnvironmentOntology/envo/releases", + "logo_url": "https://ci.kbase.us/ui-assets/images/third-party-data-sources/envo/logo-119-64.png" + } +} +``` + +Response JSON schema: + +```json +{ "type": "object", + "properties": { + "name": { + "type: "string", + "description": "canonical identifier for this data source" + }, + "category": { + "type: "string", + "description": "parent category, such as taxonomy or ontology" + }, + "title": { + "type: "string", + "description": "human readable name for the data source" + }, + "home_url": { + "type: "string", + "description": "full URL of the home page for the data source" + }, + "data_url": { + "type: "string", + "description": "full URL from where the data can be downloaded" + }, + "logo_url": { + "type: "string", + "description": "the URL of a logo image representing this data source" + }, + } +} +``` + ### PUT /api/v1/specs/ Manually check and pull spec updates. Requires sysadmin auth. diff --git a/api/src/relation_engine_server/utils/load_data_sources.py b/api/src/relation_engine_server/utils/load_data_sources.py index 19498926..61f01ee5 100644 --- a/api/src/relation_engine_server/utils/load_data_sources.py +++ b/api/src/relation_engine_server/utils/load_data_sources.py @@ -35,4 +35,7 @@ def fetch_one(name): contents = yaml.safe_load(fd) except FileNotFoundError: raise NotFound(f"The data source with name '{name}' does not exist.") + # Append the logo root url to be the ui-assets server url with the correct environment + contents['logo_url'] = _CONF['kbase_endpoint'] + '/ui-assets' + contents['logo_path'] + del contents['logo_path'] return contents diff --git a/api/src/test/test_api_v1.py b/api/src/test/test_api_v1.py index d0f861ed..6d4e4141 100644 --- a/api/src/test/test_api_v1.py +++ b/api/src/test/test_api_v1.py @@ -446,7 +446,6 @@ def test_save_docs_invalid(self): def test_list_data_sources(self): resp = requests.get(API_URL + '/data_sources') - print('xyz test_list_data_source', resp.text) self.assertTrue(resp.ok) resp_json = resp.json() self.assertTrue(len(resp_json['data_sources']) > 0) @@ -454,13 +453,17 @@ def test_list_data_sources(self): def test_show_data_source(self): resp = requests.get(API_URL + '/data_sources/ncbi_taxonomy') - print('xyz test_show_data_source', resp.text) self.assertTrue(resp.ok) resp_json = resp.json() self.assertEqual(type(resp_json['data_source']), dict) self.assertEqual(set(resp_json['data_source'].keys()), { - 'name', 'category', 'title', 'home_url', 'data_url', 'logo_path' + 'name', 'category', 'title', 'home_url', 'data_url', 'logo_url' }) + self.assertTrue( + resp_json['data_source']['logo_url'].startswith( + _CONF['kbase_endpoint'] + '/ui-assets/images/third-party-data-sources/ncbi' + ) + ) def test_show_data_source_unknown(self): """Unknown data source name should yield 404 status.""" From bc7516c6244785d31e84bf2451371d1e343911de Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 5 Nov 2019 11:22:56 -0800 Subject: [PATCH 463/732] Fix json --- api/README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/api/README.md b/api/README.md index e894e5ef..26085942 100644 --- a/api/README.md +++ b/api/README.md @@ -189,7 +189,7 @@ Response JSON schema: { "type": "object", "properties": { "data_sources": { - "type: "array", + "type": "array", "items": { "type": "string" } } } @@ -221,27 +221,27 @@ Response JSON schema: { "type": "object", "properties": { "name": { - "type: "string", + "type": "string", "description": "canonical identifier for this data source" }, "category": { - "type: "string", + "type": "string", "description": "parent category, such as taxonomy or ontology" }, "title": { - "type: "string", + "type": "string", "description": "human readable name for the data source" }, "home_url": { - "type: "string", + "type": "string", "description": "full URL of the home page for the data source" }, "data_url": { - "type: "string", + "type": "string", "description": "full URL from where the data can be downloaded" }, "logo_url": { - "type: "string", + "type": "string", "description": "the URL of a logo image representing this data source" }, } From b1837c6cda8fe4ac231e1b885f1044fda0132e7c Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 5 Nov 2019 12:11:14 -0800 Subject: [PATCH 464/732] Add local build script with image version embedded --- api/hooks/build | 4 ++++ api/scripts/local-build.sh | 7 +++++++ 2 files changed, 11 insertions(+) create mode 100644 api/scripts/local-build.sh diff --git a/api/hooks/build b/api/hooks/build index ffed9243..3d8b8414 100755 --- a/api/hooks/build +++ b/api/hooks/build @@ -4,6 +4,10 @@ # $IMAGE_NAME var is injected into the build so the tag is correct. +if [ -z "$IMAGE_NAME" ]; then + export IMAGE_NAME="kbase/relation_engine_api:0.0.4" +fi + echo "Build hook running" export BRANCH=${TRAVIS_BRANCH:-`git symbolic-ref --short HEAD`} export DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` diff --git a/api/scripts/local-build.sh b/api/scripts/local-build.sh new file mode 100644 index 00000000..b02a5da1 --- /dev/null +++ b/api/scripts/local-build.sh @@ -0,0 +1,7 @@ +#!/bin/sh +set -e +# show the commands we execute +set -o xtrace +export IMAGE_NAME="kbase/relation_engine_api:0.0.4" +sh hooks/build +docker push $IMAGE_NAME From f4256fa4fd963c854c43676f334dc0fb49d95851 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 5 Nov 2019 12:13:52 -0800 Subject: [PATCH 465/732] Fix tag in title --- api/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/README.md b/api/README.md index 26085942..15d76cab 100644 --- a/api/README.md +++ b/api/README.md @@ -196,7 +196,7 @@ Response JSON schema: } ``` -### GET /api/v1/data_sources/ +### GET /api/v1/data_sources/{name} Fetch the details for a data source by name. Will return an object of key/value details. From fc0531da1e2955af86ac97341b5c45ab3f14dd3a Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 5 Nov 2019 12:56:43 -0800 Subject: [PATCH 466/732] Fix logo url --- api/src/relation_engine_server/utils/load_data_sources.py | 4 +++- api/src/test/test_api_v1.py | 4 +--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/api/src/relation_engine_server/utils/load_data_sources.py b/api/src/relation_engine_server/utils/load_data_sources.py index 61f01ee5..539404ed 100644 --- a/api/src/relation_engine_server/utils/load_data_sources.py +++ b/api/src/relation_engine_server/utils/load_data_sources.py @@ -4,6 +4,7 @@ The spec holds some information about some of the source data for the RE, such as NCBI taxonomy, Gene Ontology, etc. This info may be used in the UI. """ +import re import yaml import os import glob @@ -36,6 +37,7 @@ def fetch_one(name): except FileNotFoundError: raise NotFound(f"The data source with name '{name}' does not exist.") # Append the logo root url to be the ui-assets server url with the correct environment - contents['logo_url'] = _CONF['kbase_endpoint'] + '/ui-assets' + contents['logo_path'] + base_logo_url = re.sub(r'\/services\/?', '/ui-assets', _CONF['kbase_endpoint']) + contents['logo_url'] = base_logo_url + contents['logo_path'] del contents['logo_path'] return contents diff --git a/api/src/test/test_api_v1.py b/api/src/test/test_api_v1.py index 6d4e4141..c8ec7ec0 100644 --- a/api/src/test/test_api_v1.py +++ b/api/src/test/test_api_v1.py @@ -460,9 +460,7 @@ def test_show_data_source(self): 'name', 'category', 'title', 'home_url', 'data_url', 'logo_url' }) self.assertTrue( - resp_json['data_source']['logo_url'].startswith( - _CONF['kbase_endpoint'] + '/ui-assets/images/third-party-data-sources/ncbi' - ) + '/ui-assets/images/third-party-data-sources/ncbi' in resp_json['data_source']['logo_url'] ) def test_show_data_source_unknown(self): From a9957aa4235ce43dd88327e036abacf5bef8b214 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 5 Nov 2019 12:57:41 -0800 Subject: [PATCH 467/732] Increment version -> 0.0.5 --- api/README.md | 2 ++ api/scripts/local-build.sh | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/api/README.md b/api/README.md index 15d76cab..f97eb625 100644 --- a/api/README.md +++ b/api/README.md @@ -348,6 +348,8 @@ make test The docker image is pushed to Docker Hub when new commits are made to master. The script that runs when pushing to docker hub is found in `hooks/build`. +Alternatively, set the image name in `scripts/local-build.sh` and run it to build and deploy locally, which may be a lot faster. + ## Project anatomy * Source code is in `./src` diff --git a/api/scripts/local-build.sh b/api/scripts/local-build.sh index b02a5da1..c1c3cc2c 100644 --- a/api/scripts/local-build.sh +++ b/api/scripts/local-build.sh @@ -2,6 +2,6 @@ set -e # show the commands we execute set -o xtrace -export IMAGE_NAME="kbase/relation_engine_api:0.0.4" +export IMAGE_NAME="kbase/relation_engine_api:0.0.5" sh hooks/build docker push $IMAGE_NAME From ffb20afdb25b01cec049b2f1710be14d8d6b8273 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Thu, 12 Dec 2019 13:41:20 -0800 Subject: [PATCH 468/732] Fix stored query; move WITH clause into prefix --- spec/stored_queries/list_genes_for_similar_reactions.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/stored_queries/list_genes_for_similar_reactions.yaml b/spec/stored_queries/list_genes_for_similar_reactions.yaml index c508c14b..76d9d00b 100644 --- a/spec/stored_queries/list_genes_for_similar_reactions.yaml +++ b/spec/stored_queries/list_genes_for_similar_reactions.yaml @@ -20,8 +20,8 @@ params: description: If true, don't include the query reactions genes default: false +query_prefix: WITH rxn_reaction query: | - WITH rxn_reaction LET start = @exclude_self ? 1 : 0 LET rxns = ( FOR v, e IN start..1 From 46851cdd7cbd569469dbf4187dfb27b03e06fb97 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Mon, 16 Dec 2019 17:08:43 -0800 Subject: [PATCH 469/732] Remove extraneous print --- api/src/relation_engine_server/utils/load_data_sources.py | 1 - 1 file changed, 1 deletion(-) diff --git a/api/src/relation_engine_server/utils/load_data_sources.py b/api/src/relation_engine_server/utils/load_data_sources.py index 539404ed..b2a7c463 100644 --- a/api/src/relation_engine_server/utils/load_data_sources.py +++ b/api/src/relation_engine_server/utils/load_data_sources.py @@ -14,7 +14,6 @@ _CONF = get_config() _PATH = _CONF['spec_paths']['data_sources'] -print('_PATH is', _PATH) def list_all(): From 7163b31cf69fff00112451d390b6775006213a69 Mon Sep 17 00:00:00 2001 From: Shane Canon Date: Fri, 17 Jan 2020 07:33:08 -0800 Subject: [PATCH 470/732] Fix schema URL in docs I think this got out of sync. --- api/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/api/README.md b/api/README.md index f97eb625..f5807833 100644 --- a/api/README.md +++ b/api/README.md @@ -264,12 +264,12 @@ _Query params_ Every call to update specs will reset the spec data (do a clean download and overwrite). -### GET /api/v1/schemas +### GET /api/v1/specs/schemas Get all schema names (returns an array of strings): ```sh -GET {root_url}/api/v1/schemas +GET {root_url}/api/v1/specs/schemas ``` Example response: @@ -281,7 +281,7 @@ Example response: Get the contents of a specific schema ```sh -GET "{root_url}/api/v1/schemas?name=test_vertex" +GET "{root_url}/api/v1/specs/schemas?name=test_vertex" ``` Example response: @@ -307,7 +307,7 @@ Example response: Get the schema for a particular document by its full ID ```sh -GET "{root_url}/api/v1/schemas?doc_id=test_vertex/1" +GET "{root_url}/api/v1/specs/schemas?doc_id=test_vertex/1" ``` The response will have the same format as the example response above From b5d0493313fdbf36cce1f5d8300c4ccdc8b6c43d Mon Sep 17 00:00:00 2001 From: Shane Canon Date: Thu, 30 Jan 2020 16:50:37 -0800 Subject: [PATCH 471/732] Add views for Compounds and Reactions plus README --- spec/views/Compounds.json | 43 +++++++++++++++++++++++++++++++++++++++ spec/views/README.md | 5 +++++ spec/views/Reactions.json | 38 ++++++++++++++++++++++++++++++++++ 3 files changed, 86 insertions(+) create mode 100644 spec/views/Compounds.json create mode 100644 spec/views/README.md create mode 100644 spec/views/Reactions.json diff --git a/spec/views/Compounds.json b/spec/views/Compounds.json new file mode 100644 index 00000000..a4214352 --- /dev/null +++ b/spec/views/Compounds.json @@ -0,0 +1,43 @@ +{ + "writebufferIdle": 64, + "writebufferActive": 0, + "type": "arangosearch", + "primarySort": [], + "writebufferSizeMax": 33554432, + "commitIntervalMsec": 1000, + "consolidationPolicy": { + "type": "bytes_accum", + "threshold": 0.10000000149011612 + }, + "globallyUniqueId": "h5455DEB9D2A1/9852581", + "cleanupIntervalStep": 10, + "id": "9852581", + "links": { + "rxn_compound": { + "analyzers": [ + "identity" + ], + "fields": { + "id": { + "analyzers": [ + "text_en" + ] + }, + "abbreviation": { + "analyzers": [ + "text_en" + ] + }, + "aliases": { + "analyzers": [ + "text_en" + ] + } + }, + "includeAllFields": true, + "storeValues": "none", + "trackListPositions": false + } + }, + "consolidationIntervalMsec": 60000 +} diff --git a/spec/views/README.md b/spec/views/README.md new file mode 100644 index 00000000..96c7f473 --- /dev/null +++ b/spec/views/README.md @@ -0,0 +1,5 @@ +# Views + +These are json files for arango views. Currently you would need to manually create the view then cut and paste the json contents. + + diff --git a/spec/views/Reactions.json b/spec/views/Reactions.json new file mode 100644 index 00000000..a7822dfd --- /dev/null +++ b/spec/views/Reactions.json @@ -0,0 +1,38 @@ +{ + "writebufferIdle": 64, + "writebufferActive": 0, + "type": "arangosearch", + "primarySort": [], + "writebufferSizeMax": 33554432, + "commitIntervalMsec": 1000, + "consolidationPolicy": { + "type": "bytes_accum", + "threshold": 0.10000000149011612 + }, + "globallyUniqueId": "h5455DEB9D2A1/9853332", + "cleanupIntervalStep": 10, + "id": "9853332", + "links": { + "rxn_reaction": { + "analyzers": [ + "identity" + ], + "fields": { + "name": { + "analyzers": [ + "text_en" + ] + }, + "aliases": { + "analyzers": [ + "text_en" + ] + } + }, + "includeAllFields": true, + "storeValues": "none", + "trackListPositions": false + } + }, + "consolidationIntervalMsec": 60000 +} From 10aac63bd4de7b6b27673f3d1099dc77c2817a5d Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Fri, 13 Mar 2020 15:31:43 -0700 Subject: [PATCH 472/732] Get all the generic queries added with correct syntax and params --- spec/schemas/taxonomy/child_of_taxon.yaml | 26 +++ .../taxonomy/taxonomy_fetch_taxon.yaml | 22 +++ .../taxonomy_fetch_taxon_by_sciname.yaml | 26 +++ .../taxonomy_get_associated_ws_objects.yaml | 74 +++++++ .../taxonomy/taxonomy_get_children.yaml | 69 +++++++ .../taxonomy_get_children_cursor.yaml | 33 ++++ .../taxonomy/taxonomy_get_lineage.yaml | 41 ++++ .../taxonomy/taxonomy_get_siblings.yaml | 67 +++++++ .../taxonomy_get_taxon_from_ws_obj.yaml | 26 +++ .../taxonomy/taxonomy_search_sci_name.yaml | 64 ++++++ spec/test/stored_queries/test_ncbi_tax.py | 1 + spec/test/stored_queries/test_taxonomy.py | 184 ++++++++++++++++++ spec/test/validate.py | 2 +- 13 files changed, 634 insertions(+), 1 deletion(-) create mode 100644 spec/schemas/taxonomy/child_of_taxon.yaml create mode 100644 spec/stored_queries/taxonomy/taxonomy_fetch_taxon.yaml create mode 100644 spec/stored_queries/taxonomy/taxonomy_fetch_taxon_by_sciname.yaml create mode 100644 spec/stored_queries/taxonomy/taxonomy_get_associated_ws_objects.yaml create mode 100644 spec/stored_queries/taxonomy/taxonomy_get_children.yaml create mode 100644 spec/stored_queries/taxonomy/taxonomy_get_children_cursor.yaml create mode 100644 spec/stored_queries/taxonomy/taxonomy_get_lineage.yaml create mode 100644 spec/stored_queries/taxonomy/taxonomy_get_siblings.yaml create mode 100644 spec/stored_queries/taxonomy/taxonomy_get_taxon_from_ws_obj.yaml create mode 100644 spec/stored_queries/taxonomy/taxonomy_search_sci_name.yaml create mode 100644 spec/test/stored_queries/test_taxonomy.py diff --git a/spec/schemas/taxonomy/child_of_taxon.yaml b/spec/schemas/taxonomy/child_of_taxon.yaml new file mode 100644 index 00000000..6a5a2bef --- /dev/null +++ b/spec/schemas/taxonomy/child_of_taxon.yaml @@ -0,0 +1,26 @@ +name: child_of_taxon +type: edge +delta: true + +indexes: + - type: persistent + fields: [id, expired, created] + - type: persistent + fields: [expired, created, last_version] + +schema: + "$schema": http://json-schema.org/draft-07/schema# + type: object + required: [from, to, id] + description: Edges linking parent/child relationships between taxonomy vertices + properties: + id: + type: string + description: The id of the edge. This is the same as the from ID for NCBI. + from: + type: string + description: The child taxon. + to: + type: string + description: The parent taxon. + diff --git a/spec/stored_queries/taxonomy/taxonomy_fetch_taxon.yaml b/spec/stored_queries/taxonomy/taxonomy_fetch_taxon.yaml new file mode 100644 index 00000000..67cf2ecc --- /dev/null +++ b/spec/stored_queries/taxonomy/taxonomy_fetch_taxon.yaml @@ -0,0 +1,22 @@ +# Fetch a taxon document by taxonomy ID +name: taxonomy_fetch_taxon +params: + type: object + required: [id, ts, "@taxon_coll"] + properties: + id: + type: string + title: NCBI Taxonomy ID + ts: + type: integer + title: Versioning timestamp + "@taxon_coll": + type: string + title: Taxon collection name + examples: [ncbi_taxon, gtdb_taxon] +query: | + for t in @@taxon_coll + filter t.id == @id + filter t.created <= @ts AND t.expired >= @ts + limit 1 + return t diff --git a/spec/stored_queries/taxonomy/taxonomy_fetch_taxon_by_sciname.yaml b/spec/stored_queries/taxonomy/taxonomy_fetch_taxon_by_sciname.yaml new file mode 100644 index 00000000..617a34b2 --- /dev/null +++ b/spec/stored_queries/taxonomy/taxonomy_fetch_taxon_by_sciname.yaml @@ -0,0 +1,26 @@ +# Fetch a taxon document by exact match on sciname +name: taxonomy_fetch_taxon_by_sciname +params: + type: object + required: [sciname, sciname_field, ts, "@taxon_coll"] + properties: + sciname: + type: string + title: NCBI scientific name + sciname_field: + type: string + title: Scientific name field name + examples: [scientific_name, name] + ts: + type: integer + title: Versioning timestamp + "@taxon_coll": + type: string + title: Taxon collection name + examples: [ncbi_taxon, gtdb_taxon] +query: | + for t in @@taxon_coll + filter t.@sciname_field == @sciname + filter t.created <= @ts AND t.expired >= @ts + limit 1 + return t diff --git a/spec/stored_queries/taxonomy/taxonomy_get_associated_ws_objects.yaml b/spec/stored_queries/taxonomy/taxonomy_get_associated_ws_objects.yaml new file mode 100644 index 00000000..46686b54 --- /dev/null +++ b/spec/stored_queries/taxonomy/taxonomy_get_associated_ws_objects.yaml @@ -0,0 +1,74 @@ +# Get the workspace objects associated with a taxon + +name: taxonomy_get_associated_ws_objects + +params: + type: object + required: [taxon_id, ts, "@taxon_coll"] + properties: + "@taxon_coll": + type: string + title: Taxon collection name + examples: [ncbi_taxon, gtdb_taxon] + taxon_id: + type: string + title: NCBI Taxon ID + description: ID of the taxon vertex to find associated taxa + limit: + type: integer + default: 20 + description: Maximum result limit + maximum: 1000 + offset: + type: integer + default: 0 + description: Result offset for pagination + maximum: 100000 + ts: + type: integer + title: Versioning timestamp + select_obj: + type: [array, "null"] + items: {type: string} + title: WS obj fields to keep in the results + default: null + select_edge: + type: [array, "null"] + items: {type: string} + description: Taxon edge fields to keep in the results + default: null +query_prefix: WITH ws_object_version, ws_type_version, ws_workspace +query: | + LET count = COUNT( + FOR tax IN @@taxon_coll + FILTER tax.id == @taxon_id + FILTER tax.created <= @ts AND tax.expired >= @ts + LIMIT 1 + FOR obj IN 1..1 INBOUND tax ws_obj_version_has_taxon + RETURN 1 + ) + LET results = ( + FOR tax IN @@taxon_coll + FILTER tax.id == @taxon_id + FILTER tax.created <= @ts AND tax.expired >= @ts + LIMIT 1 + FOR obj, e IN 1 INBOUND tax ws_obj_version_has_taxon + FILTER obj.is_public OR obj.workspace_id IN ws_ids + LIMIT @offset, @limit + LET type = first( + FOR type IN 1 OUTBOUND obj ws_obj_instance_of_type + RETURN KEEP(type, ['_key', 'module_name', 'type_name', 'maj_ver', 'min_ver']) + ) + LET unver_id = CONCAT("ws_object/", TO_STRING(obj.workspace_id), ':', TO_STRING(obj.object_id)) + LET ws_info = FIRST( + FOR ws IN 1 INBOUND unver_id ws_workspace_contains_obj + FILTER !ws.is_deleted + RETURN KEEP(ws, ['owner', 'metadata', 'is_public', 'mod_epoch']) + ) + LET o = MERGE(obj, {type, ws_info}) + RETURN { + ws_obj: @select_obj ? KEEP(o, @select_obj) : o, + edge: @select_edge ? KEEP(e, @select_edge) : e + } + ) + RETURN {results, total_count: count} diff --git a/spec/stored_queries/taxonomy/taxonomy_get_children.yaml b/spec/stored_queries/taxonomy/taxonomy_get_children.yaml new file mode 100644 index 00000000..94efa1be --- /dev/null +++ b/spec/stored_queries/taxonomy/taxonomy_get_children.yaml @@ -0,0 +1,69 @@ +# Get the array of direct descendants for any taxon +name: taxonomy_get_children +params: + type: object + required: [id, ts, sciname_field, "@taxon_coll", "@taxon_child_of"] + properties: + sciname_field: + type: string + title: Scientific name field name + examples: [scientific_name, name] + "@taxon_coll": + type: string + title: Taxon vertex collection name + examples: [ncbi_taxon, gtdb_taxon] + "@taxon_child_of": + type: string + title: Taxon edge collection name for parent-to-child relationship + examples: [ncbi_child_of_taxon, gtdb_child_of_taxon] + id: + type: string + title: Document ID + description: ID of the taxon vertex for which you want to find descendants + limit: + type: integer + default: 20 + description: Maximum result limit + maximum: 1000 + offset: + type: integer + default: 0 + description: Result offset for pagination + maximum: 100000 + search_text: + type: string + description: Search scientific name + default: '' + ts: + type: integer + title: Versioning timestamp + select: + type: [array, "null"] + items: {type: string} + description: Taxon fields to keep in the results + default: null +query: | + // Fetch the child IDs using the edge attributes + let child_ids = ( + for e in @@taxon_child_of + filter e.to == @id + filter e.created <= @ts AND e.expired >= @ts + return e.from + ) + // Sort and filter the children + // Should only get evaluated if search_text is truthy + let searched = ( + for tax in FULLTEXT(@@taxon_coll, @sciname_field, @search_text) + filter tax.id in child_ids + return tax.id + ) + let filtered = @search_text ? searched : child_ids + let results = ( + for tax in @@taxon_coll + filter tax.id in filtered + filter tax.created <= @ts AND tax.expired >= @ts + sort tax.@sciname_field asc + limit @offset, @limit + return (@select ? KEEP(tax, @select) : tax) + ) + return {total_count: COUNT(filtered), results: results} diff --git a/spec/stored_queries/taxonomy/taxonomy_get_children_cursor.yaml b/spec/stored_queries/taxonomy/taxonomy_get_children_cursor.yaml new file mode 100644 index 00000000..3320da29 --- /dev/null +++ b/spec/stored_queries/taxonomy/taxonomy_get_children_cursor.yaml @@ -0,0 +1,33 @@ +# Get all children for a taxon, using a cursor +name: taxonomy_get_children_cursor +params: + type: object + required: [id, ts, "@taxon_coll"] + properties: + "@taxon_coll": + type: string + title: Taxon vertex collection name + examples: [ncbi_taxon, gtdb_taxon] + "@taxon_child_of": + type: string + title: Taxon edge collection name for parent-to-child relationship + examples: [ncbi_child_of_taxon, gtdb_child_of_taxon] + id: + type: string + title: Document ID + description: ID of the taxon vertex for which you want to find descendants + ts: + type: integer + title: Versioning timestamp + select: + type: [array, "null"] + items: {type: string} + description: Taxon fields to keep in the results + default: null +query: | + for tax in @@taxon_coll + filter tax.id == @id + filter tax.created <= @ts AND tax.expired >= @ts + limit 1 + for child in 1..1 inbound tax @@taxon_child_of + return @select ? KEEP(tax, @select) : tax diff --git a/spec/stored_queries/taxonomy/taxonomy_get_lineage.yaml b/spec/stored_queries/taxonomy/taxonomy_get_lineage.yaml new file mode 100644 index 00000000..11d92656 --- /dev/null +++ b/spec/stored_queries/taxonomy/taxonomy_get_lineage.yaml @@ -0,0 +1,41 @@ +# Get the lineage array for a taxon +# Returns an array where the top-most (closest to the root) taxon is at the beginning +name: taxonomy_get_lineage +params: + type: object + required: [id, ts, "@taxon_coll", "@taxon_child_of"] + properties: + "@taxon_coll": + type: string + title: Taxon collection name + examples: [ncbi_taxon, gtdb_taxon] + "@taxon_child_of": + type: string + title: Taxon edge collection name for parent-to-child relationship + examples: [ncbi_child_of_taxon, gtdb_child_of_taxon] + id: + type: string + title: Document id + description: ID of the taxon vertex for which you want to find ancestors + ts: + type: integer + title: Versioning timestamp + select: + type: [array, "null"] + items: {type: string} + description: Taxon fields to keep in the results + default: null +query: | + let ps = ( + for t in @@taxon_coll + filter t.id == @id + filter t.created <= @ts AND t.expired >= @ts + limit 1 + for ancestor, e, path in 1..100 outbound t @@taxon_child_of + options {bfs: true} + filter path.edges[*].created ALL <= @ts AND path.edges[*].expired ALL >= @ts + return (@select ? KEEP(ancestor, @select) : ancestor) + ) + // doing return reverse(ps) returns an array of an array for some reason, + // which we don't want + for d in reverse(ps) return d diff --git a/spec/stored_queries/taxonomy/taxonomy_get_siblings.yaml b/spec/stored_queries/taxonomy/taxonomy_get_siblings.yaml new file mode 100644 index 00000000..95bfa7ba --- /dev/null +++ b/spec/stored_queries/taxonomy/taxonomy_get_siblings.yaml @@ -0,0 +1,67 @@ +# Get the array of siblings for a taxon +# Results are limited to 10k +name: taxonomy_get_siblings +params: + type: object + required: [id, ts, sciname_field, "@taxon_coll", "@taxon_child_of"] + properties: + sciname_field: + type: string + title: Scientific name field name + examples: [scientific_name, name] + "@taxon_coll": + type: string + title: Taxon vertex collection name + examples: [ncbi_taxon, gtdb_taxon] + "@taxon_child_of": + type: string + title: Taxon edge collection name for parent-to-child relationship + examples: [ncbi_child_of_taxon, gtdb_child_of_taxon] + id: + type: string + title: Document id + description: ID of the taxon vertex for which you want to find siblings + limit: + type: integer + default: 20 + description: Maximum result limit + maximum: 1000 + offset: + type: integer + default: 0 + description: Result offset for pagination + maximum: 100000 + ts: + type: integer + title: Versioning timestamp + select: + type: [array, "null"] + items: {type: string} + description: Taxon fields to keep in the results + default: null +query: | + // Fetch the siblings + let parent_id = first( + for e in @@taxon_child_of + filter e.from == @id + filter e.created <= @ts and e.expired >= @ts + limit 1 + return e.to + ) + let sibling_ids = ( + for e in @@taxon_child_of + filter e.to == parent_id + filter e.created <= @ts and e.expired >= @ts + filter e.from != @id + return e.from + ) + // Apply sort and limits to the results + let siblings = ( + for tax in @@taxon_coll + filter tax.id in sibling_ids + filter tax.created <= @ts AND tax.expired >= @ts + sort tax.@sciname_field asc + limit @offset, @limit + return (@select ? KEEP(tax, @select) : tax) + ) + return {total_count: COUNT(sibling_ids), results: siblings} diff --git a/spec/stored_queries/taxonomy/taxonomy_get_taxon_from_ws_obj.yaml b/spec/stored_queries/taxonomy/taxonomy_get_taxon_from_ws_obj.yaml new file mode 100644 index 00000000..fe81aa9b --- /dev/null +++ b/spec/stored_queries/taxonomy/taxonomy_get_taxon_from_ws_obj.yaml @@ -0,0 +1,26 @@ +# Fetch a taxon document from a workspace object reference +name: taxonomy_get_taxon_from_ws_obj +params: + type: object + required: [obj_ref, ts, "@taxon_coll"] + properties: + "@taxon_coll": + type: string + title: Taxon collection name + examples: [ncbi_taxon, gtdb_taxon] + obj_ref: + type: string + title: Workspace versioned object reference + ts: + type: integer + title: Versioning timestamp +query_prefix: with @@taxon_coll +query: | + for obj in ws_object_version + filter obj._key == @obj_ref + filter obj.is_public or obj.workspace_id IN ws_ids + for tax in 1 outbound obj ws_obj_version_has_taxon + filter tax.created <= @ts AND tax.expired >= @ts + limit 1 + return tax + diff --git a/spec/stored_queries/taxonomy/taxonomy_search_sci_name.yaml b/spec/stored_queries/taxonomy/taxonomy_search_sci_name.yaml new file mode 100644 index 00000000..d6175838 --- /dev/null +++ b/spec/stored_queries/taxonomy/taxonomy_search_sci_name.yaml @@ -0,0 +1,64 @@ +# Search for a taxon with a scientific name +# Offset is limited to 10k +name: taxonomy_search_sci_name +params: + type: object + required: [search_text, ts, "@taxon_coll", sciname_field] + properties: + "@taxon_coll": + type: string + title: Taxon collection name + examples: [ncbi_taxon, gtdb_taxon] + search_text: + type: string + title: Search text + description: Text to search on for the scientific name + ranks: + description: Filter the query to include only these ranks. An empty array is ignored. + type: array + default: [] + items: + type: string + include_strains: + description: true to include strains in the result, regardless of the ranks field. false + to perform no special filtering on strains. + type: boolean + default: false + offset: + type: integer + default: 0 + maximum: 100000 + limit: + type: integer + default: 20 + maximum: 1000 + ts: + type: integer + title: Versioning timestamp + select: + type: [array, "null"] + items: {type: string} + description: Taxon fields to keep in the results + default: null + sciname_field: + type: string + title: Scientific name field name + examples: [scientific_name, name] +query: | + // Search using the fulltext index on scientific_name + // Don't limit the results yet so we can get the total_count below + LET results = ( + FOR doc IN FULLTEXT(@@taxon_coll, @sciname_field, @search_text) + // Filter non-expired docs + FILTER doc.created <= @ts AND doc.expired >= @ts + FILTER LENGTH(@ranks) > 0 ? + (@include_strains ? (doc.rank in @ranks OR doc.strain) : doc.rank in @ranks) : true + RETURN doc + ) + // Limit the results + LET limited = ( + FOR r IN results + LIMIT @offset, @limit + RETURN @select ? KEEP(r, @select) : r + ) + RETURN {results: limited, total_count: COUNT(results)} diff --git a/spec/test/stored_queries/test_ncbi_tax.py b/spec/test/stored_queries/test_ncbi_tax.py index 0c3e2fe7..9ca34215 100644 --- a/spec/test/stored_queries/test_ncbi_tax.py +++ b/spec/test/stored_queries/test_ncbi_tax.py @@ -13,6 +13,7 @@ _NOW = int(time.time() * 1000) +@unittest.skip('TODO remove me') class TestNcbiTax(unittest.TestCase): @classmethod diff --git a/spec/test/stored_queries/test_taxonomy.py b/spec/test/stored_queries/test_taxonomy.py new file mode 100644 index 00000000..7d61e011 --- /dev/null +++ b/spec/test/stored_queries/test_taxonomy.py @@ -0,0 +1,184 @@ +""" +Tests for the ncbi taxonomy stored queries. +""" +import json +import time +import unittest +import requests + +from test.helpers import get_config +from test.stored_queries.helpers import create_test_docs + +_CONF = get_config() +_NOW = int(time.time() * 1000) + + +class TestTaxonomy(unittest.TestCase): + + @classmethod + def setUpClass(cls): + """Create test documents""" + taxon_docs = [ + {'_key': '1', 'scientific_name': 'Bacteria', 'rank': 'Domain', 'strain': False}, + {'_key': '2', 'scientific_name': 'Firmicutes', 'rank': 'Phylum', 'strain': False}, + {'_key': '3', 'scientific_name': 'Bacilli', 'rank': 'Class', 'strain': False}, + {'_key': '4', 'scientific_name': 'Proteobacteria', 'rank': 'Phylum', 'strain': False}, + {'_key': '5', 'scientific_name': 'Alphaproteobacteria', 'rank': 'Class', 'strain': False}, + {'_key': '6', 'scientific_name': 'Gammaproteobacteria', 'rank': 'Class', 'strain': False}, + {'_key': '7', 'scientific_name': 'Deltaproteobacteria', 'rank': 'Class', 'strain': False}, + {'_key': '8', 'scientific_name': 'Bacillus subtilis 168', 'rank': 'no rank', 'strain': True}, + ] + child_docs = [ + {'_from': 'ncbi_taxon/2', '_to': 'ncbi_taxon/1', 'from': '2', 'to': '1', 'id': '2'}, + {'_from': 'ncbi_taxon/4', '_to': 'ncbi_taxon/1', 'from': '4', 'to': '1', 'id': '4'}, + {'_from': 'ncbi_taxon/3', '_to': 'ncbi_taxon/2', 'from': '3', 'to': '2', 'id': '3'}, + {'_from': 'ncbi_taxon/5', '_to': 'ncbi_taxon/4', 'from': '5', 'to': '4', 'id': '5'}, + {'_from': 'ncbi_taxon/6', '_to': 'ncbi_taxon/4', 'from': '6', 'to': '4', 'id': '6'}, + {'_from': 'ncbi_taxon/7', '_to': 'ncbi_taxon/4', 'from': '7', 'to': '4', 'id': '7'}, + # a few levels missing here + {'_from': 'ncbi_taxon/8', '_to': 'ncbi_taxon/3', 'from': '8', 'to': '3', 'id': '8'}, + ] + obj_ver_docs = [ + _construct_ws_obj_ver(1, 1, 1, is_public=True), + _construct_ws_obj_ver(1, 1, 2, is_public=True), + _construct_ws_obj_ver(2, 1, 1, is_public=False), + ] + obj_docs = [ + _construct_ws_obj(1, 1, is_public=True), + _construct_ws_obj(2, 1, is_public=False), + ] + obj_to_taxa_docs = [ + {'_from': 'ws_object_version/1:1:1', '_to': 'ncbi_taxon/1', 'assigned_by': 'assn1'}, + {'_from': 'ws_object_version/1:1:2', '_to': 'ncbi_taxon/1', 'assigned_by': 'assn2'}, + {'_from': 'ws_object_version/2:1:1', '_to': 'ncbi_taxon/1', 'assigned_by': 'assn2'}, + ] + # Create workspace objects associated to taxa + ws_docs = [ + _ws_defaults({'_key': '1', 'is_public': True}), + _ws_defaults({'_key': '2', 'is_public': False}), + ] + ws_to_obj = [ + {'_from': 'ws_workspace/1', '_to': 'ws_object/1:1'}, + {'_from': 'ws_workspace/2', '_to': 'ws_object/2:1'}, + ] + ws_type_version_docs = [ + {'_key': 'KBaseGenomes.Genome-99.77', 'module_name': 'KBaseGenomes', + 'type_name': 'Genome', 'maj_ver': 99, 'min_ver': 77} + ] + ws_obj_instance_of_type_docs = [ + {'_from': 'ws_object_version/1:1:1', '_to': 'ws_type_version/KBaseGenomes.Genome-99.77'}, + {'_from': 'ws_object_version/1:1:2', '_to': 'ws_type_version/KBaseGenomes.Genome-99.77'} + ] + _create_delta_test_docs('ncbi_taxon', taxon_docs) + _create_delta_test_docs('ncbi_child_of_taxon', child_docs, edge=True) + create_test_docs('ws_obj_version_has_taxon', obj_to_taxa_docs) + create_test_docs('ws_object', obj_docs) + create_test_docs('ws_workspace', ws_docs) + create_test_docs('ws_workspace_contains_obj', ws_to_obj) + create_test_docs('ws_object_version', obj_ver_docs) + create_test_docs('ws_obj_instance_of_type', ws_obj_instance_of_type_docs) + create_test_docs('ws_type_version', ws_type_version_docs) + + def test_get_lineage_valid(self): + """Test a valid query of taxon lineage.""" + resp = requests.post( + _CONF['re_api_url'] + '/api/v1/query_results', + params={'stored_query': 'taxonomy_get_lineage'}, + data=json.dumps({ + 'ts': _NOW, + 'id': '7', + 'select': ['rank', 'scientific_name'], + '@taxon_coll': 'ncbi_taxon', + '@child_of_coll': 'ncbi_child_of_taxon' + }), + ).json() + self.assertEqual(resp['count'], 2) + ranks = [r['rank'] for r in resp['results']] + names = [r['scientific_name'] for r in resp['results']] + self.assertEqual(ranks, ['Domain', 'Phylum']) + self.assertEqual(names, ['Bacteria', 'Proteobacteria']) + + +# -- Test helpers + +def _run_search_sciname(self, ranks, include_strains, expected_count, expected_sci_names): + """ + Helper to run the ncbi_taxon_search_sci_name query and make some standard + assertions on the response. + """ + data = { + 'ts': _NOW, + 'search_text': "prefix:bac" + } + if ranks is not None: + data['ranks'] = ranks + if include_strains is not None: + data['include_strains'] = include_strains + resp = requests.post( + _CONF['re_api_url'] + '/api/v1/query_results', + params={'stored_query': 'ncbi_taxon_search_sci_name'}, + data=json.dumps(data) + ).json() + result = resp['results'][0] + self.assertEqual(result['total_count'], expected_count) + names = {r['scientific_name'] for r in result['results']} + self.assertEqual(names, expected_sci_names) + + +def _ws_defaults(data): + """Set some defaults for the required workspace fields.""" + defaults = { + 'owner': 'owner', + 'max_obj_id': 1, + 'lock_status': 'n', + 'name': 'wsname', + 'mod_epoch': 1, + 'is_public': True, + 'is_deleted': False, + 'metadata': {'narrative_nice_name': 'narrname'}, + } + # Merge the data with the above defaults + return dict(defaults, **data) + + +def _construct_ws_obj_ver(wsid, objid, ver, is_public=False): + """Test helper to create a ws_object_version vertex.""" + return { + '_key': f"{wsid}:{objid}:{ver}", + 'workspace_id': wsid, + 'object_id': objid, + 'version': ver, + 'name': f'obj_name{objid}', + 'hash': 'xyz', + 'size': 100, + 'epoch': 0, + 'deleted': False, + 'is_public': is_public, + } + + +def _construct_ws_obj(wsid, objid, is_public=False): + """Test helper to create a ws_object vertex.""" + return { + '_key': f"{wsid}:{objid}", + 'workspace_id': wsid, + 'object_id': objid, + 'deleted': False, + 'is_public': is_public, + } + + +def _create_delta_test_docs(coll_name, docs, edge=False): + """Add in delta required fields.""" + if edge: + for doc in docs: + # Replicate the time-travel system by just setting 'from' and 'to' to the keys + doc['from'] = doc['_from'].split('/')[1] + doc['to'] = doc['_to'].split('/')[1] + else: + for doc in docs: + doc['id'] = doc['_key'] + for doc in docs: + doc['expired'] = 9007199254740991 + doc['created'] = 0 + create_test_docs(coll_name, docs) diff --git a/spec/test/validate.py b/spec/test/validate.py index 1fb9de47..1ef61abd 100644 --- a/spec/test/validate.py +++ b/spec/test/validate.py @@ -120,7 +120,7 @@ def validate_stored_queries(): # Params must be of type 'object' if data['params'].get('type') != 'object': _fatal("Params schema must have type 'object'") - query = data['query'] + query = data.get('query_prefix', '') + ' ' + data['query'] # Parse the AQL query on arangodb url = _CONF['db_url'] + '/_api/query' resp = requests.post(url, data=json.dumps({'query': query}), auth=_CONF['db_auth']) From a545ac679033145525122b6cec761c1aea18eb26 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Fri, 13 Mar 2020 16:41:04 -0700 Subject: [PATCH 473/732] Add all tests for generic taxonomy querying --- spec/test/stored_queries/test_taxonomy.py | 394 +++++++++++++++++++++- 1 file changed, 389 insertions(+), 5 deletions(-) diff --git a/spec/test/stored_queries/test_taxonomy.py b/spec/test/stored_queries/test_taxonomy.py index 7d61e011..6769c339 100644 --- a/spec/test/stored_queries/test_taxonomy.py +++ b/spec/test/stored_queries/test_taxonomy.py @@ -6,7 +6,7 @@ import unittest import requests -from test.helpers import get_config +from test.helpers import get_config, assert_subset from test.stored_queries.helpers import create_test_docs _CONF = get_config() @@ -89,7 +89,7 @@ def test_get_lineage_valid(self): 'id': '7', 'select': ['rank', 'scientific_name'], '@taxon_coll': 'ncbi_taxon', - '@child_of_coll': 'ncbi_child_of_taxon' + '@taxon_child_of': 'ncbi_child_of_taxon' }), ).json() self.assertEqual(resp['count'], 2) @@ -98,17 +98,401 @@ def test_get_lineage_valid(self): self.assertEqual(ranks, ['Domain', 'Phylum']) self.assertEqual(names, ['Bacteria', 'Proteobacteria']) + def test_get_children(self): + """Test a valid query of taxon descendants.""" + resp = requests.post( + _CONF['re_api_url'] + '/api/v1/query_results', + params={'stored_query': 'taxonomy_get_children'}, + data=json.dumps({ + 'id': '1', + 'ts': _NOW, + 'search_text': 'firmicutes,|proteobacteria', + 'select': ['rank', 'scientific_name'], + 'sciname_field': 'scientific_name', + '@taxon_coll': 'ncbi_taxon', + '@taxon_child_of': 'ncbi_child_of_taxon', + }), + ).json() + result = resp['results'][0] + self.assertEqual(result['total_count'], 2) + ranks = {r['rank'] for r in result['results']} + names = [r['scientific_name'] for r in result['results']] + self.assertEqual(ranks, {'Phylum'}) + self.assertEqual(names, ['Firmicutes', 'Proteobacteria']) + + def test_get_children_cursor(self): + """Test a valid query to get children with a cursor.""" + resp = requests.post( + _CONF['re_api_url'] + '/api/v1/query_results', + params={'stored_query': 'taxonomy_get_children_cursor'}, + data=json.dumps({ + 'ts': _NOW, + 'id': '1', + '@taxon_coll': 'ncbi_taxon', + '@taxon_child_of': 'ncbi_child_of_taxon' + }) + ).json() + self.assertEqual(len(resp['results']), 2) + + def test_siblings_valid(self): + """Test a valid query for siblings.""" + # Querying from "Alphaproteobacteria" + resp = requests.post( + _CONF['re_api_url'] + '/api/v1/query_results', + params={'stored_query': 'taxonomy_get_siblings'}, + data=json.dumps({ + 'ts': _NOW, + 'id': '5', + 'select': ['rank', 'scientific_name'], + 'sciname_field': 'scientific_name', + '@taxon_coll': 'ncbi_taxon', + '@taxon_child_of': 'ncbi_child_of_taxon', + }) + ).json() + result = resp['results'][0] + self.assertEqual(result['total_count'], 2) + ranks = {r['rank'] for r in result['results']} + names = [r['scientific_name'] for r in result['results']] + self.assertEqual(ranks, {'Class'}) + self.assertEqual(names, ['Deltaproteobacteria', 'Gammaproteobacteria']) + + def test_siblings_root(self): + """Test a query for siblings on the root node with no parent.""" + resp = requests.post( + _CONF['re_api_url'] + '/api/v1/query_results', + params={'stored_query': 'taxonomy_get_siblings'}, + data=json.dumps({ + 'ts': _NOW, + 'id': '1', + 'sciname_field': 'scientific_name', + '@taxon_coll': 'ncbi_taxon', + '@taxon_child_of': 'ncbi_child_of_taxon', + }), # Querying from "Bacteria" + ).json() + self.assertEqual(resp['results'][0]['total_count'], 0) + + def test_siblings_nonexistent_node(self): + """Test a query for siblings on the root node with no parent.""" + resp = requests.post( + _CONF['re_api_url'] + '/api/v1/query_results', + params={'stored_query': 'taxonomy_get_siblings'}, + data=json.dumps({ + 'ts': _NOW, + 'id': 'xyz', # Nonexistent node + 'sciname_field': 'scientific_name', + '@taxon_coll': 'ncbi_taxon', + '@taxon_child_of': 'ncbi_child_of_taxon', + }) + ).json() + self.assertEqual(resp['results'][0]['total_count'], 0) + + def test_search_sciname_prefix(self): + """Test a query to search sciname.""" + resp = requests.post( + _CONF['re_api_url'] + '/api/v1/query_results', + params={'stored_query': 'taxonomy_search_sci_name'}, + data=json.dumps({ + 'ts': _NOW, + 'search_text': 'prefix:bact', + 'select': ['scientific_name'], + 'sciname_field': 'scientific_name', + '@taxon_coll': 'ncbi_taxon', + }), + ).json() + result = resp['results'][0] + self.assertEqual(result['total_count'], 1) + self.assertEqual(result['results'][0]['scientific_name'], 'Bacteria') + + def test_search_sciname_nonexistent(self): + """Test a query to search sciname for empty results.""" + resp = requests.post( + _CONF['re_api_url'] + '/api/v1/query_results', + params={'stored_query': 'taxonomy_search_sci_name'}, + data=json.dumps({ + 'ts': _NOW, + 'search_text': 'xyzabc', + 'sciname_field': 'scientific_name', + '@taxon_coll': 'ncbi_taxon' + }), + ).json() + self.assertEqual(resp['results'][0]['total_count'], 0) + + def test_search_sciname_wrong_type(self): + """Test a query to search sciname with the wrong type for the search_text param.""" + resp = requests.post( + _CONF['re_api_url'] + '/api/v1/query_results', + params={'stored_query': 'taxonomy_search_sci_name'}, + data=json.dumps({ + 'ts': _NOW, + 'search_text': 123, + '@taxon_coll': 'ncbi_taxon', + 'sciname_field': 'scientific_name', + }) + ) + self.assertEqual(resp.status_code, 400) + self.assertEqual(resp.json()['error'], "123 is not of type 'string'") + + def test_search_sciname_missing_search(self): + """Test a query to search sciname with the search_text param missing.""" + resp = requests.post( + _CONF['re_api_url'] + '/api/v1/query_results', + params={'stored_query': 'taxonomy_search_sci_name'}, + data=json.dumps({'ts': _NOW, '@taxon_coll': 'ncbi_taxon'}) + ) + self.assertEqual(resp.status_code, 400) + self.assertEqual(resp.json()['error'], "'search_text' is a required property") + + def test_search_sciname_more_complicated(self): + """Test a query to search sciname with some more keyword options.""" + resp = requests.post( + _CONF['re_api_url'] + '/api/v1/query_results', + params={'stored_query': 'taxonomy_search_sci_name'}, + data=json.dumps({ + 'ts': _NOW, + 'search_text': "prefix:gamma,|prefix:alpha,|prefix:delta", + 'sciname_field': 'scientific_name', + '@taxon_coll': 'ncbi_taxon', + }) + ).json() + result = resp['results'][0] + self.assertEqual(result['total_count'], 3) + names = {r['scientific_name'] for r in result['results']} + self.assertEqual(names, {'Gammaproteobacteria', 'Alphaproteobacteria', 'Deltaproteobacteria'}) + + def test_search_sciname_offset_max(self): + """Test a query to search sciname with an invalid offset (greater than max).""" + resp = requests.post( + _CONF['re_api_url'] + '/api/v1/query_results', + params={'stored_query': 'taxonomy_search_sci_name'}, + data=json.dumps({ + 'ts': _NOW, + 'search_text': "prefix:bact", + "offset": 100001, + '@taxon_coll': 'ncbi_taxon', + 'sciname_field': 'scientific_name', + }) + ) + self.assertEqual(resp.status_code, 400) + self.assertEqual(resp.json()['error'], "100001 is greater than the maximum of 100000") + + def test_search_sciname_limit_max(self): + """Test a query to search sciname with an invalid offset (greater than max).""" + resp = requests.post( + _CONF['re_api_url'] + '/api/v1/query_results', + params={'stored_query': 'taxonomy_search_sci_name'}, + data=json.dumps({ + 'ts': _NOW, + 'search_text': "prefix:bact", + "limit": 1001, + '@taxon_coll': 'ncbi_taxon', + 'sciname_field': 'scientific_name', + }) + ) + self.assertEqual(resp.status_code, 400) + self.assertEqual(resp.json()['error'], "1001 is greater than the maximum of 1000") + + def test_search_sciname_limit_ranks_implicit_defaults(self): + """ Test queries where the results are limited by the rank or strain flag. """ + _run_search_sciname( + self, + ranks=None, + include_strains=None, + expected_count=3, + expected_sci_names={'Bacteria', 'Bacilli', 'Bacillus subtilis 168'}) + + def test_search_sciname_limit_ranks_explicit_defaults(self): + """ Test queries where the results are limited by the rank or strain flag. """ + _run_search_sciname( + self, + ranks=[], + include_strains=False, + expected_count=3, + expected_sci_names={'Bacteria', 'Bacilli', 'Bacillus subtilis 168'}) + + def test_search_sciname_limit_ranks_2(self): + """ Test queries where the results are limited by the rank or strain flag. """ + _run_search_sciname( + self, + ranks=['Domain', 'Class'], + include_strains=None, + expected_count=2, + expected_sci_names={'Bacteria', 'Bacilli'}) + + def test_search_sciname_limit_ranks_1(self): + """ Test queries where the results are limited by the rank or strain flag. """ + _run_search_sciname( + self, + ranks=['Class'], + include_strains=None, + expected_count=1, + expected_sci_names={'Bacilli'}) + + def test_search_sciname_limit_ranks_1_with_strain(self): + """ Test queries where the results are limited by the rank or strain flag. """ + _run_search_sciname( + self, + ranks=['Class'], + include_strains=True, + expected_count=2, + expected_sci_names={'Bacilli', 'Bacillus subtilis 168'}) + + def test_search_sciname_limit_ranks_1_with_false_strain(self): + """ Test queries where the results are limited by the rank or strain flag. """ + _run_search_sciname( + self, + ranks=['Class'], + include_strains=False, + expected_count=1, + expected_sci_names={'Bacilli'}) + + def test_select_fields(self): + """Test that the 'select' works properly for one query.""" + resp = requests.post( + _CONF['re_api_url'] + '/api/v1/query_results', + params={'stored_query': 'taxonomy_get_lineage'}, + data=json.dumps({ + 'ts': _NOW, + 'id': '7', + 'select': ['rank'], + '@taxon_coll': 'ncbi_taxon', + '@taxon_child_of': 'ncbi_child_of_taxon', + }) + ).json() + self.assertEqual(resp['count'], 2) + self.assertEqual(resp['results'], [ + {'rank': 'Domain'}, + {'rank': 'Phylum'} + ]) + + def test_fetch_taxon(self): + """Test a valid query to fetch a taxon.""" + resp = requests.post( + _CONF['re_api_url'] + '/api/v1/query_results', + params={'stored_query': 'taxonomy_fetch_taxon'}, + data=json.dumps({'ts': _NOW, 'id': '1', '@taxon_coll': 'ncbi_taxon'}) + ).json() + self.assertEqual(resp['count'], 1) + self.assertEqual(resp['results'][0]['id'], '1') + + def test_get_associated_objs(self): + """ + Test a valid query to get associated objects for a taxon. + Two objects are public and one is private, so total_count will be 3 while only the public objects are returned. + """ + resp = requests.post( + _CONF['re_api_url'] + '/api/v1/query_results', + params={'stored_query': 'taxonomy_get_associated_ws_objects'}, + data=json.dumps({ + 'ts': _NOW, + 'taxon_id': '1', + 'select_obj': ['_id', 'type', 'ws_info'], + 'select_edge': ['assigned_by'], + '@taxon_coll': 'ncbi_taxon', + }), + ).json() + self.assertEqual(resp['count'], 1) + results = resp['results'][0] + self.assertEqual(results['total_count'], 3) + self.assertEqual(len(results['results']), 2) + assignments = {ret['edge']['assigned_by'] for ret in results['results']} + ids = {ret['ws_obj']['_id'] for ret in results['results']} + self.assertEqual(assignments, {'assn1', 'assn2'}) + self.assertEqual(ids, {'ws_object_version/1:1:1', 'ws_object_version/1:1:2'}) + self.assertEqual(results['results'][0]['ws_obj']['type'], { + 'type_name': 'Genome', + 'module_name': 'KBaseGenomes', + 'maj_ver': 99, + 'min_ver': 77, + '_key': 'KBaseGenomes.Genome-99.77' + }) + self.assertEqual(results['results'][0]['ws_obj']['ws_info'], { + 'owner': 'owner', + 'metadata': {'narrative_nice_name': 'narrname'}, + 'is_public': True, + 'mod_epoch': 1 + }) + + def test_get_taxon_from_ws_obj(self): + """Fetch the taxon vertex from a workspace versioned id.""" + resp = requests.post( + _CONF['re_api_url'] + '/api/v1/query_results', + params={'stored_query': 'taxonomy_get_taxon_from_ws_obj'}, + data=json.dumps({'ts': _NOW, 'obj_ref': '1:1:1', '@taxon_coll': 'ncbi_taxon'}) + ).json() + self.assertEqual(resp['count'], 1) + assert_subset(self, { + 'id': '1', + 'scientific_name': 'Bacteria', + 'rank': 'Domain' + }, resp['results'][0]) + + def test_fetch_taxon_by_sciname(self): + """Test the ncbi_fetch_taxon_by_sciname query.""" + sciname = 'Deltaproteobacteria' + resp = requests.post( + _CONF['re_api_url'] + '/api/v1/query_results', + params={'stored_query': 'taxonomy_fetch_taxon_by_sciname'}, + data=json.dumps({ + 'ts': _NOW, + 'sciname': 'Deltaproteobacteria', + 'sciname_field': 'scientific_name', + '@taxon_coll': 'ncbi_taxon' + }) + ).json() + self.assertEqual(resp['count'], 1) + assert_subset(self, { + 'id': '7', + 'scientific_name': sciname, + 'rank': 'Class', + }, resp['results'][0]) + + def test_fetch_taxon_by_sciname_failures(self): + """Test invalid cases for ncbi_fetch_taxon_by_sciname.""" + # No sciname + resp = requests.post( + _CONF['re_api_url'] + '/api/v1/query_results', + params={'stored_query': 'taxonomy_fetch_taxon_by_sciname'}, + data=json.dumps({'ts': _NOW, 'sciname_field': 'scientific_name', '@taxon_coll': 'ncbi_taxon'}) + ).json() + self.assertEqual(resp['error'], "'sciname' is a required property") + # No ts + resp = requests.post( + _CONF['re_api_url'] + '/api/v1/query_results', + params={'stored_query': 'ncbi_fetch_taxon_by_sciname'}, + data=json.dumps({ + 'sciname': 'Deltaproteobacteria', + 'sciname_field': 'scientific_name', + '@taxon_coll': 'ncbi_taxon' + }) + ).json() + self.assertEqual(resp['error'], "'ts' is a required property") + # sciname not found + resp = requests.post( + _CONF['re_api_url'] + '/api/v1/query_results', + params={'stored_query': 'taxonomy_fetch_taxon_by_sciname'}, + data=json.dumps({ + 'ts': _NOW, + 'sciname': 'xyzabc', + 'sciname_field': 'scientific_name', + '@taxon_coll': 'ncbi_taxon', + }) + ).json() + self.assertEqual(resp['count'], 0) + self.assertEqual(len(resp['results']), 0) + # -- Test helpers def _run_search_sciname(self, ranks, include_strains, expected_count, expected_sci_names): """ - Helper to run the ncbi_taxon_search_sci_name query and make some standard + Helper to run the taxonomy_search_sci_name query and make some standard assertions on the response. """ data = { 'ts': _NOW, - 'search_text': "prefix:bac" + 'search_text': "prefix:bac", + '@taxon_coll': 'ncbi_taxon', + 'sciname_field': 'scientific_name', } if ranks is not None: data['ranks'] = ranks @@ -116,7 +500,7 @@ def _run_search_sciname(self, ranks, include_strains, expected_count, expected_s data['include_strains'] = include_strains resp = requests.post( _CONF['re_api_url'] + '/api/v1/query_results', - params={'stored_query': 'ncbi_taxon_search_sci_name'}, + params={'stored_query': 'taxonomy_search_sci_name'}, data=json.dumps(data) ).json() result = resp['results'][0] From fbc93860f2ebc20ef2076054020973762c7a726e Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Fri, 13 Mar 2020 16:42:09 -0700 Subject: [PATCH 474/732] Remove unused schema --- spec/schemas/taxonomy/child_of_taxon.yaml | 26 ----------------------- 1 file changed, 26 deletions(-) delete mode 100644 spec/schemas/taxonomy/child_of_taxon.yaml diff --git a/spec/schemas/taxonomy/child_of_taxon.yaml b/spec/schemas/taxonomy/child_of_taxon.yaml deleted file mode 100644 index 6a5a2bef..00000000 --- a/spec/schemas/taxonomy/child_of_taxon.yaml +++ /dev/null @@ -1,26 +0,0 @@ -name: child_of_taxon -type: edge -delta: true - -indexes: - - type: persistent - fields: [id, expired, created] - - type: persistent - fields: [expired, created, last_version] - -schema: - "$schema": http://json-schema.org/draft-07/schema# - type: object - required: [from, to, id] - description: Edges linking parent/child relationships between taxonomy vertices - properties: - id: - type: string - description: The id of the edge. This is the same as the from ID for NCBI. - from: - type: string - description: The child taxon. - to: - type: string - description: The parent taxon. - From 4af89c0f16ada5f0c631a44e6445363f2f23f46e Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Fri, 13 Mar 2020 16:43:43 -0700 Subject: [PATCH 475/732] Minor fixes --- spec/stored_queries/taxonomy/taxonomy_get_children_cursor.yaml | 2 +- spec/test/stored_queries/test_ncbi_tax.py | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/spec/stored_queries/taxonomy/taxonomy_get_children_cursor.yaml b/spec/stored_queries/taxonomy/taxonomy_get_children_cursor.yaml index 3320da29..1ec28f00 100644 --- a/spec/stored_queries/taxonomy/taxonomy_get_children_cursor.yaml +++ b/spec/stored_queries/taxonomy/taxonomy_get_children_cursor.yaml @@ -2,7 +2,7 @@ name: taxonomy_get_children_cursor params: type: object - required: [id, ts, "@taxon_coll"] + required: [id, ts, "@taxon_coll", "@taxon_child_of"] properties: "@taxon_coll": type: string diff --git a/spec/test/stored_queries/test_ncbi_tax.py b/spec/test/stored_queries/test_ncbi_tax.py index 9ca34215..0c3e2fe7 100644 --- a/spec/test/stored_queries/test_ncbi_tax.py +++ b/spec/test/stored_queries/test_ncbi_tax.py @@ -13,7 +13,6 @@ _NOW = int(time.time() * 1000) -@unittest.skip('TODO remove me') class TestNcbiTax(unittest.TestCase): @classmethod From 1f56bc50ba561f1ac8336cffcb594a5d7e3d6781 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Fri, 13 Mar 2020 17:34:22 -0700 Subject: [PATCH 476/732] Add fulltext index on gtdb_taxon.name --- spec/schemas/gtdb/gtdb_taxon.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spec/schemas/gtdb/gtdb_taxon.yaml b/spec/schemas/gtdb/gtdb_taxon.yaml index 04c8ba72..f1b0653a 100644 --- a/spec/schemas/gtdb/gtdb_taxon.yaml +++ b/spec/schemas/gtdb/gtdb_taxon.yaml @@ -3,6 +3,8 @@ type: vertex delta: true indexes: + - type: fulltext + fields: [name] - type: persistent fields: [id, expired, created] - type: persistent From 6ef7ca3246b56e42607edf8df6067578eea20e1f Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Mon, 16 Mar 2020 10:33:37 -0700 Subject: [PATCH 477/732] Add a small test for querying against gtdb using the same queries as ncbi --- spec/test/stored_queries/test_taxonomy.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/spec/test/stored_queries/test_taxonomy.py b/spec/test/stored_queries/test_taxonomy.py index 6769c339..32caff36 100644 --- a/spec/test/stored_queries/test_taxonomy.py +++ b/spec/test/stored_queries/test_taxonomy.py @@ -28,6 +28,9 @@ def setUpClass(cls): {'_key': '7', 'scientific_name': 'Deltaproteobacteria', 'rank': 'Class', 'strain': False}, {'_key': '8', 'scientific_name': 'Bacillus subtilis 168', 'rank': 'no rank', 'strain': True}, ] + gtdb_taxon_docs = [ + {'_key': '1', 'name': 'Bacteria', 'rank': 'Domain'}, + ] child_docs = [ {'_from': 'ncbi_taxon/2', '_to': 'ncbi_taxon/1', 'from': '2', 'to': '1', 'id': '2'}, {'_from': 'ncbi_taxon/4', '_to': 'ncbi_taxon/1', 'from': '4', 'to': '1', 'id': '4'}, @@ -70,6 +73,7 @@ def setUpClass(cls): {'_from': 'ws_object_version/1:1:2', '_to': 'ws_type_version/KBaseGenomes.Genome-99.77'} ] _create_delta_test_docs('ncbi_taxon', taxon_docs) + _create_delta_test_docs('gtdb_taxon', gtdb_taxon_docs) _create_delta_test_docs('ncbi_child_of_taxon', child_docs, edge=True) create_test_docs('ws_obj_version_has_taxon', obj_to_taxa_docs) create_test_docs('ws_object', obj_docs) @@ -203,6 +207,23 @@ def test_search_sciname_prefix(self): self.assertEqual(result['total_count'], 1) self.assertEqual(result['results'][0]['scientific_name'], 'Bacteria') + def test_search_sciname_gtdb(self): + """Test a search on scientific name against the gtdb taxonomy.""" + resp = requests.post( + _CONF['re_api_url'] + '/api/v1/query_results', + params={'stored_query': 'taxonomy_search_sci_name'}, + data=json.dumps({ + 'ts': _NOW, + 'search_text': 'prefix:bact', + 'select': ['name'], + 'sciname_field': 'name', + '@taxon_coll': 'gtdb_taxon', + }), + ).json() + result = resp['results'][0] + self.assertEqual(result['total_count'], 1) + self.assertEqual(result['results'][0]['name'], 'Bacteria') + def test_search_sciname_nonexistent(self): """Test a query to search sciname for empty results.""" resp = requests.post( From 7be8f6ee22eb52f4c667e1b0c0e3fb2ec7cfa348 Mon Sep 17 00:00:00 2001 From: Jason S Fillman <6155956+jsfillman@users.noreply.github.com> Date: Mon, 23 Mar 2020 15:30:57 -0700 Subject: [PATCH 478/732] Adding `LICENSE` --- spec/LICENSE.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 spec/LICENSE.md diff --git a/spec/LICENSE.md b/spec/LICENSE.md new file mode 100644 index 00000000..916a8c78 --- /dev/null +++ b/spec/LICENSE.md @@ -0,0 +1,7 @@ +Copyright (c) 2020 The KBase Project and its Contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. From 6bf4ed563d62a747be46841ce3d00291c53ab5df Mon Sep 17 00:00:00 2001 From: Jason S Fillman <6155956+jsfillman@users.noreply.github.com> Date: Tue, 24 Mar 2020 15:36:37 -0700 Subject: [PATCH 479/732] Create LICENSE.md --- spec/LICENSE.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 spec/LICENSE.md diff --git a/spec/LICENSE.md b/spec/LICENSE.md new file mode 100644 index 00000000..916a8c78 --- /dev/null +++ b/spec/LICENSE.md @@ -0,0 +1,7 @@ +Copyright (c) 2020 The KBase Project and its Contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. From c55a0ab8ef4b62f87b0cb35d96ae281075c98b5e Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 31 Mar 2020 16:35:47 -0700 Subject: [PATCH 480/732] Add option not to count results for search sciname query --- .../taxonomy/taxonomy_search_sci_name.yaml | 6 +++++- spec/test/stored_queries/test_taxonomy.py | 21 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/spec/stored_queries/taxonomy/taxonomy_search_sci_name.yaml b/spec/stored_queries/taxonomy/taxonomy_search_sci_name.yaml index d6175838..0e43164c 100644 --- a/spec/stored_queries/taxonomy/taxonomy_search_sci_name.yaml +++ b/spec/stored_queries/taxonomy/taxonomy_search_sci_name.yaml @@ -9,6 +9,10 @@ params: type: string title: Taxon collection name examples: [ncbi_taxon, gtdb_taxon] + no_count: + type: boolean + default: false + description: Skip the calculation of a total count of search results search_text: type: string title: Search text @@ -61,4 +65,4 @@ query: | LIMIT @offset, @limit RETURN @select ? KEEP(r, @select) : r ) - RETURN {results: limited, total_count: COUNT(results)} + RETURN @no_count ? {results: limited} : {results: limited, total_count: COUNT(results)} diff --git a/spec/test/stored_queries/test_taxonomy.py b/spec/test/stored_queries/test_taxonomy.py index 32caff36..b68cda41 100644 --- a/spec/test/stored_queries/test_taxonomy.py +++ b/spec/test/stored_queries/test_taxonomy.py @@ -190,6 +190,27 @@ def test_siblings_nonexistent_node(self): ).json() self.assertEqual(resp['results'][0]['total_count'], 0) + def test_search_sci_name_no_count(self): + """Test a valid query to search sciname without a count.""" + start = time.time() + resp = requests.post( + _CONF['re_api_url'] + '/api/v1/query_results', + params={'stored_query': 'taxonomy_search_sci_name'}, + data=json.dumps({ + 'ts': _NOW, + 'no_count': True, + 'search_text': 'prefix:bact', + 'select': ['scientific_name'], + 'sciname_field': 'scientific_name', + 'ranks': ['Domain'], + '@taxon_coll': 'ncbi_taxon', + }), + ).json() + print('Total time was', time.time() - start) + result = resp['results'][0] + self.assertTrue('total_count' not in result) + self.assertEqual(result['results'][0]['scientific_name'], 'Bacteria') + def test_search_sciname_prefix(self): """Test a query to search sciname.""" resp = requests.post( From 842cb1a41dfeaf38ee1244b20216efe90a22e722 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 1 Apr 2020 21:46:29 -0700 Subject: [PATCH 481/732] Add simpler (hopefully faster) query to search species/strains for RAST autocomplete --- .../taxonomy/taxonomy_search_sci_name.yaml | 6 +-- .../taxonomy/taxonomy_search_species.yaml | 39 +++++++++++++++++++ spec/test/stored_queries/test_taxonomy.py | 19 ++++----- 3 files changed, 47 insertions(+), 17 deletions(-) create mode 100644 spec/stored_queries/taxonomy/taxonomy_search_species.yaml diff --git a/spec/stored_queries/taxonomy/taxonomy_search_sci_name.yaml b/spec/stored_queries/taxonomy/taxonomy_search_sci_name.yaml index 0e43164c..d6175838 100644 --- a/spec/stored_queries/taxonomy/taxonomy_search_sci_name.yaml +++ b/spec/stored_queries/taxonomy/taxonomy_search_sci_name.yaml @@ -9,10 +9,6 @@ params: type: string title: Taxon collection name examples: [ncbi_taxon, gtdb_taxon] - no_count: - type: boolean - default: false - description: Skip the calculation of a total count of search results search_text: type: string title: Search text @@ -65,4 +61,4 @@ query: | LIMIT @offset, @limit RETURN @select ? KEEP(r, @select) : r ) - RETURN @no_count ? {results: limited} : {results: limited, total_count: COUNT(results)} + RETURN {results: limited, total_count: COUNT(results)} diff --git a/spec/stored_queries/taxonomy/taxonomy_search_species.yaml b/spec/stored_queries/taxonomy/taxonomy_search_species.yaml new file mode 100644 index 00000000..fe7eebd0 --- /dev/null +++ b/spec/stored_queries/taxonomy/taxonomy_search_species.yaml @@ -0,0 +1,39 @@ +# Search for a species/strain. Similar to search_sci_name, but simpler and quicker +name: taxonomy_search_species +params: + type: object + required: [search_text, ts, "@taxon_coll", sciname_field] + properties: + "@taxon_coll": + type: string + title: Taxon collection name + examples: [ncbi_taxon, gtdb_taxon] + search_text: + type: string + title: Search text + description: Text to search on for the scientific name + offset: + type: integer + default: 0 + maximum: 100000 + limit: + type: integer + default: 20 + maximum: 1000 + ts: + type: integer + title: Versioning timestamp + select: + type: [array, "null"] + items: {type: string} + description: Taxon fields to keep in the results + default: null + sciname_field: + type: string + title: Scientific name field name + examples: [scientific_name, name] +query: | + FOR doc IN FULLTEXT(@@taxon_coll, @sciname_field, @search_text) + FILTER doc.created <= @ts AND doc.expired >= @ts AND (doc.rank == "species" OR doc.strain) + LIMIT @offset, @limit + RETURN @select ? KEEP(doc, @select) : doc diff --git a/spec/test/stored_queries/test_taxonomy.py b/spec/test/stored_queries/test_taxonomy.py index b68cda41..fd3d7031 100644 --- a/spec/test/stored_queries/test_taxonomy.py +++ b/spec/test/stored_queries/test_taxonomy.py @@ -190,26 +190,21 @@ def test_siblings_nonexistent_node(self): ).json() self.assertEqual(resp['results'][0]['total_count'], 0) - def test_search_sci_name_no_count(self): - """Test a valid query to search sciname without a count.""" - start = time.time() + def test_search_species_valid(self): + """Test a valid query to search species/strains.""" resp = requests.post( _CONF['re_api_url'] + '/api/v1/query_results', - params={'stored_query': 'taxonomy_search_sci_name'}, + params={'stored_query': 'taxonomy_search_species'}, data=json.dumps({ 'ts': _NOW, - 'no_count': True, - 'search_text': 'prefix:bact', - 'select': ['scientific_name'], + 'search_text': 'subtilis', + 'select': ['_key'], 'sciname_field': 'scientific_name', - 'ranks': ['Domain'], '@taxon_coll': 'ncbi_taxon', }), ).json() - print('Total time was', time.time() - start) - result = resp['results'][0] - self.assertTrue('total_count' not in result) - self.assertEqual(result['results'][0]['scientific_name'], 'Bacteria') + self.assertEqual(len(resp['results']), 1) + self.assertEqual(resp['results'][0]['_key'], '8') def test_search_sciname_prefix(self): """Test a query to search sciname.""" From 6982761bdc736c63f8e11cfc1d480a9ecce634fa Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 1 Apr 2020 21:48:31 -0700 Subject: [PATCH 482/732] Add a simpler/quicker sciname search; revert search sciname query --- .../taxonomy/taxonomy_search_sci_name.yaml | 6 +++++- spec/test/stored_queries/test_taxonomy.py | 19 ++++++++++++------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/spec/stored_queries/taxonomy/taxonomy_search_sci_name.yaml b/spec/stored_queries/taxonomy/taxonomy_search_sci_name.yaml index d6175838..0e43164c 100644 --- a/spec/stored_queries/taxonomy/taxonomy_search_sci_name.yaml +++ b/spec/stored_queries/taxonomy/taxonomy_search_sci_name.yaml @@ -9,6 +9,10 @@ params: type: string title: Taxon collection name examples: [ncbi_taxon, gtdb_taxon] + no_count: + type: boolean + default: false + description: Skip the calculation of a total count of search results search_text: type: string title: Search text @@ -61,4 +65,4 @@ query: | LIMIT @offset, @limit RETURN @select ? KEEP(r, @select) : r ) - RETURN {results: limited, total_count: COUNT(results)} + RETURN @no_count ? {results: limited} : {results: limited, total_count: COUNT(results)} diff --git a/spec/test/stored_queries/test_taxonomy.py b/spec/test/stored_queries/test_taxonomy.py index fd3d7031..b68cda41 100644 --- a/spec/test/stored_queries/test_taxonomy.py +++ b/spec/test/stored_queries/test_taxonomy.py @@ -190,21 +190,26 @@ def test_siblings_nonexistent_node(self): ).json() self.assertEqual(resp['results'][0]['total_count'], 0) - def test_search_species_valid(self): - """Test a valid query to search species/strains.""" + def test_search_sci_name_no_count(self): + """Test a valid query to search sciname without a count.""" + start = time.time() resp = requests.post( _CONF['re_api_url'] + '/api/v1/query_results', - params={'stored_query': 'taxonomy_search_species'}, + params={'stored_query': 'taxonomy_search_sci_name'}, data=json.dumps({ 'ts': _NOW, - 'search_text': 'subtilis', - 'select': ['_key'], + 'no_count': True, + 'search_text': 'prefix:bact', + 'select': ['scientific_name'], 'sciname_field': 'scientific_name', + 'ranks': ['Domain'], '@taxon_coll': 'ncbi_taxon', }), ).json() - self.assertEqual(len(resp['results']), 1) - self.assertEqual(resp['results'][0]['_key'], '8') + print('Total time was', time.time() - start) + result = resp['results'][0] + self.assertTrue('total_count' not in result) + self.assertEqual(result['results'][0]['scientific_name'], 'Bacteria') def test_search_sciname_prefix(self): """Test a query to search sciname.""" From 6f771db51c2346139bdbfdc0cd32587c243a77c6 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 8 Apr 2020 11:46:42 -0700 Subject: [PATCH 483/732] Change data source name of "gtdb_taxonomy" to "gtdb" --- spec/data_sources/{gtdb_taxonomy.yaml => gtdb.yaml} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename spec/data_sources/{gtdb_taxonomy.yaml => gtdb.yaml} (91%) diff --git a/spec/data_sources/gtdb_taxonomy.yaml b/spec/data_sources/gtdb.yaml similarity index 91% rename from spec/data_sources/gtdb_taxonomy.yaml rename to spec/data_sources/gtdb.yaml index 8dd8e5af..0e114e1a 100644 --- a/spec/data_sources/gtdb_taxonomy.yaml +++ b/spec/data_sources/gtdb.yaml @@ -1,4 +1,4 @@ -name: gtdb_taxonomy +name: gtdb category: taxonomy title: GTDB Taxonomy home_url: https://gtdb.ecogenomic.org From afcf566a649711914304abac222b92c88ddffe39 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 8 Apr 2020 14:42:51 -0700 Subject: [PATCH 484/732] Change gtdb_taxon.name to gtdb_taxon.scientific_name --- spec/schemas/gtdb/gtdb_taxon.yaml | 8 ++++---- spec/test/stored_queries/test_taxonomy.py | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/spec/schemas/gtdb/gtdb_taxon.yaml b/spec/schemas/gtdb/gtdb_taxon.yaml index f1b0653a..33fa5fc1 100644 --- a/spec/schemas/gtdb/gtdb_taxon.yaml +++ b/spec/schemas/gtdb/gtdb_taxon.yaml @@ -4,7 +4,7 @@ delta: true indexes: - type: fulltext - fields: [name] + fields: [scientific_name] - type: persistent fields: [id, expired, created] - type: persistent @@ -14,7 +14,7 @@ schema: "$schema": http://json-schema.org/draft-07/schema# type: object description: Template for a vertex entry in the GTDB taxonomy tree. - required: [id, name, rank] + required: [id, scientific_name, rank] properties: id: type: string @@ -22,9 +22,9 @@ schema: with ':' and the taxon name with spaces replaced by underscores. For an organism node, it is the accession ID. examples: ['p:Firmicutes', 's:Sediminibacterium_sp002786355', 'RS_GCF_000169355.1'] - name: + scientific_name: type: string - description: The name of the taxon. For organisms this is the species name. + description: The name of the taxon examples: ['Firmicutes', 'Sediminibacterium sp002786355'] rank: type: string diff --git a/spec/test/stored_queries/test_taxonomy.py b/spec/test/stored_queries/test_taxonomy.py index b68cda41..1683c328 100644 --- a/spec/test/stored_queries/test_taxonomy.py +++ b/spec/test/stored_queries/test_taxonomy.py @@ -29,7 +29,7 @@ def setUpClass(cls): {'_key': '8', 'scientific_name': 'Bacillus subtilis 168', 'rank': 'no rank', 'strain': True}, ] gtdb_taxon_docs = [ - {'_key': '1', 'name': 'Bacteria', 'rank': 'Domain'}, + {'_key': '1', 'scientific_name': 'Bacteria', 'rank': 'Domain'}, ] child_docs = [ {'_from': 'ncbi_taxon/2', '_to': 'ncbi_taxon/1', 'from': '2', 'to': '1', 'id': '2'}, @@ -236,14 +236,14 @@ def test_search_sciname_gtdb(self): data=json.dumps({ 'ts': _NOW, 'search_text': 'prefix:bact', - 'select': ['name'], - 'sciname_field': 'name', + 'select': ['scientific_name'], + 'sciname_field': 'scientific_name', '@taxon_coll': 'gtdb_taxon', }), ).json() result = resp['results'][0] self.assertEqual(result['total_count'], 1) - self.assertEqual(result['results'][0]['name'], 'Bacteria') + self.assertEqual(result['results'][0]['scientific_name'], 'Bacteria') def test_search_sciname_nonexistent(self): """Test a query to search sciname for empty results.""" From 3e3ab2e3ed2692bc97ba8d4ea4324ed4f8b980e3 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Thu, 9 Apr 2020 12:20:51 -0700 Subject: [PATCH 485/732] Dont filter out expired taxon verts when fetching the taxon for a ws obj --- .../taxonomy/taxonomy_get_associated_ws_objects.yaml | 2 +- .../stored_queries/taxonomy/taxonomy_get_taxon_from_ws_obj.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/stored_queries/taxonomy/taxonomy_get_associated_ws_objects.yaml b/spec/stored_queries/taxonomy/taxonomy_get_associated_ws_objects.yaml index 46686b54..36540c0c 100644 --- a/spec/stored_queries/taxonomy/taxonomy_get_associated_ws_objects.yaml +++ b/spec/stored_queries/taxonomy/taxonomy_get_associated_ws_objects.yaml @@ -50,7 +50,7 @@ query: | LET results = ( FOR tax IN @@taxon_coll FILTER tax.id == @taxon_id - FILTER tax.created <= @ts AND tax.expired >= @ts + FILTER tax.created <= @ts LIMIT 1 FOR obj, e IN 1 INBOUND tax ws_obj_version_has_taxon FILTER obj.is_public OR obj.workspace_id IN ws_ids diff --git a/spec/stored_queries/taxonomy/taxonomy_get_taxon_from_ws_obj.yaml b/spec/stored_queries/taxonomy/taxonomy_get_taxon_from_ws_obj.yaml index fe81aa9b..d7bb93c1 100644 --- a/spec/stored_queries/taxonomy/taxonomy_get_taxon_from_ws_obj.yaml +++ b/spec/stored_queries/taxonomy/taxonomy_get_taxon_from_ws_obj.yaml @@ -20,7 +20,7 @@ query: | filter obj._key == @obj_ref filter obj.is_public or obj.workspace_id IN ws_ids for tax in 1 outbound obj ws_obj_version_has_taxon - filter tax.created <= @ts AND tax.expired >= @ts + filter tax.created <= @ts limit 1 return tax From e13e7e72a0640beb52cb0d8c121b167fd53cca0b Mon Sep 17 00:00:00 2001 From: Zhenyuan Lu Date: Mon, 13 Apr 2020 15:03:13 -0400 Subject: [PATCH 486/732] adding generic ontology queries --- .../generic_ontology_get_ancestors.yaml | 43 +++++++++++++++++++ .../generic_ontology_get_children.yaml | 42 ++++++++++++++++++ .../generic_ontology_get_descendants.yaml | 42 ++++++++++++++++++ .../generic_ontology_get_metadata.yaml | 24 +++++++++++ .../generic_ontology_get_parents.yaml | 42 ++++++++++++++++++ .../generic_ontology_get_terms.yaml | 27 ++++++++++++ 6 files changed, 220 insertions(+) create mode 100644 spec/stored_queries/generic_ontology/generic_ontology_get_ancestors.yaml create mode 100644 spec/stored_queries/generic_ontology/generic_ontology_get_children.yaml create mode 100644 spec/stored_queries/generic_ontology/generic_ontology_get_descendants.yaml create mode 100644 spec/stored_queries/generic_ontology/generic_ontology_get_metadata.yaml create mode 100644 spec/stored_queries/generic_ontology/generic_ontology_get_parents.yaml create mode 100644 spec/stored_queries/generic_ontology/generic_ontology_get_terms.yaml diff --git a/spec/stored_queries/generic_ontology/generic_ontology_get_ancestors.yaml b/spec/stored_queries/generic_ontology/generic_ontology_get_ancestors.yaml new file mode 100644 index 00000000..76283c8f --- /dev/null +++ b/spec/stored_queries/generic_ontology/generic_ontology_get_ancestors.yaml @@ -0,0 +1,43 @@ +# Get all ancestors (all parent's parents) for this term + +name: generic_ontology_get_ancestors +params: + type: object + required: [id, ts, onto_terms, onto_edges] + properties: + id: + type: string + title: Document ID + description: Ontology id of the term you want to get all the ancestors of + limit: + type: integer + default: 20 + description: Maximum result limit + maximum: 1000 + offset: + type: integer + default: 0 + description: Result offset for pagination + maximum: 100000 + ts: + type: integer + title: Versioning timestamp + onto_terms: + type: string + title: Ontology terms collection + onto_edges: + type: string + title: Ontology edges collection +query_prefix: WITH @@onto_terms +query: | + FOR t in @@onto_terms + FILTER t.id == @id + FILTER t.created <= @ts AND t.expired >= @ts + limit 1 + FOR v, e, p IN 1..100 OUTBOUND t @@onto_edges + FILTER p.edges[*].created ALL <= @ts + AND p.edges[*].expired ALL >= @ts + AND p.edges[*].type ALL == "is_a" + SORT v.id ASC + LIMIT @offset, @limit + RETURN {term: v, edge: e} diff --git a/spec/stored_queries/generic_ontology/generic_ontology_get_children.yaml b/spec/stored_queries/generic_ontology/generic_ontology_get_children.yaml new file mode 100644 index 00000000..7ce182bf --- /dev/null +++ b/spec/stored_queries/generic_ontology/generic_ontology_get_children.yaml @@ -0,0 +1,42 @@ +# Get the children of this term + +name: generic_ontology_get_children +params: + type: object + required: [id, ts, onto_terms, onto_edges] + properties: + id: + type: string + title: Document ID + description: Ontology id of the term you want to get the children of + limit: + type: integer + default: 20 + description: Maximum result limit + maximum: 1000 + offset: + type: integer + default: 0 + description: Result offset for pagination + maximum: 100000 + ts: + type: integer + title: Versioning timestamp + onto_terms: + type: string + title: Ontology terms collection + onto_edges: + type: string + title: Ontology edges collection +query_prefix: WITH @@onto_terms +query: | + FOR t in @@onto_terms + FILTER t.id == @id + FILTER t.created <= @ts AND t.expired >= @ts + limit 1 + FOR v, e IN 1..1 INBOUND t @@onto_edges + FILTER e.created <= @ts AND e.expired >= @ts + FILTER e.type == "is_a" + SORT v.id ASC + LIMIT @offset, @limit + RETURN {term: v, edge: e} diff --git a/spec/stored_queries/generic_ontology/generic_ontology_get_descendants.yaml b/spec/stored_queries/generic_ontology/generic_ontology_get_descendants.yaml new file mode 100644 index 00000000..040916bd --- /dev/null +++ b/spec/stored_queries/generic_ontology/generic_ontology_get_descendants.yaml @@ -0,0 +1,42 @@ +# Get all descendents of this term +name: generic_ontology_get_descendants +params: + type: object + required: [id, ts, onto_terms, onto_edges] + properties: + id: + type: string + title: Document ID + description: Ontology id of the term you want to get all the descendants of + limit: + type: integer + default: 20 + description: Maximum result limit + maximum: 1000 + offset: + type: integer + default: 0 + description: Result offset for pagination + maximum: 100000 + ts: + type: integer + title: Versioning timestamp + onto_terms: + type: string + title: Ontology terms collection + onto_edges: + type: string + title: Ontology edges collection +query_prefix: WITH @@onto_terms +query: | + FOR t in @@onto_terms + FILTER t.id == @id + FILTER t.created <= @ts AND t.expired >= @ts + limit 1 + FOR v, e, p IN 1..100 INBOUND t @@onto_edges + FILTER p.edges[*].created ALL <= @ts + AND p.edges[*].expired ALL >= @ts + AND p.edges[*].type ALL == "is_a" + SORT v._key ASC + LIMIT @offset, @limit + RETURN {term: v, edge: e} diff --git a/spec/stored_queries/generic_ontology/generic_ontology_get_metadata.yaml b/spec/stored_queries/generic_ontology/generic_ontology_get_metadata.yaml new file mode 100644 index 00000000..bf95da3a --- /dev/null +++ b/spec/stored_queries/generic_ontology/generic_ontology_get_metadata.yaml @@ -0,0 +1,24 @@ +# Get information/metadata of a particular ontology term (see spec for available fields) + +name: generic_ontology_get_metadata +params: + type: object + required: [id, ts, onto_terms] + properties: + id: + type: string + title: Document ID + description: Get information/metadata of a particular ontology term + ts: + type: integer + title: Versioning timestamp + onto_terms: + type: string + title: Ontology terms collection +query_prefix: WITH @@onto_terms +query: | + FOR t in @@onto_terms + FILTER t.id == @id + FILTER t.created <= @ts AND t.expired >= @ts + limit 1 + RETURN t diff --git a/spec/stored_queries/generic_ontology/generic_ontology_get_parents.yaml b/spec/stored_queries/generic_ontology/generic_ontology_get_parents.yaml new file mode 100644 index 00000000..48afb046 --- /dev/null +++ b/spec/stored_queries/generic_ontology/generic_ontology_get_parents.yaml @@ -0,0 +1,42 @@ +# Get the direct parents for a specific term + +name: generic_ontology_get_parents +params: + type: object + required: [id, ts, onto_terms, onto_edges] + properties: + id: + type: string + title: Document ID + description: Ontology id of the term you want to get all the direct parents of + limit: + type: integer + default: 20 + description: Maximum result limit + maximum: 1000 + offset: + type: integer + default: 0 + description: Result offset for pagination + maximum: 100000 + ts: + type: integer + title: Versioning timestamp + onto_terms: + type: string + title: Ontology terms collection + onto_edges: + type: string + title: Ontology edges collection +query_prefix: WITH @@onto_terms +query: | + FOR t in @@onto_terms + FILTER t.id == @id + FILTER t.created <= @ts AND t.expired >= @ts + limit 1 + FOR v, e IN 1..1 OUTBOUND t @@onto_edges + FILTER e.created <= @ts AND e.expired >= @ts + FILTER e.type == "is_a" + SORT v.id ASC + LIMIT @offset, @limit + RETURN {term: v, edge: e} diff --git a/spec/stored_queries/generic_ontology/generic_ontology_get_terms.yaml b/spec/stored_queries/generic_ontology/generic_ontology_get_terms.yaml new file mode 100644 index 00000000..4ddf56bc --- /dev/null +++ b/spec/stored_queries/generic_ontology/generic_ontology_get_terms.yaml @@ -0,0 +1,27 @@ +# Get a set of terms by the term ID and a timestamp, maximum 10000 + +name: generic_ontology_get_terms +params: + type: object + required: [ids, ts] + required: [id, ts, onto_terms] + properties: + ids: + type: array + items: + type: string + title: Ontology term IDs + description: The list of ontology term IDs to be fetched + maxItems: 10000 + ts: + type: integer + title: Versioning timestamp in milliseconds since the Unix epoch + onto_terms: + type: string + title: Ontology terms collection +query_prefix: WITH @@onto_terms +query: | + FOR t in @@onto_terms + FILTER t.id IN @ids + FILTER t.expired >= @ts AND t.created <= @ts + RETURN t From 364bbfe214794edece158ac07040bd9eea72fa83 Mon Sep 17 00:00:00 2001 From: Zhenyuan Lu Date: Mon, 13 Apr 2020 15:16:04 -0400 Subject: [PATCH 487/732] adding generic_ontology query --- .../generic_ontology_get_siblings.yaml | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 spec/stored_queries/generic_ontology/generic_ontology_get_siblings.yaml diff --git a/spec/stored_queries/generic_ontology/generic_ontology_get_siblings.yaml b/spec/stored_queries/generic_ontology/generic_ontology_get_siblings.yaml new file mode 100644 index 00000000..8c7301e5 --- /dev/null +++ b/spec/stored_queries/generic_ontology/generic_ontology_get_siblings.yaml @@ -0,0 +1,46 @@ +# Get all siblings of this term + +name: generic_ontology_get_siblings +params: + type: object + required: [id, ts, onto_terms, onto_edges] + properties: + id: + type: string + title: Document ID + description: Ontology id of the term you want to get all the siblings of + limit: + type: integer + default: 20 + description: Maximum result limit + maximum: 1000 + offset: + type: integer + default: 0 + description: Result offset for pagination + maximum: 100000 + ts: + type: integer + title: Versioning timestamp + onto_terms: + type: string + title: Ontology terms collection + onto_edges: + type: string + title: Ontology edges collection +query_prefix: WITH @@onto_terms +query: | + FOR t in @@onto_terms + FILTER t.id == @id + FILTER t.created <= @ts AND t.expired >= @ts + limit 1 + FOR v_parent, e_parent IN 1..1 OUTBOUND t @@onto_edges + FILTER e_parent.created <= @ts AND e_parent.expired >= @ts + FILTER e_parent.type == "is_a" + FOR v_child, e_child in 1..1 INBOUND v_parent @@onto_edges + FILTER e_child.created <= @ts AND e_child.expired >= @ts + FILTER e_child.type == "is_a" + FILTER v_child != t + SORT v_child.id ASC + LIMIT @offset, @limit + RETURN v_child From 41a658c82f721e3d5995067d845aba004266c955 Mon Sep 17 00:00:00 2001 From: Zhenyuan Lu Date: Mon, 13 Apr 2020 15:25:25 -0400 Subject: [PATCH 488/732] fix schema errors --- .../generic_ontology_get_ancestors.yaml | 10 +++++----- .../generic_ontology_get_children.yaml | 10 +++++----- .../generic_ontology_get_descendants.yaml | 10 +++++----- .../generic_ontology_get_metadata.yaml | 6 +++--- .../generic_ontology/generic_ontology_get_parents.yaml | 10 +++++----- .../generic_ontology_get_siblings.yaml | 10 +++++----- .../generic_ontology/generic_ontology_get_terms.yaml | 6 +++--- 7 files changed, 31 insertions(+), 31 deletions(-) diff --git a/spec/stored_queries/generic_ontology/generic_ontology_get_ancestors.yaml b/spec/stored_queries/generic_ontology/generic_ontology_get_ancestors.yaml index 76283c8f..cddd78ae 100644 --- a/spec/stored_queries/generic_ontology/generic_ontology_get_ancestors.yaml +++ b/spec/stored_queries/generic_ontology/generic_ontology_get_ancestors.yaml @@ -3,7 +3,7 @@ name: generic_ontology_get_ancestors params: type: object - required: [id, ts, onto_terms, onto_edges] + required: [id, ts, "@onto_terms", "@onto_edges"] properties: id: type: string @@ -22,12 +22,12 @@ params: ts: type: integer title: Versioning timestamp - onto_terms: + "@onto_terms": type: string - title: Ontology terms collection - onto_edges: + title: Ontology terms collection name + "@onto_edges": type: string - title: Ontology edges collection + title: Ontology edges collection name query_prefix: WITH @@onto_terms query: | FOR t in @@onto_terms diff --git a/spec/stored_queries/generic_ontology/generic_ontology_get_children.yaml b/spec/stored_queries/generic_ontology/generic_ontology_get_children.yaml index 7ce182bf..ee5e2684 100644 --- a/spec/stored_queries/generic_ontology/generic_ontology_get_children.yaml +++ b/spec/stored_queries/generic_ontology/generic_ontology_get_children.yaml @@ -3,7 +3,7 @@ name: generic_ontology_get_children params: type: object - required: [id, ts, onto_terms, onto_edges] + required: [id, ts, "@onto_terms", "@onto_edges"] properties: id: type: string @@ -22,12 +22,12 @@ params: ts: type: integer title: Versioning timestamp - onto_terms: + "@onto_terms": type: string - title: Ontology terms collection - onto_edges: + title: Ontology terms collection name + "@onto_edges": type: string - title: Ontology edges collection + title: Ontology edges collection name query_prefix: WITH @@onto_terms query: | FOR t in @@onto_terms diff --git a/spec/stored_queries/generic_ontology/generic_ontology_get_descendants.yaml b/spec/stored_queries/generic_ontology/generic_ontology_get_descendants.yaml index 040916bd..43613fe8 100644 --- a/spec/stored_queries/generic_ontology/generic_ontology_get_descendants.yaml +++ b/spec/stored_queries/generic_ontology/generic_ontology_get_descendants.yaml @@ -2,7 +2,7 @@ name: generic_ontology_get_descendants params: type: object - required: [id, ts, onto_terms, onto_edges] + required: [id, ts, "@onto_terms", "@onto_edges"] properties: id: type: string @@ -21,12 +21,12 @@ params: ts: type: integer title: Versioning timestamp - onto_terms: + "@onto_terms": type: string - title: Ontology terms collection - onto_edges: + title: Ontology terms collection name + "@onto_edges": type: string - title: Ontology edges collection + title: Ontology edges collection name query_prefix: WITH @@onto_terms query: | FOR t in @@onto_terms diff --git a/spec/stored_queries/generic_ontology/generic_ontology_get_metadata.yaml b/spec/stored_queries/generic_ontology/generic_ontology_get_metadata.yaml index bf95da3a..e680f18a 100644 --- a/spec/stored_queries/generic_ontology/generic_ontology_get_metadata.yaml +++ b/spec/stored_queries/generic_ontology/generic_ontology_get_metadata.yaml @@ -3,7 +3,7 @@ name: generic_ontology_get_metadata params: type: object - required: [id, ts, onto_terms] + required: [id, ts, "@onto_terms"] properties: id: type: string @@ -12,9 +12,9 @@ params: ts: type: integer title: Versioning timestamp - onto_terms: + "@onto_terms": type: string - title: Ontology terms collection + title: Ontology terms collection name query_prefix: WITH @@onto_terms query: | FOR t in @@onto_terms diff --git a/spec/stored_queries/generic_ontology/generic_ontology_get_parents.yaml b/spec/stored_queries/generic_ontology/generic_ontology_get_parents.yaml index 48afb046..9728dd3a 100644 --- a/spec/stored_queries/generic_ontology/generic_ontology_get_parents.yaml +++ b/spec/stored_queries/generic_ontology/generic_ontology_get_parents.yaml @@ -3,7 +3,7 @@ name: generic_ontology_get_parents params: type: object - required: [id, ts, onto_terms, onto_edges] + required: [id, ts, "@onto_terms", "@onto_edges"] properties: id: type: string @@ -22,12 +22,12 @@ params: ts: type: integer title: Versioning timestamp - onto_terms: + "@onto_terms": type: string - title: Ontology terms collection - onto_edges: + title: Ontology terms collection name + "@onto_edges": type: string - title: Ontology edges collection + title: Ontology edges collection name query_prefix: WITH @@onto_terms query: | FOR t in @@onto_terms diff --git a/spec/stored_queries/generic_ontology/generic_ontology_get_siblings.yaml b/spec/stored_queries/generic_ontology/generic_ontology_get_siblings.yaml index 8c7301e5..bcf70308 100644 --- a/spec/stored_queries/generic_ontology/generic_ontology_get_siblings.yaml +++ b/spec/stored_queries/generic_ontology/generic_ontology_get_siblings.yaml @@ -3,7 +3,7 @@ name: generic_ontology_get_siblings params: type: object - required: [id, ts, onto_terms, onto_edges] + required: [id, ts, "@onto_terms", "@onto_edges"] properties: id: type: string @@ -22,12 +22,12 @@ params: ts: type: integer title: Versioning timestamp - onto_terms: + "@onto_terms": type: string - title: Ontology terms collection - onto_edges: + title: Ontology terms collection name + "@onto_edges": type: string - title: Ontology edges collection + title: Ontology edges collection name query_prefix: WITH @@onto_terms query: | FOR t in @@onto_terms diff --git a/spec/stored_queries/generic_ontology/generic_ontology_get_terms.yaml b/spec/stored_queries/generic_ontology/generic_ontology_get_terms.yaml index 4ddf56bc..235195fb 100644 --- a/spec/stored_queries/generic_ontology/generic_ontology_get_terms.yaml +++ b/spec/stored_queries/generic_ontology/generic_ontology_get_terms.yaml @@ -4,7 +4,7 @@ name: generic_ontology_get_terms params: type: object required: [ids, ts] - required: [id, ts, onto_terms] + required: [id, ts, "@onto_terms",] properties: ids: type: array @@ -16,9 +16,9 @@ params: ts: type: integer title: Versioning timestamp in milliseconds since the Unix epoch - onto_terms: + "@onto_terms": type: string - title: Ontology terms collection + title: Ontology terms collection name query_prefix: WITH @@onto_terms query: | FOR t in @@onto_terms From f972c8aa5efd2d6676479992e9ac1d8242b0260c Mon Sep 17 00:00:00 2001 From: Zhenyuan Lu Date: Tue, 14 Apr 2020 13:55:01 -0400 Subject: [PATCH 489/732] rename generic_ontology* to ontology* --- .../ontology_get_ancestors.yaml} | 2 +- .../ontology_get_children.yaml} | 2 +- .../ontology_get_descendants.yaml} | 3 ++- .../ontology_get_metadata.yaml} | 2 +- .../ontology_get_parents.yaml} | 2 +- .../ontology_get_siblings.yaml} | 2 +- .../ontology_get_terms.yaml} | 2 +- 7 files changed, 8 insertions(+), 7 deletions(-) rename spec/stored_queries/{generic_ontology/generic_ontology_get_ancestors.yaml => ontology/ontology_get_ancestors.yaml} (96%) rename spec/stored_queries/{generic_ontology/generic_ontology_get_children.yaml => ontology/ontology_get_children.yaml} (96%) rename spec/stored_queries/{generic_ontology/generic_ontology_get_descendants.yaml => ontology/ontology_get_descendants.yaml} (96%) rename spec/stored_queries/{generic_ontology/generic_ontology_get_metadata.yaml => ontology/ontology_get_metadata.yaml} (94%) rename spec/stored_queries/{generic_ontology/generic_ontology_get_parents.yaml => ontology/ontology_get_parents.yaml} (96%) rename spec/stored_queries/{generic_ontology/generic_ontology_get_siblings.yaml => ontology/ontology_get_siblings.yaml} (97%) rename spec/stored_queries/{generic_ontology/generic_ontology_get_terms.yaml => ontology/ontology_get_terms.yaml} (95%) diff --git a/spec/stored_queries/generic_ontology/generic_ontology_get_ancestors.yaml b/spec/stored_queries/ontology/ontology_get_ancestors.yaml similarity index 96% rename from spec/stored_queries/generic_ontology/generic_ontology_get_ancestors.yaml rename to spec/stored_queries/ontology/ontology_get_ancestors.yaml index cddd78ae..01d65374 100644 --- a/spec/stored_queries/generic_ontology/generic_ontology_get_ancestors.yaml +++ b/spec/stored_queries/ontology/ontology_get_ancestors.yaml @@ -1,6 +1,6 @@ # Get all ancestors (all parent's parents) for this term -name: generic_ontology_get_ancestors +name: ontology_get_ancestors params: type: object required: [id, ts, "@onto_terms", "@onto_edges"] diff --git a/spec/stored_queries/generic_ontology/generic_ontology_get_children.yaml b/spec/stored_queries/ontology/ontology_get_children.yaml similarity index 96% rename from spec/stored_queries/generic_ontology/generic_ontology_get_children.yaml rename to spec/stored_queries/ontology/ontology_get_children.yaml index ee5e2684..06d6afb6 100644 --- a/spec/stored_queries/generic_ontology/generic_ontology_get_children.yaml +++ b/spec/stored_queries/ontology/ontology_get_children.yaml @@ -1,6 +1,6 @@ # Get the children of this term -name: generic_ontology_get_children +name: ontology_get_children params: type: object required: [id, ts, "@onto_terms", "@onto_edges"] diff --git a/spec/stored_queries/generic_ontology/generic_ontology_get_descendants.yaml b/spec/stored_queries/ontology/ontology_get_descendants.yaml similarity index 96% rename from spec/stored_queries/generic_ontology/generic_ontology_get_descendants.yaml rename to spec/stored_queries/ontology/ontology_get_descendants.yaml index 43613fe8..93ec7260 100644 --- a/spec/stored_queries/generic_ontology/generic_ontology_get_descendants.yaml +++ b/spec/stored_queries/ontology/ontology_get_descendants.yaml @@ -1,5 +1,6 @@ # Get all descendents of this term -name: generic_ontology_get_descendants + +name: ontology_get_descendants params: type: object required: [id, ts, "@onto_terms", "@onto_edges"] diff --git a/spec/stored_queries/generic_ontology/generic_ontology_get_metadata.yaml b/spec/stored_queries/ontology/ontology_get_metadata.yaml similarity index 94% rename from spec/stored_queries/generic_ontology/generic_ontology_get_metadata.yaml rename to spec/stored_queries/ontology/ontology_get_metadata.yaml index e680f18a..56294cc9 100644 --- a/spec/stored_queries/generic_ontology/generic_ontology_get_metadata.yaml +++ b/spec/stored_queries/ontology/ontology_get_metadata.yaml @@ -1,6 +1,6 @@ # Get information/metadata of a particular ontology term (see spec for available fields) -name: generic_ontology_get_metadata +name: ontology_get_metadata params: type: object required: [id, ts, "@onto_terms"] diff --git a/spec/stored_queries/generic_ontology/generic_ontology_get_parents.yaml b/spec/stored_queries/ontology/ontology_get_parents.yaml similarity index 96% rename from spec/stored_queries/generic_ontology/generic_ontology_get_parents.yaml rename to spec/stored_queries/ontology/ontology_get_parents.yaml index 9728dd3a..dd3f4f1f 100644 --- a/spec/stored_queries/generic_ontology/generic_ontology_get_parents.yaml +++ b/spec/stored_queries/ontology/ontology_get_parents.yaml @@ -1,6 +1,6 @@ # Get the direct parents for a specific term -name: generic_ontology_get_parents +name: ontology_get_parents params: type: object required: [id, ts, "@onto_terms", "@onto_edges"] diff --git a/spec/stored_queries/generic_ontology/generic_ontology_get_siblings.yaml b/spec/stored_queries/ontology/ontology_get_siblings.yaml similarity index 97% rename from spec/stored_queries/generic_ontology/generic_ontology_get_siblings.yaml rename to spec/stored_queries/ontology/ontology_get_siblings.yaml index bcf70308..9acf4a72 100644 --- a/spec/stored_queries/generic_ontology/generic_ontology_get_siblings.yaml +++ b/spec/stored_queries/ontology/ontology_get_siblings.yaml @@ -1,6 +1,6 @@ # Get all siblings of this term -name: generic_ontology_get_siblings +name: ontology_get_siblings params: type: object required: [id, ts, "@onto_terms", "@onto_edges"] diff --git a/spec/stored_queries/generic_ontology/generic_ontology_get_terms.yaml b/spec/stored_queries/ontology/ontology_get_terms.yaml similarity index 95% rename from spec/stored_queries/generic_ontology/generic_ontology_get_terms.yaml rename to spec/stored_queries/ontology/ontology_get_terms.yaml index 235195fb..a0161b8f 100644 --- a/spec/stored_queries/generic_ontology/generic_ontology_get_terms.yaml +++ b/spec/stored_queries/ontology/ontology_get_terms.yaml @@ -1,6 +1,6 @@ # Get a set of terms by the term ID and a timestamp, maximum 10000 -name: generic_ontology_get_terms +name: ontology_get_terms params: type: object required: [ids, ts] From 1eb900f4394e71c94a37e57c8018d555143b89d7 Mon Sep 17 00:00:00 2001 From: Zhenyuan Lu Date: Mon, 20 Apr 2020 11:27:22 -0400 Subject: [PATCH 490/732] update queries to make GO and ontology consistent --- spec/stored_queries/GO/GO_get_siblings.yaml | 2 +- spec/stored_queries/ontology/ontology_get_terms.yaml | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/spec/stored_queries/GO/GO_get_siblings.yaml b/spec/stored_queries/GO/GO_get_siblings.yaml index 679af15a..db1cf541 100644 --- a/spec/stored_queries/GO/GO_get_siblings.yaml +++ b/spec/stored_queries/GO/GO_get_siblings.yaml @@ -36,4 +36,4 @@ query: | FILTER v_child != t SORT v_child.id ASC LIMIT @offset, @limit - RETURN v_child.id + RETURN v_child diff --git a/spec/stored_queries/ontology/ontology_get_terms.yaml b/spec/stored_queries/ontology/ontology_get_terms.yaml index a0161b8f..69459be8 100644 --- a/spec/stored_queries/ontology/ontology_get_terms.yaml +++ b/spec/stored_queries/ontology/ontology_get_terms.yaml @@ -3,8 +3,7 @@ name: ontology_get_terms params: type: object - required: [ids, ts] - required: [id, ts, "@onto_terms",] + required: [ids, ts, "@onto_terms"] properties: ids: type: array From c8a8fb0d3f5787966f6ce79cb425d6ae666269fe Mon Sep 17 00:00:00 2001 From: Zhenyuan Lu Date: Wed, 29 Apr 2020 11:04:05 -0400 Subject: [PATCH 491/732] add more ontology queries --- .../ontology_get_hierarchicalAncestors.yaml | 46 +++++++++++++++++++ .../ontology_get_hierarchicalChildren.yaml | 41 +++++++++++++++++ .../ontology_get_hierarchicalDescendants.yaml | 45 ++++++++++++++++++ .../ontology_get_hierarchicalParents.yaml | 45 ++++++++++++++++++ .../ontology/ontology_get_related.yaml | 40 ++++++++++++++++ 5 files changed, 217 insertions(+) create mode 100644 spec/stored_queries/ontology/ontology_get_hierarchicalAncestors.yaml create mode 100644 spec/stored_queries/ontology/ontology_get_hierarchicalChildren.yaml create mode 100644 spec/stored_queries/ontology/ontology_get_hierarchicalDescendants.yaml create mode 100644 spec/stored_queries/ontology/ontology_get_hierarchicalParents.yaml create mode 100644 spec/stored_queries/ontology/ontology_get_related.yaml diff --git a/spec/stored_queries/ontology/ontology_get_hierarchicalAncestors.yaml b/spec/stored_queries/ontology/ontology_get_hierarchicalAncestors.yaml new file mode 100644 index 00000000..256459ac --- /dev/null +++ b/spec/stored_queries/ontology/ontology_get_hierarchicalAncestors.yaml @@ -0,0 +1,46 @@ +# Get all hierarchical ancestors +# (all parents’s parents) resources for this term. Hierarchical +# ancestors include is-a and other related parents, such as +# part-of/develops-from, that imply a hierarchical relationship + +name: ontology_get_hierarchicalAncestors +params: + type: object + required: [id, ts, "@onto_terms", "@onto_edges"] + properties: + id: + type: string + title: Document ID + description: Ontology id of the term you want to get all the hierarchical ancestors of + limit: + type: integer + default: 20 + description: Maximum result limit + maximum: 1000 + offset: + type: integer + default: 0 + description: Result offset for pagination + maximum: 100000 + ts: + type: integer + title: Versioning timestamp + "@onto_terms": + type: string + title: Ontology terms collection name + "@onto_edges": + type: string + title: Ontology edges collection name +query_prefix: WITH @@onto_terms +query: | + FOR t in @@onto_terms + FILTER t.id == @id + FILTER t.created <= @ts AND t.expired >= @ts + limit 1 + FOR v, e, p IN 1..100 OUTBOUND t @@onto_edges + FILTER p.edges[*].created ALL <= @ts + AND p.edges[*].expired ALL >= @ts + AND p.edges[*].type ALL != NULL + SORT v.id ASC + LIMIT @offset, @limit + RETURN {term: v, edge: e} diff --git a/spec/stored_queries/ontology/ontology_get_hierarchicalChildren.yaml b/spec/stored_queries/ontology/ontology_get_hierarchicalChildren.yaml new file mode 100644 index 00000000..1702816a --- /dev/null +++ b/spec/stored_queries/ontology/ontology_get_hierarchicalChildren.yaml @@ -0,0 +1,41 @@ +# Get the direct hierarchical children for this term. Hierarchical children include is-a and other related children, such as part-of/develops-from, that imply a hierarchical relationship +name: ontology_get_hierarchicalChildren +params: + type: object + required: [id, ts, "@onto_terms", "@onto_edges"] + properties: + id: + type: string + title: Document ID + description: Ontology id of the term you want to get the direct hierarchical children of + limit: + type: integer + default: 20 + description: Maximum result limit + maximum: 1000 + offset: + type: integer + default: 0 + description: Result offset for pagination + maximum: 100000 + ts: + type: integer + title: Versioning timestamp + "@onto_terms": + type: string + title: Ontology terms collection name + "@onto_edges": + type: string + title: Ontology edges collection name +query_prefix: WITH @@onto_terms +query: | + FOR t in @@onto_terms + FILTER t.id == @id + FILTER t.created <= @ts AND t.expired >= @ts + limit 1 + FOR v, e IN 1..1 INBOUND t @@onto_edges + FILTER e.created <= @ts AND e.expired >= @ts + FILTER e.type != NULL + SORT v.id ASC + LIMIT @offset, @limit + RETURN {term: v, edge: e} diff --git a/spec/stored_queries/ontology/ontology_get_hierarchicalDescendants.yaml b/spec/stored_queries/ontology/ontology_get_hierarchicalDescendants.yaml new file mode 100644 index 00000000..8c749d8e --- /dev/null +++ b/spec/stored_queries/ontology/ontology_get_hierarchicalDescendants.yaml @@ -0,0 +1,45 @@ +# Get all hierarchical descendants +# resources for this term. Hierarchical children include is-a +# and other related children, such as part-of/develops-from, +# that imply a hierarchical relationship +name: ontology_get_hierarchicalDescendants +params: + type: object + required: [id, ts, "@onto_terms", "@onto_edges"] + properties: + id: + type: string + title: Document ID + description: Ontology id of the term you want to get all the hierarchical descendants of + limit: + type: integer + default: 20 + description: Maximum result limit + maximum: 1000 + offset: + type: integer + default: 0 + description: Result offset for pagination + maximum: 100000 + ts: + type: integer + title: Versioning timestamp + "@onto_terms": + type: string + title: Ontology terms collection name + "@onto_edges": + type: string + title: Ontology edges collection name +query_prefix: WITH @@onto_terms +query: | + FOR t in @@onto_terms + FILTER t.id == @id + FILTER t.created <= @ts AND t.expired >= @ts + limit 1 + FOR v, e, p IN 1..100 INBOUND t @@onto_edges + FILTER p.edges[*].created ALL <= @ts + AND p.edges[*].expired ALL >= @ts + AND p.edges[*].type ALL != NULL + SORT v.id ASC + LIMIT @offset, @limit + RETURN {term: v, edge: e} diff --git a/spec/stored_queries/ontology/ontology_get_hierarchicalParents.yaml b/spec/stored_queries/ontology/ontology_get_hierarchicalParents.yaml new file mode 100644 index 00000000..8fd2f71b --- /dev/null +++ b/spec/stored_queries/ontology/ontology_get_hierarchicalParents.yaml @@ -0,0 +1,45 @@ +# Get the direct hierarchical parent +# resources for this term. Hierarchical parents include is-a and +# other related parents, such as part-of/develops-from, that imply +# a hierarchical relationship. + +name: ontology_get_hierarchicalParents +params: + type: object + required: [id, ts, "@onto_terms", "@onto_edges"] + properties: + id: + type: string + title: Document ID + description: Ontology id of the term you want to get all the hierarchical parents of + limit: + type: integer + default: 20 + description: Maximum result limit + maximum: 1000 + offset: + type: integer + default: 0 + description: Result offset for pagination + maximum: 100000 + ts: + type: integer + title: Versioning timestamp + "@onto_terms": + type: string + title: Ontology terms collection name + "@onto_edges": + type: string + title: Ontology edges collection name +query_prefix: WITH @@onto_terms +query: | + FOR t in @@onto_terms + FILTER t.id == @id + FILTER t.created <= @ts AND t.expired >= @ts + limit 1 + FOR v, e IN 1..1 OUTBOUND t @@onto_edges + FILTER e.created <= @ts AND e.expired >= @ts + FILTER e.type != NULL + SORT v.id ASC + LIMIT @offset, @limit + RETURN {term: v, edge: e} diff --git a/spec/stored_queries/ontology/ontology_get_related.yaml b/spec/stored_queries/ontology/ontology_get_related.yaml new file mode 100644 index 00000000..5d0adc9f --- /dev/null +++ b/spec/stored_queries/ontology/ontology_get_related.yaml @@ -0,0 +1,40 @@ +# Get all immediate related terms for this term +name: ontology_get_related +params: + type: object + required: [id, ts, "@onto_terms", "@onto_edges"] + properties: + id: + type: string + title: Document ID + description: Ontology id of the term you want to get all the directly related nodes of + limit: + type: integer + default: 20 + description: Maximum result limit + maximum: 1000 + offset: + type: integer + default: 0 + description: Result offset for pagination + maximum: 100000 + ts: + type: integer + title: Versioning timestamp + "@onto_terms": + type: string + title: Ontology terms collection name + "@onto_edges": + type: string + title: Ontology edges collection name +query_prefix: WITH @@onto_terms +query: | + FOR t in @@onto_terms + FILTER t.id == @id + FILTER t.created <= @ts AND t.expired >= @ts + limit 1 + FOR v, e IN 1 ANY t @@onto_edges + FILTER e.created <= @ts AND e.expired >= @ts + SORT v.id ASC + LIMIT @offset, @limit + RETURN {term: v, edge: e} From 59b6a06b59ae6cd8d09b5679ea4b0a5a32f19310 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Fri, 8 May 2020 12:46:12 -0700 Subject: [PATCH 492/732] Get the related objects workspace query working --- .../ws/ws_fetch_related_data.yaml | 69 ++++++++++++++ spec/test/stored_queries/test_taxonomy.py | 1 - spec/test/stored_queries/test_ws.py | 92 +++++++++++++++++++ 3 files changed, 161 insertions(+), 1 deletion(-) create mode 100644 spec/stored_queries/ws/ws_fetch_related_data.yaml create mode 100644 spec/test/stored_queries/test_ws.py diff --git a/spec/stored_queries/ws/ws_fetch_related_data.yaml b/spec/stored_queries/ws/ws_fetch_related_data.yaml new file mode 100644 index 00000000..d5d65d6d --- /dev/null +++ b/spec/stored_queries/ws/ws_fetch_related_data.yaml @@ -0,0 +1,69 @@ +name: ws_fetch_related_data +params: + type: object + required: [obj_key] + properties: + obj_key: + type: string + description: Key of the wsprov_object to search on + show_private: + type: boolean + description: limit to objects in workspaces that a user has access to + default: true + show_public: + type: boolean + description: limit to objects in public workspaces + default: true +query_prefix: WITH ws_type_version +query: | + LET obj_id = concat('ws_object_version/', @obj_key) + FOR obj IN ws_object_version + FILTER obj._id == obj_id + LET prov = ( + FOR v, e, p IN 1..10 ANY obj ws_prov_descendant_of + OPTIONS {bfs: true, uniqueVertices: 'global'} + LIMIT 1000 + FILTER v && !v.deleted + FILTER (@show_private && @show_public) + ? (v.is_public || v.workspace_id IN ws_ids) + : (!@show_private || v.workspace_id IN ws_ids) && (!@show_public || v.is_public) + let t = FIRST( + FOR t IN 1 OUTBOUND v ws_obj_instance_of_type + return t + ) + RETURN {data: v, type: t, hops: COUNT(p.edges)} + ) + let refs = ( + FOR v, e, p IN 1..10 ANY obj ws_refers_to + OPTIONS {bfs: true, uniqueVertices: 'global'} + LIMIT 1000 + FILTER v && !v.deleted + FILTER (@show_private && @show_public) + ? (v.is_public || v.workspace_id IN ws_ids) + : (!@show_private || v.workspace_id IN ws_ids) && (!@show_public || v.is_public) + let t = FIRST( + FOR t IN 1 OUTBOUND v ws_obj_instance_of_type + return t + ) + RETURN {data: v, type: t, hops: COUNT(p.edges)} + ) + let copies = ( + FOR v, e, p IN 1..10 ANY obj ws_copied_from + OPTIONS {bfs: true, uniqueVertices: 'global'} + LIMIT 1000 + FILTER v && !v.deleted + FILTER (@show_private && @show_public) + ? (v.is_public || v.workspace_id IN ws_ids) + : (!@show_private || v.workspace_id IN ws_ids) && (!@show_public || v.is_public) + let t = FIRST( + FOR t IN 1 OUTBOUND v ws_obj_instance_of_type + LIMIT 1 + return t + ) + RETURN {data: v, type: t, hops: COUNT(p.edges)} + ) + RETURN { + copies: {data: copies, count: COUNT(copies)}, + prov: {data: prov, count: COUNT(prov)}, + refs: {data: refs, count: COUNT(refs)} + } diff --git a/spec/test/stored_queries/test_taxonomy.py b/spec/test/stored_queries/test_taxonomy.py index 1683c328..2b4a9635 100644 --- a/spec/test/stored_queries/test_taxonomy.py +++ b/spec/test/stored_queries/test_taxonomy.py @@ -206,7 +206,6 @@ def test_search_sci_name_no_count(self): '@taxon_coll': 'ncbi_taxon', }), ).json() - print('Total time was', time.time() - start) result = resp['results'][0] self.assertTrue('total_count' not in result) self.assertEqual(result['results'][0]['scientific_name'], 'Bacteria') diff --git a/spec/test/stored_queries/test_ws.py b/spec/test/stored_queries/test_ws.py new file mode 100644 index 00000000..496862c1 --- /dev/null +++ b/spec/test/stored_queries/test_ws.py @@ -0,0 +1,92 @@ +""" +Tests for workspace workspace stored queries under the ws* namespace +""" +import unittest +import json +import requests +from test.stored_queries.helpers import create_test_docs + +from test.helpers import get_config + +_CONF = get_config() + + +def _ws_obj(wsid, objid, ver): + """Create data for a dummy test workspace obj""" + return { + '_key': ':'.join((str(n) for n in (wsid, objid, ver))), + 'name': 'obj', + 'workspace_id': wsid, + 'object_id': objid, + 'version': ver, + 'hash': 'x', + 'size': 0, + 'epoch': 0, + 'deleted': False, + 'is_public': True + } + + +class TestWs(unittest.TestCase): + + @classmethod + def setUpClass(cls): + """ + Create all test data. + """ + ws_object_version = [ + _ws_obj(1, 1, 1), # root/origin object + _ws_obj(1, 2, 1), # copy object + _ws_obj(1, 3, 1), # provenance object + _ws_obj(1, 4, 1), # reference object + ] + create_test_docs('ws_object_version', ws_object_version) + ws_type_version = [{'_key': 'Module.Type1-1.0'}] + create_test_docs('ws_type_version', ws_type_version) + ws_obj_instance_of_type = [ + {'_from': 'ws_object_version/1:2:1', '_to': 'ws_type_version/Module.Type1-1.0'}, + {'_from': 'ws_object_version/1:3:1', '_to': 'ws_type_version/Module.Type1-1.0'}, + {'_from': 'ws_object_version/1:4:1', '_to': 'ws_type_version/Module.Type1-1.0'}, + ] + create_test_docs('ws_obj_instance_of_type', ws_obj_instance_of_type) + ws_prov_descendant_of = [ + {'_from': 'ws_object_version/1:1:1', '_to': 'ws_object_version/1:3:1'} + ] + create_test_docs('ws_prov_descendant_of', ws_prov_descendant_of) + ws_refers_to = [ + {'_from': 'ws_object_version/1:1:1', '_to': 'ws_object_version/1:4:1'} + ] + create_test_docs('ws_refers_to', ws_refers_to) + ws_copied_from = [ + {'_from': 'ws_object_version/1:1:1', '_to': 'ws_object_version/1:2:1'} + ] + create_test_docs('ws_copied_from', ws_copied_from) + + def test_fetch_related_data_valid(self): + """Test for the basic happy path.""" + resp = requests.post( + _CONF['re_api_url'] + '/api/v1/query_results', + params={'stored_query': 'ws_fetch_related_data', 'show_public': True}, + data=json.dumps({'obj_key': '1:1:1'}) + ).json() + self.assertEqual(resp['count'], 1) + self.assertEqual(resp['has_more'], False) + res = resp['results'][0] + # Check the copy results + self.assertEqual(res['copies']['count'], 1) + self.assertEqual(len(res['copies']['data']), 1) + self.assertEqual(res['copies']['data'][0]['data']['_id'], 'ws_object_version/1:2:1') + self.assertEqual(res['copies']['data'][0]['hops'], 1) + self.assertEqual(res['copies']['data'][0]['type']['_id'], 'ws_type_version/Module.Type1-1.0') + # Check the provenance results + self.assertEqual(res['prov']['count'], 1) + self.assertEqual(len(res['prov']['data']), 1) + self.assertEqual(res['prov']['data'][0]['data']['_id'], 'ws_object_version/1:3:1') + self.assertEqual(res['prov']['data'][0]['hops'], 1) + self.assertEqual(res['prov']['data'][0]['type']['_id'], 'ws_type_version/Module.Type1-1.0') + # Check the ref results + self.assertEqual(res['refs']['count'], 1) + self.assertEqual(len(res['refs']['data']), 1) + self.assertEqual(res['refs']['data'][0]['data']['_id'], 'ws_object_version/1:4:1') + self.assertEqual(res['refs']['data'][0]['hops'], 1) + self.assertEqual(res['refs']['data'][0]['type']['_id'], 'ws_type_version/Module.Type1-1.0') From ffe60dbb8e505ae765ef2d1f318ce04d60ba3354 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Fri, 8 May 2020 13:20:01 -0700 Subject: [PATCH 493/732] Add some permissions checking in the big test case --- spec/test/stored_queries/test_ws.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/spec/test/stored_queries/test_ws.py b/spec/test/stored_queries/test_ws.py index 496862c1..7cfbb836 100644 --- a/spec/test/stored_queries/test_ws.py +++ b/spec/test/stored_queries/test_ws.py @@ -11,7 +11,7 @@ _CONF = get_config() -def _ws_obj(wsid, objid, ver): +def _ws_obj(wsid, objid, ver, is_public=True): """Create data for a dummy test workspace obj""" return { '_key': ':'.join((str(n) for n in (wsid, objid, ver))), @@ -23,7 +23,7 @@ def _ws_obj(wsid, objid, ver): 'size': 0, 'epoch': 0, 'deleted': False, - 'is_public': True + 'is_public': is_public, } @@ -39,6 +39,9 @@ def setUpClass(cls): _ws_obj(1, 2, 1), # copy object _ws_obj(1, 3, 1), # provenance object _ws_obj(1, 4, 1), # reference object + _ws_obj(1, 5, 1, is_public=False), # private copy obj + _ws_obj(1, 6, 1, is_public=False), # private prov obj + _ws_obj(1, 7, 1, is_public=False), # private ref obj ] create_test_docs('ws_object_version', ws_object_version) ws_type_version = [{'_key': 'Module.Type1-1.0'}] @@ -50,20 +53,26 @@ def setUpClass(cls): ] create_test_docs('ws_obj_instance_of_type', ws_obj_instance_of_type) ws_prov_descendant_of = [ - {'_from': 'ws_object_version/1:1:1', '_to': 'ws_object_version/1:3:1'} + {'_from': 'ws_object_version/1:1:1', '_to': 'ws_object_version/1:3:1'}, + {'_from': 'ws_object_version/1:1:1', '_to': 'ws_object_version/1:6:1'}, ] create_test_docs('ws_prov_descendant_of', ws_prov_descendant_of) ws_refers_to = [ - {'_from': 'ws_object_version/1:1:1', '_to': 'ws_object_version/1:4:1'} + {'_from': 'ws_object_version/1:1:1', '_to': 'ws_object_version/1:4:1'}, + {'_from': 'ws_object_version/1:1:1', '_to': 'ws_object_version/1:7:1'}, ] create_test_docs('ws_refers_to', ws_refers_to) ws_copied_from = [ - {'_from': 'ws_object_version/1:1:1', '_to': 'ws_object_version/1:2:1'} + {'_from': 'ws_object_version/1:1:1', '_to': 'ws_object_version/1:2:1'}, + {'_from': 'ws_object_version/1:1:1', '_to': 'ws_object_version/1:5:1'}, ] create_test_docs('ws_copied_from', ws_copied_from) def test_fetch_related_data_valid(self): - """Test for the basic happy path.""" + """ + Test for the basic happy path. + This also covers the case of private-scope object results, which will be hidden from results. + """ resp = requests.post( _CONF['re_api_url'] + '/api/v1/query_results', params={'stored_query': 'ws_fetch_related_data', 'show_public': True}, From 0d88cab5278c881ef61ee2b87d39e490d7b9651d Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 12 May 2020 12:18:41 -0700 Subject: [PATCH 494/732] Remove show_private and show_public params; return the root object data --- .../ws/ws_fetch_related_data.yaml | 21 ++++--------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/spec/stored_queries/ws/ws_fetch_related_data.yaml b/spec/stored_queries/ws/ws_fetch_related_data.yaml index d5d65d6d..b458ef73 100644 --- a/spec/stored_queries/ws/ws_fetch_related_data.yaml +++ b/spec/stored_queries/ws/ws_fetch_related_data.yaml @@ -6,14 +6,6 @@ params: obj_key: type: string description: Key of the wsprov_object to search on - show_private: - type: boolean - description: limit to objects in workspaces that a user has access to - default: true - show_public: - type: boolean - description: limit to objects in public workspaces - default: true query_prefix: WITH ws_type_version query: | LET obj_id = concat('ws_object_version/', @obj_key) @@ -24,9 +16,7 @@ query: | OPTIONS {bfs: true, uniqueVertices: 'global'} LIMIT 1000 FILTER v && !v.deleted - FILTER (@show_private && @show_public) - ? (v.is_public || v.workspace_id IN ws_ids) - : (!@show_private || v.workspace_id IN ws_ids) && (!@show_public || v.is_public) + FILTER v.is_public || v.workspace_id IN ws_ids let t = FIRST( FOR t IN 1 OUTBOUND v ws_obj_instance_of_type return t @@ -38,9 +28,7 @@ query: | OPTIONS {bfs: true, uniqueVertices: 'global'} LIMIT 1000 FILTER v && !v.deleted - FILTER (@show_private && @show_public) - ? (v.is_public || v.workspace_id IN ws_ids) - : (!@show_private || v.workspace_id IN ws_ids) && (!@show_public || v.is_public) + FILTER v.is_public || v.workspace_id IN ws_ids let t = FIRST( FOR t IN 1 OUTBOUND v ws_obj_instance_of_type return t @@ -52,9 +40,7 @@ query: | OPTIONS {bfs: true, uniqueVertices: 'global'} LIMIT 1000 FILTER v && !v.deleted - FILTER (@show_private && @show_public) - ? (v.is_public || v.workspace_id IN ws_ids) - : (!@show_private || v.workspace_id IN ws_ids) && (!@show_public || v.is_public) + FILTER v.is_public || v.worksapce_id IN ws_ids let t = FIRST( FOR t IN 1 OUTBOUND v ws_obj_instance_of_type LIMIT 1 @@ -63,6 +49,7 @@ query: | RETURN {data: v, type: t, hops: COUNT(p.edges)} ) RETURN { + obj: obj, copies: {data: copies, count: COUNT(copies)}, prov: {data: prov, count: COUNT(prov)}, refs: {data: refs, count: COUNT(refs)} From 931c6757467e2b8774daf9187751e736e31b2d24 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 12 May 2020 12:28:08 -0700 Subject: [PATCH 495/732] Return the root object type data in the query --- spec/stored_queries/ws/ws_fetch_related_data.yaml | 8 +++++++- spec/test/stored_queries/test_ws.py | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/spec/stored_queries/ws/ws_fetch_related_data.yaml b/spec/stored_queries/ws/ws_fetch_related_data.yaml index b458ef73..7c0c762a 100644 --- a/spec/stored_queries/ws/ws_fetch_related_data.yaml +++ b/spec/stored_queries/ws/ws_fetch_related_data.yaml @@ -40,7 +40,7 @@ query: | OPTIONS {bfs: true, uniqueVertices: 'global'} LIMIT 1000 FILTER v && !v.deleted - FILTER v.is_public || v.worksapce_id IN ws_ids + FILTER v.is_public || v.workspace IN ws_ids let t = FIRST( FOR t IN 1 OUTBOUND v ws_obj_instance_of_type LIMIT 1 @@ -48,8 +48,14 @@ query: | ) RETURN {data: v, type: t, hops: COUNT(p.edges)} ) + let type = FIRST( + FOR t IN 1 OUTBOUND obj ws_obj_instance_of_type + LIMIT 1 + return t + ) RETURN { obj: obj, + obj_type: type, copies: {data: copies, count: COUNT(copies)}, prov: {data: prov, count: COUNT(prov)}, refs: {data: refs, count: COUNT(refs)} diff --git a/spec/test/stored_queries/test_ws.py b/spec/test/stored_queries/test_ws.py index 7cfbb836..10b28b19 100644 --- a/spec/test/stored_queries/test_ws.py +++ b/spec/test/stored_queries/test_ws.py @@ -47,6 +47,7 @@ def setUpClass(cls): ws_type_version = [{'_key': 'Module.Type1-1.0'}] create_test_docs('ws_type_version', ws_type_version) ws_obj_instance_of_type = [ + {'_from': 'ws_object_version/1:1:1', '_to': 'ws_type_version/Module.Type1-1.0'}, {'_from': 'ws_object_version/1:2:1', '_to': 'ws_type_version/Module.Type1-1.0'}, {'_from': 'ws_object_version/1:3:1', '_to': 'ws_type_version/Module.Type1-1.0'}, {'_from': 'ws_object_version/1:4:1', '_to': 'ws_type_version/Module.Type1-1.0'}, @@ -81,6 +82,9 @@ def test_fetch_related_data_valid(self): self.assertEqual(resp['count'], 1) self.assertEqual(resp['has_more'], False) res = resp['results'][0] + # Check the root object results + self.assertEqual(res['obj']['_key'], '1:1:1') + self.assertEqual(res['obj_type']['_key'], 'Module.Type1-1.0') # Check the copy results self.assertEqual(res['copies']['count'], 1) self.assertEqual(len(res['copies']['data']), 1) From e91b573aaf23434469af59cf14ca7c32825559b8 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 13 May 2020 22:43:39 -0700 Subject: [PATCH 496/732] Return workspace data in the related objects query --- .../ws/ws_fetch_related_data.yaml | 108 ++++++++++++------ 1 file changed, 76 insertions(+), 32 deletions(-) diff --git a/spec/stored_queries/ws/ws_fetch_related_data.yaml b/spec/stored_queries/ws/ws_fetch_related_data.yaml index 7c0c762a..d7067ea6 100644 --- a/spec/stored_queries/ws/ws_fetch_related_data.yaml +++ b/spec/stored_queries/ws/ws_fetch_related_data.yaml @@ -12,46 +12,90 @@ query: | FOR obj IN ws_object_version FILTER obj._id == obj_id LET prov = ( - FOR v, e, p IN 1..10 ANY obj ws_prov_descendant_of - OPTIONS {bfs: true, uniqueVertices: 'global'} - LIMIT 1000 - FILTER v && !v.deleted - FILTER v.is_public || v.workspace_id IN ws_ids - let t = FIRST( - FOR t IN 1 OUTBOUND v ws_obj_instance_of_type - return t - ) - RETURN {data: v, type: t, hops: COUNT(p.edges)} + FOR v, e, p IN 1..10 ANY obj ws_prov_descendant_of + OPTIONS {bfs: true, uniqueVertices: 'global'} + LIMIT 1000 + FILTER v && !v.deleted + // Check permissions + FILTER v.is_public || v.workspace IN ws_ids + // Fetch the type + LET t = FIRST( + FOR t IN 1 OUTBOUND v ws_obj_instance_of_type + LIMIT 1 + RETURN t + ) + // Fetch the parent unversioned object + LET parent = ( + FOR parent IN 1 OUTBOUND v ws_version_of + LIMIT 1 + RETURN parent + ) + // Fetch the workspace for this object + LET ws = ( + FOR ws IN 1 INBOUND parent ws_workspace_contains_obj + LIMIT 1 + RETURN ws + ) + RETURN {data: v, type: t, hops: COUNT(p.edges), ws} ) let refs = ( - FOR v, e, p IN 1..10 ANY obj ws_refers_to - OPTIONS {bfs: true, uniqueVertices: 'global'} - LIMIT 1000 - FILTER v && !v.deleted - FILTER v.is_public || v.workspace_id IN ws_ids - let t = FIRST( - FOR t IN 1 OUTBOUND v ws_obj_instance_of_type - return t - ) - RETURN {data: v, type: t, hops: COUNT(p.edges)} + FOR v, e, p IN 1..10 ANY obj ws_refers_to + OPTIONS {bfs: true, uniqueVertices: 'global'} + LIMIT 1000 + FILTER v && !v.deleted + // Check permissions + FILTER v.is_public || v.workspace IN ws_ids + // Fetch the type + LET t = FIRST( + FOR t IN 1 OUTBOUND v ws_obj_instance_of_type + LIMIT 1 + RETURN t + ) + // Fetch the parent unversioned object + LET parent = ( + FOR parent IN 1 OUTBOUND v ws_version_of + LIMIT 1 + RETURN parent + ) + // Fetch the workspace for this object + LET ws = ( + FOR ws IN 1 INBOUND parent ws_workspace_contains_obj + LIMIT 1 + RETURN ws + ) + RETURN {data: v, type: t, hops: COUNT(p.edges), ws} ) let copies = ( - FOR v, e, p IN 1..10 ANY obj ws_copied_from - OPTIONS {bfs: true, uniqueVertices: 'global'} - LIMIT 1000 - FILTER v && !v.deleted - FILTER v.is_public || v.workspace IN ws_ids - let t = FIRST( - FOR t IN 1 OUTBOUND v ws_obj_instance_of_type - LIMIT 1 - return t - ) - RETURN {data: v, type: t, hops: COUNT(p.edges)} + FOR v, e, p IN 1..10 ANY obj ws_copied_from + OPTIONS {bfs: true, uniqueVertices: 'global'} + LIMIT 1000 + FILTER v && !v.deleted + // Check permissions + FILTER v.is_public || v.workspace IN ws_ids + // Fetch the type + LET t = FIRST( + FOR t IN 1 OUTBOUND v ws_obj_instance_of_type + LIMIT 1 + RETURN t + ) + // Fetch the parent unversioned object + LET parent = ( + FOR parent IN 1 OUTBOUND v ws_version_of + LIMIT 1 + RETURN parent + ) + // Fetch the workspace for this object + LET ws = ( + FOR ws IN 1 INBOUND parent ws_workspace_contains_obj + LIMIT 1 + RETURN ws + ) + RETURN {data: v, type: t, hops: COUNT(p.edges), ws} ) let type = FIRST( FOR t IN 1 OUTBOUND obj ws_obj_instance_of_type LIMIT 1 - return t + RETURN t ) RETURN { obj: obj, From dc6eb97404c415b02aa7a7776f09bd0dd4fea099 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 13 May 2020 22:48:05 -0700 Subject: [PATCH 497/732] Cleanup docs and unused files --- spec/README.md | 2 +- spec/migrations/README.md | 9 --------- spec/migrations/__init__.py | 1 - spec/migrations/example.py | 4 ---- 4 files changed, 1 insertion(+), 15 deletions(-) delete mode 100644 spec/migrations/README.md delete mode 100644 spec/migrations/__init__.py delete mode 100644 spec/migrations/example.py diff --git a/spec/README.md b/spec/README.md index c65a02db..610139ca 100644 --- a/spec/README.md +++ b/spec/README.md @@ -8,8 +8,8 @@ These specifications are used by the [Relation Engine API]() by KBase apps to fetch data from the database. * **Schemas** are [JSON schemas](https://json-schema.org/) that define what form of data can be stored in the database's collections. -* **Migrations** are python modules that connect to the database and are responsible for transitioning the data in a collection from an old schema to a newer one. * **Data sources** (in `data_sources/`) contains some general information about where some of our imported data comes from. +* **Views** (in `views/`) are raw ArangoSearch view configuration files ## Development diff --git a/spec/migrations/README.md b/spec/migrations/README.md deleted file mode 100644 index 994aaca1..00000000 --- a/spec/migrations/README.md +++ /dev/null @@ -1,9 +0,0 @@ -# Relation Engine Migrations - -Migrations are python scripts (using pyArango) that migrate (or roll back) the database to a new -schema version. - -## Guidelines - -- Every migration script has two functions -- `forward` and `backward -- for migrating the database forwards or backwards. -- Every migration should specify a collection name, the version we're migrating *from*, and version we're migrating *to* diff --git a/spec/migrations/__init__.py b/spec/migrations/__init__.py deleted file mode 100644 index 8b137891..00000000 --- a/spec/migrations/__init__.py +++ /dev/null @@ -1 +0,0 @@ - diff --git a/spec/migrations/example.py b/spec/migrations/example.py deleted file mode 100644 index 214701eb..00000000 --- a/spec/migrations/example.py +++ /dev/null @@ -1,4 +0,0 @@ -# TODO - -x = 1 - From c19b53f241768916d635c347da15474145460d32 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 13 May 2020 23:00:55 -0700 Subject: [PATCH 498/732] Fix workspace queries --- spec/stored_queries/ws/ws_fetch_related_data.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/spec/stored_queries/ws/ws_fetch_related_data.yaml b/spec/stored_queries/ws/ws_fetch_related_data.yaml index d7067ea6..38a8d64f 100644 --- a/spec/stored_queries/ws/ws_fetch_related_data.yaml +++ b/spec/stored_queries/ws/ws_fetch_related_data.yaml @@ -25,13 +25,13 @@ query: | RETURN t ) // Fetch the parent unversioned object - LET parent = ( + LET parent = FIRST( FOR parent IN 1 OUTBOUND v ws_version_of LIMIT 1 RETURN parent ) // Fetch the workspace for this object - LET ws = ( + LET ws = FIRST( FOR ws IN 1 INBOUND parent ws_workspace_contains_obj LIMIT 1 RETURN ws @@ -52,13 +52,13 @@ query: | RETURN t ) // Fetch the parent unversioned object - LET parent = ( + LET parent = FIRST( FOR parent IN 1 OUTBOUND v ws_version_of LIMIT 1 RETURN parent ) // Fetch the workspace for this object - LET ws = ( + LET ws = FIRST( FOR ws IN 1 INBOUND parent ws_workspace_contains_obj LIMIT 1 RETURN ws @@ -79,13 +79,13 @@ query: | RETURN t ) // Fetch the parent unversioned object - LET parent = ( + LET parent = FIRST( FOR parent IN 1 OUTBOUND v ws_version_of LIMIT 1 RETURN parent ) // Fetch the workspace for this object - LET ws = ( + LET ws = FIRST( FOR ws IN 1 INBOUND parent ws_workspace_contains_obj LIMIT 1 RETURN ws From c0f71b81792de5800f5af40dcc18877d03a237ec Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 17 Jun 2020 14:53:58 -0700 Subject: [PATCH 499/732] Add basic djornl queries from last fall --- .../djornl/djornl_fetch_genes.yaml | 15 +++++++++ .../djornl/djornl_fetch_phenotypes.yaml | 15 +++++++++ .../djornl/djornl_gene_neighbors.yaml | 31 +++++++++++++++++++ 3 files changed, 61 insertions(+) create mode 100644 spec/stored_queries/djornl/djornl_fetch_genes.yaml create mode 100644 spec/stored_queries/djornl/djornl_fetch_phenotypes.yaml create mode 100644 spec/stored_queries/djornl/djornl_gene_neighbors.yaml diff --git a/spec/stored_queries/djornl/djornl_fetch_genes.yaml b/spec/stored_queries/djornl/djornl_fetch_genes.yaml new file mode 100644 index 00000000..44eda82e --- /dev/null +++ b/spec/stored_queries/djornl/djornl_fetch_genes.yaml @@ -0,0 +1,15 @@ +# Fetch a gene document by list of keys +name: djornl_fetch_genes +params: + type: object + required: [keys] + properties: + keys: + type: array + items: {type: string} + title: Gene Keys + examples: [[AT1G01010]] +query: | + FOR g IN djornl_gene + FILTER g._key IN @keys + RETURN g diff --git a/spec/stored_queries/djornl/djornl_fetch_phenotypes.yaml b/spec/stored_queries/djornl/djornl_fetch_phenotypes.yaml new file mode 100644 index 00000000..aa4de01c --- /dev/null +++ b/spec/stored_queries/djornl/djornl_fetch_phenotypes.yaml @@ -0,0 +1,15 @@ +# Fetch a phenotype document by list of keys +name: djornl_fetch_phenotypes +params: + type: object + required: [keys] + properties: + keys: + type: array + items: {type: string} + title: Phenotype Keys + examples: [[As2]] +query: | + FOR p IN djornl_phenotype + FILTER p._key IN @keys + RETURN p diff --git a/spec/stored_queries/djornl/djornl_gene_neighbors.yaml b/spec/stored_queries/djornl/djornl_gene_neighbors.yaml new file mode 100644 index 00000000..e21f167e --- /dev/null +++ b/spec/stored_queries/djornl/djornl_gene_neighbors.yaml @@ -0,0 +1,31 @@ +# Fetch the neighbors of a certain gene by distance +name: djornl_gene_neighbors +params: + type: object + required: [gene_key] + properties: + distance: + type: integer + title: Traversal Distance + description: How many hops to find neighbors and neighbors-of-neighbors + default: 1 + minimum: 1 + maximum: 100 + gene_key: + type: string + title: Gene Key + examples: [AT1G01010] +query: | + FOR g IN djornl_gene + FILTER g._key == @gene_key + FOR n, e, p IN @distance ANY g djornl_domain_co_occur, djornl_gene_coexpr, djornl_pheno_assn, djornl_ppi_hithru, djornl_ppi_liter + OPTIONS {bfs: true, uniqueVertices: "global"} + LET edges = ( + FOR entry IN p.edges + RETURN KEEP(entry, "_id", "_from", "_to") + ) + LET verts = ( + FOR entry IN SLICE(p.vertices, 1) + RETURN UNSET(entry, "_key", "_rev") + ) + RETURN {edges, verts} From 5946981956bb9d1141ce8a29e8dd0cbba3bac2e6 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 17 Jun 2020 15:18:30 -0700 Subject: [PATCH 500/732] Add djornl queries and schemas --- spec/schemas/ENVO/ENVO_terms.yaml | 2 +- .../djornl/djornl_domain_co_occur.yaml | 26 +++++++ spec/schemas/djornl/djornl_gene.yaml | 72 +++++++++++++++++++ spec/schemas/djornl/djornl_gene_coexpr.yaml | 26 +++++++ spec/schemas/djornl/djornl_pheno_assn.yaml | 24 +++++++ spec/schemas/djornl/djornl_phenotype.yaml | 60 ++++++++++++++++ spec/schemas/djornl/djornl_ppi_hithru.yaml | 26 +++++++ spec/schemas/djornl/djornl_ppi_liter.yaml | 26 +++++++ 8 files changed, 261 insertions(+), 1 deletion(-) create mode 100644 spec/schemas/djornl/djornl_domain_co_occur.yaml create mode 100644 spec/schemas/djornl/djornl_gene.yaml create mode 100644 spec/schemas/djornl/djornl_gene_coexpr.yaml create mode 100644 spec/schemas/djornl/djornl_pheno_assn.yaml create mode 100644 spec/schemas/djornl/djornl_phenotype.yaml create mode 100644 spec/schemas/djornl/djornl_ppi_hithru.yaml create mode 100644 spec/schemas/djornl/djornl_ppi_liter.yaml diff --git a/spec/schemas/ENVO/ENVO_terms.yaml b/spec/schemas/ENVO/ENVO_terms.yaml index 1e6e3553..48076a28 100644 --- a/spec/schemas/ENVO/ENVO_terms.yaml +++ b/spec/schemas/ENVO/ENVO_terms.yaml @@ -144,4 +144,4 @@ schema: - comments - subsets - synonyms - - xrefs \ No newline at end of file + - xrefs diff --git a/spec/schemas/djornl/djornl_domain_co_occur.yaml b/spec/schemas/djornl/djornl_domain_co_occur.yaml new file mode 100644 index 00000000..f56d9596 --- /dev/null +++ b/spec/schemas/djornl/djornl_domain_co_occur.yaml @@ -0,0 +1,26 @@ +name: djornl_domain_co_occur +type: edge +delta: false + +schema: + "$schema": http://json-schema.org/draft-07/schema# + title: Gene Domain Co-occurrence Edge + description: | + A layer of protein domain co-occurrence values from the Arabidopsis + AraNetv2 database. The LLS scores that serve as edge values were + calculated from weighted mutual information scores to normalize the data + for comparison across studies and different types of data layers (Lee et + al, 2015). + type: object + required: [lls, _from, _to] + properties: + lls: + title: Least Likelhood Score + # (float) + type: number + _from: + type: string + title: Gene ID + _to: + type: string + title: Gene ID diff --git a/spec/schemas/djornl/djornl_gene.yaml b/spec/schemas/djornl/djornl_gene.yaml new file mode 100644 index 00000000..b4507bd8 --- /dev/null +++ b/spec/schemas/djornl/djornl_gene.yaml @@ -0,0 +1,72 @@ +name: djornl_gene +type: vertex +delta: false + +schema: + "$schema": http://json-schema.org/draft-07/schema# + title: Gene Vertices + description: Arabidopsis gene nodes from the Dan Jacobson Lab + type: object + required: [_key] + properties: + _key: + type: string + title: Gene Key + examples: ["AT1G01010"] + node_type: + type: string + examples: ["gene"] + transcript: + type: string + examples: ["AT1G01010.1"] + gene_symbol: + type: string + examples: ["NTL10"] + gene_full_name: + type: string + examples: ["NAC domain containing protein 1"] + gene_model_type: + type: string + examples: ["protein_coding"] + tair_computational_desc: + type: string + examples: ["NAC domain containing protein 1;(source:Araport11)"] + tair_curator_summary: + type: string + tair_short_desc: + type: string + examples: ["NAC domain containing protein 1"] + go_descr: + type: string + examples: ["DNA-binding transcription factor activity"] + go_terms: + type: array + items: {type: string} + examples: [["DNA binding"]] + mapman_bin: + type: string + examples: ["GO:0003700"] + mapman_name: + type: string + examples: ["GO:0003677"] + mapman_desc: + type: string + examples: ["15.5.17"] + pheno_aragwas_id: + type: string + examples: [".RNA biosynthesis.transcriptional regulation.transcription factor (NAC)"] + pheno_desc1: + type: string + examples: ["transcription factor (NAC) (original description: pep chromosome:TAIR10:1:3631:5899:1 gene:AT1G01010 transcript:AT1G01010.1 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:NAC001 description:NAC domain-containing protein 1 [Source:UniProtKB/Swiss-Prot;Acc:Q0WV96])"] + pheno_desc2: + type: string + examples: [] + pheno_desc3: + type: string + examples: [] + pheno_ref: + type: string + examples: [] + user_notes: + type: string + examples: [] diff --git a/spec/schemas/djornl/djornl_gene_coexpr.yaml b/spec/schemas/djornl/djornl_gene_coexpr.yaml new file mode 100644 index 00000000..e0cb5b15 --- /dev/null +++ b/spec/schemas/djornl/djornl_gene_coexpr.yaml @@ -0,0 +1,26 @@ +name: djornl_gene_coexpr +type: edge +delta: false + +schema: + "$schema": http://json-schema.org/draft-07/schema# + title: Gene Co-expression Edge + description: | + A subset of pairwise gene coexpression values from the Arabidopsis + AraNetv2 database. The LLS scores that serve as edge values were + calculated from Pearson correlation coefficients to normalize the data + for comparison across studies and different types of data layers (Lee et + al, 2015). + type: object + required: [lls, _from, _to] + properties: + lls: + title: Least Likelhood Score + # (float) + type: number + _from: + type: string + title: Gene ID + _to: + type: string + title: Gene ID diff --git a/spec/schemas/djornl/djornl_pheno_assn.yaml b/spec/schemas/djornl/djornl_pheno_assn.yaml new file mode 100644 index 00000000..52e587dd --- /dev/null +++ b/spec/schemas/djornl/djornl_pheno_assn.yaml @@ -0,0 +1,24 @@ +name: djornl_pheno_assn +type: edge +delta: false + +schema: + "$schema": http://json-schema.org/draft-07/schema# + title: Phenotype Association Edge + description: | + GWAS associations produced by analyzing a subset of phenotypes and SNPs + in the Arabidopsis 1001 Genomes database. Edge values are significant + association scores after FDR correction. + type: object + required: [assn_score, _from, _to] + properties: + assn_score: + title: Association Score + # (float) + type: number + _from: + type: string + title: Gene ID + _to: + type: string + title: Phenotype ID diff --git a/spec/schemas/djornl/djornl_phenotype.yaml b/spec/schemas/djornl/djornl_phenotype.yaml new file mode 100644 index 00000000..085076fa --- /dev/null +++ b/spec/schemas/djornl/djornl_phenotype.yaml @@ -0,0 +1,60 @@ +name: djornl_gene +type: vertex +delta: false + +schema: + "$schema": http://json-schema.org/draft-07/schema# + title: Gene Vertices + description: Arabidopsis phenotype nodes from the Dan Jacobson Lab + type: object + required: [_key] + properties: + _key: + type: string + title: Phenotype Key + examples: ["Aw2"] + node_type: + type: string + examples: ["pheno"] + transcript: + type: string + gene_symbol: + type: string + gene_full_name: + type: string + gene_model_type: + type: string + tair_computational_desc: + type: string + tair_curator_summary: + type: string + tair_short_desc: + type: string + go_descr: + type: string + go_terms: + type: array + items: {type: string} + mapman_bin: + type: string + mapman_name: + type: string + mapman_desc: + type: string + pheno_aragwas_id: + type: string + examples: ["10.21958/phenotype:103"] + pheno_desc1: + type: string + pheno_desc2: + type: string + examples: ["bacterial disease resistance"] + pheno_desc3: + type: string + examples: ["The resistance exhibited by a plant or a group of plants (population) in response to the disease caused by a bacterial pathogen infection as compared to the susceptible and/or the reference plants of the same species. [GR:pj]"] + pheno_ref: + type: string + examples: ["Atwell et. al"] + user_notes: + type: string + examples: ["Nature 2010"] diff --git a/spec/schemas/djornl/djornl_ppi_hithru.yaml b/spec/schemas/djornl/djornl_ppi_hithru.yaml new file mode 100644 index 00000000..6059b818 --- /dev/null +++ b/spec/schemas/djornl/djornl_ppi_hithru.yaml @@ -0,0 +1,26 @@ +name: djornl_ppi_hithru +type: edge +delta: false + +schema: + "$schema": http://json-schema.org/draft-07/schema# + title: High Throughput PPI + description: | + Log likelihood score. A layer of protein-protein interaction values + derived from four high-throughput PPI screening experiments; from the + Arabidopsis AraNetv2 database. The LLS scores that serve as edge values + were calculated to normalize the data for comparison across studies and + different types of data layers (Lee et al, 2015). + type: object + required: [lls, _from, _to] + properties: + lls: + title: Least Likelhood Score + # (float) + type: number + _from: + type: string + title: Gene ID + _to: + type: string + title: Gene ID diff --git a/spec/schemas/djornl/djornl_ppi_liter.yaml b/spec/schemas/djornl/djornl_ppi_liter.yaml new file mode 100644 index 00000000..943f87e1 --- /dev/null +++ b/spec/schemas/djornl/djornl_ppi_liter.yaml @@ -0,0 +1,26 @@ +name: djornl_ppi_liter +type: edge +delta: false + +schema: + "$schema": http://json-schema.org/draft-07/schema# + title: Literature-Curated PPI + description: | + A layer of protein-protein interaction values from literature-curated + small- to medium-scale experimental data; from the Arabidopsis AraNetv2 + database. The LLS scores that serve as edge values were calculated to + normalize the data for comparison across studies and different types of + data layers (Lee et al, 2015). + type: object + required: [lls, _from, _to] + properties: + lls: + title: Least Likelhood Score + # (float) + type: number + _from: + type: string + title: Gene ID + _to: + type: string + title: Gene ID From 886c7a3b3197b3e0f57952eec138cf6cb1d3fde0 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 17 Jun 2020 15:22:58 -0700 Subject: [PATCH 501/732] Fix typos --- spec/schemas/djornl/djornl_domain_co_occur.yaml | 2 +- spec/schemas/djornl/djornl_gene_coexpr.yaml | 2 +- spec/schemas/djornl/djornl_ppi_hithru.yaml | 2 +- spec/schemas/djornl/djornl_ppi_liter.yaml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/schemas/djornl/djornl_domain_co_occur.yaml b/spec/schemas/djornl/djornl_domain_co_occur.yaml index f56d9596..39e5bc5c 100644 --- a/spec/schemas/djornl/djornl_domain_co_occur.yaml +++ b/spec/schemas/djornl/djornl_domain_co_occur.yaml @@ -15,7 +15,7 @@ schema: required: [lls, _from, _to] properties: lls: - title: Least Likelhood Score + title: Least Likelihood Score # (float) type: number _from: diff --git a/spec/schemas/djornl/djornl_gene_coexpr.yaml b/spec/schemas/djornl/djornl_gene_coexpr.yaml index e0cb5b15..9b1fc74b 100644 --- a/spec/schemas/djornl/djornl_gene_coexpr.yaml +++ b/spec/schemas/djornl/djornl_gene_coexpr.yaml @@ -15,7 +15,7 @@ schema: required: [lls, _from, _to] properties: lls: - title: Least Likelhood Score + title: Least Likelihood Score # (float) type: number _from: diff --git a/spec/schemas/djornl/djornl_ppi_hithru.yaml b/spec/schemas/djornl/djornl_ppi_hithru.yaml index 6059b818..b3b2a810 100644 --- a/spec/schemas/djornl/djornl_ppi_hithru.yaml +++ b/spec/schemas/djornl/djornl_ppi_hithru.yaml @@ -15,7 +15,7 @@ schema: required: [lls, _from, _to] properties: lls: - title: Least Likelhood Score + title: Least Likelihood Score # (float) type: number _from: diff --git a/spec/schemas/djornl/djornl_ppi_liter.yaml b/spec/schemas/djornl/djornl_ppi_liter.yaml index 943f87e1..46c44fdb 100644 --- a/spec/schemas/djornl/djornl_ppi_liter.yaml +++ b/spec/schemas/djornl/djornl_ppi_liter.yaml @@ -15,7 +15,7 @@ schema: required: [lls, _from, _to] properties: lls: - title: Least Likelhood Score + title: Least Likelihood Score # (float) type: number _from: From 2103592679e170212c97edcd31f956ba8ee7fd49 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Thu, 18 Jun 2020 12:06:03 -0700 Subject: [PATCH 502/732] Combine edge collections into one with score and score_type --- .../djornl/djornl_domain_co_occur.yaml | 26 -------- spec/schemas/djornl/djornl_edge.yaml | 66 +++++++++++++++++++ spec/schemas/djornl/djornl_gene_coexpr.yaml | 26 -------- spec/schemas/djornl/djornl_pheno_assn.yaml | 24 ------- spec/schemas/djornl/djornl_ppi_hithru.yaml | 26 -------- spec/schemas/djornl/djornl_ppi_liter.yaml | 26 -------- .../djornl/djornl_gene_neighbors.yaml | 4 +- 7 files changed, 68 insertions(+), 130 deletions(-) delete mode 100644 spec/schemas/djornl/djornl_domain_co_occur.yaml create mode 100644 spec/schemas/djornl/djornl_edge.yaml delete mode 100644 spec/schemas/djornl/djornl_gene_coexpr.yaml delete mode 100644 spec/schemas/djornl/djornl_pheno_assn.yaml delete mode 100644 spec/schemas/djornl/djornl_ppi_hithru.yaml delete mode 100644 spec/schemas/djornl/djornl_ppi_liter.yaml diff --git a/spec/schemas/djornl/djornl_domain_co_occur.yaml b/spec/schemas/djornl/djornl_domain_co_occur.yaml deleted file mode 100644 index 39e5bc5c..00000000 --- a/spec/schemas/djornl/djornl_domain_co_occur.yaml +++ /dev/null @@ -1,26 +0,0 @@ -name: djornl_domain_co_occur -type: edge -delta: false - -schema: - "$schema": http://json-schema.org/draft-07/schema# - title: Gene Domain Co-occurrence Edge - description: | - A layer of protein domain co-occurrence values from the Arabidopsis - AraNetv2 database. The LLS scores that serve as edge values were - calculated from weighted mutual information scores to normalize the data - for comparison across studies and different types of data layers (Lee et - al, 2015). - type: object - required: [lls, _from, _to] - properties: - lls: - title: Least Likelihood Score - # (float) - type: number - _from: - type: string - title: Gene ID - _to: - type: string - title: Gene ID diff --git a/spec/schemas/djornl/djornl_edge.yaml b/spec/schemas/djornl/djornl_edge.yaml new file mode 100644 index 00000000..2cc7516e --- /dev/null +++ b/spec/schemas/djornl/djornl_edge.yaml @@ -0,0 +1,66 @@ +name: djornl_edge +type: edge +delta: false + +indexes: + - type: hash + fields: [score_type] + - type: persistent + fields: [score] + +# A guide to the edge score types: + +# domain_co_occur: +# A layer of protein domain co-occurrence values from the Arabidopsis +# AraNetv2 database. The LLS scores that serve as edge values were calculated +# from weighted mutual information scores to normalize the data for +# comparison across studies and different types of data layers (Lee et al, +# 2015). + +# gene_coexpr: +# A subset of pairwise gene coexpression values from the Arabidopsis +# AraNetv2 database. The LLS scores that serve as edge values were +# calculated from Pearson correlation coefficients to normalize the data +# for comparison across studies and different types of data layers (Lee et +# al, 2015). + +# pheno_assn: +# GWAS associations produced by analyzing a subset of phenotypes and SNPs +# in the Arabidopsis 1001 Genomes database. Edge values are significant +# association scores after FDR correction. + +# ppi_hithru: +# Log likelihood score. A layer of protein-protein interaction values +# derived from four high-throughput PPI screening experiments; from the +# Arabidopsis AraNetv2 database. The LLS scores that serve as edge values +# were calculated to normalize the data for comparison across studies and +# different types of data layers (Lee et al, 2015). + +# ppi_liter: +# A layer of protein-protein interaction values from literature-curated +# small- to medium-scale experimental data; from the Arabidopsis AraNetv2 +# database. The LLS scores that serve as edge values were calculated to +# normalize the data for comparison across studies and different types of +# data layers (Lee et al, 2015). + +schema: + "$schema": http://json-schema.org/draft-07/schema# + title: Arabidopsis gene-gene or gene-phenotype edge + description: Generic gene-to-gene or gene-to-phenotype edge for Dan Jacobson Arabidopsis data + type: object + required: [score, score_type, _from, _to] + properties: + score: + title: Edge Score (Weight) + # (float) + type: number + score_type: + title: Least Likelihood Score + type: string + enum: [domain_co_occur, gene_coexpr, pheno_assn, ppi_hithru, ppi_liter] + _from: + type: string + title: Gene ID + _to: + type: string + title: Gene or Phenotype ID diff --git a/spec/schemas/djornl/djornl_gene_coexpr.yaml b/spec/schemas/djornl/djornl_gene_coexpr.yaml deleted file mode 100644 index 9b1fc74b..00000000 --- a/spec/schemas/djornl/djornl_gene_coexpr.yaml +++ /dev/null @@ -1,26 +0,0 @@ -name: djornl_gene_coexpr -type: edge -delta: false - -schema: - "$schema": http://json-schema.org/draft-07/schema# - title: Gene Co-expression Edge - description: | - A subset of pairwise gene coexpression values from the Arabidopsis - AraNetv2 database. The LLS scores that serve as edge values were - calculated from Pearson correlation coefficients to normalize the data - for comparison across studies and different types of data layers (Lee et - al, 2015). - type: object - required: [lls, _from, _to] - properties: - lls: - title: Least Likelihood Score - # (float) - type: number - _from: - type: string - title: Gene ID - _to: - type: string - title: Gene ID diff --git a/spec/schemas/djornl/djornl_pheno_assn.yaml b/spec/schemas/djornl/djornl_pheno_assn.yaml deleted file mode 100644 index 52e587dd..00000000 --- a/spec/schemas/djornl/djornl_pheno_assn.yaml +++ /dev/null @@ -1,24 +0,0 @@ -name: djornl_pheno_assn -type: edge -delta: false - -schema: - "$schema": http://json-schema.org/draft-07/schema# - title: Phenotype Association Edge - description: | - GWAS associations produced by analyzing a subset of phenotypes and SNPs - in the Arabidopsis 1001 Genomes database. Edge values are significant - association scores after FDR correction. - type: object - required: [assn_score, _from, _to] - properties: - assn_score: - title: Association Score - # (float) - type: number - _from: - type: string - title: Gene ID - _to: - type: string - title: Phenotype ID diff --git a/spec/schemas/djornl/djornl_ppi_hithru.yaml b/spec/schemas/djornl/djornl_ppi_hithru.yaml deleted file mode 100644 index b3b2a810..00000000 --- a/spec/schemas/djornl/djornl_ppi_hithru.yaml +++ /dev/null @@ -1,26 +0,0 @@ -name: djornl_ppi_hithru -type: edge -delta: false - -schema: - "$schema": http://json-schema.org/draft-07/schema# - title: High Throughput PPI - description: | - Log likelihood score. A layer of protein-protein interaction values - derived from four high-throughput PPI screening experiments; from the - Arabidopsis AraNetv2 database. The LLS scores that serve as edge values - were calculated to normalize the data for comparison across studies and - different types of data layers (Lee et al, 2015). - type: object - required: [lls, _from, _to] - properties: - lls: - title: Least Likelihood Score - # (float) - type: number - _from: - type: string - title: Gene ID - _to: - type: string - title: Gene ID diff --git a/spec/schemas/djornl/djornl_ppi_liter.yaml b/spec/schemas/djornl/djornl_ppi_liter.yaml deleted file mode 100644 index 46c44fdb..00000000 --- a/spec/schemas/djornl/djornl_ppi_liter.yaml +++ /dev/null @@ -1,26 +0,0 @@ -name: djornl_ppi_liter -type: edge -delta: false - -schema: - "$schema": http://json-schema.org/draft-07/schema# - title: Literature-Curated PPI - description: | - A layer of protein-protein interaction values from literature-curated - small- to medium-scale experimental data; from the Arabidopsis AraNetv2 - database. The LLS scores that serve as edge values were calculated to - normalize the data for comparison across studies and different types of - data layers (Lee et al, 2015). - type: object - required: [lls, _from, _to] - properties: - lls: - title: Least Likelihood Score - # (float) - type: number - _from: - type: string - title: Gene ID - _to: - type: string - title: Gene ID diff --git a/spec/stored_queries/djornl/djornl_gene_neighbors.yaml b/spec/stored_queries/djornl/djornl_gene_neighbors.yaml index e21f167e..9bfb642c 100644 --- a/spec/stored_queries/djornl/djornl_gene_neighbors.yaml +++ b/spec/stored_queries/djornl/djornl_gene_neighbors.yaml @@ -18,11 +18,11 @@ params: query: | FOR g IN djornl_gene FILTER g._key == @gene_key - FOR n, e, p IN @distance ANY g djornl_domain_co_occur, djornl_gene_coexpr, djornl_pheno_assn, djornl_ppi_hithru, djornl_ppi_liter + FOR n, e, p IN @distance ANY g djornl_edge OPTIONS {bfs: true, uniqueVertices: "global"} LET edges = ( FOR entry IN p.edges - RETURN KEEP(entry, "_id", "_from", "_to") + RETURN KEEP(entry, "_id", "_from", "_to", "score", "score_type") ) LET verts = ( FOR entry IN SLICE(p.vertices, 1) From 0fdd04028995dc6e2c89ce026e3cf8a53549b551 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Thu, 18 Jun 2020 14:07:39 -0700 Subject: [PATCH 503/732] Add cluster fields for genes --- spec/schemas/djornl/djornl_gene.yaml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/spec/schemas/djornl/djornl_gene.yaml b/spec/schemas/djornl/djornl_gene.yaml index b4507bd8..10f90e02 100644 --- a/spec/schemas/djornl/djornl_gene.yaml +++ b/spec/schemas/djornl/djornl_gene.yaml @@ -13,6 +13,21 @@ schema: type: string title: Gene Key examples: ["AT1G01010"] + cluster_I2: + type: string + title: Cluster ID + description: Iterative random forest cluster group ID + examples: ["Cluster1"] + cluster_I4: + type: string + title: Cluster ID + description: Iterative random forest cluster group ID + examples: ["Cluster1"] + cluster_I6: + type: string + title: Cluster ID + description: Iterative random forest cluster group ID + examples: ["Cluster1"] node_type: type: string examples: ["gene"] From 47b49f1dc299862809f8f9c45a67802e621a6f95 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Thu, 18 Jun 2020 16:05:27 -0700 Subject: [PATCH 504/732] Add djornl importer under /importers with some docs --- spec/importers/README.md | 20 ++++ spec/importers/djornl/main.py | 172 +++++++++++++++++++++++++++++++++ spec/importers/tox.ini | 2 + spec/importers/utils/config.py | 22 +++++ 4 files changed, 216 insertions(+) create mode 100644 spec/importers/README.md create mode 100644 spec/importers/djornl/main.py create mode 100644 spec/importers/tox.ini create mode 100644 spec/importers/utils/config.py diff --git a/spec/importers/README.md b/spec/importers/README.md new file mode 100644 index 00000000..f4373059 --- /dev/null +++ b/spec/importers/README.md @@ -0,0 +1,20 @@ +# RE Importers + +This directory holds python modules that import data into ArangoDB. + +## Running importers + +Configure importers through environment variables with the `RES_` prefix (which stands for Relation Engine Spec). + +Global env vars: + +* `RES_auth_token` - auth token to use when making requests to RE API - defaults to test value +* `RES_api_url` - url to use for the RE API - defaults to test value + +### djornl + +```py +RES_auth_token=admin_token \ +RES_base_path=/path/to/djornl_data \ +python -m importers.djornl.main +``` diff --git a/spec/importers/djornl/main.py b/spec/importers/djornl/main.py new file mode 100644 index 00000000..0b7b18c8 --- /dev/null +++ b/spec/importers/djornl/main.py @@ -0,0 +1,172 @@ +""" +Loads the Dan Jacobson/ORNL group's gene and phenotype network data into +arangodb. + +Running this requires a set of source files provided by the ORNL group. +""" +import json +import requests +import os +import csv + +import importers.utils.config as config +CONF = config.load_from_env() + +# Path config +_BASE_PATH = os.environ['RES_base_path'] +_VERT_PATH = os.path.join(_BASE_PATH, 'aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv') +_CLUSTER_PATHS = [ + os.path.join(_BASE_PATH, 'cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I2_named.tsv'), + os.path.join(_BASE_PATH, 'cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I4_named.tsv'), + os.path.join(_BASE_PATH, 'cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I6_named.tsv'), +] +_PHENO_ASSN_PATH = os.path.join(_BASE_PATH, 'aragwas_subnet_phenoassociations_AMW_083019.tsv') +_DOMAIN_CO_OCCUR_PATH = os.path.join(_BASE_PATH, 'aranetv2_subnet_AT-DC_anno_AF_082919.tsv') +_GENE_COEXPR_PATH = os.path.join(_BASE_PATH, 'aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.tsv') +_PPI_HITHRU_PATH = os.path.join(_BASE_PATH, 'aranetv2_subnet_AT-HT_anno_AF_082919.tsv') +_PPI_LIT_PATH = os.path.join(_BASE_PATH, 'aranetv2_subnet_AT-LC_anno_AF_082919.tsv') + +# Collection name config +_PHENO_VERT_NAME = 'djornl_phenotype' +_GENE_VERT_NAME = 'djornl_gene' +_EDGE_NAME = 'djornl_edge' + + +def load_edges(path, score_type): + # Headers and sample row: + # node1 node2 edge edge_descrip layer_descrip + # AT1G01370 AT1G57820 4.40001558779779 AraNetv2_log-likelihood-score AraNetv2-LC_lit-curated-ppi + with open(path) as fd: + gene_verts = [] + edges = [] + csv_reader = csv.reader(fd, delimiter='\t') + next(csv_reader, None) # skip headers + for row in csv_reader: + cols = [c.strip() for c in row] + gene_verts.append({'_key': cols[0]}) + gene_verts.append({'_key': cols[1]}) + edges.append({ + '_from': f'{_GENE_VERT_NAME}/{cols[0]}', + '_to': f'{_GENE_VERT_NAME}/{cols[1]}', + 'score': float(cols[2]), + 'score_type': score_type, + }) + save_docs(_GENE_VERT_NAME, gene_verts) + save_docs(_EDGE_NAME, edges) + + +def load_pheno_assns(): + # Headers and sample row: + # node1 node2 edge edge_descrip layer_descrip + # Na23 AT4G10310 41.300822742442726 AraGWAS-Association_score AraGWAS-Phenotype_Associations + with open(_PHENO_ASSN_PATH) as fd: + pheno_verts = [] + gene_verts = [] + edge_verts = [] + csv_reader = csv.reader(fd, delimiter='\t') + next(csv_reader, None) # skip headers + for row in csv_reader: + cols = [c.strip() for c in row] + edge_doc = { + '_from': f'{_GENE_VERT_NAME}/{cols[1]}', + '_to': f'{_PHENO_VERT_NAME}/{cols[0]}', + 'score': float(cols[2]), + 'score_type': 'pheno_assn' + } + edge_verts.append(edge_doc) + pheno_verts.append({'_key': cols[0]}) + gene_verts.append({'_key': cols[1]}) + save_docs(_EDGE_NAME, edge_verts) + save_docs(_PHENO_VERT_NAME, pheno_verts) + save_docs(_GENE_VERT_NAME, gene_verts) + + +def load_vert_metadata(): + with open(_VERT_PATH) as fd: + genes = [] + phenos = [] + csv_reader = csv.reader(fd, delimiter=',') + next(csv_reader, None) # skip headers + for row in csv_reader: + cols = [c.strip() for c in row] + go_terms = [c.strip() for c in cols[10].split(',')] + node_type = cols[1] + doc = { + '_key': cols[0], + 'node_type': node_type, + 'transcript': cols[2], + 'gene_symbol': cols[3], + 'gene_full_name': cols[4], + 'gene_model_type': cols[5], + 'tair_computational_desc': cols[6], + 'tair_curator_summary': cols[7], + 'tair_short_desc': cols[8], + 'go_descr': cols[9], + 'go_terms': go_terms, + 'mapman_bin': cols[11], + 'mapman_name': cols[12], + 'mapman_desc': cols[13], + 'pheno_aragwas_id': cols[14], + 'pheno_desc1': cols[15], + 'pheno_desc2': cols[16], + 'pheno_desc3': cols[17], + 'pheno_ref': cols[18], + 'user_notes': cols[19], + } + if node_type == 'gene': + genes.append(doc) + elif node_type == 'pheno': + phenos.append(doc) + else: + raise RuntimeError(f"invalid node type {node_type}") + save_docs(_PHENO_VERT_NAME, phenos) + save_docs(_GENE_VERT_NAME, genes) + + +def load_cluster_data(): + """Annotate genes with cluster ID fields.""" + docs = [] + for path in _CLUSTER_PATHS: + with open(path) as fd: + csv_reader = csv.reader(fd, delimiter='\t') + for row in csv_reader: + cluster_label = row[0] + gene_keys = row[1:] + docs += [ + {'_key': key, 'cluster': cluster_label} + for key in gene_keys + ] + save_docs(_GENE_VERT_NAME, docs) + + +def main(): + load_vert_metadata() + load_pheno_assns() + edge_paths = [ + (_GENE_COEXPR_PATH, 'gene_coexpr'), + (_DOMAIN_CO_OCCUR_PATH, 'domain_co_occur'), + (_PPI_HITHRU_PATH, 'ppi_hithru'), + (_PPI_LIT_PATH, 'ppi_liter'), + ] + for (path, score_type) in edge_paths: + load_edges(path, score_type) + load_cluster_data() + + +def save_docs(coll_name, docs, on_dupe='update'): + resp = requests.put( + CONF.api_url + '/api/v1/documents', + params={'collection': coll_name, 'on_duplicate': on_dupe}, + headers={'Authorization': CONF.auth_token}, + data='\n'.join(json.dumps(d) for d in docs) + ) + if not resp.ok: + raise RuntimeError(resp.text) + else: + print(f"Saved docs to collection {coll_name}!") + print(resp.text) + print("=" * 80) + + +if __name__ == '__main__': + main() diff --git a/spec/importers/tox.ini b/spec/importers/tox.ini new file mode 100644 index 00000000..e44b8108 --- /dev/null +++ b/spec/importers/tox.ini @@ -0,0 +1,2 @@ +[flake8] +ignore = E501 diff --git a/spec/importers/utils/config.py b/spec/importers/utils/config.py new file mode 100644 index 00000000..4828768a --- /dev/null +++ b/spec/importers/utils/config.py @@ -0,0 +1,22 @@ +import dataclasses +import os + + +def load_from_env(prefix='RES_'): + """Load all configuration vars from environment variables""" + kwargs = {} + for field in dataclasses.fields(ImporterConfig): + var = prefix + field.name + if var in os.environ: + kwargs[field.name] = os.environ[prefix + field.name] + elif isinstance(field.default, dataclasses._MISSING_TYPE): # no default + print(f"Missing required env var: {var}") + exit(1) + return ImporterConfig(**kwargs) + + +@dataclasses.dataclass +class ImporterConfig: + """Defaults use test values""" + auth_token: str = 'admin_token' + api_url: str = 'http://localhost:5000' From 197dd9f6aebc66613314837020a623c5f1b6f6f2 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Thu, 18 Jun 2020 16:08:24 -0700 Subject: [PATCH 505/732] Fix readme --- spec/importers/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/importers/README.md b/spec/importers/README.md index f4373059..ea68b0bd 100644 --- a/spec/importers/README.md +++ b/spec/importers/README.md @@ -13,7 +13,7 @@ Global env vars: ### djornl -```py +```sh RES_auth_token=admin_token \ RES_base_path=/path/to/djornl_data \ python -m importers.djornl.main From 0010fef2e2433ea8101a6644f5f19db5d130f2e5 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Thu, 18 Jun 2020 16:16:18 -0700 Subject: [PATCH 506/732] Simplify config system --- spec/importers/djornl/main.py | 26 +++++++++++++------------- spec/importers/utils/config.py | 32 +++++++++++++++++--------------- 2 files changed, 30 insertions(+), 28 deletions(-) diff --git a/spec/importers/djornl/main.py b/spec/importers/djornl/main.py index 0b7b18c8..473d4e68 100644 --- a/spec/importers/djornl/main.py +++ b/spec/importers/djornl/main.py @@ -10,21 +10,21 @@ import csv import importers.utils.config as config -CONF = config.load_from_env() +CONF = config.load_from_env(extra_required=['ROOT_DATA_PATH']) # Path config -_BASE_PATH = os.environ['RES_base_path'] -_VERT_PATH = os.path.join(_BASE_PATH, 'aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv') +_ROOT = CONF['ROOT_DATA_PATH'] +_VERT_PATH = os.path.join(_ROOT, 'aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv') _CLUSTER_PATHS = [ - os.path.join(_BASE_PATH, 'cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I2_named.tsv'), - os.path.join(_BASE_PATH, 'cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I4_named.tsv'), - os.path.join(_BASE_PATH, 'cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I6_named.tsv'), + os.path.join(_ROOT, 'cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I2_named.tsv'), + os.path.join(_ROOT, 'cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I4_named.tsv'), + os.path.join(_ROOT, 'cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I6_named.tsv'), ] -_PHENO_ASSN_PATH = os.path.join(_BASE_PATH, 'aragwas_subnet_phenoassociations_AMW_083019.tsv') -_DOMAIN_CO_OCCUR_PATH = os.path.join(_BASE_PATH, 'aranetv2_subnet_AT-DC_anno_AF_082919.tsv') -_GENE_COEXPR_PATH = os.path.join(_BASE_PATH, 'aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.tsv') -_PPI_HITHRU_PATH = os.path.join(_BASE_PATH, 'aranetv2_subnet_AT-HT_anno_AF_082919.tsv') -_PPI_LIT_PATH = os.path.join(_BASE_PATH, 'aranetv2_subnet_AT-LC_anno_AF_082919.tsv') +_PHENO_ASSN_PATH = os.path.join(_ROOT, 'aragwas_subnet_phenoassociations_AMW_083019.tsv') +_DOMAIN_CO_OCCUR_PATH = os.path.join(_ROOT, 'aranetv2_subnet_AT-DC_anno_AF_082919.tsv') +_GENE_COEXPR_PATH = os.path.join(_ROOT, 'aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.tsv') +_PPI_HITHRU_PATH = os.path.join(_ROOT, 'aranetv2_subnet_AT-HT_anno_AF_082919.tsv') +_PPI_LIT_PATH = os.path.join(_ROOT, 'aranetv2_subnet_AT-LC_anno_AF_082919.tsv') # Collection name config _PHENO_VERT_NAME = 'djornl_phenotype' @@ -155,9 +155,9 @@ def main(): def save_docs(coll_name, docs, on_dupe='update'): resp = requests.put( - CONF.api_url + '/api/v1/documents', + CONF['API_URL'] + '/api/v1/documents', params={'collection': coll_name, 'on_duplicate': on_dupe}, - headers={'Authorization': CONF.auth_token}, + headers={'Authorization': CONF['AUTH_TOKEN']}, data='\n'.join(json.dumps(d) for d in docs) ) if not resp.ok: diff --git a/spec/importers/utils/config.py b/spec/importers/utils/config.py index 4828768a..fea49f42 100644 --- a/spec/importers/utils/config.py +++ b/spec/importers/utils/config.py @@ -1,22 +1,24 @@ -import dataclasses import os -def load_from_env(prefix='RES_'): +REQUIRED = [] +OPTIONAL = ['AUTH_TOKEN', 'API_URL'] +DEFAULTS = { + 'AUTH_TOKEN': 'admin_token', # test default + 'API_URL': 'http://localhost:5000', # test default +} + + +def load_from_env(extra_required=None, extra_optional=None, prefix='RES_'): """Load all configuration vars from environment variables""" - kwargs = {} - for field in dataclasses.fields(ImporterConfig): - var = prefix + field.name + conf = dict(DEFAULTS) + required = list(REQUIRED) + (extra_required or []) + optional = list(OPTIONAL) + (extra_optional or []) + for field in required + optional: + var = prefix + field if var in os.environ: - kwargs[field.name] = os.environ[prefix + field.name] - elif isinstance(field.default, dataclasses._MISSING_TYPE): # no default + conf[field] = os.environ[var] + elif field in required: print(f"Missing required env var: {var}") exit(1) - return ImporterConfig(**kwargs) - - -@dataclasses.dataclass -class ImporterConfig: - """Defaults use test values""" - auth_token: str = 'admin_token' - api_url: str = 'http://localhost:5000' + return conf From 286fdb702713acee1dce4ae8e7a2bbc6a56399be Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Thu, 18 Jun 2020 16:17:02 -0700 Subject: [PATCH 507/732] Add tox.ini comment --- spec/importers/tox.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/importers/tox.ini b/spec/importers/tox.ini index e44b8108..0c2d49bb 100644 --- a/spec/importers/tox.ini +++ b/spec/importers/tox.ini @@ -1,2 +1,3 @@ [flake8] +; ignore line length ignore = E501 From 376aa7f007e923fbb066f8155572a490312ae2e4 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Thu, 18 Jun 2020 16:18:24 -0700 Subject: [PATCH 508/732] Fix importers readme --- spec/importers/README.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/spec/importers/README.md b/spec/importers/README.md index ea68b0bd..3ea159b2 100644 --- a/spec/importers/README.md +++ b/spec/importers/README.md @@ -8,13 +8,12 @@ Configure importers through environment variables with the `RES_` prefix (which Global env vars: -* `RES_auth_token` - auth token to use when making requests to RE API - defaults to test value -* `RES_api_url` - url to use for the RE API - defaults to test value +* `RES_AUTH_TOKEN` - auth token to use when making requests to RE API - defaults to test value +* `RES_API_URL` - url to use for the RE API - defaults to test value ### djornl ```sh -RES_auth_token=admin_token \ -RES_base_path=/path/to/djornl_data \ +RE_ROOT_DATA_PATH=/path/to/djornl_data \ python -m importers.djornl.main ``` From 8fa64f5cdcde92853d9843564742d38e5b9baf72 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Thu, 18 Jun 2020 16:18:51 -0700 Subject: [PATCH 509/732] Fix env var name --- spec/importers/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/importers/README.md b/spec/importers/README.md index 3ea159b2..53df13cc 100644 --- a/spec/importers/README.md +++ b/spec/importers/README.md @@ -14,6 +14,6 @@ Global env vars: ### djornl ```sh -RE_ROOT_DATA_PATH=/path/to/djornl_data \ +RES_ROOT_DATA_PATH=/path/to/djornl_data \ python -m importers.djornl.main ``` From 21ee31ec332b5ea1c6c0893b44d244b59798978d Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Thu, 18 Jun 2020 16:19:33 -0700 Subject: [PATCH 510/732] Fix path --- spec/importers/djornl/main.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/importers/djornl/main.py b/spec/importers/djornl/main.py index 473d4e68..f68d3b55 100644 --- a/spec/importers/djornl/main.py +++ b/spec/importers/djornl/main.py @@ -16,9 +16,9 @@ _ROOT = CONF['ROOT_DATA_PATH'] _VERT_PATH = os.path.join(_ROOT, 'aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv') _CLUSTER_PATHS = [ - os.path.join(_ROOT, 'cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I2_named.tsv'), - os.path.join(_ROOT, 'cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I4_named.tsv'), - os.path.join(_ROOT, 'cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I6_named.tsv'), + os.path.join(_ROOT, 'cluster_data', 'out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I2_named.tsv'), + os.path.join(_ROOT, 'cluster_data', 'out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I4_named.tsv'), + os.path.join(_ROOT, 'cluster_data', 'out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I6_named.tsv'), ] _PHENO_ASSN_PATH = os.path.join(_ROOT, 'aragwas_subnet_phenoassociations_AMW_083019.tsv') _DOMAIN_CO_OCCUR_PATH = os.path.join(_ROOT, 'aranetv2_subnet_AT-DC_anno_AF_082919.tsv') From cc1fce5092c7f8bf33bcd676ce6146e4cf88ebca Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Thu, 18 Jun 2020 16:21:28 -0700 Subject: [PATCH 511/732] Simplify config further --- spec/importers/utils/config.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/spec/importers/utils/config.py b/spec/importers/utils/config.py index fea49f42..fc9185c8 100644 --- a/spec/importers/utils/config.py +++ b/spec/importers/utils/config.py @@ -14,11 +14,10 @@ def load_from_env(extra_required=None, extra_optional=None, prefix='RES_'): conf = dict(DEFAULTS) required = list(REQUIRED) + (extra_required or []) optional = list(OPTIONAL) + (extra_optional or []) - for field in required + optional: - var = prefix + field - if var in os.environ: - conf[field] = os.environ[var] - elif field in required: - print(f"Missing required env var: {var}") + for field in required: + if (prefix + field) not in os.environ: + print(f"Missing required env var: {prefix + field}") exit(1) + for field in required + optional: + conf[field] = os.environ[prefix + field] return conf From 8cffa6104e6573f4eb0fcdacc12cc0e2be9f129a Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Thu, 18 Jun 2020 16:29:32 -0700 Subject: [PATCH 512/732] Improve importer config further --- spec/importers/djornl/main.py | 14 ++++++++++---- spec/importers/utils/config.py | 3 ++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/spec/importers/djornl/main.py b/spec/importers/djornl/main.py index f68d3b55..c8ffe544 100644 --- a/spec/importers/djornl/main.py +++ b/spec/importers/djornl/main.py @@ -31,6 +31,12 @@ _GENE_VERT_NAME = 'djornl_gene' _EDGE_NAME = 'djornl_edge' +# Edge score type names +_COEXPR_TYPE = 'gene_coexpr' +_CO_OCCUR_TYPE = 'domain_co_occur' +_HITHRU_TYPE = 'ppi_hithru' +_LIT_TYPE = 'ppi_liter' + def load_edges(path, score_type): # Headers and sample row: @@ -143,10 +149,10 @@ def main(): load_vert_metadata() load_pheno_assns() edge_paths = [ - (_GENE_COEXPR_PATH, 'gene_coexpr'), - (_DOMAIN_CO_OCCUR_PATH, 'domain_co_occur'), - (_PPI_HITHRU_PATH, 'ppi_hithru'), - (_PPI_LIT_PATH, 'ppi_liter'), + (_GENE_COEXPR_PATH, _COEXPR_TYPE), + (_DOMAIN_CO_OCCUR_PATH, _CO_OCCUR_TYPE), + (_PPI_HITHRU_PATH, _HITHRU_TYPE), + (_PPI_LIT_PATH, _LIT_TYPE), ] for (path, score_type) in edge_paths: load_edges(path, score_type) diff --git a/spec/importers/utils/config.py b/spec/importers/utils/config.py index fc9185c8..ab966e08 100644 --- a/spec/importers/utils/config.py +++ b/spec/importers/utils/config.py @@ -19,5 +19,6 @@ def load_from_env(extra_required=None, extra_optional=None, prefix='RES_'): print(f"Missing required env var: {prefix + field}") exit(1) for field in required + optional: - conf[field] = os.environ[prefix + field] + if (prefix + field) in os.environ: + conf[field] = os.environ[prefix + field] return conf From 1da0939f4c8349100195e045b2986d523616341c Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Thu, 18 Jun 2020 16:35:03 -0700 Subject: [PATCH 513/732] Add docstring for config module --- spec/importers/utils/config.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/spec/importers/utils/config.py b/spec/importers/utils/config.py index ab966e08..878b9fee 100644 --- a/spec/importers/utils/config.py +++ b/spec/importers/utils/config.py @@ -1,3 +1,7 @@ +""" +Loads and initializes configuration data for importers using environment +variables and a set of default values. +""" import os From a27dbbbbd68db64113d4edaa941e7cf0ec8b93f7 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 23 Jun 2020 13:19:26 -0700 Subject: [PATCH 514/732] Add ArangoSearch view for djornl_gene along with query --- .../djornl/djornl_search_genes.yaml | 26 ++++++ spec/views/Compounds.json | 2 +- spec/views/Reactions.json | 2 +- spec/views/djornl/djornl_gene_view.json | 82 +++++++++++++++++++ 4 files changed, 110 insertions(+), 2 deletions(-) create mode 100644 spec/stored_queries/djornl/djornl_search_genes.yaml create mode 100644 spec/views/djornl/djornl_gene_view.json diff --git a/spec/stored_queries/djornl/djornl_search_genes.yaml b/spec/stored_queries/djornl/djornl_search_genes.yaml new file mode 100644 index 00000000..8ebe4b45 --- /dev/null +++ b/spec/stored_queries/djornl/djornl_search_genes.yaml @@ -0,0 +1,26 @@ +# Simple fuzzy search genes using the djornl_gene_view ArangoSearch view +name: djornl_search_genes +params: + type: object + required: [query] + properties: + query: + type: string + title: Query Text + minLength: 3 +query: | + FOR g IN djornl_gene_view + SEARCH ANALYZER( + PHRASE(g.tair_computational_desc, @query) OR + PHRASE(g.tair_short_desc, @query) OR + PHRASE(g.mapman_desc, @query) OR + PHRASE(g.go_desc, @query) OR + PHRASE(g.mapman_name, @query) OR + PHRASE(g.mapman_desc, @query) OR + PHRASE(g.pheno_desc1, @query) OR + PHRASE(g.pheno_desc2, @query) OR + PHRASE(g.pheno_desc3, @query) OR + PHRASE(g.user_notes, @query), + 'text_en' + ) + RETURN g diff --git a/spec/views/Compounds.json b/spec/views/Compounds.json index a4214352..79e8c460 100644 --- a/spec/views/Compounds.json +++ b/spec/views/Compounds.json @@ -7,7 +7,7 @@ "commitIntervalMsec": 1000, "consolidationPolicy": { "type": "bytes_accum", - "threshold": 0.10000000149011612 + "threshold": 0.1 }, "globallyUniqueId": "h5455DEB9D2A1/9852581", "cleanupIntervalStep": 10, diff --git a/spec/views/Reactions.json b/spec/views/Reactions.json index a7822dfd..15d6b0c9 100644 --- a/spec/views/Reactions.json +++ b/spec/views/Reactions.json @@ -7,7 +7,7 @@ "commitIntervalMsec": 1000, "consolidationPolicy": { "type": "bytes_accum", - "threshold": 0.10000000149011612 + "threshold": 0.1 }, "globallyUniqueId": "h5455DEB9D2A1/9853332", "cleanupIntervalStep": 10, diff --git a/spec/views/djornl/djornl_gene_view.json b/spec/views/djornl/djornl_gene_view.json new file mode 100644 index 00000000..20af19fe --- /dev/null +++ b/spec/views/djornl/djornl_gene_view.json @@ -0,0 +1,82 @@ +{ + "writebufferIdle": 64, + "writebufferActive": 0, + "type": "arangosearch", + "primarySort": [], + "writebufferSizeMax": 33554432, + "commitIntervalMsec": 1000, + "consolidationPolicy": { + "type": "bytes_accum", + "threshold": 0.1 + }, + "globallyUniqueId": "c98232107/", + "cleanupIntervalStep": 2, + "id": "98232107", + "links": { + "djornl_gene": { + "analyzers": [ + "identity" + ], + "fields": { + "transcript": {}, + "tair_computational_desc": { + "analyzers": [ + "text_en" + ] + }, + "tair_short_desc": { + "analyzers": [ + "text_en" + ] + }, + "gene_model_type": {}, + "mapman_desc": { + "analyzers": [ + "text_en" + ] + }, + "go_terms": {}, + "go_desc": { + "analyzers": [ + "text_en" + ] + }, + "mapman_name": { + "analyzers": [ + "text_en" + ] + }, + "mapman_desc": { + "analyzers": [ + "text_en" + ] + }, + "pheno_desc1": { + "analyzers": [ + "text_en" + ] + }, + "pheno_desc2": { + "analyzers": [ + "text_en" + ] + }, + "pheno_desc3": { + "analyzers": [ + "text_en" + ] + }, + "pheno_ref": {}, + "user_notes": { + "analyzers": [ + "text_en" + ] + } + }, + "includeAllFields": false, + "storeValues": "none", + "trackListPositions": false + } + }, + "consolidationIntervalMsec": 60000 +} From 99cf4c47644b6a081c58da8e5322597926629f15 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 23 Jun 2020 14:49:42 -0700 Subject: [PATCH 515/732] Add go_terms and transcript into djornl_search_genes --- .../djornl/djornl_search_genes.yaml | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/spec/stored_queries/djornl/djornl_search_genes.yaml b/spec/stored_queries/djornl/djornl_search_genes.yaml index 8ebe4b45..179fe0c8 100644 --- a/spec/stored_queries/djornl/djornl_search_genes.yaml +++ b/spec/stored_queries/djornl/djornl_search_genes.yaml @@ -11,16 +11,18 @@ params: query: | FOR g IN djornl_gene_view SEARCH ANALYZER( - PHRASE(g.tair_computational_desc, @query) OR - PHRASE(g.tair_short_desc, @query) OR - PHRASE(g.mapman_desc, @query) OR - PHRASE(g.go_desc, @query) OR - PHRASE(g.mapman_name, @query) OR - PHRASE(g.mapman_desc, @query) OR - PHRASE(g.pheno_desc1, @query) OR - PHRASE(g.pheno_desc2, @query) OR - PHRASE(g.pheno_desc3, @query) OR - PHRASE(g.user_notes, @query), - 'text_en' - ) + PHRASE(g.tair_computational_desc, @query) OR + PHRASE(g.tair_short_desc, @query) OR + PHRASE(g.mapman_desc, @query) OR + PHRASE(g.go_desc, @query) OR + PHRASE(g.mapman_name, @query) OR + PHRASE(g.mapman_desc, @query) OR + PHRASE(g.pheno_desc1, @query) OR + PHRASE(g.pheno_desc2, @query) OR + PHRASE(g.pheno_desc3, @query) OR + PHRASE(g.user_notes, @query), + 'text_en' + ) + OR PHRASE(g.go_terms, @query) + OR PHRASE(g.transcript, @query) RETURN g From 9d18d027a2b612a740b3454695a8a9e8df664575 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 23 Jun 2020 14:58:21 -0700 Subject: [PATCH 516/732] Add query to find clusters and all neighbors --- .../djornl/djornl_cluster_neighbors.yaml | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 spec/stored_queries/djornl/djornl_cluster_neighbors.yaml diff --git a/spec/stored_queries/djornl/djornl_cluster_neighbors.yaml b/spec/stored_queries/djornl/djornl_cluster_neighbors.yaml new file mode 100644 index 00000000..f4076337 --- /dev/null +++ b/spec/stored_queries/djornl/djornl_cluster_neighbors.yaml @@ -0,0 +1,28 @@ +# Fetch the neighbors of all vertices in a certain cluster +name: djornl_gene_neighbors +params: + type: object + required: [cluster_name, cluster_id] + properties: + cluster_name: + type: string + enum: [cluster_I2, cluster_I4, cluster_I6] + cluster_id: + type: string + examples: [Cluster1, Cluster2] + distance: + type: integer + title: Traversal Distance + description: How many hops to find neighbors and neighbors-of-neighbors + default: 1 + minimum: 1 + maximum: 100 +query: | + FOR gene IN djornl_gene + FILTER gene[@cluster_name] = @cluster_id + LET neighbors = ( + FOR neighbor IN @distance ANY gene djornl_edge + OPTIONS {bfs: true, uniqueVertices: "global"} + RETURN neighbor + ) + RETURN {gene, neighbors} From 4f3b28baa205910b7ace847613ee3e01538a4ea8 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 23 Jun 2020 15:01:41 -0700 Subject: [PATCH 517/732] Fix name and traversal thing --- spec/stored_queries/djornl/djornl_cluster_neighbors.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/stored_queries/djornl/djornl_cluster_neighbors.yaml b/spec/stored_queries/djornl/djornl_cluster_neighbors.yaml index f4076337..abaad796 100644 --- a/spec/stored_queries/djornl/djornl_cluster_neighbors.yaml +++ b/spec/stored_queries/djornl/djornl_cluster_neighbors.yaml @@ -1,5 +1,5 @@ # Fetch the neighbors of all vertices in a certain cluster -name: djornl_gene_neighbors +name: djornl_cluster_neighbors params: type: object required: [cluster_name, cluster_id] @@ -21,7 +21,7 @@ query: | FOR gene IN djornl_gene FILTER gene[@cluster_name] = @cluster_id LET neighbors = ( - FOR neighbor IN @distance ANY gene djornl_edge + FOR neighbor IN 1..@distance ANY gene djornl_edge OPTIONS {bfs: true, uniqueVertices: "global"} RETURN neighbor ) From 2a498dc662220bff2bbc01b9761fbc2ff752c9a9 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 23 Jun 2020 15:03:45 -0700 Subject: [PATCH 518/732] Fix syntax --- spec/stored_queries/djornl/djornl_cluster_neighbors.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/stored_queries/djornl/djornl_cluster_neighbors.yaml b/spec/stored_queries/djornl/djornl_cluster_neighbors.yaml index abaad796..0e7c3ec4 100644 --- a/spec/stored_queries/djornl/djornl_cluster_neighbors.yaml +++ b/spec/stored_queries/djornl/djornl_cluster_neighbors.yaml @@ -19,7 +19,7 @@ params: maximum: 100 query: | FOR gene IN djornl_gene - FILTER gene[@cluster_name] = @cluster_id + FILTER gene[@cluster_name] == @cluster_id LET neighbors = ( FOR neighbor IN 1..@distance ANY gene djornl_edge OPTIONS {bfs: true, uniqueVertices: "global"} From fec25a235676c33f2b94100a466fc2e9314da70f Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 23 Jun 2020 16:00:18 -0700 Subject: [PATCH 519/732] Some cluster import and query fixes --- spec/importers/djornl/main.py | 26 +++++++++++++------ .../djornl/djornl_cluster_neighbors.yaml | 17 +++++++----- 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/spec/importers/djornl/main.py b/spec/importers/djornl/main.py index c8ffe544..1dd73a86 100644 --- a/spec/importers/djornl/main.py +++ b/spec/importers/djornl/main.py @@ -15,11 +15,21 @@ # Path config _ROOT = CONF['ROOT_DATA_PATH'] _VERT_PATH = os.path.join(_ROOT, 'aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv') -_CLUSTER_PATHS = [ - os.path.join(_ROOT, 'cluster_data', 'out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I2_named.tsv'), - os.path.join(_ROOT, 'cluster_data', 'out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I4_named.tsv'), - os.path.join(_ROOT, 'cluster_data', 'out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I6_named.tsv'), -] +_CLUSTER_BASE = os.path.join(_ROOT, 'cluster_data') +_CLUSTER_PATHS = { + 'cluster_I2': os.path.join( + _CLUSTER_BASE, + 'out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I2_named.tsv' + ), + 'cluster_I4': os.path.join( + _CLUSTER_BASE, + 'out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I4_named.tsv' + ), + 'cluster_I6': os.path.join( + _CLUSTER_BASE, + 'out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I6_named.tsv' + ), +} _PHENO_ASSN_PATH = os.path.join(_ROOT, 'aragwas_subnet_phenoassociations_AMW_083019.tsv') _DOMAIN_CO_OCCUR_PATH = os.path.join(_ROOT, 'aranetv2_subnet_AT-DC_anno_AF_082919.tsv') _GENE_COEXPR_PATH = os.path.join(_ROOT, 'aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.tsv') @@ -132,14 +142,14 @@ def load_vert_metadata(): def load_cluster_data(): """Annotate genes with cluster ID fields.""" docs = [] - for path in _CLUSTER_PATHS: + for (cluster_label, path) in _CLUSTER_PATHS.items(): with open(path) as fd: csv_reader = csv.reader(fd, delimiter='\t') for row in csv_reader: - cluster_label = row[0] + cluster_id = row[0] gene_keys = row[1:] docs += [ - {'_key': key, 'cluster': cluster_label} + {'_key': key, cluster_label: cluster_id} for key in gene_keys ] save_docs(_GENE_VERT_NAME, docs) diff --git a/spec/stored_queries/djornl/djornl_cluster_neighbors.yaml b/spec/stored_queries/djornl/djornl_cluster_neighbors.yaml index 0e7c3ec4..07796b41 100644 --- a/spec/stored_queries/djornl/djornl_cluster_neighbors.yaml +++ b/spec/stored_queries/djornl/djornl_cluster_neighbors.yaml @@ -17,12 +17,15 @@ params: default: 1 minimum: 1 maximum: 100 +# phenotype nodes can be returned +query_prefix: WITH djornl_phenotype query: | - FOR gene IN djornl_gene - FILTER gene[@cluster_name] == @cluster_id - LET neighbors = ( - FOR neighbor IN 1..@distance ANY gene djornl_edge + LET results = ( + FOR gene IN djornl_gene + FILTER gene[@cluster_name] == @cluster_id + FOR node IN 0..@distance ANY gene djornl_edge OPTIONS {bfs: true, uniqueVertices: "global"} - RETURN neighbor - ) - RETURN {gene, neighbors} + RETURN DISTINCT node + ) + // Return nested results to get around any limit (by default limited to 1k results) + return {results} From ba2eec11c8f27b85f7338bbc8639dd737c88c636 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Thu, 25 Jun 2020 12:23:31 -0700 Subject: [PATCH 520/732] Return edges for cluster neighbors --- .../djornl/djornl_cluster_neighbors.yaml | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/spec/stored_queries/djornl/djornl_cluster_neighbors.yaml b/spec/stored_queries/djornl/djornl_cluster_neighbors.yaml index 07796b41..d8f8a9be 100644 --- a/spec/stored_queries/djornl/djornl_cluster_neighbors.yaml +++ b/spec/stored_queries/djornl/djornl_cluster_neighbors.yaml @@ -20,12 +20,18 @@ params: # phenotype nodes can be returned query_prefix: WITH djornl_phenotype query: | - LET results = ( + LET cluster = ( FOR gene IN djornl_gene FILTER gene[@cluster_name] == @cluster_id - FOR node IN 0..@distance ANY gene djornl_edge + RETURN gene + ) + // Returns empty list if @distance is 0 + LET neighbors = ( + FOR gene IN cluster + FOR node, edge IN 0..@distance ANY gene djornl_edge OPTIONS {bfs: true, uniqueVertices: "global"} - RETURN DISTINCT node + FILTER edge + RETURN DISTINCT {node, edge} ) // Return nested results to get around any limit (by default limited to 1k results) - return {results} + return {cluster, neighbors} From 7ccc9010208652f47b8348e07c502586cfd4a5e8 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Thu, 25 Jun 2020 14:31:00 -0700 Subject: [PATCH 521/732] Tweak the djornl cluster query --- .../djornl/djornl_cluster_neighbors.yaml | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/spec/stored_queries/djornl/djornl_cluster_neighbors.yaml b/spec/stored_queries/djornl/djornl_cluster_neighbors.yaml index d8f8a9be..ac0121ba 100644 --- a/spec/stored_queries/djornl/djornl_cluster_neighbors.yaml +++ b/spec/stored_queries/djornl/djornl_cluster_neighbors.yaml @@ -20,18 +20,21 @@ params: # phenotype nodes can be returned query_prefix: WITH djornl_phenotype query: | - LET cluster = ( + LET node_ids = ( FOR gene IN djornl_gene FILTER gene[@cluster_name] == @cluster_id - RETURN gene - ) - // Returns empty list if @distance is 0 - LET neighbors = ( - FOR gene IN cluster - FOR node, edge IN 0..@distance ANY gene djornl_edge + FOR node IN 0..@distance ANY gene djornl_edge OPTIONS {bfs: true, uniqueVertices: "global"} - FILTER edge - RETURN DISTINCT {node, edge} + RETURN DISTINCT node._id + ) + let edges = ( + FOR edge IN djornl_edge + FILTER edge._from IN node_ids AND edge._to IN node_ids + RETURN edge + ) + let nodes = ( + FOR node IN djornl_gene + FILTER node._id IN node_ids + return node ) - // Return nested results to get around any limit (by default limited to 1k results) - return {cluster, neighbors} + RETURN {nodes, edges} From 4c3aa325183ed3605e66553dad09c4fb392d4d78 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Thu, 25 Jun 2020 17:32:43 -0700 Subject: [PATCH 522/732] Change query param to search_text param --- .../djornl/djornl_search_genes.yaml | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/spec/stored_queries/djornl/djornl_search_genes.yaml b/spec/stored_queries/djornl/djornl_search_genes.yaml index 179fe0c8..a8e2174e 100644 --- a/spec/stored_queries/djornl/djornl_search_genes.yaml +++ b/spec/stored_queries/djornl/djornl_search_genes.yaml @@ -4,25 +4,25 @@ params: type: object required: [query] properties: - query: + search_text: type: string title: Query Text minLength: 3 query: | FOR g IN djornl_gene_view SEARCH ANALYZER( - PHRASE(g.tair_computational_desc, @query) OR - PHRASE(g.tair_short_desc, @query) OR - PHRASE(g.mapman_desc, @query) OR - PHRASE(g.go_desc, @query) OR - PHRASE(g.mapman_name, @query) OR - PHRASE(g.mapman_desc, @query) OR - PHRASE(g.pheno_desc1, @query) OR - PHRASE(g.pheno_desc2, @query) OR - PHRASE(g.pheno_desc3, @query) OR - PHRASE(g.user_notes, @query), + PHRASE(g.tair_computational_desc, @search_text) OR + PHRASE(g.tair_short_desc, @search_text) OR + PHRASE(g.mapman_desc, @search_text) OR + PHRASE(g.go_desc, @search_text) OR + PHRASE(g.mapman_name, @search_text) OR + PHRASE(g.mapman_desc, @search_text) OR + PHRASE(g.pheno_desc1, @search_text) OR + PHRASE(g.pheno_desc2, @search_text) OR + PHRASE(g.pheno_desc3, @search_text) OR + PHRASE(g.user_notes, @search_text), 'text_en' ) - OR PHRASE(g.go_terms, @query) - OR PHRASE(g.transcript, @query) + OR PHRASE(g.go_terms, @search_text) + OR PHRASE(g.transcript, @search_text) RETURN g From a70ab226715cb272269260fb002cd76ce5267ff8 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Thu, 25 Jun 2020 17:35:32 -0700 Subject: [PATCH 523/732] Bugfix on gene search --- spec/stored_queries/djornl/djornl_search_genes.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/stored_queries/djornl/djornl_search_genes.yaml b/spec/stored_queries/djornl/djornl_search_genes.yaml index a8e2174e..226b1280 100644 --- a/spec/stored_queries/djornl/djornl_search_genes.yaml +++ b/spec/stored_queries/djornl/djornl_search_genes.yaml @@ -2,7 +2,7 @@ name: djornl_search_genes params: type: object - required: [query] + required: [search_text] properties: search_text: type: string From 04d6bed598e185268ee642b0c70a92fcfa220929 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Fri, 26 Jun 2020 14:37:47 -0700 Subject: [PATCH 524/732] Add query to fetch all verts --- .../djornl/djornl_fetch_all_vertices.yaml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 spec/stored_queries/djornl/djornl_fetch_all_vertices.yaml diff --git a/spec/stored_queries/djornl/djornl_fetch_all_vertices.yaml b/spec/stored_queries/djornl/djornl_fetch_all_vertices.yaml new file mode 100644 index 00000000..1bcf1051 --- /dev/null +++ b/spec/stored_queries/djornl/djornl_fetch_all_vertices.yaml @@ -0,0 +1,14 @@ +# Fetch all vertices in the djornl subgraph +name: djornl_fetch_all_vertices +params: + type: object +query: | + LET genes = ( + FOR v IN djornl_gene + RETURN v + ) + LET phenotypes = ( + FOR v IN djornl_phenotype + RETURN v + ) + RETURN {genes, phenotypes} From 3b028fc4ba03e6116d27fe575727a50956128b48 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Fri, 26 Jun 2020 14:45:05 -0700 Subject: [PATCH 525/732] Add edges --- ...ornl_fetch_all_vertices.yaml => djornl_fetch_all.yaml} | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) rename spec/stored_queries/djornl/{djornl_fetch_all_vertices.yaml => djornl_fetch_all.yaml} (63%) diff --git a/spec/stored_queries/djornl/djornl_fetch_all_vertices.yaml b/spec/stored_queries/djornl/djornl_fetch_all.yaml similarity index 63% rename from spec/stored_queries/djornl/djornl_fetch_all_vertices.yaml rename to spec/stored_queries/djornl/djornl_fetch_all.yaml index 1bcf1051..85eae0c6 100644 --- a/spec/stored_queries/djornl/djornl_fetch_all_vertices.yaml +++ b/spec/stored_queries/djornl/djornl_fetch_all.yaml @@ -1,5 +1,5 @@ # Fetch all vertices in the djornl subgraph -name: djornl_fetch_all_vertices +name: djornl_fetch_all params: type: object query: | @@ -11,4 +11,8 @@ query: | FOR v IN djornl_phenotype RETURN v ) - RETURN {genes, phenotypes} + LET edges = ( + FOR e IN djornl_edge + RETURN e + ) + RETURN {genes, phenotypes, edges} From fda1c9a683bfbecc19d93ed6440860158d3a9411 Mon Sep 17 00:00:00 2001 From: Zhenyuan Lu Date: Wed, 8 Jul 2020 11:56:41 -0400 Subject: [PATCH 526/732] update GO_get_associated_ws_objects.yaml to add total features count and put offset+limit on ws_obj group --- .../GO/GO_get_associated_ws_objects.yaml | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/spec/stored_queries/GO/GO_get_associated_ws_objects.yaml b/spec/stored_queries/GO/GO_get_associated_ws_objects.yaml index d4051527..3e404ddf 100644 --- a/spec/stored_queries/GO/GO_get_associated_ws_objects.yaml +++ b/spec/stored_queries/GO/GO_get_associated_ws_objects.yaml @@ -24,7 +24,7 @@ params: title: Versioning timestamp query_prefix: WITH ws_genome_features, ws_object_version query: | - LET results=( + LET raw=( FOR t in GO_terms FILTER t.id == @id FILTER t.created <= @ts AND t.expired >= @ts @@ -32,16 +32,17 @@ query: | FOR v, e, p IN 2 INBOUND t ws_feature_has_GO_annotation, ws_genome_has_feature FILTER p.edges[0].created <= @ts AND p.edges[0].expired >= @ts FILTER v.is_public OR v.workspace_id IN ws_ids - SORT v.workspace_id ASC - LIMIT @offset, @limit + SORT v.workspace_id ASC, p.vertices[1].feature_id ASC RETURN DISTINCT { ws_obj: KEEP(v, ['workspace_id', 'object_id', 'version', 'name']), feature: KEEP(p.vertices[1], ['feature_id', 'updated_at']) } ) - FOR r IN results - COLLECT ws_obj=r.ws_obj INTO features=r.feature - return { - ws_obj: ws_obj, - features: features - } + LET total_count = COUNT(raw) + LET results = ( + FOR r IN raw + COLLECT ws_obj=r.ws_obj INTO features=r.feature + LIMIT @offset, @limit + RETURN {ws_obj, features} + ) + RETURN {results, total_count} From f9bd08811527d8e30fbf637d1e3202c319c41cc7 Mon Sep 17 00:00:00 2001 From: ialarmedalien Date: Thu, 9 Jul 2020 16:59:51 -0700 Subject: [PATCH 527/732] First commit of DJ ORNL schema and query revisions, plus tests Adding in validation of views and a little bit of tidying --- spec/README.md | 4 +- spec/importers/djornl/main.py | 183 +--------- spec/importers/djornl/parser.py | 213 ++++++++++++ spec/schemas/djornl/djornl_edge.yaml | 75 ++--- .../{djornl_gene.yaml => djornl_node.yaml} | 68 ++-- spec/schemas/djornl/djornl_phenotype.yaml | 60 ---- .../djornl/djornl_cluster_neighbors.yaml | 40 --- .../djornl/djornl_fetch_all.yaml | 13 +- .../djornl/djornl_fetch_clusters.yaml | 49 +++ .../djornl/djornl_fetch_genes.yaml | 32 +- .../djornl/djornl_fetch_phenotypes.yaml | 32 +- .../djornl/djornl_gene_neighbors.yaml | 31 -- .../djornl/djornl_search_genes.yaml | 28 -- .../djornl/djornl_search_nodes.yaml | 50 +++ ...aragwas-MERGED-AMW-v2_091319_nodeTable.csv | 14 + .../merged_edges-AMW-060820_AF.tsv | 8 + ...aragwas-MERGED-AMW-v2_091319_nodeTable.csv | 1 + ...p10percent_anno_AF_082919.abc.I2_named.tsv | 1 + ...p10percent_anno_AF_082919.abc.I4_named.tsv | 1 + ...p10percent_anno_AF_082919.abc.I6_named.tsv | 1 + .../merged_edges-AMW-060820_AF.tsv | 1 + ...aragwas-MERGED-AMW-v2_091319_nodeTable.csv | 15 + .../merged_edges-AMW-060820_AF.tsv | 9 + spec/test/djornl/results.json | 313 ++++++++++++++++++ ...aragwas-MERGED-AMW-v2_091319_nodeTable.csv | 15 + ...p10percent_anno_AF_082919.abc.I2_named.tsv | 5 + ...p10percent_anno_AF_082919.abc.I4_named.tsv | 1 + ...p10percent_anno_AF_082919.abc.I6_named.tsv | 4 + .../test_data/merged_edges-AMW-060820_AF.tsv | 11 + spec/test/helpers.py | 32 ++ spec/test/stored_queries/helpers.py | 13 +- spec/test/stored_queries/test_djornl.py | 220 ++++++++++++ .../test/stored_queries/test_djornl_parser.py | 145 ++++++++ spec/test/validate.py | 41 +++ spec/views/Compounds.json | 5 +- spec/views/README.md | 4 +- spec/views/Reactions.json | 5 +- ...l_gene_view.json => djornl_node_view.json} | 22 +- 38 files changed, 1309 insertions(+), 456 deletions(-) create mode 100644 spec/importers/djornl/parser.py rename spec/schemas/djornl/{djornl_gene.yaml => djornl_node.yaml} (53%) delete mode 100644 spec/schemas/djornl/djornl_phenotype.yaml delete mode 100644 spec/stored_queries/djornl/djornl_cluster_neighbors.yaml create mode 100644 spec/stored_queries/djornl/djornl_fetch_clusters.yaml delete mode 100644 spec/stored_queries/djornl/djornl_gene_neighbors.yaml delete mode 100644 spec/stored_queries/djornl/djornl_search_genes.yaml create mode 100644 spec/stored_queries/djornl/djornl_search_nodes.yaml create mode 100644 spec/test/djornl/col_count_errors/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv create mode 100644 spec/test/djornl/col_count_errors/merged_edges-AMW-060820_AF.tsv create mode 100644 spec/test/djornl/empty_files/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv create mode 100644 spec/test/djornl/empty_files/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I2_named.tsv create mode 100644 spec/test/djornl/empty_files/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I4_named.tsv create mode 100644 spec/test/djornl/empty_files/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I6_named.tsv create mode 100644 spec/test/djornl/empty_files/merged_edges-AMW-060820_AF.tsv create mode 100644 spec/test/djornl/invalid_types/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv create mode 100644 spec/test/djornl/invalid_types/merged_edges-AMW-060820_AF.tsv create mode 100644 spec/test/djornl/results.json create mode 100644 spec/test/djornl/test_data/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv create mode 100644 spec/test/djornl/test_data/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I2_named.tsv create mode 100644 spec/test/djornl/test_data/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I4_named.tsv create mode 100644 spec/test/djornl/test_data/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I6_named.tsv create mode 100644 spec/test/djornl/test_data/merged_edges-AMW-060820_AF.tsv create mode 100644 spec/test/stored_queries/test_djornl.py create mode 100644 spec/test/stored_queries/test_djornl_parser.py rename spec/views/djornl/{djornl_gene_view.json => djornl_node_view.json} (87%) diff --git a/spec/README.md b/spec/README.md index 610139ca..9e0eca17 100644 --- a/spec/README.md +++ b/spec/README.md @@ -2,9 +2,9 @@ This repo holds the [stored queries](stored_queries), [schemas](schemas), and [migrations](migrations) for the relation engine graph database service. -These specifications are used by the [Relation Engine API]() +These specifications are used by the [Relation Engine API](https://github.com/kbase/relation_engine_api). -* **Stored queries** are stored [AQL queries](https://docs.arangodb.com/3.3/AQL/index.html) that can be used +* **Stored queries** are stored [AQL queries](https://docs.arangodb.com/3.5/AQL/index.html) that can be used by KBase apps to fetch data from the database. * **Schemas** are [JSON schemas](https://json-schema.org/) that define what form of data can be stored in the database's collections. diff --git a/spec/importers/djornl/main.py b/spec/importers/djornl/main.py index 1dd73a86..ba1bb005 100644 --- a/spec/importers/djornl/main.py +++ b/spec/importers/djornl/main.py @@ -4,185 +4,8 @@ Running this requires a set of source files provided by the ORNL group. """ -import json -import requests -import os -import csv - -import importers.utils.config as config -CONF = config.load_from_env(extra_required=['ROOT_DATA_PATH']) - -# Path config -_ROOT = CONF['ROOT_DATA_PATH'] -_VERT_PATH = os.path.join(_ROOT, 'aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv') -_CLUSTER_BASE = os.path.join(_ROOT, 'cluster_data') -_CLUSTER_PATHS = { - 'cluster_I2': os.path.join( - _CLUSTER_BASE, - 'out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I2_named.tsv' - ), - 'cluster_I4': os.path.join( - _CLUSTER_BASE, - 'out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I4_named.tsv' - ), - 'cluster_I6': os.path.join( - _CLUSTER_BASE, - 'out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I6_named.tsv' - ), -} -_PHENO_ASSN_PATH = os.path.join(_ROOT, 'aragwas_subnet_phenoassociations_AMW_083019.tsv') -_DOMAIN_CO_OCCUR_PATH = os.path.join(_ROOT, 'aranetv2_subnet_AT-DC_anno_AF_082919.tsv') -_GENE_COEXPR_PATH = os.path.join(_ROOT, 'aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.tsv') -_PPI_HITHRU_PATH = os.path.join(_ROOT, 'aranetv2_subnet_AT-HT_anno_AF_082919.tsv') -_PPI_LIT_PATH = os.path.join(_ROOT, 'aranetv2_subnet_AT-LC_anno_AF_082919.tsv') - -# Collection name config -_PHENO_VERT_NAME = 'djornl_phenotype' -_GENE_VERT_NAME = 'djornl_gene' -_EDGE_NAME = 'djornl_edge' - -# Edge score type names -_COEXPR_TYPE = 'gene_coexpr' -_CO_OCCUR_TYPE = 'domain_co_occur' -_HITHRU_TYPE = 'ppi_hithru' -_LIT_TYPE = 'ppi_liter' - - -def load_edges(path, score_type): - # Headers and sample row: - # node1 node2 edge edge_descrip layer_descrip - # AT1G01370 AT1G57820 4.40001558779779 AraNetv2_log-likelihood-score AraNetv2-LC_lit-curated-ppi - with open(path) as fd: - gene_verts = [] - edges = [] - csv_reader = csv.reader(fd, delimiter='\t') - next(csv_reader, None) # skip headers - for row in csv_reader: - cols = [c.strip() for c in row] - gene_verts.append({'_key': cols[0]}) - gene_verts.append({'_key': cols[1]}) - edges.append({ - '_from': f'{_GENE_VERT_NAME}/{cols[0]}', - '_to': f'{_GENE_VERT_NAME}/{cols[1]}', - 'score': float(cols[2]), - 'score_type': score_type, - }) - save_docs(_GENE_VERT_NAME, gene_verts) - save_docs(_EDGE_NAME, edges) - - -def load_pheno_assns(): - # Headers and sample row: - # node1 node2 edge edge_descrip layer_descrip - # Na23 AT4G10310 41.300822742442726 AraGWAS-Association_score AraGWAS-Phenotype_Associations - with open(_PHENO_ASSN_PATH) as fd: - pheno_verts = [] - gene_verts = [] - edge_verts = [] - csv_reader = csv.reader(fd, delimiter='\t') - next(csv_reader, None) # skip headers - for row in csv_reader: - cols = [c.strip() for c in row] - edge_doc = { - '_from': f'{_GENE_VERT_NAME}/{cols[1]}', - '_to': f'{_PHENO_VERT_NAME}/{cols[0]}', - 'score': float(cols[2]), - 'score_type': 'pheno_assn' - } - edge_verts.append(edge_doc) - pheno_verts.append({'_key': cols[0]}) - gene_verts.append({'_key': cols[1]}) - save_docs(_EDGE_NAME, edge_verts) - save_docs(_PHENO_VERT_NAME, pheno_verts) - save_docs(_GENE_VERT_NAME, gene_verts) - - -def load_vert_metadata(): - with open(_VERT_PATH) as fd: - genes = [] - phenos = [] - csv_reader = csv.reader(fd, delimiter=',') - next(csv_reader, None) # skip headers - for row in csv_reader: - cols = [c.strip() for c in row] - go_terms = [c.strip() for c in cols[10].split(',')] - node_type = cols[1] - doc = { - '_key': cols[0], - 'node_type': node_type, - 'transcript': cols[2], - 'gene_symbol': cols[3], - 'gene_full_name': cols[4], - 'gene_model_type': cols[5], - 'tair_computational_desc': cols[6], - 'tair_curator_summary': cols[7], - 'tair_short_desc': cols[8], - 'go_descr': cols[9], - 'go_terms': go_terms, - 'mapman_bin': cols[11], - 'mapman_name': cols[12], - 'mapman_desc': cols[13], - 'pheno_aragwas_id': cols[14], - 'pheno_desc1': cols[15], - 'pheno_desc2': cols[16], - 'pheno_desc3': cols[17], - 'pheno_ref': cols[18], - 'user_notes': cols[19], - } - if node_type == 'gene': - genes.append(doc) - elif node_type == 'pheno': - phenos.append(doc) - else: - raise RuntimeError(f"invalid node type {node_type}") - save_docs(_PHENO_VERT_NAME, phenos) - save_docs(_GENE_VERT_NAME, genes) - - -def load_cluster_data(): - """Annotate genes with cluster ID fields.""" - docs = [] - for (cluster_label, path) in _CLUSTER_PATHS.items(): - with open(path) as fd: - csv_reader = csv.reader(fd, delimiter='\t') - for row in csv_reader: - cluster_id = row[0] - gene_keys = row[1:] - docs += [ - {'_key': key, cluster_label: cluster_id} - for key in gene_keys - ] - save_docs(_GENE_VERT_NAME, docs) - - -def main(): - load_vert_metadata() - load_pheno_assns() - edge_paths = [ - (_GENE_COEXPR_PATH, _COEXPR_TYPE), - (_DOMAIN_CO_OCCUR_PATH, _CO_OCCUR_TYPE), - (_PPI_HITHRU_PATH, _HITHRU_TYPE), - (_PPI_LIT_PATH, _LIT_TYPE), - ] - for (path, score_type) in edge_paths: - load_edges(path, score_type) - load_cluster_data() - - -def save_docs(coll_name, docs, on_dupe='update'): - resp = requests.put( - CONF['API_URL'] + '/api/v1/documents', - params={'collection': coll_name, 'on_duplicate': on_dupe}, - headers={'Authorization': CONF['AUTH_TOKEN']}, - data='\n'.join(json.dumps(d) for d in docs) - ) - if not resp.ok: - raise RuntimeError(resp.text) - else: - print(f"Saved docs to collection {coll_name}!") - print(resp.text) - print("=" * 80) - +from importers.djornl.parser import DJORNL_Parser if __name__ == '__main__': - main() + parser = DJORNL_Parser() + parser.load_data() diff --git a/spec/importers/djornl/parser.py b/spec/importers/djornl/parser.py new file mode 100644 index 00000000..6f32b272 --- /dev/null +++ b/spec/importers/djornl/parser.py @@ -0,0 +1,213 @@ +""" +Loads the Dan Jacobson/ORNL group's gene and phenotype network data into +arangodb. + +Running this requires a set of source files provided by the ORNL group. +""" +import json +import requests +import os +import csv + +import importers.utils.config as config + + +class DJORNL_Parser(object): + + def config(self): + if not hasattr(self, '_config'): + return self._configure() + + return self._config + + def _configure(self): + + configuration = config.load_from_env(extra_required=['ROOT_DATA_PATH']) + + # Collection name config + configuration['_NODE_NAME'] = 'djornl_node' + configuration['_EDGE_NAME'] = 'djornl_edge' + + # Path config + configuration['_NODE_PATH'] = os.path.join( + configuration['ROOT_DATA_PATH'], + 'aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv' + ) + configuration['_NODE_FILE_COL_COUNT'] = 20 + + configuration['_EDGE_PATH'] = os.path.join( + configuration['ROOT_DATA_PATH'], + 'merged_edges-AMW-060820_AF.tsv' + ) + configuration['_EDGE_FILE_COL_COUNT'] = 5 + + _CLUSTER_BASE = os.path.join(configuration['ROOT_DATA_PATH'], 'cluster_data') + configuration['_CLUSTER_PATHS'] = { + 'cluster_I2': os.path.join( + _CLUSTER_BASE, + 'out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I2_named.tsv' + ), + 'cluster_I4': os.path.join( + _CLUSTER_BASE, + 'out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I4_named.tsv' + ), + 'cluster_I6': os.path.join( + _CLUSTER_BASE, + 'out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I6_named.tsv' + ), + } + self._config = configuration + return self._config + + + def load_edges(self): + # Headers and sample row: + # node1 node2 edge edge_descrip layer_descrip + # AT1G01370 AT1G57820 4.40001558779779 AraNetv2_log-likelihood-score AraNetv2-LC_lit-curated-ppi + edge_remap = { + 'AraGWAS-Phenotype_Associations': 'pheno_assn', + 'AraNetv2-CX_pairwise-gene-coexpression': 'gene_coexpr', + 'AraNetv2-DC_domain-co-occurrence': 'domain_co_occur', + 'AraNetv2-HT_high-throughput-ppi': 'ppi_hithru', + 'AraNetv2-LC_lit-curated-ppi': 'ppi_liter', + } + + node_ix = {} + edges = [] + node_name = self.config()['_NODE_NAME'] + expected_col_count = self.config()['_EDGE_FILE_COL_COUNT'] + + with open(self.config()['_EDGE_PATH']) as fd: + csv_reader = csv.reader(fd, delimiter='\t') + next(csv_reader, None) # skip headers + line_no = 1 + for row in csv_reader: + line_no += 1 + + cols = [c.strip() for c in row] + if len(cols) != expected_col_count: + n_cols = len(cols) + raise RuntimeError(f"line {line_no}: expected {expected_col_count} cols, found {n_cols}") + + node_ix[cols[0]] = 1 + node_ix[cols[1]] = 1 + edge_type = cols[4] + if not edge_type in edge_remap: + raise RuntimeError(f"line {line_no}: invalid edge type: {edge_type}") + + edges.append({ + '_key': f'{cols[0]}__{cols[1]}__{edge_remap[edge_type]}__{cols[2]}', + '_from': f'{node_name}/{cols[0]}', + '_to': f'{node_name}/{cols[1]}', + 'score': float(cols[2]), + 'edge_type': edge_remap[edge_type], + }) + + return { + 'nodes': [{'_key': n} for n in node_ix.keys()], + 'edges': edges, + } + + + def load_node_metadata(self): + """Load node metadata""" + + nodes = [] + expected_col_count = self.config()['_NODE_FILE_COL_COUNT'] + with open(self.config()['_NODE_PATH']) as fd: + csv_reader = csv.reader(fd, delimiter=',') + next(csv_reader, None) # skip headers + line_no = 1 + for row in csv_reader: + line_no += 1 + + cols = [c.strip() for c in row] + if len(cols) != expected_col_count: + n_cols = len(cols) + raise RuntimeError(f"line {line_no}: expected {expected_col_count} cols, found {n_cols}") + + _key = cols[0] + node_type = cols[1] + if node_type != 'gene' and node_type != 'pheno': + raise RuntimeError(f"line {line_no}: invalid node type: {node_type}") + + go_terms = [c.strip() for c in cols[10].split(',')] if len(cols[10]) else [] + + doc = { + '_key': _key, + 'node_type': node_type, + 'transcript': cols[2], + 'gene_symbol': cols[3], + 'gene_full_name': cols[4], + 'gene_model_type': cols[5], + 'tair_computational_desc': cols[6], + 'tair_curator_summary': cols[7], + 'tair_short_desc': cols[8], + 'go_descr': cols[9], + 'go_terms': go_terms, + 'mapman_bin': cols[11], + 'mapman_name': cols[12], + 'mapman_desc': cols[13], + 'pheno_aragwas_id': cols[14], + 'pheno_desc1': cols[15], + 'pheno_desc2': cols[16], + 'pheno_desc3': cols[17], + 'pheno_ref': cols[18], + 'user_notes': cols[19], + } + nodes.append(doc) + + return {'nodes': nodes} + + + def load_cluster_data(self): + """Annotate genes with cluster ID fields.""" + nodes = [] + cluster_paths = self.config()['_CLUSTER_PATHS'] + for (cluster_label, path) in cluster_paths.items(): + with open(path) as fd: + csv_reader = csv.reader(fd, delimiter='\t') + for row in csv_reader: + if len(row) > 1: + # remove the 'Cluster' text + cluster_id = row[0].replace('Cluster','') + gene_keys = row[1:] + nodes += [ + {'_key': key, cluster_label: int(cluster_id)} + for key in gene_keys + ] + + return {'nodes': nodes} + + + def save_dataset(self, dataset): + + if 'nodes' in dataset and len(dataset['nodes']) > 0: + self.save_docs(self.config()['_NODE_NAME'], dataset['nodes']) + + if 'edges' in dataset and len(dataset['edges']) > 0: + self.save_docs(self.config()['_EDGE_NAME'], dataset['edges']) + + + def save_docs(self, coll_name, docs, on_dupe='update'): + + resp = requests.put( + self.config()['API_URL'] + '/api/v1/documents', + params={'collection': coll_name, 'on_duplicate': on_dupe}, + headers={'Authorization': self.config()['AUTH_TOKEN']}, + data='\n'.join(json.dumps(d) for d in docs) + ) + if not resp.ok: + raise RuntimeError(resp.text) + + print(f"Saved docs to collection {coll_name}!") + print(resp.text) + print('=' * 80) + return resp + + + def load_data(self): + self.save_dataset(self.load_edges()) + self.save_dataset(self.load_node_metadata()) + self.save_dataset(self.load_cluster_data()) + diff --git a/spec/schemas/djornl/djornl_edge.yaml b/spec/schemas/djornl/djornl_edge.yaml index 2cc7516e..3afa987f 100644 --- a/spec/schemas/djornl/djornl_edge.yaml +++ b/spec/schemas/djornl/djornl_edge.yaml @@ -3,64 +3,45 @@ type: edge delta: false indexes: - - type: hash - fields: [score_type] - - type: persistent - fields: [score] - -# A guide to the edge score types: - -# domain_co_occur: -# A layer of protein domain co-occurrence values from the Arabidopsis -# AraNetv2 database. The LLS scores that serve as edge values were calculated -# from weighted mutual information scores to normalize the data for -# comparison across studies and different types of data layers (Lee et al, -# 2015). - -# gene_coexpr: -# A subset of pairwise gene coexpression values from the Arabidopsis -# AraNetv2 database. The LLS scores that serve as edge values were -# calculated from Pearson correlation coefficients to normalize the data -# for comparison across studies and different types of data layers (Lee et -# al, 2015). - -# pheno_assn: -# GWAS associations produced by analyzing a subset of phenotypes and SNPs -# in the Arabidopsis 1001 Genomes database. Edge values are significant -# association scores after FDR correction. - -# ppi_hithru: -# Log likelihood score. A layer of protein-protein interaction values -# derived from four high-throughput PPI screening experiments; from the -# Arabidopsis AraNetv2 database. The LLS scores that serve as edge values -# were calculated to normalize the data for comparison across studies and -# different types of data layers (Lee et al, 2015). - -# ppi_liter: -# A layer of protein-protein interaction values from literature-curated -# small- to medium-scale experimental data; from the Arabidopsis AraNetv2 -# database. The LLS scores that serve as edge values were calculated to -# normalize the data for comparison across studies and different types of -# data layers (Lee et al, 2015). + - type: hash + fields: [edge_type] + - type: persistent + fields: [score] schema: "$schema": http://json-schema.org/draft-07/schema# title: Arabidopsis gene-gene or gene-phenotype edge description: Generic gene-to-gene or gene-to-phenotype edge for Dan Jacobson Arabidopsis data type: object - required: [score, score_type, _from, _to] + required: [score, edge_type, _from, _to, _key] properties: - score: - title: Edge Score (Weight) - # (float) - type: number - score_type: - title: Least Likelihood Score + _key: type: string - enum: [domain_co_occur, gene_coexpr, pheno_assn, ppi_hithru, ppi_liter] + title: Key _from: type: string title: Gene ID _to: type: string title: Gene or Phenotype ID + score: + title: Edge Score (Weight) + # (float) + type: number + edge_type: + title: Edge Type + type: string + oneOf: + - const: domain_co_occur + description: A layer of protein domain co-occurrence values from the Arabidopsis AraNetv2 database. The LLS scores that serve as edge values were calculated from weighted mutual information scores to normalize the data for comparison across studies and different types of data layers (Lee et al, 2015). + - const: gene_coexpr + description: A subset of pairwise gene coexpression values from the Arabidopsis AraNetv2 database. The LLS scores that serve as edge values were + calculated from Pearson correlation coefficients to normalize the data + for comparison across studies and different types of data layers (Lee et + al, 2015). + - const: pheno_assn + description: GWAS associations produced by analyzing a subset of phenotypes and SNPs in the Arabidopsis 1001 Genomes database. Edge values are significant association scores after FDR correction. + - const: ppi_hithru + description: Log likelihood score. A layer of protein-protein interaction values derived from four high-throughput PPI screening experiments; from the Arabidopsis AraNetv2 database. The LLS scores that serve as edge values were calculated to normalize the data for comparison across studies and different types of data layers (Lee et al, 2015). + - const: ppi_liter + description: A layer of protein-protein interaction values from literature-curated small- to medium-scale experimental data; from the Arabidopsis AraNetv2 database. The LLS scores that serve as edge values were calculated to normalize the data for comparison across studies and different types of data layers (Lee et al, 2015). diff --git a/spec/schemas/djornl/djornl_gene.yaml b/spec/schemas/djornl/djornl_node.yaml similarity index 53% rename from spec/schemas/djornl/djornl_gene.yaml rename to spec/schemas/djornl/djornl_node.yaml index 10f90e02..9248f1c1 100644 --- a/spec/schemas/djornl/djornl_gene.yaml +++ b/spec/schemas/djornl/djornl_node.yaml @@ -1,87 +1,107 @@ -name: djornl_gene +name: djornl_node type: vertex delta: false schema: "$schema": http://json-schema.org/draft-07/schema# - title: Gene Vertices - description: Arabidopsis gene nodes from the Dan Jacobson Lab + title: Gene and Phenotype Vertices + description: Arabidopsis gene and phenotype nodes from the Dan Jacobson Lab type: object required: [_key] properties: _key: type: string - title: Gene Key + title: Key examples: ["AT1G01010"] cluster_I2: - type: string - title: Cluster ID + type: integer + title: Cluster 2 ID description: Iterative random forest cluster group ID - examples: ["Cluster1"] + examples: [1] cluster_I4: - type: string - title: Cluster ID + type: integer + title: Cluster 4 ID description: Iterative random forest cluster group ID - examples: ["Cluster1"] + examples: [13] cluster_I6: - type: string - title: Cluster ID + type: integer + title: Cluster 6 ID description: Iterative random forest cluster group ID - examples: ["Cluster1"] + examples: [27] node_type: type: string - examples: ["gene"] + title: Node type + examples: ["gene", "phenotype"] transcript: type: string + title: Transcript examples: ["AT1G01010.1"] gene_symbol: type: string + title: Gene symbol examples: ["NTL10"] gene_full_name: type: string + title: Gene full name examples: ["NAC domain containing protein 1"] gene_model_type: type: string + title: Gene model type examples: ["protein_coding"] tair_computational_desc: type: string + title: TAIR computational description examples: ["NAC domain containing protein 1;(source:Araport11)"] tair_curator_summary: type: string + title: TAIR curator summary + examples: ["Encodes a plasma membrane-localized amino acid transporter likely involved in amino acid export in the developing seed."] tair_short_desc: type: string + title: TAIR short description examples: ["NAC domain containing protein 1"] go_descr: type: string + title: GO descriptions examples: ["DNA-binding transcription factor activity"] go_terms: type: array + title: GO term IDs items: {type: string} - examples: [["DNA binding"]] + examples: [["GO:0003700", "GO:0005515"]] mapman_bin: type: string - examples: ["GO:0003700"] + title: Mapman bin + examples: ["15.5.17"] mapman_name: type: string - examples: ["GO:0003677"] + title: Mapman name + examples: [".RNA biosynthesis.transcriptional regulation.transcription factor (NAC)"] mapman_desc: type: string - examples: ["15.5.17"] + title: Mapman description + examples: ["transcription factor (NAC) (original description: pep chromosome:TAIR10:1:3631:5899:1 gene:AT1G01010 transcript:AT1G01010.1 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:NAC001 description:NAC domain-containing protein 1 [Source:UniProtKB/Swiss-Prot;Acc:Q0WV96])"] pheno_aragwas_id: type: string - examples: [".RNA biosynthesis.transcriptional regulation.transcription factor (NAC)"] + title: AraGWAS ID + examples: ["10.21958/phenotype:67"] pheno_desc1: type: string - examples: ["transcription factor (NAC) (original description: pep chromosome:TAIR10:1:3631:5899:1 gene:AT1G01010 transcript:AT1G01010.1 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:NAC001 description:NAC domain-containing protein 1 [Source:UniProtKB/Swiss-Prot;Acc:Q0WV96])"] + title: Phenotype description 1 + examples: ["Arsenic concentrations in leaves, grown in soil. Elemental analysis was performed with an ICP-MS (PerkinElmer). Sample normalized to calculated weights as described in Baxter et al., 2008"] pheno_desc2: type: string - examples: [] + title: PTO name + examples: ["arsenic concentration"] pheno_desc3: type: string - examples: [] + title: PTO description + examples: ["A mineral and ion content related trait (TO:0000465) which is the concentration of arsenic (CHEBI:22632) in some plant structure (PO:0009011). [GR:Karthik]"] pheno_ref: type: string - examples: [] + title: Phenotype reference + examples: ["Atwell et. al, Nature 2010"] user_notes: type: string - examples: [] + title: User Notes + examples: ["flowering time related"] diff --git a/spec/schemas/djornl/djornl_phenotype.yaml b/spec/schemas/djornl/djornl_phenotype.yaml deleted file mode 100644 index 085076fa..00000000 --- a/spec/schemas/djornl/djornl_phenotype.yaml +++ /dev/null @@ -1,60 +0,0 @@ -name: djornl_gene -type: vertex -delta: false - -schema: - "$schema": http://json-schema.org/draft-07/schema# - title: Gene Vertices - description: Arabidopsis phenotype nodes from the Dan Jacobson Lab - type: object - required: [_key] - properties: - _key: - type: string - title: Phenotype Key - examples: ["Aw2"] - node_type: - type: string - examples: ["pheno"] - transcript: - type: string - gene_symbol: - type: string - gene_full_name: - type: string - gene_model_type: - type: string - tair_computational_desc: - type: string - tair_curator_summary: - type: string - tair_short_desc: - type: string - go_descr: - type: string - go_terms: - type: array - items: {type: string} - mapman_bin: - type: string - mapman_name: - type: string - mapman_desc: - type: string - pheno_aragwas_id: - type: string - examples: ["10.21958/phenotype:103"] - pheno_desc1: - type: string - pheno_desc2: - type: string - examples: ["bacterial disease resistance"] - pheno_desc3: - type: string - examples: ["The resistance exhibited by a plant or a group of plants (population) in response to the disease caused by a bacterial pathogen infection as compared to the susceptible and/or the reference plants of the same species. [GR:pj]"] - pheno_ref: - type: string - examples: ["Atwell et. al"] - user_notes: - type: string - examples: ["Nature 2010"] diff --git a/spec/stored_queries/djornl/djornl_cluster_neighbors.yaml b/spec/stored_queries/djornl/djornl_cluster_neighbors.yaml deleted file mode 100644 index ac0121ba..00000000 --- a/spec/stored_queries/djornl/djornl_cluster_neighbors.yaml +++ /dev/null @@ -1,40 +0,0 @@ -# Fetch the neighbors of all vertices in a certain cluster -name: djornl_cluster_neighbors -params: - type: object - required: [cluster_name, cluster_id] - properties: - cluster_name: - type: string - enum: [cluster_I2, cluster_I4, cluster_I6] - cluster_id: - type: string - examples: [Cluster1, Cluster2] - distance: - type: integer - title: Traversal Distance - description: How many hops to find neighbors and neighbors-of-neighbors - default: 1 - minimum: 1 - maximum: 100 -# phenotype nodes can be returned -query_prefix: WITH djornl_phenotype -query: | - LET node_ids = ( - FOR gene IN djornl_gene - FILTER gene[@cluster_name] == @cluster_id - FOR node IN 0..@distance ANY gene djornl_edge - OPTIONS {bfs: true, uniqueVertices: "global"} - RETURN DISTINCT node._id - ) - let edges = ( - FOR edge IN djornl_edge - FILTER edge._from IN node_ids AND edge._to IN node_ids - RETURN edge - ) - let nodes = ( - FOR node IN djornl_gene - FILTER node._id IN node_ids - return node - ) - RETURN {nodes, edges} diff --git a/spec/stored_queries/djornl/djornl_fetch_all.yaml b/spec/stored_queries/djornl/djornl_fetch_all.yaml index 85eae0c6..0d918c2f 100644 --- a/spec/stored_queries/djornl/djornl_fetch_all.yaml +++ b/spec/stored_queries/djornl/djornl_fetch_all.yaml @@ -1,18 +1,15 @@ -# Fetch all vertices in the djornl subgraph name: djornl_fetch_all +description: Fetch all node and edge data from the djornl subgraph params: type: object +# additionalProperties: false query: | - LET genes = ( - FOR v IN djornl_gene - RETURN v - ) - LET phenotypes = ( - FOR v IN djornl_phenotype + LET nodes = ( + FOR v IN djornl_node RETURN v ) LET edges = ( FOR e IN djornl_edge RETURN e ) - RETURN {genes, phenotypes, edges} + RETURN {nodes, edges} diff --git a/spec/stored_queries/djornl/djornl_fetch_clusters.yaml b/spec/stored_queries/djornl/djornl_fetch_clusters.yaml new file mode 100644 index 00000000..4c6b8c50 --- /dev/null +++ b/spec/stored_queries/djornl/djornl_fetch_clusters.yaml @@ -0,0 +1,49 @@ +name: djornl_fetch_clusters +description: Fetch all nodes that are members of the specified cluster(s), and the edges and nodes within the specified distance (number of hops) of those nodes. +params: + type: object + properties: + cluster_i2_ids: + title: Cluster I2 IDs + description: Cluster I2 IDs to locate + items: {type: integer} + default: [] + examples: [[1], [3, 5]] + cluster_i4_ids: + title: Cluster I4 IDs + description: Cluster I4 IDs to locate + items: {type: integer} + examples: [[2], [4, 6]] + default: [] + cluster_i6_ids: + title: Cluster I6 IDs + description: Cluster I6 IDs to locate + items: {type: integer} + examples: [[666], [999, 333]] + default: [] + distance: + type: integer + title: Traversal Distance + description: How many hops to find neighbors and neighbors-of-neighbors + default: 1 + minimum: 0 + maximum: 100 +query: | + LET node_ids = ( + FOR n IN djornl_node + FILTER n.cluster_I2 IN @cluster_i2_ids OR n.cluster_I4 IN @cluster_i4_ids OR n.cluster_I6 IN @cluster_i6_ids + FOR node IN 0..@distance ANY n djornl_edge + OPTIONS {bfs: true, uniqueVertices: "global"} + RETURN DISTINCT node._id + ) + LET edges = ( + FOR edge IN djornl_edge + FILTER edge._from IN node_ids AND edge._to IN node_ids + RETURN edge + ) + LET nodes = ( + FOR node IN djornl_node + FILTER node._id IN node_ids + RETURN node + ) + RETURN {nodes, edges} diff --git a/spec/stored_queries/djornl/djornl_fetch_genes.yaml b/spec/stored_queries/djornl/djornl_fetch_genes.yaml index 44eda82e..42bbeeb5 100644 --- a/spec/stored_queries/djornl/djornl_fetch_genes.yaml +++ b/spec/stored_queries/djornl/djornl_fetch_genes.yaml @@ -1,15 +1,37 @@ -# Fetch a gene document by list of keys name: djornl_fetch_genes +description: Fetch a gene or list of genes by key, and the edges and nodes within the specified distance (number of hops) of those genes. params: type: object required: [keys] properties: + distance: + type: integer + title: Traversal Distance + description: How many hops to find neighbors and neighbors-of-neighbors + default: 1 + minimum: 0 + maximum: 100 keys: type: array items: {type: string} title: Gene Keys - examples: [[AT1G01010]] + examples: [["AT1G01010"],["AT1G01020","AT1G01070"]] query: | - FOR g IN djornl_gene - FILTER g._key IN @keys - RETURN g + LET node_ids = ( + FOR n IN djornl_node + FILTER n._key IN @keys AND n.node_type == 'gene' + FOR node IN 0..@distance ANY n djornl_edge + OPTIONS {bfs: true, uniqueVertices: "global"} + RETURN DISTINCT node._id + ) + LET edges = ( + FOR edge IN djornl_edge + FILTER edge._from IN node_ids AND edge._to IN node_ids + RETURN edge + ) + LET nodes = ( + FOR node IN djornl_node + FILTER node._id IN node_ids + RETURN node + ) + RETURN {nodes, edges} diff --git a/spec/stored_queries/djornl/djornl_fetch_phenotypes.yaml b/spec/stored_queries/djornl/djornl_fetch_phenotypes.yaml index aa4de01c..0e27ee4a 100644 --- a/spec/stored_queries/djornl/djornl_fetch_phenotypes.yaml +++ b/spec/stored_queries/djornl/djornl_fetch_phenotypes.yaml @@ -1,15 +1,37 @@ -# Fetch a phenotype document by list of keys name: djornl_fetch_phenotypes +description: Fetch a phenotype or list of phenotypes by key, and the edges and nodes within the specified distance (number of hops) of those phenotype nodes. params: type: object required: [keys] properties: + distance: + type: integer + title: Traversal Distance + description: How many hops to find neighbors and neighbors-of-neighbors + default: 1 + minimum: 0 + maximum: 100 keys: type: array items: {type: string} title: Phenotype Keys - examples: [[As2]] + examples: [["As2"],["As2", "Na23"]] query: | - FOR p IN djornl_phenotype - FILTER p._key IN @keys - RETURN p + LET node_ids = ( + FOR n IN djornl_node + FILTER n._key IN @keys AND n.node_type == 'pheno' + FOR node IN 0..@distance ANY n djornl_edge + OPTIONS {bfs: true, uniqueVertices: "global"} + RETURN DISTINCT node._id + ) + LET edges = ( + FOR edge IN djornl_edge + FILTER edge._from IN node_ids AND edge._to IN node_ids + RETURN edge + ) + LET nodes = ( + FOR node IN djornl_node + FILTER node._id IN node_ids + RETURN node + ) + RETURN {nodes, edges} diff --git a/spec/stored_queries/djornl/djornl_gene_neighbors.yaml b/spec/stored_queries/djornl/djornl_gene_neighbors.yaml deleted file mode 100644 index 9bfb642c..00000000 --- a/spec/stored_queries/djornl/djornl_gene_neighbors.yaml +++ /dev/null @@ -1,31 +0,0 @@ -# Fetch the neighbors of a certain gene by distance -name: djornl_gene_neighbors -params: - type: object - required: [gene_key] - properties: - distance: - type: integer - title: Traversal Distance - description: How many hops to find neighbors and neighbors-of-neighbors - default: 1 - minimum: 1 - maximum: 100 - gene_key: - type: string - title: Gene Key - examples: [AT1G01010] -query: | - FOR g IN djornl_gene - FILTER g._key == @gene_key - FOR n, e, p IN @distance ANY g djornl_edge - OPTIONS {bfs: true, uniqueVertices: "global"} - LET edges = ( - FOR entry IN p.edges - RETURN KEEP(entry, "_id", "_from", "_to", "score", "score_type") - ) - LET verts = ( - FOR entry IN SLICE(p.vertices, 1) - RETURN UNSET(entry, "_key", "_rev") - ) - RETURN {edges, verts} diff --git a/spec/stored_queries/djornl/djornl_search_genes.yaml b/spec/stored_queries/djornl/djornl_search_genes.yaml deleted file mode 100644 index 226b1280..00000000 --- a/spec/stored_queries/djornl/djornl_search_genes.yaml +++ /dev/null @@ -1,28 +0,0 @@ -# Simple fuzzy search genes using the djornl_gene_view ArangoSearch view -name: djornl_search_genes -params: - type: object - required: [search_text] - properties: - search_text: - type: string - title: Query Text - minLength: 3 -query: | - FOR g IN djornl_gene_view - SEARCH ANALYZER( - PHRASE(g.tair_computational_desc, @search_text) OR - PHRASE(g.tair_short_desc, @search_text) OR - PHRASE(g.mapman_desc, @search_text) OR - PHRASE(g.go_desc, @search_text) OR - PHRASE(g.mapman_name, @search_text) OR - PHRASE(g.mapman_desc, @search_text) OR - PHRASE(g.pheno_desc1, @search_text) OR - PHRASE(g.pheno_desc2, @search_text) OR - PHRASE(g.pheno_desc3, @search_text) OR - PHRASE(g.user_notes, @search_text), - 'text_en' - ) - OR PHRASE(g.go_terms, @search_text) - OR PHRASE(g.transcript, @search_text) - RETURN g diff --git a/spec/stored_queries/djornl/djornl_search_nodes.yaml b/spec/stored_queries/djornl/djornl_search_nodes.yaml new file mode 100644 index 00000000..7cd36c4f --- /dev/null +++ b/spec/stored_queries/djornl/djornl_search_nodes.yaml @@ -0,0 +1,50 @@ +name: djornl_search_nodes +description: Search for nodes using a simple fuzzy search on node metadata; return the matching nodes, and the edges and nodes within the specified distance (number of hops) of those nodes. +params: + type: object + required: [search_text] + properties: + distance: + type: integer + title: Traversal Distance + description: How many hops to find neighbors and neighbors-of-neighbors + default: 1 + minimum: 0 + maximum: 100 + search_text: + type: string + title: Search text + examples: ['GO:0005515', 'organelle machinery'] +query: | + LET node_ids = ( + FOR g IN djornl_node_view + SEARCH ANALYZER( + PHRASE(g.tair_computational_desc, @search_text) OR + PHRASE(g.tair_short_desc, @search_text) OR + PHRASE(g.mapman_desc, @search_text) OR + PHRASE(g.go_desc, @search_text) OR + PHRASE(g.mapman_name, @search_text) OR + PHRASE(g.mapman_desc, @search_text) OR + PHRASE(g.pheno_desc1, @search_text) OR + PHRASE(g.pheno_desc2, @search_text) OR + PHRASE(g.pheno_desc3, @search_text) OR + PHRASE(g.user_notes, @search_text), + 'text_en' + ) + OR PHRASE(g.go_terms, @search_text) + OR PHRASE(g.transcript, @search_text) + FOR node IN 0..@distance ANY g djornl_edge + OPTIONS {bfs: true, uniqueVertices: "global"} + RETURN DISTINCT node._id + ) + LET edges = ( + FOR edge IN djornl_edge + FILTER edge._from IN node_ids AND edge._to IN node_ids + RETURN edge + ) + LET nodes = ( + FOR node IN djornl_node + FILTER node._id IN node_ids + RETURN node + ) + RETURN {nodes, edges} diff --git a/spec/test/djornl/col_count_errors/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv b/spec/test/djornl/col_count_errors/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv new file mode 100644 index 00000000..48e5ab19 --- /dev/null +++ b/spec/test/djornl/col_count_errors/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv @@ -0,0 +1,14 @@ +node_id,node_type,transcript,gene_symbol,gene_full_name,gene_model_type,TAIR_Computational_description,TAIR_Curator_summary,TAIR_short_description,GO_descr,GO_terms,MapMan_bin,MapMan_name,MapMan_descr,pheno_AraGWAS_ID,pheno_descrip1,pheno_descrip2,pheno_descrip3,pheno_ref,UserNotes +As2,pheno,,,,,,,,,,,,,10.21958/phenotype:103,,bacterial disease resistance,The resistance exhibited by a plant or a group of plants (population) in response to the disease caused by a bacterial pathogen infection as compared to the susceptible and/or the reference plants of the same species. [GR:pj],"Atwell et. al, Nature 2010", +As75,pheno,,,,,,,,,,,,,,,10.21958/phenotype:67,"Arsenic concentrations in leaves, grown in soil. Elemental analysis was performed with an ICP-MS (PerkinElmer). Sample normalized to calculated weights as described in Baxter et al., 2008",arsenic concentration,A mineral and ion content related trait (TO:0000465) which is the concentration of arsenic (CHEBI:22632) in some plant structure (PO:0009011). [GR:Karthik],"Atwell et. al, Nature 2010", +AT1G01020,gene,AT1G01020.6,ARV1,,protein_coding,ARV1 family protein;(source:Araport11),,,molecular_function,GO:0003674,35.1,not assigned.annotated,(original description: pep chromosome:TAIR10:1:6788:8737:-1 gene:AT1G01020 transcript:AT1G01020.6 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:ARV1 description:ARV1 family protein [Source:UniProtKB/TrEMBL;Acc:Q5MK24]) & no description available(sp|q5mk24|arv1_arath : 99.4),,,,,, +AT1G01030,gene,AT1G01030.2,NGA3,NGATHA3,protein_coding,AP2/B3-like transcriptional factor family protein;(source:Araport11),,,"DNA-binding transcription factor activity, DNA binding","GO:0003700, GO:0003677",15.5.5.3,.RNA biosynthesis.transcriptional regulation.B3 transcription factor superfamily.transcription factor (RAV/NGATHA),transcription factor (RAV/NGATHA) (original description: pep chromosome:TAIR10:1:11649:13714:-1 gene:AT1G01030 transcript:AT1G01030.2 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:NGA3 description:B3 domain-containing transcription factor NGA3 [Source:UniProtKB/Swiss-Prot;Acc:Q9MAN1]),,,,,, +AT1G01040,gene,AT1G01040.2,SUS1,SUSPENSOR 1,protein_coding,dicer-like 1;(source:Araport11),"Encodes a Dicer homolog. Dicer is a RNA helicase involved in microRNA processing. Mutations in this locus can result in embryo lethality. Embryo shape at seed maturity is globular-elongate. Other mutants convert the floral meristems to an indeterminate state, others yet show defects in ovule development. mRNA is expressed in all shoot tissues. DCL1 is able to produce miRNAs and siRNAs. The mRNA is cell-to-cell mobile.",dicer-like 1,"metal ion binding, protein binding, ribonuclease III activity, ATP-dependent helicase activity, ATP binding, RNA binding, helicase activity, double-stranded RNA binding, DNA binding","GO:0046872, GO:0005515, GO:0004525, GO:0008026, GO:0005524, GO:0003723, GO:0004386, GO:0003725, GO:0003677",16.10.2.1.1,.RNA processing.mRNA silencing.miRNA pathway.DCL1-HYL1 miRNA biogenesis complex.endoribonuclease component DCL1,endoribonuclease component DCL1 of DCL1-HYL1 miRNA biogenesis complex (original description: pep chromosome:TAIR10:1:23416:31120:1 gene:AT1G01040 transcript:AT1G01040.2 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:DCL1 description:Dicer-like 1 [Source:UniProtKB/TrEMBL;Acc:F4HQG6]),,,,,, +AT1G01050,gene,AT1G01050.2,PPa1,pyrophosphorylase 1,protein_coding,pyrophosphorylase 1;(source:Araport11),,,inorganic diphosphatase activity,GO:0004427,35.1,not assigned.annotated,(original description: pep chromosome:TAIR10:1:31382:33009:-1 gene:AT1G01050 transcript:AT1G01050.2 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:PPA1 description:Soluble inorganic pyrophosphatase 1 [Source:UniProtKB/Swiss-Prot;Acc:Q93V56]) & Soluble inorganic pyrophosphatase 1 OS=Arabidopsis thaliana (sp|q93v56|ipyr1_arath : 419.0),,,,,, +AT1G01060,gene,AT1G01060.8,LHY1,LATE ELONGATED HYPOCOTYL 1,protein_coding,Homeodomain-like superfamily protein;(source:Araport11),,,"DNA-binding transcription factor activity, DNA binding, transcription regulatory region DNA binding","GO:0003700, GO:0003677, GO:0044212",27.1.1,.Multi-process regulation.circadian clock system.core oscillator protein (LHY|CCA1),circadian clock core oscillator protein (LHY|CCA1) (original description: pep chromosome:TAIR10:1:33967:37230:-1 gene:AT1G01060 transcript:AT1G01060.8 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:LHY description:LHY1 [Source:UniProtKB/TrEMBL;Acc:A0A178W761]),,,,,, +AT1G01070,gene,AT1G01070.2,UMAMIT28,Usually multiple acids move in and out Transporters 28,protein_coding,nodulin MtN21 /EamA-like transporter family protein;(source:Araport11),Encodes a plasma membrane-localized amino acid transporter likely involved in amino acid export in the developing seed.,nodulin MtN21 /EamA-like transporter family protein,L-glutamine transmembrane transporter activity,GO:0015186,24.2.1.5,.Solute transport.carrier-mediated transport.DMT superfamily.solute transporter (UmamiT),solute transporter (UmamiT) (original description: pep chromosome:TAIR10:1:38752:40945:-1 gene:AT1G01070 transcript:AT1G01070.2 gene_biotype:protein_coding transcript_biotype:protein_coding description:WAT1-related protein [Source:UniProtKB/TrEMBL;Acc:A0A178WFU3]),,,,,, +AT1G01080,gene,AT1G01080.3,,,protein_coding,RNA-binding (RRM/RBD/RNP motifs) family protein;(source:Araport11),,,"RNA binding, mRNA binding","GO:0003723, GO:0003729",35.1,not assigned.annotated,"(original description: pep chromosome:TAIR10:1:44970:47059:-1 gene:AT1G01080 transcript:AT1G01080.3 gene_biotype:protein_coding transcript_biotype:protein_coding description:RNA-binding (RRM/RBD/RNP motifs) family protein [Source:UniProtKB/TrEMBL;Acc:F4HQH8]) & 33 kDa ribonucleoprotein, chloroplastic OS=Nicotiana sylvestris (sp|p19684|roc5_nicsy : 109.0)",,,,,, +AT1G01090,gene,AT1G01090.1,PDH-E1 ALPHA,pyruvate dehydrogenase E1 alpha,protein_coding,pyruvate dehydrogenase E1 alpha;(source:Araport11),pyruvate dehydrogenase E1 alpha subunit,pyruvate dehydrogenase E1 alpha,pyruvate dehydrogenase (acetyl-transferring) activity,GO:0004739,5.1.2.2.1.1,.Lipid metabolism.fatty acid biosynthesis.acetyl-CoA generation.plastidial pyruvate dehydrogenase complex.E1 pyruvate dehydrogenase subcomplex.subunit alpha,subunit alpha of E1 pyruvate dehydrogenase component (original description: pep chromosome:TAIR10:1:47234:49304:-1 gene:AT1G01090 transcript:AT1G01090.1 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:PDH-E1 ALPHA description:Pyruvate dehydrogenase E1 component subunit alpha [Source:UniProtKB/TrEMBL;Acc:A0A178W8A7]),,,,,, +AT1G01100,gene,AT1G01100.4,,,protein_coding,60S acidic ribosomal protein family;(source:Araport11),,60S acidic ribosomal protein family,"structural constituent of ribosome, ribonucleoprotein complex binding, protein kinase activator activity","GO:0003735, GO:0043021, GO:0030295",17.1.2.1.46,.Protein biosynthesis.ribosome biogenesis.large ribosomal subunit (LSU).LSU proteome.component RPP1,component RPP1 of LSU proteome component (original description: pep chromosome:TAIR10:1:50090:51187:-1 gene:AT1G01100 transcript:AT1G01100.4 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:RPP1A description:60S acidic ribosomal protein P1-1 [Source:UniProtKB/Swiss-Prot;Acc:Q8LCW9]),,,,,, +Na23,pheno,,,,,,,,,,,,,10.21958/phenotype:5,"Sodium concentrations in leaves, grown in soil. Elemental analysis was performed with an ICP-MS (PerkinElmer). Sample normalized to calculated weights as described in Baxter et al., 2008",sodium concentration,The total sodium ion concentration measured in a given volume of a plant or a plant part or plant extract. [GR:pj],"Atwell et. al, Nature 2010", +SDV,pheno,,,,,,,,,,,,,10.21958/phenotype:104,"Number of days following stratification to opening of first flower. The experiment was stopped at 200 d, and accessions that had not flowered at that point were assigned a value of 200",days to flowering trait,"A flowering time trait (TO:0002616)which is the number of days required for an individual flower (PO:0009046), a whole plant (PO:0000003) or a plant population to reach flowering stage (PO:0007616) from a predetermined time point (e.g. the date of seed sowing, seedling transplant, or seedling emergence). [GR:pj, TO:cooperl]","Atwell et. al, Nature 2010", diff --git a/spec/test/djornl/col_count_errors/merged_edges-AMW-060820_AF.tsv b/spec/test/djornl/col_count_errors/merged_edges-AMW-060820_AF.tsv new file mode 100644 index 00000000..a2d07a73 --- /dev/null +++ b/spec/test/djornl/col_count_errors/merged_edges-AMW-060820_AF.tsv @@ -0,0 +1,8 @@ +node1 node2 edge edge_descrip layer_descrip +As2 AT1G01040 5.422046084731258 AraGWAS-Association_score AraGWAS-Phenotype_Associations +As75 AT1G01020 39.98573324312915 AraGWAS-Association_score AraGWAS-Phenotype_Associations +AT1G01010 AT1G01020 2.39322646755088 AraNetv2_log-likelihood-score AraNetv2-HT_high-throughput-ppi +AT1G01010 AT1G01030 2.39322646755088 AraNetv2_log-likelihood-score AraNetv2-HT_high-throughput-ppi +AT1G01010 AT1G01040 2.39322646755088 +AT1G01030 AT1G01050 2.5494618241936697 AraNetv2_log-likelihood-score AraNetv2-CX_pairwise-gene-coexpression +AT1G01050 AT1G01060 4.34242054808616 AraNetv2_log-likelihood-score AraNetv2-LC_lit-curated-ppi diff --git a/spec/test/djornl/empty_files/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv b/spec/test/djornl/empty_files/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv new file mode 100644 index 00000000..118cfbcc --- /dev/null +++ b/spec/test/djornl/empty_files/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv @@ -0,0 +1 @@ +node_id,node_type,transcript,gene_symbol,gene_full_name,gene_model_type,TAIR_Computational_description,TAIR_Curator_summary,TAIR_short_description,GO_descr,GO_terms,MapMan_bin,MapMan_name,MapMan_descr,pheno_AraGWAS_ID,pheno_descrip1,pheno_descrip2,pheno_descrip3,pheno_ref,UserNotes diff --git a/spec/test/djornl/empty_files/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I2_named.tsv b/spec/test/djornl/empty_files/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I2_named.tsv new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/spec/test/djornl/empty_files/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I2_named.tsv @@ -0,0 +1 @@ + diff --git a/spec/test/djornl/empty_files/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I4_named.tsv b/spec/test/djornl/empty_files/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I4_named.tsv new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/spec/test/djornl/empty_files/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I4_named.tsv @@ -0,0 +1 @@ + diff --git a/spec/test/djornl/empty_files/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I6_named.tsv b/spec/test/djornl/empty_files/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I6_named.tsv new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/spec/test/djornl/empty_files/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I6_named.tsv @@ -0,0 +1 @@ + diff --git a/spec/test/djornl/empty_files/merged_edges-AMW-060820_AF.tsv b/spec/test/djornl/empty_files/merged_edges-AMW-060820_AF.tsv new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/spec/test/djornl/empty_files/merged_edges-AMW-060820_AF.tsv @@ -0,0 +1 @@ + diff --git a/spec/test/djornl/invalid_types/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv b/spec/test/djornl/invalid_types/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv new file mode 100644 index 00000000..af5fa6cb --- /dev/null +++ b/spec/test/djornl/invalid_types/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv @@ -0,0 +1,15 @@ +node_id,node_type,transcript,gene_symbol,gene_full_name,gene_model_type,TAIR_Computational_description,TAIR_Curator_summary,TAIR_short_description,GO_descr,GO_terms,MapMan_bin,MapMan_name,MapMan_descr,pheno_AraGWAS_ID,pheno_descrip1,pheno_descrip2,pheno_descrip3,pheno_ref,UserNotes +As2,pheno,,,,,,,,,,,,,10.21958/phenotype:103,,bacterial disease resistance,The resistance exhibited by a plant or a group of plants (population) in response to the disease caused by a bacterial pathogen infection as compared to the susceptible and/or the reference plants of the same species. [GR:pj],"Atwell et. al, Nature 2010", +As75,pheno,,,,,,,,,,,,,10.21958/phenotype:67,"Arsenic concentrations in leaves, grown in soil. Elemental analysis was performed with an ICP-MS (PerkinElmer). Sample normalized to calculated weights as described in Baxter et al., 2008",arsenic concentration,A mineral and ion content related trait (TO:0000465) which is the concentration of arsenic (CHEBI:22632) in some plant structure (PO:0009011). [GR:Karthik],"Atwell et. al, Nature 2010", +AT1G01010,Monkey,AT1G01010.1,NTL10,NAC domain containing protein 1,protein_coding,NAC domain containing protein 1;(source:Araport11),,NAC domain containing protein 1,"DNA-binding transcription factor activity, DNA binding","GO:0003700, GO:0003677",15.5.17,.RNA biosynthesis.transcriptional regulation.transcription factor (NAC),transcription factor (NAC) (original description: pep chromosome:TAIR10:1:3631:5899:1 gene:AT1G01010 transcript:AT1G01010.1 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:NAC001 description:NAC domain-containing protein 1 [Source:UniProtKB/Swiss-Prot;Acc:Q0WV96]),,,,,, +AT1G01020,gene,AT1G01020.6,ARV1,,protein_coding,ARV1 family protein;(source:Araport11),,,molecular_function,GO:0003674,35.1,not assigned.annotated,(original description: pep chromosome:TAIR10:1:6788:8737:-1 gene:AT1G01020 transcript:AT1G01020.6 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:ARV1 description:ARV1 family protein [Source:UniProtKB/TrEMBL;Acc:Q5MK24]) & no description available(sp|q5mk24|arv1_arath : 99.4),,,,,, +AT1G01030,gene,AT1G01030.2,NGA3,NGATHA3,protein_coding,AP2/B3-like transcriptional factor family protein;(source:Araport11),,,"DNA-binding transcription factor activity, DNA binding","GO:0003700, GO:0003677",15.5.5.3,.RNA biosynthesis.transcriptional regulation.B3 transcription factor superfamily.transcription factor (RAV/NGATHA),transcription factor (RAV/NGATHA) (original description: pep chromosome:TAIR10:1:11649:13714:-1 gene:AT1G01030 transcript:AT1G01030.2 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:NGA3 description:B3 domain-containing transcription factor NGA3 [Source:UniProtKB/Swiss-Prot;Acc:Q9MAN1]),,,,,, +AT1G01040,gene,AT1G01040.2,SUS1,SUSPENSOR 1,protein_coding,dicer-like 1;(source:Araport11),"Encodes a Dicer homolog. Dicer is a RNA helicase involved in microRNA processing. Mutations in this locus can result in embryo lethality. Embryo shape at seed maturity is globular-elongate. Other mutants convert the floral meristems to an indeterminate state, others yet show defects in ovule development. mRNA is expressed in all shoot tissues. DCL1 is able to produce miRNAs and siRNAs. The mRNA is cell-to-cell mobile.",dicer-like 1,"metal ion binding, protein binding, ribonuclease III activity, ATP-dependent helicase activity, ATP binding, RNA binding, helicase activity, double-stranded RNA binding, DNA binding","GO:0046872, GO:0005515, GO:0004525, GO:0008026, GO:0005524, GO:0003723, GO:0004386, GO:0003725, GO:0003677",16.10.2.1.1,.RNA processing.mRNA silencing.miRNA pathway.DCL1-HYL1 miRNA biogenesis complex.endoribonuclease component DCL1,endoribonuclease component DCL1 of DCL1-HYL1 miRNA biogenesis complex (original description: pep chromosome:TAIR10:1:23416:31120:1 gene:AT1G01040 transcript:AT1G01040.2 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:DCL1 description:Dicer-like 1 [Source:UniProtKB/TrEMBL;Acc:F4HQG6]),,,,,, +AT1G01050,gene,AT1G01050.2,PPa1,pyrophosphorylase 1,protein_coding,pyrophosphorylase 1;(source:Araport11),,,inorganic diphosphatase activity,GO:0004427,35.1,not assigned.annotated,(original description: pep chromosome:TAIR10:1:31382:33009:-1 gene:AT1G01050 transcript:AT1G01050.2 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:PPA1 description:Soluble inorganic pyrophosphatase 1 [Source:UniProtKB/Swiss-Prot;Acc:Q93V56]) & Soluble inorganic pyrophosphatase 1 OS=Arabidopsis thaliana (sp|q93v56|ipyr1_arath : 419.0),,,,,, +AT1G01060,gene,AT1G01060.8,LHY1,LATE ELONGATED HYPOCOTYL 1,protein_coding,Homeodomain-like superfamily protein;(source:Araport11),,,"DNA-binding transcription factor activity, DNA binding, transcription regulatory region DNA binding","GO:0003700, GO:0003677, GO:0044212",27.1.1,.Multi-process regulation.circadian clock system.core oscillator protein (LHY|CCA1),circadian clock core oscillator protein (LHY|CCA1) (original description: pep chromosome:TAIR10:1:33967:37230:-1 gene:AT1G01060 transcript:AT1G01060.8 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:LHY description:LHY1 [Source:UniProtKB/TrEMBL;Acc:A0A178W761]),,,,,, +AT1G01070,gene,AT1G01070.2,UMAMIT28,Usually multiple acids move in and out Transporters 28,protein_coding,nodulin MtN21 /EamA-like transporter family protein;(source:Araport11),Encodes a plasma membrane-localized amino acid transporter likely involved in amino acid export in the developing seed.,nodulin MtN21 /EamA-like transporter family protein,L-glutamine transmembrane transporter activity,GO:0015186,24.2.1.5,.Solute transport.carrier-mediated transport.DMT superfamily.solute transporter (UmamiT),solute transporter (UmamiT) (original description: pep chromosome:TAIR10:1:38752:40945:-1 gene:AT1G01070 transcript:AT1G01070.2 gene_biotype:protein_coding transcript_biotype:protein_coding description:WAT1-related protein [Source:UniProtKB/TrEMBL;Acc:A0A178WFU3]),,,,,, +AT1G01080,gene,AT1G01080.3,,,protein_coding,RNA-binding (RRM/RBD/RNP motifs) family protein;(source:Araport11),,,"RNA binding, mRNA binding","GO:0003723, GO:0003729",35.1,not assigned.annotated,"(original description: pep chromosome:TAIR10:1:44970:47059:-1 gene:AT1G01080 transcript:AT1G01080.3 gene_biotype:protein_coding transcript_biotype:protein_coding description:RNA-binding (RRM/RBD/RNP motifs) family protein [Source:UniProtKB/TrEMBL;Acc:F4HQH8]) & 33 kDa ribonucleoprotein, chloroplastic OS=Nicotiana sylvestris (sp|p19684|roc5_nicsy : 109.0)",,,,,, +AT1G01090,gene,AT1G01090.1,PDH-E1 ALPHA,pyruvate dehydrogenase E1 alpha,protein_coding,pyruvate dehydrogenase E1 alpha;(source:Araport11),pyruvate dehydrogenase E1 alpha subunit,pyruvate dehydrogenase E1 alpha,pyruvate dehydrogenase (acetyl-transferring) activity,GO:0004739,5.1.2.2.1.1,.Lipid metabolism.fatty acid biosynthesis.acetyl-CoA generation.plastidial pyruvate dehydrogenase complex.E1 pyruvate dehydrogenase subcomplex.subunit alpha,subunit alpha of E1 pyruvate dehydrogenase component (original description: pep chromosome:TAIR10:1:47234:49304:-1 gene:AT1G01090 transcript:AT1G01090.1 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:PDH-E1 ALPHA description:Pyruvate dehydrogenase E1 component subunit alpha [Source:UniProtKB/TrEMBL;Acc:A0A178W8A7]),,,,,, +AT1G01100,gene,AT1G01100.4,,,protein_coding,60S acidic ribosomal protein family;(source:Araport11),,60S acidic ribosomal protein family,"structural constituent of ribosome, ribonucleoprotein complex binding, protein kinase activator activity","GO:0003735, GO:0043021, GO:0030295",17.1.2.1.46,.Protein biosynthesis.ribosome biogenesis.large ribosomal subunit (LSU).LSU proteome.component RPP1,component RPP1 of LSU proteome component (original description: pep chromosome:TAIR10:1:50090:51187:-1 gene:AT1G01100 transcript:AT1G01100.4 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:RPP1A description:60S acidic ribosomal protein P1-1 [Source:UniProtKB/Swiss-Prot;Acc:Q8LCW9]),,,,,, +Na23,pheno,,,,,,,,,,,,,10.21958/phenotype:5,"Sodium concentrations in leaves, grown in soil. Elemental analysis was performed with an ICP-MS (PerkinElmer). Sample normalized to calculated weights as described in Baxter et al., 2008",sodium concentration,The total sodium ion concentration measured in a given volume of a plant or a plant part or plant extract. [GR:pj],"Atwell et. al, Nature 2010", +SDV,pheno,,,,,,,,,,,,,10.21958/phenotype:104,"Number of days following stratification to opening of first flower. The experiment was stopped at 200 d, and accessions that had not flowered at that point were assigned a value of 200",days to flowering trait,"A flowering time trait (TO:0002616)which is the number of days required for an individual flower (PO:0009046), a whole plant (PO:0000003) or a plant population to reach flowering stage (PO:0007616) from a predetermined time point (e.g. the date of seed sowing, seedling transplant, or seedling emergence). [GR:pj, TO:cooperl]","Atwell et. al, Nature 2010", diff --git a/spec/test/djornl/invalid_types/merged_edges-AMW-060820_AF.tsv b/spec/test/djornl/invalid_types/merged_edges-AMW-060820_AF.tsv new file mode 100644 index 00000000..f9857bde --- /dev/null +++ b/spec/test/djornl/invalid_types/merged_edges-AMW-060820_AF.tsv @@ -0,0 +1,9 @@ +node1 node2 edge edge_descrip layer_descrip +As2 AT1G01020 8.422046084731258 AraGWAS-Association_score AraGWAS-Some-Old-Rubbish-I-Made-Up +As2 AT1G01040 5.422046084731258 AraGWAS-Association_score AraGWAS-Phenotype_Associations +As75 AT1G01020 39.98573324312915 AraGWAS-Association_score AraGWAS-Phenotype_Associations +AT1G01010 AT1G01020 2.39322646755088 AraNetv2_log-likelihood-score AraNetv2-HT_high-throughput-ppi +AT1G01010 AT1G01030 2.39322646755088 AraNetv2_log-likelihood-score AraNetv2-HT_high-throughput-ppi +AT1G01010 AT1G01040 2.39322646755088 AraNetv2_log-likelihood-score raNetv2-DC_domain-co-occurrence +AT1G01030 AT1G01050 2.5494618241936697 AraNetv2_log-likelihood-score AraNetv2-CX_pairwise-gene-coexpression +AT1G01050 AT1G01060 4.34242054808616 AraNetv2_log-likelihood-score AraNetv2-LC_lit-curated-ppi diff --git a/spec/test/djornl/results.json b/spec/test/djornl/results.json new file mode 100644 index 00000000..a844c2c2 --- /dev/null +++ b/spec/test/djornl/results.json @@ -0,0 +1,313 @@ +{ + "load_edges": { + "nodes": [ + {"_key": "As2"}, + {"_key": "AT1G01020"}, + {"_key": "AT1G01040"}, + {"_key": "As75"}, + {"_key": "AT1G01010"}, + {"_key": "AT1G01030"}, + {"_key": "AT1G01050"}, + {"_key": "AT1G01060"}, + {"_key": "AT1G01080"}, + {"_key": "AT1G01090"} + ], + "edges": [ + {"_key": "As2__AT1G01020__pheno_assn__8.4", "_from": "djornl_node/As2", "_to": "djornl_node/AT1G01020", "edge_type": "pheno_assn", "score": 8.4}, + {"_key": "As2__AT1G01040__pheno_assn__5.4", "_from": "djornl_node/As2", "_to": "djornl_node/AT1G01040", "edge_type": "pheno_assn", "score": 5.4}, + {"_key": "As75__AT1G01020__pheno_assn__39.9", "_from": "djornl_node/As75", "_to": "djornl_node/AT1G01020", "edge_type": "pheno_assn", "score": 39.9}, + {"_key": "AT1G01010__AT1G01020__ppi_hithru__2.3", "_from": "djornl_node/AT1G01010", "_to": "djornl_node/AT1G01020", "edge_type": "ppi_hithru", "score": 2.3}, + {"_key": "AT1G01010__AT1G01030__ppi_hithru__2.4", "_from": "djornl_node/AT1G01010", "_to": "djornl_node/AT1G01030", "edge_type": "ppi_hithru", "score": 2.4}, + {"_key": "AT1G01010__AT1G01040__domain_co_occur__2.5", "_from": "djornl_node/AT1G01010", "_to": "djornl_node/AT1G01040", "edge_type": "domain_co_occur", "score": 2.5}, + {"_key": "AT1G01010__AT1G01040__ppi_liter__170.5", "_from": "djornl_node/AT1G01010", "_to": "djornl_node/AT1G01040", "edge_type": "ppi_liter", "score": 170.5}, + {"_key": "AT1G01030__AT1G01050__gene_coexpr__2.6", "_from": "djornl_node/AT1G01030", "_to": "djornl_node/AT1G01050", "edge_type": "gene_coexpr", "score": 2.6}, + {"_key": "AT1G01050__AT1G01060__ppi_liter__2.7", "_from": "djornl_node/AT1G01050", "_to": "djornl_node/AT1G01060", "edge_type": "ppi_liter", "score": 2.7}, + {"_key": "AT1G01080__AT1G01090__ppi_liter__2.8", "_from": "djornl_node/AT1G01080", "_to": "djornl_node/AT1G01090", "edge_type": "ppi_liter", "score": 2.8} + ] + }, + "load_cluster_data": { + "nodes": [ + {"_key": "AT1G01010", "cluster_I2": 1}, + {"_key": "AT1G01030", "cluster_I2": 1}, + {"_key": "AT1G01040", "cluster_I2": 1}, + {"_key": "AT1G01050", "cluster_I2": 2}, + {"_key": "AT1G01060", "cluster_I2": 2}, + {"_key": "AT1G01070", "cluster_I2": 2}, + {"_key": "AT1G01080", "cluster_I2": 3}, + {"_key": "AT1G01090", "cluster_I2": 3}, + {"_key": "AT1G01020", "cluster_I2": 5}, + {"_key": "AT1G01040", "cluster_I6": 1}, + {"_key": "AT1G01090", "cluster_I6": 1}, + {"_key": "AT1G01070", "cluster_I6": 2}, + {"_key": "AT1G01010", "cluster_I6": 3}, + {"_key": "AT1G01020", "cluster_I6": 3}, + {"_key": "AT1G01030", "cluster_I6": 3} + ] + }, + "load_node_metadata": { + "nodes": [ + {"_key": "As2", "node_type": "pheno", "transcript": "", "gene_symbol": "", "gene_full_name": "", "gene_model_type": "", "tair_computational_desc": "", "tair_curator_summary": "", "tair_short_desc": "", "go_descr": "", "go_terms": [], "mapman_bin": "", "mapman_name": "", "mapman_desc": "", "pheno_aragwas_id": "10.21958/phenotype:103", "pheno_desc1": "", "pheno_desc2": "bacterial disease resistance", "pheno_desc3": "The resistance exhibited by a plant or a group of plants (population) in response to the disease caused by a bacterial pathogen infection as compared to the susceptible and/or the reference plants of the same species. [GR:pj]", "pheno_ref": "Atwell et. al, Nature 2010", "user_notes": ""}, + {"_key": "As75", "node_type": "pheno", "transcript": "", "gene_symbol": "", "gene_full_name": "", "gene_model_type": "", "tair_computational_desc": "", "tair_curator_summary": "", "tair_short_desc": "", "go_descr": "", "go_terms": [], "mapman_bin": "", "mapman_name": "", "mapman_desc": "", "pheno_aragwas_id": "10.21958/phenotype:67", "pheno_desc1": "Arsenic concentrations in leaves, grown in soil. Elemental analysis was performed with an ICP-MS (PerkinElmer). Sample normalized to calculated weights as described in Baxter et al., 2008", "pheno_desc2": "arsenic concentration", "pheno_desc3": "A mineral and ion content related trait (TO:0000465) which is the concentration of arsenic (CHEBI:22632) in some plant structure (PO:0009011). [GR:Karthik]", "pheno_ref": "Atwell et. al, Nature 2010", "user_notes": ""}, + {"_key": "AT1G01010", "node_type": "gene", "transcript": "AT1G01010.1", "gene_symbol": "NTL10", "gene_full_name": "NAC domain containing protein 1", "gene_model_type": "protein_coding", "tair_computational_desc": "NAC domain containing protein 1;(source:Araport11)", "tair_curator_summary": "", "tair_short_desc": "NAC domain containing protein 1", "go_descr": "DNA-binding transcription factor activity, DNA binding", "go_terms": ["GO:0003700", "GO:0003677"], "mapman_bin": "15.5.17", "mapman_name": ".RNA biosynthesis.transcriptional regulation.transcription factor (NAC)", "mapman_desc": "transcription factor (NAC) (original description: pep chromosome:TAIR10:1:3631:5899:1 gene:AT1G01010 transcript:AT1G01010.1 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:NAC001 description:NAC domain-containing protein 1 [Source:UniProtKB/Swiss-Prot;Acc:Q0WV96])", "pheno_aragwas_id": "", "pheno_desc1": "", "pheno_desc2": "", "pheno_desc3": "", "pheno_ref": "", "user_notes": ""}, + {"_key": "AT1G01020", "node_type": "gene", "transcript": "AT1G01020.6", "gene_symbol": "ARV1", "gene_full_name": "", "gene_model_type": "protein_coding", "tair_computational_desc": "ARV1 family protein;(source:Araport11)", "tair_curator_summary": "", "tair_short_desc": "", "go_descr": "molecular_function", "go_terms": ["GO:0003674"], "mapman_bin": "35.1", "mapman_name": "not assigned.annotated", "mapman_desc": "(original description: pep chromosome:TAIR10:1:6788:8737:-1 gene:AT1G01020 transcript:AT1G01020.6 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:ARV1 description:ARV1 family protein [Source:UniProtKB/TrEMBL;Acc:Q5MK24]) & no description available(sp|q5mk24|arv1_arath : 99.4)", "pheno_aragwas_id": "", "pheno_desc1": "", "pheno_desc2": "", "pheno_desc3": "", "pheno_ref": "", "user_notes": ""}, + {"_key": "AT1G01030", "node_type": "gene", "transcript": "AT1G01030.2", "gene_symbol": "NGA3", "gene_full_name": "NGATHA3", "gene_model_type": "protein_coding", "tair_computational_desc": "AP2/B3-like transcriptional factor family protein;(source:Araport11)", "tair_curator_summary": "", "tair_short_desc": "", "go_descr": "DNA-binding transcription factor activity, DNA binding", "go_terms": ["GO:0003700", "GO:0003677"], "mapman_bin": "15.5.5.3", "mapman_name": ".RNA biosynthesis.transcriptional regulation.B3 transcription factor superfamily.transcription factor (RAV/NGATHA)", "mapman_desc": "transcription factor (RAV/NGATHA) (original description: pep chromosome:TAIR10:1:11649:13714:-1 gene:AT1G01030 transcript:AT1G01030.2 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:NGA3 description:B3 domain-containing transcription factor NGA3 [Source:UniProtKB/Swiss-Prot;Acc:Q9MAN1])", "pheno_aragwas_id": "", "pheno_desc1": "", "pheno_desc2": "", "pheno_desc3": "", "pheno_ref": "", "user_notes": ""}, + {"_key": "AT1G01040", "node_type": "gene", "transcript": "AT1G01040.2", "gene_symbol": "SUS1", "gene_full_name": "SUSPENSOR 1", "gene_model_type": "protein_coding", "tair_computational_desc": "dicer-like 1;(source:Araport11)", "tair_curator_summary": "Encodes a Dicer homolog. Dicer is a RNA helicase involved in microRNA processing. Mutations in this locus can result in embryo lethality. Embryo shape at seed maturity is globular-elongate. Other mutants convert the floral meristems to an indeterminate state, others yet show defects in ovule development. mRNA is expressed in all shoot tissues. DCL1 is able to produce miRNAs and siRNAs. The mRNA is cell-to-cell mobile.", "tair_short_desc": "dicer-like 1", "go_descr": "metal ion binding, protein binding, ribonuclease III activity, ATP-dependent helicase activity, ATP binding, RNA binding, helicase activity, double-stranded RNA binding, DNA binding", "go_terms": ["GO:0046872", "GO:0005515", "GO:0004525", "GO:0008026", "GO:0005524", "GO:0003723", "GO:0004386", "GO:0003725", "GO:0003677"], "mapman_bin": "16.10.2.1.1", "mapman_name": ".RNA processing.mRNA silencing.miRNA pathway.DCL1-HYL1 miRNA biogenesis complex.endoribonuclease component DCL1", "mapman_desc": "endoribonuclease component DCL1 of DCL1-HYL1 miRNA biogenesis complex (original description: pep chromosome:TAIR10:1:23416:31120:1 gene:AT1G01040 transcript:AT1G01040.2 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:DCL1 description:Dicer-like 1 [Source:UniProtKB/TrEMBL;Acc:F4HQG6])", "pheno_aragwas_id": "", "pheno_desc1": "", "pheno_desc2": "", "pheno_desc3": "", "pheno_ref": "", "user_notes": ""}, + {"_key": "AT1G01050", "node_type": "gene", "transcript": "AT1G01050.2", "gene_symbol": "PPa1", "gene_full_name": "pyrophosphorylase 1", "gene_model_type": "protein_coding", "tair_computational_desc": "pyrophosphorylase 1;(source:Araport11)", "tair_curator_summary": "", "tair_short_desc": "", "go_descr": "inorganic diphosphatase activity", "go_terms": ["GO:0004427"], "mapman_bin": "35.1", "mapman_name": "not assigned.annotated", "mapman_desc": "(original description: pep chromosome:TAIR10:1:31382:33009:-1 gene:AT1G01050 transcript:AT1G01050.2 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:PPA1 description:Soluble inorganic pyrophosphatase 1 [Source:UniProtKB/Swiss-Prot;Acc:Q93V56]) & Soluble inorganic pyrophosphatase 1 OS=Arabidopsis thaliana (sp|q93v56|ipyr1_arath : 419.0)", "pheno_aragwas_id": "", "pheno_desc1": "", "pheno_desc2": "", "pheno_desc3": "", "pheno_ref": "", "user_notes": ""}, + {"_key": "AT1G01060", "node_type": "gene", "transcript": "AT1G01060.8", "gene_symbol": "LHY1", "gene_full_name": "LATE ELONGATED HYPOCOTYL 1", "gene_model_type": "protein_coding", "tair_computational_desc": "Homeodomain-like superfamily protein;(source:Araport11)", "tair_curator_summary": "", "tair_short_desc": "", "go_descr": "DNA-binding transcription factor activity, DNA binding, transcription regulatory region DNA binding", "go_terms": ["GO:0003700", "GO:0003677", "GO:0044212"], "mapman_bin": "27.1.1", "mapman_name": ".Multi-process regulation.circadian clock system.core oscillator protein (LHY|CCA1)", "mapman_desc": "circadian clock core oscillator protein (LHY|CCA1) (original description: pep chromosome:TAIR10:1:33967:37230:-1 gene:AT1G01060 transcript:AT1G01060.8 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:LHY description:LHY1 [Source:UniProtKB/TrEMBL;Acc:A0A178W761])", "pheno_aragwas_id": "", "pheno_desc1": "", "pheno_desc2": "", "pheno_desc3": "", "pheno_ref": "", "user_notes": ""}, + {"_key": "AT1G01070", "node_type": "gene", "transcript": "AT1G01070.2", "gene_symbol": "UMAMIT28", "gene_full_name": "Usually multiple acids move in and out Transporters 28", "gene_model_type": "protein_coding", "tair_computational_desc": "nodulin MtN21 /EamA-like transporter family protein;(source:Araport11)", "tair_curator_summary": "Encodes a plasma membrane-localized amino acid transporter likely involved in amino acid export in the developing seed.", "tair_short_desc": "nodulin MtN21 /EamA-like transporter family protein", "go_descr": "L-glutamine transmembrane transporter activity", "go_terms": ["GO:0015186"], "mapman_bin": "24.2.1.5", "mapman_name": ".Solute transport.carrier-mediated transport.DMT superfamily.solute transporter (UmamiT)", "mapman_desc": "solute transporter (UmamiT) (original description: pep chromosome:TAIR10:1:38752:40945:-1 gene:AT1G01070 transcript:AT1G01070.2 gene_biotype:protein_coding transcript_biotype:protein_coding description:WAT1-related protein [Source:UniProtKB/TrEMBL;Acc:A0A178WFU3])", "pheno_aragwas_id": "", "pheno_desc1": "", "pheno_desc2": "", "pheno_desc3": "", "pheno_ref": "", "user_notes": ""}, + {"_key": "AT1G01080", "node_type": "gene", "transcript": "AT1G01080.3", "gene_symbol": "", "gene_full_name": "", "gene_model_type": "protein_coding", "tair_computational_desc": "RNA-binding (RRM/RBD/RNP motifs) family protein;(source:Araport11)", "tair_curator_summary": "", "tair_short_desc": "", "go_descr": "RNA binding, mRNA binding", "go_terms": ["GO:0003723", "GO:0003729"], "mapman_bin": "35.1", "mapman_name": "not assigned.annotated", "mapman_desc": "(original description: pep chromosome:TAIR10:1:44970:47059:-1 gene:AT1G01080 transcript:AT1G01080.3 gene_biotype:protein_coding transcript_biotype:protein_coding description:RNA-binding (RRM/RBD/RNP motifs) family protein [Source:UniProtKB/TrEMBL;Acc:F4HQH8]) & 33 kDa ribonucleoprotein, chloroplastic OS=Nicotiana sylvestris (sp|p19684|roc5_nicsy : 109.0)", "pheno_aragwas_id": "", "pheno_desc1": "", "pheno_desc2": "", "pheno_desc3": "", "pheno_ref": "", "user_notes": ""}, + {"_key": "AT1G01090", "node_type": "gene", "transcript": "AT1G01090.1", "gene_symbol": "PDH-E1 ALPHA", "gene_full_name": "pyruvate dehydrogenase E1 alpha", "gene_model_type": "protein_coding", "tair_computational_desc": "pyruvate dehydrogenase E1 alpha;(source:Araport11)", "tair_curator_summary": "pyruvate dehydrogenase E1 alpha subunit", "tair_short_desc": "pyruvate dehydrogenase E1 alpha", "go_descr": "pyruvate dehydrogenase (acetyl-transferring) activity, protein binding", "go_terms": ["GO:0004739", "GO:0005515"], "mapman_bin": "5.1.2.2.1.1", "mapman_name": ".Lipid metabolism.fatty acid biosynthesis.acetyl-CoA generation.plastidial pyruvate dehydrogenase complex.E1 pyruvate dehydrogenase subcomplex.subunit alpha", "mapman_desc": "subunit alpha of E1 pyruvate dehydrogenase component (original description: pep chromosome:TAIR10:1:47234:49304:-1 gene:AT1G01090 transcript:AT1G01090.1 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:PDH-E1 ALPHA description:Pyruvate dehydrogenase E1 component subunit alpha [Source:UniProtKB/TrEMBL;Acc:A0A178W8A7])", "pheno_aragwas_id": "", "pheno_desc1": "", "pheno_desc2": "", "pheno_desc3": "", "pheno_ref": "", "user_notes": ""}, + {"_key": "AT1G01100", "node_type": "gene", "transcript": "AT1G01100.4", "gene_symbol": "", "gene_full_name": "", "gene_model_type": "protein_coding", "tair_computational_desc": "60S acidic ribosomal protein family;(source:Araport11)", "tair_curator_summary": "", "tair_short_desc": "60S acidic ribosomal protein family", "go_descr": "structural constituent of ribosome, ribonucleoprotein complex binding, protein kinase activator activity", "go_terms": ["GO:0003735", "GO:0043021", "GO:0030295"], "mapman_bin": "17.1.2.1.46", "mapman_name": ".Protein biosynthesis.ribosome biogenesis.large ribosomal subunit (LSU).LSU proteome.component RPP1", "mapman_desc": "component RPP1 of LSU proteome component (original description: pep chromosome:TAIR10:1:50090:51187:-1 gene:AT1G01100 transcript:AT1G01100.4 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:RPP1A description:60S acidic ribosomal protein P1-1 [Source:UniProtKB/Swiss-Prot;Acc:Q8LCW9])", "pheno_aragwas_id": "", "pheno_desc1": "", "pheno_desc2": "", "pheno_desc3": "", "pheno_ref": "", "user_notes": ""}, + {"_key": "Na23", "node_type": "pheno", "transcript": "", "gene_symbol": "", "gene_full_name": "", "gene_model_type": "", "tair_computational_desc": "", "tair_curator_summary": "", "tair_short_desc": "", "go_descr": "", "go_terms": [], "mapman_bin": "", "mapman_name": "", "mapman_desc": "", "pheno_aragwas_id": "10.21958/phenotype:5", "pheno_desc1": "Sodium concentrations in leaves, grown in soil. Elemental analysis was performed with an ICP-MS (PerkinElmer). Sample normalized to calculated weights as described in Baxter et al., 2008", "pheno_desc2": "sodium concentration", "pheno_desc3": "The total sodium ion concentration measured in a given volume of a plant or a plant part or plant extract. [GR:pj]", "pheno_ref": "Atwell et. al, Nature 2010", "user_notes": ""}, + {"_key": "SDV", "node_type": "pheno", "transcript": "", "gene_symbol": "", "gene_full_name": "", "gene_model_type": "", "tair_computational_desc": "", "tair_curator_summary": "", "tair_short_desc": "", "go_descr": "", "go_terms": [], "mapman_bin": "", "mapman_name": "", "mapman_desc": "", "pheno_aragwas_id": "10.21958/phenotype:104", "pheno_desc1": "Number of days following stratification to opening of first flower. The experiment was stopped at 200 d, and accessions that had not flowered at that point were assigned a value of 200", "pheno_desc2": "days to flowering trait", "pheno_desc3": "A flowering time trait (TO:0002616)which is the number of days required for an individual flower (PO:0009046), a whole plant (PO:0000003) or a plant population to reach flowering stage (PO:0007616) from a predetermined time point (e.g. the date of seed sowing, seedling transplant, or seedling emergence). [GR:pj, TO:cooperl]", "pheno_ref": "Atwell et. al, Nature 2010", "user_notes": ""} + ] + }, + "fetch_all": { + "nodes": [ + "As2", + "As75", + "AT1G01010", + "AT1G01020", + "AT1G01030", + "AT1G01040", + "AT1G01050", + "AT1G01060", + "AT1G01070", + "AT1G01080", + "AT1G01090", + "AT1G01100", + "Na23", + "SDV" + ], + "edges": [ + "As2__AT1G01020__pheno_assn__8.4", + "As2__AT1G01040__pheno_assn__5.4", + "As75__AT1G01020__pheno_assn__39.9", + "AT1G01010__AT1G01020__ppi_hithru__2.3", + "AT1G01010__AT1G01030__ppi_hithru__2.4", + "AT1G01010__AT1G01040__domain_co_occur__2.5", + "AT1G01010__AT1G01040__ppi_liter__170.5", + "AT1G01030__AT1G01050__gene_coexpr__2.6", + "AT1G01050__AT1G01060__ppi_liter__2.7", + "AT1G01080__AT1G01090__ppi_liter__2.8" + ] + }, + "fetch_genes": { + "AT1G01010": { + "0": { + "nodes": ["AT1G01010"], + "edges": [] + }, + "1": { + "nodes": [ + "AT1G01010", + "AT1G01020", + "AT1G01030", + "AT1G01040" + ], + "edges": [ + "AT1G01010__AT1G01020__ppi_hithru__2.3", + "AT1G01010__AT1G01030__ppi_hithru__2.4", + "AT1G01010__AT1G01040__domain_co_occur__2.5", + "AT1G01010__AT1G01040__ppi_liter__170.5" + ] + }, + "5": { + "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060"], + "edges": [ + "As2__AT1G01020__pheno_assn__8.4", + "As2__AT1G01040__pheno_assn__5.4", + "As75__AT1G01020__pheno_assn__39.9", + "AT1G01010__AT1G01020__ppi_hithru__2.3", + "AT1G01010__AT1G01030__ppi_hithru__2.4", + "AT1G01010__AT1G01040__domain_co_occur__2.5", + "AT1G01010__AT1G01040__ppi_liter__170.5", + "AT1G01030__AT1G01050__gene_coexpr__2.6", + "AT1G01050__AT1G01060__ppi_liter__2.7" + ] + } + }, + "AT1G01020__AT1G01070": { + "0": { + "nodes": ["AT1G01020", "AT1G01070"], + "edges": [] + }, + "1": { + "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01070"], + "edges": [ + "As2__AT1G01020__pheno_assn__8.4", + "As75__AT1G01020__pheno_assn__39.9", + "AT1G01010__AT1G01020__ppi_hithru__2.3" + ] + }, + "5": { + "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060", "AT1G01070"], + "edges": [ + "As2__AT1G01020__pheno_assn__8.4", + "As2__AT1G01040__pheno_assn__5.4", + "As75__AT1G01020__pheno_assn__39.9", + "AT1G01010__AT1G01020__ppi_hithru__2.3", + "AT1G01010__AT1G01030__ppi_hithru__2.4", + "AT1G01010__AT1G01040__domain_co_occur__2.5", + "AT1G01010__AT1G01040__ppi_liter__170.5", + "AT1G01030__AT1G01050__gene_coexpr__2.6", + "AT1G01050__AT1G01060__ppi_liter__2.7" + ] + } + } + }, + "fetch_phenotypes": { + "As2": { + "0": { + "nodes": ["As2"], + "edges": [] + }, + "1": { + "nodes": ["As2", "AT1G01020", "AT1G01040"], + "edges": [ + "As2__AT1G01020__pheno_assn__8.4", + "As2__AT1G01040__pheno_assn__5.4" + ] + }, + "5": { + "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060"], + "edges": [ + "As2__AT1G01020__pheno_assn__8.4", + "As2__AT1G01040__pheno_assn__5.4", + "As75__AT1G01020__pheno_assn__39.9", + "AT1G01010__AT1G01020__ppi_hithru__2.3", + "AT1G01010__AT1G01030__ppi_hithru__2.4", + "AT1G01010__AT1G01040__domain_co_occur__2.5", + "AT1G01010__AT1G01040__ppi_liter__170.5", + "AT1G01030__AT1G01050__gene_coexpr__2.6", + "AT1G01050__AT1G01060__ppi_liter__2.7" + ] + } + }, + "As2__Na23": { + "0": { + "nodes": ["As2", "Na23"], + "edges": [] + }, + "1": { + "nodes": ["As2", "Na23", "AT1G01020", "AT1G01040"], + "edges": [ + "As2__AT1G01020__pheno_assn__8.4", + "As2__AT1G01040__pheno_assn__5.4" + ] + }, + "5": { + "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060", "Na23"], + "edges": [ + "As2__AT1G01020__pheno_assn__8.4", + "As2__AT1G01040__pheno_assn__5.4", + "As75__AT1G01020__pheno_assn__39.9", + "AT1G01010__AT1G01020__ppi_hithru__2.3", + "AT1G01010__AT1G01030__ppi_hithru__2.4", + "AT1G01010__AT1G01040__domain_co_occur__2.5", + "AT1G01010__AT1G01040__ppi_liter__170.5", + "AT1G01030__AT1G01050__gene_coexpr__2.6", + "AT1G01050__AT1G01060__ppi_liter__2.7" + ] + } + } + }, + "search_nodes": { + "Mary Poppins": { + "0": {"nodes": [], "edges": []}, + "1": {"nodes": [], "edges": []}, + "5": {"nodes": [], "edges": []} + }, + "GO:0005515": { + "0": { + "nodes": ["AT1G01040", "AT1G01090"], + "edges": [] + }, + "1": { + "nodes": ["As2", "AT1G01010", "AT1G01040", "AT1G01080", "AT1G01090"], + "edges": [ + "As2__AT1G01040__pheno_assn__5.4", + "AT1G01010__AT1G01040__domain_co_occur__2.5", + "AT1G01010__AT1G01040__ppi_liter__170.5", + "AT1G01080__AT1G01090__ppi_liter__2.8" + ] + }, + "5": { + "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060", "AT1G01080", "AT1G01090"], + "edges": [ + "As2__AT1G01020__pheno_assn__8.4", + "As2__AT1G01040__pheno_assn__5.4", + "As75__AT1G01020__pheno_assn__39.9", + "AT1G01010__AT1G01020__ppi_hithru__2.3", + "AT1G01010__AT1G01030__ppi_hithru__2.4", + "AT1G01010__AT1G01040__domain_co_occur__2.5", + "AT1G01010__AT1G01040__ppi_liter__170.5", + "AT1G01030__AT1G01050__gene_coexpr__2.6", + "AT1G01050__AT1G01060__ppi_liter__2.7", + "AT1G01080__AT1G01090__ppi_liter__2.8" + ] + } + } + }, + + "fetch_clusters": { + "i6-1": { + "0": { + "nodes": ["AT1G01040", "AT1G01090"], + "edges": [] + }, + "1": { + "nodes": ["As2", "AT1G01010", "AT1G01040", "AT1G01080", "AT1G01090"], + "edges": [ + "As2__AT1G01040__pheno_assn__5.4", + "AT1G01010__AT1G01040__domain_co_occur__2.5", + "AT1G01010__AT1G01040__ppi_liter__170.5", + "AT1G01080__AT1G01090__ppi_liter__2.8" + ] + }, + "5": { + "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060", "AT1G01080", "AT1G01090"], + "edges": [ + "As2__AT1G01020__pheno_assn__8.4", + "As2__AT1G01040__pheno_assn__5.4", + "As75__AT1G01020__pheno_assn__39.9", + "AT1G01010__AT1G01020__ppi_hithru__2.3", + "AT1G01010__AT1G01030__ppi_hithru__2.4", + "AT1G01010__AT1G01040__domain_co_occur__2.5", + "AT1G01010__AT1G01040__ppi_liter__170.5", + "AT1G01030__AT1G01050__gene_coexpr__2.6", + "AT1G01050__AT1G01060__ppi_liter__2.7", + "AT1G01080__AT1G01090__ppi_liter__2.8" + ] + } + }, + "i2-5__i6-2": { + "0": { + "nodes": ["AT1G01020", "AT1G01070"], + "edges": [] + }, + "1": { + "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01070"], + "edges": [ + "As2__AT1G01020__pheno_assn__8.4", + "As75__AT1G01020__pheno_assn__39.9", + "AT1G01010__AT1G01020__ppi_hithru__2.3" + ] + }, + "5": { + "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060", "AT1G01070"], + "edges": [ + "As2__AT1G01020__pheno_assn__8.4", + "As2__AT1G01040__pheno_assn__5.4", + "As75__AT1G01020__pheno_assn__39.9", + "AT1G01010__AT1G01020__ppi_hithru__2.3", + "AT1G01010__AT1G01030__ppi_hithru__2.4", + "AT1G01010__AT1G01040__domain_co_occur__2.5", + "AT1G01010__AT1G01040__ppi_liter__170.5", + "AT1G01030__AT1G01050__gene_coexpr__2.6", + "AT1G01050__AT1G01060__ppi_liter__2.7" + ] + } + } + } +} diff --git a/spec/test/djornl/test_data/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv b/spec/test/djornl/test_data/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv new file mode 100644 index 00000000..5bc0e1d8 --- /dev/null +++ b/spec/test/djornl/test_data/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv @@ -0,0 +1,15 @@ +node_id,node_type,transcript,gene_symbol,gene_full_name,gene_model_type,TAIR_Computational_description,TAIR_Curator_summary,TAIR_short_description,GO_descr,GO_terms,MapMan_bin,MapMan_name,MapMan_descr,pheno_AraGWAS_ID,pheno_descrip1,pheno_descrip2,pheno_descrip3,pheno_ref,UserNotes +As2,pheno,,,,,,,,,,,,,10.21958/phenotype:103,,bacterial disease resistance,The resistance exhibited by a plant or a group of plants (population) in response to the disease caused by a bacterial pathogen infection as compared to the susceptible and/or the reference plants of the same species. [GR:pj],"Atwell et. al, Nature 2010", +As75,pheno,,,,,,,,,,,,,10.21958/phenotype:67,"Arsenic concentrations in leaves, grown in soil. Elemental analysis was performed with an ICP-MS (PerkinElmer). Sample normalized to calculated weights as described in Baxter et al., 2008",arsenic concentration,A mineral and ion content related trait (TO:0000465) which is the concentration of arsenic (CHEBI:22632) in some plant structure (PO:0009011). [GR:Karthik],"Atwell et. al, Nature 2010", +AT1G01010,gene,AT1G01010.1,NTL10,NAC domain containing protein 1,protein_coding,NAC domain containing protein 1;(source:Araport11),,NAC domain containing protein 1,"DNA-binding transcription factor activity, DNA binding","GO:0003700, GO:0003677",15.5.17,.RNA biosynthesis.transcriptional regulation.transcription factor (NAC),transcription factor (NAC) (original description: pep chromosome:TAIR10:1:3631:5899:1 gene:AT1G01010 transcript:AT1G01010.1 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:NAC001 description:NAC domain-containing protein 1 [Source:UniProtKB/Swiss-Prot;Acc:Q0WV96]),,,,,, +AT1G01020,gene,AT1G01020.6,ARV1,,protein_coding,ARV1 family protein;(source:Araport11),,,molecular_function,GO:0003674,35.1,not assigned.annotated,(original description: pep chromosome:TAIR10:1:6788:8737:-1 gene:AT1G01020 transcript:AT1G01020.6 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:ARV1 description:ARV1 family protein [Source:UniProtKB/TrEMBL;Acc:Q5MK24]) & no description available(sp|q5mk24|arv1_arath : 99.4),,,,,, +AT1G01030,gene,AT1G01030.2,NGA3,NGATHA3,protein_coding,AP2/B3-like transcriptional factor family protein;(source:Araport11),,,"DNA-binding transcription factor activity, DNA binding","GO:0003700, GO:0003677",15.5.5.3,.RNA biosynthesis.transcriptional regulation.B3 transcription factor superfamily.transcription factor (RAV/NGATHA),transcription factor (RAV/NGATHA) (original description: pep chromosome:TAIR10:1:11649:13714:-1 gene:AT1G01030 transcript:AT1G01030.2 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:NGA3 description:B3 domain-containing transcription factor NGA3 [Source:UniProtKB/Swiss-Prot;Acc:Q9MAN1]),,,,,, +AT1G01040,gene,AT1G01040.2,SUS1,SUSPENSOR 1,protein_coding,dicer-like 1;(source:Araport11),"Encodes a Dicer homolog. Dicer is a RNA helicase involved in microRNA processing. Mutations in this locus can result in embryo lethality. Embryo shape at seed maturity is globular-elongate. Other mutants convert the floral meristems to an indeterminate state, others yet show defects in ovule development. mRNA is expressed in all shoot tissues. DCL1 is able to produce miRNAs and siRNAs. The mRNA is cell-to-cell mobile.",dicer-like 1,"metal ion binding, protein binding, ribonuclease III activity, ATP-dependent helicase activity, ATP binding, RNA binding, helicase activity, double-stranded RNA binding, DNA binding","GO:0046872, GO:0005515, GO:0004525, GO:0008026, GO:0005524, GO:0003723, GO:0004386, GO:0003725, GO:0003677",16.10.2.1.1,.RNA processing.mRNA silencing.miRNA pathway.DCL1-HYL1 miRNA biogenesis complex.endoribonuclease component DCL1,endoribonuclease component DCL1 of DCL1-HYL1 miRNA biogenesis complex (original description: pep chromosome:TAIR10:1:23416:31120:1 gene:AT1G01040 transcript:AT1G01040.2 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:DCL1 description:Dicer-like 1 [Source:UniProtKB/TrEMBL;Acc:F4HQG6]),,,,,, +AT1G01050,gene,AT1G01050.2,PPa1,pyrophosphorylase 1,protein_coding,pyrophosphorylase 1;(source:Araport11),,,inorganic diphosphatase activity,GO:0004427,35.1,not assigned.annotated,(original description: pep chromosome:TAIR10:1:31382:33009:-1 gene:AT1G01050 transcript:AT1G01050.2 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:PPA1 description:Soluble inorganic pyrophosphatase 1 [Source:UniProtKB/Swiss-Prot;Acc:Q93V56]) & Soluble inorganic pyrophosphatase 1 OS=Arabidopsis thaliana (sp|q93v56|ipyr1_arath : 419.0),,,,,, +AT1G01060,gene,AT1G01060.8,LHY1,LATE ELONGATED HYPOCOTYL 1,protein_coding,Homeodomain-like superfamily protein;(source:Araport11),,,"DNA-binding transcription factor activity, DNA binding, transcription regulatory region DNA binding","GO:0003700, GO:0003677, GO:0044212",27.1.1,.Multi-process regulation.circadian clock system.core oscillator protein (LHY|CCA1),circadian clock core oscillator protein (LHY|CCA1) (original description: pep chromosome:TAIR10:1:33967:37230:-1 gene:AT1G01060 transcript:AT1G01060.8 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:LHY description:LHY1 [Source:UniProtKB/TrEMBL;Acc:A0A178W761]),,,,,, +AT1G01070,gene,AT1G01070.2,UMAMIT28,Usually multiple acids move in and out Transporters 28,protein_coding,nodulin MtN21 /EamA-like transporter family protein;(source:Araport11),Encodes a plasma membrane-localized amino acid transporter likely involved in amino acid export in the developing seed.,nodulin MtN21 /EamA-like transporter family protein,L-glutamine transmembrane transporter activity,GO:0015186,24.2.1.5,.Solute transport.carrier-mediated transport.DMT superfamily.solute transporter (UmamiT),solute transporter (UmamiT) (original description: pep chromosome:TAIR10:1:38752:40945:-1 gene:AT1G01070 transcript:AT1G01070.2 gene_biotype:protein_coding transcript_biotype:protein_coding description:WAT1-related protein [Source:UniProtKB/TrEMBL;Acc:A0A178WFU3]),,,,,, +AT1G01080,gene,AT1G01080.3,,,protein_coding,RNA-binding (RRM/RBD/RNP motifs) family protein;(source:Araport11),,,"RNA binding, mRNA binding","GO:0003723, GO:0003729",35.1,not assigned.annotated,"(original description: pep chromosome:TAIR10:1:44970:47059:-1 gene:AT1G01080 transcript:AT1G01080.3 gene_biotype:protein_coding transcript_biotype:protein_coding description:RNA-binding (RRM/RBD/RNP motifs) family protein [Source:UniProtKB/TrEMBL;Acc:F4HQH8]) & 33 kDa ribonucleoprotein, chloroplastic OS=Nicotiana sylvestris (sp|p19684|roc5_nicsy : 109.0)",,,,,, +AT1G01090,gene,AT1G01090.1,PDH-E1 ALPHA,pyruvate dehydrogenase E1 alpha,protein_coding,pyruvate dehydrogenase E1 alpha;(source:Araport11),pyruvate dehydrogenase E1 alpha subunit,pyruvate dehydrogenase E1 alpha,"pyruvate dehydrogenase (acetyl-transferring) activity, protein binding","GO:0004739, GO:0005515",5.1.2.2.1.1,.Lipid metabolism.fatty acid biosynthesis.acetyl-CoA generation.plastidial pyruvate dehydrogenase complex.E1 pyruvate dehydrogenase subcomplex.subunit alpha,subunit alpha of E1 pyruvate dehydrogenase component (original description: pep chromosome:TAIR10:1:47234:49304:-1 gene:AT1G01090 transcript:AT1G01090.1 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:PDH-E1 ALPHA description:Pyruvate dehydrogenase E1 component subunit alpha [Source:UniProtKB/TrEMBL;Acc:A0A178W8A7]),,,,,, +AT1G01100,gene,AT1G01100.4,,,protein_coding,60S acidic ribosomal protein family;(source:Araport11),,60S acidic ribosomal protein family,"structural constituent of ribosome, ribonucleoprotein complex binding, protein kinase activator activity","GO:0003735, GO:0043021, GO:0030295",17.1.2.1.46,.Protein biosynthesis.ribosome biogenesis.large ribosomal subunit (LSU).LSU proteome.component RPP1,component RPP1 of LSU proteome component (original description: pep chromosome:TAIR10:1:50090:51187:-1 gene:AT1G01100 transcript:AT1G01100.4 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:RPP1A description:60S acidic ribosomal protein P1-1 [Source:UniProtKB/Swiss-Prot;Acc:Q8LCW9]),,,,,, +Na23,pheno,,,,,,,,,,,,,10.21958/phenotype:5,"Sodium concentrations in leaves, grown in soil. Elemental analysis was performed with an ICP-MS (PerkinElmer). Sample normalized to calculated weights as described in Baxter et al., 2008",sodium concentration,The total sodium ion concentration measured in a given volume of a plant or a plant part or plant extract. [GR:pj],"Atwell et. al, Nature 2010", +SDV,pheno,,,,,,,,,,,,,10.21958/phenotype:104,"Number of days following stratification to opening of first flower. The experiment was stopped at 200 d, and accessions that had not flowered at that point were assigned a value of 200",days to flowering trait,"A flowering time trait (TO:0002616)which is the number of days required for an individual flower (PO:0009046), a whole plant (PO:0000003) or a plant population to reach flowering stage (PO:0007616) from a predetermined time point (e.g. the date of seed sowing, seedling transplant, or seedling emergence). [GR:pj, TO:cooperl]","Atwell et. al, Nature 2010", diff --git a/spec/test/djornl/test_data/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I2_named.tsv b/spec/test/djornl/test_data/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I2_named.tsv new file mode 100644 index 00000000..086a9209 --- /dev/null +++ b/spec/test/djornl/test_data/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I2_named.tsv @@ -0,0 +1,5 @@ +Cluster1 AT1G01010 AT1G01030 AT1G01040 +Cluster2 AT1G01050 AT1G01060 AT1G01070 +Cluster3 AT1G01080 AT1G01090 +Cluster4 +Cluster5 AT1G01020 diff --git a/spec/test/djornl/test_data/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I4_named.tsv b/spec/test/djornl/test_data/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I4_named.tsv new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/spec/test/djornl/test_data/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I4_named.tsv @@ -0,0 +1 @@ + diff --git a/spec/test/djornl/test_data/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I6_named.tsv b/spec/test/djornl/test_data/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I6_named.tsv new file mode 100644 index 00000000..389cae2e --- /dev/null +++ b/spec/test/djornl/test_data/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I6_named.tsv @@ -0,0 +1,4 @@ +Cluster1 AT1G01040 AT1G01090 +Cluster2 AT1G01070 +Cluster3 AT1G01010 AT1G01020 AT1G01030 +Cluster4 diff --git a/spec/test/djornl/test_data/merged_edges-AMW-060820_AF.tsv b/spec/test/djornl/test_data/merged_edges-AMW-060820_AF.tsv new file mode 100644 index 00000000..44acc6ff --- /dev/null +++ b/spec/test/djornl/test_data/merged_edges-AMW-060820_AF.tsv @@ -0,0 +1,11 @@ +node1 node2 edge edge_descrip layer_descrip +As2 AT1G01020 8.4 AraGWAS-Association_score AraGWAS-Phenotype_Associations +As2 AT1G01040 5.4 AraGWAS-Association_score AraGWAS-Phenotype_Associations +As75 AT1G01020 39.9 AraGWAS-Association_score AraGWAS-Phenotype_Associations +AT1G01010 AT1G01020 2.3 AraNetv2_log-likelihood-score AraNetv2-HT_high-throughput-ppi +AT1G01010 AT1G01030 2.4 AraNetv2_log-likelihood-score AraNetv2-HT_high-throughput-ppi +AT1G01010 AT1G01040 2.5 AraNetv2_log-likelihood-score AraNetv2-DC_domain-co-occurrence +AT1G01010 AT1G01040 170.5 AraNetv2_log-likelihood-score AraNetv2-LC_lit-curated-ppi +AT1G01030 AT1G01050 2.6 AraNetv2_log-likelihood-score AraNetv2-CX_pairwise-gene-coexpression +AT1G01050 AT1G01060 2.7 AraNetv2_log-likelihood-score AraNetv2-LC_lit-curated-ppi +AT1G01080 AT1G01090 2.8 AraNetv2_log-likelihood-score AraNetv2-LC_lit-curated-ppi diff --git a/spec/test/helpers.py b/spec/test/helpers.py index 02a013c3..ae4368fe 100644 --- a/spec/test/helpers.py +++ b/spec/test/helpers.py @@ -6,6 +6,7 @@ import time import requests import functools +import contextlib @functools.lru_cache(maxsize=1) @@ -68,6 +69,37 @@ def assert_subset(testCls, subset, _dict): testCls.assertEqual(subset.get(key), _dict.get(key)) +@contextlib.contextmanager +def modified_environ(*remove, **update): + """ + Temporarily updates the ``os.environ`` dictionary in-place. + + The ``os.environ`` dictionary is updated in-place so that the modification + is sure to work in all situations. + + :param remove: Environment variables to remove. + :param update: Dictionary of environment variables and values to add/update. + """ + env = os.environ + update = update or {} + remove = remove or [] + + # List of environment variables being updated or removed. + stomped = (set(update.keys()) | set(remove)) & set(env.keys()) + # Environment variables and values to restore on exit. + update_after = {k: env[k] for k in stomped} + # Environment variables and values to remove on exit. + remove_after = frozenset(k for k in update if k not in env) + + try: + env.update(update) + [env.pop(k, None) for k in remove] + yield + finally: + env.update(update_after) + [env.pop(k) for k in remove_after] + + if __name__ == '__main__': if sys.argv[1] == 'wait_for_api': wait_for_api() diff --git a/spec/test/stored_queries/helpers.py b/spec/test/stored_queries/helpers.py index e873aa47..bf8ecd7f 100644 --- a/spec/test/stored_queries/helpers.py +++ b/spec/test/stored_queries/helpers.py @@ -4,15 +4,22 @@ _CONF = get_config() - -def create_test_docs(coll_name, docs): +def create_test_docs(coll_name, docs, update_on_dupe=False): """Create a set of documents for use in tests.""" body = '\n'.join([json.dumps(d) for d in docs]) + params = {'overwrite': True, 'collection': coll_name, 'display_errors': '1'} + + if update_on_dupe: + del params['overwrite'] + params['on_duplicate'] = 'update' + resp = requests.put( _CONF['re_api_url'] + '/api/v1/documents', - params={'overwrite': True, 'collection': coll_name, 'display_errors': '1'}, + params=params, data=body, headers={'Authorization': 'admin_token'} ) if not resp.ok: raise RuntimeError(resp.text) + + return resp diff --git a/spec/test/stored_queries/test_djornl.py b/spec/test/stored_queries/test_djornl.py new file mode 100644 index 00000000..df2a7e56 --- /dev/null +++ b/spec/test/stored_queries/test_djornl.py @@ -0,0 +1,220 @@ +""" +Tests for the Dan Jacobson ORNL Arabidopsis stored queries. +""" +import json +import time +import unittest +import requests +import os +import glob +import yaml + +from test.helpers import get_config, assert_subset, modified_environ +from test.stored_queries.helpers import create_test_docs +from importers.djornl.parser import DJORNL_Parser + +_CONF = get_config() +_NOW = int(time.time() * 1000) +_TEST_DIR = '/app/test' +_VERBOSE = 0 + + +def print_db_update(response, collection): + if not _VERBOSE: + return + print(f"Saved docs to collection {collection}!") + print(response.text) + print('=' * 80) + + +class Test_DJORNL_Stored_Queries(unittest.TestCase): + + @classmethod + def setUpClass(cls): + + # import the results file + results_file = os.path.join(_TEST_DIR, 'djornl', 'results.json') + with open(results_file) as fh: + cls.json_data = json.load(fh) + + cls.no_results = {'nodes': [], 'edges': []} + + # load the DB + root_path = os.path.join(_TEST_DIR, 'djornl', 'test_data') + with modified_environ(RES_ROOT_DATA_PATH=root_path): + parser = DJORNL_Parser() + config = parser.config() + + edge_data = parser.load_edges() + r = create_test_docs(config['_NODE_NAME'], edge_data['nodes']) + print_db_update(r, config['_NODE_NAME']) + r = create_test_docs(config['_EDGE_NAME'], edge_data['edges']) + print_db_update(r, config['_EDGE_NAME']) + + node_metadata = parser.load_node_metadata() + r = create_test_docs(config['_NODE_NAME'], node_metadata['nodes'], True) + print_db_update(r, config['_NODE_NAME']) + + cluster_data = parser.load_cluster_data() + r = create_test_docs(config['_NODE_NAME'], cluster_data['nodes'], True) + print_db_update(r, config['_NODE_NAME']) + + + def submit_query(self, query_name, query_data={}): + """submit a database query""" + + q_data_str = json.dumps(query_data) + if _VERBOSE: + print('query data string: ' + q_data_str) + response = requests.post( + _CONF['re_api_url'] + '/api/v1/query_results', + params={'stored_query': query_name}, + data=q_data_str + ).json() + + return response + + + def check_expected_results(self, description, response, expected): + + if _VERBOSE: + print("Running test " + description) + results = response['results'][0] + self.assertEqual( + set([n["_key"] for n in results['nodes']]), + set(expected['nodes']) + ) + + self.assertEqual( + set([e["_key"] for e in results['edges']]), + set(expected['edges']) + ) + + + def test_fetch_all(self): + + # expect all the nodes from load_node_metadata and all the edges from load_edges + expected = { + "nodes": [n["_key"] for n in self.json_data['load_node_metadata']['nodes']], + "edges": [ { + "_to": e["_to"], + "_from": e["_from"], + "score": e["score"], + "edge_type": e["edge_type"] } for e in self.json_data['load_edges']['edges'] + ] + } + + self.check_expected_results( + "djornl_fetch_all", + self.submit_query('djornl_fetch_all'), + self.json_data['fetch_all'] + ) + + + # indexing schema in results.json + # self.json_data[query][primary_param][distance_param] + # if primary_param is an array, join the array entities with "__" + # results are in the form {"nodes": [...], "edges": [...]} + # nodes are represented as a list of node[_key] + # edges are objects with keys _to, _from, edge_type and score + + def test_fetch_phenotypes_no_results(self): + + resp = self.submit_query('djornl_fetch_phenotypes', { + # gene node + "keys": ["AT1G01010"], + }) + self.assertEqual(resp['results'][0], self.no_results) + + + def test_fetch_phenotypes(self): + + for fetch_args in self.json_data['fetch_phenotypes'].keys(): + for distance in self.json_data['fetch_phenotypes'][fetch_args].keys(): + resp = self.submit_query('djornl_fetch_phenotypes', { + "keys": fetch_args.split('__'), + "distance": int(distance), + }) + self.check_expected_results( + "fetch phenotypes with args " + fetch_args + " and distance " + distance, + resp, + self.json_data['fetch_phenotypes'][fetch_args][distance] + ) + + + def test_fetch_genes_no_results(self): + resp = self.submit_query('djornl_fetch_genes', { + # phenotype node + "keys": ["As2"], + }) + self.assertEqual(resp['results'][0], self.no_results) + + + def test_fetch_genes(self): + + for fetch_args in self.json_data['fetch_genes'].keys(): + for distance in self.json_data['fetch_genes'][fetch_args].keys(): + resp = self.submit_query('djornl_fetch_genes', { + "keys": fetch_args.split('__'), + "distance": int(distance), + }) + self.check_expected_results( + "fetch genes with args " + fetch_args + " and distance " + distance, + resp, + self.json_data['fetch_genes'][fetch_args][distance] + ) + + + def test_fetch_clusters_no_results(self): + + resp = self.submit_query('djornl_fetch_clusters', { + 'cluster_i2_ids': [666], + 'cluster_i4_ids': [666], + 'cluster_i6_ids': [666], + }) + self.assertEqual(resp['results'][0], self.no_results) + + + def test_fetch_clusters(self): + + for fetch_args in self.json_data['fetch_clusters'].keys(): + cluster_args = {} + for arg in fetch_args.split('__'): + [c_name, c_id] = arg.split('-', maxsplit=1) + if "cluster_" + c_name + "_ids" in cluster_args: + cluster_args["cluster_" + c_name + "_ids"] += int(c_id) + else: + cluster_args["cluster_" + c_name + "_ids"] = [int(c_id)] + + for distance in self.json_data['fetch_clusters'][fetch_args].keys(): + cluster_args['distance'] = int(distance) + resp = self.submit_query('djornl_fetch_clusters', cluster_args) + self.check_expected_results( + "fetch clusters with args " + fetch_args + " and distance " + distance, + resp, + self.json_data['fetch_clusters'][fetch_args][distance] + ) + + @unittest.skip('This test is disabled until automated view loading is possible') + def test_search_nodes_no_results(self): + + resp = self.submit_query('djornl_search_nodes', { + "search_text": "Mary Poppins", + }) + self.assertEqual(resp['results'][0], self.no_results) + + + @unittest.skip('This test is disabled until automated view loading is possible') + def test_search_nodes(self): + + for search_text in self.json_data['search_nodes'].keys(): + for distance in self.json_data['search_nodes'][search_text].keys(): + resp = self.submit_query('djornl_search_nodes', { + "search_text": search_text, + "distance": int(distance), + }) + self.check_expected_results( + "search nodes with args " + search_text + " and distance " + distance, + resp, + self.json_data['search_nodes'][search_text][distance] + ) diff --git a/spec/test/stored_queries/test_djornl_parser.py b/spec/test/stored_queries/test_djornl_parser.py new file mode 100644 index 00000000..b2043b95 --- /dev/null +++ b/spec/test/stored_queries/test_djornl_parser.py @@ -0,0 +1,145 @@ +""" +Tests for the DJORNL Parser + +At the present time, this just ensures that the files are parsed correctly; +it does not check data loading into the db. +""" +import json +import time +import unittest +import requests +import os +import contextlib + +from importers.djornl.parser import DJORNL_Parser + +from test.helpers import get_config, assert_subset, modified_environ +from test.stored_queries.helpers import create_test_docs + +_CONF = get_config() +_NOW = int(time.time() * 1000) +_TEST_DIR = '/app/test' + + +class Test_DJORNL_Parser(unittest.TestCase): + + @classmethod + def setUpClass(cls): + # import the results file + results_file = os.path.join(_TEST_DIR, 'djornl', 'results.json') + with open(results_file) as fh: + cls.json_data = json.load(fh) + + + def init_parser_with_path(self, root_path): + + with modified_environ(RES_ROOT_DATA_PATH=root_path): + parser = DJORNL_Parser() + # ensure that the configuration has been set + parser.config() + return parser + + + def test_load_empty_files(self): + """ test loading files containing no data """ + + # path: test/djornl/empty_files + RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, 'djornl', 'empty_files') + parser = self.init_parser_with_path(RES_ROOT_DATA_PATH) + + self.assertEqual(parser.load_edges(), {"nodes": [], "edges": []}) + self.assertEqual(parser.load_node_metadata(), {"nodes": []}) + self.assertEqual(parser.load_cluster_data(), {"nodes": []}) + + + def test_load_missing_files(self): + """ test loading when files cannot be found """ + + # this dir does not contain the correct file structure + # path: test/djornl/empty_files/cluster_data + RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, 'djornl', 'empty_files', 'cluster_data') + parser = self.init_parser_with_path(RES_ROOT_DATA_PATH) + + err_str = "No such file or directory: '" + RES_ROOT_DATA_PATH + with self.assertRaisesRegex(FileNotFoundError, err_str): + parser.load_edges() + + with self.assertRaisesRegex(FileNotFoundError, err_str): + parser.load_node_metadata() + + with self.assertRaisesRegex(FileNotFoundError, err_str): + parser.load_cluster_data() + + + def test_load_invalid_types(self): + """ test file format errors """ + + # path: test/djornl/invalid_types + RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, 'djornl', 'invalid_types') + parser = self.init_parser_with_path(RES_ROOT_DATA_PATH) + + # invalid edge type + edge_err_msg = 'line 2: invalid edge type: AraGWAS-Some-Old-Rubbish-I-Made-Up' + with self.assertRaisesRegex(RuntimeError, edge_err_msg): + parser.load_edges() + + # invalid node type + node_err_msg = 'line 4: invalid node type: Monkey' + with self.assertRaisesRegex(RuntimeError, node_err_msg): + parser.load_node_metadata() + + + def test_load_col_count_errors(self): + """ test files with invalid numbers of columns """ + + # path: test/djornl/col_count_errors + RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, 'djornl', 'col_count_errors') + parser = self.init_parser_with_path(RES_ROOT_DATA_PATH) + + # invalid edge type + edge_err_msg = 'line 6: expected 5 cols, found 3' + with self.assertRaisesRegex(RuntimeError, edge_err_msg): + parser.load_edges() + + # invalid node type + node_err_msg = 'line 3: expected 20 cols, found 22' + with self.assertRaisesRegex(RuntimeError, node_err_msg): + parser.load_node_metadata() + + + def test_load_valid_edge_data(self): + + RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, 'djornl', 'test_data') + parser = self.init_parser_with_path(RES_ROOT_DATA_PATH) + + self.maxDiff = None + + edge_data = parser.load_edges() + self.assertEqual( + edge_data, + self.json_data["load_edges"] + ) + + def test_load_valid_node_metadata(self): + + self.maxDiff = None + RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, 'djornl', 'test_data') + parser = self.init_parser_with_path(RES_ROOT_DATA_PATH) + + node_metadata = parser.load_node_metadata() + self.assertEqual( + node_metadata, + self.json_data["load_node_metadata"] + ) + + def test_load_valid_cluster_data(self): + + RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, 'djornl', 'test_data') + parser = self.init_parser_with_path(RES_ROOT_DATA_PATH) + + cluster_data = parser.load_cluster_data() + self.assertEqual( + cluster_data, + self.json_data["load_cluster_data"] + ) + diff --git a/spec/test/validate.py b/spec/test/validate.py index 1ef61abd..003bd8a4 100644 --- a/spec/test/validate.py +++ b/spec/test/validate.py @@ -137,6 +137,46 @@ def validate_stored_queries(): print('..all valid.') +# JSON schema for arangosearch views found in /views +view_schema = { + "type": "object", + "required": ["name", "type"], + "properties": { + "name": { + 'title': 'Collection name', + "type": "string", + "format": r'^[a-z_]+$' + }, + 'type': { + 'type': 'string', + 'enum': ['arangosearch'] + } + } +} + + +def validate_views(): + """Validate the structure and syntax of arangosearch views""" + print('Validating views..') + names = set() # type: set + for path in glob.iglob('views/**/*.json', recursive=True): + print(f' validating {path}..') + with open(path) as fd: + data = json.load(fd) + jsonschema.validate(data, view_schema) + name = data['name'] + filename = os.path.splitext(os.path.basename(path))[0] + if name != filename: + _fatal(f'Name key should match filename: {name} vs {filename}') + if name in names: + _fatal(f'Duplicate queries named {name}') + else: + names.add(name) + + print(f'✓ {name} is valid.') + print('..all valid.') + + def _fatal(msg): """Fatal error.""" sys.stderr.write(str(msg) + '\n') @@ -147,3 +187,4 @@ def _fatal(msg): wait_for_arangodb() validate_json_schemas() validate_stored_queries() + validate_views() diff --git a/spec/views/Compounds.json b/spec/views/Compounds.json index 79e8c460..2fc4e82b 100644 --- a/spec/views/Compounds.json +++ b/spec/views/Compounds.json @@ -1,7 +1,8 @@ { + "name": "Compounds", + "type": "arangosearch", "writebufferIdle": 64, "writebufferActive": 0, - "type": "arangosearch", "primarySort": [], "writebufferSizeMax": 33554432, "commitIntervalMsec": 1000, @@ -9,9 +10,7 @@ "type": "bytes_accum", "threshold": 0.1 }, - "globallyUniqueId": "h5455DEB9D2A1/9852581", "cleanupIntervalStep": 10, - "id": "9852581", "links": { "rxn_compound": { "analyzers": [ diff --git a/spec/views/README.md b/spec/views/README.md index 96c7f473..471c7821 100644 --- a/spec/views/README.md +++ b/spec/views/README.md @@ -1,5 +1,3 @@ # Views -These are json files for arango views. Currently you would need to manually create the view then cut and paste the json contents. - - +These are json files for Arango views, which are required to perform searches on vertices or edges in Arango. The data in them is used by the [Relation Engine API](https://github.com/kbase/relation_engine_api) to create views via the `POST /_api/view#arangosearch` endpoint of the ArangoDB HTTP interface. Please [see the ArangoDB docs](https://www.arangodb.com/docs/3.5/http/views-arangosearch.html) for the full set of parameters available. \ No newline at end of file diff --git a/spec/views/Reactions.json b/spec/views/Reactions.json index 15d6b0c9..8bf91caf 100644 --- a/spec/views/Reactions.json +++ b/spec/views/Reactions.json @@ -1,7 +1,8 @@ { + "name": "Reactions", + "type": "arangosearch", "writebufferIdle": 64, "writebufferActive": 0, - "type": "arangosearch", "primarySort": [], "writebufferSizeMax": 33554432, "commitIntervalMsec": 1000, @@ -9,9 +10,7 @@ "type": "bytes_accum", "threshold": 0.1 }, - "globallyUniqueId": "h5455DEB9D2A1/9853332", "cleanupIntervalStep": 10, - "id": "9853332", "links": { "rxn_reaction": { "analyzers": [ diff --git a/spec/views/djornl/djornl_gene_view.json b/spec/views/djornl/djornl_node_view.json similarity index 87% rename from spec/views/djornl/djornl_gene_view.json rename to spec/views/djornl/djornl_node_view.json index 20af19fe..7330fd3a 100644 --- a/spec/views/djornl/djornl_gene_view.json +++ b/spec/views/djornl/djornl_node_view.json @@ -1,19 +1,19 @@ { - "writebufferIdle": 64, - "writebufferActive": 0, + "name": "djornl_node_view", "type": "arangosearch", "primarySort": [], - "writebufferSizeMax": 33554432, + "cleanupIntervalStep": 2, "commitIntervalMsec": 1000, "consolidationPolicy": { "type": "bytes_accum", "threshold": 0.1 }, - "globallyUniqueId": "c98232107/", - "cleanupIntervalStep": 2, - "id": "98232107", + "writebufferIdle": 64, + "writebufferActive": 0, + "consolidationIntervalMsec": 60000, + "writebufferSizeMax": 33554432, "links": { - "djornl_gene": { + "djornl_node": { "analyzers": [ "identity" ], @@ -30,11 +30,6 @@ ] }, "gene_model_type": {}, - "mapman_desc": { - "analyzers": [ - "text_en" - ] - }, "go_terms": {}, "go_desc": { "analyzers": [ @@ -77,6 +72,5 @@ "storeValues": "none", "trackListPositions": false } - }, - "consolidationIntervalMsec": 60000 + } } From 4f6c7c3cf3d92d6e79e9cf42845c1189ab2eae69 Mon Sep 17 00:00:00 2001 From: ialarmedalien Date: Fri, 10 Jul 2020 15:04:48 -0700 Subject: [PATCH 528/732] Adding in automated view loading --- api/Dockerfile | 2 +- .../utils/arango_client.py | 32 +++++++++++++++++++ .../relation_engine_server/utils/config.py | 2 ++ .../relation_engine_server/utils/pull_spec.py | 1 + 4 files changed, 36 insertions(+), 1 deletion(-) diff --git a/api/Dockerfile b/api/Dockerfile index fbe8588e..2ef6eaf2 100644 --- a/api/Dockerfile +++ b/api/Dockerfile @@ -18,7 +18,7 @@ RUN apk --update add --virtual build-dependencies curl tar gzip && \ apk del build-dependencies # Install dependencies -RUN apk --update add --virtual build-dependencies python-dev build-base && \ +RUN apk --update add --virtual build-dependencies build-base python3-dev && \ pip install --upgrade pip && \ pip install --no-cache-dir -r /tmp/requirements.txt && \ if [ "$DEVELOPMENT" ]; then pip install --no-cache-dir -r /tmp/dev-requirements.txt; fi && \ diff --git a/api/src/relation_engine_server/utils/arango_client.py b/api/src/relation_engine_server/utils/arango_client.py index 462e1f55..5a6ee8d0 100644 --- a/api/src/relation_engine_server/utils/arango_client.py +++ b/api/src/relation_engine_server/utils/arango_client.py @@ -78,6 +78,16 @@ def init_collections(): create_collection(coll_name, config) +def init_views(): + """Initialize any uninitialized views in the database from a set of schemas.""" + pattern = os.path.join(_CONF['spec_paths']['views'], '**', '*.json') + for path in glob.iglob(pattern): + view_name = os.path.basename(os.path.splitext(path)[0]) + with open(path) as fd: + config = json.load(fd) + create_view(view_name, config) + + def create_collection(name, config): """ Create a single collection by name using some basic defaults. @@ -167,6 +177,28 @@ def import_from_file(file_path, query): return resp_json +def create_view(name, config): + """ + Create a view by name, ignoring duplicates. + For any other server error, an exception is thrown. + """ + + url = _CONF['api_url'] + '/view#arangosearch' + + if 'name' not in config: + config['name'] = name + if 'type' not in config: + config['type'] = 'arangosearch' + print(f"Creating view {name}") + data = json.dumps(config) + resp = requests.post(url, data, auth=(_CONF['db_user'], _CONF['db_pass'])) + resp_json = resp.json() + if not resp.ok: + if 'duplicate' not in resp_json['errorMessage']: + # Unable to create the view + raise ArangoServerError(resp.text) + + class ArangoServerError(Exception): """A request to the ArangoDB server has failed (non-2xx).""" diff --git a/api/src/relation_engine_server/utils/config.py b/api/src/relation_engine_server/utils/config.py index e329ff7b..4cfe7fb1 100644 --- a/api/src/relation_engine_server/utils/config.py +++ b/api/src/relation_engine_server/utils/config.py @@ -15,6 +15,7 @@ def get_config(): spec_repo_path = os.path.join(spec_path, 'repo') # /spec/repo spec_schemas_path = os.path.join(spec_repo_path, 'schemas') # /spec/repo/schemas stored_queries_path = os.path.join(spec_repo_path, 'stored_queries') # /spec/repo/stored_queries + spec_views_path = os.path.join(spec_repo_path, 'views') # /spec/repo/views spec_url = 'https://api.github.com/repos/kbase/relation_engine_spec' kbase_endpoint = os.environ.get('KBASE_ENDPOINT', 'https://ci.kbase.us/services') auth_url = os.environ.get('KBASE_AUTH_URL', urljoin(kbase_endpoint + '/', 'auth')) @@ -46,6 +47,7 @@ def get_config(): 'repo': spec_repo_path, 'schemas': spec_schemas_path, 'stored_queries': stored_queries_path, + 'views': spec_views_path, 'vertices': os.path.join(spec_schemas_path, 'vertices'), 'data_sources': os.path.join(spec_repo_path, 'data_sources'), } diff --git a/api/src/relation_engine_server/utils/pull_spec.py b/api/src/relation_engine_server/utils/pull_spec.py index b86ef305..17cdcae6 100644 --- a/api/src/relation_engine_server/utils/pull_spec.py +++ b/api/src/relation_engine_server/utils/pull_spec.py @@ -41,6 +41,7 @@ def download_specs(init_collections=True, release_url=None, reset=False): # Initialize all the collections if init_collections: arango_client.init_collections() + arango_client.init_views() def _fetch_github_release_url(): From 0d4425ca4f464faa53499eb884275d1c3811f4c7 Mon Sep 17 00:00:00 2001 From: Zhenyuan Lu Date: Mon, 13 Jul 2020 12:51:20 -0400 Subject: [PATCH 529/732] update GO_get_associated_ws_objects.yaml to add feature_count and add GO_get_associated_ws_features.yaml --- .../GO/GO_get_associated_ws_features.yaml | 49 +++++++++++++++++++ .../GO/GO_get_associated_ws_objects.yaml | 10 ++-- 2 files changed, 52 insertions(+), 7 deletions(-) create mode 100644 spec/stored_queries/GO/GO_get_associated_ws_features.yaml diff --git a/spec/stored_queries/GO/GO_get_associated_ws_features.yaml b/spec/stored_queries/GO/GO_get_associated_ws_features.yaml new file mode 100644 index 00000000..03a7ac84 --- /dev/null +++ b/spec/stored_queries/GO/GO_get_associated_ws_features.yaml @@ -0,0 +1,49 @@ +# Get the associated ws features of this term + +name: GO_get_associated_ws_features +params: + type: object + required: [id, ts] + properties: + id: + type: string + title: Document ID + description: GO id of the term you want to get the ws object of + obj_ref: + type: string + title: Workspace versioned object reference + limit: + type: integer + title: Maximum result limit + default: 20 + maximum: 1000 + offset: + type: integer + title: Result offset for pagination + default: 0 + maximum: 100000 + ts: + type: integer + title: Versioning timestamp +query_prefix: WITH ws_genome_features, ws_object_version +query: | + LET flag=IS_NULL(@obj_ref) OR LENGTH(@obj_ref) == 0 ? 1 : 0 + LET raw=( + FOR t in GO_terms + FILTER t.id == @id + FILTER t.created <= @ts AND t.expired >= @ts + limit 1 + FOR v, e, p IN 2 INBOUND t ws_feature_has_GO_annotation, ws_genome_has_feature + FILTER p.edges[0].created <= @ts AND p.edges[0].expired >= @ts + FILTER v.is_public OR v.workspace_id IN ws_ids + FILTER v._key == @obj_ref OR 1 == flag + SORT v.workspace_id ASC, p.vertices[1].feature_id ASC + LIMIT @offset, @limit + RETURN DISTINCT { + ws_obj: KEEP(v, ['workspace_id', 'object_id', 'version', 'name']), + feature: KEEP(p.vertices[1], ['feature_id', 'updated_at']) + } + ) + FOR r IN raw + COLLECT ws_obj=r.ws_obj INTO features=r.feature + RETURN {ws_obj, features} diff --git a/spec/stored_queries/GO/GO_get_associated_ws_objects.yaml b/spec/stored_queries/GO/GO_get_associated_ws_objects.yaml index 3e404ddf..712f0bdf 100644 --- a/spec/stored_queries/GO/GO_get_associated_ws_objects.yaml +++ b/spec/stored_queries/GO/GO_get_associated_ws_objects.yaml @@ -38,11 +38,7 @@ query: | feature: KEEP(p.vertices[1], ['feature_id', 'updated_at']) } ) - LET total_count = COUNT(raw) - LET results = ( - FOR r IN raw - COLLECT ws_obj=r.ws_obj INTO features=r.feature + FOR r IN raw + COLLECT ws_obj=r.ws_obj WITH COUNT INTO feature_count LIMIT @offset, @limit - RETURN {ws_obj, features} - ) - RETURN {results, total_count} + RETURN {ws_obj, feature_count} From 0062321c039619d6d104dca0572682d842153569 Mon Sep 17 00:00:00 2001 From: ialarmedalien Date: Mon, 13 Jul 2020 12:04:08 -0700 Subject: [PATCH 530/732] Small text edit and small stylistic change --- spec/importers/djornl/parser.py | 3 ++- spec/test/validate.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/spec/importers/djornl/parser.py b/spec/importers/djornl/parser.py index 6f32b272..9eb5c87b 100644 --- a/spec/importers/djornl/parser.py +++ b/spec/importers/djornl/parser.py @@ -72,6 +72,7 @@ def load_edges(self): 'AraNetv2-LC_lit-curated-ppi': 'ppi_liter', } + # dict of nodes, indexed by node ID (node1 and node2 from the file) node_ix = {} edges = [] node_name = self.config()['_NODE_NAME'] @@ -92,7 +93,7 @@ def load_edges(self): node_ix[cols[0]] = 1 node_ix[cols[1]] = 1 edge_type = cols[4] - if not edge_type in edge_remap: + if edge_type not in edge_remap: raise RuntimeError(f"line {line_no}: invalid edge type: {edge_type}") edges.append({ diff --git a/spec/test/validate.py b/spec/test/validate.py index 003bd8a4..e4c11d98 100644 --- a/spec/test/validate.py +++ b/spec/test/validate.py @@ -143,7 +143,7 @@ def validate_stored_queries(): "required": ["name", "type"], "properties": { "name": { - 'title': 'Collection name', + 'title': 'View name', "type": "string", "format": r'^[a-z_]+$' }, From 04571f21deec34bdea56d82a819bdf48483c424c Mon Sep 17 00:00:00 2001 From: ialarmedalien Date: Mon, 13 Jul 2020 13:39:17 -0700 Subject: [PATCH 531/732] Moving collection and view init into pull_spec.py and updating a line of documentation --- api/README.md | 2 +- .../utils/arango_client.py | 22 --------------- .../relation_engine_server/utils/pull_spec.py | 28 +++++++++++++++++-- 3 files changed, 27 insertions(+), 25 deletions(-) diff --git a/api/README.md b/api/README.md index f5807833..1e280ce8 100644 --- a/api/README.md +++ b/api/README.md @@ -259,7 +259,7 @@ curl {root_url}/api/v1/update_specs ``` _Query params_ -* `init_collections` - optional - boolean - defaults to true - whether to initialize any new collections in arango (also creates indexes) +* `init_collections` - optional - boolean - defaults to true - whether to initialize any new collections in arango (also creates indexes and views) * `spec_url` - optional - string - the specific url of the release to download and use (as a tarball). If left blank, then the latest release from github is used (not including any pre-releases or drafts). Every call to update specs will reset the spec data (do a clean download and overwrite). diff --git a/api/src/relation_engine_server/utils/arango_client.py b/api/src/relation_engine_server/utils/arango_client.py index 5a6ee8d0..868128fa 100644 --- a/api/src/relation_engine_server/utils/arango_client.py +++ b/api/src/relation_engine_server/utils/arango_client.py @@ -5,8 +5,6 @@ import os import requests import json -import glob -import yaml from .config import get_config @@ -68,26 +66,6 @@ def run_query(query_text=None, cursor_id=None, bind_vars=None, batch_size=10000, } -def init_collections(): - """Initialize any uninitialized collections in the database from a set of schemas.""" - pattern = os.path.join(_CONF['spec_paths']['schemas'], '**', '*.yaml') - for path in glob.iglob(pattern): - coll_name = os.path.basename(os.path.splitext(path)[0]) - with open(path) as fd: - config = yaml.safe_load(fd) - create_collection(coll_name, config) - - -def init_views(): - """Initialize any uninitialized views in the database from a set of schemas.""" - pattern = os.path.join(_CONF['spec_paths']['views'], '**', '*.json') - for path in glob.iglob(pattern): - view_name = os.path.basename(os.path.splitext(path)[0]) - with open(path) as fd: - config = json.load(fd) - create_view(view_name, config) - - def create_collection(name, config): """ Create a single collection by name using some basic defaults. diff --git a/api/src/relation_engine_server/utils/pull_spec.py b/api/src/relation_engine_server/utils/pull_spec.py index 17cdcae6..9358d018 100644 --- a/api/src/relation_engine_server/utils/pull_spec.py +++ b/api/src/relation_engine_server/utils/pull_spec.py @@ -4,6 +4,10 @@ import tarfile import tempfile import shutil +import json +import glob +import yaml + from . import arango_client from .config import get_config @@ -40,8 +44,28 @@ def download_specs(init_collections=True, release_url=None, reset=False): _rename_directories(_CONF['spec_paths']['root'], _CONF['spec_paths']['repo']) # Initialize all the collections if init_collections: - arango_client.init_collections() - arango_client.init_views() + do_init_collections() + do_init_views() + + +def do_init_collections(): + """Initialize any uninitialized collections in the database from a set of schemas.""" + pattern = os.path.join(_CONF['spec_paths']['schemas'], '**', '*.yaml') + for path in glob.iglob(pattern): + coll_name = os.path.basename(os.path.splitext(path)[0]) + with open(path) as fd: + config = yaml.safe_load(fd) + arango_client.create_collection(coll_name, config) + + +def do_init_views(): + """Initialize any uninitialized views in the database from a set of schemas.""" + pattern = os.path.join(_CONF['spec_paths']['views'], '**', '*.json') + for path in glob.iglob(pattern): + view_name = os.path.basename(os.path.splitext(path)[0]) + with open(path) as fd: + config = json.load(fd) + arango_client.create_view(view_name, config) def _fetch_github_release_url(): From e7764c33113b03270158ad65bd506c835c4d38cc Mon Sep 17 00:00:00 2001 From: Zhenyuan Lu Date: Mon, 13 Jul 2020 19:01:18 -0400 Subject: [PATCH 532/732] update GO_get_associated_ws_objects.yaml to add feature_count and add GO_get_associated_ws_features.yaml --- spec/stored_queries/GO/GO_get_associated_ws_features.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/stored_queries/GO/GO_get_associated_ws_features.yaml b/spec/stored_queries/GO/GO_get_associated_ws_features.yaml index 03a7ac84..efa5bc75 100644 --- a/spec/stored_queries/GO/GO_get_associated_ws_features.yaml +++ b/spec/stored_queries/GO/GO_get_associated_ws_features.yaml @@ -27,7 +27,7 @@ params: title: Versioning timestamp query_prefix: WITH ws_genome_features, ws_object_version query: | - LET flag=IS_NULL(@obj_ref) OR LENGTH(@obj_ref) == 0 ? 1 : 0 + LET obj_ref_null=IS_NULL(@obj_ref) OR LENGTH(@obj_ref) == 0 LET raw=( FOR t in GO_terms FILTER t.id == @id @@ -36,7 +36,7 @@ query: | FOR v, e, p IN 2 INBOUND t ws_feature_has_GO_annotation, ws_genome_has_feature FILTER p.edges[0].created <= @ts AND p.edges[0].expired >= @ts FILTER v.is_public OR v.workspace_id IN ws_ids - FILTER v._key == @obj_ref OR 1 == flag + FILTER obj_ref_null OR v._key == @obj_ref SORT v.workspace_id ASC, p.vertices[1].feature_id ASC LIMIT @offset, @limit RETURN DISTINCT { From 2c4fe9a72aa0d0c6a6a09c2ddecb10c49e072ba9 Mon Sep 17 00:00:00 2001 From: Zhenyuan Lu Date: Tue, 14 Jul 2020 11:44:28 -0400 Subject: [PATCH 533/732] update GO_get_associated_ws_objects.yaml to add feature_count and add GO_get_associated_ws_features.yaml --- .../GO/GO_get_associated_ws_objects.yaml | 30 ++++++++----------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/spec/stored_queries/GO/GO_get_associated_ws_objects.yaml b/spec/stored_queries/GO/GO_get_associated_ws_objects.yaml index 712f0bdf..7ebe0e7c 100644 --- a/spec/stored_queries/GO/GO_get_associated_ws_objects.yaml +++ b/spec/stored_queries/GO/GO_get_associated_ws_objects.yaml @@ -24,21 +24,17 @@ params: title: Versioning timestamp query_prefix: WITH ws_genome_features, ws_object_version query: | - LET raw=( - FOR t in GO_terms - FILTER t.id == @id - FILTER t.created <= @ts AND t.expired >= @ts - limit 1 - FOR v, e, p IN 2 INBOUND t ws_feature_has_GO_annotation, ws_genome_has_feature - FILTER p.edges[0].created <= @ts AND p.edges[0].expired >= @ts - FILTER v.is_public OR v.workspace_id IN ws_ids - SORT v.workspace_id ASC, p.vertices[1].feature_id ASC - RETURN DISTINCT { - ws_obj: KEEP(v, ['workspace_id', 'object_id', 'version', 'name']), - feature: KEEP(p.vertices[1], ['feature_id', 'updated_at']) - } - ) - FOR r IN raw - COLLECT ws_obj=r.ws_obj WITH COUNT INTO feature_count + FOR t in GO_terms + FILTER t.id == @id + FILTER t.created <= @ts AND t.expired >= @ts + LIMIT 1 + FOR v, e, p IN 2 INBOUND t ws_feature_has_GO_annotation, ws_genome_has_feature + FILTER p.edges[0].created <= @ts AND p.edges[0].expired >= @ts + FILTER v.is_public OR v.workspace_id IN ws_ids + SORT v.workspace_id ASC, p.vertices[1].feature_id ASC + COLLECT ws_obj = v WITH COUNT INTO feature_count LIMIT @offset, @limit - RETURN {ws_obj, feature_count} + RETURN DISTINCT { + ws_obj: KEEP(ws_obj, ['workspace_id', 'object_id', 'version', 'name']), + feature_count + } From 1cc3fff3cf8ba8fe16e6972318519c093a90de22 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 15 Jul 2020 10:03:35 -0700 Subject: [PATCH 534/732] Fix key in rdp taxonomy data source --- spec/data_sources/rdp_taxonomy.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/data_sources/rdp_taxonomy.yaml b/spec/data_sources/rdp_taxonomy.yaml index ffef460c..570da538 100644 --- a/spec/data_sources/rdp_taxonomy.yaml +++ b/spec/data_sources/rdp_taxonomy.yaml @@ -3,4 +3,4 @@ category: taxonomy title: Ribosomal Database Project home_url: http://rdp.cme.msu.edu/taxomatic/main.spr data_url: http://rdp.cme.msu.edu/misc/resources.jsp -logo_url: /images/third-party-data-sources/ncbi/logo-51-64.png +logo_path: /images/third-party-data-sources/ncbi/logo-51-64.png From bd1d3a03f22af81f55ce881bb0a99b50f932285e Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 15 Jul 2020 13:03:18 -0700 Subject: [PATCH 535/732] Add fulltext index for rdp_taxonomy/name field --- spec/schemas/rdp/rdp_taxon.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spec/schemas/rdp/rdp_taxon.yaml b/spec/schemas/rdp/rdp_taxon.yaml index 42234447..71b13d38 100644 --- a/spec/schemas/rdp/rdp_taxon.yaml +++ b/spec/schemas/rdp/rdp_taxon.yaml @@ -3,6 +3,8 @@ type: vertex delta: true indexes: + - type: fulltext + fields: [name] - type: persistent fields: [id, expired, created] - type: persistent From 225bd51e0e35c07f90b6915483fcfa2443de203d Mon Sep 17 00:00:00 2001 From: Zhenyuan Lu Date: Tue, 21 Jul 2020 10:43:07 -0400 Subject: [PATCH 536/732] add total_count --- .../GO/GO_get_associated_ws_features.yaml | 14 +++++--- .../GO/GO_get_associated_ws_objects.yaml | 34 ++++++++++++------- 2 files changed, 30 insertions(+), 18 deletions(-) diff --git a/spec/stored_queries/GO/GO_get_associated_ws_features.yaml b/spec/stored_queries/GO/GO_get_associated_ws_features.yaml index efa5bc75..34f93aea 100644 --- a/spec/stored_queries/GO/GO_get_associated_ws_features.yaml +++ b/spec/stored_queries/GO/GO_get_associated_ws_features.yaml @@ -28,7 +28,7 @@ params: query_prefix: WITH ws_genome_features, ws_object_version query: | LET obj_ref_null=IS_NULL(@obj_ref) OR LENGTH(@obj_ref) == 0 - LET raw=( + LET results=( FOR t in GO_terms FILTER t.id == @id FILTER t.created <= @ts AND t.expired >= @ts @@ -38,12 +38,16 @@ query: | FILTER v.is_public OR v.workspace_id IN ws_ids FILTER obj_ref_null OR v._key == @obj_ref SORT v.workspace_id ASC, p.vertices[1].feature_id ASC - LIMIT @offset, @limit RETURN DISTINCT { ws_obj: KEEP(v, ['workspace_id', 'object_id', 'version', 'name']), feature: KEEP(p.vertices[1], ['feature_id', 'updated_at']) } ) - FOR r IN raw - COLLECT ws_obj=r.ws_obj INTO features=r.feature - RETURN {ws_obj, features} + LET total_count=COUNT(results) + LET limited=( + FOR r in results + LIMIT @offset, @limit + COLLECT ws_obj=r.ws_obj INTO features=r.feature + RETURN {ws_obj, features} + ) + RETURN {results: limited, total_count} diff --git a/spec/stored_queries/GO/GO_get_associated_ws_objects.yaml b/spec/stored_queries/GO/GO_get_associated_ws_objects.yaml index 7ebe0e7c..01e58914 100644 --- a/spec/stored_queries/GO/GO_get_associated_ws_objects.yaml +++ b/spec/stored_queries/GO/GO_get_associated_ws_objects.yaml @@ -24,17 +24,25 @@ params: title: Versioning timestamp query_prefix: WITH ws_genome_features, ws_object_version query: | - FOR t in GO_terms - FILTER t.id == @id - FILTER t.created <= @ts AND t.expired >= @ts - LIMIT 1 - FOR v, e, p IN 2 INBOUND t ws_feature_has_GO_annotation, ws_genome_has_feature - FILTER p.edges[0].created <= @ts AND p.edges[0].expired >= @ts - FILTER v.is_public OR v.workspace_id IN ws_ids - SORT v.workspace_id ASC, p.vertices[1].feature_id ASC - COLLECT ws_obj = v WITH COUNT INTO feature_count + LET results=( + FOR t in GO_terms + FILTER t.id == @id + FILTER t.created <= @ts AND t.expired >= @ts + LIMIT 1 + FOR v, e, p IN 2 INBOUND t ws_feature_has_GO_annotation, ws_genome_has_feature + FILTER p.edges[0].created <= @ts AND p.edges[0].expired >= @ts + FILTER v.is_public OR v.workspace_id IN ws_ids + SORT v.workspace_id ASC, p.vertices[1].feature_id ASC + COLLECT ws_obj = v WITH COUNT INTO feature_count + RETURN DISTINCT { + ws_obj: KEEP(ws_obj, ['workspace_id', 'object_id', 'version', 'name']), + feature_count + } + ) + LET total_count=COUNT(results) + LET limited=( + FOR r in results LIMIT @offset, @limit - RETURN DISTINCT { - ws_obj: KEEP(ws_obj, ['workspace_id', 'object_id', 'version', 'name']), - feature_count - } + RETURN r + ) + RETURN {results: limited, total_count} From ce42c2077fef3655b9f7779da2a21c1a67db85c6 Mon Sep 17 00:00:00 2001 From: ialarmedalien Date: Mon, 27 Jul 2020 13:20:39 -0700 Subject: [PATCH 537/732] moving files and adding top level readme --- .gitattributes | 7 +++++++ .travis.yml | 8 ++++++++ spec/LICENSE.md => LICENSE.md | 0 README.md | 14 ++++++++++++++ api/LICENSE.md | 2 +- 5 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 .gitattributes create mode 100644 .travis.yml rename spec/LICENSE.md => LICENSE.md (100%) create mode 100644 README.md diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..2b3b13a8 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,7 @@ +/CODEOWNERS export-ignore +/.gitattributes export-ignore +/.gitignore export-ignore +/.travis.yml export-ignore +README.md export-ignore +/Makefile export-ignore +/test export-ignore diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..4cf93926 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,8 @@ +sudo: required +services: +- docker +script: +- cd api +- make test +- cd ../spec +- make test \ No newline at end of file diff --git a/spec/LICENSE.md b/LICENSE.md similarity index 100% rename from spec/LICENSE.md rename to LICENSE.md diff --git a/README.md b/README.md new file mode 100644 index 00000000..61030f21 --- /dev/null +++ b/README.md @@ -0,0 +1,14 @@ +# KBase Relation Engine + +This repo holds the code associated with the KBase relation engine, previously held in https://github.com/kbase/relation_engine_api and https://github.com/kbase/relation_engine_spec. + +## Relation Engine Spec + +This repo holds the [stored queries](spec/stored_queries), [schemas](spec/schemas), and [migrations](spec/migrations) for the relation engine graph database service. + +These specifications are used by the [Relation Engine API](https://github.com/kbase/relation_engine_api). + +## Relation Engine API + +A simple API that allows KBase community developers to interact with the Relation Engine graph database. You can run stored queries or do bulk updates on documents. + diff --git a/api/LICENSE.md b/api/LICENSE.md index a1fa12dc..916a8c78 100644 --- a/api/LICENSE.md +++ b/api/LICENSE.md @@ -1,4 +1,4 @@ -Copyright (c) 2018 The KBase Project and its Contributors +Copyright (c) 2020 The KBase Project and its Contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: From 7ec458fc9a30a5950bf1f0ce7e2acb68bf26c811 Mon Sep 17 00:00:00 2001 From: ialarmedalien Date: Mon, 27 Jul 2020 13:33:23 -0700 Subject: [PATCH 538/732] Finishing distribution of misc files to top level dirs --- {api/.github => .github}/CONTRIBUTING.md | 0 .../pull_request_template.md | 0 api/.gitignore => .gitignore | 0 .gitignore/.gitignore | 129 ------------------ CODEOWNERS | 3 + api/CODEOWNERS | 1 - api/LICENSE.md | 7 - spec/.gitattributes | 7 - spec/.gitignore | 14 -- spec/CODEOWNERS | 1 - 10 files changed, 3 insertions(+), 159 deletions(-) rename {api/.github => .github}/CONTRIBUTING.md (100%) rename {api/.github => .github}/pull_request_template.md (100%) rename api/.gitignore => .gitignore (100%) delete mode 100644 .gitignore/.gitignore create mode 100644 CODEOWNERS delete mode 100644 api/CODEOWNERS delete mode 100644 api/LICENSE.md delete mode 100644 spec/.gitattributes delete mode 100644 spec/.gitignore delete mode 100644 spec/CODEOWNERS diff --git a/api/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md similarity index 100% rename from api/.github/CONTRIBUTING.md rename to .github/CONTRIBUTING.md diff --git a/api/.github/pull_request_template.md b/.github/pull_request_template.md similarity index 100% rename from api/.github/pull_request_template.md rename to .github/pull_request_template.md diff --git a/api/.gitignore b/.gitignore similarity index 100% rename from api/.gitignore rename to .gitignore diff --git a/.gitignore/.gitignore b/.gitignore/.gitignore deleted file mode 100644 index b6e47617..00000000 --- a/.gitignore/.gitignore +++ /dev/null @@ -1,129 +0,0 @@ -# Byte-compiled / optimized / DLL files -__pycache__/ -*.py[cod] -*$py.class - -# C extensions -*.so - -# Distribution / packaging -.Python -build/ -develop-eggs/ -dist/ -downloads/ -eggs/ -.eggs/ -lib/ -lib64/ -parts/ -sdist/ -var/ -wheels/ -pip-wheel-metadata/ -share/python-wheels/ -*.egg-info/ -.installed.cfg -*.egg -MANIFEST - -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest -*.spec - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt - -# Unit test / coverage reports -htmlcov/ -.tox/ -.nox/ -.coverage -.coverage.* -.cache -nosetests.xml -coverage.xml -*.cover -*.py,cover -.hypothesis/ -.pytest_cache/ - -# Translations -*.mo -*.pot - -# Django stuff: -*.log -local_settings.py -db.sqlite3 -db.sqlite3-journal - -# Flask stuff: -instance/ -.webassets-cache - -# Scrapy stuff: -.scrapy - -# Sphinx documentation -docs/_build/ - -# PyBuilder -target/ - -# Jupyter Notebook -.ipynb_checkpoints - -# IPython -profile_default/ -ipython_config.py - -# pyenv -.python-version - -# pipenv -# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. -# However, in case of collaboration, if having platform-specific dependencies or dependencies -# having no cross-platform support, pipenv may install dependencies that don't work, or not -# install all needed dependencies. -#Pipfile.lock - -# PEP 582; used by e.g. github.com/David-OConnor/pyflow -__pypackages__/ - -# Celery stuff -celerybeat-schedule -celerybeat.pid - -# SageMath parsed files -*.sage.py - -# Environments -.env -.venv -env/ -venv/ -ENV/ -env.bak/ -venv.bak/ - -# Spyder project settings -.spyderproject -.spyproject - -# Rope project settings -.ropeproject - -# mkdocs documentation -/site - -# mypy -.mypy_cache/ -.dmypy.json -dmypy.json - -# Pyre type checker -.pyre/ diff --git a/CODEOWNERS b/CODEOWNERS new file mode 100644 index 00000000..38691172 --- /dev/null +++ b/CODEOWNERS @@ -0,0 +1,3 @@ +* @jayrbolton + +api/* @jayrbolton @slebras diff --git a/api/CODEOWNERS b/api/CODEOWNERS deleted file mode 100644 index d65e940f..00000000 --- a/api/CODEOWNERS +++ /dev/null @@ -1 +0,0 @@ -* @jayrbolton @slebras diff --git a/api/LICENSE.md b/api/LICENSE.md deleted file mode 100644 index 916a8c78..00000000 --- a/api/LICENSE.md +++ /dev/null @@ -1,7 +0,0 @@ -Copyright (c) 2020 The KBase Project and its Contributors - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/spec/.gitattributes b/spec/.gitattributes deleted file mode 100644 index eb4fa0e8..00000000 --- a/spec/.gitattributes +++ /dev/null @@ -1,7 +0,0 @@ -/CODEOWNERS export-ignore -/.gitattributes export-ignore -/.gitignore export-ignore -/.travis.yaml export-ignore -README.md export-ignore -/Makefile export-ignore -/test export-ignore diff --git a/spec/.gitignore b/spec/.gitignore deleted file mode 100644 index 17a31216..00000000 --- a/spec/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -# Environment variables -.env - -# Caches and temp dirs -build -dist -*.pyc -.mypy_cache -.cache -tmp/* -coverage_report/ -.coverage -*.egg-info/ - diff --git a/spec/CODEOWNERS b/spec/CODEOWNERS deleted file mode 100644 index 788e5f5d..00000000 --- a/spec/CODEOWNERS +++ /dev/null @@ -1 +0,0 @@ -* @jayrbolton From 4a7dad1a4ba9fde250ae4ff61a5dcdf3ef793c12 Mon Sep 17 00:00:00 2001 From: ialarmedalien Date: Tue, 28 Jul 2020 10:50:53 -0700 Subject: [PATCH 539/732] Reorg part 1: api tests all functional --- api/Dockerfile => Dockerfile-api | 4 +- spec/Dockerfile => Dockerfile-spec | 3 +- Makefile | 26 ++++ api/.dockerignore | 2 + api/Makefile | 10 -- {spec => api}/importers/README.md | 0 {spec => api}/importers/djornl/main.py | 0 {spec => api}/importers/djornl/parser.py | 0 api/importers/test/helpers.py | 129 ++++++++++++++++++ .../importers/test}/test_djornl_parser.py | 5 +- {spec => api}/importers/tox.ini | 0 {spec => api}/importers/utils/config.py | 0 ...v-requirements.txt => dev-requirements.txt | 0 ...r-compose.yaml => docker-compose-spec.yaml | 8 +- ...docker-compose.yaml => docker-compose.yaml | 10 +- {api/hooks => hooks}/build | 0 api/requirements.txt => requirements.txt | 2 +- {api/scripts => scripts}/local-build.sh | 0 {api/scripts => scripts}/run_tests.sh | 3 +- {api/scripts => scripts}/start_server.sh | 0 spec/test/helpers.py | 24 ++++ spec/test/stored_queries/test_djornl.py | 3 +- spec/test/stored_queries/test_ncbi_tax.py | 3 +- spec/test/stored_queries/test_taxonomy.py | 3 +- spec/test/stored_queries/test_ws.py | 4 +- 25 files changed, 205 insertions(+), 34 deletions(-) rename api/Dockerfile => Dockerfile-api (95%) rename spec/Dockerfile => Dockerfile-spec (65%) create mode 100644 Makefile delete mode 100644 api/Makefile rename {spec => api}/importers/README.md (100%) rename {spec => api}/importers/djornl/main.py (100%) rename {spec => api}/importers/djornl/parser.py (100%) create mode 100644 api/importers/test/helpers.py rename {spec/test/stored_queries => api/importers/test}/test_djornl_parser.py (96%) rename {spec => api}/importers/tox.ini (100%) rename {spec => api}/importers/utils/config.py (100%) rename api/dev-requirements.txt => dev-requirements.txt (100%) rename spec/docker-compose.yaml => docker-compose-spec.yaml (93%) rename api/docker-compose.yaml => docker-compose.yaml (84%) rename {api/hooks => hooks}/build (100%) rename api/requirements.txt => requirements.txt (86%) rename {api/scripts => scripts}/local-build.sh (100%) rename {api/scripts => scripts}/run_tests.sh (79%) rename {api/scripts => scripts}/start_server.sh (100%) diff --git a/api/Dockerfile b/Dockerfile-api similarity index 95% rename from api/Dockerfile rename to Dockerfile-api index 2ef6eaf2..a95b6e8b 100644 --- a/api/Dockerfile +++ b/Dockerfile-api @@ -24,7 +24,9 @@ RUN apk --update add --virtual build-dependencies build-base python3-dev && \ if [ "$DEVELOPMENT" ]; then pip install --no-cache-dir -r /tmp/dev-requirements.txt; fi && \ apk del build-dependencies -COPY . /app +COPY api/ /app +COPY scripts /app/scripts +COPY spec/test test LABEL org.label-schema.build-date=$BUILD_DATE \ org.label-schema.vcs-url="https://github.com/kbase/relation_engine_api" \ diff --git a/spec/Dockerfile b/Dockerfile-spec similarity index 65% rename from spec/Dockerfile rename to Dockerfile-spec index cdefd899..3a405702 100644 --- a/spec/Dockerfile +++ b/Dockerfile-spec @@ -2,4 +2,5 @@ from python:3.7-slim RUN pip install --upgrade pip requests jsonschema pyyaml WORKDIR /app -COPY . /app +COPY spec/ /app +COPY api/importers /app/importers \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..bc661db4 --- /dev/null +++ b/Makefile @@ -0,0 +1,26 @@ +.PHONY: test reset + +test: + docker-compose down + docker-compose build + docker-compose run web sh scripts/run_tests.sh + docker-compose down + +api-shell: + docker-compose down + docker-compose build + docker-compose run web sh + +reset: + docker-compose --rmi all -v + docker-compose build + +spec-test: + docker-compose build + docker-compose -f docker-compose-spec.yaml run spec sh /app/test/run_tests.sh + docker-compose down + +spec-shell: + docker-compose down + docker-compose -f docker-compose-spec.yaml build + docker-compose -f docker-compose-spec.yaml run spec bash diff --git a/api/.dockerignore b/api/.dockerignore index 1648d981..cc8bc85d 100644 --- a/api/.dockerignore +++ b/api/.dockerignore @@ -1,3 +1,5 @@ +.dockerignore +.travis.yml __pycache__ *.pyc *.pyo diff --git a/api/Makefile b/api/Makefile deleted file mode 100644 index 236f5400..00000000 --- a/api/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -.PHONY: test reset - -test: - docker-compose down - docker-compose run web sh scripts/run_tests.sh - docker-compose down - -reset: - docker-compose --rmi all -v - docker-compose build diff --git a/spec/importers/README.md b/api/importers/README.md similarity index 100% rename from spec/importers/README.md rename to api/importers/README.md diff --git a/spec/importers/djornl/main.py b/api/importers/djornl/main.py similarity index 100% rename from spec/importers/djornl/main.py rename to api/importers/djornl/main.py diff --git a/spec/importers/djornl/parser.py b/api/importers/djornl/parser.py similarity index 100% rename from spec/importers/djornl/parser.py rename to api/importers/djornl/parser.py diff --git a/api/importers/test/helpers.py b/api/importers/test/helpers.py new file mode 100644 index 00000000..83f14737 --- /dev/null +++ b/api/importers/test/helpers.py @@ -0,0 +1,129 @@ +""" +Test helpers +""" +import sys +import os +import time +import requests +import functools +import contextlib +import json + + +@functools.lru_cache(maxsize=1) +def get_config(): + """Return configuration data for tests.""" + return { + 're_api_url': os.environ['RE_API_URL'], + 'db_url': os.environ['DB_URL'], + 'db_auth': (os.environ['DB_USER'], os.environ.get('DB_PASS', '')) + } + + +def wait_for_arangodb(): + """Wait for arangodb to go live.""" + conf = get_config() + db_url = conf['db_url'] + auth = ('root', '') + timeout = time.time() + 60 + while True: + try: + resp = requests.get(db_url + '/_admin/cluster/health', auth=auth) + resp.raise_for_status() + break + except Exception as err: + print('Waiting for arangodb to come online') + if time.time() > timeout: + sys.stderr.write(str(err) + '\n') + raise RuntimeError('Timed out waiting for arangodb') + time.sleep(3) + + +def wait_for_api(): + wait_for_arangodb() + # Wait for other dependent services to come online + conf = get_config() + timeout = int(time.time()) + 60 + auth_url = 'http://auth:5000' + ws_url = 'http://workspace:5000' + while True: + try: + # Reassign the `url` variable so we can print which service errored + url = conf['re_api_url'] + requests.get(url).raise_for_status() + url = auth_url + requests.get(url) + url = ws_url + requests.get(url) + break + except Exception as err: + print(f"Waiting for dependent service to come online: {url}") + if int(time.time()) > timeout: + sys.stderr.write(str(err) + "\n") + raise RuntimeError(f"Timed out waiting for {url}") + time.sleep(2) + + +def assert_subset(testCls, subset, _dict): + """Replacement for the deprecated `assertDictContainsSubset` method.""" + for (key, val) in subset.items(): + testCls.assertEqual(subset.get(key), _dict.get(key)) + + +def create_test_docs(coll_name, docs, update_on_dupe=False): + """Create a set of documents for use in tests.""" + body = '\n'.join([json.dumps(d) for d in docs]) + params = {'overwrite': True, 'collection': coll_name, 'display_errors': '1'} + + if update_on_dupe: + del params['overwrite'] + params['on_duplicate'] = 'update' + + conf = get_config() + + resp = requests.put( + conf['re_api_url'] + '/api/v1/documents', + params=params, + data=body, + headers={'Authorization': 'admin_token'} + ) + if not resp.ok: + raise RuntimeError(resp.text) + + return resp + + +@contextlib.contextmanager +def modified_environ(*remove, **update): + """ + Temporarily updates the ``os.environ`` dictionary in-place. + + The ``os.environ`` dictionary is updated in-place so that the modification + is sure to work in all situations. + + :param remove: Environment variables to remove. + :param update: Dictionary of environment variables and values to add/update. + """ + env = os.environ + update = update or {} + remove = remove or [] + + # List of environment variables being updated or removed. + stomped = (set(update.keys()) | set(remove)) & set(env.keys()) + # Environment variables and values to restore on exit. + update_after = {k: env[k] for k in stomped} + # Environment variables and values to remove on exit. + remove_after = frozenset(k for k in update if k not in env) + + try: + env.update(update) + [env.pop(k, None) for k in remove] + yield + finally: + env.update(update_after) + [env.pop(k) for k in remove_after] + + +if __name__ == '__main__': + if sys.argv[1] == 'wait_for_api': + wait_for_api() diff --git a/spec/test/stored_queries/test_djornl_parser.py b/api/importers/test/test_djornl_parser.py similarity index 96% rename from spec/test/stored_queries/test_djornl_parser.py rename to api/importers/test/test_djornl_parser.py index b2043b95..28e5fc7c 100644 --- a/spec/test/stored_queries/test_djornl_parser.py +++ b/api/importers/test/test_djornl_parser.py @@ -13,11 +13,8 @@ from importers.djornl.parser import DJORNL_Parser -from test.helpers import get_config, assert_subset, modified_environ -from test.stored_queries.helpers import create_test_docs +from test.helpers import modified_environ, create_test_docs -_CONF = get_config() -_NOW = int(time.time() * 1000) _TEST_DIR = '/app/test' diff --git a/spec/importers/tox.ini b/api/importers/tox.ini similarity index 100% rename from spec/importers/tox.ini rename to api/importers/tox.ini diff --git a/spec/importers/utils/config.py b/api/importers/utils/config.py similarity index 100% rename from spec/importers/utils/config.py rename to api/importers/utils/config.py diff --git a/api/dev-requirements.txt b/dev-requirements.txt similarity index 100% rename from api/dev-requirements.txt rename to dev-requirements.txt diff --git a/spec/docker-compose.yaml b/docker-compose-spec.yaml similarity index 93% rename from spec/docker-compose.yaml rename to docker-compose-spec.yaml index f7c17b97..1f9080d2 100644 --- a/spec/docker-compose.yaml +++ b/docker-compose-spec.yaml @@ -6,9 +6,11 @@ services: # General python container for executing tests spec: - build: . - volumes: - - ${PWD}:/app + build: + context: . + dockerfile: Dockerfile-spec +# volumes: +# - ${PWD}:/app depends_on: - re_api environment: diff --git a/api/docker-compose.yaml b/docker-compose.yaml similarity index 84% rename from api/docker-compose.yaml rename to docker-compose.yaml index 50bd90b2..718b2ae6 100644 --- a/api/docker-compose.yaml +++ b/docker-compose.yaml @@ -8,12 +8,14 @@ services: web: build: context: . + dockerfile: Dockerfile-api args: DEVELOPMENT: 1 ports: - "127.0.0.1:5000:5000" - volumes: - - ${PWD}:/app +# volumes: +# - ${PWD}:/app +# - ${PWD}/scripts:/app/scripts depends_on: - auth - workspace @@ -34,13 +36,13 @@ services: auth: image: mockservices/mock_json_service volumes: - - ${PWD}/src/test/mock_auth:/config + - ${PWD}/api/src/test/mock_auth:/config # Mock workspace server (see src/test/mock_workspace/endpoints.json) workspace: image: mockservices/mock_json_service volumes: - - ${PWD}/src/test/mock_workspace:/config + - ${PWD}/api/src/test/mock_workspace:/config # Arangodb server in cluster mode arangodb: diff --git a/api/hooks/build b/hooks/build similarity index 100% rename from api/hooks/build rename to hooks/build diff --git a/api/requirements.txt b/requirements.txt similarity index 86% rename from api/requirements.txt rename to requirements.txt index a286db3a..c6ff7500 100644 --- a/api/requirements.txt +++ b/requirements.txt @@ -4,5 +4,5 @@ gevent==1.3.7 simplejson==3.16.0 python-dotenv==0.9.1 requests==2.20.0 -jsonschema==3.0.1 +jsonschema==3.2.0 pyyaml==5.1.1 diff --git a/api/scripts/local-build.sh b/scripts/local-build.sh similarity index 100% rename from api/scripts/local-build.sh rename to scripts/local-build.sh diff --git a/api/scripts/run_tests.sh b/scripts/run_tests.sh similarity index 79% rename from api/scripts/run_tests.sh rename to scripts/run_tests.sh index c60d73af..b6c7b243 100644 --- a/api/scripts/run_tests.sh +++ b/scripts/run_tests.sh @@ -8,4 +8,5 @@ bandit -r src sh scripts/start_server.sh & python -m src.test.wait_for_api && python -m unittest discover src/test/ && -PYTHONPATH=client_src python -m unittest discover client_src/test/ +PYTHONPATH=client_src python -m unittest discover client_src/test/ && +PYTHONPATH=importers python -m unittest discover importers/test diff --git a/api/scripts/start_server.sh b/scripts/start_server.sh similarity index 100% rename from api/scripts/start_server.sh rename to scripts/start_server.sh diff --git a/spec/test/helpers.py b/spec/test/helpers.py index ae4368fe..83f14737 100644 --- a/spec/test/helpers.py +++ b/spec/test/helpers.py @@ -7,6 +7,7 @@ import requests import functools import contextlib +import json @functools.lru_cache(maxsize=1) @@ -69,6 +70,29 @@ def assert_subset(testCls, subset, _dict): testCls.assertEqual(subset.get(key), _dict.get(key)) +def create_test_docs(coll_name, docs, update_on_dupe=False): + """Create a set of documents for use in tests.""" + body = '\n'.join([json.dumps(d) for d in docs]) + params = {'overwrite': True, 'collection': coll_name, 'display_errors': '1'} + + if update_on_dupe: + del params['overwrite'] + params['on_duplicate'] = 'update' + + conf = get_config() + + resp = requests.put( + conf['re_api_url'] + '/api/v1/documents', + params=params, + data=body, + headers={'Authorization': 'admin_token'} + ) + if not resp.ok: + raise RuntimeError(resp.text) + + return resp + + @contextlib.contextmanager def modified_environ(*remove, **update): """ diff --git a/spec/test/stored_queries/test_djornl.py b/spec/test/stored_queries/test_djornl.py index df2a7e56..7d4f17df 100644 --- a/spec/test/stored_queries/test_djornl.py +++ b/spec/test/stored_queries/test_djornl.py @@ -9,8 +9,7 @@ import glob import yaml -from test.helpers import get_config, assert_subset, modified_environ -from test.stored_queries.helpers import create_test_docs +from test.helpers import get_config, modified_environ, create_test_docs from importers.djornl.parser import DJORNL_Parser _CONF = get_config() diff --git a/spec/test/stored_queries/test_ncbi_tax.py b/spec/test/stored_queries/test_ncbi_tax.py index 0c3e2fe7..5fc6f2a8 100644 --- a/spec/test/stored_queries/test_ncbi_tax.py +++ b/spec/test/stored_queries/test_ncbi_tax.py @@ -6,8 +6,7 @@ import unittest import requests -from test.helpers import get_config, assert_subset -from test.stored_queries.helpers import create_test_docs +from test.helpers import get_config, assert_subset, create_test_docs _CONF = get_config() _NOW = int(time.time() * 1000) diff --git a/spec/test/stored_queries/test_taxonomy.py b/spec/test/stored_queries/test_taxonomy.py index 2b4a9635..32fa2588 100644 --- a/spec/test/stored_queries/test_taxonomy.py +++ b/spec/test/stored_queries/test_taxonomy.py @@ -6,8 +6,7 @@ import unittest import requests -from test.helpers import get_config, assert_subset -from test.stored_queries.helpers import create_test_docs +from test.helpers import get_config, assert_subset, create_test_docs _CONF = get_config() _NOW = int(time.time() * 1000) diff --git a/spec/test/stored_queries/test_ws.py b/spec/test/stored_queries/test_ws.py index 10b28b19..197e88e0 100644 --- a/spec/test/stored_queries/test_ws.py +++ b/spec/test/stored_queries/test_ws.py @@ -4,9 +4,7 @@ import unittest import json import requests -from test.stored_queries.helpers import create_test_docs - -from test.helpers import get_config +from test.helpers import get_config, create_test_docs _CONF = get_config() From 9ccfc5ecd2a3d1f62265cd381950dfafb1ad4351 Mon Sep 17 00:00:00 2001 From: ialarmedalien Date: Tue, 28 Jul 2020 15:23:55 -0700 Subject: [PATCH 540/732] Moving spec files around and fixing tests --- api/.dockerignore => .dockerignore | 6 +++ .travis.yml | 3 -- Dockerfile-api | 6 +-- Dockerfile-spec | 6 ++- Makefile | 12 +++-- api/.travis.yml | 5 -- docker-compose-spec.yaml | 12 +++-- docker-compose.yaml | 4 +- .../run_tests.sh => scripts/run_spec_tests.sh | 2 +- scripts/run_tests.sh | 8 +-- spec/.travis.yml | 5 -- spec/Makefile | 4 -- {api => src}/README.md | 0 {api => src}/client_src/README.md | 0 .../relation_engine_client/__init__.py | 0 .../relation_engine_client/exceptions.py | 0 .../client_src/relation_engine_client/main.py | 0 {api => src}/client_src/setup.py | 0 {api => src}/client_src/test/__init__.py | 0 .../client_src/test/test_integration.py | 0 {api => src}/importers/README.md | 0 .../importers}/__init__.py | 0 .../importers/djornl}/__init__.py | 0 {api => src}/importers/djornl/main.py | 0 {api => src}/importers/djornl/parser.py | 22 +++----- .../utils => src/importers/test}/__init__.py | 0 {api => src}/importers/test/helpers.py | 0 .../importers/test/test_djornl_parser.py | 12 +---- {api => src}/importers/tox.ini | 0 {api => src}/importers/utils/config.py | 0 .../relation_engine_server}/__init__.py | 0 .../api_versions}/__init__.py | 0 .../api_versions/api_v1.py | 0 .../relation_engine_server/exceptions.py | 0 .../relation_engine_server/main.py | 0 .../relation_engine_server/utils}/__init__.py | 0 .../utils/arango_client.py | 0 .../relation_engine_server/utils/auth.py | 0 .../utils/bulk_import.py | 0 .../relation_engine_server/utils/config.py | 0 .../utils/json_validation.py | 0 .../utils/load_data_sources.py | 0 .../utils/parse_json.py | 0 .../relation_engine_server/utils/pull_spec.py | 0 .../utils/spec_loader.py | 0 .../wait_for_services.py | 0 src/test/__init__.py | 0 .../test/mock_auth/auth_admin.json | 0 .../test/mock_auth/auth_invalid.json | 0 .../test/mock_auth/auth_missing.json | 0 .../test/mock_auth/auth_non_admin.json | 0 .../list_workspace_ids_invalid.json | 0 .../list_workspace_ids_valid.json | 0 .../list_workspace_ids_valid2.json | 0 {api/src => src}/test/spec_release/README.md | 0 .../src => src}/test/spec_release/spec.tar.gz | Bin {api/src => src}/test/test_api_v1.py | 0 {api/src => src}/test/test_utils.py | 0 {api/src => src}/test/wait_for_api.py | 0 {api => src}/tox.ini | 0 test/__init__.py | 0 ...aragwas-MERGED-AMW-v2_091319_nodeTable.csv | 0 .../merged_edges-AMW-060820_AF.tsv | 0 ...aragwas-MERGED-AMW-v2_091319_nodeTable.csv | 0 ...p10percent_anno_AF_082919.abc.I2_named.tsv | 0 ...p10percent_anno_AF_082919.abc.I4_named.tsv | 0 ...p10percent_anno_AF_082919.abc.I6_named.tsv | 0 .../merged_edges-AMW-060820_AF.tsv | 0 ...aragwas-MERGED-AMW-v2_091319_nodeTable.csv | 0 .../merged_edges-AMW-060820_AF.tsv | 0 {spec/test => test}/djornl/results.json | 0 ...aragwas-MERGED-AMW-v2_091319_nodeTable.csv | 0 ...p10percent_anno_AF_082919.abc.I2_named.tsv | 0 ...p10percent_anno_AF_082919.abc.I4_named.tsv | 0 ...p10percent_anno_AF_082919.abc.I6_named.tsv | 0 .../test_data/merged_edges-AMW-060820_AF.tsv | 0 {spec/test => test}/helpers.py | 0 .../mock_services/mock_auth/admin.json | 0 .../mock_services/mock_auth/invalid.json | 0 .../mock_services/mock_auth/invalid2.json | 0 .../mock_services/mock_auth/valid.json | 0 .../list_workspace_ids_admin.json | 0 .../list_workspace_ids_invalid1.json | 0 .../list_workspace_ids_valid.json | 0 test/stored_queries/__init__.py | 0 {spec/test => test}/stored_queries/helpers.py | 0 .../stored_queries/test_djornl.py | 4 -- .../stored_queries/test_list_test_vertices.py | 49 ++++++++++-------- .../stored_queries/test_ncbi_tax.py | 0 .../stored_queries/test_taxonomy.py | 0 {spec/test => test}/stored_queries/test_ws.py | 0 {spec/test => test}/tox.ini | 0 {spec/test => test}/validate.py | 15 ++++-- 93 files changed, 81 insertions(+), 94 deletions(-) rename api/.dockerignore => .dockerignore (88%) delete mode 100644 api/.travis.yml rename spec/test/run_tests.sh => scripts/run_spec_tests.sh (54%) delete mode 100644 spec/.travis.yml delete mode 100644 spec/Makefile rename {api => src}/README.md (100%) rename {api => src}/client_src/README.md (100%) rename {api => src}/client_src/relation_engine_client/__init__.py (100%) rename {api => src}/client_src/relation_engine_client/exceptions.py (100%) rename {api => src}/client_src/relation_engine_client/main.py (100%) rename {api => src}/client_src/setup.py (100%) rename {api => src}/client_src/test/__init__.py (100%) rename {api => src}/client_src/test/test_integration.py (100%) rename {api => src}/importers/README.md (100%) rename {api/src/relation_engine_server => src/importers}/__init__.py (100%) rename {api/src/relation_engine_server/api_versions => src/importers/djornl}/__init__.py (100%) rename {api => src}/importers/djornl/main.py (100%) rename {api => src}/importers/djornl/parser.py (94%) rename {api/src/relation_engine_server/utils => src/importers/test}/__init__.py (100%) rename {api => src}/importers/test/helpers.py (100%) rename {api => src}/importers/test/test_djornl_parser.py (97%) rename {api => src}/importers/tox.ini (100%) rename {api => src}/importers/utils/config.py (100%) rename {api/src/test => src/relation_engine_server}/__init__.py (100%) rename {spec/test => src/relation_engine_server/api_versions}/__init__.py (100%) rename {api/src => src}/relation_engine_server/api_versions/api_v1.py (100%) rename {api/src => src}/relation_engine_server/exceptions.py (100%) rename {api/src => src}/relation_engine_server/main.py (100%) rename {spec/test/stored_queries => src/relation_engine_server/utils}/__init__.py (100%) rename {api/src => src}/relation_engine_server/utils/arango_client.py (100%) rename {api/src => src}/relation_engine_server/utils/auth.py (100%) rename {api/src => src}/relation_engine_server/utils/bulk_import.py (100%) rename {api/src => src}/relation_engine_server/utils/config.py (100%) rename {api/src => src}/relation_engine_server/utils/json_validation.py (100%) rename {api/src => src}/relation_engine_server/utils/load_data_sources.py (100%) rename {api/src => src}/relation_engine_server/utils/parse_json.py (100%) rename {api/src => src}/relation_engine_server/utils/pull_spec.py (100%) rename {api/src => src}/relation_engine_server/utils/spec_loader.py (100%) rename {api/src => src}/relation_engine_server/wait_for_services.py (100%) create mode 100644 src/test/__init__.py rename {api/src => src}/test/mock_auth/auth_admin.json (100%) rename {api/src => src}/test/mock_auth/auth_invalid.json (100%) rename {api/src => src}/test/mock_auth/auth_missing.json (100%) rename {api/src => src}/test/mock_auth/auth_non_admin.json (100%) rename {api/src => src}/test/mock_workspace/list_workspace_ids_invalid.json (100%) rename {api/src => src}/test/mock_workspace/list_workspace_ids_valid.json (100%) rename {api/src => src}/test/mock_workspace/list_workspace_ids_valid2.json (100%) rename {api/src => src}/test/spec_release/README.md (100%) rename {api/src => src}/test/spec_release/spec.tar.gz (100%) rename {api/src => src}/test/test_api_v1.py (100%) rename {api/src => src}/test/test_utils.py (100%) rename {api/src => src}/test/wait_for_api.py (100%) rename {api => src}/tox.ini (100%) create mode 100644 test/__init__.py rename {spec/test => test}/djornl/col_count_errors/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv (100%) rename {spec/test => test}/djornl/col_count_errors/merged_edges-AMW-060820_AF.tsv (100%) rename {spec/test => test}/djornl/empty_files/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv (100%) rename {spec/test => test}/djornl/empty_files/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I2_named.tsv (100%) rename {spec/test => test}/djornl/empty_files/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I4_named.tsv (100%) rename {spec/test => test}/djornl/empty_files/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I6_named.tsv (100%) rename {spec/test => test}/djornl/empty_files/merged_edges-AMW-060820_AF.tsv (100%) rename {spec/test => test}/djornl/invalid_types/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv (100%) rename {spec/test => test}/djornl/invalid_types/merged_edges-AMW-060820_AF.tsv (100%) rename {spec/test => test}/djornl/results.json (100%) rename {spec/test => test}/djornl/test_data/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv (100%) rename {spec/test => test}/djornl/test_data/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I2_named.tsv (100%) rename {spec/test => test}/djornl/test_data/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I4_named.tsv (100%) rename {spec/test => test}/djornl/test_data/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I6_named.tsv (100%) rename {spec/test => test}/djornl/test_data/merged_edges-AMW-060820_AF.tsv (100%) rename {spec/test => test}/helpers.py (100%) rename {spec/test => test}/mock_services/mock_auth/admin.json (100%) rename {spec/test => test}/mock_services/mock_auth/invalid.json (100%) rename {spec/test => test}/mock_services/mock_auth/invalid2.json (100%) rename {spec/test => test}/mock_services/mock_auth/valid.json (100%) rename {spec/test => test}/mock_services/mock_workspace/list_workspace_ids_admin.json (100%) rename {spec/test => test}/mock_services/mock_workspace/list_workspace_ids_invalid1.json (100%) rename {spec/test => test}/mock_services/mock_workspace/list_workspace_ids_valid.json (100%) create mode 100644 test/stored_queries/__init__.py rename {spec/test => test}/stored_queries/helpers.py (100%) rename {spec/test => test}/stored_queries/test_djornl.py (97%) rename {spec/test => test}/stored_queries/test_list_test_vertices.py (53%) rename {spec/test => test}/stored_queries/test_ncbi_tax.py (100%) rename {spec/test => test}/stored_queries/test_taxonomy.py (100%) rename {spec/test => test}/stored_queries/test_ws.py (100%) rename {spec/test => test}/tox.ini (100%) rename {spec/test => test}/validate.py (94%) diff --git a/api/.dockerignore b/.dockerignore similarity index 88% rename from api/.dockerignore rename to .dockerignore index cc8bc85d..359c034e 100644 --- a/api/.dockerignore +++ b/.dockerignore @@ -14,6 +14,8 @@ coverage.xml *,cover *.log .git +.git* +CODEOWNERS # Byte-compiled / optimized / DLL files __pycache__/ @@ -40,3 +42,7 @@ pip-delete-this-directory.txt .mypy_cache/ .dmypy.json dmypy.json + +# docker bits +Dockerfile* +docker-compose* \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 4cf93926..10dc631b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,4 @@ sudo: required services: - docker script: -- cd api - make test -- cd ../spec -- make test \ No newline at end of file diff --git a/Dockerfile-api b/Dockerfile-api index a95b6e8b..c1c7e29b 100644 --- a/Dockerfile-api +++ b/Dockerfile-api @@ -24,9 +24,9 @@ RUN apk --update add --virtual build-dependencies build-base python3-dev && \ if [ "$DEVELOPMENT" ]; then pip install --no-cache-dir -r /tmp/dev-requirements.txt; fi && \ apk del build-dependencies -COPY api/ /app +COPY src /app/src COPY scripts /app/scripts -COPY spec/test test +COPY test /app/test LABEL org.label-schema.build-date=$BUILD_DATE \ org.label-schema.vcs-url="https://github.com/kbase/relation_engine_api" \ @@ -37,4 +37,4 @@ LABEL org.label-schema.build-date=$BUILD_DATE \ EXPOSE 5000 ENTRYPOINT ["/usr/local/bin/dockerize"] -CMD ["sh", "-x", "scripts/start_server.sh"] +CMD ["sh", "-x", "/app/scripts/start_server.sh"] diff --git a/Dockerfile-spec b/Dockerfile-spec index 3a405702..a1a5b87a 100644 --- a/Dockerfile-spec +++ b/Dockerfile-spec @@ -2,5 +2,7 @@ from python:3.7-slim RUN pip install --upgrade pip requests jsonschema pyyaml WORKDIR /app -COPY spec/ /app -COPY api/importers /app/importers \ No newline at end of file +COPY spec /app/spec +COPY test /app/test +COPY scripts /app/scripts +COPY src /app/src \ No newline at end of file diff --git a/Makefile b/Makefile index bc661db4..248960a3 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,15 @@ .PHONY: test reset -test: - docker-compose down +test: api-test spec-test + +api-test: + docker-compose down --remove-orphans docker-compose build docker-compose run web sh scripts/run_tests.sh docker-compose down api-shell: - docker-compose down + docker-compose down --remove-orphans docker-compose build docker-compose run web sh @@ -17,10 +19,10 @@ reset: spec-test: docker-compose build - docker-compose -f docker-compose-spec.yaml run spec sh /app/test/run_tests.sh + docker-compose -f docker-compose-spec.yaml run spec sh scripts/run_spec_tests.sh docker-compose down spec-shell: - docker-compose down + docker-compose down --remove-orphans docker-compose -f docker-compose-spec.yaml build docker-compose -f docker-compose-spec.yaml run spec bash diff --git a/api/.travis.yml b/api/.travis.yml deleted file mode 100644 index 10dc631b..00000000 --- a/api/.travis.yml +++ /dev/null @@ -1,5 +0,0 @@ -sudo: required -services: -- docker -script: -- make test diff --git a/docker-compose-spec.yaml b/docker-compose-spec.yaml index 1f9080d2..830fb825 100644 --- a/docker-compose-spec.yaml +++ b/docker-compose-spec.yaml @@ -20,13 +20,18 @@ services: # Relation Engine API re_api: - image: kbase/relation_engine_api:develop +# image: kbase/relation_engine_api:develop + build: + context: . + dockerfile: Dockerfile-api + args: + DEVELOPMENT: 1 ports: - "127.0.0.1:5000:5000" depends_on: - - arangodb - auth - workspace + - arangodb environment: - WORKERS=2 - DEVELOPMENT=1 @@ -37,8 +42,9 @@ services: - PYTHONUNBUFFERED=true - DB_URL=http://arangodb:8529 - DB_USER=root +# - SPEC_RELEASE_PATH=/app/src/test/spec_release/spec.tar.gz volumes: - - ".:/spec/repo" + - "./spec:/spec/repo" # Arangodb server in cluster mode arangodb: diff --git a/docker-compose.yaml b/docker-compose.yaml index 718b2ae6..923ca230 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -36,13 +36,13 @@ services: auth: image: mockservices/mock_json_service volumes: - - ${PWD}/api/src/test/mock_auth:/config + - ${PWD}/src/test/mock_auth:/config # Mock workspace server (see src/test/mock_workspace/endpoints.json) workspace: image: mockservices/mock_json_service volumes: - - ${PWD}/api/src/test/mock_workspace:/config + - ${PWD}/src/test/mock_workspace:/config # Arangodb server in cluster mode arangodb: diff --git a/spec/test/run_tests.sh b/scripts/run_spec_tests.sh similarity index 54% rename from spec/test/run_tests.sh rename to scripts/run_spec_tests.sh index 9f63e2ac..13de4d0f 100644 --- a/spec/test/run_tests.sh +++ b/scripts/run_spec_tests.sh @@ -2,4 +2,4 @@ set -e python -m test.helpers wait_for_api && \ python -m test.validate && \ -python -m unittest discover /app/test/stored_queries +PYTHONPATH=/app/src python -m unittest discover /app/test/stored_queries diff --git a/scripts/run_tests.sh b/scripts/run_tests.sh index b6c7b243..febaee8d 100644 --- a/scripts/run_tests.sh +++ b/scripts/run_tests.sh @@ -2,11 +2,11 @@ set -e -flake8 --max-complexity 10 src +flake8 --max-complexity 10 --ignore=E501 src mypy --ignore-missing-imports src bandit -r src -sh scripts/start_server.sh & +sh /app/scripts/start_server.sh & python -m src.test.wait_for_api && python -m unittest discover src/test/ && -PYTHONPATH=client_src python -m unittest discover client_src/test/ && -PYTHONPATH=importers python -m unittest discover importers/test +PYTHONPATH=src/client_src python -m unittest discover src/client_src/test/ && +PYTHONPATH=src python -m unittest discover src/importers/test diff --git a/spec/.travis.yml b/spec/.travis.yml deleted file mode 100644 index 10dc631b..00000000 --- a/spec/.travis.yml +++ /dev/null @@ -1,5 +0,0 @@ -sudo: required -services: -- docker -script: -- make test diff --git a/spec/Makefile b/spec/Makefile deleted file mode 100644 index c3baa811..00000000 --- a/spec/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -.PHONY: test - -test: - docker-compose run spec sh /app/test/run_tests.sh diff --git a/api/README.md b/src/README.md similarity index 100% rename from api/README.md rename to src/README.md diff --git a/api/client_src/README.md b/src/client_src/README.md similarity index 100% rename from api/client_src/README.md rename to src/client_src/README.md diff --git a/api/client_src/relation_engine_client/__init__.py b/src/client_src/relation_engine_client/__init__.py similarity index 100% rename from api/client_src/relation_engine_client/__init__.py rename to src/client_src/relation_engine_client/__init__.py diff --git a/api/client_src/relation_engine_client/exceptions.py b/src/client_src/relation_engine_client/exceptions.py similarity index 100% rename from api/client_src/relation_engine_client/exceptions.py rename to src/client_src/relation_engine_client/exceptions.py diff --git a/api/client_src/relation_engine_client/main.py b/src/client_src/relation_engine_client/main.py similarity index 100% rename from api/client_src/relation_engine_client/main.py rename to src/client_src/relation_engine_client/main.py diff --git a/api/client_src/setup.py b/src/client_src/setup.py similarity index 100% rename from api/client_src/setup.py rename to src/client_src/setup.py diff --git a/api/client_src/test/__init__.py b/src/client_src/test/__init__.py similarity index 100% rename from api/client_src/test/__init__.py rename to src/client_src/test/__init__.py diff --git a/api/client_src/test/test_integration.py b/src/client_src/test/test_integration.py similarity index 100% rename from api/client_src/test/test_integration.py rename to src/client_src/test/test_integration.py diff --git a/api/importers/README.md b/src/importers/README.md similarity index 100% rename from api/importers/README.md rename to src/importers/README.md diff --git a/api/src/relation_engine_server/__init__.py b/src/importers/__init__.py similarity index 100% rename from api/src/relation_engine_server/__init__.py rename to src/importers/__init__.py diff --git a/api/src/relation_engine_server/api_versions/__init__.py b/src/importers/djornl/__init__.py similarity index 100% rename from api/src/relation_engine_server/api_versions/__init__.py rename to src/importers/djornl/__init__.py diff --git a/api/importers/djornl/main.py b/src/importers/djornl/main.py similarity index 100% rename from api/importers/djornl/main.py rename to src/importers/djornl/main.py diff --git a/api/importers/djornl/parser.py b/src/importers/djornl/parser.py similarity index 94% rename from api/importers/djornl/parser.py rename to src/importers/djornl/parser.py index 9eb5c87b..5f09ea68 100644 --- a/api/importers/djornl/parser.py +++ b/src/importers/djornl/parser.py @@ -59,17 +59,16 @@ def _configure(self): self._config = configuration return self._config - def load_edges(self): # Headers and sample row: # node1 node2 edge edge_descrip layer_descrip # AT1G01370 AT1G57820 4.40001558779779 AraNetv2_log-likelihood-score AraNetv2-LC_lit-curated-ppi edge_remap = { - 'AraGWAS-Phenotype_Associations': 'pheno_assn', - 'AraNetv2-CX_pairwise-gene-coexpression': 'gene_coexpr', - 'AraNetv2-DC_domain-co-occurrence': 'domain_co_occur', - 'AraNetv2-HT_high-throughput-ppi': 'ppi_hithru', - 'AraNetv2-LC_lit-curated-ppi': 'ppi_liter', + 'AraGWAS-Phenotype_Associations': 'pheno_assn', + 'AraNetv2-CX_pairwise-gene-coexpression': 'gene_coexpr', + 'AraNetv2-DC_domain-co-occurrence': 'domain_co_occur', + 'AraNetv2-HT_high-throughput-ppi': 'ppi_hithru', + 'AraNetv2-LC_lit-curated-ppi': 'ppi_liter', } # dict of nodes, indexed by node ID (node1 and node2 from the file) @@ -103,13 +102,11 @@ def load_edges(self): 'score': float(cols[2]), 'edge_type': edge_remap[edge_type], }) - return { 'nodes': [{'_key': n} for n in node_ix.keys()], 'edges': edges, } - def load_node_metadata(self): """Load node metadata""" @@ -157,10 +154,8 @@ def load_node_metadata(self): 'user_notes': cols[19], } nodes.append(doc) - return {'nodes': nodes} - def load_cluster_data(self): """Annotate genes with cluster ID fields.""" nodes = [] @@ -171,16 +166,14 @@ def load_cluster_data(self): for row in csv_reader: if len(row) > 1: # remove the 'Cluster' text - cluster_id = row[0].replace('Cluster','') + cluster_id = row[0].replace('Cluster', '') gene_keys = row[1:] nodes += [ {'_key': key, cluster_label: int(cluster_id)} for key in gene_keys ] - return {'nodes': nodes} - def save_dataset(self, dataset): if 'nodes' in dataset and len(dataset['nodes']) > 0: @@ -189,7 +182,6 @@ def save_dataset(self, dataset): if 'edges' in dataset and len(dataset['edges']) > 0: self.save_docs(self.config()['_EDGE_NAME'], dataset['edges']) - def save_docs(self, coll_name, docs, on_dupe='update'): resp = requests.put( @@ -206,9 +198,7 @@ def save_docs(self, coll_name, docs, on_dupe='update'): print('=' * 80) return resp - def load_data(self): self.save_dataset(self.load_edges()) self.save_dataset(self.load_node_metadata()) self.save_dataset(self.load_cluster_data()) - diff --git a/api/src/relation_engine_server/utils/__init__.py b/src/importers/test/__init__.py similarity index 100% rename from api/src/relation_engine_server/utils/__init__.py rename to src/importers/test/__init__.py diff --git a/api/importers/test/helpers.py b/src/importers/test/helpers.py similarity index 100% rename from api/importers/test/helpers.py rename to src/importers/test/helpers.py diff --git a/api/importers/test/test_djornl_parser.py b/src/importers/test/test_djornl_parser.py similarity index 97% rename from api/importers/test/test_djornl_parser.py rename to src/importers/test/test_djornl_parser.py index 28e5fc7c..14c3a62e 100644 --- a/api/importers/test/test_djornl_parser.py +++ b/src/importers/test/test_djornl_parser.py @@ -5,15 +5,12 @@ it does not check data loading into the db. """ import json -import time import unittest -import requests import os -import contextlib from importers.djornl.parser import DJORNL_Parser -from test.helpers import modified_environ, create_test_docs +from test.helpers import modified_environ _TEST_DIR = '/app/test' @@ -27,7 +24,6 @@ def setUpClass(cls): with open(results_file) as fh: cls.json_data = json.load(fh) - def init_parser_with_path(self, root_path): with modified_environ(RES_ROOT_DATA_PATH=root_path): @@ -36,7 +32,6 @@ def init_parser_with_path(self, root_path): parser.config() return parser - def test_load_empty_files(self): """ test loading files containing no data """ @@ -48,7 +43,6 @@ def test_load_empty_files(self): self.assertEqual(parser.load_node_metadata(), {"nodes": []}) self.assertEqual(parser.load_cluster_data(), {"nodes": []}) - def test_load_missing_files(self): """ test loading when files cannot be found """ @@ -67,7 +61,6 @@ def test_load_missing_files(self): with self.assertRaisesRegex(FileNotFoundError, err_str): parser.load_cluster_data() - def test_load_invalid_types(self): """ test file format errors """ @@ -85,7 +78,6 @@ def test_load_invalid_types(self): with self.assertRaisesRegex(RuntimeError, node_err_msg): parser.load_node_metadata() - def test_load_col_count_errors(self): """ test files with invalid numbers of columns """ @@ -103,7 +95,6 @@ def test_load_col_count_errors(self): with self.assertRaisesRegex(RuntimeError, node_err_msg): parser.load_node_metadata() - def test_load_valid_edge_data(self): RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, 'djornl', 'test_data') @@ -139,4 +130,3 @@ def test_load_valid_cluster_data(self): cluster_data, self.json_data["load_cluster_data"] ) - diff --git a/api/importers/tox.ini b/src/importers/tox.ini similarity index 100% rename from api/importers/tox.ini rename to src/importers/tox.ini diff --git a/api/importers/utils/config.py b/src/importers/utils/config.py similarity index 100% rename from api/importers/utils/config.py rename to src/importers/utils/config.py diff --git a/api/src/test/__init__.py b/src/relation_engine_server/__init__.py similarity index 100% rename from api/src/test/__init__.py rename to src/relation_engine_server/__init__.py diff --git a/spec/test/__init__.py b/src/relation_engine_server/api_versions/__init__.py similarity index 100% rename from spec/test/__init__.py rename to src/relation_engine_server/api_versions/__init__.py diff --git a/api/src/relation_engine_server/api_versions/api_v1.py b/src/relation_engine_server/api_versions/api_v1.py similarity index 100% rename from api/src/relation_engine_server/api_versions/api_v1.py rename to src/relation_engine_server/api_versions/api_v1.py diff --git a/api/src/relation_engine_server/exceptions.py b/src/relation_engine_server/exceptions.py similarity index 100% rename from api/src/relation_engine_server/exceptions.py rename to src/relation_engine_server/exceptions.py diff --git a/api/src/relation_engine_server/main.py b/src/relation_engine_server/main.py similarity index 100% rename from api/src/relation_engine_server/main.py rename to src/relation_engine_server/main.py diff --git a/spec/test/stored_queries/__init__.py b/src/relation_engine_server/utils/__init__.py similarity index 100% rename from spec/test/stored_queries/__init__.py rename to src/relation_engine_server/utils/__init__.py diff --git a/api/src/relation_engine_server/utils/arango_client.py b/src/relation_engine_server/utils/arango_client.py similarity index 100% rename from api/src/relation_engine_server/utils/arango_client.py rename to src/relation_engine_server/utils/arango_client.py diff --git a/api/src/relation_engine_server/utils/auth.py b/src/relation_engine_server/utils/auth.py similarity index 100% rename from api/src/relation_engine_server/utils/auth.py rename to src/relation_engine_server/utils/auth.py diff --git a/api/src/relation_engine_server/utils/bulk_import.py b/src/relation_engine_server/utils/bulk_import.py similarity index 100% rename from api/src/relation_engine_server/utils/bulk_import.py rename to src/relation_engine_server/utils/bulk_import.py diff --git a/api/src/relation_engine_server/utils/config.py b/src/relation_engine_server/utils/config.py similarity index 100% rename from api/src/relation_engine_server/utils/config.py rename to src/relation_engine_server/utils/config.py diff --git a/api/src/relation_engine_server/utils/json_validation.py b/src/relation_engine_server/utils/json_validation.py similarity index 100% rename from api/src/relation_engine_server/utils/json_validation.py rename to src/relation_engine_server/utils/json_validation.py diff --git a/api/src/relation_engine_server/utils/load_data_sources.py b/src/relation_engine_server/utils/load_data_sources.py similarity index 100% rename from api/src/relation_engine_server/utils/load_data_sources.py rename to src/relation_engine_server/utils/load_data_sources.py diff --git a/api/src/relation_engine_server/utils/parse_json.py b/src/relation_engine_server/utils/parse_json.py similarity index 100% rename from api/src/relation_engine_server/utils/parse_json.py rename to src/relation_engine_server/utils/parse_json.py diff --git a/api/src/relation_engine_server/utils/pull_spec.py b/src/relation_engine_server/utils/pull_spec.py similarity index 100% rename from api/src/relation_engine_server/utils/pull_spec.py rename to src/relation_engine_server/utils/pull_spec.py diff --git a/api/src/relation_engine_server/utils/spec_loader.py b/src/relation_engine_server/utils/spec_loader.py similarity index 100% rename from api/src/relation_engine_server/utils/spec_loader.py rename to src/relation_engine_server/utils/spec_loader.py diff --git a/api/src/relation_engine_server/wait_for_services.py b/src/relation_engine_server/wait_for_services.py similarity index 100% rename from api/src/relation_engine_server/wait_for_services.py rename to src/relation_engine_server/wait_for_services.py diff --git a/src/test/__init__.py b/src/test/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/api/src/test/mock_auth/auth_admin.json b/src/test/mock_auth/auth_admin.json similarity index 100% rename from api/src/test/mock_auth/auth_admin.json rename to src/test/mock_auth/auth_admin.json diff --git a/api/src/test/mock_auth/auth_invalid.json b/src/test/mock_auth/auth_invalid.json similarity index 100% rename from api/src/test/mock_auth/auth_invalid.json rename to src/test/mock_auth/auth_invalid.json diff --git a/api/src/test/mock_auth/auth_missing.json b/src/test/mock_auth/auth_missing.json similarity index 100% rename from api/src/test/mock_auth/auth_missing.json rename to src/test/mock_auth/auth_missing.json diff --git a/api/src/test/mock_auth/auth_non_admin.json b/src/test/mock_auth/auth_non_admin.json similarity index 100% rename from api/src/test/mock_auth/auth_non_admin.json rename to src/test/mock_auth/auth_non_admin.json diff --git a/api/src/test/mock_workspace/list_workspace_ids_invalid.json b/src/test/mock_workspace/list_workspace_ids_invalid.json similarity index 100% rename from api/src/test/mock_workspace/list_workspace_ids_invalid.json rename to src/test/mock_workspace/list_workspace_ids_invalid.json diff --git a/api/src/test/mock_workspace/list_workspace_ids_valid.json b/src/test/mock_workspace/list_workspace_ids_valid.json similarity index 100% rename from api/src/test/mock_workspace/list_workspace_ids_valid.json rename to src/test/mock_workspace/list_workspace_ids_valid.json diff --git a/api/src/test/mock_workspace/list_workspace_ids_valid2.json b/src/test/mock_workspace/list_workspace_ids_valid2.json similarity index 100% rename from api/src/test/mock_workspace/list_workspace_ids_valid2.json rename to src/test/mock_workspace/list_workspace_ids_valid2.json diff --git a/api/src/test/spec_release/README.md b/src/test/spec_release/README.md similarity index 100% rename from api/src/test/spec_release/README.md rename to src/test/spec_release/README.md diff --git a/api/src/test/spec_release/spec.tar.gz b/src/test/spec_release/spec.tar.gz similarity index 100% rename from api/src/test/spec_release/spec.tar.gz rename to src/test/spec_release/spec.tar.gz diff --git a/api/src/test/test_api_v1.py b/src/test/test_api_v1.py similarity index 100% rename from api/src/test/test_api_v1.py rename to src/test/test_api_v1.py diff --git a/api/src/test/test_utils.py b/src/test/test_utils.py similarity index 100% rename from api/src/test/test_utils.py rename to src/test/test_utils.py diff --git a/api/src/test/wait_for_api.py b/src/test/wait_for_api.py similarity index 100% rename from api/src/test/wait_for_api.py rename to src/test/wait_for_api.py diff --git a/api/tox.ini b/src/tox.ini similarity index 100% rename from api/tox.ini rename to src/tox.ini diff --git a/test/__init__.py b/test/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/spec/test/djornl/col_count_errors/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv b/test/djornl/col_count_errors/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv similarity index 100% rename from spec/test/djornl/col_count_errors/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv rename to test/djornl/col_count_errors/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv diff --git a/spec/test/djornl/col_count_errors/merged_edges-AMW-060820_AF.tsv b/test/djornl/col_count_errors/merged_edges-AMW-060820_AF.tsv similarity index 100% rename from spec/test/djornl/col_count_errors/merged_edges-AMW-060820_AF.tsv rename to test/djornl/col_count_errors/merged_edges-AMW-060820_AF.tsv diff --git a/spec/test/djornl/empty_files/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv b/test/djornl/empty_files/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv similarity index 100% rename from spec/test/djornl/empty_files/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv rename to test/djornl/empty_files/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv diff --git a/spec/test/djornl/empty_files/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I2_named.tsv b/test/djornl/empty_files/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I2_named.tsv similarity index 100% rename from spec/test/djornl/empty_files/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I2_named.tsv rename to test/djornl/empty_files/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I2_named.tsv diff --git a/spec/test/djornl/empty_files/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I4_named.tsv b/test/djornl/empty_files/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I4_named.tsv similarity index 100% rename from spec/test/djornl/empty_files/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I4_named.tsv rename to test/djornl/empty_files/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I4_named.tsv diff --git a/spec/test/djornl/empty_files/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I6_named.tsv b/test/djornl/empty_files/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I6_named.tsv similarity index 100% rename from spec/test/djornl/empty_files/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I6_named.tsv rename to test/djornl/empty_files/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I6_named.tsv diff --git a/spec/test/djornl/empty_files/merged_edges-AMW-060820_AF.tsv b/test/djornl/empty_files/merged_edges-AMW-060820_AF.tsv similarity index 100% rename from spec/test/djornl/empty_files/merged_edges-AMW-060820_AF.tsv rename to test/djornl/empty_files/merged_edges-AMW-060820_AF.tsv diff --git a/spec/test/djornl/invalid_types/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv b/test/djornl/invalid_types/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv similarity index 100% rename from spec/test/djornl/invalid_types/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv rename to test/djornl/invalid_types/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv diff --git a/spec/test/djornl/invalid_types/merged_edges-AMW-060820_AF.tsv b/test/djornl/invalid_types/merged_edges-AMW-060820_AF.tsv similarity index 100% rename from spec/test/djornl/invalid_types/merged_edges-AMW-060820_AF.tsv rename to test/djornl/invalid_types/merged_edges-AMW-060820_AF.tsv diff --git a/spec/test/djornl/results.json b/test/djornl/results.json similarity index 100% rename from spec/test/djornl/results.json rename to test/djornl/results.json diff --git a/spec/test/djornl/test_data/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv b/test/djornl/test_data/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv similarity index 100% rename from spec/test/djornl/test_data/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv rename to test/djornl/test_data/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv diff --git a/spec/test/djornl/test_data/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I2_named.tsv b/test/djornl/test_data/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I2_named.tsv similarity index 100% rename from spec/test/djornl/test_data/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I2_named.tsv rename to test/djornl/test_data/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I2_named.tsv diff --git a/spec/test/djornl/test_data/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I4_named.tsv b/test/djornl/test_data/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I4_named.tsv similarity index 100% rename from spec/test/djornl/test_data/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I4_named.tsv rename to test/djornl/test_data/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I4_named.tsv diff --git a/spec/test/djornl/test_data/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I6_named.tsv b/test/djornl/test_data/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I6_named.tsv similarity index 100% rename from spec/test/djornl/test_data/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I6_named.tsv rename to test/djornl/test_data/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I6_named.tsv diff --git a/spec/test/djornl/test_data/merged_edges-AMW-060820_AF.tsv b/test/djornl/test_data/merged_edges-AMW-060820_AF.tsv similarity index 100% rename from spec/test/djornl/test_data/merged_edges-AMW-060820_AF.tsv rename to test/djornl/test_data/merged_edges-AMW-060820_AF.tsv diff --git a/spec/test/helpers.py b/test/helpers.py similarity index 100% rename from spec/test/helpers.py rename to test/helpers.py diff --git a/spec/test/mock_services/mock_auth/admin.json b/test/mock_services/mock_auth/admin.json similarity index 100% rename from spec/test/mock_services/mock_auth/admin.json rename to test/mock_services/mock_auth/admin.json diff --git a/spec/test/mock_services/mock_auth/invalid.json b/test/mock_services/mock_auth/invalid.json similarity index 100% rename from spec/test/mock_services/mock_auth/invalid.json rename to test/mock_services/mock_auth/invalid.json diff --git a/spec/test/mock_services/mock_auth/invalid2.json b/test/mock_services/mock_auth/invalid2.json similarity index 100% rename from spec/test/mock_services/mock_auth/invalid2.json rename to test/mock_services/mock_auth/invalid2.json diff --git a/spec/test/mock_services/mock_auth/valid.json b/test/mock_services/mock_auth/valid.json similarity index 100% rename from spec/test/mock_services/mock_auth/valid.json rename to test/mock_services/mock_auth/valid.json diff --git a/spec/test/mock_services/mock_workspace/list_workspace_ids_admin.json b/test/mock_services/mock_workspace/list_workspace_ids_admin.json similarity index 100% rename from spec/test/mock_services/mock_workspace/list_workspace_ids_admin.json rename to test/mock_services/mock_workspace/list_workspace_ids_admin.json diff --git a/spec/test/mock_services/mock_workspace/list_workspace_ids_invalid1.json b/test/mock_services/mock_workspace/list_workspace_ids_invalid1.json similarity index 100% rename from spec/test/mock_services/mock_workspace/list_workspace_ids_invalid1.json rename to test/mock_services/mock_workspace/list_workspace_ids_invalid1.json diff --git a/spec/test/mock_services/mock_workspace/list_workspace_ids_valid.json b/test/mock_services/mock_workspace/list_workspace_ids_valid.json similarity index 100% rename from spec/test/mock_services/mock_workspace/list_workspace_ids_valid.json rename to test/mock_services/mock_workspace/list_workspace_ids_valid.json diff --git a/test/stored_queries/__init__.py b/test/stored_queries/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/spec/test/stored_queries/helpers.py b/test/stored_queries/helpers.py similarity index 100% rename from spec/test/stored_queries/helpers.py rename to test/stored_queries/helpers.py diff --git a/spec/test/stored_queries/test_djornl.py b/test/stored_queries/test_djornl.py similarity index 97% rename from spec/test/stored_queries/test_djornl.py rename to test/stored_queries/test_djornl.py index 7d4f17df..d616d577 100644 --- a/spec/test/stored_queries/test_djornl.py +++ b/test/stored_queries/test_djornl.py @@ -13,7 +13,6 @@ from importers.djornl.parser import DJORNL_Parser _CONF = get_config() -_NOW = int(time.time() * 1000) _TEST_DIR = '/app/test' _VERBOSE = 0 @@ -194,7 +193,6 @@ def test_fetch_clusters(self): self.json_data['fetch_clusters'][fetch_args][distance] ) - @unittest.skip('This test is disabled until automated view loading is possible') def test_search_nodes_no_results(self): resp = self.submit_query('djornl_search_nodes', { @@ -202,8 +200,6 @@ def test_search_nodes_no_results(self): }) self.assertEqual(resp['results'][0], self.no_results) - - @unittest.skip('This test is disabled until automated view loading is possible') def test_search_nodes(self): for search_text in self.json_data['search_nodes'].keys(): diff --git a/spec/test/stored_queries/test_list_test_vertices.py b/test/stored_queries/test_list_test_vertices.py similarity index 53% rename from spec/test/stored_queries/test_list_test_vertices.py rename to test/stored_queries/test_list_test_vertices.py index 8397254a..1234423d 100644 --- a/spec/test/stored_queries/test_list_test_vertices.py +++ b/test/stored_queries/test_list_test_vertices.py @@ -3,19 +3,10 @@ import requests import time -_API_URL = 'http://re_api:5000/api' -_VERSION = 'v1' -_QUERY_URL = f'{_API_URL}/{_VERSION}/query_results?view=list_test_vertices' +from test.helpers import create_test_docs, get_config - -def create_test_docs(docs): - body = '\n'.join([json.dumps(d) for d in docs]) - return requests.put( - f'{_API_URL}/{_VERSION}/documents', - params={'overwrite': True, 'collection': 'test_vertex'}, - data=body, - headers={'Authorization': 'admin_token'} - ).json() +_CONF = get_config() +_QUERY_URL = _CONF['re_api_url'] + '/api/v1/query_results?view=list_test_vertices' class TestListTestVertices(unittest.TestCase): @@ -40,11 +31,18 @@ def setUpClass(cls): def test_valid(self): """Test a valid query.""" - print(create_test_docs([ - {'is_public': True, '_key': 'a', 'ws_id': 10}, # public access - {'is_public': False, '_key': 'b', 'ws_id': 1}, # private access - {'is_public': False, '_key': 'c', 'ws_id': 99} # no access - ])) + docs_created = create_test_docs( + 'test_vertex', + [ + {'is_public': True, '_key': 'a', 'ws_id': 10}, # public access + {'is_public': False, '_key': 'b', 'ws_id': 1}, # private access + {'is_public': False, '_key': 'c', 'ws_id': 99} # no access + ] + ) + self.assertEqual( + docs_created.json(), + {'created': 3, 'details': [], 'empty': 0, 'error': False, 'errors': 0, 'ignored': 0, 'updated': 0}, + ) resp = requests.post( _QUERY_URL, headers={'Authorization': 'valid_token'} # gives access to workspaces [1,2,3] @@ -55,11 +53,18 @@ def test_valid(self): def test_no_auth(self): """Test with blank auth.""" - print(create_test_docs([ - {'is_public': True, '_key': 'a', 'ws_id': 10}, # public access - {'is_public': False, '_key': 'b', 'ws_id': 1}, # private access - {'is_public': False, '_key': 'c', 'ws_id': 99} # no access - ])) + docs_created = create_test_docs( + 'test_vertex', + [ + {'is_public': True, '_key': 'a', 'ws_id': 10}, # public access + {'is_public': False, '_key': 'b', 'ws_id': 1}, # private access + {'is_public': False, '_key': 'c', 'ws_id': 99} # no access + ] + ) + self.assertEqual( + docs_created.json(), + {'created': 3, 'details': [], 'empty': 0, 'error': False, 'errors': 0, 'ignored': 0, 'updated': 0}, + ) resp = requests.post(_QUERY_URL).json() self.assertEqual(resp['count'], 1) # 'b' and 'c' are inaccessible diff --git a/spec/test/stored_queries/test_ncbi_tax.py b/test/stored_queries/test_ncbi_tax.py similarity index 100% rename from spec/test/stored_queries/test_ncbi_tax.py rename to test/stored_queries/test_ncbi_tax.py diff --git a/spec/test/stored_queries/test_taxonomy.py b/test/stored_queries/test_taxonomy.py similarity index 100% rename from spec/test/stored_queries/test_taxonomy.py rename to test/stored_queries/test_taxonomy.py diff --git a/spec/test/stored_queries/test_ws.py b/test/stored_queries/test_ws.py similarity index 100% rename from spec/test/stored_queries/test_ws.py rename to test/stored_queries/test_ws.py diff --git a/spec/test/tox.ini b/test/tox.ini similarity index 100% rename from spec/test/tox.ini rename to test/tox.ini diff --git a/spec/test/validate.py b/test/validate.py similarity index 94% rename from spec/test/validate.py rename to test/validate.py index e4c11d98..e5ac73d7 100644 --- a/spec/test/validate.py +++ b/test/validate.py @@ -13,6 +13,7 @@ from test.helpers import get_config, wait_for_arangodb _CONF = get_config() +_BASE_DIR = '/app/spec' # JSON schema for vertex and edge collection schemas found in /schema schema_schema = { @@ -37,7 +38,9 @@ def validate_json_schemas(): """Validate the syntax of all the JSON schemas.""" print('Validating JSON schemas..') names = set() # type: set - for path in glob.iglob('schemas/**/*.yaml', recursive=True): + for path in glob.iglob( + os.path.join(_BASE_DIR, 'schemas', '**', '*.yaml'), + recursive=True): name = os.path.basename(path) print(f' validating {path}..') with open(path) as fd: @@ -95,7 +98,9 @@ def validate_stored_queries(): """Validate the structure and syntax of all the queries.""" print('Validating AQL queries..') names = set() # type: set - for path in glob.iglob('stored_queries/**/*.yaml', recursive=True): + for path in glob.iglob( + os.path.join(_BASE_DIR, 'stored_queries', '**', '*.yaml'), + recursive=True): print(f' validating {path}..') with open(path) as fd: data = yaml.safe_load(fd) @@ -159,7 +164,9 @@ def validate_views(): """Validate the structure and syntax of arangosearch views""" print('Validating views..') names = set() # type: set - for path in glob.iglob('views/**/*.json', recursive=True): + for path in glob.iglob( + os.path.join(_BASE_DIR, 'views', '**', '*.json'), + recursive=True): print(f' validating {path}..') with open(path) as fd: data = json.load(fd) @@ -173,7 +180,7 @@ def validate_views(): else: names.add(name) - print(f'✓ {name} is valid.') + print(f'✓ {path} is valid.') print('..all valid.') From 10f01b3077281681deff17e7d70a773b1ca58929 Mon Sep 17 00:00:00 2001 From: ialarmedalien Date: Tue, 28 Jul 2020 15:40:09 -0700 Subject: [PATCH 541/732] tinkering with dockerfiles --- .dockerignore | 3 + Dockerfile-api | 4 +- Dockerfile-spec | 5 +- Makefile | 5 +- docker-compose-spec.yaml | 9 ++- docker-compose.yaml | 2 +- scripts/run_tests.sh | 2 +- src/importers/test/helpers.py | 129 --------------------------------- test/stored_queries/helpers.py | 25 ------- 9 files changed, 14 insertions(+), 170 deletions(-) delete mode 100644 src/importers/test/helpers.py delete mode 100644 test/stored_queries/helpers.py diff --git a/.dockerignore b/.dockerignore index 359c034e..e0862330 100644 --- a/.dockerignore +++ b/.dockerignore @@ -16,6 +16,9 @@ coverage.xml .git .git* CODEOWNERS +LICENSE.md +Makefile +hooks # Byte-compiled / optimized / DLL files __pycache__/ diff --git a/Dockerfile-api b/Dockerfile-api index c1c7e29b..42dc4189 100644 --- a/Dockerfile-api +++ b/Dockerfile-api @@ -24,9 +24,7 @@ RUN apk --update add --virtual build-dependencies build-base python3-dev && \ if [ "$DEVELOPMENT" ]; then pip install --no-cache-dir -r /tmp/dev-requirements.txt; fi && \ apk del build-dependencies -COPY src /app/src -COPY scripts /app/scripts -COPY test /app/test +COPY . /app LABEL org.label-schema.build-date=$BUILD_DATE \ org.label-schema.vcs-url="https://github.com/kbase/relation_engine_api" \ diff --git a/Dockerfile-spec b/Dockerfile-spec index a1a5b87a..cdefd899 100644 --- a/Dockerfile-spec +++ b/Dockerfile-spec @@ -2,7 +2,4 @@ from python:3.7-slim RUN pip install --upgrade pip requests jsonschema pyyaml WORKDIR /app -COPY spec /app/spec -COPY test /app/test -COPY scripts /app/scripts -COPY src /app/src \ No newline at end of file +COPY . /app diff --git a/Makefile b/Makefile index 248960a3..e582324c 100644 --- a/Makefile +++ b/Makefile @@ -3,10 +3,9 @@ test: api-test spec-test api-test: - docker-compose down --remove-orphans docker-compose build docker-compose run web sh scripts/run_tests.sh - docker-compose down + docker-compose down --remove-orphans api-shell: docker-compose down --remove-orphans @@ -20,7 +19,7 @@ reset: spec-test: docker-compose build docker-compose -f docker-compose-spec.yaml run spec sh scripts/run_spec_tests.sh - docker-compose down + docker-compose down --remove-orphans spec-shell: docker-compose down --remove-orphans diff --git a/docker-compose-spec.yaml b/docker-compose-spec.yaml index 830fb825..793505a2 100644 --- a/docker-compose-spec.yaml +++ b/docker-compose-spec.yaml @@ -9,6 +9,7 @@ services: build: context: . dockerfile: Dockerfile-spec +# uncomment to mount local dir # volumes: # - ${PWD}:/app depends_on: @@ -20,7 +21,8 @@ services: # Relation Engine API re_api: -# image: kbase/relation_engine_api:develop + # uncomment to use the RE API docker image + # image: kbase/relation_engine_api:develop build: context: . dockerfile: Dockerfile-api @@ -42,7 +44,6 @@ services: - PYTHONUNBUFFERED=true - DB_URL=http://arangodb:8529 - DB_USER=root -# - SPEC_RELEASE_PATH=/app/src/test/spec_release/spec.tar.gz volumes: - "./spec:/spec/repo" @@ -53,13 +54,13 @@ services: - "127.0.0.1:8529:8529" command: sh -c "arangodb --starter.local" - # A mock kbase auth server (see src/test/mock_auth/endpoints.json) + # A mock kbase auth server (see test/mock_auth/endpoints.json) auth: image: mockservices/mock_json_service volumes: - ${PWD}/test/mock_services/mock_auth:/config - # Mock workspace server (see src/test/mock_workspace/endpoints.json) + # Mock workspace server (see test/mock_workspace/endpoints.json) workspace: image: mockservices/mock_json_service volumes: diff --git a/docker-compose.yaml b/docker-compose.yaml index 923ca230..6971e8cd 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -13,9 +13,9 @@ services: DEVELOPMENT: 1 ports: - "127.0.0.1:5000:5000" +# uncomment to mount local dir # volumes: # - ${PWD}:/app -# - ${PWD}/scripts:/app/scripts depends_on: - auth - workspace diff --git a/scripts/run_tests.sh b/scripts/run_tests.sh index febaee8d..109a95f5 100644 --- a/scripts/run_tests.sh +++ b/scripts/run_tests.sh @@ -9,4 +9,4 @@ sh /app/scripts/start_server.sh & python -m src.test.wait_for_api && python -m unittest discover src/test/ && PYTHONPATH=src/client_src python -m unittest discover src/client_src/test/ && -PYTHONPATH=src python -m unittest discover src/importers/test +PYTHONPATH=src:/app python -m unittest discover src/importers/test diff --git a/src/importers/test/helpers.py b/src/importers/test/helpers.py deleted file mode 100644 index 83f14737..00000000 --- a/src/importers/test/helpers.py +++ /dev/null @@ -1,129 +0,0 @@ -""" -Test helpers -""" -import sys -import os -import time -import requests -import functools -import contextlib -import json - - -@functools.lru_cache(maxsize=1) -def get_config(): - """Return configuration data for tests.""" - return { - 're_api_url': os.environ['RE_API_URL'], - 'db_url': os.environ['DB_URL'], - 'db_auth': (os.environ['DB_USER'], os.environ.get('DB_PASS', '')) - } - - -def wait_for_arangodb(): - """Wait for arangodb to go live.""" - conf = get_config() - db_url = conf['db_url'] - auth = ('root', '') - timeout = time.time() + 60 - while True: - try: - resp = requests.get(db_url + '/_admin/cluster/health', auth=auth) - resp.raise_for_status() - break - except Exception as err: - print('Waiting for arangodb to come online') - if time.time() > timeout: - sys.stderr.write(str(err) + '\n') - raise RuntimeError('Timed out waiting for arangodb') - time.sleep(3) - - -def wait_for_api(): - wait_for_arangodb() - # Wait for other dependent services to come online - conf = get_config() - timeout = int(time.time()) + 60 - auth_url = 'http://auth:5000' - ws_url = 'http://workspace:5000' - while True: - try: - # Reassign the `url` variable so we can print which service errored - url = conf['re_api_url'] - requests.get(url).raise_for_status() - url = auth_url - requests.get(url) - url = ws_url - requests.get(url) - break - except Exception as err: - print(f"Waiting for dependent service to come online: {url}") - if int(time.time()) > timeout: - sys.stderr.write(str(err) + "\n") - raise RuntimeError(f"Timed out waiting for {url}") - time.sleep(2) - - -def assert_subset(testCls, subset, _dict): - """Replacement for the deprecated `assertDictContainsSubset` method.""" - for (key, val) in subset.items(): - testCls.assertEqual(subset.get(key), _dict.get(key)) - - -def create_test_docs(coll_name, docs, update_on_dupe=False): - """Create a set of documents for use in tests.""" - body = '\n'.join([json.dumps(d) for d in docs]) - params = {'overwrite': True, 'collection': coll_name, 'display_errors': '1'} - - if update_on_dupe: - del params['overwrite'] - params['on_duplicate'] = 'update' - - conf = get_config() - - resp = requests.put( - conf['re_api_url'] + '/api/v1/documents', - params=params, - data=body, - headers={'Authorization': 'admin_token'} - ) - if not resp.ok: - raise RuntimeError(resp.text) - - return resp - - -@contextlib.contextmanager -def modified_environ(*remove, **update): - """ - Temporarily updates the ``os.environ`` dictionary in-place. - - The ``os.environ`` dictionary is updated in-place so that the modification - is sure to work in all situations. - - :param remove: Environment variables to remove. - :param update: Dictionary of environment variables and values to add/update. - """ - env = os.environ - update = update or {} - remove = remove or [] - - # List of environment variables being updated or removed. - stomped = (set(update.keys()) | set(remove)) & set(env.keys()) - # Environment variables and values to restore on exit. - update_after = {k: env[k] for k in stomped} - # Environment variables and values to remove on exit. - remove_after = frozenset(k for k in update if k not in env) - - try: - env.update(update) - [env.pop(k, None) for k in remove] - yield - finally: - env.update(update_after) - [env.pop(k) for k in remove_after] - - -if __name__ == '__main__': - if sys.argv[1] == 'wait_for_api': - wait_for_api() diff --git a/test/stored_queries/helpers.py b/test/stored_queries/helpers.py deleted file mode 100644 index bf8ecd7f..00000000 --- a/test/stored_queries/helpers.py +++ /dev/null @@ -1,25 +0,0 @@ -import requests -import json -from test.helpers import get_config - -_CONF = get_config() - -def create_test_docs(coll_name, docs, update_on_dupe=False): - """Create a set of documents for use in tests.""" - body = '\n'.join([json.dumps(d) for d in docs]) - params = {'overwrite': True, 'collection': coll_name, 'display_errors': '1'} - - if update_on_dupe: - del params['overwrite'] - params['on_duplicate'] = 'update' - - resp = requests.put( - _CONF['re_api_url'] + '/api/v1/documents', - params=params, - data=body, - headers={'Authorization': 'admin_token'} - ) - if not resp.ok: - raise RuntimeError(resp.text) - - return resp From 54d7c7363be2878a69a28879f7ce3a541e603d25 Mon Sep 17 00:00:00 2001 From: ialarmedalien Date: Tue, 28 Jul 2020 16:28:42 -0700 Subject: [PATCH 542/732] fix docker build scripts --- hooks/build | 5 +++-- scripts/local-build.sh | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/hooks/build b/hooks/build index 3d8b8414..730be97d 100755 --- a/hooks/build +++ b/hooks/build @@ -5,14 +5,15 @@ # $IMAGE_NAME var is injected into the build so the tag is correct. if [ -z "$IMAGE_NAME" ]; then - export IMAGE_NAME="kbase/relation_engine_api:0.0.4" + export IMAGE_NAME="kbase/relation_engine_api:latest" fi echo "Build hook running" export BRANCH=${TRAVIS_BRANCH:-`git symbolic-ref --short HEAD`} export DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` export COMMIT=${TRAVIS_COMMIT:-`git rev-parse --short HEAD`} -docker build --build-arg BUILD_DATE=$DATE \ +docker build --file Dockerfile-api + --build-arg BUILD_DATE=$DATE \ --build-arg VCS_REF=$COMMIT \ --build-arg BRANCH=$BRANCH \ -t ${IMAGE_NAME} . diff --git a/scripts/local-build.sh b/scripts/local-build.sh index c1c3cc2c..a9182d61 100644 --- a/scripts/local-build.sh +++ b/scripts/local-build.sh @@ -2,6 +2,6 @@ set -e # show the commands we execute set -o xtrace -export IMAGE_NAME="kbase/relation_engine_api:0.0.5" +export IMAGE_NAME="kbase/relation_engine_api:local_build" sh hooks/build docker push $IMAGE_NAME From 97583aee0d7515f70554cb740e820778ae3473e7 Mon Sep 17 00:00:00 2001 From: ialarmedalien Date: Fri, 31 Jul 2020 08:32:16 -0700 Subject: [PATCH 543/732] Moving spec tests to spec/tests; moving src/ files to top level directory; updated file paths accordingly Removing unused file --- CODEOWNERS | 2 +- Dockerfile-api => Dockerfile | 0 Dockerfile-spec | 5 -- Makefile | 20 ++---- {src/client_src => client_src}/README.md | 0 .../relation_engine_client/__init__.py | 0 .../relation_engine_client/exceptions.py | 0 .../relation_engine_client/main.py | 0 {src/client_src => client_src}/setup.py | 0 .../test/__init__.py | 0 .../test/test_integration.py | 0 docker-compose-spec.yaml | 67 ------------------ docker-compose.yaml | 16 +++-- {src/importers => importers}/README.md | 0 {src/importers => importers}/__init__.py | 0 .../djornl/__init__.py | 0 {src/importers => importers}/djornl/main.py | 0 {src/importers => importers}/djornl/parser.py | 0 {src/importers => importers}/test/__init__.py | 0 .../test/test_djornl_parser.py | 4 +- {src/importers => importers}/tox.ini | 0 {src/importers => importers}/utils/config.py | 0 {src => relation_engine_server}/README.md | 7 +- .../__init__.py | 0 .../api_versions/__init__.py | 0 .../api_versions/api_v1.py | 4 +- .../exceptions.py | 0 .../main.py | 0 .../test}/__init__.py | 0 .../test/mock_auth/auth_admin.json | 0 .../test/mock_auth/auth_invalid.json | 0 .../test/mock_auth/auth_missing.json | 0 .../test/mock_auth/auth_non_admin.json | 0 .../list_workspace_ids_invalid.json | 0 .../list_workspace_ids_valid.json | 0 .../list_workspace_ids_valid2.json | 0 .../test/spec_release/README.md | 0 .../test/spec_release/spec.tar.gz | Bin .../test/test_api_v1.py | 2 +- .../test/test_utils.py | 2 +- .../test/wait_for_api.py | 0 .../utils}/__init__.py | 0 .../utils/arango_client.py | 0 .../utils/auth.py | 0 .../utils/bulk_import.py | 2 +- .../utils/config.py | 0 .../utils/json_validation.py | 0 .../utils/load_data_sources.py | 4 +- .../utils/parse_json.py | 0 .../utils/pull_spec.py | 6 -- .../utils/spec_loader.py | 0 .../wait_for_services.py | 0 scripts/run_spec_tests.sh | 5 -- scripts/run_tests.sh | 25 +++++-- scripts/start_server.sh | 6 +- spec/README.md | 15 ++-- {test => spec/test}/__init__.py | 0 ...aragwas-MERGED-AMW-v2_091319_nodeTable.csv | 0 .../merged_edges-AMW-060820_AF.tsv | 0 ...aragwas-MERGED-AMW-v2_091319_nodeTable.csv | 0 ...p10percent_anno_AF_082919.abc.I2_named.tsv | 0 ...p10percent_anno_AF_082919.abc.I4_named.tsv | 0 ...p10percent_anno_AF_082919.abc.I6_named.tsv | 0 .../merged_edges-AMW-060820_AF.tsv | 0 ...aragwas-MERGED-AMW-v2_091319_nodeTable.csv | 0 .../merged_edges-AMW-060820_AF.tsv | 0 {test => spec/test}/djornl/results.json | 0 ...aragwas-MERGED-AMW-v2_091319_nodeTable.csv | 0 ...p10percent_anno_AF_082919.abc.I2_named.tsv | 0 ...p10percent_anno_AF_082919.abc.I4_named.tsv | 0 ...p10percent_anno_AF_082919.abc.I6_named.tsv | 0 .../test_data/merged_edges-AMW-060820_AF.tsv | 0 {test => spec/test}/helpers.py | 0 .../test}/mock_services/mock_auth/admin.json | 0 .../mock_services/mock_auth/invalid.json | 0 .../mock_services/mock_auth/invalid2.json | 0 .../test}/mock_services/mock_auth/valid.json | 0 .../list_workspace_ids_admin.json | 0 .../list_workspace_ids_invalid1.json | 0 .../list_workspace_ids_valid.json | 0 .../test}/stored_queries/__init__.py | 0 .../test}/stored_queries/test_djornl.py | 28 +------- .../stored_queries/test_list_test_vertices.py | 5 +- .../test}/stored_queries/test_ncbi_tax.py | 2 +- .../test}/stored_queries/test_taxonomy.py | 3 +- {test => spec/test}/stored_queries/test_ws.py | 2 +- {src => spec/test}/tox.ini | 0 {test => spec/test}/validate.py | 2 +- test/tox.ini => tox.ini | 0 89 files changed, 62 insertions(+), 172 deletions(-) rename Dockerfile-api => Dockerfile (100%) delete mode 100644 Dockerfile-spec rename {src/client_src => client_src}/README.md (100%) rename {src/client_src => client_src}/relation_engine_client/__init__.py (100%) rename {src/client_src => client_src}/relation_engine_client/exceptions.py (100%) rename {src/client_src => client_src}/relation_engine_client/main.py (100%) rename {src/client_src => client_src}/setup.py (100%) rename {src/client_src => client_src}/test/__init__.py (100%) rename {src/client_src => client_src}/test/test_integration.py (100%) delete mode 100644 docker-compose-spec.yaml rename {src/importers => importers}/README.md (100%) rename {src/importers => importers}/__init__.py (100%) rename {src/importers => importers}/djornl/__init__.py (100%) rename {src/importers => importers}/djornl/main.py (100%) rename {src/importers => importers}/djornl/parser.py (100%) rename {src/importers => importers}/test/__init__.py (100%) rename {src/importers => importers}/test/test_djornl_parser.py (98%) rename {src/importers => importers}/tox.ini (100%) rename {src/importers => importers}/utils/config.py (100%) rename {src => relation_engine_server}/README.md (97%) rename {src/relation_engine_server => relation_engine_server}/__init__.py (100%) rename {src/relation_engine_server => relation_engine_server}/api_versions/__init__.py (100%) rename {src/relation_engine_server => relation_engine_server}/api_versions/api_v1.py (98%) rename {src/relation_engine_server => relation_engine_server}/exceptions.py (100%) rename {src/relation_engine_server => relation_engine_server}/main.py (100%) rename {src/relation_engine_server/utils => relation_engine_server/test}/__init__.py (100%) rename {src => relation_engine_server}/test/mock_auth/auth_admin.json (100%) rename {src => relation_engine_server}/test/mock_auth/auth_invalid.json (100%) rename {src => relation_engine_server}/test/mock_auth/auth_missing.json (100%) rename {src => relation_engine_server}/test/mock_auth/auth_non_admin.json (100%) rename {src => relation_engine_server}/test/mock_workspace/list_workspace_ids_invalid.json (100%) rename {src => relation_engine_server}/test/mock_workspace/list_workspace_ids_valid.json (100%) rename {src => relation_engine_server}/test/mock_workspace/list_workspace_ids_valid2.json (100%) rename {src => relation_engine_server}/test/spec_release/README.md (100%) rename {src => relation_engine_server}/test/spec_release/spec.tar.gz (100%) rename {src => relation_engine_server}/test/test_api_v1.py (99%) rename {src => relation_engine_server}/test/test_utils.py (86%) rename {src => relation_engine_server}/test/wait_for_api.py (100%) rename {src/test => relation_engine_server/utils}/__init__.py (100%) rename {src/relation_engine_server => relation_engine_server}/utils/arango_client.py (100%) rename {src/relation_engine_server => relation_engine_server}/utils/auth.py (100%) rename {src/relation_engine_server => relation_engine_server}/utils/bulk_import.py (96%) rename {src/relation_engine_server => relation_engine_server}/utils/config.py (100%) rename {src/relation_engine_server => relation_engine_server}/utils/json_validation.py (100%) rename {src/relation_engine_server => relation_engine_server}/utils/load_data_sources.py (90%) rename {src/relation_engine_server => relation_engine_server}/utils/parse_json.py (100%) rename {src/relation_engine_server => relation_engine_server}/utils/pull_spec.py (96%) rename {src/relation_engine_server => relation_engine_server}/utils/spec_loader.py (100%) rename {src/relation_engine_server => relation_engine_server}/wait_for_services.py (100%) delete mode 100644 scripts/run_spec_tests.sh rename {test => spec/test}/__init__.py (100%) rename {test => spec/test}/djornl/col_count_errors/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv (100%) rename {test => spec/test}/djornl/col_count_errors/merged_edges-AMW-060820_AF.tsv (100%) rename {test => spec/test}/djornl/empty_files/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv (100%) rename {test => spec/test}/djornl/empty_files/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I2_named.tsv (100%) rename {test => spec/test}/djornl/empty_files/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I4_named.tsv (100%) rename {test => spec/test}/djornl/empty_files/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I6_named.tsv (100%) rename {test => spec/test}/djornl/empty_files/merged_edges-AMW-060820_AF.tsv (100%) rename {test => spec/test}/djornl/invalid_types/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv (100%) rename {test => spec/test}/djornl/invalid_types/merged_edges-AMW-060820_AF.tsv (100%) rename {test => spec/test}/djornl/results.json (100%) rename {test => spec/test}/djornl/test_data/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv (100%) rename {test => spec/test}/djornl/test_data/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I2_named.tsv (100%) rename {test => spec/test}/djornl/test_data/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I4_named.tsv (100%) rename {test => spec/test}/djornl/test_data/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I6_named.tsv (100%) rename {test => spec/test}/djornl/test_data/merged_edges-AMW-060820_AF.tsv (100%) rename {test => spec/test}/helpers.py (100%) rename {test => spec/test}/mock_services/mock_auth/admin.json (100%) rename {test => spec/test}/mock_services/mock_auth/invalid.json (100%) rename {test => spec/test}/mock_services/mock_auth/invalid2.json (100%) rename {test => spec/test}/mock_services/mock_auth/valid.json (100%) rename {test => spec/test}/mock_services/mock_workspace/list_workspace_ids_admin.json (100%) rename {test => spec/test}/mock_services/mock_workspace/list_workspace_ids_invalid1.json (100%) rename {test => spec/test}/mock_services/mock_workspace/list_workspace_ids_valid.json (100%) rename {test => spec/test}/stored_queries/__init__.py (100%) rename {test => spec/test}/stored_queries/test_djornl.py (91%) rename {test => spec/test}/stored_queries/test_list_test_vertices.py (94%) rename {test => spec/test}/stored_queries/test_ncbi_tax.py (99%) rename {test => spec/test}/stored_queries/test_taxonomy.py (99%) rename {test => spec/test}/stored_queries/test_ws.py (98%) rename {src => spec/test}/tox.ini (100%) rename {test => spec/test}/validate.py (99%) rename test/tox.ini => tox.ini (100%) diff --git a/CODEOWNERS b/CODEOWNERS index 38691172..d371bfb1 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -1,3 +1,3 @@ * @jayrbolton -api/* @jayrbolton @slebras +relation_engine_server/* @jayrbolton @slebras diff --git a/Dockerfile-api b/Dockerfile similarity index 100% rename from Dockerfile-api rename to Dockerfile diff --git a/Dockerfile-spec b/Dockerfile-spec deleted file mode 100644 index cdefd899..00000000 --- a/Dockerfile-spec +++ /dev/null @@ -1,5 +0,0 @@ -from python:3.7-slim - -RUN pip install --upgrade pip requests jsonschema pyyaml -WORKDIR /app -COPY . /app diff --git a/Makefile b/Makefile index e582324c..86023d46 100644 --- a/Makefile +++ b/Makefile @@ -1,27 +1,15 @@ .PHONY: test reset -test: api-test spec-test - -api-test: +test: docker-compose build - docker-compose run web sh scripts/run_tests.sh + docker-compose run re_api sh scripts/run_tests.sh docker-compose down --remove-orphans -api-shell: +shell: docker-compose down --remove-orphans docker-compose build - docker-compose run web sh + docker-compose run re_api sh reset: docker-compose --rmi all -v docker-compose build - -spec-test: - docker-compose build - docker-compose -f docker-compose-spec.yaml run spec sh scripts/run_spec_tests.sh - docker-compose down --remove-orphans - -spec-shell: - docker-compose down --remove-orphans - docker-compose -f docker-compose-spec.yaml build - docker-compose -f docker-compose-spec.yaml run spec bash diff --git a/src/client_src/README.md b/client_src/README.md similarity index 100% rename from src/client_src/README.md rename to client_src/README.md diff --git a/src/client_src/relation_engine_client/__init__.py b/client_src/relation_engine_client/__init__.py similarity index 100% rename from src/client_src/relation_engine_client/__init__.py rename to client_src/relation_engine_client/__init__.py diff --git a/src/client_src/relation_engine_client/exceptions.py b/client_src/relation_engine_client/exceptions.py similarity index 100% rename from src/client_src/relation_engine_client/exceptions.py rename to client_src/relation_engine_client/exceptions.py diff --git a/src/client_src/relation_engine_client/main.py b/client_src/relation_engine_client/main.py similarity index 100% rename from src/client_src/relation_engine_client/main.py rename to client_src/relation_engine_client/main.py diff --git a/src/client_src/setup.py b/client_src/setup.py similarity index 100% rename from src/client_src/setup.py rename to client_src/setup.py diff --git a/src/client_src/test/__init__.py b/client_src/test/__init__.py similarity index 100% rename from src/client_src/test/__init__.py rename to client_src/test/__init__.py diff --git a/src/client_src/test/test_integration.py b/client_src/test/test_integration.py similarity index 100% rename from src/client_src/test/test_integration.py rename to client_src/test/test_integration.py diff --git a/docker-compose-spec.yaml b/docker-compose-spec.yaml deleted file mode 100644 index 793505a2..00000000 --- a/docker-compose-spec.yaml +++ /dev/null @@ -1,67 +0,0 @@ -version: '3' - -# This docker-compose is for developer convenience and testing, not for running in production. - -services: - - # General python container for executing tests - spec: - build: - context: . - dockerfile: Dockerfile-spec -# uncomment to mount local dir -# volumes: -# - ${PWD}:/app - depends_on: - - re_api - environment: - - DB_URL=http://arangodb:8529 - - DB_USER=root - - RE_API_URL=http://re_api:5000 - - # Relation Engine API - re_api: - # uncomment to use the RE API docker image - # image: kbase/relation_engine_api:develop - build: - context: . - dockerfile: Dockerfile-api - args: - DEVELOPMENT: 1 - ports: - - "127.0.0.1:5000:5000" - depends_on: - - auth - - workspace - - arangodb - environment: - - WORKERS=2 - - DEVELOPMENT=1 - - FLASK_ENV=development - - FLASK_DEBUG=1 - - KBASE_AUTH_URL=http://auth:5000 - - KBASE_WORKSPACE_URL=http://workspace:5000 - - PYTHONUNBUFFERED=true - - DB_URL=http://arangodb:8529 - - DB_USER=root - volumes: - - "./spec:/spec/repo" - - # Arangodb server in cluster mode - arangodb: - image: arangodb:3.5 - ports: - - "127.0.0.1:8529:8529" - command: sh -c "arangodb --starter.local" - - # A mock kbase auth server (see test/mock_auth/endpoints.json) - auth: - image: mockservices/mock_json_service - volumes: - - ${PWD}/test/mock_services/mock_auth:/config - - # Mock workspace server (see test/mock_workspace/endpoints.json) - workspace: - image: mockservices/mock_json_service - volumes: - - ${PWD}/test/mock_services/mock_workspace:/config diff --git a/docker-compose.yaml b/docker-compose.yaml index 6971e8cd..1d2443b2 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -4,18 +4,19 @@ version: '3' services: - # For running the Flask server - web: + # For running the Flask server and tests + re_api: build: context: . - dockerfile: Dockerfile-api + dockerfile: Dockerfile args: DEVELOPMENT: 1 ports: - "127.0.0.1:5000:5000" -# uncomment to mount local dir +# uncomment to mount local directories # volumes: # - ${PWD}:/app +# - "./spec:/spec/repo" depends_on: - auth - workspace @@ -28,21 +29,22 @@ services: - KBASE_AUTH_URL=http://auth:5000 - KBASE_WORKSPACE_URL=http://workspace:5000 - PYTHONUNBUFFERED=true - - SPEC_RELEASE_PATH=/app/src/test/spec_release/spec.tar.gz + - SPEC_RELEASE_PATH=/app/relation_engine_server/test/spec_release/spec.tar.gz - DB_URL=http://arangodb:8529 - DB_USER=root + - RE_API_URL=http://127.0.0.1:5000 # A mock kbase auth server (see src/test/mock_auth/endpoints.json) auth: image: mockservices/mock_json_service volumes: - - ${PWD}/src/test/mock_auth:/config + - ${PWD}/relation_engine_server/test/mock_auth:/config # Mock workspace server (see src/test/mock_workspace/endpoints.json) workspace: image: mockservices/mock_json_service volumes: - - ${PWD}/src/test/mock_workspace:/config + - ${PWD}/relation_engine_server/test/mock_workspace:/config # Arangodb server in cluster mode arangodb: diff --git a/src/importers/README.md b/importers/README.md similarity index 100% rename from src/importers/README.md rename to importers/README.md diff --git a/src/importers/__init__.py b/importers/__init__.py similarity index 100% rename from src/importers/__init__.py rename to importers/__init__.py diff --git a/src/importers/djornl/__init__.py b/importers/djornl/__init__.py similarity index 100% rename from src/importers/djornl/__init__.py rename to importers/djornl/__init__.py diff --git a/src/importers/djornl/main.py b/importers/djornl/main.py similarity index 100% rename from src/importers/djornl/main.py rename to importers/djornl/main.py diff --git a/src/importers/djornl/parser.py b/importers/djornl/parser.py similarity index 100% rename from src/importers/djornl/parser.py rename to importers/djornl/parser.py diff --git a/src/importers/test/__init__.py b/importers/test/__init__.py similarity index 100% rename from src/importers/test/__init__.py rename to importers/test/__init__.py diff --git a/src/importers/test/test_djornl_parser.py b/importers/test/test_djornl_parser.py similarity index 98% rename from src/importers/test/test_djornl_parser.py rename to importers/test/test_djornl_parser.py index 14c3a62e..71d43dbc 100644 --- a/src/importers/test/test_djornl_parser.py +++ b/importers/test/test_djornl_parser.py @@ -10,9 +10,9 @@ from importers.djornl.parser import DJORNL_Parser -from test.helpers import modified_environ +from spec.test.helpers import modified_environ -_TEST_DIR = '/app/test' +_TEST_DIR = '/app/spec/test' class Test_DJORNL_Parser(unittest.TestCase): diff --git a/src/importers/tox.ini b/importers/tox.ini similarity index 100% rename from src/importers/tox.ini rename to importers/tox.ini diff --git a/src/importers/utils/config.py b/importers/utils/config.py similarity index 100% rename from src/importers/utils/config.py rename to importers/utils/config.py diff --git a/src/README.md b/relation_engine_server/README.md similarity index 97% rename from src/README.md rename to relation_engine_server/README.md index 1e280ce8..5ad15f2b 100644 --- a/src/README.md +++ b/relation_engine_server/README.md @@ -166,7 +166,7 @@ _Response JSON schema_ #### JSON Schema error responses -If you try to update a collection and it fails validation against a JSON schema found in the [relation_engine_spec](https://github.com/kbase/relation_engine_spec/), then you will get a JSON error response with the following fields: +If you try to update a collection and it fails validation against a JSON schema found in the [relation engine spec](spec/), then you will get a JSON error response with the following fields: * `"error"` - Human readable message explaining the error * `"failed_validator"` - The name of the validator that failed (eg. "required") @@ -352,6 +352,5 @@ Alternatively, set the image name in `scripts/local-build.sh` and run it to buil ## Project anatomy -* Source code is in `./src` -* Tests are in `./src/test` -* The main server code is in `./src/relation_engine_server`. +* The main server code is in `./relation_engine_server`. +* Tests are in `./relation_engine_server/test` diff --git a/src/relation_engine_server/__init__.py b/relation_engine_server/__init__.py similarity index 100% rename from src/relation_engine_server/__init__.py rename to relation_engine_server/__init__.py diff --git a/src/relation_engine_server/api_versions/__init__.py b/relation_engine_server/api_versions/__init__.py similarity index 100% rename from src/relation_engine_server/api_versions/__init__.py rename to relation_engine_server/api_versions/__init__.py diff --git a/src/relation_engine_server/api_versions/api_v1.py b/relation_engine_server/api_versions/api_v1.py similarity index 98% rename from src/relation_engine_server/api_versions/api_v1.py rename to relation_engine_server/api_versions/api_v1.py index 275415ac..6d4a0779 100644 --- a/src/relation_engine_server/api_versions/api_v1.py +++ b/relation_engine_server/api_versions/api_v1.py @@ -1,5 +1,5 @@ import flask -from src.relation_engine_server.utils import ( +from relation_engine_server.utils import ( json_validation, arango_client, spec_loader, @@ -10,7 +10,7 @@ config, parse_json ) -from src.relation_engine_server.exceptions import InvalidParameters +from relation_engine_server.exceptions import InvalidParameters api_v1 = flask.Blueprint('api_v1', __name__) diff --git a/src/relation_engine_server/exceptions.py b/relation_engine_server/exceptions.py similarity index 100% rename from src/relation_engine_server/exceptions.py rename to relation_engine_server/exceptions.py diff --git a/src/relation_engine_server/main.py b/relation_engine_server/main.py similarity index 100% rename from src/relation_engine_server/main.py rename to relation_engine_server/main.py diff --git a/src/relation_engine_server/utils/__init__.py b/relation_engine_server/test/__init__.py similarity index 100% rename from src/relation_engine_server/utils/__init__.py rename to relation_engine_server/test/__init__.py diff --git a/src/test/mock_auth/auth_admin.json b/relation_engine_server/test/mock_auth/auth_admin.json similarity index 100% rename from src/test/mock_auth/auth_admin.json rename to relation_engine_server/test/mock_auth/auth_admin.json diff --git a/src/test/mock_auth/auth_invalid.json b/relation_engine_server/test/mock_auth/auth_invalid.json similarity index 100% rename from src/test/mock_auth/auth_invalid.json rename to relation_engine_server/test/mock_auth/auth_invalid.json diff --git a/src/test/mock_auth/auth_missing.json b/relation_engine_server/test/mock_auth/auth_missing.json similarity index 100% rename from src/test/mock_auth/auth_missing.json rename to relation_engine_server/test/mock_auth/auth_missing.json diff --git a/src/test/mock_auth/auth_non_admin.json b/relation_engine_server/test/mock_auth/auth_non_admin.json similarity index 100% rename from src/test/mock_auth/auth_non_admin.json rename to relation_engine_server/test/mock_auth/auth_non_admin.json diff --git a/src/test/mock_workspace/list_workspace_ids_invalid.json b/relation_engine_server/test/mock_workspace/list_workspace_ids_invalid.json similarity index 100% rename from src/test/mock_workspace/list_workspace_ids_invalid.json rename to relation_engine_server/test/mock_workspace/list_workspace_ids_invalid.json diff --git a/src/test/mock_workspace/list_workspace_ids_valid.json b/relation_engine_server/test/mock_workspace/list_workspace_ids_valid.json similarity index 100% rename from src/test/mock_workspace/list_workspace_ids_valid.json rename to relation_engine_server/test/mock_workspace/list_workspace_ids_valid.json diff --git a/src/test/mock_workspace/list_workspace_ids_valid2.json b/relation_engine_server/test/mock_workspace/list_workspace_ids_valid2.json similarity index 100% rename from src/test/mock_workspace/list_workspace_ids_valid2.json rename to relation_engine_server/test/mock_workspace/list_workspace_ids_valid2.json diff --git a/src/test/spec_release/README.md b/relation_engine_server/test/spec_release/README.md similarity index 100% rename from src/test/spec_release/README.md rename to relation_engine_server/test/spec_release/README.md diff --git a/src/test/spec_release/spec.tar.gz b/relation_engine_server/test/spec_release/spec.tar.gz similarity index 100% rename from src/test/spec_release/spec.tar.gz rename to relation_engine_server/test/spec_release/spec.tar.gz diff --git a/src/test/test_api_v1.py b/relation_engine_server/test/test_api_v1.py similarity index 99% rename from src/test/test_api_v1.py rename to relation_engine_server/test/test_api_v1.py index c8ec7ec0..41bbabe2 100644 --- a/src/test/test_api_v1.py +++ b/relation_engine_server/test/test_api_v1.py @@ -8,7 +8,7 @@ import json import os -from src.relation_engine_server.utils.config import get_config +from relation_engine_server.utils.config import get_config _CONF = get_config() diff --git a/src/test/test_utils.py b/relation_engine_server/test/test_utils.py similarity index 86% rename from src/test/test_utils.py rename to relation_engine_server/test/test_utils.py index 0e2ed6d0..ac8ece7c 100644 --- a/src/test/test_utils.py +++ b/relation_engine_server/test/test_utils.py @@ -1,7 +1,7 @@ """ Test utility functions """ -from src.relation_engine_server.utils import json_validation +from relation_engine_server.utils import json_validation import unittest diff --git a/src/test/wait_for_api.py b/relation_engine_server/test/wait_for_api.py similarity index 100% rename from src/test/wait_for_api.py rename to relation_engine_server/test/wait_for_api.py diff --git a/src/test/__init__.py b/relation_engine_server/utils/__init__.py similarity index 100% rename from src/test/__init__.py rename to relation_engine_server/utils/__init__.py diff --git a/src/relation_engine_server/utils/arango_client.py b/relation_engine_server/utils/arango_client.py similarity index 100% rename from src/relation_engine_server/utils/arango_client.py rename to relation_engine_server/utils/arango_client.py diff --git a/src/relation_engine_server/utils/auth.py b/relation_engine_server/utils/auth.py similarity index 100% rename from src/relation_engine_server/utils/auth.py rename to relation_engine_server/utils/auth.py diff --git a/src/relation_engine_server/utils/bulk_import.py b/relation_engine_server/utils/bulk_import.py similarity index 96% rename from src/relation_engine_server/utils/bulk_import.py rename to relation_engine_server/utils/bulk_import.py index 3faa0c25..739f8ead 100644 --- a/src/relation_engine_server/utils/bulk_import.py +++ b/relation_engine_server/utils/bulk_import.py @@ -5,7 +5,7 @@ import json import hashlib -from src.relation_engine_server.utils import json_validation +from relation_engine_server.utils import json_validation from . import spec_loader from .arango_client import import_from_file diff --git a/src/relation_engine_server/utils/config.py b/relation_engine_server/utils/config.py similarity index 100% rename from src/relation_engine_server/utils/config.py rename to relation_engine_server/utils/config.py diff --git a/src/relation_engine_server/utils/json_validation.py b/relation_engine_server/utils/json_validation.py similarity index 100% rename from src/relation_engine_server/utils/json_validation.py rename to relation_engine_server/utils/json_validation.py diff --git a/src/relation_engine_server/utils/load_data_sources.py b/relation_engine_server/utils/load_data_sources.py similarity index 90% rename from src/relation_engine_server/utils/load_data_sources.py rename to relation_engine_server/utils/load_data_sources.py index b2a7c463..89dd598d 100644 --- a/src/relation_engine_server/utils/load_data_sources.py +++ b/relation_engine_server/utils/load_data_sources.py @@ -9,8 +9,8 @@ import os import glob -from src.relation_engine_server.utils.config import get_config -from src.relation_engine_server.exceptions import NotFound +from relation_engine_server.utils.config import get_config +from relation_engine_server.exceptions import NotFound _CONF = get_config() _PATH = _CONF['spec_paths']['data_sources'] diff --git a/src/relation_engine_server/utils/parse_json.py b/relation_engine_server/utils/parse_json.py similarity index 100% rename from src/relation_engine_server/utils/parse_json.py rename to relation_engine_server/utils/parse_json.py diff --git a/src/relation_engine_server/utils/pull_spec.py b/relation_engine_server/utils/pull_spec.py similarity index 96% rename from src/relation_engine_server/utils/pull_spec.py rename to relation_engine_server/utils/pull_spec.py index 9358d018..99c828ca 100644 --- a/src/relation_engine_server/utils/pull_spec.py +++ b/relation_engine_server/utils/pull_spec.py @@ -1,4 +1,3 @@ -import sys import os import requests import tarfile @@ -26,8 +25,6 @@ def download_specs(init_collections=True, release_url=None, reset=False): if _CONF['spec_release_path']: _extract_tarball(_CONF['spec_release_path'], _CONF['spec_paths']['root']) else: - if release_url: - tarball_url = release_url if _CONF['spec_release_url']: tarball_url = _CONF['spec_release_url'] else: @@ -125,7 +122,4 @@ def _save_release_id(info): if __name__ == '__main__': - if len(sys.argv) > 1: - if sys.argv[1] == 'init': - download_specs(init_collections=True) download_specs() diff --git a/src/relation_engine_server/utils/spec_loader.py b/relation_engine_server/utils/spec_loader.py similarity index 100% rename from src/relation_engine_server/utils/spec_loader.py rename to relation_engine_server/utils/spec_loader.py diff --git a/src/relation_engine_server/wait_for_services.py b/relation_engine_server/wait_for_services.py similarity index 100% rename from src/relation_engine_server/wait_for_services.py rename to relation_engine_server/wait_for_services.py diff --git a/scripts/run_spec_tests.sh b/scripts/run_spec_tests.sh deleted file mode 100644 index 13de4d0f..00000000 --- a/scripts/run_spec_tests.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -set -e -python -m test.helpers wait_for_api && \ -python -m test.validate && \ -PYTHONPATH=/app/src python -m unittest discover /app/test/stored_queries diff --git a/scripts/run_tests.sh b/scripts/run_tests.sh index 109a95f5..829d1d30 100644 --- a/scripts/run_tests.sh +++ b/scripts/run_tests.sh @@ -2,11 +2,22 @@ set -e -flake8 --max-complexity 10 --ignore=E501 src -mypy --ignore-missing-imports src -bandit -r src +flake8 --max-complexity 15 /app +mypy --ignore-missing-imports /app +bandit -r /app +mkdir /spec +mkdir /spec/repo +cp -r /app/spec/* /spec/repo/ +# start server, using the specs in /spec/repo sh /app/scripts/start_server.sh & -python -m src.test.wait_for_api && -python -m unittest discover src/test/ && -PYTHONPATH=src/client_src python -m unittest discover src/client_src/test/ && -PYTHONPATH=src:/app python -m unittest discover src/importers/test +python -m spec.test.helpers wait_for_api && +# spec validation +python -m spec.test.validate && +# spec stored query tests +python -m unittest discover spec/test && +# importer tests +python -m unittest discover importers/test && +# RE API tests +python -m unittest discover relation_engine_server/test && +# RE client tests +PYTHONPATH=client_src python -m unittest discover client_src/test diff --git a/scripts/start_server.sh b/scripts/start_server.sh index f1127858..4bd39aaa 100644 --- a/scripts/start_server.sh +++ b/scripts/start_server.sh @@ -7,8 +7,8 @@ calc_workers="$(($(nproc) * 2 + 1))" # Use the WORKERS environment variable, if present workers=${WORKERS:-$calc_workers} -python -m src.relation_engine_server.wait_for_services -python -m src.relation_engine_server.utils.pull_spec +python -m relation_engine_server.wait_for_services +python -m relation_engine_server.utils.pull_spec gunicorn \ --worker-class gevent \ @@ -16,4 +16,4 @@ gunicorn \ --workers $workers \ --bind :5000 \ ${DEVELOPMENT:+"--reload"} \ - src.relation_engine_server.main:app + relation_engine_server.main:app diff --git a/spec/README.md b/spec/README.md index 9e0eca17..9ce4e777 100644 --- a/spec/README.md +++ b/spec/README.md @@ -1,18 +1,17 @@ # Relation Engine Spec -This repo holds the [stored queries](stored_queries), [schemas](schemas), and [migrations](migrations) for the relation engine graph database service. +This repo holds the [stored queries](spec/stored_queries), [schemas](spec/schemas), and [migrations](migrations) for the relation engine graph database service. -These specifications are used by the [Relation Engine API](https://github.com/kbase/relation_engine_api). +These specifications are used by the [Relation Engine API](relation_engine_server). -* **Stored queries** are stored [AQL queries](https://docs.arangodb.com/3.5/AQL/index.html) that can be used +* **[Stored queries](spec/stored_queries)** are stored [AQL queries](https://docs.arangodb.com/3.5/AQL/index.html) that can be used by KBase apps to fetch data from the database. -* **Schemas** are [JSON schemas](https://json-schema.org/) that define what form of data can be stored in -the database's collections. -* **Data sources** (in `data_sources/`) contains some general information about where some of our imported data comes from. -* **Views** (in `views/`) are raw ArangoSearch view configuration files +* **[Collections, or document schemas,](spec/schemas)** are [JSON schemas](https://json-schema.org/) that define what form of data can be stored in the database's collections. +* **[Data sources](spec/data_sources)** contain general information about where some of our imported data comes from. +* **[Views](spec/views)** are raw ArangoSearch view configuration files ## Development ### Running tests -Run tests with `make test`. +Tests are located in the [spec/tests](spec/tests) directory, and are run as part of the test suite triggered by `scripts/run_tests.sh`. diff --git a/test/__init__.py b/spec/test/__init__.py similarity index 100% rename from test/__init__.py rename to spec/test/__init__.py diff --git a/test/djornl/col_count_errors/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv b/spec/test/djornl/col_count_errors/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv similarity index 100% rename from test/djornl/col_count_errors/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv rename to spec/test/djornl/col_count_errors/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv diff --git a/test/djornl/col_count_errors/merged_edges-AMW-060820_AF.tsv b/spec/test/djornl/col_count_errors/merged_edges-AMW-060820_AF.tsv similarity index 100% rename from test/djornl/col_count_errors/merged_edges-AMW-060820_AF.tsv rename to spec/test/djornl/col_count_errors/merged_edges-AMW-060820_AF.tsv diff --git a/test/djornl/empty_files/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv b/spec/test/djornl/empty_files/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv similarity index 100% rename from test/djornl/empty_files/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv rename to spec/test/djornl/empty_files/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv diff --git a/test/djornl/empty_files/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I2_named.tsv b/spec/test/djornl/empty_files/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I2_named.tsv similarity index 100% rename from test/djornl/empty_files/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I2_named.tsv rename to spec/test/djornl/empty_files/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I2_named.tsv diff --git a/test/djornl/empty_files/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I4_named.tsv b/spec/test/djornl/empty_files/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I4_named.tsv similarity index 100% rename from test/djornl/empty_files/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I4_named.tsv rename to spec/test/djornl/empty_files/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I4_named.tsv diff --git a/test/djornl/empty_files/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I6_named.tsv b/spec/test/djornl/empty_files/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I6_named.tsv similarity index 100% rename from test/djornl/empty_files/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I6_named.tsv rename to spec/test/djornl/empty_files/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I6_named.tsv diff --git a/test/djornl/empty_files/merged_edges-AMW-060820_AF.tsv b/spec/test/djornl/empty_files/merged_edges-AMW-060820_AF.tsv similarity index 100% rename from test/djornl/empty_files/merged_edges-AMW-060820_AF.tsv rename to spec/test/djornl/empty_files/merged_edges-AMW-060820_AF.tsv diff --git a/test/djornl/invalid_types/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv b/spec/test/djornl/invalid_types/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv similarity index 100% rename from test/djornl/invalid_types/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv rename to spec/test/djornl/invalid_types/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv diff --git a/test/djornl/invalid_types/merged_edges-AMW-060820_AF.tsv b/spec/test/djornl/invalid_types/merged_edges-AMW-060820_AF.tsv similarity index 100% rename from test/djornl/invalid_types/merged_edges-AMW-060820_AF.tsv rename to spec/test/djornl/invalid_types/merged_edges-AMW-060820_AF.tsv diff --git a/test/djornl/results.json b/spec/test/djornl/results.json similarity index 100% rename from test/djornl/results.json rename to spec/test/djornl/results.json diff --git a/test/djornl/test_data/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv b/spec/test/djornl/test_data/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv similarity index 100% rename from test/djornl/test_data/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv rename to spec/test/djornl/test_data/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv diff --git a/test/djornl/test_data/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I2_named.tsv b/spec/test/djornl/test_data/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I2_named.tsv similarity index 100% rename from test/djornl/test_data/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I2_named.tsv rename to spec/test/djornl/test_data/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I2_named.tsv diff --git a/test/djornl/test_data/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I4_named.tsv b/spec/test/djornl/test_data/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I4_named.tsv similarity index 100% rename from test/djornl/test_data/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I4_named.tsv rename to spec/test/djornl/test_data/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I4_named.tsv diff --git a/test/djornl/test_data/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I6_named.tsv b/spec/test/djornl/test_data/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I6_named.tsv similarity index 100% rename from test/djornl/test_data/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I6_named.tsv rename to spec/test/djornl/test_data/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I6_named.tsv diff --git a/test/djornl/test_data/merged_edges-AMW-060820_AF.tsv b/spec/test/djornl/test_data/merged_edges-AMW-060820_AF.tsv similarity index 100% rename from test/djornl/test_data/merged_edges-AMW-060820_AF.tsv rename to spec/test/djornl/test_data/merged_edges-AMW-060820_AF.tsv diff --git a/test/helpers.py b/spec/test/helpers.py similarity index 100% rename from test/helpers.py rename to spec/test/helpers.py diff --git a/test/mock_services/mock_auth/admin.json b/spec/test/mock_services/mock_auth/admin.json similarity index 100% rename from test/mock_services/mock_auth/admin.json rename to spec/test/mock_services/mock_auth/admin.json diff --git a/test/mock_services/mock_auth/invalid.json b/spec/test/mock_services/mock_auth/invalid.json similarity index 100% rename from test/mock_services/mock_auth/invalid.json rename to spec/test/mock_services/mock_auth/invalid.json diff --git a/test/mock_services/mock_auth/invalid2.json b/spec/test/mock_services/mock_auth/invalid2.json similarity index 100% rename from test/mock_services/mock_auth/invalid2.json rename to spec/test/mock_services/mock_auth/invalid2.json diff --git a/test/mock_services/mock_auth/valid.json b/spec/test/mock_services/mock_auth/valid.json similarity index 100% rename from test/mock_services/mock_auth/valid.json rename to spec/test/mock_services/mock_auth/valid.json diff --git a/test/mock_services/mock_workspace/list_workspace_ids_admin.json b/spec/test/mock_services/mock_workspace/list_workspace_ids_admin.json similarity index 100% rename from test/mock_services/mock_workspace/list_workspace_ids_admin.json rename to spec/test/mock_services/mock_workspace/list_workspace_ids_admin.json diff --git a/test/mock_services/mock_workspace/list_workspace_ids_invalid1.json b/spec/test/mock_services/mock_workspace/list_workspace_ids_invalid1.json similarity index 100% rename from test/mock_services/mock_workspace/list_workspace_ids_invalid1.json rename to spec/test/mock_services/mock_workspace/list_workspace_ids_invalid1.json diff --git a/test/mock_services/mock_workspace/list_workspace_ids_valid.json b/spec/test/mock_services/mock_workspace/list_workspace_ids_valid.json similarity index 100% rename from test/mock_services/mock_workspace/list_workspace_ids_valid.json rename to spec/test/mock_services/mock_workspace/list_workspace_ids_valid.json diff --git a/test/stored_queries/__init__.py b/spec/test/stored_queries/__init__.py similarity index 100% rename from test/stored_queries/__init__.py rename to spec/test/stored_queries/__init__.py diff --git a/test/stored_queries/test_djornl.py b/spec/test/stored_queries/test_djornl.py similarity index 91% rename from test/stored_queries/test_djornl.py rename to spec/test/stored_queries/test_djornl.py index d616d577..d22f85b0 100644 --- a/test/stored_queries/test_djornl.py +++ b/spec/test/stored_queries/test_djornl.py @@ -2,18 +2,15 @@ Tests for the Dan Jacobson ORNL Arabidopsis stored queries. """ import json -import time import unittest import requests import os -import glob -import yaml -from test.helpers import get_config, modified_environ, create_test_docs +from spec.test.helpers import get_config, modified_environ, create_test_docs from importers.djornl.parser import DJORNL_Parser _CONF = get_config() -_TEST_DIR = '/app/test' +_TEST_DIR = '/app/spec/test' _VERBOSE = 0 @@ -57,7 +54,6 @@ def setUpClass(cls): r = create_test_docs(config['_NODE_NAME'], cluster_data['nodes'], True) print_db_update(r, config['_NODE_NAME']) - def submit_query(self, query_name, query_data={}): """submit a database query""" @@ -69,10 +65,8 @@ def submit_query(self, query_name, query_data={}): params={'stored_query': query_name}, data=q_data_str ).json() - return response - def check_expected_results(self, description, response, expected): if _VERBOSE: @@ -88,27 +82,14 @@ def check_expected_results(self, description, response, expected): set(expected['edges']) ) - def test_fetch_all(self): - # expect all the nodes from load_node_metadata and all the edges from load_edges - expected = { - "nodes": [n["_key"] for n in self.json_data['load_node_metadata']['nodes']], - "edges": [ { - "_to": e["_to"], - "_from": e["_from"], - "score": e["score"], - "edge_type": e["edge_type"] } for e in self.json_data['load_edges']['edges'] - ] - } - self.check_expected_results( "djornl_fetch_all", self.submit_query('djornl_fetch_all'), self.json_data['fetch_all'] ) - # indexing schema in results.json # self.json_data[query][primary_param][distance_param] # if primary_param is an array, join the array entities with "__" @@ -124,7 +105,6 @@ def test_fetch_phenotypes_no_results(self): }) self.assertEqual(resp['results'][0], self.no_results) - def test_fetch_phenotypes(self): for fetch_args in self.json_data['fetch_phenotypes'].keys(): @@ -139,7 +119,6 @@ def test_fetch_phenotypes(self): self.json_data['fetch_phenotypes'][fetch_args][distance] ) - def test_fetch_genes_no_results(self): resp = self.submit_query('djornl_fetch_genes', { # phenotype node @@ -147,7 +126,6 @@ def test_fetch_genes_no_results(self): }) self.assertEqual(resp['results'][0], self.no_results) - def test_fetch_genes(self): for fetch_args in self.json_data['fetch_genes'].keys(): @@ -162,7 +140,6 @@ def test_fetch_genes(self): self.json_data['fetch_genes'][fetch_args][distance] ) - def test_fetch_clusters_no_results(self): resp = self.submit_query('djornl_fetch_clusters', { @@ -172,7 +149,6 @@ def test_fetch_clusters_no_results(self): }) self.assertEqual(resp['results'][0], self.no_results) - def test_fetch_clusters(self): for fetch_args in self.json_data['fetch_clusters'].keys(): diff --git a/test/stored_queries/test_list_test_vertices.py b/spec/test/stored_queries/test_list_test_vertices.py similarity index 94% rename from test/stored_queries/test_list_test_vertices.py rename to spec/test/stored_queries/test_list_test_vertices.py index 1234423d..2368168a 100644 --- a/test/stored_queries/test_list_test_vertices.py +++ b/spec/test/stored_queries/test_list_test_vertices.py @@ -1,9 +1,8 @@ -import json import unittest import requests import time -from test.helpers import create_test_docs, get_config +from spec.test.helpers import create_test_docs, get_config _CONF = get_config() _QUERY_URL = _CONF['re_api_url'] + '/api/v1/query_results?view=list_test_vertices' @@ -18,7 +17,7 @@ def setUpClass(cls): api_up = False while not api_up: try: - requests.get('http://re_api:5000').raise_for_status() + requests.get('http://127.0.0.1:5000').raise_for_status() requests.get('http://auth:5000') requests.get('http://workspace:5000') api_up = True diff --git a/test/stored_queries/test_ncbi_tax.py b/spec/test/stored_queries/test_ncbi_tax.py similarity index 99% rename from test/stored_queries/test_ncbi_tax.py rename to spec/test/stored_queries/test_ncbi_tax.py index 5fc6f2a8..9ea7a8f2 100644 --- a/test/stored_queries/test_ncbi_tax.py +++ b/spec/test/stored_queries/test_ncbi_tax.py @@ -6,7 +6,7 @@ import unittest import requests -from test.helpers import get_config, assert_subset, create_test_docs +from spec.test.helpers import get_config, assert_subset, create_test_docs _CONF = get_config() _NOW = int(time.time() * 1000) diff --git a/test/stored_queries/test_taxonomy.py b/spec/test/stored_queries/test_taxonomy.py similarity index 99% rename from test/stored_queries/test_taxonomy.py rename to spec/test/stored_queries/test_taxonomy.py index 32fa2588..76ac1e3e 100644 --- a/test/stored_queries/test_taxonomy.py +++ b/spec/test/stored_queries/test_taxonomy.py @@ -6,7 +6,7 @@ import unittest import requests -from test.helpers import get_config, assert_subset, create_test_docs +from spec.test.helpers import get_config, assert_subset, create_test_docs _CONF = get_config() _NOW = int(time.time() * 1000) @@ -191,7 +191,6 @@ def test_siblings_nonexistent_node(self): def test_search_sci_name_no_count(self): """Test a valid query to search sciname without a count.""" - start = time.time() resp = requests.post( _CONF['re_api_url'] + '/api/v1/query_results', params={'stored_query': 'taxonomy_search_sci_name'}, diff --git a/test/stored_queries/test_ws.py b/spec/test/stored_queries/test_ws.py similarity index 98% rename from test/stored_queries/test_ws.py rename to spec/test/stored_queries/test_ws.py index 197e88e0..d5a726a8 100644 --- a/test/stored_queries/test_ws.py +++ b/spec/test/stored_queries/test_ws.py @@ -4,7 +4,7 @@ import unittest import json import requests -from test.helpers import get_config, create_test_docs +from spec.test.helpers import get_config, create_test_docs _CONF = get_config() diff --git a/src/tox.ini b/spec/test/tox.ini similarity index 100% rename from src/tox.ini rename to spec/test/tox.ini diff --git a/test/validate.py b/spec/test/validate.py similarity index 99% rename from test/validate.py rename to spec/test/validate.py index e5ac73d7..e5b8329a 100644 --- a/test/validate.py +++ b/spec/test/validate.py @@ -10,7 +10,7 @@ import json from jsonschema.exceptions import ValidationError -from test.helpers import get_config, wait_for_arangodb +from spec.test.helpers import get_config, wait_for_arangodb _CONF = get_config() _BASE_DIR = '/app/spec' diff --git a/test/tox.ini b/tox.ini similarity index 100% rename from test/tox.ini rename to tox.ini From d3e0771466eb2852ca9d9bcf4280eb5434b63a87 Mon Sep 17 00:00:00 2001 From: ialarmedalien Date: Fri, 31 Jul 2020 12:11:03 -0700 Subject: [PATCH 544/732] Consolidating all JSON validation functions into relation_engine_server.utils.json_validation, and moving all the "wait_for..." code into relation_engine_server.utils.wait_for. --- relation_engine_server/test/test_api_v1.py | 5 ++ ...{test_utils.py => test_json_validation.py} | 8 +- relation_engine_server/test/wait_for_api.py | 23 ----- .../utils/json_validation.py | 41 ++++++++- relation_engine_server/utils/wait_for.py | 89 +++++++++++++++++++ relation_engine_server/wait_for_services.py | 31 ------- scripts/run_tests.sh | 1 - scripts/start_server.sh | 2 +- spec/collection_schema.yaml | 13 +++ spec/stored_query_schema.yaml | 12 +++ spec/test/helpers.py | 68 +++++--------- spec/test/stored_queries/test_djornl.py | 15 ++-- .../stored_queries/test_list_test_vertices.py | 17 +--- spec/test/stored_queries/test_ncbi_tax.py | 4 + spec/test/stored_queries/test_taxonomy.py | 3 + spec/test/stored_queries/test_ws.py | 4 + spec/test/tox.ini | 2 - spec/test/validate.py | 3 +- spec/view_schema.yaml | 11 +++ 19 files changed, 216 insertions(+), 136 deletions(-) rename relation_engine_server/test/{test_utils.py => test_json_validation.py} (62%) delete mode 100644 relation_engine_server/test/wait_for_api.py create mode 100644 relation_engine_server/utils/wait_for.py delete mode 100644 relation_engine_server/wait_for_services.py create mode 100644 spec/collection_schema.yaml create mode 100644 spec/stored_query_schema.yaml delete mode 100644 spec/test/tox.ini create mode 100644 spec/view_schema.yaml diff --git a/relation_engine_server/test/test_api_v1.py b/relation_engine_server/test/test_api_v1.py index 41bbabe2..ff0f5ffd 100644 --- a/relation_engine_server/test/test_api_v1.py +++ b/relation_engine_server/test/test_api_v1.py @@ -9,6 +9,7 @@ import os from relation_engine_server.utils.config import get_config +from relation_engine_server.utils.wait_for import wait_for_api _CONF = get_config() @@ -57,6 +58,10 @@ def save_test_docs(count, edges=False): class TestApi(unittest.TestCase): + @classmethod + def setUpClass(cls): + wait_for_api() + def test_root(self): """Test root path for api.""" resp = requests.get(URL + '/').json() diff --git a/relation_engine_server/test/test_utils.py b/relation_engine_server/test/test_json_validation.py similarity index 62% rename from relation_engine_server/test/test_utils.py rename to relation_engine_server/test/test_json_validation.py index ac8ece7c..c926498d 100644 --- a/relation_engine_server/test/test_utils.py +++ b/relation_engine_server/test/test_json_validation.py @@ -1,8 +1,7 @@ """ -Test utility functions +Test JSON validation functions """ -from relation_engine_server.utils import json_validation - +from relation_engine_server.utils.json_validation import run_validator import unittest @@ -11,6 +10,5 @@ class TestUtils(unittest.TestCase): def test_json_validation_defaults(self): """Test that the jsonschema validator sets default values.""" schema = {'properties': {'foo': {'default': 'bar'}}} - obj = {} # type: dict - json_validation.Validator(schema).validate(obj) + obj = run_validator(data={}, schema=schema) self.assertEqual(obj, {'foo': 'bar'}) diff --git a/relation_engine_server/test/wait_for_api.py b/relation_engine_server/test/wait_for_api.py deleted file mode 100644 index 9a74eb85..00000000 --- a/relation_engine_server/test/wait_for_api.py +++ /dev/null @@ -1,23 +0,0 @@ -""" -Block until the api starts up -""" -import requests -import time - - -def main(): - timeout = int(time.time()) + 60 - while True: - try: - requests.get('http://localhost:5000').raise_for_status() - break - except Exception: - print('Waiting for app to start..') - if int(time.time()) > timeout: - raise RuntimeError('Timed out waiting for services.') - time.sleep(3) - print('Services started!') - - -if __name__ == '__main__': - main() diff --git a/relation_engine_server/utils/json_validation.py b/relation_engine_server/utils/json_validation.py index 8ee085f7..c604f29f 100644 --- a/relation_engine_server/utils/json_validation.py +++ b/relation_engine_server/utils/json_validation.py @@ -10,7 +10,9 @@ Validator(schema).validate(obj) assert obj == {'foo': 'bar'} """ -from jsonschema import validators, Draft7Validator +from jsonschema import validators, Draft7Validator, FormatChecker +import yaml +import json def extend_with_default(validator_class): @@ -26,3 +28,40 @@ def set_defaults(validator, properties, instance, schema): Validator = extend_with_default(Draft7Validator) + + +def run_validator(schema=None, schema_file=None, data=None, data_file=None, validate_at=None): + + if schema is None and schema_file is None: + raise ValueError("Please supply either a schema or a schema file path") + + if data is None and data_file is None: + raise ValueError("Please supply either a data structure or a data file path") + + # data to validate + if data_file: + data = _load_json_schema(data_file) + + # schema to validate against + if schema_file: + schema = _load_json_schema(schema_file) + + if validate_at: + schema = schema[validate_at[0]] + + Validator(schema, format_checker=FormatChecker()).validate(data) + + return data + + +def _load_json_schema(file): + """ Loads the given schema file """ + + with open(file) as fd: + if file.endswith('.yaml') or file.endswith('.yml'): + return yaml.safe_load(fd) + + if file.endswith('.json'): + return json.load(fd) + + raise TypeError('Unknown file type encountered: ' + file) diff --git a/relation_engine_server/utils/wait_for.py b/relation_engine_server/utils/wait_for.py new file mode 100644 index 00000000..3757b1a8 --- /dev/null +++ b/relation_engine_server/utils/wait_for.py @@ -0,0 +1,89 @@ +""" +Block until all dependent services come online. +""" +import requests +import time +import sys +from .config import get_config + +_CONF = get_config() + + +def wait_for_service(service_list): + '''wait for a service or list of services to start up''' + timeout = int(time.time()) + 60 + + service_conf_list = [get_service_conf(s) for s in service_list] + + while True: + try: + for service in service_conf_list: + name = service['name'] + url = service['url'] + if service['auth'] is not None: + requests.get(service['url'], auth=service['auth']).raise_for_status() + else: + requests.get(service['url']) + break + except Exception: + print(f"Waiting for {name} to start...") + if int(time.time()) > timeout: + raise RuntimeError(f"Timed out waiting for {name}, {url}") + time.sleep(3) + print(f"{name} started!") + + +def get_service_conf(service_name): + + service_conf = { + 'arangodb': { + 'url': _CONF['db_url'] + '/_admin/cluster/health', + # server auth credentials + 'auth': (_CONF['db_user'], _CONF['db_pass']), + }, + 'auth': { + 'url': _CONF['auth_url'], + }, + 'workspace': { + 'url': _CONF['workspace_url'], + }, + 'localhost': { + 'url': 'http://127.0.0.1:5000', + } + } + + if service_name not in service_conf: + raise KeyError(f'Configuration for {service_name} not found') + + return { + 'name': service_name, + # auth defaults to None if there is nothing set + 'auth': service_conf[service_name].get('auth'), + 'url': service_conf[service_name]['url'], + } + + +def wait_for_arangodb(): + '''wait for arangodb to be ready''' + + wait_for_service(['arangodb']) + + +def wait_for_services(): + '''wait for the workspace, auth, and arango to start up''' + + wait_for_service(['auth', 'workspace', 'arangodb']) + + +def wait_for_api(): + '''wait for the workspace, auth, arango, AND localhost:5000 to start up''' + + wait_for_services() + wait_for_service(['localhost']) + + +if __name__ == '__main__': + if sys.argv[1] == 'services': + wait_for_services() + elif sys.argv[1] == 'api': + wait_for_api() diff --git a/relation_engine_server/wait_for_services.py b/relation_engine_server/wait_for_services.py deleted file mode 100644 index 51a9a546..00000000 --- a/relation_engine_server/wait_for_services.py +++ /dev/null @@ -1,31 +0,0 @@ -""" -Block until all dependency services (arango, workspace, auth) to come online. -""" -import requests -import time - -from .utils.config import get_config - -_CONFIG = get_config() - - -def main(): - timeout = int(time.time()) + 60 - adb_url = f"{_CONFIG['api_url']}/version" - while True: - try: - requests.get(_CONFIG['workspace_url']) - requests.get(_CONFIG['auth_url']) - auth = (_CONFIG['db_user'], _CONFIG['db_pass']) - requests.get(adb_url, auth=auth).raise_for_status() - break - except Exception: - print('Waiting for services..') - if int(time.time()) > timeout: - raise RuntimeError('Timed out waiting for services.') - time.sleep(3) - print('Services started!') - - -if __name__ == '__main__': - main() diff --git a/scripts/run_tests.sh b/scripts/run_tests.sh index 829d1d30..d5b45ad6 100644 --- a/scripts/run_tests.sh +++ b/scripts/run_tests.sh @@ -10,7 +10,6 @@ mkdir /spec/repo cp -r /app/spec/* /spec/repo/ # start server, using the specs in /spec/repo sh /app/scripts/start_server.sh & -python -m spec.test.helpers wait_for_api && # spec validation python -m spec.test.validate && # spec stored query tests diff --git a/scripts/start_server.sh b/scripts/start_server.sh index 4bd39aaa..71e06535 100644 --- a/scripts/start_server.sh +++ b/scripts/start_server.sh @@ -7,7 +7,7 @@ calc_workers="$(($(nproc) * 2 + 1))" # Use the WORKERS environment variable, if present workers=${WORKERS:-$calc_workers} -python -m relation_engine_server.wait_for_services +python -m relation_engine_server.utils.wait_for services python -m relation_engine_server.utils.pull_spec gunicorn \ diff --git a/spec/collection_schema.yaml b/spec/collection_schema.yaml new file mode 100644 index 00000000..c60a4af3 --- /dev/null +++ b/spec/collection_schema.yaml @@ -0,0 +1,13 @@ +name: collection_schema +type: object +required: ['name', 'type', 'schema'] +properties: + name: + type: string + title: Collection name + format: ^\w+$ + type: + type: string + enum: ['vertex', 'edge'] + schema: + type: object diff --git a/spec/stored_query_schema.yaml b/spec/stored_query_schema.yaml new file mode 100644 index 00000000..d8a03717 --- /dev/null +++ b/spec/stored_query_schema.yaml @@ -0,0 +1,12 @@ +name: stored_query_schema +type: object +required: ['query', 'name'] +properties: + name: + type: string + params: + type: object + query_prefix: + type: string + query: + type: string diff --git a/spec/test/helpers.py b/spec/test/helpers.py index 83f14737..4b72c66f 100644 --- a/spec/test/helpers.py +++ b/spec/test/helpers.py @@ -1,9 +1,7 @@ """ Test helpers """ -import sys import os -import time import requests import functools import contextlib @@ -15,53 +13,22 @@ def get_config(): """Return configuration data for tests.""" return { 're_api_url': os.environ['RE_API_URL'], + 're_query_results_url': os.environ['RE_API_URL'] + '/api/v1/query_results', 'db_url': os.environ['DB_URL'], 'db_auth': (os.environ['DB_USER'], os.environ.get('DB_PASS', '')) } -def wait_for_arangodb(): - """Wait for arangodb to go live.""" - conf = get_config() - db_url = conf['db_url'] - auth = ('root', '') - timeout = time.time() + 60 - while True: - try: - resp = requests.get(db_url + '/_admin/cluster/health', auth=auth) - resp.raise_for_status() - break - except Exception as err: - print('Waiting for arangodb to come online') - if time.time() > timeout: - sys.stderr.write(str(err) + '\n') - raise RuntimeError('Timed out waiting for arangodb') - time.sleep(3) - - -def wait_for_api(): - wait_for_arangodb() - # Wait for other dependent services to come online - conf = get_config() - timeout = int(time.time()) + 60 - auth_url = 'http://auth:5000' - ws_url = 'http://workspace:5000' - while True: - try: - # Reassign the `url` variable so we can print which service errored - url = conf['re_api_url'] - requests.get(url).raise_for_status() - url = auth_url - requests.get(url) - url = ws_url - requests.get(url) - break - except Exception as err: - print(f"Waiting for dependent service to come online: {url}") - if int(time.time()) > timeout: - sys.stderr.write(str(err) + "\n") - raise RuntimeError(f"Timed out waiting for {url}") - time.sleep(2) +def run_query(query_name, query_data={}): + """submit a database query""" + + query_results_url = os.environ['RE_API_URL'] + '/api/v1/query_results' + + return requests.post( + query_results_url, + params={'stored_query': query_name}, + data=json.dumps(query_data) + ).json() def assert_subset(testCls, subset, _dict): @@ -124,6 +91,13 @@ def modified_environ(*remove, **update): [env.pop(k) for k in remove_after] -if __name__ == '__main__': - if sys.argv[1] == 'wait_for_api': - wait_for_api() +# def update_specs(): +# """Test the endpoint that triggers an update on the specs.""" +# resp = requests.put( +# conf['re_api_url'] + '/api/v1/specs', +# headers={'Authorization': 'admin_token'}, +# params={'reset': '1', 'init_collections': '1'} +# ) +# resp_json = resp.json() +# self.assertEqual(resp.status_code, 200) +# self.assertTrue(len(resp_json['status'])) diff --git a/spec/test/stored_queries/test_djornl.py b/spec/test/stored_queries/test_djornl.py index d22f85b0..98250993 100644 --- a/spec/test/stored_queries/test_djornl.py +++ b/spec/test/stored_queries/test_djornl.py @@ -3,11 +3,11 @@ """ import json import unittest -import requests import os -from spec.test.helpers import get_config, modified_environ, create_test_docs +from spec.test.helpers import get_config, modified_environ, create_test_docs, run_query from importers.djornl.parser import DJORNL_Parser +from relation_engine_server.utils.wait_for import wait_for_api _CONF = get_config() _TEST_DIR = '/app/spec/test' @@ -27,6 +27,7 @@ class Test_DJORNL_Stored_Queries(unittest.TestCase): @classmethod def setUpClass(cls): + wait_for_api() # import the results file results_file = os.path.join(_TEST_DIR, 'djornl', 'results.json') with open(results_file) as fh: @@ -57,15 +58,11 @@ def setUpClass(cls): def submit_query(self, query_name, query_data={}): """submit a database query""" - q_data_str = json.dumps(query_data) if _VERBOSE: + q_data_str = json.dumps(query_data) print('query data string: ' + q_data_str) - response = requests.post( - _CONF['re_api_url'] + '/api/v1/query_results', - params={'stored_query': query_name}, - data=q_data_str - ).json() - return response + + return run_query(query_name, query_data) def check_expected_results(self, description, response, expected): diff --git a/spec/test/stored_queries/test_list_test_vertices.py b/spec/test/stored_queries/test_list_test_vertices.py index 2368168a..796db4c0 100644 --- a/spec/test/stored_queries/test_list_test_vertices.py +++ b/spec/test/stored_queries/test_list_test_vertices.py @@ -1,8 +1,8 @@ import unittest import requests -import time from spec.test.helpers import create_test_docs, get_config +from relation_engine_server.utils.wait_for import wait_for_api _CONF = get_config() _QUERY_URL = _CONF['re_api_url'] + '/api/v1/query_results?view=list_test_vertices' @@ -13,20 +13,7 @@ class TestListTestVertices(unittest.TestCase): @classmethod def setUpClass(cls): # Wait for the API to come online - timeout = int(time.time()) + 60 - api_up = False - while not api_up: - try: - requests.get('http://127.0.0.1:5000').raise_for_status() - requests.get('http://auth:5000') - requests.get('http://workspace:5000') - api_up = True - except Exception as err: - print(err) - print('Waiting for RE API to come online..') - if int(time.time()) > timeout: - raise RuntimeError("Timed out waiting for RE API.") - time.sleep(2) + wait_for_api() def test_valid(self): """Test a valid query.""" diff --git a/spec/test/stored_queries/test_ncbi_tax.py b/spec/test/stored_queries/test_ncbi_tax.py index 9ea7a8f2..759aa4ed 100644 --- a/spec/test/stored_queries/test_ncbi_tax.py +++ b/spec/test/stored_queries/test_ncbi_tax.py @@ -7,6 +7,7 @@ import requests from spec.test.helpers import get_config, assert_subset, create_test_docs +from relation_engine_server.utils.wait_for import wait_for_api _CONF = get_config() _NOW = int(time.time() * 1000) @@ -17,6 +18,9 @@ class TestNcbiTax(unittest.TestCase): @classmethod def setUpClass(cls): """Create test documents""" + + wait_for_api() + taxon_docs = [ {'_key': '1', 'scientific_name': 'Bacteria', 'rank': 'Domain', 'strain': False}, {'_key': '2', 'scientific_name': 'Firmicutes', 'rank': 'Phylum', 'strain': False}, diff --git a/spec/test/stored_queries/test_taxonomy.py b/spec/test/stored_queries/test_taxonomy.py index 76ac1e3e..9d67b921 100644 --- a/spec/test/stored_queries/test_taxonomy.py +++ b/spec/test/stored_queries/test_taxonomy.py @@ -7,6 +7,7 @@ import requests from spec.test.helpers import get_config, assert_subset, create_test_docs +from relation_engine_server.utils.wait_for import wait_for_api _CONF = get_config() _NOW = int(time.time() * 1000) @@ -17,6 +18,8 @@ class TestTaxonomy(unittest.TestCase): @classmethod def setUpClass(cls): """Create test documents""" + + wait_for_api() taxon_docs = [ {'_key': '1', 'scientific_name': 'Bacteria', 'rank': 'Domain', 'strain': False}, {'_key': '2', 'scientific_name': 'Firmicutes', 'rank': 'Phylum', 'strain': False}, diff --git a/spec/test/stored_queries/test_ws.py b/spec/test/stored_queries/test_ws.py index d5a726a8..a3cf800b 100644 --- a/spec/test/stored_queries/test_ws.py +++ b/spec/test/stored_queries/test_ws.py @@ -5,6 +5,7 @@ import json import requests from spec.test.helpers import get_config, create_test_docs +from relation_engine_server.utils.wait_for import wait_for_api _CONF = get_config() @@ -32,6 +33,9 @@ def setUpClass(cls): """ Create all test data. """ + + wait_for_api() + ws_object_version = [ _ws_obj(1, 1, 1), # root/origin object _ws_obj(1, 2, 1), # copy object diff --git a/spec/test/tox.ini b/spec/test/tox.ini deleted file mode 100644 index 6deafc26..00000000 --- a/spec/test/tox.ini +++ /dev/null @@ -1,2 +0,0 @@ -[flake8] -max-line-length = 120 diff --git a/spec/test/validate.py b/spec/test/validate.py index e5b8329a..994ad139 100644 --- a/spec/test/validate.py +++ b/spec/test/validate.py @@ -10,7 +10,8 @@ import json from jsonschema.exceptions import ValidationError -from spec.test.helpers import get_config, wait_for_arangodb +from spec.test.helpers import get_config +from relation_engine_server.utils.wait_for import wait_for_arangodb _CONF = get_config() _BASE_DIR = '/app/spec' diff --git a/spec/view_schema.yaml b/spec/view_schema.yaml new file mode 100644 index 00000000..79b7caa4 --- /dev/null +++ b/spec/view_schema.yaml @@ -0,0 +1,11 @@ +name: view_schema +type: object +required: ['name', 'type'] +properties: + name: + type: string + title: View name + format: ^\\w+$ + type: + type: string + enum: ['arangosearch'] From f8aff091f132e91ea112390bb0ee775700a27e66 Mon Sep 17 00:00:00 2001 From: ialarmedalien Date: Fri, 31 Jul 2020 12:17:40 -0700 Subject: [PATCH 545/732] Adding self to codeowners, removing comments --- CODEOWNERS | 2 +- spec/test/helpers.py | 12 ------------ 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/CODEOWNERS b/CODEOWNERS index d371bfb1..d70d24cd 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -1,3 +1,3 @@ -* @jayrbolton +* @jayrbolton @ialarmedalien relation_engine_server/* @jayrbolton @slebras diff --git a/spec/test/helpers.py b/spec/test/helpers.py index 4b72c66f..e432c790 100644 --- a/spec/test/helpers.py +++ b/spec/test/helpers.py @@ -89,15 +89,3 @@ def modified_environ(*remove, **update): finally: env.update(update_after) [env.pop(k) for k in remove_after] - - -# def update_specs(): -# """Test the endpoint that triggers an update on the specs.""" -# resp = requests.put( -# conf['re_api_url'] + '/api/v1/specs', -# headers={'Authorization': 'admin_token'}, -# params={'reset': '1', 'init_collections': '1'} -# ) -# resp_json = resp.json() -# self.assertEqual(resp.status_code, 200) -# self.assertTrue(len(resp_json['status'])) From 48e71edcd0b1ad21f5db190aedbc7c232d860f3b Mon Sep 17 00:00:00 2001 From: ialarmedalien Date: Wed, 5 Aug 2020 12:12:14 -0700 Subject: [PATCH 546/732] Moving spec validation module up a level to the /spec dir; adding tests; adding a test file for the validate.py module. Refactoring validate.py somewhat to reduce redundant checks. --- relation_engine_server/api_versions/api_v1.py | 7 +- relation_engine_server/main.py | 6 +- .../test/test_json_validation.py | 122 ++++++++++- relation_engine_server/utils/arango_client.py | 2 +- relation_engine_server/utils/auth.py | 4 +- relation_engine_server/utils/bulk_import.py | 9 +- .../utils/json_validation.py | 81 ++++++- relation_engine_server/utils/pull_spec.py | 4 +- relation_engine_server/utils/spec_loader.py | 2 +- relation_engine_server/utils/wait_for.py | 3 +- requirements.txt | 2 + scripts/run_tests.sh | 2 +- spec/collection_schema.yaml | 38 +++- spec/data_source_schema.yaml | 27 +++ spec/data_sources/djornl.yaml | 5 + spec/stored_query_schema.yaml | 5 + spec/test/helpers.py | 19 +- .../edge_delta_missing_to_from.yaml | 14 ++ .../collections/edge_missing_to_from.yaml | 12 ++ .../collections/extra_top_level_entries.yaml | 13 ++ .../collections/not_a_schema.yaml | 6 + .../collections/schema_not_object.yaml | 4 + .../sample_schemas/collections/test_edge.yaml | 10 + .../collections/test_vertex.yaml | 11 + .../collections/vertex_missing_id.yaml | 13 ++ .../collections/vertex_missing_key.yaml | 13 ++ .../collections/wrong_name.yaml | 12 ++ .../invalid_additional_property.json | 6 + .../sample_schemas/data_sources/minimal.yaml | 3 + .../data_sources/uri_validation.json | 6 + .../stored_queries/invalid_aql.yaml | 27 +++ .../stored_queries/invalid_bind_params.yaml | 32 +++ .../stored_queries/params_not_object.yaml | 3 + spec/test/sample_schemas/views/minimal.json | 4 + .../test/sample_schemas/views/wrong_type.json | 4 + spec/test/test_validate.py | 177 ++++++++++++++++ spec/test/validate.py | 198 ----------------- spec/validate.py | 199 ++++++++++++++++++ spec/view_schema.yaml | 3 +- 39 files changed, 869 insertions(+), 239 deletions(-) create mode 100644 spec/data_source_schema.yaml create mode 100644 spec/data_sources/djornl.yaml create mode 100644 spec/test/sample_schemas/collections/edge_delta_missing_to_from.yaml create mode 100644 spec/test/sample_schemas/collections/edge_missing_to_from.yaml create mode 100644 spec/test/sample_schemas/collections/extra_top_level_entries.yaml create mode 100644 spec/test/sample_schemas/collections/not_a_schema.yaml create mode 100644 spec/test/sample_schemas/collections/schema_not_object.yaml create mode 100644 spec/test/sample_schemas/collections/test_edge.yaml create mode 100644 spec/test/sample_schemas/collections/test_vertex.yaml create mode 100644 spec/test/sample_schemas/collections/vertex_missing_id.yaml create mode 100644 spec/test/sample_schemas/collections/vertex_missing_key.yaml create mode 100644 spec/test/sample_schemas/collections/wrong_name.yaml create mode 100644 spec/test/sample_schemas/data_sources/invalid_additional_property.json create mode 100644 spec/test/sample_schemas/data_sources/minimal.yaml create mode 100644 spec/test/sample_schemas/data_sources/uri_validation.json create mode 100644 spec/test/sample_schemas/stored_queries/invalid_aql.yaml create mode 100644 spec/test/sample_schemas/stored_queries/invalid_bind_params.yaml create mode 100644 spec/test/sample_schemas/stored_queries/params_not_object.yaml create mode 100644 spec/test/sample_schemas/views/minimal.json create mode 100644 spec/test/sample_schemas/views/wrong_type.json create mode 100644 spec/test/test_validate.py delete mode 100644 spec/test/validate.py create mode 100644 spec/validate.py diff --git a/relation_engine_server/api_versions/api_v1.py b/relation_engine_server/api_versions/api_v1.py index 6d4a0779..7f85284b 100644 --- a/relation_engine_server/api_versions/api_v1.py +++ b/relation_engine_server/api_versions/api_v1.py @@ -1,6 +1,5 @@ import flask from relation_engine_server.utils import ( - json_validation, arango_client, spec_loader, load_data_sources, @@ -10,6 +9,7 @@ config, parse_json ) +from relation_engine_server.utils.json_validation import run_validator from relation_engine_server.exceptions import InvalidParameters api_v1 = flask.Blueprint('api_v1', __name__) @@ -78,7 +78,7 @@ def run_query(): 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): + 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 @@ -87,7 +87,8 @@ def run_query(): stored_query_source = _preprocess_stored_query(stored_query['query'], stored_query) if 'params' in stored_query: # Validate the user params for the query - json_validation.Validator(stored_query['params']).validate(json_body) + run_validator(schema=stored_query['params'], data=json_body) +# json_validation.Validator(stored_query['params']).validate(json_body) json_body['ws_ids'] = ws_ids resp_body = arango_client.run_query(query_text=stored_query_source, bind_vars=json_body, diff --git a/relation_engine_server/main.py b/relation_engine_server/main.py index 0a83467b..3a654151 100644 --- a/relation_engine_server/main.py +++ b/relation_engine_server/main.py @@ -6,9 +6,9 @@ import traceback from jsonschema.exceptions import ValidationError -from .api_versions.api_v1 import api_v1 -from .exceptions import MissingHeader, UnauthorizedAccess, InvalidParameters, NotFound -from .utils import arango_client, spec_loader +from relation_engine_server.api_versions.api_v1 import api_v1 +from relation_engine_server.exceptions import MissingHeader, UnauthorizedAccess, InvalidParameters, NotFound +from relation_engine_server.utils import arango_client, spec_loader app = flask.Flask(__name__) app.config['DEBUG'] = os.environ.get('FLASK_DEBUG', True) diff --git a/relation_engine_server/test/test_json_validation.py b/relation_engine_server/test/test_json_validation.py index c926498d..cc9b3571 100644 --- a/relation_engine_server/test/test_json_validation.py +++ b/relation_engine_server/test/test_json_validation.py @@ -1,14 +1,128 @@ """ Test JSON validation functions """ -from relation_engine_server.utils.json_validation import run_validator import unittest +from relation_engine_server.utils.json_validation import run_validator +from jsonschema.exceptions import ValidationError +from jsonpointer import JsonPointerException + + +test_schema = { + 'properties': { + 'params': { + 'type': 'object', + 'properties': { + 'name': { + 'type': 'string', + 'format': 'regex', + 'pattern': '^\\w+$', + 'default': 'blank', + }, + 'distance': { + 'type': 'integer', + 'minimum': 0, + 'maximum': 10, + 'default': 1, + }, + 'home_page': { + 'type': 'string', + 'format': 'uri', + }, + 'creation_date': { + 'type': 'string', + 'format': 'date', + } + } + } + } +} + +valid_json_loc = '/properties/params' class TestUtils(unittest.TestCase): + def test_non_validation_validator_errors(self): + '''test errors in the validator that are unrelated to the valiation functionality''' + + err_str = "Please supply either a schema or a schema file path" + with self.assertRaisesRegex(ValueError, err_str): + run_validator() + + with self.assertRaisesRegex(ValueError, err_str): + run_validator(data={}) + + # only supply one of schema or schema_file + with self.assertRaisesRegex(ValueError, err_str): + run_validator(schema={}, schema_file='/path/to/file') + + err_str = "Please supply either a data structure or a data file path" + with self.assertRaisesRegex(ValueError, err_str): + run_validator(schema={}) + + with self.assertRaisesRegex(ValueError, err_str): + run_validator(schema={}, data={}, data_file='') + + with self.assertRaisesRegex(ValueError, err_str): + run_validator(schema={}, data=None, data_file=None) + + # invalid jsonpointer string - note the grammar error is from jsonpointer + err_str = 'location must starts with /' + json_loc = 'start validating here' + with self.assertRaisesRegex(JsonPointerException, err_str): + run_validator(schema=test_schema, data={}, validate_at=json_loc) + + # invalid jsonpointer ref + err_str = "member 'property' not found in" + json_loc = '/properties/params/property' + with self.assertRaisesRegex(JsonPointerException, err_str): + run_validator(schema=test_schema, data={}, validate_at=json_loc) + + # finally!! + output = run_validator( + schema=test_schema, + data={'name': 'name', 'distance': 3}, + validate_at='/properties/params') + self.assertEqual(output, {'name': 'name', 'distance': 3}) + def test_json_validation_defaults(self): """Test that the jsonschema validator sets default values.""" - schema = {'properties': {'foo': {'default': 'bar'}}} - obj = run_validator(data={}, schema=schema) - self.assertEqual(obj, {'foo': 'bar'}) + + test_data = run_validator(schema=test_schema, data={}, validate_at=valid_json_loc) + self.assertEqual(test_data, {'name': 'blank', 'distance': 1}) + + def test_pattern_validation(self): + '''Test pattern validation''' + + # validation error - string does not match regex + err_str = "'Mr Blobby' does not match .*?" + with self.assertRaisesRegex(ValidationError, err_str): + run_validator( + schema=test_schema, + data={'name': 'Mr Blobby', 'distance': 3}, + validate_at=valid_json_loc) + + # this string is OK + output = run_validator( + schema=test_schema, + data={'name': 'Mr_Blobby_666', 'distance': 3}, + validate_at=valid_json_loc) + self.assertEqual(output, {'name': 'Mr_Blobby_666', 'distance': 3}) + + def test_date_format_validation(self): + '''ensure that fancy date formats are correctly validated''' + + err_str = "'12345678' is not a 'date'" + with self.assertRaisesRegex(ValidationError, err_str): + input = {'name': 'whatever', 'distance': 1, 'creation_date': '12345678'} + run_validator( + schema=test_schema, + data=input, + validate_at=valid_json_loc) + + input = {'name': 'whatever', 'distance': 1, 'creation_date': '2020-05-23'} + output = run_validator( + schema=test_schema, + data=input, + validate_at=valid_json_loc) + self.assertEqual(input, output) diff --git a/relation_engine_server/utils/arango_client.py b/relation_engine_server/utils/arango_client.py index 868128fa..ea75e47b 100644 --- a/relation_engine_server/utils/arango_client.py +++ b/relation_engine_server/utils/arango_client.py @@ -6,7 +6,7 @@ import requests import json -from .config import get_config +from relation_engine_server.utils.config import get_config _CONF = get_config() diff --git a/relation_engine_server/utils/auth.py b/relation_engine_server/utils/auth.py index 3e269103..d3a3f991 100644 --- a/relation_engine_server/utils/auth.py +++ b/relation_engine_server/utils/auth.py @@ -5,8 +5,8 @@ import flask import requests -from .config import get_config -from ..exceptions import MissingHeader, UnauthorizedAccess +from relation_engine_server.utils.config import get_config +from relation_engine_server.exceptions import MissingHeader, UnauthorizedAccess def require_auth_token(roles=[]): diff --git a/relation_engine_server/utils/bulk_import.py b/relation_engine_server/utils/bulk_import.py index 739f8ead..1fd3e44d 100644 --- a/relation_engine_server/utils/bulk_import.py +++ b/relation_engine_server/utils/bulk_import.py @@ -5,9 +5,9 @@ import json import hashlib -from relation_engine_server.utils import json_validation -from . import spec_loader -from .arango_client import import_from_file +from relation_engine_server.utils.json_validation import get_schema_validator +from relation_engine_server.utils import spec_loader +from relation_engine_server.utils.arango_client import import_from_file def bulk_import(query_params): @@ -17,6 +17,7 @@ def bulk_import(query_params): arango client. """ schema = spec_loader.get_schema(query_params['collection']) + validator = get_schema_validator(schema=schema['schema']) # We can't use a context manager here # We need to close the file to have the file contents readable # and we need to prevent deletion of the temp file on close (default behavior of tempfiles) @@ -26,7 +27,7 @@ def bulk_import(query_params): # Parse each line to json, validate the schema, and write to a file for line in flask.request.stream: json_line = json.loads(line) - json_validation.Validator(schema['schema']).validate(json_line) + validator.validate(json_line) json_line = _write_edge_key(json_line) json_line['updated_at'] = int(time.time() * 1000) temp_fd.write(json.dumps(json_line) + '\n') diff --git a/relation_engine_server/utils/json_validation.py b/relation_engine_server/utils/json_validation.py index c604f29f..829f4764 100644 --- a/relation_engine_server/utils/json_validation.py +++ b/relation_engine_server/utils/json_validation.py @@ -11,6 +11,8 @@ assert obj == {'foo': 'bar'} """ from jsonschema import validators, Draft7Validator, FormatChecker +# from jsonschema.exceptions import ValidationError +from jsonpointer import resolve_pointer import yaml import json @@ -24,34 +26,91 @@ def set_defaults(validator, properties, instance, schema): instance.setdefault(property, subschema["default"]) for error in validate_properties(validator, properties, instance, schema): yield error + return validators.extend(validator_class, {"properties": set_defaults}) Validator = extend_with_default(Draft7Validator) -def run_validator(schema=None, schema_file=None, data=None, data_file=None, validate_at=None): +def get_schema_validator(schema=None, schema_file=None, validate_at=""): + """ + Get a validator for the supplied schema + + :param schema: (dict) the schema as a data structure + :param schema_file: (string) path to the schema file (json or yaml format) + + :param validate_at: (string) where in the data structure the schema to validate against + is located, in JSON pointer syntax + defaults to the root of the schema object if not set + + only one of `schema` and `schema_file` should be supplied - if schema is None and schema_file is None: + :return: + validator (Validator) jsonschema validator instance + + """ + + if schema is None and schema_file is None or schema is not None and schema_file is not None: raise ValueError("Please supply either a schema or a schema file path") - if data is None and data_file is None: + # schema to validate against + if schema is None: + schema = _load_json_schema(schema_file) + + # get the appropriate location in the schema + validation_schema = resolve_pointer(schema, validate_at) + + # resolver = RefResolver("file://{}/".format(schema_dir), None) + + return Validator(validation_schema, format_checker=FormatChecker()) + + +def run_validator(schema=None, schema_file=None, validate_at="", data=None, data_file=None): + """ + Validate data against a schema, filling in defaults if appropriate + + :param schema: (dict) the schema as a data structure + :param schema_file: (string) path to the schema file (json or yaml format) + + :param validate_at: (string) where in the data structure the schema to validate against + is located, in JSON pointer syntax + defaults to the root of the schema object if not set + + :param data: (*) data to validate + :param data_file: (string) path to file containing data (json or yaml format) + + + only one of `schema` and `schema_file` should be supplied + + only one of `data` and `data_file` should be supplied + + :return: + data (*) validated data + + """ + + validator = get_schema_validator(schema, schema_file, validate_at) + + if data is None and data_file is None or data is not None and data_file is not None: raise ValueError("Please supply either a data structure or a data file path") # data to validate - if data_file: + if data is None: data = _load_json_schema(data_file) - # schema to validate against - if schema_file: - schema = _load_json_schema(schema_file) + if validator.is_valid(data): + return data - if validate_at: - schema = schema[validate_at[0]] + validator.validate(data) - Validator(schema, format_checker=FormatChecker()).validate(data) +# err_arr = [e.message + '\n' for e in sorted(validator.iter_errors(data), key=str)] +# raise ValidationError(err_arr) - return data +# err_arr = [e.message + '\n' for e in sorted(validator.iter_errors(data), key=str)] +# raise ValidationError( +# 'Validation failed with the following errors:\n' + '\n'.join(err_arr) +# ) def _load_json_schema(file): diff --git a/relation_engine_server/utils/pull_spec.py b/relation_engine_server/utils/pull_spec.py index 99c828ca..48126b7f 100644 --- a/relation_engine_server/utils/pull_spec.py +++ b/relation_engine_server/utils/pull_spec.py @@ -8,8 +8,8 @@ import yaml -from . import arango_client -from .config import get_config +from relation_engine_server.utils import arango_client +from relation_engine_server.utils.config import get_config _CONF = get_config() diff --git a/relation_engine_server/utils/spec_loader.py b/relation_engine_server/utils/spec_loader.py index 5694a9a4..07210054 100644 --- a/relation_engine_server/utils/spec_loader.py +++ b/relation_engine_server/utils/spec_loader.py @@ -5,7 +5,7 @@ import os import yaml -from .config import get_config +from relation_engine_server.utils.config import get_config _CONF = get_config() diff --git a/relation_engine_server/utils/wait_for.py b/relation_engine_server/utils/wait_for.py index 3757b1a8..bd6a7e72 100644 --- a/relation_engine_server/utils/wait_for.py +++ b/relation_engine_server/utils/wait_for.py @@ -4,7 +4,7 @@ import requests import time import sys -from .config import get_config +from relation_engine_server.utils.config import get_config _CONF = get_config() @@ -23,6 +23,7 @@ def wait_for_service(service_list): if service['auth'] is not None: requests.get(service['url'], auth=service['auth']).raise_for_status() else: + # auth and workspace both return 500, so don't raise_for_status requests.get(service['url']) break except Exception: diff --git a/requirements.txt b/requirements.txt index c6ff7500..7a01e57c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,5 +4,7 @@ gevent==1.3.7 simplejson==3.16.0 python-dotenv==0.9.1 requests==2.20.0 +jsonpointer==2.0 jsonschema==3.2.0 +jsonschema[format]==3.2.0 pyyaml==5.1.1 diff --git a/scripts/run_tests.sh b/scripts/run_tests.sh index d5b45ad6..3d205ada 100644 --- a/scripts/run_tests.sh +++ b/scripts/run_tests.sh @@ -11,7 +11,7 @@ cp -r /app/spec/* /spec/repo/ # start server, using the specs in /spec/repo sh /app/scripts/start_server.sh & # spec validation -python -m spec.test.validate && +python -m spec.validate && # spec stored query tests python -m unittest discover spec/test && # importer tests diff --git a/spec/collection_schema.yaml b/spec/collection_schema.yaml index c60a4af3..b35d9fed 100644 --- a/spec/collection_schema.yaml +++ b/spec/collection_schema.yaml @@ -1,13 +1,45 @@ name: collection_schema type: object required: ['name', 'type', 'schema'] +additionalProperties: false properties: + delta: + type: boolean + default: false + indexes: + type: array + items: + type: object + required: ['fields', 'type'] + properties: + fields: + type: array + items: + type: string + type: + type: string + enum: ['fulltext', 'geo', 'hash', 'persistent'] name: type: string title: Collection name - format: ^\w+$ + format: regex + pattern: ^\w+$ + schema: + type: object + required: ['properties', 'required'] + properties: + description: + type: string + properties: + type: object + required: + type: array + items: + type: string + title: + type: string + type: + type: string type: type: string enum: ['vertex', 'edge'] - schema: - type: object diff --git a/spec/data_source_schema.yaml b/spec/data_source_schema.yaml new file mode 100644 index 00000000..ecf2b039 --- /dev/null +++ b/spec/data_source_schema.yaml @@ -0,0 +1,27 @@ +name: data_source_schema +type: object +required: ['name', 'title', 'category'] +properties: + name: + type: string + title: Abbreviated data source name + format: regex + pattern: ^\w+$ + category: + type: string + title: Data source category + title: + type: string + title: Full data source name + home_url: + type: string + title: Data source home page + format: uri + data_url: + type: string + title: URL where data can be downloaded + format: uri + logo_path: + type: string + title: Path to logo +additionalProperties: false \ No newline at end of file diff --git a/spec/data_sources/djornl.yaml b/spec/data_sources/djornl.yaml new file mode 100644 index 00000000..495aa8af --- /dev/null +++ b/spec/data_sources/djornl.yaml @@ -0,0 +1,5 @@ +name: djornl +category: network +title: Jacobson Lab Exascale Networking data +home_url: https://github.com/kbase/exascale_data +data_url: https://github.com/kbase/exascale_data/releases/latest diff --git a/spec/stored_query_schema.yaml b/spec/stored_query_schema.yaml index d8a03717..89f1ba18 100644 --- a/spec/stored_query_schema.yaml +++ b/spec/stored_query_schema.yaml @@ -4,9 +4,14 @@ required: ['query', 'name'] properties: name: type: string + title: + type: string + description: + type: string params: type: object query_prefix: type: string query: type: string +additionalProperties: false \ No newline at end of file diff --git a/spec/test/helpers.py b/spec/test/helpers.py index e432c790..866e57a9 100644 --- a/spec/test/helpers.py +++ b/spec/test/helpers.py @@ -1,11 +1,13 @@ """ Test helpers """ -import os -import requests -import functools import contextlib +import functools +import io import json +import os +import requests +import sys @functools.lru_cache(maxsize=1) @@ -22,7 +24,7 @@ def get_config(): def run_query(query_name, query_data={}): """submit a database query""" - query_results_url = os.environ['RE_API_URL'] + '/api/v1/query_results' + query_results_url = get_config()['re_query_results_url'] return requests.post( query_results_url, @@ -60,6 +62,15 @@ def create_test_docs(coll_name, docs, update_on_dupe=False): return resp +def capture_stdout(function, *args, **kwargs): + """capture and return the standard output from a function""" + io_stdout = io.StringIO() + sys.stdout = io_stdout + function(*args, **kwargs) + sys.stdout = sys.__stdout__ + return io_stdout.getvalue() + + @contextlib.contextmanager def modified_environ(*remove, **update): """ diff --git a/spec/test/sample_schemas/collections/edge_delta_missing_to_from.yaml b/spec/test/sample_schemas/collections/edge_delta_missing_to_from.yaml new file mode 100644 index 00000000..67fa7941 --- /dev/null +++ b/spec/test/sample_schemas/collections/edge_delta_missing_to_from.yaml @@ -0,0 +1,14 @@ +# Time-travel edge schemas must require "from" and "to" attributes +name: edge_delta_missing_to_from +delta: true +type: edge +schema: + "$schema": "http://json-schema.org/draft-07/schema#" + type: object + required: + - name + description: Example edge schema for testing. + properties: + name: {type: string} + _from: {type: string} + _to: {type: string} diff --git a/spec/test/sample_schemas/collections/edge_missing_to_from.yaml b/spec/test/sample_schemas/collections/edge_missing_to_from.yaml new file mode 100644 index 00000000..3b7bc780 --- /dev/null +++ b/spec/test/sample_schemas/collections/edge_missing_to_from.yaml @@ -0,0 +1,12 @@ +# Edge schemas must require "_from" and "_to" attributes +name: edge_missing_to_from +type: edge +schema: + "$schema": "http://json-schema.org/draft-07/schema#" + type: object + required: [_key, _from] + description: Example edge schema for testing. + properties: + _key: {type: string} + _from: {type: string} + _to: {type: string} diff --git a/spec/test/sample_schemas/collections/extra_top_level_entries.yaml b/spec/test/sample_schemas/collections/extra_top_level_entries.yaml new file mode 100644 index 00000000..57b977ef --- /dev/null +++ b/spec/test/sample_schemas/collections/extra_top_level_entries.yaml @@ -0,0 +1,13 @@ +name: extra_top_level_entries +title: Extra Top-Level Entries +type: vertex +delta: false +schema: + "$schema": http://json-schema.org/draft-07/schema# + type: object + required: [_key] + properties: + _key: + type: string + title: Key + diff --git a/spec/test/sample_schemas/collections/not_a_schema.yaml b/spec/test/sample_schemas/collections/not_a_schema.yaml new file mode 100644 index 00000000..b909289d --- /dev/null +++ b/spec/test/sample_schemas/collections/not_a_schema.yaml @@ -0,0 +1,6 @@ +name: not_a_schema +type: edge +schema: + required: ['whatever'] + properties: + type: "17" diff --git a/spec/test/sample_schemas/collections/schema_not_object.yaml b/spec/test/sample_schemas/collections/schema_not_object.yaml new file mode 100644 index 00000000..78001d2f --- /dev/null +++ b/spec/test/sample_schemas/collections/schema_not_object.yaml @@ -0,0 +1,4 @@ +name: schema_not_object +type: vertex +delta: false +schema: http://json-schema.org/draft-07/schema# diff --git a/spec/test/sample_schemas/collections/test_edge.yaml b/spec/test/sample_schemas/collections/test_edge.yaml new file mode 100644 index 00000000..fab7ad6e --- /dev/null +++ b/spec/test/sample_schemas/collections/test_edge.yaml @@ -0,0 +1,10 @@ +name: test_edge +type: edge +schema: + "$schema": "http://json-schema.org/draft-07/schema#" + type: object + required: [_from, _to] + description: Example edge schema for testing. + properties: + _from: {type: string} + _to: {type: string} diff --git a/spec/test/sample_schemas/collections/test_vertex.yaml b/spec/test/sample_schemas/collections/test_vertex.yaml new file mode 100644 index 00000000..b2d34668 --- /dev/null +++ b/spec/test/sample_schemas/collections/test_vertex.yaml @@ -0,0 +1,11 @@ +name: test_vertex +type: vertex +schema: + "$schema": "http://json-schema.org/draft-07/schema#" + type: object + required: [_key] + description: An example vertex schema for testing + properties: + _key: {type: string} + is_public: {type: boolean} + ws_id: {type: integer} diff --git a/spec/test/sample_schemas/collections/vertex_missing_id.yaml b/spec/test/sample_schemas/collections/vertex_missing_id.yaml new file mode 100644 index 00000000..5275049c --- /dev/null +++ b/spec/test/sample_schemas/collections/vertex_missing_id.yaml @@ -0,0 +1,13 @@ +# Time-travel vertex schemas must require the "id" attribute +name: vertex_missing_id +type: vertex +delta: true +schema: + "$schema": "http://json-schema.org/draft-07/schema#" + type: object + required: [_key] + description: An example vertex schema for testing + properties: + _key: {type: string} + is_public: {type: boolean} + ws_id: {type: integer} diff --git a/spec/test/sample_schemas/collections/vertex_missing_key.yaml b/spec/test/sample_schemas/collections/vertex_missing_key.yaml new file mode 100644 index 00000000..e94b8f14 --- /dev/null +++ b/spec/test/sample_schemas/collections/vertex_missing_key.yaml @@ -0,0 +1,13 @@ +# Vertex schemas must require the "_key" attribute +name: vertex_missing_key +type: vertex +delta: false +schema: + "$schema": "http://json-schema.org/draft-07/schema#" + type: object + required: [id] + description: An example vertex schema for testing + properties: + id: {type: string} + is_public: {type: boolean} + ws_id: {type: integer} diff --git a/spec/test/sample_schemas/collections/wrong_name.yaml b/spec/test/sample_schemas/collections/wrong_name.yaml new file mode 100644 index 00000000..45dbcc3b --- /dev/null +++ b/spec/test/sample_schemas/collections/wrong_name.yaml @@ -0,0 +1,12 @@ +name: test_nodes +type: vertex +delta: false +schema: + "$schema": http://json-schema.org/draft-07/schema# + type: object + required: [_key] + properties: + _key: + type: string + title: Key + diff --git a/spec/test/sample_schemas/data_sources/invalid_additional_property.json b/spec/test/sample_schemas/data_sources/invalid_additional_property.json new file mode 100644 index 00000000..d36c3609 --- /dev/null +++ b/spec/test/sample_schemas/data_sources/invalid_additional_property.json @@ -0,0 +1,6 @@ +{ + "name": "invalid_additional_property", + "type": "invalid", + "category": "something boring", + "title": "An invalid additional property" +} \ No newline at end of file diff --git a/spec/test/sample_schemas/data_sources/minimal.yaml b/spec/test/sample_schemas/data_sources/minimal.yaml new file mode 100644 index 00000000..7027a4e1 --- /dev/null +++ b/spec/test/sample_schemas/data_sources/minimal.yaml @@ -0,0 +1,3 @@ +name: minimal +category: network +title: Example minimal data source diff --git a/spec/test/sample_schemas/data_sources/uri_validation.json b/spec/test/sample_schemas/data_sources/uri_validation.json new file mode 100644 index 00000000..af9d2b74 --- /dev/null +++ b/spec/test/sample_schemas/data_sources/uri_validation.json @@ -0,0 +1,6 @@ +{ + "name": "uri_validation", + "category": "validator testing", + "title": "URI vaildation test", + "home_url": "this is not a valid URI" +} \ No newline at end of file diff --git a/spec/test/sample_schemas/stored_queries/invalid_aql.yaml b/spec/test/sample_schemas/stored_queries/invalid_aql.yaml new file mode 100644 index 00000000..e50e7fea --- /dev/null +++ b/spec/test/sample_schemas/stored_queries/invalid_aql.yaml @@ -0,0 +1,27 @@ +# Return genes associated with reactions similar to a query reaction +name: invalid_aql +params: + type: object + required: [sf_sim, df_sim, rid] + properties: + rid: + type: string + title: Reaction id (rxn_reaction vertex id) + sf_sim: + type: number + title: Minimum structural fingerprint similarity score + df_sim: + type: number + title: Minimum difference fingerprint similarity score + exclude_self: + type: boolean + description: If true, don't include the query reactions genes + default: false + +query_prefix: WITH rxn_reaction +query: | + LET start = @exclude_self ? 1 : 0 + LET us pray + FOR a + RETURN to + NORMALITY \ No newline at end of file diff --git a/spec/test/sample_schemas/stored_queries/invalid_bind_params.yaml b/spec/test/sample_schemas/stored_queries/invalid_bind_params.yaml new file mode 100644 index 00000000..0dc1f7ac --- /dev/null +++ b/spec/test/sample_schemas/stored_queries/invalid_bind_params.yaml @@ -0,0 +1,32 @@ +name: invalid_bind_params +params: + type: object + required: [keys] + properties: + distance_to_nearest_star: + type: integer + default: 1 + minimum: 0 + maximum: 100 + keys: + type: array + items: {type: string} +query: | + LET node_ids = ( + FOR n IN djornl_node + FILTER n._key IN @door_keys AND n.node_type == 'gene' + FOR node IN 0..@distance ANY n djornl_edge + OPTIONS {bfs: true, uniqueVertices: "global"} + RETURN DISTINCT node._id + ) + LET edges = ( + FOR edge IN djornl_edge + FILTER edge._from IN node_ids AND edge._to IN node_ids + RETURN edge + ) + LET nodes = ( + FOR node IN djornl_node + FILTER node._id IN node_ids + RETURN node + ) + RETURN {nodes, edges} diff --git a/spec/test/sample_schemas/stored_queries/params_not_object.yaml b/spec/test/sample_schemas/stored_queries/params_not_object.yaml new file mode 100644 index 00000000..a5e6f937 --- /dev/null +++ b/spec/test/sample_schemas/stored_queries/params_not_object.yaml @@ -0,0 +1,3 @@ +name: params_not_object +query: whatever +params: false diff --git a/spec/test/sample_schemas/views/minimal.json b/spec/test/sample_schemas/views/minimal.json new file mode 100644 index 00000000..1d0f8109 --- /dev/null +++ b/spec/test/sample_schemas/views/minimal.json @@ -0,0 +1,4 @@ +{ + "name": "minimal", + "type": "arangosearch" +} \ No newline at end of file diff --git a/spec/test/sample_schemas/views/wrong_type.json b/spec/test/sample_schemas/views/wrong_type.json new file mode 100644 index 00000000..7b5ee97c --- /dev/null +++ b/spec/test/sample_schemas/views/wrong_type.json @@ -0,0 +1,4 @@ +{ + "name": "wrong_type", + "type": "from the shore" +} \ No newline at end of file diff --git a/spec/test/test_validate.py b/spec/test/test_validate.py new file mode 100644 index 00000000..f6748055 --- /dev/null +++ b/spec/test/test_validate.py @@ -0,0 +1,177 @@ +""" +Tests for the schema validation functions +""" +import unittest +import os.path as os_path + +from spec.test.helpers import capture_stdout +from relation_engine_server.utils.wait_for import wait_for_arangodb +from jsonschema.exceptions import ValidationError +from spec.validate import ( + validate_schema, + validate_collection, + validate_stored_query, + validate_data_source, + validate_view, + validate_all +) + +_TEST_DIR = '/app/spec/test/sample_schemas' + + +class TestValidate(unittest.TestCase): + + @classmethod + def setUpClass(cls): + wait_for_arangodb() + + def test_validate_schema(self): + """Validate a single file using the generic validate_schema method""" + + err_msg = 'No validation schema found for made-up_schema' + with self.assertRaisesRegex(ValueError, err_msg): + validate_schema('/path/to/file', 'made-up_schema') + + def test_validate_collection(self): + """Testing collection-specific schema errors""" + + base_dir = os_path.join(_TEST_DIR, 'collections') + + error_list = [ + { + 'msg': "Name key should match filename: test_nodes vs wrong_name", + 'file': 'wrong_name.yaml', + 'err': ValueError + }, + { + 'msg': "'http://json-schema.org/draft-07/schema#' is not of type 'object'", + 'file': 'schema_not_object.yaml', + }, + { + 'msg': "Additional properties are not allowed \('title' was unexpected\)", + 'file': 'extra_top_level_entries.yaml', + }, + { + 'msg': 'Time-travel edge schemas must require "from" and "to" attributes in ', + 'file': 'edge_delta_missing_to_from.yaml', + }, + { + 'msg': 'Edge schemas must require "_from" and "_to" attributes in ', + 'file': 'edge_missing_to_from.yaml', + }, + { + 'msg': 'Vertex schemas must require the "_key" attribute in ', + 'file': 'vertex_missing_key.yaml', + }, + { + 'msg': 'Time-travel vertex schemas must require the "id" attribute in ', + 'file': 'vertex_missing_id.yaml', + }, + ] + + for entry in error_list: + err_type = entry['err'] if 'err' in entry else ValidationError + # generic method, requires schema type + with self.assertRaisesRegex(err_type, entry['msg']): + validate_schema(os_path.join(base_dir, entry['file']), 'collection') + # specific method + with self.assertRaisesRegex(err_type, entry['msg']): + validate_collection(os_path.join(base_dir, entry['file'])) + + # TODO: add an example of a schema that validates but where data['schema'] is + # not a valid json schema. + + def test_validate_data_source(self): + + base_dir = os_path.join(_TEST_DIR, 'data_sources') + + # working example + output = validate_data_source(os_path.join(base_dir, 'minimal.yaml')) + self.assertEqual( + output, + { + "name": "minimal", + "category": "network", + "title": "Example minimal data source", + } + ) + + error_list = [ + { + 'msg': "Additional properties are not allowed \('type' was unexpected\)", + 'file': 'invalid_additional_property.json', + }, + ] + + for entry in error_list: + err_type = entry['err'] if 'err' in entry else ValidationError + + # generic method + with self.assertRaisesRegex(err_type, entry['msg']): + validate_schema(os_path.join(base_dir, entry['file']), 'data_source') + + # same thing as above via specific method + with self.assertRaisesRegex(err_type, entry['msg']): + validate_data_source(os_path.join(base_dir, entry['file'])) + + # TODO: add in a test for URL validation (once URL validation is working) + # see uri_validation.json for example + + def test_validate_stored_query(self): + + base_dir = os_path.join(_TEST_DIR, 'stored_queries') + + err_str = "False is not of type 'object'" + with self.assertRaisesRegex(ValidationError, err_str): + validate_stored_query(os_path.join(base_dir, 'params_not_object.yaml')) + + # total nonsense instead of AQL + err_str = 'syntax error, unexpected identifier, expecting assignment' + with self.assertRaisesRegex(ValueError, err_str): + validate_stored_query(os_path.join(base_dir, 'invalid_aql.yaml')) + + # invalid bind params + err_str = 'Bind vars are invalid' + with self.assertRaisesRegex(ValueError, err_str): + validate_stored_query(os_path.join(base_dir, 'invalid_bind_params.yaml')) + + def test_validate_view(self): + + base_dir = os_path.join(_TEST_DIR, 'views') + output = { + "name": "minimal", + "type": "arangosearch", + } + + self.assertEqual( + validate_schema(os_path.join(base_dir, 'minimal.json'), 'view'), + output + ) + + self.assertEqual( + validate_view(os_path.join(base_dir, 'minimal.json')), + output + ) + + err_str = "'from the shore' is not one of \['arangosearch'\]" + with self.assertRaisesRegex(ValidationError, err_str): + validate_view(os_path.join(base_dir, 'wrong_type.json')) + + def test_validate_all(self): + """test all the files in a directory""" + + sample_schemas = { + 'collection': 'collections', + 'stored_query': 'stored_queries', + 'view': 'views', + 'data_source': 'data_sources', + } + + for (schema_type, directory) in sample_schemas.items(): + + # n.b. this assumes all the schemas in /spec are valid! + stdout = capture_stdout(validate_all, schema_type) + self.assertRegex(stdout, r'...all valid') + + with self.assertRaises(Exception): + validate_all(schema_type, os_path.join(_TEST_DIR, directory)) diff --git a/spec/test/validate.py b/spec/test/validate.py deleted file mode 100644 index 994ad139..00000000 --- a/spec/test/validate.py +++ /dev/null @@ -1,198 +0,0 @@ -""" -Validate everything in this repo, such as syntax, structure, etc. -""" -import sys -import os -import glob -import yaml -import jsonschema -import requests -import json -from jsonschema.exceptions import ValidationError - -from spec.test.helpers import get_config -from relation_engine_server.utils.wait_for import wait_for_arangodb - -_CONF = get_config() -_BASE_DIR = '/app/spec' - -# JSON schema for vertex and edge collection schemas found in /schema -schema_schema = { - "type": "object", - "required": ["name", "type", "schema"], - "properties": { - "name": { - 'title': 'Collection name', - "type": "string", - "format": r'^[a-z_]+$' - }, - 'type': { - 'type': 'string', - 'enum': ['vertex', 'edge'] - }, - 'schema': {'type': 'object'} - } -} - - -def validate_json_schemas(): - """Validate the syntax of all the JSON schemas.""" - print('Validating JSON schemas..') - names = set() # type: set - for path in glob.iglob( - os.path.join(_BASE_DIR, 'schemas', '**', '*.yaml'), - recursive=True): - name = os.path.basename(path) - print(f' validating {path}..') - with open(path) as fd: - data = yaml.safe_load(fd) - jsonschema.validate(data, schema_schema) - # Check for any duplicate schema names - if name in names: - _fatal('Duplicate schemas for name ' + name) - else: - names.add(name) - # Make sure it can be used as a JSON schema - # If the schema is invalid, a SchemaError will get raised - # Otherwise, the schema will work and a ValidationError will get raised (what we want) - try: - jsonschema.validate({}, data['schema']) - except ValidationError: - pass - except Exception as err: - print('=' * 80) - print('Unable to load schema in ' + path) - print(str(err)) - exit(1) - # All schemas must be object types - if data['schema']['type'] != 'object': - _fatal('Schemas must be an object. Schema in %s is not an object.' % path) - required = data['schema'].get('required', []) - # Edges must require _from and _to while vertices must require _key - has_edge_fields = ('_from' in required and '_to' in required) - has_delta_edge_fields = ('from' in required and 'to' in required) - if data['type'] == 'edge' and data.get('delta') and not has_delta_edge_fields: - _fatal('Time-travel edge schemas must require "from" and "to" attributes in ' + path) - elif data['type'] == 'edge' and not data.get('delta') and not has_edge_fields: - _fatal('Edge schemas must require "_from" and "_to" attributes in ' + path) - elif data['type'] == 'vertex' and data.get('delta') and 'id' not in required: - _fatal('Time-travel vertex schemas must require the "id" attribute in ' + path) - elif data['type'] == 'vertex' and not data.get('delta') and '_key' not in required: - _fatal('Vertex schemas must require the "_key" attribute in ' + path) - print(f'✓ {name} is valid.') - print('..all valid.') - - -stored_query_schema = { - 'type': 'object', - 'required': ['query', 'name'], - 'properties': { - 'name': {'type': 'string'}, - 'params': {'type': 'object'}, - 'query_prefix': {'type': 'string'}, - 'query': {'type': 'string'} - } -} - - -def validate_stored_queries(): - """Validate the structure and syntax of all the queries.""" - print('Validating AQL queries..') - names = set() # type: set - for path in glob.iglob( - os.path.join(_BASE_DIR, 'stored_queries', '**', '*.yaml'), - recursive=True): - print(f' validating {path}..') - with open(path) as fd: - data = yaml.safe_load(fd) - jsonschema.validate(data, stored_query_schema) - name = data['name'] - filename = os.path.splitext(os.path.basename(path))[0] - if name != filename: - _fatal(f'Name key should match filename: {name} vs {filename}') - if name in names: - _fatal(f'Duplicate queries named {name}') - else: - names.add(name) - # Make sure `params` can be used as a JSON schema - if data.get('params'): - # Make sure it can be used as a JSON schema - # If the schema is invalid, a SchemaError will get raised - # Otherwise, the schema will work and a ValidationError will get raised (what we want) - try: - jsonschema.validate({}, data['params']) - except ValidationError: - pass - # Params must be of type 'object' - if data['params'].get('type') != 'object': - _fatal("Params schema must have type 'object'") - query = data.get('query_prefix', '') + ' ' + data['query'] - # Parse the AQL query on arangodb - url = _CONF['db_url'] + '/_api/query' - resp = requests.post(url, data=json.dumps({'query': query}), auth=_CONF['db_auth']) - parsed = resp.json() - if parsed['error']: - _fatal(parsed['errorMessage']) - query_bind_vars = set(parsed['bindVars']) - params = set(data.get('params', {}).get('properties', {}).keys()) - if params != query_bind_vars: - _fatal((f"Bind vars are invalid.\n" - f" Extra vars in query: {query_bind_vars - params}.\n" - f" Extra params in schema: {params - query_bind_vars}")) - print(f'✓ {path} is valid.') - print('..all valid.') - - -# JSON schema for arangosearch views found in /views -view_schema = { - "type": "object", - "required": ["name", "type"], - "properties": { - "name": { - 'title': 'View name', - "type": "string", - "format": r'^[a-z_]+$' - }, - 'type': { - 'type': 'string', - 'enum': ['arangosearch'] - } - } -} - - -def validate_views(): - """Validate the structure and syntax of arangosearch views""" - print('Validating views..') - names = set() # type: set - for path in glob.iglob( - os.path.join(_BASE_DIR, 'views', '**', '*.json'), - recursive=True): - print(f' validating {path}..') - with open(path) as fd: - data = json.load(fd) - jsonschema.validate(data, view_schema) - name = data['name'] - filename = os.path.splitext(os.path.basename(path))[0] - if name != filename: - _fatal(f'Name key should match filename: {name} vs {filename}') - if name in names: - _fatal(f'Duplicate queries named {name}') - else: - names.add(name) - - print(f'✓ {path} is valid.') - print('..all valid.') - - -def _fatal(msg): - """Fatal error.""" - sys.stderr.write(str(msg) + '\n') - sys.exit(1) - - -if __name__ == '__main__': - wait_for_arangodb() - validate_json_schemas() - validate_stored_queries() - validate_views() diff --git a/spec/validate.py b/spec/validate.py new file mode 100644 index 00000000..3056d0ea --- /dev/null +++ b/spec/validate.py @@ -0,0 +1,199 @@ +""" +Validate everything in this repo, such as syntax, structure, etc. +""" +import sys +import os +import glob +import requests +import json +from jsonschema.exceptions import ValidationError + +from relation_engine_server.utils.config import get_config +from relation_engine_server.utils.wait_for import wait_for_arangodb +from relation_engine_server.utils.json_validation import run_validator + +_CONF = get_config() +_BASE_DIR = '/app/spec' + +_VALID_SCHEMA_TYPES = { + 'data_source': { + 'file': os.path.join(_BASE_DIR, 'data_source_schema.yaml'), + 'plural': 'data_sources', + }, + 'stored_query': { + 'file': os.path.join(_BASE_DIR, 'stored_query_schema.yaml'), + 'plural': 'stored_queries', + }, + 'collection': { + 'file': os.path.join(_BASE_DIR, 'collection_schema.yaml'), + 'plural': 'schemas', + }, + 'view': { + 'file': os.path.join(_BASE_DIR, 'view_schema.yaml'), + 'plural': 'views', + }, +} + + +def validate_all(schema_type, directory=None): + """Validate the syntax of all schemas of a certain type.""" + print(f'Validating {schema_type} schemas...') + + if schema_type not in _VALID_SCHEMA_TYPES.keys(): + raise ValueError('No validation schema found for ' + schema_type) + + names = set() # type: set + if directory is None: + type_dir_name = _VALID_SCHEMA_TYPES[schema_type]['plural'] + directory = _CONF['spec_paths'][type_dir_name] + + for path in glob.iglob(os.path.join(directory, '**', '*.*'), recursive=True): + if path.endswith('.yaml') or path.endswith('.json'): + data = validate_schema(path, schema_type) + + # Check for any duplicate schema names + name = data['name'] + if name in names: + raise ValueError(f'Duplicate queries named {name}') + else: + names.add(name) + + print('...all valid.') + + +def validate_schema(path, schema_type): + """Validate a single file against its schema""" + + if schema_type not in _VALID_SCHEMA_TYPES.keys(): + raise ValueError('No validation schema found for ' + schema_type) + + return globals()["validate_" + schema_type](path) + + +def validate_collection(path): + print(f' validating {path}..') + + # JSON schema for vertex and edge collection schemas found in /schema + collection_schema_file = _VALID_SCHEMA_TYPES['collection']['file'] + data = run_validator(schema_file=collection_schema_file, data_file=path) + namecheck_schema(path, data) + + # Make sure it can be used as a JSON schema + # If the schema is invalid, a SchemaError will get raised + # Otherwise, the schema will work and a ValidationError will get raised (what we want) + try: + run_validator(data={}, schema=data['schema']) + except ValidationError: + pass + except Exception as err: + print('=' * 80) + print('Unable to load schema in ' + path) + raise err + + required = data['schema'].get('required', []) + + # Edges must require _from and _to while vertices must require _key + has_edge_fields = ('_from' in required and '_to' in required) + has_delta_edge_fields = ('from' in required and 'to' in required) + + if data['type'] == 'edge' and data.get('delta') and not has_delta_edge_fields: + raise ValidationError('Time-travel edge schemas must require "from" and "to" attributes in ' + path) + elif data['type'] == 'edge' and not data.get('delta') and not has_edge_fields: + raise ValidationError('Edge schemas must require "_from" and "_to" attributes in ' + path) + elif data['type'] == 'vertex' and data.get('delta') and 'id' not in required: + raise ValidationError('Time-travel vertex schemas must require the "id" attribute in ' + path) + elif data['type'] == 'vertex' and not data.get('delta') and '_key' not in required: + raise ValidationError('Vertex schemas must require the "_key" attribute in ' + path) + + print(f'✓ {path} is valid.') + return data + + +def validate_data_source(path): + print(f' validating {path}..') + + # JSON schema for data source files in /data_sources + data_source_schema_file = _VALID_SCHEMA_TYPES['data_source']['file'] + data = run_validator(schema_file=data_source_schema_file, data_file=path) + namecheck_schema(path, data) + + print(f'✓ {path} is valid.') + return data + + +def validate_stored_query(path): + print(f' validating {path}..') + + stored_queries_schema_file = _VALID_SCHEMA_TYPES['stored_query']['file'] + data = run_validator(schema_file=stored_queries_schema_file, data_file=path) + namecheck_schema(path, data) + + # Make sure `params` can be used as a JSON schema + if data.get('params'): + # If the schema is invalid, a SchemaError will get raised + # Otherwise, the schema will work and a ValidationError will get raised + try: + run_validator(data={}, schema=data['params']) + except ValidationError: + pass + + # check that the query is valid AQL + validate_aql_on_arango(data) + + print(f'✓ {path} is valid.') + return data + + +def validate_view(path): + """Validate the structure and syntax of an arangodb view""" + print(f' validating {path}..') + + # JSON schema for /views + view_schema_file = _VALID_SCHEMA_TYPES['view']['file'] + data = run_validator(data_file=path, schema_file=view_schema_file) + namecheck_schema(path, data) + + print(f'✓ {path} is valid.') + return data + + +def namecheck_schema(path, data): + '''Ensure that the schema "name" is the same as the file name minus extensions''' + name = data['name'] + filename = os.path.splitext(os.path.basename(path))[0] + if name != filename: + raise ValueError(f'Name key should match filename: {name} vs {filename}') + + +def validate_aql_on_arango(data): + """Validate a string as valid AQL syntax by running it on the ArangoDB""" + query = data.get('query_prefix', '') + ' ' + data['query'] + url = _CONF['db_url'] + '/_api/query' + auth = (_CONF['db_user'], _CONF['db_pass']) + + resp = requests.post(url, data=json.dumps({'query': query}), auth=auth) + parsed = resp.json() + if parsed['error']: + raise ValueError(parsed['errorMessage']) + query_bind_vars = set(parsed['bindVars']) + params = set(data.get('params', {}).get('properties', {}).keys()) + if params != query_bind_vars: + raise ValueError( + f"Bind vars are invalid.\n" + + f" Extra vars in query: {query_bind_vars - params}.\n" + + f" Extra params in schema: {params - query_bind_vars}") + + +def _fatal(msg): + """Fatal error.""" + sys.stderr.write(str(msg) + '\n') + sys.exit(1) + + +if __name__ == '__main__': + wait_for_arangodb() + try: + for s in ['data_source', 'stored_query', 'view', 'collection']: + validate_all(s) + except Exception as err: + _fatal(err) diff --git a/spec/view_schema.yaml b/spec/view_schema.yaml index 79b7caa4..1b03536f 100644 --- a/spec/view_schema.yaml +++ b/spec/view_schema.yaml @@ -5,7 +5,8 @@ properties: name: type: string title: View name - format: ^\\w+$ + format: regex + pattern: ^\w+$ type: type: string enum: ['arangosearch'] From 3e6fc5c2ab0c0c92023a818bcfcd85f242bab623 Mon Sep 17 00:00:00 2001 From: ialarmedalien Date: Wed, 5 Aug 2020 13:04:42 -0700 Subject: [PATCH 547/732] adding in two extra test files --- relation_engine_server/api_versions/api_v1.py | 1 - relation_engine_server/utils/json_validation.py | 12 +----------- spec/data_source_schema.yaml | 2 +- spec/stored_query_schema.yaml | 2 +- .../collections/test_delta_edge.yaml | 11 +++++++++++ .../collections/test_delta_vertex.yaml | 11 +++++++++++ spec/test/test_validate.py | 16 +++++++++++++++- 7 files changed, 40 insertions(+), 15 deletions(-) create mode 100644 spec/test/sample_schemas/collections/test_delta_edge.yaml create mode 100644 spec/test/sample_schemas/collections/test_delta_vertex.yaml diff --git a/relation_engine_server/api_versions/api_v1.py b/relation_engine_server/api_versions/api_v1.py index 7f85284b..95f497d0 100644 --- a/relation_engine_server/api_versions/api_v1.py +++ b/relation_engine_server/api_versions/api_v1.py @@ -88,7 +88,6 @@ def run_query(): if 'params' in stored_query: # Validate the user params for the query run_validator(schema=stored_query['params'], data=json_body) -# json_validation.Validator(stored_query['params']).validate(json_body) json_body['ws_ids'] = ws_ids resp_body = arango_client.run_query(query_text=stored_query_source, bind_vars=json_body, diff --git a/relation_engine_server/utils/json_validation.py b/relation_engine_server/utils/json_validation.py index 829f4764..9dcb9d76 100644 --- a/relation_engine_server/utils/json_validation.py +++ b/relation_engine_server/utils/json_validation.py @@ -11,7 +11,6 @@ assert obj == {'foo': 'bar'} """ from jsonschema import validators, Draft7Validator, FormatChecker -# from jsonschema.exceptions import ValidationError from jsonpointer import resolve_pointer import yaml import json @@ -61,8 +60,6 @@ def get_schema_validator(schema=None, schema_file=None, validate_at=""): # get the appropriate location in the schema validation_schema = resolve_pointer(schema, validate_at) - # resolver = RefResolver("file://{}/".format(schema_dir), None) - return Validator(validation_schema, format_checker=FormatChecker()) @@ -102,16 +99,9 @@ def run_validator(schema=None, schema_file=None, validate_at="", data=None, data if validator.is_valid(data): return data + # this will throw a ValidationError validator.validate(data) -# err_arr = [e.message + '\n' for e in sorted(validator.iter_errors(data), key=str)] -# raise ValidationError(err_arr) - -# err_arr = [e.message + '\n' for e in sorted(validator.iter_errors(data), key=str)] -# raise ValidationError( -# 'Validation failed with the following errors:\n' + '\n'.join(err_arr) -# ) - def _load_json_schema(file): """ Loads the given schema file """ diff --git a/spec/data_source_schema.yaml b/spec/data_source_schema.yaml index ecf2b039..49beaca1 100644 --- a/spec/data_source_schema.yaml +++ b/spec/data_source_schema.yaml @@ -24,4 +24,4 @@ properties: logo_path: type: string title: Path to logo -additionalProperties: false \ No newline at end of file +additionalProperties: false diff --git a/spec/stored_query_schema.yaml b/spec/stored_query_schema.yaml index 89f1ba18..034c3642 100644 --- a/spec/stored_query_schema.yaml +++ b/spec/stored_query_schema.yaml @@ -14,4 +14,4 @@ properties: type: string query: type: string -additionalProperties: false \ No newline at end of file +additionalProperties: false diff --git a/spec/test/sample_schemas/collections/test_delta_edge.yaml b/spec/test/sample_schemas/collections/test_delta_edge.yaml new file mode 100644 index 00000000..388b31f0 --- /dev/null +++ b/spec/test/sample_schemas/collections/test_delta_edge.yaml @@ -0,0 +1,11 @@ +name: test_delta_edge +type: edge +delta: true +schema: + "$schema": "http://json-schema.org/draft-07/schema#" + type: object + required: [from, to] + description: Example edge schema for testing. + properties: + from: {type: string} + to: {type: string} diff --git a/spec/test/sample_schemas/collections/test_delta_vertex.yaml b/spec/test/sample_schemas/collections/test_delta_vertex.yaml new file mode 100644 index 00000000..6ee273b8 --- /dev/null +++ b/spec/test/sample_schemas/collections/test_delta_vertex.yaml @@ -0,0 +1,11 @@ +name: test_delta_vertex +type: vertex +delta: true +schema: + "$schema": "http://json-schema.org/draft-07/schema#" + type: object + required: [id] + description: An example vertex schema for testing + properties: + id: {type: string} + quality: {type: string} \ No newline at end of file diff --git a/spec/test/test_validate.py b/spec/test/test_validate.py index f6748055..28e5f627 100644 --- a/spec/test/test_validate.py +++ b/spec/test/test_validate.py @@ -32,7 +32,7 @@ def test_validate_schema(self): with self.assertRaisesRegex(ValueError, err_msg): validate_schema('/path/to/file', 'made-up_schema') - def test_validate_collection(self): + def test_validate_collection_errors(self): """Testing collection-specific schema errors""" base_dir = os_path.join(_TEST_DIR, 'collections') @@ -81,6 +81,20 @@ def test_validate_collection(self): # TODO: add an example of a schema that validates but where data['schema'] is # not a valid json schema. + def test_validate_collection(self): + """Testing collection-specific schema errors""" + + base_dir = os_path.join(_TEST_DIR, 'collections') + + # valid schemas -- check delta is set appropriately + for type in ['edge', 'vertex']: + data = validate_collection(os_path.join(base_dir, 'test_' + type + '.yaml')) + self.assertEqual(data['delta'], False) + + # delta is true: + data = validate_collection(os_path.join(base_dir, 'test_delta_' + type + '.yaml')) + self.assertEqual(data['delta'], True) + def test_validate_data_source(self): base_dir = os_path.join(_TEST_DIR, 'data_sources') From b55fcc6562b7a4280ff13db1dcd689542b6484ea Mon Sep 17 00:00:00 2001 From: ialarmedalien Date: Wed, 5 Aug 2020 14:36:40 -0700 Subject: [PATCH 548/732] Using "collection" to refer to collections, rather than "schema" --- README.md | 4 +- client_src/test/test_integration.py | 4 +- relation_engine_server/README.md | 14 +++-- relation_engine_server/api_versions/api_v1.py | 9 +-- relation_engine_server/main.py | 1 + .../test/spec_release/spec.tar.gz | Bin 21465 -> 2838 bytes relation_engine_server/test/test_api_v1.py | 58 ++++++++++++++---- relation_engine_server/utils/bulk_import.py | 2 +- relation_engine_server/utils/config.py | 10 +-- relation_engine_server/utils/pull_spec.py | 4 +- relation_engine_server/utils/spec_loader.py | 26 +++++--- spec/README.md | 4 +- .../ENVO/ENVO_edges.yaml | 0 .../ENVO/ENVO_merges.yaml | 0 .../ENVO/ENVO_terms.yaml | 0 .../{schemas => collections}/GO/GO_edges.yaml | 0 .../GO/GO_merges.yaml | 0 .../{schemas => collections}/GO/GO_terms.yaml | 0 spec/{schemas => collections}/README.md | 0 .../deltaloader/delta_load_registry.yaml | 0 .../djornl/djornl_edge.yaml | 0 .../djornl/djornl_node.yaml | 0 spec/{schemas => collections}/gtdb/README.md | 0 .../gtdb/gtdb_child_of_taxon.yaml | 0 .../gtdb/gtdb_taxon.yaml | 0 .../mash/mash_genome_similar_to.yaml | 0 spec/{schemas => collections}/ncbi/README.md | 0 .../ncbi/ncbi_child_of_taxon.yaml | 0 .../ncbi/ncbi_gene.yaml | 0 .../ncbi/ncbi_gene_within_genome.yaml | 0 .../ncbi/ncbi_genome.yaml | 0 .../ncbi/ncbi_taxon.yaml | 0 .../ncbi/ncbi_taxon_merges.yaml | 0 spec/{schemas => collections}/rdp/README.md | 0 .../rdp/rdp_child_of_taxon.yaml | 0 .../rdp/rdp_taxon.yaml | 0 spec/{schemas => collections}/rxn/README.md | 0 .../rxn/rxn_compound.yaml | 0 .../rxn/rxn_compound_linked_to_compound.yaml | 0 .../rxn/rxn_compound_within_reaction.yaml | 0 .../rxn/rxn_gene_complex.yaml | 0 .../rxn/rxn_gene_within_complex.yaml | 0 .../rxn/rxn_reaction.yaml | 0 .../rxn/rxn_reaction_linked_to_reaction.yaml | 0 .../rxn/rxn_reaction_within_complex.yaml | 0 .../rxn/rxn_similar_to_reaction.yaml | 0 .../test/test_edge.yaml | 0 .../test/test_vertex.yaml | 0 spec/{schemas => collections}/ws/README.md | 0 .../ws/ws_copied_from.yaml | 0 .../ws/ws_feature_has_GO_annotation.yaml | 0 .../ws/ws_genome_features.yaml | 0 .../ws/ws_genome_has_feature.yaml | 0 .../ws/ws_has_perm.yaml | 0 .../ws/ws_latest_version_of.yaml | 0 .../ws/ws_method.yaml | 0 .../ws/ws_method_version.yaml | 0 .../ws/ws_module.yaml | 0 .../ws/ws_module_contains_method.yaml | 0 .../ws/ws_module_version.yaml | 0 .../ws/ws_obj_created_with_method.yaml | 0 .../ws/ws_obj_created_with_module.yaml | 0 .../ws/ws_obj_instance_of_type.yaml | 0 .../ws/ws_obj_version_has_taxon.yaml | 0 .../ws/ws_object.yaml | 0 .../ws/ws_object_hash.yaml | 0 .../ws/ws_object_version.yaml | 0 .../ws/ws_owner_of.yaml | 0 .../ws/ws_prov_descendant_of.yaml | 0 .../ws/ws_refers_to.yaml | 0 spec/{schemas => collections}/ws/ws_type.yaml | 0 .../ws/ws_type_consumed_by_method.yaml | 0 .../ws/ws_type_module.yaml | 0 .../ws/ws_type_version.yaml | 0 spec/{schemas => collections}/ws/ws_user.yaml | 0 .../ws/ws_version_of.yaml | 0 .../ws/ws_workspace.yaml | 0 .../ws/ws_workspace_contains_obj.yaml | 0 .../{schemas => collections}/wsprov/README.md | 0 .../wsprov/wsprov_action.yaml | 0 .../wsprov/wsprov_copied_into.yaml | 0 .../wsprov/wsprov_input_in.yaml | 0 .../wsprov/wsprov_links.yaml | 0 .../wsprov/wsprov_object.yaml | 0 .../wsprov/wsprov_produced.yaml | 0 spec/validate.py | 2 +- 86 files changed, 92 insertions(+), 46 deletions(-) rename spec/{schemas => collections}/ENVO/ENVO_edges.yaml (100%) rename spec/{schemas => collections}/ENVO/ENVO_merges.yaml (100%) rename spec/{schemas => collections}/ENVO/ENVO_terms.yaml (100%) rename spec/{schemas => collections}/GO/GO_edges.yaml (100%) rename spec/{schemas => collections}/GO/GO_merges.yaml (100%) rename spec/{schemas => collections}/GO/GO_terms.yaml (100%) rename spec/{schemas => collections}/README.md (100%) rename spec/{schemas => collections}/deltaloader/delta_load_registry.yaml (100%) rename spec/{schemas => collections}/djornl/djornl_edge.yaml (100%) rename spec/{schemas => collections}/djornl/djornl_node.yaml (100%) rename spec/{schemas => collections}/gtdb/README.md (100%) rename spec/{schemas => collections}/gtdb/gtdb_child_of_taxon.yaml (100%) rename spec/{schemas => collections}/gtdb/gtdb_taxon.yaml (100%) rename spec/{schemas => collections}/mash/mash_genome_similar_to.yaml (100%) rename spec/{schemas => collections}/ncbi/README.md (100%) rename spec/{schemas => collections}/ncbi/ncbi_child_of_taxon.yaml (100%) rename spec/{schemas => collections}/ncbi/ncbi_gene.yaml (100%) rename spec/{schemas => collections}/ncbi/ncbi_gene_within_genome.yaml (100%) rename spec/{schemas => collections}/ncbi/ncbi_genome.yaml (100%) rename spec/{schemas => collections}/ncbi/ncbi_taxon.yaml (100%) rename spec/{schemas => collections}/ncbi/ncbi_taxon_merges.yaml (100%) rename spec/{schemas => collections}/rdp/README.md (100%) rename spec/{schemas => collections}/rdp/rdp_child_of_taxon.yaml (100%) rename spec/{schemas => collections}/rdp/rdp_taxon.yaml (100%) rename spec/{schemas => collections}/rxn/README.md (100%) rename spec/{schemas => collections}/rxn/rxn_compound.yaml (100%) rename spec/{schemas => collections}/rxn/rxn_compound_linked_to_compound.yaml (100%) rename spec/{schemas => collections}/rxn/rxn_compound_within_reaction.yaml (100%) rename spec/{schemas => collections}/rxn/rxn_gene_complex.yaml (100%) rename spec/{schemas => collections}/rxn/rxn_gene_within_complex.yaml (100%) rename spec/{schemas => collections}/rxn/rxn_reaction.yaml (100%) rename spec/{schemas => collections}/rxn/rxn_reaction_linked_to_reaction.yaml (100%) rename spec/{schemas => collections}/rxn/rxn_reaction_within_complex.yaml (100%) rename spec/{schemas => collections}/rxn/rxn_similar_to_reaction.yaml (100%) rename spec/{schemas => collections}/test/test_edge.yaml (100%) rename spec/{schemas => collections}/test/test_vertex.yaml (100%) rename spec/{schemas => collections}/ws/README.md (100%) rename spec/{schemas => collections}/ws/ws_copied_from.yaml (100%) rename spec/{schemas => collections}/ws/ws_feature_has_GO_annotation.yaml (100%) rename spec/{schemas => collections}/ws/ws_genome_features.yaml (100%) rename spec/{schemas => collections}/ws/ws_genome_has_feature.yaml (100%) rename spec/{schemas => collections}/ws/ws_has_perm.yaml (100%) rename spec/{schemas => collections}/ws/ws_latest_version_of.yaml (100%) rename spec/{schemas => collections}/ws/ws_method.yaml (100%) rename spec/{schemas => collections}/ws/ws_method_version.yaml (100%) rename spec/{schemas => collections}/ws/ws_module.yaml (100%) rename spec/{schemas => collections}/ws/ws_module_contains_method.yaml (100%) rename spec/{schemas => collections}/ws/ws_module_version.yaml (100%) rename spec/{schemas => collections}/ws/ws_obj_created_with_method.yaml (100%) rename spec/{schemas => collections}/ws/ws_obj_created_with_module.yaml (100%) rename spec/{schemas => collections}/ws/ws_obj_instance_of_type.yaml (100%) rename spec/{schemas => collections}/ws/ws_obj_version_has_taxon.yaml (100%) rename spec/{schemas => collections}/ws/ws_object.yaml (100%) rename spec/{schemas => collections}/ws/ws_object_hash.yaml (100%) rename spec/{schemas => collections}/ws/ws_object_version.yaml (100%) rename spec/{schemas => collections}/ws/ws_owner_of.yaml (100%) rename spec/{schemas => collections}/ws/ws_prov_descendant_of.yaml (100%) rename spec/{schemas => collections}/ws/ws_refers_to.yaml (100%) rename spec/{schemas => collections}/ws/ws_type.yaml (100%) rename spec/{schemas => collections}/ws/ws_type_consumed_by_method.yaml (100%) rename spec/{schemas => collections}/ws/ws_type_module.yaml (100%) rename spec/{schemas => collections}/ws/ws_type_version.yaml (100%) rename spec/{schemas => collections}/ws/ws_user.yaml (100%) rename spec/{schemas => collections}/ws/ws_version_of.yaml (100%) rename spec/{schemas => collections}/ws/ws_workspace.yaml (100%) rename spec/{schemas => collections}/ws/ws_workspace_contains_obj.yaml (100%) rename spec/{schemas => collections}/wsprov/README.md (100%) rename spec/{schemas => collections}/wsprov/wsprov_action.yaml (100%) rename spec/{schemas => collections}/wsprov/wsprov_copied_into.yaml (100%) rename spec/{schemas => collections}/wsprov/wsprov_input_in.yaml (100%) rename spec/{schemas => collections}/wsprov/wsprov_links.yaml (100%) rename spec/{schemas => collections}/wsprov/wsprov_object.yaml (100%) rename spec/{schemas => collections}/wsprov/wsprov_produced.yaml (100%) diff --git a/README.md b/README.md index 61030f21..f7a14c0b 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,9 @@ This repo holds the code associated with the KBase relation engine, previously h ## Relation Engine Spec -This repo holds the [stored queries](spec/stored_queries), [schemas](spec/schemas), and [migrations](spec/migrations) for the relation engine graph database service. +This repo holds the schemas for [stored queries](spec/stored_queries), [collections](spec/collections), [views](spec/views) and [migrations](spec/migrations) for the relation engine graph database service. -These specifications are used by the [Relation Engine API](https://github.com/kbase/relation_engine_api). +These specifications are used by the [Relation Engine API](relation_engine_server). ## Relation Engine API diff --git a/client_src/test/test_integration.py b/client_src/test/test_integration.py index 31905775..a7327af6 100644 --- a/client_src/test/test_integration.py +++ b/client_src/test/test_integration.py @@ -7,11 +7,11 @@ _API_URL = os.environ.get('RE_API_URL', 'http://localhost:5000') # See the test schemas here: -# https://github.com/kbase/relation_engine_spec/tree/develop/schemas/test +# https://github.com/kbase/relation_engine/tree/develop/spec/collections/test _VERT_COLL = 'test_vertex' _EDGE_COLL = 'test_edge' # See the docker-compose.yaml file in the root of this repo -# See the mock auth endpoints in src/test/mock_auth/*.json +# See the mock auth endpoints in relation_engine_server/test/mock_auth/*.json _TOK_ADMIN = 'admin_token' _TOK_USER = 'non_admin_token' _TOK_INVALID = 'invalid_token' diff --git a/relation_engine_server/README.md b/relation_engine_server/README.md index 5ad15f2b..aaae50a3 100644 --- a/relation_engine_server/README.md +++ b/relation_engine_server/README.md @@ -264,12 +264,14 @@ _Query params_ Every call to update specs will reset the spec data (do a clean download and overwrite). -### GET /api/v1/specs/schemas +### GET /api/v1/specs/collections or /api/v1/specs/schemas -Get all schema names (returns an array of strings): +Both `collections` and `schemas` return the same data. + +Get all collection names (returns an array of strings): ```sh -GET {root_url}/api/v1/specs/schemas +GET {root_url}/api/v1/specs/collections ``` Example response: @@ -278,10 +280,10 @@ Example response: ["test_vertex", "test_edge"] ``` -Get the contents of a specific schema +Get the schema for a specific collection ```sh -GET "{root_url}/api/v1/specs/schemas?name=test_vertex" +GET "{root_url}/api/v1/specs/collections?name=test_vertex" ``` Example response: @@ -307,7 +309,7 @@ Example response: Get the schema for a particular document by its full ID ```sh -GET "{root_url}/api/v1/specs/schemas?doc_id=test_vertex/1" +GET "{root_url}/api/v1/specs/collections?doc_id=test_vertex/1" ``` The response will have the same format as the example response above diff --git a/relation_engine_server/api_versions/api_v1.py b/relation_engine_server/api_versions/api_v1.py index 95f497d0..36dcf3fd 100644 --- a/relation_engine_server/api_versions/api_v1.py +++ b/relation_engine_server/api_versions/api_v1.py @@ -36,17 +36,18 @@ def show_stored_queries(): return flask.jsonify(spec_loader.get_stored_query_names()) +@api_v1.route('/specs/collections', methods=['GET']) @api_v1.route('/specs/schemas', methods=['GET']) -def show_schemas(): - """Show the current schema names (edges and vertices) loaded from the spec.""" +def show_collections(): + """Show the names of the (document) collections (edges and vertices) loaded from the spec.""" name = flask.request.args.get('name') doc_id = flask.request.args.get('doc_id') if name: - return flask.jsonify(spec_loader.get_schema(name)) + return flask.jsonify(spec_loader.get_collection(name)) elif doc_id: return flask.jsonify(spec_loader.get_schema_for_doc(doc_id)) else: - return flask.jsonify(spec_loader.get_schema_names()) + return flask.jsonify(spec_loader.get_collection_names()) @api_v1.route('/query_results', methods=['POST']) diff --git a/relation_engine_server/main.py b/relation_engine_server/main.py index 3a654151..d04f691c 100644 --- a/relation_engine_server/main.py +++ b/relation_engine_server/main.py @@ -64,6 +64,7 @@ def invalid_params(err): return (flask.jsonify(resp), 400) +@app.errorhandler(spec_loader.CollectionNonexistent) @app.errorhandler(spec_loader.SchemaNonexistent) @app.errorhandler(spec_loader.StoredQueryNonexistent) def view_does_not_exist(err): diff --git a/relation_engine_server/test/spec_release/spec.tar.gz b/relation_engine_server/test/spec_release/spec.tar.gz index 9187ff78f6ba24dfe3ac5d93eb23336dfb2da3e2..e654605a76d146fd27e1ef4bd9f76d710d169155 100644 GIT binary patch literal 2838 zcmXYyX*?8c7siDwAryr$)~t!F$ykcUC}fF@wX&6+LDs2Jk0nAVvPDG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9ukWqPIqr~g|uLv5``*=VpTKh zf`*G`>W&vS+Y&qj7cBh=LWhoA8`CGK>n;S+nZ-9w*{Kl+8|hl3@vKQceI}hdv8+0K z%IJy;$O4sq)WPQ2vrOSvRl$>CEKOJoxDGru^9B97+daZ!xi$Bh{BA>1NMZRkaL$>J zQgpi2d~@oo@m0bjTV93MHVjhsP#2>2K#7DZi>By`rD;Ck!!AzO2~=i%NB^B{U(0Jd zJU+iTK7k%7zCTYw*-74iIRAN$kEM+N6S;|tDvXrGPWhqNp%2JlHl%*_XxgX{K17bvro&X>N E08G0<=l}o! diff --git a/relation_engine_server/test/test_api_v1.py b/relation_engine_server/test/test_api_v1.py index ff0f5ffd..5ea07a42 100644 --- a/relation_engine_server/test/test_api_v1.py +++ b/relation_engine_server/test/test_api_v1.py @@ -107,22 +107,54 @@ def test_update_specs(self): def test_list_stored_queries(self): """Test the listing out of saved AQL stored queries.""" resp = requests.get(API_URL + '/specs/stored_queries').json() - self.assertTrue('list_test_vertices' in resp) + for sq in ['fetch_test_vertex', 'list_test_vertices', 'ncbi_fetch_taxon']: + self.assertIn(sq, resp) - def test_list_schemas(self): - """Test the listing out of registered JSON schemas for vertices and edges.""" - resp = requests.get(API_URL + '/specs/schemas').json() - self.assertTrue('test_vertex' in resp) - self.assertTrue('test_edge' in resp) - self.assertFalse('error' in resp) - self.assertTrue(len(resp)) + def test_list_collections(self): + """Test the listing out of registered collection schemas for vertices and edges.""" + for variant in ['schemas', 'collections']: + resp = requests.get(API_URL + '/specs/' + variant).json() + self.assertTrue(len(resp)) + for coll in ['test_edge', 'test_vertex', 'ncbi_taxon']: + self.assertIn(coll, resp) def test_fetch_schema_for_doc(self): """Given a document ID, fetch its schema.""" - resp = requests.get(API_URL + '/specs/schemas', params={'doc_id': 'test_vertex/123'}).json() - self.assertEqual(resp['name'], 'test_vertex') - self.assertEqual(resp['type'], 'vertex') - self.assertTrue(resp['schema']) + + for variant in ['schemas', 'collections']: + resp = requests.get( + API_URL + '/specs/' + variant, + params={'doc_id': 'test_vertex/123'} + ).json() + self.assertEqual(resp['name'], 'test_vertex') + self.assertEqual(resp['type'], 'vertex') + self.assertTrue(resp['schema']) + + def test_fetch_invalid_collections(self): + """Test the case where the collection/schema does not exist.""" + for variant in ['schemas', 'collections']: + resp = requests.get( + API_URL + '/specs/' + variant, + params={'name': 'xyzabc'}, + ).json() + self.assertEqual(resp['error'], 'Collection does not exist.') + + def test_fetch_invalid_documents(self): + """Test the case where the collection/schema does not exist.""" + for variant in ['schemas', 'collections']: + resp = requests.get( + API_URL + '/specs/' + variant, + params={'doc_id': 'fake_collection/123'}, + ).json() + self.assertEqual(resp['error'], 'Collection does not exist.') + + def test_fetch_invalid_queries(self): + """Test the case where the stored query does not exist.""" + resp = requests.get( + API_URL + '/specs/stored_queries', + params={'name': 'xyzabc'}, + ).json() + self.assertEqual(resp['error'], 'Stored query does not exist.') def test_save_documents_missing_auth(self): """Test an invalid attempt to save a doc with a missing auth token.""" @@ -170,7 +202,7 @@ def test_save_documents_missing_schema(self): data='', headers=HEADERS_ADMIN ).json() - self.assertTrue('Schema does not exist' in resp['error']) + self.assertTrue('Collection does not exist' in resp['error']) def test_save_documents_invalid_json(self): """Test an attempt to save documents with an invalid JSON body.""" diff --git a/relation_engine_server/utils/bulk_import.py b/relation_engine_server/utils/bulk_import.py index 1fd3e44d..8e520726 100644 --- a/relation_engine_server/utils/bulk_import.py +++ b/relation_engine_server/utils/bulk_import.py @@ -16,7 +16,7 @@ def bulk_import(query_params): schema, then write them into a temporary file that can be passed into the arango client. """ - schema = spec_loader.get_schema(query_params['collection']) + schema = spec_loader.get_collection(query_params['collection']) validator = get_schema_validator(schema=schema['schema']) # We can't use a context manager here # We need to close the file to have the file contents readable diff --git a/relation_engine_server/utils/config.py b/relation_engine_server/utils/config.py index 4cfe7fb1..f3c031b7 100644 --- a/relation_engine_server/utils/config.py +++ b/relation_engine_server/utils/config.py @@ -13,9 +13,9 @@ def get_config(): spec_release_url = os.environ.get('SPEC_RELEASE_URL') spec_release_path = os.environ.get('SPEC_RELEASE_PATH') spec_repo_path = os.path.join(spec_path, 'repo') # /spec/repo - spec_schemas_path = os.path.join(spec_repo_path, 'schemas') # /spec/repo/schemas + collections_path = os.path.join(spec_repo_path, 'collections') # /spec/repo/collections stored_queries_path = os.path.join(spec_repo_path, 'stored_queries') # /spec/repo/stored_queries - spec_views_path = os.path.join(spec_repo_path, 'views') # /spec/repo/views + views_path = os.path.join(spec_repo_path, 'views') # /spec/repo/views spec_url = 'https://api.github.com/repos/kbase/relation_engine_spec' kbase_endpoint = os.environ.get('KBASE_ENDPOINT', 'https://ci.kbase.us/services') auth_url = os.environ.get('KBASE_AUTH_URL', urljoin(kbase_endpoint + '/', 'auth')) @@ -45,10 +45,10 @@ def get_config(): 'release_id': os.path.join(spec_path, '.release_id'), 'root': spec_path, 'repo': spec_repo_path, - 'schemas': spec_schemas_path, + 'collections': collections_path, 'stored_queries': stored_queries_path, - 'views': spec_views_path, - 'vertices': os.path.join(spec_schemas_path, 'vertices'), + 'views': views_path, + 'vertices': os.path.join(collections_path, 'vertices'), # unused 'data_sources': os.path.join(spec_repo_path, 'data_sources'), } } diff --git a/relation_engine_server/utils/pull_spec.py b/relation_engine_server/utils/pull_spec.py index 48126b7f..f5681e11 100644 --- a/relation_engine_server/utils/pull_spec.py +++ b/relation_engine_server/utils/pull_spec.py @@ -46,8 +46,8 @@ def download_specs(init_collections=True, release_url=None, reset=False): def do_init_collections(): - """Initialize any uninitialized collections in the database from a set of schemas.""" - pattern = os.path.join(_CONF['spec_paths']['schemas'], '**', '*.yaml') + """Initialize any uninitialized collections in the database from a set of collection schemas.""" + pattern = os.path.join(_CONF['spec_paths']['collections'], '**', '*.yaml') for path in glob.iglob(pattern): coll_name = os.path.basename(os.path.splitext(path)[0]) with open(path) as fd: diff --git a/relation_engine_server/utils/spec_loader.py b/relation_engine_server/utils/spec_loader.py index 07210054..e0c9b50b 100644 --- a/relation_engine_server/utils/spec_loader.py +++ b/relation_engine_server/utils/spec_loader.py @@ -1,5 +1,5 @@ """ -Utilities for loading stored queries, schemas, and migrations from the spec. +Utilities for loading stored queries, collections, and migrations from the spec. """ import glob import os @@ -10,10 +10,10 @@ _CONF = get_config() -def get_schema_names(): +def get_collection_names(): """Return a dict of vertex and edge base names.""" names = [] # type: list - for path in _find_paths(_CONF['spec_paths']['schemas'], '*.yaml'): + for path in _find_paths(_CONF['spec_paths']['collections'], '*.yaml'): names.append(_get_file_name(path)) return names @@ -26,12 +26,12 @@ def get_stored_query_names(): return names -def get_schema(name): - """Get YAML content for a specific schema. Throws an error if nonexistent.""" +def get_collection(name): + """Get YAML content for a specific collection. Throws an error if nonexistent.""" try: - path = _find_paths(_CONF['spec_paths']['schemas'], name + '.yaml')[0] + path = _find_paths(_CONF['spec_paths']['collections'], name + '.yaml')[0] except IndexError: - raise SchemaNonexistent(name) + raise CollectionNonexistent(name) with open(path) as fd: return yaml.safe_load(fd) @@ -39,7 +39,7 @@ def get_schema(name): def get_schema_for_doc(doc_id): """Get the schema for a particular document by its full ID.""" (coll_name, _) = doc_id.split('/') - ret = get_schema(coll_name) + ret = get_collection(coll_name) return ret @@ -69,6 +69,16 @@ def _get_file_name(path): return os.path.splitext(os.path.basename(path))[0] +class CollectionNonexistent(Exception): + """Requested collection is not in the spec.""" + + def __init__(self, name): + self.name = name + + def __str__(self): + return 'Collection does not exist.' + + class StoredQueryNonexistent(Exception): """Requested stored query is not in the spec.""" diff --git a/spec/README.md b/spec/README.md index 9ce4e777..7eb975bc 100644 --- a/spec/README.md +++ b/spec/README.md @@ -1,12 +1,12 @@ # Relation Engine Spec -This repo holds the [stored queries](spec/stored_queries), [schemas](spec/schemas), and [migrations](migrations) for the relation engine graph database service. +This repo holds the [stored queries](spec/stored_queries), [collections](spec/collections), and [migrations](migrations) for the relation engine graph database service. These specifications are used by the [Relation Engine API](relation_engine_server). * **[Stored queries](spec/stored_queries)** are stored [AQL queries](https://docs.arangodb.com/3.5/AQL/index.html) that can be used by KBase apps to fetch data from the database. -* **[Collections, or document schemas,](spec/schemas)** are [JSON schemas](https://json-schema.org/) that define what form of data can be stored in the database's collections. +* **[Collections, or document schemas,](spec/collections)** are [JSON schemas](https://json-schema.org/) that define what form of data can be stored in the database's collections. * **[Data sources](spec/data_sources)** contain general information about where some of our imported data comes from. * **[Views](spec/views)** are raw ArangoSearch view configuration files diff --git a/spec/schemas/ENVO/ENVO_edges.yaml b/spec/collections/ENVO/ENVO_edges.yaml similarity index 100% rename from spec/schemas/ENVO/ENVO_edges.yaml rename to spec/collections/ENVO/ENVO_edges.yaml diff --git a/spec/schemas/ENVO/ENVO_merges.yaml b/spec/collections/ENVO/ENVO_merges.yaml similarity index 100% rename from spec/schemas/ENVO/ENVO_merges.yaml rename to spec/collections/ENVO/ENVO_merges.yaml diff --git a/spec/schemas/ENVO/ENVO_terms.yaml b/spec/collections/ENVO/ENVO_terms.yaml similarity index 100% rename from spec/schemas/ENVO/ENVO_terms.yaml rename to spec/collections/ENVO/ENVO_terms.yaml diff --git a/spec/schemas/GO/GO_edges.yaml b/spec/collections/GO/GO_edges.yaml similarity index 100% rename from spec/schemas/GO/GO_edges.yaml rename to spec/collections/GO/GO_edges.yaml diff --git a/spec/schemas/GO/GO_merges.yaml b/spec/collections/GO/GO_merges.yaml similarity index 100% rename from spec/schemas/GO/GO_merges.yaml rename to spec/collections/GO/GO_merges.yaml diff --git a/spec/schemas/GO/GO_terms.yaml b/spec/collections/GO/GO_terms.yaml similarity index 100% rename from spec/schemas/GO/GO_terms.yaml rename to spec/collections/GO/GO_terms.yaml diff --git a/spec/schemas/README.md b/spec/collections/README.md similarity index 100% rename from spec/schemas/README.md rename to spec/collections/README.md diff --git a/spec/schemas/deltaloader/delta_load_registry.yaml b/spec/collections/deltaloader/delta_load_registry.yaml similarity index 100% rename from spec/schemas/deltaloader/delta_load_registry.yaml rename to spec/collections/deltaloader/delta_load_registry.yaml diff --git a/spec/schemas/djornl/djornl_edge.yaml b/spec/collections/djornl/djornl_edge.yaml similarity index 100% rename from spec/schemas/djornl/djornl_edge.yaml rename to spec/collections/djornl/djornl_edge.yaml diff --git a/spec/schemas/djornl/djornl_node.yaml b/spec/collections/djornl/djornl_node.yaml similarity index 100% rename from spec/schemas/djornl/djornl_node.yaml rename to spec/collections/djornl/djornl_node.yaml diff --git a/spec/schemas/gtdb/README.md b/spec/collections/gtdb/README.md similarity index 100% rename from spec/schemas/gtdb/README.md rename to spec/collections/gtdb/README.md diff --git a/spec/schemas/gtdb/gtdb_child_of_taxon.yaml b/spec/collections/gtdb/gtdb_child_of_taxon.yaml similarity index 100% rename from spec/schemas/gtdb/gtdb_child_of_taxon.yaml rename to spec/collections/gtdb/gtdb_child_of_taxon.yaml diff --git a/spec/schemas/gtdb/gtdb_taxon.yaml b/spec/collections/gtdb/gtdb_taxon.yaml similarity index 100% rename from spec/schemas/gtdb/gtdb_taxon.yaml rename to spec/collections/gtdb/gtdb_taxon.yaml diff --git a/spec/schemas/mash/mash_genome_similar_to.yaml b/spec/collections/mash/mash_genome_similar_to.yaml similarity index 100% rename from spec/schemas/mash/mash_genome_similar_to.yaml rename to spec/collections/mash/mash_genome_similar_to.yaml diff --git a/spec/schemas/ncbi/README.md b/spec/collections/ncbi/README.md similarity index 100% rename from spec/schemas/ncbi/README.md rename to spec/collections/ncbi/README.md diff --git a/spec/schemas/ncbi/ncbi_child_of_taxon.yaml b/spec/collections/ncbi/ncbi_child_of_taxon.yaml similarity index 100% rename from spec/schemas/ncbi/ncbi_child_of_taxon.yaml rename to spec/collections/ncbi/ncbi_child_of_taxon.yaml diff --git a/spec/schemas/ncbi/ncbi_gene.yaml b/spec/collections/ncbi/ncbi_gene.yaml similarity index 100% rename from spec/schemas/ncbi/ncbi_gene.yaml rename to spec/collections/ncbi/ncbi_gene.yaml diff --git a/spec/schemas/ncbi/ncbi_gene_within_genome.yaml b/spec/collections/ncbi/ncbi_gene_within_genome.yaml similarity index 100% rename from spec/schemas/ncbi/ncbi_gene_within_genome.yaml rename to spec/collections/ncbi/ncbi_gene_within_genome.yaml diff --git a/spec/schemas/ncbi/ncbi_genome.yaml b/spec/collections/ncbi/ncbi_genome.yaml similarity index 100% rename from spec/schemas/ncbi/ncbi_genome.yaml rename to spec/collections/ncbi/ncbi_genome.yaml diff --git a/spec/schemas/ncbi/ncbi_taxon.yaml b/spec/collections/ncbi/ncbi_taxon.yaml similarity index 100% rename from spec/schemas/ncbi/ncbi_taxon.yaml rename to spec/collections/ncbi/ncbi_taxon.yaml diff --git a/spec/schemas/ncbi/ncbi_taxon_merges.yaml b/spec/collections/ncbi/ncbi_taxon_merges.yaml similarity index 100% rename from spec/schemas/ncbi/ncbi_taxon_merges.yaml rename to spec/collections/ncbi/ncbi_taxon_merges.yaml diff --git a/spec/schemas/rdp/README.md b/spec/collections/rdp/README.md similarity index 100% rename from spec/schemas/rdp/README.md rename to spec/collections/rdp/README.md diff --git a/spec/schemas/rdp/rdp_child_of_taxon.yaml b/spec/collections/rdp/rdp_child_of_taxon.yaml similarity index 100% rename from spec/schemas/rdp/rdp_child_of_taxon.yaml rename to spec/collections/rdp/rdp_child_of_taxon.yaml diff --git a/spec/schemas/rdp/rdp_taxon.yaml b/spec/collections/rdp/rdp_taxon.yaml similarity index 100% rename from spec/schemas/rdp/rdp_taxon.yaml rename to spec/collections/rdp/rdp_taxon.yaml diff --git a/spec/schemas/rxn/README.md b/spec/collections/rxn/README.md similarity index 100% rename from spec/schemas/rxn/README.md rename to spec/collections/rxn/README.md diff --git a/spec/schemas/rxn/rxn_compound.yaml b/spec/collections/rxn/rxn_compound.yaml similarity index 100% rename from spec/schemas/rxn/rxn_compound.yaml rename to spec/collections/rxn/rxn_compound.yaml diff --git a/spec/schemas/rxn/rxn_compound_linked_to_compound.yaml b/spec/collections/rxn/rxn_compound_linked_to_compound.yaml similarity index 100% rename from spec/schemas/rxn/rxn_compound_linked_to_compound.yaml rename to spec/collections/rxn/rxn_compound_linked_to_compound.yaml diff --git a/spec/schemas/rxn/rxn_compound_within_reaction.yaml b/spec/collections/rxn/rxn_compound_within_reaction.yaml similarity index 100% rename from spec/schemas/rxn/rxn_compound_within_reaction.yaml rename to spec/collections/rxn/rxn_compound_within_reaction.yaml diff --git a/spec/schemas/rxn/rxn_gene_complex.yaml b/spec/collections/rxn/rxn_gene_complex.yaml similarity index 100% rename from spec/schemas/rxn/rxn_gene_complex.yaml rename to spec/collections/rxn/rxn_gene_complex.yaml diff --git a/spec/schemas/rxn/rxn_gene_within_complex.yaml b/spec/collections/rxn/rxn_gene_within_complex.yaml similarity index 100% rename from spec/schemas/rxn/rxn_gene_within_complex.yaml rename to spec/collections/rxn/rxn_gene_within_complex.yaml diff --git a/spec/schemas/rxn/rxn_reaction.yaml b/spec/collections/rxn/rxn_reaction.yaml similarity index 100% rename from spec/schemas/rxn/rxn_reaction.yaml rename to spec/collections/rxn/rxn_reaction.yaml diff --git a/spec/schemas/rxn/rxn_reaction_linked_to_reaction.yaml b/spec/collections/rxn/rxn_reaction_linked_to_reaction.yaml similarity index 100% rename from spec/schemas/rxn/rxn_reaction_linked_to_reaction.yaml rename to spec/collections/rxn/rxn_reaction_linked_to_reaction.yaml diff --git a/spec/schemas/rxn/rxn_reaction_within_complex.yaml b/spec/collections/rxn/rxn_reaction_within_complex.yaml similarity index 100% rename from spec/schemas/rxn/rxn_reaction_within_complex.yaml rename to spec/collections/rxn/rxn_reaction_within_complex.yaml diff --git a/spec/schemas/rxn/rxn_similar_to_reaction.yaml b/spec/collections/rxn/rxn_similar_to_reaction.yaml similarity index 100% rename from spec/schemas/rxn/rxn_similar_to_reaction.yaml rename to spec/collections/rxn/rxn_similar_to_reaction.yaml diff --git a/spec/schemas/test/test_edge.yaml b/spec/collections/test/test_edge.yaml similarity index 100% rename from spec/schemas/test/test_edge.yaml rename to spec/collections/test/test_edge.yaml diff --git a/spec/schemas/test/test_vertex.yaml b/spec/collections/test/test_vertex.yaml similarity index 100% rename from spec/schemas/test/test_vertex.yaml rename to spec/collections/test/test_vertex.yaml diff --git a/spec/schemas/ws/README.md b/spec/collections/ws/README.md similarity index 100% rename from spec/schemas/ws/README.md rename to spec/collections/ws/README.md diff --git a/spec/schemas/ws/ws_copied_from.yaml b/spec/collections/ws/ws_copied_from.yaml similarity index 100% rename from spec/schemas/ws/ws_copied_from.yaml rename to spec/collections/ws/ws_copied_from.yaml diff --git a/spec/schemas/ws/ws_feature_has_GO_annotation.yaml b/spec/collections/ws/ws_feature_has_GO_annotation.yaml similarity index 100% rename from spec/schemas/ws/ws_feature_has_GO_annotation.yaml rename to spec/collections/ws/ws_feature_has_GO_annotation.yaml diff --git a/spec/schemas/ws/ws_genome_features.yaml b/spec/collections/ws/ws_genome_features.yaml similarity index 100% rename from spec/schemas/ws/ws_genome_features.yaml rename to spec/collections/ws/ws_genome_features.yaml diff --git a/spec/schemas/ws/ws_genome_has_feature.yaml b/spec/collections/ws/ws_genome_has_feature.yaml similarity index 100% rename from spec/schemas/ws/ws_genome_has_feature.yaml rename to spec/collections/ws/ws_genome_has_feature.yaml diff --git a/spec/schemas/ws/ws_has_perm.yaml b/spec/collections/ws/ws_has_perm.yaml similarity index 100% rename from spec/schemas/ws/ws_has_perm.yaml rename to spec/collections/ws/ws_has_perm.yaml diff --git a/spec/schemas/ws/ws_latest_version_of.yaml b/spec/collections/ws/ws_latest_version_of.yaml similarity index 100% rename from spec/schemas/ws/ws_latest_version_of.yaml rename to spec/collections/ws/ws_latest_version_of.yaml diff --git a/spec/schemas/ws/ws_method.yaml b/spec/collections/ws/ws_method.yaml similarity index 100% rename from spec/schemas/ws/ws_method.yaml rename to spec/collections/ws/ws_method.yaml diff --git a/spec/schemas/ws/ws_method_version.yaml b/spec/collections/ws/ws_method_version.yaml similarity index 100% rename from spec/schemas/ws/ws_method_version.yaml rename to spec/collections/ws/ws_method_version.yaml diff --git a/spec/schemas/ws/ws_module.yaml b/spec/collections/ws/ws_module.yaml similarity index 100% rename from spec/schemas/ws/ws_module.yaml rename to spec/collections/ws/ws_module.yaml diff --git a/spec/schemas/ws/ws_module_contains_method.yaml b/spec/collections/ws/ws_module_contains_method.yaml similarity index 100% rename from spec/schemas/ws/ws_module_contains_method.yaml rename to spec/collections/ws/ws_module_contains_method.yaml diff --git a/spec/schemas/ws/ws_module_version.yaml b/spec/collections/ws/ws_module_version.yaml similarity index 100% rename from spec/schemas/ws/ws_module_version.yaml rename to spec/collections/ws/ws_module_version.yaml diff --git a/spec/schemas/ws/ws_obj_created_with_method.yaml b/spec/collections/ws/ws_obj_created_with_method.yaml similarity index 100% rename from spec/schemas/ws/ws_obj_created_with_method.yaml rename to spec/collections/ws/ws_obj_created_with_method.yaml diff --git a/spec/schemas/ws/ws_obj_created_with_module.yaml b/spec/collections/ws/ws_obj_created_with_module.yaml similarity index 100% rename from spec/schemas/ws/ws_obj_created_with_module.yaml rename to spec/collections/ws/ws_obj_created_with_module.yaml diff --git a/spec/schemas/ws/ws_obj_instance_of_type.yaml b/spec/collections/ws/ws_obj_instance_of_type.yaml similarity index 100% rename from spec/schemas/ws/ws_obj_instance_of_type.yaml rename to spec/collections/ws/ws_obj_instance_of_type.yaml diff --git a/spec/schemas/ws/ws_obj_version_has_taxon.yaml b/spec/collections/ws/ws_obj_version_has_taxon.yaml similarity index 100% rename from spec/schemas/ws/ws_obj_version_has_taxon.yaml rename to spec/collections/ws/ws_obj_version_has_taxon.yaml diff --git a/spec/schemas/ws/ws_object.yaml b/spec/collections/ws/ws_object.yaml similarity index 100% rename from spec/schemas/ws/ws_object.yaml rename to spec/collections/ws/ws_object.yaml diff --git a/spec/schemas/ws/ws_object_hash.yaml b/spec/collections/ws/ws_object_hash.yaml similarity index 100% rename from spec/schemas/ws/ws_object_hash.yaml rename to spec/collections/ws/ws_object_hash.yaml diff --git a/spec/schemas/ws/ws_object_version.yaml b/spec/collections/ws/ws_object_version.yaml similarity index 100% rename from spec/schemas/ws/ws_object_version.yaml rename to spec/collections/ws/ws_object_version.yaml diff --git a/spec/schemas/ws/ws_owner_of.yaml b/spec/collections/ws/ws_owner_of.yaml similarity index 100% rename from spec/schemas/ws/ws_owner_of.yaml rename to spec/collections/ws/ws_owner_of.yaml diff --git a/spec/schemas/ws/ws_prov_descendant_of.yaml b/spec/collections/ws/ws_prov_descendant_of.yaml similarity index 100% rename from spec/schemas/ws/ws_prov_descendant_of.yaml rename to spec/collections/ws/ws_prov_descendant_of.yaml diff --git a/spec/schemas/ws/ws_refers_to.yaml b/spec/collections/ws/ws_refers_to.yaml similarity index 100% rename from spec/schemas/ws/ws_refers_to.yaml rename to spec/collections/ws/ws_refers_to.yaml diff --git a/spec/schemas/ws/ws_type.yaml b/spec/collections/ws/ws_type.yaml similarity index 100% rename from spec/schemas/ws/ws_type.yaml rename to spec/collections/ws/ws_type.yaml diff --git a/spec/schemas/ws/ws_type_consumed_by_method.yaml b/spec/collections/ws/ws_type_consumed_by_method.yaml similarity index 100% rename from spec/schemas/ws/ws_type_consumed_by_method.yaml rename to spec/collections/ws/ws_type_consumed_by_method.yaml diff --git a/spec/schemas/ws/ws_type_module.yaml b/spec/collections/ws/ws_type_module.yaml similarity index 100% rename from spec/schemas/ws/ws_type_module.yaml rename to spec/collections/ws/ws_type_module.yaml diff --git a/spec/schemas/ws/ws_type_version.yaml b/spec/collections/ws/ws_type_version.yaml similarity index 100% rename from spec/schemas/ws/ws_type_version.yaml rename to spec/collections/ws/ws_type_version.yaml diff --git a/spec/schemas/ws/ws_user.yaml b/spec/collections/ws/ws_user.yaml similarity index 100% rename from spec/schemas/ws/ws_user.yaml rename to spec/collections/ws/ws_user.yaml diff --git a/spec/schemas/ws/ws_version_of.yaml b/spec/collections/ws/ws_version_of.yaml similarity index 100% rename from spec/schemas/ws/ws_version_of.yaml rename to spec/collections/ws/ws_version_of.yaml diff --git a/spec/schemas/ws/ws_workspace.yaml b/spec/collections/ws/ws_workspace.yaml similarity index 100% rename from spec/schemas/ws/ws_workspace.yaml rename to spec/collections/ws/ws_workspace.yaml diff --git a/spec/schemas/ws/ws_workspace_contains_obj.yaml b/spec/collections/ws/ws_workspace_contains_obj.yaml similarity index 100% rename from spec/schemas/ws/ws_workspace_contains_obj.yaml rename to spec/collections/ws/ws_workspace_contains_obj.yaml diff --git a/spec/schemas/wsprov/README.md b/spec/collections/wsprov/README.md similarity index 100% rename from spec/schemas/wsprov/README.md rename to spec/collections/wsprov/README.md diff --git a/spec/schemas/wsprov/wsprov_action.yaml b/spec/collections/wsprov/wsprov_action.yaml similarity index 100% rename from spec/schemas/wsprov/wsprov_action.yaml rename to spec/collections/wsprov/wsprov_action.yaml diff --git a/spec/schemas/wsprov/wsprov_copied_into.yaml b/spec/collections/wsprov/wsprov_copied_into.yaml similarity index 100% rename from spec/schemas/wsprov/wsprov_copied_into.yaml rename to spec/collections/wsprov/wsprov_copied_into.yaml diff --git a/spec/schemas/wsprov/wsprov_input_in.yaml b/spec/collections/wsprov/wsprov_input_in.yaml similarity index 100% rename from spec/schemas/wsprov/wsprov_input_in.yaml rename to spec/collections/wsprov/wsprov_input_in.yaml diff --git a/spec/schemas/wsprov/wsprov_links.yaml b/spec/collections/wsprov/wsprov_links.yaml similarity index 100% rename from spec/schemas/wsprov/wsprov_links.yaml rename to spec/collections/wsprov/wsprov_links.yaml diff --git a/spec/schemas/wsprov/wsprov_object.yaml b/spec/collections/wsprov/wsprov_object.yaml similarity index 100% rename from spec/schemas/wsprov/wsprov_object.yaml rename to spec/collections/wsprov/wsprov_object.yaml diff --git a/spec/schemas/wsprov/wsprov_produced.yaml b/spec/collections/wsprov/wsprov_produced.yaml similarity index 100% rename from spec/schemas/wsprov/wsprov_produced.yaml rename to spec/collections/wsprov/wsprov_produced.yaml diff --git a/spec/validate.py b/spec/validate.py index 3056d0ea..dec6b6dc 100644 --- a/spec/validate.py +++ b/spec/validate.py @@ -26,7 +26,7 @@ }, 'collection': { 'file': os.path.join(_BASE_DIR, 'collection_schema.yaml'), - 'plural': 'schemas', + 'plural': 'collections', }, 'view': { 'file': os.path.join(_BASE_DIR, 'view_schema.yaml'), From e7f060af1849da6606cbf01b564e83bc5eaf978a Mon Sep 17 00:00:00 2001 From: ialarmedalien Date: Thu, 6 Aug 2020 15:33:56 -0700 Subject: [PATCH 549/732] Removing unneeded SchemaNonexistent class and marking the /schema endpoint as deprecated --- relation_engine_server/README.md | 11 ++++++++--- relation_engine_server/main.py | 1 - relation_engine_server/utils/arango_client.py | 2 -- relation_engine_server/utils/config.py | 1 - relation_engine_server/utils/spec_loader.py | 10 ---------- 5 files changed, 8 insertions(+), 17 deletions(-) diff --git a/relation_engine_server/README.md b/relation_engine_server/README.md index aaae50a3..27a4dba5 100644 --- a/relation_engine_server/README.md +++ b/relation_engine_server/README.md @@ -264,9 +264,7 @@ _Query params_ Every call to update specs will reset the spec data (do a clean download and overwrite). -### GET /api/v1/specs/collections or /api/v1/specs/schemas - -Both `collections` and `schemas` return the same data. +### GET /api/v1/specs/collections Get all collection names (returns an array of strings): @@ -336,6 +334,13 @@ curl -X PUT -H "Authorization: " \ "https://ci.kbase.us/services/relation_engine_api/api/v1/specs?init_collections=1 ``` +## Deprecated Endpoints + +#### GET `/api/v1/specs/schemas` (replaced by `/api/v1/specs/schemas`) + +This endpoint has been deprecated; queries should use `/api/v1/specs/schemas` instead. + + ## Development See the [Contribution Guidelines](/.github/CONTRIBUTING.md). diff --git a/relation_engine_server/main.py b/relation_engine_server/main.py index d04f691c..5e5a249a 100644 --- a/relation_engine_server/main.py +++ b/relation_engine_server/main.py @@ -65,7 +65,6 @@ def invalid_params(err): @app.errorhandler(spec_loader.CollectionNonexistent) -@app.errorhandler(spec_loader.SchemaNonexistent) @app.errorhandler(spec_loader.StoredQueryNonexistent) def view_does_not_exist(err): """General error cases.""" diff --git a/relation_engine_server/utils/arango_client.py b/relation_engine_server/utils/arango_client.py index ea75e47b..3606ec38 100644 --- a/relation_engine_server/utils/arango_client.py +++ b/relation_engine_server/utils/arango_client.py @@ -45,8 +45,6 @@ def run_query(query_text=None, cursor_id=None, bind_vars=None, batch_size=10000, req_json['options'] = {'fullCount': True} if bind_vars: req_json['bindVars'] = bind_vars - # Initialize the readonly user - # _init_readonly_user() # Run the query as the readonly user resp = requests.request( method, diff --git a/relation_engine_server/utils/config.py b/relation_engine_server/utils/config.py index f3c031b7..156d37b8 100644 --- a/relation_engine_server/utils/config.py +++ b/relation_engine_server/utils/config.py @@ -48,7 +48,6 @@ def get_config(): 'collections': collections_path, 'stored_queries': stored_queries_path, 'views': views_path, - 'vertices': os.path.join(collections_path, 'vertices'), # unused 'data_sources': os.path.join(spec_repo_path, 'data_sources'), } } diff --git a/relation_engine_server/utils/spec_loader.py b/relation_engine_server/utils/spec_loader.py index e0c9b50b..86e40a94 100644 --- a/relation_engine_server/utils/spec_loader.py +++ b/relation_engine_server/utils/spec_loader.py @@ -87,13 +87,3 @@ def __init__(self, name): def __str__(self): return 'Stored query does not exist.' - - -class SchemaNonexistent(Exception): - """Requested schema is not in the spec.""" - - def __init__(self, name): - self.name = name - - def __str__(self): - return 'Schema does not exist.' From 18f93fd93f8064667cf56ac152481112cdc7e936 Mon Sep 17 00:00:00 2001 From: ialarmedalien Date: Mon, 10 Aug 2020 10:49:54 -0700 Subject: [PATCH 550/732] Add URI validation tests Extend RefResolver to cope with local refs and yaml files --- .../test/test_json_validation.py | 224 +++++++++++++++++- .../utils/json_validation.py | 62 ++++- requirements.txt | 1 + .../deltaloader/delta_load_registry.yaml | 2 +- spec/data_sources/djornl.yaml | 4 +- spec/data_sources/envo_ontology.yaml | 6 +- spec/data_sources/go_ontology.yaml | 6 +- spec/data_sources/gtdb.yaml | 6 +- spec/data_sources/ncbi_taxonomy.yaml | 6 +- spec/data_sources/rdp_taxonomy.yaml | 6 +- spec/test/test_validate.py | 8 +- 11 files changed, 302 insertions(+), 29 deletions(-) diff --git a/relation_engine_server/test/test_json_validation.py b/relation_engine_server/test/test_json_validation.py index cc9b3571..a45712cd 100644 --- a/relation_engine_server/test/test_json_validation.py +++ b/relation_engine_server/test/test_json_validation.py @@ -2,6 +2,8 @@ Test JSON validation functions """ import unittest +import os.path as os_path +from yaml import safe_load from relation_engine_server.utils.json_validation import run_validator from jsonschema.exceptions import ValidationError from jsonpointer import JsonPointerException @@ -15,7 +17,7 @@ 'name': { 'type': 'string', 'format': 'regex', - 'pattern': '^\\w+$', + 'pattern': '^\w+$', 'default': 'blank', }, 'distance': { @@ -29,6 +31,14 @@ 'format': 'uri', }, 'creation_date': { + 'title': 'date of creation', + 'description': 'Approx six thousand years ago', + 'type': 'string', + 'format': 'date', + }, + 'date': { + 'title': 'date', + 'description': 'A type of dried fruit', 'type': 'string', 'format': 'date', } @@ -37,10 +47,87 @@ } } +test_schema_two = { + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "Exascale parser file manifest", + "type": "object", + "required": ["name", "file_list"], + "properties": { + "name": { + "title": "Dataset name", + "type": "string", + "description": "The name of the dataset", + "examples": ["Dan Jacobson Exascale dataset"] + }, + "release_date": { + "title": "Release date", + "type": "string", + "description": "Date of the dataset release, in YYYY-MM-DD format", + "format": "date" + }, + "notes": { + "type": "string", + "title": "Release notes", + "description": "Free text describing the release and any notes, or comments relevant to consumers of the data." + }, + "file_list": { + "type": "array", + "items": { + "type": "object", + "required": ["data_type", "path"], + "oneOf": [ + { + "properties": { + "data_type": {"enum": ["cluster"]} + }, + "required": ["cluster_prefix"] + }, + { + "properties": { + "data_type": {"enum": ["node", "edge"]} + } + } + ], + "properties": { + "data_type": { + "title": "Data type", + "type": "string", + "enum": ["node", "edge", "cluster"] + }, + "date": { + "title": "File creation date", + "description": "date of file creation in the format YYYY-MM-DD", + "type": "string", + "format": "date" + }, + "description": { + "title": "Description of the cluster set", + "type": "string" + }, + "path": { + "title": "File path", + "type": "string" + }, + "cluster_prefix": { + "title": "Prefix", + "type": "string", + "description": "The prefix to be used for clusters" + }, + "title": { + "title": "Name of the cluster set", + "type": "string" + } + } + } + } + } +} + + valid_json_loc = '/properties/params' -class TestUtils(unittest.TestCase): +class TestJsonValidation(unittest.TestCase): def test_non_validation_validator_errors(self): '''test errors in the validator that are unrelated to the valiation functionality''' @@ -109,6 +196,24 @@ def test_pattern_validation(self): validate_at=valid_json_loc) self.assertEqual(output, {'name': 'Mr_Blobby_666', 'distance': 3}) + def test_uri_validation(self): + '''Test URI validation is operational''' + + err_str = "'where is it\?' is not a 'uri'" + with self.assertRaisesRegex(ValidationError, err_str): + run_validator( + schema=test_schema, + data={'name': 'blank', 'distance': 3, 'home_page': 'where is it?'}, + validate_at=valid_json_loc) + + # this string is OK + input = {'name': 'blank', 'distance': 3, 'home_page': 'http://www.home/com'} + output = run_validator( + schema=test_schema, + data=input, + validate_at=valid_json_loc) + self.assertEqual(output, input) + def test_date_format_validation(self): '''ensure that fancy date formats are correctly validated''' @@ -120,9 +225,124 @@ def test_date_format_validation(self): data=input, validate_at=valid_json_loc) + # date field NAMED date! + err_str = "'12345678' is not a 'date'" + with self.assertRaisesRegex(ValidationError, err_str): + input = {'name': 'whatever', 'distance': 1, 'date': '12345678'} + run_validator( + schema=test_schema, + data=input, + validate_at=valid_json_loc) + input = {'name': 'whatever', 'distance': 1, 'creation_date': '2020-05-23'} output = run_validator( schema=test_schema, data=input, validate_at=valid_json_loc) self.assertEqual(input, output) + + # use the manifest schema + with self.assertRaisesRegex(ValidationError, err_str): + run_validator( + schema=test_schema_two, + data={'name': 'a', 'file_list': [], 'release_date': '12345678'} + ) + + with self.assertRaisesRegex(ValidationError, err_str): + run_validator( + schema_file='/app/importers/djornl/manifest.schema.json', + data={'name': 'a', 'file_list': [], 'release_date': '12345678'} + ) + + # valid inputs + more_input = {'name': 'a', 'file_list': [], 'release_date': '1999-12-31'} + more_output = run_validator( + schema=test_schema_two, + data=more_input + ) + self.assertEqual(more_input, more_output) + + more_output = run_validator( + schema_file='/app/importers/djornl/manifest.schema.json', + data=more_input + ) + self.assertEqual(more_input, more_output) + + def test_valid_manifest_validation(self): + """ensure that a valid manifest passes validation""" + + manifest_schema = '/app/importers/djornl/manifest.schema.json' + test_dir = '/app/spec/test/djornl/' + with open(os_path.join(test_dir, 'test_data', 'manifest.yaml')) as fd: + file_contents = safe_load(fd) + + # raw data + manifest_data = run_validator( + schema_file=manifest_schema, + data=file_contents, + nicer_errors=True + ) + self.assertTrue(manifest_data) + + # data file + manifest_data = run_validator( + schema_file=manifest_schema, + data_file=os_path.join(test_dir, 'test_data', 'manifest.yaml'), + nicer_errors=True + ) + self.assertTrue(manifest_data) + + # data file + manifest_data = run_validator( + schema_file=manifest_schema, + data_file=os_path.join(test_dir, 'valid', 'with_descriptions.yaml'), + nicer_errors=True + ) + self.assertTrue(manifest_data) + + def test_schema_references(self): + """ensure referenced schemas can be accessed""" + + valid_edge_data = { + "_from": "here", + "_to": "eternity", + "score": 1.23456, + "_key": "abcdefg", + "edge_type": "domain_co_occur", + } + + invalid_edge_data = { + "_from": "here", + "_to": "eternity", + "score": 1.23456, + "_key": "abcdefg", + "edge_type": "whatever", + } + + schema_ref_dir = ['/app', 'spec', 'test', 'sample_schemas', 'schema_refs'] + + # same schema in different places + path_list = [ + [], + ['level_1'], + ['level_1', 'level_2'] + ] + + err_msg = "'whatever' is not valid under any of the given schemas" + for path in path_list: + + for file_ext in ['json', 'yaml']: + file_path = os_path.join(*(schema_ref_dir + path), 'edge.' + file_ext) + with self.assertRaisesRegex(ValidationError, err_msg): + run_validator( + schema_file=file_path, + data=invalid_edge_data, + ) + + self.assertEqual( + run_validator( + schema_file=file_path, + data=valid_edge_data, + ), + valid_edge_data + ) diff --git a/relation_engine_server/utils/json_validation.py b/relation_engine_server/utils/json_validation.py index 9dcb9d76..da2f9c79 100644 --- a/relation_engine_server/utils/json_validation.py +++ b/relation_engine_server/utils/json_validation.py @@ -10,10 +10,17 @@ Validator(schema).validate(obj) assert obj == {'foo': 'bar'} """ -from jsonschema import validators, Draft7Validator, FormatChecker +from jsonschema import validators, Draft7Validator, FormatChecker, RefResolver + +from jsonschema.compat import ( + urlopen, + urlsplit, +) +from jsonschema.exceptions import ValidationError from jsonpointer import resolve_pointer import yaml import json +import requests def extend_with_default(validator_class): @@ -50,7 +57,7 @@ def get_schema_validator(schema=None, schema_file=None, validate_at=""): """ - if schema is None and schema_file is None or schema is not None and schema_file is not None: + if schema == schema_file and schema is None or schema is not None and schema_file is not None: raise ValueError("Please supply either a schema or a schema file path") # schema to validate against @@ -60,10 +67,19 @@ def get_schema_validator(schema=None, schema_file=None, validate_at=""): # get the appropriate location in the schema validation_schema = resolve_pointer(schema, validate_at) - return Validator(validation_schema, format_checker=FormatChecker()) + if schema_file: + resolver = ExtendedRefResolver(schema_file, schema) + else: + resolver = ExtendedRefResolver.from_schema(schema) + + return Validator( + validation_schema, + format_checker=FormatChecker(), + resolver=resolver + ) -def run_validator(schema=None, schema_file=None, validate_at="", data=None, data_file=None): +def run_validator(schema=None, schema_file=None, validate_at="", data=None, data_file=None, nicer_errors=False): """ Validate data against a schema, filling in defaults if appropriate @@ -99,8 +115,13 @@ def run_validator(schema=None, schema_file=None, validate_at="", data=None, data if validator.is_valid(data): return data - # this will throw a ValidationError - validator.validate(data) + if not nicer_errors: + # this will throw a ValidationError + validator.validate(data) + + err_msg = "".join(e.message + "\n" for e in sorted(validator.iter_errors(data), key=str)) + + raise ValidationError(err_msg) def _load_json_schema(file): @@ -114,3 +135,32 @@ def _load_json_schema(file): return json.load(fd) raise TypeError('Unknown file type encountered: ' + file) + + +class ExtendedRefResolver(RefResolver): + + def resolve_remote(self, uri): + + scheme = urlsplit(uri).scheme + # if there's no scheme, it's a local file, so prefix it with "file://" + if scheme == '': + uri = 'file://' + uri + + if scheme in self.handlers: + result = self.handlers[scheme](uri) + elif scheme in [u"http", u"https"]: + # Requests has support for detecting the correct encoding of + # json over http + result = requests.get(uri).json() + else: + # Otherwise, pass off to urllib and assume utf-8 + with urlopen(uri) as url: + content = url.read().decode("utf-8") + if uri.endswith('.yaml') or uri.endswith('.yml'): + result = yaml.safe_load(content) + else: + result = json.loads(content) + + if self.cache_remote: + self.store[uri] = result + return result diff --git a/requirements.txt b/requirements.txt index 7a01e57c..e8b9563e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,3 +8,4 @@ jsonpointer==2.0 jsonschema==3.2.0 jsonschema[format]==3.2.0 pyyaml==5.1.1 +rfc3987==1.3.8 diff --git a/spec/collections/deltaloader/delta_load_registry.yaml b/spec/collections/deltaloader/delta_load_registry.yaml index dc9c7f86..419b2a78 100644 --- a/spec/collections/deltaloader/delta_load_registry.yaml +++ b/spec/collections/deltaloader/delta_load_registry.yaml @@ -5,7 +5,7 @@ schema: "$schema": http://json-schema.org/draft-07/schema# title: delta_load_registry type: object - description: Don't touch this. It's for the exlusive use of delta loaders. + description: Don't touch this. It's for the exclusive use of delta loaders. properties: _key: type: string diff --git a/spec/data_sources/djornl.yaml b/spec/data_sources/djornl.yaml index 495aa8af..1fb27f23 100644 --- a/spec/data_sources/djornl.yaml +++ b/spec/data_sources/djornl.yaml @@ -1,5 +1,5 @@ name: djornl category: network title: Jacobson Lab Exascale Networking data -home_url: https://github.com/kbase/exascale_data -data_url: https://github.com/kbase/exascale_data/releases/latest +home_url: "https://github.com/kbase/exascale_data" +data_url: "https://github.com/kbase/exascale_data/releases/latest" diff --git a/spec/data_sources/envo_ontology.yaml b/spec/data_sources/envo_ontology.yaml index 0b138c35..03cce27f 100644 --- a/spec/data_sources/envo_ontology.yaml +++ b/spec/data_sources/envo_ontology.yaml @@ -1,6 +1,6 @@ name: envo_ontology category: ontology title: Environment Ontology -home_url: http://www.obofoundry.org/ontology/envo.html -data_url: https://github.com/EnvironmentOntology/envo/releases -logo_path: /images/third-party-data-sources/envo/logo-119-64.png +home_url: "http://www.obofoundry.org/ontology/envo.html" +data_url: "https://github.com/EnvironmentOntology/envo/releases" +logo_path: "/images/third-party-data-sources/envo/logo-119-64.png" diff --git a/spec/data_sources/go_ontology.yaml b/spec/data_sources/go_ontology.yaml index 21cbfadf..b47b00a8 100644 --- a/spec/data_sources/go_ontology.yaml +++ b/spec/data_sources/go_ontology.yaml @@ -1,6 +1,6 @@ name: go_ontology category: ontology title: Gene Ontology -home_url: http://geneontology.org/ -data_url: http://release.geneontology.org/ -logo_path: /images/third-party-data-sources/go/logo-248-64.png +home_url: "http://geneontology.org/" +data_url: "http://release.geneontology.org/" +logo_path: "/images/third-party-data-sources/go/logo-248-64.png" diff --git a/spec/data_sources/gtdb.yaml b/spec/data_sources/gtdb.yaml index 0e114e1a..bbc39037 100644 --- a/spec/data_sources/gtdb.yaml +++ b/spec/data_sources/gtdb.yaml @@ -1,6 +1,6 @@ name: gtdb category: taxonomy title: GTDB Taxonomy -home_url: https://gtdb.ecogenomic.org -data_url: https://data.ace.uq.edu.au/public/gtdb/data/releases/ -logo_path: /images/third-party-data-sources/gtdb/logo-128-64.png +home_url: "https://gtdb.ecogenomic.org" +data_url: "https://data.ace.uq.edu.au/public/gtdb/data/releases/" +logo_path: "/images/third-party-data-sources/gtdb/logo-128-64.png" diff --git a/spec/data_sources/ncbi_taxonomy.yaml b/spec/data_sources/ncbi_taxonomy.yaml index 37a88195..781bd2d0 100644 --- a/spec/data_sources/ncbi_taxonomy.yaml +++ b/spec/data_sources/ncbi_taxonomy.yaml @@ -1,6 +1,6 @@ name: ncbi_taxonomy category: taxonomy title: NCBI Taxonomy -home_url: https://www.ncbi.nlm.nih.gov/taxonomy -data_url: ftp://ftp.ncbi.nlm.nih.gov/pub/taxonomy/ -logo_path: /images/third-party-data-sources/ncbi/logo-51-64.png +home_url: "https://www.ncbi.nlm.nih.gov/taxonomy" +data_url: "ftp://ftp.ncbi.nlm.nih.gov/pub/taxonomy/" +logo_path: "/images/third-party-data-sources/ncbi/logo-51-64.png" diff --git a/spec/data_sources/rdp_taxonomy.yaml b/spec/data_sources/rdp_taxonomy.yaml index 570da538..953a0873 100644 --- a/spec/data_sources/rdp_taxonomy.yaml +++ b/spec/data_sources/rdp_taxonomy.yaml @@ -1,6 +1,6 @@ name: rdp_taxonomy category: taxonomy title: Ribosomal Database Project -home_url: http://rdp.cme.msu.edu/taxomatic/main.spr -data_url: http://rdp.cme.msu.edu/misc/resources.jsp -logo_path: /images/third-party-data-sources/ncbi/logo-51-64.png +home_url: "http://rdp.cme.msu.edu/taxomatic/main.spr" +data_url: "http://rdp.cme.msu.edu/misc/resources.jsp" +logo_path: "/images/third-party-data-sources/ncbi/logo-51-64.png" diff --git a/spec/test/test_validate.py b/spec/test/test_validate.py index 28e5f627..1577147c 100644 --- a/spec/test/test_validate.py +++ b/spec/test/test_validate.py @@ -115,6 +115,11 @@ def test_validate_data_source(self): 'msg': "Additional properties are not allowed \('type' was unexpected\)", 'file': 'invalid_additional_property.json', }, + { + 'msg': "'this is not a valid URI' is not a 'uri'", + 'file': 'uri_validation.json', + + } ] for entry in error_list: @@ -128,9 +133,6 @@ def test_validate_data_source(self): with self.assertRaisesRegex(err_type, entry['msg']): validate_data_source(os_path.join(base_dir, entry['file'])) - # TODO: add in a test for URL validation (once URL validation is working) - # see uri_validation.json for example - def test_validate_stored_query(self): base_dir = os_path.join(_TEST_DIR, 'stored_queries') From dd97b86287487ac85de1dd650d58279e7304eb47 Mon Sep 17 00:00:00 2001 From: ialarmedalien Date: Tue, 11 Aug 2020 07:38:51 -0700 Subject: [PATCH 551/732] Move pure validation tests to test_json_validation.py, and ensure tests cover schemas in yaml/json files and py data structures. Update README - small text fix. --- README.md | 7 +- .../test/data/json_validation/defaults.json | 1 + .../test/data/json_validation/defaults.yaml | 1 + .../data/json_validation/invalid_date.json | 5 + .../data/json_validation/invalid_date.yaml | 3 + .../json_validation/invalid_date_type.json | 5 + .../json_validation/invalid_date_type.yaml | 3 + .../data/json_validation/invalid_pattern.json | 4 + .../data/json_validation/invalid_pattern.yaml | 2 + .../data/json_validation/invalid_uri.json | 5 + .../data/json_validation/invalid_uri.yaml | 3 + .../data/json_validation/test_schema.json | 36 ++ .../data/json_validation/test_schema.yaml | 26 ++ .../data/json_validation/unquoted_date.yaml | 3 + .../test/data/json_validation/valid_date.json | 5 + .../test/data/json_validation/valid_date.yaml | 3 + .../data/json_validation/valid_pattern.json | 4 + .../data/json_validation/valid_pattern.yaml | 2 + .../test/data/json_validation/valid_uri.json | 5 + .../test/data/json_validation/valid_uri.yaml | 3 + .../test/data/schema_refs/edge.json | 35 ++ .../test/data/schema_refs/edge.yaml | 21 ++ .../test/data/schema_refs/level_1/edge.json | 35 ++ .../test/data/schema_refs/level_1/edge.yaml | 21 ++ .../data/schema_refs/level_1/edge_type.json | 29 ++ .../data/schema_refs/level_1/edge_type.yaml | 23 ++ .../schema_refs/level_1/level_2/edge.json | 35 ++ .../schema_refs/level_1/level_2/edge.yaml | 21 ++ .../test/test_json_validation.py | 327 +++++++++--------- .../collections/extra_top_level_entries.yaml | 1 - .../collections/test_delta_vertex.yaml | 2 +- .../collections/wrong_name.yaml | 1 - .../invalid_additional_property.json | 2 +- .../data_sources/uri_validation.json | 2 +- .../stored_queries/invalid_aql.yaml | 2 +- spec/test/sample_schemas/views/minimal.json | 2 +- .../test/sample_schemas/views/wrong_type.json | 2 +- 37 files changed, 507 insertions(+), 180 deletions(-) create mode 100644 relation_engine_server/test/data/json_validation/defaults.json create mode 100644 relation_engine_server/test/data/json_validation/defaults.yaml create mode 100644 relation_engine_server/test/data/json_validation/invalid_date.json create mode 100644 relation_engine_server/test/data/json_validation/invalid_date.yaml create mode 100644 relation_engine_server/test/data/json_validation/invalid_date_type.json create mode 100644 relation_engine_server/test/data/json_validation/invalid_date_type.yaml create mode 100644 relation_engine_server/test/data/json_validation/invalid_pattern.json create mode 100644 relation_engine_server/test/data/json_validation/invalid_pattern.yaml create mode 100644 relation_engine_server/test/data/json_validation/invalid_uri.json create mode 100644 relation_engine_server/test/data/json_validation/invalid_uri.yaml create mode 100644 relation_engine_server/test/data/json_validation/test_schema.json create mode 100644 relation_engine_server/test/data/json_validation/test_schema.yaml create mode 100644 relation_engine_server/test/data/json_validation/unquoted_date.yaml create mode 100644 relation_engine_server/test/data/json_validation/valid_date.json create mode 100644 relation_engine_server/test/data/json_validation/valid_date.yaml create mode 100644 relation_engine_server/test/data/json_validation/valid_pattern.json create mode 100644 relation_engine_server/test/data/json_validation/valid_pattern.yaml create mode 100644 relation_engine_server/test/data/json_validation/valid_uri.json create mode 100644 relation_engine_server/test/data/json_validation/valid_uri.yaml create mode 100644 relation_engine_server/test/data/schema_refs/edge.json create mode 100644 relation_engine_server/test/data/schema_refs/edge.yaml create mode 100644 relation_engine_server/test/data/schema_refs/level_1/edge.json create mode 100644 relation_engine_server/test/data/schema_refs/level_1/edge.yaml create mode 100644 relation_engine_server/test/data/schema_refs/level_1/edge_type.json create mode 100644 relation_engine_server/test/data/schema_refs/level_1/edge_type.yaml create mode 100644 relation_engine_server/test/data/schema_refs/level_1/level_2/edge.json create mode 100644 relation_engine_server/test/data/schema_refs/level_1/level_2/edge.yaml diff --git a/README.md b/README.md index f7a14c0b..6fe50a93 100644 --- a/README.md +++ b/README.md @@ -3,12 +3,13 @@ This repo holds the code associated with the KBase relation engine, previously held in https://github.com/kbase/relation_engine_api and https://github.com/kbase/relation_engine_spec. ## Relation Engine Spec +### `spec/` -This repo holds the schemas for [stored queries](spec/stored_queries), [collections](spec/collections), [views](spec/views) and [migrations](spec/migrations) for the relation engine graph database service. +The `spec/` directory holds the schemas for [stored queries](spec/stored_queries), [collections](spec/collections), [views](spec/views) and [migrations](spec/migrations) for the relation engine graph database service. These specifications are used by the [Relation Engine API](relation_engine_server). ## Relation Engine API +### `relation_engine_server/` -A simple API that allows KBase community developers to interact with the Relation Engine graph database. You can run stored queries or do bulk updates on documents. - +The relation engine server (`relation_engine_server/`) is a simple API that allows KBase community developers to interact with the Relation Engine graph database. You can run stored queries or do bulk updates on documents. diff --git a/relation_engine_server/test/data/json_validation/defaults.json b/relation_engine_server/test/data/json_validation/defaults.json new file mode 100644 index 00000000..0967ef42 --- /dev/null +++ b/relation_engine_server/test/data/json_validation/defaults.json @@ -0,0 +1 @@ +{} diff --git a/relation_engine_server/test/data/json_validation/defaults.yaml b/relation_engine_server/test/data/json_validation/defaults.yaml new file mode 100644 index 00000000..0967ef42 --- /dev/null +++ b/relation_engine_server/test/data/json_validation/defaults.yaml @@ -0,0 +1 @@ +{} diff --git a/relation_engine_server/test/data/json_validation/invalid_date.json b/relation_engine_server/test/data/json_validation/invalid_date.json new file mode 100644 index 00000000..9b9a7378 --- /dev/null +++ b/relation_engine_server/test/data/json_validation/invalid_date.json @@ -0,0 +1,5 @@ +{ + "name": "invalid_date", + "distance": 1, + "date": "20200606" +} diff --git a/relation_engine_server/test/data/json_validation/invalid_date.yaml b/relation_engine_server/test/data/json_validation/invalid_date.yaml new file mode 100644 index 00000000..e4613be1 --- /dev/null +++ b/relation_engine_server/test/data/json_validation/invalid_date.yaml @@ -0,0 +1,3 @@ +name: invalid_date +distance: 1 +date: "20200606" diff --git a/relation_engine_server/test/data/json_validation/invalid_date_type.json b/relation_engine_server/test/data/json_validation/invalid_date_type.json new file mode 100644 index 00000000..50d309a2 --- /dev/null +++ b/relation_engine_server/test/data/json_validation/invalid_date_type.json @@ -0,0 +1,5 @@ +{ + "name": "invalid_date", + "distance": 1, + "date": 20200606 +} diff --git a/relation_engine_server/test/data/json_validation/invalid_date_type.yaml b/relation_engine_server/test/data/json_validation/invalid_date_type.yaml new file mode 100644 index 00000000..1d029817 --- /dev/null +++ b/relation_engine_server/test/data/json_validation/invalid_date_type.yaml @@ -0,0 +1,3 @@ +name: invalid_date +distance: 1 +date: 20200606 diff --git a/relation_engine_server/test/data/json_validation/invalid_pattern.json b/relation_engine_server/test/data/json_validation/invalid_pattern.json new file mode 100644 index 00000000..9ee2461d --- /dev/null +++ b/relation_engine_server/test/data/json_validation/invalid_pattern.json @@ -0,0 +1,4 @@ +{ + "name": "what's-the-problem with-this-string?", + "distance": 1 +} diff --git a/relation_engine_server/test/data/json_validation/invalid_pattern.yaml b/relation_engine_server/test/data/json_validation/invalid_pattern.yaml new file mode 100644 index 00000000..66a97fff --- /dev/null +++ b/relation_engine_server/test/data/json_validation/invalid_pattern.yaml @@ -0,0 +1,2 @@ +name: what's-the-problem with-this-string? +distance: 1 diff --git a/relation_engine_server/test/data/json_validation/invalid_uri.json b/relation_engine_server/test/data/json_validation/invalid_uri.json new file mode 100644 index 00000000..334aa51f --- /dev/null +++ b/relation_engine_server/test/data/json_validation/invalid_uri.json @@ -0,0 +1,5 @@ +{ + "name": "uri_validation", + "distance": 1, + "home_page": "where is it?" +} diff --git a/relation_engine_server/test/data/json_validation/invalid_uri.yaml b/relation_engine_server/test/data/json_validation/invalid_uri.yaml new file mode 100644 index 00000000..358adc59 --- /dev/null +++ b/relation_engine_server/test/data/json_validation/invalid_uri.yaml @@ -0,0 +1,3 @@ +name: uri_validation +distance: 1 +home_page: where is it? diff --git a/relation_engine_server/test/data/json_validation/test_schema.json b/relation_engine_server/test/data/json_validation/test_schema.json new file mode 100644 index 00000000..3271e0f0 --- /dev/null +++ b/relation_engine_server/test/data/json_validation/test_schema.json @@ -0,0 +1,36 @@ +{ + "name": "test_schema", + "$schema": "http://json-schema.org/draft-07/schema#", + "properties": { + "params": { + "type": "object", + "properties": { + "name": { + "type": "string", + "format": "regex", + "pattern": "^\\w+$", + "default": "blank" + }, + "distance": { + "type": "integer", + "minimum": 0, + "maximum": 10, + "default": 1 + }, + "home_page": { + "type": "string", + "format": "uri" + }, + "title": { + "type": "string" + }, + "date": { + "title": "date", + "description": "A type of dried fruit", + "type": "string", + "format": "date" + } + } + } + } +} diff --git a/relation_engine_server/test/data/json_validation/test_schema.yaml b/relation_engine_server/test/data/json_validation/test_schema.yaml new file mode 100644 index 00000000..7ab2540e --- /dev/null +++ b/relation_engine_server/test/data/json_validation/test_schema.yaml @@ -0,0 +1,26 @@ +name: test_schema +$schema: 'http://json-schema.org/draft-07/schema#' +properties: + params: + type: object + properties: + name: + type: string + format: regex + pattern: ^\w+$ + default: blank + title: + type: string + distance: + type: integer + minimum: 0 + maximum: 10 + default: 1 + home_page: + type: string + format: uri + date: + title: date + description: A type of dried fruit + type: string + format: date diff --git a/relation_engine_server/test/data/json_validation/unquoted_date.yaml b/relation_engine_server/test/data/json_validation/unquoted_date.yaml new file mode 100644 index 00000000..9dc694f0 --- /dev/null +++ b/relation_engine_server/test/data/json_validation/unquoted_date.yaml @@ -0,0 +1,3 @@ +name: unquoted_date +distance: 3 +date: 2020-06-06 diff --git a/relation_engine_server/test/data/json_validation/valid_date.json b/relation_engine_server/test/data/json_validation/valid_date.json new file mode 100644 index 00000000..71831bb6 --- /dev/null +++ b/relation_engine_server/test/data/json_validation/valid_date.json @@ -0,0 +1,5 @@ +{ + "name": "valid_date", + "distance": 3, + "date": "2020-06-06" +} diff --git a/relation_engine_server/test/data/json_validation/valid_date.yaml b/relation_engine_server/test/data/json_validation/valid_date.yaml new file mode 100644 index 00000000..2a964808 --- /dev/null +++ b/relation_engine_server/test/data/json_validation/valid_date.yaml @@ -0,0 +1,3 @@ +name: valid_date +distance: 3 +date: "2020-06-06" diff --git a/relation_engine_server/test/data/json_validation/valid_pattern.json b/relation_engine_server/test/data/json_validation/valid_pattern.json new file mode 100644 index 00000000..e02c12d6 --- /dev/null +++ b/relation_engine_server/test/data/json_validation/valid_pattern.json @@ -0,0 +1,4 @@ +{ + "name": "No_problem_with_this_string", + "distance": 3 +} diff --git a/relation_engine_server/test/data/json_validation/valid_pattern.yaml b/relation_engine_server/test/data/json_validation/valid_pattern.yaml new file mode 100644 index 00000000..835d68e6 --- /dev/null +++ b/relation_engine_server/test/data/json_validation/valid_pattern.yaml @@ -0,0 +1,2 @@ +name: No_problem_with_this_string +distance: 3 diff --git a/relation_engine_server/test/data/json_validation/valid_uri.json b/relation_engine_server/test/data/json_validation/valid_uri.json new file mode 100644 index 00000000..e885d722 --- /dev/null +++ b/relation_engine_server/test/data/json_validation/valid_uri.json @@ -0,0 +1,5 @@ +{ + "name": "valid_uri", + "distance": 3, + "home_page": "http://json-validation.com:5000/this/is/valid" +} diff --git a/relation_engine_server/test/data/json_validation/valid_uri.yaml b/relation_engine_server/test/data/json_validation/valid_uri.yaml new file mode 100644 index 00000000..2fe93df3 --- /dev/null +++ b/relation_engine_server/test/data/json_validation/valid_uri.yaml @@ -0,0 +1,3 @@ +name: valid_uri +distance: 3 +home_page: "http://json-validation.com:5000/this/is/valid" diff --git a/relation_engine_server/test/data/schema_refs/edge.json b/relation_engine_server/test/data/schema_refs/edge.json new file mode 100644 index 00000000..c03ab862 --- /dev/null +++ b/relation_engine_server/test/data/schema_refs/edge.json @@ -0,0 +1,35 @@ +{ + "name": "edge", + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "Arabidopsis gene-gene or gene-phenotype edge", + "description": "Generic gene-to-gene or gene-to-phenotype edge for Dan Jacobson Arabidopsis data", + "type": "object", + "required": [ + "score", + "edge_type", + "_from", + "_to", + "_key" + ], + "properties": { + "_key": { + "type": "string", + "title": "Key" + }, + "_from": { + "type": "string", + "title": "Gene ID" + }, + "_to": { + "type": "string", + "title": "Gene or Phenotype ID" + }, + "score": { + "title": "Edge Score (Weight)", + "type": "number" + }, + "edge_type": { + "$ref": "level_1/edge_type.json" + } + } +} diff --git a/relation_engine_server/test/data/schema_refs/edge.yaml b/relation_engine_server/test/data/schema_refs/edge.yaml new file mode 100644 index 00000000..2c006fc4 --- /dev/null +++ b/relation_engine_server/test/data/schema_refs/edge.yaml @@ -0,0 +1,21 @@ +name: edge +"$schema": http://json-schema.org/draft-07/schema# +title: Arabidopsis gene-gene or gene-phenotype edge +description: Generic gene-to-gene or gene-to-phenotype edge for Dan Jacobson Arabidopsis data +type: object +required: [score, edge_type, _from, _to, _key] +properties: + _key: + type: string + title: Key + _from: + type: string + title: Gene ID + _to: + type: string + title: Gene or Phenotype ID + score: + title: Edge Score (Weight) + type: number + edge_type: + $ref: level_1/edge_type.yaml diff --git a/relation_engine_server/test/data/schema_refs/level_1/edge.json b/relation_engine_server/test/data/schema_refs/level_1/edge.json new file mode 100644 index 00000000..7e9939cb --- /dev/null +++ b/relation_engine_server/test/data/schema_refs/level_1/edge.json @@ -0,0 +1,35 @@ +{ + "name": "edge", + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "Arabidopsis gene-gene or gene-phenotype edge", + "description": "Generic gene-to-gene or gene-to-phenotype edge for Dan Jacobson Arabidopsis data", + "type": "object", + "required": [ + "score", + "edge_type", + "_from", + "_to", + "_key" + ], + "properties": { + "_key": { + "type": "string", + "title": "Key" + }, + "_from": { + "type": "string", + "title": "Gene ID" + }, + "_to": { + "type": "string", + "title": "Gene or Phenotype ID" + }, + "score": { + "title": "Edge Score (Weight)", + "type": "number" + }, + "edge_type": { + "$ref": "edge_type.json" + } + } +} diff --git a/relation_engine_server/test/data/schema_refs/level_1/edge.yaml b/relation_engine_server/test/data/schema_refs/level_1/edge.yaml new file mode 100644 index 00000000..3009e0be --- /dev/null +++ b/relation_engine_server/test/data/schema_refs/level_1/edge.yaml @@ -0,0 +1,21 @@ +name: edge +"$schema": http://json-schema.org/draft-07/schema# +title: Arabidopsis gene-gene or gene-phenotype edge +description: Generic gene-to-gene or gene-to-phenotype edge for Dan Jacobson Arabidopsis data +type: object +required: [score, edge_type, _from, _to, _key] +properties: + _key: + type: string + title: Key + _from: + type: string + title: Gene ID + _to: + type: string + title: Gene or Phenotype ID + score: + title: Edge Score (Weight) + type: number + edge_type: + $ref: edge_type.yaml diff --git a/relation_engine_server/test/data/schema_refs/level_1/edge_type.json b/relation_engine_server/test/data/schema_refs/level_1/edge_type.json new file mode 100644 index 00000000..0f440d79 --- /dev/null +++ b/relation_engine_server/test/data/schema_refs/level_1/edge_type.json @@ -0,0 +1,29 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "name": "edge_type", + "title": "Edge Type", + "description": "Edge types in Dan Jacobson Exascale dataset", + "type": "string", + "oneOf": [ + { + "const": "domain_co_occur", + "description": "A layer of protein domain co-occurrence values from the Arabidopsis AraNetv2 database. The LLS scores that serve as edge values were calculated from weighted mutual information scores to normalize the data for comparison across studies and different types of data layers (Lee et al, 2015)." + }, + { + "const": "gene_coexpr", + "description": "A subset of pairwise gene coexpression values from the Arabidopsis AraNetv2 database. The LLS scores that serve as edge values were calculated from Pearson correlation coefficients to normalize the data for comparison across studies and different types of data layers (Lee et al, 2015)." + }, + { + "const": "pheno_assn", + "description": "GWAS associations produced by analyzing a subset of phenotypes and SNPs in the Arabidopsis 1001 Genomes database. Edge values are significant association scores after FDR correction." + }, + { + "const": "ppi_hithru", + "description": "Log likelihood score. A layer of protein-protein interaction values derived from four high-throughput PPI screening experiments; from the Arabidopsis AraNetv2 database. The LLS scores that serve as edge values were calculated to normalize the data for comparison across studies and different types of data layers (Lee et al, 2015)." + }, + { + "const": "ppi_liter", + "description": "A layer of protein-protein interaction values from literature-curated small- to medium-scale experimental data; from the Arabidopsis AraNetv2 database. The LLS scores that serve as edge values were calculated to normalize the data for comparison across studies and different types of data layers (Lee et al, 2015)." + } + ] +} diff --git a/relation_engine_server/test/data/schema_refs/level_1/edge_type.yaml b/relation_engine_server/test/data/schema_refs/level_1/edge_type.yaml new file mode 100644 index 00000000..31cad5a1 --- /dev/null +++ b/relation_engine_server/test/data/schema_refs/level_1/edge_type.yaml @@ -0,0 +1,23 @@ +$schema: "http://json-schema.org/draft-07/schema#" +#type: object +#required: [edge_type] +#properties: +# edge_type: +name: edge_type +title: Edge Type +description: Edge types in Dan Jacobson Exascale dataset +type: string +oneOf: + - const: domain_co_occur + description: A layer of protein domain co-occurrence values from the Arabidopsis AraNetv2 database. The LLS scores that serve as edge values were calculated from weighted mutual information scores to normalize the data for comparison across studies and different types of data layers (Lee et al, 2015). + - const: gene_coexpr + description: A subset of pairwise gene coexpression values from the Arabidopsis AraNetv2 database. The LLS scores that serve as edge values were + calculated from Pearson correlation coefficients to normalize the data + for comparison across studies and different types of data layers (Lee et + al, 2015). + - const: pheno_assn + description: GWAS associations produced by analyzing a subset of phenotypes and SNPs in the Arabidopsis 1001 Genomes database. Edge values are significant association scores after FDR correction. + - const: ppi_hithru + description: Log likelihood score. A layer of protein-protein interaction values derived from four high-throughput PPI screening experiments; from the Arabidopsis AraNetv2 database. The LLS scores that serve as edge values were calculated to normalize the data for comparison across studies and different types of data layers (Lee et al, 2015). + - const: ppi_liter + description: A layer of protein-protein interaction values from literature-curated small- to medium-scale experimental data; from the Arabidopsis AraNetv2 database. The LLS scores that serve as edge values were calculated to normalize the data for comparison across studies and different types of data layers (Lee et al, 2015). diff --git a/relation_engine_server/test/data/schema_refs/level_1/level_2/edge.json b/relation_engine_server/test/data/schema_refs/level_1/level_2/edge.json new file mode 100644 index 00000000..9cd204d0 --- /dev/null +++ b/relation_engine_server/test/data/schema_refs/level_1/level_2/edge.json @@ -0,0 +1,35 @@ +{ + "name": "edge", + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "Arabidopsis gene-gene or gene-phenotype edge", + "description": "Generic gene-to-gene or gene-to-phenotype edge for Dan Jacobson Arabidopsis data", + "type": "object", + "required": [ + "score", + "edge_type", + "_from", + "_to", + "_key" + ], + "properties": { + "_key": { + "type": "string", + "title": "Key" + }, + "_from": { + "type": "string", + "title": "Gene ID" + }, + "_to": { + "type": "string", + "title": "Gene or Phenotype ID" + }, + "score": { + "title": "Edge Score (Weight)", + "type": "number" + }, + "edge_type": { + "$ref": "../edge_type.json" + } + } +} diff --git a/relation_engine_server/test/data/schema_refs/level_1/level_2/edge.yaml b/relation_engine_server/test/data/schema_refs/level_1/level_2/edge.yaml new file mode 100644 index 00000000..f01cf077 --- /dev/null +++ b/relation_engine_server/test/data/schema_refs/level_1/level_2/edge.yaml @@ -0,0 +1,21 @@ +name: edge +"$schema": http://json-schema.org/draft-07/schema# +title: Arabidopsis gene-gene or gene-phenotype edge +description: Generic gene-to-gene or gene-to-phenotype edge for Dan Jacobson Arabidopsis data +type: object +required: [score, edge_type, _from, _to, _key] +properties: + _key: + type: string + title: Key + _from: + type: string + title: Gene ID + _to: + type: string + title: Gene or Phenotype ID + score: + title: Edge Score (Weight) + type: number + edge_type: + $ref: ../edge_type.yaml diff --git a/relation_engine_server/test/test_json_validation.py b/relation_engine_server/test/test_json_validation.py index a45712cd..ac3ddfe6 100644 --- a/relation_engine_server/test/test_json_validation.py +++ b/relation_engine_server/test/test_json_validation.py @@ -3,7 +3,6 @@ """ import unittest import os.path as os_path -from yaml import safe_load from relation_engine_server.utils.json_validation import run_validator from jsonschema.exceptions import ValidationError from jsonpointer import JsonPointerException @@ -17,7 +16,7 @@ 'name': { 'type': 'string', 'format': 'regex', - 'pattern': '^\w+$', + 'pattern': '^\\w+$', 'default': 'blank', }, 'distance': { @@ -30,12 +29,6 @@ 'type': 'string', 'format': 'uri', }, - 'creation_date': { - 'title': 'date of creation', - 'description': 'Approx six thousand years ago', - 'type': 'string', - 'format': 'date', - }, 'date': { 'title': 'date', 'description': 'A type of dried fruit', @@ -47,84 +40,14 @@ } } -test_schema_two = { - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "Exascale parser file manifest", - "type": "object", - "required": ["name", "file_list"], - "properties": { - "name": { - "title": "Dataset name", - "type": "string", - "description": "The name of the dataset", - "examples": ["Dan Jacobson Exascale dataset"] - }, - "release_date": { - "title": "Release date", - "type": "string", - "description": "Date of the dataset release, in YYYY-MM-DD format", - "format": "date" - }, - "notes": { - "type": "string", - "title": "Release notes", - "description": "Free text describing the release and any notes, or comments relevant to consumers of the data." - }, - "file_list": { - "type": "array", - "items": { - "type": "object", - "required": ["data_type", "path"], - "oneOf": [ - { - "properties": { - "data_type": {"enum": ["cluster"]} - }, - "required": ["cluster_prefix"] - }, - { - "properties": { - "data_type": {"enum": ["node", "edge"]} - } - } - ], - "properties": { - "data_type": { - "title": "Data type", - "type": "string", - "enum": ["node", "edge", "cluster"] - }, - "date": { - "title": "File creation date", - "description": "date of file creation in the format YYYY-MM-DD", - "type": "string", - "format": "date" - }, - "description": { - "title": "Description of the cluster set", - "type": "string" - }, - "path": { - "title": "File path", - "type": "string" - }, - "cluster_prefix": { - "title": "Prefix", - "type": "string", - "description": "The prefix to be used for clusters" - }, - "title": { - "title": "Name of the cluster set", - "type": "string" - } - } - } - } - } -} - - valid_json_loc = '/properties/params' +test_data_dir = os_path.join('/app', 'relation_engine_server', 'test', 'data', 'json_validation') + +test_schema_list = [ + ['schema', test_schema], + ['schema_file', os_path.join(test_data_dir, 'test_schema.json')], + ['schema_file', os_path.join(test_data_dir, 'test_schema.yaml')], +] class TestJsonValidation(unittest.TestCase): @@ -172,136 +95,202 @@ def test_non_validation_validator_errors(self): validate_at='/properties/params') self.assertEqual(output, {'name': 'name', 'distance': 3}) - def test_json_validation_defaults(self): + def test_json_validation(self): + + test_list = [ + self.add_defaults, + self.pattern_validation, + self.uri_validation, + self.date_format_validation, + ] + + for test_schema in test_schema_list: + schema_file_arg = schema_arg = test_schema[1] + + if test_schema[0] == 'schema': + schema_file_arg = None + else: + schema_arg = None + + for test in test_list: + test(schema_arg, schema_file_arg) + + def add_defaults(self, schema_arg, schema_file_arg): """Test that the jsonschema validator sets default values.""" - test_data = run_validator(schema=test_schema, data={}, validate_at=valid_json_loc) + test_data = run_validator( + schema=schema_arg, + schema_file=schema_file_arg, + data={}, + validate_at=valid_json_loc) self.assertEqual(test_data, {'name': 'blank', 'distance': 1}) - def test_pattern_validation(self): + for file_ext in ['json', 'yaml']: + file_path = os_path.join(test_data_dir, 'defaults.' + file_ext) + self.assertEqual( + run_validator( + schema=schema_arg, + schema_file=schema_file_arg, + data_file=file_path, + validate_at=valid_json_loc + ), + {'name': 'blank', 'distance': 1} + ) + + def pattern_validation(self, schema_arg, schema_file_arg): '''Test pattern validation''' # validation error - string does not match regex err_str = "'Mr Blobby' does not match .*?" with self.assertRaisesRegex(ValidationError, err_str): run_validator( - schema=test_schema, + schema=schema_arg, + schema_file=schema_file_arg, data={'name': 'Mr Blobby', 'distance': 3}, validate_at=valid_json_loc) # this string is OK output = run_validator( - schema=test_schema, - data={'name': 'Mr_Blobby_666', 'distance': 3}, - validate_at=valid_json_loc) + schema=schema_arg, + schema_file=schema_file_arg, + data={'name': 'Mr_Blobby_666', 'distance': 3}, + validate_at=valid_json_loc) self.assertEqual(output, {'name': 'Mr_Blobby_666', 'distance': 3}) - def test_uri_validation(self): + for file_ext in ['json', 'yaml']: + # validation error - string does not match regex + err_str = '"what\'s-the-problem with-this-string\?" does not match .*?' + file_path = os_path.join(test_data_dir, 'invalid_pattern.' + file_ext) + with self.assertRaisesRegex(ValidationError, err_str): + run_validator( + schema=schema_arg, + schema_file=schema_file_arg, + data_file=file_path, + validate_at=valid_json_loc) + + file_path = os_path.join(test_data_dir, 'valid_pattern.' + file_ext) + self.assertEqual( + run_validator( + schema=schema_arg, + schema_file=schema_file_arg, + data_file=file_path, + validate_at=valid_json_loc), + {'name': 'No_problem_with_this_string', 'distance': 3} + ) + + def uri_validation(self, schema_arg, schema_file_arg): '''Test URI validation is operational''' err_str = "'where is it\?' is not a 'uri'" with self.assertRaisesRegex(ValidationError, err_str): run_validator( - schema=test_schema, + schema=schema_arg, + schema_file=schema_file_arg, data={'name': 'blank', 'distance': 3, 'home_page': 'where is it?'}, validate_at=valid_json_loc) # this string is OK - input = {'name': 'blank', 'distance': 3, 'home_page': 'http://www.home/com'} + input = {'name': 'valid_uri', 'distance': 3, 'home_page': 'http://www.home.com'} output = run_validator( - schema=test_schema, - data=input, - validate_at=valid_json_loc) + schema=schema_arg, + schema_file=schema_file_arg, + data=input, + validate_at=valid_json_loc) self.assertEqual(output, input) - def test_date_format_validation(self): - '''ensure that fancy date formats are correctly validated''' + # data files + for file_ext in ['json', 'yaml']: + file_path = os_path.join(test_data_dir, 'invalid_uri.' + file_ext) + err_str = "'where is it\?' is not a 'uri'" + with self.assertRaisesRegex(ValidationError, err_str): + run_validator( + schema=schema_arg, + schema_file=schema_file_arg, + data_file=file_path, + validate_at=valid_json_loc) + + file_path = os_path.join(test_data_dir, 'valid_uri.' + file_ext) + self.assertEqual( + run_validator( + schema=schema_arg, + schema_file=schema_file_arg, + data_file=file_path, + validate_at=valid_json_loc), + { + "name": "valid_uri", + "distance": 3, + "home_page": "http://json-validation.com:5000/this/is/valid" + } + ) - err_str = "'12345678' is not a 'date'" - with self.assertRaisesRegex(ValidationError, err_str): - input = {'name': 'whatever', 'distance': 1, 'creation_date': '12345678'} - run_validator( - schema=test_schema, - data=input, - validate_at=valid_json_loc) + def date_format_validation(self, schema_arg, schema_file_arg): + '''ensure that fancy date formats are correctly validated''' - # date field NAMED date! - err_str = "'12345678' is not a 'date'" + err_str = "'202001017' is not a 'date'" with self.assertRaisesRegex(ValidationError, err_str): - input = {'name': 'whatever', 'distance': 1, 'date': '12345678'} + input = {'name': 'whatever', 'distance': 1, 'date': '202001017'} run_validator( - schema=test_schema, + schema=schema_arg, + schema_file=schema_file_arg, data=input, validate_at=valid_json_loc) - input = {'name': 'whatever', 'distance': 1, 'creation_date': '2020-05-23'} + input = {'name': 'whatever', 'distance': 1, 'date': '2020-05-23'} output = run_validator( - schema=test_schema, + schema=schema_arg, + schema_file=schema_file_arg, data=input, validate_at=valid_json_loc) self.assertEqual(input, output) - # use the manifest schema - with self.assertRaisesRegex(ValidationError, err_str): - run_validator( - schema=test_schema_two, - data={'name': 'a', 'file_list': [], 'release_date': '12345678'} + # data files + for file_ext in ['json', 'yaml']: + # invalid type (number instead of string) + file_path = os_path.join(test_data_dir, 'invalid_date_type.' + file_ext) + err_str = "20200606 is not of type 'string'" + with self.assertRaisesRegex(ValidationError, err_str): + run_validator( + schema=schema_arg, + schema_file=schema_file_arg, + data_file=file_path, + validate_at=valid_json_loc) + + # quoted string but not in the correct format + file_path = os_path.join(test_data_dir, 'invalid_date.' + file_ext) + err_str = "'20200606' is not a 'date'" + with self.assertRaisesRegex(ValidationError, err_str): + run_validator( + schema=schema_arg, + schema_file=schema_file_arg, + data_file=file_path, + validate_at=valid_json_loc) + + file_path = os_path.join(test_data_dir, 'valid_date.' + file_ext) + self.assertEqual( + run_validator( + schema=schema_arg, + schema_file=schema_file_arg, + data_file=file_path, + validate_at=valid_json_loc), + { + "name": "valid_date", + "date": "2020-06-06", + "distance": 3, + } ) + # pyyaml-specific issue: dates get automatically parsed into datetime objects (doh!) + file_path = os_path.join(test_data_dir, 'unquoted_date.yaml') + err_str = "datetime.date\(2020, 6, 6\) is not of type 'string'" with self.assertRaisesRegex(ValidationError, err_str): run_validator( - schema_file='/app/importers/djornl/manifest.schema.json', - data={'name': 'a', 'file_list': [], 'release_date': '12345678'} - ) - - # valid inputs - more_input = {'name': 'a', 'file_list': [], 'release_date': '1999-12-31'} - more_output = run_validator( - schema=test_schema_two, - data=more_input - ) - self.assertEqual(more_input, more_output) - - more_output = run_validator( - schema_file='/app/importers/djornl/manifest.schema.json', - data=more_input - ) - self.assertEqual(more_input, more_output) - - def test_valid_manifest_validation(self): - """ensure that a valid manifest passes validation""" - - manifest_schema = '/app/importers/djornl/manifest.schema.json' - test_dir = '/app/spec/test/djornl/' - with open(os_path.join(test_dir, 'test_data', 'manifest.yaml')) as fd: - file_contents = safe_load(fd) - - # raw data - manifest_data = run_validator( - schema_file=manifest_schema, - data=file_contents, - nicer_errors=True - ) - self.assertTrue(manifest_data) - - # data file - manifest_data = run_validator( - schema_file=manifest_schema, - data_file=os_path.join(test_dir, 'test_data', 'manifest.yaml'), - nicer_errors=True - ) - self.assertTrue(manifest_data) - - # data file - manifest_data = run_validator( - schema_file=manifest_schema, - data_file=os_path.join(test_dir, 'valid', 'with_descriptions.yaml'), - nicer_errors=True - ) - self.assertTrue(manifest_data) + schema=schema_arg, + schema_file=schema_file_arg, + data_file=file_path, + validate_at=valid_json_loc) def test_schema_references(self): - """ensure referenced schemas can be accessed""" + """Ensure referenced schemas, including those written in yaml, can be accessed.""" valid_edge_data = { "_from": "here", @@ -319,7 +308,7 @@ def test_schema_references(self): "edge_type": "whatever", } - schema_ref_dir = ['/app', 'spec', 'test', 'sample_schemas', 'schema_refs'] + schema_ref_dir = ['/app', 'relation_engine_server', 'test', 'data', 'schema_refs'] # same schema in different places path_list = [ diff --git a/spec/test/sample_schemas/collections/extra_top_level_entries.yaml b/spec/test/sample_schemas/collections/extra_top_level_entries.yaml index 57b977ef..a4263ccf 100644 --- a/spec/test/sample_schemas/collections/extra_top_level_entries.yaml +++ b/spec/test/sample_schemas/collections/extra_top_level_entries.yaml @@ -10,4 +10,3 @@ schema: _key: type: string title: Key - diff --git a/spec/test/sample_schemas/collections/test_delta_vertex.yaml b/spec/test/sample_schemas/collections/test_delta_vertex.yaml index 6ee273b8..272e3188 100644 --- a/spec/test/sample_schemas/collections/test_delta_vertex.yaml +++ b/spec/test/sample_schemas/collections/test_delta_vertex.yaml @@ -8,4 +8,4 @@ schema: description: An example vertex schema for testing properties: id: {type: string} - quality: {type: string} \ No newline at end of file + quality: {type: string} diff --git a/spec/test/sample_schemas/collections/wrong_name.yaml b/spec/test/sample_schemas/collections/wrong_name.yaml index 45dbcc3b..29b6f98f 100644 --- a/spec/test/sample_schemas/collections/wrong_name.yaml +++ b/spec/test/sample_schemas/collections/wrong_name.yaml @@ -9,4 +9,3 @@ schema: _key: type: string title: Key - diff --git a/spec/test/sample_schemas/data_sources/invalid_additional_property.json b/spec/test/sample_schemas/data_sources/invalid_additional_property.json index d36c3609..3759e962 100644 --- a/spec/test/sample_schemas/data_sources/invalid_additional_property.json +++ b/spec/test/sample_schemas/data_sources/invalid_additional_property.json @@ -3,4 +3,4 @@ "type": "invalid", "category": "something boring", "title": "An invalid additional property" -} \ No newline at end of file +} diff --git a/spec/test/sample_schemas/data_sources/uri_validation.json b/spec/test/sample_schemas/data_sources/uri_validation.json index af9d2b74..30b4a2f7 100644 --- a/spec/test/sample_schemas/data_sources/uri_validation.json +++ b/spec/test/sample_schemas/data_sources/uri_validation.json @@ -3,4 +3,4 @@ "category": "validator testing", "title": "URI vaildation test", "home_url": "this is not a valid URI" -} \ No newline at end of file +} diff --git a/spec/test/sample_schemas/stored_queries/invalid_aql.yaml b/spec/test/sample_schemas/stored_queries/invalid_aql.yaml index e50e7fea..3fe1e85b 100644 --- a/spec/test/sample_schemas/stored_queries/invalid_aql.yaml +++ b/spec/test/sample_schemas/stored_queries/invalid_aql.yaml @@ -24,4 +24,4 @@ query: | LET us pray FOR a RETURN to - NORMALITY \ No newline at end of file + NORMALITY diff --git a/spec/test/sample_schemas/views/minimal.json b/spec/test/sample_schemas/views/minimal.json index 1d0f8109..fdf8b8a7 100644 --- a/spec/test/sample_schemas/views/minimal.json +++ b/spec/test/sample_schemas/views/minimal.json @@ -1,4 +1,4 @@ { "name": "minimal", "type": "arangosearch" -} \ No newline at end of file +} diff --git a/spec/test/sample_schemas/views/wrong_type.json b/spec/test/sample_schemas/views/wrong_type.json index 7b5ee97c..49282bed 100644 --- a/spec/test/sample_schemas/views/wrong_type.json +++ b/spec/test/sample_schemas/views/wrong_type.json @@ -1,4 +1,4 @@ { "name": "wrong_type", "type": "from the shore" -} \ No newline at end of file +} From 3389ac1a7a46944b2344f75b462fc9b95c4f2e3f Mon Sep 17 00:00:00 2001 From: ialarmedalien Date: Wed, 12 Aug 2020 11:30:44 -0700 Subject: [PATCH 552/732] Adding some more JSON validation tests with more complex reference schemas --- .../collection_types/common_stuff.json | 25 ++++ .../collection_types/common_stuff.yaml | 20 +++ .../collection_types/node_elements.json | 23 +++ .../collection_types/node_elements.yaml | 19 +++ .../data/schema_refs/level_1/edge_type.yaml | 4 - .../data/schema_refs/level_1/test_object.json | 19 +++ .../data/schema_refs/level_1/test_object.yaml | 17 +++ .../test/test_json_validation.py | 133 ++++++++++++++---- 8 files changed, 225 insertions(+), 35 deletions(-) create mode 100644 relation_engine_server/test/data/schema_refs/collection_types/common_stuff.json create mode 100644 relation_engine_server/test/data/schema_refs/collection_types/common_stuff.yaml create mode 100644 relation_engine_server/test/data/schema_refs/collection_types/node_elements.json create mode 100644 relation_engine_server/test/data/schema_refs/collection_types/node_elements.yaml create mode 100644 relation_engine_server/test/data/schema_refs/level_1/test_object.json create mode 100644 relation_engine_server/test/data/schema_refs/level_1/test_object.yaml diff --git a/relation_engine_server/test/data/schema_refs/collection_types/common_stuff.json b/relation_engine_server/test/data/schema_refs/collection_types/common_stuff.json new file mode 100644 index 00000000..80f18d5c --- /dev/null +++ b/relation_engine_server/test/data/schema_refs/collection_types/common_stuff.json @@ -0,0 +1,25 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "definitions": { + "marks_out_of_10": { + "type": "number", + "minimum": 0, + "maximum": 10 + }, + "node": { + "type": "object", + "properties": { + "type": { + "$ref": "/app/relation_engine_server/test/data/schema_refs/node_elements.json#/definitions/node/properties/type" + }, + "id": { + "$ref": "file:///app/relation_engine_server/test/data/schema_refs/node_elements.json#/definitions/node/properties/id" + } + }, + "required": ["type", "id"] + }, + "edge": { + "$ref": "../level_1/level_2/edge.yaml" + } + } +} diff --git a/relation_engine_server/test/data/schema_refs/collection_types/common_stuff.yaml b/relation_engine_server/test/data/schema_refs/collection_types/common_stuff.yaml new file mode 100644 index 00000000..593201cb --- /dev/null +++ b/relation_engine_server/test/data/schema_refs/collection_types/common_stuff.yaml @@ -0,0 +1,20 @@ +$schema: 'http://json-schema.org/draft-07/schema#' +definitions: + marks_out_of_10: + type: number + minimum: 0 + maximum: 10 + node: + type: object + properties: + type: + $ref: >- + /app/relation_engine_server/test/data/schema_refs/node_elements.json#/definitions/node/properties/type + id: + $ref: >- + file:///app/relation_engine_server/test/data/schema_refs/node_elements.json#/definitions/node/properties/id + required: + - type + - id + edge: + $ref: ../level_1/level_2/edge.yaml diff --git a/relation_engine_server/test/data/schema_refs/collection_types/node_elements.json b/relation_engine_server/test/data/schema_refs/collection_types/node_elements.json new file mode 100644 index 00000000..231dac44 --- /dev/null +++ b/relation_engine_server/test/data/schema_refs/collection_types/node_elements.json @@ -0,0 +1,23 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "definitions": { + "node": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": ["gene", "pheno"] + }, + "id": { + "type": "string", + "format": "regex", + "pattern": "^[a-zA-Z]+:\\d+$" + }, + "name": { + "type": "string" + } + }, + "required": ["type", "id"] + } + } +} diff --git a/relation_engine_server/test/data/schema_refs/collection_types/node_elements.yaml b/relation_engine_server/test/data/schema_refs/collection_types/node_elements.yaml new file mode 100644 index 00000000..d8dcb55a --- /dev/null +++ b/relation_engine_server/test/data/schema_refs/collection_types/node_elements.yaml @@ -0,0 +1,19 @@ +$schema: 'http://json-schema.org/draft-07/schema#' +definitions: + node: + type: object + properties: + type: + type: string + enum: + - gene + - pheno + id: + type: string + format: regex + pattern: '^[a-zA-Z]+:\d+$' + name: + type: string + required: + - type + - id diff --git a/relation_engine_server/test/data/schema_refs/level_1/edge_type.yaml b/relation_engine_server/test/data/schema_refs/level_1/edge_type.yaml index 31cad5a1..15263b80 100644 --- a/relation_engine_server/test/data/schema_refs/level_1/edge_type.yaml +++ b/relation_engine_server/test/data/schema_refs/level_1/edge_type.yaml @@ -1,8 +1,4 @@ $schema: "http://json-schema.org/draft-07/schema#" -#type: object -#required: [edge_type] -#properties: -# edge_type: name: edge_type title: Edge Type description: Edge types in Dan Jacobson Exascale dataset diff --git a/relation_engine_server/test/data/schema_refs/level_1/test_object.json b/relation_engine_server/test/data/schema_refs/level_1/test_object.json new file mode 100644 index 00000000..46e6bfaa --- /dev/null +++ b/relation_engine_server/test/data/schema_refs/level_1/test_object.json @@ -0,0 +1,19 @@ +{ + "name": "test_object", + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "Test object", + "description": "Object composed from numerous different files", + "type": "object", + "required": ["edge", "node", "marks_out_of_ten"], + "properties": { + "edge": { + "$ref": "edge.json" + }, + "node": { + "$ref": "../../schema_refs/collection_types/node_elements.yaml#/definitions/node" + }, + "marks_out_of_ten": { + "$ref": "file:///app/relation_engine_server/test/data/schema_refs/collection_types/common_stuff.json#/definitions/marks_out_of_10" + } + } +} diff --git a/relation_engine_server/test/data/schema_refs/level_1/test_object.yaml b/relation_engine_server/test/data/schema_refs/level_1/test_object.yaml new file mode 100644 index 00000000..d6f6084b --- /dev/null +++ b/relation_engine_server/test/data/schema_refs/level_1/test_object.yaml @@ -0,0 +1,17 @@ +name: test_object +$schema: 'http://json-schema.org/draft-07/schema#' +title: Test object +description: Object composed from numerous different files +type: object +required: + - edge + - marks_out_of_ten + - node +properties: + edge: + $ref: edge.json + node: + $ref: '../../schema_refs/collection_types/node_elements.yaml#/definitions/node' + marks_out_of_ten: + $ref: >- + file:///app/relation_engine_server/test/data/schema_refs/collection_types/common_stuff.json#/definitions/marks_out_of_10 diff --git a/relation_engine_server/test/test_json_validation.py b/relation_engine_server/test/test_json_validation.py index ac3ddfe6..5f0c0ab8 100644 --- a/relation_engine_server/test/test_json_validation.py +++ b/relation_engine_server/test/test_json_validation.py @@ -3,8 +3,11 @@ """ import unittest import os.path as os_path +import json +import yaml from relation_engine_server.utils.json_validation import run_validator from jsonschema.exceptions import ValidationError +from jsonschema.exceptions import RefResolutionError from jsonpointer import JsonPointerException @@ -41,14 +44,32 @@ } valid_json_loc = '/properties/params' -test_data_dir = os_path.join('/app', 'relation_engine_server', 'test', 'data', 'json_validation') +test_data_dirs = ['/app', 'relation_engine_server', 'test', 'data'] +json_validation_dir = os_path.join(*(test_data_dirs + ['json_validation'])) +schema_refs_dir = os_path.join(*(test_data_dirs + ['schema_refs'])) test_schema_list = [ ['schema', test_schema], - ['schema_file', os_path.join(test_data_dir, 'test_schema.json')], - ['schema_file', os_path.join(test_data_dir, 'test_schema.yaml')], + ['schema_file', os_path.join(json_validation_dir, 'test_schema.json')], + ['schema_file', os_path.join(json_validation_dir, 'test_schema.yaml')], ] +valid_edge_data = { + "_from": "here", + "_to": "eternity", + "score": 1.23456, + "_key": "abcdefg", + "edge_type": "domain_co_occur", +} + +invalid_edge_data = { + "_from": "here", + "_to": "eternity", + "score": 1.23456, + "_key": "abcdefg", + "edge_type": "whatever", +} + class TestJsonValidation(unittest.TestCase): @@ -126,7 +147,7 @@ def add_defaults(self, schema_arg, schema_file_arg): self.assertEqual(test_data, {'name': 'blank', 'distance': 1}) for file_ext in ['json', 'yaml']: - file_path = os_path.join(test_data_dir, 'defaults.' + file_ext) + file_path = os_path.join(json_validation_dir, 'defaults.' + file_ext) self.assertEqual( run_validator( schema=schema_arg, @@ -160,7 +181,7 @@ def pattern_validation(self, schema_arg, schema_file_arg): for file_ext in ['json', 'yaml']: # validation error - string does not match regex err_str = '"what\'s-the-problem with-this-string\?" does not match .*?' - file_path = os_path.join(test_data_dir, 'invalid_pattern.' + file_ext) + file_path = os_path.join(json_validation_dir, 'invalid_pattern.' + file_ext) with self.assertRaisesRegex(ValidationError, err_str): run_validator( schema=schema_arg, @@ -168,7 +189,7 @@ def pattern_validation(self, schema_arg, schema_file_arg): data_file=file_path, validate_at=valid_json_loc) - file_path = os_path.join(test_data_dir, 'valid_pattern.' + file_ext) + file_path = os_path.join(json_validation_dir, 'valid_pattern.' + file_ext) self.assertEqual( run_validator( schema=schema_arg, @@ -200,7 +221,7 @@ def uri_validation(self, schema_arg, schema_file_arg): # data files for file_ext in ['json', 'yaml']: - file_path = os_path.join(test_data_dir, 'invalid_uri.' + file_ext) + file_path = os_path.join(json_validation_dir, 'invalid_uri.' + file_ext) err_str = "'where is it\?' is not a 'uri'" with self.assertRaisesRegex(ValidationError, err_str): run_validator( @@ -209,7 +230,7 @@ def uri_validation(self, schema_arg, schema_file_arg): data_file=file_path, validate_at=valid_json_loc) - file_path = os_path.join(test_data_dir, 'valid_uri.' + file_ext) + file_path = os_path.join(json_validation_dir, 'valid_uri.' + file_ext) self.assertEqual( run_validator( schema=schema_arg, @@ -246,7 +267,7 @@ def date_format_validation(self, schema_arg, schema_file_arg): # data files for file_ext in ['json', 'yaml']: # invalid type (number instead of string) - file_path = os_path.join(test_data_dir, 'invalid_date_type.' + file_ext) + file_path = os_path.join(json_validation_dir, 'invalid_date_type.' + file_ext) err_str = "20200606 is not of type 'string'" with self.assertRaisesRegex(ValidationError, err_str): run_validator( @@ -256,7 +277,7 @@ def date_format_validation(self, schema_arg, schema_file_arg): validate_at=valid_json_loc) # quoted string but not in the correct format - file_path = os_path.join(test_data_dir, 'invalid_date.' + file_ext) + file_path = os_path.join(json_validation_dir, 'invalid_date.' + file_ext) err_str = "'20200606' is not a 'date'" with self.assertRaisesRegex(ValidationError, err_str): run_validator( @@ -265,7 +286,7 @@ def date_format_validation(self, schema_arg, schema_file_arg): data_file=file_path, validate_at=valid_json_loc) - file_path = os_path.join(test_data_dir, 'valid_date.' + file_ext) + file_path = os_path.join(json_validation_dir, 'valid_date.' + file_ext) self.assertEqual( run_validator( schema=schema_arg, @@ -280,7 +301,7 @@ def date_format_validation(self, schema_arg, schema_file_arg): ) # pyyaml-specific issue: dates get automatically parsed into datetime objects (doh!) - file_path = os_path.join(test_data_dir, 'unquoted_date.yaml') + file_path = os_path.join(json_validation_dir, 'unquoted_date.yaml') err_str = "datetime.date\(2020, 6, 6\) is not of type 'string'" with self.assertRaisesRegex(ValidationError, err_str): run_validator( @@ -292,24 +313,6 @@ def date_format_validation(self, schema_arg, schema_file_arg): def test_schema_references(self): """Ensure referenced schemas, including those written in yaml, can be accessed.""" - valid_edge_data = { - "_from": "here", - "_to": "eternity", - "score": 1.23456, - "_key": "abcdefg", - "edge_type": "domain_co_occur", - } - - invalid_edge_data = { - "_from": "here", - "_to": "eternity", - "score": 1.23456, - "_key": "abcdefg", - "edge_type": "whatever", - } - - schema_ref_dir = ['/app', 'relation_engine_server', 'test', 'data', 'schema_refs'] - # same schema in different places path_list = [ [], @@ -321,13 +324,16 @@ def test_schema_references(self): for path in path_list: for file_ext in ['json', 'yaml']: - file_path = os_path.join(*(schema_ref_dir + path), 'edge.' + file_ext) + file_path = os_path.join(*(test_data_dirs + ['schema_refs'] + path), 'edge.' + file_ext) + + # fails due to invalid data with self.assertRaisesRegex(ValidationError, err_msg): run_validator( schema_file=file_path, data=invalid_edge_data, ) + # valid data self.assertEqual( run_validator( schema_file=file_path, @@ -335,3 +341,68 @@ def test_schema_references(self): ), valid_edge_data ) + + # validate using the schema instead of the schema_file + with open(file_path) as fd: + contents = yaml.safe_load(fd) if file_ext == 'yaml' else json.load(fd) + + # if there is no $id in the schema, the ref resolver won't know + # where the schema file is located and will not resolve relative references + with self.assertRaisesRegex(RefResolutionError, 'No such file or directory'): + run_validator( + schema=contents, + data=valid_edge_data + ) + + # inject an $id with the current file path + contents['$id'] = file_path + self.assertEqual( + run_validator( + schema=contents, + data=valid_edge_data, + ), + valid_edge_data + ) + + def test_complex_schema_references(self): + """test validation with complex references that reference other references""" + + valid_data = { + 'node': { + 'id': 'TAIR:19830', + 'type': 'gene', + }, + 'edge': valid_edge_data, + 'marks_out_of_ten': 5 + } + + invalid_data = { + 'node': { + 'id': 'TAIR:19830', + 'type': 'gene', + }, + 'edge': invalid_edge_data, + 'marks_out_of_ten': 5 + } + + err_msg = "'whatever' is not valid under any of the given schemas" + for file_ext in ['json', 'yaml']: + file_path = os_path.join( + *(test_data_dirs + ['schema_refs', 'level_1']), + 'test_object.' + file_ext + ) + + # data fails validation + with self.assertRaisesRegex(ValidationError, err_msg): + run_validator( + schema_file=file_path, + data=invalid_data, + ) + + self.assertEqual( + run_validator( + schema_file=file_path, + data=valid_data, + ), + valid_data + ) From 4d3c3c713d7c5161e6156f36d809adc45d81d7bd Mon Sep 17 00:00:00 2001 From: ialarmedalien Date: Wed, 12 Aug 2020 17:15:17 -0700 Subject: [PATCH 553/732] Run tests with GitHub Actions --- .github/workflows/run_tests.yaml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 .github/workflows/run_tests.yaml diff --git a/.github/workflows/run_tests.yaml b/.github/workflows/run_tests.yaml new file mode 100644 index 00000000..4700872f --- /dev/null +++ b/.github/workflows/run_tests.yaml @@ -0,0 +1,18 @@ +name: Run Tests +on: + [push, pull_request] +jobs: + run_tests: + runs-on: ubuntu-latest + steps: + - name: checkout git repo + uses: actions/checkout@v2 + + - name: run tests + shell: bash + env: + GITHUB_ACTIONS_CI: 1 + run: | + docker-compose build + docker-compose run re_api sh scripts/run_tests.sh + docker-compose down --remove-orphans From d85ba310e79a27c383608fe1b6800384116bee5a Mon Sep 17 00:00:00 2001 From: ialarmedalien Date: Tue, 18 Aug 2020 09:08:13 -0700 Subject: [PATCH 554/732] refactor relation_engine_server/utils/spec_loader; add spec_loader tests; rework relation_engine_server api tests and add tests for endpoints not covered --- client_src/test/test_integration.py | 13 +- relation_engine_server/api_versions/api_v1.py | 33 +- relation_engine_server/main.py | 25 +- .../collections/sample/directory/README.md | 0 .../data/collections/sample/set/README.md | 0 .../test/data/collections/straight/edge.yaml | 0 .../data/collections/straight/to/README.md | 0 .../collections/straight/to/the/core.json | 0 .../collections/straight/to/the/point.json | 0 .../data/collections/test_another_node.json | 0 .../test/data/collections/test_edge.yaml | 0 .../test/data/collections/test_node.yaml | 0 relation_engine_server/test/test_api_v1.py | 387 ++++++++++++++---- .../test/test_json_validation.py | 3 +- .../test/test_spec_loader.py | 156 +++++++ relation_engine_server/utils/config.py | 26 +- .../utils/load_data_sources.py | 42 -- relation_engine_server/utils/spec_loader.py | 155 +++++-- spec/test/mock_services/mock_auth/admin.json | 26 -- .../test/mock_services/mock_auth/invalid.json | 23 -- .../mock_services/mock_auth/invalid2.json | 21 - spec/test/mock_services/mock_auth/valid.json | 24 -- .../list_workspace_ids_admin.json | 17 - .../list_workspace_ids_invalid1.json | 22 - .../list_workspace_ids_valid.json | 22 - 25 files changed, 635 insertions(+), 360 deletions(-) create mode 100644 relation_engine_server/test/data/collections/sample/directory/README.md create mode 100644 relation_engine_server/test/data/collections/sample/set/README.md create mode 100644 relation_engine_server/test/data/collections/straight/edge.yaml create mode 100644 relation_engine_server/test/data/collections/straight/to/README.md create mode 100644 relation_engine_server/test/data/collections/straight/to/the/core.json create mode 100644 relation_engine_server/test/data/collections/straight/to/the/point.json create mode 100644 relation_engine_server/test/data/collections/test_another_node.json create mode 100644 relation_engine_server/test/data/collections/test_edge.yaml create mode 100644 relation_engine_server/test/data/collections/test_node.yaml create mode 100644 relation_engine_server/test/test_spec_loader.py delete mode 100644 relation_engine_server/utils/load_data_sources.py delete mode 100644 spec/test/mock_services/mock_auth/admin.json delete mode 100644 spec/test/mock_services/mock_auth/invalid.json delete mode 100644 spec/test/mock_services/mock_auth/invalid2.json delete mode 100644 spec/test/mock_services/mock_auth/valid.json delete mode 100644 spec/test/mock_services/mock_workspace/list_workspace_ids_admin.json delete mode 100644 spec/test/mock_services/mock_workspace/list_workspace_ids_invalid1.json delete mode 100644 spec/test/mock_services/mock_workspace/list_workspace_ids_valid.json diff --git a/client_src/test/test_integration.py b/client_src/test/test_integration.py index a7327af6..43d757e0 100644 --- a/client_src/test/test_integration.py +++ b/client_src/test/test_integration.py @@ -169,7 +169,18 @@ def test_save_docs_invalid_args(self): def test_save_docs_unknown_coll(self): with self.assertRaises(RERequestError) as ctx: self.client.save_docs('xyz123', [{'_key': 0}]) - self.assertEqual(ctx.exception.resp.status_code, 400) + self.assertEqual(ctx.exception.resp.status_code, 404) + self.assertEqual( + ctx.exception.resp.json(), + { + 'error': { + 'message': 'Not found', + 'status': 404, + 'details': "Collection 'xyz123' does not exist.", + 'name': 'xyz123', + } + } + ) # Mostly make sure that the __str__ method does not throw any errs self.assertTrue('Response:' in str(ctx.exception)) diff --git a/relation_engine_server/api_versions/api_v1.py b/relation_engine_server/api_versions/api_v1.py index 36dcf3fd..515dd7a5 100644 --- a/relation_engine_server/api_versions/api_v1.py +++ b/relation_engine_server/api_versions/api_v1.py @@ -2,7 +2,6 @@ from relation_engine_server.utils import ( arango_client, spec_loader, - load_data_sources, auth, bulk_import, pull_spec, @@ -15,25 +14,38 @@ api_v1 = flask.Blueprint('api_v1', __name__) -@api_v1.route("/data_sources", methods=["GET"]) +@api_v1.route("/data_sources", methods=['GET']) def list_data_sources(): - data_sources = load_data_sources.list_all() + # note the custom response format is used by the frontend, so this endpoint is provided + # in addition to the /specs/data_sources endpoint + + data_sources = spec_loader.get_names('data_sources') return flask.jsonify({'data_sources': data_sources}) -@api_v1.route("/data_sources/", methods=["GET"]) -def show_data_source(name): - data_source = load_data_sources.fetch_one(name) +@api_v1.route("/data_sources/", methods=['GET']) +def fetch_data_source(name): + + data_source = spec_loader.get_schema('data_source', name) return flask.jsonify({'data_source': data_source}) +@api_v1.route('/specs/data_sources', methods=['GET']) +def show_data_sources(): + """Show the current data sources loaded from the spec.""" + name = flask.request.args.get('name') + if name: + return flask.jsonify(spec_loader.get_schema('data_source', name)) + return flask.jsonify(spec_loader.get_names('data_sources')) + + @api_v1.route('/specs/stored_queries', methods=['GET']) def show_stored_queries(): """Show the current stored query names loaded from the spec.""" name = flask.request.args.get('name') if name: - return {'stored_query': spec_loader.get_stored_query(name)} - return flask.jsonify(spec_loader.get_stored_query_names()) + return flask.jsonify({'stored_query': spec_loader.get_schema('stored_query', name)}) + return flask.jsonify(spec_loader.get_names('stored_query')) @api_v1.route('/specs/collections', methods=['GET']) @@ -43,11 +55,11 @@ def show_collections(): name = flask.request.args.get('name') doc_id = flask.request.args.get('doc_id') if name: - return flask.jsonify(spec_loader.get_collection(name)) + return flask.jsonify(spec_loader.get_schema('collection', name)) elif doc_id: return flask.jsonify(spec_loader.get_schema_for_doc(doc_id)) else: - return flask.jsonify(spec_loader.get_collection_names()) + return flask.jsonify(spec_loader.get_names('collection')) @api_v1.route('/query_results', methods=['POST']) @@ -70,7 +82,6 @@ def run_query(): if 'query' in json_body: # Run an adhoc query for a sysadmin auth.require_auth_token(roles=['RE_ADMIN']) - query_text = json_body['query'] query_text = _preprocess_stored_query(json_body['query'], json_body) del json_body['query'] json_body['ws_ids'] = ws_ids diff --git a/relation_engine_server/main.py b/relation_engine_server/main.py index 5e5a249a..9425d42a 100644 --- a/relation_engine_server/main.py +++ b/relation_engine_server/main.py @@ -8,7 +8,8 @@ from relation_engine_server.api_versions.api_v1 import api_v1 from relation_engine_server.exceptions import MissingHeader, UnauthorizedAccess, InvalidParameters, NotFound -from relation_engine_server.utils import arango_client, spec_loader +from relation_engine_server.utils.spec_loader import SchemaNonexistent +from relation_engine_server.utils import arango_client app = flask.Flask(__name__) app.config['DEBUG'] = os.environ.get('FLASK_DEBUG', True) @@ -64,14 +65,6 @@ def invalid_params(err): return (flask.jsonify(resp), 400) -@app.errorhandler(spec_loader.CollectionNonexistent) -@app.errorhandler(spec_loader.StoredQueryNonexistent) -def view_does_not_exist(err): - """General error cases.""" - resp = {'error': str(err), 'name': err.name} - return (flask.jsonify(resp), 400) - - @app.errorhandler(ValidationError) def validation_error(err): """Json Schema validation error.""" @@ -99,6 +92,20 @@ def unauthorized_access(err): return (flask.jsonify(resp), 403) +@app.errorhandler(SchemaNonexistent) +def schema_does_not_exist(err): + """General error cases.""" + resp = { + 'error': { + 'message': 'Not found', + 'status': 404, + 'details': str(err), + 'name': err.name, + } + } + return (flask.jsonify(resp), 404) + + @app.errorhandler(NotFound) @app.errorhandler(404) def page_not_found(err): diff --git a/relation_engine_server/test/data/collections/sample/directory/README.md b/relation_engine_server/test/data/collections/sample/directory/README.md new file mode 100644 index 00000000..e69de29b diff --git a/relation_engine_server/test/data/collections/sample/set/README.md b/relation_engine_server/test/data/collections/sample/set/README.md new file mode 100644 index 00000000..e69de29b diff --git a/relation_engine_server/test/data/collections/straight/edge.yaml b/relation_engine_server/test/data/collections/straight/edge.yaml new file mode 100644 index 00000000..e69de29b diff --git a/relation_engine_server/test/data/collections/straight/to/README.md b/relation_engine_server/test/data/collections/straight/to/README.md new file mode 100644 index 00000000..e69de29b diff --git a/relation_engine_server/test/data/collections/straight/to/the/core.json b/relation_engine_server/test/data/collections/straight/to/the/core.json new file mode 100644 index 00000000..e69de29b diff --git a/relation_engine_server/test/data/collections/straight/to/the/point.json b/relation_engine_server/test/data/collections/straight/to/the/point.json new file mode 100644 index 00000000..e69de29b diff --git a/relation_engine_server/test/data/collections/test_another_node.json b/relation_engine_server/test/data/collections/test_another_node.json new file mode 100644 index 00000000..e69de29b diff --git a/relation_engine_server/test/data/collections/test_edge.yaml b/relation_engine_server/test/data/collections/test_edge.yaml new file mode 100644 index 00000000..e69de29b diff --git a/relation_engine_server/test/data/collections/test_node.yaml b/relation_engine_server/test/data/collections/test_node.yaml new file mode 100644 index 00000000..e69de29b diff --git a/relation_engine_server/test/test_api_v1.py b/relation_engine_server/test/test_api_v1.py index 5ea07a42..9872514c 100644 --- a/relation_engine_server/test/test_api_v1.py +++ b/relation_engine_server/test/test_api_v1.py @@ -7,7 +7,6 @@ import requests import json import os - from relation_engine_server.utils.config import get_config from relation_engine_server.utils.wait_for import wait_for_api @@ -62,6 +61,39 @@ class TestApi(unittest.TestCase): def setUpClass(cls): wait_for_api() + def test_request(self, url=None, params=None, data=None, headers=None, method='get', + status_code=200, resp_json=None, resp_test=None): + '''test a get request to the server + + arguments: + url url to be appended to API_URL (i.e. request will be made to API_URL + url) + params request parameters + method HTTP method; defaults to 'get' + status_code expected response status; defaults to 200 + resp_json expected response content (JSON) + resp_test a function to perform on the response to test it is as expected + ''' + + if url is None: + self.skipTest('No arguments provided') + + resp = requests.request( + method, + API_URL + url, + params=params, + data=data, + headers=headers, + ) + self.assertEqual(resp.status_code, status_code) + if resp_json: + self.assertEqual( + resp_json, + resp.json() + ) + + if resp_test: + resp_test(self, resp) + def test_root(self): """Test root path for api.""" resp = requests.get(URL + '/').json() @@ -104,57 +136,248 @@ def test_update_specs(self): ('expired', 'created', 'last_version') }) - def test_list_stored_queries(self): - """Test the listing out of saved AQL stored queries.""" - resp = requests.get(API_URL + '/specs/stored_queries').json() - for sq in ['fetch_test_vertex', 'list_test_vertices', 'ncbi_fetch_taxon']: - self.assertIn(sq, resp) + def check_list_contains(self, the_list, must_contain): + '''ensure the_list contains the items in must_contain''' + for item in must_contain: + self.assertIn(item, the_list) def test_list_collections(self): """Test the listing out of registered collection schemas for vertices and edges.""" for variant in ['schemas', 'collections']: - resp = requests.get(API_URL + '/specs/' + variant).json() - self.assertTrue(len(resp)) - for coll in ['test_edge', 'test_vertex', 'ncbi_taxon']: - self.assertIn(coll, resp) - def test_fetch_schema_for_doc(self): - """Given a document ID, fetch its schema.""" + def check_resp_json_contains(self, resp): + resp_json = resp.json() + self.check_list_contains(resp_json, ['test_edge', 'test_vertex', 'ncbi_taxon']) - for variant in ['schemas', 'collections']: - resp = requests.get( - API_URL + '/specs/' + variant, - params={'doc_id': 'test_vertex/123'} - ).json() - self.assertEqual(resp['name'], 'test_vertex') - self.assertEqual(resp['type'], 'vertex') - self.assertTrue(resp['schema']) - - def test_fetch_invalid_collections(self): - """Test the case where the collection/schema does not exist.""" - for variant in ['schemas', 'collections']: - resp = requests.get( - API_URL + '/specs/' + variant, - params={'name': 'xyzabc'}, - ).json() - self.assertEqual(resp['error'], 'Collection does not exist.') + self.test_request( + '/specs/' + variant, + resp_test=check_resp_json_contains + ) + + def test_list_data_sources(self): + """test the data source listing endpoints""" + + # there are two different data_sources endpoints that return very similar results + # /data_sources is used by the UI and requires slightly different response formatting + # /specs/data_sources is in the standard /specs format used by collections and stored_queries + + data_sources = ['djornl', 'envo_ontology', 'go_ontology', 'gtdb', 'ncbi_taxonomy', 'rdp_taxonomy'] + + # /spec/data_sources endpoint + def check_resp_json_spec_endpoint(self, resp): + resp_json = resp.json() + self.check_list_contains( + resp_json, + data_sources, + ) + + self.test_request( + '/specs/data_sources', + resp_test=check_resp_json_spec_endpoint + ) + + def test_list_stored_queries(self): + """Test the listing out of saved AQL stored queries.""" + + def check_resp_json_contains(self, resp): + resp_json = resp.json() + self.check_list_contains( + resp_json, + ['fetch_test_vertex', 'list_test_vertices', 'ncbi_fetch_taxon'] + ) + + self.test_request( + '/specs/stored_queries', + resp_test=check_resp_json_contains, + ) + + def test_fetch_collection_and_fetch_schema_for_doc(self): + """Given a collection name or a document ID, fetch its schema.""" + + name = 'test_vertex' + collection_params = {'name': name} # valid collection + document_params = {'doc_id': name + '/123'} # valid document + + def check_resp_json(self, resp): + resp_json = resp.json() + self.assertEqual(resp_json['name'], name) + self.assertEqual(resp_json['type'], 'vertex') + self.assertTrue(resp_json['schema']) - def test_fetch_invalid_documents(self): - """Test the case where the collection/schema does not exist.""" for variant in ['schemas', 'collections']: - resp = requests.get( - API_URL + '/specs/' + variant, - params={'doc_id': 'fake_collection/123'}, - ).json() - self.assertEqual(resp['error'], 'Collection does not exist.') + for params in [document_params, collection_params]: + self.test_request( + '/specs/' + variant, + params=params, + resp_test=check_resp_json, + ) + + def test_fetch_data_source(self): + '''fetch a data source by name''' + + name = 'ncbi_taxonomy' + + def check_resp_json(self, resp): + resp_json = resp.json() + self.assertEqual(type(resp_json), dict) + self.assertEqual(set(resp_json.keys()), { + 'name', 'category', 'title', 'home_url', 'data_url', 'logo_url' + }) + self.assertTrue( + '/ui-assets/images/third-party-data-sources/ncbi' in resp_json['logo_url'] + ) + + self.test_request( + '/specs/data_sources', + {'name': name}, + resp_test=check_resp_json + ) + + def test_fetch_stored_query(self): + '''fetch a stored query by name''' + + name = 'fetch_test_vertex' + + # note that the stored_queries endpoint returns the query data in a dict + # under the key 'stored_query' + def check_resp_json(self, resp): + resp_json = resp.json() + self.assertEqual(type(resp_json['stored_query']), dict) + self.assertEqual(resp_json['stored_query']['name'], name) + self.assertEqual(set(resp_json['stored_query'].keys()), { + 'name', 'query', 'params' + }) + + self.test_request( + '/specs/stored_queries', + {'name': name}, + resp_test=check_resp_json + ) + + def test_fetch_invalid_data_source(self): + """Unknown data source name should yield 404 status.""" - def test_fetch_invalid_queries(self): + name = 'invalid_data_source' + self.test_request( + '/specs/data_sources', + {'name': name}, + status_code=404, + resp_json={ + 'error': { + 'status': 404, + 'message': 'Not found', + 'details': f"Data source '{name}' does not exist.", + 'name': name, + } + } + ) + + def test_fetch_invalid_collections_and_documents(self): + """Test the case where the collection or document does not exist.""" + + name = 'fake_collection' + collection_params = {'name': name} # fetch an invalid collection + document_params = {'doc_id': name + '/123'} # fetch an invalid document + for variant in ['schemas', 'collections']: + for params in [document_params, collection_params]: + + self.test_request( + '/specs/' + variant, + params=params, + status_code=404, + resp_json={ + 'error': { + 'status': 404, + 'message': 'Not found', + 'details': f"Collection '{name}' does not exist.", + 'name': name, + } + } + ) + + def test_fetch_invalid_stored_queries(self): """Test the case where the stored query does not exist.""" - resp = requests.get( - API_URL + '/specs/stored_queries', - params={'name': 'xyzabc'}, - ).json() - self.assertEqual(resp['error'], 'Stored query does not exist.') + + name = 'made_up_stored_query' + self.test_request( + '/specs/stored_queries', + params={'name': name}, + status_code=404, + resp_json={ + 'error': { + 'status': 404, + 'message': 'Not found', + 'details': f"Stored query '{name}' does not exist.", + 'name': name, + } + } + ) + + def test_show_data_sources(self): + resp = requests.get(API_URL + '/data_sources') + self.assertTrue(resp.ok) + resp_json = resp.json() + self.assertTrue(len(resp_json['data_sources']) > 0) + self.assertEqual(set(type(x) for x in resp_json['data_sources']), {str}) + + def test_show_data_source(self): + + name = 'ncbi_taxonomy' + + def check_resp_json(self, resp): + resp_json = resp.json() + self.assertEqual(type(resp_json['data_source']), dict) + self.assertEqual(set(resp_json['data_source'].keys()), { + 'name', 'category', 'title', 'home_url', 'data_url', 'logo_url' + }) + self.assertTrue( + '/ui-assets/images/third-party-data-sources/ncbi' in resp_json['data_source']['logo_url'] + ) + + self.test_request( + '/data_sources/' + name, + resp_test=check_resp_json + ) + + resp = requests.get(API_URL + '/data_sources/ncbi_taxonomy') + self.assertTrue(resp.ok) + resp_json = resp.json() + self.assertEqual(type(resp_json['data_source']), dict) + self.assertEqual(set(resp_json['data_source'].keys()), { + 'name', 'category', 'title', 'home_url', 'data_url', 'logo_url' + }) + self.assertTrue( + '/ui-assets/images/third-party-data-sources/ncbi' in resp_json['data_source']['logo_url'] + ) + + def test_show_data_source_unknown(self): + """Unknown data source name should yield 404 status.""" + name = 'xyzyxz' + + self.test_request( + f"/data_sources/{name}", + status_code=404, + resp_json={ + 'error': { + 'status': 404, + 'message': 'Not found', + 'details': f"Data source '{name}' does not exist.", + 'name': name, + } + } + ) + + resp = requests.get(f"{API_URL}/data_sources/{name}") + self.assertEqual(resp.status_code, 404) + resp_json = resp.json() + self.assertEqual(resp_json, { + 'error': { + 'message': 'Not found', + 'status': 404, + 'name': name, + 'details': f"Data source '{name}' does not exist.", + } + }) def test_save_documents_missing_auth(self): """Test an invalid attempt to save a doc with a missing auth token.""" @@ -196,13 +419,24 @@ def test_save_documents_invalid_schema(self): def test_save_documents_missing_schema(self): """Test the case where the collection/schema does not exist.""" - resp = requests.put( - API_URL + '/documents', - params={'collection': 'xyzabc'}, + + name = 'fake_collection' + self.test_request( + '/documents', + method='put', + params={'collection': name}, data='', - headers=HEADERS_ADMIN - ).json() - self.assertTrue('Collection does not exist' in resp['error']) + headers=HEADERS_ADMIN, + status_code=404, + resp_json={ + 'error': { + 'status': 404, + 'message': 'Not found', + 'details': f"Collection '{name}' does not exist.", + 'name': name, + } + } + ) def test_save_documents_invalid_json(self): """Test an attempt to save documents with an invalid JSON body.""" @@ -362,12 +596,22 @@ def test_query_with_cursor(self): def test_query_no_name(self): """Test a query error with a stored query name that does not exist.""" - resp = requests.post( - API_URL + '/query_results', - params={'stored_query': 'nonexistent'} - ).json() - self.assertEqual(resp['error'], 'Stored query does not exist.') - self.assertEqual(resp['name'], 'nonexistent') + + name = 'nonexistent' + self.test_request( + '/query_results', + method='post', + params={'stored_query': name}, + status_code=404, + resp_json={ + 'error': { + 'status': 404, + 'message': 'Not found', + 'details': f"Stored query '{name}' does not exist.", + 'name': name, + } + } + ) def test_query_missing_bind_var(self): """Test a query error with a missing bind variable.""" @@ -442,6 +686,7 @@ def test_auth_query_invalid_token(self): data='{"name": "requires_auth", "_key": "1", "ws_id": 99}', headers=HEADERS_ADMIN ) + resp = requests.post( API_URL + '/query_results', params={'view': 'list_test_vertices'}, @@ -480,37 +725,3 @@ def test_save_docs_invalid(self): self.assertEqual(resp.status_code, 400) resp_json = resp.json() self.assertEqual(resp_json['errors'], 1) - - def test_list_data_sources(self): - resp = requests.get(API_URL + '/data_sources') - self.assertTrue(resp.ok) - resp_json = resp.json() - self.assertTrue(len(resp_json['data_sources']) > 0) - self.assertEqual(set(type(x) for x in resp_json['data_sources']), {str}) - - def test_show_data_source(self): - resp = requests.get(API_URL + '/data_sources/ncbi_taxonomy') - self.assertTrue(resp.ok) - resp_json = resp.json() - self.assertEqual(type(resp_json['data_source']), dict) - self.assertEqual(set(resp_json['data_source'].keys()), { - 'name', 'category', 'title', 'home_url', 'data_url', 'logo_url' - }) - self.assertTrue( - '/ui-assets/images/third-party-data-sources/ncbi' in resp_json['data_source']['logo_url'] - ) - - def test_show_data_source_unknown(self): - """Unknown data source name should yield 404 status.""" - name = 'xyzyxz' - resp = requests.get(f"{API_URL}/data_sources/{name}") - self.assertEqual(resp.status_code, 404) - resp_json = resp.json() - # Just assert that it returns any json in the body - self.assertEqual(resp_json, { - 'error': { - 'message': 'Not found', - 'status': 404, - 'details': f"The data source with name '{name}' does not exist.", - } - }) diff --git a/relation_engine_server/test/test_json_validation.py b/relation_engine_server/test/test_json_validation.py index 5f0c0ab8..649cba81 100644 --- a/relation_engine_server/test/test_json_validation.py +++ b/relation_engine_server/test/test_json_validation.py @@ -6,8 +6,7 @@ import json import yaml from relation_engine_server.utils.json_validation import run_validator -from jsonschema.exceptions import ValidationError -from jsonschema.exceptions import RefResolutionError +from jsonschema.exceptions import ValidationError, RefResolutionError from jsonpointer import JsonPointerException diff --git a/relation_engine_server/test/test_spec_loader.py b/relation_engine_server/test/test_spec_loader.py new file mode 100644 index 00000000..8349b2db --- /dev/null +++ b/relation_engine_server/test/test_spec_loader.py @@ -0,0 +1,156 @@ +""" +Test JSON validation functions +""" +import unittest +import os.path as os_path +from urllib.parse import urlparse +from relation_engine_server.utils import spec_loader +from relation_engine_server.utils.spec_loader import SchemaNonexistent +from relation_engine_server.utils.config import get_config +from relation_engine_server.utils.wait_for import wait_for_api + +_CONF = get_config() +_TEST_DIR = os_path.join('/app', 'relation_engine_server', 'test', 'data') + + +class TestSpecLoader(unittest.TestCase): + + @classmethod + def setUpClass(cls): + wait_for_api() + cls.config = get_config() + + def test_get_names(self, schema_type_names=[], expected=[]): + + # this method should only be run from another test method + if len(schema_type_names) == 0: + self.skipTest('No schema type names supplied. Skipping') + + schema_type_singular = schema_type_names[0] + schema_type_plural = schema_type_names[1] + method = getattr(spec_loader, 'get_' + schema_type_singular + '_names') + + # save the original value + original_config_dir = _CONF['spec_paths'][schema_type_plural] + # set the config to the test directory + _CONF['spec_paths'][schema_type_plural] = os_path.join(_TEST_DIR, schema_type_plural) + + got_names_method = method() + got_names_singular = spec_loader.get_names(schema_type_singular) + got_names_plural = spec_loader.get_names(schema_type_plural) + + _CONF['spec_paths'][schema_type_plural] = os_path.join(_TEST_DIR, 'empty') + got_names_method_empty = method() + got_names_empty = spec_loader.get_names(schema_type_singular) + + # restore the original value + _CONF['spec_paths'][schema_type_plural] = original_config_dir + + # ensure the results are as expected + # get_collection_names + self.assertEqual(set(expected), set(got_names_method)) + # get_names('collection') + self.assertEqual(set(expected), set(got_names_singular)) + # get_names('collections') + self.assertEqual(set(expected), set(got_names_plural)) + + # empty collections dir + self.assertEqual(got_names_method_empty, []) + self.assertEqual(got_names_empty, []) + + def test_run_spec_loading_tests(self, schema_type_names=[], test_name=None): + """test the different ways of returning a schema file path or its contents""" + + # only run the test if it's being called from another test + if test_name is None: + self.skipTest('No test name supplied') + + print("running test_run_spec_loading_tests with schema_type " + schema_type_names[0]) + method = getattr(spec_loader, 'get_' + schema_type_names[0]) + + # get the path of the requested file + result_path = method(test_name, path_only=True) + self.assertIsInstance(result_path, str) + self.assertIn(test_name, result_path) + self.assertIn( + self.config['spec_paths'][schema_type_names[1]], + result_path, + ) + + # use get_schema directly to get the file path + for schema_type in schema_type_names: + self.assertEqual( + result_path, + spec_loader.get_schema(schema_type, test_name, True) + ) + + # get the file contents + result_obj = method(test_name) + self.assertIs(type(result_obj), dict) + self.assertEqual(result_obj['name'], test_name) + + # check the contents of the dict when getting a data source + if schema_type_names[0] == 'data_source': + + # logo_url should start with the same base as _CONF['kbase_endpoint'] + endpoint = urlparse(_CONF['kbase_endpoint']) + self.assertIn(endpoint.scheme + '://' + endpoint.netloc, result_obj['logo_url']) + + # logo_path is deleted + self.assertNotIn('logo_path', result_obj.keys()) + + # a nonexistent file raises the appropriate error + fake_name = '../../../../spec/repo/collections/djornl/djornl_edge' + err_msg = schema_type_names[0].capitalize().replace("_", " ") + " '" + fake_name + "' does not exist." + with self.assertRaisesRegex(SchemaNonexistent, err_msg): + method(fake_name, path_only=True) + + def test_get_schemas_of_various_types(self): + """test retrieving schemas or paths to schemas for the different schema types""" + + schema_type_list = [ + { + # schema_type_names: singular, plural + 'schema_type_names': ['collection', 'collections'], + 'example': 'ncbi_taxon', + 'names': ['core', 'edge', 'point', 'test_another_node', 'test_edge', 'test_node'], + }, + { + 'schema_type_names': ['data_source', 'data_sources'], + 'example': 'ncbi_taxonomy', + }, + { + 'schema_type_names': ['stored_query', 'stored_queries'], + 'example': 'ncbi_fetch_taxon', + }, + ] + + for schema in schema_type_list: + self.test_run_spec_loading_tests(schema['schema_type_names'], schema['example']) + if schema['schema_type_names'][0] == 'collection': + self.test_get_names(schema['schema_type_names'], schema['names']) + + def test_get_schema_for_doc(self): + """test getting the schema for a specific document""" + + test_name = 'ncbi_taxon' + test_doc = test_name + '/12345' + # get the path of the requested file + result_path = spec_loader.get_schema_for_doc(test_doc, path_only=True) + self.assertIsInstance(result_path, str) + self.assertIn(test_name, result_path) + self.assertIn( + self.config['spec_paths']['collections'], + result_path, + ) + + # get the file contents + result_obj = spec_loader.get_schema_for_doc(test_doc) + self.assertIs(type(result_obj), dict) + self.assertEqual(result_obj['name'], test_name) + + fake_name = 'fake_name/12345' + # a nonexistent file raises the appropriate error + err_msg = f"Collection 'fake_name' does not exist." + with self.assertRaisesRegex(SchemaNonexistent, err_msg): + spec_loader.get_schema_for_doc(fake_name, path_only=True) diff --git a/relation_engine_server/utils/config.py b/relation_engine_server/utils/config.py index 156d37b8..599f65fa 100644 --- a/relation_engine_server/utils/config.py +++ b/relation_engine_server/utils/config.py @@ -9,24 +9,25 @@ @functools.lru_cache(maxsize=1) def get_config(): """Load environment configuration data.""" - spec_path = os.environ.get('SPEC_PATH', '/spec') - spec_release_url = os.environ.get('SPEC_RELEASE_URL') - spec_release_path = os.environ.get('SPEC_RELEASE_PATH') + spec_path = os.environ.get('SPEC_PATH', '/spec') # /spec spec_repo_path = os.path.join(spec_path, 'repo') # /spec/repo - collections_path = os.path.join(spec_repo_path, 'collections') # /spec/repo/collections - stored_queries_path = os.path.join(spec_repo_path, 'stored_queries') # /spec/repo/stored_queries - views_path = os.path.join(spec_repo_path, 'views') # /spec/repo/views + spec_url = 'https://api.github.com/repos/kbase/relation_engine_spec' + spec_release_url = os.environ.get('SPEC_RELEASE_URL') + spec_release_path = os.environ.get('SPEC_RELEASE_PATH') + kbase_endpoint = os.environ.get('KBASE_ENDPOINT', 'https://ci.kbase.us/services') auth_url = os.environ.get('KBASE_AUTH_URL', urljoin(kbase_endpoint + '/', 'auth')) workspace_url = os.environ.get('KBASE_WORKSPACE_URL', urljoin(kbase_endpoint + '/', 'ws')) + db_url = os.environ.get('DB_URL', 'http://arangodb:8529') db_name = os.environ.get('DB_NAME', '_system') db_user = os.environ.get('DB_USER', 'root') db_pass = os.environ.get('DB_PASS', '') - api_url = db_url + '/_db/' + db_name + '/_api' db_readonly_user = os.environ.get('DB_READONLY_USER', db_user) db_readonly_pass = os.environ.get('DB_READONLY_PASS', db_pass) + api_url = db_url + '/_db/' + db_name + '/_api' + return { 'auth_url': auth_url, 'workspace_url': workspace_url, @@ -42,12 +43,13 @@ def get_config(): 'spec_release_url': spec_release_url, 'spec_release_path': spec_release_path, 'spec_paths': { + 'root': spec_path, # /spec 'release_id': os.path.join(spec_path, '.release_id'), - 'root': spec_path, - 'repo': spec_repo_path, - 'collections': collections_path, - 'stored_queries': stored_queries_path, - 'views': views_path, + 'repo': spec_repo_path, # /spec/repo + 'collections': os.path.join(spec_repo_path, 'collections'), # /spec/repo/collections + 'datasets': os.path.join(spec_repo_path, 'datasets'), 'data_sources': os.path.join(spec_repo_path, 'data_sources'), + 'stored_queries': os.path.join(spec_repo_path, 'stored_queries'), + 'views': os.path.join(spec_repo_path, 'views'), } } diff --git a/relation_engine_server/utils/load_data_sources.py b/relation_engine_server/utils/load_data_sources.py deleted file mode 100644 index 89dd598d..00000000 --- a/relation_engine_server/utils/load_data_sources.py +++ /dev/null @@ -1,42 +0,0 @@ -""" -Load the `data_sources` info from the relation engine spec. - -The spec holds some information about some of the source data for the RE, such -as NCBI taxonomy, Gene Ontology, etc. This info may be used in the UI. -""" -import re -import yaml -import os -import glob - -from relation_engine_server.utils.config import get_config -from relation_engine_server.exceptions import NotFound - -_CONF = get_config() -_PATH = _CONF['spec_paths']['data_sources'] - - -def list_all(): - """ - List the names of all data sources. - """ - names = [] - for path in glob.iglob(os.path.join(_PATH + '/*.yaml')): - with open(path) as fd: - contents = yaml.safe_load(fd) - names.append(contents['name']) - return names - - -def fetch_one(name): - # Try .yaml or .yml - try: - with open(os.path.join(_PATH, f"{name}.yaml")) as fd: - contents = yaml.safe_load(fd) - except FileNotFoundError: - raise NotFound(f"The data source with name '{name}' does not exist.") - # Append the logo root url to be the ui-assets server url with the correct environment - base_logo_url = re.sub(r'\/services\/?', '/ui-assets', _CONF['kbase_endpoint']) - contents['logo_url'] = base_logo_url + contents['logo_path'] - del contents['logo_path'] - return contents diff --git a/relation_engine_server/utils/spec_loader.py b/relation_engine_server/utils/spec_loader.py index 86e40a94..2cc1ffa8 100644 --- a/relation_engine_server/utils/spec_loader.py +++ b/relation_engine_server/utils/spec_loader.py @@ -2,55 +2,135 @@ Utilities for loading stored queries, collections, and migrations from the spec. """ import glob +import json import os +import re import yaml from relation_engine_server.utils.config import get_config _CONF = get_config() +_schema_types = { + # singular version of schema_type names + 'singular': ['collection', 'dataset', 'data_source', 'stored_query', 'view'], + # plural version of schema_type names + 'plural': ['collections', 'datasets', 'data_sources', 'stored_queries', 'views'] +} -def get_collection_names(): - """Return a dict of vertex and edge base names.""" - names = [] # type: list - for path in _find_paths(_CONF['spec_paths']['collections'], '*.yaml'): - names.append(_get_file_name(path)) - return names +_VALID_SCHEMA_TYPES = _schema_types['singular'] + _schema_types['plural'] -def get_stored_query_names(): - """Return an array of all stored queries base names.""" - names = [] # type: list - for path in _find_paths(_CONF['spec_paths']['stored_queries'], '*.yaml'): - names.append(_get_file_name(path)) +def _switch_schema_type_name(schema_type, to_form): + """switch a schema_type name to the `to_form` version, ensuring that the schema exists first""" + + # this schema type does not exist + if schema_type not in _VALID_SCHEMA_TYPES: + raise SchemaNonexistent(schema_type) + + if schema_type in _schema_types[to_form]: + return schema_type + + from_form = 'singular' if to_form == 'plural' else 'plural' + ix = _schema_types[from_form].index(schema_type) + return _schema_types[to_form][ix] + + +def pluralise_schema_type(schema_type): + """ensure a schema_type is in the plural form""" + return _switch_schema_type_name(schema_type, 'plural') + + +def singularise_schema_type(schema_type): + """ensure a schema_type is in the singular form""" + return _switch_schema_type_name(schema_type, 'singular') + + +def get_names(schema_type): + """ + get a list of all schemas of the specified schema_type + + Throws a SchemaNonexistent error if the schema_type does not exist. + """ + + # ensure that the name is in the plural form + schema_search_type = pluralise_schema_type(schema_type) + + yaml_paths = _find_paths(_CONF['spec_paths'][schema_search_type], '*.yaml') + json_paths = _find_paths(_CONF['spec_paths'][schema_search_type], '*.json') + + names = [_get_file_name(path) for path in sorted(yaml_paths + json_paths)] + return names -def get_collection(name): - """Get YAML content for a specific collection. Throws an error if nonexistent.""" +def get_schema(schema_type, name, path_only=False): + """ + Get content or file path for a named schema of specified schema_type. + If path_only is true, the file path is returned; if not, the file contents are returned. + + Throws a SchemaNonexistent error if the named schema does not exist. + """ + + schema_search_type = pluralise_schema_type(schema_type) + try: - path = _find_paths(_CONF['spec_paths']['collections'], name + '.yaml')[0] + path = _find_paths(_CONF['spec_paths'][schema_search_type], name + '.yaml')[0] except IndexError: - raise CollectionNonexistent(name) + raise SchemaNonexistent(singularise_schema_type(schema_type), name) + + if path_only: + return path + with open(path) as fd: - return yaml.safe_load(fd) + if path.endswith('.json'): + contents = json.load(fd) + else: + contents = yaml.safe_load(fd) + + if schema_search_type == 'data_sources' and 'logo_path' in contents: + # Append the logo root url to be the ui-assets server url with the correct environment + base_logo_url = re.sub(r'\/services\/?', '/ui-assets', _CONF['kbase_endpoint']) + contents['logo_url'] = base_logo_url + contents['logo_path'] + del contents['logo_path'] + + return contents + + +def get_collection_names(): + """Return a dict of vertex and edge base names.""" + return get_names('collections') + + +def get_data_source_names(): + """Return an array of all the data source names.""" + return get_names('data_sources') + + +def get_stored_query_names(): + """Return an array of all stored queries base names.""" + return get_names('stored_queries') + +def get_collection(name, path_only=False): + """Get YAML content (or file path) for a specific collection. Throws an error if nonexistent.""" + return get_schema('collection', name, path_only) -def get_schema_for_doc(doc_id): + +def get_schema_for_doc(doc_id, path_only=False): """Get the schema for a particular document by its full ID.""" (coll_name, _) = doc_id.split('/') - ret = get_collection(coll_name) - return ret + return get_schema('collection', coll_name, path_only) -def get_stored_query(name): - """Get AQL content for a specific stored query. Throws an error if nonexistent.""" - try: - path = _find_paths(_CONF['spec_paths']['stored_queries'], name + '.yaml')[0] - except IndexError: - raise StoredQueryNonexistent(name) - with open(path) as fd: - return yaml.safe_load(fd) +def get_data_source(name, path_only=False): + """Get YAML content (or file path) for a data source. Throws an error if it does not exist.""" + return get_schema('data_source', name, path_only) + + +def get_stored_query(name, path_only=False): + """Get AQL content or file path for a specific stored query. Throws an error if nonexistent.""" + return get_schema('stored_query', name, path_only) def _find_paths(dir_path, file_pattern): @@ -69,21 +149,16 @@ def _get_file_name(path): return os.path.splitext(os.path.basename(path))[0] -class CollectionNonexistent(Exception): - """Requested collection is not in the spec.""" +class SchemaNonexistent(Exception): + """Requested schema or schema type is not in the spec""" - def __init__(self, name): + def __init__(self, schema_type, name=None): + self.schema_type = schema_type self.name = name def __str__(self): - return 'Collection does not exist.' - - -class StoredQueryNonexistent(Exception): - """Requested stored query is not in the spec.""" + schema_type = self.schema_type.capitalize().replace("_", " ") + if self.name is None: + return f"{schema_type} does not exist." - def __init__(self, name): - self.name = name - - def __str__(self): - return 'Stored query does not exist.' + return f"{schema_type} '{self.name}' does not exist." diff --git a/spec/test/mock_services/mock_auth/admin.json b/spec/test/mock_services/mock_auth/admin.json deleted file mode 100644 index 631e5bea..00000000 --- a/spec/test/mock_services/mock_auth/admin.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "methods": [ - "GET" - ], - "path": "/api/V2/me", - "headers": { - "Authorization": "admin_token" - }, - "response": { - "status": "200", - "body": { - "created": 1528306100471, - "lastlogin": 1542068355002, - "display": "Test User", - "roles": [], - "customroles": [ - "RE_ADMIN" - ], - "policyids": [], - "user": "username", - "local": false, - "email": "user@example.com", - "idents": [] - } - } -} diff --git a/spec/test/mock_services/mock_auth/invalid.json b/spec/test/mock_services/mock_auth/invalid.json deleted file mode 100644 index e74e7269..00000000 --- a/spec/test/mock_services/mock_auth/invalid.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "methods": [ - "GET" - ], - "path": "/api/V2/me", - "headers": { - "Authorization": "invalid_token" - }, - "response": { - "status": "401", - "body": { - "error": { - "httpcode": 401, - "httpstatus": "Unauthorized", - "appcode": 10020, - "apperror": "Invalid token", - "message": "10020 Invalid token", - "callid": "1757210147564211", - "time": 1542737889450 - } - } - } -} diff --git a/spec/test/mock_services/mock_auth/invalid2.json b/spec/test/mock_services/mock_auth/invalid2.json deleted file mode 100644 index 785369ac..00000000 --- a/spec/test/mock_services/mock_auth/invalid2.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "methods": [ - "GET" - ], - "path": "/api/V2/me", - "absent_headers": ["Authorization"], - "response": { - "status": "400", - "body": { - "error": { - "httpcode": 400, - "httpstatus": "Bad Request", - "appcode": 10010, - "apperror": "No authentication token", - "message": "10010 No authentication token: No user token provided", - "callid": "7334881776774415", - "time": 1542737656377 - } - } - } -} diff --git a/spec/test/mock_services/mock_auth/valid.json b/spec/test/mock_services/mock_auth/valid.json deleted file mode 100644 index 9236f450..00000000 --- a/spec/test/mock_services/mock_auth/valid.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "methods": [ - "GET" - ], - "path": "/api/V2/me", - "headers": { - "Authorization": "non_admin_token" - }, - "response": { - "status": "200", - "body": { - "created": 1528306100471, - "lastlogin": 1542068355002, - "display": "Test User", - "roles": [], - "customroles": [], - "policyids": [], - "user": "username", - "local": false, - "email": "user@example.com", - "idents": [] - } - } -} diff --git a/spec/test/mock_services/mock_workspace/list_workspace_ids_admin.json b/spec/test/mock_services/mock_workspace/list_workspace_ids_admin.json deleted file mode 100644 index 0c4ac18a..00000000 --- a/spec/test/mock_services/mock_workspace/list_workspace_ids_admin.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "methods": ["POST"], - "path": "/", - "headers": {"Authorization": "admin_token"}, - "body": { - "method": "Workspace.list_workspace_ids", - "version": "1.1", - "params": [{"perm": "r"}] - }, - "response": { - "status": "200", - "body": { - "version": "1.1", - "result": [{"workspaces": [99], "pub": []}] - } - } -} diff --git a/spec/test/mock_services/mock_workspace/list_workspace_ids_invalid1.json b/spec/test/mock_services/mock_workspace/list_workspace_ids_invalid1.json deleted file mode 100644 index 89100454..00000000 --- a/spec/test/mock_services/mock_workspace/list_workspace_ids_invalid1.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "methods": ["POST"], - "path": "/", - "headers": {"Authorization": "invalid_token"}, - "body": { - "method": "Workspace.list_workspace_ids", - "version": "1.1", - "params": [{"perm": "r"}] - }, - "response": { - "status": "500", - "body": { - "version": "1.1", - "error": { - "name": "JSONRPCError", - "code": -32400, - "message": "Token validation failed!", - "error": "..." - } - } - } -} diff --git a/spec/test/mock_services/mock_workspace/list_workspace_ids_valid.json b/spec/test/mock_services/mock_workspace/list_workspace_ids_valid.json deleted file mode 100644 index 0c879099..00000000 --- a/spec/test/mock_services/mock_workspace/list_workspace_ids_valid.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "methods": ["POST"], - "path": "/", - "headers": {"Authorization": "valid_token"}, - "body": { - "method": "Workspace.list_workspace_ids", - "version": "1.1", - "params": [{"perm": "r"}] - }, - "response": { - "status": "200", - "body": { - "version": "1.1", - "result": [ - { - "workspaces": [1, 2, 3], - "pub": [] - } - ] - } - } -} From c49351dde139a76cb9761fd97d6e5c6b561d793b Mon Sep 17 00:00:00 2001 From: ialarmedalien Date: Tue, 18 Aug 2020 10:24:11 -0700 Subject: [PATCH 555/732] Update readme with details of spec endpoints --- relation_engine_server/README.md | 202 ++++++++++++++++++++++--------- 1 file changed, 147 insertions(+), 55 deletions(-) diff --git a/relation_engine_server/README.md b/relation_engine_server/README.md index 27a4dba5..7198b7e1 100644 --- a/relation_engine_server/README.md +++ b/relation_engine_server/README.md @@ -173,45 +173,102 @@ If you try to update a collection and it fails validation against a JSON schema * `"value"` - The (possibly nested) value in your data that failed validation * `"path"` - The path into your data where you can find the value that failed validation -### GET /api/v1/data_sources +### PUT /api/v1/specs/ -Fetch a list of data source names. Will return an array of strings. +Manually check and pull spec updates. Requires sysadmin auth. -Example response body: +_Example_ + +``` +curl {root_url}/api/v1/update_specs +``` + +_Query params_ +* `init_collections` - optional - boolean - defaults to true - whether to initialize any new collections in arango (also creates indexes and views) +* `spec_url` - optional - string - the specific url of the release to download and use (as a tarball). If left blank, then the latest release from github is used (not including any pre-releases or drafts). + +Every call to update specs will reset the spec data (do a clean download and overwrite). + +### GET /api/v1/specs/collections + +Get all collection names (returns an array of strings): + +```sh +GET {root_url}/api/v1/specs/collections +``` + +Example response: ```json -{"data_sources": ["x", "y", "z"]} +["test_vertex", "test_edge"] ``` -Response JSON schema: +Get the schema for a specific collection + +```sh +GET "{root_url}/api/v1/specs/collections?name=test_vertex" +``` + +Example response: ```json -{ "type": "object", - "properties": { - "data_sources": { - "type": "array", - "items": { "type": "string" } +{ + "name": "test_vertex", + "type": "vertex", + "schema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "required": ["_key"], + "description": "An example vertex schema for testing", + "properties": { + "_key": {"type": "string"}, + "is_public": {"type": "boolean"}, + "ws_id": {"type": "integer"} } } } ``` -### GET /api/v1/data_sources/{name} +Get the schema for a particular document by its full ID -Fetch the details for a data source by name. Will return an object of key/value details. +```sh +GET "{root_url}/api/v1/specs/collections?doc_id=test_vertex/1" +``` -Example response body: +The response will have the same format as the example response above + +### GET /api/v1/specs/data_sources + +See also `GET /api/v1/data_sources` for a similar API that returns results in a slightly different format. + +Get all data source names (returns an array of strings): + +```sh +GET {root_url}/api/v1/specs/data_sources +``` + +Example response: + +```json +["envo_ontology", "go_ontology", "gtdb"] +``` + +Get the schema for a specific data source + +```sh +GET "{root_url}/api/v1/specs/data_source?name=ncbi_taxonomy" +``` + +Example response: ```json { - "data_source": { - "name": "envo_ontology", - "category": "ontology", - "title": "Environment Ontology", - "home_url": "http://www.obofoundry.org/ontology/envo.html", - "data_url": "https://github.com/EnvironmentOntology/envo/releases", - "logo_url": "https://ci.kbase.us/ui-assets/images/third-party-data-sources/envo/logo-119-64.png" - } + "name": "ncbi_taxonomy", + "category": "taxonomy", + "title": "NCBI Taxonomy", + "home_url": "https://www.ncbi.nlm.nih.gov/taxonomy", + "data_url": "ftp://ftp.ncbi.nlm.nih.gov/pub/taxonomy/", + "logo_url": "https://kbase.us/ui-assets/images/third-party-data-sources/ncbi/logo-51-64.png" } ``` @@ -248,69 +305,104 @@ Response JSON schema: } ``` -### PUT /api/v1/specs/ -Manually check and pull spec updates. Requires sysadmin auth. +### GET /api/v1/specs/stored_queries -_Example_ +Get all stored query names (returns an array of strings): -``` -curl {root_url}/api/v1/update_specs +```sh +GET {root_url}/api/v1/specs/stored_queries ``` -_Query params_ -* `init_collections` - optional - boolean - defaults to true - whether to initialize any new collections in arango (also creates indexes and views) -* `spec_url` - optional - string - the specific url of the release to download and use (as a tarball). If left blank, then the latest release from github is used (not including any pre-releases or drafts). - -Every call to update specs will reset the spec data (do a clean download and overwrite). +Example response: -### GET /api/v1/specs/collections +```json +["fetch_test_vertices", "fetch_test_edges", "ncbi_fetch_taxon"] +``` -Get all collection names (returns an array of strings): +Get the schema for a specific stored query ```sh -GET {root_url}/api/v1/specs/collections +GET "{root_url}/api/v1/specs/stored_query?name=ncbi_fetch_taxon" ``` Example response: ```json -["test_vertex", "test_edge"] +{ + "stored_query": { + "name": "ncbi_fetch_taxon", + "params": { + "type": "object", + "required": [ + "id", + "ts" + ], + "properties": { + "id": { + "type": "string", + "title": "NCBI Taxonomy ID" + }, + "ts": { + "type": "integer", + "title": "Versioning timestamp" + } + } + }, + "query": "for t in ncbi_taxon\n filter t.id == @id\n filter t.created <= @ts AND t.expired >= @ts\n limit 1\n return t\n" + } +} ``` -Get the schema for a specific collection -```sh -GET "{root_url}/api/v1/specs/collections?name=test_vertex" +### GET /api/v1/data_sources + +See also `GET /api/v1/spec/data_sources` for the standard `/specs` API endpoint access to this data. + +Fetch a list of data source names. Will return an array of strings. + +Example response body: + +```json +{"data_sources": ["x", "y", "z"]} ``` +The response is nearly identical to that for `GET /api/v1/specs/data_sources`, but this data is held in an object under the key `data_sources`. -Example response: + +Response JSON schema: ```json -{ - "name": "test_vertex", - "type": "vertex", - "schema": { - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "required": ["_key"], - "description": "An example vertex schema for testing", - "properties": { - "_key": {"type": "string"}, - "is_public": {"type": "boolean"}, - "ws_id": {"type": "integer"} +{ "type": "object", + "properties": { + "data_sources": { + "type": "array", + "items": { "type": "string" } } } } ``` -Get the schema for a particular document by its full ID +### GET /api/v1/data_sources/{name} -```sh -GET "{root_url}/api/v1/specs/collections?doc_id=test_vertex/1" +Fetch the details for a data source by name. Will return an object of key/value details. + +Example response body: + +```json +{ + "data_source": { + "name": "envo_ontology", + "category": "ontology", + "title": "Environment Ontology", + "home_url": "http://www.obofoundry.org/ontology/envo.html", + "data_url": "https://github.com/EnvironmentOntology/envo/releases", + "logo_url": "https://ci.kbase.us/ui-assets/images/third-party-data-sources/envo/logo-119-64.png" + } +} ``` -The response will have the same format as the example response above +Response JSON schema is the same as for `GET /api/v1/specs/data_sources?name=data_source_name`, but the data is held in an object under the key `data_source`. + ## Administration From b7780a002fccbda525e01aed3dbdbf26f00ecbdb Mon Sep 17 00:00:00 2001 From: ialarmedalien Date: Tue, 18 Aug 2020 15:57:42 -0700 Subject: [PATCH 556/732] Reformat clusters to be a single field in the djornl_node collection. Update parser and tests accordingly --- importers/djornl/parser.py | 97 +++- importers/test/test_djornl_parser.py | 47 +- spec/collections/djornl/djornl_node.yaml | 28 +- .../djornl/djornl_fetch_clusters.yaml | 26 +- .../merged_edges-AMW-060820_AF.tsv/empty | 0 spec/test/djornl/results.json | 457 ++++++++++-------- spec/test/stored_queries/test_djornl.py | 118 ++--- 7 files changed, 426 insertions(+), 347 deletions(-) create mode 100644 spec/test/djornl/invalid_file/merged_edges-AMW-060820_AF.tsv/empty diff --git a/importers/djornl/parser.py b/importers/djornl/parser.py index 5f09ea68..771b359a 100644 --- a/importers/djornl/parser.py +++ b/importers/djornl/parser.py @@ -14,11 +14,14 @@ class DJORNL_Parser(object): - def config(self): + def config(self, value): if not hasattr(self, '_config'): - return self._configure() + self._configure() - return self._config + if value not in self._config: + raise KeyError(f'No such config value: {value}') + + return self._config[value] def _configure(self): @@ -43,15 +46,15 @@ def _configure(self): _CLUSTER_BASE = os.path.join(configuration['ROOT_DATA_PATH'], 'cluster_data') configuration['_CLUSTER_PATHS'] = { - 'cluster_I2': os.path.join( + 'markov_i2': os.path.join( _CLUSTER_BASE, 'out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I2_named.tsv' ), - 'cluster_I4': os.path.join( + 'markov_i4': os.path.join( _CLUSTER_BASE, 'out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I4_named.tsv' ), - 'cluster_I6': os.path.join( + 'markov_i6': os.path.join( _CLUSTER_BASE, 'out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I6_named.tsv' ), @@ -74,10 +77,10 @@ def load_edges(self): # dict of nodes, indexed by node ID (node1 and node2 from the file) node_ix = {} edges = [] - node_name = self.config()['_NODE_NAME'] - expected_col_count = self.config()['_EDGE_FILE_COL_COUNT'] + node_name = self.config('_NODE_NAME') + expected_col_count = self.config('_EDGE_FILE_COL_COUNT') - with open(self.config()['_EDGE_PATH']) as fd: + with open(self.config('_EDGE_PATH')) as fd: csv_reader = csv.reader(fd, delimiter='\t') next(csv_reader, None) # skip headers line_no = 1 @@ -102,6 +105,7 @@ def load_edges(self): 'score': float(cols[2]), 'edge_type': edge_remap[edge_type], }) + return { 'nodes': [{'_key': n} for n in node_ix.keys()], 'edges': edges, @@ -111,8 +115,9 @@ def load_node_metadata(self): """Load node metadata""" nodes = [] - expected_col_count = self.config()['_NODE_FILE_COL_COUNT'] - with open(self.config()['_NODE_PATH']) as fd: + valid_node_types = ['gene', 'pheno'] + expected_col_count = self.config('_NODE_FILE_COL_COUNT') + with open(self.config('_NODE_PATH')) as fd: csv_reader = csv.reader(fd, delimiter=',') next(csv_reader, None) # skip headers line_no = 1 @@ -126,7 +131,7 @@ def load_node_metadata(self): _key = cols[0] node_type = cols[1] - if node_type != 'gene' and node_type != 'pheno': + if node_type not in valid_node_types: raise RuntimeError(f"line {line_no}: invalid node type: {node_type}") go_terms = [c.strip() for c in cols[10].split(',')] if len(cols[10]) else [] @@ -154,40 +159,53 @@ def load_node_metadata(self): 'user_notes': cols[19], } nodes.append(doc) + return {'nodes': nodes} def load_cluster_data(self): """Annotate genes with cluster ID fields.""" - nodes = [] - cluster_paths = self.config()['_CLUSTER_PATHS'] + + # index of nodes + node_ix = {} + + cluster_paths = self.config('_CLUSTER_PATHS') for (cluster_label, path) in cluster_paths.items(): with open(path) as fd: csv_reader = csv.reader(fd, delimiter='\t') for row in csv_reader: if len(row) > 1: - # remove the 'Cluster' text - cluster_id = row[0].replace('Cluster', '') - gene_keys = row[1:] - nodes += [ - {'_key': key, cluster_label: int(cluster_id)} - for key in gene_keys - ] + # remove the 'Cluster' text and replace it with cluster_label + cluster_id = cluster_label + ':' + row[0].replace('Cluster', '') + + node_keys = row[1:] + for key in node_keys: + if key not in node_ix: + node_ix[key] = [cluster_id] + elif cluster_id not in node_ix[key]: + node_ix[key].append(cluster_id) + + # gather a list of cluster IDs for each node + nodes = [{ + '_key': key, + 'clusters': cluster_data + } for (key, cluster_data) in node_ix.items()] + return {'nodes': nodes} def save_dataset(self, dataset): if 'nodes' in dataset and len(dataset['nodes']) > 0: - self.save_docs(self.config()['_NODE_NAME'], dataset['nodes']) + self.save_docs(self.config('_NODE_NAME'), dataset['nodes']) if 'edges' in dataset and len(dataset['edges']) > 0: - self.save_docs(self.config()['_EDGE_NAME'], dataset['edges']) + self.save_docs(self.config('_EDGE_NAME'), dataset['edges']) def save_docs(self, coll_name, docs, on_dupe='update'): resp = requests.put( - self.config()['API_URL'] + '/api/v1/documents', + self.config('API_URL') + '/api/v1/documents', params={'collection': coll_name, 'on_duplicate': on_dupe}, - headers={'Authorization': self.config()['AUTH_TOKEN']}, + headers={'Authorization': self.config('AUTH_TOKEN')}, data='\n'.join(json.dumps(d) for d in docs) ) if not resp.ok: @@ -202,3 +220,32 @@ def load_data(self): self.save_dataset(self.load_edges()) self.save_dataset(self.load_node_metadata()) self.save_dataset(self.load_cluster_data()) + + def check_data_delta(self): + edge_data = self.load_edges() + node_metadata = self.load_node_metadata() + clusters = self.load_cluster_data() + + self.check_deltas(edge_data=edge_data, node_metadata=node_metadata, cluster_data=clusters) + + def check_deltas(self, edge_data={}, node_metadata={}, cluster_data={}): + + edge_nodes = set([e['_key'] for e in edge_data['nodes']]) + node_metadata_nodes = set([e['_key'] for e in node_metadata['nodes']]) + cluster_nodes = set([e['_key'] for e in cluster_data['nodes']]) + all_nodes = edge_nodes.union(node_metadata_nodes).union(cluster_nodes) + + # check all nodes in cluster_data have node_metadata + clstr_no_node_md_set = cluster_nodes.difference(node_metadata_nodes) + if clstr_no_node_md_set: + print({'clusters with no node metadata': clstr_no_node_md_set}) + + # check all nodes in the edge_data have node_metadata + edge_no_node_md_set = edge_nodes.difference(node_metadata_nodes) + if edge_no_node_md_set: + print({'edges with no node metadata': edge_no_node_md_set}) + + # count all edges + print("Dataset contains " + str(len(edge_data['edges'])) + " edges") + # count all nodes + print("Dataset contains " + str(len(all_nodes)) + " nodes") diff --git a/importers/test/test_djornl_parser.py b/importers/test/test_djornl_parser.py index 71d43dbc..2ad9184e 100644 --- a/importers/test/test_djornl_parser.py +++ b/importers/test/test_djornl_parser.py @@ -9,7 +9,6 @@ import os from importers.djornl.parser import DJORNL_Parser - from spec.test.helpers import modified_environ _TEST_DIR = '/app/spec/test' @@ -24,14 +23,29 @@ def setUpClass(cls): with open(results_file) as fh: cls.json_data = json.load(fh) + cls.maxDiff = None + def init_parser_with_path(self, root_path): with modified_environ(RES_ROOT_DATA_PATH=root_path): parser = DJORNL_Parser() # ensure that the configuration has been set - parser.config() + parser._configure() return parser + def test_load_invalid_file(self): + """ test loading when what is supposed to be a file is actually a directory """ + + RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, 'djornl', 'invalid_file') + + # edges: directory, not a file + edges_file_path = os.path.join(RES_ROOT_DATA_PATH, "merged_edges-AMW-060820_AF.tsv") + err_str = f"Is a directory: '{edges_file_path}'" + parser = self.init_parser_with_path(RES_ROOT_DATA_PATH) + + with self.assertRaisesRegex(IsADirectoryError, err_str): + parser.load_edges() + def test_load_empty_files(self): """ test loading files containing no data """ @@ -100,33 +114,38 @@ def test_load_valid_edge_data(self): RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, 'djornl', 'test_data') parser = self.init_parser_with_path(RES_ROOT_DATA_PATH) - self.maxDiff = None - edge_data = parser.load_edges() - self.assertEqual( - edge_data, - self.json_data["load_edges"] - ) + expected = self.json_data["load_edges"] + + for data_structure in [edge_data, expected]: + for k in data_structure.keys(): + data_structure[k] = sorted(data_structure[k], key=lambda n: n['_key']) + + self.assertEqual(edge_data, expected) def test_load_valid_node_metadata(self): - self.maxDiff = None RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, 'djornl', 'test_data') parser = self.init_parser_with_path(RES_ROOT_DATA_PATH) node_metadata = parser.load_node_metadata() - self.assertEqual( - node_metadata, - self.json_data["load_node_metadata"] - ) + expected = self.json_data["load_node_metadata"] + + for data_structure in [node_metadata, expected]: + for k in data_structure.keys(): + data_structure[k] = sorted(data_structure[k], key=lambda n: n['_key']) + data_structure[k] = [n['_key'] for n in data_structure[k]] + + self.assertEqual(node_metadata, expected) def test_load_valid_cluster_data(self): RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, 'djornl', 'test_data') parser = self.init_parser_with_path(RES_ROOT_DATA_PATH) - cluster_data = parser.load_cluster_data() self.assertEqual( cluster_data, self.json_data["load_cluster_data"] ) + + parser.check_data_delta() diff --git a/spec/collections/djornl/djornl_node.yaml b/spec/collections/djornl/djornl_node.yaml index 9248f1c1..13b14541 100644 --- a/spec/collections/djornl/djornl_node.yaml +++ b/spec/collections/djornl/djornl_node.yaml @@ -2,6 +2,10 @@ name: djornl_node type: vertex delta: false +indexes: + - type: hash + fields: ["clusters[*]"] + schema: "$schema": http://json-schema.org/draft-07/schema# title: Gene and Phenotype Vertices @@ -13,21 +17,15 @@ schema: type: string title: Key examples: ["AT1G01010"] - cluster_I2: - type: integer - title: Cluster 2 ID - description: Iterative random forest cluster group ID - examples: [1] - cluster_I4: - type: integer - title: Cluster 4 ID - description: Iterative random forest cluster group ID - examples: [13] - cluster_I6: - type: integer - title: Cluster 6 ID - description: Iterative random forest cluster group ID - examples: [27] + clusters: + type: array + title: Clusters + description: Clusters to which the node has been assigned + items: + type: string + format: regex + pattern: ^\w+:\d+$ + examples: [["markov_i2:1", "markov_i4:5"], ["markov_i6:3"]] node_type: type: string title: Node type diff --git a/spec/stored_queries/djornl/djornl_fetch_clusters.yaml b/spec/stored_queries/djornl/djornl_fetch_clusters.yaml index 4c6b8c50..1fadca36 100644 --- a/spec/stored_queries/djornl/djornl_fetch_clusters.yaml +++ b/spec/stored_queries/djornl/djornl_fetch_clusters.yaml @@ -2,25 +2,13 @@ name: djornl_fetch_clusters description: Fetch all nodes that are members of the specified cluster(s), and the edges and nodes within the specified distance (number of hops) of those nodes. params: type: object + required: [cluster_ids] properties: - cluster_i2_ids: - title: Cluster I2 IDs - description: Cluster I2 IDs to locate - items: {type: integer} - default: [] - examples: [[1], [3, 5]] - cluster_i4_ids: - title: Cluster I4 IDs - description: Cluster I4 IDs to locate - items: {type: integer} - examples: [[2], [4, 6]] - default: [] - cluster_i6_ids: - title: Cluster I6 IDs - description: Cluster I6 IDs to locate - items: {type: integer} - examples: [[666], [999, 333]] - default: [] + cluster_ids: + title: Cluster IDs + description: Cluster IDs, in the form "clustering_system_name:cluster_id" + items: {type: string} + examples: [['markov_i2:5', 'markov_i6:2'],['markov_i6:1']] distance: type: integer title: Traversal Distance @@ -31,7 +19,7 @@ params: query: | LET node_ids = ( FOR n IN djornl_node - FILTER n.cluster_I2 IN @cluster_i2_ids OR n.cluster_I4 IN @cluster_i4_ids OR n.cluster_I6 IN @cluster_i6_ids + FILTER n.clusters ANY IN @cluster_ids FOR node IN 0..@distance ANY n djornl_edge OPTIONS {bfs: true, uniqueVertices: "global"} RETURN DISTINCT node._id diff --git a/spec/test/djornl/invalid_file/merged_edges-AMW-060820_AF.tsv/empty b/spec/test/djornl/invalid_file/merged_edges-AMW-060820_AF.tsv/empty new file mode 100644 index 00000000..e69de29b diff --git a/spec/test/djornl/results.json b/spec/test/djornl/results.json index a844c2c2..7fd3a4d5 100644 --- a/spec/test/djornl/results.json +++ b/spec/test/djornl/results.json @@ -27,21 +27,15 @@ }, "load_cluster_data": { "nodes": [ - {"_key": "AT1G01010", "cluster_I2": 1}, - {"_key": "AT1G01030", "cluster_I2": 1}, - {"_key": "AT1G01040", "cluster_I2": 1}, - {"_key": "AT1G01050", "cluster_I2": 2}, - {"_key": "AT1G01060", "cluster_I2": 2}, - {"_key": "AT1G01070", "cluster_I2": 2}, - {"_key": "AT1G01080", "cluster_I2": 3}, - {"_key": "AT1G01090", "cluster_I2": 3}, - {"_key": "AT1G01020", "cluster_I2": 5}, - {"_key": "AT1G01040", "cluster_I6": 1}, - {"_key": "AT1G01090", "cluster_I6": 1}, - {"_key": "AT1G01070", "cluster_I6": 2}, - {"_key": "AT1G01010", "cluster_I6": 3}, - {"_key": "AT1G01020", "cluster_I6": 3}, - {"_key": "AT1G01030", "cluster_I6": 3} + {"_key": "AT1G01010", "clusters": ["markov_i2:1", "markov_i6:3"]}, + {"_key": "AT1G01030", "clusters": ["markov_i2:1", "markov_i6:3"]}, + {"_key": "AT1G01040", "clusters": ["markov_i2:1", "markov_i6:1"]}, + {"_key": "AT1G01050", "clusters": ["markov_i2:2"]}, + {"_key": "AT1G01060", "clusters": ["markov_i2:2"]}, + {"_key": "AT1G01070", "clusters": ["markov_i2:2", "markov_i6:2"]}, + {"_key": "AT1G01080", "clusters": ["markov_i2:3"]}, + {"_key": "AT1G01090", "clusters": ["markov_i2:3", "markov_i6:1"]}, + {"_key": "AT1G01020", "clusters": ["markov_i2:5", "markov_i6:3"]} ] }, "load_node_metadata": { @@ -93,220 +87,265 @@ ] }, "fetch_genes": { - "AT1G01010": { - "0": { - "nodes": ["AT1G01010"], - "edges": [] + "keys": { + "Mary Poppins": { + "distance": { + "0": {"nodes": [], "edges": []}, + "1": {"nodes": [], "edges": []}, + "5": {"nodes": [], "edges": []} + } }, - "1": { - "nodes": [ - "AT1G01010", - "AT1G01020", - "AT1G01030", - "AT1G01040" - ], - "edges": [ - "AT1G01010__AT1G01020__ppi_hithru__2.3", - "AT1G01010__AT1G01030__ppi_hithru__2.4", - "AT1G01010__AT1G01040__domain_co_occur__2.5", - "AT1G01010__AT1G01040__ppi_liter__170.5" - ] + "AT1G01010": { + "distance": { + "0": { + "nodes": ["AT1G01010"], + "edges": [] + }, + "1": { + "nodes": [ + "AT1G01010", + "AT1G01020", + "AT1G01030", + "AT1G01040" + ], + "edges": [ + "AT1G01010__AT1G01020__ppi_hithru__2.3", + "AT1G01010__AT1G01030__ppi_hithru__2.4", + "AT1G01010__AT1G01040__domain_co_occur__2.5", + "AT1G01010__AT1G01040__ppi_liter__170.5" + ] + }, + "5": { + "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060"], + "edges": [ + "As2__AT1G01020__pheno_assn__8.4", + "As2__AT1G01040__pheno_assn__5.4", + "As75__AT1G01020__pheno_assn__39.9", + "AT1G01010__AT1G01020__ppi_hithru__2.3", + "AT1G01010__AT1G01030__ppi_hithru__2.4", + "AT1G01010__AT1G01040__domain_co_occur__2.5", + "AT1G01010__AT1G01040__ppi_liter__170.5", + "AT1G01030__AT1G01050__gene_coexpr__2.6", + "AT1G01050__AT1G01060__ppi_liter__2.7" + ] + } + } }, - "5": { - "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060"], - "edges": [ - "As2__AT1G01020__pheno_assn__8.4", - "As2__AT1G01040__pheno_assn__5.4", - "As75__AT1G01020__pheno_assn__39.9", - "AT1G01010__AT1G01020__ppi_hithru__2.3", - "AT1G01010__AT1G01030__ppi_hithru__2.4", - "AT1G01010__AT1G01040__domain_co_occur__2.5", - "AT1G01010__AT1G01040__ppi_liter__170.5", - "AT1G01030__AT1G01050__gene_coexpr__2.6", - "AT1G01050__AT1G01060__ppi_liter__2.7" - ] - } - }, - "AT1G01020__AT1G01070": { - "0": { - "nodes": ["AT1G01020", "AT1G01070"], - "edges": [] - }, - "1": { - "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01070"], - "edges": [ - "As2__AT1G01020__pheno_assn__8.4", - "As75__AT1G01020__pheno_assn__39.9", - "AT1G01010__AT1G01020__ppi_hithru__2.3" - ] - }, - "5": { - "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060", "AT1G01070"], - "edges": [ - "As2__AT1G01020__pheno_assn__8.4", - "As2__AT1G01040__pheno_assn__5.4", - "As75__AT1G01020__pheno_assn__39.9", - "AT1G01010__AT1G01020__ppi_hithru__2.3", - "AT1G01010__AT1G01030__ppi_hithru__2.4", - "AT1G01010__AT1G01040__domain_co_occur__2.5", - "AT1G01010__AT1G01040__ppi_liter__170.5", - "AT1G01030__AT1G01050__gene_coexpr__2.6", - "AT1G01050__AT1G01060__ppi_liter__2.7" - ] + "AT1G01020__AT1G01070": { + "distance": { + "0": { + "nodes": ["AT1G01020", "AT1G01070"], + "edges": [] + }, + "1": { + "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01070"], + "edges": [ + "As2__AT1G01020__pheno_assn__8.4", + "As75__AT1G01020__pheno_assn__39.9", + "AT1G01010__AT1G01020__ppi_hithru__2.3" + ] + }, + "5": { + "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060", "AT1G01070"], + "edges": [ + "As2__AT1G01020__pheno_assn__8.4", + "As2__AT1G01040__pheno_assn__5.4", + "As75__AT1G01020__pheno_assn__39.9", + "AT1G01010__AT1G01020__ppi_hithru__2.3", + "AT1G01010__AT1G01030__ppi_hithru__2.4", + "AT1G01010__AT1G01040__domain_co_occur__2.5", + "AT1G01010__AT1G01040__ppi_liter__170.5", + "AT1G01030__AT1G01050__gene_coexpr__2.6", + "AT1G01050__AT1G01060__ppi_liter__2.7" + ] + } + } } } }, "fetch_phenotypes": { - "As2": { - "0": { - "nodes": ["As2"], - "edges": [] - }, - "1": { - "nodes": ["As2", "AT1G01020", "AT1G01040"], - "edges": [ - "As2__AT1G01020__pheno_assn__8.4", - "As2__AT1G01040__pheno_assn__5.4" - ] - }, - "5": { - "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060"], - "edges": [ - "As2__AT1G01020__pheno_assn__8.4", - "As2__AT1G01040__pheno_assn__5.4", - "As75__AT1G01020__pheno_assn__39.9", - "AT1G01010__AT1G01020__ppi_hithru__2.3", - "AT1G01010__AT1G01030__ppi_hithru__2.4", - "AT1G01010__AT1G01040__domain_co_occur__2.5", - "AT1G01010__AT1G01040__ppi_liter__170.5", - "AT1G01030__AT1G01050__gene_coexpr__2.6", - "AT1G01050__AT1G01060__ppi_liter__2.7" - ] - } - }, - "As2__Na23": { - "0": { - "nodes": ["As2", "Na23"], - "edges": [] + "keys": { + "Mary Poppins": { + "distance": { + "0": {"nodes": [], "edges": []}, + "1": {"nodes": [], "edges": []}, + "5": {"nodes": [], "edges": []} + } }, - "1": { - "nodes": ["As2", "Na23", "AT1G01020", "AT1G01040"], - "edges": [ - "As2__AT1G01020__pheno_assn__8.4", - "As2__AT1G01040__pheno_assn__5.4" - ] + "As2": { + "distance": { + "0": { + "nodes": ["As2"], + "edges": [] + }, + "1": { + "nodes": ["As2", "AT1G01020", "AT1G01040"], + "edges": [ + "As2__AT1G01020__pheno_assn__8.4", + "As2__AT1G01040__pheno_assn__5.4" + ] + }, + "5": { + "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060"], + "edges": [ + "As2__AT1G01020__pheno_assn__8.4", + "As2__AT1G01040__pheno_assn__5.4", + "As75__AT1G01020__pheno_assn__39.9", + "AT1G01010__AT1G01020__ppi_hithru__2.3", + "AT1G01010__AT1G01030__ppi_hithru__2.4", + "AT1G01010__AT1G01040__domain_co_occur__2.5", + "AT1G01010__AT1G01040__ppi_liter__170.5", + "AT1G01030__AT1G01050__gene_coexpr__2.6", + "AT1G01050__AT1G01060__ppi_liter__2.7" + ] + } + } }, - "5": { - "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060", "Na23"], - "edges": [ - "As2__AT1G01020__pheno_assn__8.4", - "As2__AT1G01040__pheno_assn__5.4", - "As75__AT1G01020__pheno_assn__39.9", - "AT1G01010__AT1G01020__ppi_hithru__2.3", - "AT1G01010__AT1G01030__ppi_hithru__2.4", - "AT1G01010__AT1G01040__domain_co_occur__2.5", - "AT1G01010__AT1G01040__ppi_liter__170.5", - "AT1G01030__AT1G01050__gene_coexpr__2.6", - "AT1G01050__AT1G01060__ppi_liter__2.7" - ] + "As2__Na23": { + "distance": { + "0": { + "nodes": ["As2", "Na23"], + "edges": [] + }, + "1": { + "nodes": ["As2", "Na23", "AT1G01020", "AT1G01040"], + "edges": [ + "As2__AT1G01020__pheno_assn__8.4", + "As2__AT1G01040__pheno_assn__5.4" + ] + }, + "5": { + "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060", "Na23"], + "edges": [ + "As2__AT1G01020__pheno_assn__8.4", + "As2__AT1G01040__pheno_assn__5.4", + "As75__AT1G01020__pheno_assn__39.9", + "AT1G01010__AT1G01020__ppi_hithru__2.3", + "AT1G01010__AT1G01030__ppi_hithru__2.4", + "AT1G01010__AT1G01040__domain_co_occur__2.5", + "AT1G01010__AT1G01040__ppi_liter__170.5", + "AT1G01030__AT1G01050__gene_coexpr__2.6", + "AT1G01050__AT1G01060__ppi_liter__2.7" + ] + } + } } } }, "search_nodes": { - "Mary Poppins": { - "0": {"nodes": [], "edges": []}, - "1": {"nodes": [], "edges": []}, - "5": {"nodes": [], "edges": []} - }, - "GO:0005515": { - "0": { - "nodes": ["AT1G01040", "AT1G01090"], - "edges": [] - }, - "1": { - "nodes": ["As2", "AT1G01010", "AT1G01040", "AT1G01080", "AT1G01090"], - "edges": [ - "As2__AT1G01040__pheno_assn__5.4", - "AT1G01010__AT1G01040__domain_co_occur__2.5", - "AT1G01010__AT1G01040__ppi_liter__170.5", - "AT1G01080__AT1G01090__ppi_liter__2.8" - ] + "search_text": { + "Mary Poppins": { + "distance": { + "0": {"nodes": [], "edges": []}, + "1": {"nodes": [], "edges": []}, + "5": {"nodes": [], "edges": []} + } }, - "5": { - "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060", "AT1G01080", "AT1G01090"], - "edges": [ - "As2__AT1G01020__pheno_assn__8.4", - "As2__AT1G01040__pheno_assn__5.4", - "As75__AT1G01020__pheno_assn__39.9", - "AT1G01010__AT1G01020__ppi_hithru__2.3", - "AT1G01010__AT1G01030__ppi_hithru__2.4", - "AT1G01010__AT1G01040__domain_co_occur__2.5", - "AT1G01010__AT1G01040__ppi_liter__170.5", - "AT1G01030__AT1G01050__gene_coexpr__2.6", - "AT1G01050__AT1G01060__ppi_liter__2.7", - "AT1G01080__AT1G01090__ppi_liter__2.8" - ] + "GO:0005515": { + "distance": { + "0": { + "nodes": ["AT1G01040", "AT1G01090"], + "edges": [] + }, + "1": { + "nodes": ["As2", "AT1G01010", "AT1G01040", "AT1G01080", "AT1G01090"], + "edges": [ + "As2__AT1G01040__pheno_assn__5.4", + "AT1G01010__AT1G01040__domain_co_occur__2.5", + "AT1G01010__AT1G01040__ppi_liter__170.5", + "AT1G01080__AT1G01090__ppi_liter__2.8" + ] + }, + "5": { + "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060", "AT1G01080", "AT1G01090"], + "edges": [ + "As2__AT1G01020__pheno_assn__8.4", + "As2__AT1G01040__pheno_assn__5.4", + "As75__AT1G01020__pheno_assn__39.9", + "AT1G01010__AT1G01020__ppi_hithru__2.3", + "AT1G01010__AT1G01030__ppi_hithru__2.4", + "AT1G01010__AT1G01040__domain_co_occur__2.5", + "AT1G01010__AT1G01040__ppi_liter__170.5", + "AT1G01030__AT1G01050__gene_coexpr__2.6", + "AT1G01050__AT1G01060__ppi_liter__2.7", + "AT1G01080__AT1G01090__ppi_liter__2.8" + ] + } + } } } }, "fetch_clusters": { - "i6-1": { - "0": { - "nodes": ["AT1G01040", "AT1G01090"], - "edges": [] - }, - "1": { - "nodes": ["As2", "AT1G01010", "AT1G01040", "AT1G01080", "AT1G01090"], - "edges": [ - "As2__AT1G01040__pheno_assn__5.4", - "AT1G01010__AT1G01040__domain_co_occur__2.5", - "AT1G01010__AT1G01040__ppi_liter__170.5", - "AT1G01080__AT1G01090__ppi_liter__2.8" - ] - }, - "5": { - "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060", "AT1G01080", "AT1G01090"], - "edges": [ - "As2__AT1G01020__pheno_assn__8.4", - "As2__AT1G01040__pheno_assn__5.4", - "As75__AT1G01020__pheno_assn__39.9", - "AT1G01010__AT1G01020__ppi_hithru__2.3", - "AT1G01010__AT1G01030__ppi_hithru__2.4", - "AT1G01010__AT1G01040__domain_co_occur__2.5", - "AT1G01010__AT1G01040__ppi_liter__170.5", - "AT1G01030__AT1G01050__gene_coexpr__2.6", - "AT1G01050__AT1G01060__ppi_liter__2.7", - "AT1G01080__AT1G01090__ppi_liter__2.8" - ] - } - }, - "i2-5__i6-2": { - "0": { - "nodes": ["AT1G01020", "AT1G01070"], - "edges": [] + "cluster_ids": { + "Mary Poppins": { + "distance": { + "0": {"nodes": [], "edges": []}, + "1": {"nodes": [], "edges": []}, + "5": {"nodes": [], "edges": []} + } }, - "1": { - "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01070"], - "edges": [ - "As2__AT1G01020__pheno_assn__8.4", - "As75__AT1G01020__pheno_assn__39.9", - "AT1G01010__AT1G01020__ppi_hithru__2.3" - ] + "markov_i6:1": { + "distance": { + "0": { + "nodes": ["AT1G01040", "AT1G01090"], + "edges": [] + }, + "1": { + "nodes": ["As2", "AT1G01010", "AT1G01040", "AT1G01080", "AT1G01090"], + "edges": [ + "As2__AT1G01040__pheno_assn__5.4", + "AT1G01010__AT1G01040__domain_co_occur__2.5", + "AT1G01010__AT1G01040__ppi_liter__170.5", + "AT1G01080__AT1G01090__ppi_liter__2.8" + ] + }, + "5": { + "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060", "AT1G01080", "AT1G01090"], + "edges": [ + "As2__AT1G01020__pheno_assn__8.4", + "As2__AT1G01040__pheno_assn__5.4", + "As75__AT1G01020__pheno_assn__39.9", + "AT1G01010__AT1G01020__ppi_hithru__2.3", + "AT1G01010__AT1G01030__ppi_hithru__2.4", + "AT1G01010__AT1G01040__domain_co_occur__2.5", + "AT1G01010__AT1G01040__ppi_liter__170.5", + "AT1G01030__AT1G01050__gene_coexpr__2.6", + "AT1G01050__AT1G01060__ppi_liter__2.7", + "AT1G01080__AT1G01090__ppi_liter__2.8" + ] + } + } }, - "5": { - "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060", "AT1G01070"], - "edges": [ - "As2__AT1G01020__pheno_assn__8.4", - "As2__AT1G01040__pheno_assn__5.4", - "As75__AT1G01020__pheno_assn__39.9", - "AT1G01010__AT1G01020__ppi_hithru__2.3", - "AT1G01010__AT1G01030__ppi_hithru__2.4", - "AT1G01010__AT1G01040__domain_co_occur__2.5", - "AT1G01010__AT1G01040__ppi_liter__170.5", - "AT1G01030__AT1G01050__gene_coexpr__2.6", - "AT1G01050__AT1G01060__ppi_liter__2.7" - ] + "markov_i2:5__markov_i6:2": { + "distance": { + "0": { + "nodes": ["AT1G01020", "AT1G01070"], + "edges": [] + }, + "1": { + "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01070"], + "edges": [ + "As2__AT1G01020__pheno_assn__8.4", + "As75__AT1G01020__pheno_assn__39.9", + "AT1G01010__AT1G01020__ppi_hithru__2.3" + ] + }, + "5": { + "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060", "AT1G01070"], + "edges": [ + "As2__AT1G01020__pheno_assn__8.4", + "As2__AT1G01040__pheno_assn__5.4", + "As75__AT1G01020__pheno_assn__39.9", + "AT1G01010__AT1G01020__ppi_hithru__2.3", + "AT1G01010__AT1G01030__ppi_hithru__2.4", + "AT1G01010__AT1G01040__domain_co_occur__2.5", + "AT1G01010__AT1G01040__ppi_liter__170.5", + "AT1G01030__AT1G01050__gene_coexpr__2.6", + "AT1G01050__AT1G01060__ppi_liter__2.7" + ] + } + } } } } diff --git a/spec/test/stored_queries/test_djornl.py b/spec/test/stored_queries/test_djornl.py index 98250993..8e492fbe 100644 --- a/spec/test/stored_queries/test_djornl.py +++ b/spec/test/stored_queries/test_djornl.py @@ -34,26 +34,28 @@ def setUpClass(cls): cls.json_data = json.load(fh) cls.no_results = {'nodes': [], 'edges': []} + cls.maxDiff = None # load the DB root_path = os.path.join(_TEST_DIR, 'djornl', 'test_data') with modified_environ(RES_ROOT_DATA_PATH=root_path): parser = DJORNL_Parser() - config = parser.config() + node_name = parser.config('_NODE_NAME') + edge_name = parser.config('_EDGE_NAME') edge_data = parser.load_edges() - r = create_test_docs(config['_NODE_NAME'], edge_data['nodes']) - print_db_update(r, config['_NODE_NAME']) - r = create_test_docs(config['_EDGE_NAME'], edge_data['edges']) - print_db_update(r, config['_EDGE_NAME']) + r = create_test_docs(node_name, edge_data['nodes']) + print_db_update(r, node_name) + r = create_test_docs(edge_name, edge_data['edges']) + print_db_update(r, edge_name) node_metadata = parser.load_node_metadata() - r = create_test_docs(config['_NODE_NAME'], node_metadata['nodes'], True) - print_db_update(r, config['_NODE_NAME']) + r = create_test_docs(node_name, node_metadata['nodes'], True) + print_db_update(r, node_name) cluster_data = parser.load_cluster_data() - r = create_test_docs(config['_NODE_NAME'], cluster_data['nodes'], True) - print_db_update(r, config['_NODE_NAME']) + r = create_test_docs(node_name, cluster_data['nodes'], True) + print_db_update(r, node_name) def submit_query(self, query_name, query_data={}): """submit a database query""" @@ -68,6 +70,7 @@ def check_expected_results(self, description, response, expected): if _VERBOSE: print("Running test " + description) + results = response['results'][0] self.assertEqual( set([n["_key"] for n in results['nodes']]), @@ -81,31 +84,45 @@ def check_expected_results(self, description, response, expected): def test_fetch_all(self): + response = self.submit_query('djornl_fetch_all') self.check_expected_results( "djornl_fetch_all", - self.submit_query('djornl_fetch_all'), + response, self.json_data['fetch_all'] ) + # ensure that all the cluster data is returned OK + node_data = response['results'][0]['nodes'] + expected_node_data = self.json_data['load_cluster_data']['nodes'] + self.assertEqual( + {n['_key']: n['clusters'] for n in node_data if 'clusters' in n}, + {n['_key']: n['clusters'] for n in expected_node_data if 'clusters' in n}, + ) + # indexing schema in results.json - # self.json_data[query][primary_param][distance_param] - # if primary_param is an array, join the array entities with "__" + # self.json_data[query_name][param_name][param_value]["distance"][distance_param] + # e.g. for fetch_clusters data: + # "fetch_clusters": { + # "cluster_ids": { + # "markov_i2:6__markov_i4:3": { + # "distance": { + # 1: { + # "nodes": [ node IDs ], + # "edges": [ edge data ], + # } + # } + # } + # } + # } + # if param_value is an array, join the array entities with "__" # results are in the form {"nodes": [...], "edges": [...]} # nodes are represented as a list of node[_key] # edges are objects with keys _to, _from, edge_type and score - def test_fetch_phenotypes_no_results(self): - - resp = self.submit_query('djornl_fetch_phenotypes', { - # gene node - "keys": ["AT1G01010"], - }) - self.assertEqual(resp['results'][0], self.no_results) - def test_fetch_phenotypes(self): - for fetch_args in self.json_data['fetch_phenotypes'].keys(): - for distance in self.json_data['fetch_phenotypes'][fetch_args].keys(): + for (fetch_args, key_data) in self.json_data['fetch_phenotypes']['keys'].items(): + for (distance, distance_data) in key_data['distance'].items(): resp = self.submit_query('djornl_fetch_phenotypes', { "keys": fetch_args.split('__'), "distance": int(distance), @@ -113,20 +130,13 @@ def test_fetch_phenotypes(self): self.check_expected_results( "fetch phenotypes with args " + fetch_args + " and distance " + distance, resp, - self.json_data['fetch_phenotypes'][fetch_args][distance] + distance_data ) - def test_fetch_genes_no_results(self): - resp = self.submit_query('djornl_fetch_genes', { - # phenotype node - "keys": ["As2"], - }) - self.assertEqual(resp['results'][0], self.no_results) - def test_fetch_genes(self): - for fetch_args in self.json_data['fetch_genes'].keys(): - for distance in self.json_data['fetch_genes'][fetch_args].keys(): + for (fetch_args, key_data) in self.json_data['fetch_genes']['keys'].items(): + for (distance, distance_data) in key_data['distance'].items(): resp = self.submit_query('djornl_fetch_genes', { "keys": fetch_args.split('__'), "distance": int(distance), @@ -134,49 +144,27 @@ def test_fetch_genes(self): self.check_expected_results( "fetch genes with args " + fetch_args + " and distance " + distance, resp, - self.json_data['fetch_genes'][fetch_args][distance] + distance_data ) - def test_fetch_clusters_no_results(self): - - resp = self.submit_query('djornl_fetch_clusters', { - 'cluster_i2_ids': [666], - 'cluster_i4_ids': [666], - 'cluster_i6_ids': [666], - }) - self.assertEqual(resp['results'][0], self.no_results) - def test_fetch_clusters(self): - for fetch_args in self.json_data['fetch_clusters'].keys(): - cluster_args = {} - for arg in fetch_args.split('__'): - [c_name, c_id] = arg.split('-', maxsplit=1) - if "cluster_" + c_name + "_ids" in cluster_args: - cluster_args["cluster_" + c_name + "_ids"] += int(c_id) - else: - cluster_args["cluster_" + c_name + "_ids"] = [int(c_id)] - - for distance in self.json_data['fetch_clusters'][fetch_args].keys(): - cluster_args['distance'] = int(distance) - resp = self.submit_query('djornl_fetch_clusters', cluster_args) + for (fetch_args, cluster_data) in self.json_data['fetch_clusters']['cluster_ids'].items(): + for (distance, distance_data) in cluster_data['distance'].items(): + resp = self.submit_query('djornl_fetch_clusters', { + "cluster_ids": fetch_args.split('__'), + "distance": int(distance), + }) self.check_expected_results( "fetch clusters with args " + fetch_args + " and distance " + distance, resp, - self.json_data['fetch_clusters'][fetch_args][distance] + distance_data ) - def test_search_nodes_no_results(self): - - resp = self.submit_query('djornl_search_nodes', { - "search_text": "Mary Poppins", - }) - self.assertEqual(resp['results'][0], self.no_results) - def test_search_nodes(self): - for search_text in self.json_data['search_nodes'].keys(): - for distance in self.json_data['search_nodes'][search_text].keys(): + for (search_text, search_data) in self.json_data['search_nodes']['search_text'].items(): + for (distance, distance_data) in search_data['distance'].items(): resp = self.submit_query('djornl_search_nodes', { "search_text": search_text, "distance": int(distance), @@ -184,5 +172,5 @@ def test_search_nodes(self): self.check_expected_results( "search nodes with args " + search_text + " and distance " + distance, resp, - self.json_data['search_nodes'][search_text][distance] + distance_data ) From a1a26cb79dcb89636e73374e6cdd0dbffdb08048 Mon Sep 17 00:00:00 2001 From: ialarmedalien Date: Fri, 21 Aug 2020 11:29:03 -0700 Subject: [PATCH 557/732] Add GitHub action step to build and upload to dockerhub Add VERSION file Use ialarmedalien dockerhub repo temporarily for testing --- .github/workflows/run_tests.yaml | 33 +++++++++++++++++++++++++++++++- VERSION | 1 + 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 VERSION diff --git a/.github/workflows/run_tests.yaml b/.github/workflows/run_tests.yaml index 4700872f..580ec981 100644 --- a/.github/workflows/run_tests.yaml +++ b/.github/workflows/run_tests.yaml @@ -1,4 +1,4 @@ -name: Run Tests +name: Relation Engine test and deploy on: [push, pull_request] jobs: @@ -16,3 +16,34 @@ jobs: docker-compose build docker-compose run re_api sh scripts/run_tests.sh docker-compose down --remove-orphans + + docker_build_and_push: + runs-on: ubuntu-latest + needs: run_tests + if: (github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/master' || github.ref == 'refs/heads/add_docker_build') && github.event_name == 'push' && !contains(github.event.head_commit.message, 'skip_docker_build') + steps: + - name: checkout git repo + uses: actions/checkout@v2 + + - name: set env vars + shell: bash + run: | + echo ::set-env name=DATE::$(date -u +"%Y-%m-%dT%H:%M:%SZ") + echo ::set-env name=BRANCH::$(git symbolic-ref --short HEAD) + echo ::set-env name=COMMIT::$(git rev-parse --short HEAD) + + - name: copy VERSION to TAG_NAME + shell: bash + run: | + mkdir -p .target + cp VERSION .target/TAG_NAME + + - name: build and push to dockerhub + uses: opspresso/action-docker@master + with: + args: --docker + env: + USERNAME: ${{ secrets.DOCKER_USERNAME }} + PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + DOCKERFILE: "Dockerfile" + IMAGE_NAME: "ialarmedalien/relation_engine_api" diff --git a/VERSION b/VERSION new file mode 100644 index 00000000..1750564f --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +0.0.6 From d041d0e96b48ddaa4cbc968eece695c51c91f9c9 Mon Sep 17 00:00:00 2001 From: ialarmedalien Date: Tue, 25 Aug 2020 09:46:52 -0700 Subject: [PATCH 558/732] Add README details about automated builds. Remove personal docker repo and branch-specific build info --- .github/workflows/run_tests.yaml | 16 ++++++++-------- README.md | 4 ++++ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/.github/workflows/run_tests.yaml b/.github/workflows/run_tests.yaml index 580ec981..40d2dd71 100644 --- a/.github/workflows/run_tests.yaml +++ b/.github/workflows/run_tests.yaml @@ -20,11 +20,17 @@ jobs: docker_build_and_push: runs-on: ubuntu-latest needs: run_tests - if: (github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/master' || github.ref == 'refs/heads/add_docker_build') && github.event_name == 'push' && !contains(github.event.head_commit.message, 'skip_docker_build') + if: (github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/master') && github.event_name == 'push' && !contains(github.event.head_commit.message, 'skip_docker_build') steps: - name: checkout git repo uses: actions/checkout@v2 + - name: copy VERSION to TAG_NAME + shell: bash + run: | + mkdir -p .target + cp VERSION .target/TAG_NAME + - name: set env vars shell: bash run: | @@ -32,12 +38,6 @@ jobs: echo ::set-env name=BRANCH::$(git symbolic-ref --short HEAD) echo ::set-env name=COMMIT::$(git rev-parse --short HEAD) - - name: copy VERSION to TAG_NAME - shell: bash - run: | - mkdir -p .target - cp VERSION .target/TAG_NAME - - name: build and push to dockerhub uses: opspresso/action-docker@master with: @@ -46,4 +46,4 @@ jobs: USERNAME: ${{ secrets.DOCKER_USERNAME }} PASSWORD: ${{ secrets.DOCKER_PASSWORD }} DOCKERFILE: "Dockerfile" - IMAGE_NAME: "ialarmedalien/relation_engine_api" + IMAGE_NAME: "kbase/relation_engine_api" diff --git a/README.md b/README.md index 6fe50a93..d84a4e49 100644 --- a/README.md +++ b/README.md @@ -13,3 +13,7 @@ These specifications are used by the [Relation Engine API](relation_engine_serve ### `relation_engine_server/` The relation engine server (`relation_engine_server/`) is a simple API that allows KBase community developers to interact with the Relation Engine graph database. You can run stored queries or do bulk updates on documents. + +## Relation Engine builds + +The Relation Engine is available on dockerhub as `kbase/relation_engine_api`. Automated builds are performed whenever there is a new push to `master` or `develop`. From 6b911a420dd6f420bba27fd4692c515dc513d2a6 Mon Sep 17 00:00:00 2001 From: ialarmedalien Date: Wed, 26 Aug 2020 09:50:19 -0700 Subject: [PATCH 559/732] Removing hooks folder and consolidating local build script into scripts/local-build.sh --- hooks/build | 19 ------------------- scripts/local-build.sh | 16 ++++++++++++++-- 2 files changed, 14 insertions(+), 21 deletions(-) delete mode 100755 hooks/build diff --git a/hooks/build b/hooks/build deleted file mode 100755 index 730be97d..00000000 --- a/hooks/build +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -# See the docs for automated docker builds: https://docs.docker.com/docker-cloud/builds/advanced/ - -# $IMAGE_NAME var is injected into the build so the tag is correct. - -if [ -z "$IMAGE_NAME" ]; then - export IMAGE_NAME="kbase/relation_engine_api:latest" -fi - -echo "Build hook running" -export BRANCH=${TRAVIS_BRANCH:-`git symbolic-ref --short HEAD`} -export DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` -export COMMIT=${TRAVIS_COMMIT:-`git rev-parse --short HEAD`} -docker build --file Dockerfile-api - --build-arg BUILD_DATE=$DATE \ - --build-arg VCS_REF=$COMMIT \ - --build-arg BRANCH=$BRANCH \ - -t ${IMAGE_NAME} . diff --git a/scripts/local-build.sh b/scripts/local-build.sh index a9182d61..3948b73c 100644 --- a/scripts/local-build.sh +++ b/scripts/local-build.sh @@ -2,6 +2,18 @@ set -e # show the commands we execute set -o xtrace -export IMAGE_NAME="kbase/relation_engine_api:local_build" -sh hooks/build + +# $IMAGE_NAME var is injected into the build so the tag is correct. +if [ -z "$IMAGE_NAME" ]; then + export IMAGE_NAME="kbase/relation_engine_api:latest" +fi + +export BRANCH=`git symbolic-ref --short HEAD` +export DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` +export COMMIT=`git rev-parse --short HEAD` +docker build --file Dockerfile + --build-arg BUILD_DATE=$DATE \ + --build-arg VCS_REF=$COMMIT \ + --build-arg BRANCH=$BRANCH \ + -t ${IMAGE_NAME} . docker push $IMAGE_NAME From 855152d8b8a805fba9610e6c637ff653ff7346a3 Mon Sep 17 00:00:00 2001 From: ialarmedalien Date: Thu, 20 Aug 2020 10:27:22 -0700 Subject: [PATCH 560/732] - use manifest file to specify files to be included in release - update DJORNL parser to apply manifest file - add tests for manifest file validation - small refactor of parser to apply the same QC to every file - small formatting updates to DJORNL source files --- CHANGELOG.md | 23 ++ importers/djornl/parser.py | 357 ++++++++++++------ importers/test/test_djornl_parser.py | 46 +-- spec/README.md | 1 + spec/collections/djornl/djornl_edge.yaml | 5 + spec/collections/djornl/djornl_node.yaml | 18 +- spec/datasets/djornl/manifest.schema.json | 102 +++++ .../djornl/djornl_fetch_clusters.yaml | 1 + .../djornl/djornl_search_nodes.yaml | 16 +- ...aragwas-MERGED-AMW-v2_091319_nodeTable.csv | 2 +- .../djornl/col_count_errors/manifest.yaml | 8 + spec/test/djornl/empty_files/manifest.yaml | 20 + spec/test/djornl/invalid_file/edges.tsv/empty | 0 spec/test/djornl/invalid_file/manifest.yaml | 12 + .../invalid_manifest/cluster_no_prefix.yaml | 18 + .../invalid_manifest/date_not_in_quotes.yaml | 17 + .../invalid_manifest/invalid_format.yaml | 17 + .../djornl/invalid_manifest/manifest.yaml | 14 + .../djornl/invalid_manifest/missing_path.yaml | 21 ++ .../invalid_manifest/no_file_format.yaml | 16 + .../djornl/invalid_manifest/no_file_list.yaml | 3 + ...aragwas-MERGED-AMW-v2_091319_nodeTable.csv | 3 +- spec/test/djornl/invalid_types/manifest.yaml | 8 + .../merged_edges-AMW-060820_AF.tsv | 1 + spec/test/djornl/missing_files/manifest.yaml | 12 + spec/test/djornl/results.json | 28 +- spec/test/djornl/test_data/I2_named.tsv | 9 + spec/test/djornl/test_data/I4_named.tsv | 4 + spec/test/djornl/test_data/I6_named.tsv | 8 + ...p10percent_anno_AF_082919.abc.I2_named.tsv | 5 - ...p10percent_anno_AF_082919.abc.I4_named.tsv | 1 - ...p10percent_anno_AF_082919.abc.I6_named.tsv | 4 - ...rged_edges-AMW-060820_AF.tsv => edges.tsv} | 2 - spec/test/djornl/test_data/extra_node.tsv | 3 + .../test/djornl/test_data/hithruput-edges.csv | 3 + spec/test/djornl/test_data/manifest.yaml | 35 ++ ...-AMW-v2_091319_nodeTable.csv => nodes.csv} | 8 +- spec/test/djornl/test_data/pheno_nodes.csv | 5 + .../djornl/valid_manifest/no_file_ext.yaml | 40 ++ .../djornl/valid_manifest/no_file_format.yaml | 39 ++ .../valid_manifest/with_descriptions.yaml | 39 ++ spec/test/stored_queries/test_djornl.py | 4 +- spec/test/test_manifest_schema.py | 82 ++++ spec/views/djornl/djornl_node_view.json | 14 +- 44 files changed, 877 insertions(+), 197 deletions(-) create mode 100644 CHANGELOG.md create mode 100644 spec/datasets/djornl/manifest.schema.json create mode 100644 spec/test/djornl/col_count_errors/manifest.yaml create mode 100644 spec/test/djornl/empty_files/manifest.yaml create mode 100644 spec/test/djornl/invalid_file/edges.tsv/empty create mode 100644 spec/test/djornl/invalid_file/manifest.yaml create mode 100644 spec/test/djornl/invalid_manifest/cluster_no_prefix.yaml create mode 100644 spec/test/djornl/invalid_manifest/date_not_in_quotes.yaml create mode 100644 spec/test/djornl/invalid_manifest/invalid_format.yaml create mode 100644 spec/test/djornl/invalid_manifest/manifest.yaml create mode 100644 spec/test/djornl/invalid_manifest/missing_path.yaml create mode 100644 spec/test/djornl/invalid_manifest/no_file_format.yaml create mode 100644 spec/test/djornl/invalid_manifest/no_file_list.yaml create mode 100644 spec/test/djornl/invalid_types/manifest.yaml create mode 100644 spec/test/djornl/missing_files/manifest.yaml create mode 100644 spec/test/djornl/test_data/I2_named.tsv create mode 100644 spec/test/djornl/test_data/I4_named.tsv create mode 100644 spec/test/djornl/test_data/I6_named.tsv delete mode 100644 spec/test/djornl/test_data/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I2_named.tsv delete mode 100644 spec/test/djornl/test_data/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I4_named.tsv delete mode 100644 spec/test/djornl/test_data/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I6_named.tsv rename spec/test/djornl/test_data/{merged_edges-AMW-060820_AF.tsv => edges.tsv} (80%) create mode 100644 spec/test/djornl/test_data/extra_node.tsv create mode 100644 spec/test/djornl/test_data/hithruput-edges.csv create mode 100644 spec/test/djornl/test_data/manifest.yaml rename spec/test/djornl/test_data/{aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv => nodes.csv} (72%) create mode 100644 spec/test/djornl/test_data/pheno_nodes.csv create mode 100644 spec/test/djornl/valid_manifest/no_file_ext.yaml create mode 100644 spec/test/djornl/valid_manifest/no_file_format.yaml create mode 100644 spec/test/djornl/valid_manifest/with_descriptions.yaml create mode 100644 spec/test/test_manifest_schema.py diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000..ad4fa3fc --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,23 @@ +## 0.0.6 + +### `relation_engine_server` + +- `relation_engine_server/api_versions/api_v1.py`: add and/or document API endpoints: + - /api/v1/specs/stored_queries + - /api/v1/specs/data_sources + +- `relation_engine_server/utils/spec_loader.py`: refactor to return a schema or the path to a schema file + +### `importers` + +- `importers/djornl`: use manifest file to specify the list of files to be parsed to create a dataset. Refactor file parsing for more flexibility. + +### `spec` + +- add `datasets` folder for dataset-specific schemas + +---- + +## 0.0.5 + +Last release with RE components in two repositories, https://github.com/kbase/relation_engine_api and https://github.com/kbase/relation_engine_spec diff --git a/importers/djornl/parser.py b/importers/djornl/parser.py index 771b359a..928b55fe 100644 --- a/importers/djornl/parser.py +++ b/importers/djornl/parser.py @@ -8,8 +8,10 @@ import requests import os import csv +import yaml import importers.utils.config as config +from relation_engine_server.utils.json_validation import run_validator class DJORNL_Parser(object): @@ -28,45 +30,119 @@ def _configure(self): configuration = config.load_from_env(extra_required=['ROOT_DATA_PATH']) # Collection name config - configuration['_NODE_NAME'] = 'djornl_node' - configuration['_EDGE_NAME'] = 'djornl_edge' + configuration['node_name'] = 'djornl_node' + configuration['edge_name'] = 'djornl_edge' - # Path config - configuration['_NODE_PATH'] = os.path.join( - configuration['ROOT_DATA_PATH'], - 'aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv' - ) - configuration['_NODE_FILE_COL_COUNT'] = 20 + # fetch the manifest and make sure all the files listed actually exist + manifest = self._get_manifest(configuration) + for type in ['node', 'edge', 'cluster']: + configuration[type + '_files'] = [] + + error_list = [] + for file in manifest['file_list']: + file_path = os.path.join(configuration['ROOT_DATA_PATH'], file['path']) + + if not os.path.exists(file_path): + error_list.append(f"{file_path}: file does not exist") + continue + + if not os.path.isfile(file_path): + error_list.append(f"{file_path}: not a file") + continue + + # add the file to the appropriate list + file['file_path'] = file_path + configuration[file['data_type'] + '_files'].append(file) + + if error_list: + raise RuntimeError("\n".join(error_list)) - configuration['_EDGE_PATH'] = os.path.join( - configuration['ROOT_DATA_PATH'], - 'merged_edges-AMW-060820_AF.tsv' - ) - configuration['_EDGE_FILE_COL_COUNT'] = 5 - - _CLUSTER_BASE = os.path.join(configuration['ROOT_DATA_PATH'], 'cluster_data') - configuration['_CLUSTER_PATHS'] = { - 'markov_i2': os.path.join( - _CLUSTER_BASE, - 'out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I2_named.tsv' - ), - 'markov_i4': os.path.join( - _CLUSTER_BASE, - 'out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I4_named.tsv' - ), - 'markov_i6': os.path.join( - _CLUSTER_BASE, - 'out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I6_named.tsv' - ), - } self._config = configuration return self._config + def _get_manifest_schema_file(self): + + return os.path.join('/app', 'spec', 'datasets', 'djornl', 'manifest.schema.json') + + def _get_manifest(self, configuration): + """ + Read the manifest file, which contains path and file type info, and validate it. + The manifest is expected to be at ROOT_DATA_PATH/manifest.yaml + """ + + schema_file = self._get_manifest_schema_file() + + # load the manifest and validate it against the schema + manifest_file = os.path.join(configuration['ROOT_DATA_PATH'], 'manifest.yaml') + + try: + with open(manifest_file) as fd: + manifest = yaml.safe_load(fd) + except FileNotFoundError: + raise RuntimeError( + f"No manifest file found at {manifest_file}.\n" + + "Please ensure that you have created a manifest that lists the files " + + "in the release" + ) + + try: + validated_manifest = run_validator( + schema_file=schema_file, + data=manifest + ) + except Exception as err: + print(err) + raise RuntimeError( + "The manifest file failed validation. Please recheck the file and try again." + ) + + return validated_manifest + + def _get_file_reader(self, fd, file): + '''Given a dict containing file information, instantiate the correct type of parser''' + + delimiter = '\t' + if 'file_format' in file and file['file_format'].lower() == 'csv' or file['path'].lower().endswith('.csv'): + delimiter = ',' + return csv.reader(fd, delimiter=delimiter) + + def parser_gen(self, file): + """generator function to parse a file""" + expected_col_count = 0 + with open(file['file_path']) as fd: + csv_reader = self._get_file_reader(fd, file) + line_no = 0 + for row in csv_reader: + line_no += 1 + if len(row) <= 1 or row[0][0] == '#': + # comment / metadata + continue + + cols = [c.strip() for c in row] + + if len(cols) == expected_col_count: + yield (line_no, cols) + continue + + # if we didn't get the expected number of cols: + if expected_col_count == 0: + # this is the header row; set up the expected column count + expected_col_count = len(cols) + yield (line_no, [c.lower() for c in cols]) + continue + + # otherwise, this row does not have the correct number of columns + n_cols = len(cols) + raise RuntimeError( + f"{file['path']} line {line_no}: " + + f"expected {expected_col_count} cols, found {n_cols}" + ) + def load_edges(self): # Headers and sample row: # node1 node2 edge edge_descrip layer_descrip # AT1G01370 AT1G57820 4.40001558779779 AraNetv2_log-likelihood-score AraNetv2-LC_lit-curated-ppi - edge_remap = { + edge_type_remap = { 'AraGWAS-Phenotype_Associations': 'pheno_assn', 'AraNetv2-CX_pairwise-gene-coexpression': 'gene_coexpr', 'AraNetv2-DC_domain-co-occurrence': 'domain_co_occur', @@ -77,34 +153,56 @@ def load_edges(self): # dict of nodes, indexed by node ID (node1 and node2 from the file) node_ix = {} edges = [] - node_name = self.config('_NODE_NAME') - expected_col_count = self.config('_EDGE_FILE_COL_COUNT') + node_name = self.config('node_name') + + def edge_type(row): + if row['layer_descrip'] not in edge_type_remap: + raise RuntimeError( + f"{file['path']} line {line_no}: invalid edge type: {row['layer_descrip']}" + ) + return edge_type_remap[row['layer_descrip']] + + def _key(row): + return '__'.join([ + row['node1'], + row['node2'], + edge_type(row), + row['edge'], + ]) + + # these functions remap the values in the columns of the input file to + # appropriate values to go into Arango + remap_functions = { + '_from': lambda row: node_name + '/' + row['node1'], + '_to': lambda row: node_name + '/' + row['node2'], + 'score': lambda row: float(row['edge']), + 'edge_type': edge_type, + '_key': _key, + } - with open(self.config('_EDGE_PATH')) as fd: - csv_reader = csv.reader(fd, delimiter='\t') - next(csv_reader, None) # skip headers - line_no = 1 - for row in csv_reader: - line_no += 1 + for file in self.config('edge_files'): + file_parser = self.parser_gen(file) + headers = [] - cols = [c.strip() for c in row] - if len(cols) != expected_col_count: - n_cols = len(cols) - raise RuntimeError(f"line {line_no}: expected {expected_col_count} cols, found {n_cols}") - - node_ix[cols[0]] = 1 - node_ix[cols[1]] = 1 - edge_type = cols[4] - if edge_type not in edge_remap: - raise RuntimeError(f"line {line_no}: invalid edge type: {edge_type}") - - edges.append({ - '_key': f'{cols[0]}__{cols[1]}__{edge_remap[edge_type]}__{cols[2]}', - '_from': f'{node_name}/{cols[0]}', - '_to': f'{node_name}/{cols[1]}', - 'score': float(cols[2]), - 'edge_type': edge_remap[edge_type], - }) + while True: + try: + (line_no, cols) = next(file_parser) + except StopIteration: + break + + if len(headers) == 0: + headers = cols + continue + + # merge headers with cols to create an object + row_object = dict(zip(headers, cols)) + # transform it using the remap_functions + datum = {key: func(row_object) for (key, func) in remap_functions.items()} + edges.append(datum) + + # keep track of the nodes mentioned in this edge set + for node in ["1", "2"]: + node_ix[row_object[f"node{node}"]] = 1 return { 'nodes': [{'_key': n} for n in node_ix.keys()], @@ -116,49 +214,69 @@ def load_node_metadata(self): nodes = [] valid_node_types = ['gene', 'pheno'] - expected_col_count = self.config('_NODE_FILE_COL_COUNT') - with open(self.config('_NODE_PATH')) as fd: - csv_reader = csv.reader(fd, delimiter=',') - next(csv_reader, None) # skip headers - line_no = 1 - for row in csv_reader: - line_no += 1 - cols = [c.strip() for c in row] - if len(cols) != expected_col_count: - n_cols = len(cols) - raise RuntimeError(f"line {line_no}: expected {expected_col_count} cols, found {n_cols}") - - _key = cols[0] - node_type = cols[1] - if node_type not in valid_node_types: - raise RuntimeError(f"line {line_no}: invalid node type: {node_type}") - - go_terms = [c.strip() for c in cols[10].split(',')] if len(cols[10]) else [] - - doc = { - '_key': _key, - 'node_type': node_type, - 'transcript': cols[2], - 'gene_symbol': cols[3], - 'gene_full_name': cols[4], - 'gene_model_type': cols[5], - 'tair_computational_desc': cols[6], - 'tair_curator_summary': cols[7], - 'tair_short_desc': cols[8], - 'go_descr': cols[9], - 'go_terms': go_terms, - 'mapman_bin': cols[11], - 'mapman_name': cols[12], - 'mapman_desc': cols[13], - 'pheno_aragwas_id': cols[14], - 'pheno_desc1': cols[15], - 'pheno_desc2': cols[16], - 'pheno_desc3': cols[17], - 'pheno_ref': cols[18], - 'user_notes': cols[19], - } - nodes.append(doc) + def go_terms(row): + if len(row['go_terms']): + return [c.strip() for c in row_object['go_terms'].split(',')] + return [] + + def node_type(row): + if row['node_type'] not in valid_node_types: + raise RuntimeError( + f"{file['path']} line {line_no}: invalid node type: {row['node_type']}" + ) + return row['node_type'] + + remap_functions = { + # these pass straight through + 'transcript': None, + 'gene_symbol': None, + 'gene_full_name': None, + 'gene_model_type': None, + 'tair_computational_description': None, + 'tair_short_description': None, + 'tair_curator_summary': None, + 'mapman_bin': None, + 'mapman_name': None, + 'pheno_aragwas_id': None, + 'pheno_ref': None, + 'user_notes': None, + # rename + '_key': lambda row: row['node_id'], + 'go_description': lambda row: row['go_descr'], + 'mapman_description': lambda row: row['mapman_descr'], + 'pheno_description': lambda row: row['pheno_descrip1'], + 'pheno_pto_name': lambda row: row['pheno_descrip2'], + 'pheno_pto_description': lambda row: row['pheno_descrip3'], + # see functions above + 'node_type': node_type, + 'go_terms': go_terms, + } + + for file in self.config('node_files'): + file_parser = self.parser_gen(file) + headers = [] + + while True: + try: + (line_no, cols) = next(file_parser) + except StopIteration: + break + + if len(headers) == 0: + headers = cols + continue + + # merge with headers to form an object, then remap to create Arango-ready data + row_object = dict(zip(headers, cols)) + + datum = {} + for (key, func) in remap_functions.items(): + if func is None: + datum[key] = row_object[key] + else: + datum[key] = func(row_object) + nodes.append(datum) return {'nodes': nodes} @@ -167,22 +285,29 @@ def load_cluster_data(self): # index of nodes node_ix = {} - - cluster_paths = self.config('_CLUSTER_PATHS') - for (cluster_label, path) in cluster_paths.items(): - with open(path) as fd: - csv_reader = csv.reader(fd, delimiter='\t') - for row in csv_reader: - if len(row) > 1: - # remove the 'Cluster' text and replace it with cluster_label - cluster_id = cluster_label + ':' + row[0].replace('Cluster', '') - - node_keys = row[1:] - for key in node_keys: - if key not in node_ix: - node_ix[key] = [cluster_id] - elif cluster_id not in node_ix[key]: - node_ix[key].append(cluster_id) + for file in self.config('cluster_files'): + cluster_label = file['cluster_prefix'] + headers = [] + file_parser = self.parser_gen(file) + + while True: + try: + (line_no, cols) = next(file_parser) + except StopIteration: + break + + if len(headers) == 0: + headers = cols + continue + + # remove the 'Cluster' text and replace it with cluster_label + cluster_id = cluster_label + ':' + cols[0].replace('Cluster', '') + node_keys = [n.strip() for n in cols[1].split(',')] + for key in node_keys: + if key not in node_ix: + node_ix[key] = [cluster_id] + elif cluster_id not in node_ix[key]: + node_ix[key].append(cluster_id) # gather a list of cluster IDs for each node nodes = [{ @@ -195,10 +320,10 @@ def load_cluster_data(self): def save_dataset(self, dataset): if 'nodes' in dataset and len(dataset['nodes']) > 0: - self.save_docs(self.config('_NODE_NAME'), dataset['nodes']) + self.save_docs(self.config('node_name'), dataset['nodes']) if 'edges' in dataset and len(dataset['edges']) > 0: - self.save_docs(self.config('_EDGE_NAME'), dataset['edges']) + self.save_docs(self.config('edge_name'), dataset['edges']) def save_docs(self, coll_name, docs, on_dupe='update'): diff --git a/importers/test/test_djornl_parser.py b/importers/test/test_djornl_parser.py index 2ad9184e..e2442c8d 100644 --- a/importers/test/test_djornl_parser.py +++ b/importers/test/test_djornl_parser.py @@ -33,18 +33,29 @@ def init_parser_with_path(self, root_path): parser._configure() return parser + def test_load_no_manifest(self): + """ test loading when the manifest does not exist """ + RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, 'djornl', 'no_manifest') + err_str = 'No manifest file found at ' + os.path.join(RES_ROOT_DATA_PATH, 'manifest.yaml') + with self.assertRaisesRegex(RuntimeError, err_str): + self.init_parser_with_path(RES_ROOT_DATA_PATH) + + def test_load_invalid_manifest(self): + """ test an invalid manifest file """ + RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, 'djornl', 'invalid_manifest') + err_str = "The manifest file failed validation" + with self.assertRaisesRegex(RuntimeError, err_str): + self.init_parser_with_path(RES_ROOT_DATA_PATH) + def test_load_invalid_file(self): """ test loading when what is supposed to be a file is actually a directory """ RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, 'djornl', 'invalid_file') # edges: directory, not a file - edges_file_path = os.path.join(RES_ROOT_DATA_PATH, "merged_edges-AMW-060820_AF.tsv") - err_str = f"Is a directory: '{edges_file_path}'" - parser = self.init_parser_with_path(RES_ROOT_DATA_PATH) - - with self.assertRaisesRegex(IsADirectoryError, err_str): - parser.load_edges() + err_str = os.path.join(RES_ROOT_DATA_PATH, "edges.tsv") + ": not a file" + with self.assertRaisesRegex(RuntimeError, err_str): + self.init_parser_with_path(RES_ROOT_DATA_PATH) def test_load_empty_files(self): """ test loading files containing no data """ @@ -60,20 +71,11 @@ def test_load_empty_files(self): def test_load_missing_files(self): """ test loading when files cannot be found """ - # this dir does not contain the correct file structure - # path: test/djornl/empty_files/cluster_data - RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, 'djornl', 'empty_files', 'cluster_data') - parser = self.init_parser_with_path(RES_ROOT_DATA_PATH) - - err_str = "No such file or directory: '" + RES_ROOT_DATA_PATH - with self.assertRaisesRegex(FileNotFoundError, err_str): - parser.load_edges() - - with self.assertRaisesRegex(FileNotFoundError, err_str): - parser.load_node_metadata() - - with self.assertRaisesRegex(FileNotFoundError, err_str): - parser.load_cluster_data() + RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, 'djornl', 'missing_files') + # not found + err_str = os.path.join(RES_ROOT_DATA_PATH, "edges.tsv") + ': file does not exist' + with self.assertRaisesRegex(RuntimeError, err_str): + self.init_parser_with_path(RES_ROOT_DATA_PATH) def test_load_invalid_types(self): """ test file format errors """ @@ -83,12 +85,12 @@ def test_load_invalid_types(self): parser = self.init_parser_with_path(RES_ROOT_DATA_PATH) # invalid edge type - edge_err_msg = 'line 2: invalid edge type: AraGWAS-Some-Old-Rubbish-I-Made-Up' + edge_err_msg = 'merged_edges-AMW-060820_AF.tsv line 3: invalid edge type: AraGWAS-Some-Old-Rubbish-I-Made-Up' with self.assertRaisesRegex(RuntimeError, edge_err_msg): parser.load_edges() # invalid node type - node_err_msg = 'line 4: invalid node type: Monkey' + node_err_msg = 'aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv line 5: invalid node type: Monkey' with self.assertRaisesRegex(RuntimeError, node_err_msg): parser.load_node_metadata() diff --git a/spec/README.md b/spec/README.md index 7eb975bc..27b2c8ee 100644 --- a/spec/README.md +++ b/spec/README.md @@ -7,6 +7,7 @@ These specifications are used by the [Relation Engine API](relation_engine_serve * **[Stored queries](spec/stored_queries)** are stored [AQL queries](https://docs.arangodb.com/3.5/AQL/index.html) that can be used by KBase apps to fetch data from the database. * **[Collections, or document schemas,](spec/collections)** are [JSON schemas](https://json-schema.org/) that define what form of data can be stored in the database's collections. +* **[Datasets](spec/datasets)** contain partial and full schemas specific to a certain dataset. * **[Data sources](spec/data_sources)** contain general information about where some of our imported data comes from. * **[Views](spec/views)** are raw ArangoSearch view configuration files diff --git a/spec/collections/djornl/djornl_edge.yaml b/spec/collections/djornl/djornl_edge.yaml index 3afa987f..1c956fdc 100644 --- a/spec/collections/djornl/djornl_edge.yaml +++ b/spec/collections/djornl/djornl_edge.yaml @@ -33,15 +33,20 @@ schema: type: string oneOf: - const: domain_co_occur + title: AraNetv2-DC_domain-co-occurrence description: A layer of protein domain co-occurrence values from the Arabidopsis AraNetv2 database. The LLS scores that serve as edge values were calculated from weighted mutual information scores to normalize the data for comparison across studies and different types of data layers (Lee et al, 2015). - const: gene_coexpr + title: AraNetv2-CX_pairwise-gene-coexpression description: A subset of pairwise gene coexpression values from the Arabidopsis AraNetv2 database. The LLS scores that serve as edge values were calculated from Pearson correlation coefficients to normalize the data for comparison across studies and different types of data layers (Lee et al, 2015). - const: pheno_assn + title: AraGWAS-Phenotype_Associations description: GWAS associations produced by analyzing a subset of phenotypes and SNPs in the Arabidopsis 1001 Genomes database. Edge values are significant association scores after FDR correction. - const: ppi_hithru + title: AraNetv2-HT_high-throughput-ppi description: Log likelihood score. A layer of protein-protein interaction values derived from four high-throughput PPI screening experiments; from the Arabidopsis AraNetv2 database. The LLS scores that serve as edge values were calculated to normalize the data for comparison across studies and different types of data layers (Lee et al, 2015). - const: ppi_liter + title: AraNetv2-LC_lit-curated-ppi description: A layer of protein-protein interaction values from literature-curated small- to medium-scale experimental data; from the Arabidopsis AraNetv2 database. The LLS scores that serve as edge values were calculated to normalize the data for comparison across studies and different types of data layers (Lee et al, 2015). diff --git a/spec/collections/djornl/djornl_node.yaml b/spec/collections/djornl/djornl_node.yaml index 13b14541..e0a744a7 100644 --- a/spec/collections/djornl/djornl_node.yaml +++ b/spec/collections/djornl/djornl_node.yaml @@ -46,7 +46,7 @@ schema: type: string title: Gene model type examples: ["protein_coding"] - tair_computational_desc: + tair_computational_description: type: string title: TAIR computational description examples: ["NAC domain containing protein 1;(source:Araport11)"] @@ -54,11 +54,11 @@ schema: type: string title: TAIR curator summary examples: ["Encodes a plasma membrane-localized amino acid transporter likely involved in amino acid export in the developing seed."] - tair_short_desc: + tair_short_description: type: string title: TAIR short description examples: ["NAC domain containing protein 1"] - go_descr: + go_description: type: string title: GO descriptions examples: ["DNA-binding transcription factor activity"] @@ -75,7 +75,7 @@ schema: type: string title: Mapman name examples: [".RNA biosynthesis.transcriptional regulation.transcription factor (NAC)"] - mapman_desc: + mapman_description: type: string title: Mapman description examples: ["transcription factor (NAC) (original description: pep chromosome:TAIR10:1:3631:5899:1 gene:AT1G01010 transcript:AT1G01010.1 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:NAC001 description:NAC domain-containing protein 1 [Source:UniProtKB/Swiss-Prot;Acc:Q0WV96])"] @@ -83,17 +83,19 @@ schema: type: string title: AraGWAS ID examples: ["10.21958/phenotype:67"] - pheno_desc1: + pheno_description: type: string - title: Phenotype description 1 + title: Phenotype description examples: ["Arsenic concentrations in leaves, grown in soil. Elemental analysis was performed with an ICP-MS (PerkinElmer). Sample normalized to calculated weights as described in Baxter et al., 2008"] - pheno_desc2: + pheno_pto_name: type: string title: PTO name + description: Plant Trait Ontology name examples: ["arsenic concentration"] - pheno_desc3: + pheno_pto_description: type: string title: PTO description + description: Plant Trait Ontology description examples: ["A mineral and ion content related trait (TO:0000465) which is the concentration of arsenic (CHEBI:22632) in some plant structure (PO:0009011). [GR:Karthik]"] pheno_ref: type: string diff --git a/spec/datasets/djornl/manifest.schema.json b/spec/datasets/djornl/manifest.schema.json new file mode 100644 index 00000000..beb7309f --- /dev/null +++ b/spec/datasets/djornl/manifest.schema.json @@ -0,0 +1,102 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "Exascale parser file manifest", + "type": "object", + "required": ["name", "file_list"], + "properties": { + "name": { + "title": "Dataset name", + "type": "string", + "description": "The name of the dataset", + "examples": ["Dan Jacobson Exascale dataset"] + }, + "release_date": { + "title": "Release date", + "type": "string", + "description": "Date of the dataset release, in YYYY-MM-DD format", + "format": "date" + }, + "notes": { + "type": "string", + "title": "Release notes", + "description": "Free text describing the release and any notes, or comments relevant to consumers of the data." + }, + "file_list": { + "type": "array", + "items": { + "type": "object", + "required": ["data_type", "path"], + "oneOf": [{ + "properties": { + "data_type": { + "enum": ["cluster"] + } + }, + "required": ["cluster_prefix"] + }, + { + "properties": { + "data_type": { + "enum": ["node", "edge"] + } + } + } + ], + "anyOf": [{ + "properties": { + "file_format": { + "enum": ["tsv", "csv"] + } + }, + "required": ["file_format"] + }, + { + "properties": { + "path": { + "format": "regex", + "pattern": ".[ct]sv" + } + }, + "required": ["path"] + } + ], + "properties": { + "path": { + "title": "File path", + "type": "string" + }, + "data_type": { + "title": "Data type", + "type": "string", + "enum": ["node", "edge", "cluster"] + }, + "file_format": { + "title": "File format", + "type": "string", + "enum": ["tsv", "csv"] + }, + "date": { + "title": "File creation date", + "description": "date of file creation in the format YYYY-MM-DD", + "type": "string", + "format": "date" + }, + "description": { + "title": "Description of the file contents", + "type": "string" + }, + "cluster_prefix": { + "title": "Prefix", + "type": "string", + "description": "The prefix to be used for clusters, e.g. markov_i2:4. Required for cluster data, not used for node or edge data" + }, + "cluster_title": { + "title": "Cluster set name", + "description": "Human-readable name of the cluster set. Not used for edge or node data", + "type": "string" + } + } + } + } + } +} diff --git a/spec/stored_queries/djornl/djornl_fetch_clusters.yaml b/spec/stored_queries/djornl/djornl_fetch_clusters.yaml index 1fadca36..4aa6070e 100644 --- a/spec/stored_queries/djornl/djornl_fetch_clusters.yaml +++ b/spec/stored_queries/djornl/djornl_fetch_clusters.yaml @@ -5,6 +5,7 @@ params: required: [cluster_ids] properties: cluster_ids: + type: array title: Cluster IDs description: Cluster IDs, in the form "clustering_system_name:cluster_id" items: {type: string} diff --git a/spec/stored_queries/djornl/djornl_search_nodes.yaml b/spec/stored_queries/djornl/djornl_search_nodes.yaml index 7cd36c4f..9c8d6a1d 100644 --- a/spec/stored_queries/djornl/djornl_search_nodes.yaml +++ b/spec/stored_queries/djornl/djornl_search_nodes.yaml @@ -19,15 +19,15 @@ query: | LET node_ids = ( FOR g IN djornl_node_view SEARCH ANALYZER( - PHRASE(g.tair_computational_desc, @search_text) OR - PHRASE(g.tair_short_desc, @search_text) OR - PHRASE(g.mapman_desc, @search_text) OR - PHRASE(g.go_desc, @search_text) OR + PHRASE(g.tair_computational_description, @search_text) OR + PHRASE(g.tair_short_description, @search_text) OR + PHRASE(g.mapman_description, @search_text) OR + PHRASE(g.go_description, @search_text) OR PHRASE(g.mapman_name, @search_text) OR - PHRASE(g.mapman_desc, @search_text) OR - PHRASE(g.pheno_desc1, @search_text) OR - PHRASE(g.pheno_desc2, @search_text) OR - PHRASE(g.pheno_desc3, @search_text) OR + PHRASE(g.mapman_description, @search_text) OR + PHRASE(g.pheno_description, @search_text) OR + PHRASE(g.pheno_pto_name, @search_text) OR + PHRASE(g.pheno_pto_description, @search_text) OR PHRASE(g.user_notes, @search_text), 'text_en' ) diff --git a/spec/test/djornl/col_count_errors/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv b/spec/test/djornl/col_count_errors/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv index 48e5ab19..7727cd8a 100644 --- a/spec/test/djornl/col_count_errors/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv +++ b/spec/test/djornl/col_count_errors/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv @@ -1,4 +1,4 @@ -node_id,node_type,transcript,gene_symbol,gene_full_name,gene_model_type,TAIR_Computational_description,TAIR_Curator_summary,TAIR_short_description,GO_descr,GO_terms,MapMan_bin,MapMan_name,MapMan_descr,pheno_AraGWAS_ID,pheno_descrip1,pheno_descrip2,pheno_descrip3,pheno_ref,UserNotes +node_id,node_type,transcript,gene_symbol,gene_full_name,gene_model_type,TAIR_Computational_description,TAIR_Curator_summary,TAIR_short_description,GO_descr,GO_terms,MapMan_bin,MapMan_name,MapMan_descr,pheno_AraGWAS_ID,pheno_descrip1,pheno_descrip2,pheno_descrip3,pheno_ref,User_Notes As2,pheno,,,,,,,,,,,,,10.21958/phenotype:103,,bacterial disease resistance,The resistance exhibited by a plant or a group of plants (population) in response to the disease caused by a bacterial pathogen infection as compared to the susceptible and/or the reference plants of the same species. [GR:pj],"Atwell et. al, Nature 2010", As75,pheno,,,,,,,,,,,,,,,10.21958/phenotype:67,"Arsenic concentrations in leaves, grown in soil. Elemental analysis was performed with an ICP-MS (PerkinElmer). Sample normalized to calculated weights as described in Baxter et al., 2008",arsenic concentration,A mineral and ion content related trait (TO:0000465) which is the concentration of arsenic (CHEBI:22632) in some plant structure (PO:0009011). [GR:Karthik],"Atwell et. al, Nature 2010", AT1G01020,gene,AT1G01020.6,ARV1,,protein_coding,ARV1 family protein;(source:Araport11),,,molecular_function,GO:0003674,35.1,not assigned.annotated,(original description: pep chromosome:TAIR10:1:6788:8737:-1 gene:AT1G01020 transcript:AT1G01020.6 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:ARV1 description:ARV1 family protein [Source:UniProtKB/TrEMBL;Acc:Q5MK24]) & no description available(sp|q5mk24|arv1_arath : 99.4),,,,,, diff --git a/spec/test/djornl/col_count_errors/manifest.yaml b/spec/test/djornl/col_count_errors/manifest.yaml new file mode 100644 index 00000000..50c5f454 --- /dev/null +++ b/spec/test/djornl/col_count_errors/manifest.yaml @@ -0,0 +1,8 @@ +name: Dan Jacobson Exascale data +release_date: "2020-06-06" +file_list: + - data_type: edge + path: merged_edges-AMW-060820_AF.tsv + + - data_type: node + path: aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv diff --git a/spec/test/djornl/empty_files/manifest.yaml b/spec/test/djornl/empty_files/manifest.yaml new file mode 100644 index 00000000..fb231666 --- /dev/null +++ b/spec/test/djornl/empty_files/manifest.yaml @@ -0,0 +1,20 @@ +name: Dan Jacobson Exascale data +release_date: "2020-06-06" +file_list: + - data_type: edge + path: merged_edges-AMW-060820_AF.tsv + + - data_type: node + path: aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv + + - data_type: cluster + cluster_prefix: markov_i2 + path: cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I2_named.tsv + + - data_type: cluster + cluster_prefix: markov_i4 + path: cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I4_named.tsv + + - data_type: cluster + cluster_prefix: markov_i6 + path: cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I6_named.tsv diff --git a/spec/test/djornl/invalid_file/edges.tsv/empty b/spec/test/djornl/invalid_file/edges.tsv/empty new file mode 100644 index 00000000..e69de29b diff --git a/spec/test/djornl/invalid_file/manifest.yaml b/spec/test/djornl/invalid_file/manifest.yaml new file mode 100644 index 00000000..d79e76a7 --- /dev/null +++ b/spec/test/djornl/invalid_file/manifest.yaml @@ -0,0 +1,12 @@ +name: Dan Jacobson Exascale data +release_date: "2020-06-06" +file_list: + - data_type: edge + path: edges.tsv + + - data_type: node + path: nodes.csv + + - data_type: cluster + cluster_prefix: markov_i2 + path: clusters.tsv diff --git a/spec/test/djornl/invalid_manifest/cluster_no_prefix.yaml b/spec/test/djornl/invalid_manifest/cluster_no_prefix.yaml new file mode 100644 index 00000000..b8993731 --- /dev/null +++ b/spec/test/djornl/invalid_manifest/cluster_no_prefix.yaml @@ -0,0 +1,18 @@ +# first cluster file has no prefix +name: Dan Jacobson Exascale data +release_date: "2020-06-06" +file_list: + - data_type: edge + path: edges.tsv + date: "2020-12-25" + + - data_type: node + path: nodes.csv + date: "2019-01-01" + + - data_type: cluster + path: I2_named.tsv + + - data_type: cluster + cluster_prefix: markov_i4 + path: I4_named.tsv diff --git a/spec/test/djornl/invalid_manifest/date_not_in_quotes.yaml b/spec/test/djornl/invalid_manifest/date_not_in_quotes.yaml new file mode 100644 index 00000000..d40e9e6f --- /dev/null +++ b/spec/test/djornl/invalid_manifest/date_not_in_quotes.yaml @@ -0,0 +1,17 @@ +# edge date is not quoted (pyyaml creates a datetime.date object) +name: Dan Jacobson Exascale data +release_date: "2020-06-06" +file_list: + - data_type: edge + date: 2020-12-25 + path: edge_data + file_format: csv + + - data_type: node + path: nodes.csv + date: "2019-01-01" + + - data_type: cluster + cluster_prefix: markov_i2 + file_format: tsv + path: clusters diff --git a/spec/test/djornl/invalid_manifest/invalid_format.yaml b/spec/test/djornl/invalid_manifest/invalid_format.yaml new file mode 100644 index 00000000..125227ce --- /dev/null +++ b/spec/test/djornl/invalid_manifest/invalid_format.yaml @@ -0,0 +1,17 @@ +# invalid node file format +name: Dan Jacobson Exascale data +release_date: "2020-06-06" +file_list: + - data_type: edge + date: "2020-12-25" + path: edge_data.tsv + + - data_type: node + path: nodes.csv + date: "2019-01-01" + file_format: txt + + - data_type: cluster + cluster_prefix: markov_i2 + file_format: tsv + path: clusters diff --git a/spec/test/djornl/invalid_manifest/manifest.yaml b/spec/test/djornl/invalid_manifest/manifest.yaml new file mode 100644 index 00000000..7abfa0e2 --- /dev/null +++ b/spec/test/djornl/invalid_manifest/manifest.yaml @@ -0,0 +1,14 @@ +# multiple errors +name: Dan Jacobson Exascale data +release_date: "2020-06-06" +file_list: + - data_type: edge + path: edges.tsv + + - data_type: node + + - data_type: cluster + path: clusters.tsv + + - data_type: ping-pong balls + path: where? diff --git a/spec/test/djornl/invalid_manifest/missing_path.yaml b/spec/test/djornl/invalid_manifest/missing_path.yaml new file mode 100644 index 00000000..c93bec17 --- /dev/null +++ b/spec/test/djornl/invalid_manifest/missing_path.yaml @@ -0,0 +1,21 @@ +# edge file path missing +name: Dan Jacobson Exascale data +release_date: "2020-06-06" +file_list: + - data_type: edge + date: "2020-12-25" + + - data_type: node + path: nodes.csv + date: "2019-01-01" + + - data_type: cluster + cluster_prefix: markov_i2 + + - data_type: cluster + cluster_prefix: markov_i4 + path: I4_named.tsv + + - data_type: cluster + cluster_prefix: markov_i6 + path: I6_named.tsv diff --git a/spec/test/djornl/invalid_manifest/no_file_format.yaml b/spec/test/djornl/invalid_manifest/no_file_format.yaml new file mode 100644 index 00000000..ee8b9082 --- /dev/null +++ b/spec/test/djornl/invalid_manifest/no_file_format.yaml @@ -0,0 +1,16 @@ +# edge file has no indicator of file format +name: Dan Jacobson Exascale data +release_date: "2020-06-06" +file_list: + - data_type: edge + date: "2020-12-25" + path: edge_data + + - data_type: node + path: nodes.csv + date: "2019-01-01" + + - data_type: cluster + cluster_prefix: markov_i2 + file_format: tsv + path: clusters diff --git a/spec/test/djornl/invalid_manifest/no_file_list.yaml b/spec/test/djornl/invalid_manifest/no_file_list.yaml new file mode 100644 index 00000000..ebaf9fb8 --- /dev/null +++ b/spec/test/djornl/invalid_manifest/no_file_list.yaml @@ -0,0 +1,3 @@ +# missing file_list +name: Dan Jacobson Exascale data +release_date: "2020-06-06" diff --git a/spec/test/djornl/invalid_types/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv b/spec/test/djornl/invalid_types/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv index af5fa6cb..e98310e5 100644 --- a/spec/test/djornl/invalid_types/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv +++ b/spec/test/djornl/invalid_types/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv @@ -1,4 +1,5 @@ -node_id,node_type,transcript,gene_symbol,gene_full_name,gene_model_type,TAIR_Computational_description,TAIR_Curator_summary,TAIR_short_description,GO_descr,GO_terms,MapMan_bin,MapMan_name,MapMan_descr,pheno_AraGWAS_ID,pheno_descrip1,pheno_descrip2,pheno_descrip3,pheno_ref,UserNotes +node_id,node_type,transcript,gene_symbol,gene_full_name,gene_model_type,TAIR_Computational_description,TAIR_Curator_summary,TAIR_short_description,GO_descr,GO_terms,MapMan_bin,MapMan_name,MapMan_descr,pheno_AraGWAS_ID,pheno_descrip1,pheno_descrip2,pheno_descrip3,pheno_ref,User_Notes +# data_type: node As2,pheno,,,,,,,,,,,,,10.21958/phenotype:103,,bacterial disease resistance,The resistance exhibited by a plant or a group of plants (population) in response to the disease caused by a bacterial pathogen infection as compared to the susceptible and/or the reference plants of the same species. [GR:pj],"Atwell et. al, Nature 2010", As75,pheno,,,,,,,,,,,,,10.21958/phenotype:67,"Arsenic concentrations in leaves, grown in soil. Elemental analysis was performed with an ICP-MS (PerkinElmer). Sample normalized to calculated weights as described in Baxter et al., 2008",arsenic concentration,A mineral and ion content related trait (TO:0000465) which is the concentration of arsenic (CHEBI:22632) in some plant structure (PO:0009011). [GR:Karthik],"Atwell et. al, Nature 2010", AT1G01010,Monkey,AT1G01010.1,NTL10,NAC domain containing protein 1,protein_coding,NAC domain containing protein 1;(source:Araport11),,NAC domain containing protein 1,"DNA-binding transcription factor activity, DNA binding","GO:0003700, GO:0003677",15.5.17,.RNA biosynthesis.transcriptional regulation.transcription factor (NAC),transcription factor (NAC) (original description: pep chromosome:TAIR10:1:3631:5899:1 gene:AT1G01010 transcript:AT1G01010.1 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:NAC001 description:NAC domain-containing protein 1 [Source:UniProtKB/Swiss-Prot;Acc:Q0WV96]),,,,,, diff --git a/spec/test/djornl/invalid_types/manifest.yaml b/spec/test/djornl/invalid_types/manifest.yaml new file mode 100644 index 00000000..50c5f454 --- /dev/null +++ b/spec/test/djornl/invalid_types/manifest.yaml @@ -0,0 +1,8 @@ +name: Dan Jacobson Exascale data +release_date: "2020-06-06" +file_list: + - data_type: edge + path: merged_edges-AMW-060820_AF.tsv + + - data_type: node + path: aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv diff --git a/spec/test/djornl/invalid_types/merged_edges-AMW-060820_AF.tsv b/spec/test/djornl/invalid_types/merged_edges-AMW-060820_AF.tsv index f9857bde..a98f49f9 100644 --- a/spec/test/djornl/invalid_types/merged_edges-AMW-060820_AF.tsv +++ b/spec/test/djornl/invalid_types/merged_edges-AMW-060820_AF.tsv @@ -1,3 +1,4 @@ +# data_type: edge node1 node2 edge edge_descrip layer_descrip As2 AT1G01020 8.422046084731258 AraGWAS-Association_score AraGWAS-Some-Old-Rubbish-I-Made-Up As2 AT1G01040 5.422046084731258 AraGWAS-Association_score AraGWAS-Phenotype_Associations diff --git a/spec/test/djornl/missing_files/manifest.yaml b/spec/test/djornl/missing_files/manifest.yaml new file mode 100644 index 00000000..d79e76a7 --- /dev/null +++ b/spec/test/djornl/missing_files/manifest.yaml @@ -0,0 +1,12 @@ +name: Dan Jacobson Exascale data +release_date: "2020-06-06" +file_list: + - data_type: edge + path: edges.tsv + + - data_type: node + path: nodes.csv + + - data_type: cluster + cluster_prefix: markov_i2 + path: clusters.tsv diff --git a/spec/test/djornl/results.json b/spec/test/djornl/results.json index 7fd3a4d5..e15408d2 100644 --- a/spec/test/djornl/results.json +++ b/spec/test/djornl/results.json @@ -40,20 +40,20 @@ }, "load_node_metadata": { "nodes": [ - {"_key": "As2", "node_type": "pheno", "transcript": "", "gene_symbol": "", "gene_full_name": "", "gene_model_type": "", "tair_computational_desc": "", "tair_curator_summary": "", "tair_short_desc": "", "go_descr": "", "go_terms": [], "mapman_bin": "", "mapman_name": "", "mapman_desc": "", "pheno_aragwas_id": "10.21958/phenotype:103", "pheno_desc1": "", "pheno_desc2": "bacterial disease resistance", "pheno_desc3": "The resistance exhibited by a plant or a group of plants (population) in response to the disease caused by a bacterial pathogen infection as compared to the susceptible and/or the reference plants of the same species. [GR:pj]", "pheno_ref": "Atwell et. al, Nature 2010", "user_notes": ""}, - {"_key": "As75", "node_type": "pheno", "transcript": "", "gene_symbol": "", "gene_full_name": "", "gene_model_type": "", "tair_computational_desc": "", "tair_curator_summary": "", "tair_short_desc": "", "go_descr": "", "go_terms": [], "mapman_bin": "", "mapman_name": "", "mapman_desc": "", "pheno_aragwas_id": "10.21958/phenotype:67", "pheno_desc1": "Arsenic concentrations in leaves, grown in soil. Elemental analysis was performed with an ICP-MS (PerkinElmer). Sample normalized to calculated weights as described in Baxter et al., 2008", "pheno_desc2": "arsenic concentration", "pheno_desc3": "A mineral and ion content related trait (TO:0000465) which is the concentration of arsenic (CHEBI:22632) in some plant structure (PO:0009011). [GR:Karthik]", "pheno_ref": "Atwell et. al, Nature 2010", "user_notes": ""}, - {"_key": "AT1G01010", "node_type": "gene", "transcript": "AT1G01010.1", "gene_symbol": "NTL10", "gene_full_name": "NAC domain containing protein 1", "gene_model_type": "protein_coding", "tair_computational_desc": "NAC domain containing protein 1;(source:Araport11)", "tair_curator_summary": "", "tair_short_desc": "NAC domain containing protein 1", "go_descr": "DNA-binding transcription factor activity, DNA binding", "go_terms": ["GO:0003700", "GO:0003677"], "mapman_bin": "15.5.17", "mapman_name": ".RNA biosynthesis.transcriptional regulation.transcription factor (NAC)", "mapman_desc": "transcription factor (NAC) (original description: pep chromosome:TAIR10:1:3631:5899:1 gene:AT1G01010 transcript:AT1G01010.1 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:NAC001 description:NAC domain-containing protein 1 [Source:UniProtKB/Swiss-Prot;Acc:Q0WV96])", "pheno_aragwas_id": "", "pheno_desc1": "", "pheno_desc2": "", "pheno_desc3": "", "pheno_ref": "", "user_notes": ""}, - {"_key": "AT1G01020", "node_type": "gene", "transcript": "AT1G01020.6", "gene_symbol": "ARV1", "gene_full_name": "", "gene_model_type": "protein_coding", "tair_computational_desc": "ARV1 family protein;(source:Araport11)", "tair_curator_summary": "", "tair_short_desc": "", "go_descr": "molecular_function", "go_terms": ["GO:0003674"], "mapman_bin": "35.1", "mapman_name": "not assigned.annotated", "mapman_desc": "(original description: pep chromosome:TAIR10:1:6788:8737:-1 gene:AT1G01020 transcript:AT1G01020.6 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:ARV1 description:ARV1 family protein [Source:UniProtKB/TrEMBL;Acc:Q5MK24]) & no description available(sp|q5mk24|arv1_arath : 99.4)", "pheno_aragwas_id": "", "pheno_desc1": "", "pheno_desc2": "", "pheno_desc3": "", "pheno_ref": "", "user_notes": ""}, - {"_key": "AT1G01030", "node_type": "gene", "transcript": "AT1G01030.2", "gene_symbol": "NGA3", "gene_full_name": "NGATHA3", "gene_model_type": "protein_coding", "tair_computational_desc": "AP2/B3-like transcriptional factor family protein;(source:Araport11)", "tair_curator_summary": "", "tair_short_desc": "", "go_descr": "DNA-binding transcription factor activity, DNA binding", "go_terms": ["GO:0003700", "GO:0003677"], "mapman_bin": "15.5.5.3", "mapman_name": ".RNA biosynthesis.transcriptional regulation.B3 transcription factor superfamily.transcription factor (RAV/NGATHA)", "mapman_desc": "transcription factor (RAV/NGATHA) (original description: pep chromosome:TAIR10:1:11649:13714:-1 gene:AT1G01030 transcript:AT1G01030.2 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:NGA3 description:B3 domain-containing transcription factor NGA3 [Source:UniProtKB/Swiss-Prot;Acc:Q9MAN1])", "pheno_aragwas_id": "", "pheno_desc1": "", "pheno_desc2": "", "pheno_desc3": "", "pheno_ref": "", "user_notes": ""}, - {"_key": "AT1G01040", "node_type": "gene", "transcript": "AT1G01040.2", "gene_symbol": "SUS1", "gene_full_name": "SUSPENSOR 1", "gene_model_type": "protein_coding", "tair_computational_desc": "dicer-like 1;(source:Araport11)", "tair_curator_summary": "Encodes a Dicer homolog. Dicer is a RNA helicase involved in microRNA processing. Mutations in this locus can result in embryo lethality. Embryo shape at seed maturity is globular-elongate. Other mutants convert the floral meristems to an indeterminate state, others yet show defects in ovule development. mRNA is expressed in all shoot tissues. DCL1 is able to produce miRNAs and siRNAs. The mRNA is cell-to-cell mobile.", "tair_short_desc": "dicer-like 1", "go_descr": "metal ion binding, protein binding, ribonuclease III activity, ATP-dependent helicase activity, ATP binding, RNA binding, helicase activity, double-stranded RNA binding, DNA binding", "go_terms": ["GO:0046872", "GO:0005515", "GO:0004525", "GO:0008026", "GO:0005524", "GO:0003723", "GO:0004386", "GO:0003725", "GO:0003677"], "mapman_bin": "16.10.2.1.1", "mapman_name": ".RNA processing.mRNA silencing.miRNA pathway.DCL1-HYL1 miRNA biogenesis complex.endoribonuclease component DCL1", "mapman_desc": "endoribonuclease component DCL1 of DCL1-HYL1 miRNA biogenesis complex (original description: pep chromosome:TAIR10:1:23416:31120:1 gene:AT1G01040 transcript:AT1G01040.2 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:DCL1 description:Dicer-like 1 [Source:UniProtKB/TrEMBL;Acc:F4HQG6])", "pheno_aragwas_id": "", "pheno_desc1": "", "pheno_desc2": "", "pheno_desc3": "", "pheno_ref": "", "user_notes": ""}, - {"_key": "AT1G01050", "node_type": "gene", "transcript": "AT1G01050.2", "gene_symbol": "PPa1", "gene_full_name": "pyrophosphorylase 1", "gene_model_type": "protein_coding", "tair_computational_desc": "pyrophosphorylase 1;(source:Araport11)", "tair_curator_summary": "", "tair_short_desc": "", "go_descr": "inorganic diphosphatase activity", "go_terms": ["GO:0004427"], "mapman_bin": "35.1", "mapman_name": "not assigned.annotated", "mapman_desc": "(original description: pep chromosome:TAIR10:1:31382:33009:-1 gene:AT1G01050 transcript:AT1G01050.2 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:PPA1 description:Soluble inorganic pyrophosphatase 1 [Source:UniProtKB/Swiss-Prot;Acc:Q93V56]) & Soluble inorganic pyrophosphatase 1 OS=Arabidopsis thaliana (sp|q93v56|ipyr1_arath : 419.0)", "pheno_aragwas_id": "", "pheno_desc1": "", "pheno_desc2": "", "pheno_desc3": "", "pheno_ref": "", "user_notes": ""}, - {"_key": "AT1G01060", "node_type": "gene", "transcript": "AT1G01060.8", "gene_symbol": "LHY1", "gene_full_name": "LATE ELONGATED HYPOCOTYL 1", "gene_model_type": "protein_coding", "tair_computational_desc": "Homeodomain-like superfamily protein;(source:Araport11)", "tair_curator_summary": "", "tair_short_desc": "", "go_descr": "DNA-binding transcription factor activity, DNA binding, transcription regulatory region DNA binding", "go_terms": ["GO:0003700", "GO:0003677", "GO:0044212"], "mapman_bin": "27.1.1", "mapman_name": ".Multi-process regulation.circadian clock system.core oscillator protein (LHY|CCA1)", "mapman_desc": "circadian clock core oscillator protein (LHY|CCA1) (original description: pep chromosome:TAIR10:1:33967:37230:-1 gene:AT1G01060 transcript:AT1G01060.8 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:LHY description:LHY1 [Source:UniProtKB/TrEMBL;Acc:A0A178W761])", "pheno_aragwas_id": "", "pheno_desc1": "", "pheno_desc2": "", "pheno_desc3": "", "pheno_ref": "", "user_notes": ""}, - {"_key": "AT1G01070", "node_type": "gene", "transcript": "AT1G01070.2", "gene_symbol": "UMAMIT28", "gene_full_name": "Usually multiple acids move in and out Transporters 28", "gene_model_type": "protein_coding", "tair_computational_desc": "nodulin MtN21 /EamA-like transporter family protein;(source:Araport11)", "tair_curator_summary": "Encodes a plasma membrane-localized amino acid transporter likely involved in amino acid export in the developing seed.", "tair_short_desc": "nodulin MtN21 /EamA-like transporter family protein", "go_descr": "L-glutamine transmembrane transporter activity", "go_terms": ["GO:0015186"], "mapman_bin": "24.2.1.5", "mapman_name": ".Solute transport.carrier-mediated transport.DMT superfamily.solute transporter (UmamiT)", "mapman_desc": "solute transporter (UmamiT) (original description: pep chromosome:TAIR10:1:38752:40945:-1 gene:AT1G01070 transcript:AT1G01070.2 gene_biotype:protein_coding transcript_biotype:protein_coding description:WAT1-related protein [Source:UniProtKB/TrEMBL;Acc:A0A178WFU3])", "pheno_aragwas_id": "", "pheno_desc1": "", "pheno_desc2": "", "pheno_desc3": "", "pheno_ref": "", "user_notes": ""}, - {"_key": "AT1G01080", "node_type": "gene", "transcript": "AT1G01080.3", "gene_symbol": "", "gene_full_name": "", "gene_model_type": "protein_coding", "tair_computational_desc": "RNA-binding (RRM/RBD/RNP motifs) family protein;(source:Araport11)", "tair_curator_summary": "", "tair_short_desc": "", "go_descr": "RNA binding, mRNA binding", "go_terms": ["GO:0003723", "GO:0003729"], "mapman_bin": "35.1", "mapman_name": "not assigned.annotated", "mapman_desc": "(original description: pep chromosome:TAIR10:1:44970:47059:-1 gene:AT1G01080 transcript:AT1G01080.3 gene_biotype:protein_coding transcript_biotype:protein_coding description:RNA-binding (RRM/RBD/RNP motifs) family protein [Source:UniProtKB/TrEMBL;Acc:F4HQH8]) & 33 kDa ribonucleoprotein, chloroplastic OS=Nicotiana sylvestris (sp|p19684|roc5_nicsy : 109.0)", "pheno_aragwas_id": "", "pheno_desc1": "", "pheno_desc2": "", "pheno_desc3": "", "pheno_ref": "", "user_notes": ""}, - {"_key": "AT1G01090", "node_type": "gene", "transcript": "AT1G01090.1", "gene_symbol": "PDH-E1 ALPHA", "gene_full_name": "pyruvate dehydrogenase E1 alpha", "gene_model_type": "protein_coding", "tair_computational_desc": "pyruvate dehydrogenase E1 alpha;(source:Araport11)", "tair_curator_summary": "pyruvate dehydrogenase E1 alpha subunit", "tair_short_desc": "pyruvate dehydrogenase E1 alpha", "go_descr": "pyruvate dehydrogenase (acetyl-transferring) activity, protein binding", "go_terms": ["GO:0004739", "GO:0005515"], "mapman_bin": "5.1.2.2.1.1", "mapman_name": ".Lipid metabolism.fatty acid biosynthesis.acetyl-CoA generation.plastidial pyruvate dehydrogenase complex.E1 pyruvate dehydrogenase subcomplex.subunit alpha", "mapman_desc": "subunit alpha of E1 pyruvate dehydrogenase component (original description: pep chromosome:TAIR10:1:47234:49304:-1 gene:AT1G01090 transcript:AT1G01090.1 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:PDH-E1 ALPHA description:Pyruvate dehydrogenase E1 component subunit alpha [Source:UniProtKB/TrEMBL;Acc:A0A178W8A7])", "pheno_aragwas_id": "", "pheno_desc1": "", "pheno_desc2": "", "pheno_desc3": "", "pheno_ref": "", "user_notes": ""}, - {"_key": "AT1G01100", "node_type": "gene", "transcript": "AT1G01100.4", "gene_symbol": "", "gene_full_name": "", "gene_model_type": "protein_coding", "tair_computational_desc": "60S acidic ribosomal protein family;(source:Araport11)", "tair_curator_summary": "", "tair_short_desc": "60S acidic ribosomal protein family", "go_descr": "structural constituent of ribosome, ribonucleoprotein complex binding, protein kinase activator activity", "go_terms": ["GO:0003735", "GO:0043021", "GO:0030295"], "mapman_bin": "17.1.2.1.46", "mapman_name": ".Protein biosynthesis.ribosome biogenesis.large ribosomal subunit (LSU).LSU proteome.component RPP1", "mapman_desc": "component RPP1 of LSU proteome component (original description: pep chromosome:TAIR10:1:50090:51187:-1 gene:AT1G01100 transcript:AT1G01100.4 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:RPP1A description:60S acidic ribosomal protein P1-1 [Source:UniProtKB/Swiss-Prot;Acc:Q8LCW9])", "pheno_aragwas_id": "", "pheno_desc1": "", "pheno_desc2": "", "pheno_desc3": "", "pheno_ref": "", "user_notes": ""}, - {"_key": "Na23", "node_type": "pheno", "transcript": "", "gene_symbol": "", "gene_full_name": "", "gene_model_type": "", "tair_computational_desc": "", "tair_curator_summary": "", "tair_short_desc": "", "go_descr": "", "go_terms": [], "mapman_bin": "", "mapman_name": "", "mapman_desc": "", "pheno_aragwas_id": "10.21958/phenotype:5", "pheno_desc1": "Sodium concentrations in leaves, grown in soil. Elemental analysis was performed with an ICP-MS (PerkinElmer). Sample normalized to calculated weights as described in Baxter et al., 2008", "pheno_desc2": "sodium concentration", "pheno_desc3": "The total sodium ion concentration measured in a given volume of a plant or a plant part or plant extract. [GR:pj]", "pheno_ref": "Atwell et. al, Nature 2010", "user_notes": ""}, - {"_key": "SDV", "node_type": "pheno", "transcript": "", "gene_symbol": "", "gene_full_name": "", "gene_model_type": "", "tair_computational_desc": "", "tair_curator_summary": "", "tair_short_desc": "", "go_descr": "", "go_terms": [], "mapman_bin": "", "mapman_name": "", "mapman_desc": "", "pheno_aragwas_id": "10.21958/phenotype:104", "pheno_desc1": "Number of days following stratification to opening of first flower. The experiment was stopped at 200 d, and accessions that had not flowered at that point were assigned a value of 200", "pheno_desc2": "days to flowering trait", "pheno_desc3": "A flowering time trait (TO:0002616)which is the number of days required for an individual flower (PO:0009046), a whole plant (PO:0000003) or a plant population to reach flowering stage (PO:0007616) from a predetermined time point (e.g. the date of seed sowing, seedling transplant, or seedling emergence). [GR:pj, TO:cooperl]", "pheno_ref": "Atwell et. al, Nature 2010", "user_notes": ""} + {"_key": "As2", "node_type": "pheno", "transcript": "", "gene_symbol": "", "gene_full_name": "", "gene_model_type": "", "tair_computational_description": "", "tair_curator_summary": "", "tair_short_description": "", "go_description": "", "go_terms": [], "mapman_bin": "", "mapman_name": "", "mapman_description": "", "pheno_aragwas_id": "10.21958/phenotype:103", "pheno_description": "", "pheno_pto_name": "bacterial disease resistance", "pheno_pto_description": "The resistance exhibited by a plant or a group of plants (population) in response to the disease caused by a bacterial pathogen infection as compared to the susceptible and/or the reference plants of the same species. [GR:pj]", "pheno_ref": "Atwell et. al, Nature 2010", "user_notes": ""}, + {"_key": "As75", "node_type": "pheno", "transcript": "", "gene_symbol": "", "gene_full_name": "", "gene_model_type": "", "tair_computational_description": "", "tair_curator_summary": "", "tair_short_description": "", "go_description": "", "go_terms": [], "mapman_bin": "", "mapman_name": "", "mapman_description": "", "pheno_aragwas_id": "10.21958/phenotype:67", "pheno_description": "Arsenic concentrations in leaves, grown in soil. Elemental analysis was performed with an ICP-MS (PerkinElmer). Sample normalized to calculated weights as described in Baxter et al., 2008", "pheno_pto_name": "arsenic concentration", "pheno_pto_description": "A mineral and ion content related trait (TO:0000465) which is the concentration of arsenic (CHEBI:22632) in some plant structure (PO:0009011). [GR:Karthik]", "pheno_ref": "Atwell et. al, Nature 2010", "user_notes": ""}, + {"_key": "AT1G01010", "node_type": "gene", "transcript": "AT1G01010.1", "gene_symbol": "NTL10", "gene_full_name": "NAC domain containing protein 1", "gene_model_type": "protein_coding", "tair_computational_description": "NAC domain containing protein 1;(source:Araport11)", "tair_curator_summary": "", "tair_short_description": "NAC domain containing protein 1", "go_description": "DNA-binding transcription factor activity, DNA binding", "go_terms": ["GO:0003700", "GO:0003677"], "mapman_bin": "15.5.17", "mapman_name": ".RNA biosynthesis.transcriptional regulation.transcription factor (NAC)", "mapman_description": "transcription factor (NAC) (original description: pep chromosome:TAIR10:1:3631:5899:1 gene:AT1G01010 transcript:AT1G01010.1 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:NAC001 description:NAC domain-containing protein 1 [Source:UniProtKB/Swiss-Prot;Acc:Q0WV96])", "pheno_aragwas_id": "", "pheno_description": "", "pheno_pto_name": "", "pheno_pto_description": "", "pheno_ref": "", "user_notes": ""}, + {"_key": "AT1G01020", "node_type": "gene", "transcript": "AT1G01020.6", "gene_symbol": "ARV1", "gene_full_name": "", "gene_model_type": "protein_coding", "tair_computational_description": "ARV1 family protein;(source:Araport11)", "tair_curator_summary": "", "tair_short_description": "", "go_description": "molecular_function", "go_terms": ["GO:0003674"], "mapman_bin": "35.1", "mapman_name": "not assigned.annotated", "mapman_description": "(original description: pep chromosome:TAIR10:1:6788:8737:-1 gene:AT1G01020 transcript:AT1G01020.6 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:ARV1 description:ARV1 family protein [Source:UniProtKB/TrEMBL;Acc:Q5MK24]) & no description available(sp|q5mk24|arv1_arath : 99.4)", "pheno_aragwas_id": "", "pheno_description": "", "pheno_pto_name": "", "pheno_pto_description": "", "pheno_ref": "", "user_notes": ""}, + {"_key": "AT1G01030", "node_type": "gene", "transcript": "AT1G01030.2", "gene_symbol": "NGA3", "gene_full_name": "NGATHA3", "gene_model_type": "protein_coding", "tair_computational_description": "AP2/B3-like transcriptional factor family protein;(source:Araport11)", "tair_curator_summary": "", "tair_short_description": "", "go_description": "DNA-binding transcription factor activity, DNA binding", "go_terms": ["GO:0003700", "GO:0003677"], "mapman_bin": "15.5.5.3", "mapman_name": ".RNA biosynthesis.transcriptional regulation.B3 transcription factor superfamily.transcription factor (RAV/NGATHA)", "mapman_description": "transcription factor (RAV/NGATHA) (original description: pep chromosome:TAIR10:1:11649:13714:-1 gene:AT1G01030 transcript:AT1G01030.2 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:NGA3 description:B3 domain-containing transcription factor NGA3 [Source:UniProtKB/Swiss-Prot;Acc:Q9MAN1])", "pheno_aragwas_id": "", "pheno_description": "", "pheno_pto_name": "", "pheno_pto_description": "", "pheno_ref": "", "user_notes": ""}, + {"_key": "AT1G01040", "node_type": "gene", "transcript": "AT1G01040.2", "gene_symbol": "SUS1", "gene_full_name": "SUSPENSOR 1", "gene_model_type": "protein_coding", "tair_computational_description": "dicer-like 1;(source:Araport11)", "tair_curator_summary": "Encodes a Dicer homolog. Dicer is a RNA helicase involved in microRNA processing. Mutations in this locus can result in embryo lethality. Embryo shape at seed maturity is globular-elongate. Other mutants convert the floral meristems to an indeterminate state, others yet show defects in ovule development. mRNA is expressed in all shoot tissues. DCL1 is able to produce miRNAs and siRNAs. The mRNA is cell-to-cell mobile.", "tair_short_description": "dicer-like 1", "go_description": "metal ion binding, protein binding, ribonuclease III activity, ATP-dependent helicase activity, ATP binding, RNA binding, helicase activity, double-stranded RNA binding, DNA binding", "go_terms": ["GO:0046872", "GO:0005515", "GO:0004525", "GO:0008026", "GO:0005524", "GO:0003723", "GO:0004386", "GO:0003725", "GO:0003677"], "mapman_bin": "16.10.2.1.1", "mapman_name": ".RNA processing.mRNA silencing.miRNA pathway.DCL1-HYL1 miRNA biogenesis complex.endoribonuclease component DCL1", "mapman_description": "endoribonuclease component DCL1 of DCL1-HYL1 miRNA biogenesis complex (original description: pep chromosome:TAIR10:1:23416:31120:1 gene:AT1G01040 transcript:AT1G01040.2 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:DCL1 description:Dicer-like 1 [Source:UniProtKB/TrEMBL;Acc:F4HQG6])", "pheno_aragwas_id": "", "pheno_description": "", "pheno_pto_name": "", "pheno_pto_description": "", "pheno_ref": "", "user_notes": ""}, + {"_key": "AT1G01050", "node_type": "gene", "transcript": "AT1G01050.2", "gene_symbol": "PPa1", "gene_full_name": "pyrophosphorylase 1", "gene_model_type": "protein_coding", "tair_computational_description": "pyrophosphorylase 1;(source:Araport11)", "tair_curator_summary": "", "tair_short_description": "", "go_description": "inorganic diphosphatase activity", "go_terms": ["GO:0004427"], "mapman_bin": "35.1", "mapman_name": "not assigned.annotated", "mapman_description": "(original description: pep chromosome:TAIR10:1:31382:33009:-1 gene:AT1G01050 transcript:AT1G01050.2 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:PPA1 description:Soluble inorganic pyrophosphatase 1 [Source:UniProtKB/Swiss-Prot;Acc:Q93V56]) & Soluble inorganic pyrophosphatase 1 OS=Arabidopsis thaliana (sp|q93v56|ipyr1_arath : 419.0)", "pheno_aragwas_id": "", "pheno_description": "", "pheno_pto_name": "", "pheno_pto_description": "", "pheno_ref": "", "user_notes": ""}, + {"_key": "AT1G01060", "node_type": "gene", "transcript": "AT1G01060.8", "gene_symbol": "LHY1", "gene_full_name": "LATE ELONGATED HYPOCOTYL 1", "gene_model_type": "protein_coding", "tair_computational_description": "Homeodomain-like superfamily protein;(source:Araport11)", "tair_curator_summary": "", "tair_short_description": "", "go_description": "DNA-binding transcription factor activity, DNA binding, transcription regulatory region DNA binding", "go_terms": ["GO:0003700", "GO:0003677", "GO:0044212"], "mapman_bin": "27.1.1", "mapman_name": ".Multi-process regulation.circadian clock system.core oscillator protein (LHY|CCA1)", "mapman_description": "circadian clock core oscillator protein (LHY|CCA1) (original description: pep chromosome:TAIR10:1:33967:37230:-1 gene:AT1G01060 transcript:AT1G01060.8 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:LHY description:LHY1 [Source:UniProtKB/TrEMBL;Acc:A0A178W761])", "pheno_aragwas_id": "", "pheno_description": "", "pheno_pto_name": "", "pheno_pto_description": "", "pheno_ref": "", "user_notes": ""}, + {"_key": "AT1G01070", "node_type": "gene", "transcript": "AT1G01070.2", "gene_symbol": "UMAMIT28", "gene_full_name": "Usually multiple acids move in and out Transporters 28", "gene_model_type": "protein_coding", "tair_computational_description": "nodulin MtN21 /EamA-like transporter family protein;(source:Araport11)", "tair_curator_summary": "Encodes a plasma membrane-localized amino acid transporter likely involved in amino acid export in the developing seed.", "tair_short_description": "nodulin MtN21 /EamA-like transporter family protein", "go_description": "L-glutamine transmembrane transporter activity", "go_terms": ["GO:0015186"], "mapman_bin": "24.2.1.5", "mapman_name": ".Solute transport.carrier-mediated transport.DMT superfamily.solute transporter (UmamiT)", "mapman_description": "solute transporter (UmamiT) (original description: pep chromosome:TAIR10:1:38752:40945:-1 gene:AT1G01070 transcript:AT1G01070.2 gene_biotype:protein_coding transcript_biotype:protein_coding description:WAT1-related protein [Source:UniProtKB/TrEMBL;Acc:A0A178WFU3])", "pheno_aragwas_id": "", "pheno_description": "", "pheno_pto_name": "", "pheno_pto_description": "", "pheno_ref": "", "user_notes": ""}, + {"_key": "AT1G01080", "node_type": "gene", "transcript": "AT1G01080.3", "gene_symbol": "", "gene_full_name": "", "gene_model_type": "protein_coding", "tair_computational_description": "RNA-binding (RRM/RBD/RNP motifs) family protein;(source:Araport11)", "tair_curator_summary": "", "tair_short_description": "", "go_description": "RNA binding, mRNA binding", "go_terms": ["GO:0003723", "GO:0003729"], "mapman_bin": "35.1", "mapman_name": "not assigned.annotated", "mapman_description": "(original description: pep chromosome:TAIR10:1:44970:47059:-1 gene:AT1G01080 transcript:AT1G01080.3 gene_biotype:protein_coding transcript_biotype:protein_coding description:RNA-binding (RRM/RBD/RNP motifs) family protein [Source:UniProtKB/TrEMBL;Acc:F4HQH8]) & 33 kDa ribonucleoprotein, chloroplastic OS=Nicotiana sylvestris (sp|p19684|roc5_nicsy : 109.0)", "pheno_aragwas_id": "", "pheno_description": "", "pheno_pto_name": "", "pheno_pto_description": "", "pheno_ref": "", "user_notes": ""}, + {"_key": "AT1G01090", "node_type": "gene", "transcript": "AT1G01090.1", "gene_symbol": "PDH-E1 ALPHA", "gene_full_name": "pyruvate dehydrogenase E1 alpha", "gene_model_type": "protein_coding", "tair_computational_description": "pyruvate dehydrogenase E1 alpha;(source:Araport11)", "tair_curator_summary": "pyruvate dehydrogenase E1 alpha subunit", "tair_short_description": "pyruvate dehydrogenase E1 alpha", "go_description": "pyruvate dehydrogenase (acetyl-transferring) activity, protein binding", "go_terms": ["GO:0004739", "GO:0005515"], "mapman_bin": "5.1.2.2.1.1", "mapman_name": ".Lipid metabolism.fatty acid biosynthesis.acetyl-CoA generation.plastidial pyruvate dehydrogenase complex.E1 pyruvate dehydrogenase subcomplex.subunit alpha", "mapman_description": "subunit alpha of E1 pyruvate dehydrogenase component (original description: pep chromosome:TAIR10:1:47234:49304:-1 gene:AT1G01090 transcript:AT1G01090.1 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:PDH-E1 ALPHA description:Pyruvate dehydrogenase E1 component subunit alpha [Source:UniProtKB/TrEMBL;Acc:A0A178W8A7])", "pheno_aragwas_id": "", "pheno_description": "", "pheno_pto_name": "", "pheno_pto_description": "", "pheno_ref": "", "user_notes": ""}, + {"_key": "AT1G01100", "node_type": "gene", "transcript": "AT1G01100.4", "gene_symbol": "", "gene_full_name": "", "gene_model_type": "protein_coding", "tair_computational_description": "60S acidic ribosomal protein family;(source:Araport11)", "tair_curator_summary": "", "tair_short_description": "60S acidic ribosomal protein family", "go_description": "structural constituent of ribosome, ribonucleoprotein complex binding, protein kinase activator activity", "go_terms": ["GO:0003735", "GO:0043021", "GO:0030295"], "mapman_bin": "17.1.2.1.46", "mapman_name": ".Protein biosynthesis.ribosome biogenesis.large ribosomal subunit (LSU).LSU proteome.component RPP1", "mapman_description": "component RPP1 of LSU proteome component (original description: pep chromosome:TAIR10:1:50090:51187:-1 gene:AT1G01100 transcript:AT1G01100.4 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:RPP1A description:60S acidic ribosomal protein P1-1 [Source:UniProtKB/Swiss-Prot;Acc:Q8LCW9])", "pheno_aragwas_id": "", "pheno_description": "", "pheno_pto_name": "", "pheno_pto_description": "", "pheno_ref": "", "user_notes": ""}, + {"_key": "Na23", "node_type": "pheno", "transcript": "", "gene_symbol": "", "gene_full_name": "", "gene_model_type": "", "tair_computational_description": "", "tair_curator_summary": "", "tair_short_description": "", "go_description": "", "go_terms": [], "mapman_bin": "", "mapman_name": "", "mapman_description": "", "pheno_aragwas_id": "10.21958/phenotype:5", "pheno_description": "Sodium concentrations in leaves, grown in soil. Elemental analysis was performed with an ICP-MS (PerkinElmer). Sample normalized to calculated weights as described in Baxter et al., 2008", "pheno_pto_name": "sodium concentration", "pheno_pto_description": "The total sodium ion concentration measured in a given volume of a plant or a plant part or plant extract. [GR:pj]", "pheno_ref": "Atwell et. al, Nature 2010", "user_notes": ""}, + {"_key": "SDV", "node_type": "pheno", "transcript": "", "gene_symbol": "", "gene_full_name": "", "gene_model_type": "", "tair_computational_description": "", "tair_curator_summary": "", "tair_short_description": "", "go_description": "", "go_terms": [], "mapman_bin": "", "mapman_name": "", "mapman_description": "", "pheno_aragwas_id": "10.21958/phenotype:104", "pheno_description": "Number of days following stratification to opening of first flower. The experiment was stopped at 200 d, and accessions that had not flowered at that point were assigned a value of 200", "pheno_pto_name": "days to flowering trait", "pheno_pto_description": "A flowering time trait (TO:0002616)which is the number of days required for an individual flower (PO:0009046), a whole plant (PO:0000003) or a plant population to reach flowering stage (PO:0007616) from a predetermined time point (e.g. the date of seed sowing, seedling transplant, or seedling emergence). [GR:pj, TO:cooperl]", "pheno_ref": "Atwell et. al, Nature 2010", "user_notes": ""} ] }, "fetch_all": { diff --git a/spec/test/djornl/test_data/I2_named.tsv b/spec/test/djornl/test_data/I2_named.tsv new file mode 100644 index 00000000..3f129851 --- /dev/null +++ b/spec/test/djornl/test_data/I2_named.tsv @@ -0,0 +1,9 @@ +cluster ids +# data_type: cluster +# cluster_prefix: markov_i2 +# title: Markov clustering, inflation = 2 +Cluster1 AT1G01010,AT1G01030,AT1G01040 +Cluster2 AT1G01050,AT1G01060,AT1G01070 +Cluster3 AT1G01080,AT1G01090 +Cluster4 +Cluster5 AT1G01020 diff --git a/spec/test/djornl/test_data/I4_named.tsv b/spec/test/djornl/test_data/I4_named.tsv new file mode 100644 index 00000000..39e46deb --- /dev/null +++ b/spec/test/djornl/test_data/I4_named.tsv @@ -0,0 +1,4 @@ +cluster ids +# cluster_prefix: markov_i4 +# title: Markov clustering, inflation = 4 +# data_type: cluster diff --git a/spec/test/djornl/test_data/I6_named.tsv b/spec/test/djornl/test_data/I6_named.tsv new file mode 100644 index 00000000..d504f6b4 --- /dev/null +++ b/spec/test/djornl/test_data/I6_named.tsv @@ -0,0 +1,8 @@ +cluster ids +# data_type: cluster +# cluster_prefix: markov_i6 +# title: Markov clustering, inflation = 6 +Cluster1 AT1G01040,AT1G01090 +Cluster2 AT1G01070 +Cluster3 AT1G01010,AT1G01020,AT1G01030 +Cluster4 diff --git a/spec/test/djornl/test_data/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I2_named.tsv b/spec/test/djornl/test_data/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I2_named.tsv deleted file mode 100644 index 086a9209..00000000 --- a/spec/test/djornl/test_data/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I2_named.tsv +++ /dev/null @@ -1,5 +0,0 @@ -Cluster1 AT1G01010 AT1G01030 AT1G01040 -Cluster2 AT1G01050 AT1G01060 AT1G01070 -Cluster3 AT1G01080 AT1G01090 -Cluster4 -Cluster5 AT1G01020 diff --git a/spec/test/djornl/test_data/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I4_named.tsv b/spec/test/djornl/test_data/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I4_named.tsv deleted file mode 100644 index 8b137891..00000000 --- a/spec/test/djornl/test_data/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I4_named.tsv +++ /dev/null @@ -1 +0,0 @@ - diff --git a/spec/test/djornl/test_data/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I6_named.tsv b/spec/test/djornl/test_data/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I6_named.tsv deleted file mode 100644 index 389cae2e..00000000 --- a/spec/test/djornl/test_data/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I6_named.tsv +++ /dev/null @@ -1,4 +0,0 @@ -Cluster1 AT1G01040 AT1G01090 -Cluster2 AT1G01070 -Cluster3 AT1G01010 AT1G01020 AT1G01030 -Cluster4 diff --git a/spec/test/djornl/test_data/merged_edges-AMW-060820_AF.tsv b/spec/test/djornl/test_data/edges.tsv similarity index 80% rename from spec/test/djornl/test_data/merged_edges-AMW-060820_AF.tsv rename to spec/test/djornl/test_data/edges.tsv index 44acc6ff..ee443140 100644 --- a/spec/test/djornl/test_data/merged_edges-AMW-060820_AF.tsv +++ b/spec/test/djornl/test_data/edges.tsv @@ -2,8 +2,6 @@ node1 node2 edge edge_descrip layer_descrip As2 AT1G01020 8.4 AraGWAS-Association_score AraGWAS-Phenotype_Associations As2 AT1G01040 5.4 AraGWAS-Association_score AraGWAS-Phenotype_Associations As75 AT1G01020 39.9 AraGWAS-Association_score AraGWAS-Phenotype_Associations -AT1G01010 AT1G01020 2.3 AraNetv2_log-likelihood-score AraNetv2-HT_high-throughput-ppi -AT1G01010 AT1G01030 2.4 AraNetv2_log-likelihood-score AraNetv2-HT_high-throughput-ppi AT1G01010 AT1G01040 2.5 AraNetv2_log-likelihood-score AraNetv2-DC_domain-co-occurrence AT1G01010 AT1G01040 170.5 AraNetv2_log-likelihood-score AraNetv2-LC_lit-curated-ppi AT1G01030 AT1G01050 2.6 AraNetv2_log-likelihood-score AraNetv2-CX_pairwise-gene-coexpression diff --git a/spec/test/djornl/test_data/extra_node.tsv b/spec/test/djornl/test_data/extra_node.tsv new file mode 100644 index 00000000..664425c5 --- /dev/null +++ b/spec/test/djornl/test_data/extra_node.tsv @@ -0,0 +1,3 @@ +# data_type: node +node_id node_type transcript gene_symbol gene_full_name gene_model_type TAIR_Computational_description TAIR_Curator_summary TAIR_short_description GO_descr GO_terms MapMan_bin MapMan_name MapMan_descr pheno_AraGWAS_ID pheno_descrip1 pheno_descrip2 pheno_descrip3 pheno_ref User_Notes +AT1G01100 gene AT1G01100.4 protein_coding 60S acidic ribosomal protein family;(source:Araport11) 60S acidic ribosomal protein family structural constituent of ribosome, ribonucleoprotein complex binding, protein kinase activator activity GO:0003735, GO:0043021, GO:0030295 17.1.2.1.46 .Protein biosynthesis.ribosome biogenesis.large ribosomal subunit (LSU).LSU proteome.component RPP1 component RPP1 of LSU proteome component (original description: pep chromosome:TAIR10:1:50090:51187:-1 gene:AT1G01100 transcript:AT1G01100.4 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:RPP1A description:60S acidic ribosomal protein P1-1 [Source:UniProtKB/Swiss-Prot;Acc:Q8LCW9]) diff --git a/spec/test/djornl/test_data/hithruput-edges.csv b/spec/test/djornl/test_data/hithruput-edges.csv new file mode 100644 index 00000000..586476ab --- /dev/null +++ b/spec/test/djornl/test_data/hithruput-edges.csv @@ -0,0 +1,3 @@ +node1,node2,edge,edge_descrip,layer_descrip +AT1G01010,AT1G01020,2.3,AraNetv2_log-likelihood-score,AraNetv2-HT_high-throughput-ppi +AT1G01010,AT1G01030,2.4,AraNetv2_log-likelihood-score,AraNetv2-HT_high-throughput-ppi diff --git a/spec/test/djornl/test_data/manifest.yaml b/spec/test/djornl/test_data/manifest.yaml new file mode 100644 index 00000000..1762a86d --- /dev/null +++ b/spec/test/djornl/test_data/manifest.yaml @@ -0,0 +1,35 @@ +name: Dan Jacobson Exascale data +release_date: "2020-06-06" +home_url: "https://github.com/kbase/exascale_data" +file_list: + - data_type: edge + path: edges.tsv + date: "2020-12-25" + + - data_type: edge + path: hithruput-edges.csv + date: "2020-12-25" + + - data_type: node + path: nodes.csv + date: "2019-01-01" + + - data_type: cluster + cluster_prefix: markov_i2 + path: I2_named.tsv + + - data_type: cluster + cluster_prefix: markov_i4 + path: I4_named.tsv + + - data_type: cluster + cluster_prefix: markov_i6 + path: I6_named.tsv + + - data_type: node + path: pheno_nodes.csv + date: "2019-01-01" + + - data_type: node + path: extra_node.tsv + date: "2019-01-01" diff --git a/spec/test/djornl/test_data/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv b/spec/test/djornl/test_data/nodes.csv similarity index 72% rename from spec/test/djornl/test_data/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv rename to spec/test/djornl/test_data/nodes.csv index 5bc0e1d8..2245bd59 100644 --- a/spec/test/djornl/test_data/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv +++ b/spec/test/djornl/test_data/nodes.csv @@ -1,6 +1,5 @@ -node_id,node_type,transcript,gene_symbol,gene_full_name,gene_model_type,TAIR_Computational_description,TAIR_Curator_summary,TAIR_short_description,GO_descr,GO_terms,MapMan_bin,MapMan_name,MapMan_descr,pheno_AraGWAS_ID,pheno_descrip1,pheno_descrip2,pheno_descrip3,pheno_ref,UserNotes -As2,pheno,,,,,,,,,,,,,10.21958/phenotype:103,,bacterial disease resistance,The resistance exhibited by a plant or a group of plants (population) in response to the disease caused by a bacterial pathogen infection as compared to the susceptible and/or the reference plants of the same species. [GR:pj],"Atwell et. al, Nature 2010", -As75,pheno,,,,,,,,,,,,,10.21958/phenotype:67,"Arsenic concentrations in leaves, grown in soil. Elemental analysis was performed with an ICP-MS (PerkinElmer). Sample normalized to calculated weights as described in Baxter et al., 2008",arsenic concentration,A mineral and ion content related trait (TO:0000465) which is the concentration of arsenic (CHEBI:22632) in some plant structure (PO:0009011). [GR:Karthik],"Atwell et. al, Nature 2010", +# data_type: node +node_id,node_type,transcript,gene_symbol,gene_full_name,gene_model_type,TAIR_Computational_description,TAIR_Curator_summary,TAIR_short_description,GO_descr,GO_terms,MapMan_bin,MapMan_name,MapMan_descr,pheno_AraGWAS_ID,pheno_descrip1,pheno_descrip2,pheno_descrip3,pheno_ref,User_Notes AT1G01010,gene,AT1G01010.1,NTL10,NAC domain containing protein 1,protein_coding,NAC domain containing protein 1;(source:Araport11),,NAC domain containing protein 1,"DNA-binding transcription factor activity, DNA binding","GO:0003700, GO:0003677",15.5.17,.RNA biosynthesis.transcriptional regulation.transcription factor (NAC),transcription factor (NAC) (original description: pep chromosome:TAIR10:1:3631:5899:1 gene:AT1G01010 transcript:AT1G01010.1 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:NAC001 description:NAC domain-containing protein 1 [Source:UniProtKB/Swiss-Prot;Acc:Q0WV96]),,,,,, AT1G01020,gene,AT1G01020.6,ARV1,,protein_coding,ARV1 family protein;(source:Araport11),,,molecular_function,GO:0003674,35.1,not assigned.annotated,(original description: pep chromosome:TAIR10:1:6788:8737:-1 gene:AT1G01020 transcript:AT1G01020.6 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:ARV1 description:ARV1 family protein [Source:UniProtKB/TrEMBL;Acc:Q5MK24]) & no description available(sp|q5mk24|arv1_arath : 99.4),,,,,, AT1G01030,gene,AT1G01030.2,NGA3,NGATHA3,protein_coding,AP2/B3-like transcriptional factor family protein;(source:Araport11),,,"DNA-binding transcription factor activity, DNA binding","GO:0003700, GO:0003677",15.5.5.3,.RNA biosynthesis.transcriptional regulation.B3 transcription factor superfamily.transcription factor (RAV/NGATHA),transcription factor (RAV/NGATHA) (original description: pep chromosome:TAIR10:1:11649:13714:-1 gene:AT1G01030 transcript:AT1G01030.2 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:NGA3 description:B3 domain-containing transcription factor NGA3 [Source:UniProtKB/Swiss-Prot;Acc:Q9MAN1]),,,,,, @@ -10,6 +9,3 @@ AT1G01060,gene,AT1G01060.8,LHY1,LATE ELONGATED HYPOCOTYL 1,protein_coding,Homeod AT1G01070,gene,AT1G01070.2,UMAMIT28,Usually multiple acids move in and out Transporters 28,protein_coding,nodulin MtN21 /EamA-like transporter family protein;(source:Araport11),Encodes a plasma membrane-localized amino acid transporter likely involved in amino acid export in the developing seed.,nodulin MtN21 /EamA-like transporter family protein,L-glutamine transmembrane transporter activity,GO:0015186,24.2.1.5,.Solute transport.carrier-mediated transport.DMT superfamily.solute transporter (UmamiT),solute transporter (UmamiT) (original description: pep chromosome:TAIR10:1:38752:40945:-1 gene:AT1G01070 transcript:AT1G01070.2 gene_biotype:protein_coding transcript_biotype:protein_coding description:WAT1-related protein [Source:UniProtKB/TrEMBL;Acc:A0A178WFU3]),,,,,, AT1G01080,gene,AT1G01080.3,,,protein_coding,RNA-binding (RRM/RBD/RNP motifs) family protein;(source:Araport11),,,"RNA binding, mRNA binding","GO:0003723, GO:0003729",35.1,not assigned.annotated,"(original description: pep chromosome:TAIR10:1:44970:47059:-1 gene:AT1G01080 transcript:AT1G01080.3 gene_biotype:protein_coding transcript_biotype:protein_coding description:RNA-binding (RRM/RBD/RNP motifs) family protein [Source:UniProtKB/TrEMBL;Acc:F4HQH8]) & 33 kDa ribonucleoprotein, chloroplastic OS=Nicotiana sylvestris (sp|p19684|roc5_nicsy : 109.0)",,,,,, AT1G01090,gene,AT1G01090.1,PDH-E1 ALPHA,pyruvate dehydrogenase E1 alpha,protein_coding,pyruvate dehydrogenase E1 alpha;(source:Araport11),pyruvate dehydrogenase E1 alpha subunit,pyruvate dehydrogenase E1 alpha,"pyruvate dehydrogenase (acetyl-transferring) activity, protein binding","GO:0004739, GO:0005515",5.1.2.2.1.1,.Lipid metabolism.fatty acid biosynthesis.acetyl-CoA generation.plastidial pyruvate dehydrogenase complex.E1 pyruvate dehydrogenase subcomplex.subunit alpha,subunit alpha of E1 pyruvate dehydrogenase component (original description: pep chromosome:TAIR10:1:47234:49304:-1 gene:AT1G01090 transcript:AT1G01090.1 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:PDH-E1 ALPHA description:Pyruvate dehydrogenase E1 component subunit alpha [Source:UniProtKB/TrEMBL;Acc:A0A178W8A7]),,,,,, -AT1G01100,gene,AT1G01100.4,,,protein_coding,60S acidic ribosomal protein family;(source:Araport11),,60S acidic ribosomal protein family,"structural constituent of ribosome, ribonucleoprotein complex binding, protein kinase activator activity","GO:0003735, GO:0043021, GO:0030295",17.1.2.1.46,.Protein biosynthesis.ribosome biogenesis.large ribosomal subunit (LSU).LSU proteome.component RPP1,component RPP1 of LSU proteome component (original description: pep chromosome:TAIR10:1:50090:51187:-1 gene:AT1G01100 transcript:AT1G01100.4 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:RPP1A description:60S acidic ribosomal protein P1-1 [Source:UniProtKB/Swiss-Prot;Acc:Q8LCW9]),,,,,, -Na23,pheno,,,,,,,,,,,,,10.21958/phenotype:5,"Sodium concentrations in leaves, grown in soil. Elemental analysis was performed with an ICP-MS (PerkinElmer). Sample normalized to calculated weights as described in Baxter et al., 2008",sodium concentration,The total sodium ion concentration measured in a given volume of a plant or a plant part or plant extract. [GR:pj],"Atwell et. al, Nature 2010", -SDV,pheno,,,,,,,,,,,,,10.21958/phenotype:104,"Number of days following stratification to opening of first flower. The experiment was stopped at 200 d, and accessions that had not flowered at that point were assigned a value of 200",days to flowering trait,"A flowering time trait (TO:0002616)which is the number of days required for an individual flower (PO:0009046), a whole plant (PO:0000003) or a plant population to reach flowering stage (PO:0007616) from a predetermined time point (e.g. the date of seed sowing, seedling transplant, or seedling emergence). [GR:pj, TO:cooperl]","Atwell et. al, Nature 2010", diff --git a/spec/test/djornl/test_data/pheno_nodes.csv b/spec/test/djornl/test_data/pheno_nodes.csv new file mode 100644 index 00000000..d8bb15a9 --- /dev/null +++ b/spec/test/djornl/test_data/pheno_nodes.csv @@ -0,0 +1,5 @@ +node_id,node_type,transcript,gene_symbol,gene_full_name,gene_model_type,TAIR_Computational_description,TAIR_Curator_summary,TAIR_short_description,GO_descr,GO_terms,MapMan_bin,MapMan_name,MapMan_descr,pheno_AraGWAS_ID,pheno_descrip1,pheno_descrip2,pheno_descrip3,pheno_ref,User_Notes +As2,pheno,,,,,,,,,,,,,10.21958/phenotype:103,,bacterial disease resistance,The resistance exhibited by a plant or a group of plants (population) in response to the disease caused by a bacterial pathogen infection as compared to the susceptible and/or the reference plants of the same species. [GR:pj],"Atwell et. al, Nature 2010", +As75,pheno,,,,,,,,,,,,,10.21958/phenotype:67,"Arsenic concentrations in leaves, grown in soil. Elemental analysis was performed with an ICP-MS (PerkinElmer). Sample normalized to calculated weights as described in Baxter et al., 2008",arsenic concentration,A mineral and ion content related trait (TO:0000465) which is the concentration of arsenic (CHEBI:22632) in some plant structure (PO:0009011). [GR:Karthik],"Atwell et. al, Nature 2010", +Na23,pheno,,,,,,,,,,,,,10.21958/phenotype:5,"Sodium concentrations in leaves, grown in soil. Elemental analysis was performed with an ICP-MS (PerkinElmer). Sample normalized to calculated weights as described in Baxter et al., 2008",sodium concentration,The total sodium ion concentration measured in a given volume of a plant or a plant part or plant extract. [GR:pj],"Atwell et. al, Nature 2010", +SDV,pheno,,,,,,,,,,,,,10.21958/phenotype:104,"Number of days following stratification to opening of first flower. The experiment was stopped at 200 d, and accessions that had not flowered at that point were assigned a value of 200",days to flowering trait,"A flowering time trait (TO:0002616)which is the number of days required for an individual flower (PO:0009046), a whole plant (PO:0000003) or a plant population to reach flowering stage (PO:0007616) from a predetermined time point (e.g. the date of seed sowing, seedling transplant, or seedling emergence). [GR:pj, TO:cooperl]","Atwell et. al, Nature 2010", diff --git a/spec/test/djornl/valid_manifest/no_file_ext.yaml b/spec/test/djornl/valid_manifest/no_file_ext.yaml new file mode 100644 index 00000000..3120e553 --- /dev/null +++ b/spec/test/djornl/valid_manifest/no_file_ext.yaml @@ -0,0 +1,40 @@ +# nodes does not have a file extension, so file format must be used +name: Dan Jacobson Exascale data +release_date: "2020-08-06" +description: Preliminary Jacobson dataset +file_list: + - data_type: edge + path: merged_edges-AMW-060820_AF.tsv + file_format: tsv + description: Merged edge data. AraGWAS phenotype-GWAS layer has an FDR filter was applied, removing some of the edges. The Aranetv2 coexpression layer network contains the top (highest log-likelihood scores) 15% coexpression edges to compensate for the decreased network size of the phenotype-GWAS layer. + date_created: "2020-06-08" + + - data_type: node + path: nodes + file_format: csv + description: Merged AraNet AraGWAS gene and phenotype data + date_created: "2019-09-13" + + - data_type: cluster + cluster_prefix: markov_i2 + path: cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I2_named.tsv + file_format: tsv + title: Markov clustering, inflation 2 + description: Iterative random forest Markov clustering, inflation set to 2 + date_created: "2019-08-19" + + - data_type: cluster + cluster_prefix: markov_i4 + path: cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I4_named.tsv + file_format: tsv + title: Markov clustering, inflation 4 + description: Iterative random forest Markov clustering, inflation set to 4 + date_created: "2019-08-19" + + - data_type: cluster + cluster_prefix: markov_i6 + path: cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I6_named.tsv + file_format: tsv + title: Markov clustering, inflation 6 + description: Iterative random forest Markov clustering, inflation set to 6 + date_created: "2019-08-19" diff --git a/spec/test/djornl/valid_manifest/no_file_format.yaml b/spec/test/djornl/valid_manifest/no_file_format.yaml new file mode 100644 index 00000000..d3010deb --- /dev/null +++ b/spec/test/djornl/valid_manifest/no_file_format.yaml @@ -0,0 +1,39 @@ +# node file has no format specified, so the path must be parsed +name: Dan Jacobson Exascale data +release_date: "2020-08-06" +description: Preliminary Jacobson dataset +file_list: + - data_type: edge + path: merged_edges-AMW-060820_AF.tsv + file_format: tsv + description: Merged edge data. AraGWAS phenotype-GWAS layer has an FDR filter was applied, removing some of the edges. The Aranetv2 coexpression layer network contains the top (highest log-likelihood scores) 15% coexpression edges to compensate for the decreased network size of the phenotype-GWAS layer. + date_created: "2020-06-08" + + - data_type: node + path: nodes.csv + description: Merged AraNet AraGWAS gene and phenotype data + date_created: "2019-09-13" + + - data_type: cluster + cluster_prefix: markov_i2 + path: cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I2_named.tsv + file_format: tsv + title: Markov clustering, inflation 2 + description: Iterative random forest Markov clustering, inflation set to 2 + date_created: "2019-08-19" + + - data_type: cluster + cluster_prefix: markov_i4 + path: cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I4_named.tsv + file_format: tsv + title: Markov clustering, inflation 4 + description: Iterative random forest Markov clustering, inflation set to 4 + date_created: "2019-08-19" + + - data_type: cluster + cluster_prefix: markov_i6 + path: cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I6_named.tsv + file_format: tsv + title: Markov clustering, inflation 6 + description: Iterative random forest Markov clustering, inflation set to 6 + date_created: "2019-08-19" diff --git a/spec/test/djornl/valid_manifest/with_descriptions.yaml b/spec/test/djornl/valid_manifest/with_descriptions.yaml new file mode 100644 index 00000000..6c39a234 --- /dev/null +++ b/spec/test/djornl/valid_manifest/with_descriptions.yaml @@ -0,0 +1,39 @@ +name: Dan Jacobson Exascale data +release_date: "2020-08-06" +description: Preliminary Jacobson dataset +file_list: + - data_type: edge + path: merged_edges-AMW-060820_AF.tsv + file_format: tsv + description: Merged edge data. AraGWAS phenotype-GWAS layer has an FDR filter was applied, removing some of the edges. The Aranetv2 coexpression layer network contains the top (highest log-likelihood scores) 15% coexpression edges to compensate for the decreased network size of the phenotype-GWAS layer. + date_created: "2020-06-08" + + - data_type: node + path: aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv + file_format: csv + description: Merged AraNet AraGWAS gene and phenotype data + date_created: "2019-09-13" + + - data_type: cluster + cluster_prefix: markov_i2 + path: cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I2_named.tsv + file_format: tsv + title: Markov clustering, inflation 2 + description: Iterative random forest Markov clustering, inflation set to 2 + date_created: "2019-08-19" + + - data_type: cluster + cluster_prefix: markov_i4 + path: cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I4_named.tsv + file_format: tsv + title: Markov clustering, inflation 4 + description: Iterative random forest Markov clustering, inflation set to 4 + date_created: "2019-08-19" + + - data_type: cluster + cluster_prefix: markov_i6 + path: cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I6_named.tsv + file_format: tsv + title: Markov clustering, inflation 6 + description: Iterative random forest Markov clustering, inflation set to 6 + date_created: "2019-08-19" diff --git a/spec/test/stored_queries/test_djornl.py b/spec/test/stored_queries/test_djornl.py index 8e492fbe..cde4d0c2 100644 --- a/spec/test/stored_queries/test_djornl.py +++ b/spec/test/stored_queries/test_djornl.py @@ -40,8 +40,8 @@ def setUpClass(cls): root_path = os.path.join(_TEST_DIR, 'djornl', 'test_data') with modified_environ(RES_ROOT_DATA_PATH=root_path): parser = DJORNL_Parser() - node_name = parser.config('_NODE_NAME') - edge_name = parser.config('_EDGE_NAME') + node_name = parser.config('node_name') + edge_name = parser.config('edge_name') edge_data = parser.load_edges() r = create_test_docs(node_name, edge_data['nodes']) diff --git a/spec/test/test_manifest_schema.py b/spec/test/test_manifest_schema.py new file mode 100644 index 00000000..4237624d --- /dev/null +++ b/spec/test/test_manifest_schema.py @@ -0,0 +1,82 @@ +""" +Tests for manifest.schema.json + +Ensure that the manifest schema correctly validates data +""" +import unittest +import os.path as os_path +from relation_engine_server.utils.json_validation import run_validator +from jsonschema.exceptions import ValidationError + +schema_file = os_path.join('/app', 'spec', 'datasets', 'djornl', 'manifest.schema.json') +_TEST_DIR = os_path.join('/app', 'spec', 'test', 'djornl') + + +class Test_Manifest_Schema(unittest.TestCase): + + def test_load_invalid_manifest(self): + """ test an invalid manifest file """ + + invalid_dir = os_path.join(_TEST_DIR, 'invalid_manifest') + + error_list = [ + { + # no file list provided + 'file': 'no_file_list', + 'msg': "'file_list' is a required property", + }, + { + # a cluster file entry should have a prefix + 'file': 'cluster_no_prefix', + 'msg': r"{'data_type': 'cluster', 'path': 'I2_named.tsv'} is not valid under any of the given schemas", + }, + { + # each file_list entry has to have a path + 'file': 'missing_path', + 'msg': "'path' is a required property", + }, + { + # if the date is not quoted, pyyaml will turn it into a date object. Doh! + 'file': 'date_not_in_quotes', + 'msg': "datetime.date\(2020, 12, 25\) is not of type 'string'", + }, + { + # file format is invalid + 'file': 'invalid_format', + 'msg': "'txt' is not one of \['tsv', 'csv'\]" + }, + { + # there must be an indicator of file format + 'file': 'no_file_format', + 'msg': r"{'data_type': 'edge', 'date': '2020-12-25', 'path': 'edge_data'}" + + " is not valid under any of the given schemas", + }, + ] + + for entry in error_list: + data_file = os_path.join(invalid_dir, entry['file'] + '.yaml') + print('looking at ' + data_file) + + with self.assertRaisesRegex(ValidationError, entry['msg']): + run_validator( + schema_file=schema_file, + data_file=data_file, + nicer_errors=True + ) + + def test_load_valid_manifests(self): + + valid_dir = os_path.join(_TEST_DIR, 'valid_manifest') + file_list = ['with_descriptions', 'no_file_ext', 'no_file_format'] + + for file in file_list: + data_file = os_path.join(valid_dir, file + '.yaml') + print('looking at ' + data_file) + + self.assertTrue( + run_validator( + schema_file=schema_file, + data_file=data_file, + nicer_errors=True + ) + ) diff --git a/spec/views/djornl/djornl_node_view.json b/spec/views/djornl/djornl_node_view.json index 7330fd3a..2287f615 100644 --- a/spec/views/djornl/djornl_node_view.json +++ b/spec/views/djornl/djornl_node_view.json @@ -19,19 +19,19 @@ ], "fields": { "transcript": {}, - "tair_computational_desc": { + "tair_computational_description": { "analyzers": [ "text_en" ] }, - "tair_short_desc": { + "tair_short_description": { "analyzers": [ "text_en" ] }, "gene_model_type": {}, "go_terms": {}, - "go_desc": { + "go_description": { "analyzers": [ "text_en" ] @@ -41,22 +41,22 @@ "text_en" ] }, - "mapman_desc": { + "mapman_description": { "analyzers": [ "text_en" ] }, - "pheno_desc1": { + "pheno_description": { "analyzers": [ "text_en" ] }, - "pheno_desc2": { + "pheno_pto_name": { "analyzers": [ "text_en" ] }, - "pheno_desc3": { + "pheno_pto_description": { "analyzers": [ "text_en" ] From b2357f1e580c2b98cfc7242952ed35a62febd66f Mon Sep 17 00:00:00 2001 From: ialarmedalien Date: Thu, 20 Aug 2020 16:12:29 -0700 Subject: [PATCH 561/732] Update changelog to use Keep a Changelog format --- CHANGELOG.md | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ad4fa3fc..ad51ca09 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,23 +1,33 @@ -## 0.0.6 +# Changelog for kbase/relation_engine -### `relation_engine_server` +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [0.0.6] - 2020-08-20 + +### Added - `relation_engine_server/api_versions/api_v1.py`: add and/or document API endpoints: - - /api/v1/specs/stored_queries - - /api/v1/specs/data_sources + - `/api/v1/specs/stored_queries` + - `/api/v1/specs/data_sources` +- `spec/datasets`: new directory for dataset-specific schemas, e.g. DJORNL parser manifest, `spec/datasets/djornl/manifest.schema.json` +- `spec/test/test_manifest_schema.py`: to test the manifest schema against example input +- `importers/djornl/parser.py`: use manifest file to specify the files to be parsed and loaded into ArangoDB -- `relation_engine_server/utils/spec_loader.py`: refactor to return a schema or the path to a schema file +### Changed -### `importers` +- `relation_engine_server/utils/spec_loader.py`: refactor to return a schema or the path to a schema file +- `importers/djornl/parser.py`: refactor parsing code to be more flexible and parse multiple files +- `spec/collections/djornl/*`, `spec/stored_queries/djornl/*`, `spec/views/djornl/*`, and `spec/test/djornl`: rename DB fields and headers in test files -- `importers/djornl`: use manifest file to specify the list of files to be parsed to create a dataset. Refactor file parsing for more flexibility. +### Removed -### `spec` +- `spec/test/djornl`: delete unneeded test files -- add `datasets` folder for dataset-specific schemas ----- -## 0.0.5 +## [0.0.5] Last release with RE components in two repositories, https://github.com/kbase/relation_engine_api and https://github.com/kbase/relation_engine_spec From 541dd4e08b953ea83022f6380401c38425ee850c Mon Sep 17 00:00:00 2001 From: ialarmedalien Date: Wed, 26 Aug 2020 17:01:41 -0700 Subject: [PATCH 562/732] Refactor parsing method to be more generic Refactor spec files to use a definitions file Add tests for duplicated data --- importers/djornl/parser.py | 345 +++++++++++------- importers/test/test_djornl_parser.py | 106 +++++- relation_engine_server/utils/bulk_import.py | 6 +- spec/collections/djornl/djornl_edge.yaml | 36 +- spec/collections/djornl/djornl_node.yaml | 5 +- spec/datasets/djornl/csv_cluster.yaml | 15 + spec/datasets/djornl/csv_edge.yaml | 23 ++ spec/datasets/djornl/csv_node.yaml | 52 +++ spec/datasets/djornl/definitions.yaml | 129 +++++++ spec/datasets/djornl/edge_type.yaml | 25 ++ spec/datasets/djornl/node_type.yaml | 10 + ...aragwas-MERGED-AMW-v2_091319_nodeTable.csv | 2 +- spec/test/djornl/duplicate_data/I2_named.tsv | 9 + spec/test/djornl/duplicate_data/I4_named.tsv | 8 + spec/test/djornl/duplicate_data/I6_copy.csv | 8 + spec/test/djornl/duplicate_data/I6_named.tsv | 8 + spec/test/djornl/duplicate_data/edges.tsv | 11 + .../test/djornl/duplicate_data/extra_node.tsv | 5 + .../djornl/duplicate_data/hithruput-edges.csv | 9 + spec/test/djornl/duplicate_data/manifest.yaml | 39 ++ spec/test/djornl/duplicate_data/nodes.csv | 13 + .../djornl/duplicate_data/pheno_nodes.csv | 5 + ...aragwas-MERGED-AMW-v2_091319_nodeTable.csv | 2 +- .../empty_files/cluster_data/comment_only.tsv | 1 + .../empty_files/cluster_data/headers_only.tsv | 4 + ...082919.abc.I2_named.tsv => no_content.tsv} | 0 ...p10percent_anno_AF_082919.abc.I4_named.tsv | 1 - ...p10percent_anno_AF_082919.abc.I6_named.tsv | 1 - spec/test/djornl/empty_files/manifest.yaml | 6 +- .../merged_edges-AMW-060820_AF.tsv | 5 +- spec/test/djornl/invalid_types/edges.tsv | 10 + spec/test/djornl/invalid_types/manifest.yaml | 8 +- .../djornl/invalid_types/markov2_named.tsv | 9 + .../merged_edges-AMW-060820_AF.tsv | 10 - ...-AMW-v2_091319_nodeTable.csv => nodes.csv} | 2 +- spec/test/djornl/results.json | 218 +++++------ spec/test/djornl/test_data/I2_named.tsv | 5 +- spec/test/djornl/test_data/I4_named.tsv | 3 +- spec/test/djornl/test_data/I6_named.tsv | 4 +- spec/test/djornl/test_data/extra_node.tsv | 4 +- spec/test/djornl/test_data/nodes.csv | 2 +- spec/test/djornl/test_data/pheno_nodes.csv | 10 +- 42 files changed, 856 insertions(+), 318 deletions(-) create mode 100644 spec/datasets/djornl/csv_cluster.yaml create mode 100644 spec/datasets/djornl/csv_edge.yaml create mode 100644 spec/datasets/djornl/csv_node.yaml create mode 100644 spec/datasets/djornl/definitions.yaml create mode 100644 spec/datasets/djornl/edge_type.yaml create mode 100644 spec/datasets/djornl/node_type.yaml create mode 100644 spec/test/djornl/duplicate_data/I2_named.tsv create mode 100644 spec/test/djornl/duplicate_data/I4_named.tsv create mode 100644 spec/test/djornl/duplicate_data/I6_copy.csv create mode 100644 spec/test/djornl/duplicate_data/I6_named.tsv create mode 100644 spec/test/djornl/duplicate_data/edges.tsv create mode 100644 spec/test/djornl/duplicate_data/extra_node.tsv create mode 100644 spec/test/djornl/duplicate_data/hithruput-edges.csv create mode 100644 spec/test/djornl/duplicate_data/manifest.yaml create mode 100644 spec/test/djornl/duplicate_data/nodes.csv create mode 100644 spec/test/djornl/duplicate_data/pheno_nodes.csv create mode 100644 spec/test/djornl/empty_files/cluster_data/comment_only.tsv create mode 100644 spec/test/djornl/empty_files/cluster_data/headers_only.tsv rename spec/test/djornl/empty_files/cluster_data/{out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I2_named.tsv => no_content.tsv} (100%) delete mode 100644 spec/test/djornl/empty_files/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I4_named.tsv delete mode 100644 spec/test/djornl/empty_files/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I6_named.tsv create mode 100644 spec/test/djornl/invalid_types/edges.tsv create mode 100644 spec/test/djornl/invalid_types/markov2_named.tsv delete mode 100644 spec/test/djornl/invalid_types/merged_edges-AMW-060820_AF.tsv rename spec/test/djornl/invalid_types/{aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv => nodes.csv} (98%) diff --git a/importers/djornl/parser.py b/importers/djornl/parser.py index 928b55fe..990c745a 100644 --- a/importers/djornl/parser.py +++ b/importers/djornl/parser.py @@ -11,7 +11,7 @@ import yaml import importers.utils.config as config -from relation_engine_server.utils.json_validation import run_validator +from relation_engine_server.utils.json_validation import run_validator, get_schema_validator class DJORNL_Parser(object): @@ -62,7 +62,15 @@ def _configure(self): def _get_manifest_schema_file(self): - return os.path.join('/app', 'spec', 'datasets', 'djornl', 'manifest.schema.json') + return os.path.join(self._get_dataset_schema_dir(), 'manifest.schema.json') + + def _get_dataset_schema_dir(self): + + if not hasattr(self, '_dataset_schema_dir'): + dir_path = os.path.dirname(os.path.realpath(__file__)) + self._dataset_schema_dir = os.path.join(dir_path, '../', '../', 'spec', 'datasets', 'djornl') + + return self._dataset_schema_dir def _get_manifest(self, configuration): """ @@ -81,8 +89,8 @@ def _get_manifest(self, configuration): except FileNotFoundError: raise RuntimeError( f"No manifest file found at {manifest_file}.\n" - + "Please ensure that you have created a manifest that lists the files " - + "in the release" + "Please ensure that you have created a manifest that lists the files " + "in the release" ) try: @@ -109,205 +117,282 @@ def _get_file_reader(self, fd, file): def parser_gen(self, file): """generator function to parse a file""" expected_col_count = 0 - with open(file['file_path']) as fd: + with open(file['file_path'], newline='') as fd: csv_reader = self._get_file_reader(fd, file) line_no = 0 for row in csv_reader: line_no += 1 - if len(row) <= 1 or row[0][0] == '#': + if not len(row) or row[0][0] == '#': # comment / metadata continue cols = [c.strip() for c in row] if len(cols) == expected_col_count: - yield (line_no, cols) + yield (line_no, cols, None) continue # if we didn't get the expected number of cols: if expected_col_count == 0: # this is the header row; set up the expected column count expected_col_count = len(cols) - yield (line_no, [c.lower() for c in cols]) + yield (line_no, [c.lower() for c in cols], None) continue # otherwise, this row does not have the correct number of columns - n_cols = len(cols) - raise RuntimeError( - f"{file['path']} line {line_no}: " - + f"expected {expected_col_count} cols, found {n_cols}" - ) + col_count = len(cols) + msg = f"expected {expected_col_count} cols, found {col_count}" + yield(line_no, None, f"{file['path']} line {line_no}: {msg}") + + def remap_object(self, raw_data, remap_functions): + """ Given a dict, raw_data, create a new dict, remapped_data, using the functions in the + dictionary `remap_functions`. """ + remapped_data = {} + for (key, function) in remap_functions.items(): + # these keys get copied over unchanged to the new object if they exist in the input obj + if function is None: + if key in raw_data: + remapped_data[key] = raw_data[key] + else: + remapped_data[key] = function(raw_data) + + return remapped_data + + def process_file(self, file, remap_fn, store_fn, err_list, validator=None): + """ process an input file to generate a dataset and possibly an error list + + Each valid line in the file is turned into a dictionary using the header row, and then + validated against the csv validation schema in spec/datasets/djornl/csv_. + If that completes successfully, it is transformed using the functions in the dictionary + `remap_fn`, checked for uniqueness against existing data, and saved to a dictionary. Once + all files of a certain type have been processed, results can be saved to Arango. + + Any errors that occur during parsing and processing are accumulated in `err_list`. + + :param file: (dict) file data + :param remap_fn: (dict) mapping of output param names to functions + each function should take the row data object as input and + return the value for the output parameter + + :param store_fn: (func) function to store the results of the remapping + + :param err_list: (list) error list + + :param validator: (Validator) jsonschema validator object + + """ + file_parser = self.parser_gen(file) + try: + (line_no, cols, err_str) = next(file_parser) + except StopIteration: + # no valid lines found in the file + err_list.append(f"{file['path']}: no header line found") + return + + headers = cols + n_stored = 0 + for (line_no, cols, err_str) in file_parser: + # mismatch in number of cols + if cols is None: + err_list.append(err_str) + continue + + # merge headers with cols to create an object + row_object = dict(zip(headers, cols)) + + if validator is not None: + # validate the object + if not validator.is_valid(row_object): + err_msg = "".join( + f"{file['path']} line {line_no}: " + e.message + for e in sorted(validator.iter_errors(row_object), key=str) + ) + err_list.append(err_msg) + continue + + # transform it using the remap_functions + datum = self.remap_object(row_object, remap_fn) + + # and store it + storage_error = store_fn(datum) + if storage_error is None: + n_stored += 1 + else: + err_list.append(f"{file['path']} line {line_no}: " + storage_error) + + if not n_stored: + err_list.append(f"{file['path']}: no valid data found") def load_edges(self): - # Headers and sample row: - # node1 node2 edge edge_descrip layer_descrip - # AT1G01370 AT1G57820 4.40001558779779 AraNetv2_log-likelihood-score AraNetv2-LC_lit-curated-ppi - edge_type_remap = { - 'AraGWAS-Phenotype_Associations': 'pheno_assn', - 'AraNetv2-CX_pairwise-gene-coexpression': 'gene_coexpr', - 'AraNetv2-DC_domain-co-occurrence': 'domain_co_occur', - 'AraNetv2-HT_high-throughput-ppi': 'ppi_hithru', - 'AraNetv2-LC_lit-curated-ppi': 'ppi_liter', - } + """Load edge data from the set of edge files""" # dict of nodes, indexed by node ID (node1 and node2 from the file) node_ix = {} - edges = [] - node_name = self.config('node_name') + # dict of edges, indexed by node1__node2__edge_type + edge_ix = {} + # error accumulator + err_list = [] - def edge_type(row): - if row['layer_descrip'] not in edge_type_remap: - raise RuntimeError( - f"{file['path']} line {line_no}: invalid edge type: {row['layer_descrip']}" - ) - return edge_type_remap[row['layer_descrip']] - - def _key(row): - return '__'.join([ - row['node1'], - row['node2'], - edge_type(row), - row['edge'], - ]) + schema_file = os.path.join(self._get_dataset_schema_dir(), 'csv_edge.yaml') + validator = get_schema_validator(schema_file=schema_file) + node_name = self.config('node_name') # these functions remap the values in the columns of the input file to # appropriate values to go into Arango remap_functions = { + # create a unique key for each record + '_key': lambda row: '__'.join([row[_] for _ in ['node1', 'node2', 'layer_descrip', 'edge']]), + 'node1': None, # this will be deleted in the 'store' step + 'node2': None, # as will this '_from': lambda row: node_name + '/' + row['node1'], '_to': lambda row: node_name + '/' + row['node2'], 'score': lambda row: float(row['edge']), - 'edge_type': edge_type, - '_key': _key, + 'edge_type': lambda row: row['layer_descrip'], } - for file in self.config('edge_files'): - file_parser = self.parser_gen(file) - headers = [] + # store edge data, checking for potential duplicates + def store_edges(datum): + # there should only be one value for each node<->node edge of a given type + edge_key = "__".join([datum['node1'], datum['node2'], datum['edge_type']]) - while True: - try: - (line_no, cols) = next(file_parser) - except StopIteration: - break + if edge_key in edge_ix: + # ignore duplicate lines; report non-matching data + if datum['score'] != edge_ix[edge_key]['score']: + return f"duplicate data for edge {edge_key}" + return None - if len(headers) == 0: - headers = cols - continue + # keep track of the nodes mentioned in this edge set + for node_n in ["1", "2"]: + node_ix[datum[f"node{node_n}"]] = 1 + del datum[f"node{node_n}"] - # merge headers with cols to create an object - row_object = dict(zip(headers, cols)) - # transform it using the remap_functions - datum = {key: func(row_object) for (key, func) in remap_functions.items()} - edges.append(datum) + edge_ix[edge_key] = datum + return None - # keep track of the nodes mentioned in this edge set - for node in ["1", "2"]: - node_ix[row_object[f"node{node}"]] = 1 + for file in self.config('edge_files'): + self.process_file( + file=file, + remap_fn=remap_functions, + store_fn=store_edges, + err_list=err_list, + validator=validator, + ) + + if len(err_list): + raise RuntimeError('\n'.join(err_list)) return { 'nodes': [{'_key': n} for n in node_ix.keys()], - 'edges': edges, + 'edges': edge_ix.values(), } def load_node_metadata(self): """Load node metadata""" - nodes = [] - valid_node_types = ['gene', 'pheno'] + node_ix = {} + err_list = [] + + schema_file = os.path.join(self._get_dataset_schema_dir(), 'csv_node.yaml') + validator = get_schema_validator(schema_file=schema_file) def go_terms(row): - if len(row['go_terms']): - return [c.strip() for c in row_object['go_terms'].split(',')] + if 'go_terms' in row and len(row['go_terms']): + return [c.strip() for c in row['go_terms'].split(',')] return [] - def node_type(row): - if row['node_type'] not in valid_node_types: - raise RuntimeError( - f"{file['path']} line {line_no}: invalid node type: {row['node_type']}" - ) - return row['node_type'] - remap_functions = { # these pass straight through - 'transcript': None, - 'gene_symbol': None, 'gene_full_name': None, 'gene_model_type': None, - 'tair_computational_description': None, - 'tair_short_description': None, - 'tair_curator_summary': None, + 'gene_symbol': None, + 'go_description': None, 'mapman_bin': None, + 'mapman_description': None, 'mapman_name': None, + 'node_type': None, 'pheno_aragwas_id': None, + 'pheno_description': None, + 'pheno_pto_description': None, + 'pheno_pto_name': None, 'pheno_ref': None, + 'tair_computational_description': None, + 'tair_curator_summary': None, + 'tair_short_description': None, + 'transcript': None, 'user_notes': None, # rename '_key': lambda row: row['node_id'], - 'go_description': lambda row: row['go_descr'], - 'mapman_description': lambda row: row['mapman_descr'], - 'pheno_description': lambda row: row['pheno_descrip1'], - 'pheno_pto_name': lambda row: row['pheno_descrip2'], - 'pheno_pto_description': lambda row: row['pheno_descrip3'], # see functions above - 'node_type': node_type, 'go_terms': go_terms, } - for file in self.config('node_files'): - file_parser = self.parser_gen(file) - headers = [] - - while True: - try: - (line_no, cols) = next(file_parser) - except StopIteration: - break - - if len(headers) == 0: - headers = cols - continue + # store nodes in a dict indexed by _key + def store_nodes(datum): + # check whether we have this node already + if datum['_key'] in node_ix: + # report non-matching data + if datum != node_ix[datum['_key']]: + return f"duplicate data for node {datum['_key']}" + # otherwise, it's duplicated line: ignore + return None - # merge with headers to form an object, then remap to create Arango-ready data - row_object = dict(zip(headers, cols)) + node_ix[datum['_key']] = datum + return None - datum = {} - for (key, func) in remap_functions.items(): - if func is None: - datum[key] = row_object[key] - else: - datum[key] = func(row_object) - nodes.append(datum) + for file in self.config('node_files'): + self.process_file( + file=file, + remap_fn=remap_functions, + store_fn=store_nodes, + err_list=err_list, + validator=validator, + ) - return {'nodes': nodes} + if len(err_list): + raise RuntimeError('\n'.join(err_list)) + return {'nodes': node_ix.values()} def load_cluster_data(self): """Annotate genes with cluster ID fields.""" # index of nodes node_ix = {} + err_list = [] + + schema_file = os.path.join(self._get_dataset_schema_dir(), 'csv_cluster.yaml') + validator = get_schema_validator(schema_file=schema_file) + + # these functions remap the values in the columns of the input file to + # appropriate values to go into Arango + remap_functions = { + 'node_ids': lambda row: [n.strip() for n in row['node_ids'].split(',')] + } + + # store clusters in a dictionary with key node_id and value list of cluster IDs to which + # the node is assigned + def store_clusters(datum): + cluster_id = datum['cluster_id'] + for node_id in datum['node_ids']: + if node_id not in node_ix: + node_ix[node_id] = [cluster_id] + elif cluster_id not in node_ix[node_id]: + node_ix[node_id].append(cluster_id) + return None + for file in self.config('cluster_files'): - cluster_label = file['cluster_prefix'] - headers = [] - file_parser = self.parser_gen(file) - - while True: - try: - (line_no, cols) = next(file_parser) - except StopIteration: - break - - if len(headers) == 0: - headers = cols - continue + prefix = file['cluster_prefix'] + remap_functions['cluster_id'] = lambda row: prefix + ':' + row['cluster_id'].replace('Cluster', '') + + self.process_file( + file=file, + remap_fn=remap_functions, + store_fn=store_clusters, + err_list=err_list, + validator=validator, + ) - # remove the 'Cluster' text and replace it with cluster_label - cluster_id = cluster_label + ':' + cols[0].replace('Cluster', '') - node_keys = [n.strip() for n in cols[1].split(',')] - for key in node_keys: - if key not in node_ix: - node_ix[key] = [cluster_id] - elif cluster_id not in node_ix[key]: - node_ix[key].append(cluster_id) + if len(err_list): + raise RuntimeError('\n'.join(err_list)) # gather a list of cluster IDs for each node nodes = [{ @@ -345,6 +430,7 @@ def load_data(self): self.save_dataset(self.load_edges()) self.save_dataset(self.load_node_metadata()) self.save_dataset(self.load_cluster_data()) + return True def check_data_delta(self): edge_data = self.load_edges() @@ -374,3 +460,8 @@ def check_deltas(self, edge_data={}, node_metadata={}, cluster_data={}): print("Dataset contains " + str(len(edge_data['edges'])) + " edges") # count all nodes print("Dataset contains " + str(len(all_nodes)) + " nodes") + + +if __name__ == '__main__': + parser = DJORNL_Parser() + parser.load_data() diff --git a/importers/test/test_djornl_parser.py b/importers/test/test_djornl_parser.py index e2442c8d..a3c8ecfa 100644 --- a/importers/test/test_djornl_parser.py +++ b/importers/test/test_djornl_parser.py @@ -64,9 +64,24 @@ def test_load_empty_files(self): RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, 'djornl', 'empty_files') parser = self.init_parser_with_path(RES_ROOT_DATA_PATH) - self.assertEqual(parser.load_edges(), {"nodes": [], "edges": []}) - self.assertEqual(parser.load_node_metadata(), {"nodes": []}) - self.assertEqual(parser.load_cluster_data(), {"nodes": []}) + # header only, no content + err_str = 'aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv: no valid data found' + with self.assertRaisesRegex(RuntimeError, err_str): + parser.load_node_metadata() + + # comments only + err_str = 'merged_edges-AMW-060820_AF.tsv: no header line found' + with self.assertRaisesRegex(RuntimeError, err_str): + parser.load_edges() + + # mix of problems + err_str = "\n".join([ + 'cluster_data/headers_only.tsv: no valid data found', + 'cluster_data/no_content.tsv: no header line found', + 'cluster_data/comment_only.tsv: no header line found', + ]) + with self.assertRaisesRegex(RuntimeError, err_str): + parser.load_cluster_data() def test_load_missing_files(self): """ test loading when files cannot be found """ @@ -77,23 +92,47 @@ def test_load_missing_files(self): with self.assertRaisesRegex(RuntimeError, err_str): self.init_parser_with_path(RES_ROOT_DATA_PATH) - def test_load_invalid_types(self): + def test_load_invalid_edges(self): """ test file format errors """ # path: test/djornl/invalid_types RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, 'djornl', 'invalid_types') parser = self.init_parser_with_path(RES_ROOT_DATA_PATH) - # invalid edge type - edge_err_msg = 'merged_edges-AMW-060820_AF.tsv line 3: invalid edge type: AraGWAS-Some-Old-Rubbish-I-Made-Up' + # invalid edge type, invalid scores + edge_err_msg = "\n".join([ + r"edges.tsv line 3: 'Same-Old-Stuff' is not valid under any of the given schemas", + r"edges.tsv line 7: '2.' does not match .*?", + r"edges.tsv line 8: 'raNetv2-DC_' is not valid under any of the given schemas", + r"edges.tsv line 10: 'score!' does not match .*?" + ]) with self.assertRaisesRegex(RuntimeError, edge_err_msg): parser.load_edges() + def test_load_invalid_nodes(self): + """ test file format errors """ + + # path: test/djornl/invalid_types + RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, 'djornl', 'invalid_types') + parser = self.init_parser_with_path(RES_ROOT_DATA_PATH) + # invalid node type - node_err_msg = 'aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv line 5: invalid node type: Monkey' + node_err_msg = "nodes.csv line 5: 'Monkey' is not valid under any of the given schemas" with self.assertRaisesRegex(RuntimeError, node_err_msg): parser.load_node_metadata() + def test_load_invalid_clusters(self): + """ test file format errors """ + + # path: test/djornl/invalid_types + RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, 'djornl', 'invalid_types') + parser = self.init_parser_with_path(RES_ROOT_DATA_PATH) + + # invalid node type + cluster_err_msg = "markov2_named.tsv line 7: 'HoneyNutCluster3' does not match" + with self.assertRaisesRegex(RuntimeError, cluster_err_msg): + parser.load_cluster_data() + def test_load_col_count_errors(self): """ test files with invalid numbers of columns """ @@ -101,13 +140,13 @@ def test_load_col_count_errors(self): RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, 'djornl', 'col_count_errors') parser = self.init_parser_with_path(RES_ROOT_DATA_PATH) - # invalid edge type - edge_err_msg = 'line 6: expected 5 cols, found 3' + # not enough cols + edge_err_msg = 'merged_edges-AMW-060820_AF.tsv line 6: expected 5 cols, found 3' with self.assertRaisesRegex(RuntimeError, edge_err_msg): parser.load_edges() - # invalid node type - node_err_msg = 'line 3: expected 20 cols, found 22' + # too many cols + node_err_msg = 'aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv line 3: expected 20 cols, found 22' with self.assertRaisesRegex(RuntimeError, node_err_msg): parser.load_node_metadata() @@ -144,10 +183,53 @@ def test_load_valid_cluster_data(self): RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, 'djornl', 'test_data') parser = self.init_parser_with_path(RES_ROOT_DATA_PATH) + cluster_data = parser.load_cluster_data() self.assertEqual( cluster_data, self.json_data["load_cluster_data"] ) - parser.check_data_delta() + def test_duplicate_edge_data(self): + """ test files with duplicate edge data, which should throw an error """ + + RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, 'djornl', 'duplicate_data') + parser = self.init_parser_with_path(RES_ROOT_DATA_PATH) + + err_msg = "\n".join([ + "hithruput-edges.csv line 5: duplicate data for edge AT1G01010__AT1G01030__AraNetv2-HT_.*?", + "hithruput-edges.csv line 9: duplicate data for edge AT1G01030__AT1G01050__AraNetv2-CX_.*?" + ]) + with self.assertRaisesRegex(RuntimeError, err_msg): + parser.load_edges() + + def test_duplicate_node_data(self): + """ test files with duplicate node data, which should throw an error """ + + RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, 'djornl', 'duplicate_data') + parser = self.init_parser_with_path(RES_ROOT_DATA_PATH) + + err_msg = "extra_node.tsv line 5: duplicate data for node AT1G01080" + with self.assertRaisesRegex(RuntimeError, err_msg): + parser.load_node_metadata() + + def test_duplicate_cluster_data(self): + """ test files with duplicate cluster data, which should be seamlessly merged """ + + # path: test/djornl/col_count_errors + RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, 'djornl', 'duplicate_data') + parser = self.init_parser_with_path(RES_ROOT_DATA_PATH) + + cluster_data = parser.load_cluster_data() + self.assertEqual( + cluster_data, + self.json_data["load_cluster_data"] + ) + + def test_the_full_shebang(self): + + RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, 'djornl', 'test_data') + parser = self.init_parser_with_path(RES_ROOT_DATA_PATH) + + parser.load_data() + self.assertEqual(True, parser.load_data()) diff --git a/relation_engine_server/utils/bulk_import.py b/relation_engine_server/utils/bulk_import.py index 8e520726..fbd1c6c3 100644 --- a/relation_engine_server/utils/bulk_import.py +++ b/relation_engine_server/utils/bulk_import.py @@ -6,7 +6,7 @@ import hashlib from relation_engine_server.utils.json_validation import get_schema_validator -from relation_engine_server.utils import spec_loader +from relation_engine_server.utils.spec_loader import get_collection from relation_engine_server.utils.arango_client import import_from_file @@ -16,8 +16,8 @@ def bulk_import(query_params): schema, then write them into a temporary file that can be passed into the arango client. """ - schema = spec_loader.get_collection(query_params['collection']) - validator = get_schema_validator(schema=schema['schema']) + schema_file = get_collection(query_params['collection'], path_only=True) + validator = get_schema_validator(schema_file=schema_file, validate_at='/schema') # We can't use a context manager here # We need to close the file to have the file contents readable # and we need to prevent deletion of the temp file on close (default behavior of tempfiles) diff --git a/spec/collections/djornl/djornl_edge.yaml b/spec/collections/djornl/djornl_edge.yaml index 1c956fdc..a6f93d51 100644 --- a/spec/collections/djornl/djornl_edge.yaml +++ b/spec/collections/djornl/djornl_edge.yaml @@ -14,39 +14,15 @@ schema: description: Generic gene-to-gene or gene-to-phenotype edge for Dan Jacobson Arabidopsis data type: object required: [score, edge_type, _from, _to, _key] + additionalProperties: false properties: _key: - type: string - title: Key + $ref: ../../datasets/djornl/definitions.yaml#definitions/djornl_edge/_key _from: - type: string - title: Gene ID + $ref: ../../datasets/djornl/definitions.yaml#definitions/djornl_edge/_from _to: - type: string - title: Gene or Phenotype ID + $ref: ../../datasets/djornl/definitions.yaml#definitions/djornl_edge/_to score: - title: Edge Score (Weight) - # (float) - type: number + $ref: ../../datasets/djornl/definitions.yaml#definitions/djornl_edge/score edge_type: - title: Edge Type - type: string - oneOf: - - const: domain_co_occur - title: AraNetv2-DC_domain-co-occurrence - description: A layer of protein domain co-occurrence values from the Arabidopsis AraNetv2 database. The LLS scores that serve as edge values were calculated from weighted mutual information scores to normalize the data for comparison across studies and different types of data layers (Lee et al, 2015). - - const: gene_coexpr - title: AraNetv2-CX_pairwise-gene-coexpression - description: A subset of pairwise gene coexpression values from the Arabidopsis AraNetv2 database. The LLS scores that serve as edge values were - calculated from Pearson correlation coefficients to normalize the data - for comparison across studies and different types of data layers (Lee et - al, 2015). - - const: pheno_assn - title: AraGWAS-Phenotype_Associations - description: GWAS associations produced by analyzing a subset of phenotypes and SNPs in the Arabidopsis 1001 Genomes database. Edge values are significant association scores after FDR correction. - - const: ppi_hithru - title: AraNetv2-HT_high-throughput-ppi - description: Log likelihood score. A layer of protein-protein interaction values derived from four high-throughput PPI screening experiments; from the Arabidopsis AraNetv2 database. The LLS scores that serve as edge values were calculated to normalize the data for comparison across studies and different types of data layers (Lee et al, 2015). - - const: ppi_liter - title: AraNetv2-LC_lit-curated-ppi - description: A layer of protein-protein interaction values from literature-curated small- to medium-scale experimental data; from the Arabidopsis AraNetv2 database. The LLS scores that serve as edge values were calculated to normalize the data for comparison across studies and different types of data layers (Lee et al, 2015). + $ref: ../../datasets/djornl/definitions.yaml#definitions/djornl_edge/edge_type diff --git a/spec/collections/djornl/djornl_node.yaml b/spec/collections/djornl/djornl_node.yaml index e0a744a7..62d17dda 100644 --- a/spec/collections/djornl/djornl_node.yaml +++ b/spec/collections/djornl/djornl_node.yaml @@ -3,8 +3,8 @@ type: vertex delta: false indexes: - - type: hash - fields: ["clusters[*]"] + - type: hash + fields: ["clusters[*]"] schema: "$schema": http://json-schema.org/draft-07/schema# @@ -12,6 +12,7 @@ schema: description: Arabidopsis gene and phenotype nodes from the Dan Jacobson Lab type: object required: [_key] + additionalProperties: false properties: _key: type: string diff --git a/spec/datasets/djornl/csv_cluster.yaml b/spec/datasets/djornl/csv_cluster.yaml new file mode 100644 index 00000000..c60f1dfd --- /dev/null +++ b/spec/datasets/djornl/csv_cluster.yaml @@ -0,0 +1,15 @@ +"$schema": http://json-schema.org/draft-07/schema# +name: csv_cluster +title: Cluster data +description: Cluster ID to node ID mappings +type: object +required: [cluster_id, node_ids] +additionalProperties: false +properties: + cluster_id: + type: string + format: regex + pattern: "^Cluster\\d+" + # pre-transform node_ids + node_ids: + type: string diff --git a/spec/datasets/djornl/csv_edge.yaml b/spec/datasets/djornl/csv_edge.yaml new file mode 100644 index 00000000..c2416262 --- /dev/null +++ b/spec/datasets/djornl/csv_edge.yaml @@ -0,0 +1,23 @@ +"$schema": http://json-schema.org/draft-07/schema# +name: csv_edge +title: Arabidopsis gene-gene or gene-phenotype edge +description: Generic gene-to-gene or gene-to-phenotype edge for Dan Jacobson Arabidopsis data +type: object +required: [node1, node2, edge, layer_descrip] +properties: + node1: + $ref: definitions.yaml#definitions/djornl_edge/_from + node2: + $ref: definitions.yaml#definitions/djornl_edge/_to + edge: + type: string + format: regex + pattern: "^\\d*(\\.\\d+)?$" + layer_descrip: + type: string + oneOf: + - const: AraNetv2-DC_domain-co-occurrence + - const: AraNetv2-CX_pairwise-gene-coexpression + - const: AraGWAS-Phenotype_Associations + - const: AraNetv2-HT_high-throughput-ppi + - const: AraNetv2-LC_lit-curated-ppi diff --git a/spec/datasets/djornl/csv_node.yaml b/spec/datasets/djornl/csv_node.yaml new file mode 100644 index 00000000..c957ff98 --- /dev/null +++ b/spec/datasets/djornl/csv_node.yaml @@ -0,0 +1,52 @@ +"$schema": http://json-schema.org/draft-07/schema# +name: csv_node +title: CSV node file syntax +description: Arabidopsis gene and phenotype nodes from the Dan Jacobson Lab +type: object +required: [node_id, node_type] +additionalProperties: false +properties: + node_id: + $ref: definitions.yaml#definitions/djornl_node/_key + node_type: + $ref: definitions.yaml#definitions/djornl_node/node_type + clusters: + $ref: definitions.yaml#definitions/djornl_node/clusters + transcript: + $ref: definitions.yaml#definitions/djornl_node/transcript + gene_symbol: + $ref: definitions.yaml#definitions/djornl_node/gene_symbol + gene_full_name: + $ref: definitions.yaml#definitions/djornl_node/gene_full_name + gene_model_type: + $ref: definitions.yaml#definitions/djornl_node/gene_model_type + tair_computational_description: + $ref: definitions.yaml#definitions/djornl_node/tair_computational_description + tair_curator_summary: + $ref: definitions.yaml#definitions/djornl_node/tair_curator_summary + tair_short_description: + $ref: definitions.yaml#definitions/djornl_node/tair_short_description + go_terms: + type: string + format: regex + pattern: "^(GO:\\d{7}, ?)*(GO:\\d{7})?$" + go_description: + $ref: definitions.yaml#definitions/djornl_node/go_description + mapman_bin: + $ref: definitions.yaml#definitions/djornl_node/mapman_bin + mapman_name: + $ref: definitions.yaml#definitions/djornl_node/mapman_name + mapman_description: + $ref: definitions.yaml#definitions/djornl_node/mapman_description + pheno_aragwas_id: + $ref: definitions.yaml#definitions/djornl_node/pheno_aragwas_id + pheno_description: + $ref: definitions.yaml#definitions/djornl_node/pheno_description + pheno_pto_name: + $ref: definitions.yaml#definitions/djornl_node/pheno_pto_name + pheno_pto_description: + $ref: definitions.yaml#definitions/djornl_node/pheno_pto_description + pheno_ref: + $ref: definitions.yaml#definitions/djornl_node/pheno_ref + user_notes: + $ref: definitions.yaml#definitions/djornl_node/user_notes diff --git a/spec/datasets/djornl/definitions.yaml b/spec/datasets/djornl/definitions.yaml new file mode 100644 index 00000000..81ee5e29 --- /dev/null +++ b/spec/datasets/djornl/definitions.yaml @@ -0,0 +1,129 @@ +"$schema": "http://json-schema.org/draft-07/schema#" +name: definitions +title: DJORNL schema definitions +description: Node and edge metadata definitions for the Dan Jacobson Exascale dataset +definitions: + cluster_id: + type: string + format: regex + pattern: ^\w+:\d+$ + examples: ["markov_i2:1", "markov_i4:5", "markov_i6:3"] + go_term: + type: string + format: regex + pattern: ^GO:\d{7}$ + examples: ["GO:0003700", "GO:0005515"] + djornl_edge: + _key: + type: string + title: Key + format: regex + pattern: ^(\S+__){3}(\S+)$ + _from: + type: string + title: Gene ID + _to: + type: string + title: Gene or Phenotype ID + score: + title: Edge Score (Weight) + # (float) + type: number + edge_type: + $ref: edge_type.yaml + djornl_node: + _key: + type: string + title: Key + examples: ["AT1G01010"] + clusters: + type: array + title: Clusters + description: Clusters to which the node has been assigned + items: + $ref: #definitions/cluster_id + examples: [["markov_i2:1", "markov_i4:5"], ["markov_i6:3"]] + node_type: + type: string + title: Node type + oneOf: + - const: gene + title: Gene + - const: pheno + title: Phenotype + examples: ["gene", "pheno"] + transcript: + type: string + title: Transcript + examples: ["AT1G01010.1"] + gene_symbol: + type: string + title: Gene symbol + examples: ["NTL10"] + gene_full_name: + type: string + title: Gene full name + examples: ["NAC domain containing protein 1"] + gene_model_type: + type: string + title: Gene model type + examples: ["protein_coding"] + tair_computational_description: + type: string + title: TAIR computational description + examples: ["NAC domain containing protein 1;(source:Araport11)"] + tair_curator_summary: + type: string + title: TAIR curator summary + examples: ["Encodes a plasma membrane-localized amino acid transporter likely involved in amino acid export in the developing seed."] + tair_short_description: + type: string + title: TAIR short description + examples: ["NAC domain containing protein 1"] + go_description: + type: string + title: GO descriptions + examples: ["DNA-binding transcription factor activity"] + go_terms: + type: array + title: GO term IDs + items: + $ref: #definitions/go_term + mapman_bin: + type: string + title: Mapman bin + examples: ["15.5.17"] + mapman_name: + type: string + title: Mapman name + examples: [".RNA biosynthesis.transcriptional regulation.transcription factor (NAC)"] + mapman_description: + type: string + title: Mapman description + examples: ["transcription factor (NAC) (original description: pep chromosome:TAIR10:1:3631:5899:1 gene:AT1G01010 transcript:AT1G01010.1 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:NAC001 description:NAC domain-containing protein 1 [Source:UniProtKB/Swiss-Prot;Acc:Q0WV96])"] + pheno_aragwas_id: + type: string + title: AraGWAS ID + examples: ["10.21958/phenotype:67"] + pheno_description: + type: string + title: Phenotype description + examples: ["Arsenic concentrations in leaves, grown in soil. Elemental analysis was performed with an ICP-MS (PerkinElmer). Sample normalized to calculated weights as described in Baxter et al., 2008"] + pheno_pto_name: + type: string + title: PTO name + description: Plant Trait Ontology name + examples: ["arsenic concentration"] + pheno_pto_description: + type: string + title: PTO description + description: Plant Trait Ontology description + examples: ["A mineral and ion content related trait (TO:0000465) which is the concentration of arsenic (CHEBI:22632) in some plant structure (PO:0009011). [GR:Karthik]"] + pheno_ref: + type: string + title: Phenotype reference + examples: ["Atwell et. al, Nature 2010"] + user_notes: + type: string + title: User Notes + examples: ["flowering time related"] diff --git a/spec/datasets/djornl/edge_type.yaml b/spec/datasets/djornl/edge_type.yaml new file mode 100644 index 00000000..3ac6d62a --- /dev/null +++ b/spec/datasets/djornl/edge_type.yaml @@ -0,0 +1,25 @@ +$schema: "http://json-schema.org/draft-07/schema#" +name: edge_type +title: Edge Type +description: Edge types in Dan Jacobson Arabidopsis Exascale dataset +type: string +oneOf: + - const: AraGWAS-Phenotype_Associations + title: AraGWAS phenotype associations + description: GWAS associations produced by analyzing a subset of phenotypes and SNPs in the Arabidopsis 1001 Genomes database. Edge values are significant association scores after FDR correction. + + - const: AraNetv2-CX_pairwise-gene-coexpression + title: AraNetv2 pairwise gene coexpression + description: A subset of pairwise gene coexpression values from the Arabidopsis AraNetv2 database. The LLS scores that serve as edge values were calculated from Pearson correlation coefficients to normalize the data for comparison across studies and different types of data layers (Lee et al, 2015). + + - const: AraNetv2-DC_domain-co-occurrence + title: AraNetv2 domain co-occurrence + description: A layer of protein domain co-occurrence values from the Arabidopsis AraNetv2 database. The LLS scores that serve as edge values were calculated from weighted mutual information scores to normalize the data for comparison across studies and different types of data layers (Lee et al, 2015). + + - const: AraNetv2-HT_high-throughput-ppi + title: AraNetv2 high-throughput protein-protein interaction + description: Log likelihood score. A layer of protein-protein interaction values derived from four high-throughput PPI screening experiments; from the Arabidopsis AraNetv2 database. The LLS scores that serve as edge values were calculated to normalize the data for comparison across studies and different types of data layers (Lee et al, 2015). + + - const: AraNetv2-LC_lit-curated-ppi + title: AraNetv2 literature-curated protein-protein interaction + description: A layer of protein-protein interaction values from literature-curated small- to medium-scale experimental data; from the Arabidopsis AraNetv2 database. The LLS scores that serve as edge values were calculated to normalize the data for comparison across studies and different types of data layers (Lee et al, 2015). diff --git a/spec/datasets/djornl/node_type.yaml b/spec/datasets/djornl/node_type.yaml new file mode 100644 index 00000000..e839c2d0 --- /dev/null +++ b/spec/datasets/djornl/node_type.yaml @@ -0,0 +1,10 @@ +"$schema": "http://json-schema.org/draft-07/schema#" +name: node_type +title: Node Type +description: Node types in Dan Jacobson Exascale dataset +type: string +oneOf: + - const: gene + title: Gene + - const: pheno + title: Phenotype diff --git a/spec/test/djornl/col_count_errors/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv b/spec/test/djornl/col_count_errors/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv index 7727cd8a..e989f2ca 100644 --- a/spec/test/djornl/col_count_errors/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv +++ b/spec/test/djornl/col_count_errors/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv @@ -1,4 +1,4 @@ -node_id,node_type,transcript,gene_symbol,gene_full_name,gene_model_type,TAIR_Computational_description,TAIR_Curator_summary,TAIR_short_description,GO_descr,GO_terms,MapMan_bin,MapMan_name,MapMan_descr,pheno_AraGWAS_ID,pheno_descrip1,pheno_descrip2,pheno_descrip3,pheno_ref,User_Notes +node_id,node_type,transcript,gene_symbol,gene_full_name,gene_model_type,TAIR_Computational_description,TAIR_Curator_summary,TAIR_short_description,GO_description,GO_terms,MapMan_bin,MapMan_name,MapMan_description,pheno_AraGWAS_ID,pheno_description,pheno_pto_name,pheno_pto_description,pheno_ref,User_Notes As2,pheno,,,,,,,,,,,,,10.21958/phenotype:103,,bacterial disease resistance,The resistance exhibited by a plant or a group of plants (population) in response to the disease caused by a bacterial pathogen infection as compared to the susceptible and/or the reference plants of the same species. [GR:pj],"Atwell et. al, Nature 2010", As75,pheno,,,,,,,,,,,,,,,10.21958/phenotype:67,"Arsenic concentrations in leaves, grown in soil. Elemental analysis was performed with an ICP-MS (PerkinElmer). Sample normalized to calculated weights as described in Baxter et al., 2008",arsenic concentration,A mineral and ion content related trait (TO:0000465) which is the concentration of arsenic (CHEBI:22632) in some plant structure (PO:0009011). [GR:Karthik],"Atwell et. al, Nature 2010", AT1G01020,gene,AT1G01020.6,ARV1,,protein_coding,ARV1 family protein;(source:Araport11),,,molecular_function,GO:0003674,35.1,not assigned.annotated,(original description: pep chromosome:TAIR10:1:6788:8737:-1 gene:AT1G01020 transcript:AT1G01020.6 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:ARV1 description:ARV1 family protein [Source:UniProtKB/TrEMBL;Acc:Q5MK24]) & no description available(sp|q5mk24|arv1_arath : 99.4),,,,,, diff --git a/spec/test/djornl/duplicate_data/I2_named.tsv b/spec/test/djornl/duplicate_data/I2_named.tsv new file mode 100644 index 00000000..bef48c38 --- /dev/null +++ b/spec/test/djornl/duplicate_data/I2_named.tsv @@ -0,0 +1,9 @@ +cluster_id node_ids +# data_type: cluster +# cluster_prefix: markov_i2 +# title: Markov clustering, inflation = 2 +Cluster1 AT1G01010,AT1G01030,AT1G01040 +Cluster2 AT1G01050,AT1G01060,AT1G01070 +Cluster3 AT1G01090 +# Cluster4 +Cluster5 AT1G01020 diff --git a/spec/test/djornl/duplicate_data/I4_named.tsv b/spec/test/djornl/duplicate_data/I4_named.tsv new file mode 100644 index 00000000..29b6cd36 --- /dev/null +++ b/spec/test/djornl/duplicate_data/I4_named.tsv @@ -0,0 +1,8 @@ +cluster_id node_ids +# cluster_prefix: markov_i4 +# title: Markov clustering, inflation = 4 +# data_type: cluster +# Cluster1 +# Cluster2 +Cluster3 AT1G01080 +# Cluster4 diff --git a/spec/test/djornl/duplicate_data/I6_copy.csv b/spec/test/djornl/duplicate_data/I6_copy.csv new file mode 100644 index 00000000..a21bd2af --- /dev/null +++ b/spec/test/djornl/duplicate_data/I6_copy.csv @@ -0,0 +1,8 @@ +cluster_id,node_ids +# data_type: cluster +# cluster_prefix: markov_i6 +# title: Markov clustering, inflation = 6 +Cluster1,"AT1G01040,AT1G01090" +Cluster2,AT1G01070 +Cluster3,"AT1G01010,AT1G01020,AT1G01030" +# Cluster4 diff --git a/spec/test/djornl/duplicate_data/I6_named.tsv b/spec/test/djornl/duplicate_data/I6_named.tsv new file mode 100644 index 00000000..e7688f17 --- /dev/null +++ b/spec/test/djornl/duplicate_data/I6_named.tsv @@ -0,0 +1,8 @@ +cluster_id node_ids +# data_type: cluster +# cluster_prefix: markov_i6 +# title: Markov clustering, inflation = 6 +Cluster1 AT1G01040,AT1G01090 +Cluster2 AT1G01070 +Cluster3 AT1G01010,AT1G01020,AT1G01030 +# Cluster4 diff --git a/spec/test/djornl/duplicate_data/edges.tsv b/spec/test/djornl/duplicate_data/edges.tsv new file mode 100644 index 00000000..432c2deb --- /dev/null +++ b/spec/test/djornl/duplicate_data/edges.tsv @@ -0,0 +1,11 @@ +node1 node2 edge edge_descrip layer_descrip +As2 AT1G01020 8.4 AraGWAS-Association_score AraGWAS-Phenotype_Associations +As2 AT1G01040 5.4 AraGWAS-Association_score AraGWAS-Phenotype_Associations +As75 AT1G01020 39.9 AraGWAS-Association_score AraGWAS-Phenotype_Associations +AT1G01010 AT1G01040 2.5 AraNetv2_log-likelihood-score AraNetv2-DC_domain-co-occurrence +AT1G01010 AT1G01040 170.5 AraNetv2_log-likelihood-score AraNetv2-LC_lit-curated-ppi +AT1G01030 AT1G01050 2.6 AraNetv2_log-likelihood-score AraNetv2-CX_pairwise-gene-coexpression +AT1G01050 AT1G01060 2.7 AraNetv2_log-likelihood-score AraNetv2-LC_lit-curated-ppi +# duplicated line +AT1G01010 AT1G01040 2.5 AraNetv2_log-likelihood-score AraNetv2-DC_domain-co-occurrence +AT1G01080 AT1G01090 2.8 AraNetv2_log-likelihood-score AraNetv2-LC_lit-curated-ppi diff --git a/spec/test/djornl/duplicate_data/extra_node.tsv b/spec/test/djornl/duplicate_data/extra_node.tsv new file mode 100644 index 00000000..a1a28b69 --- /dev/null +++ b/spec/test/djornl/duplicate_data/extra_node.tsv @@ -0,0 +1,5 @@ +# data_type: node +node_id node_type transcript gene_symbol gene_full_name gene_model_type TAIR_Computational_description TAIR_Curator_summary TAIR_short_description GO_description GO_terms MapMan_bin MapMan_name MapMan_description +AT1G01100 gene AT1G01100.4 protein_coding 60S acidic ribosomal protein family;(source:Araport11) 60S acidic ribosomal protein family structural constituent of ribosome, ribonucleoprotein complex binding, protein kinase activator activity GO:0003735, GO:0043021, GO:0030295 17.1.2.1.46 .Protein biosynthesis.ribosome biogenesis.large ribosomal subunit (LSU).LSU proteome.component RPP1 component RPP1 of LSU proteome component (original description: pep chromosome:TAIR10:1:50090:51187:-1 gene:AT1G01100 transcript:AT1G01100.4 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:RPP1A description:60S acidic ribosomal protein P1-1 [Source:UniProtKB/Swiss-Prot;Acc:Q8LCW9]) +# duplicated line with alterations +AT1G01080 gene AT1G01080.3 whatever! protein_coding RNA-binding (RRM/RBD/RNP motifs) family protein;(source:Araport11) "RNA binding, mRNA binding" "GO:0003723, GO:0003729" 35.1 not assigned.annotated "(original description: pep chromosome:TAIR10:1:44970:47059:-1 gene:AT1G01080 transcript:AT1G01080.3 gene_biotype:protein_coding transcript_biotype:protein_coding description:RNA-binding (RRM/RBD/RNP motifs) family protein [Source:UniProtKB/TrEMBL;Acc:F4HQH8]) & 33 kDa ribonucleoprotein chloroplastic OS=Nicotiana sylvestris (sp|p19684|roc5_nicsy : 109.0)" diff --git a/spec/test/djornl/duplicate_data/hithruput-edges.csv b/spec/test/djornl/duplicate_data/hithruput-edges.csv new file mode 100644 index 00000000..c11caa3d --- /dev/null +++ b/spec/test/djornl/duplicate_data/hithruput-edges.csv @@ -0,0 +1,9 @@ +node1,node2,edge,edge_descrip,layer_descrip +AT1G01010,AT1G01020,2.3,AraNetv2_log-likelihood-score,AraNetv2-HT_high-throughput-ppi +AT1G01010,AT1G01030,2.4,AraNetv2_log-likelihood-score,AraNetv2-HT_high-throughput-ppi +# potentially erroneous line +AT1G01010,AT1G01030,2.7,AraNetv2_log-likelihood-score,AraNetv2-HT_high-throughput-ppi +# duplicated line from the other file +AT1G01050,AT1G01060,2.7,AraNetv2_log-likelihood-score,AraNetv2-LC_lit-curated-ppi +# potentially erroneous duplication from the other file +AT1G01030,AT1G01050,2.6000001,AraNetv2_log-likelihood-score,AraNetv2-CX_pairwise-gene-coexpression diff --git a/spec/test/djornl/duplicate_data/manifest.yaml b/spec/test/djornl/duplicate_data/manifest.yaml new file mode 100644 index 00000000..beffb367 --- /dev/null +++ b/spec/test/djornl/duplicate_data/manifest.yaml @@ -0,0 +1,39 @@ +name: Dan Jacobson Exascale data +release_date: "2020-06-06" +home_url: "https://github.com/kbase/exascale_data" +file_list: + - data_type: edge + path: edges.tsv + date: "2020-12-25" + + - data_type: edge + path: hithruput-edges.csv + date: "2020-12-25" + + - data_type: node + path: nodes.csv + date: "2019-01-01" + + - data_type: cluster + cluster_prefix: markov_i2 + path: I2_named.tsv + + - data_type: cluster + cluster_prefix: markov_i4 + path: I4_named.tsv + + - data_type: cluster + cluster_prefix: markov_i6 + path: I6_named.tsv + + - data_type: cluster + cluster_prefix: markov_i6 + path: I6_copy.csv + + - data_type: node + path: pheno_nodes.csv + date: "2019-01-01" + + - data_type: node + path: extra_node.tsv + date: "2019-01-01" diff --git a/spec/test/djornl/duplicate_data/nodes.csv b/spec/test/djornl/duplicate_data/nodes.csv new file mode 100644 index 00000000..b1938272 --- /dev/null +++ b/spec/test/djornl/duplicate_data/nodes.csv @@ -0,0 +1,13 @@ +# data_type: node +node_id,node_type,transcript,gene_symbol,gene_full_name,gene_model_type,TAIR_Computational_description,TAIR_Curator_summary,TAIR_short_description,GO_description,GO_terms,MapMan_bin,MapMan_name,MapMan_description,pheno_AraGWAS_ID,pheno_description,pheno_pto_name,pheno_pto_description,pheno_ref,User_Notes +AT1G01010,gene,AT1G01010.1,NTL10,NAC domain containing protein 1,protein_coding,NAC domain containing protein 1;(source:Araport11),,NAC domain containing protein 1,"DNA-binding transcription factor activity, DNA binding","GO:0003700, GO:0003677",15.5.17,.RNA biosynthesis.transcriptional regulation.transcription factor (NAC),transcription factor (NAC) (original description: pep chromosome:TAIR10:1:3631:5899:1 gene:AT1G01010 transcript:AT1G01010.1 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:NAC001 description:NAC domain-containing protein 1 [Source:UniProtKB/Swiss-Prot;Acc:Q0WV96]),,,,,, +AT1G01020,gene,AT1G01020.6,ARV1,,protein_coding,ARV1 family protein;(source:Araport11),,,molecular_function,GO:0003674,35.1,not assigned.annotated,(original description: pep chromosome:TAIR10:1:6788:8737:-1 gene:AT1G01020 transcript:AT1G01020.6 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:ARV1 description:ARV1 family protein [Source:UniProtKB/TrEMBL;Acc:Q5MK24]) & no description available(sp|q5mk24|arv1_arath : 99.4),,,,,, +AT1G01030,gene,AT1G01030.2,NGA3,NGATHA3,protein_coding,AP2/B3-like transcriptional factor family protein;(source:Araport11),,,"DNA-binding transcription factor activity, DNA binding","GO:0003700, GO:0003677",15.5.5.3,.RNA biosynthesis.transcriptional regulation.B3 transcription factor superfamily.transcription factor (RAV/NGATHA),transcription factor (RAV/NGATHA) (original description: pep chromosome:TAIR10:1:11649:13714:-1 gene:AT1G01030 transcript:AT1G01030.2 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:NGA3 description:B3 domain-containing transcription factor NGA3 [Source:UniProtKB/Swiss-Prot;Acc:Q9MAN1]),,,,,, +AT1G01040,gene,AT1G01040.2,SUS1,SUSPENSOR 1,protein_coding,dicer-like 1;(source:Araport11),"Encodes a Dicer homolog. Dicer is a RNA helicase involved in microRNA processing. Mutations in this locus can result in embryo lethality. Embryo shape at seed maturity is globular-elongate. Other mutants convert the floral meristems to an indeterminate state, others yet show defects in ovule development. mRNA is expressed in all shoot tissues. DCL1 is able to produce miRNAs and siRNAs. The mRNA is cell-to-cell mobile.",dicer-like 1,"metal ion binding, protein binding, ribonuclease III activity, ATP-dependent helicase activity, ATP binding, RNA binding, helicase activity, double-stranded RNA binding, DNA binding","GO:0046872, GO:0005515, GO:0004525, GO:0008026, GO:0005524, GO:0003723, GO:0004386, GO:0003725, GO:0003677",16.10.2.1.1,.RNA processing.mRNA silencing.miRNA pathway.DCL1-HYL1 miRNA biogenesis complex.endoribonuclease component DCL1,endoribonuclease component DCL1 of DCL1-HYL1 miRNA biogenesis complex (original description: pep chromosome:TAIR10:1:23416:31120:1 gene:AT1G01040 transcript:AT1G01040.2 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:DCL1 description:Dicer-like 1 [Source:UniProtKB/TrEMBL;Acc:F4HQG6]),,,,,, +AT1G01050,gene,AT1G01050.2,PPa1,pyrophosphorylase 1,protein_coding,pyrophosphorylase 1;(source:Araport11),,,inorganic diphosphatase activity,GO:0004427,35.1,not assigned.annotated,(original description: pep chromosome:TAIR10:1:31382:33009:-1 gene:AT1G01050 transcript:AT1G01050.2 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:PPA1 description:Soluble inorganic pyrophosphatase 1 [Source:UniProtKB/Swiss-Prot;Acc:Q93V56]) & Soluble inorganic pyrophosphatase 1 OS=Arabidopsis thaliana (sp|q93v56|ipyr1_arath : 419.0),,,,,, +AT1G01060,gene,AT1G01060.8,LHY1,LATE ELONGATED HYPOCOTYL 1,protein_coding,Homeodomain-like superfamily protein;(source:Araport11),,,"DNA-binding transcription factor activity, DNA binding, transcription regulatory region DNA binding","GO:0003700, GO:0003677, GO:0044212",27.1.1,.Multi-process regulation.circadian clock system.core oscillator protein (LHY|CCA1),circadian clock core oscillator protein (LHY|CCA1) (original description: pep chromosome:TAIR10:1:33967:37230:-1 gene:AT1G01060 transcript:AT1G01060.8 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:LHY description:LHY1 [Source:UniProtKB/TrEMBL;Acc:A0A178W761]),,,,,, +AT1G01070,gene,AT1G01070.2,UMAMIT28,Usually multiple acids move in and out Transporters 28,protein_coding,nodulin MtN21 /EamA-like transporter family protein;(source:Araport11),Encodes a plasma membrane-localized amino acid transporter likely involved in amino acid export in the developing seed.,nodulin MtN21 /EamA-like transporter family protein,L-glutamine transmembrane transporter activity,GO:0015186,24.2.1.5,.Solute transport.carrier-mediated transport.DMT superfamily.solute transporter (UmamiT),solute transporter (UmamiT) (original description: pep chromosome:TAIR10:1:38752:40945:-1 gene:AT1G01070 transcript:AT1G01070.2 gene_biotype:protein_coding transcript_biotype:protein_coding description:WAT1-related protein [Source:UniProtKB/TrEMBL;Acc:A0A178WFU3]),,,,,, +AT1G01080,gene,AT1G01080.3,,,protein_coding,RNA-binding (RRM/RBD/RNP motifs) family protein;(source:Araport11),,,"RNA binding, mRNA binding","GO:0003723, GO:0003729",35.1,not assigned.annotated,"(original description: pep chromosome:TAIR10:1:44970:47059:-1 gene:AT1G01080 transcript:AT1G01080.3 gene_biotype:protein_coding transcript_biotype:protein_coding description:RNA-binding (RRM/RBD/RNP motifs) family protein [Source:UniProtKB/TrEMBL;Acc:F4HQH8]) & 33 kDa ribonucleoprotein, chloroplastic OS=Nicotiana sylvestris (sp|p19684|roc5_nicsy : 109.0)",,,,,, +AT1G01090,gene,AT1G01090.1,PDH-E1 ALPHA,pyruvate dehydrogenase E1 alpha,protein_coding,pyruvate dehydrogenase E1 alpha;(source:Araport11),pyruvate dehydrogenase E1 alpha subunit,pyruvate dehydrogenase E1 alpha,"pyruvate dehydrogenase (acetyl-transferring) activity, protein binding","GO:0004739, GO:0005515",5.1.2.2.1.1,.Lipid metabolism.fatty acid biosynthesis.acetyl-CoA generation.plastidial pyruvate dehydrogenase complex.E1 pyruvate dehydrogenase subcomplex.subunit alpha,subunit alpha of E1 pyruvate dehydrogenase component (original description: pep chromosome:TAIR10:1:47234:49304:-1 gene:AT1G01090 transcript:AT1G01090.1 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:PDH-E1 ALPHA description:Pyruvate dehydrogenase E1 component subunit alpha [Source:UniProtKB/TrEMBL;Acc:A0A178W8A7]),,,,,, +# duplicated line +AT1G01050,gene,AT1G01050.2,PPa1,pyrophosphorylase 1,protein_coding,pyrophosphorylase 1;(source:Araport11),,,inorganic diphosphatase activity,GO:0004427,35.1,not assigned.annotated,(original description: pep chromosome:TAIR10:1:31382:33009:-1 gene:AT1G01050 transcript:AT1G01050.2 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:PPA1 description:Soluble inorganic pyrophosphatase 1 [Source:UniProtKB/Swiss-Prot;Acc:Q93V56]) & Soluble inorganic pyrophosphatase 1 OS=Arabidopsis thaliana (sp|q93v56|ipyr1_arath : 419.0),,,,,, diff --git a/spec/test/djornl/duplicate_data/pheno_nodes.csv b/spec/test/djornl/duplicate_data/pheno_nodes.csv new file mode 100644 index 00000000..83fbf4be --- /dev/null +++ b/spec/test/djornl/duplicate_data/pheno_nodes.csv @@ -0,0 +1,5 @@ +node_id,node_type,pheno_AraGWAS_ID,pheno_description,pheno_pto_name,pheno_pto_description,pheno_ref,User_Notes +As2,pheno,10.21958/phenotype:103,,bacterial disease resistance,The resistance exhibited by a plant or a group of plants (population) in response to the disease caused by a bacterial pathogen infection as compared to the susceptible and/or the reference plants of the same species. [GR:pj],"Atwell et. al, Nature 2010", +As75,pheno,10.21958/phenotype:67,"Arsenic concentrations in leaves, grown in soil. Elemental analysis was performed with an ICP-MS (PerkinElmer). Sample normalized to calculated weights as described in Baxter et al., 2008",arsenic concentration,A mineral and ion content related trait (TO:0000465) which is the concentration of arsenic (CHEBI:22632) in some plant structure (PO:0009011). [GR:Karthik],"Atwell et. al, Nature 2010", +Na23,pheno,10.21958/phenotype:5,"Sodium concentrations in leaves, grown in soil. Elemental analysis was performed with an ICP-MS (PerkinElmer). Sample normalized to calculated weights as described in Baxter et al., 2008",sodium concentration,The total sodium ion concentration measured in a given volume of a plant or a plant part or plant extract. [GR:pj],"Atwell et. al, Nature 2010", +SDV,pheno,10.21958/phenotype:104,"Number of days following stratification to opening of first flower. The experiment was stopped at 200 d, and accessions that had not flowered at that point were assigned a value of 200",days to flowering trait,"A flowering time trait (TO:0002616)which is the number of days required for an individual flower (PO:0009046), a whole plant (PO:0000003) or a plant population to reach flowering stage (PO:0007616) from a predetermined time point (e.g. the date of seed sowing, seedling transplant, or seedling emergence). [GR:pj, TO:cooperl]","Atwell et. al, Nature 2010", diff --git a/spec/test/djornl/empty_files/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv b/spec/test/djornl/empty_files/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv index 118cfbcc..ab31e045 100644 --- a/spec/test/djornl/empty_files/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv +++ b/spec/test/djornl/empty_files/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv @@ -1 +1 @@ -node_id,node_type,transcript,gene_symbol,gene_full_name,gene_model_type,TAIR_Computational_description,TAIR_Curator_summary,TAIR_short_description,GO_descr,GO_terms,MapMan_bin,MapMan_name,MapMan_descr,pheno_AraGWAS_ID,pheno_descrip1,pheno_descrip2,pheno_descrip3,pheno_ref,UserNotes +node_id,node_type,transcript,gene_symbol,gene_full_name,gene_model_type,TAIR_Computational_description,TAIR_Curator_summary,TAIR_short_description,GO_description,GO_terms,MapMan_bin,MapMan_name,MapMan_description,pheno_AraGWAS_ID,pheno_description,pheno_pto_name,pheno_pto_description,pheno_ref,User_Notes diff --git a/spec/test/djornl/empty_files/cluster_data/comment_only.tsv b/spec/test/djornl/empty_files/cluster_data/comment_only.tsv new file mode 100644 index 00000000..9ce2fbf1 --- /dev/null +++ b/spec/test/djornl/empty_files/cluster_data/comment_only.tsv @@ -0,0 +1 @@ +# what? diff --git a/spec/test/djornl/empty_files/cluster_data/headers_only.tsv b/spec/test/djornl/empty_files/cluster_data/headers_only.tsv new file mode 100644 index 00000000..3233ca40 --- /dev/null +++ b/spec/test/djornl/empty_files/cluster_data/headers_only.tsv @@ -0,0 +1,4 @@ +cluster_id node_ids +# comment +# comment +# comment diff --git a/spec/test/djornl/empty_files/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I2_named.tsv b/spec/test/djornl/empty_files/cluster_data/no_content.tsv similarity index 100% rename from spec/test/djornl/empty_files/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I2_named.tsv rename to spec/test/djornl/empty_files/cluster_data/no_content.tsv diff --git a/spec/test/djornl/empty_files/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I4_named.tsv b/spec/test/djornl/empty_files/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I4_named.tsv deleted file mode 100644 index 8b137891..00000000 --- a/spec/test/djornl/empty_files/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I4_named.tsv +++ /dev/null @@ -1 +0,0 @@ - diff --git a/spec/test/djornl/empty_files/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I6_named.tsv b/spec/test/djornl/empty_files/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I6_named.tsv deleted file mode 100644 index 8b137891..00000000 --- a/spec/test/djornl/empty_files/cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I6_named.tsv +++ /dev/null @@ -1 +0,0 @@ - diff --git a/spec/test/djornl/empty_files/manifest.yaml b/spec/test/djornl/empty_files/manifest.yaml index fb231666..ae04f7a4 100644 --- a/spec/test/djornl/empty_files/manifest.yaml +++ b/spec/test/djornl/empty_files/manifest.yaml @@ -9,12 +9,12 @@ file_list: - data_type: cluster cluster_prefix: markov_i2 - path: cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I2_named.tsv + path: cluster_data/headers_only.tsv - data_type: cluster cluster_prefix: markov_i4 - path: cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I4_named.tsv + path: cluster_data/no_content.tsv - data_type: cluster cluster_prefix: markov_i6 - path: cluster_data/out.aranetv2_subnet_AT-CX_top10percent_anno_AF_082919.abc.I6_named.tsv + path: cluster_data/comment_only.tsv diff --git a/spec/test/djornl/empty_files/merged_edges-AMW-060820_AF.tsv b/spec/test/djornl/empty_files/merged_edges-AMW-060820_AF.tsv index 8b137891..4b2bca02 100644 --- a/spec/test/djornl/empty_files/merged_edges-AMW-060820_AF.tsv +++ b/spec/test/djornl/empty_files/merged_edges-AMW-060820_AF.tsv @@ -1 +1,4 @@ - +# this line is a comment +# so is this line +# oh no +# there's no content in this file! diff --git a/spec/test/djornl/invalid_types/edges.tsv b/spec/test/djornl/invalid_types/edges.tsv new file mode 100644 index 00000000..06bbe9fd --- /dev/null +++ b/spec/test/djornl/invalid_types/edges.tsv @@ -0,0 +1,10 @@ +# data_type: edge +node1 node2 edge edge_descrip layer_descrip +As2 AT1G01020 8.422046084731258 AraGWAS-Association_score Same-Old-Stuff +As2 AT1G01040 6 AraGWAS-Association_score AraGWAS-Phenotype_Associations +As75 AT1G01020 39.98573324312915 AraGWAS-Association_score AraGWAS-Phenotype_Associations +AT1G01010 AT1G01020 2.39322646755088 AraNetv2_log-likelihood-score AraNetv2-HT_high-throughput-ppi +AT1G01010 AT1G01030 2. AraNetv2_log-likelihood-score AraNetv2-HT_high-throughput-ppi +AT1G01010 AT1G01040 "2.39322646755088" AraNetv2_log-likelihood-score raNetv2-DC_ +AT1G01030 AT1G01050 25494618241936697 AraNetv2_log-likelihood-score AraNetv2-CX_pairwise-gene-coexpression +AT1G01050 AT1G01060 score! AraNetv2_log-likelihood-score AraNetv2-LC_lit-curated-ppi diff --git a/spec/test/djornl/invalid_types/manifest.yaml b/spec/test/djornl/invalid_types/manifest.yaml index 50c5f454..e37ca783 100644 --- a/spec/test/djornl/invalid_types/manifest.yaml +++ b/spec/test/djornl/invalid_types/manifest.yaml @@ -2,7 +2,11 @@ name: Dan Jacobson Exascale data release_date: "2020-06-06" file_list: - data_type: edge - path: merged_edges-AMW-060820_AF.tsv + path: edges.tsv - data_type: node - path: aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv + path: nodes.csv + + - data_type: cluster + path: markov2_named.tsv + cluster_prefix: markov_i2 diff --git a/spec/test/djornl/invalid_types/markov2_named.tsv b/spec/test/djornl/invalid_types/markov2_named.tsv new file mode 100644 index 00000000..f82190fd --- /dev/null +++ b/spec/test/djornl/invalid_types/markov2_named.tsv @@ -0,0 +1,9 @@ +cluster_id node_ids +# data_type: cluster +# cluster_prefix: markov_i2 +# title: Markov clustering, inflation = 2 +Cluster1 AT1G01010,AT1G01030,AT1G01040 +Cluster2 AT1G01050,AT1G01060,AT1G01070 +HoneyNutCluster3 AT1G01080,AT1G01090 +Cluster4 +Cluster5 AT1G01020 diff --git a/spec/test/djornl/invalid_types/merged_edges-AMW-060820_AF.tsv b/spec/test/djornl/invalid_types/merged_edges-AMW-060820_AF.tsv deleted file mode 100644 index a98f49f9..00000000 --- a/spec/test/djornl/invalid_types/merged_edges-AMW-060820_AF.tsv +++ /dev/null @@ -1,10 +0,0 @@ -# data_type: edge -node1 node2 edge edge_descrip layer_descrip -As2 AT1G01020 8.422046084731258 AraGWAS-Association_score AraGWAS-Some-Old-Rubbish-I-Made-Up -As2 AT1G01040 5.422046084731258 AraGWAS-Association_score AraGWAS-Phenotype_Associations -As75 AT1G01020 39.98573324312915 AraGWAS-Association_score AraGWAS-Phenotype_Associations -AT1G01010 AT1G01020 2.39322646755088 AraNetv2_log-likelihood-score AraNetv2-HT_high-throughput-ppi -AT1G01010 AT1G01030 2.39322646755088 AraNetv2_log-likelihood-score AraNetv2-HT_high-throughput-ppi -AT1G01010 AT1G01040 2.39322646755088 AraNetv2_log-likelihood-score raNetv2-DC_domain-co-occurrence -AT1G01030 AT1G01050 2.5494618241936697 AraNetv2_log-likelihood-score AraNetv2-CX_pairwise-gene-coexpression -AT1G01050 AT1G01060 4.34242054808616 AraNetv2_log-likelihood-score AraNetv2-LC_lit-curated-ppi diff --git a/spec/test/djornl/invalid_types/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv b/spec/test/djornl/invalid_types/nodes.csv similarity index 98% rename from spec/test/djornl/invalid_types/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv rename to spec/test/djornl/invalid_types/nodes.csv index e98310e5..e469f003 100644 --- a/spec/test/djornl/invalid_types/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv +++ b/spec/test/djornl/invalid_types/nodes.csv @@ -1,4 +1,4 @@ -node_id,node_type,transcript,gene_symbol,gene_full_name,gene_model_type,TAIR_Computational_description,TAIR_Curator_summary,TAIR_short_description,GO_descr,GO_terms,MapMan_bin,MapMan_name,MapMan_descr,pheno_AraGWAS_ID,pheno_descrip1,pheno_descrip2,pheno_descrip3,pheno_ref,User_Notes +node_id,node_type,transcript,gene_symbol,gene_full_name,gene_model_type,TAIR_Computational_description,TAIR_Curator_summary,TAIR_short_description,GO_description,GO_terms,MapMan_bin,MapMan_name,MapMan_description,pheno_AraGWAS_ID,pheno_description,pheno_pto_name,pheno_pto_description,pheno_ref,User_Notes # data_type: node As2,pheno,,,,,,,,,,,,,10.21958/phenotype:103,,bacterial disease resistance,The resistance exhibited by a plant or a group of plants (population) in response to the disease caused by a bacterial pathogen infection as compared to the susceptible and/or the reference plants of the same species. [GR:pj],"Atwell et. al, Nature 2010", As75,pheno,,,,,,,,,,,,,10.21958/phenotype:67,"Arsenic concentrations in leaves, grown in soil. Elemental analysis was performed with an ICP-MS (PerkinElmer). Sample normalized to calculated weights as described in Baxter et al., 2008",arsenic concentration,A mineral and ion content related trait (TO:0000465) which is the concentration of arsenic (CHEBI:22632) in some plant structure (PO:0009011). [GR:Karthik],"Atwell et. al, Nature 2010", diff --git a/spec/test/djornl/results.json b/spec/test/djornl/results.json index e15408d2..9eefcebc 100644 --- a/spec/test/djornl/results.json +++ b/spec/test/djornl/results.json @@ -13,16 +13,16 @@ {"_key": "AT1G01090"} ], "edges": [ - {"_key": "As2__AT1G01020__pheno_assn__8.4", "_from": "djornl_node/As2", "_to": "djornl_node/AT1G01020", "edge_type": "pheno_assn", "score": 8.4}, - {"_key": "As2__AT1G01040__pheno_assn__5.4", "_from": "djornl_node/As2", "_to": "djornl_node/AT1G01040", "edge_type": "pheno_assn", "score": 5.4}, - {"_key": "As75__AT1G01020__pheno_assn__39.9", "_from": "djornl_node/As75", "_to": "djornl_node/AT1G01020", "edge_type": "pheno_assn", "score": 39.9}, - {"_key": "AT1G01010__AT1G01020__ppi_hithru__2.3", "_from": "djornl_node/AT1G01010", "_to": "djornl_node/AT1G01020", "edge_type": "ppi_hithru", "score": 2.3}, - {"_key": "AT1G01010__AT1G01030__ppi_hithru__2.4", "_from": "djornl_node/AT1G01010", "_to": "djornl_node/AT1G01030", "edge_type": "ppi_hithru", "score": 2.4}, - {"_key": "AT1G01010__AT1G01040__domain_co_occur__2.5", "_from": "djornl_node/AT1G01010", "_to": "djornl_node/AT1G01040", "edge_type": "domain_co_occur", "score": 2.5}, - {"_key": "AT1G01010__AT1G01040__ppi_liter__170.5", "_from": "djornl_node/AT1G01010", "_to": "djornl_node/AT1G01040", "edge_type": "ppi_liter", "score": 170.5}, - {"_key": "AT1G01030__AT1G01050__gene_coexpr__2.6", "_from": "djornl_node/AT1G01030", "_to": "djornl_node/AT1G01050", "edge_type": "gene_coexpr", "score": 2.6}, - {"_key": "AT1G01050__AT1G01060__ppi_liter__2.7", "_from": "djornl_node/AT1G01050", "_to": "djornl_node/AT1G01060", "edge_type": "ppi_liter", "score": 2.7}, - {"_key": "AT1G01080__AT1G01090__ppi_liter__2.8", "_from": "djornl_node/AT1G01080", "_to": "djornl_node/AT1G01090", "edge_type": "ppi_liter", "score": 2.8} + {"_key": "As2__AT1G01020__AraGWAS-Phenotype_Associations__8.4", "_from": "djornl_node/As2", "_to": "djornl_node/AT1G01020", "edge_type": "AraGWAS-Phenotype_Associations", "score": 8.4}, + {"_key": "As2__AT1G01040__AraGWAS-Phenotype_Associations__5.4", "_from": "djornl_node/As2", "_to": "djornl_node/AT1G01040", "edge_type": "AraGWAS-Phenotype_Associations", "score": 5.4}, + {"_key": "As75__AT1G01020__AraGWAS-Phenotype_Associations__39.9", "_from": "djornl_node/As75", "_to": "djornl_node/AT1G01020", "edge_type": "AraGWAS-Phenotype_Associations", "score": 39.9}, + {"_key": "AT1G01010__AT1G01020__AraNetv2-HT_high-throughput-ppi__2.3", "_from": "djornl_node/AT1G01010", "_to": "djornl_node/AT1G01020", "edge_type": "AraNetv2-HT_high-throughput-ppi", "score": 2.3}, + {"_key": "AT1G01010__AT1G01030__AraNetv2-HT_high-throughput-ppi__2.4", "_from": "djornl_node/AT1G01010", "_to": "djornl_node/AT1G01030", "edge_type": "AraNetv2-HT_high-throughput-ppi", "score": 2.4}, + {"_key": "AT1G01010__AT1G01040__AraNetv2-DC_domain-co-occurrence__2.5", "_from": "djornl_node/AT1G01010", "_to": "djornl_node/AT1G01040", "edge_type": "AraNetv2-DC_domain-co-occurrence", "score": 2.5}, + {"_key": "AT1G01010__AT1G01040__AraNetv2-LC_lit-curated-ppi__170.5", "_from": "djornl_node/AT1G01010", "_to": "djornl_node/AT1G01040", "edge_type": "AraNetv2-LC_lit-curated-ppi", "score": 170.5}, + {"_key": "AT1G01030__AT1G01050__AraNetv2-CX_pairwise-gene-coexpression__2.6", "_from": "djornl_node/AT1G01030", "_to": "djornl_node/AT1G01050", "edge_type": "AraNetv2-CX_pairwise-gene-coexpression", "score": 2.6}, + {"_key": "AT1G01050__AT1G01060__AraNetv2-LC_lit-curated-ppi__2.7", "_from": "djornl_node/AT1G01050", "_to": "djornl_node/AT1G01060", "edge_type": "AraNetv2-LC_lit-curated-ppi", "score": 2.7}, + {"_key": "AT1G01080__AT1G01090__AraNetv2-LC_lit-curated-ppi__2.8", "_from": "djornl_node/AT1G01080", "_to": "djornl_node/AT1G01090", "edge_type": "AraNetv2-LC_lit-curated-ppi", "score": 2.8} ] }, "load_cluster_data": { @@ -33,9 +33,9 @@ {"_key": "AT1G01050", "clusters": ["markov_i2:2"]}, {"_key": "AT1G01060", "clusters": ["markov_i2:2"]}, {"_key": "AT1G01070", "clusters": ["markov_i2:2", "markov_i6:2"]}, - {"_key": "AT1G01080", "clusters": ["markov_i2:3"]}, {"_key": "AT1G01090", "clusters": ["markov_i2:3", "markov_i6:1"]}, - {"_key": "AT1G01020", "clusters": ["markov_i2:5", "markov_i6:3"]} + {"_key": "AT1G01020", "clusters": ["markov_i2:5", "markov_i6:3"]}, + {"_key": "AT1G01080", "clusters": ["markov_i4:3"]} ] }, "load_node_metadata": { @@ -74,16 +74,16 @@ "SDV" ], "edges": [ - "As2__AT1G01020__pheno_assn__8.4", - "As2__AT1G01040__pheno_assn__5.4", - "As75__AT1G01020__pheno_assn__39.9", - "AT1G01010__AT1G01020__ppi_hithru__2.3", - "AT1G01010__AT1G01030__ppi_hithru__2.4", - "AT1G01010__AT1G01040__domain_co_occur__2.5", - "AT1G01010__AT1G01040__ppi_liter__170.5", - "AT1G01030__AT1G01050__gene_coexpr__2.6", - "AT1G01050__AT1G01060__ppi_liter__2.7", - "AT1G01080__AT1G01090__ppi_liter__2.8" + "As2__AT1G01020__AraGWAS-Phenotype_Associations__8.4", + "As2__AT1G01040__AraGWAS-Phenotype_Associations__5.4", + "As75__AT1G01020__AraGWAS-Phenotype_Associations__39.9", + "AT1G01010__AT1G01020__AraNetv2-HT_high-throughput-ppi__2.3", + "AT1G01010__AT1G01030__AraNetv2-HT_high-throughput-ppi__2.4", + "AT1G01010__AT1G01040__AraNetv2-DC_domain-co-occurrence__2.5", + "AT1G01010__AT1G01040__AraNetv2-LC_lit-curated-ppi__170.5", + "AT1G01030__AT1G01050__AraNetv2-CX_pairwise-gene-coexpression__2.6", + "AT1G01050__AT1G01060__AraNetv2-LC_lit-curated-ppi__2.7", + "AT1G01080__AT1G01090__AraNetv2-LC_lit-curated-ppi__2.8" ] }, "fetch_genes": { @@ -109,24 +109,24 @@ "AT1G01040" ], "edges": [ - "AT1G01010__AT1G01020__ppi_hithru__2.3", - "AT1G01010__AT1G01030__ppi_hithru__2.4", - "AT1G01010__AT1G01040__domain_co_occur__2.5", - "AT1G01010__AT1G01040__ppi_liter__170.5" + "AT1G01010__AT1G01020__AraNetv2-HT_high-throughput-ppi__2.3", + "AT1G01010__AT1G01030__AraNetv2-HT_high-throughput-ppi__2.4", + "AT1G01010__AT1G01040__AraNetv2-DC_domain-co-occurrence__2.5", + "AT1G01010__AT1G01040__AraNetv2-LC_lit-curated-ppi__170.5" ] }, "5": { "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060"], "edges": [ - "As2__AT1G01020__pheno_assn__8.4", - "As2__AT1G01040__pheno_assn__5.4", - "As75__AT1G01020__pheno_assn__39.9", - "AT1G01010__AT1G01020__ppi_hithru__2.3", - "AT1G01010__AT1G01030__ppi_hithru__2.4", - "AT1G01010__AT1G01040__domain_co_occur__2.5", - "AT1G01010__AT1G01040__ppi_liter__170.5", - "AT1G01030__AT1G01050__gene_coexpr__2.6", - "AT1G01050__AT1G01060__ppi_liter__2.7" + "As2__AT1G01020__AraGWAS-Phenotype_Associations__8.4", + "As2__AT1G01040__AraGWAS-Phenotype_Associations__5.4", + "As75__AT1G01020__AraGWAS-Phenotype_Associations__39.9", + "AT1G01010__AT1G01020__AraNetv2-HT_high-throughput-ppi__2.3", + "AT1G01010__AT1G01030__AraNetv2-HT_high-throughput-ppi__2.4", + "AT1G01010__AT1G01040__AraNetv2-DC_domain-co-occurrence__2.5", + "AT1G01010__AT1G01040__AraNetv2-LC_lit-curated-ppi__170.5", + "AT1G01030__AT1G01050__AraNetv2-CX_pairwise-gene-coexpression__2.6", + "AT1G01050__AT1G01060__AraNetv2-LC_lit-curated-ppi__2.7" ] } } @@ -140,23 +140,23 @@ "1": { "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01070"], "edges": [ - "As2__AT1G01020__pheno_assn__8.4", - "As75__AT1G01020__pheno_assn__39.9", - "AT1G01010__AT1G01020__ppi_hithru__2.3" + "As2__AT1G01020__AraGWAS-Phenotype_Associations__8.4", + "As75__AT1G01020__AraGWAS-Phenotype_Associations__39.9", + "AT1G01010__AT1G01020__AraNetv2-HT_high-throughput-ppi__2.3" ] }, "5": { "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060", "AT1G01070"], "edges": [ - "As2__AT1G01020__pheno_assn__8.4", - "As2__AT1G01040__pheno_assn__5.4", - "As75__AT1G01020__pheno_assn__39.9", - "AT1G01010__AT1G01020__ppi_hithru__2.3", - "AT1G01010__AT1G01030__ppi_hithru__2.4", - "AT1G01010__AT1G01040__domain_co_occur__2.5", - "AT1G01010__AT1G01040__ppi_liter__170.5", - "AT1G01030__AT1G01050__gene_coexpr__2.6", - "AT1G01050__AT1G01060__ppi_liter__2.7" + "As2__AT1G01020__AraGWAS-Phenotype_Associations__8.4", + "As2__AT1G01040__AraGWAS-Phenotype_Associations__5.4", + "As75__AT1G01020__AraGWAS-Phenotype_Associations__39.9", + "AT1G01010__AT1G01020__AraNetv2-HT_high-throughput-ppi__2.3", + "AT1G01010__AT1G01030__AraNetv2-HT_high-throughput-ppi__2.4", + "AT1G01010__AT1G01040__AraNetv2-DC_domain-co-occurrence__2.5", + "AT1G01010__AT1G01040__AraNetv2-LC_lit-curated-ppi__170.5", + "AT1G01030__AT1G01050__AraNetv2-CX_pairwise-gene-coexpression__2.6", + "AT1G01050__AT1G01060__AraNetv2-LC_lit-curated-ppi__2.7" ] } } @@ -181,22 +181,22 @@ "1": { "nodes": ["As2", "AT1G01020", "AT1G01040"], "edges": [ - "As2__AT1G01020__pheno_assn__8.4", - "As2__AT1G01040__pheno_assn__5.4" + "As2__AT1G01020__AraGWAS-Phenotype_Associations__8.4", + "As2__AT1G01040__AraGWAS-Phenotype_Associations__5.4" ] }, "5": { "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060"], "edges": [ - "As2__AT1G01020__pheno_assn__8.4", - "As2__AT1G01040__pheno_assn__5.4", - "As75__AT1G01020__pheno_assn__39.9", - "AT1G01010__AT1G01020__ppi_hithru__2.3", - "AT1G01010__AT1G01030__ppi_hithru__2.4", - "AT1G01010__AT1G01040__domain_co_occur__2.5", - "AT1G01010__AT1G01040__ppi_liter__170.5", - "AT1G01030__AT1G01050__gene_coexpr__2.6", - "AT1G01050__AT1G01060__ppi_liter__2.7" + "As2__AT1G01020__AraGWAS-Phenotype_Associations__8.4", + "As2__AT1G01040__AraGWAS-Phenotype_Associations__5.4", + "As75__AT1G01020__AraGWAS-Phenotype_Associations__39.9", + "AT1G01010__AT1G01020__AraNetv2-HT_high-throughput-ppi__2.3", + "AT1G01010__AT1G01030__AraNetv2-HT_high-throughput-ppi__2.4", + "AT1G01010__AT1G01040__AraNetv2-DC_domain-co-occurrence__2.5", + "AT1G01010__AT1G01040__AraNetv2-LC_lit-curated-ppi__170.5", + "AT1G01030__AT1G01050__AraNetv2-CX_pairwise-gene-coexpression__2.6", + "AT1G01050__AT1G01060__AraNetv2-LC_lit-curated-ppi__2.7" ] } } @@ -210,22 +210,22 @@ "1": { "nodes": ["As2", "Na23", "AT1G01020", "AT1G01040"], "edges": [ - "As2__AT1G01020__pheno_assn__8.4", - "As2__AT1G01040__pheno_assn__5.4" + "As2__AT1G01020__AraGWAS-Phenotype_Associations__8.4", + "As2__AT1G01040__AraGWAS-Phenotype_Associations__5.4" ] }, "5": { "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060", "Na23"], "edges": [ - "As2__AT1G01020__pheno_assn__8.4", - "As2__AT1G01040__pheno_assn__5.4", - "As75__AT1G01020__pheno_assn__39.9", - "AT1G01010__AT1G01020__ppi_hithru__2.3", - "AT1G01010__AT1G01030__ppi_hithru__2.4", - "AT1G01010__AT1G01040__domain_co_occur__2.5", - "AT1G01010__AT1G01040__ppi_liter__170.5", - "AT1G01030__AT1G01050__gene_coexpr__2.6", - "AT1G01050__AT1G01060__ppi_liter__2.7" + "As2__AT1G01020__AraGWAS-Phenotype_Associations__8.4", + "As2__AT1G01040__AraGWAS-Phenotype_Associations__5.4", + "As75__AT1G01020__AraGWAS-Phenotype_Associations__39.9", + "AT1G01010__AT1G01020__AraNetv2-HT_high-throughput-ppi__2.3", + "AT1G01010__AT1G01030__AraNetv2-HT_high-throughput-ppi__2.4", + "AT1G01010__AT1G01040__AraNetv2-DC_domain-co-occurrence__2.5", + "AT1G01010__AT1G01040__AraNetv2-LC_lit-curated-ppi__170.5", + "AT1G01030__AT1G01050__AraNetv2-CX_pairwise-gene-coexpression__2.6", + "AT1G01050__AT1G01060__AraNetv2-LC_lit-curated-ppi__2.7" ] } } @@ -250,25 +250,25 @@ "1": { "nodes": ["As2", "AT1G01010", "AT1G01040", "AT1G01080", "AT1G01090"], "edges": [ - "As2__AT1G01040__pheno_assn__5.4", - "AT1G01010__AT1G01040__domain_co_occur__2.5", - "AT1G01010__AT1G01040__ppi_liter__170.5", - "AT1G01080__AT1G01090__ppi_liter__2.8" + "As2__AT1G01040__AraGWAS-Phenotype_Associations__5.4", + "AT1G01010__AT1G01040__AraNetv2-DC_domain-co-occurrence__2.5", + "AT1G01010__AT1G01040__AraNetv2-LC_lit-curated-ppi__170.5", + "AT1G01080__AT1G01090__AraNetv2-LC_lit-curated-ppi__2.8" ] }, "5": { "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060", "AT1G01080", "AT1G01090"], "edges": [ - "As2__AT1G01020__pheno_assn__8.4", - "As2__AT1G01040__pheno_assn__5.4", - "As75__AT1G01020__pheno_assn__39.9", - "AT1G01010__AT1G01020__ppi_hithru__2.3", - "AT1G01010__AT1G01030__ppi_hithru__2.4", - "AT1G01010__AT1G01040__domain_co_occur__2.5", - "AT1G01010__AT1G01040__ppi_liter__170.5", - "AT1G01030__AT1G01050__gene_coexpr__2.6", - "AT1G01050__AT1G01060__ppi_liter__2.7", - "AT1G01080__AT1G01090__ppi_liter__2.8" + "As2__AT1G01020__AraGWAS-Phenotype_Associations__8.4", + "As2__AT1G01040__AraGWAS-Phenotype_Associations__5.4", + "As75__AT1G01020__AraGWAS-Phenotype_Associations__39.9", + "AT1G01010__AT1G01020__AraNetv2-HT_high-throughput-ppi__2.3", + "AT1G01010__AT1G01030__AraNetv2-HT_high-throughput-ppi__2.4", + "AT1G01010__AT1G01040__AraNetv2-DC_domain-co-occurrence__2.5", + "AT1G01010__AT1G01040__AraNetv2-LC_lit-curated-ppi__170.5", + "AT1G01030__AT1G01050__AraNetv2-CX_pairwise-gene-coexpression__2.6", + "AT1G01050__AT1G01060__AraNetv2-LC_lit-curated-ppi__2.7", + "AT1G01080__AT1G01090__AraNetv2-LC_lit-curated-ppi__2.8" ] } } @@ -294,25 +294,25 @@ "1": { "nodes": ["As2", "AT1G01010", "AT1G01040", "AT1G01080", "AT1G01090"], "edges": [ - "As2__AT1G01040__pheno_assn__5.4", - "AT1G01010__AT1G01040__domain_co_occur__2.5", - "AT1G01010__AT1G01040__ppi_liter__170.5", - "AT1G01080__AT1G01090__ppi_liter__2.8" + "As2__AT1G01040__AraGWAS-Phenotype_Associations__5.4", + "AT1G01010__AT1G01040__AraNetv2-DC_domain-co-occurrence__2.5", + "AT1G01010__AT1G01040__AraNetv2-LC_lit-curated-ppi__170.5", + "AT1G01080__AT1G01090__AraNetv2-LC_lit-curated-ppi__2.8" ] }, "5": { "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060", "AT1G01080", "AT1G01090"], "edges": [ - "As2__AT1G01020__pheno_assn__8.4", - "As2__AT1G01040__pheno_assn__5.4", - "As75__AT1G01020__pheno_assn__39.9", - "AT1G01010__AT1G01020__ppi_hithru__2.3", - "AT1G01010__AT1G01030__ppi_hithru__2.4", - "AT1G01010__AT1G01040__domain_co_occur__2.5", - "AT1G01010__AT1G01040__ppi_liter__170.5", - "AT1G01030__AT1G01050__gene_coexpr__2.6", - "AT1G01050__AT1G01060__ppi_liter__2.7", - "AT1G01080__AT1G01090__ppi_liter__2.8" + "As2__AT1G01020__AraGWAS-Phenotype_Associations__8.4", + "As2__AT1G01040__AraGWAS-Phenotype_Associations__5.4", + "As75__AT1G01020__AraGWAS-Phenotype_Associations__39.9", + "AT1G01010__AT1G01020__AraNetv2-HT_high-throughput-ppi__2.3", + "AT1G01010__AT1G01030__AraNetv2-HT_high-throughput-ppi__2.4", + "AT1G01010__AT1G01040__AraNetv2-DC_domain-co-occurrence__2.5", + "AT1G01010__AT1G01040__AraNetv2-LC_lit-curated-ppi__170.5", + "AT1G01030__AT1G01050__AraNetv2-CX_pairwise-gene-coexpression__2.6", + "AT1G01050__AT1G01060__AraNetv2-LC_lit-curated-ppi__2.7", + "AT1G01080__AT1G01090__AraNetv2-LC_lit-curated-ppi__2.8" ] } } @@ -326,23 +326,23 @@ "1": { "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01070"], "edges": [ - "As2__AT1G01020__pheno_assn__8.4", - "As75__AT1G01020__pheno_assn__39.9", - "AT1G01010__AT1G01020__ppi_hithru__2.3" + "As2__AT1G01020__AraGWAS-Phenotype_Associations__8.4", + "As75__AT1G01020__AraGWAS-Phenotype_Associations__39.9", + "AT1G01010__AT1G01020__AraNetv2-HT_high-throughput-ppi__2.3" ] }, "5": { "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060", "AT1G01070"], "edges": [ - "As2__AT1G01020__pheno_assn__8.4", - "As2__AT1G01040__pheno_assn__5.4", - "As75__AT1G01020__pheno_assn__39.9", - "AT1G01010__AT1G01020__ppi_hithru__2.3", - "AT1G01010__AT1G01030__ppi_hithru__2.4", - "AT1G01010__AT1G01040__domain_co_occur__2.5", - "AT1G01010__AT1G01040__ppi_liter__170.5", - "AT1G01030__AT1G01050__gene_coexpr__2.6", - "AT1G01050__AT1G01060__ppi_liter__2.7" + "As2__AT1G01020__AraGWAS-Phenotype_Associations__8.4", + "As2__AT1G01040__AraGWAS-Phenotype_Associations__5.4", + "As75__AT1G01020__AraGWAS-Phenotype_Associations__39.9", + "AT1G01010__AT1G01020__AraNetv2-HT_high-throughput-ppi__2.3", + "AT1G01010__AT1G01030__AraNetv2-HT_high-throughput-ppi__2.4", + "AT1G01010__AT1G01040__AraNetv2-DC_domain-co-occurrence__2.5", + "AT1G01010__AT1G01040__AraNetv2-LC_lit-curated-ppi__170.5", + "AT1G01030__AT1G01050__AraNetv2-CX_pairwise-gene-coexpression__2.6", + "AT1G01050__AT1G01060__AraNetv2-LC_lit-curated-ppi__2.7" ] } } diff --git a/spec/test/djornl/test_data/I2_named.tsv b/spec/test/djornl/test_data/I2_named.tsv index 3f129851..c7a9c200 100644 --- a/spec/test/djornl/test_data/I2_named.tsv +++ b/spec/test/djornl/test_data/I2_named.tsv @@ -1,9 +1,8 @@ -cluster ids +cluster_id node_ids # data_type: cluster # cluster_prefix: markov_i2 # title: Markov clustering, inflation = 2 Cluster1 AT1G01010,AT1G01030,AT1G01040 Cluster2 AT1G01050,AT1G01060,AT1G01070 -Cluster3 AT1G01080,AT1G01090 -Cluster4 +Cluster3 AT1G01090 Cluster5 AT1G01020 diff --git a/spec/test/djornl/test_data/I4_named.tsv b/spec/test/djornl/test_data/I4_named.tsv index 39e46deb..6e7d91e4 100644 --- a/spec/test/djornl/test_data/I4_named.tsv +++ b/spec/test/djornl/test_data/I4_named.tsv @@ -1,4 +1,5 @@ -cluster ids +cluster_id node_ids # cluster_prefix: markov_i4 # title: Markov clustering, inflation = 4 # data_type: cluster +Cluster3 AT1G01080 diff --git a/spec/test/djornl/test_data/I6_named.tsv b/spec/test/djornl/test_data/I6_named.tsv index d504f6b4..e7688f17 100644 --- a/spec/test/djornl/test_data/I6_named.tsv +++ b/spec/test/djornl/test_data/I6_named.tsv @@ -1,8 +1,8 @@ -cluster ids +cluster_id node_ids # data_type: cluster # cluster_prefix: markov_i6 # title: Markov clustering, inflation = 6 Cluster1 AT1G01040,AT1G01090 Cluster2 AT1G01070 Cluster3 AT1G01010,AT1G01020,AT1G01030 -Cluster4 +# Cluster4 diff --git a/spec/test/djornl/test_data/extra_node.tsv b/spec/test/djornl/test_data/extra_node.tsv index 664425c5..de069d70 100644 --- a/spec/test/djornl/test_data/extra_node.tsv +++ b/spec/test/djornl/test_data/extra_node.tsv @@ -1,3 +1,3 @@ # data_type: node -node_id node_type transcript gene_symbol gene_full_name gene_model_type TAIR_Computational_description TAIR_Curator_summary TAIR_short_description GO_descr GO_terms MapMan_bin MapMan_name MapMan_descr pheno_AraGWAS_ID pheno_descrip1 pheno_descrip2 pheno_descrip3 pheno_ref User_Notes -AT1G01100 gene AT1G01100.4 protein_coding 60S acidic ribosomal protein family;(source:Araport11) 60S acidic ribosomal protein family structural constituent of ribosome, ribonucleoprotein complex binding, protein kinase activator activity GO:0003735, GO:0043021, GO:0030295 17.1.2.1.46 .Protein biosynthesis.ribosome biogenesis.large ribosomal subunit (LSU).LSU proteome.component RPP1 component RPP1 of LSU proteome component (original description: pep chromosome:TAIR10:1:50090:51187:-1 gene:AT1G01100 transcript:AT1G01100.4 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:RPP1A description:60S acidic ribosomal protein P1-1 [Source:UniProtKB/Swiss-Prot;Acc:Q8LCW9]) +node_id node_type transcript gene_symbol gene_full_name gene_model_type TAIR_Computational_description TAIR_Curator_summary TAIR_short_description GO_description GO_terms MapMan_bin MapMan_name MapMan_description +AT1G01100 gene AT1G01100.4 protein_coding 60S acidic ribosomal protein family;(source:Araport11) 60S acidic ribosomal protein family structural constituent of ribosome, ribonucleoprotein complex binding, protein kinase activator activity GO:0003735, GO:0043021, GO:0030295 17.1.2.1.46 .Protein biosynthesis.ribosome biogenesis.large ribosomal subunit (LSU).LSU proteome.component RPP1 component RPP1 of LSU proteome component (original description: pep chromosome:TAIR10:1:50090:51187:-1 gene:AT1G01100 transcript:AT1G01100.4 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:RPP1A description:60S acidic ribosomal protein P1-1 [Source:UniProtKB/Swiss-Prot;Acc:Q8LCW9]) diff --git a/spec/test/djornl/test_data/nodes.csv b/spec/test/djornl/test_data/nodes.csv index 2245bd59..92f60761 100644 --- a/spec/test/djornl/test_data/nodes.csv +++ b/spec/test/djornl/test_data/nodes.csv @@ -1,5 +1,5 @@ # data_type: node -node_id,node_type,transcript,gene_symbol,gene_full_name,gene_model_type,TAIR_Computational_description,TAIR_Curator_summary,TAIR_short_description,GO_descr,GO_terms,MapMan_bin,MapMan_name,MapMan_descr,pheno_AraGWAS_ID,pheno_descrip1,pheno_descrip2,pheno_descrip3,pheno_ref,User_Notes +node_id,node_type,transcript,gene_symbol,gene_full_name,gene_model_type,TAIR_Computational_description,TAIR_Curator_summary,TAIR_short_description,GO_description,GO_terms,MapMan_bin,MapMan_name,MapMan_description,pheno_AraGWAS_ID,pheno_description,pheno_pto_name,pheno_pto_description,pheno_ref,User_Notes AT1G01010,gene,AT1G01010.1,NTL10,NAC domain containing protein 1,protein_coding,NAC domain containing protein 1;(source:Araport11),,NAC domain containing protein 1,"DNA-binding transcription factor activity, DNA binding","GO:0003700, GO:0003677",15.5.17,.RNA biosynthesis.transcriptional regulation.transcription factor (NAC),transcription factor (NAC) (original description: pep chromosome:TAIR10:1:3631:5899:1 gene:AT1G01010 transcript:AT1G01010.1 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:NAC001 description:NAC domain-containing protein 1 [Source:UniProtKB/Swiss-Prot;Acc:Q0WV96]),,,,,, AT1G01020,gene,AT1G01020.6,ARV1,,protein_coding,ARV1 family protein;(source:Araport11),,,molecular_function,GO:0003674,35.1,not assigned.annotated,(original description: pep chromosome:TAIR10:1:6788:8737:-1 gene:AT1G01020 transcript:AT1G01020.6 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:ARV1 description:ARV1 family protein [Source:UniProtKB/TrEMBL;Acc:Q5MK24]) & no description available(sp|q5mk24|arv1_arath : 99.4),,,,,, AT1G01030,gene,AT1G01030.2,NGA3,NGATHA3,protein_coding,AP2/B3-like transcriptional factor family protein;(source:Araport11),,,"DNA-binding transcription factor activity, DNA binding","GO:0003700, GO:0003677",15.5.5.3,.RNA biosynthesis.transcriptional regulation.B3 transcription factor superfamily.transcription factor (RAV/NGATHA),transcription factor (RAV/NGATHA) (original description: pep chromosome:TAIR10:1:11649:13714:-1 gene:AT1G01030 transcript:AT1G01030.2 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:NGA3 description:B3 domain-containing transcription factor NGA3 [Source:UniProtKB/Swiss-Prot;Acc:Q9MAN1]),,,,,, diff --git a/spec/test/djornl/test_data/pheno_nodes.csv b/spec/test/djornl/test_data/pheno_nodes.csv index d8bb15a9..83fbf4be 100644 --- a/spec/test/djornl/test_data/pheno_nodes.csv +++ b/spec/test/djornl/test_data/pheno_nodes.csv @@ -1,5 +1,5 @@ -node_id,node_type,transcript,gene_symbol,gene_full_name,gene_model_type,TAIR_Computational_description,TAIR_Curator_summary,TAIR_short_description,GO_descr,GO_terms,MapMan_bin,MapMan_name,MapMan_descr,pheno_AraGWAS_ID,pheno_descrip1,pheno_descrip2,pheno_descrip3,pheno_ref,User_Notes -As2,pheno,,,,,,,,,,,,,10.21958/phenotype:103,,bacterial disease resistance,The resistance exhibited by a plant or a group of plants (population) in response to the disease caused by a bacterial pathogen infection as compared to the susceptible and/or the reference plants of the same species. [GR:pj],"Atwell et. al, Nature 2010", -As75,pheno,,,,,,,,,,,,,10.21958/phenotype:67,"Arsenic concentrations in leaves, grown in soil. Elemental analysis was performed with an ICP-MS (PerkinElmer). Sample normalized to calculated weights as described in Baxter et al., 2008",arsenic concentration,A mineral and ion content related trait (TO:0000465) which is the concentration of arsenic (CHEBI:22632) in some plant structure (PO:0009011). [GR:Karthik],"Atwell et. al, Nature 2010", -Na23,pheno,,,,,,,,,,,,,10.21958/phenotype:5,"Sodium concentrations in leaves, grown in soil. Elemental analysis was performed with an ICP-MS (PerkinElmer). Sample normalized to calculated weights as described in Baxter et al., 2008",sodium concentration,The total sodium ion concentration measured in a given volume of a plant or a plant part or plant extract. [GR:pj],"Atwell et. al, Nature 2010", -SDV,pheno,,,,,,,,,,,,,10.21958/phenotype:104,"Number of days following stratification to opening of first flower. The experiment was stopped at 200 d, and accessions that had not flowered at that point were assigned a value of 200",days to flowering trait,"A flowering time trait (TO:0002616)which is the number of days required for an individual flower (PO:0009046), a whole plant (PO:0000003) or a plant population to reach flowering stage (PO:0007616) from a predetermined time point (e.g. the date of seed sowing, seedling transplant, or seedling emergence). [GR:pj, TO:cooperl]","Atwell et. al, Nature 2010", +node_id,node_type,pheno_AraGWAS_ID,pheno_description,pheno_pto_name,pheno_pto_description,pheno_ref,User_Notes +As2,pheno,10.21958/phenotype:103,,bacterial disease resistance,The resistance exhibited by a plant or a group of plants (population) in response to the disease caused by a bacterial pathogen infection as compared to the susceptible and/or the reference plants of the same species. [GR:pj],"Atwell et. al, Nature 2010", +As75,pheno,10.21958/phenotype:67,"Arsenic concentrations in leaves, grown in soil. Elemental analysis was performed with an ICP-MS (PerkinElmer). Sample normalized to calculated weights as described in Baxter et al., 2008",arsenic concentration,A mineral and ion content related trait (TO:0000465) which is the concentration of arsenic (CHEBI:22632) in some plant structure (PO:0009011). [GR:Karthik],"Atwell et. al, Nature 2010", +Na23,pheno,10.21958/phenotype:5,"Sodium concentrations in leaves, grown in soil. Elemental analysis was performed with an ICP-MS (PerkinElmer). Sample normalized to calculated weights as described in Baxter et al., 2008",sodium concentration,The total sodium ion concentration measured in a given volume of a plant or a plant part or plant extract. [GR:pj],"Atwell et. al, Nature 2010", +SDV,pheno,10.21958/phenotype:104,"Number of days following stratification to opening of first flower. The experiment was stopped at 200 d, and accessions that had not flowered at that point were assigned a value of 200",days to flowering trait,"A flowering time trait (TO:0002616)which is the number of days required for an individual flower (PO:0009046), a whole plant (PO:0000003) or a plant population to reach flowering stage (PO:0007616) from a predetermined time point (e.g. the date of seed sowing, seedling transplant, or seedling emergence). [GR:pj, TO:cooperl]","Atwell et. al, Nature 2010", From 4875b0528df9dbbe038309d5c68ceef438bf1e2c Mon Sep 17 00:00:00 2001 From: ialarmedalien Date: Fri, 28 Aug 2020 07:04:07 -0700 Subject: [PATCH 563/732] Rename some functions and variables for greater consistency Add a couple more parser tests --- importers/README.md | 2 +- importers/djornl/main.py | 11 ----- importers/djornl/parser.py | 63 +++++++++++++++---------- importers/test/test_djornl_parser.py | 37 ++++++++++----- importers/utils/config.py | 3 +- spec/test/djornl/results.json | 4 +- spec/test/stored_queries/test_djornl.py | 6 +-- 7 files changed, 69 insertions(+), 57 deletions(-) delete mode 100644 importers/djornl/main.py diff --git a/importers/README.md b/importers/README.md index 53df13cc..e54bb379 100644 --- a/importers/README.md +++ b/importers/README.md @@ -15,5 +15,5 @@ Global env vars: ```sh RES_ROOT_DATA_PATH=/path/to/djornl_data \ -python -m importers.djornl.main +python -m importers.djornl.parser ``` diff --git a/importers/djornl/main.py b/importers/djornl/main.py deleted file mode 100644 index ba1bb005..00000000 --- a/importers/djornl/main.py +++ /dev/null @@ -1,11 +0,0 @@ -""" -Loads the Dan Jacobson/ORNL group's gene and phenotype network data into -arangodb. - -Running this requires a set of source files provided by the ORNL group. -""" -from importers.djornl.parser import DJORNL_Parser - -if __name__ == '__main__': - parser = DJORNL_Parser() - parser.load_data() diff --git a/importers/djornl/parser.py b/importers/djornl/parser.py index 990c745a..c62c6793 100644 --- a/importers/djornl/parser.py +++ b/importers/djornl/parser.py @@ -252,14 +252,16 @@ def load_edges(self): # store edge data, checking for potential duplicates def store_edges(datum): - # there should only be one value for each node<->node edge of a given type + # there should only be one value for each node<->node edge of a given type, + # so use these values as an index key edge_key = "__".join([datum['node1'], datum['node2'], datum['edge_type']]) if edge_key in edge_ix: - # ignore duplicate lines; report non-matching data - if datum['score'] != edge_ix[edge_key]['score']: - return f"duplicate data for edge {edge_key}" - return None + # duplicate lines can be ignored + if datum['score'] == edge_ix[edge_key]['score']: + return None + # report non-matching data + return f"duplicate data for edge {edge_key}" # keep track of the nodes mentioned in this edge set for node_n in ["1", "2"]: @@ -286,7 +288,7 @@ def store_edges(datum): 'edges': edge_ix.values(), } - def load_node_metadata(self): + def load_nodes(self): """Load node metadata""" node_ix = {} @@ -352,7 +354,7 @@ def store_nodes(datum): raise RuntimeError('\n'.join(err_list)) return {'nodes': node_ix.values()} - def load_cluster_data(self): + def load_clusters(self): """Annotate genes with cluster ID fields.""" # index of nodes @@ -428,33 +430,38 @@ def save_docs(self, coll_name, docs, on_dupe='update'): def load_data(self): self.save_dataset(self.load_edges()) - self.save_dataset(self.load_node_metadata()) - self.save_dataset(self.load_cluster_data()) + self.save_dataset(self.load_nodes()) + self.save_dataset(self.load_clusters()) return True def check_data_delta(self): edge_data = self.load_edges() - node_metadata = self.load_node_metadata() - clusters = self.load_cluster_data() + node_data = self.load_nodes() + clusters = self.load_clusters() + + self.check_deltas(edge_data=edge_data, node_data=node_data, cluster_data=clusters) - self.check_deltas(edge_data=edge_data, node_metadata=node_metadata, cluster_data=clusters) + def check_deltas(self, edge_data={}, node_data={}, cluster_data={}): - def check_deltas(self, edge_data={}, node_metadata={}, cluster_data={}): + edges_nodelist = set([e['_key'] for e in edge_data['nodes']]) + nodes_nodelist = set([e['_key'] for e in node_data['nodes']]) + clusters_nodelist = set([e['_key'] for e in cluster_data['nodes']]) + all_nodes = edges_nodelist.union(nodes_nodelist).union(clusters_nodelist) - edge_nodes = set([e['_key'] for e in edge_data['nodes']]) - node_metadata_nodes = set([e['_key'] for e in node_metadata['nodes']]) - cluster_nodes = set([e['_key'] for e in cluster_data['nodes']]) - all_nodes = edge_nodes.union(node_metadata_nodes).union(cluster_nodes) + # check all nodes in cluster_data have node data + cluster_no_node_set = clusters_nodelist.difference(nodes_nodelist) + if cluster_no_node_set: + print({'clusters with no node metadata': cluster_no_node_set}) - # check all nodes in cluster_data have node_metadata - clstr_no_node_md_set = cluster_nodes.difference(node_metadata_nodes) - if clstr_no_node_md_set: - print({'clusters with no node metadata': clstr_no_node_md_set}) + # check all nodes in the edge_data have node data + edge_no_node_set = edges_nodelist.difference(nodes_nodelist) + if edge_no_node_set: + print({'edges with no node metadata': edge_no_node_set}) - # check all nodes in the edge_data have node_metadata - edge_no_node_md_set = edge_nodes.difference(node_metadata_nodes) - if edge_no_node_md_set: - print({'edges with no node metadata': edge_no_node_md_set}) + # check all nodes are in the edge_data set + node_no_edge_set = nodes_nodelist.difference(edges_nodelist) + if node_no_edge_set: + print({'nodes not in an edge': node_no_edge_set}) # count all edges print("Dataset contains " + str(len(edge_data['edges'])) + " edges") @@ -464,4 +471,8 @@ def check_deltas(self, edge_data={}, node_metadata={}, cluster_data={}): if __name__ == '__main__': parser = DJORNL_Parser() - parser.load_data() + try: + parser.load_data() + except Exception as err: + print(err) + exit(1) diff --git a/importers/test/test_djornl_parser.py b/importers/test/test_djornl_parser.py index a3c8ecfa..daf2b417 100644 --- a/importers/test/test_djornl_parser.py +++ b/importers/test/test_djornl_parser.py @@ -33,6 +33,19 @@ def init_parser_with_path(self, root_path): parser._configure() return parser + def test_missing_required_env_var(self): + '''test that the parser exits with code 1 if the RES_ROOT_DATA_PATH env var is not set''' + with self.assertRaisesRegex(RuntimeError, 'Missing required env var: RES_ROOT_DATA_PATH'): + parser = DJORNL_Parser() + parser.load_edges() + + def test_config(self): + '''test that the parser raises an error if a config value cannot be found''' + RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, 'djornl', 'test_data') + parser = self.init_parser_with_path(RES_ROOT_DATA_PATH) + with self.assertRaisesRegex(KeyError, 'No such config value: bananas'): + parser.config('bananas') + def test_load_no_manifest(self): """ test loading when the manifest does not exist """ RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, 'djornl', 'no_manifest') @@ -67,7 +80,7 @@ def test_load_empty_files(self): # header only, no content err_str = 'aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv: no valid data found' with self.assertRaisesRegex(RuntimeError, err_str): - parser.load_node_metadata() + parser.load_nodes() # comments only err_str = 'merged_edges-AMW-060820_AF.tsv: no header line found' @@ -81,7 +94,7 @@ def test_load_empty_files(self): 'cluster_data/comment_only.tsv: no header line found', ]) with self.assertRaisesRegex(RuntimeError, err_str): - parser.load_cluster_data() + parser.load_clusters() def test_load_missing_files(self): """ test loading when files cannot be found """ @@ -119,7 +132,7 @@ def test_load_invalid_nodes(self): # invalid node type node_err_msg = "nodes.csv line 5: 'Monkey' is not valid under any of the given schemas" with self.assertRaisesRegex(RuntimeError, node_err_msg): - parser.load_node_metadata() + parser.load_nodes() def test_load_invalid_clusters(self): """ test file format errors """ @@ -131,7 +144,7 @@ def test_load_invalid_clusters(self): # invalid node type cluster_err_msg = "markov2_named.tsv line 7: 'HoneyNutCluster3' does not match" with self.assertRaisesRegex(RuntimeError, cluster_err_msg): - parser.load_cluster_data() + parser.load_clusters() def test_load_col_count_errors(self): """ test files with invalid numbers of columns """ @@ -148,7 +161,7 @@ def test_load_col_count_errors(self): # too many cols node_err_msg = 'aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv line 3: expected 20 cols, found 22' with self.assertRaisesRegex(RuntimeError, node_err_msg): - parser.load_node_metadata() + parser.load_nodes() def test_load_valid_edge_data(self): @@ -169,8 +182,8 @@ def test_load_valid_node_metadata(self): RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, 'djornl', 'test_data') parser = self.init_parser_with_path(RES_ROOT_DATA_PATH) - node_metadata = parser.load_node_metadata() - expected = self.json_data["load_node_metadata"] + node_metadata = parser.load_nodes() + expected = self.json_data["load_nodes"] for data_structure in [node_metadata, expected]: for k in data_structure.keys(): @@ -184,10 +197,10 @@ def test_load_valid_cluster_data(self): RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, 'djornl', 'test_data') parser = self.init_parser_with_path(RES_ROOT_DATA_PATH) - cluster_data = parser.load_cluster_data() + cluster_data = parser.load_clusters() self.assertEqual( cluster_data, - self.json_data["load_cluster_data"] + self.json_data["load_clusters"] ) def test_duplicate_edge_data(self): @@ -211,7 +224,7 @@ def test_duplicate_node_data(self): err_msg = "extra_node.tsv line 5: duplicate data for node AT1G01080" with self.assertRaisesRegex(RuntimeError, err_msg): - parser.load_node_metadata() + parser.load_nodes() def test_duplicate_cluster_data(self): """ test files with duplicate cluster data, which should be seamlessly merged """ @@ -220,10 +233,10 @@ def test_duplicate_cluster_data(self): RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, 'djornl', 'duplicate_data') parser = self.init_parser_with_path(RES_ROOT_DATA_PATH) - cluster_data = parser.load_cluster_data() + cluster_data = parser.load_clusters() self.assertEqual( cluster_data, - self.json_data["load_cluster_data"] + self.json_data["load_clusters"] ) def test_the_full_shebang(self): diff --git a/importers/utils/config.py b/importers/utils/config.py index 878b9fee..1f30080e 100644 --- a/importers/utils/config.py +++ b/importers/utils/config.py @@ -20,8 +20,7 @@ def load_from_env(extra_required=None, extra_optional=None, prefix='RES_'): optional = list(OPTIONAL) + (extra_optional or []) for field in required: if (prefix + field) not in os.environ: - print(f"Missing required env var: {prefix + field}") - exit(1) + raise RuntimeError(f"Missing required env var: {prefix + field}") for field in required + optional: if (prefix + field) in os.environ: conf[field] = os.environ[prefix + field] diff --git a/spec/test/djornl/results.json b/spec/test/djornl/results.json index 9eefcebc..fe9a613c 100644 --- a/spec/test/djornl/results.json +++ b/spec/test/djornl/results.json @@ -25,7 +25,7 @@ {"_key": "AT1G01080__AT1G01090__AraNetv2-LC_lit-curated-ppi__2.8", "_from": "djornl_node/AT1G01080", "_to": "djornl_node/AT1G01090", "edge_type": "AraNetv2-LC_lit-curated-ppi", "score": 2.8} ] }, - "load_cluster_data": { + "load_clusters": { "nodes": [ {"_key": "AT1G01010", "clusters": ["markov_i2:1", "markov_i6:3"]}, {"_key": "AT1G01030", "clusters": ["markov_i2:1", "markov_i6:3"]}, @@ -38,7 +38,7 @@ {"_key": "AT1G01080", "clusters": ["markov_i4:3"]} ] }, - "load_node_metadata": { + "load_nodes": { "nodes": [ {"_key": "As2", "node_type": "pheno", "transcript": "", "gene_symbol": "", "gene_full_name": "", "gene_model_type": "", "tair_computational_description": "", "tair_curator_summary": "", "tair_short_description": "", "go_description": "", "go_terms": [], "mapman_bin": "", "mapman_name": "", "mapman_description": "", "pheno_aragwas_id": "10.21958/phenotype:103", "pheno_description": "", "pheno_pto_name": "bacterial disease resistance", "pheno_pto_description": "The resistance exhibited by a plant or a group of plants (population) in response to the disease caused by a bacterial pathogen infection as compared to the susceptible and/or the reference plants of the same species. [GR:pj]", "pheno_ref": "Atwell et. al, Nature 2010", "user_notes": ""}, {"_key": "As75", "node_type": "pheno", "transcript": "", "gene_symbol": "", "gene_full_name": "", "gene_model_type": "", "tair_computational_description": "", "tair_curator_summary": "", "tair_short_description": "", "go_description": "", "go_terms": [], "mapman_bin": "", "mapman_name": "", "mapman_description": "", "pheno_aragwas_id": "10.21958/phenotype:67", "pheno_description": "Arsenic concentrations in leaves, grown in soil. Elemental analysis was performed with an ICP-MS (PerkinElmer). Sample normalized to calculated weights as described in Baxter et al., 2008", "pheno_pto_name": "arsenic concentration", "pheno_pto_description": "A mineral and ion content related trait (TO:0000465) which is the concentration of arsenic (CHEBI:22632) in some plant structure (PO:0009011). [GR:Karthik]", "pheno_ref": "Atwell et. al, Nature 2010", "user_notes": ""}, diff --git a/spec/test/stored_queries/test_djornl.py b/spec/test/stored_queries/test_djornl.py index cde4d0c2..befe46cd 100644 --- a/spec/test/stored_queries/test_djornl.py +++ b/spec/test/stored_queries/test_djornl.py @@ -49,11 +49,11 @@ def setUpClass(cls): r = create_test_docs(edge_name, edge_data['edges']) print_db_update(r, edge_name) - node_metadata = parser.load_node_metadata() + node_metadata = parser.load_nodes() r = create_test_docs(node_name, node_metadata['nodes'], True) print_db_update(r, node_name) - cluster_data = parser.load_cluster_data() + cluster_data = parser.load_clusters() r = create_test_docs(node_name, cluster_data['nodes'], True) print_db_update(r, node_name) @@ -93,7 +93,7 @@ def test_fetch_all(self): # ensure that all the cluster data is returned OK node_data = response['results'][0]['nodes'] - expected_node_data = self.json_data['load_cluster_data']['nodes'] + expected_node_data = self.json_data['load_clusters']['nodes'] self.assertEqual( {n['_key']: n['clusters'] for n in node_data if 'clusters' in n}, {n['_key']: n['clusters'] for n in expected_node_data if 'clusters' in n}, From 82a5996e365888580500285c66e9521f7da99646 Mon Sep 17 00:00:00 2001 From: ialarmedalien Date: Fri, 28 Aug 2020 07:57:24 -0700 Subject: [PATCH 564/732] Add env var that indicates when full specs have been loaded. If env var is not present and the tests require the full specs, they will be loaded. --- relation_engine_server/test/test_api_v1.py | 6 +++++- spec/test/helpers.py | 19 +++++++++++++++++++ spec/test/stored_queries/test_djornl.py | 5 ++--- .../stored_queries/test_list_test_vertices.py | 6 ++---- spec/test/stored_queries/test_ncbi_tax.py | 5 ++--- spec/test/stored_queries/test_taxonomy.py | 5 ++--- spec/test/stored_queries/test_ws.py | 5 ++--- 7 files changed, 34 insertions(+), 17 deletions(-) diff --git a/relation_engine_server/test/test_api_v1.py b/relation_engine_server/test/test_api_v1.py index 9872514c..97532572 100644 --- a/relation_engine_server/test/test_api_v1.py +++ b/relation_engine_server/test/test_api_v1.py @@ -121,6 +121,10 @@ def test_update_specs(self): resp_json = resp.json() self.assertEqual(resp.status_code, 200) self.assertTrue(len(resp_json['status'])) + + # delete the SPEC_TEST_READY env var as it is no longer true + os.environ.pop('SPEC_TEST_READY', None) + # Test that the indexes get created and not duplicated url = _CONF['db_url'] + '/_api/index' auth = (_CONF['db_user'], _CONF['db_pass']) @@ -161,7 +165,7 @@ def test_list_data_sources(self): # /data_sources is used by the UI and requires slightly different response formatting # /specs/data_sources is in the standard /specs format used by collections and stored_queries - data_sources = ['djornl', 'envo_ontology', 'go_ontology', 'gtdb', 'ncbi_taxonomy', 'rdp_taxonomy'] + data_sources = ['ncbi_taxonomy'] # /spec/data_sources endpoint def check_resp_json_spec_endpoint(self, resp): diff --git a/spec/test/helpers.py b/spec/test/helpers.py index 866e57a9..f407a0dd 100644 --- a/spec/test/helpers.py +++ b/spec/test/helpers.py @@ -8,6 +8,10 @@ import os import requests import sys +import shutil +from relation_engine_server.utils.wait_for import wait_for_api +from relation_engine_server.utils.pull_spec import download_specs +from relation_engine_server.utils.config import get_config as get_re_config @functools.lru_cache(maxsize=1) @@ -62,6 +66,21 @@ def create_test_docs(coll_name, docs, update_on_dupe=False): return resp +def check_spec_test_env(): + """ ensure that the environment is prepared for running the spec tests """ + if os.environ.get('SPEC_TEST_READY', None) is None: + wait_for_api() + _CONF = get_re_config() + # Remove the spec directory, ignoring if it is already missing + shutil.rmtree(_CONF['spec_paths']['root'], ignore_errors=True) + # Recreate the spec directory so we have a clean slate, avoiding name conflicts + os.makedirs(_CONF['spec_paths']['root']) + # copy the contents of /app/spec into /spec/repo + shutil.copytree('/app/spec', _CONF['spec_paths']['repo']) + download_specs() + os.environ.update({'SPEC_TEST_READY': "Done"}) + + def capture_stdout(function, *args, **kwargs): """capture and return the standard output from a function""" io_stdout = io.StringIO() diff --git a/spec/test/stored_queries/test_djornl.py b/spec/test/stored_queries/test_djornl.py index befe46cd..fe14dd23 100644 --- a/spec/test/stored_queries/test_djornl.py +++ b/spec/test/stored_queries/test_djornl.py @@ -5,9 +5,8 @@ import unittest import os -from spec.test.helpers import get_config, modified_environ, create_test_docs, run_query +from spec.test.helpers import get_config, modified_environ, create_test_docs, run_query, check_spec_test_env from importers.djornl.parser import DJORNL_Parser -from relation_engine_server.utils.wait_for import wait_for_api _CONF = get_config() _TEST_DIR = '/app/spec/test' @@ -27,7 +26,7 @@ class Test_DJORNL_Stored_Queries(unittest.TestCase): @classmethod def setUpClass(cls): - wait_for_api() + check_spec_test_env() # import the results file results_file = os.path.join(_TEST_DIR, 'djornl', 'results.json') with open(results_file) as fh: diff --git a/spec/test/stored_queries/test_list_test_vertices.py b/spec/test/stored_queries/test_list_test_vertices.py index 796db4c0..086c2b2e 100644 --- a/spec/test/stored_queries/test_list_test_vertices.py +++ b/spec/test/stored_queries/test_list_test_vertices.py @@ -1,8 +1,7 @@ import unittest import requests -from spec.test.helpers import create_test_docs, get_config -from relation_engine_server.utils.wait_for import wait_for_api +from spec.test.helpers import create_test_docs, get_config, check_spec_test_env _CONF = get_config() _QUERY_URL = _CONF['re_api_url'] + '/api/v1/query_results?view=list_test_vertices' @@ -12,8 +11,7 @@ class TestListTestVertices(unittest.TestCase): @classmethod def setUpClass(cls): - # Wait for the API to come online - wait_for_api() + check_spec_test_env() def test_valid(self): """Test a valid query.""" diff --git a/spec/test/stored_queries/test_ncbi_tax.py b/spec/test/stored_queries/test_ncbi_tax.py index 759aa4ed..7b6817e0 100644 --- a/spec/test/stored_queries/test_ncbi_tax.py +++ b/spec/test/stored_queries/test_ncbi_tax.py @@ -6,8 +6,7 @@ import unittest import requests -from spec.test.helpers import get_config, assert_subset, create_test_docs -from relation_engine_server.utils.wait_for import wait_for_api +from spec.test.helpers import get_config, assert_subset, create_test_docs, check_spec_test_env _CONF = get_config() _NOW = int(time.time() * 1000) @@ -19,7 +18,7 @@ class TestNcbiTax(unittest.TestCase): def setUpClass(cls): """Create test documents""" - wait_for_api() + check_spec_test_env() taxon_docs = [ {'_key': '1', 'scientific_name': 'Bacteria', 'rank': 'Domain', 'strain': False}, diff --git a/spec/test/stored_queries/test_taxonomy.py b/spec/test/stored_queries/test_taxonomy.py index 9d67b921..e317d205 100644 --- a/spec/test/stored_queries/test_taxonomy.py +++ b/spec/test/stored_queries/test_taxonomy.py @@ -6,8 +6,7 @@ import unittest import requests -from spec.test.helpers import get_config, assert_subset, create_test_docs -from relation_engine_server.utils.wait_for import wait_for_api +from spec.test.helpers import get_config, assert_subset, create_test_docs, check_spec_test_env _CONF = get_config() _NOW = int(time.time() * 1000) @@ -19,7 +18,7 @@ class TestTaxonomy(unittest.TestCase): def setUpClass(cls): """Create test documents""" - wait_for_api() + check_spec_test_env() taxon_docs = [ {'_key': '1', 'scientific_name': 'Bacteria', 'rank': 'Domain', 'strain': False}, {'_key': '2', 'scientific_name': 'Firmicutes', 'rank': 'Phylum', 'strain': False}, diff --git a/spec/test/stored_queries/test_ws.py b/spec/test/stored_queries/test_ws.py index a3cf800b..c8796a94 100644 --- a/spec/test/stored_queries/test_ws.py +++ b/spec/test/stored_queries/test_ws.py @@ -4,8 +4,7 @@ import unittest import json import requests -from spec.test.helpers import get_config, create_test_docs -from relation_engine_server.utils.wait_for import wait_for_api +from spec.test.helpers import get_config, create_test_docs, check_spec_test_env _CONF = get_config() @@ -34,7 +33,7 @@ def setUpClass(cls): Create all test data. """ - wait_for_api() + check_spec_test_env() ws_object_version = [ _ws_obj(1, 1, 1), # root/origin object From 2de5e065422155e728a18739a5e181de490fe3fe Mon Sep 17 00:00:00 2001 From: ialarmedalien Date: Fri, 28 Aug 2020 08:05:08 -0700 Subject: [PATCH 565/732] Separate parser tests into two files --- importers/test/test_djornl_parser.py | 8 ------ .../test/test_djornl_parser_integration.py | 27 +++++++++++++++++++ 2 files changed, 27 insertions(+), 8 deletions(-) create mode 100644 importers/test/test_djornl_parser_integration.py diff --git a/importers/test/test_djornl_parser.py b/importers/test/test_djornl_parser.py index daf2b417..763eea5d 100644 --- a/importers/test/test_djornl_parser.py +++ b/importers/test/test_djornl_parser.py @@ -238,11 +238,3 @@ def test_duplicate_cluster_data(self): cluster_data, self.json_data["load_clusters"] ) - - def test_the_full_shebang(self): - - RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, 'djornl', 'test_data') - parser = self.init_parser_with_path(RES_ROOT_DATA_PATH) - - parser.load_data() - self.assertEqual(True, parser.load_data()) diff --git a/importers/test/test_djornl_parser_integration.py b/importers/test/test_djornl_parser_integration.py new file mode 100644 index 00000000..e7e758e8 --- /dev/null +++ b/importers/test/test_djornl_parser_integration.py @@ -0,0 +1,27 @@ +""" +Tests for the DJORNL Parser + +At the present time, this just ensures that the files are parsed correctly; +it does not check data loading into the db. +""" +import unittest +import os + +from importers.djornl.parser import DJORNL_Parser +from spec.test.helpers import modified_environ, check_spec_test_env + +_TEST_DIR = '/app/spec/test' + + +class Test_DJORNL_Parser_Integration(unittest.TestCase): + + @classmethod + def setUpClass(cls): + check_spec_test_env() + + def test_the_full_shebang(self): + + with modified_environ(RES_ROOT_DATA_PATH=os.path.join(_TEST_DIR, 'djornl', 'test_data')): + parser = DJORNL_Parser() + parser.load_data() + self.assertEqual(True, parser.load_data()) From ae1f8e471d7d26719e0f1c055443ed670b97c21c Mon Sep 17 00:00:00 2001 From: i alarmed alien Date: Fri, 28 Aug 2020 11:48:19 -0700 Subject: [PATCH 566/732] Add badges Adding badges for LGTM and Github Actions Still need to add coverage stats. --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index d84a4e49..37a5b67f 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,6 @@ +[![Total alerts](https://img.shields.io/lgtm/alerts/g/kbase/relation_engine.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/kbase/relation_engine/alerts/) [![Language grade: Python](https://img.shields.io/lgtm/grade/python/g/kbase/relation_engine.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/kbase/relation_engine/context:python) +![RE test and deploy](https://github.com/kbase/relation_engine/workflows/Relation%20Engine%20test%20and%20deploy/badge.svg) + # KBase Relation Engine This repo holds the code associated with the KBase relation engine, previously held in https://github.com/kbase/relation_engine_api and https://github.com/kbase/relation_engine_spec. From b38f769a5ec824f5d7ba2a56e78b2c3ad8c89c8e Mon Sep 17 00:00:00 2001 From: ialarmedalien Date: Sun, 30 Aug 2020 07:31:20 -0700 Subject: [PATCH 567/732] Standardise error responses and update tests Add a couple more tests for error cases. Add coverage calculation to test runs. Update readme with error structure details --- dev-requirements.txt | 2 +- relation_engine_server/README.md | 22 +++- relation_engine_server/exceptions.py | 2 +- relation_engine_server/main.py | 98 ++++++++------ relation_engine_server/test/data/test_file.md | 0 relation_engine_server/test/test_api_v1.py | 65 +++++---- .../test/test_json_validation.py | 6 + .../test/test_spec_loader.py | 14 +- scripts/run_tests.sh | 11 +- spec/__init__.py | 0 spec/test/djornl/results.json | 60 +++++---- .../duplicate_names/ncbi/ncbi_taxon.yaml | 64 +++++++++ .../duplicate_names/ncbi/test_vertex.yaml | 11 ++ .../duplicate_names/test/test_edge.yaml | 10 ++ .../duplicate_names/test/test_vertex.yaml | 11 ++ spec/test/stored_queries/test_djornl.py | 124 ++++++++++++++++-- spec/test/stored_queries/test_ncbi_tax.py | 12 +- spec/test/stored_queries/test_taxonomy.py | 12 +- spec/test/test_validate.py | 27 +++- spec/validate.py | 96 ++++++++++---- 20 files changed, 496 insertions(+), 151 deletions(-) create mode 100644 relation_engine_server/test/data/test_file.md create mode 100644 spec/__init__.py create mode 100644 spec/test/sample_schemas/duplicate_names/ncbi/ncbi_taxon.yaml create mode 100644 spec/test/sample_schemas/duplicate_names/ncbi/test_vertex.yaml create mode 100644 spec/test/sample_schemas/duplicate_names/test/test_edge.yaml create mode 100644 spec/test/sample_schemas/duplicate_names/test/test_vertex.yaml diff --git a/dev-requirements.txt b/dev-requirements.txt index ab184106..399563a0 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -3,4 +3,4 @@ bandit==1.5.1 mccabe==0.6.1 flake8==3.5.0 grequests==0.3.0 -coverage==4.5.1 +coverage==5.2.1 diff --git a/relation_engine_server/README.md b/relation_engine_server/README.md index 7198b7e1..9f4a0909 100644 --- a/relation_engine_server/README.md +++ b/relation_engine_server/README.md @@ -13,6 +13,22 @@ The API is a small, rest-ish service where all data is in JSON format. Replace t * Staging: `https://ci.kbase.us/services/relation_engine_api` * App-dev: `https://appdev.kbase.us/services/relation_engine_api` +### Error responses + +The majority of errors returned from the server have explanatory information in the response content in the following format: + +```json + +{ + "error": { + "message": "A brief message explaining the error", + "status": 400, # or the appropriate HTTP error status code + } +} +``` + +Specific errors may have other fields giving more details, e.g. JSON parsing errors have `source_json`, `pos`, `lineno`, and `colno` describing the error; ArangoDB errors have an `arango_message` field. + ### GET / Returns server status info @@ -168,7 +184,7 @@ _Response JSON schema_ If you try to update a collection and it fails validation against a JSON schema found in the [relation engine spec](spec/), then you will get a JSON error response with the following fields: -* `"error"` - Human readable message explaining the error +* `"message"` - Human readable message explaining the error * `"failed_validator"` - The name of the validator that failed (eg. "required") * `"value"` - The (possibly nested) value in your data that failed validation * `"path"` - The path into your data where you can find the value that failed validation @@ -428,9 +444,9 @@ curl -X PUT -H "Authorization: " \ ## Deprecated Endpoints -#### GET `/api/v1/specs/schemas` (replaced by `/api/v1/specs/schemas`) +#### GET `/api/v1/specs/schemas` (replaced by `/api/v1/specs/collections`) -This endpoint has been deprecated; queries should use `/api/v1/specs/schemas` instead. +This endpoint has been deprecated; queries should use `/api/v1/specs/collections` instead. ## Development diff --git a/relation_engine_server/exceptions.py b/relation_engine_server/exceptions.py index 095c2dc4..5b18f839 100644 --- a/relation_engine_server/exceptions.py +++ b/relation_engine_server/exceptions.py @@ -24,7 +24,7 @@ def __str__(self): class UnauthorizedAccess(Exception): - "Authentication failed for an authorization header.""" + """Authentication failed for an authorization header.""" def __init__(self, auth_url, response): self.auth_url = auth_url diff --git a/relation_engine_server/main.py b/relation_engine_server/main.py index 9425d42a..266e5375 100644 --- a/relation_engine_server/main.py +++ b/relation_engine_server/main.py @@ -18,6 +18,26 @@ app.register_blueprint(api_v1, url_prefix='/api/v1') +def return_error(error_dict, code): + """return the appropriate error structure and code + + Errors returned by the server have the basic format + + 'error': { + 'message': , + 'status': , + } + + The 'error' dictionary may have extra keys if there is additional information. + + This helper adds the 'status' key and value to the input, and wraps the whole structure + in an extra dict under the key 'error'. + + """ + error_dict['status'] = code + return (flask.jsonify({'error': error_dict}), code) + + @app.route('/', methods=['GET']) def root(): """Server status.""" @@ -40,29 +60,32 @@ def root(): def json_decode_error(err): """A problem parsing json.""" resp = { - 'error': 'Unable to parse JSON', + 'message': 'Unable to parse JSON', 'source_json': err.doc, 'pos': err.pos, 'lineno': err.lineno, - 'colno': err.colno + 'colno': err.colno, } - return (flask.jsonify(resp), 400) + return return_error(resp, 400) @app.errorhandler(arango_client.ArangoServerError) def arango_server_error(err): resp = { - 'error': str(err), - 'arango_message': err.resp_json['errorMessage'] + 'message': str(err), + 'arango_message': err.resp_json['errorMessage'], } - return (flask.jsonify(resp), 400) + return return_error(resp, 400) +# Invalid request body json params or missing headers +@app.errorhandler(MissingHeader) @app.errorhandler(InvalidParameters) -def invalid_params(err): - """Invalid request body json params.""" - resp = {'error': str(err)} - return (flask.jsonify(resp), 400) +def generic_400(err): + resp = { + 'message': str(err), + } + return return_error(resp, 400) @app.errorhandler(ValidationError) @@ -71,63 +94,52 @@ def validation_error(err): # Refer to the documentation on jsonschema.exceptions.ValidationError: # https://python-jsonschema.readthedocs.io/en/stable/errors/ resp = { - 'error': err.message, + 'message': err.message, 'failed_validator': err.validator, 'value': err.instance, 'path': list(err.absolute_path), } - return (flask.jsonify(resp), 400) + return return_error(resp, 400) @app.errorhandler(UnauthorizedAccess) def unauthorized_access(err): resp = { - 'error': { - 'status': 403, - 'message': 'Unauthorized', - 'auth_url': err.auth_url, - 'auth_response': err.response, - }, + 'message': 'Unauthorized', + 'auth_url': err.auth_url, + 'auth_response': err.response, } - return (flask.jsonify(resp), 403) + return return_error(resp, 403) @app.errorhandler(SchemaNonexistent) def schema_does_not_exist(err): """General error cases.""" resp = { - 'error': { - 'message': 'Not found', - 'status': 404, - 'details': str(err), - 'name': err.name, - } + 'message': 'Not found', + 'details': str(err), + 'name': err.name, } - return (flask.jsonify(resp), 404) + return return_error(resp, 404) @app.errorhandler(NotFound) @app.errorhandler(404) def page_not_found(err): resp = { - 'error': { - 'message': 'Not found', - 'status': 404, - } + 'message': 'Not found', } if hasattr(err, 'details'): - resp['error']['details'] = err.details - return (flask.jsonify(resp), 404) + resp['details'] = err.details + return return_error(resp, 404) @app.errorhandler(405) def method_not_allowed(err): - return (flask.jsonify({'error': {'message': 'Method not allowed', 'status': 405}}), 405) - - -@app.errorhandler(MissingHeader) -def generic_400(err): - return (flask.jsonify({'error': {'message': str(err), 'status': 400}}), 400) + resp = { + 'message': 'Method not allowed', + } + return return_error(resp, 405) # Any other unhandled exceptions -> 500 @@ -139,11 +151,13 @@ def server_error(err): print('-' * 80) traceback.print_exc() print('=' * 80) - resp = {'error': {'status': 500, 'message': 'Unexpected server error'}} + resp = { + 'message': 'Unexpected server error' + } # TODO only set below two fields in dev mode - resp['error']['class'] = err.__class__.__name__ - resp['error']['details'] = str(err) - return (flask.jsonify(resp), 500) + resp['class'] = err.__class__.__name__ + resp['details'] = str(err) + return return_error(resp, 500) @app.after_request diff --git a/relation_engine_server/test/data/test_file.md b/relation_engine_server/test/data/test_file.md new file mode 100644 index 00000000..e69de29b diff --git a/relation_engine_server/test/test_api_v1.py b/relation_engine_server/test/test_api_v1.py index 97532572..d941d449 100644 --- a/relation_engine_server/test/test_api_v1.py +++ b/relation_engine_server/test/test_api_v1.py @@ -63,19 +63,22 @@ def setUpClass(cls): def test_request(self, url=None, params=None, data=None, headers=None, method='get', status_code=200, resp_json=None, resp_test=None): - '''test a get request to the server + '''test a request to the server arguments: url url to be appended to API_URL (i.e. request will be made to API_URL + url) params request parameters + data query data, encoded as JSON method HTTP method; defaults to 'get' status_code expected response status; defaults to 200 resp_json expected response content (JSON) - resp_test a function to perform on the response to test it is as expected + resp_test a function to perform on the response to test that it is as expected ''' + # this method should only be run from another test method if url is None: - self.skipTest('No arguments provided') + self.assertTrue(True) + return resp = requests.request( method, @@ -416,10 +419,10 @@ def test_save_documents_invalid_schema(self): data='{"name": "x"}\n{"name": "y"}', headers=HEADERS_ADMIN ).json() - self.assertEqual(resp['error'], "'_key' is a required property") - self.assertEqual(resp['value'], {'name': 'x'}) - self.assertEqual(resp['path'], []) - self.assertEqual(resp['failed_validator'], 'required') + self.assertEqual(resp['error']['message'], "'_key' is a required property") + self.assertEqual(resp['error']['value'], {'name': 'x'}) + self.assertEqual(resp['error']['path'], []) + self.assertEqual(resp['error']['failed_validator'], 'required') def test_save_documents_missing_schema(self): """Test the case where the collection/schema does not exist.""" @@ -450,9 +453,9 @@ def test_save_documents_invalid_json(self): data='\n', headers=HEADERS_ADMIN ).json() - self.assertTrue('Unable to parse' in resp['error']) - self.assertEqual(resp['pos'], 1) - self.assertEqual(resp['source_json'], '\n') + self.assertTrue('Unable to parse' in resp['error']['message']) + self.assertEqual(resp['error']['pos'], 1) + self.assertEqual(resp['error']['source_json'], '\n') def test_create_documents(self): """Test all valid cases for saving documents.""" @@ -580,6 +583,7 @@ def test_query_with_cursor(self): self.assertEqual(resp['count'], 20) self.assertEqual(resp['stats']['fullCount'], 20) self.assertTrue(len(resp['results']), 10) + cursor_id = resp['cursor_id'] resp = requests.post( API_URL + '/query_results', @@ -590,13 +594,21 @@ def test_query_with_cursor(self): self.assertEqual(resp['has_more'], False) self.assertEqual(resp['cursor_id'], None) self.assertTrue(len(resp['results']), 10) + # Try to get the same cursor again - resp = requests.post( - API_URL + '/query_results', - params={'cursor_id': cursor_id} - ).json() - self.assertTrue(resp['error']) - self.assertEqual(resp['arango_message'], 'cursor not found') + self.test_request( + '/query_results', + method='post', + params={'cursor_id': cursor_id}, + status_code=400, + resp_json={ + 'error': { + 'status': 400, + 'message': 'ArangoDB server error.', + 'arango_message': 'cursor not found', + } + } + ) def test_query_no_name(self): """Test a query error with a stored query name that does not exist.""" @@ -619,13 +631,22 @@ def test_query_no_name(self): def test_query_missing_bind_var(self): """Test a query error with a missing bind variable.""" - resp = requests.post( - API_URL + '/query_results', + + arango_msg = "AQL: bind parameter 'xyz' was not declared in the query (while parsing)" + self.test_request( + '/query_results', + method='post', params={'stored_query': 'list_test_vertices'}, - data=json.dumps({'xyz': 'test_vertex'}) - ).json() - self.assertEqual(resp['error'], 'ArangoDB server error.') - self.assertTrue(resp['arango_message']) + data=json.dumps({'xyz': 'test_vertex'}), + status_code=400, + resp_json={ + 'error': { + 'status': 400, + 'message': 'ArangoDB server error.', + 'arango_message': arango_msg, + } + } + ) def test_auth_query_with_access(self): """Test the case where we query a collection with specific workspace access.""" diff --git a/relation_engine_server/test/test_json_validation.py b/relation_engine_server/test/test_json_validation.py index 649cba81..1a48fc1d 100644 --- a/relation_engine_server/test/test_json_validation.py +++ b/relation_engine_server/test/test_json_validation.py @@ -96,6 +96,12 @@ def test_non_validation_validator_errors(self): with self.assertRaisesRegex(ValueError, err_str): run_validator(schema={}, data=None, data_file=None) + # invalid file type + test_file = os_path.join(*(test_data_dirs + ['test_file.md'])) + err_msg = f'Unknown file type encountered: {test_file}' + with self.assertRaisesRegex(TypeError, err_msg): + run_validator(schema_file=test_file, data={}) + # invalid jsonpointer string - note the grammar error is from jsonpointer err_str = 'location must starts with /' json_loc = 'start validating here' diff --git a/relation_engine_server/test/test_spec_loader.py b/relation_engine_server/test/test_spec_loader.py index 8349b2db..d1da1df9 100644 --- a/relation_engine_server/test/test_spec_loader.py +++ b/relation_engine_server/test/test_spec_loader.py @@ -24,7 +24,8 @@ def test_get_names(self, schema_type_names=[], expected=[]): # this method should only be run from another test method if len(schema_type_names) == 0: - self.skipTest('No schema type names supplied. Skipping') + self.assertTrue(True) + return schema_type_singular = schema_type_names[0] schema_type_plural = schema_type_names[1] @@ -63,7 +64,8 @@ def test_run_spec_loading_tests(self, schema_type_names=[], test_name=None): # only run the test if it's being called from another test if test_name is None: - self.skipTest('No test name supplied') + self.assertTrue(True) + return print("running test_run_spec_loading_tests with schema_type " + schema_type_names[0]) method = getattr(spec_loader, 'get_' + schema_type_names[0]) @@ -127,9 +129,15 @@ def test_get_schemas_of_various_types(self): for schema in schema_type_list: self.test_run_spec_loading_tests(schema['schema_type_names'], schema['example']) - if schema['schema_type_names'][0] == 'collection': + if 'names' in schema: self.test_get_names(schema['schema_type_names'], schema['names']) + def test_non_existent_schema(self): + + err_msg = 'Reality does not exist' + with self.assertRaisesRegex(SchemaNonexistent, err_msg): + spec_loader.get_names('Reality') + def test_get_schema_for_doc(self): """test getting the schema for a specific document""" diff --git a/scripts/run_tests.sh b/scripts/run_tests.sh index 3d205ada..8f1f1ab9 100644 --- a/scripts/run_tests.sh +++ b/scripts/run_tests.sh @@ -5,6 +5,7 @@ set -e flake8 --max-complexity 15 /app mypy --ignore-missing-imports /app bandit -r /app +rm -rf /spec mkdir /spec mkdir /spec/repo cp -r /app/spec/* /spec/repo/ @@ -13,10 +14,12 @@ sh /app/scripts/start_server.sh & # spec validation python -m spec.validate && # spec stored query tests -python -m unittest discover spec/test && +coverage run --parallel-mode -m unittest discover spec/test && # importer tests -python -m unittest discover importers/test && +coverage run --parallel-mode -m unittest discover importers/test && # RE API tests -python -m unittest discover relation_engine_server/test && +coverage run --parallel-mode -m unittest discover relation_engine_server/test && # RE client tests -PYTHONPATH=client_src python -m unittest discover client_src/test +PYTHONPATH=client_src coverage run --parallel-mode -m unittest discover client_src/test +coverage combine +coverage html --omit=*/test_* diff --git a/spec/__init__.py b/spec/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/spec/test/djornl/results.json b/spec/test/djornl/results.json index fe9a613c..71e5e7ba 100644 --- a/spec/test/djornl/results.json +++ b/spec/test/djornl/results.json @@ -57,34 +57,36 @@ ] }, "fetch_all": { - "nodes": [ - "As2", - "As75", - "AT1G01010", - "AT1G01020", - "AT1G01030", - "AT1G01040", - "AT1G01050", - "AT1G01060", - "AT1G01070", - "AT1G01080", - "AT1G01090", - "AT1G01100", - "Na23", - "SDV" - ], - "edges": [ - "As2__AT1G01020__AraGWAS-Phenotype_Associations__8.4", - "As2__AT1G01040__AraGWAS-Phenotype_Associations__5.4", - "As75__AT1G01020__AraGWAS-Phenotype_Associations__39.9", - "AT1G01010__AT1G01020__AraNetv2-HT_high-throughput-ppi__2.3", - "AT1G01010__AT1G01030__AraNetv2-HT_high-throughput-ppi__2.4", - "AT1G01010__AT1G01040__AraNetv2-DC_domain-co-occurrence__2.5", - "AT1G01010__AT1G01040__AraNetv2-LC_lit-curated-ppi__170.5", - "AT1G01030__AT1G01050__AraNetv2-CX_pairwise-gene-coexpression__2.6", - "AT1G01050__AT1G01060__AraNetv2-LC_lit-curated-ppi__2.7", - "AT1G01080__AT1G01090__AraNetv2-LC_lit-curated-ppi__2.8" - ] + "-": { + "nodes": [ + "As2", + "As75", + "AT1G01010", + "AT1G01020", + "AT1G01030", + "AT1G01040", + "AT1G01050", + "AT1G01060", + "AT1G01070", + "AT1G01080", + "AT1G01090", + "AT1G01100", + "Na23", + "SDV" + ], + "edges": [ + "As2__AT1G01020__AraGWAS-Phenotype_Associations__8.4", + "As2__AT1G01040__AraGWAS-Phenotype_Associations__5.4", + "As75__AT1G01020__AraGWAS-Phenotype_Associations__39.9", + "AT1G01010__AT1G01020__AraNetv2-HT_high-throughput-ppi__2.3", + "AT1G01010__AT1G01030__AraNetv2-HT_high-throughput-ppi__2.4", + "AT1G01010__AT1G01040__AraNetv2-DC_domain-co-occurrence__2.5", + "AT1G01010__AT1G01040__AraNetv2-LC_lit-curated-ppi__170.5", + "AT1G01030__AT1G01050__AraNetv2-CX_pairwise-gene-coexpression__2.6", + "AT1G01050__AT1G01060__AraNetv2-LC_lit-curated-ppi__2.7", + "AT1G01080__AT1G01090__AraNetv2-LC_lit-curated-ppi__2.8" + ] + } }, "fetch_genes": { "keys": { @@ -278,7 +280,7 @@ "fetch_clusters": { "cluster_ids": { - "Mary Poppins": { + "MaryPoppins:1": { "distance": { "0": {"nodes": [], "edges": []}, "1": {"nodes": [], "edges": []}, diff --git a/spec/test/sample_schemas/duplicate_names/ncbi/ncbi_taxon.yaml b/spec/test/sample_schemas/duplicate_names/ncbi/ncbi_taxon.yaml new file mode 100644 index 00000000..39c97168 --- /dev/null +++ b/spec/test/sample_schemas/duplicate_names/ncbi/ncbi_taxon.yaml @@ -0,0 +1,64 @@ +name: ncbi_taxon +type: vertex +delta: true + +indexes: + - type: fulltext + fields: [scientific_name] + - type: persistent + fields: [id, expired, created] + - type: persistent + fields: [expired, created, last_version] + +schema: + "$schema": http://json-schema.org/draft-07/schema# + type: object + description: Template for a vertex entry in the NCBI taxonomy tree. + required: [id, scientific_name, rank, strain] + properties: + id: + type: string + description: NCBI Taxon id (positive integer) + examples: ['1', '2053699'] + scientific_name: + type: string + title: Taxon name. + examples: ['Methylophilus methylotrophus', 'Bacteria', 'Firmicutes'] + aliases: + type: array + description: Aliases + examples: + - - category: authority + name: Borreliella burgdorferi (Johnson et al. 1984) Adeolu and Gupta 2015 + - category: genbank common name + name: Lyme disease spirochet + - category: synonym + name: Borrelia burgdorferi + - - category: common name + name: E. coli + - category: authority + name: '"Bacterium coli commune" Escherich 1885' + - category: synonym + name: Bacterium coli + items: + type: object + required: ['category', 'name'] + properties: + category: {type: string} + name: {type: string} + rank: + type: string + title: Taxonomic rank + examples: ["Domain", "Phylum", "no rank"] + strain: + type: boolean + title: Strain flag + description: Whether this node corresponds to a strain. Strains are considered to be nodes + that have a rank of "no rank" and whose parents' rank is either species or subspecies or + where the parent's strain flag is true. + ncbi_taxon_id: + type: integer + title: The NCBI taxon ID as a number + gencode: + type: integer + title: The numerc ID of the genetic code for this organism. diff --git a/spec/test/sample_schemas/duplicate_names/ncbi/test_vertex.yaml b/spec/test/sample_schemas/duplicate_names/ncbi/test_vertex.yaml new file mode 100644 index 00000000..b2d34668 --- /dev/null +++ b/spec/test/sample_schemas/duplicate_names/ncbi/test_vertex.yaml @@ -0,0 +1,11 @@ +name: test_vertex +type: vertex +schema: + "$schema": "http://json-schema.org/draft-07/schema#" + type: object + required: [_key] + description: An example vertex schema for testing + properties: + _key: {type: string} + is_public: {type: boolean} + ws_id: {type: integer} diff --git a/spec/test/sample_schemas/duplicate_names/test/test_edge.yaml b/spec/test/sample_schemas/duplicate_names/test/test_edge.yaml new file mode 100644 index 00000000..fab7ad6e --- /dev/null +++ b/spec/test/sample_schemas/duplicate_names/test/test_edge.yaml @@ -0,0 +1,10 @@ +name: test_edge +type: edge +schema: + "$schema": "http://json-schema.org/draft-07/schema#" + type: object + required: [_from, _to] + description: Example edge schema for testing. + properties: + _from: {type: string} + _to: {type: string} diff --git a/spec/test/sample_schemas/duplicate_names/test/test_vertex.yaml b/spec/test/sample_schemas/duplicate_names/test/test_vertex.yaml new file mode 100644 index 00000000..b2d34668 --- /dev/null +++ b/spec/test/sample_schemas/duplicate_names/test/test_vertex.yaml @@ -0,0 +1,11 @@ +name: test_vertex +type: vertex +schema: + "$schema": "http://json-schema.org/draft-07/schema#" + type: object + required: [_key] + description: An example vertex schema for testing + properties: + _key: {type: string} + is_public: {type: boolean} + ws_id: {type: integer} diff --git a/spec/test/stored_queries/test_djornl.py b/spec/test/stored_queries/test_djornl.py index fe14dd23..6794645e 100644 --- a/spec/test/stored_queries/test_djornl.py +++ b/spec/test/stored_queries/test_djornl.py @@ -60,15 +60,21 @@ def submit_query(self, query_name, query_data={}): """submit a database query""" if _VERBOSE: - q_data_str = json.dumps(query_data) - print('query data string: ' + q_data_str) + print('query data string: ' + json.dumps(query_data)) return run_query(query_name, query_data) - def check_expected_results(self, description, response, expected): + def test_expected_results(self, description=None, response=None, expected=None): + + # don't run the tests if they're being called automatically + if response is None: + self.assertTrue(True) + return if _VERBOSE: print("Running test " + description) + if 'results' not in response: + print({'response': response}) results = response['results'][0] self.assertEqual( @@ -81,13 +87,113 @@ def check_expected_results(self, description, response, expected): set(expected['edges']) ) + def test_error_response(self, description=None, response=None, expected=None): + + # don't run the tests if they're being called automatically + if response is None: + self.assertTrue(True) + return + + self.assertIn('error', response) + self.assertEqual(response['error'], expected) + + def test_errors(self): + + # query not found + self.test_error_response( + 'stored query not found', + self.submit_query('djornl_fetch_phenotype', { + 'keys': ['A', 'B', 'C'], + }), + { + 'details': "Stored query 'djornl_fetch_phenotype' does not exist.", + 'message': 'Not found', + 'name': 'djornl_fetch_phenotype', + 'status': 404 + } + ) + + # extra param not in query + self.test_error_response( + 'parameter not allowed in query', + self.submit_query('djornl_fetch_all', { + 'musical': 'Mary Poppins', + }), + { + 'failed_validator': 'additionalProperties', + 'message': "Additional properties are not allowed ('musical' was unexpected)", + 'path': [], + 'status': 400, + 'value': {'musical': 'Mary Poppins'}, + } + ) + + # missing required param + self.test_error_response( + 'missing required parameter', + self.submit_query('djornl_fetch_phenotypes', {}), + { + 'failed_validator': 'required', + 'message': "'keys' is a required property", + 'path': [], + 'status': 400, + 'value': {}, + } + ) + + # param not in correct format (should be array, not str) + self.test_error_response( + 'parameter should be array, not string', + self.submit_query('djornl_fetch_clusters', { + 'cluster_ids': 'Mary Poppins', + }), + { + 'failed_validator': 'type', + 'message': "'Mary Poppins' is not of type 'array'", + 'path': ['cluster_ids'], + 'status': 400, + 'value': 'Mary Poppins' + } + ) + + # invalid param (fails validation) + self.test_error_response( + 'invalid parameter fails validation', + self.submit_query('djornl_fetch_clusters', { + 'cluster_ids': ['Mary Poppins'], + }), + { + 'failed_validator': 'pattern', + 'message': "'Mary Poppins' does not match '^\\\\w+:\\\\d+$'", + 'path': ['cluster_ids', 0], + 'status': 400, + 'value': 'Mary Poppins' + } + ) + + # not enough array items + self.test_error_response( + 'minItems parameter fails validation', + self.submit_query('djornl_fetch_clusters', { + 'cluster_ids': [], + }), + { + 'failed_validator': 'minItems', + 'message': "[] is too short", + 'path': ['cluster_ids'], + 'status': 400, + 'value': [] + } + ) + def test_fetch_all(self): + all_results = self.json_data['fetch_all']['-'] response = self.submit_query('djornl_fetch_all') - self.check_expected_results( + self.test_expected_results( "djornl_fetch_all", response, - self.json_data['fetch_all'] + all_results ) # ensure that all the cluster data is returned OK @@ -126,7 +232,7 @@ def test_fetch_phenotypes(self): "keys": fetch_args.split('__'), "distance": int(distance), }) - self.check_expected_results( + self.test_expected_results( "fetch phenotypes with args " + fetch_args + " and distance " + distance, resp, distance_data @@ -140,7 +246,7 @@ def test_fetch_genes(self): "keys": fetch_args.split('__'), "distance": int(distance), }) - self.check_expected_results( + self.test_expected_results( "fetch genes with args " + fetch_args + " and distance " + distance, resp, distance_data @@ -154,7 +260,7 @@ def test_fetch_clusters(self): "cluster_ids": fetch_args.split('__'), "distance": int(distance), }) - self.check_expected_results( + self.test_expected_results( "fetch clusters with args " + fetch_args + " and distance " + distance, resp, distance_data @@ -168,7 +274,7 @@ def test_search_nodes(self): "search_text": search_text, "distance": int(distance), }) - self.check_expected_results( + self.test_expected_results( "search nodes with args " + search_text + " and distance " + distance, resp, distance_data diff --git a/spec/test/stored_queries/test_ncbi_tax.py b/spec/test/stored_queries/test_ncbi_tax.py index 7b6817e0..6e3a0435 100644 --- a/spec/test/stored_queries/test_ncbi_tax.py +++ b/spec/test/stored_queries/test_ncbi_tax.py @@ -187,7 +187,7 @@ def test_search_sciname_wrong_type(self): data=json.dumps({'ts': _NOW, 'search_text': 123}) ) self.assertEqual(resp.status_code, 400) - self.assertEqual(resp.json()['error'], "123 is not of type 'string'") + self.assertEqual(resp.json()['error']['message'], "123 is not of type 'string'") def test_search_sciname_missing_search(self): """Test a query to search sciname with the search_text param missing.""" @@ -197,7 +197,7 @@ def test_search_sciname_missing_search(self): data=json.dumps({'ts': _NOW}) ) self.assertEqual(resp.status_code, 400) - self.assertEqual(resp.json()['error'], "'search_text' is a required property") + self.assertEqual(resp.json()['error']['message'], "'search_text' is a required property") def test_search_sciname_more_complicated(self): """Test a query to search sciname with some more keyword options.""" @@ -222,7 +222,7 @@ def test_search_sciname_offset_max(self): data=json.dumps({'ts': _NOW, 'search_text': "prefix:bact", "offset": 100001}) ) self.assertEqual(resp.status_code, 400) - self.assertEqual(resp.json()['error'], "100001 is greater than the maximum of 100000") + self.assertEqual(resp.json()['error']['message'], "100001 is greater than the maximum of 100000") def test_search_sciname_limit_max(self): """Test a query to search sciname with an invalid offset (greater than max).""" @@ -232,7 +232,7 @@ def test_search_sciname_limit_max(self): data=json.dumps({'ts': _NOW, 'search_text': "prefix:bact", "limit": 1001}) ) self.assertEqual(resp.status_code, 400) - self.assertEqual(resp.json()['error'], "1001 is greater than the maximum of 1000") + self.assertEqual(resp.json()['error']['message'], "1001 is greater than the maximum of 1000") def test_search_sciname_limit_ranks_implicit_defaults(self): """ Test queries where the results are limited by the rank or strain flag. """ @@ -381,14 +381,14 @@ def test_fetch_taxon_by_sciname_failures(self): params={'stored_query': 'ncbi_fetch_taxon_by_sciname'}, data=json.dumps({'ts': _NOW}) ).json() - self.assertEqual(resp['error'], "'sciname' is a required property") + self.assertEqual(resp['error']['message'], "'sciname' is a required property") # No ts resp = requests.post( _CONF['re_api_url'] + '/api/v1/query_results', params={'stored_query': 'ncbi_fetch_taxon_by_sciname'}, data=json.dumps({'sciname': 'Deltaproteobacteria'}) ).json() - self.assertEqual(resp['error'], "'ts' is a required property") + self.assertEqual(resp['error']['message'], "'ts' is a required property") # sciname not found resp = requests.post( _CONF['re_api_url'] + '/api/v1/query_results', diff --git a/spec/test/stored_queries/test_taxonomy.py b/spec/test/stored_queries/test_taxonomy.py index e317d205..a6075548 100644 --- a/spec/test/stored_queries/test_taxonomy.py +++ b/spec/test/stored_queries/test_taxonomy.py @@ -271,7 +271,7 @@ def test_search_sciname_wrong_type(self): }) ) self.assertEqual(resp.status_code, 400) - self.assertEqual(resp.json()['error'], "123 is not of type 'string'") + self.assertEqual(resp.json()['error']['message'], "123 is not of type 'string'") def test_search_sciname_missing_search(self): """Test a query to search sciname with the search_text param missing.""" @@ -281,7 +281,7 @@ def test_search_sciname_missing_search(self): data=json.dumps({'ts': _NOW, '@taxon_coll': 'ncbi_taxon'}) ) self.assertEqual(resp.status_code, 400) - self.assertEqual(resp.json()['error'], "'search_text' is a required property") + self.assertEqual(resp.json()['error']['message'], "'search_text' is a required property") def test_search_sciname_more_complicated(self): """Test a query to search sciname with some more keyword options.""" @@ -314,7 +314,7 @@ def test_search_sciname_offset_max(self): }) ) self.assertEqual(resp.status_code, 400) - self.assertEqual(resp.json()['error'], "100001 is greater than the maximum of 100000") + self.assertEqual(resp.json()['error']['message'], "100001 is greater than the maximum of 100000") def test_search_sciname_limit_max(self): """Test a query to search sciname with an invalid offset (greater than max).""" @@ -330,7 +330,7 @@ def test_search_sciname_limit_max(self): }) ) self.assertEqual(resp.status_code, 400) - self.assertEqual(resp.json()['error'], "1001 is greater than the maximum of 1000") + self.assertEqual(resp.json()['error']['message'], "1001 is greater than the maximum of 1000") def test_search_sciname_limit_ranks_implicit_defaults(self): """ Test queries where the results are limited by the rank or strain flag. """ @@ -495,7 +495,7 @@ def test_fetch_taxon_by_sciname_failures(self): params={'stored_query': 'taxonomy_fetch_taxon_by_sciname'}, data=json.dumps({'ts': _NOW, 'sciname_field': 'scientific_name', '@taxon_coll': 'ncbi_taxon'}) ).json() - self.assertEqual(resp['error'], "'sciname' is a required property") + self.assertEqual(resp['error']['message'], "'sciname' is a required property") # No ts resp = requests.post( _CONF['re_api_url'] + '/api/v1/query_results', @@ -506,7 +506,7 @@ def test_fetch_taxon_by_sciname_failures(self): '@taxon_coll': 'ncbi_taxon' }) ).json() - self.assertEqual(resp['error'], "'ts' is a required property") + self.assertEqual(resp['error']['message'], "'ts' is a required property") # sciname not found resp = requests.post( _CONF['re_api_url'] + '/api/v1/query_results', diff --git a/spec/test/test_validate.py b/spec/test/test_validate.py index 1577147c..e104a6c5 100644 --- a/spec/test/test_validate.py +++ b/spec/test/test_validate.py @@ -13,7 +13,8 @@ validate_stored_query, validate_data_source, validate_view, - validate_all + validate_all, + validate_all_by_type, ) _TEST_DIR = '/app/spec/test/sample_schemas' @@ -28,7 +29,7 @@ def setUpClass(cls): def test_validate_schema(self): """Validate a single file using the generic validate_schema method""" - err_msg = 'No validation schema found for made-up_schema' + err_msg = "No validation schema found for 'made-up_schema'" with self.assertRaisesRegex(ValueError, err_msg): validate_schema('/path/to/file', 'made-up_schema') @@ -176,6 +177,16 @@ def test_validate_view(self): def test_validate_all(self): """test all the files in a directory""" + with self.assertRaisesRegex(ValueError, "No validation schema found for 'muffins'"): + validate_all('muffins') + + def validate_all_duplicate_names(self): + with self.assertRaisesRegex(ValidationError, "duplicate_names failed validation"): + validate_all('collection', os_path.join(_TEST_DIR, 'duplicate_names')) + + stdout = capture_stdout(validate_all_duplicate_names, self) + self.assertRegex(stdout, "Duplicate queries named 'test_vertex'") + sample_schemas = { 'collection': 'collections', 'stored_query': 'stored_queries', @@ -184,10 +195,20 @@ def test_validate_all(self): } for (schema_type, directory) in sample_schemas.items(): - # n.b. this assumes all the schemas in /spec are valid! stdout = capture_stdout(validate_all, schema_type) self.assertRegex(stdout, r'...all valid') with self.assertRaises(Exception): validate_all(schema_type, os_path.join(_TEST_DIR, directory)) + + def test_validate_all_by_type(self): + """test all files of all types from a root directory""" + + # use value from config + n_errors = validate_all_by_type() + self.assertEqual(n_errors, 0) + + # known dodgy dir + n_errors = validate_all_by_type(_TEST_DIR) + self.assertGreater(n_errors, 0) diff --git a/spec/validate.py b/spec/validate.py index dec6b6dc..4ce6dbda 100644 --- a/spec/validate.py +++ b/spec/validate.py @@ -36,12 +36,20 @@ def validate_all(schema_type, directory=None): - """Validate the syntax of all schemas of a certain type.""" - print(f'Validating {schema_type} schemas...') - + """ + Validate the syntax of all schemas of type schema_type in a specified directory + + :param schema_type: (string) the schema type to validate + :param directory: (string) the directory to look in. + If not specified, the default directory for the schema_type + will be used. + """ if schema_type not in _VALID_SCHEMA_TYPES.keys(): - raise ValueError('No validation schema found for ' + schema_type) + raise ValueError(f"No validation schema found for '{schema_type}'") + print(f'Validating {schema_type} schemas...') + + err_count = 0 names = set() # type: set if directory is None: type_dir_name = _VALID_SCHEMA_TYPES[schema_type]['plural'] @@ -49,23 +57,71 @@ def validate_all(schema_type, directory=None): for path in glob.iglob(os.path.join(directory, '**', '*.*'), recursive=True): if path.endswith('.yaml') or path.endswith('.json'): - data = validate_schema(path, schema_type) + try: + data = validate_schema(path, schema_type) + # Check for any duplicate schema names + name = data['name'] + if name in names: + raise ValueError(f"Duplicate queries named '{name}'") + else: + names.add(name) + + except Exception as err: + print(f"✕ {path} failed validation") + print(err) + err_count += 1 + + if err_count: + raise ValidationError(f'{directory} failed validation') + + # all's well + print('...all valid.') + return + + +def validate_all_by_type(validation_base_dir=None): + """ + Validate the syntax of all schemas of all types in validation_base_dir + + Assumes that the schemas will be set up in parent directories named with the plural form + of the schema type name, i.e. all collection schemas in the 'collections' dir, all views + in the 'views' dir, etc. + + :param validation_base_dir: (string) the directory to look in. + If not specified, the default directory from the config + will be used - # Check for any duplicate schema names - name = data['name'] - if name in names: - raise ValueError(f'Duplicate queries named {name}') + :return n_errors: (int) the number of errors encountered + + """ + + n_errors = 0 + for schema_type in sorted(_VALID_SCHEMA_TYPES.keys()): + try: + if validation_base_dir is None: + validate_all(schema_type) else: - names.add(name) + directory = os.path.join( + validation_base_dir, + _VALID_SCHEMA_TYPES[schema_type]['plural'] + ) + validate_all(schema_type, directory) + except Exception as err: + print(err) + n_errors += 1 + print("\n") - print('...all valid.') + if n_errors > 0: + print('Validation failed!\n') + + return n_errors def validate_schema(path, schema_type): """Validate a single file against its schema""" if schema_type not in _VALID_SCHEMA_TYPES.keys(): - raise ValueError('No validation schema found for ' + schema_type) + raise ValueError(f"No validation schema found for '{schema_type}'") return globals()["validate_" + schema_type](path) @@ -184,16 +240,12 @@ def validate_aql_on_arango(data): + f" Extra params in schema: {params - query_bind_vars}") -def _fatal(msg): - """Fatal error.""" - sys.stderr.write(str(msg) + '\n') - sys.exit(1) +if __name__ == '__main__': + validation_base_dir = None + if len(sys.argv) > 1: + validation_base_dir = sys.argv[1] -if __name__ == '__main__': wait_for_arangodb() - try: - for s in ['data_source', 'stored_query', 'view', 'collection']: - validate_all(s) - except Exception as err: - _fatal(err) + n_errors = validate_all_by_type(validation_base_dir) + sys.exit(n_errors) From 3df50b05640db7606a541744f51d4454bddd7d7b Mon Sep 17 00:00:00 2001 From: ialarmedalien Date: Tue, 1 Sep 2020 09:46:45 -0700 Subject: [PATCH 568/732] Remove "status" key from error response and update affected files. Refactor test_djornl tests to put all results in the results.json file. Update djornl_fetch_* queries to ensure that empty arrays cannot be entered as query params --- client_src/test/test_integration.py | 1 - relation_engine_server/README.md | 1 - relation_engine_server/main.py | 5 +- relation_engine_server/test/test_api_v1.py | 279 +++++--- .../djornl/djornl_fetch_clusters.yaml | 6 +- .../djornl/djornl_fetch_genes.yaml | 4 +- .../djornl/djornl_fetch_phenotypes.yaml | 4 +- spec/test/djornl/results.json | 666 +++++++++++------- spec/test/stored_queries/test_djornl.py | 244 ++----- spec/validate.py | 3 +- 10 files changed, 626 insertions(+), 587 deletions(-) diff --git a/client_src/test/test_integration.py b/client_src/test/test_integration.py index 43d757e0..40cf1bdb 100644 --- a/client_src/test/test_integration.py +++ b/client_src/test/test_integration.py @@ -175,7 +175,6 @@ def test_save_docs_unknown_coll(self): { 'error': { 'message': 'Not found', - 'status': 404, 'details': "Collection 'xyz123' does not exist.", 'name': 'xyz123', } diff --git a/relation_engine_server/README.md b/relation_engine_server/README.md index 9f4a0909..1689158d 100644 --- a/relation_engine_server/README.md +++ b/relation_engine_server/README.md @@ -22,7 +22,6 @@ The majority of errors returned from the server have explanatory information in { "error": { "message": "A brief message explaining the error", - "status": 400, # or the appropriate HTTP error status code } } ``` diff --git a/relation_engine_server/main.py b/relation_engine_server/main.py index 266e5375..00a0c2f8 100644 --- a/relation_engine_server/main.py +++ b/relation_engine_server/main.py @@ -25,16 +25,13 @@ def return_error(error_dict, code): 'error': { 'message': , - 'status': , } The 'error' dictionary may have extra keys if there is additional information. - This helper adds the 'status' key and value to the input, and wraps the whole structure - in an extra dict under the key 'error'. + This helper wraps the whole structure in an extra dict under the key 'error'. """ - error_dict['status'] = code return (flask.jsonify({'error': error_dict}), code) diff --git a/relation_engine_server/test/test_api_v1.py b/relation_engine_server/test/test_api_v1.py index d941d449..21c50ded 100644 --- a/relation_engine_server/test/test_api_v1.py +++ b/relation_engine_server/test/test_api_v1.py @@ -99,20 +99,20 @@ def test_request(self, url=None, params=None, data=None, headers=None, method='g def test_root(self): """Test root path for api.""" - resp = requests.get(URL + '/').json() - self.assertEqual(resp['arangodb_status'], 'connected_authorized') - self.assertTrue(resp['commit_hash']) - self.assertTrue(resp['repo_url']) + resp_json = requests.get(URL + '/').json() + self.assertEqual(resp_json['arangodb_status'], 'connected_authorized') + self.assertTrue(resp_json['commit_hash']) + self.assertTrue(resp_json['repo_url']) def test_config(self): """Test config fetch.""" - resp = requests.get(API_URL + '/config').json() - self.assertTrue(len(resp['auth_url'])) - self.assertTrue(len(resp['workspace_url'])) - self.assertTrue(len(resp['kbase_endpoint'])) - self.assertTrue(len(resp['db_url'])) - self.assertTrue(len(resp['db_name'])) - self.assertTrue(len(resp['spec_url'])) + resp_json = requests.get(API_URL + '/config').json() + self.assertTrue(len(resp_json['auth_url'])) + self.assertTrue(len(resp_json['workspace_url'])) + self.assertTrue(len(resp_json['kbase_endpoint'])) + self.assertTrue(len(resp_json['db_url'])) + self.assertTrue(len(resp_json['db_name'])) + self.assertTrue(len(resp_json['spec_url'])) def test_update_specs(self): """Test the endpoint that triggers an update on the specs.""" @@ -271,7 +271,6 @@ def test_fetch_invalid_data_source(self): status_code=404, resp_json={ 'error': { - 'status': 404, 'message': 'Not found', 'details': f"Data source '{name}' does not exist.", 'name': name, @@ -294,7 +293,6 @@ def test_fetch_invalid_collections_and_documents(self): status_code=404, resp_json={ 'error': { - 'status': 404, 'message': 'Not found', 'details': f"Collection '{name}' does not exist.", 'name': name, @@ -312,7 +310,6 @@ def test_fetch_invalid_stored_queries(self): status_code=404, resp_json={ 'error': { - 'status': 404, 'message': 'Not found', 'details': f"Stored query '{name}' does not exist.", 'name': name, @@ -366,7 +363,6 @@ def test_show_data_source_unknown(self): status_code=404, resp_json={ 'error': { - 'status': 404, 'message': 'Not found', 'details': f"Data source '{name}' does not exist.", 'name': name, @@ -374,55 +370,76 @@ def test_show_data_source_unknown(self): } ) - resp = requests.get(f"{API_URL}/data_sources/{name}") - self.assertEqual(resp.status_code, 404) - resp_json = resp.json() - self.assertEqual(resp_json, { - 'error': { - 'message': 'Not found', - 'status': 404, - 'name': name, - 'details': f"Data source '{name}' does not exist.", - } - }) - def test_save_documents_missing_auth(self): """Test an invalid attempt to save a doc with a missing auth token.""" - resp = requests.put( - API_URL + '/documents?on_duplicate=error&overwrite=true&collection' - ).json() - self.assertEqual(resp['error'], {'message': 'Missing header: Authorization', 'status': 400}) + self.test_request( + '/documents?on_duplicate=error&overwrite=true&collection', + method='put', + status_code=400, + resp_json={'error': {'message': 'Missing header: Authorization'}}, + ) def test_save_documents_invalid_auth(self): """Test an invalid attempt to save a doc with a bad auth token.""" - resp = requests.put( - API_URL + '/documents?on_duplicate=error&overwrite=true&collection', - headers={'Authorization': 'Bearer ' + INVALID_TOKEN} - ).json() - self.assertEqual(resp['error']['message'], 'Unauthorized') - self.assertEqual(resp['error']['status'], 403) + + # see ./mock_auth/auth_invalid.json for the response + auth_response = { + "error": { + "httpcode": 401, + "httpstatus": "Unauthorized", + "appcode": 10020, + "apperror": "Invalid token", + "message": "10020 Invalid token", + "callid": "1757210147564211", + "time": 1542737889450 + } + } + + self.test_request( + '/documents?on_duplicate=error&overwrite=true&collection', + headers={'Authorization': 'Bearer ' + INVALID_TOKEN}, + method='put', + status_code=403, + resp_json={'error': { + 'message': 'Unauthorized', + 'auth_url': 'http://auth:5000', + 'auth_response': json.dumps(auth_response) + }}, + ) def test_save_documents_non_admin(self): """Test an invalid attempt to save a doc as a non-admin.""" - resp = requests.put( - API_URL + '/documents?on_duplicate=error&overwrite=true&collection', - headers=HEADERS_NON_ADMIN - ).json() - self.assertEqual(resp['error']['message'], 'Unauthorized') - self.assertEqual(resp['error']['status'], 403) + self.test_request( + '/documents?on_duplicate=error&overwrite=true&collection', + headers=HEADERS_NON_ADMIN, + method='put', + status_code=403, + resp_json={ + 'error': { + 'auth_response': 'Missing role', + 'auth_url': 'http://auth:5000', + 'message': 'Unauthorized' + } + }, + ) def test_save_documents_invalid_schema(self): """Test the case where some documents fail against their schema.""" - resp = requests.put( - API_URL + '/documents', + + self.test_request( + '/documents', params={'on_duplicate': 'ignore', 'collection': 'test_vertex'}, data='{"name": "x"}\n{"name": "y"}', - headers=HEADERS_ADMIN - ).json() - self.assertEqual(resp['error']['message'], "'_key' is a required property") - self.assertEqual(resp['error']['value'], {'name': 'x'}) - self.assertEqual(resp['error']['path'], []) - self.assertEqual(resp['error']['failed_validator'], 'required') + headers=HEADERS_ADMIN, + method='put', + status_code=400, + resp_json={'error': { + 'message': "'_key' is a required property", + 'value': {'name': 'x'}, + 'path': [], + 'failed_validator': 'required', + }}, + ) def test_save_documents_missing_schema(self): """Test the case where the collection/schema does not exist.""" @@ -437,7 +454,6 @@ def test_save_documents_missing_schema(self): status_code=404, resp_json={ 'error': { - 'status': 404, 'message': 'Not found', 'details': f"Collection '{name}' does not exist.", 'name': name, @@ -447,15 +463,15 @@ def test_save_documents_missing_schema(self): def test_save_documents_invalid_json(self): """Test an attempt to save documents with an invalid JSON body.""" - resp = requests.put( + resp_json = requests.put( API_URL + '/documents', params={'collection': 'test_vertex'}, data='\n', headers=HEADERS_ADMIN ).json() - self.assertTrue('Unable to parse' in resp['error']['message']) - self.assertEqual(resp['error']['pos'], 1) - self.assertEqual(resp['error']['source_json'], '\n') + self.assertTrue('Unable to parse' in resp_json['error']['message']) + self.assertEqual(resp_json['error']['pos'], 1) + self.assertEqual(resp_json['error']['source_json'], '\n') def test_create_documents(self): """Test all valid cases for saving documents.""" @@ -471,14 +487,14 @@ def test_create_edges(self): def test_update_documents(self): """Test updating existing documents.""" - resp = requests.put( + resp_json = requests.put( API_URL + '/documents', params={'on_duplicate': 'update', 'collection': 'test_vertex'}, data=create_test_docs(3), headers=HEADERS_ADMIN ).json() expected = {'created': 0, 'errors': 0, 'empty': 0, 'updated': 3, 'ignored': 0, 'error': False} - self.assertEqual(resp, expected) + self.assertEqual(resp_json, expected) def test_update_edge(self): """Test updating existing edge.""" @@ -490,110 +506,133 @@ def test_update_edge(self): headers=HEADERS_ADMIN ) self.assertTrue(resp.ok) - resp = requests.put( + resp_json = requests.put( API_URL + '/documents', params={'on_duplicate': 'update', 'collection': 'test_edge'}, data=edges, headers=HEADERS_ADMIN ).json() expected = {'created': 0, 'errors': 0, 'empty': 0, 'updated': 3, 'ignored': 0, 'error': False} - self.assertEqual(resp, expected) + self.assertEqual(resp_json, expected) def test_replace_documents(self): """Test replacing of existing documents.""" - resp = requests.put( + resp_json = requests.put( API_URL + '/documents', params={'on_duplicate': 'replace', 'collection': 'test_vertex'}, data=create_test_docs(3), headers=HEADERS_ADMIN ).json() expected = {'created': 0, 'errors': 0, 'empty': 0, 'updated': 3, 'ignored': 0, 'error': False} - self.assertEqual(resp, expected) + self.assertEqual(resp_json, expected) def test_save_documents_dupe_errors(self): """Test where we want to raise errors on duplicate documents.""" save_test_docs(3) - resp = requests.put( + resp_json = requests.put( API_URL + '/documents', params={'on_duplicate': 'error', 'collection': 'test_vertex', 'display_errors': '1'}, data=create_test_docs(3), headers=HEADERS_ADMIN ).json() - self.assertEqual(resp['created'], 0) - self.assertEqual(resp['errors'], 3) - self.assertTrue(resp['details']) + self.assertEqual(resp_json['created'], 0) + self.assertEqual(resp_json['errors'], 3) + self.assertTrue(resp_json['details']) def test_save_documents_ignore_dupes(self): """Test ignoring duplicate, existing documents when saving.""" - resp = requests.put( + resp_json = requests.put( API_URL + '/documents', params={'on_duplicate': 'ignore', 'collection': 'test_vertex'}, data=create_test_docs(3), headers=HEADERS_ADMIN ).json() expected = {'created': 0, 'errors': 0, 'empty': 0, 'updated': 0, 'ignored': 3, 'error': False} - self.assertEqual(resp, expected) + self.assertEqual(resp_json, expected) def test_admin_query(self): """Test an ad-hoc query made by an admin.""" save_test_docs(1) query = 'for v in test_vertex sort rand() limit @count return v._id' - resp = requests.post( + resp_json = requests.post( API_URL + '/query_results', params={}, headers=HEADERS_ADMIN, data=json.dumps({'query': query, 'count': 1}) ).json() - self.assertEqual(resp['count'], 1) - self.assertEqual(len(resp['results']), 1) + self.assertEqual(resp_json['count'], 1) + self.assertEqual(len(resp_json['results']), 1) def test_admin_query_non_admin(self): """Test an ad-hoc query error as a non-admin.""" query = 'for v in test_vertex sort rand() limit @count return v._id' - resp = requests.post( - API_URL + '/query_results', + auth_response = '{"class":"Exception","error":"Unable to match endpoint: POST /"}\n' + self.test_request( + '/query_results', + method='post', params={}, headers=HEADERS_NON_ADMIN, - data=json.dumps({'query': query, 'count': 1}) - ).json() - self.assertEqual(resp['error']['message'], 'Unauthorized') - self.assertEqual(resp['error']['status'], 403) + data=json.dumps({'query': query, 'count': 1}), + status_code=403, + resp_json={'error': { + 'message': 'Unauthorized', + 'auth_url': 'http://workspace:5000', + 'auth_response': auth_response + }}, + ) def test_admin_query_invalid_auth(self): """Test the error response for an ad-hoc admin query without auth.""" + + # see ./mock_workspace/list_workspace_ids_invalid.json for response query = 'for v in test_vertex sort rand() limit @count return v._id' - resp = requests.post( - API_URL + '/query_results', + self.test_request( + '/query_results', + method='post', params={}, headers={'Authorization': INVALID_TOKEN}, - data=json.dumps({'query': query, 'count': 1}) - ).json() - self.assertEqual(resp['error']['message'], 'Unauthorized') - self.assertEqual(resp['error']['status'], 403) + data=json.dumps({'query': query, 'count': 1}), + status_code=403, + resp_json={ + 'error': { + 'message': 'Unauthorized', + 'auth_url': 'http://workspace:5000', + 'auth_response': json.dumps({ + "version": "1.1", + "error": { + "name": "JSONRPCError", + "code": -32400, + "message": "Token validation failed!", + "error": "..." + } + }) + } + } + ) def test_query_with_cursor(self): """Test getting more data via a query cursor and setting batch size.""" save_test_docs(count=20) - resp = requests.post( + resp_json = requests.post( API_URL + '/query_results', params={'stored_query': 'list_test_vertices', 'batch_size': 10, 'full_count': True} ).json() - self.assertTrue(resp['cursor_id']) - self.assertEqual(resp['has_more'], True) - self.assertEqual(resp['count'], 20) - self.assertEqual(resp['stats']['fullCount'], 20) - self.assertTrue(len(resp['results']), 10) - - cursor_id = resp['cursor_id'] - resp = requests.post( + self.assertTrue(resp_json['cursor_id']) + self.assertEqual(resp_json['has_more'], True) + self.assertEqual(resp_json['count'], 20) + self.assertEqual(resp_json['stats']['fullCount'], 20) + self.assertTrue(len(resp_json['results']), 10) + + cursor_id = resp_json['cursor_id'] + resp_json = requests.post( API_URL + '/query_results', params={'cursor_id': cursor_id} ).json() - self.assertEqual(resp['count'], 20) - self.assertEqual(resp['stats']['fullCount'], 20) - self.assertEqual(resp['has_more'], False) - self.assertEqual(resp['cursor_id'], None) - self.assertTrue(len(resp['results']), 10) + self.assertEqual(resp_json['count'], 20) + self.assertEqual(resp_json['stats']['fullCount'], 20) + self.assertEqual(resp_json['has_more'], False) + self.assertEqual(resp_json['cursor_id'], None) + self.assertTrue(len(resp_json['results']), 10) # Try to get the same cursor again self.test_request( @@ -603,7 +642,6 @@ def test_query_with_cursor(self): status_code=400, resp_json={ 'error': { - 'status': 400, 'message': 'ArangoDB server error.', 'arango_message': 'cursor not found', } @@ -621,7 +659,6 @@ def test_query_no_name(self): status_code=404, resp_json={ 'error': { - 'status': 404, 'message': 'Not found', 'details': f"Stored query '{name}' does not exist.", 'name': name, @@ -641,7 +678,6 @@ def test_query_missing_bind_var(self): status_code=400, resp_json={ 'error': { - 'status': 400, 'message': 'ArangoDB server error.', 'arango_message': arango_msg, } @@ -662,13 +698,13 @@ def test_auth_query_with_access(self): }), headers=HEADERS_ADMIN ) - resp = requests.post( + resp_json = requests.post( API_URL + '/query_results', params={'stored_query': 'list_test_vertices'}, headers={'Authorization': 'valid_token'} # see ./mock_workspace/endpoints.json ).json() - self.assertEqual(resp['count'], 1) - self.assertEqual(resp['results'][0]['ws_id'], ws_id) + self.assertEqual(resp_json['count'], 1) + self.assertEqual(resp_json['results'][0]['ws_id'], ws_id) def test_auth_query_no_access(self): """Test the case where we try to query a collection without the right workspace access.""" @@ -679,12 +715,12 @@ def test_auth_query_no_access(self): data='{"name": "requires_auth", "_key": "1", "ws_id": 9999}', headers=HEADERS_ADMIN ) - resp = requests.post( + resp_json = requests.post( API_URL + '/query_results', params={'stored_query': 'list_test_vertices'}, headers={'Authorization': 'valid_token'} # see ./mock_workspace/endpoints.json ).json() - self.assertEqual(resp['count'], 0) + self.assertEqual(resp_json['count'], 0) def test_query_cannot_pass_ws_ids(self): """Test that users cannot set the ws_ids param.""" @@ -695,13 +731,13 @@ def test_query_cannot_pass_ws_ids(self): data='{"name": "requires_auth", "_key": "1", "ws_id": 99}', headers=HEADERS_ADMIN ) - resp = requests.post( + resp_json = requests.post( API_URL + '/query_results', params={'view': 'list_test_vertices'}, data=json.dumps({'ws_ids': [ws_id]}), headers={'Authorization': 'valid_token'} ).json() - self.assertEqual(resp['count'], 0) + self.assertEqual(resp_json['count'], 0) def test_auth_query_invalid_token(self): """Test the case where we try to authorize a query using an invalid auth token.""" @@ -712,13 +748,30 @@ def test_auth_query_invalid_token(self): headers=HEADERS_ADMIN ) - resp = requests.post( - API_URL + '/query_results', + # see ./mock_workspace/list_workspace_ids_invalid.json for response + self.test_request( + '/query_results', params={'view': 'list_test_vertices'}, data=json.dumps({'ws_ids': [1]}), - headers={'Authorization': INVALID_TOKEN} + headers={'Authorization': INVALID_TOKEN}, + method='post', + status_code=403, + resp_json={ + 'error': { + 'message': 'Unauthorized', + 'auth_url': 'http://workspace:5000', + 'auth_response': json.dumps({ + "version": "1.1", + "error": { + "name": "JSONRPCError", + "code": -32400, + "message": "Token validation failed!", + "error": "..." + } + }) + } + } ) - self.assertEqual(resp.status_code, 403) def test_auth_adhoc_query(self): """Test that the 'ws_ids' bind-var is set for RE_ADMINs.""" @@ -731,12 +784,12 @@ def test_auth_adhoc_query(self): ) # This is the same query as list_test_vertices.aql in the spec query = 'for o in test_vertex filter o.is_public || o.ws_id IN ws_ids return o' - resp = requests.post( + resp_json = requests.post( API_URL + '/query_results', data=json.dumps({'query': query}), headers={'Authorization': ADMIN_TOKEN} # see ./mock_workspace/endpoints.json ).json() - self.assertEqual(resp['count'], 1) + self.assertEqual(resp_json['count'], 1) def test_save_docs_invalid(self): """Test that an invalid bulk save returns a 400 response""" diff --git a/spec/stored_queries/djornl/djornl_fetch_clusters.yaml b/spec/stored_queries/djornl/djornl_fetch_clusters.yaml index 4aa6070e..498dc62b 100644 --- a/spec/stored_queries/djornl/djornl_fetch_clusters.yaml +++ b/spec/stored_queries/djornl/djornl_fetch_clusters.yaml @@ -8,8 +8,12 @@ params: type: array title: Cluster IDs description: Cluster IDs, in the form "clustering_system_name:cluster_id" - items: {type: string} + items: + type: string + format: regex + pattern: ^\w+:\d+$ examples: [['markov_i2:5', 'markov_i6:2'],['markov_i6:1']] + minItems: 1 distance: type: integer title: Traversal Distance diff --git a/spec/stored_queries/djornl/djornl_fetch_genes.yaml b/spec/stored_queries/djornl/djornl_fetch_genes.yaml index 42bbeeb5..6b8a8639 100644 --- a/spec/stored_queries/djornl/djornl_fetch_genes.yaml +++ b/spec/stored_queries/djornl/djornl_fetch_genes.yaml @@ -13,8 +13,10 @@ params: maximum: 100 keys: type: array - items: {type: string} + items: + type: string title: Gene Keys + minItems: 1 examples: [["AT1G01010"],["AT1G01020","AT1G01070"]] query: | LET node_ids = ( diff --git a/spec/stored_queries/djornl/djornl_fetch_phenotypes.yaml b/spec/stored_queries/djornl/djornl_fetch_phenotypes.yaml index 0e27ee4a..41482924 100644 --- a/spec/stored_queries/djornl/djornl_fetch_phenotypes.yaml +++ b/spec/stored_queries/djornl/djornl_fetch_phenotypes.yaml @@ -13,8 +13,10 @@ params: maximum: 100 keys: type: array - items: {type: string} + items: + type: string title: Phenotype Keys + minItems: 1 examples: [["As2"],["As2", "Na23"]] query: | LET node_ids = ( diff --git a/spec/test/djornl/results.json b/spec/test/djornl/results.json index 71e5e7ba..80c42a9c 100644 --- a/spec/test/djornl/results.json +++ b/spec/test/djornl/results.json @@ -56,299 +56,421 @@ {"_key": "SDV", "node_type": "pheno", "transcript": "", "gene_symbol": "", "gene_full_name": "", "gene_model_type": "", "tair_computational_description": "", "tair_curator_summary": "", "tair_short_description": "", "go_description": "", "go_terms": [], "mapman_bin": "", "mapman_name": "", "mapman_description": "", "pheno_aragwas_id": "10.21958/phenotype:104", "pheno_description": "Number of days following stratification to opening of first flower. The experiment was stopped at 200 d, and accessions that had not flowered at that point were assigned a value of 200", "pheno_pto_name": "days to flowering trait", "pheno_pto_description": "A flowering time trait (TO:0002616)which is the number of days required for an individual flower (PO:0009046), a whole plant (PO:0000003) or a plant population to reach flowering stage (PO:0007616) from a predetermined time point (e.g. the date of seed sowing, seedling transplant, or seedling emergence). [GR:pj, TO:cooperl]", "pheno_ref": "Atwell et. al, Nature 2010", "user_notes": ""} ] }, - "fetch_all": { - "-": { - "nodes": [ - "As2", - "As75", - "AT1G01010", - "AT1G01020", - "AT1G01030", - "AT1G01040", - "AT1G01050", - "AT1G01060", - "AT1G01070", - "AT1G01080", - "AT1G01090", - "AT1G01100", - "Na23", - "SDV" - ], - "edges": [ - "As2__AT1G01020__AraGWAS-Phenotype_Associations__8.4", - "As2__AT1G01040__AraGWAS-Phenotype_Associations__5.4", - "As75__AT1G01020__AraGWAS-Phenotype_Associations__39.9", - "AT1G01010__AT1G01020__AraNetv2-HT_high-throughput-ppi__2.3", - "AT1G01010__AT1G01030__AraNetv2-HT_high-throughput-ppi__2.4", - "AT1G01010__AT1G01040__AraNetv2-DC_domain-co-occurrence__2.5", - "AT1G01010__AT1G01040__AraNetv2-LC_lit-curated-ppi__170.5", - "AT1G01030__AT1G01050__AraNetv2-CX_pairwise-gene-coexpression__2.6", - "AT1G01050__AT1G01060__AraNetv2-LC_lit-curated-ppi__2.7", - "AT1G01080__AT1G01090__AraNetv2-LC_lit-curated-ppi__2.8" - ] - } - }, - "fetch_genes": { - "keys": { - "Mary Poppins": { - "distance": { - "0": {"nodes": [], "edges": []}, - "1": {"nodes": [], "edges": []}, - "5": {"nodes": [], "edges": []} + "queries": { + "djornl_fetch_phenotype": [ + { + "params": {"keys": ["A", "B", "C"]}, + "error": { + "details": "Stored query 'djornl_fetch_phenotype' does not exist.", + "message": "Not found", + "name": "djornl_fetch_phenotype" + } + } + ], + "djornl_fetch_all": [ + { + "params": {}, + "results": { + "nodes": [ + "As2", + "As75", + "AT1G01010", + "AT1G01020", + "AT1G01030", + "AT1G01040", + "AT1G01050", + "AT1G01060", + "AT1G01070", + "AT1G01080", + "AT1G01090", + "AT1G01100", + "Na23", + "SDV" + ], + "edges": [ + "As2__AT1G01020__AraGWAS-Phenotype_Associations__8.4", + "As2__AT1G01040__AraGWAS-Phenotype_Associations__5.4", + "As75__AT1G01020__AraGWAS-Phenotype_Associations__39.9", + "AT1G01010__AT1G01020__AraNetv2-HT_high-throughput-ppi__2.3", + "AT1G01010__AT1G01030__AraNetv2-HT_high-throughput-ppi__2.4", + "AT1G01010__AT1G01040__AraNetv2-DC_domain-co-occurrence__2.5", + "AT1G01010__AT1G01040__AraNetv2-LC_lit-curated-ppi__170.5", + "AT1G01030__AT1G01050__AraNetv2-CX_pairwise-gene-coexpression__2.6", + "AT1G01050__AT1G01060__AraNetv2-LC_lit-curated-ppi__2.7", + "AT1G01080__AT1G01090__AraNetv2-LC_lit-curated-ppi__2.8" + ] + } + }, + { + "params": {"musical": "Mary Poppins"}, + "error": { + "message": "ArangoDB server error.", + "arango_message": "AQL: bind parameter 'musical' was not declared in the query (while parsing)" + } + } + ], + "djornl_fetch_genes": [ + { + "params": {}, + "error": { + "failed_validator": "required", + "message": "'keys' is a required property", + "path": [], + "value": {"ws_ids": []} + } + }, + { + "params": {"keys": []}, + "error": { + "failed_validator": "minItems", + "message": "[] is too short", + "path": ["keys"], + "value": [] + } + }, + { + "params": { "keys": ["Mary Poppins"], "distance": 0 }, + "results": {"nodes": [], "edges": []} + }, + { + "params": { "keys": ["Mary Poppins"], "distance": 1 }, + "results": {"nodes": [], "edges": []} + }, + { + "params": { "keys": ["Mary Poppins"], "distance": 5 }, + "results": {"nodes": [], "edges": []} + }, + { + "params": { "keys": ["AT1G01010"], "distance": 0 }, + "results": { + "nodes": ["AT1G01010"], + "edges": [] + } + }, + { + "params": { "keys": ["AT1G01010"], "distance": 1 }, + "results": { + "nodes": [ + "AT1G01010", + "AT1G01020", + "AT1G01030", + "AT1G01040" + ], + "edges": [ + "AT1G01010__AT1G01020__AraNetv2-HT_high-throughput-ppi__2.3", + "AT1G01010__AT1G01030__AraNetv2-HT_high-throughput-ppi__2.4", + "AT1G01010__AT1G01040__AraNetv2-DC_domain-co-occurrence__2.5", + "AT1G01010__AT1G01040__AraNetv2-LC_lit-curated-ppi__170.5" + ] + } + }, + { + "params": { "keys": ["AT1G01010"], "distance": 5 }, + "results": { + "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060"], + "edges": [ + "As2__AT1G01020__AraGWAS-Phenotype_Associations__8.4", + "As2__AT1G01040__AraGWAS-Phenotype_Associations__5.4", + "As75__AT1G01020__AraGWAS-Phenotype_Associations__39.9", + "AT1G01010__AT1G01020__AraNetv2-HT_high-throughput-ppi__2.3", + "AT1G01010__AT1G01030__AraNetv2-HT_high-throughput-ppi__2.4", + "AT1G01010__AT1G01040__AraNetv2-DC_domain-co-occurrence__2.5", + "AT1G01010__AT1G01040__AraNetv2-LC_lit-curated-ppi__170.5", + "AT1G01030__AT1G01050__AraNetv2-CX_pairwise-gene-coexpression__2.6", + "AT1G01050__AT1G01060__AraNetv2-LC_lit-curated-ppi__2.7" + ] + } + }, + { + "params": {"keys": ["AT1G01020", "AT1G01070"], "distance": 0 }, + "results": { + "nodes": ["AT1G01020", "AT1G01070"], + "edges": [] } }, - "AT1G01010": { - "distance": { - "0": { - "nodes": ["AT1G01010"], - "edges": [] - }, - "1": { - "nodes": [ - "AT1G01010", - "AT1G01020", - "AT1G01030", - "AT1G01040" - ], - "edges": [ - "AT1G01010__AT1G01020__AraNetv2-HT_high-throughput-ppi__2.3", - "AT1G01010__AT1G01030__AraNetv2-HT_high-throughput-ppi__2.4", - "AT1G01010__AT1G01040__AraNetv2-DC_domain-co-occurrence__2.5", - "AT1G01010__AT1G01040__AraNetv2-LC_lit-curated-ppi__170.5" - ] - }, - "5": { - "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060"], - "edges": [ - "As2__AT1G01020__AraGWAS-Phenotype_Associations__8.4", - "As2__AT1G01040__AraGWAS-Phenotype_Associations__5.4", - "As75__AT1G01020__AraGWAS-Phenotype_Associations__39.9", - "AT1G01010__AT1G01020__AraNetv2-HT_high-throughput-ppi__2.3", - "AT1G01010__AT1G01030__AraNetv2-HT_high-throughput-ppi__2.4", - "AT1G01010__AT1G01040__AraNetv2-DC_domain-co-occurrence__2.5", - "AT1G01010__AT1G01040__AraNetv2-LC_lit-curated-ppi__170.5", - "AT1G01030__AT1G01050__AraNetv2-CX_pairwise-gene-coexpression__2.6", - "AT1G01050__AT1G01060__AraNetv2-LC_lit-curated-ppi__2.7" - ] - } + { + "params": {"keys": ["AT1G01020", "AT1G01070"], "distance": 1 }, + "results": { + "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01070"], + "edges": [ + "As2__AT1G01020__AraGWAS-Phenotype_Associations__8.4", + "As75__AT1G01020__AraGWAS-Phenotype_Associations__39.9", + "AT1G01010__AT1G01020__AraNetv2-HT_high-throughput-ppi__2.3" + ] } }, - "AT1G01020__AT1G01070": { - "distance": { - "0": { - "nodes": ["AT1G01020", "AT1G01070"], - "edges": [] - }, - "1": { - "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01070"], - "edges": [ - "As2__AT1G01020__AraGWAS-Phenotype_Associations__8.4", - "As75__AT1G01020__AraGWAS-Phenotype_Associations__39.9", - "AT1G01010__AT1G01020__AraNetv2-HT_high-throughput-ppi__2.3" - ] - }, - "5": { - "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060", "AT1G01070"], - "edges": [ - "As2__AT1G01020__AraGWAS-Phenotype_Associations__8.4", - "As2__AT1G01040__AraGWAS-Phenotype_Associations__5.4", - "As75__AT1G01020__AraGWAS-Phenotype_Associations__39.9", - "AT1G01010__AT1G01020__AraNetv2-HT_high-throughput-ppi__2.3", - "AT1G01010__AT1G01030__AraNetv2-HT_high-throughput-ppi__2.4", - "AT1G01010__AT1G01040__AraNetv2-DC_domain-co-occurrence__2.5", - "AT1G01010__AT1G01040__AraNetv2-LC_lit-curated-ppi__170.5", - "AT1G01030__AT1G01050__AraNetv2-CX_pairwise-gene-coexpression__2.6", - "AT1G01050__AT1G01060__AraNetv2-LC_lit-curated-ppi__2.7" - ] - } + { + "params": {"keys": ["AT1G01020", "AT1G01070"], "distance": 5 }, + "results": { + "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060", "AT1G01070"], + "edges": [ + "As2__AT1G01020__AraGWAS-Phenotype_Associations__8.4", + "As2__AT1G01040__AraGWAS-Phenotype_Associations__5.4", + "As75__AT1G01020__AraGWAS-Phenotype_Associations__39.9", + "AT1G01010__AT1G01020__AraNetv2-HT_high-throughput-ppi__2.3", + "AT1G01010__AT1G01030__AraNetv2-HT_high-throughput-ppi__2.4", + "AT1G01010__AT1G01040__AraNetv2-DC_domain-co-occurrence__2.5", + "AT1G01010__AT1G01040__AraNetv2-LC_lit-curated-ppi__170.5", + "AT1G01030__AT1G01050__AraNetv2-CX_pairwise-gene-coexpression__2.6", + "AT1G01050__AT1G01060__AraNetv2-LC_lit-curated-ppi__2.7" + ] } } - } - }, - "fetch_phenotypes": { - "keys": { - "Mary Poppins": { - "distance": { - "0": {"nodes": [], "edges": []}, - "1": {"nodes": [], "edges": []}, - "5": {"nodes": [], "edges": []} + ], + "djornl_fetch_phenotypes": [ + { + "params": {"keys": "Mary Poppins"}, + "error": { + "failed_validator": "type", + "message": "'Mary Poppins' is not of type 'array'", + "path": ["keys"], + "value": "Mary Poppins" + } + }, + { + "params": {"keys": ["Mary Poppins"], "distance": 0}, + "results": {"nodes": [], "edges": []} + }, + { + "params": {"keys": ["Mary Poppins"], "distance": 1}, + "results": {"nodes": [], "edges": []} + }, + { + "params": {"keys": ["Mary Poppins"], "distance": 5}, + "results": {"nodes": [], "edges": []} + }, + { + "params": {"keys": ["As2"], "distance": 0}, + "results": { + "nodes": ["As2"], + "edges": [] + } + }, + { + "params": {"keys": ["As2"], "distance": 1}, + "results": { + "nodes": ["As2", "AT1G01020", "AT1G01040"], + "edges": [ + "As2__AT1G01020__AraGWAS-Phenotype_Associations__8.4", + "As2__AT1G01040__AraGWAS-Phenotype_Associations__5.4" + ] + } + }, + { + "params": {"keys": ["As2"], "distance": 5}, + "results": { + "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060"], + "edges": [ + "As2__AT1G01020__AraGWAS-Phenotype_Associations__8.4", + "As2__AT1G01040__AraGWAS-Phenotype_Associations__5.4", + "As75__AT1G01020__AraGWAS-Phenotype_Associations__39.9", + "AT1G01010__AT1G01020__AraNetv2-HT_high-throughput-ppi__2.3", + "AT1G01010__AT1G01030__AraNetv2-HT_high-throughput-ppi__2.4", + "AT1G01010__AT1G01040__AraNetv2-DC_domain-co-occurrence__2.5", + "AT1G01010__AT1G01040__AraNetv2-LC_lit-curated-ppi__170.5", + "AT1G01030__AT1G01050__AraNetv2-CX_pairwise-gene-coexpression__2.6", + "AT1G01050__AT1G01060__AraNetv2-LC_lit-curated-ppi__2.7" + ] + } + }, + { + "params": {"keys": ["As2", "Na23"], "distance": 0}, + "results": { + "nodes": ["As2", "Na23"], + "edges": [] } }, - "As2": { - "distance": { - "0": { - "nodes": ["As2"], - "edges": [] - }, - "1": { - "nodes": ["As2", "AT1G01020", "AT1G01040"], - "edges": [ - "As2__AT1G01020__AraGWAS-Phenotype_Associations__8.4", - "As2__AT1G01040__AraGWAS-Phenotype_Associations__5.4" - ] - }, - "5": { - "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060"], - "edges": [ - "As2__AT1G01020__AraGWAS-Phenotype_Associations__8.4", - "As2__AT1G01040__AraGWAS-Phenotype_Associations__5.4", - "As75__AT1G01020__AraGWAS-Phenotype_Associations__39.9", - "AT1G01010__AT1G01020__AraNetv2-HT_high-throughput-ppi__2.3", - "AT1G01010__AT1G01030__AraNetv2-HT_high-throughput-ppi__2.4", - "AT1G01010__AT1G01040__AraNetv2-DC_domain-co-occurrence__2.5", - "AT1G01010__AT1G01040__AraNetv2-LC_lit-curated-ppi__170.5", - "AT1G01030__AT1G01050__AraNetv2-CX_pairwise-gene-coexpression__2.6", - "AT1G01050__AT1G01060__AraNetv2-LC_lit-curated-ppi__2.7" - ] - } + { + "params": {"keys": ["As2", "Na23"], "distance": 1}, + "results": { + "nodes": ["As2", "Na23", "AT1G01020", "AT1G01040"], + "edges": [ + "As2__AT1G01020__AraGWAS-Phenotype_Associations__8.4", + "As2__AT1G01040__AraGWAS-Phenotype_Associations__5.4" + ] } }, - "As2__Na23": { - "distance": { - "0": { - "nodes": ["As2", "Na23"], - "edges": [] - }, - "1": { - "nodes": ["As2", "Na23", "AT1G01020", "AT1G01040"], - "edges": [ - "As2__AT1G01020__AraGWAS-Phenotype_Associations__8.4", - "As2__AT1G01040__AraGWAS-Phenotype_Associations__5.4" - ] - }, - "5": { - "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060", "Na23"], - "edges": [ - "As2__AT1G01020__AraGWAS-Phenotype_Associations__8.4", - "As2__AT1G01040__AraGWAS-Phenotype_Associations__5.4", - "As75__AT1G01020__AraGWAS-Phenotype_Associations__39.9", - "AT1G01010__AT1G01020__AraNetv2-HT_high-throughput-ppi__2.3", - "AT1G01010__AT1G01030__AraNetv2-HT_high-throughput-ppi__2.4", - "AT1G01010__AT1G01040__AraNetv2-DC_domain-co-occurrence__2.5", - "AT1G01010__AT1G01040__AraNetv2-LC_lit-curated-ppi__170.5", - "AT1G01030__AT1G01050__AraNetv2-CX_pairwise-gene-coexpression__2.6", - "AT1G01050__AT1G01060__AraNetv2-LC_lit-curated-ppi__2.7" - ] - } + { + "params": {"keys": ["As2", "Na23"], "distance": 5}, + "results": { + "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060", "Na23"], + "edges": [ + "As2__AT1G01020__AraGWAS-Phenotype_Associations__8.4", + "As2__AT1G01040__AraGWAS-Phenotype_Associations__5.4", + "As75__AT1G01020__AraGWAS-Phenotype_Associations__39.9", + "AT1G01010__AT1G01020__AraNetv2-HT_high-throughput-ppi__2.3", + "AT1G01010__AT1G01030__AraNetv2-HT_high-throughput-ppi__2.4", + "AT1G01010__AT1G01040__AraNetv2-DC_domain-co-occurrence__2.5", + "AT1G01010__AT1G01040__AraNetv2-LC_lit-curated-ppi__170.5", + "AT1G01030__AT1G01050__AraNetv2-CX_pairwise-gene-coexpression__2.6", + "AT1G01050__AT1G01060__AraNetv2-LC_lit-curated-ppi__2.7" + ] } } - } - }, - "search_nodes": { - "search_text": { - "Mary Poppins": { - "distance": { - "0": {"nodes": [], "edges": []}, - "1": {"nodes": [], "edges": []}, - "5": {"nodes": [], "edges": []} + ], + "djornl_search_nodes": [ + { + "params": {"search_text": "Mary Poppins", "distance": 0}, + "results": {"nodes": [], "edges": []} + }, + { + "params": {"search_text": "Mary Poppins", "distance": 1}, + "results": {"nodes": [], "edges": []} + }, + { + "params": {"search_text": "Mary Poppins", "distance": 5}, + "results": {"nodes": [], "edges": []} + }, + { + "params": {"search_text": "GO:0005515", "distance": 0}, + "results": { + "nodes": ["AT1G01040", "AT1G01090"], + "edges": [] + } + }, + { + "params": {"search_text": "GO:0005515", "distance": 1}, + "results": { + "nodes": ["As2", "AT1G01010", "AT1G01040", "AT1G01080", "AT1G01090"], + "edges": [ + "As2__AT1G01040__AraGWAS-Phenotype_Associations__5.4", + "AT1G01010__AT1G01040__AraNetv2-DC_domain-co-occurrence__2.5", + "AT1G01010__AT1G01040__AraNetv2-LC_lit-curated-ppi__170.5", + "AT1G01080__AT1G01090__AraNetv2-LC_lit-curated-ppi__2.8" + ] } }, - "GO:0005515": { - "distance": { - "0": { - "nodes": ["AT1G01040", "AT1G01090"], - "edges": [] - }, - "1": { - "nodes": ["As2", "AT1G01010", "AT1G01040", "AT1G01080", "AT1G01090"], - "edges": [ - "As2__AT1G01040__AraGWAS-Phenotype_Associations__5.4", - "AT1G01010__AT1G01040__AraNetv2-DC_domain-co-occurrence__2.5", - "AT1G01010__AT1G01040__AraNetv2-LC_lit-curated-ppi__170.5", - "AT1G01080__AT1G01090__AraNetv2-LC_lit-curated-ppi__2.8" - ] - }, - "5": { - "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060", "AT1G01080", "AT1G01090"], - "edges": [ - "As2__AT1G01020__AraGWAS-Phenotype_Associations__8.4", - "As2__AT1G01040__AraGWAS-Phenotype_Associations__5.4", - "As75__AT1G01020__AraGWAS-Phenotype_Associations__39.9", - "AT1G01010__AT1G01020__AraNetv2-HT_high-throughput-ppi__2.3", - "AT1G01010__AT1G01030__AraNetv2-HT_high-throughput-ppi__2.4", - "AT1G01010__AT1G01040__AraNetv2-DC_domain-co-occurrence__2.5", - "AT1G01010__AT1G01040__AraNetv2-LC_lit-curated-ppi__170.5", - "AT1G01030__AT1G01050__AraNetv2-CX_pairwise-gene-coexpression__2.6", - "AT1G01050__AT1G01060__AraNetv2-LC_lit-curated-ppi__2.7", - "AT1G01080__AT1G01090__AraNetv2-LC_lit-curated-ppi__2.8" - ] - } + { + "params": {"search_text": "GO:0005515", "distance": 5}, + "results": { + "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060", "AT1G01080", "AT1G01090"], + "edges": [ + "As2__AT1G01020__AraGWAS-Phenotype_Associations__8.4", + "As2__AT1G01040__AraGWAS-Phenotype_Associations__5.4", + "As75__AT1G01020__AraGWAS-Phenotype_Associations__39.9", + "AT1G01010__AT1G01020__AraNetv2-HT_high-throughput-ppi__2.3", + "AT1G01010__AT1G01030__AraNetv2-HT_high-throughput-ppi__2.4", + "AT1G01010__AT1G01040__AraNetv2-DC_domain-co-occurrence__2.5", + "AT1G01010__AT1G01040__AraNetv2-LC_lit-curated-ppi__170.5", + "AT1G01030__AT1G01050__AraNetv2-CX_pairwise-gene-coexpression__2.6", + "AT1G01050__AT1G01060__AraNetv2-LC_lit-curated-ppi__2.7", + "AT1G01080__AT1G01090__AraNetv2-LC_lit-curated-ppi__2.8" + ] } } - } - }, - - "fetch_clusters": { - "cluster_ids": { - "MaryPoppins:1": { - "distance": { - "0": {"nodes": [], "edges": []}, - "1": {"nodes": [], "edges": []}, - "5": {"nodes": [], "edges": []} + ], + "djornl_fetch_clusters": [ + { + "params": {"cluster_ids": "Mary Poppins"}, + "error": { + "failed_validator": "type", + "message": "'Mary Poppins' is not of type 'array'", + "path": ["cluster_ids"], + "value": "Mary Poppins" + } + }, + { + "params": {"cluster_ids": ["Mary Poppins"]}, + "error": { + "failed_validator": "pattern", + "message": "'Mary Poppins' does not match '^\\\\w+:\\\\d+$'", + "path": ["cluster_ids", 0], + "value": "Mary Poppins" + } + }, + { + "params": {"cluster_ids": []}, + "error": { + "failed_validator": "minItems", + "message": "[] is too short", + "path": ["cluster_ids"], + "value": [] + } + }, + { + "params": {"cluster_ids": ["MaryPoppins:1"], "distance": 0}, + "results": {"nodes": [], "edges": []} + }, + { + "params": {"cluster_ids": ["MaryPoppins:1"], "distance": 1}, + "results": {"nodes": [], "edges": []} + }, + { + "params": {"cluster_ids": ["MaryPoppins:1"], "distance": 5}, + "results": {"nodes": [], "edges": []} + }, + { + "params": {"cluster_ids": ["markov_i6:1"], "distance": 0}, + "results": { + "nodes": ["AT1G01040", "AT1G01090"], + "edges": [] } }, - "markov_i6:1": { - "distance": { - "0": { - "nodes": ["AT1G01040", "AT1G01090"], - "edges": [] - }, - "1": { - "nodes": ["As2", "AT1G01010", "AT1G01040", "AT1G01080", "AT1G01090"], - "edges": [ - "As2__AT1G01040__AraGWAS-Phenotype_Associations__5.4", - "AT1G01010__AT1G01040__AraNetv2-DC_domain-co-occurrence__2.5", - "AT1G01010__AT1G01040__AraNetv2-LC_lit-curated-ppi__170.5", - "AT1G01080__AT1G01090__AraNetv2-LC_lit-curated-ppi__2.8" - ] - }, - "5": { - "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060", "AT1G01080", "AT1G01090"], - "edges": [ - "As2__AT1G01020__AraGWAS-Phenotype_Associations__8.4", - "As2__AT1G01040__AraGWAS-Phenotype_Associations__5.4", - "As75__AT1G01020__AraGWAS-Phenotype_Associations__39.9", - "AT1G01010__AT1G01020__AraNetv2-HT_high-throughput-ppi__2.3", - "AT1G01010__AT1G01030__AraNetv2-HT_high-throughput-ppi__2.4", - "AT1G01010__AT1G01040__AraNetv2-DC_domain-co-occurrence__2.5", - "AT1G01010__AT1G01040__AraNetv2-LC_lit-curated-ppi__170.5", - "AT1G01030__AT1G01050__AraNetv2-CX_pairwise-gene-coexpression__2.6", - "AT1G01050__AT1G01060__AraNetv2-LC_lit-curated-ppi__2.7", - "AT1G01080__AT1G01090__AraNetv2-LC_lit-curated-ppi__2.8" - ] - } + { + "params": {"cluster_ids": ["markov_i6:1"], "distance": 1}, + "results": { + "nodes": ["As2", "AT1G01010", "AT1G01040", "AT1G01080", "AT1G01090"], + "edges": [ + "As2__AT1G01040__AraGWAS-Phenotype_Associations__5.4", + "AT1G01010__AT1G01040__AraNetv2-DC_domain-co-occurrence__2.5", + "AT1G01010__AT1G01040__AraNetv2-LC_lit-curated-ppi__170.5", + "AT1G01080__AT1G01090__AraNetv2-LC_lit-curated-ppi__2.8" + ] } }, - "markov_i2:5__markov_i6:2": { - "distance": { - "0": { - "nodes": ["AT1G01020", "AT1G01070"], - "edges": [] - }, - "1": { - "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01070"], - "edges": [ - "As2__AT1G01020__AraGWAS-Phenotype_Associations__8.4", - "As75__AT1G01020__AraGWAS-Phenotype_Associations__39.9", - "AT1G01010__AT1G01020__AraNetv2-HT_high-throughput-ppi__2.3" - ] - }, - "5": { - "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060", "AT1G01070"], - "edges": [ - "As2__AT1G01020__AraGWAS-Phenotype_Associations__8.4", - "As2__AT1G01040__AraGWAS-Phenotype_Associations__5.4", - "As75__AT1G01020__AraGWAS-Phenotype_Associations__39.9", - "AT1G01010__AT1G01020__AraNetv2-HT_high-throughput-ppi__2.3", - "AT1G01010__AT1G01030__AraNetv2-HT_high-throughput-ppi__2.4", - "AT1G01010__AT1G01040__AraNetv2-DC_domain-co-occurrence__2.5", - "AT1G01010__AT1G01040__AraNetv2-LC_lit-curated-ppi__170.5", - "AT1G01030__AT1G01050__AraNetv2-CX_pairwise-gene-coexpression__2.6", - "AT1G01050__AT1G01060__AraNetv2-LC_lit-curated-ppi__2.7" - ] - } + { + "params": {"cluster_ids": ["markov_i6:1"], "distance": 5}, + "results": { + "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060", "AT1G01080", "AT1G01090"], + "edges": [ + "As2__AT1G01020__AraGWAS-Phenotype_Associations__8.4", + "As2__AT1G01040__AraGWAS-Phenotype_Associations__5.4", + "As75__AT1G01020__AraGWAS-Phenotype_Associations__39.9", + "AT1G01010__AT1G01020__AraNetv2-HT_high-throughput-ppi__2.3", + "AT1G01010__AT1G01030__AraNetv2-HT_high-throughput-ppi__2.4", + "AT1G01010__AT1G01040__AraNetv2-DC_domain-co-occurrence__2.5", + "AT1G01010__AT1G01040__AraNetv2-LC_lit-curated-ppi__170.5", + "AT1G01030__AT1G01050__AraNetv2-CX_pairwise-gene-coexpression__2.6", + "AT1G01050__AT1G01060__AraNetv2-LC_lit-curated-ppi__2.7", + "AT1G01080__AT1G01090__AraNetv2-LC_lit-curated-ppi__2.8" + ] + } + }, + { + "params": {"cluster_ids": ["markov_i2:5", "markov_i6:2"], "distance": 0}, + "results": { + "nodes": ["AT1G01020", "AT1G01070"], + "edges": [] + } + }, + { + "params": {"cluster_ids": ["markov_i2:5", "markov_i6:2"], "distance": 1}, + "results": { + "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01070"], + "edges": [ + "As2__AT1G01020__AraGWAS-Phenotype_Associations__8.4", + "As75__AT1G01020__AraGWAS-Phenotype_Associations__39.9", + "AT1G01010__AT1G01020__AraNetv2-HT_high-throughput-ppi__2.3" + ] + } + }, + { + "params": {"cluster_ids": ["markov_i2:5", "markov_i6:2"], "distance": 5}, + "results": { + "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060", "AT1G01070"], + "edges": [ + "As2__AT1G01020__AraGWAS-Phenotype_Associations__8.4", + "As2__AT1G01040__AraGWAS-Phenotype_Associations__5.4", + "As75__AT1G01020__AraGWAS-Phenotype_Associations__39.9", + "AT1G01010__AT1G01020__AraNetv2-HT_high-throughput-ppi__2.3", + "AT1G01010__AT1G01030__AraNetv2-HT_high-throughput-ppi__2.4", + "AT1G01010__AT1G01040__AraNetv2-DC_domain-co-occurrence__2.5", + "AT1G01010__AT1G01040__AraNetv2-LC_lit-curated-ppi__170.5", + "AT1G01030__AT1G01050__AraNetv2-CX_pairwise-gene-coexpression__2.6", + "AT1G01050__AT1G01060__AraNetv2-LC_lit-curated-ppi__2.7" + ] } } - } + ] } } diff --git a/spec/test/stored_queries/test_djornl.py b/spec/test/stored_queries/test_djornl.py index 6794645e..8c27e719 100644 --- a/spec/test/stored_queries/test_djornl.py +++ b/spec/test/stored_queries/test_djornl.py @@ -56,144 +56,72 @@ def setUpClass(cls): r = create_test_docs(node_name, cluster_data['nodes'], True) print_db_update(r, node_name) - def submit_query(self, query_name, query_data={}): - """submit a database query""" - - if _VERBOSE: - print('query data string: ' + json.dumps(query_data)) - - return run_query(query_name, query_data) - - def test_expected_results(self, description=None, response=None, expected=None): + def test_expected_results(self, query_name=None, test_data=None): # don't run the tests if they're being called automatically - if response is None: + if query_name is None: self.assertTrue(True) return - if _VERBOSE: - print("Running test " + description) - if 'results' not in response: - print({'response': response}) + # ensure we have either 'results' or 'error' in the test data + self.assertTrue('results' in test_data or 'error' in test_data) - results = response['results'][0] - self.assertEqual( - set([n["_key"] for n in results['nodes']]), - set(expected['nodes']) - ) + params = {} + if 'params' in test_data: + params = test_data['params'] - self.assertEqual( - set([e["_key"] for e in results['edges']]), - set(expected['edges']) - ) + response = run_query(query_name, params) - def test_error_response(self, description=None, response=None, expected=None): - - # don't run the tests if they're being called automatically - if response is None: - self.assertTrue(True) - return - - self.assertIn('error', response) - self.assertEqual(response['error'], expected) + if _VERBOSE: + print("Running query " + query_name) + if 'params' in test_data: + print({'params': params}) - def test_errors(self): + # expecting an error response + if 'error' in test_data: + if 'error' not in response: + print({'response': response}) - # query not found - self.test_error_response( - 'stored query not found', - self.submit_query('djornl_fetch_phenotype', { - 'keys': ['A', 'B', 'C'], - }), - { - 'details': "Stored query 'djornl_fetch_phenotype' does not exist.", - 'message': 'Not found', - 'name': 'djornl_fetch_phenotype', - 'status': 404 - } - ) + self.assertIn('error', response) + self.assertEqual(response['error'], test_data['error']) + return response - # extra param not in query - self.test_error_response( - 'parameter not allowed in query', - self.submit_query('djornl_fetch_all', { - 'musical': 'Mary Poppins', - }), - { - 'failed_validator': 'additionalProperties', - 'message': "Additional properties are not allowed ('musical' was unexpected)", - 'path': [], - 'status': 400, - 'value': {'musical': 'Mary Poppins'}, - } - ) + # expecting a valid response + if 'results' not in response: + print({'response': response}) - # missing required param - self.test_error_response( - 'missing required parameter', - self.submit_query('djornl_fetch_phenotypes', {}), - { - 'failed_validator': 'required', - 'message': "'keys' is a required property", - 'path': [], - 'status': 400, - 'value': {}, - } - ) + self.assertIn('results', response) + results = response['results'][0] - # param not in correct format (should be array, not str) - self.test_error_response( - 'parameter should be array, not string', - self.submit_query('djornl_fetch_clusters', { - 'cluster_ids': 'Mary Poppins', - }), - { - 'failed_validator': 'type', - 'message': "'Mary Poppins' is not of type 'array'", - 'path': ['cluster_ids'], - 'status': 400, - 'value': 'Mary Poppins' - } + self.assertEqual( + set([n["_key"] for n in results['nodes']]), + set(test_data['results']['nodes']) ) - # invalid param (fails validation) - self.test_error_response( - 'invalid parameter fails validation', - self.submit_query('djornl_fetch_clusters', { - 'cluster_ids': ['Mary Poppins'], - }), - { - 'failed_validator': 'pattern', - 'message': "'Mary Poppins' does not match '^\\\\w+:\\\\d+$'", - 'path': ['cluster_ids', 0], - 'status': 400, - 'value': 'Mary Poppins' - } + self.assertEqual( + set([e["_key"] for e in results['edges']]), + set(test_data['results']['edges']) ) + return response - # not enough array items - self.test_error_response( - 'minItems parameter fails validation', - self.submit_query('djornl_fetch_clusters', { - 'cluster_ids': [], - }), - { - 'failed_validator': 'minItems', - 'message': "[] is too short", - 'path': ['cluster_ids'], - 'status': 400, - 'value': [] - } - ) + # indexing schema in results.json + # self.json_data['queries'][query_name] + # e.g. for fetch_clusters data: + # "djornl_fetch_clusters": { + # "params": { "cluster_ids": ["markov_i2:6", "markov_i4:3"], "distance": "1"}, + # "results": { + # "nodes": [ node IDs ], + # "edges": [ edge data ] + # } + # } + # nodes are represented as a list of node[_key] + # edges are objects with keys _to, _from, edge_type and score def test_fetch_all(self): - - all_results = self.json_data['fetch_all']['-'] - response = self.submit_query('djornl_fetch_all') - self.test_expected_results( + '''Ensure that data returned by the fetch all query has all the information that we expect''' + response = self.test_expected_results( "djornl_fetch_all", - response, - all_results + self.json_data['queries']['djornl_fetch_all'][0] ) # ensure that all the cluster data is returned OK @@ -204,78 +132,10 @@ def test_fetch_all(self): {n['_key']: n['clusters'] for n in expected_node_data if 'clusters' in n}, ) - # indexing schema in results.json - # self.json_data[query_name][param_name][param_value]["distance"][distance_param] - # e.g. for fetch_clusters data: - # "fetch_clusters": { - # "cluster_ids": { - # "markov_i2:6__markov_i4:3": { - # "distance": { - # 1: { - # "nodes": [ node IDs ], - # "edges": [ edge data ], - # } - # } - # } - # } - # } - # if param_value is an array, join the array entities with "__" - # results are in the form {"nodes": [...], "edges": [...]} - # nodes are represented as a list of node[_key] - # edges are objects with keys _to, _from, edge_type and score - - def test_fetch_phenotypes(self): - - for (fetch_args, key_data) in self.json_data['fetch_phenotypes']['keys'].items(): - for (distance, distance_data) in key_data['distance'].items(): - resp = self.submit_query('djornl_fetch_phenotypes', { - "keys": fetch_args.split('__'), - "distance": int(distance), - }) - self.test_expected_results( - "fetch phenotypes with args " + fetch_args + " and distance " + distance, - resp, - distance_data - ) - - def test_fetch_genes(self): - - for (fetch_args, key_data) in self.json_data['fetch_genes']['keys'].items(): - for (distance, distance_data) in key_data['distance'].items(): - resp = self.submit_query('djornl_fetch_genes', { - "keys": fetch_args.split('__'), - "distance": int(distance), - }) - self.test_expected_results( - "fetch genes with args " + fetch_args + " and distance " + distance, - resp, - distance_data - ) - - def test_fetch_clusters(self): - - for (fetch_args, cluster_data) in self.json_data['fetch_clusters']['cluster_ids'].items(): - for (distance, distance_data) in cluster_data['distance'].items(): - resp = self.submit_query('djornl_fetch_clusters', { - "cluster_ids": fetch_args.split('__'), - "distance": int(distance), - }) - self.test_expected_results( - "fetch clusters with args " + fetch_args + " and distance " + distance, - resp, - distance_data - ) - - def test_search_nodes(self): + def test_queries(self): + '''Run parameterised queries and check for results or error messages''' - for (search_text, search_data) in self.json_data['search_nodes']['search_text'].items(): - for (distance, distance_data) in search_data['distance'].items(): - resp = self.submit_query('djornl_search_nodes', { - "search_text": search_text, - "distance": int(distance), - }) - self.test_expected_results( - "search nodes with args " + search_text + " and distance " + distance, - resp, - distance_data - ) + for query in self.json_data['queries'].keys(): + for test in self.json_data['queries'][query]: + with self.subTest(query=query, params=test['params']): + self.test_expected_results(query, test) diff --git a/spec/validate.py b/spec/validate.py index 4ce6dbda..286cdb58 100644 --- a/spec/validate.py +++ b/spec/validate.py @@ -248,4 +248,5 @@ def validate_aql_on_arango(data): wait_for_arangodb() n_errors = validate_all_by_type(validation_base_dir) - sys.exit(n_errors) + exit_code = 0 if not n_errors else 1 + sys.exit(exit_code) From e32e906efac38b036a05629b33ee062d30b82140 Mon Sep 17 00:00:00 2001 From: ialarmedalien Date: Tue, 1 Sep 2020 11:40:51 -0700 Subject: [PATCH 569/732] Remove injected ws_ids param unless it is required by the query Add "additionalProperties" to stored queries --- relation_engine_server/api_versions/api_v1.py | 27 +++- spec/datasets/distance.yaml | 7 + spec/datasets/djornl/definitions.yaml | 2 +- .../djornl/djornl_fetch_all.yaml | 12 +- .../djornl/djornl_fetch_clusters.yaml | 14 +- .../djornl/djornl_fetch_genes.yaml | 14 +- .../djornl/djornl_fetch_phenotypes.yaml | 14 +- .../djornl/djornl_search_nodes.yaml | 10 +- spec/test/djornl/results.json | 124 +++++++++++++++++- 9 files changed, 178 insertions(+), 46 deletions(-) create mode 100644 spec/datasets/distance.yaml diff --git a/relation_engine_server/api_versions/api_v1.py b/relation_engine_server/api_versions/api_v1.py index 515dd7a5..59687d92 100644 --- a/relation_engine_server/api_versions/api_v1.py +++ b/relation_engine_server/api_versions/api_v1.py @@ -79,6 +79,7 @@ def run_query(): # 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']) @@ -90,22 +91,36 @@ def run_query(): 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) + + has_ws_ids = False + if 'ws_ids' in stored_query['query']: + json_body['ws_ids'] = ws_ids + has_ws_ids = True + else: + del json_body['ws_ids'] + + stored_query_source = _preprocess_stored_query( + stored_query['query'], stored_query, has_ws_ids + ) + 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') + 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'] @@ -165,11 +180,11 @@ def show_config(): }) -def _preprocess_stored_query(query_text, config): +def _preprocess_stored_query(query_text, config, has_ws_ids=True): """Inject some default code into each stored query.""" + ws_id_text = " LET ws_ids = @ws_ids " if has_ws_ids else "" return ( config.get('query_prefix', '') + - " LET ws_ids = @ws_ids " + - # " LET maxint = 9007199254740991 " + + ws_id_text + query_text ) diff --git a/spec/datasets/distance.yaml b/spec/datasets/distance.yaml new file mode 100644 index 00000000..98b927b3 --- /dev/null +++ b/spec/datasets/distance.yaml @@ -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 diff --git a/spec/datasets/djornl/definitions.yaml b/spec/datasets/djornl/definitions.yaml index 81ee5e29..ceaa5546 100644 --- a/spec/datasets/djornl/definitions.yaml +++ b/spec/datasets/djornl/definitions.yaml @@ -35,7 +35,7 @@ definitions: _key: type: string title: Key - examples: ["AT1G01010"] + examples: ["AT1G01010", "As2"] clusters: type: array title: Clusters diff --git a/spec/stored_queries/djornl/djornl_fetch_all.yaml b/spec/stored_queries/djornl/djornl_fetch_all.yaml index 0d918c2f..c663efeb 100644 --- a/spec/stored_queries/djornl/djornl_fetch_all.yaml +++ b/spec/stored_queries/djornl/djornl_fetch_all.yaml @@ -2,7 +2,16 @@ name: djornl_fetch_all description: Fetch all node and edge data from the djornl subgraph params: type: object -# additionalProperties: false + additionalProperties: false + properties: + edge_types: + type: array + title: Edge types + description: Permitted edge types + items: + $ref: "../../datasets/djornl/edge_type.yaml" + default: [] + examples: [['AraNetv2-HT_high-throughput-ppi', 'AraNetv2-LC_lit-curated-ppi'],['AraGWAS-Phenotype_Associations']] query: | LET nodes = ( FOR v IN djornl_node @@ -10,6 +19,7 @@ query: | ) LET edges = ( FOR e IN djornl_edge + FILTER length(@edge_types) > 0 && e.edge_type IN @edge_types || length(@edge_types) == 0 RETURN e ) RETURN {nodes, edges} diff --git a/spec/stored_queries/djornl/djornl_fetch_clusters.yaml b/spec/stored_queries/djornl/djornl_fetch_clusters.yaml index 498dc62b..f8b099c6 100644 --- a/spec/stored_queries/djornl/djornl_fetch_clusters.yaml +++ b/spec/stored_queries/djornl/djornl_fetch_clusters.yaml @@ -2,6 +2,7 @@ name: djornl_fetch_clusters description: Fetch all nodes that are members of the specified cluster(s), and the edges and nodes within the specified distance (number of hops) of those nodes. params: type: object + additionalProperties: false required: [cluster_ids] properties: cluster_ids: @@ -9,18 +10,11 @@ params: title: Cluster IDs description: Cluster IDs, in the form "clustering_system_name:cluster_id" items: - type: string - format: regex - pattern: ^\w+:\d+$ - examples: [['markov_i2:5', 'markov_i6:2'],['markov_i6:1']] + $ref: "../../datasets/djornl/definitions.yaml#definitions/cluster_id" minItems: 1 + examples: [['markov_i2:5', 'markov_i6:2'],['markov_i6:1']] distance: - type: integer - title: Traversal Distance - description: How many hops to find neighbors and neighbors-of-neighbors - default: 1 - minimum: 0 - maximum: 100 + $ref: "../../datasets/distance.yaml" query: | LET node_ids = ( FOR n IN djornl_node diff --git a/spec/stored_queries/djornl/djornl_fetch_genes.yaml b/spec/stored_queries/djornl/djornl_fetch_genes.yaml index 6b8a8639..c0e5867b 100644 --- a/spec/stored_queries/djornl/djornl_fetch_genes.yaml +++ b/spec/stored_queries/djornl/djornl_fetch_genes.yaml @@ -2,22 +2,18 @@ name: djornl_fetch_genes description: Fetch a gene or list of genes by key, and the edges and nodes within the specified distance (number of hops) of those genes. params: type: object + additionalProperties: false required: [keys] properties: - distance: - type: integer - title: Traversal Distance - description: How many hops to find neighbors and neighbors-of-neighbors - default: 1 - minimum: 0 - maximum: 100 keys: type: array - items: - type: string title: Gene Keys + items: + $ref: "../../datasets/djornl/definitions.yaml#definitions/djornl_node/_key" minItems: 1 examples: [["AT1G01010"],["AT1G01020","AT1G01070"]] + distance: + $ref: "../../datasets/distance.yaml" query: | LET node_ids = ( FOR n IN djornl_node diff --git a/spec/stored_queries/djornl/djornl_fetch_phenotypes.yaml b/spec/stored_queries/djornl/djornl_fetch_phenotypes.yaml index 41482924..b76337a2 100644 --- a/spec/stored_queries/djornl/djornl_fetch_phenotypes.yaml +++ b/spec/stored_queries/djornl/djornl_fetch_phenotypes.yaml @@ -2,22 +2,18 @@ name: djornl_fetch_phenotypes description: Fetch a phenotype or list of phenotypes by key, and the edges and nodes within the specified distance (number of hops) of those phenotype nodes. params: type: object + additionalProperties: false required: [keys] properties: - distance: - type: integer - title: Traversal Distance - description: How many hops to find neighbors and neighbors-of-neighbors - default: 1 - minimum: 0 - maximum: 100 keys: type: array - items: - type: string title: Phenotype Keys + items: + $ref: "../../datasets/djornl/definitions.yaml#definitions/djornl_node/_key" minItems: 1 examples: [["As2"],["As2", "Na23"]] + distance: + $ref: "../../datasets/distance.yaml" query: | LET node_ids = ( FOR n IN djornl_node diff --git a/spec/stored_queries/djornl/djornl_search_nodes.yaml b/spec/stored_queries/djornl/djornl_search_nodes.yaml index 9c8d6a1d..db70cf2d 100644 --- a/spec/stored_queries/djornl/djornl_search_nodes.yaml +++ b/spec/stored_queries/djornl/djornl_search_nodes.yaml @@ -2,19 +2,15 @@ name: djornl_search_nodes description: Search for nodes using a simple fuzzy search on node metadata; return the matching nodes, and the edges and nodes within the specified distance (number of hops) of those nodes. params: type: object + additionalProperties: false required: [search_text] properties: - distance: - type: integer - title: Traversal Distance - description: How many hops to find neighbors and neighbors-of-neighbors - default: 1 - minimum: 0 - maximum: 100 search_text: type: string title: Search text examples: ['GO:0005515', 'organelle machinery'] + distance: + $ref: "../../datasets/distance.yaml" query: | LET node_ids = ( FOR g IN djornl_node_view diff --git a/spec/test/djornl/results.json b/spec/test/djornl/results.json index 80c42a9c..4a3cbed2 100644 --- a/spec/test/djornl/results.json +++ b/spec/test/djornl/results.json @@ -104,8 +104,109 @@ { "params": {"musical": "Mary Poppins"}, "error": { - "message": "ArangoDB server error.", - "arango_message": "AQL: bind parameter 'musical' was not declared in the query (while parsing)" + "failed_validator": "additionalProperties", + "message": "Additional properties are not allowed ('musical' was unexpected)", + "path": [], + "value": {"musical": "Mary Poppins"} + } + }, + { + "params": {"edge_types": ["straight", "curved"]}, + "error": { + "failed_validator": "oneOf", + "message": "'straight' is not valid under any of the given schemas", + "path": ["edge_types", 0], + "value": "straight" + } + }, + { + "params": {"edge_types": []}, + "results": { + "nodes": [ + "As2", + "As75", + "AT1G01010", + "AT1G01020", + "AT1G01030", + "AT1G01040", + "AT1G01050", + "AT1G01060", + "AT1G01070", + "AT1G01080", + "AT1G01090", + "AT1G01100", + "Na23", + "SDV" + ], + "edges": [ + "As2__AT1G01020__AraGWAS-Phenotype_Associations__8.4", + "As2__AT1G01040__AraGWAS-Phenotype_Associations__5.4", + "As75__AT1G01020__AraGWAS-Phenotype_Associations__39.9", + "AT1G01010__AT1G01020__AraNetv2-HT_high-throughput-ppi__2.3", + "AT1G01010__AT1G01030__AraNetv2-HT_high-throughput-ppi__2.4", + "AT1G01010__AT1G01040__AraNetv2-DC_domain-co-occurrence__2.5", + "AT1G01010__AT1G01040__AraNetv2-LC_lit-curated-ppi__170.5", + "AT1G01030__AT1G01050__AraNetv2-CX_pairwise-gene-coexpression__2.6", + "AT1G01050__AT1G01060__AraNetv2-LC_lit-curated-ppi__2.7", + "AT1G01080__AT1G01090__AraNetv2-LC_lit-curated-ppi__2.8" + ] + } + }, + { + "params": {"edge_types": ["AraGWAS-Phenotype_Associations"]}, + "results": { + "nodes": [ + "As2", + "As75", + "AT1G01010", + "AT1G01020", + "AT1G01030", + "AT1G01040", + "AT1G01050", + "AT1G01060", + "AT1G01070", + "AT1G01080", + "AT1G01090", + "AT1G01100", + "Na23", + "SDV" + ], + "edges": [ + "As2__AT1G01020__AraGWAS-Phenotype_Associations__8.4", + "As2__AT1G01040__AraGWAS-Phenotype_Associations__5.4", + "As75__AT1G01020__AraGWAS-Phenotype_Associations__39.9" + ] + } + }, + { + "params": {"edge_types": ["AraGWAS-Phenotype_Associations", "AraNetv2-HT_high-throughput-ppi", "AraNetv2-LC_lit-curated-ppi"]}, + "results": { + "nodes": [ + "As2", + "As75", + "AT1G01010", + "AT1G01020", + "AT1G01030", + "AT1G01040", + "AT1G01050", + "AT1G01060", + "AT1G01070", + "AT1G01080", + "AT1G01090", + "AT1G01100", + "Na23", + "SDV" + ], + "edges": [ + "As2__AT1G01020__AraGWAS-Phenotype_Associations__8.4", + "As2__AT1G01040__AraGWAS-Phenotype_Associations__5.4", + "As75__AT1G01020__AraGWAS-Phenotype_Associations__39.9", + "AT1G01010__AT1G01020__AraNetv2-HT_high-throughput-ppi__2.3", + "AT1G01010__AT1G01030__AraNetv2-HT_high-throughput-ppi__2.4", + "AT1G01010__AT1G01040__AraNetv2-LC_lit-curated-ppi__170.5", + "AT1G01050__AT1G01060__AraNetv2-LC_lit-curated-ppi__2.7", + "AT1G01080__AT1G01090__AraNetv2-LC_lit-curated-ppi__2.8" + ] } } ], @@ -116,7 +217,7 @@ "failed_validator": "required", "message": "'keys' is a required property", "path": [], - "value": {"ws_ids": []} + "value": {} } }, { @@ -181,6 +282,23 @@ ] } }, + { + "params": { "keys": ["AT1G01010"], "distance": 5 }, + "results": { + "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060"], + "edges": [ + "As2__AT1G01020__AraGWAS-Phenotype_Associations__8.4", + "As2__AT1G01040__AraGWAS-Phenotype_Associations__5.4", + "As75__AT1G01020__AraGWAS-Phenotype_Associations__39.9", + "AT1G01010__AT1G01020__AraNetv2-HT_high-throughput-ppi__2.3", + "AT1G01010__AT1G01030__AraNetv2-HT_high-throughput-ppi__2.4", + "AT1G01010__AT1G01040__AraNetv2-DC_domain-co-occurrence__2.5", + "AT1G01010__AT1G01040__AraNetv2-LC_lit-curated-ppi__170.5", + "AT1G01030__AT1G01050__AraNetv2-CX_pairwise-gene-coexpression__2.6", + "AT1G01050__AT1G01060__AraNetv2-LC_lit-curated-ppi__2.7" + ] + } + }, { "params": {"keys": ["AT1G01020", "AT1G01070"], "distance": 0 }, "results": { From 8f45ed442262689046dd99ed46fb7d55757849ad Mon Sep 17 00:00:00 2001 From: ialarmedalien Date: Tue, 1 Sep 2020 12:55:11 -0700 Subject: [PATCH 570/732] Move addition of ws_ids to query to after query param validation --- relation_engine_server/api_versions/api_v1.py | 23 +++++-------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/relation_engine_server/api_versions/api_v1.py b/relation_engine_server/api_versions/api_v1.py index 59687d92..5d7b59d1 100644 --- a/relation_engine_server/api_versions/api_v1.py +++ b/relation_engine_server/api_versions/api_v1.py @@ -71,10 +71,8 @@ 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 + auth_token = auth.get_auth_header() ws_ids = auth.get_workspace_ids(auth_token) # fetch number of documents to return batch_size = int(flask.request.args.get('batch_size', 10000)) @@ -99,22 +97,14 @@ def run_query(): query_name = flask.request.args.get('stored_query') or flask.request.args.get('view') stored_query = spec_loader.get_stored_query(query_name) - has_ws_ids = False - if 'ws_ids' in stored_query['query']: - json_body['ws_ids'] = ws_ids - has_ws_ids = True - else: - del json_body['ws_ids'] - - stored_query_source = _preprocess_stored_query( - stored_query['query'], stored_query, has_ws_ids - ) - if 'params' in stored_query: # Validate the user params for the query 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') + stored_query_source = _preprocess_stored_query(stored_query['query'], stored_query) + json_body['ws_ids'] = ws_ids + resp_body = arango_client.run_query(query_text=stored_query_source, bind_vars=json_body, batch_size=batch_size, @@ -180,11 +170,10 @@ def show_config(): }) -def _preprocess_stored_query(query_text, config, has_ws_ids=True): +def _preprocess_stored_query(query_text, config): """Inject some default code into each stored query.""" - ws_id_text = " LET ws_ids = @ws_ids " if has_ws_ids else "" return ( config.get('query_prefix', '') + - ws_id_text + + " LET ws_ids = @ws_ids " + query_text ) From 884bacbaea1b58b30446374ad3496892ceb1e75b Mon Sep 17 00:00:00 2001 From: ialarmedalien Date: Tue, 1 Sep 2020 14:31:01 -0700 Subject: [PATCH 571/732] refactor run_query to prevent unnecessary call to the workspace --- relation_engine_server/api_versions/api_v1.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/relation_engine_server/api_versions/api_v1.py b/relation_engine_server/api_versions/api_v1.py index 5d7b59d1..426eac1b 100644 --- a/relation_engine_server/api_versions/api_v1.py +++ b/relation_engine_server/api_versions/api_v1.py @@ -71,9 +71,6 @@ def run_query(): - public stored queries (these have access controls within them based on params) """ json_body = parse_json.get_json_body() or {} - # Fetch any authorized workspace IDs using a KBase auth token, if present - auth_token = auth.get_auth_header() - 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) @@ -83,7 +80,11 @@ def run_query(): 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, @@ -103,7 +104,10 @@ def run_query(): run_validator(schema_file=stored_query_path, data=json_body, validate_at='/params') stored_query_source = _preprocess_stored_query(stored_query['query'], stored_query) - json_body['ws_ids'] = ws_ids + 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, @@ -172,8 +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 " + + ws_id_text + query_text ) From fb0abe1bc0efd9f2360c82ba0253acbd661c3acb Mon Sep 17 00:00:00 2001 From: ialarmedalien Date: Tue, 1 Sep 2020 18:15:38 -0700 Subject: [PATCH 572/732] Add edge type filtering to DJORNL queries --- spec/datasets/djornl/definitions.yaml | 2 +- spec/datasets/djornl/edge_types_filter.yaml | 8 + spec/datasets/djornl/node_type.yaml | 2 +- .../djornl/djornl_fetch_all.yaml | 8 +- .../djornl/djornl_fetch_clusters.yaml | 8 +- .../djornl/djornl_fetch_genes.yaml | 8 +- .../djornl/djornl_fetch_phenotypes.yaml | 8 +- .../djornl/djornl_search_nodes.yaml | 8 +- spec/test/djornl/results.json | 231 ++++++++++++++---- 9 files changed, 225 insertions(+), 58 deletions(-) create mode 100644 spec/datasets/djornl/edge_types_filter.yaml diff --git a/spec/datasets/djornl/definitions.yaml b/spec/datasets/djornl/definitions.yaml index ceaa5546..0c7b4395 100644 --- a/spec/datasets/djornl/definitions.yaml +++ b/spec/datasets/djornl/definitions.yaml @@ -1,4 +1,4 @@ -"$schema": "http://json-schema.org/draft-07/schema#" +$schema: "http://json-schema.org/draft-07/schema#" name: definitions title: DJORNL schema definitions description: Node and edge metadata definitions for the Dan Jacobson Exascale dataset diff --git a/spec/datasets/djornl/edge_types_filter.yaml b/spec/datasets/djornl/edge_types_filter.yaml new file mode 100644 index 00000000..06521ba4 --- /dev/null +++ b/spec/datasets/djornl/edge_types_filter.yaml @@ -0,0 +1,8 @@ +$schema: "http://json-schema.org/draft-07/schema#" +name: edge_types_filter +title: Edge Types +description: Edge types to filter on +items: + $ref: "edge_type.yaml" +default: [] +examples: [['AraNetv2-HT_high-throughput-ppi', 'AraNetv2-LC_lit-curated-ppi'], ['AraGWAS-Phenotype_Associations']] diff --git a/spec/datasets/djornl/node_type.yaml b/spec/datasets/djornl/node_type.yaml index e839c2d0..b322ee81 100644 --- a/spec/datasets/djornl/node_type.yaml +++ b/spec/datasets/djornl/node_type.yaml @@ -1,4 +1,4 @@ -"$schema": "http://json-schema.org/draft-07/schema#" +$schema: "http://json-schema.org/draft-07/schema#" name: node_type title: Node Type description: Node types in Dan Jacobson Exascale dataset diff --git a/spec/stored_queries/djornl/djornl_fetch_all.yaml b/spec/stored_queries/djornl/djornl_fetch_all.yaml index c663efeb..94754976 100644 --- a/spec/stored_queries/djornl/djornl_fetch_all.yaml +++ b/spec/stored_queries/djornl/djornl_fetch_all.yaml @@ -5,13 +5,7 @@ params: additionalProperties: false properties: edge_types: - type: array - title: Edge types - description: Permitted edge types - items: - $ref: "../../datasets/djornl/edge_type.yaml" - default: [] - examples: [['AraNetv2-HT_high-throughput-ppi', 'AraNetv2-LC_lit-curated-ppi'],['AraGWAS-Phenotype_Associations']] + $ref: "../../datasets/djornl/edge_types_filter.yaml" query: | LET nodes = ( FOR v IN djornl_node diff --git a/spec/stored_queries/djornl/djornl_fetch_clusters.yaml b/spec/stored_queries/djornl/djornl_fetch_clusters.yaml index f8b099c6..7169cbbe 100644 --- a/spec/stored_queries/djornl/djornl_fetch_clusters.yaml +++ b/spec/stored_queries/djornl/djornl_fetch_clusters.yaml @@ -15,17 +15,21 @@ params: examples: [['markov_i2:5', 'markov_i6:2'],['markov_i6:1']] distance: $ref: "../../datasets/distance.yaml" + edge_types: + $ref: "../../datasets/djornl/edge_types_filter.yaml" query: | LET node_ids = ( FOR n IN djornl_node FILTER n.clusters ANY IN @cluster_ids - FOR node IN 0..@distance ANY n djornl_edge + FOR v, e, p IN 0..@distance ANY n djornl_edge OPTIONS {bfs: true, uniqueVertices: "global"} - RETURN DISTINCT node._id + FILTER length(@edge_types) == 0 || p.edges[*].edge_type ALL IN @edge_types + RETURN DISTINCT v._id ) LET edges = ( FOR edge IN djornl_edge FILTER edge._from IN node_ids AND edge._to IN node_ids + AND (edge.edge_type IN @edge_types || length(@edge_types) == 0) RETURN edge ) LET nodes = ( diff --git a/spec/stored_queries/djornl/djornl_fetch_genes.yaml b/spec/stored_queries/djornl/djornl_fetch_genes.yaml index c0e5867b..3e0de05b 100644 --- a/spec/stored_queries/djornl/djornl_fetch_genes.yaml +++ b/spec/stored_queries/djornl/djornl_fetch_genes.yaml @@ -14,17 +14,21 @@ params: examples: [["AT1G01010"],["AT1G01020","AT1G01070"]] distance: $ref: "../../datasets/distance.yaml" + edge_types: + $ref: "../../datasets/djornl/edge_types_filter.yaml" query: | LET node_ids = ( FOR n IN djornl_node FILTER n._key IN @keys AND n.node_type == 'gene' - FOR node IN 0..@distance ANY n djornl_edge + FOR v, e, p IN 0..@distance ANY n djornl_edge OPTIONS {bfs: true, uniqueVertices: "global"} - RETURN DISTINCT node._id + FILTER length(@edge_types) == 0 || p.edges[*].edge_type ALL IN @edge_types + RETURN DISTINCT v._id ) LET edges = ( FOR edge IN djornl_edge FILTER edge._from IN node_ids AND edge._to IN node_ids + AND (edge.edge_type IN @edge_types || length(@edge_types) == 0) RETURN edge ) LET nodes = ( diff --git a/spec/stored_queries/djornl/djornl_fetch_phenotypes.yaml b/spec/stored_queries/djornl/djornl_fetch_phenotypes.yaml index b76337a2..9190bb32 100644 --- a/spec/stored_queries/djornl/djornl_fetch_phenotypes.yaml +++ b/spec/stored_queries/djornl/djornl_fetch_phenotypes.yaml @@ -14,17 +14,21 @@ params: examples: [["As2"],["As2", "Na23"]] distance: $ref: "../../datasets/distance.yaml" + edge_types: + $ref: "../../datasets/djornl/edge_types_filter.yaml" query: | LET node_ids = ( FOR n IN djornl_node FILTER n._key IN @keys AND n.node_type == 'pheno' - FOR node IN 0..@distance ANY n djornl_edge + FOR v, e, p IN 0..@distance ANY n djornl_edge OPTIONS {bfs: true, uniqueVertices: "global"} - RETURN DISTINCT node._id + FILTER length(@edge_types) == 0 || p.edges[*].edge_type ALL IN @edge_types + RETURN DISTINCT v._id ) LET edges = ( FOR edge IN djornl_edge FILTER edge._from IN node_ids AND edge._to IN node_ids + AND (edge.edge_type IN @edge_types || length(@edge_types) == 0) RETURN edge ) LET nodes = ( diff --git a/spec/stored_queries/djornl/djornl_search_nodes.yaml b/spec/stored_queries/djornl/djornl_search_nodes.yaml index db70cf2d..695b6275 100644 --- a/spec/stored_queries/djornl/djornl_search_nodes.yaml +++ b/spec/stored_queries/djornl/djornl_search_nodes.yaml @@ -11,6 +11,8 @@ params: examples: ['GO:0005515', 'organelle machinery'] distance: $ref: "../../datasets/distance.yaml" + edge_types: + $ref: "../../datasets/djornl/edge_types_filter.yaml" query: | LET node_ids = ( FOR g IN djornl_node_view @@ -29,13 +31,15 @@ query: | ) OR PHRASE(g.go_terms, @search_text) OR PHRASE(g.transcript, @search_text) - FOR node IN 0..@distance ANY g djornl_edge + FOR v, e, p IN 0..@distance ANY g djornl_edge OPTIONS {bfs: true, uniqueVertices: "global"} - RETURN DISTINCT node._id + FILTER length(@edge_types) == 0 || p.edges[*].edge_type ALL IN @edge_types + RETURN DISTINCT v._id ) LET edges = ( FOR edge IN djornl_edge FILTER edge._from IN node_ids AND edge._to IN node_ids + AND (edge.edge_type IN @edge_types || length(@edge_types) == 0) RETURN edge ) LET nodes = ( diff --git a/spec/test/djornl/results.json b/spec/test/djornl/results.json index 4a3cbed2..12f85bfb 100644 --- a/spec/test/djornl/results.json +++ b/spec/test/djornl/results.json @@ -69,7 +69,7 @@ ], "djornl_fetch_all": [ { - "params": {}, + "params": {"edge_types": []}, "results": { "nodes": [ "As2", @@ -230,26 +230,26 @@ } }, { - "params": { "keys": ["Mary Poppins"], "distance": 0 }, + "params": { "keys": ["Mary Poppins"], "distance": 0, "edge_types": [] }, "results": {"nodes": [], "edges": []} }, { - "params": { "keys": ["Mary Poppins"], "distance": 1 }, + "params": { "keys": ["Mary Poppins"], "distance": 1, "edge_types": [] }, "results": {"nodes": [], "edges": []} }, { - "params": { "keys": ["Mary Poppins"], "distance": 5 }, + "params": { "keys": ["Mary Poppins"], "distance": 5, "edge_types": [] }, "results": {"nodes": [], "edges": []} }, { - "params": { "keys": ["AT1G01010"], "distance": 0 }, + "params": { "keys": ["AT1G01010"], "distance": 0, "edge_types": [] }, "results": { "nodes": ["AT1G01010"], "edges": [] } }, { - "params": { "keys": ["AT1G01010"], "distance": 1 }, + "params": { "keys": ["AT1G01010"], "distance": 1, "edge_types": [] }, "results": { "nodes": [ "AT1G01010", @@ -266,7 +266,7 @@ } }, { - "params": { "keys": ["AT1G01010"], "distance": 5 }, + "params": { "keys": ["AT1G01010"], "distance": 5, "edge_types": [] }, "results": { "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060"], "edges": [ @@ -283,7 +283,7 @@ } }, { - "params": { "keys": ["AT1G01010"], "distance": 5 }, + "params": { "keys": ["AT1G01010"], "distance": 5, "edge_types": [] }, "results": { "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060"], "edges": [ @@ -300,14 +300,14 @@ } }, { - "params": {"keys": ["AT1G01020", "AT1G01070"], "distance": 0 }, + "params": {"keys": ["AT1G01020", "AT1G01070"], "distance": 0, "edge_types": [] }, "results": { "nodes": ["AT1G01020", "AT1G01070"], "edges": [] } }, { - "params": {"keys": ["AT1G01020", "AT1G01070"], "distance": 1 }, + "params": {"keys": ["AT1G01020", "AT1G01070"], "distance": 1, "edge_types": [] }, "results": { "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01070"], "edges": [ @@ -318,19 +318,45 @@ } }, { - "params": {"keys": ["AT1G01020", "AT1G01070"], "distance": 5 }, + "params": {"keys": ["AT1G01020", "AT1G01070"], "distance": 1, "edge_types": ["AraGWAS-Phenotype_Associations"] }, "results": { - "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060", "AT1G01070"], + "nodes": ["As2", "As75", "AT1G01020", "AT1G01070"], "edges": [ "As2__AT1G01020__AraGWAS-Phenotype_Associations__8.4", - "As2__AT1G01040__AraGWAS-Phenotype_Associations__5.4", - "As75__AT1G01020__AraGWAS-Phenotype_Associations__39.9", + "As75__AT1G01020__AraGWAS-Phenotype_Associations__39.9" + ] + } + }, + { + "params": {"keys": ["AT1G01020", "AT1G01070"], "distance": 5, "edge_types": [] }, + "results": { + "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060", "AT1G01070"], + "edges": [ + "As2__AT1G01020__AraGWAS-Phenotype_Associations__8.4", + "As2__AT1G01040__AraGWAS-Phenotype_Associations__5.4", + "As75__AT1G01020__AraGWAS-Phenotype_Associations__39.9", + "AT1G01010__AT1G01020__AraNetv2-HT_high-throughput-ppi__2.3", + "AT1G01010__AT1G01030__AraNetv2-HT_high-throughput-ppi__2.4", + "AT1G01010__AT1G01040__AraNetv2-DC_domain-co-occurrence__2.5", + "AT1G01010__AT1G01040__AraNetv2-LC_lit-curated-ppi__170.5", + "AT1G01030__AT1G01050__AraNetv2-CX_pairwise-gene-coexpression__2.6", + "AT1G01050__AT1G01060__AraNetv2-LC_lit-curated-ppi__2.7" + ] + } + }, + { + "params": { + "keys": ["AT1G01020", "AT1G01070"], + "distance": 5, + "edge_types": ["AraNetv2-CX_pairwise-gene-coexpression", "AraNetv2-DC_domain-co-occurrence", "AraNetv2-HT_high-throughput-ppi"] + }, + "results": { + "nodes": ["AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01070"], + "edges": [ "AT1G01010__AT1G01020__AraNetv2-HT_high-throughput-ppi__2.3", "AT1G01010__AT1G01030__AraNetv2-HT_high-throughput-ppi__2.4", "AT1G01010__AT1G01040__AraNetv2-DC_domain-co-occurrence__2.5", - "AT1G01010__AT1G01040__AraNetv2-LC_lit-curated-ppi__170.5", - "AT1G01030__AT1G01050__AraNetv2-CX_pairwise-gene-coexpression__2.6", - "AT1G01050__AT1G01060__AraNetv2-LC_lit-curated-ppi__2.7" + "AT1G01030__AT1G01050__AraNetv2-CX_pairwise-gene-coexpression__2.6" ] } } @@ -346,26 +372,26 @@ } }, { - "params": {"keys": ["Mary Poppins"], "distance": 0}, + "params": {"keys": ["Mary Poppins"], "distance": 0, "edge_types": []}, "results": {"nodes": [], "edges": []} }, { - "params": {"keys": ["Mary Poppins"], "distance": 1}, + "params": {"keys": ["Mary Poppins"], "distance": 1, "edge_types": []}, "results": {"nodes": [], "edges": []} }, { - "params": {"keys": ["Mary Poppins"], "distance": 5}, + "params": {"keys": ["Mary Poppins"], "distance": 5, "edge_types": []}, "results": {"nodes": [], "edges": []} }, { - "params": {"keys": ["As2"], "distance": 0}, + "params": {"keys": ["As2"], "distance": 0, "edge_types": []}, "results": { "nodes": ["As2"], "edges": [] } }, { - "params": {"keys": ["As2"], "distance": 1}, + "params": {"keys": ["As2"], "distance": 1, "edge_types": []}, "results": { "nodes": ["As2", "AT1G01020", "AT1G01040"], "edges": [ @@ -375,7 +401,7 @@ } }, { - "params": {"keys": ["As2"], "distance": 5}, + "params": {"keys": ["As2"], "distance": 5, "edge_types": []}, "results": { "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060"], "edges": [ @@ -392,14 +418,14 @@ } }, { - "params": {"keys": ["As2", "Na23"], "distance": 0}, + "params": {"keys": ["As2", "Na23"], "distance": 0, "edge_types": []}, "results": { "nodes": ["As2", "Na23"], "edges": [] } }, { - "params": {"keys": ["As2", "Na23"], "distance": 1}, + "params": {"keys": ["As2", "Na23"], "distance": 1, "edge_types": []}, "results": { "nodes": ["As2", "Na23", "AT1G01020", "AT1G01040"], "edges": [ @@ -409,7 +435,7 @@ } }, { - "params": {"keys": ["As2", "Na23"], "distance": 5}, + "params": {"keys": ["As2", "Na23"], "distance": 5, "edge_types": []}, "results": { "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060", "Na23"], "edges": [ @@ -424,30 +450,63 @@ "AT1G01050__AT1G01060__AraNetv2-LC_lit-curated-ppi__2.7" ] } + }, + { + "params": {"keys": ["As2", "Na23"], "distance": 0, "edge_types": []}, + "results": { + "nodes": ["As2", "Na23"], + "edges": [] + } + }, + { + "params": { + "keys": ["As2", "Na23"], + "distance": 5, + "edge_types": ["AraNetv2-CX_pairwise-gene-coexpression", "AraNetv2-DC_domain-co-occurrence", "AraNetv2-HT_high-throughput-ppi", "AraNetv2-LC_lit-curated-ppi"] + }, + "results": { + "nodes": ["As2", "Na23"], + "edges": [] + } + }, + { + "params": { + "keys": ["As2", "Na23"], + "distance": 5, + "edge_types": ["AraGWAS-Phenotype_Associations"] + }, + "results": { + "nodes": ["As2", "As75", "AT1G01020", "AT1G01040", "Na23"], + "edges": [ + "As2__AT1G01020__AraGWAS-Phenotype_Associations__8.4", + "As2__AT1G01040__AraGWAS-Phenotype_Associations__5.4", + "As75__AT1G01020__AraGWAS-Phenotype_Associations__39.9" + ] + } } ], "djornl_search_nodes": [ { - "params": {"search_text": "Mary Poppins", "distance": 0}, + "params": {"search_text": "Mary Poppins", "distance": 0, "edge_types": []}, "results": {"nodes": [], "edges": []} }, { - "params": {"search_text": "Mary Poppins", "distance": 1}, + "params": {"search_text": "Mary Poppins", "distance": 1, "edge_types": []}, "results": {"nodes": [], "edges": []} }, { - "params": {"search_text": "Mary Poppins", "distance": 5}, + "params": {"search_text": "Mary Poppins", "distance": 5, "edge_types": []}, "results": {"nodes": [], "edges": []} }, { - "params": {"search_text": "GO:0005515", "distance": 0}, + "params": {"search_text": "GO:0005515", "distance": 0, "edge_types": []}, "results": { "nodes": ["AT1G01040", "AT1G01090"], "edges": [] } }, { - "params": {"search_text": "GO:0005515", "distance": 1}, + "params": {"search_text": "GO:0005515", "distance": 1, "edge_types": []}, "results": { "nodes": ["As2", "AT1G01010", "AT1G01040", "AT1G01080", "AT1G01090"], "edges": [ @@ -459,7 +518,7 @@ } }, { - "params": {"search_text": "GO:0005515", "distance": 5}, + "params": {"search_text": "GO:0005515", "distance": 5, "edge_types": []}, "results": { "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060", "AT1G01080", "AT1G01090"], "edges": [ @@ -475,6 +534,33 @@ "AT1G01080__AT1G01090__AraNetv2-LC_lit-curated-ppi__2.8" ] } + }, + { + "params": {"search_text": "GO:0005515", "distance": 0, "edge_types": ["AraGWAS-Phenotype_Associations"]}, + "results": { + "nodes": ["AT1G01040", "AT1G01090"], + "edges": [] + } + }, + { + "params": {"search_text": "GO:0005515", "distance": 1, "edge_types": ["AraGWAS-Phenotype_Associations"]}, + "results": { + "nodes": ["As2", "AT1G01040", "AT1G01090"], + "edges": [ + "As2__AT1G01040__AraGWAS-Phenotype_Associations__5.4" + ] + } + }, + { + "params": {"search_text": "GO:0005515", "distance": 5, "edge_types": ["AraGWAS-Phenotype_Associations"]}, + "results": { + "nodes": ["As2", "As75", "AT1G01020", "AT1G01040", "AT1G01090"], + "edges": [ + "As2__AT1G01020__AraGWAS-Phenotype_Associations__8.4", + "As2__AT1G01040__AraGWAS-Phenotype_Associations__5.4", + "As75__AT1G01020__AraGWAS-Phenotype_Associations__39.9" + ] + } } ], "djornl_fetch_clusters": [ @@ -506,26 +592,26 @@ } }, { - "params": {"cluster_ids": ["MaryPoppins:1"], "distance": 0}, + "params": {"cluster_ids": ["MaryPoppins:1"], "distance": 0, "edge_types": []}, "results": {"nodes": [], "edges": []} }, { - "params": {"cluster_ids": ["MaryPoppins:1"], "distance": 1}, + "params": {"cluster_ids": ["MaryPoppins:1"], "distance": 1, "edge_types": []}, "results": {"nodes": [], "edges": []} }, { - "params": {"cluster_ids": ["MaryPoppins:1"], "distance": 5}, + "params": {"cluster_ids": ["MaryPoppins:1"], "distance": 5, "edge_types": []}, "results": {"nodes": [], "edges": []} }, { - "params": {"cluster_ids": ["markov_i6:1"], "distance": 0}, + "params": {"cluster_ids": ["markov_i6:1"], "distance": 0, "edge_types": []}, "results": { "nodes": ["AT1G01040", "AT1G01090"], "edges": [] } }, { - "params": {"cluster_ids": ["markov_i6:1"], "distance": 1}, + "params": {"cluster_ids": ["markov_i6:1"], "distance": 1, "edge_types": []}, "results": { "nodes": ["As2", "AT1G01010", "AT1G01040", "AT1G01080", "AT1G01090"], "edges": [ @@ -537,7 +623,7 @@ } }, { - "params": {"cluster_ids": ["markov_i6:1"], "distance": 5}, + "params": {"cluster_ids": ["markov_i6:1"], "distance": 5, "edge_types": []}, "results": { "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060", "AT1G01080", "AT1G01090"], "edges": [ @@ -555,14 +641,14 @@ } }, { - "params": {"cluster_ids": ["markov_i2:5", "markov_i6:2"], "distance": 0}, + "params": {"cluster_ids": ["markov_i2:5", "markov_i6:2"], "distance": 0, "edge_types": []}, "results": { "nodes": ["AT1G01020", "AT1G01070"], "edges": [] } }, { - "params": {"cluster_ids": ["markov_i2:5", "markov_i6:2"], "distance": 1}, + "params": {"cluster_ids": ["markov_i2:5", "markov_i6:2"], "distance": 1, "edge_types": []}, "results": { "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01070"], "edges": [ @@ -573,7 +659,7 @@ } }, { - "params": {"cluster_ids": ["markov_i2:5", "markov_i6:2"], "distance": 5}, + "params": {"cluster_ids": ["markov_i2:5", "markov_i6:2"], "distance": 5, "edge_types": []}, "results": { "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060", "AT1G01070"], "edges": [ @@ -588,6 +674,69 @@ "AT1G01050__AT1G01060__AraNetv2-LC_lit-curated-ppi__2.7" ] } + }, + { + "params": { + "cluster_ids": ["markov_i2:5", "markov_i6:2"], + "distance": 0, + "edge_types": ["AraNetv2-HT_high-throughput-ppi"] + }, + "results": { + "nodes": ["AT1G01020", "AT1G01070"], + "edges": [] + } + }, + { + "params": { + "cluster_ids": ["markov_i2:5", "markov_i6:2"], + "distance": 1, + "edge_types": ["AraNetv2-HT_high-throughput-ppi"] + }, + "results": { + "nodes": ["AT1G01010", "AT1G01020", "AT1G01070"], + "edges": [ + "AT1G01010__AT1G01020__AraNetv2-HT_high-throughput-ppi__2.3" + ] + } + }, + { + "params": { + "cluster_ids": ["markov_i2:5", "markov_i6:2"], + "distance": 5, + "edge_types": ["AraNetv2-HT_high-throughput-ppi"] + }, + "results": { + "nodes": ["AT1G01010", "AT1G01020", "AT1G01030", "AT1G01070"], + "edges": [ + "AT1G01010__AT1G01020__AraNetv2-HT_high-throughput-ppi__2.3", + "AT1G01010__AT1G01030__AraNetv2-HT_high-throughput-ppi__2.4" + ] + } + }, + { + "params": { + "cluster_ids": ["markov_i2:5", "markov_i6:2"], + "distance": 5, + "edge_types": [ + "AraGWAS-Phenotype_Associations", + "AraNetv2-HT_high-throughput-ppi", + "AraNetv2-LC_lit-curated-ppi", + "AraNetv2-CX_pairwise-gene-coexpression" + ] + }, + "results": { + "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060", "AT1G01070"], + "edges": [ + "As2__AT1G01020__AraGWAS-Phenotype_Associations__8.4", + "As2__AT1G01040__AraGWAS-Phenotype_Associations__5.4", + "As75__AT1G01020__AraGWAS-Phenotype_Associations__39.9", + "AT1G01010__AT1G01020__AraNetv2-HT_high-throughput-ppi__2.3", + "AT1G01010__AT1G01030__AraNetv2-HT_high-throughput-ppi__2.4", + "AT1G01010__AT1G01040__AraNetv2-LC_lit-curated-ppi__170.5", + "AT1G01030__AT1G01050__AraNetv2-CX_pairwise-gene-coexpression__2.6", + "AT1G01050__AT1G01060__AraNetv2-LC_lit-curated-ppi__2.7" + ] + } } ] } From 38b9899e8499d365f96b9462ce85bc866c5a6e81 Mon Sep 17 00:00:00 2001 From: ialarmedalien Date: Wed, 2 Sep 2020 08:05:50 -0700 Subject: [PATCH 573/732] Fix auth responses for invalid or non-admin tokens --- relation_engine_server/test/test_api_v1.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/relation_engine_server/test/test_api_v1.py b/relation_engine_server/test/test_api_v1.py index 21c50ded..f5de696d 100644 --- a/relation_engine_server/test/test_api_v1.py +++ b/relation_engine_server/test/test_api_v1.py @@ -60,6 +60,7 @@ class TestApi(unittest.TestCase): @classmethod def setUpClass(cls): wait_for_api() + cls.maxDiff = None def test_request(self, url=None, params=None, data=None, headers=None, method='get', status_code=200, resp_json=None, resp_test=None): @@ -566,7 +567,6 @@ def test_admin_query(self): def test_admin_query_non_admin(self): """Test an ad-hoc query error as a non-admin.""" query = 'for v in test_vertex sort rand() limit @count return v._id' - auth_response = '{"class":"Exception","error":"Unable to match endpoint: POST /"}\n' self.test_request( '/query_results', method='post', @@ -576,15 +576,15 @@ def test_admin_query_non_admin(self): status_code=403, resp_json={'error': { 'message': 'Unauthorized', - 'auth_url': 'http://workspace:5000', - 'auth_response': auth_response + 'auth_url': 'http://auth:5000', + 'auth_response': 'Missing role' }}, ) def test_admin_query_invalid_auth(self): """Test the error response for an ad-hoc admin query without auth.""" - # see ./mock_workspace/list_workspace_ids_invalid.json for response + # see ./mock_auth/auth_invalid.json for response query = 'for v in test_vertex sort rand() limit @count return v._id' self.test_request( '/query_results', @@ -596,14 +596,16 @@ def test_admin_query_invalid_auth(self): resp_json={ 'error': { 'message': 'Unauthorized', - 'auth_url': 'http://workspace:5000', + 'auth_url': 'http://auth:5000', 'auth_response': json.dumps({ - "version": "1.1", "error": { - "name": "JSONRPCError", - "code": -32400, - "message": "Token validation failed!", - "error": "..." + "httpcode": 401, + "httpstatus": "Unauthorized", + "appcode": 10020, + "apperror": "Invalid token", + "message": "10020 Invalid token", + "callid": "1757210147564211", + "time": 1542737889450 } }) } From 718eecc0f93014f16733f2405057a1820d2b8667 Mon Sep 17 00:00:00 2001 From: ialarmedalien Date: Wed, 2 Sep 2020 10:53:41 -0700 Subject: [PATCH 574/732] reorder filtering in spec queries. Add type to edge_types_filter --- spec/datasets/djornl/edge_types_filter.yaml | 1 + spec/stored_queries/djornl/djornl_fetch_all.yaml | 2 +- spec/stored_queries/djornl/djornl_fetch_clusters.yaml | 2 +- spec/stored_queries/djornl/djornl_fetch_genes.yaml | 2 +- spec/stored_queries/djornl/djornl_fetch_phenotypes.yaml | 2 +- spec/stored_queries/djornl/djornl_search_nodes.yaml | 2 +- 6 files changed, 6 insertions(+), 5 deletions(-) diff --git a/spec/datasets/djornl/edge_types_filter.yaml b/spec/datasets/djornl/edge_types_filter.yaml index 06521ba4..3bce0661 100644 --- a/spec/datasets/djornl/edge_types_filter.yaml +++ b/spec/datasets/djornl/edge_types_filter.yaml @@ -2,6 +2,7 @@ $schema: "http://json-schema.org/draft-07/schema#" name: edge_types_filter title: Edge Types description: Edge types to filter on +type: array items: $ref: "edge_type.yaml" default: [] diff --git a/spec/stored_queries/djornl/djornl_fetch_all.yaml b/spec/stored_queries/djornl/djornl_fetch_all.yaml index 94754976..90757835 100644 --- a/spec/stored_queries/djornl/djornl_fetch_all.yaml +++ b/spec/stored_queries/djornl/djornl_fetch_all.yaml @@ -13,7 +13,7 @@ query: | ) LET edges = ( FOR e IN djornl_edge - FILTER length(@edge_types) > 0 && e.edge_type IN @edge_types || length(@edge_types) == 0 + FILTER length(@edge_types) == 0 || e.edge_type IN @edge_types RETURN e ) RETURN {nodes, edges} diff --git a/spec/stored_queries/djornl/djornl_fetch_clusters.yaml b/spec/stored_queries/djornl/djornl_fetch_clusters.yaml index 7169cbbe..9b18c6bf 100644 --- a/spec/stored_queries/djornl/djornl_fetch_clusters.yaml +++ b/spec/stored_queries/djornl/djornl_fetch_clusters.yaml @@ -29,7 +29,7 @@ query: | LET edges = ( FOR edge IN djornl_edge FILTER edge._from IN node_ids AND edge._to IN node_ids - AND (edge.edge_type IN @edge_types || length(@edge_types) == 0) + AND (length(@edge_types) == 0 || edge.edge_type IN @edge_types) RETURN edge ) LET nodes = ( diff --git a/spec/stored_queries/djornl/djornl_fetch_genes.yaml b/spec/stored_queries/djornl/djornl_fetch_genes.yaml index 3e0de05b..d8b1e008 100644 --- a/spec/stored_queries/djornl/djornl_fetch_genes.yaml +++ b/spec/stored_queries/djornl/djornl_fetch_genes.yaml @@ -28,7 +28,7 @@ query: | LET edges = ( FOR edge IN djornl_edge FILTER edge._from IN node_ids AND edge._to IN node_ids - AND (edge.edge_type IN @edge_types || length(@edge_types) == 0) + AND (length(@edge_types) == 0 || edge.edge_type IN @edge_types) RETURN edge ) LET nodes = ( diff --git a/spec/stored_queries/djornl/djornl_fetch_phenotypes.yaml b/spec/stored_queries/djornl/djornl_fetch_phenotypes.yaml index 9190bb32..e1d2a426 100644 --- a/spec/stored_queries/djornl/djornl_fetch_phenotypes.yaml +++ b/spec/stored_queries/djornl/djornl_fetch_phenotypes.yaml @@ -28,7 +28,7 @@ query: | LET edges = ( FOR edge IN djornl_edge FILTER edge._from IN node_ids AND edge._to IN node_ids - AND (edge.edge_type IN @edge_types || length(@edge_types) == 0) + AND (length(@edge_types) == 0 || edge.edge_type IN @edge_types) RETURN edge ) LET nodes = ( diff --git a/spec/stored_queries/djornl/djornl_search_nodes.yaml b/spec/stored_queries/djornl/djornl_search_nodes.yaml index 695b6275..1279a4bb 100644 --- a/spec/stored_queries/djornl/djornl_search_nodes.yaml +++ b/spec/stored_queries/djornl/djornl_search_nodes.yaml @@ -39,7 +39,7 @@ query: | LET edges = ( FOR edge IN djornl_edge FILTER edge._from IN node_ids AND edge._to IN node_ids - AND (edge.edge_type IN @edge_types || length(@edge_types) == 0) + AND (length(@edge_types) == 0 || edge.edge_type IN @edge_types) RETURN edge ) LET nodes = ( From 30e25ce035637b04e40a0848e4c2d61ea97a4608 Mon Sep 17 00:00:00 2001 From: ialarmedalien Date: Tue, 8 Sep 2020 09:08:55 -0700 Subject: [PATCH 575/732] Patch security hole in spec_loader.py add sample_spec_release dir and instructions for updating the test spec archive add "get_view" method to spec_loader.py and sample view to the test spec archive --- .../test/spec_release/README.md | 22 ++++- .../collections/ncbi/ncbi_taxon.yaml | 64 ++++++++++++++ .../collections/test/test_edge.yaml | 10 +++ .../collections/test/test_vertex.yaml | 11 +++ .../data_sources/ncbi_taxonomy.yaml | 6 ++ .../migrations/__init__.py | 0 .../sample_spec_release/migrations/example.py | 3 + .../ncbi_tax/ncbi_fetch_taxon.yaml | 18 ++++ .../test/fetch_test_vertex.yaml | 13 +++ .../test/list_test_vertices.yaml | 7 ++ .../views/test_vertices.json | 34 ++++++++ .../test/spec_release/spec.tar.gz | Bin 2838 -> 2197 bytes .../test/test_spec_loader.py | 80 +++++++++++++----- relation_engine_server/utils/spec_loader.py | 23 ++++- 14 files changed, 265 insertions(+), 26 deletions(-) create mode 100644 relation_engine_server/test/spec_release/sample_spec_release/collections/ncbi/ncbi_taxon.yaml create mode 100644 relation_engine_server/test/spec_release/sample_spec_release/collections/test/test_edge.yaml create mode 100644 relation_engine_server/test/spec_release/sample_spec_release/collections/test/test_vertex.yaml create mode 100644 relation_engine_server/test/spec_release/sample_spec_release/data_sources/ncbi_taxonomy.yaml create mode 100644 relation_engine_server/test/spec_release/sample_spec_release/migrations/__init__.py create mode 100644 relation_engine_server/test/spec_release/sample_spec_release/migrations/example.py create mode 100644 relation_engine_server/test/spec_release/sample_spec_release/stored_queries/ncbi_tax/ncbi_fetch_taxon.yaml create mode 100644 relation_engine_server/test/spec_release/sample_spec_release/stored_queries/test/fetch_test_vertex.yaml create mode 100644 relation_engine_server/test/spec_release/sample_spec_release/stored_queries/test/list_test_vertices.yaml create mode 100644 relation_engine_server/test/spec_release/sample_spec_release/views/test_vertices.json diff --git a/relation_engine_server/test/spec_release/README.md b/relation_engine_server/test/spec_release/README.md index 8419f925..a371c2e3 100644 --- a/relation_engine_server/test/spec_release/README.md +++ b/relation_engine_server/test/spec_release/README.md @@ -1,8 +1,22 @@ +## Test Spec Release -The file in this directory, `spec.tar.gz` is a cached release of the `relation_engine_spec` repo, found here: +`sample_spec_release`, and the corresponding archive, `spec.tar.gz`, contain a set of sample schema files suitable for use in tests. -https://github.com/kbase/relation_engine_spec +To create a new version of `spec.tar.gz`, you will need to exec into the `re_api` docker image to ensure that the new archive and its contents have the appropriate file owner and permissions (all files must have owner and group `root`/`root`). -It is cached here to avoid Github API usage limits when running tests on Travis. +Example commands: -It is also stored in the docker image for the RE API for use in tests in other codebases that depend on this one. +``` +$ docker exec -it relation_engine_re_api_run_1234567890 sh +# # in the docker image +# cd relation_engine_server/test/spec_release +# # ... perform any edits ... +# tar -czvf new_spec.tar.gz sample_spec_release/ +# # check the file listing is as expected +# tar -ztvf new_spec.tar.gz +# mv spec.tar.gz old_spec.tar.gz +# mv new_spec.tar.gz spec.tar.gz +# # ensure that the tests pass +# cd /app +# sh scripts/run_tests.sh +``` diff --git a/relation_engine_server/test/spec_release/sample_spec_release/collections/ncbi/ncbi_taxon.yaml b/relation_engine_server/test/spec_release/sample_spec_release/collections/ncbi/ncbi_taxon.yaml new file mode 100644 index 00000000..39c97168 --- /dev/null +++ b/relation_engine_server/test/spec_release/sample_spec_release/collections/ncbi/ncbi_taxon.yaml @@ -0,0 +1,64 @@ +name: ncbi_taxon +type: vertex +delta: true + +indexes: + - type: fulltext + fields: [scientific_name] + - type: persistent + fields: [id, expired, created] + - type: persistent + fields: [expired, created, last_version] + +schema: + "$schema": http://json-schema.org/draft-07/schema# + type: object + description: Template for a vertex entry in the NCBI taxonomy tree. + required: [id, scientific_name, rank, strain] + properties: + id: + type: string + description: NCBI Taxon id (positive integer) + examples: ['1', '2053699'] + scientific_name: + type: string + title: Taxon name. + examples: ['Methylophilus methylotrophus', 'Bacteria', 'Firmicutes'] + aliases: + type: array + description: Aliases + examples: + - - category: authority + name: Borreliella burgdorferi (Johnson et al. 1984) Adeolu and Gupta 2015 + - category: genbank common name + name: Lyme disease spirochet + - category: synonym + name: Borrelia burgdorferi + - - category: common name + name: E. coli + - category: authority + name: '"Bacterium coli commune" Escherich 1885' + - category: synonym + name: Bacterium coli + items: + type: object + required: ['category', 'name'] + properties: + category: {type: string} + name: {type: string} + rank: + type: string + title: Taxonomic rank + examples: ["Domain", "Phylum", "no rank"] + strain: + type: boolean + title: Strain flag + description: Whether this node corresponds to a strain. Strains are considered to be nodes + that have a rank of "no rank" and whose parents' rank is either species or subspecies or + where the parent's strain flag is true. + ncbi_taxon_id: + type: integer + title: The NCBI taxon ID as a number + gencode: + type: integer + title: The numerc ID of the genetic code for this organism. diff --git a/relation_engine_server/test/spec_release/sample_spec_release/collections/test/test_edge.yaml b/relation_engine_server/test/spec_release/sample_spec_release/collections/test/test_edge.yaml new file mode 100644 index 00000000..fab7ad6e --- /dev/null +++ b/relation_engine_server/test/spec_release/sample_spec_release/collections/test/test_edge.yaml @@ -0,0 +1,10 @@ +name: test_edge +type: edge +schema: + "$schema": "http://json-schema.org/draft-07/schema#" + type: object + required: [_from, _to] + description: Example edge schema for testing. + properties: + _from: {type: string} + _to: {type: string} diff --git a/relation_engine_server/test/spec_release/sample_spec_release/collections/test/test_vertex.yaml b/relation_engine_server/test/spec_release/sample_spec_release/collections/test/test_vertex.yaml new file mode 100644 index 00000000..b2d34668 --- /dev/null +++ b/relation_engine_server/test/spec_release/sample_spec_release/collections/test/test_vertex.yaml @@ -0,0 +1,11 @@ +name: test_vertex +type: vertex +schema: + "$schema": "http://json-schema.org/draft-07/schema#" + type: object + required: [_key] + description: An example vertex schema for testing + properties: + _key: {type: string} + is_public: {type: boolean} + ws_id: {type: integer} diff --git a/relation_engine_server/test/spec_release/sample_spec_release/data_sources/ncbi_taxonomy.yaml b/relation_engine_server/test/spec_release/sample_spec_release/data_sources/ncbi_taxonomy.yaml new file mode 100644 index 00000000..37a88195 --- /dev/null +++ b/relation_engine_server/test/spec_release/sample_spec_release/data_sources/ncbi_taxonomy.yaml @@ -0,0 +1,6 @@ +name: ncbi_taxonomy +category: taxonomy +title: NCBI Taxonomy +home_url: https://www.ncbi.nlm.nih.gov/taxonomy +data_url: ftp://ftp.ncbi.nlm.nih.gov/pub/taxonomy/ +logo_path: /images/third-party-data-sources/ncbi/logo-51-64.png diff --git a/relation_engine_server/test/spec_release/sample_spec_release/migrations/__init__.py b/relation_engine_server/test/spec_release/sample_spec_release/migrations/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/relation_engine_server/test/spec_release/sample_spec_release/migrations/example.py b/relation_engine_server/test/spec_release/sample_spec_release/migrations/example.py new file mode 100644 index 00000000..ce5ce389 --- /dev/null +++ b/relation_engine_server/test/spec_release/sample_spec_release/migrations/example.py @@ -0,0 +1,3 @@ +# TODO + +x = 1 diff --git a/relation_engine_server/test/spec_release/sample_spec_release/stored_queries/ncbi_tax/ncbi_fetch_taxon.yaml b/relation_engine_server/test/spec_release/sample_spec_release/stored_queries/ncbi_tax/ncbi_fetch_taxon.yaml new file mode 100644 index 00000000..3a9c4170 --- /dev/null +++ b/relation_engine_server/test/spec_release/sample_spec_release/stored_queries/ncbi_tax/ncbi_fetch_taxon.yaml @@ -0,0 +1,18 @@ +# Fetch a taxon document by taxonomy ID +name: ncbi_fetch_taxon +params: + type: object + required: [id, ts] + properties: + id: + type: string + title: NCBI Taxonomy ID + ts: + type: integer + title: Versioning timestamp +query: | + for t in ncbi_taxon + filter t.id == @id + filter t.created <= @ts AND t.expired >= @ts + limit 1 + return t diff --git a/relation_engine_server/test/spec_release/sample_spec_release/stored_queries/test/fetch_test_vertex.yaml b/relation_engine_server/test/spec_release/sample_spec_release/stored_queries/test/fetch_test_vertex.yaml new file mode 100644 index 00000000..8845f4a1 --- /dev/null +++ b/relation_engine_server/test/spec_release/sample_spec_release/stored_queries/test/fetch_test_vertex.yaml @@ -0,0 +1,13 @@ +# Test query - fetch a single test vertex by ID +name: fetch_test_vertex +params: + type: object + required: [key] + properties: + key: + type: string + title: _key to match on +query: | + FOR o IN test_vertex + FILTER o._key == @key + RETURN o diff --git a/relation_engine_server/test/spec_release/sample_spec_release/stored_queries/test/list_test_vertices.yaml b/relation_engine_server/test/spec_release/sample_spec_release/stored_queries/test/list_test_vertices.yaml new file mode 100644 index 00000000..5d027d78 --- /dev/null +++ b/relation_engine_server/test/spec_release/sample_spec_release/stored_queries/test/list_test_vertices.yaml @@ -0,0 +1,7 @@ +# Test query - List all test vertices +# Has some simple auth against ws_ids +name: list_test_vertices +query: | + FOR o IN test_vertex + FILTER o.is_public || o.ws_id IN ws_ids + RETURN o diff --git a/relation_engine_server/test/spec_release/sample_spec_release/views/test_vertices.json b/relation_engine_server/test/spec_release/sample_spec_release/views/test_vertices.json new file mode 100644 index 00000000..d45c3731 --- /dev/null +++ b/relation_engine_server/test/spec_release/sample_spec_release/views/test_vertices.json @@ -0,0 +1,34 @@ +{ + "name": "test_vertices", + "type": "arangosearch", + "writebufferIdle": 64, + "writebufferActive": 0, + "primarySort": [], + "writebufferSizeMax": 33554432, + "commitIntervalMsec": 1000, + "consolidationPolicy": { + "type": "bytes_accum", + "threshold": 0.1 + }, + "cleanupIntervalStep": 10, + "links": { + "test_vertex": { + "analyzers": [ + "identity" + ], + "fields": { + "_key": { + "analyzers": [ + "text_en" + ] + }, + "is_public": {}, + "ws_id": {} + }, + "includeAllFields": false, + "storeValues": "none", + "trackListPositions": false + } + }, + "consolidationIntervalMsec": 60000 +} diff --git a/relation_engine_server/test/spec_release/spec.tar.gz b/relation_engine_server/test/spec_release/spec.tar.gz index e654605a76d146fd27e1ef4bd9f76d710d169155..e4c2d7b71b6b7a939c4cdbdcc0cf2abcb0aa30b9 100644 GIT binary patch literal 2197 zcmV;G2x|8qiwFP!000021MM4YZ`(LBpZzNa?g7~aY{xIzt#LhEdP(kb=nHLj_roF( zXo@BCGocX?>D4m*_PGXPE)mqY6{d6XE+>jo_s`+Fy_=%G4)(YIVFmo96c~} z5yp;Ve-Vnm_PIA0_nmQX)bEaty1juj>K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N!OJKtGaH&1jhiMq6KH9+7I&%*ti1wnOlQ6T!eJb;@yRP(#i9&W+^wq9(RQC2# zR;O*nD!8{JOX7&gfJu&wTJI&Zf{k$=Gj|Ycy|_4Yrx#RAjF3@5jR|CwOJx>qh#I9s zV5)SY`PAAb90xvp3L4;bTN5C!kv1=xn%xo3Progz%$t~6gV2w<#rL=2$ERxykny^wwS6+ve}-aGGcVQ{YrRo$(LB7^M!WQ% z@sv+>;RB_&yV)mY+*NEciI1Am3fIMjZr|dtS-Ggg`mR{4>*Mn(?j?oqYO(IWzkYV; zlIFBJnW-`MEdUiEt*_1b3?J8ee<5vy&7w=bo`UwCw#7QLwV+gI5+Od#CX58lJAySz zUS=38WyIfe7GIO4Iz-9$;0L4>bbw%&xjHRXGtMAug*@~KA0YKl8jkcVG|NcsEG_vu zw~$LV(36GYSa(90Y1v>>PiMqZ-!4IJv|w_}QeV-yBWXu^xqGCIcZ3z06i%~NVs~Qa zexI9xklbB>4P5Mbf_ZxOv_KucM8h(5+#|@td?8WQa;tH?X z2cr!6*66$5_m!Hwpy!T1XxbPeL3d8rjVFGUbq>?2nLm*G^65b;|2}-HAXdXE6MqYP zr!!l$3IcuTRTgwrIq;2VdAiQX8hZZ4J0BBvACK91VV4Gka*N8&?koQv74iH1%Ns7v z9?u;{JsIQ4`jI34YK?<#JEH|%col+^%x|VWzup@L9v!~Uy|&l z0>xt^1!MYIS-HCRl!~q$ThMyiKri{lT$Ffh0q*16<0Si%kzmVD9?~%u&^Rvhs=w(0 zuk9#O`LdaPibLNhd^vnzb-=VZW8OK@jS#TibVE8zh4o&mkA8cOkOoe26^)knM?!sh zk+1VKEZ&CO!zd9j$M8Gp?rnvRR27`jt47c`o2YBGPlds{fv5Tw8RGI}ONaZA$arsb l>mh(8I1i{tL{_9pp+)$>=|fZ>)?V$PH2zLk(GlqA{s+5s-Mjz* diff --git a/relation_engine_server/test/test_spec_loader.py b/relation_engine_server/test/test_spec_loader.py index d1da1df9..0833e5e9 100644 --- a/relation_engine_server/test/test_spec_loader.py +++ b/relation_engine_server/test/test_spec_loader.py @@ -7,20 +7,37 @@ from relation_engine_server.utils import spec_loader from relation_engine_server.utils.spec_loader import SchemaNonexistent from relation_engine_server.utils.config import get_config -from relation_engine_server.utils.wait_for import wait_for_api - -_CONF = get_config() -_TEST_DIR = os_path.join('/app', 'relation_engine_server', 'test', 'data') class TestSpecLoader(unittest.TestCase): @classmethod def setUpClass(cls): - wait_for_api() - cls.config = get_config() + cls.test_dir = os_path.join('/app', 'relation_engine_server', 'test') + cls.test_spec_dir = os_path.join(cls.test_dir, 'spec_release', 'sample_spec_release') + + config = get_config() + cls.repo_path = config['spec_paths']['repo'] + for key in config['spec_paths'].keys(): + if cls.repo_path in config['spec_paths'][key]: + config['spec_paths'][key] = config['spec_paths'][key].replace( + cls.repo_path, + cls.test_spec_dir + ) + cls.config = config + + @classmethod + def tearDownClass(cls): + # undo all the config changes + for key in cls.config['spec_paths'].keys(): + if cls.test_spec_dir in cls.config['spec_paths'][key]: + cls.config['spec_paths'][key] = cls.config['spec_paths'][key].replace( + cls.test_spec_dir, + cls.repo_path + ) def test_get_names(self, schema_type_names=[], expected=[]): + """test getting the names of all the schemas of a given type""" # this method should only be run from another test method if len(schema_type_names) == 0: @@ -32,20 +49,20 @@ def test_get_names(self, schema_type_names=[], expected=[]): method = getattr(spec_loader, 'get_' + schema_type_singular + '_names') # save the original value - original_config_dir = _CONF['spec_paths'][schema_type_plural] + original_config_dir = self.config['spec_paths'][schema_type_plural] # set the config to the test directory - _CONF['spec_paths'][schema_type_plural] = os_path.join(_TEST_DIR, schema_type_plural) + self.config['spec_paths'][schema_type_plural] = os_path.join(self.test_dir, 'data', schema_type_plural) got_names_method = method() got_names_singular = spec_loader.get_names(schema_type_singular) got_names_plural = spec_loader.get_names(schema_type_plural) - _CONF['spec_paths'][schema_type_plural] = os_path.join(_TEST_DIR, 'empty') + self.config['spec_paths'][schema_type_plural] = os_path.join(self.test_dir, 'data', 'empty') got_names_method_empty = method() got_names_empty = spec_loader.get_names(schema_type_singular) - # restore the original value - _CONF['spec_paths'][schema_type_plural] = original_config_dir + # restore the original value before running tests + self.config['spec_paths'][schema_type_plural] = original_config_dir # ensure the results are as expected # get_collection_names @@ -67,15 +84,17 @@ def test_run_spec_loading_tests(self, schema_type_names=[], test_name=None): self.assertTrue(True) return - print("running test_run_spec_loading_tests with schema_type " + schema_type_names[0]) - method = getattr(spec_loader, 'get_' + schema_type_names[0]) + schema_type_singular = schema_type_names[0] + schema_type_plural = schema_type_names[1] + # e.g. 'spec_loader.get_collection' + method = getattr(spec_loader, 'get_' + schema_type_singular) # get the path of the requested file result_path = method(test_name, path_only=True) self.assertIsInstance(result_path, str) self.assertIn(test_name, result_path) self.assertIn( - self.config['spec_paths'][schema_type_names[1]], + self.config['spec_paths'][schema_type_plural], result_path, ) @@ -92,18 +111,18 @@ def test_run_spec_loading_tests(self, schema_type_names=[], test_name=None): self.assertEqual(result_obj['name'], test_name) # check the contents of the dict when getting a data source - if schema_type_names[0] == 'data_source': + if schema_type_singular == 'data_source': - # logo_url should start with the same base as _CONF['kbase_endpoint'] - endpoint = urlparse(_CONF['kbase_endpoint']) + # logo_url should start with the same base as config['kbase_endpoint'] + endpoint = urlparse(self.config['kbase_endpoint']) self.assertIn(endpoint.scheme + '://' + endpoint.netloc, result_obj['logo_url']) # logo_path is deleted self.assertNotIn('logo_path', result_obj.keys()) # a nonexistent file raises the appropriate error - fake_name = '../../../../spec/repo/collections/djornl/djornl_edge' - err_msg = schema_type_names[0].capitalize().replace("_", " ") + " '" + fake_name + "' does not exist." + fake_name = 'test/test_node' + err_msg = schema_type_singular.capitalize().replace("_", " ") + " '" + fake_name + "' does not exist." with self.assertRaisesRegex(SchemaNonexistent, err_msg): method(fake_name, path_only=True) @@ -125,6 +144,10 @@ def test_get_schemas_of_various_types(self): 'schema_type_names': ['stored_query', 'stored_queries'], 'example': 'ncbi_fetch_taxon', }, + { + 'schema_type_names': ['view', 'views'], + 'example': 'test_vertices', + } ] for schema in schema_type_list: @@ -162,3 +185,22 @@ def test_get_schema_for_doc(self): err_msg = f"Collection 'fake_name' does not exist." with self.assertRaisesRegex(SchemaNonexistent, err_msg): spec_loader.get_schema_for_doc(fake_name, path_only=True) + + def test_prevent_non_spec_dir_access(self): + """ + Ensure that matching files in directories outside the designated spec repo cannot be retrieved + """ + + # this query is OK as the file is still in the spec repo + path_in_spec_repo = '../../../../../**/fetch_test_vertex' + result = spec_loader.get_schema('stored_queries', path_in_spec_repo, path_only=True) + self.assertEqual( + result, + os_path.join(self.test_spec_dir, 'stored_queries', 'test', 'fetch_test_vertex.yaml') + ) + + # this matches a file in one of the other test data dirs => should throw an error + path_outside_spec_repo = '../../../../data/collections/test_node' + err_msg = f"Stored query '{path_outside_spec_repo}' does not exist" + with self.assertRaisesRegex(SchemaNonexistent, err_msg): + spec_loader.get_schema('stored_queries', path_outside_spec_repo, path_only=True) diff --git a/relation_engine_server/utils/spec_loader.py b/relation_engine_server/utils/spec_loader.py index 2cc1ffa8..625ebfd9 100644 --- a/relation_engine_server/utils/spec_loader.py +++ b/relation_engine_server/utils/spec_loader.py @@ -74,11 +74,18 @@ def get_schema(schema_type, name, path_only=False): schema_search_type = pluralise_schema_type(schema_type) - try: - path = _find_paths(_CONF['spec_paths'][schema_search_type], name + '.yaml')[0] - except IndexError: + yaml_paths = _find_paths(_CONF['spec_paths'][schema_search_type], f'{name}.yaml') + json_paths = _find_paths(_CONF['spec_paths'][schema_search_type], f'{name}.json') + # ensure we're using the canonical path and that all paths are unique + # we are only interested in paths that are in the designated spec repo + repo_path = os.path.abspath(_CONF['spec_paths']['repo']) + all_paths = [p for p in set(os.path.abspath(path) for path in yaml_paths + json_paths) if repo_path in p] + + if len(all_paths) == 0: raise SchemaNonexistent(singularise_schema_type(schema_type), name) + # ignore duplicates or multiple results, just go with the first one + path = all_paths[0] if path_only: return path @@ -112,6 +119,11 @@ def get_stored_query_names(): return get_names('stored_queries') +def get_view_names(): + """Return an array of all stored queries base names.""" + return get_names('views') + + def get_collection(name, path_only=False): """Get YAML content (or file path) for a specific collection. Throws an error if nonexistent.""" return get_schema('collection', name, path_only) @@ -133,6 +145,11 @@ def get_stored_query(name, path_only=False): return get_schema('stored_query', name, path_only) +def get_view(name, path_only=False): + """Get AQL content or file path for a specific stored query. Throws an error if nonexistent.""" + return get_schema('view', name, path_only) + + def _find_paths(dir_path, file_pattern): """ Return all file paths from a filename pattern, starting from a parent From 282958efb6579f08cf9fd38764d7526b9b416b63 Mon Sep 17 00:00:00 2001 From: ialarmedalien Date: Tue, 8 Sep 2020 10:06:25 -0700 Subject: [PATCH 576/732] Improve output of spec/validate.py to give more detail on errors --- spec/validate.py | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/spec/validate.py b/spec/validate.py index 286cdb58..62fa273e 100644 --- a/spec/validate.py +++ b/spec/validate.py @@ -47,16 +47,18 @@ def validate_all(schema_type, directory=None): if schema_type not in _VALID_SCHEMA_TYPES.keys(): raise ValueError(f"No validation schema found for '{schema_type}'") - print(f'Validating {schema_type} schemas...') - - err_count = 0 + err_files = [] + n_files = 0 names = set() # type: set if directory is None: type_dir_name = _VALID_SCHEMA_TYPES[schema_type]['plural'] directory = _CONF['spec_paths'][type_dir_name] + print(f'Validating {schema_type} schemas in {directory}...') + for path in glob.iglob(os.path.join(directory, '**', '*.*'), recursive=True): if path.endswith('.yaml') or path.endswith('.json'): + n_files += 1 try: data = validate_schema(path, schema_type) # Check for any duplicate schema names @@ -69,10 +71,19 @@ def validate_all(schema_type, directory=None): except Exception as err: print(f"✕ {path} failed validation") print(err) - err_count += 1 + err_files.append([path, err]) + + if not n_files: + print(f'No schema files found') + return - if err_count: - raise ValidationError(f'{directory} failed validation') + if err_files: + err_file_str = '\n'.join([i[0] for i in err_files]) + raise ValidationError( + f'{directory} failed validation\n' + f'files with errors:\n' + f'{err_file_str}' + ) # all's well print('...all valid.') @@ -95,7 +106,7 @@ def validate_all_by_type(validation_base_dir=None): """ - n_errors = 0 + n_errors = [] for schema_type in sorted(_VALID_SCHEMA_TYPES.keys()): try: if validation_base_dir is None: @@ -107,14 +118,16 @@ def validate_all_by_type(validation_base_dir=None): ) validate_all(schema_type, directory) except Exception as err: - print(err) - n_errors += 1 + n_errors.append(err) print("\n") - if n_errors > 0: + if n_errors: print('Validation failed!\n') + print("\n\n".join([str(n) for n in n_errors])) + else: + print('Validation succeeded!') - return n_errors + return len(n_errors) def validate_schema(path, schema_type): From 4dc2ea32617de8f98856c53e5cfcbaf7ece7a71f Mon Sep 17 00:00:00 2001 From: ialarmedalien Date: Tue, 8 Sep 2020 10:12:10 -0700 Subject: [PATCH 577/732] Fix incorrect comments for get_view and get_view_names Simplify code to reduce array of paths to a unique set --- relation_engine_server/utils/spec_loader.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/relation_engine_server/utils/spec_loader.py b/relation_engine_server/utils/spec_loader.py index 625ebfd9..f91daa2d 100644 --- a/relation_engine_server/utils/spec_loader.py +++ b/relation_engine_server/utils/spec_loader.py @@ -79,7 +79,8 @@ def get_schema(schema_type, name, path_only=False): # ensure we're using the canonical path and that all paths are unique # we are only interested in paths that are in the designated spec repo repo_path = os.path.abspath(_CONF['spec_paths']['repo']) - all_paths = [p for p in set(os.path.abspath(path) for path in yaml_paths + json_paths) if repo_path in p] + all_paths_set = set(os.path.abspath(path) for path in yaml_paths + json_paths) + all_paths = [p for p in all_paths_set if p.startswith(repo_path)] if len(all_paths) == 0: raise SchemaNonexistent(singularise_schema_type(schema_type), name) @@ -120,7 +121,7 @@ def get_stored_query_names(): def get_view_names(): - """Return an array of all stored queries base names.""" + """Return an array of all view base names.""" return get_names('views') @@ -146,7 +147,7 @@ def get_stored_query(name, path_only=False): def get_view(name, path_only=False): - """Get AQL content or file path for a specific stored query. Throws an error if nonexistent.""" + """Get content or file path for a view file. Throws an error if nonexistent.""" return get_schema('view', name, path_only) From 53ad1bb643e505f051e0f690ebe44389c0d1d9fb Mon Sep 17 00:00:00 2001 From: ialarmedalien Date: Sun, 6 Sep 2020 08:30:09 -0700 Subject: [PATCH 578/732] Additional json validation test for arrays Improve readme for test/spec_release Add test description Improve formatting and info given by validate.py Add djornl collection schema test Add sample_spec_release dir with decompressed versions of the files in relation_engine_server/test/spec_release/spec.tar.gz Edit spec_loader.py to prevent access outside the spec dir Add tests to test_spec_loader.py to ensure correct functioning spec loader remove $schema line from stored query --- .../data/json_validation/invalid_array.json | 5 + .../data/json_validation/invalid_array.yaml | 3 + .../json_validation/invalid_array_items.json | 5 + .../json_validation/invalid_array_items.yaml | 6 + .../data/json_validation/test_schema.json | 6 + .../data/json_validation/test_schema.yaml | 4 + .../data/json_validation/valid_array.json | 5 + .../data/json_validation/valid_array.yaml | 5 + .../test/test_json_validation.py | 129 ++++++++++++++++-- scripts/run_tests.sh | 12 +- spec/collections/djornl/djornl_edge.yaml | 2 +- spec/collections/djornl/djornl_node.yaml | 94 +++---------- spec/datasets/djornl/csv_cluster.yaml | 8 +- spec/datasets/djornl/csv_edge.yaml | 17 +-- spec/datasets/djornl/csv_node.yaml | 12 +- spec/datasets/djornl/definitions.yaml | 15 +- spec/datasets/djornl/edge_types_filter.yaml | 8 +- spec/datasets/djornl/node_type.yaml | 3 + .../djornl/djornl_fetch_clusters.yaml | 1 + spec/stored_query_schema.yaml | 3 + spec/test/collections/__init__.py | 0 spec/test/collections/test_djornl.py | 52 +++++++ 22 files changed, 274 insertions(+), 121 deletions(-) create mode 100644 relation_engine_server/test/data/json_validation/invalid_array.json create mode 100644 relation_engine_server/test/data/json_validation/invalid_array.yaml create mode 100644 relation_engine_server/test/data/json_validation/invalid_array_items.json create mode 100644 relation_engine_server/test/data/json_validation/invalid_array_items.yaml create mode 100644 relation_engine_server/test/data/json_validation/valid_array.json create mode 100644 relation_engine_server/test/data/json_validation/valid_array.yaml create mode 100644 spec/test/collections/__init__.py create mode 100644 spec/test/collections/test_djornl.py diff --git a/relation_engine_server/test/data/json_validation/invalid_array.json b/relation_engine_server/test/data/json_validation/invalid_array.json new file mode 100644 index 00000000..438e32c0 --- /dev/null +++ b/relation_engine_server/test/data/json_validation/invalid_array.json @@ -0,0 +1,5 @@ +{ + "name": "invalid_array", + "distance": 1, + "fruits": "pear" +} diff --git a/relation_engine_server/test/data/json_validation/invalid_array.yaml b/relation_engine_server/test/data/json_validation/invalid_array.yaml new file mode 100644 index 00000000..6471b4f4 --- /dev/null +++ b/relation_engine_server/test/data/json_validation/invalid_array.yaml @@ -0,0 +1,3 @@ +name: invalid_array +distance: 1 +fruits: pear diff --git a/relation_engine_server/test/data/json_validation/invalid_array_items.json b/relation_engine_server/test/data/json_validation/invalid_array_items.json new file mode 100644 index 00000000..2341cd7b --- /dev/null +++ b/relation_engine_server/test/data/json_validation/invalid_array_items.json @@ -0,0 +1,5 @@ +{ + "name": "invalid_array", + "distance": 1, + "fruits": ["pear", 1, "peach"] +} diff --git a/relation_engine_server/test/data/json_validation/invalid_array_items.yaml b/relation_engine_server/test/data/json_validation/invalid_array_items.yaml new file mode 100644 index 00000000..6a1be689 --- /dev/null +++ b/relation_engine_server/test/data/json_validation/invalid_array_items.yaml @@ -0,0 +1,6 @@ +name: invalid_array +distance: 1 +fruits: + - pear + - 1 + - peach diff --git a/relation_engine_server/test/data/json_validation/test_schema.json b/relation_engine_server/test/data/json_validation/test_schema.json index 3271e0f0..465836d7 100644 --- a/relation_engine_server/test/data/json_validation/test_schema.json +++ b/relation_engine_server/test/data/json_validation/test_schema.json @@ -29,6 +29,12 @@ "description": "A type of dried fruit", "type": "string", "format": "date" + }, + "fruits": { + "type": "array", + "items": { + "type": "string" + } } } } diff --git a/relation_engine_server/test/data/json_validation/test_schema.yaml b/relation_engine_server/test/data/json_validation/test_schema.yaml index 7ab2540e..164d5101 100644 --- a/relation_engine_server/test/data/json_validation/test_schema.yaml +++ b/relation_engine_server/test/data/json_validation/test_schema.yaml @@ -24,3 +24,7 @@ properties: description: A type of dried fruit type: string format: date + fruits: + type: array + items: + type: string diff --git a/relation_engine_server/test/data/json_validation/valid_array.json b/relation_engine_server/test/data/json_validation/valid_array.json new file mode 100644 index 00000000..77d95f7f --- /dev/null +++ b/relation_engine_server/test/data/json_validation/valid_array.json @@ -0,0 +1,5 @@ +{ + "name": "valid_array", + "distance": 3, + "fruits": ["pear", "plum"] +} diff --git a/relation_engine_server/test/data/json_validation/valid_array.yaml b/relation_engine_server/test/data/json_validation/valid_array.yaml new file mode 100644 index 00000000..79546e4b --- /dev/null +++ b/relation_engine_server/test/data/json_validation/valid_array.yaml @@ -0,0 +1,5 @@ +name: valid_array +distance: 3 +fruits: + - pear + - plum diff --git a/relation_engine_server/test/test_json_validation.py b/relation_engine_server/test/test_json_validation.py index 1a48fc1d..e7dbc7ee 100644 --- a/relation_engine_server/test/test_json_validation.py +++ b/relation_engine_server/test/test_json_validation.py @@ -1,5 +1,17 @@ """ Test JSON validation functions + +The majority of the validation tests use `test_schema`, defined below and replicated as +JSON and YAML files. The tests are run with files and data structures for both the schema +and the data to be validated to ensure that all formats function the same. + +Test data files are in relation_engine_server/test/data/json_validation + +schema files: test_schema.json and test_schema.yaml (replicates test_schema) +data files: generally named (in)?valid_.(json|yaml) + +Other validation tests are at the bottom of the file. + """ import unittest import os.path as os_path @@ -36,6 +48,14 @@ 'description': 'A type of dried fruit', 'type': 'string', 'format': 'date', + }, + 'fruits': { + 'title': 'Fruits', + 'type': 'array', + 'uniqueItems': True, + 'items': { + 'type': 'string' + } } } } @@ -73,7 +93,7 @@ class TestJsonValidation(unittest.TestCase): def test_non_validation_validator_errors(self): - '''test errors in the validator that are unrelated to the valiation functionality''' + '''test errors in the validator that are unrelated to the validation functionality''' err_str = "Please supply either a schema or a schema file path" with self.assertRaisesRegex(ValueError, err_str): @@ -122,12 +142,15 @@ def test_non_validation_validator_errors(self): self.assertEqual(output, {'name': 'name', 'distance': 3}) def test_json_validation(self): + """ Generic JSON validation tests to ensure that all is working as expected """ + # run these tests with the schema as a data structure, as JSON, and as YAML test_list = [ - self.add_defaults, - self.pattern_validation, - self.uri_validation, - self.date_format_validation, + self.test_add_defaults, + self.test_pattern_validation, + self.test_uri_validation, + self.test_date_format_validation, + self.test_array_validation, ] for test_schema in test_schema_list: @@ -141,9 +164,14 @@ def test_json_validation(self): for test in test_list: test(schema_arg, schema_file_arg) - def add_defaults(self, schema_arg, schema_file_arg): + def test_add_defaults(self, schema_arg=None, schema_file_arg=None): """Test that the jsonschema validator sets default values.""" + # skip if the test is not being called from test_json_validation + if schema_arg is None and schema_file_arg is None: + self.assertTrue(True) + return + test_data = run_validator( schema=schema_arg, schema_file=schema_file_arg, @@ -163,9 +191,14 @@ def add_defaults(self, schema_arg, schema_file_arg): {'name': 'blank', 'distance': 1} ) - def pattern_validation(self, schema_arg, schema_file_arg): + def test_pattern_validation(self, schema_arg=None, schema_file_arg=None): '''Test pattern validation''' + # skip if the test is not being called from test_json_validation + if schema_arg is None and schema_file_arg is None: + self.assertTrue(True) + return + # validation error - string does not match regex err_str = "'Mr Blobby' does not match .*?" with self.assertRaisesRegex(ValidationError, err_str): @@ -204,9 +237,14 @@ def pattern_validation(self, schema_arg, schema_file_arg): {'name': 'No_problem_with_this_string', 'distance': 3} ) - def uri_validation(self, schema_arg, schema_file_arg): + def test_uri_validation(self, schema_arg=None, schema_file_arg=None): '''Test URI validation is operational''' + # skip if the test is not being called from test_json_validation + if schema_arg is None and schema_file_arg is None: + self.assertTrue(True) + return + err_str = "'where is it\?' is not a 'uri'" with self.assertRaisesRegex(ValidationError, err_str): run_validator( @@ -249,9 +287,14 @@ def uri_validation(self, schema_arg, schema_file_arg): } ) - def date_format_validation(self, schema_arg, schema_file_arg): + def test_date_format_validation(self, schema_arg=None, schema_file_arg=None): '''ensure that fancy date formats are correctly validated''' + # skip if the test is not being called from test_json_validation + if schema_arg is None and schema_file_arg is None: + self.assertTrue(True) + return + err_str = "'202001017' is not a 'date'" with self.assertRaisesRegex(ValidationError, err_str): input = {'name': 'whatever', 'distance': 1, 'date': '202001017'} @@ -315,6 +358,74 @@ def date_format_validation(self, schema_arg, schema_file_arg): data_file=file_path, validate_at=valid_json_loc) + def test_array_validation(self, schema_arg=None, schema_file_arg=None): + """ check array validation works correctly """ + + # skip if the test is not being called from test_json_validation + if schema_arg is None and schema_file_arg is None: + self.assertTrue(True) + return + + err_str = "'pear' is not of type 'array'" + with self.assertRaisesRegex(ValidationError, err_str): + run_validator( + schema=schema_arg, + schema_file=schema_file_arg, + data={'name': 'blank', 'distance': 3, 'fruits': 'pear'}, + validate_at=valid_json_loc) + + err_str = "1 is not of type 'string'" + with self.assertRaisesRegex(ValidationError, err_str): + run_validator( + schema=schema_arg, + schema_file=schema_file_arg, + data={'name': 'blank', 'distance': 3, 'fruits': ['pear', 1, 'peach']}, + validate_at=valid_json_loc) + + # this string is OK + input = {'name': 'valid_uri', 'distance': 3, 'fruits': ['pear', 'plum']} + output = run_validator( + schema=schema_arg, + schema_file=schema_file_arg, + data=input, + validate_at=valid_json_loc) + self.assertEqual(output, input) + + # data files + for file_ext in ['json', 'yaml']: + file_path = os_path.join(json_validation_dir, 'invalid_array.' + file_ext) + err_str = "'pear' is not of type 'array'" + with self.assertRaisesRegex(ValidationError, err_str): + run_validator( + schema=schema_arg, + schema_file=schema_file_arg, + data_file=file_path, + validate_at=valid_json_loc) + + for file_ext in ['json', 'yaml']: + file_path = os_path.join(json_validation_dir, 'invalid_array_items.' + file_ext) + err_str = "1 is not of type 'string'" + with self.assertRaisesRegex(ValidationError, err_str): + run_validator( + schema=schema_arg, + schema_file=schema_file_arg, + data_file=file_path, + validate_at=valid_json_loc) + + file_path = os_path.join(json_validation_dir, 'valid_array.' + file_ext) + self.assertEqual( + run_validator( + schema=schema_arg, + schema_file=schema_file_arg, + data_file=file_path, + validate_at=valid_json_loc), + { + "name": "valid_array", + "distance": 3, + 'fruits': ['pear', 'plum'], + } + ) + def test_schema_references(self): """Ensure referenced schemas, including those written in yaml, can be accessed.""" diff --git a/scripts/run_tests.sh b/scripts/run_tests.sh index 8f1f1ab9..2c9a2899 100644 --- a/scripts/run_tests.sh +++ b/scripts/run_tests.sh @@ -11,15 +11,11 @@ mkdir /spec/repo cp -r /app/spec/* /spec/repo/ # start server, using the specs in /spec/repo sh /app/scripts/start_server.sh & +coverage erase # spec validation python -m spec.validate && -# spec stored query tests -coverage run --parallel-mode -m unittest discover spec/test && -# importer tests -coverage run --parallel-mode -m unittest discover importers/test && -# RE API tests -coverage run --parallel-mode -m unittest discover relation_engine_server/test && +# run importer/, relation_engine_server/, and spec/ tests +coverage run --branch -m unittest discover -v && # RE client tests -PYTHONPATH=client_src coverage run --parallel-mode -m unittest discover client_src/test -coverage combine +PYTHONPATH=client_src python -m unittest discover client_src/test && coverage html --omit=*/test_* diff --git a/spec/collections/djornl/djornl_edge.yaml b/spec/collections/djornl/djornl_edge.yaml index a6f93d51..9ba2b6e2 100644 --- a/spec/collections/djornl/djornl_edge.yaml +++ b/spec/collections/djornl/djornl_edge.yaml @@ -9,7 +9,7 @@ indexes: fields: [score] schema: - "$schema": http://json-schema.org/draft-07/schema# + $schema: http://json-schema.org/draft-07/schema# title: Arabidopsis gene-gene or gene-phenotype edge description: Generic gene-to-gene or gene-to-phenotype edge for Dan Jacobson Arabidopsis data type: object diff --git a/spec/collections/djornl/djornl_node.yaml b/spec/collections/djornl/djornl_node.yaml index 62d17dda..d4082554 100644 --- a/spec/collections/djornl/djornl_node.yaml +++ b/spec/collections/djornl/djornl_node.yaml @@ -7,7 +7,7 @@ indexes: fields: ["clusters[*]"] schema: - "$schema": http://json-schema.org/draft-07/schema# + $schema: http://json-schema.org/draft-07/schema# title: Gene and Phenotype Vertices description: Arabidopsis gene and phenotype nodes from the Dan Jacobson Lab type: object @@ -15,94 +15,44 @@ schema: additionalProperties: false properties: _key: - type: string - title: Key - examples: ["AT1G01010"] + $ref: ../../datasets/djornl/definitions.yaml#definitions/djornl_node/_key clusters: - type: array - title: Clusters - description: Clusters to which the node has been assigned - items: - type: string - format: regex - pattern: ^\w+:\d+$ - examples: [["markov_i2:1", "markov_i4:5"], ["markov_i6:3"]] + $ref: ../../datasets/djornl/definitions.yaml#definitions/djornl_node/clusters node_type: - type: string - title: Node type - examples: ["gene", "phenotype"] + $ref: ../../datasets/djornl/definitions.yaml#definitions/djornl_node/node_type transcript: - type: string - title: Transcript - examples: ["AT1G01010.1"] + $ref: ../../datasets/djornl/definitions.yaml#definitions/djornl_node/transcript gene_symbol: - type: string - title: Gene symbol - examples: ["NTL10"] + $ref: ../../datasets/djornl/definitions.yaml#definitions/djornl_node/gene_symbol gene_full_name: - type: string - title: Gene full name - examples: ["NAC domain containing protein 1"] + $ref: ../../datasets/djornl/definitions.yaml#definitions/djornl_node/gene_full_name gene_model_type: - type: string - title: Gene model type - examples: ["protein_coding"] + $ref: ../../datasets/djornl/definitions.yaml#definitions/djornl_node/gene_model_type tair_computational_description: - type: string - title: TAIR computational description - examples: ["NAC domain containing protein 1;(source:Araport11)"] + $ref: ../../datasets/djornl/definitions.yaml#definitions/djornl_node/tair_computational_description tair_curator_summary: - type: string - title: TAIR curator summary - examples: ["Encodes a plasma membrane-localized amino acid transporter likely involved in amino acid export in the developing seed."] + $ref: ../../datasets/djornl/definitions.yaml#definitions/djornl_node/tair_curator_summary tair_short_description: - type: string - title: TAIR short description - examples: ["NAC domain containing protein 1"] + $ref: ../../datasets/djornl/definitions.yaml#definitions/djornl_node/tair_short_description go_description: - type: string - title: GO descriptions - examples: ["DNA-binding transcription factor activity"] + $ref: ../../datasets/djornl/definitions.yaml#definitions/djornl_node/go_description go_terms: - type: array - title: GO term IDs - items: {type: string} - examples: [["GO:0003700", "GO:0005515"]] + $ref: ../../datasets/djornl/definitions.yaml#definitions/djornl_node/go_terms mapman_bin: - type: string - title: Mapman bin - examples: ["15.5.17"] + $ref: ../../datasets/djornl/definitions.yaml#definitions/djornl_node/mapman_bin mapman_name: - type: string - title: Mapman name - examples: [".RNA biosynthesis.transcriptional regulation.transcription factor (NAC)"] + $ref: ../../datasets/djornl/definitions.yaml#definitions/djornl_node/mapman_name mapman_description: - type: string - title: Mapman description - examples: ["transcription factor (NAC) (original description: pep chromosome:TAIR10:1:3631:5899:1 gene:AT1G01010 transcript:AT1G01010.1 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:NAC001 description:NAC domain-containing protein 1 [Source:UniProtKB/Swiss-Prot;Acc:Q0WV96])"] + $ref: ../../datasets/djornl/definitions.yaml#definitions/djornl_node/mapman_description pheno_aragwas_id: - type: string - title: AraGWAS ID - examples: ["10.21958/phenotype:67"] + $ref: ../../datasets/djornl/definitions.yaml#definitions/djornl_node/pheno_aragwas_id pheno_description: - type: string - title: Phenotype description - examples: ["Arsenic concentrations in leaves, grown in soil. Elemental analysis was performed with an ICP-MS (PerkinElmer). Sample normalized to calculated weights as described in Baxter et al., 2008"] + $ref: ../../datasets/djornl/definitions.yaml#definitions/djornl_node/pheno_description pheno_pto_name: - type: string - title: PTO name - description: Plant Trait Ontology name - examples: ["arsenic concentration"] + $ref: ../../datasets/djornl/definitions.yaml#definitions/djornl_node/pheno_pto_name pheno_pto_description: - type: string - title: PTO description - description: Plant Trait Ontology description - examples: ["A mineral and ion content related trait (TO:0000465) which is the concentration of arsenic (CHEBI:22632) in some plant structure (PO:0009011). [GR:Karthik]"] + $ref: ../../datasets/djornl/definitions.yaml#definitions/djornl_node/pheno_pto_description pheno_ref: - type: string - title: Phenotype reference - examples: ["Atwell et. al, Nature 2010"] + $ref: ../../datasets/djornl/definitions.yaml#definitions/djornl_node/pheno_ref user_notes: - type: string - title: User Notes - examples: ["flowering time related"] + $ref: ../../datasets/djornl/definitions.yaml#definitions/djornl_node/user_notes diff --git a/spec/datasets/djornl/csv_cluster.yaml b/spec/datasets/djornl/csv_cluster.yaml index c60f1dfd..9f36b08c 100644 --- a/spec/datasets/djornl/csv_cluster.yaml +++ b/spec/datasets/djornl/csv_cluster.yaml @@ -1,7 +1,7 @@ -"$schema": http://json-schema.org/draft-07/schema# +$schema: http://json-schema.org/draft-07/schema# name: csv_cluster -title: Cluster data -description: Cluster ID to node ID mappings +title: Cluster file syntax +description: Jacobson lab cluster ID to node ID mappings type: object required: [cluster_id, node_ids] additionalProperties: false @@ -9,7 +9,7 @@ properties: cluster_id: type: string format: regex - pattern: "^Cluster\\d+" + pattern: ^Cluster\d+$ # pre-transform node_ids node_ids: type: string diff --git a/spec/datasets/djornl/csv_edge.yaml b/spec/datasets/djornl/csv_edge.yaml index c2416262..f5c88b1a 100644 --- a/spec/datasets/djornl/csv_edge.yaml +++ b/spec/datasets/djornl/csv_edge.yaml @@ -1,7 +1,7 @@ -"$schema": http://json-schema.org/draft-07/schema# +$schema: http://json-schema.org/draft-07/schema# name: csv_edge -title: Arabidopsis gene-gene or gene-phenotype edge -description: Generic gene-to-gene or gene-to-phenotype edge for Dan Jacobson Arabidopsis data +title: CSV edge file syntax +description: Jacobson lab Arabidopsis edge data file columns for generic node-to-node edges with scores type: object required: [node1, node2, edge, layer_descrip] properties: @@ -10,14 +10,9 @@ properties: node2: $ref: definitions.yaml#definitions/djornl_edge/_to edge: + # pre-transformation, the parser treats this as a string type: string format: regex - pattern: "^\\d*(\\.\\d+)?$" + pattern: ^\d+(\.\d+)?$ layer_descrip: - type: string - oneOf: - - const: AraNetv2-DC_domain-co-occurrence - - const: AraNetv2-CX_pairwise-gene-coexpression - - const: AraGWAS-Phenotype_Associations - - const: AraNetv2-HT_high-throughput-ppi - - const: AraNetv2-LC_lit-curated-ppi + $ref: edge_type.yaml diff --git a/spec/datasets/djornl/csv_node.yaml b/spec/datasets/djornl/csv_node.yaml index c957ff98..4c3c3b48 100644 --- a/spec/datasets/djornl/csv_node.yaml +++ b/spec/datasets/djornl/csv_node.yaml @@ -1,7 +1,7 @@ -"$schema": http://json-schema.org/draft-07/schema# +$schema: http://json-schema.org/draft-07/schema# name: csv_node title: CSV node file syntax -description: Arabidopsis gene and phenotype nodes from the Dan Jacobson Lab +description: Jacobson lab Arabidopsis gene and phenotype data file columns type: object required: [node_id, node_type] additionalProperties: false @@ -10,8 +10,11 @@ properties: $ref: definitions.yaml#definitions/djornl_node/_key node_type: $ref: definitions.yaml#definitions/djornl_node/node_type + # comma-separated array of cluster IDs clusters: - $ref: definitions.yaml#definitions/djornl_node/clusters + type: string + format: regex + pattern: ^(\w+:\d+, ?)*(\w+:\d+)?$ transcript: $ref: definitions.yaml#definitions/djornl_node/transcript gene_symbol: @@ -26,10 +29,11 @@ properties: $ref: definitions.yaml#definitions/djornl_node/tair_curator_summary tair_short_description: $ref: definitions.yaml#definitions/djornl_node/tair_short_description + # comma-separated array of GO terms go_terms: type: string format: regex - pattern: "^(GO:\\d{7}, ?)*(GO:\\d{7})?$" + pattern: ^(GO:\d{7}, ?)*(GO:\d{7})?$ go_description: $ref: definitions.yaml#definitions/djornl_node/go_description mapman_bin: diff --git a/spec/datasets/djornl/definitions.yaml b/spec/datasets/djornl/definitions.yaml index 0c7b4395..da9b5dc4 100644 --- a/spec/datasets/djornl/definitions.yaml +++ b/spec/datasets/djornl/definitions.yaml @@ -40,18 +40,12 @@ definitions: type: array title: Clusters description: Clusters to which the node has been assigned + uniqueItems: true items: - $ref: #definitions/cluster_id + $ref: "#/definitions/cluster_id" examples: [["markov_i2:1", "markov_i4:5"], ["markov_i6:3"]] node_type: - type: string - title: Node type - oneOf: - - const: gene - title: Gene - - const: pheno - title: Phenotype - examples: ["gene", "pheno"] + $ref: node_type.yaml transcript: type: string title: Transcript @@ -87,8 +81,9 @@ definitions: go_terms: type: array title: GO term IDs + uniqueItems: true items: - $ref: #definitions/go_term + $ref: "#/definitions/go_term" mapman_bin: type: string title: Mapman bin diff --git a/spec/datasets/djornl/edge_types_filter.yaml b/spec/datasets/djornl/edge_types_filter.yaml index 3bce0661..6c090052 100644 --- a/spec/datasets/djornl/edge_types_filter.yaml +++ b/spec/datasets/djornl/edge_types_filter.yaml @@ -4,6 +4,10 @@ title: Edge Types description: Edge types to filter on type: array items: - $ref: "edge_type.yaml" + $ref: edge_type.yaml default: [] -examples: [['AraNetv2-HT_high-throughput-ppi', 'AraNetv2-LC_lit-curated-ppi'], ['AraGWAS-Phenotype_Associations']] +uniqueItems: true +examples: + - ['AraNetv2-HT_high-throughput-ppi', 'AraNetv2-LC_lit-curated-ppi'] + - ['AraGWAS-Phenotype_Associations'] + - [] diff --git a/spec/datasets/djornl/node_type.yaml b/spec/datasets/djornl/node_type.yaml index b322ee81..f81f0a96 100644 --- a/spec/datasets/djornl/node_type.yaml +++ b/spec/datasets/djornl/node_type.yaml @@ -3,6 +3,9 @@ name: node_type title: Node Type description: Node types in Dan Jacobson Exascale dataset type: string +examples: + - gene + - phenotype oneOf: - const: gene title: Gene diff --git a/spec/stored_queries/djornl/djornl_fetch_clusters.yaml b/spec/stored_queries/djornl/djornl_fetch_clusters.yaml index 9b18c6bf..55222225 100644 --- a/spec/stored_queries/djornl/djornl_fetch_clusters.yaml +++ b/spec/stored_queries/djornl/djornl_fetch_clusters.yaml @@ -12,6 +12,7 @@ params: items: $ref: "../../datasets/djornl/definitions.yaml#definitions/cluster_id" minItems: 1 + uniqueItems: true examples: [['markov_i2:5', 'markov_i6:2'],['markov_i6:1']] distance: $ref: "../../datasets/distance.yaml" diff --git a/spec/stored_query_schema.yaml b/spec/stored_query_schema.yaml index 034c3642..62ce4d74 100644 --- a/spec/stored_query_schema.yaml +++ b/spec/stored_query_schema.yaml @@ -14,4 +14,7 @@ properties: type: string query: type: string + $schema: + type: string + format: uri additionalProperties: false diff --git a/spec/test/collections/__init__.py b/spec/test/collections/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/spec/test/collections/test_djornl.py b/spec/test/collections/test_djornl.py new file mode 100644 index 00000000..39008fbc --- /dev/null +++ b/spec/test/collections/test_djornl.py @@ -0,0 +1,52 @@ +""" +Tests for the Dan Jacobson ORNL Arabidopsis collection schemas. + +These tests ensure that specific elements of the collection schemas validate correctly. + +""" +import unittest + +from spec.test.helpers import check_spec_test_env +from relation_engine_server.utils.spec_loader import get_schema +from relation_engine_server.utils.json_validation import get_schema_validator +from jsonschema.exceptions import ValidationError + + +class Test_DJORNL_Collections(unittest.TestCase): + + @classmethod + def setUpClass(cls): + cls.maxDiff = None + check_spec_test_env() + + def test_node(self, query_name=None, test_data=None): + """ ensure node data validates correctly """ + + schema_file = get_schema('collection', 'djornl_node', path_only=True) + validator = get_schema_validator(schema_file=schema_file, validate_at='/schema') + + test_data = [ + { + 'data': {'_key': 'AT1G01010', 'go_terms': ['GO:0003700', 'GO:0003677']}, + 'valid': True, + }, + { + 'data': {'_key': 'ABCDE', 'node_type': 'vertex'}, + 'valid': False, + 'error': "'vertex' is not valid under any of the given schemas", + }, + { + 'data': {'_key': 'ABCDE', 'clusters': ['GO:0003700', 'GO:0003700']}, + 'valid': False, + 'error': "\['GO:0003700', 'GO:0003700'\] has non-unique elements" + } + ] + + for test in test_data: + if test['valid']: + self.assertTrue( + validator.is_valid(test['data']) + ) + else: + with self.assertRaisesRegex(ValidationError, test['error']): + validator.validate(test['data']) From 1c5bbea82e16126987f30f773b7a93d9ed87f6d2 Mon Sep 17 00:00:00 2001 From: ialarmedalien Date: Wed, 9 Sep 2020 11:27:45 -0700 Subject: [PATCH 579/732] Adding information on test requirements Refactor json tests Remove some unneeded test files Add tests for the specific example of the default population failure Update DJORNL stored queries to a ref structure that will work when populating defaults Remove comments from file --- importers/test/test_djornl_parser.py | 2 + relation_engine_server/README.md | 4 +- .../test/data/json_validation/fruit.yaml | 9 + .../data/json_validation/fruits_array.yaml | 13 + .../data/json_validation/invalid_array.json | 5 - .../data/json_validation/invalid_array.yaml | 3 - .../json_validation/invalid_array_items.json | 5 - .../json_validation/invalid_array_items.yaml | 6 - .../data/json_validation/test_schema.json | 6 +- .../data/json_validation/test_schema.yaml | 8 +- .../data/json_validation/valid_array.json | 5 - .../data/json_validation/valid_array.yaml | 5 - .../test/data/json_validation/valid_uri.yaml | 2 +- .../test/spec_release/README.md | 20 +- relation_engine_server/test/test_api_v1.py | 2 +- .../test/test_json_validation.py | 533 +++++++++--------- .../test/test_spec_loader.py | 22 +- .../djornl/djornl_fetch_all.yaml | 12 +- .../djornl/djornl_fetch_clusters.yaml | 21 +- .../djornl/djornl_fetch_genes.yaml | 22 +- .../djornl/djornl_fetch_phenotypes.yaml | 22 +- .../djornl/djornl_search_nodes.yaml | 19 +- spec/test/collections/test_djornl.py | 28 +- spec/test/djornl/results.json | 70 +-- spec/test/stored_queries/test_djornl.py | 2 + .../stored_queries/test_list_test_vertices.py | 7 + spec/test/stored_queries/test_ncbi_tax.py | 2 + spec/test/stored_queries/test_taxonomy.py | 2 + spec/test/stored_queries/test_ws.py | 5 +- spec/test/test_manifest_schema.py | 4 +- spec/test/test_validate.py | 2 + 31 files changed, 503 insertions(+), 365 deletions(-) create mode 100644 relation_engine_server/test/data/json_validation/fruit.yaml create mode 100644 relation_engine_server/test/data/json_validation/fruits_array.yaml delete mode 100644 relation_engine_server/test/data/json_validation/invalid_array.json delete mode 100644 relation_engine_server/test/data/json_validation/invalid_array.yaml delete mode 100644 relation_engine_server/test/data/json_validation/invalid_array_items.json delete mode 100644 relation_engine_server/test/data/json_validation/invalid_array_items.yaml delete mode 100644 relation_engine_server/test/data/json_validation/valid_array.json delete mode 100644 relation_engine_server/test/data/json_validation/valid_array.yaml diff --git a/importers/test/test_djornl_parser.py b/importers/test/test_djornl_parser.py index 763eea5d..4f95f645 100644 --- a/importers/test/test_djornl_parser.py +++ b/importers/test/test_djornl_parser.py @@ -3,6 +3,8 @@ At the present time, this just ensures that the files are parsed correctly; it does not check data loading into the db. + +These tests run within the re_api docker image. """ import json import unittest diff --git a/relation_engine_server/README.md b/relation_engine_server/README.md index 1689158d..e500b29a 100644 --- a/relation_engine_server/README.md +++ b/relation_engine_server/README.md @@ -271,7 +271,7 @@ Example response: Get the schema for a specific data source ```sh -GET "{root_url}/api/v1/specs/data_source?name=ncbi_taxonomy" +GET "{root_url}/api/v1/specs/data_sources?name=ncbi_taxonomy" ``` Example response: @@ -338,7 +338,7 @@ Example response: Get the schema for a specific stored query ```sh -GET "{root_url}/api/v1/specs/stored_query?name=ncbi_fetch_taxon" +GET "{root_url}/api/v1/specs/stored_queries?name=ncbi_fetch_taxon" ``` Example response: diff --git a/relation_engine_server/test/data/json_validation/fruit.yaml b/relation_engine_server/test/data/json_validation/fruit.yaml new file mode 100644 index 00000000..75e2acf7 --- /dev/null +++ b/relation_engine_server/test/data/json_validation/fruit.yaml @@ -0,0 +1,9 @@ +$schema: "http://json-schema.org/draft-07/schema#" +name: fruit +type: string +oneOf: + - const: peach + - const: plum + - const: dragonfruit + - const: strawberry + - const: pear diff --git a/relation_engine_server/test/data/json_validation/fruits_array.yaml b/relation_engine_server/test/data/json_validation/fruits_array.yaml new file mode 100644 index 00000000..ed6c710f --- /dev/null +++ b/relation_engine_server/test/data/json_validation/fruits_array.yaml @@ -0,0 +1,13 @@ +$schema: "http://json-schema.org/draft-07/schema#" +name: fruits_array +definitions: + fruits: + type: array + items: + $ref: fruit.yaml + default: [] + uniqueItems: true + examples: + - ['peach', 'plum'] + - ['strawberry'] + - [] diff --git a/relation_engine_server/test/data/json_validation/invalid_array.json b/relation_engine_server/test/data/json_validation/invalid_array.json deleted file mode 100644 index 438e32c0..00000000 --- a/relation_engine_server/test/data/json_validation/invalid_array.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "invalid_array", - "distance": 1, - "fruits": "pear" -} diff --git a/relation_engine_server/test/data/json_validation/invalid_array.yaml b/relation_engine_server/test/data/json_validation/invalid_array.yaml deleted file mode 100644 index 6471b4f4..00000000 --- a/relation_engine_server/test/data/json_validation/invalid_array.yaml +++ /dev/null @@ -1,3 +0,0 @@ -name: invalid_array -distance: 1 -fruits: pear diff --git a/relation_engine_server/test/data/json_validation/invalid_array_items.json b/relation_engine_server/test/data/json_validation/invalid_array_items.json deleted file mode 100644 index 2341cd7b..00000000 --- a/relation_engine_server/test/data/json_validation/invalid_array_items.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "invalid_array", - "distance": 1, - "fruits": ["pear", 1, "peach"] -} diff --git a/relation_engine_server/test/data/json_validation/invalid_array_items.yaml b/relation_engine_server/test/data/json_validation/invalid_array_items.yaml deleted file mode 100644 index 6a1be689..00000000 --- a/relation_engine_server/test/data/json_validation/invalid_array_items.yaml +++ /dev/null @@ -1,6 +0,0 @@ -name: invalid_array -distance: 1 -fruits: - - pear - - 1 - - peach diff --git a/relation_engine_server/test/data/json_validation/test_schema.json b/relation_engine_server/test/data/json_validation/test_schema.json index 465836d7..d0e93a98 100644 --- a/relation_engine_server/test/data/json_validation/test_schema.json +++ b/relation_engine_server/test/data/json_validation/test_schema.json @@ -33,8 +33,10 @@ "fruits": { "type": "array", "items": { - "type": "string" - } + "$ref": "fruit.yaml" + }, + "default": [], + "uniqueItems": "true" } } } diff --git a/relation_engine_server/test/data/json_validation/test_schema.yaml b/relation_engine_server/test/data/json_validation/test_schema.yaml index 164d5101..bbdc0707 100644 --- a/relation_engine_server/test/data/json_validation/test_schema.yaml +++ b/relation_engine_server/test/data/json_validation/test_schema.yaml @@ -27,4 +27,10 @@ properties: fruits: type: array items: - type: string + $ref: fruit.yaml + default: [] + uniqueItems: true + examples: + - ['peach', 'plum'] + - ['strawberry'] + - [] diff --git a/relation_engine_server/test/data/json_validation/valid_array.json b/relation_engine_server/test/data/json_validation/valid_array.json deleted file mode 100644 index 77d95f7f..00000000 --- a/relation_engine_server/test/data/json_validation/valid_array.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "valid_array", - "distance": 3, - "fruits": ["pear", "plum"] -} diff --git a/relation_engine_server/test/data/json_validation/valid_array.yaml b/relation_engine_server/test/data/json_validation/valid_array.yaml deleted file mode 100644 index 79546e4b..00000000 --- a/relation_engine_server/test/data/json_validation/valid_array.yaml +++ /dev/null @@ -1,5 +0,0 @@ -name: valid_array -distance: 3 -fruits: - - pear - - plum diff --git a/relation_engine_server/test/data/json_validation/valid_uri.yaml b/relation_engine_server/test/data/json_validation/valid_uri.yaml index 2fe93df3..e31a0c49 100644 --- a/relation_engine_server/test/data/json_validation/valid_uri.yaml +++ b/relation_engine_server/test/data/json_validation/valid_uri.yaml @@ -1,3 +1,3 @@ name: valid_uri distance: 3 -home_page: "http://json-validation.com:5000/this/is/valid" +home_page: http://json-validation.com:5000/this/is/valid diff --git a/relation_engine_server/test/spec_release/README.md b/relation_engine_server/test/spec_release/README.md index a371c2e3..61d16dce 100644 --- a/relation_engine_server/test/spec_release/README.md +++ b/relation_engine_server/test/spec_release/README.md @@ -2,13 +2,27 @@ `sample_spec_release`, and the corresponding archive, `spec.tar.gz`, contain a set of sample schema files suitable for use in tests. -To create a new version of `spec.tar.gz`, you will need to exec into the `re_api` docker image to ensure that the new archive and its contents have the appropriate file owner and permissions (all files must have owner and group `root`/`root`). +To create a new version of `spec.tar.gz`, you will need to open a shell into the `re_api` docker image and create the new archive there to ensure that the new archive and its contents have the appropriate file owner and permissions (all files must have owner and group `root`/`root`). -Example commands: +Ensure that you have mounted your current working directory as `/app` in the docker `re_api` image by uncommenting the lines in `docker-compose.yaml`: +``` yaml + re_api: + ( ... ) +# uncomment to mount local directories + volumes: + - ${PWD}:/app ``` + +Run `make shell` to start up the docker container, and then get the ID of the current `re_api` image. Exec into the `re_api` image via the Docker Desktop client or the command line: + +``` sh $ docker exec -it relation_engine_re_api_run_1234567890 sh -# # in the docker image +``` + +Example commands for updating `spec.tar.gz`: + +``` sh # cd relation_engine_server/test/spec_release # # ... perform any edits ... # tar -czvf new_spec.tar.gz sample_spec_release/ diff --git a/relation_engine_server/test/test_api_v1.py b/relation_engine_server/test/test_api_v1.py index f5de696d..b309fe23 100644 --- a/relation_engine_server/test/test_api_v1.py +++ b/relation_engine_server/test/test_api_v1.py @@ -1,7 +1,7 @@ """ Simple integration tests on the API itself. -We make actual ajax requests to the running docker container. +These tests run within the re_api docker image, and require access to the ArangoDB, auth, and workspace images. """ import unittest import requests diff --git a/relation_engine_server/test/test_json_validation.py b/relation_engine_server/test/test_json_validation.py index e7dbc7ee..501b786f 100644 --- a/relation_engine_server/test/test_json_validation.py +++ b/relation_engine_server/test/test_json_validation.py @@ -12,6 +12,7 @@ Other validation tests are at the bottom of the file. +These tests run within the re_api docker image. """ import unittest import os.path as os_path @@ -21,6 +22,10 @@ from jsonschema.exceptions import ValidationError, RefResolutionError from jsonpointer import JsonPointerException +test_data_dirs = ['/app', 'relation_engine_server', 'test', 'data'] +json_validation_dir = os_path.join(*(test_data_dirs + ['json_validation'])) +schema_refs_dir = os_path.join(*(test_data_dirs + ['schema_refs'])) + test_schema = { 'properties': { @@ -50,22 +55,57 @@ 'format': 'date', }, 'fruits': { - 'title': 'Fruits', 'type': 'array', - 'uniqueItems': True, 'items': { - 'type': 'string' - } + 'name': 'fruit', + 'type': 'string', + 'oneOf': [ + {'const': 'peach'}, + {'const': 'plum'}, + {'const': 'pear'}, + {'const': 'strawberry'}, + ] + }, + 'default': [], + 'uniqueItems': True } } } } } +fruits_explicit = { + 'type': 'array', + 'items': { + 'name': 'fruit', + 'type': 'string', + 'oneOf': [ + {'const': 'peach'}, + {'const': 'plum'}, + {'const': 'pear'}, + {'const': 'strawberry'}, + ] + }, + 'default': [], + 'uniqueItems': True +} + +fruits_array_ref = { + '$ref': 'file://' + os_path.join(json_validation_dir, 'fruits_array.yaml') + + '#/definitions/fruits' +} + +fruit_ref = { + 'type': 'array', + 'items': { + '$ref': 'file://' + os_path.join(json_validation_dir, 'fruit.yaml') + }, + 'default': [], + 'uniqueItems': True +} + valid_json_loc = '/properties/params' -test_data_dirs = ['/app', 'relation_engine_server', 'test', 'data'] -json_validation_dir = os_path.join(*(test_data_dirs + ['json_validation'])) -schema_refs_dir = os_path.join(*(test_data_dirs + ['schema_refs'])) +schema_defaults = {'name': 'blank', 'distance': 1, 'fruits': []} test_schema_list = [ ['schema', test_schema], @@ -138,8 +178,11 @@ def test_non_validation_validator_errors(self): output = run_validator( schema=test_schema, data={'name': 'name', 'distance': 3}, - validate_at='/properties/params') - self.assertEqual(output, {'name': 'name', 'distance': 3}) + validate_at=valid_json_loc) + self.assertEqual( + output, + {**schema_defaults, **{'name': 'name', 'distance': 3}} + ) def test_json_validation(self): """ Generic JSON validation tests to ensure that all is working as expected """ @@ -161,8 +204,45 @@ def test_json_validation(self): else: schema_arg = None - for test in test_list: - test(schema_arg, schema_file_arg) + for test_name in test_list: + with self.subTest(test_name=test_name.__name__): + test_name(schema_arg, schema_file_arg) + + def execute_tests(self, schema_arg, schema_file_arg, tests, file_types=[None, 'json', 'yaml']): + + for t in tests: + for file_ext in file_types: + data = t['input'] + data_file = os_path.join(json_validation_dir, f"{t['file']}.{file_ext}") + if file_ext is None: + data_file = None + else: + data = None + + with self.subTest(input=t['input'], file_type=file_ext): + if 'err_str' in t: + with self.assertRaisesRegex(ValidationError, t['err_str']): + run_validator( + schema=schema_arg, + schema_file=schema_file_arg, + data=data, + data_file=data_file, + validate_at=valid_json_loc) + + else: + output = run_validator( + schema=schema_arg, + schema_file=schema_file_arg, + data=data, + data_file=data_file, + validate_at=valid_json_loc) + self.assertEqual( + output, + { + **schema_defaults, + **t['output'] + } + ) def test_add_defaults(self, schema_arg=None, schema_file_arg=None): """Test that the jsonschema validator sets default values.""" @@ -172,24 +252,15 @@ def test_add_defaults(self, schema_arg=None, schema_file_arg=None): self.assertTrue(True) return - test_data = run_validator( - schema=schema_arg, - schema_file=schema_file_arg, - data={}, - validate_at=valid_json_loc) - self.assertEqual(test_data, {'name': 'blank', 'distance': 1}) + tests = [ + { + 'input': {}, + 'file': 'defaults', + 'output': schema_defaults, + } + ] - for file_ext in ['json', 'yaml']: - file_path = os_path.join(json_validation_dir, 'defaults.' + file_ext) - self.assertEqual( - run_validator( - schema=schema_arg, - schema_file=schema_file_arg, - data_file=file_path, - validate_at=valid_json_loc - ), - {'name': 'blank', 'distance': 1} - ) + self.execute_tests(schema_arg, schema_file_arg, tests) def test_pattern_validation(self, schema_arg=None, schema_file_arg=None): '''Test pattern validation''' @@ -199,43 +270,22 @@ def test_pattern_validation(self, schema_arg=None, schema_file_arg=None): self.assertTrue(True) return - # validation error - string does not match regex - err_str = "'Mr Blobby' does not match .*?" - with self.assertRaisesRegex(ValidationError, err_str): - run_validator( - schema=schema_arg, - schema_file=schema_file_arg, - data={'name': 'Mr Blobby', 'distance': 3}, - validate_at=valid_json_loc) - - # this string is OK - output = run_validator( - schema=schema_arg, - schema_file=schema_file_arg, - data={'name': 'Mr_Blobby_666', 'distance': 3}, - validate_at=valid_json_loc) - self.assertEqual(output, {'name': 'Mr_Blobby_666', 'distance': 3}) - - for file_ext in ['json', 'yaml']: - # validation error - string does not match regex - err_str = '"what\'s-the-problem with-this-string\?" does not match .*?' - file_path = os_path.join(json_validation_dir, 'invalid_pattern.' + file_ext) - with self.assertRaisesRegex(ValidationError, err_str): - run_validator( - schema=schema_arg, - schema_file=schema_file_arg, - data_file=file_path, - validate_at=valid_json_loc) - - file_path = os_path.join(json_validation_dir, 'valid_pattern.' + file_ext) - self.assertEqual( - run_validator( - schema=schema_arg, - schema_file=schema_file_arg, - data_file=file_path, - validate_at=valid_json_loc), - {'name': 'No_problem_with_this_string', 'distance': 3} - ) + tests = [ + { + 'input': {"name": "what's-the-problem with-this-string?", "distance": 3}, + 'file': 'invalid_pattern', + 'err_str': '"what\'s-the-problem with-this-string\?" does not match .*?', + }, + { + 'input': {"name": "No_problem_with_this_string", "distance": 3}, + 'file': 'valid_pattern', + 'output': { + 'name': 'No_problem_with_this_string', + 'distance': 3, + } + } + ] + self.execute_tests(schema_arg, schema_file_arg, tests) def test_uri_validation(self, schema_arg=None, schema_file_arg=None): '''Test URI validation is operational''' @@ -245,47 +295,28 @@ def test_uri_validation(self, schema_arg=None, schema_file_arg=None): self.assertTrue(True) return - err_str = "'where is it\?' is not a 'uri'" - with self.assertRaisesRegex(ValidationError, err_str): - run_validator( - schema=schema_arg, - schema_file=schema_file_arg, - data={'name': 'blank', 'distance': 3, 'home_page': 'where is it?'}, - validate_at=valid_json_loc) - - # this string is OK - input = {'name': 'valid_uri', 'distance': 3, 'home_page': 'http://www.home.com'} - output = run_validator( - schema=schema_arg, - schema_file=schema_file_arg, - data=input, - validate_at=valid_json_loc) - self.assertEqual(output, input) - - # data files - for file_ext in ['json', 'yaml']: - file_path = os_path.join(json_validation_dir, 'invalid_uri.' + file_ext) - err_str = "'where is it\?' is not a 'uri'" - with self.assertRaisesRegex(ValidationError, err_str): - run_validator( - schema=schema_arg, - schema_file=schema_file_arg, - data_file=file_path, - validate_at=valid_json_loc) - - file_path = os_path.join(json_validation_dir, 'valid_uri.' + file_ext) - self.assertEqual( - run_validator( - schema=schema_arg, - schema_file=schema_file_arg, - data_file=file_path, - validate_at=valid_json_loc), - { - "name": "valid_uri", - "distance": 3, + tests = [ + { + 'input': { + 'name': 'valid_uri', + 'distance': 3, + "home_page": "http://json-validation.com:5000/this/is/valid" + }, + 'file': 'valid_uri', + 'output': { + 'name': 'valid_uri', + 'distance': 3, "home_page": "http://json-validation.com:5000/this/is/valid" } - ) + }, + { + 'input': {'name': 'invalid_uri', 'home_page': 'where is it?'}, + 'file': 'invalid_uri', + 'err_str': "'where is it\?' is not a 'uri'" + }, + ] + + self.execute_tests(schema_arg, schema_file_arg, tests) def test_date_format_validation(self, schema_arg=None, schema_file_arg=None): '''ensure that fancy date formats are correctly validated''' @@ -295,58 +326,30 @@ def test_date_format_validation(self, schema_arg=None, schema_file_arg=None): self.assertTrue(True) return - err_str = "'202001017' is not a 'date'" - with self.assertRaisesRegex(ValidationError, err_str): - input = {'name': 'whatever', 'distance': 1, 'date': '202001017'} - run_validator( - schema=schema_arg, - schema_file=schema_file_arg, - data=input, - validate_at=valid_json_loc) - - input = {'name': 'whatever', 'distance': 1, 'date': '2020-05-23'} - output = run_validator( - schema=schema_arg, - schema_file=schema_file_arg, - data=input, - validate_at=valid_json_loc) - self.assertEqual(input, output) - - # data files - for file_ext in ['json', 'yaml']: - # invalid type (number instead of string) - file_path = os_path.join(json_validation_dir, 'invalid_date_type.' + file_ext) - err_str = "20200606 is not of type 'string'" - with self.assertRaisesRegex(ValidationError, err_str): - run_validator( - schema=schema_arg, - schema_file=schema_file_arg, - data_file=file_path, - validate_at=valid_json_loc) - - # quoted string but not in the correct format - file_path = os_path.join(json_validation_dir, 'invalid_date.' + file_ext) - err_str = "'20200606' is not a 'date'" - with self.assertRaisesRegex(ValidationError, err_str): - run_validator( - schema=schema_arg, - schema_file=schema_file_arg, - data_file=file_path, - validate_at=valid_json_loc) - - file_path = os_path.join(json_validation_dir, 'valid_date.' + file_ext) - self.assertEqual( - run_validator( - schema=schema_arg, - schema_file=schema_file_arg, - data_file=file_path, - validate_at=valid_json_loc), - { + tests = [ + { + 'input': {'date': '20200606'}, + 'file': 'invalid_date', + 'err_str': "'20200606' is not a 'date'", + }, + { + 'input': {'date': 20200606}, + 'file': 'invalid_date_type', + 'err_str': "20200606 is not of type 'string'" + }, + { + 'input': {"name": "valid_date", "date": "2020-06-06", "distance": 3}, + 'file': 'valid_date', + 'output': { + **schema_defaults, "name": "valid_date", "date": "2020-06-06", "distance": 3, } - ) + } + ] + + self.execute_tests(schema_arg, schema_file_arg, tests) # pyyaml-specific issue: dates get automatically parsed into datetime objects (doh!) file_path = os_path.join(json_validation_dir, 'unquoted_date.yaml') @@ -359,72 +362,74 @@ def test_date_format_validation(self, schema_arg=None, schema_file_arg=None): validate_at=valid_json_loc) def test_array_validation(self, schema_arg=None, schema_file_arg=None): - """ check array validation works correctly """ + """ + check array validation and default population works correctly when refs are used + + The current implementation of the population of defaults does not allow defaults to be + populated if the property is a reference, i.e. + + 'properties': { + 'fruits': { + '$ref': '...' + } + } + + """ # skip if the test is not being called from test_json_validation if schema_arg is None and schema_file_arg is None: self.assertTrue(True) return - err_str = "'pear' is not of type 'array'" - with self.assertRaisesRegex(ValidationError, err_str): - run_validator( - schema=schema_arg, - schema_file=schema_file_arg, - data={'name': 'blank', 'distance': 3, 'fruits': 'pear'}, - validate_at=valid_json_loc) - - err_str = "1 is not of type 'string'" - with self.assertRaisesRegex(ValidationError, err_str): - run_validator( - schema=schema_arg, - schema_file=schema_file_arg, - data={'name': 'blank', 'distance': 3, 'fruits': ['pear', 1, 'peach']}, - validate_at=valid_json_loc) + # test the use of refs when populating defaults + tests = [ + { + 'fruits': fruit_ref, + 'name': 'using fruit.yaml -- array item is a ref', + 'output': { + 'params': { + 'name': 'name', + 'distance': 1, + 'fruits': [] + } + } + }, + { + # N.b. the default does not get populated in this case! + # This is a change from the expected functionality + 'fruits': fruits_array_ref, + 'name': 'using fruits_array.yaml -- the array is a ref', + 'output': { + 'params': { + 'name': 'name', + 'distance': 1, + } + } + }, + { + 'fruits': fruits_explicit, + 'name': 'with no references', + 'output': { + 'params': { + 'name': 'name', + 'distance': 1, + 'fruits': [] + } + } + } + ] - # this string is OK - input = {'name': 'valid_uri', 'distance': 3, 'fruits': ['pear', 'plum']} - output = run_validator( - schema=schema_arg, - schema_file=schema_file_arg, - data=input, - validate_at=valid_json_loc) - self.assertEqual(output, input) + for t in tests: + with self.subTest(desc=t['name']): + test_schema['properties']['params']['properties']['fruits'] = t['fruits'] + output = run_validator( + schema=test_schema, + data={'params': {'name': 'name'}} + ) + self.assertEqual(output, t['output']) - # data files - for file_ext in ['json', 'yaml']: - file_path = os_path.join(json_validation_dir, 'invalid_array.' + file_ext) - err_str = "'pear' is not of type 'array'" - with self.assertRaisesRegex(ValidationError, err_str): - run_validator( - schema=schema_arg, - schema_file=schema_file_arg, - data_file=file_path, - validate_at=valid_json_loc) - - for file_ext in ['json', 'yaml']: - file_path = os_path.join(json_validation_dir, 'invalid_array_items.' + file_ext) - err_str = "1 is not of type 'string'" - with self.assertRaisesRegex(ValidationError, err_str): - run_validator( - schema=schema_arg, - schema_file=schema_file_arg, - data_file=file_path, - validate_at=valid_json_loc) - - file_path = os_path.join(json_validation_dir, 'valid_array.' + file_ext) - self.assertEqual( - run_validator( - schema=schema_arg, - schema_file=schema_file_arg, - data_file=file_path, - validate_at=valid_json_loc), - { - "name": "valid_array", - "distance": 3, - 'fruits': ['pear', 'plum'], - } - ) + # restore the original value + test_schema['properties']['params']['properties']['fruits'] = fruits_explicit def test_schema_references(self): """Ensure referenced schemas, including those written in yaml, can be accessed.""" @@ -440,46 +445,47 @@ def test_schema_references(self): for path in path_list: for file_ext in ['json', 'yaml']: - file_path = os_path.join(*(test_data_dirs + ['schema_refs'] + path), 'edge.' + file_ext) - - # fails due to invalid data - with self.assertRaisesRegex(ValidationError, err_msg): - run_validator( - schema_file=file_path, - data=invalid_edge_data, + with self.subTest(file_ext=file_ext): + file_path = os_path.join(*(test_data_dirs + ['schema_refs'] + path), 'edge.' + file_ext) + + # fails due to invalid data + with self.assertRaisesRegex(ValidationError, err_msg): + run_validator( + schema_file=file_path, + data=invalid_edge_data, + ) + + # valid data + self.assertEqual( + run_validator( + schema_file=file_path, + data=valid_edge_data, + ), + valid_edge_data ) - # valid data - self.assertEqual( - run_validator( - schema_file=file_path, - data=valid_edge_data, - ), - valid_edge_data - ) - - # validate using the schema instead of the schema_file - with open(file_path) as fd: - contents = yaml.safe_load(fd) if file_ext == 'yaml' else json.load(fd) - - # if there is no $id in the schema, the ref resolver won't know - # where the schema file is located and will not resolve relative references - with self.assertRaisesRegex(RefResolutionError, 'No such file or directory'): - run_validator( - schema=contents, - data=valid_edge_data + # validate using the schema instead of the schema_file + with open(file_path) as fd: + contents = yaml.safe_load(fd) if file_ext == 'yaml' else json.load(fd) + + # if there is no $id in the schema, the ref resolver won't know + # where the schema file is located and will not resolve relative references + with self.assertRaisesRegex(RefResolutionError, 'No such file or directory'): + run_validator( + schema=contents, + data=valid_edge_data + ) + + # inject an $id with the current file path + contents['$id'] = file_path + self.assertEqual( + run_validator( + schema=contents, + data=valid_edge_data, + ), + valid_edge_data ) - # inject an $id with the current file path - contents['$id'] = file_path - self.assertEqual( - run_validator( - schema=contents, - data=valid_edge_data, - ), - valid_edge_data - ) - def test_complex_schema_references(self): """test validation with complex references that reference other references""" @@ -503,22 +509,23 @@ def test_complex_schema_references(self): err_msg = "'whatever' is not valid under any of the given schemas" for file_ext in ['json', 'yaml']: - file_path = os_path.join( - *(test_data_dirs + ['schema_refs', 'level_1']), - 'test_object.' + file_ext - ) - - # data fails validation - with self.assertRaisesRegex(ValidationError, err_msg): - run_validator( - schema_file=file_path, - data=invalid_data, + with self.subTest(file_ext=file_ext): + file_path = os_path.join( + *(test_data_dirs + ['schema_refs', 'level_1']), + 'test_object.' + file_ext ) - self.assertEqual( - run_validator( - schema_file=file_path, - data=valid_data, - ), - valid_data - ) + # data fails validation + with self.assertRaisesRegex(ValidationError, err_msg): + run_validator( + schema_file=file_path, + data=invalid_data, + ) + + self.assertEqual( + run_validator( + schema_file=file_path, + data=valid_data, + ), + valid_data + ) diff --git a/relation_engine_server/test/test_spec_loader.py b/relation_engine_server/test/test_spec_loader.py index 0833e5e9..fdefdea1 100644 --- a/relation_engine_server/test/test_spec_loader.py +++ b/relation_engine_server/test/test_spec_loader.py @@ -1,5 +1,7 @@ """ -Test JSON validation functions +Test spec_loader functions + +These tests run within the re_api docker image. """ import unittest import os.path as os_path @@ -16,15 +18,14 @@ def setUpClass(cls): cls.test_dir = os_path.join('/app', 'relation_engine_server', 'test') cls.test_spec_dir = os_path.join(cls.test_dir, 'spec_release', 'sample_spec_release') - config = get_config() - cls.repo_path = config['spec_paths']['repo'] - for key in config['spec_paths'].keys(): - if cls.repo_path in config['spec_paths'][key]: - config['spec_paths'][key] = config['spec_paths'][key].replace( + cls.config = get_config() + cls.repo_path = cls.config['spec_paths']['repo'] + for key in cls.config['spec_paths'].keys(): + if cls.repo_path in cls.config['spec_paths'][key]: + cls.config['spec_paths'][key] = cls.config['spec_paths'][key].replace( cls.repo_path, cls.test_spec_dir ) - cls.config = config @classmethod def tearDownClass(cls): @@ -151,9 +152,10 @@ def test_get_schemas_of_various_types(self): ] for schema in schema_type_list: - self.test_run_spec_loading_tests(schema['schema_type_names'], schema['example']) - if 'names' in schema: - self.test_get_names(schema['schema_type_names'], schema['names']) + with self.subTest(schema=schema['schema_type_names'][0]): + self.test_run_spec_loading_tests(schema['schema_type_names'], schema['example']) + if 'names' in schema: + self.test_get_names(schema['schema_type_names'], schema['names']) def test_non_existent_schema(self): diff --git a/spec/stored_queries/djornl/djornl_fetch_all.yaml b/spec/stored_queries/djornl/djornl_fetch_all.yaml index 90757835..88295928 100644 --- a/spec/stored_queries/djornl/djornl_fetch_all.yaml +++ b/spec/stored_queries/djornl/djornl_fetch_all.yaml @@ -5,7 +5,17 @@ params: additionalProperties: false properties: edge_types: - $ref: "../../datasets/djornl/edge_types_filter.yaml" + title: Edge Types + description: Edge types to filter on + type: array + items: + $ref: ../../datasets/djornl/edge_type.yaml + default: [] + uniqueItems: true + examples: + - ['AraNetv2-HT_high-throughput-ppi', 'AraNetv2-LC_lit-curated-ppi'] + - ['AraGWAS-Phenotype_Associations'] + - [] query: | LET nodes = ( FOR v IN djornl_node diff --git a/spec/stored_queries/djornl/djornl_fetch_clusters.yaml b/spec/stored_queries/djornl/djornl_fetch_clusters.yaml index 55222225..e39f82b4 100644 --- a/spec/stored_queries/djornl/djornl_fetch_clusters.yaml +++ b/spec/stored_queries/djornl/djornl_fetch_clusters.yaml @@ -10,14 +10,29 @@ params: title: Cluster IDs description: Cluster IDs, in the form "clustering_system_name:cluster_id" items: - $ref: "../../datasets/djornl/definitions.yaml#definitions/cluster_id" + $ref: ../../datasets/djornl/definitions.yaml#definitions/cluster_id minItems: 1 uniqueItems: true examples: [['markov_i2:5', 'markov_i6:2'],['markov_i6:1']] distance: - $ref: "../../datasets/distance.yaml" + type: integer + title: Traversal Distance + description: How many hops to find neighbors and neighbors-of-neighbors + default: 1 + minimum: 0 + maximum: 100 edge_types: - $ref: "../../datasets/djornl/edge_types_filter.yaml" + title: Edge Types + description: Edge types to filter on + type: array + items: + $ref: ../../datasets/djornl/edge_type.yaml + default: [] + uniqueItems: true + examples: + - ['AraNetv2-HT_high-throughput-ppi', 'AraNetv2-LC_lit-curated-ppi'] + - ['AraGWAS-Phenotype_Associations'] + - [] query: | LET node_ids = ( FOR n IN djornl_node diff --git a/spec/stored_queries/djornl/djornl_fetch_genes.yaml b/spec/stored_queries/djornl/djornl_fetch_genes.yaml index d8b1e008..87045a08 100644 --- a/spec/stored_queries/djornl/djornl_fetch_genes.yaml +++ b/spec/stored_queries/djornl/djornl_fetch_genes.yaml @@ -9,13 +9,29 @@ params: type: array title: Gene Keys items: - $ref: "../../datasets/djornl/definitions.yaml#definitions/djornl_node/_key" + $ref: ../../datasets/djornl/definitions.yaml#definitions/djornl_node/_key minItems: 1 + uniqueItems: true examples: [["AT1G01010"],["AT1G01020","AT1G01070"]] distance: - $ref: "../../datasets/distance.yaml" + type: integer + title: Traversal Distance + description: How many hops to find neighbors and neighbors-of-neighbors + default: 1 + minimum: 0 + maximum: 100 edge_types: - $ref: "../../datasets/djornl/edge_types_filter.yaml" + title: Edge Types + description: Edge types to filter on + type: array + items: + $ref: ../../datasets/djornl/edge_type.yaml + default: [] + uniqueItems: true + examples: + - ['AraNetv2-HT_high-throughput-ppi', 'AraNetv2-LC_lit-curated-ppi'] + - ['AraGWAS-Phenotype_Associations'] + - [] query: | LET node_ids = ( FOR n IN djornl_node diff --git a/spec/stored_queries/djornl/djornl_fetch_phenotypes.yaml b/spec/stored_queries/djornl/djornl_fetch_phenotypes.yaml index e1d2a426..8ae92892 100644 --- a/spec/stored_queries/djornl/djornl_fetch_phenotypes.yaml +++ b/spec/stored_queries/djornl/djornl_fetch_phenotypes.yaml @@ -9,13 +9,29 @@ params: type: array title: Phenotype Keys items: - $ref: "../../datasets/djornl/definitions.yaml#definitions/djornl_node/_key" + $ref: ../../datasets/djornl/definitions.yaml#definitions/djornl_node/_key minItems: 1 + uniqueItems: true examples: [["As2"],["As2", "Na23"]] distance: - $ref: "../../datasets/distance.yaml" + type: integer + title: Traversal Distance + description: How many hops to find neighbors and neighbors-of-neighbors + default: 1 + minimum: 0 + maximum: 100 edge_types: - $ref: "../../datasets/djornl/edge_types_filter.yaml" + title: Edge Types + description: Edge types to filter on + type: array + items: + $ref: ../../datasets/djornl/edge_type.yaml + default: [] + uniqueItems: true + examples: + - ['AraNetv2-HT_high-throughput-ppi', 'AraNetv2-LC_lit-curated-ppi'] + - ['AraGWAS-Phenotype_Associations'] + - [] query: | LET node_ids = ( FOR n IN djornl_node diff --git a/spec/stored_queries/djornl/djornl_search_nodes.yaml b/spec/stored_queries/djornl/djornl_search_nodes.yaml index 1279a4bb..d318781d 100644 --- a/spec/stored_queries/djornl/djornl_search_nodes.yaml +++ b/spec/stored_queries/djornl/djornl_search_nodes.yaml @@ -10,9 +10,24 @@ params: title: Search text examples: ['GO:0005515', 'organelle machinery'] distance: - $ref: "../../datasets/distance.yaml" + type: integer + title: Traversal Distance + description: How many hops to find neighbors and neighbors-of-neighbors + default: 1 + minimum: 0 + maximum: 100 edge_types: - $ref: "../../datasets/djornl/edge_types_filter.yaml" + title: Edge Types + description: Edge types to filter on + type: array + items: + $ref: ../../datasets/djornl/edge_type.yaml + default: [] + uniqueItems: true + examples: + - ['AraNetv2-HT_high-throughput-ppi', 'AraNetv2-LC_lit-curated-ppi'] + - ['AraGWAS-Phenotype_Associations'] + - [] query: | LET node_ids = ( FOR g IN djornl_node_view diff --git a/spec/test/collections/test_djornl.py b/spec/test/collections/test_djornl.py index 39008fbc..f2ea6511 100644 --- a/spec/test/collections/test_djornl.py +++ b/spec/test/collections/test_djornl.py @@ -1,23 +1,43 @@ """ Tests for the Dan Jacobson ORNL Arabidopsis collection schemas. -These tests ensure that specific elements of the collection schemas validate correctly. +Tests to ensure that specific elements of the collection schemas validate correctly. +These tests run within the re_api docker image. """ import unittest - -from spec.test.helpers import check_spec_test_env +from os.path import join as os_path_join +from relation_engine_server.utils.config import get_config from relation_engine_server.utils.spec_loader import get_schema from relation_engine_server.utils.json_validation import get_schema_validator from jsonschema.exceptions import ValidationError +_BASE_DIR = os_path_join('/app', 'spec') + class Test_DJORNL_Collections(unittest.TestCase): @classmethod def setUpClass(cls): cls.maxDiff = None - check_spec_test_env() + cls.config = get_config() + cls.repo_path = cls.config['spec_paths']['repo'] + for key in cls.config['spec_paths'].keys(): + if cls.repo_path in cls.config['spec_paths'][key]: + cls.config['spec_paths'][key] = cls.config['spec_paths'][key].replace( + cls.repo_path, + _BASE_DIR + ) + + @classmethod + def tearDownClass(cls): + # undo all the config changes + for key in cls.config['spec_paths'].keys(): + if _BASE_DIR in cls.config['spec_paths'][key]: + cls.config['spec_paths'][key] = cls.config['spec_paths'][key].replace( + _BASE_DIR, + cls.repo_path + ) def test_node(self, query_name=None, test_data=None): """ ensure node data validates correctly """ diff --git a/spec/test/djornl/results.json b/spec/test/djornl/results.json index 12f85bfb..9d397848 100644 --- a/spec/test/djornl/results.json +++ b/spec/test/djornl/results.json @@ -230,26 +230,26 @@ } }, { - "params": { "keys": ["Mary Poppins"], "distance": 0, "edge_types": [] }, + "params": { "keys": ["Mary Poppins"], "distance": 0 }, "results": {"nodes": [], "edges": []} }, { - "params": { "keys": ["Mary Poppins"], "distance": 1, "edge_types": [] }, + "params": { "keys": ["Mary Poppins"], "distance": 1 }, "results": {"nodes": [], "edges": []} }, { - "params": { "keys": ["Mary Poppins"], "distance": 5, "edge_types": [] }, + "params": { "keys": ["Mary Poppins"], "distance": 5 }, "results": {"nodes": [], "edges": []} }, { - "params": { "keys": ["AT1G01010"], "distance": 0, "edge_types": [] }, + "params": { "keys": ["AT1G01010"], "distance": 0 }, "results": { "nodes": ["AT1G01010"], "edges": [] } }, { - "params": { "keys": ["AT1G01010"], "distance": 1, "edge_types": [] }, + "params": { "keys": ["AT1G01010"], "distance": 1 }, "results": { "nodes": [ "AT1G01010", @@ -266,7 +266,7 @@ } }, { - "params": { "keys": ["AT1G01010"], "distance": 5, "edge_types": [] }, + "params": { "keys": ["AT1G01010"], "distance": 5 }, "results": { "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060"], "edges": [ @@ -283,7 +283,7 @@ } }, { - "params": { "keys": ["AT1G01010"], "distance": 5, "edge_types": [] }, + "params": { "keys": ["AT1G01010"], "distance": 5 }, "results": { "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060"], "edges": [ @@ -300,14 +300,14 @@ } }, { - "params": {"keys": ["AT1G01020", "AT1G01070"], "distance": 0, "edge_types": [] }, + "params": {"keys": ["AT1G01020", "AT1G01070"], "distance": 0 }, "results": { "nodes": ["AT1G01020", "AT1G01070"], "edges": [] } }, { - "params": {"keys": ["AT1G01020", "AT1G01070"], "distance": 1, "edge_types": [] }, + "params": {"keys": ["AT1G01020", "AT1G01070"], "distance": 1 }, "results": { "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01070"], "edges": [ @@ -328,7 +328,7 @@ } }, { - "params": {"keys": ["AT1G01020", "AT1G01070"], "distance": 5, "edge_types": [] }, + "params": {"keys": ["AT1G01020", "AT1G01070"], "distance": 5 }, "results": { "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060", "AT1G01070"], "edges": [ @@ -372,26 +372,26 @@ } }, { - "params": {"keys": ["Mary Poppins"], "distance": 0, "edge_types": []}, + "params": {"keys": ["Mary Poppins"], "distance": 0}, "results": {"nodes": [], "edges": []} }, { - "params": {"keys": ["Mary Poppins"], "distance": 1, "edge_types": []}, + "params": {"keys": ["Mary Poppins"], "distance": 1}, "results": {"nodes": [], "edges": []} }, { - "params": {"keys": ["Mary Poppins"], "distance": 5, "edge_types": []}, + "params": {"keys": ["Mary Poppins"], "distance": 5}, "results": {"nodes": [], "edges": []} }, { - "params": {"keys": ["As2"], "distance": 0, "edge_types": []}, + "params": {"keys": ["As2"], "distance": 0}, "results": { "nodes": ["As2"], "edges": [] } }, { - "params": {"keys": ["As2"], "distance": 1, "edge_types": []}, + "params": {"keys": ["As2"], "distance": 1}, "results": { "nodes": ["As2", "AT1G01020", "AT1G01040"], "edges": [ @@ -401,7 +401,7 @@ } }, { - "params": {"keys": ["As2"], "distance": 5, "edge_types": []}, + "params": {"keys": ["As2"], "distance": 5}, "results": { "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060"], "edges": [ @@ -418,14 +418,14 @@ } }, { - "params": {"keys": ["As2", "Na23"], "distance": 0, "edge_types": []}, + "params": {"keys": ["As2", "Na23"], "distance": 0}, "results": { "nodes": ["As2", "Na23"], "edges": [] } }, { - "params": {"keys": ["As2", "Na23"], "distance": 1, "edge_types": []}, + "params": {"keys": ["As2", "Na23"], "distance": 1}, "results": { "nodes": ["As2", "Na23", "AT1G01020", "AT1G01040"], "edges": [ @@ -435,7 +435,7 @@ } }, { - "params": {"keys": ["As2", "Na23"], "distance": 5, "edge_types": []}, + "params": {"keys": ["As2", "Na23"], "distance": 5}, "results": { "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060", "Na23"], "edges": [ @@ -452,7 +452,7 @@ } }, { - "params": {"keys": ["As2", "Na23"], "distance": 0, "edge_types": []}, + "params": {"keys": ["As2", "Na23"], "distance": 0}, "results": { "nodes": ["As2", "Na23"], "edges": [] @@ -487,26 +487,26 @@ ], "djornl_search_nodes": [ { - "params": {"search_text": "Mary Poppins", "distance": 0, "edge_types": []}, + "params": {"search_text": "Mary Poppins", "distance": 0}, "results": {"nodes": [], "edges": []} }, { - "params": {"search_text": "Mary Poppins", "distance": 1, "edge_types": []}, + "params": {"search_text": "Mary Poppins", "distance": 1}, "results": {"nodes": [], "edges": []} }, { - "params": {"search_text": "Mary Poppins", "distance": 5, "edge_types": []}, + "params": {"search_text": "Mary Poppins", "distance": 5}, "results": {"nodes": [], "edges": []} }, { - "params": {"search_text": "GO:0005515", "distance": 0, "edge_types": []}, + "params": {"search_text": "GO:0005515", "distance": 0}, "results": { "nodes": ["AT1G01040", "AT1G01090"], "edges": [] } }, { - "params": {"search_text": "GO:0005515", "distance": 1, "edge_types": []}, + "params": {"search_text": "GO:0005515", "distance": 1}, "results": { "nodes": ["As2", "AT1G01010", "AT1G01040", "AT1G01080", "AT1G01090"], "edges": [ @@ -518,7 +518,7 @@ } }, { - "params": {"search_text": "GO:0005515", "distance": 5, "edge_types": []}, + "params": {"search_text": "GO:0005515", "distance": 5}, "results": { "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060", "AT1G01080", "AT1G01090"], "edges": [ @@ -592,26 +592,26 @@ } }, { - "params": {"cluster_ids": ["MaryPoppins:1"], "distance": 0, "edge_types": []}, + "params": {"cluster_ids": ["MaryPoppins:1"], "distance": 0}, "results": {"nodes": [], "edges": []} }, { - "params": {"cluster_ids": ["MaryPoppins:1"], "distance": 1, "edge_types": []}, + "params": {"cluster_ids": ["MaryPoppins:1"], "distance": 1}, "results": {"nodes": [], "edges": []} }, { - "params": {"cluster_ids": ["MaryPoppins:1"], "distance": 5, "edge_types": []}, + "params": {"cluster_ids": ["MaryPoppins:1"], "distance": 5}, "results": {"nodes": [], "edges": []} }, { - "params": {"cluster_ids": ["markov_i6:1"], "distance": 0, "edge_types": []}, + "params": {"cluster_ids": ["markov_i6:1"], "distance": 0}, "results": { "nodes": ["AT1G01040", "AT1G01090"], "edges": [] } }, { - "params": {"cluster_ids": ["markov_i6:1"], "distance": 1, "edge_types": []}, + "params": {"cluster_ids": ["markov_i6:1"], "distance": 1}, "results": { "nodes": ["As2", "AT1G01010", "AT1G01040", "AT1G01080", "AT1G01090"], "edges": [ @@ -623,7 +623,7 @@ } }, { - "params": {"cluster_ids": ["markov_i6:1"], "distance": 5, "edge_types": []}, + "params": {"cluster_ids": ["markov_i6:1"], "distance": 5}, "results": { "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060", "AT1G01080", "AT1G01090"], "edges": [ @@ -641,14 +641,14 @@ } }, { - "params": {"cluster_ids": ["markov_i2:5", "markov_i6:2"], "distance": 0, "edge_types": []}, + "params": {"cluster_ids": ["markov_i2:5", "markov_i6:2"], "distance": 0}, "results": { "nodes": ["AT1G01020", "AT1G01070"], "edges": [] } }, { - "params": {"cluster_ids": ["markov_i2:5", "markov_i6:2"], "distance": 1, "edge_types": []}, + "params": {"cluster_ids": ["markov_i2:5", "markov_i6:2"], "distance": 1}, "results": { "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01070"], "edges": [ @@ -659,7 +659,7 @@ } }, { - "params": {"cluster_ids": ["markov_i2:5", "markov_i6:2"], "distance": 5, "edge_types": []}, + "params": {"cluster_ids": ["markov_i2:5", "markov_i6:2"], "distance": 5}, "results": { "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060", "AT1G01070"], "edges": [ diff --git a/spec/test/stored_queries/test_djornl.py b/spec/test/stored_queries/test_djornl.py index 8c27e719..94a57680 100644 --- a/spec/test/stored_queries/test_djornl.py +++ b/spec/test/stored_queries/test_djornl.py @@ -1,5 +1,7 @@ """ Tests for the Dan Jacobson ORNL Arabidopsis stored queries. + +These tests run within the re_api docker image, and require access to the ArangoDB, auth, and workspace images. """ import json import unittest diff --git a/spec/test/stored_queries/test_list_test_vertices.py b/spec/test/stored_queries/test_list_test_vertices.py index 086c2b2e..1644b600 100644 --- a/spec/test/stored_queries/test_list_test_vertices.py +++ b/spec/test/stored_queries/test_list_test_vertices.py @@ -1,3 +1,10 @@ +""" +Test the 'list_test_vertices' stored query (see +relation_engine_server/test/spec_release/sample_spec_release/stored_queries/test for the query). + +These tests run within the re_api docker image, and require access to the ArangoDB, auth, and workspace images. + +""" import unittest import requests diff --git a/spec/test/stored_queries/test_ncbi_tax.py b/spec/test/stored_queries/test_ncbi_tax.py index 6e3a0435..9daf5550 100644 --- a/spec/test/stored_queries/test_ncbi_tax.py +++ b/spec/test/stored_queries/test_ncbi_tax.py @@ -1,5 +1,7 @@ """ Tests for the ncbi taxonomy stored queries. + +These tests require access to the ArangoDB, auth, and workspace images. """ import json import time diff --git a/spec/test/stored_queries/test_taxonomy.py b/spec/test/stored_queries/test_taxonomy.py index a6075548..27025b18 100644 --- a/spec/test/stored_queries/test_taxonomy.py +++ b/spec/test/stored_queries/test_taxonomy.py @@ -1,5 +1,7 @@ """ Tests for the ncbi taxonomy stored queries. + +These tests run within the re_api docker image, and require access to the ArangoDB, auth, and workspace images. """ import json import time diff --git a/spec/test/stored_queries/test_ws.py b/spec/test/stored_queries/test_ws.py index c8796a94..15672cf7 100644 --- a/spec/test/stored_queries/test_ws.py +++ b/spec/test/stored_queries/test_ws.py @@ -1,5 +1,8 @@ """ -Tests for workspace workspace stored queries under the ws* namespace +Tests for workspace stored queries under the ws* namespace + + +These tests run within the re_api docker image, and require access to the ArangoDB, auth, and workspace images. """ import unittest import json diff --git a/spec/test/test_manifest_schema.py b/spec/test/test_manifest_schema.py index 4237624d..c00eeb77 100644 --- a/spec/test/test_manifest_schema.py +++ b/spec/test/test_manifest_schema.py @@ -1,7 +1,9 @@ """ Tests for manifest.schema.json -Ensure that the manifest schema correctly validates data +Ensure that the manifest schema correctly validates data. + +These tests run within the re_api docker image. """ import unittest import os.path as os_path diff --git a/spec/test/test_validate.py b/spec/test/test_validate.py index e104a6c5..4c6dacaf 100644 --- a/spec/test/test_validate.py +++ b/spec/test/test_validate.py @@ -1,5 +1,7 @@ """ Tests for the schema validation functions + +These tests run within the re_api docker image, and require access to the ArangoDB image for validation of AQL strings. """ import unittest import os.path as os_path From fa37e611aba3c81215a249da2394ad1929f9467c Mon Sep 17 00:00:00 2001 From: Sumin Date: Thu, 3 Sep 2020 16:02:38 -0700 Subject: [PATCH 580/732] silva spec --- .gitignore | 1 + spec/collections/silva/README.md | 7 +++ .../silva/silva_child_of_taxon.yaml | 25 +++++++++ spec/collections/silva/silva_taxon.yaml | 53 +++++++++++++++++++ 4 files changed, 86 insertions(+) create mode 100644 spec/collections/silva/README.md create mode 100644 spec/collections/silva/silva_child_of_taxon.yaml create mode 100644 spec/collections/silva/silva_taxon.yaml diff --git a/.gitignore b/.gitignore index 4a0a770f..8264d26b 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ coverage_report/ .coverage *.egg-info/ +.*.sw[a-z] diff --git a/spec/collections/silva/README.md b/spec/collections/silva/README.md new file mode 100644 index 00000000..415d1202 --- /dev/null +++ b/spec/collections/silva/README.md @@ -0,0 +1,7 @@ +# SILVA rRNA Database Project + +KBase Relation Engine schemas for SILVA taxonomy data + +References: + +* https://www.arb-silva.de/ diff --git a/spec/collections/silva/silva_child_of_taxon.yaml b/spec/collections/silva/silva_child_of_taxon.yaml new file mode 100644 index 00000000..d86d4a17 --- /dev/null +++ b/spec/collections/silva/silva_child_of_taxon.yaml @@ -0,0 +1,25 @@ +name: silva_child_of_taxon +type: edge +delta: true + +indexes: + - type: persistent + fields: [id, expired, created] + - type: persistent + fields: [expired, created, last_version] + +schema: + "$schema": http://json-schema.org/draft-07/schema# + type: object + required: [from, to, id] + description: Edges in the SILVA taxonomy tree in direction from leaf to root. + properties: + id: + type: string + description: The id of the edge, which is identical to the edge's `from` field + from: + type: string + description: The taxon id of the edge's source node + to: + type: string + description: The taxon id of the edge's sink node diff --git a/spec/collections/silva/silva_taxon.yaml b/spec/collections/silva/silva_taxon.yaml new file mode 100644 index 00000000..23c8738b --- /dev/null +++ b/spec/collections/silva/silva_taxon.yaml @@ -0,0 +1,53 @@ +name: silva_taxon +type: vertex +delta: true + +indexes: + - type: fulltext + fields: [name] + - type: persistent + fields: [id, expired, created] + - type: persistent + fields: [expired, created, last_version] + +schema: + "$schema": http://json-schema.org/draft-07/schema# + type: object + description: Template for a vertex entry in the SILVA SSU taxonomy tree. + required: [id, name, rank] + properties: + id: + type: string + description: For taxon nodes, the SILVA taxon id. These will be "mostly stable in upcoming + releases" as of SILVA 138. For sequence nodes, the INSDC primary accession identifier, and + the start and stop of the 16S gene within the entry. See SILVA documentation for more + details. + examples: ['2', '44', '50000', 'CP010838.1980157.1981698'] + name: + type: string + description: For taxon nodes, the name of the taxon. For sequence nodes, the organism name + given to the sequence. + examples: ['Ewamiania TS0513', 'Methyloligellaceae', 'BCP clade', 'uncultured', + 'Bordetella pertussis'] + rank: + type: string + description: SILVA's taxonomic rank, with addition of `root_rank` and `sequence` for + root and sequence nodes, respectively + examples: ['superfamily', 'subphylum', 'subfamily', 'phylum', 'order', 'major_clade', + 'infraclass', 'suborder', 'family', 'superkingdom', 'domain', 'superphylum', 'superorder', + 'superclass', 'infraphylum', 'subclass', 'genus', 'class', 'kingdom', 'subkingdom', + 'root_rank', 'sequence'] + release: + type: number + description: SILVA release number, primarily for taxon nodes + examples: [138.1, 138, 132, 128, 123.1, 123, 119.1, 119] + sequence: + type: string + description: rRNA sequence for sequence nodes + dataset: + type: array + items: string + description: The datasets that a sequence node is from. Composed of 'parc', 'ref', and + 'nr99', corresponding to the Parc, Ref and Ref NR99 datasets, respectively. + Parc > Ref > NR99, with > denoting superset. + examples: [['parc'], ['parc', 'ref'], ['parc', 'ref', 'nr99']] From 305e1175b276d636d45245fa9bfa80028e683255 Mon Sep 17 00:00:00 2001 From: Sumin Date: Fri, 4 Sep 2020 10:46:56 -0700 Subject: [PATCH 581/732] example to enum --- spec/collections/silva/silva_taxon.yaml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/spec/collections/silva/silva_taxon.yaml b/spec/collections/silva/silva_taxon.yaml index 23c8738b..8e01ed41 100644 --- a/spec/collections/silva/silva_taxon.yaml +++ b/spec/collections/silva/silva_taxon.yaml @@ -31,9 +31,9 @@ schema: 'Bordetella pertussis'] rank: type: string - description: SILVA's taxonomic rank, with addition of `root_rank` and `sequence` for + description: SILVA's taxonomic rank, with addition of 'root_rank' and 'sequence' for root and sequence nodes, respectively - examples: ['superfamily', 'subphylum', 'subfamily', 'phylum', 'order', 'major_clade', + enum: ['superfamily', 'subphylum', 'subfamily', 'phylum', 'order', 'major_clade', 'infraclass', 'suborder', 'family', 'superkingdom', 'domain', 'superphylum', 'superorder', 'superclass', 'infraphylum', 'subclass', 'genus', 'class', 'kingdom', 'subkingdom', 'root_rank', 'sequence'] @@ -46,8 +46,9 @@ schema: description: rRNA sequence for sequence nodes dataset: type: array - items: string + items: + type: string description: The datasets that a sequence node is from. Composed of 'parc', 'ref', and 'nr99', corresponding to the Parc, Ref and Ref NR99 datasets, respectively. - Parc > Ref > NR99, with > denoting superset. - examples: [['parc'], ['parc', 'ref'], ['parc', 'ref', 'nr99']] + Parc > Ref > Ref NR99, with > denoting superset. + enum: [['parc'], ['parc', 'ref'], ['parc', 'ref', 'nr99']] From 83290f95379e7badae15d107eabacd5be52403bb Mon Sep 17 00:00:00 2001 From: Sumin Date: Tue, 8 Sep 2020 18:53:32 -0700 Subject: [PATCH 582/732] test silva node/edge json schema --- spec/collections/silva/test/test.py | 235 ++++++++++++++++++++++++++++ 1 file changed, 235 insertions(+) create mode 100644 spec/collections/silva/test/test.py diff --git a/spec/collections/silva/test/test.py b/spec/collections/silva/test/test.py new file mode 100644 index 00000000..f17489cf --- /dev/null +++ b/spec/collections/silva/test/test.py @@ -0,0 +1,235 @@ +from yaml import safe_load +from jsonschema import validate +from jsonschema.exceptions import ValidationError +import os +import unittest + +cwd = os.path.dirname(os.path.abspath(__file__)) +node_yaml_flpth = os.path.join('..', 'silva_taxon.yaml') +edge_yaml_flpth = os.path.join('..', 'silva_child_of_taxon.yaml') + +class SILVATreeJSONSchemaTest(unittest.TestCase): + ''' + Test the API of the nodes and edges representing SILVA taxonomy tree + All information is from SILVA (arb-silva.de) + See their documentation for more details + ''' + + @classmethod + def setUpClass(cls): + with open(node_yaml_flpth) as fh: + cls.schema_node = safe_load(fh)['schema'] + with open(edge_yaml_flpth) as fh: + cls.schema_edge = safe_load(fh)['schema'] + + cls.nodes_valid = [ + { + 'id': '0', # Root's info is assigned by API, since SILVA doesn't seem to have a root node + 'name': 'Root', + 'rank': 'root_rank', + },{ + 'id': '2', + 'name': 'Archea', + 'rank': 'domain', + },{ + 'id': '47023', + 'name': 'BCP clade', + 'rank': 'major_clade', + 'release': 138, + },{ + 'id': '42919', + 'name': 'Asgardarchaeota', + 'rank': 'phylum', + 'release': 138, + },{ + 'id': '4155', + 'name': 'Amb-18S-504', + 'rank': 'order', + 'release': 119.1, + },{ + 'id': '47162', + 'name': 'Japygoidea', + 'rank': 'superfamily', + 'release': 138, + },{ + 'id': '47142', + 'name': 'Tantulocarida', + 'rank': 'subclass', + 'release': 138, + },{ + 'id': 'HM032797.1.1344', + 'name': 'Yeosuana aromativorans', + 'rank': 'sequence', + 'sequence': 'gattaca', + 'dataset': ['parc', 'ref', 'nr99'] + },{ + 'id': 'CRQV01000019.5091.6588', + 'name': 'Streptococcus penumoniae', + 'rank': 'sequence', + 'sequence': 'gattaca', + 'dataset': ['parc', 'ref'], # actually in nr99 + },{ + 'id': 'HQ216288.1.1242', + 'name': 'uncultured bacterium', + 'rank': 'sequence', + 'sequence': 'gattaca', + 'dataset': ['parc'], # actually in nr99 + } + ] + + cls.nodes_invalid = [ + { + # missing + 'id': 'id', + 'name': 'name', + },{ + # missing + 'id': 'id', + 'rank': 'kingdom', + },{ + # missing + 'name': 'name', + 'rank': 'major_clade', + },{ + # type + 'id': 1, + 'name': 'name', + 'rank': 'subphylum', + },{ + # type + 'id': 'id', + 'name': 1, + 'rank': 'subkingdom', + },{ + # type + 'id': 'id', + 'name': 'name', + 'rank': 1, + },{ + # type + 'id': 'id', + 'name': 'name', + 'rank': 'infraphylum', + 'release': '119', + },{ + # type + 'id': 'id', + 'name': 'name', + 'rank': 'sequence', + 'sequence': 1, + },{ + # type + 'id': 'id', + 'name': 'name', + 'rank': 'subphylum', + 'dataset': 1, + },{ + # enum + 'id': 'id', + 'name': 'name', + 'rank': 'fictional_rank', + },{ + # enum + 'id': 'id', + 'name': 'name', + 'rank': 'superclass', + 'dataset': ['nr99', 'ref', 'parc'], # array in wrong order + } + ] + + cls.nodes_errors = [ + "'rank' is a required property", + "'name' is a required property", + "'id' is a required property", + "1 is not of type 'string'", + "1 is not of type 'string'", + "1 is not of type 'string'", + "'119' is not of type 'number'", + "1 is not of type 'string'", + "1 is not of type 'array'", + "'fictional_rank' is not one of ['superfamily', 'subphylum', 'subfamily', 'phylum', 'order', 'major_clade', 'infraclass', 'suborder', 'family', 'superkingdom', 'domain', 'superphylum', 'superorder', 'superclass', 'infraphylum', 'subclass', 'genus', 'class', 'kingdom', 'subkingdom', 'root_rank', 'sequence']", + "['nr99', 'ref', 'parc'] is not one of [['parc'], ['parc', 'ref'], ['parc', 'ref', 'nr99']]", + ] + + cls.edges_valid = [ + { + 'id': '2', + 'from': '2', + 'to': '0', + },{ + 'id': '42919', + 'from': '42919', + 'to': '2', + },{ + 'id': 'HM032797.1.1344', + 'from': 'HM032797.1.1344', + 'to': '44300', + },{ + 'id': 'CRQV01000019.5091.6588', + 'from': 'CRQV01000019.5091.6588', + 'to': '1853', + }, + ] + + cls.edges_invalid = [ + { + # missing + 'from': '2', + 'to': '0', + },{ + # missing + 'id': '2', + 'to': '0', + },{ + # missing + 'id': '2', + 'from': '2', + },{ + # type + 'id': 2, + 'from': '2', + 'to': '0', + },{ + # type + 'id': '2', + 'from': 2, + 'to': '0', + },{ + # type + 'id': '2', + 'from': '2', + 'to': 0, + }, + + ] + + cls.edges_errors = [ + "'id' is a required property", + "'from' is a required property", + "'to' is a required property", + "2 is not of type 'string'", + "2 is not of type 'string'", + "0 is not of type 'string'", + ] + + + def _test_type(self, schema, valid, invalid, errors=None): + for inst in valid: + validate(inst, schema=schema) + + for inst, error in zip(invalid, errors): + with self.assertRaises(ValidationError) as cm: + validate(inst, schema=schema) + msg = str(cm.exception).split('\n')[0] + + print(msg) + self.assertTrue(msg == error, '`%s` vs `%s`' % (msg, str(cm.exception))) + + + def test(self): + self._test_type(self.schema_node, self.nodes_valid, self.nodes_invalid, self.nodes_errors) + self._test_type(self.schema_edge, self.edges_valid, self.edges_invalid, self.edges_errors) + + +if __name__ == '__main__': + unittest.main() From a60df8e281e89faa853b6af162663c5ff8dcfdbe Mon Sep 17 00:00:00 2001 From: Sumin Date: Wed, 9 Sep 2020 14:55:32 -0700 Subject: [PATCH 583/732] move test, pair error with json inst, data source yaml --- .gitignore | 1 - spec/collections/silva/test/test.py | 235 ----------------------- spec/data_sources/silva_taxonomy.yaml | 6 + spec/test/collections/test_silva.py | 266 ++++++++++++++++++++++++++ 4 files changed, 272 insertions(+), 236 deletions(-) delete mode 100644 spec/collections/silva/test/test.py create mode 100644 spec/data_sources/silva_taxonomy.yaml create mode 100644 spec/test/collections/test_silva.py diff --git a/.gitignore b/.gitignore index 8264d26b..4a0a770f 100644 --- a/.gitignore +++ b/.gitignore @@ -12,4 +12,3 @@ coverage_report/ .coverage *.egg-info/ -.*.sw[a-z] diff --git a/spec/collections/silva/test/test.py b/spec/collections/silva/test/test.py deleted file mode 100644 index f17489cf..00000000 --- a/spec/collections/silva/test/test.py +++ /dev/null @@ -1,235 +0,0 @@ -from yaml import safe_load -from jsonschema import validate -from jsonschema.exceptions import ValidationError -import os -import unittest - -cwd = os.path.dirname(os.path.abspath(__file__)) -node_yaml_flpth = os.path.join('..', 'silva_taxon.yaml') -edge_yaml_flpth = os.path.join('..', 'silva_child_of_taxon.yaml') - -class SILVATreeJSONSchemaTest(unittest.TestCase): - ''' - Test the API of the nodes and edges representing SILVA taxonomy tree - All information is from SILVA (arb-silva.de) - See their documentation for more details - ''' - - @classmethod - def setUpClass(cls): - with open(node_yaml_flpth) as fh: - cls.schema_node = safe_load(fh)['schema'] - with open(edge_yaml_flpth) as fh: - cls.schema_edge = safe_load(fh)['schema'] - - cls.nodes_valid = [ - { - 'id': '0', # Root's info is assigned by API, since SILVA doesn't seem to have a root node - 'name': 'Root', - 'rank': 'root_rank', - },{ - 'id': '2', - 'name': 'Archea', - 'rank': 'domain', - },{ - 'id': '47023', - 'name': 'BCP clade', - 'rank': 'major_clade', - 'release': 138, - },{ - 'id': '42919', - 'name': 'Asgardarchaeota', - 'rank': 'phylum', - 'release': 138, - },{ - 'id': '4155', - 'name': 'Amb-18S-504', - 'rank': 'order', - 'release': 119.1, - },{ - 'id': '47162', - 'name': 'Japygoidea', - 'rank': 'superfamily', - 'release': 138, - },{ - 'id': '47142', - 'name': 'Tantulocarida', - 'rank': 'subclass', - 'release': 138, - },{ - 'id': 'HM032797.1.1344', - 'name': 'Yeosuana aromativorans', - 'rank': 'sequence', - 'sequence': 'gattaca', - 'dataset': ['parc', 'ref', 'nr99'] - },{ - 'id': 'CRQV01000019.5091.6588', - 'name': 'Streptococcus penumoniae', - 'rank': 'sequence', - 'sequence': 'gattaca', - 'dataset': ['parc', 'ref'], # actually in nr99 - },{ - 'id': 'HQ216288.1.1242', - 'name': 'uncultured bacterium', - 'rank': 'sequence', - 'sequence': 'gattaca', - 'dataset': ['parc'], # actually in nr99 - } - ] - - cls.nodes_invalid = [ - { - # missing - 'id': 'id', - 'name': 'name', - },{ - # missing - 'id': 'id', - 'rank': 'kingdom', - },{ - # missing - 'name': 'name', - 'rank': 'major_clade', - },{ - # type - 'id': 1, - 'name': 'name', - 'rank': 'subphylum', - },{ - # type - 'id': 'id', - 'name': 1, - 'rank': 'subkingdom', - },{ - # type - 'id': 'id', - 'name': 'name', - 'rank': 1, - },{ - # type - 'id': 'id', - 'name': 'name', - 'rank': 'infraphylum', - 'release': '119', - },{ - # type - 'id': 'id', - 'name': 'name', - 'rank': 'sequence', - 'sequence': 1, - },{ - # type - 'id': 'id', - 'name': 'name', - 'rank': 'subphylum', - 'dataset': 1, - },{ - # enum - 'id': 'id', - 'name': 'name', - 'rank': 'fictional_rank', - },{ - # enum - 'id': 'id', - 'name': 'name', - 'rank': 'superclass', - 'dataset': ['nr99', 'ref', 'parc'], # array in wrong order - } - ] - - cls.nodes_errors = [ - "'rank' is a required property", - "'name' is a required property", - "'id' is a required property", - "1 is not of type 'string'", - "1 is not of type 'string'", - "1 is not of type 'string'", - "'119' is not of type 'number'", - "1 is not of type 'string'", - "1 is not of type 'array'", - "'fictional_rank' is not one of ['superfamily', 'subphylum', 'subfamily', 'phylum', 'order', 'major_clade', 'infraclass', 'suborder', 'family', 'superkingdom', 'domain', 'superphylum', 'superorder', 'superclass', 'infraphylum', 'subclass', 'genus', 'class', 'kingdom', 'subkingdom', 'root_rank', 'sequence']", - "['nr99', 'ref', 'parc'] is not one of [['parc'], ['parc', 'ref'], ['parc', 'ref', 'nr99']]", - ] - - cls.edges_valid = [ - { - 'id': '2', - 'from': '2', - 'to': '0', - },{ - 'id': '42919', - 'from': '42919', - 'to': '2', - },{ - 'id': 'HM032797.1.1344', - 'from': 'HM032797.1.1344', - 'to': '44300', - },{ - 'id': 'CRQV01000019.5091.6588', - 'from': 'CRQV01000019.5091.6588', - 'to': '1853', - }, - ] - - cls.edges_invalid = [ - { - # missing - 'from': '2', - 'to': '0', - },{ - # missing - 'id': '2', - 'to': '0', - },{ - # missing - 'id': '2', - 'from': '2', - },{ - # type - 'id': 2, - 'from': '2', - 'to': '0', - },{ - # type - 'id': '2', - 'from': 2, - 'to': '0', - },{ - # type - 'id': '2', - 'from': '2', - 'to': 0, - }, - - ] - - cls.edges_errors = [ - "'id' is a required property", - "'from' is a required property", - "'to' is a required property", - "2 is not of type 'string'", - "2 is not of type 'string'", - "0 is not of type 'string'", - ] - - - def _test_type(self, schema, valid, invalid, errors=None): - for inst in valid: - validate(inst, schema=schema) - - for inst, error in zip(invalid, errors): - with self.assertRaises(ValidationError) as cm: - validate(inst, schema=schema) - msg = str(cm.exception).split('\n')[0] - - print(msg) - self.assertTrue(msg == error, '`%s` vs `%s`' % (msg, str(cm.exception))) - - - def test(self): - self._test_type(self.schema_node, self.nodes_valid, self.nodes_invalid, self.nodes_errors) - self._test_type(self.schema_edge, self.edges_valid, self.edges_invalid, self.edges_errors) - - -if __name__ == '__main__': - unittest.main() diff --git a/spec/data_sources/silva_taxonomy.yaml b/spec/data_sources/silva_taxonomy.yaml new file mode 100644 index 00000000..ad6c5664 --- /dev/null +++ b/spec/data_sources/silva_taxonomy.yaml @@ -0,0 +1,6 @@ +name: silva_taxonomy +category: taxonomy +title: SILVA Taxonomy +home_url: "https://arb-silva.de" +data_url: "https://arb-silva.de/no_cache/download/archive/" + diff --git a/spec/test/collections/test_silva.py b/spec/test/collections/test_silva.py new file mode 100644 index 00000000..7d9d11d4 --- /dev/null +++ b/spec/test/collections/test_silva.py @@ -0,0 +1,266 @@ +from yaml import safe_load +from jsonschema import validate +from jsonschema.exceptions import ValidationError +import os +import unittest + +cwd = os.path.dirname(os.path.abspath(__file__)) +yaml_drpth = os.path.join(cwd, '../../collections/silva') +node_yaml_flpth = os.path.join(yaml_drpth, 'silva_taxon.yaml') +edge_yaml_flpth = os.path.join(yaml_drpth, 'silva_child_of_taxon.yaml') + + +class SILVATreeJSONSchemaTest(unittest.TestCase): + ''' + Test the API of the nodes and edges representing SILVA taxonomy tree + All information is from SILVA (arb-silva.de) + See their documentation for more details + ''' + + @classmethod + def setUpClass(cls): + with open(node_yaml_flpth) as fh: + cls.schema_node = safe_load(fh)['schema'] + with open(edge_yaml_flpth) as fh: + cls.schema_edge = safe_load(fh)['schema'] + + cls.nodes_valid = [ + { + 'id': '0', # Root's info is assigned by API, since SILVA doesn't seem to have a root node + 'name': 'Root', + 'rank': 'root_rank', + }, { + 'id': '2', + 'name': 'Archea', + 'rank': 'domain', + }, { + 'id': '47023', + 'name': 'BCP clade', + 'rank': 'major_clade', + 'release': 138, + }, { + 'id': '42919', + 'name': 'Asgardarchaeota', + 'rank': 'phylum', + 'release': 138, + }, { + 'id': '4155', + 'name': 'Amb-18S-504', + 'rank': 'order', + 'release': 119.1, + }, { + 'id': '47162', + 'name': 'Japygoidea', + 'rank': 'superfamily', + 'release': 138, + }, { + 'id': '47142', + 'name': 'Tantulocarida', + 'rank': 'subclass', + 'release': 138, + }, { + 'id': 'HM032797.1.1344', + 'name': 'Yeosuana aromativorans', + 'rank': 'sequence', + 'sequence': 'gattaca', + 'dataset': ['parc', 'ref', 'nr99'] + }, { + 'id': 'CRQV01000019.5091.6588', + 'name': 'Streptococcus penumoniae', + 'rank': 'sequence', + 'sequence': 'gattaca', + 'dataset': ['parc', 'ref'], # actually in nr99 + }, { + 'id': 'HQ216288.1.1242', + 'name': 'uncultured bacterium', + 'rank': 'sequence', + 'sequence': 'gattaca', + 'dataset': ['parc'], # actually in nr99 + } + ] + + cls.nodes_invalid_errors = [ + ( + { + # missing + 'id': 'id', + 'name': 'name', + }, + "'rank' is a required property", + ), ( + { + # missing + 'id': 'id', + 'rank': 'kingdom', + }, + "'name' is a required property", + ), ( + { + # missing + 'name': 'name', + 'rank': 'major_clade', + }, + "'id' is a required property", + ), ( + { + # type + 'id': 1, + 'name': 'name', + 'rank': 'subphylum', + }, + "1 is not of type 'string'", + ), ( + { + # type + 'id': 'id', + 'name': 1, + 'rank': 'subkingdom', + }, + "1 is not of type 'string'", + ), ( + { + # type + 'id': 'id', + 'name': 'name', + 'rank': 1, + }, + "1 is not of type 'string'", + ), ( + { + # type + 'id': 'id', + 'name': 'name', + 'rank': 'infraphylum', + 'release': '119', + }, + "'119' is not of type 'number'", + ), ( + { + # type + 'id': 'id', + 'name': 'name', + 'rank': 'sequence', + 'sequence': 1, + }, + "1 is not of type 'string'", + ), ( + { + # type + 'id': 'id', + 'name': 'name', + 'rank': 'subphylum', + 'dataset': 1, + }, + "1 is not of type 'array'", + ), ( + { + # enum + 'id': 'id', + 'name': 'name', + 'rank': 'fictional_rank', + }, + "'fictional_rank' is not one of ['superfamily', 'subphylum', 'subfamily', " + \ + "'phylum', 'order', 'major_clade', 'infraclass', 'suborder', 'family', " + \ + "'superkingdom', 'domain', 'superphylum', 'superorder', 'superclass', " + \ + "'infraphylum', 'subclass', 'genus', 'class', 'kingdom', 'subkingdom', " + \ + "'root_rank', 'sequence']", + ), ( + { + # enum + 'id': 'id', + 'name': 'name', + 'rank': 'superclass', + 'dataset': ['nr99', 'ref', 'parc'], # array in wrong order + }, + "['nr99', 'ref', 'parc'] is not one of [['parc'], ['parc', 'ref'], ['parc', 'ref', 'nr99']]", + ) + ] + + cls.edges_valid = [ + { + 'id': '2', + 'from': '2', + 'to': '0', + }, { + 'id': '42919', + 'from': '42919', + 'to': '2', + }, { + 'id': 'HM032797.1.1344', + 'from': 'HM032797.1.1344', + 'to': '44300', + }, { + 'id': 'CRQV01000019.5091.6588', + 'from': 'CRQV01000019.5091.6588', + 'to': '1853', + }, + ] + + cls.edges_invalid_errors = [ + ( + { + # missing + 'from': '2', + 'to': '0', + }, + "'id' is a required property", + ), ( + { + # missing + 'id': '2', + 'to': '0', + }, + "'from' is a required property", + ), ( + { + # missing + 'id': '2', + 'from': '2', + }, + "'to' is a required property", + ), ( + { + # type + 'id': 2, + 'from': '2', + 'to': '0', + }, + "2 is not of type 'string'", + ), ( + { + # type + 'id': '2', + 'from': 2, + 'to': '0', + }, + "2 is not of type 'string'", + ), ( + { + # type + 'id': '2', + 'from': '2', + 'to': 0, + }, + "0 is not of type 'string'", + ) + ] + + def _test_type(self, schema, valid, invalid_errors): + for inst in valid: + validate(inst, schema=schema) + + for inst, err_expected in invalid_errors: + with self.assertRaises(ValidationError) as cm: + validate(inst, schema=schema) + msg = str(cm.exception).split('\n')[0] + + print(msg) + self.assertTrue(msg == err_expected, '`%s` vs `%s`' % (msg, err_expected)) + + def test(self): + self._test_type(self.schema_node, self.nodes_valid, self.nodes_invalid_errors) + self._test_type(self.schema_edge, self.edges_valid, self.edges_invalid_errors) + + +if __name__ == '__main__': + unittest.main() From 3273d4b8972da16f4e0b882723a6a081e4ddbd8a Mon Sep 17 00:00:00 2001 From: Sumin Date: Fri, 11 Sep 2020 15:15:52 -0700 Subject: [PATCH 584/732] improve silva json schema tests --- spec/test/collections/test_silva.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/spec/test/collections/test_silva.py b/spec/test/collections/test_silva.py index 7d9d11d4..7da37f54 100644 --- a/spec/test/collections/test_silva.py +++ b/spec/test/collections/test_silva.py @@ -1,6 +1,7 @@ +import re from yaml import safe_load -from jsonschema import validate from jsonschema.exceptions import ValidationError +from relation_engine_server.utils.json_validation import run_validator import os import unittest @@ -247,15 +248,15 @@ def setUpClass(cls): def _test_type(self, schema, valid, invalid_errors): for inst in valid: - validate(inst, schema=schema) + run_validator(schema=schema, data=inst) for inst, err_expected in invalid_errors: - with self.assertRaises(ValidationError) as cm: - validate(inst, schema=schema) - msg = str(cm.exception).split('\n')[0] + with self.subTest(inst=inst): + with self.assertRaisesRegex(ValidationError, '^' + re.escape(err_expected) + '\n') as cm: + run_validator(schema=schema, data=inst) - print(msg) - self.assertTrue(msg == err_expected, '`%s` vs `%s`' % (msg, err_expected)) + msg = str(cm.exception).split('\n')[0] + print(msg) def test(self): self._test_type(self.schema_node, self.nodes_valid, self.nodes_invalid_errors) From 98f362add3f6d8f140966d79a5f140a5092107c2 Mon Sep 17 00:00:00 2001 From: Sumin Date: Fri, 11 Sep 2020 17:09:10 -0700 Subject: [PATCH 585/732] use repo jsonschema validator starting from yaml --- spec/test/collections/test_silva.py | 32 ++++++++++++++--------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/spec/test/collections/test_silva.py b/spec/test/collections/test_silva.py index 7da37f54..983285e5 100644 --- a/spec/test/collections/test_silva.py +++ b/spec/test/collections/test_silva.py @@ -1,7 +1,6 @@ import re -from yaml import safe_load from jsonschema.exceptions import ValidationError -from relation_engine_server.utils.json_validation import run_validator +from relation_engine_server.utils.json_validation import get_schema_validator import os import unittest @@ -20,10 +19,8 @@ class SILVATreeJSONSchemaTest(unittest.TestCase): @classmethod def setUpClass(cls): - with open(node_yaml_flpth) as fh: - cls.schema_node = safe_load(fh)['schema'] - with open(edge_yaml_flpth) as fh: - cls.schema_edge = safe_load(fh)['schema'] + cls.validator_node = get_schema_validator(schema_file=node_yaml_flpth, validate_at='/schema') + cls.validator_edge = get_schema_validator(schema_file=edge_yaml_flpth, validate_at='/schema') cls.nodes_valid = [ { @@ -246,21 +243,24 @@ def setUpClass(cls): ) ] - def _test_type(self, schema, valid, invalid_errors): - for inst in valid: - run_validator(schema=schema, data=inst) + def _test_type(self, validator, insts_valid, insts_invalid_errors): + for inst in insts_valid: + with self.subTest(inst=inst): + validator.validate(inst) + + print('v', end='') + print() - for inst, err_expected in invalid_errors: + for inst, err_expected in insts_invalid_errors: with self.subTest(inst=inst): - with self.assertRaisesRegex(ValidationError, '^' + re.escape(err_expected) + '\n') as cm: - run_validator(schema=schema, data=inst) + with self.assertRaisesRegex(ValidationError, '^' + re.escape(err_expected) + '\n'): + validator.validate(inst) - msg = str(cm.exception).split('\n')[0] - print(msg) + print(err_expected) def test(self): - self._test_type(self.schema_node, self.nodes_valid, self.nodes_invalid_errors) - self._test_type(self.schema_edge, self.edges_valid, self.edges_invalid_errors) + self._test_type(self.validator_node, self.nodes_valid, self.nodes_invalid_errors) + self._test_type(self.validator_edge, self.edges_valid, self.edges_invalid_errors) if __name__ == '__main__': From 5f48481af81a24328aaa620725f2998a53d9ec59 Mon Sep 17 00:00:00 2001 From: ialarmedalien Date: Sun, 13 Sep 2020 08:03:46 -0700 Subject: [PATCH 586/732] Add "gene_" or "phenotype_" to keys param for DJORNL queries Text edits on query schemas --- .../djornl/djornl_fetch_all.yaml | 2 +- .../djornl/djornl_fetch_clusters.yaml | 8 ++- .../djornl/djornl_fetch_genes.yaml | 13 ++-- .../djornl/djornl_fetch_phenotypes.yaml | 13 ++-- .../djornl/djornl_search_nodes.yaml | 7 ++- spec/test/djornl/results.json | 60 +++++++++---------- 6 files changed, 57 insertions(+), 46 deletions(-) diff --git a/spec/stored_queries/djornl/djornl_fetch_all.yaml b/spec/stored_queries/djornl/djornl_fetch_all.yaml index 88295928..6a0a0b35 100644 --- a/spec/stored_queries/djornl/djornl_fetch_all.yaml +++ b/spec/stored_queries/djornl/djornl_fetch_all.yaml @@ -1,5 +1,5 @@ name: djornl_fetch_all -description: Fetch all node and edge data from the djornl subgraph +description: Fetch all node and edge data, optionally filtering on edge type. params: type: object additionalProperties: false diff --git a/spec/stored_queries/djornl/djornl_fetch_clusters.yaml b/spec/stored_queries/djornl/djornl_fetch_clusters.yaml index e39f82b4..b8daf83b 100644 --- a/spec/stored_queries/djornl/djornl_fetch_clusters.yaml +++ b/spec/stored_queries/djornl/djornl_fetch_clusters.yaml @@ -8,16 +8,18 @@ params: cluster_ids: type: array title: Cluster IDs - description: Cluster IDs, in the form "clustering_system_name:cluster_id" + description: Fetch nodes by cluster ID, in the form "clustering_system_name:cluster_id" items: $ref: ../../datasets/djornl/definitions.yaml#definitions/cluster_id minItems: 1 uniqueItems: true - examples: [['markov_i2:5', 'markov_i6:2'],['markov_i6:1']] + examples: + - ['markov_i2:5', 'markov_i6:2'] + - ['markov_i6:1'] distance: type: integer title: Traversal Distance - description: How many hops to find neighbors and neighbors-of-neighbors + description: Number of hops to find neighbors and neighbors-of-neighbors default: 1 minimum: 0 maximum: 100 diff --git a/spec/stored_queries/djornl/djornl_fetch_genes.yaml b/spec/stored_queries/djornl/djornl_fetch_genes.yaml index 87045a08..4c10c39c 100644 --- a/spec/stored_queries/djornl/djornl_fetch_genes.yaml +++ b/spec/stored_queries/djornl/djornl_fetch_genes.yaml @@ -3,20 +3,23 @@ description: Fetch a gene or list of genes by key, and the edges and nodes withi params: type: object additionalProperties: false - required: [keys] + required: [gene_keys] properties: - keys: + gene_keys: type: array title: Gene Keys + description: Fetch a gene or list of genes by ID items: $ref: ../../datasets/djornl/definitions.yaml#definitions/djornl_node/_key minItems: 1 uniqueItems: true - examples: [["AT1G01010"],["AT1G01020","AT1G01070"]] + examples: + - ["AT1G01020","AT1G01070"] + - ["AT1G01010"] distance: type: integer title: Traversal Distance - description: How many hops to find neighbors and neighbors-of-neighbors + description: Number of hops to find neighbors and neighbors-of-neighbors default: 1 minimum: 0 maximum: 100 @@ -35,7 +38,7 @@ params: query: | LET node_ids = ( FOR n IN djornl_node - FILTER n._key IN @keys AND n.node_type == 'gene' + FILTER n._key IN @gene_keys AND n.node_type == 'gene' FOR v, e, p IN 0..@distance ANY n djornl_edge OPTIONS {bfs: true, uniqueVertices: "global"} FILTER length(@edge_types) == 0 || p.edges[*].edge_type ALL IN @edge_types diff --git a/spec/stored_queries/djornl/djornl_fetch_phenotypes.yaml b/spec/stored_queries/djornl/djornl_fetch_phenotypes.yaml index 8ae92892..47ebd197 100644 --- a/spec/stored_queries/djornl/djornl_fetch_phenotypes.yaml +++ b/spec/stored_queries/djornl/djornl_fetch_phenotypes.yaml @@ -3,20 +3,23 @@ description: Fetch a phenotype or list of phenotypes by key, and the edges and n params: type: object additionalProperties: false - required: [keys] + required: [phenotype_keys] properties: - keys: + phenotype_keys: type: array title: Phenotype Keys + description: Fetch a phenotype or list of phenotypes by ID items: $ref: ../../datasets/djornl/definitions.yaml#definitions/djornl_node/_key minItems: 1 uniqueItems: true - examples: [["As2"],["As2", "Na23"]] + examples: + - ["As2", "Na23"] + - ["As2"] distance: type: integer title: Traversal Distance - description: How many hops to find neighbors and neighbors-of-neighbors + description: Number of hops to find neighbors and neighbors-of-neighbors default: 1 minimum: 0 maximum: 100 @@ -35,7 +38,7 @@ params: query: | LET node_ids = ( FOR n IN djornl_node - FILTER n._key IN @keys AND n.node_type == 'pheno' + FILTER n._key IN @phenotype_keys AND n.node_type == 'pheno' FOR v, e, p IN 0..@distance ANY n djornl_edge OPTIONS {bfs: true, uniqueVertices: "global"} FILTER length(@edge_types) == 0 || p.edges[*].edge_type ALL IN @edge_types diff --git a/spec/stored_queries/djornl/djornl_search_nodes.yaml b/spec/stored_queries/djornl/djornl_search_nodes.yaml index d318781d..36ad8189 100644 --- a/spec/stored_queries/djornl/djornl_search_nodes.yaml +++ b/spec/stored_queries/djornl/djornl_search_nodes.yaml @@ -8,11 +8,14 @@ params: search_text: type: string title: Search text - examples: ['GO:0005515', 'organelle machinery'] + description: Search nodes and their metadata for the search string + examples: + - 'GO:0005515' + - 'organelle machinery' distance: type: integer title: Traversal Distance - description: How many hops to find neighbors and neighbors-of-neighbors + description: Number of hops to find neighbors and neighbors-of-neighbors default: 1 minimum: 0 maximum: 100 diff --git a/spec/test/djornl/results.json b/spec/test/djornl/results.json index 9d397848..db6f60fc 100644 --- a/spec/test/djornl/results.json +++ b/spec/test/djornl/results.json @@ -59,7 +59,7 @@ "queries": { "djornl_fetch_phenotype": [ { - "params": {"keys": ["A", "B", "C"]}, + "params": {"phenotype_keys": ["A", "B", "C"]}, "error": { "details": "Stored query 'djornl_fetch_phenotype' does not exist.", "message": "Not found", @@ -215,41 +215,41 @@ "params": {}, "error": { "failed_validator": "required", - "message": "'keys' is a required property", + "message": "'gene_keys' is a required property", "path": [], "value": {} } }, { - "params": {"keys": []}, + "params": {"gene_keys": []}, "error": { "failed_validator": "minItems", "message": "[] is too short", - "path": ["keys"], + "path": ["gene_keys"], "value": [] } }, { - "params": { "keys": ["Mary Poppins"], "distance": 0 }, + "params": { "gene_keys": ["Mary Poppins"], "distance": 0 }, "results": {"nodes": [], "edges": []} }, { - "params": { "keys": ["Mary Poppins"], "distance": 1 }, + "params": { "gene_keys": ["Mary Poppins"], "distance": 1 }, "results": {"nodes": [], "edges": []} }, { - "params": { "keys": ["Mary Poppins"], "distance": 5 }, + "params": { "gene_keys": ["Mary Poppins"], "distance": 5 }, "results": {"nodes": [], "edges": []} }, { - "params": { "keys": ["AT1G01010"], "distance": 0 }, + "params": { "gene_keys": ["AT1G01010"], "distance": 0 }, "results": { "nodes": ["AT1G01010"], "edges": [] } }, { - "params": { "keys": ["AT1G01010"], "distance": 1 }, + "params": { "gene_keys": ["AT1G01010"], "distance": 1 }, "results": { "nodes": [ "AT1G01010", @@ -266,7 +266,7 @@ } }, { - "params": { "keys": ["AT1G01010"], "distance": 5 }, + "params": { "gene_keys": ["AT1G01010"], "distance": 5 }, "results": { "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060"], "edges": [ @@ -283,7 +283,7 @@ } }, { - "params": { "keys": ["AT1G01010"], "distance": 5 }, + "params": { "gene_keys": ["AT1G01010"], "distance": 5 }, "results": { "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060"], "edges": [ @@ -300,14 +300,14 @@ } }, { - "params": {"keys": ["AT1G01020", "AT1G01070"], "distance": 0 }, + "params": {"gene_keys": ["AT1G01020", "AT1G01070"], "distance": 0 }, "results": { "nodes": ["AT1G01020", "AT1G01070"], "edges": [] } }, { - "params": {"keys": ["AT1G01020", "AT1G01070"], "distance": 1 }, + "params": {"gene_keys": ["AT1G01020", "AT1G01070"], "distance": 1 }, "results": { "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01070"], "edges": [ @@ -318,7 +318,7 @@ } }, { - "params": {"keys": ["AT1G01020", "AT1G01070"], "distance": 1, "edge_types": ["AraGWAS-Phenotype_Associations"] }, + "params": {"gene_keys": ["AT1G01020", "AT1G01070"], "distance": 1, "edge_types": ["AraGWAS-Phenotype_Associations"] }, "results": { "nodes": ["As2", "As75", "AT1G01020", "AT1G01070"], "edges": [ @@ -328,7 +328,7 @@ } }, { - "params": {"keys": ["AT1G01020", "AT1G01070"], "distance": 5 }, + "params": {"gene_keys": ["AT1G01020", "AT1G01070"], "distance": 5 }, "results": { "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060", "AT1G01070"], "edges": [ @@ -346,7 +346,7 @@ }, { "params": { - "keys": ["AT1G01020", "AT1G01070"], + "gene_keys": ["AT1G01020", "AT1G01070"], "distance": 5, "edge_types": ["AraNetv2-CX_pairwise-gene-coexpression", "AraNetv2-DC_domain-co-occurrence", "AraNetv2-HT_high-throughput-ppi"] }, @@ -363,35 +363,35 @@ ], "djornl_fetch_phenotypes": [ { - "params": {"keys": "Mary Poppins"}, + "params": {"phenotype_keys": "Mary Poppins"}, "error": { "failed_validator": "type", "message": "'Mary Poppins' is not of type 'array'", - "path": ["keys"], + "path": ["phenotype_keys"], "value": "Mary Poppins" } }, { - "params": {"keys": ["Mary Poppins"], "distance": 0}, + "params": {"phenotype_keys": ["Mary Poppins"], "distance": 0}, "results": {"nodes": [], "edges": []} }, { - "params": {"keys": ["Mary Poppins"], "distance": 1}, + "params": {"phenotype_keys": ["Mary Poppins"], "distance": 1}, "results": {"nodes": [], "edges": []} }, { - "params": {"keys": ["Mary Poppins"], "distance": 5}, + "params": {"phenotype_keys": ["Mary Poppins"], "distance": 5}, "results": {"nodes": [], "edges": []} }, { - "params": {"keys": ["As2"], "distance": 0}, + "params": {"phenotype_keys": ["As2"], "distance": 0}, "results": { "nodes": ["As2"], "edges": [] } }, { - "params": {"keys": ["As2"], "distance": 1}, + "params": {"phenotype_keys": ["As2"], "distance": 1}, "results": { "nodes": ["As2", "AT1G01020", "AT1G01040"], "edges": [ @@ -401,7 +401,7 @@ } }, { - "params": {"keys": ["As2"], "distance": 5}, + "params": {"phenotype_keys": ["As2"], "distance": 5}, "results": { "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060"], "edges": [ @@ -418,14 +418,14 @@ } }, { - "params": {"keys": ["As2", "Na23"], "distance": 0}, + "params": {"phenotype_keys": ["As2", "Na23"], "distance": 0}, "results": { "nodes": ["As2", "Na23"], "edges": [] } }, { - "params": {"keys": ["As2", "Na23"], "distance": 1}, + "params": {"phenotype_keys": ["As2", "Na23"], "distance": 1}, "results": { "nodes": ["As2", "Na23", "AT1G01020", "AT1G01040"], "edges": [ @@ -435,7 +435,7 @@ } }, { - "params": {"keys": ["As2", "Na23"], "distance": 5}, + "params": {"phenotype_keys": ["As2", "Na23"], "distance": 5}, "results": { "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060", "Na23"], "edges": [ @@ -452,7 +452,7 @@ } }, { - "params": {"keys": ["As2", "Na23"], "distance": 0}, + "params": {"phenotype_keys": ["As2", "Na23"], "distance": 0}, "results": { "nodes": ["As2", "Na23"], "edges": [] @@ -460,7 +460,7 @@ }, { "params": { - "keys": ["As2", "Na23"], + "phenotype_keys": ["As2", "Na23"], "distance": 5, "edge_types": ["AraNetv2-CX_pairwise-gene-coexpression", "AraNetv2-DC_domain-co-occurrence", "AraNetv2-HT_high-throughput-ppi", "AraNetv2-LC_lit-curated-ppi"] }, @@ -471,7 +471,7 @@ }, { "params": { - "keys": ["As2", "Na23"], + "phenotype_keys": ["As2", "Na23"], "distance": 5, "edge_types": ["AraGWAS-Phenotype_Associations"] }, From d39e84cf16dc302680f3cf15b1cec12620669ea8 Mon Sep 17 00:00:00 2001 From: ialarmedalien Date: Tue, 15 Sep 2020 17:51:02 -0700 Subject: [PATCH 587/732] Fixing JSON pointer errors --- spec/collections/djornl/djornl_edge.yaml | 10 ++--- spec/collections/djornl/djornl_node.yaml | 42 +++++++++---------- spec/datasets/djornl/csv_edge.yaml | 4 +- spec/datasets/djornl/csv_node.yaml | 38 ++++++++--------- .../djornl/djornl_fetch_clusters.yaml | 2 +- .../djornl/djornl_fetch_genes.yaml | 2 +- .../djornl/djornl_fetch_phenotypes.yaml | 2 +- 7 files changed, 50 insertions(+), 50 deletions(-) diff --git a/spec/collections/djornl/djornl_edge.yaml b/spec/collections/djornl/djornl_edge.yaml index 9ba2b6e2..57c2affd 100644 --- a/spec/collections/djornl/djornl_edge.yaml +++ b/spec/collections/djornl/djornl_edge.yaml @@ -17,12 +17,12 @@ schema: additionalProperties: false properties: _key: - $ref: ../../datasets/djornl/definitions.yaml#definitions/djornl_edge/_key + $ref: ../../datasets/djornl/definitions.yaml#/definitions/djornl_edge/_key _from: - $ref: ../../datasets/djornl/definitions.yaml#definitions/djornl_edge/_from + $ref: ../../datasets/djornl/definitions.yaml#/definitions/djornl_edge/_from _to: - $ref: ../../datasets/djornl/definitions.yaml#definitions/djornl_edge/_to + $ref: ../../datasets/djornl/definitions.yaml#/definitions/djornl_edge/_to score: - $ref: ../../datasets/djornl/definitions.yaml#definitions/djornl_edge/score + $ref: ../../datasets/djornl/definitions.yaml#/definitions/djornl_edge/score edge_type: - $ref: ../../datasets/djornl/definitions.yaml#definitions/djornl_edge/edge_type + $ref: ../../datasets/djornl/definitions.yaml#/definitions/djornl_edge/edge_type diff --git a/spec/collections/djornl/djornl_node.yaml b/spec/collections/djornl/djornl_node.yaml index d4082554..cf7e4d9d 100644 --- a/spec/collections/djornl/djornl_node.yaml +++ b/spec/collections/djornl/djornl_node.yaml @@ -15,44 +15,44 @@ schema: additionalProperties: false properties: _key: - $ref: ../../datasets/djornl/definitions.yaml#definitions/djornl_node/_key + $ref: ../../datasets/djornl/definitions.yaml#/definitions/djornl_node/_key clusters: - $ref: ../../datasets/djornl/definitions.yaml#definitions/djornl_node/clusters + $ref: ../../datasets/djornl/definitions.yaml#/definitions/djornl_node/clusters node_type: - $ref: ../../datasets/djornl/definitions.yaml#definitions/djornl_node/node_type + $ref: ../../datasets/djornl/definitions.yaml#/definitions/djornl_node/node_type transcript: - $ref: ../../datasets/djornl/definitions.yaml#definitions/djornl_node/transcript + $ref: ../../datasets/djornl/definitions.yaml#/definitions/djornl_node/transcript gene_symbol: - $ref: ../../datasets/djornl/definitions.yaml#definitions/djornl_node/gene_symbol + $ref: ../../datasets/djornl/definitions.yaml#/definitions/djornl_node/gene_symbol gene_full_name: - $ref: ../../datasets/djornl/definitions.yaml#definitions/djornl_node/gene_full_name + $ref: ../../datasets/djornl/definitions.yaml#/definitions/djornl_node/gene_full_name gene_model_type: - $ref: ../../datasets/djornl/definitions.yaml#definitions/djornl_node/gene_model_type + $ref: ../../datasets/djornl/definitions.yaml#/definitions/djornl_node/gene_model_type tair_computational_description: - $ref: ../../datasets/djornl/definitions.yaml#definitions/djornl_node/tair_computational_description + $ref: ../../datasets/djornl/definitions.yaml#/definitions/djornl_node/tair_computational_description tair_curator_summary: - $ref: ../../datasets/djornl/definitions.yaml#definitions/djornl_node/tair_curator_summary + $ref: ../../datasets/djornl/definitions.yaml#/definitions/djornl_node/tair_curator_summary tair_short_description: - $ref: ../../datasets/djornl/definitions.yaml#definitions/djornl_node/tair_short_description + $ref: ../../datasets/djornl/definitions.yaml#/definitions/djornl_node/tair_short_description go_description: - $ref: ../../datasets/djornl/definitions.yaml#definitions/djornl_node/go_description + $ref: ../../datasets/djornl/definitions.yaml#/definitions/djornl_node/go_description go_terms: - $ref: ../../datasets/djornl/definitions.yaml#definitions/djornl_node/go_terms + $ref: ../../datasets/djornl/definitions.yaml#/definitions/djornl_node/go_terms mapman_bin: - $ref: ../../datasets/djornl/definitions.yaml#definitions/djornl_node/mapman_bin + $ref: ../../datasets/djornl/definitions.yaml#/definitions/djornl_node/mapman_bin mapman_name: - $ref: ../../datasets/djornl/definitions.yaml#definitions/djornl_node/mapman_name + $ref: ../../datasets/djornl/definitions.yaml#/definitions/djornl_node/mapman_name mapman_description: - $ref: ../../datasets/djornl/definitions.yaml#definitions/djornl_node/mapman_description + $ref: ../../datasets/djornl/definitions.yaml#/definitions/djornl_node/mapman_description pheno_aragwas_id: - $ref: ../../datasets/djornl/definitions.yaml#definitions/djornl_node/pheno_aragwas_id + $ref: ../../datasets/djornl/definitions.yaml#/definitions/djornl_node/pheno_aragwas_id pheno_description: - $ref: ../../datasets/djornl/definitions.yaml#definitions/djornl_node/pheno_description + $ref: ../../datasets/djornl/definitions.yaml#/definitions/djornl_node/pheno_description pheno_pto_name: - $ref: ../../datasets/djornl/definitions.yaml#definitions/djornl_node/pheno_pto_name + $ref: ../../datasets/djornl/definitions.yaml#/definitions/djornl_node/pheno_pto_name pheno_pto_description: - $ref: ../../datasets/djornl/definitions.yaml#definitions/djornl_node/pheno_pto_description + $ref: ../../datasets/djornl/definitions.yaml#/definitions/djornl_node/pheno_pto_description pheno_ref: - $ref: ../../datasets/djornl/definitions.yaml#definitions/djornl_node/pheno_ref + $ref: ../../datasets/djornl/definitions.yaml#/definitions/djornl_node/pheno_ref user_notes: - $ref: ../../datasets/djornl/definitions.yaml#definitions/djornl_node/user_notes + $ref: ../../datasets/djornl/definitions.yaml#/definitions/djornl_node/user_notes diff --git a/spec/datasets/djornl/csv_edge.yaml b/spec/datasets/djornl/csv_edge.yaml index f5c88b1a..19617c5b 100644 --- a/spec/datasets/djornl/csv_edge.yaml +++ b/spec/datasets/djornl/csv_edge.yaml @@ -6,9 +6,9 @@ type: object required: [node1, node2, edge, layer_descrip] properties: node1: - $ref: definitions.yaml#definitions/djornl_edge/_from + $ref: definitions.yaml#/definitions/djornl_edge/_from node2: - $ref: definitions.yaml#definitions/djornl_edge/_to + $ref: definitions.yaml#/definitions/djornl_edge/_to edge: # pre-transformation, the parser treats this as a string type: string diff --git a/spec/datasets/djornl/csv_node.yaml b/spec/datasets/djornl/csv_node.yaml index 4c3c3b48..b245d623 100644 --- a/spec/datasets/djornl/csv_node.yaml +++ b/spec/datasets/djornl/csv_node.yaml @@ -7,50 +7,50 @@ required: [node_id, node_type] additionalProperties: false properties: node_id: - $ref: definitions.yaml#definitions/djornl_node/_key + $ref: definitions.yaml#/definitions/djornl_node/_key node_type: - $ref: definitions.yaml#definitions/djornl_node/node_type + $ref: definitions.yaml#/definitions/djornl_node/node_type # comma-separated array of cluster IDs clusters: type: string format: regex pattern: ^(\w+:\d+, ?)*(\w+:\d+)?$ transcript: - $ref: definitions.yaml#definitions/djornl_node/transcript + $ref: definitions.yaml#/definitions/djornl_node/transcript gene_symbol: - $ref: definitions.yaml#definitions/djornl_node/gene_symbol + $ref: definitions.yaml#/definitions/djornl_node/gene_symbol gene_full_name: - $ref: definitions.yaml#definitions/djornl_node/gene_full_name + $ref: definitions.yaml#/definitions/djornl_node/gene_full_name gene_model_type: - $ref: definitions.yaml#definitions/djornl_node/gene_model_type + $ref: definitions.yaml#/definitions/djornl_node/gene_model_type tair_computational_description: - $ref: definitions.yaml#definitions/djornl_node/tair_computational_description + $ref: definitions.yaml#/definitions/djornl_node/tair_computational_description tair_curator_summary: - $ref: definitions.yaml#definitions/djornl_node/tair_curator_summary + $ref: definitions.yaml#/definitions/djornl_node/tair_curator_summary tair_short_description: - $ref: definitions.yaml#definitions/djornl_node/tair_short_description + $ref: definitions.yaml#/definitions/djornl_node/tair_short_description # comma-separated array of GO terms go_terms: type: string format: regex pattern: ^(GO:\d{7}, ?)*(GO:\d{7})?$ go_description: - $ref: definitions.yaml#definitions/djornl_node/go_description + $ref: definitions.yaml#/definitions/djornl_node/go_description mapman_bin: - $ref: definitions.yaml#definitions/djornl_node/mapman_bin + $ref: definitions.yaml#/definitions/djornl_node/mapman_bin mapman_name: - $ref: definitions.yaml#definitions/djornl_node/mapman_name + $ref: definitions.yaml#/definitions/djornl_node/mapman_name mapman_description: - $ref: definitions.yaml#definitions/djornl_node/mapman_description + $ref: definitions.yaml#/definitions/djornl_node/mapman_description pheno_aragwas_id: - $ref: definitions.yaml#definitions/djornl_node/pheno_aragwas_id + $ref: definitions.yaml#/definitions/djornl_node/pheno_aragwas_id pheno_description: - $ref: definitions.yaml#definitions/djornl_node/pheno_description + $ref: definitions.yaml#/definitions/djornl_node/pheno_description pheno_pto_name: - $ref: definitions.yaml#definitions/djornl_node/pheno_pto_name + $ref: definitions.yaml#/definitions/djornl_node/pheno_pto_name pheno_pto_description: - $ref: definitions.yaml#definitions/djornl_node/pheno_pto_description + $ref: definitions.yaml#/definitions/djornl_node/pheno_pto_description pheno_ref: - $ref: definitions.yaml#definitions/djornl_node/pheno_ref + $ref: definitions.yaml#/definitions/djornl_node/pheno_ref user_notes: - $ref: definitions.yaml#definitions/djornl_node/user_notes + $ref: definitions.yaml#/definitions/djornl_node/user_notes diff --git a/spec/stored_queries/djornl/djornl_fetch_clusters.yaml b/spec/stored_queries/djornl/djornl_fetch_clusters.yaml index b8daf83b..28812599 100644 --- a/spec/stored_queries/djornl/djornl_fetch_clusters.yaml +++ b/spec/stored_queries/djornl/djornl_fetch_clusters.yaml @@ -10,7 +10,7 @@ params: title: Cluster IDs description: Fetch nodes by cluster ID, in the form "clustering_system_name:cluster_id" items: - $ref: ../../datasets/djornl/definitions.yaml#definitions/cluster_id + $ref: ../../datasets/djornl/definitions.yaml#/definitions/cluster_id minItems: 1 uniqueItems: true examples: diff --git a/spec/stored_queries/djornl/djornl_fetch_genes.yaml b/spec/stored_queries/djornl/djornl_fetch_genes.yaml index 4c10c39c..4a48cfa6 100644 --- a/spec/stored_queries/djornl/djornl_fetch_genes.yaml +++ b/spec/stored_queries/djornl/djornl_fetch_genes.yaml @@ -10,7 +10,7 @@ params: title: Gene Keys description: Fetch a gene or list of genes by ID items: - $ref: ../../datasets/djornl/definitions.yaml#definitions/djornl_node/_key + $ref: ../../datasets/djornl/definitions.yaml#/definitions/djornl_node/_key minItems: 1 uniqueItems: true examples: diff --git a/spec/stored_queries/djornl/djornl_fetch_phenotypes.yaml b/spec/stored_queries/djornl/djornl_fetch_phenotypes.yaml index 47ebd197..6a122efc 100644 --- a/spec/stored_queries/djornl/djornl_fetch_phenotypes.yaml +++ b/spec/stored_queries/djornl/djornl_fetch_phenotypes.yaml @@ -10,7 +10,7 @@ params: title: Phenotype Keys description: Fetch a phenotype or list of phenotypes by ID items: - $ref: ../../datasets/djornl/definitions.yaml#definitions/djornl_node/_key + $ref: ../../datasets/djornl/definitions.yaml#/definitions/djornl_node/_key minItems: 1 uniqueItems: true examples: From 21456a23455bffcfac7d0719088528c5011f33bb Mon Sep 17 00:00:00 2001 From: ialarmedalien Date: Wed, 16 Sep 2020 13:43:19 -0700 Subject: [PATCH 588/732] Change tests to remove duplication --- spec/test/djornl/results.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/test/djornl/results.json b/spec/test/djornl/results.json index db6f60fc..6c844968 100644 --- a/spec/test/djornl/results.json +++ b/spec/test/djornl/results.json @@ -69,7 +69,7 @@ ], "djornl_fetch_all": [ { - "params": {"edge_types": []}, + "params": {}, "results": { "nodes": [ "As2", @@ -212,7 +212,7 @@ ], "djornl_fetch_genes": [ { - "params": {}, + "params": { "distance": 0 }, "error": { "failed_validator": "required", "message": "'gene_keys' is a required property", From 279d5ff3169e3d041c8e88b3a323b5286531edd9 Mon Sep 17 00:00:00 2001 From: ialarmedalien Date: Wed, 16 Sep 2020 16:25:23 -0700 Subject: [PATCH 589/732] A few minor test edits --- spec/test/djornl/results.json | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/spec/test/djornl/results.json b/spec/test/djornl/results.json index 6c844968..8e294eb4 100644 --- a/spec/test/djornl/results.json +++ b/spec/test/djornl/results.json @@ -217,7 +217,7 @@ "failed_validator": "required", "message": "'gene_keys' is a required property", "path": [], - "value": {} + "value": {"distance": 0} } }, { @@ -229,6 +229,15 @@ "value": [] } }, + { + "params": { "gene_keys": ["Mary Poppins"], "phenotype_keys": 0 }, + "error": { + "failed_validator": "additionalProperties", + "message": "Additional properties are not allowed ('phenotype_keys' was unexpected)", + "path": [], + "value": {"gene_keys": ["Mary Poppins"], "phenotype_keys": 0} + } + }, { "params": { "gene_keys": ["Mary Poppins"], "distance": 0 }, "results": {"nodes": [], "edges": []} @@ -486,6 +495,24 @@ } ], "djornl_search_nodes": [ + { + "params": {"search_text": "Mary Poppins", "distance": 500}, + "error": { + "failed_validator": "maximum", + "message": "500 is greater than the maximum of 100", + "path": ["distance"], + "value": 500 + } + }, + { + "params": "erm... what?", + "error": { + "failed_validator": "type", + "message": "'erm... what?' is not of type 'object'", + "path": [], + "value": "erm... what?" + } + }, { "params": {"search_text": "Mary Poppins", "distance": 0}, "results": {"nodes": [], "edges": []} From 127ea8511c0b8545c300d71855c8667bbd3745d7 Mon Sep 17 00:00:00 2001 From: ialarmedalien Date: Thu, 17 Sep 2020 07:40:00 -0700 Subject: [PATCH 590/732] Make 0 the default distance for queries --- spec/datasets/distance.yaml | 2 +- .../djornl/djornl_fetch_clusters.yaml | 2 +- spec/stored_queries/djornl/djornl_fetch_genes.yaml | 2 +- .../djornl/djornl_fetch_phenotypes.yaml | 2 +- .../stored_queries/djornl/djornl_search_nodes.yaml | 2 +- spec/test/djornl/results.json | 14 ++++++++++++++ 6 files changed, 19 insertions(+), 5 deletions(-) diff --git a/spec/datasets/distance.yaml b/spec/datasets/distance.yaml index 98b927b3..20d35b40 100644 --- a/spec/datasets/distance.yaml +++ b/spec/datasets/distance.yaml @@ -2,6 +2,6 @@ name: distance type: integer title: Traversal Distance description: How many hops to find neighbors and neighbors-of-neighbors -default: 1 +default: 0 minimum: 0 maximum: 100 diff --git a/spec/stored_queries/djornl/djornl_fetch_clusters.yaml b/spec/stored_queries/djornl/djornl_fetch_clusters.yaml index 28812599..9a3aab28 100644 --- a/spec/stored_queries/djornl/djornl_fetch_clusters.yaml +++ b/spec/stored_queries/djornl/djornl_fetch_clusters.yaml @@ -20,7 +20,7 @@ params: type: integer title: Traversal Distance description: Number of hops to find neighbors and neighbors-of-neighbors - default: 1 + default: 0 minimum: 0 maximum: 100 edge_types: diff --git a/spec/stored_queries/djornl/djornl_fetch_genes.yaml b/spec/stored_queries/djornl/djornl_fetch_genes.yaml index 4a48cfa6..c12178ab 100644 --- a/spec/stored_queries/djornl/djornl_fetch_genes.yaml +++ b/spec/stored_queries/djornl/djornl_fetch_genes.yaml @@ -20,7 +20,7 @@ params: type: integer title: Traversal Distance description: Number of hops to find neighbors and neighbors-of-neighbors - default: 1 + default: 0 minimum: 0 maximum: 100 edge_types: diff --git a/spec/stored_queries/djornl/djornl_fetch_phenotypes.yaml b/spec/stored_queries/djornl/djornl_fetch_phenotypes.yaml index 6a122efc..ce5bfecc 100644 --- a/spec/stored_queries/djornl/djornl_fetch_phenotypes.yaml +++ b/spec/stored_queries/djornl/djornl_fetch_phenotypes.yaml @@ -20,7 +20,7 @@ params: type: integer title: Traversal Distance description: Number of hops to find neighbors and neighbors-of-neighbors - default: 1 + default: 0 minimum: 0 maximum: 100 edge_types: diff --git a/spec/stored_queries/djornl/djornl_search_nodes.yaml b/spec/stored_queries/djornl/djornl_search_nodes.yaml index 36ad8189..877b8dc5 100644 --- a/spec/stored_queries/djornl/djornl_search_nodes.yaml +++ b/spec/stored_queries/djornl/djornl_search_nodes.yaml @@ -16,7 +16,7 @@ params: type: integer title: Traversal Distance description: Number of hops to find neighbors and neighbors-of-neighbors - default: 1 + default: 0 minimum: 0 maximum: 100 edge_types: diff --git a/spec/test/djornl/results.json b/spec/test/djornl/results.json index 8e294eb4..363614fb 100644 --- a/spec/test/djornl/results.json +++ b/spec/test/djornl/results.json @@ -392,6 +392,13 @@ "params": {"phenotype_keys": ["Mary Poppins"], "distance": 5}, "results": {"nodes": [], "edges": []} }, + { + "params": {"phenotype_keys": ["As2"]}, + "results": { + "nodes": ["As2"], + "edges": [] + } + }, { "params": {"phenotype_keys": ["As2"], "distance": 0}, "results": { @@ -667,6 +674,13 @@ ] } }, + { + "params": {"cluster_ids": ["markov_i2:5", "markov_i6:2"]}, + "results": { + "nodes": ["AT1G01020", "AT1G01070"], + "edges": [] + } + }, { "params": {"cluster_ids": ["markov_i2:5", "markov_i6:2"], "distance": 0}, "results": { From 699f336438bd68d390c75423a44d085fbabb9488 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Thu, 17 Sep 2020 15:52:10 -0700 Subject: [PATCH 591/732] Add newline break char --- scripts/local-build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/local-build.sh b/scripts/local-build.sh index 3948b73c..18b29960 100644 --- a/scripts/local-build.sh +++ b/scripts/local-build.sh @@ -11,7 +11,7 @@ fi export BRANCH=`git symbolic-ref --short HEAD` export DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` export COMMIT=`git rev-parse --short HEAD` -docker build --file Dockerfile +docker build --file Dockerfile \ --build-arg BUILD_DATE=$DATE \ --build-arg VCS_REF=$COMMIT \ --build-arg BRANCH=$BRANCH \ From 449bf39b51320f6640b221ce290c39d9b3865f17 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Fri, 18 Sep 2020 10:21:04 -0700 Subject: [PATCH 592/732] Clean up docker deploy script to make it usable for CI --- scripts/docker_deploy | 16 ++++++++++++++++ scripts/local-build.sh | 19 ------------------- 2 files changed, 16 insertions(+), 19 deletions(-) create mode 100755 scripts/docker_deploy delete mode 100644 scripts/local-build.sh diff --git a/scripts/docker_deploy b/scripts/docker_deploy new file mode 100755 index 00000000..7fe7dbe0 --- /dev/null +++ b/scripts/docker_deploy @@ -0,0 +1,16 @@ +#!/bin/bash +# Build and deploy the docker image to Dockerhub + +# Exit on error +set -e +set -o xtrace + +ver=$(cat VERSION) +export IMAGE_NAME="kbase/relation_engine_api:$ver" +export DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` +export COMMIT=`git rev-parse --short HEAD` +docker build --build-arg BUILD_DATE=$DATE \ + --build-arg VCS_REF=$COMMIT \ + --build-arg BRANCH=$BRANCH \ + -t ${IMAGE_NAME} . +docker push $IMAGE_NAME diff --git a/scripts/local-build.sh b/scripts/local-build.sh deleted file mode 100644 index 18b29960..00000000 --- a/scripts/local-build.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh -set -e -# show the commands we execute -set -o xtrace - -# $IMAGE_NAME var is injected into the build so the tag is correct. -if [ -z "$IMAGE_NAME" ]; then - export IMAGE_NAME="kbase/relation_engine_api:latest" -fi - -export BRANCH=`git symbolic-ref --short HEAD` -export DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` -export COMMIT=`git rev-parse --short HEAD` -docker build --file Dockerfile \ - --build-arg BUILD_DATE=$DATE \ - --build-arg VCS_REF=$COMMIT \ - --build-arg BRANCH=$BRANCH \ - -t ${IMAGE_NAME} . -docker push $IMAGE_NAME From b7ef1d3684dc6e143fabf48c5fddba6da05a2b3f Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Fri, 18 Sep 2020 11:34:13 -0700 Subject: [PATCH 593/732] Update CHANGELOG.md and VERSON --- CHANGELOG.md | 4 ++++ VERSION | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ad51ca09..e768338b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.0.7] - 2020-09-18 +### Fixed +- Modified the docker deployment script so it can be used to release to the staging server + ## [0.0.6] - 2020-08-20 ### Added diff --git a/VERSION b/VERSION index 1750564f..17e51c38 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.0.6 +0.1.1 From 0375ef55b3f3c1a47af374e56e4e54775ffff04c Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Fri, 18 Sep 2020 11:34:56 -0700 Subject: [PATCH 594/732] Set version --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 17e51c38..5a5831ab 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.1.1 +0.0.7 From f10e8571ea825d38408fdd31051e348e28ec1ecf Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Fri, 18 Sep 2020 12:26:52 -0700 Subject: [PATCH 595/732] Add branch command --- scripts/docker_deploy | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/docker_deploy b/scripts/docker_deploy index 7fe7dbe0..7c4c0a10 100755 --- a/scripts/docker_deploy +++ b/scripts/docker_deploy @@ -3,10 +3,12 @@ # Exit on error set -e +# Show the commands we execute set -o xtrace ver=$(cat VERSION) export IMAGE_NAME="kbase/relation_engine_api:$ver" +export BRANCH=`git symbolic-ref --short HEAD` export DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` export COMMIT=`git rev-parse --short HEAD` docker build --build-arg BUILD_DATE=$DATE \ From 0df30e542cbe5ac48b8740f71146d33de442edb4 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Fri, 18 Sep 2020 13:12:25 -0700 Subject: [PATCH 596/732] Remove arango auth --- relation_engine_server/utils/wait_for.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/relation_engine_server/utils/wait_for.py b/relation_engine_server/utils/wait_for.py index bd6a7e72..9ea9a821 100644 --- a/relation_engine_server/utils/wait_for.py +++ b/relation_engine_server/utils/wait_for.py @@ -38,9 +38,7 @@ def get_service_conf(service_name): service_conf = { 'arangodb': { - 'url': _CONF['db_url'] + '/_admin/cluster/health', - # server auth credentials - 'auth': (_CONF['db_user'], _CONF['db_pass']), + 'url': _CONF['db_url'], }, 'auth': { 'url': _CONF['auth_url'], From 80d64480f418579947bd55eec05ce0e9b6a81378 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Fri, 18 Sep 2020 13:15:48 -0700 Subject: [PATCH 597/732] Ver and changelog --- CHANGELOG.md | 4 ++++ VERSION | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e768338b..eed9b559 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.0.8] - 2020-09-18 +### Fixed +- Remove need for authentication when waiting for the ArangoDB dependency to start (this is a staging server restriction) + ## [0.0.7] - 2020-09-18 ### Fixed - Modified the docker deployment script so it can be used to release to the staging server diff --git a/VERSION b/VERSION index 5a5831ab..d169b2f2 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.0.7 +0.0.8 From 067e48eac406e2066a79ad108a34044cce7dbc27 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Fri, 18 Sep 2020 16:13:52 -0700 Subject: [PATCH 598/732] Gitignore the test spec tarball --- .gitignore | 3 +++ .../test/spec_release/spec.tar.gz | Bin 2197 -> 0 bytes 2 files changed, 3 insertions(+) delete mode 100644 relation_engine_server/test/spec_release/spec.tar.gz diff --git a/.gitignore b/.gitignore index 4a0a770f..56534d99 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,6 @@ coverage_report/ .coverage *.egg-info/ + +# Test spec archive +/relation_engine_server/test/spec_release/spec.tar.gz diff --git a/relation_engine_server/test/spec_release/spec.tar.gz b/relation_engine_server/test/spec_release/spec.tar.gz deleted file mode 100644 index e4c2d7b71b6b7a939c4cdbdcc0cf2abcb0aa30b9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2197 zcmV;G2x|8qiwFP!000021MM4YZ`(LBpZzNa?g7~aY{xIzt#LhEdP(kb=nHLj_roF( zXo@BCGocX?>D4m*_PGXPE)mqY6{d6XE+>jo_s`+Fy_=%G4)(YIVFmo96c~} z5yp;Ve-Vnm_PIA0_nmQX)bEaty1juj>K=jf(1MgfqBM~JM^Xs=Il5i=|5H#U`VZM$ z63s-U9>x?7*S|9!3~T*Y0Xy{Xx-4SabvyCm{$m&gkA}nj_22Jy2ZJN%Rxts!{y(RG zdS~%pr2gId?~MxnKOPT8wf?JsM{xD(>{X+22T!5b_}0?YP&JhKztTcd-~BV8lFOQq#N6f`oj(F?Qwu z;a2@O#0sF!|5X6yf7B@$T`!;wR?R>_v1raI7=1&kZ zAu$4qs9`0Zzy~C|c=ZMZT)u>LflS|v%jZ|;i0jziPoKg+@z-MBoL~L&<|T+9zT(-} z|2e~{&F7bSRP7%CcKLsQJSzJCuv@SHDuIIkKSwnK;e6%!M%9f+@E@W;iI8GsFa`r8 z(HJM@ghfbqt6b)*EH-Rg%3;3Blp7~g&OG?=0bea|(;*wA_TC4DJ^VlNrp(pk?%p-v z!S!DsOM<%os{{_wzkSG3Ke-dpz8PRw{CCD%^`A4U>%U6i5nN;?pH(UN!b?ILX;bdm z77?!1eMJk{tL$Tb3$!Y${FuMH@O$~MXP0obCW*zV&5kV6bWY`F&tIujOhm{LTS81X zXzJ^!XeK0R>Y3OBdlIlc8pud~URp$Rb(Zp3Ek={e>{@iQ-r(d7{R0BKpzj6-rzXKNiYp^T+ z4+i5x{Kw`0u#W##z*<~iD!JidXqyWYCiAAUVB83BJ>VviPax1bR+E#H+uPfY;nj(F z*oj!snTwl~oQbt7OFz>wQse*I)L8rHJx&^2%!L~h9ZcYag=B7)qXCnC8xxOSv<=7h zx}~0&4sEB`9t}G&rjlnZ!Fynu$pEVP<`OP`w)Xqr@y zx%&?#qITNa5psUwOES~#?)W5ad(`~wlF*$=5w^h9!Ym7YsyxYJV{j8VPj8%95g=uj zuGCOOT*`GymXVg*1m3SNB0r`WEwK20PcwYgOM{R#{cf1TgU$@pt%3D8UB6B zHNo^C6WVC7$ftK{#BFDBeU@;Jbh?plj#KU{jO@x|G}3IwJlC+lUh5E>J$a=Oz1hW_ z5oFuvEyy<4_vu&c(*jP?RA#pRuN&nFY|s3)oxV15)fGk8!9i_qBFlV*BFcq1RnP%V z_sjBQ6fG(3Y@dx3rmF>#MDJQAjS&_dd~C8I;%dJRJHbz}P)xHMy3BMxXMM7iYbNx# zcie*Ge%Bd{o;*3ewgd$Mcc0m$BO2OH$p|l~4i;R*0pp2+Fn!bbjX|Q!;LnJssbs`F zUoaUmFTu>8$wD~85LGz-AySe>+4rBO)I}k(_cs1p?RAeJXeYB=X_kNvsL#Ze(87HNI<2N+2z?^gjOhF`kic^hNq+${I%G|>v*-)K~lR_snM3G`XHHV-`Go`kx zS}7$U8Ulg=h*+UP%vK*@J?1tLXy-BVinKaTiBJN{tTd)dL9GDBTa`>#Z}|YXNJVYr zO<5ePOicTshLcHUX;50_JhvE7OOKPUHsU#4o&mv+hA0WA87ca+hu^y=FYHLAXZYYO z7?H6%)u?>KBVF&9$;ZS*BBsL5*IAX6)qgjP-agQu{#iJ@{vVF(`~TIzr}e*i+0)cY z_Z?$L{om`4dRzCu#`XQrO5nYzj7{D$`#KvcZ?+7|1Tljm7>ef@n~C&-6myFipH7n* zmJ^pgH$@WI)+#zl-aGc?A(6+rwjZxmw28@ni(pILzr- Date: Fri, 18 Sep 2020 16:14:21 -0700 Subject: [PATCH 599/732] Rename the test spec files to match the actual repo directory structure --- .../test/spec_release/README.md | 33 ------------------- .../collections/ncbi/ncbi_taxon.yaml | 0 .../collections/test/test_edge.yaml | 0 .../collections/test/test_vertex.yaml | 0 .../data_sources/ncbi_taxonomy.yaml | 0 .../{ => spec}/migrations/__init__.py | 0 .../{ => spec}/migrations/example.py | 0 .../ncbi_tax/ncbi_fetch_taxon.yaml | 0 .../test/fetch_test_vertex.yaml | 0 .../test/list_test_vertices.yaml | 0 .../{ => spec}/views/test_vertices.json | 0 11 files changed, 33 deletions(-) rename relation_engine_server/test/spec_release/sample_spec_release/{ => spec}/collections/ncbi/ncbi_taxon.yaml (100%) rename relation_engine_server/test/spec_release/sample_spec_release/{ => spec}/collections/test/test_edge.yaml (100%) rename relation_engine_server/test/spec_release/sample_spec_release/{ => spec}/collections/test/test_vertex.yaml (100%) rename relation_engine_server/test/spec_release/sample_spec_release/{ => spec}/data_sources/ncbi_taxonomy.yaml (100%) rename relation_engine_server/test/spec_release/sample_spec_release/{ => spec}/migrations/__init__.py (100%) rename relation_engine_server/test/spec_release/sample_spec_release/{ => spec}/migrations/example.py (100%) rename relation_engine_server/test/spec_release/sample_spec_release/{ => spec}/stored_queries/ncbi_tax/ncbi_fetch_taxon.yaml (100%) rename relation_engine_server/test/spec_release/sample_spec_release/{ => spec}/stored_queries/test/fetch_test_vertex.yaml (100%) rename relation_engine_server/test/spec_release/sample_spec_release/{ => spec}/stored_queries/test/list_test_vertices.yaml (100%) rename relation_engine_server/test/spec_release/sample_spec_release/{ => spec}/views/test_vertices.json (100%) diff --git a/relation_engine_server/test/spec_release/README.md b/relation_engine_server/test/spec_release/README.md index 61d16dce..1a5a479a 100644 --- a/relation_engine_server/test/spec_release/README.md +++ b/relation_engine_server/test/spec_release/README.md @@ -1,36 +1,3 @@ ## Test Spec Release `sample_spec_release`, and the corresponding archive, `spec.tar.gz`, contain a set of sample schema files suitable for use in tests. - -To create a new version of `spec.tar.gz`, you will need to open a shell into the `re_api` docker image and create the new archive there to ensure that the new archive and its contents have the appropriate file owner and permissions (all files must have owner and group `root`/`root`). - -Ensure that you have mounted your current working directory as `/app` in the docker `re_api` image by uncommenting the lines in `docker-compose.yaml`: - -``` yaml - re_api: - ( ... ) -# uncomment to mount local directories - volumes: - - ${PWD}:/app -``` - -Run `make shell` to start up the docker container, and then get the ID of the current `re_api` image. Exec into the `re_api` image via the Docker Desktop client or the command line: - -``` sh -$ docker exec -it relation_engine_re_api_run_1234567890 sh -``` - -Example commands for updating `spec.tar.gz`: - -``` sh -# cd relation_engine_server/test/spec_release -# # ... perform any edits ... -# tar -czvf new_spec.tar.gz sample_spec_release/ -# # check the file listing is as expected -# tar -ztvf new_spec.tar.gz -# mv spec.tar.gz old_spec.tar.gz -# mv new_spec.tar.gz spec.tar.gz -# # ensure that the tests pass -# cd /app -# sh scripts/run_tests.sh -``` diff --git a/relation_engine_server/test/spec_release/sample_spec_release/collections/ncbi/ncbi_taxon.yaml b/relation_engine_server/test/spec_release/sample_spec_release/spec/collections/ncbi/ncbi_taxon.yaml similarity index 100% rename from relation_engine_server/test/spec_release/sample_spec_release/collections/ncbi/ncbi_taxon.yaml rename to relation_engine_server/test/spec_release/sample_spec_release/spec/collections/ncbi/ncbi_taxon.yaml diff --git a/relation_engine_server/test/spec_release/sample_spec_release/collections/test/test_edge.yaml b/relation_engine_server/test/spec_release/sample_spec_release/spec/collections/test/test_edge.yaml similarity index 100% rename from relation_engine_server/test/spec_release/sample_spec_release/collections/test/test_edge.yaml rename to relation_engine_server/test/spec_release/sample_spec_release/spec/collections/test/test_edge.yaml diff --git a/relation_engine_server/test/spec_release/sample_spec_release/collections/test/test_vertex.yaml b/relation_engine_server/test/spec_release/sample_spec_release/spec/collections/test/test_vertex.yaml similarity index 100% rename from relation_engine_server/test/spec_release/sample_spec_release/collections/test/test_vertex.yaml rename to relation_engine_server/test/spec_release/sample_spec_release/spec/collections/test/test_vertex.yaml diff --git a/relation_engine_server/test/spec_release/sample_spec_release/data_sources/ncbi_taxonomy.yaml b/relation_engine_server/test/spec_release/sample_spec_release/spec/data_sources/ncbi_taxonomy.yaml similarity index 100% rename from relation_engine_server/test/spec_release/sample_spec_release/data_sources/ncbi_taxonomy.yaml rename to relation_engine_server/test/spec_release/sample_spec_release/spec/data_sources/ncbi_taxonomy.yaml diff --git a/relation_engine_server/test/spec_release/sample_spec_release/migrations/__init__.py b/relation_engine_server/test/spec_release/sample_spec_release/spec/migrations/__init__.py similarity index 100% rename from relation_engine_server/test/spec_release/sample_spec_release/migrations/__init__.py rename to relation_engine_server/test/spec_release/sample_spec_release/spec/migrations/__init__.py diff --git a/relation_engine_server/test/spec_release/sample_spec_release/migrations/example.py b/relation_engine_server/test/spec_release/sample_spec_release/spec/migrations/example.py similarity index 100% rename from relation_engine_server/test/spec_release/sample_spec_release/migrations/example.py rename to relation_engine_server/test/spec_release/sample_spec_release/spec/migrations/example.py diff --git a/relation_engine_server/test/spec_release/sample_spec_release/stored_queries/ncbi_tax/ncbi_fetch_taxon.yaml b/relation_engine_server/test/spec_release/sample_spec_release/spec/stored_queries/ncbi_tax/ncbi_fetch_taxon.yaml similarity index 100% rename from relation_engine_server/test/spec_release/sample_spec_release/stored_queries/ncbi_tax/ncbi_fetch_taxon.yaml rename to relation_engine_server/test/spec_release/sample_spec_release/spec/stored_queries/ncbi_tax/ncbi_fetch_taxon.yaml diff --git a/relation_engine_server/test/spec_release/sample_spec_release/stored_queries/test/fetch_test_vertex.yaml b/relation_engine_server/test/spec_release/sample_spec_release/spec/stored_queries/test/fetch_test_vertex.yaml similarity index 100% rename from relation_engine_server/test/spec_release/sample_spec_release/stored_queries/test/fetch_test_vertex.yaml rename to relation_engine_server/test/spec_release/sample_spec_release/spec/stored_queries/test/fetch_test_vertex.yaml diff --git a/relation_engine_server/test/spec_release/sample_spec_release/stored_queries/test/list_test_vertices.yaml b/relation_engine_server/test/spec_release/sample_spec_release/spec/stored_queries/test/list_test_vertices.yaml similarity index 100% rename from relation_engine_server/test/spec_release/sample_spec_release/stored_queries/test/list_test_vertices.yaml rename to relation_engine_server/test/spec_release/sample_spec_release/spec/stored_queries/test/list_test_vertices.yaml diff --git a/relation_engine_server/test/spec_release/sample_spec_release/views/test_vertices.json b/relation_engine_server/test/spec_release/sample_spec_release/spec/views/test_vertices.json similarity index 100% rename from relation_engine_server/test/spec_release/sample_spec_release/views/test_vertices.json rename to relation_engine_server/test/spec_release/sample_spec_release/spec/views/test_vertices.json From 4c5fe3739c3b9d8ea238656f9b59c4350ea72191 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Fri, 18 Sep 2020 16:16:33 -0700 Subject: [PATCH 600/732] Simplify spec root directory; get the new repo structure working --- docker-compose.yaml | 2 +- .../test/test_spec_loader.py | 4 +-- relation_engine_server/utils/config.py | 12 +++---- relation_engine_server/utils/pull_spec.py | 31 +++++++------------ relation_engine_server/utils/spec_loader.py | 2 +- scripts/run_tests.sh | 4 +++ spec/test/collections/test_djornl.py | 4 +-- spec/test/helpers.py | 5 +-- 8 files changed, 29 insertions(+), 35 deletions(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index 1d2443b2..55fab70c 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -16,7 +16,7 @@ services: # uncomment to mount local directories # volumes: # - ${PWD}:/app -# - "./spec:/spec/repo" +# - "./spec:/spec" depends_on: - auth - workspace diff --git a/relation_engine_server/test/test_spec_loader.py b/relation_engine_server/test/test_spec_loader.py index fdefdea1..4b21b628 100644 --- a/relation_engine_server/test/test_spec_loader.py +++ b/relation_engine_server/test/test_spec_loader.py @@ -16,10 +16,10 @@ class TestSpecLoader(unittest.TestCase): @classmethod def setUpClass(cls): cls.test_dir = os_path.join('/app', 'relation_engine_server', 'test') - cls.test_spec_dir = os_path.join(cls.test_dir, 'spec_release', 'sample_spec_release') + cls.test_spec_dir = os_path.join(cls.test_dir, 'spec_release', 'sample_spec_release', 'spec') cls.config = get_config() - cls.repo_path = cls.config['spec_paths']['repo'] + cls.repo_path = cls.config['spec_paths']['root'] for key in cls.config['spec_paths'].keys(): if cls.repo_path in cls.config['spec_paths'][key]: cls.config['spec_paths'][key] = cls.config['spec_paths'][key].replace( diff --git a/relation_engine_server/utils/config.py b/relation_engine_server/utils/config.py index 599f65fa..7756b2ef 100644 --- a/relation_engine_server/utils/config.py +++ b/relation_engine_server/utils/config.py @@ -10,7 +10,6 @@ def get_config(): """Load environment configuration data.""" spec_path = os.environ.get('SPEC_PATH', '/spec') # /spec - spec_repo_path = os.path.join(spec_path, 'repo') # /spec/repo spec_url = 'https://api.github.com/repos/kbase/relation_engine_spec' spec_release_url = os.environ.get('SPEC_RELEASE_URL') @@ -45,11 +44,10 @@ def get_config(): 'spec_paths': { 'root': spec_path, # /spec 'release_id': os.path.join(spec_path, '.release_id'), - 'repo': spec_repo_path, # /spec/repo - 'collections': os.path.join(spec_repo_path, 'collections'), # /spec/repo/collections - 'datasets': os.path.join(spec_repo_path, 'datasets'), - 'data_sources': os.path.join(spec_repo_path, 'data_sources'), - 'stored_queries': os.path.join(spec_repo_path, 'stored_queries'), - 'views': os.path.join(spec_repo_path, 'views'), + 'collections': os.path.join(spec_path, 'collections'), # /spec/collections + 'datasets': os.path.join(spec_path, 'datasets'), + 'data_sources': os.path.join(spec_path, 'data_sources'), + 'stored_queries': os.path.join(spec_path, 'stored_queries'), + 'views': os.path.join(spec_path, 'views'), } } diff --git a/relation_engine_server/utils/pull_spec.py b/relation_engine_server/utils/pull_spec.py index f5681e11..3daf5e9a 100644 --- a/relation_engine_server/utils/pull_spec.py +++ b/relation_engine_server/utils/pull_spec.py @@ -19,11 +19,11 @@ def download_specs(init_collections=True, release_url=None, reset=False): if reset or not os.path.exists(_CONF['spec_paths']['root']): # Remove the spec directory, ignoring if it is already missing shutil.rmtree(_CONF['spec_paths']['root'], ignore_errors=True) - # Recreate the spec directory so we have a clean slate, avoiding name conflicts - os.makedirs(_CONF['spec_paths']['root']) + # Directory to extract into + temp_dir = tempfile.mkdtemp() # Download and extract a new release to /spec/repo if _CONF['spec_release_path']: - _extract_tarball(_CONF['spec_release_path'], _CONF['spec_paths']['root']) + _extract_tarball(_CONF['spec_release_path'], temp_dir) else: if _CONF['spec_release_url']: tarball_url = _CONF['spec_release_url'] @@ -35,10 +35,14 @@ def download_specs(init_collections=True, release_url=None, reset=False): # Download from the tarball url to the temp file _download_file(resp, temp_file.name) # Extract the downloaded tarball into the spec path - _extract_tarball(temp_file.name, _CONF['spec_paths']['root']) - # The files will be extracted into a directory like /spec/kbase-relation_engine_spec-xyz - # We want to move that to /spec/repo - _rename_directories(_CONF['spec_paths']['root'], _CONF['spec_paths']['repo']) + _extract_tarball(temp_file.name, temp_dir) + # At this point, the repo content is extracted into the temp directory + # Remove the top-level directory extracted from the tarball + subdir = os.listdir(temp_dir)[0] + # We can move /tmp/temp_dir/spec into /spec + shutil.move(os.path.join(temp_dir, subdir, 'spec'), _CONF['spec_paths']['root']) + # Remove our temporary extraction directory + shutil.rmtree(temp_dir) # Initialize all the collections if init_collections: do_init_collections() @@ -89,19 +93,6 @@ def _extract_tarball(tar_path, dest_dir): tar.extractall(path=dest_dir) -def _rename_directories(dir_path, dest_path): - """ - Rename directories under a path. - The files will be extracted into a directory like /spec/kbase-relation_engine_spec-xyz - We want to move it to /spec/repo. - This could probably be improved to be less confusing. - """ - for file_name in os.listdir(dir_path): - file_path = os.path.join(dir_path, file_name) - if os.path.isdir(file_path): - os.rename(file_path, dest_path) - - def _has_latest_spec(info): """Check if downloaded release info matches the latest downloaded spec.""" release_id = str(info['id']) diff --git a/relation_engine_server/utils/spec_loader.py b/relation_engine_server/utils/spec_loader.py index f91daa2d..bcf0bb93 100644 --- a/relation_engine_server/utils/spec_loader.py +++ b/relation_engine_server/utils/spec_loader.py @@ -78,7 +78,7 @@ def get_schema(schema_type, name, path_only=False): json_paths = _find_paths(_CONF['spec_paths'][schema_search_type], f'{name}.json') # ensure we're using the canonical path and that all paths are unique # we are only interested in paths that are in the designated spec repo - repo_path = os.path.abspath(_CONF['spec_paths']['repo']) + repo_path = os.path.abspath(_CONF['spec_paths']['root']) all_paths_set = set(os.path.abspath(path) for path in yaml_paths + json_paths) all_paths = [p for p in all_paths_set if p.startswith(repo_path)] diff --git a/scripts/run_tests.sh b/scripts/run_tests.sh index 2c9a2899..59499134 100644 --- a/scripts/run_tests.sh +++ b/scripts/run_tests.sh @@ -2,6 +2,10 @@ set -e +# Create tarball of the test spec directory +(cd /app/relation_engine_server/test/spec_release && \ + tar czvf spec.tar.gz sample_spec_release) + flake8 --max-complexity 15 /app mypy --ignore-missing-imports /app bandit -r /app diff --git a/spec/test/collections/test_djornl.py b/spec/test/collections/test_djornl.py index f2ea6511..a481a546 100644 --- a/spec/test/collections/test_djornl.py +++ b/spec/test/collections/test_djornl.py @@ -21,7 +21,7 @@ class Test_DJORNL_Collections(unittest.TestCase): def setUpClass(cls): cls.maxDiff = None cls.config = get_config() - cls.repo_path = cls.config['spec_paths']['repo'] + cls.repo_path = cls.config['spec_paths']['root'] for key in cls.config['spec_paths'].keys(): if cls.repo_path in cls.config['spec_paths'][key]: cls.config['spec_paths'][key] = cls.config['spec_paths'][key].replace( @@ -58,7 +58,7 @@ def test_node(self, query_name=None, test_data=None): { 'data': {'_key': 'ABCDE', 'clusters': ['GO:0003700', 'GO:0003700']}, 'valid': False, - 'error': "\['GO:0003700', 'GO:0003700'\] has non-unique elements" + 'error': "\\['GO:0003700', 'GO:0003700'\\] has non-unique elements" } ] diff --git a/spec/test/helpers.py b/spec/test/helpers.py index f407a0dd..b29f6753 100644 --- a/spec/test/helpers.py +++ b/spec/test/helpers.py @@ -75,8 +75,9 @@ def check_spec_test_env(): shutil.rmtree(_CONF['spec_paths']['root'], ignore_errors=True) # Recreate the spec directory so we have a clean slate, avoiding name conflicts os.makedirs(_CONF['spec_paths']['root']) - # copy the contents of /app/spec into /spec/repo - shutil.copytree('/app/spec', _CONF['spec_paths']['repo']) + # copy the contents of /app/spec into /spec + shutil.rmtree(_CONF['spec_paths']['root'], ignore_errors=True) + shutil.copytree('/app/spec', _CONF['spec_paths']['root']) download_specs() os.environ.update({'SPEC_TEST_READY': "Done"}) From 75fd2102a5e864e81031b6a912d52d5820cea3be Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Fri, 18 Sep 2020 16:24:06 -0700 Subject: [PATCH 601/732] Fix comments --- relation_engine_server/utils/pull_spec.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/relation_engine_server/utils/pull_spec.py b/relation_engine_server/utils/pull_spec.py index 3daf5e9a..9b874a35 100644 --- a/relation_engine_server/utils/pull_spec.py +++ b/relation_engine_server/utils/pull_spec.py @@ -37,9 +37,9 @@ def download_specs(init_collections=True, release_url=None, reset=False): # Extract the downloaded tarball into the spec path _extract_tarball(temp_file.name, temp_dir) # At this point, the repo content is extracted into the temp directory - # Remove the top-level directory extracted from the tarball + # Get the top-level directory name from the tarball subdir = os.listdir(temp_dir)[0] - # We can move /tmp/temp_dir/spec into /spec + # Move /tmp/temp_dir/x/spec into /spec shutil.move(os.path.join(temp_dir, subdir, 'spec'), _CONF['spec_paths']['root']) # Remove our temporary extraction directory shutil.rmtree(temp_dir) From e879e362c7222bf0e7e0d979235dfc052d7f6e5f Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Fri, 18 Sep 2020 16:34:19 -0700 Subject: [PATCH 602/732] Remove travis build in favor of github actions --- .travis.yml | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 10dc631b..00000000 --- a/.travis.yml +++ /dev/null @@ -1,5 +0,0 @@ -sudo: required -services: -- docker -script: -- make test From 6e9406a00c687896d72fd6faa89b131c4c4f99ae Mon Sep 17 00:00:00 2001 From: ialarmedalien Date: Mon, 28 Sep 2020 14:56:27 -0700 Subject: [PATCH 603/732] Small alteration to results structure --- spec/test/djornl/results.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spec/test/djornl/results.json b/spec/test/djornl/results.json index 363614fb..9baeed2f 100644 --- a/spec/test/djornl/results.json +++ b/spec/test/djornl/results.json @@ -378,7 +378,8 @@ "message": "'Mary Poppins' is not of type 'array'", "path": ["phenotype_keys"], "value": "Mary Poppins" - } + }, + "coerce": {"nodes": [], "edges": []} }, { "params": {"phenotype_keys": ["Mary Poppins"], "distance": 0}, From 8cb734bcd139f43f448893e300f9ed88397221dc Mon Sep 17 00:00:00 2001 From: ialarmedalien Date: Tue, 29 Sep 2020 07:07:52 -0700 Subject: [PATCH 604/732] Temporary fix for "greenlet.greenlet size changed" warning --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index e8b9563e..4b48e947 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,5 @@ Flask==1.0.2 +greenlet==0.4.16 gunicorn==19.9.0 gevent==1.3.7 simplejson==3.16.0 From ea4e8b3576f809ec1b6dd0be98ae6a377f28a24a Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Mon, 5 Oct 2020 11:47:21 -0700 Subject: [PATCH 605/732] Fix the function that concatenates query parts for the api --- relation_engine_server/api_versions/api_v1.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/relation_engine_server/api_versions/api_v1.py b/relation_engine_server/api_versions/api_v1.py index 426eac1b..5dd4e699 100644 --- a/relation_engine_server/api_versions/api_v1.py +++ b/relation_engine_server/api_versions/api_v1.py @@ -177,8 +177,8 @@ 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', '') + - ws_id_text + + return '\n'.join([ + config.get('query_prefix', ''), + ws_id_text, query_text - ) + ]) From 680317a9dc004072928fb1c1748bae4824304999 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Mon, 5 Oct 2020 11:48:54 -0700 Subject: [PATCH 606/732] Version and changelog --- CHANGELOG.md | 4 ++++ VERSION | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eed9b559..b4e2293b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.0.9] - 2020-10-05 +## Fixed +- Fixed the function that concatenates parts of the query for the API + ## [0.0.8] - 2020-09-18 ### Fixed - Remove need for authentication when waiting for the ArangoDB dependency to start (this is a staging server restriction) diff --git a/VERSION b/VERSION index d169b2f2..c5d54ec3 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.0.8 +0.0.9 From 89ec55a1ccde0dbb2d3057a05d20f1320f928d52 Mon Sep 17 00:00:00 2001 From: ialarmedalien Date: Mon, 5 Oct 2020 15:37:14 -0700 Subject: [PATCH 607/732] - rename edge file headers to "edge_type" and "score" - add in parser check for missing headers --- importers/djornl/parser.py | 107 ++++++++++++++---- importers/test/test_djornl_parser.py | 46 ++++++-- spec/datasets/djornl/csv_edge.yaml | 6 +- .../merged_edges-AMW-060820_AF.tsv | 2 +- spec/test/djornl/duplicate_data/edges.tsv | 2 +- .../djornl/duplicate_data/hithruput-edges.csv | 6 +- spec/test/djornl/invalid_types/edges.tsv | 2 +- .../missing_required_headers/I2_named.tsv | 8 ++ .../missing_required_headers/I4_named.tsv | 5 + .../missing_required_headers/I6_named.tsv | 8 ++ .../djornl/missing_required_headers/edges.tsv | 9 ++ .../missing_required_headers/extra_node.tsv | 3 + .../hithruput-edges.csv | 3 + .../missing_required_headers/manifest.yaml | 35 ++++++ .../djornl/missing_required_headers/nodes.csv | 11 ++ .../missing_required_headers/pheno_nodes.csv | 5 + spec/test/djornl/test_data/edges.tsv | 2 +- .../test/djornl/test_data/hithruput-edges.csv | 2 +- 18 files changed, 220 insertions(+), 42 deletions(-) create mode 100644 spec/test/djornl/missing_required_headers/I2_named.tsv create mode 100644 spec/test/djornl/missing_required_headers/I4_named.tsv create mode 100644 spec/test/djornl/missing_required_headers/I6_named.tsv create mode 100644 spec/test/djornl/missing_required_headers/edges.tsv create mode 100644 spec/test/djornl/missing_required_headers/extra_node.tsv create mode 100644 spec/test/djornl/missing_required_headers/hithruput-edges.csv create mode 100644 spec/test/djornl/missing_required_headers/manifest.yaml create mode 100644 spec/test/djornl/missing_required_headers/nodes.csv create mode 100644 spec/test/djornl/missing_required_headers/pheno_nodes.csv diff --git a/importers/djornl/parser.py b/importers/djornl/parser.py index c62c6793..1a64eeee 100644 --- a/importers/djornl/parser.py +++ b/importers/djornl/parser.py @@ -1,8 +1,19 @@ """ -Loads the Dan Jacobson/ORNL group's gene and phenotype network data into -arangodb. +Loads the Dan Jacobson/ORNL group's gene and phenotype network data into arangodb. Running this requires a set of source files provided by the ORNL group. + +The parser sets up its configuration, including the files it will parse, from the RES_ROOT_DATA_PATH +environment variable once per instantiation. To parse a set of files from a different directory, +create a new parser with RES_ROOT_DATA_PATH set appropriately. + +Sample usage: + +from the command line: + +# load files from /path/to/data/dir +RES_ROOT_DATA_PATH=/path/to/data/dir python -m importers.djornl.parser + """ import json import requests @@ -144,9 +155,46 @@ def parser_gen(self, file): msg = f"expected {expected_col_count} cols, found {col_count}" yield(line_no, None, f"{file['path']} line {line_no}: {msg}") + def check_headers(self, headers, validator=None): + """ + Ensure that the file headers contain required columns for the data type. Checks the schema + in the validator to ensure that all required fields are present in the headers. + + :param headers: (list) list containing headers + + :param validator: (obj) validator object, with the appropriate schema loaded + + :return missing_headers: (list) list of required headers that are missing from the input. + If the list of headers supplied is valid--i.e. it + contains all the fields marked as required in the validator + schema--or no validator has been supplied, the method + returns an empty list + """ + + if validator is None: + return [] + + # check that each required header in the schema is present in headers + required_props = validator.schema['required'] + return [i for i in required_props if i not in headers] + def remap_object(self, raw_data, remap_functions): - """ Given a dict, raw_data, create a new dict, remapped_data, using the functions in the - dictionary `remap_functions`. """ + """ + Given a dict, raw_data, create a new dict, remapped_data, using the functions in the + dictionary `remap_functions`. + + :param raw_data: (dict) input data for remapping + + :param remap_fn: (dict) mapping of output param names to functions + + Each function should take the raw_data object as an + argument and return the value for the output parameter. + For parameters that can be copied over to the output + object without modification, set the value to `None` + instead of a function. + + :return remapped_data: (dict) the remapped data! + """ remapped_data = {} for (key, function) in remap_functions.items(): # these keys get copied over unchanged to the new object if they exist in the input obj @@ -189,6 +237,12 @@ def process_file(self, file, remap_fn, store_fn, err_list, validator=None): err_list.append(f"{file['path']}: no header line found") return + missing_headers = self.check_headers(cols, validator) + if missing_headers: + err_list.append( + f"{file['path']}: missing required headers: " + ", ".join(sorted(missing_headers)) + ) + return headers = cols n_stored = 0 for (line_no, cols, err_str) in file_parser: @@ -210,8 +264,15 @@ def process_file(self, file, remap_fn, store_fn, err_list, validator=None): err_list.append(err_msg) continue - # transform it using the remap_functions - datum = self.remap_object(row_object, remap_fn) + try: + # transform it using the remap_functions + datum = self.remap_object(row_object, remap_fn) + except Exception as err: + err_type = type(err) + err_list.append( + f"{file['path']} line {line_no}: error remapping data: {err_type} {err}" + ) + continue # and store it storage_error = store_fn(datum) @@ -239,22 +300,24 @@ def load_edges(self): node_name = self.config('node_name') # these functions remap the values in the columns of the input file to # appropriate values to go into Arango + # note that the functions that assume the presence of a certain key in the input + # can do so because that key is in a 'required' property in the CSV spec file remap_functions = { # create a unique key for each record - '_key': lambda row: '__'.join([row[_] for _ in ['node1', 'node2', 'layer_descrip', 'edge']]), + '_key': lambda row: '__'.join([row[_] for _ in ['node1', 'node2', 'edge_type', 'score']]), 'node1': None, # this will be deleted in the 'store' step 'node2': None, # as will this '_from': lambda row: node_name + '/' + row['node1'], '_to': lambda row: node_name + '/' + row['node2'], - 'score': lambda row: float(row['edge']), - 'edge_type': lambda row: row['layer_descrip'], + 'score': lambda row: float(row['score']), + 'edge_type': None, } # store edge data, checking for potential duplicates def store_edges(datum): # there should only be one value for each node<->node edge of a given type, # so use these values as an index key - edge_key = "__".join([datum['node1'], datum['node2'], datum['edge_type']]) + edge_key = "__".join([*sorted([datum['node1'], datum['node2']]), datum['edge_type']]) if edge_key in edge_ix: # duplicate lines can be ignored @@ -265,7 +328,7 @@ def store_edges(datum): # keep track of the nodes mentioned in this edge set for node_n in ["1", "2"]: - node_ix[datum[f"node{node_n}"]] = 1 + node_ix[datum[f"node{node_n}"]] = {'_key': datum[f"node{node_n}"]} del datum[f"node{node_n}"] edge_ix[edge_key] = datum @@ -284,7 +347,7 @@ def store_edges(datum): raise RuntimeError('\n'.join(err_list)) return { - 'nodes': [{'_key': n} for n in node_ix.keys()], + 'nodes': node_ix.values(), 'edges': edge_ix.values(), } @@ -366,19 +429,21 @@ def load_clusters(self): # these functions remap the values in the columns of the input file to # appropriate values to go into Arango + # the 'cluster_id' remap function is assigned below on a per-file basis remap_functions = { 'node_ids': lambda row: [n.strip() for n in row['node_ids'].split(',')] } - # store clusters in a dictionary with key node_id and value list of cluster IDs to which - # the node is assigned + # store cluster IDs in a list under the key 'clusters' def store_clusters(datum): cluster_id = datum['cluster_id'] for node_id in datum['node_ids']: if node_id not in node_ix: - node_ix[node_id] = [cluster_id] - elif cluster_id not in node_ix[node_id]: - node_ix[node_id].append(cluster_id) + node_ix[node_id] = {'_key': node_id, 'clusters': [cluster_id]} + elif 'clusters' not in node_ix[node_id]: + node_ix[node_id]['clusters'] = [cluster_id] + elif cluster_id not in node_ix[node_id]['clusters']: + node_ix[node_id]['clusters'].append(cluster_id) return None for file in self.config('cluster_files'): @@ -396,13 +461,7 @@ def store_clusters(datum): if len(err_list): raise RuntimeError('\n'.join(err_list)) - # gather a list of cluster IDs for each node - nodes = [{ - '_key': key, - 'clusters': cluster_data - } for (key, cluster_data) in node_ix.items()] - - return {'nodes': nodes} + return {'nodes': list(node_ix.values())} def save_dataset(self, dataset): diff --git a/importers/test/test_djornl_parser.py b/importers/test/test_djornl_parser.py index 4f95f645..4e0c68ee 100644 --- a/importers/test/test_djornl_parser.py +++ b/importers/test/test_djornl_parser.py @@ -72,6 +72,15 @@ def test_load_invalid_file(self): with self.assertRaisesRegex(RuntimeError, err_str): self.init_parser_with_path(RES_ROOT_DATA_PATH) + def test_load_missing_files(self): + """ test loading when files cannot be found """ + + RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, 'djornl', 'missing_files') + # not found + err_str = os.path.join(RES_ROOT_DATA_PATH, "edges.tsv") + ': file does not exist' + with self.assertRaisesRegex(RuntimeError, err_str): + self.init_parser_with_path(RES_ROOT_DATA_PATH) + def test_load_empty_files(self): """ test loading files containing no data """ @@ -98,14 +107,37 @@ def test_load_empty_files(self): with self.assertRaisesRegex(RuntimeError, err_str): parser.load_clusters() - def test_load_missing_files(self): - """ test loading when files cannot be found """ + def test_load_missing_headers(self): + """ test loading when files lack required headers """ - RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, 'djornl', 'missing_files') - # not found - err_str = os.path.join(RES_ROOT_DATA_PATH, "edges.tsv") + ': file does not exist' - with self.assertRaisesRegex(RuntimeError, err_str): - self.init_parser_with_path(RES_ROOT_DATA_PATH) + RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, 'djornl', 'missing_required_headers') + parser = self.init_parser_with_path(RES_ROOT_DATA_PATH) + + def create_err(args): + (file_name, missing_list) = args + return f"{file_name}: missing required headers: " + ", ".join(sorted(missing_list)) + + errs = { + 'clusters': [ + # tuple containing file name and list of column headers missing in that file + ("I2_named.tsv", ["cluster_id", "node_ids"]) + ], + 'edges': [ + ("edges.tsv", ["score"]), + ("hithruput-edges.csv", ["edge_type"]) + ], + 'nodes': [ + ("extra_node.tsv", ["node_type"]), + ("pheno_nodes.csv", ["node_id"]), + ], + } + + for data_type in errs.keys(): + with self.subTest(data_type=data_type): + method = f"load_{data_type}" + err_str = "\n".join(map(create_err, errs[data_type])) + with self.assertRaisesRegex(RuntimeError, err_str): + getattr(parser, method)() def test_load_invalid_edges(self): """ test file format errors """ diff --git a/spec/datasets/djornl/csv_edge.yaml b/spec/datasets/djornl/csv_edge.yaml index 19617c5b..c166eb66 100644 --- a/spec/datasets/djornl/csv_edge.yaml +++ b/spec/datasets/djornl/csv_edge.yaml @@ -3,16 +3,16 @@ name: csv_edge title: CSV edge file syntax description: Jacobson lab Arabidopsis edge data file columns for generic node-to-node edges with scores type: object -required: [node1, node2, edge, layer_descrip] +required: [node1, node2, score, edge_type] properties: node1: $ref: definitions.yaml#/definitions/djornl_edge/_from node2: $ref: definitions.yaml#/definitions/djornl_edge/_to - edge: + score: # pre-transformation, the parser treats this as a string type: string format: regex pattern: ^\d+(\.\d+)?$ - layer_descrip: + edge_type: $ref: edge_type.yaml diff --git a/spec/test/djornl/col_count_errors/merged_edges-AMW-060820_AF.tsv b/spec/test/djornl/col_count_errors/merged_edges-AMW-060820_AF.tsv index a2d07a73..0cb3f090 100644 --- a/spec/test/djornl/col_count_errors/merged_edges-AMW-060820_AF.tsv +++ b/spec/test/djornl/col_count_errors/merged_edges-AMW-060820_AF.tsv @@ -1,4 +1,4 @@ -node1 node2 edge edge_descrip layer_descrip +node1 node2 score edge_descrip edge_type As2 AT1G01040 5.422046084731258 AraGWAS-Association_score AraGWAS-Phenotype_Associations As75 AT1G01020 39.98573324312915 AraGWAS-Association_score AraGWAS-Phenotype_Associations AT1G01010 AT1G01020 2.39322646755088 AraNetv2_log-likelihood-score AraNetv2-HT_high-throughput-ppi diff --git a/spec/test/djornl/duplicate_data/edges.tsv b/spec/test/djornl/duplicate_data/edges.tsv index 432c2deb..be7a654a 100644 --- a/spec/test/djornl/duplicate_data/edges.tsv +++ b/spec/test/djornl/duplicate_data/edges.tsv @@ -1,4 +1,4 @@ -node1 node2 edge edge_descrip layer_descrip +node1 node2 score edge_descrip edge_type As2 AT1G01020 8.4 AraGWAS-Association_score AraGWAS-Phenotype_Associations As2 AT1G01040 5.4 AraGWAS-Association_score AraGWAS-Phenotype_Associations As75 AT1G01020 39.9 AraGWAS-Association_score AraGWAS-Phenotype_Associations diff --git a/spec/test/djornl/duplicate_data/hithruput-edges.csv b/spec/test/djornl/duplicate_data/hithruput-edges.csv index c11caa3d..e02aad44 100644 --- a/spec/test/djornl/duplicate_data/hithruput-edges.csv +++ b/spec/test/djornl/duplicate_data/hithruput-edges.csv @@ -1,9 +1,9 @@ -node1,node2,edge,edge_descrip,layer_descrip +node1,node2,score,edge_descrip,edge_type AT1G01010,AT1G01020,2.3,AraNetv2_log-likelihood-score,AraNetv2-HT_high-throughput-ppi AT1G01010,AT1G01030,2.4,AraNetv2_log-likelihood-score,AraNetv2-HT_high-throughput-ppi # potentially erroneous line AT1G01010,AT1G01030,2.7,AraNetv2_log-likelihood-score,AraNetv2-HT_high-throughput-ppi # duplicated line from the other file -AT1G01050,AT1G01060,2.7,AraNetv2_log-likelihood-score,AraNetv2-LC_lit-curated-ppi +AT1G01060,AT1G01050,2.7,AraNetv2_log-likelihood-score,AraNetv2-LC_lit-curated-ppi # potentially erroneous duplication from the other file -AT1G01030,AT1G01050,2.6000001,AraNetv2_log-likelihood-score,AraNetv2-CX_pairwise-gene-coexpression +AT1G01050,AT1G01030,2.6000001,AraNetv2_log-likelihood-score,AraNetv2-CX_pairwise-gene-coexpression diff --git a/spec/test/djornl/invalid_types/edges.tsv b/spec/test/djornl/invalid_types/edges.tsv index 06bbe9fd..bad2b9b4 100644 --- a/spec/test/djornl/invalid_types/edges.tsv +++ b/spec/test/djornl/invalid_types/edges.tsv @@ -1,5 +1,5 @@ # data_type: edge -node1 node2 edge edge_descrip layer_descrip +node1 node2 score edge_descrip edge_type As2 AT1G01020 8.422046084731258 AraGWAS-Association_score Same-Old-Stuff As2 AT1G01040 6 AraGWAS-Association_score AraGWAS-Phenotype_Associations As75 AT1G01020 39.98573324312915 AraGWAS-Association_score AraGWAS-Phenotype_Associations diff --git a/spec/test/djornl/missing_required_headers/I2_named.tsv b/spec/test/djornl/missing_required_headers/I2_named.tsv new file mode 100644 index 00000000..3767347f --- /dev/null +++ b/spec/test/djornl/missing_required_headers/I2_named.tsv @@ -0,0 +1,8 @@ +cluster node_list +# data_type: cluster +# cluster_prefix: markov_i2 +# title: Markov clustering, inflation = 2 +Cluster1 AT1G01010,AT1G01030,AT1G01040 +Cluster2 AT1G01050,AT1G01060,AT1G01070 +Cluster3 AT1G01090 +Cluster5 AT1G01020 diff --git a/spec/test/djornl/missing_required_headers/I4_named.tsv b/spec/test/djornl/missing_required_headers/I4_named.tsv new file mode 100644 index 00000000..6e7d91e4 --- /dev/null +++ b/spec/test/djornl/missing_required_headers/I4_named.tsv @@ -0,0 +1,5 @@ +cluster_id node_ids +# cluster_prefix: markov_i4 +# title: Markov clustering, inflation = 4 +# data_type: cluster +Cluster3 AT1G01080 diff --git a/spec/test/djornl/missing_required_headers/I6_named.tsv b/spec/test/djornl/missing_required_headers/I6_named.tsv new file mode 100644 index 00000000..e7688f17 --- /dev/null +++ b/spec/test/djornl/missing_required_headers/I6_named.tsv @@ -0,0 +1,8 @@ +cluster_id node_ids +# data_type: cluster +# cluster_prefix: markov_i6 +# title: Markov clustering, inflation = 6 +Cluster1 AT1G01040,AT1G01090 +Cluster2 AT1G01070 +Cluster3 AT1G01010,AT1G01020,AT1G01030 +# Cluster4 diff --git a/spec/test/djornl/missing_required_headers/edges.tsv b/spec/test/djornl/missing_required_headers/edges.tsv new file mode 100644 index 00000000..1d37c927 --- /dev/null +++ b/spec/test/djornl/missing_required_headers/edges.tsv @@ -0,0 +1,9 @@ +node1 node2 edge edge_descrip edge_type +As2 AT1G01020 8.4 AraGWAS-Association_score AraGWAS-Phenotype_Associations +As2 AT1G01040 5.4 AraGWAS-Association_score AraGWAS-Phenotype_Associations +As75 AT1G01020 39.9 AraGWAS-Association_score AraGWAS-Phenotype_Associations +AT1G01010 AT1G01040 2.5 AraNetv2_log-likelihood-score AraNetv2-DC_domain-co-occurrence +AT1G01010 AT1G01040 170.5 AraNetv2_log-likelihood-score AraNetv2-LC_lit-curated-ppi +AT1G01030 AT1G01050 2.6 AraNetv2_log-likelihood-score AraNetv2-CX_pairwise-gene-coexpression +AT1G01050 AT1G01060 2.7 AraNetv2_log-likelihood-score AraNetv2-LC_lit-curated-ppi +AT1G01080 AT1G01090 2.8 AraNetv2_log-likelihood-score AraNetv2-LC_lit-curated-ppi diff --git a/spec/test/djornl/missing_required_headers/extra_node.tsv b/spec/test/djornl/missing_required_headers/extra_node.tsv new file mode 100644 index 00000000..d09b410f --- /dev/null +++ b/spec/test/djornl/missing_required_headers/extra_node.tsv @@ -0,0 +1,3 @@ +# data_type: node +node_id node_types transcript gene_symbol gene_full_name gene_model_type TAIR_Computational_description TAIR_Curator_summary TAIR_short_description GO_description GO_terms MapMan_bin MapMan_name MapMan_description +AT1G01100 gene AT1G01100.4 protein_coding 60S acidic ribosomal protein family;(source:Araport11) 60S acidic ribosomal protein family structural constituent of ribosome, ribonucleoprotein complex binding, protein kinase activator activity GO:0003735, GO:0043021, GO:0030295 17.1.2.1.46 .Protein biosynthesis.ribosome biogenesis.large ribosomal subunit (LSU).LSU proteome.component RPP1 component RPP1 of LSU proteome component (original description: pep chromosome:TAIR10:1:50090:51187:-1 gene:AT1G01100 transcript:AT1G01100.4 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:RPP1A description:60S acidic ribosomal protein P1-1 [Source:UniProtKB/Swiss-Prot;Acc:Q8LCW9]) diff --git a/spec/test/djornl/missing_required_headers/hithruput-edges.csv b/spec/test/djornl/missing_required_headers/hithruput-edges.csv new file mode 100644 index 00000000..e4dbc008 --- /dev/null +++ b/spec/test/djornl/missing_required_headers/hithruput-edges.csv @@ -0,0 +1,3 @@ +node1,node2,score,edge_descrip,layer_descrip +AT1G01010,AT1G01020,2.3,AraNetv2_log-likelihood-score,AraNetv2-HT_high-throughput-ppi +AT1G01010,AT1G01030,2.4,AraNetv2_log-likelihood-score,AraNetv2-HT_high-throughput-ppi diff --git a/spec/test/djornl/missing_required_headers/manifest.yaml b/spec/test/djornl/missing_required_headers/manifest.yaml new file mode 100644 index 00000000..88098f82 --- /dev/null +++ b/spec/test/djornl/missing_required_headers/manifest.yaml @@ -0,0 +1,35 @@ +name: Dan Jacobson Exascale data +release_date: "2020-06-06" +home_url: "https://github.com/kbase/exascale_data" +file_list: + - data_type: edge + path: edges.tsv + date: "2020-12-25" + + - data_type: edge + path: hithruput-edges.csv + date: "2020-12-25" + + - data_type: node + path: nodes.csv + date: "2019-01-01" + + - data_type: cluster + cluster_prefix: markov_i2 + path: I2_named.tsv + + - data_type: cluster + cluster_prefix: markov_i4 + path: I4_named.tsv + + - data_type: cluster + cluster_prefix: markov_i6 + path: I6_named.tsv + + - data_type: node + path: extra_node.tsv + date: "2019-01-01" + + - data_type: node + path: pheno_nodes.csv + date: "2019-01-01" diff --git a/spec/test/djornl/missing_required_headers/nodes.csv b/spec/test/djornl/missing_required_headers/nodes.csv new file mode 100644 index 00000000..92f60761 --- /dev/null +++ b/spec/test/djornl/missing_required_headers/nodes.csv @@ -0,0 +1,11 @@ +# data_type: node +node_id,node_type,transcript,gene_symbol,gene_full_name,gene_model_type,TAIR_Computational_description,TAIR_Curator_summary,TAIR_short_description,GO_description,GO_terms,MapMan_bin,MapMan_name,MapMan_description,pheno_AraGWAS_ID,pheno_description,pheno_pto_name,pheno_pto_description,pheno_ref,User_Notes +AT1G01010,gene,AT1G01010.1,NTL10,NAC domain containing protein 1,protein_coding,NAC domain containing protein 1;(source:Araport11),,NAC domain containing protein 1,"DNA-binding transcription factor activity, DNA binding","GO:0003700, GO:0003677",15.5.17,.RNA biosynthesis.transcriptional regulation.transcription factor (NAC),transcription factor (NAC) (original description: pep chromosome:TAIR10:1:3631:5899:1 gene:AT1G01010 transcript:AT1G01010.1 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:NAC001 description:NAC domain-containing protein 1 [Source:UniProtKB/Swiss-Prot;Acc:Q0WV96]),,,,,, +AT1G01020,gene,AT1G01020.6,ARV1,,protein_coding,ARV1 family protein;(source:Araport11),,,molecular_function,GO:0003674,35.1,not assigned.annotated,(original description: pep chromosome:TAIR10:1:6788:8737:-1 gene:AT1G01020 transcript:AT1G01020.6 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:ARV1 description:ARV1 family protein [Source:UniProtKB/TrEMBL;Acc:Q5MK24]) & no description available(sp|q5mk24|arv1_arath : 99.4),,,,,, +AT1G01030,gene,AT1G01030.2,NGA3,NGATHA3,protein_coding,AP2/B3-like transcriptional factor family protein;(source:Araport11),,,"DNA-binding transcription factor activity, DNA binding","GO:0003700, GO:0003677",15.5.5.3,.RNA biosynthesis.transcriptional regulation.B3 transcription factor superfamily.transcription factor (RAV/NGATHA),transcription factor (RAV/NGATHA) (original description: pep chromosome:TAIR10:1:11649:13714:-1 gene:AT1G01030 transcript:AT1G01030.2 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:NGA3 description:B3 domain-containing transcription factor NGA3 [Source:UniProtKB/Swiss-Prot;Acc:Q9MAN1]),,,,,, +AT1G01040,gene,AT1G01040.2,SUS1,SUSPENSOR 1,protein_coding,dicer-like 1;(source:Araport11),"Encodes a Dicer homolog. Dicer is a RNA helicase involved in microRNA processing. Mutations in this locus can result in embryo lethality. Embryo shape at seed maturity is globular-elongate. Other mutants convert the floral meristems to an indeterminate state, others yet show defects in ovule development. mRNA is expressed in all shoot tissues. DCL1 is able to produce miRNAs and siRNAs. The mRNA is cell-to-cell mobile.",dicer-like 1,"metal ion binding, protein binding, ribonuclease III activity, ATP-dependent helicase activity, ATP binding, RNA binding, helicase activity, double-stranded RNA binding, DNA binding","GO:0046872, GO:0005515, GO:0004525, GO:0008026, GO:0005524, GO:0003723, GO:0004386, GO:0003725, GO:0003677",16.10.2.1.1,.RNA processing.mRNA silencing.miRNA pathway.DCL1-HYL1 miRNA biogenesis complex.endoribonuclease component DCL1,endoribonuclease component DCL1 of DCL1-HYL1 miRNA biogenesis complex (original description: pep chromosome:TAIR10:1:23416:31120:1 gene:AT1G01040 transcript:AT1G01040.2 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:DCL1 description:Dicer-like 1 [Source:UniProtKB/TrEMBL;Acc:F4HQG6]),,,,,, +AT1G01050,gene,AT1G01050.2,PPa1,pyrophosphorylase 1,protein_coding,pyrophosphorylase 1;(source:Araport11),,,inorganic diphosphatase activity,GO:0004427,35.1,not assigned.annotated,(original description: pep chromosome:TAIR10:1:31382:33009:-1 gene:AT1G01050 transcript:AT1G01050.2 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:PPA1 description:Soluble inorganic pyrophosphatase 1 [Source:UniProtKB/Swiss-Prot;Acc:Q93V56]) & Soluble inorganic pyrophosphatase 1 OS=Arabidopsis thaliana (sp|q93v56|ipyr1_arath : 419.0),,,,,, +AT1G01060,gene,AT1G01060.8,LHY1,LATE ELONGATED HYPOCOTYL 1,protein_coding,Homeodomain-like superfamily protein;(source:Araport11),,,"DNA-binding transcription factor activity, DNA binding, transcription regulatory region DNA binding","GO:0003700, GO:0003677, GO:0044212",27.1.1,.Multi-process regulation.circadian clock system.core oscillator protein (LHY|CCA1),circadian clock core oscillator protein (LHY|CCA1) (original description: pep chromosome:TAIR10:1:33967:37230:-1 gene:AT1G01060 transcript:AT1G01060.8 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:LHY description:LHY1 [Source:UniProtKB/TrEMBL;Acc:A0A178W761]),,,,,, +AT1G01070,gene,AT1G01070.2,UMAMIT28,Usually multiple acids move in and out Transporters 28,protein_coding,nodulin MtN21 /EamA-like transporter family protein;(source:Araport11),Encodes a plasma membrane-localized amino acid transporter likely involved in amino acid export in the developing seed.,nodulin MtN21 /EamA-like transporter family protein,L-glutamine transmembrane transporter activity,GO:0015186,24.2.1.5,.Solute transport.carrier-mediated transport.DMT superfamily.solute transporter (UmamiT),solute transporter (UmamiT) (original description: pep chromosome:TAIR10:1:38752:40945:-1 gene:AT1G01070 transcript:AT1G01070.2 gene_biotype:protein_coding transcript_biotype:protein_coding description:WAT1-related protein [Source:UniProtKB/TrEMBL;Acc:A0A178WFU3]),,,,,, +AT1G01080,gene,AT1G01080.3,,,protein_coding,RNA-binding (RRM/RBD/RNP motifs) family protein;(source:Araport11),,,"RNA binding, mRNA binding","GO:0003723, GO:0003729",35.1,not assigned.annotated,"(original description: pep chromosome:TAIR10:1:44970:47059:-1 gene:AT1G01080 transcript:AT1G01080.3 gene_biotype:protein_coding transcript_biotype:protein_coding description:RNA-binding (RRM/RBD/RNP motifs) family protein [Source:UniProtKB/TrEMBL;Acc:F4HQH8]) & 33 kDa ribonucleoprotein, chloroplastic OS=Nicotiana sylvestris (sp|p19684|roc5_nicsy : 109.0)",,,,,, +AT1G01090,gene,AT1G01090.1,PDH-E1 ALPHA,pyruvate dehydrogenase E1 alpha,protein_coding,pyruvate dehydrogenase E1 alpha;(source:Araport11),pyruvate dehydrogenase E1 alpha subunit,pyruvate dehydrogenase E1 alpha,"pyruvate dehydrogenase (acetyl-transferring) activity, protein binding","GO:0004739, GO:0005515",5.1.2.2.1.1,.Lipid metabolism.fatty acid biosynthesis.acetyl-CoA generation.plastidial pyruvate dehydrogenase complex.E1 pyruvate dehydrogenase subcomplex.subunit alpha,subunit alpha of E1 pyruvate dehydrogenase component (original description: pep chromosome:TAIR10:1:47234:49304:-1 gene:AT1G01090 transcript:AT1G01090.1 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:PDH-E1 ALPHA description:Pyruvate dehydrogenase E1 component subunit alpha [Source:UniProtKB/TrEMBL;Acc:A0A178W8A7]),,,,,, diff --git a/spec/test/djornl/missing_required_headers/pheno_nodes.csv b/spec/test/djornl/missing_required_headers/pheno_nodes.csv new file mode 100644 index 00000000..88e15082 --- /dev/null +++ b/spec/test/djornl/missing_required_headers/pheno_nodes.csv @@ -0,0 +1,5 @@ +id,node_type,pheno_AraGWAS_ID,pheno_description,pheno_pto_name,pheno_pto_description,pheno_ref,User_Notes +As2,pheno,10.21958/phenotype:103,,bacterial disease resistance,The resistance exhibited by a plant or a group of plants (population) in response to the disease caused by a bacterial pathogen infection as compared to the susceptible and/or the reference plants of the same species. [GR:pj],"Atwell et. al, Nature 2010", +As75,pheno,10.21958/phenotype:67,"Arsenic concentrations in leaves, grown in soil. Elemental analysis was performed with an ICP-MS (PerkinElmer). Sample normalized to calculated weights as described in Baxter et al., 2008",arsenic concentration,A mineral and ion content related trait (TO:0000465) which is the concentration of arsenic (CHEBI:22632) in some plant structure (PO:0009011). [GR:Karthik],"Atwell et. al, Nature 2010", +Na23,pheno,10.21958/phenotype:5,"Sodium concentrations in leaves, grown in soil. Elemental analysis was performed with an ICP-MS (PerkinElmer). Sample normalized to calculated weights as described in Baxter et al., 2008",sodium concentration,The total sodium ion concentration measured in a given volume of a plant or a plant part or plant extract. [GR:pj],"Atwell et. al, Nature 2010", +SDV,pheno,10.21958/phenotype:104,"Number of days following stratification to opening of first flower. The experiment was stopped at 200 d, and accessions that had not flowered at that point were assigned a value of 200",days to flowering trait,"A flowering time trait (TO:0002616)which is the number of days required for an individual flower (PO:0009046), a whole plant (PO:0000003) or a plant population to reach flowering stage (PO:0007616) from a predetermined time point (e.g. the date of seed sowing, seedling transplant, or seedling emergence). [GR:pj, TO:cooperl]","Atwell et. al, Nature 2010", diff --git a/spec/test/djornl/test_data/edges.tsv b/spec/test/djornl/test_data/edges.tsv index ee443140..3fc69278 100644 --- a/spec/test/djornl/test_data/edges.tsv +++ b/spec/test/djornl/test_data/edges.tsv @@ -1,4 +1,4 @@ -node1 node2 edge edge_descrip layer_descrip +node1 node2 score edge_descrip edge_type As2 AT1G01020 8.4 AraGWAS-Association_score AraGWAS-Phenotype_Associations As2 AT1G01040 5.4 AraGWAS-Association_score AraGWAS-Phenotype_Associations As75 AT1G01020 39.9 AraGWAS-Association_score AraGWAS-Phenotype_Associations diff --git a/spec/test/djornl/test_data/hithruput-edges.csv b/spec/test/djornl/test_data/hithruput-edges.csv index 586476ab..cf771db2 100644 --- a/spec/test/djornl/test_data/hithruput-edges.csv +++ b/spec/test/djornl/test_data/hithruput-edges.csv @@ -1,3 +1,3 @@ -node1,node2,edge,edge_descrip,layer_descrip +node1,node2,score,edge_descrip,edge_type AT1G01010,AT1G01020,2.3,AraNetv2_log-likelihood-score,AraNetv2-HT_high-throughput-ppi AT1G01010,AT1G01030,2.4,AraNetv2_log-likelihood-score,AraNetv2-HT_high-throughput-ppi From 786046595b8d7b6efd4e4b06add4defed02adfed Mon Sep 17 00:00:00 2001 From: ialarmedalien Date: Mon, 5 Oct 2020 16:14:07 -0700 Subject: [PATCH 608/732] Refactoring error tests to use a helper --- importers/test/test_djornl_parser.py | 154 ++++++++++++--------------- 1 file changed, 71 insertions(+), 83 deletions(-) diff --git a/importers/test/test_djornl_parser.py b/importers/test/test_djornl_parser.py index 4e0c68ee..5f00aac2 100644 --- a/importers/test/test_djornl_parser.py +++ b/importers/test/test_djornl_parser.py @@ -35,6 +35,18 @@ def init_parser_with_path(self, root_path): parser._configure() return parser + def test_errors(self, parser=None, errs={}): + if parser is None: + self.assertTrue(True) + return + + for data_type in errs.keys(): + with self.subTest(data_type=data_type): + method = f"load_{data_type}" + err_str = "\n".join(errs[data_type]) + with self.assertRaisesRegex(RuntimeError, err_str): + getattr(parser, method)() + def test_missing_required_env_var(self): '''test that the parser exits with code 1 if the RES_ROOT_DATA_PATH env var is not set''' with self.assertRaisesRegex(RuntimeError, 'Missing required env var: RES_ROOT_DATA_PATH'): @@ -88,24 +100,19 @@ def test_load_empty_files(self): RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, 'djornl', 'empty_files') parser = self.init_parser_with_path(RES_ROOT_DATA_PATH) - # header only, no content - err_str = 'aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv: no valid data found' - with self.assertRaisesRegex(RuntimeError, err_str): - parser.load_nodes() - - # comments only - err_str = 'merged_edges-AMW-060820_AF.tsv: no header line found' - with self.assertRaisesRegex(RuntimeError, err_str): - parser.load_edges() - - # mix of problems - err_str = "\n".join([ - 'cluster_data/headers_only.tsv: no valid data found', - 'cluster_data/no_content.tsv: no header line found', - 'cluster_data/comment_only.tsv: no header line found', - ]) - with self.assertRaisesRegex(RuntimeError, err_str): - parser.load_clusters() + errs = { + # mix of problems + 'clusters': [ + 'cluster_data/headers_only.tsv: no valid data found', + 'cluster_data/no_content.tsv: no header line found', + 'cluster_data/comment_only.tsv: no header line found', + ], + # comments only + 'edges': ['merged_edges-AMW-060820_AF.tsv: no header line found'], + # header only, no content + 'nodes': ['aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv: no valid data found'], + } + self.test_errors(parser, errs) def test_load_missing_headers(self): """ test loading when files lack required headers """ @@ -139,46 +146,30 @@ def create_err(args): with self.assertRaisesRegex(RuntimeError, err_str): getattr(parser, method)() - def test_load_invalid_edges(self): - """ test file format errors """ - - # path: test/djornl/invalid_types - RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, 'djornl', 'invalid_types') - parser = self.init_parser_with_path(RES_ROOT_DATA_PATH) - - # invalid edge type, invalid scores - edge_err_msg = "\n".join([ - r"edges.tsv line 3: 'Same-Old-Stuff' is not valid under any of the given schemas", - r"edges.tsv line 7: '2.' does not match .*?", - r"edges.tsv line 8: 'raNetv2-DC_' is not valid under any of the given schemas", - r"edges.tsv line 10: 'score!' does not match .*?" - ]) - with self.assertRaisesRegex(RuntimeError, edge_err_msg): - parser.load_edges() - - def test_load_invalid_nodes(self): - """ test file format errors """ - - # path: test/djornl/invalid_types - RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, 'djornl', 'invalid_types') - parser = self.init_parser_with_path(RES_ROOT_DATA_PATH) - - # invalid node type - node_err_msg = "nodes.csv line 5: 'Monkey' is not valid under any of the given schemas" - with self.assertRaisesRegex(RuntimeError, node_err_msg): - parser.load_nodes() - - def test_load_invalid_clusters(self): + def test_load_invalid_types(self): """ test file format errors """ # path: test/djornl/invalid_types RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, 'djornl', 'invalid_types') parser = self.init_parser_with_path(RES_ROOT_DATA_PATH) - # invalid node type - cluster_err_msg = "markov2_named.tsv line 7: 'HoneyNutCluster3' does not match" - with self.assertRaisesRegex(RuntimeError, cluster_err_msg): - parser.load_clusters() + errs = { + # invalid edge type, invalid scores + 'edges': [ + r"edges.tsv line 3: 'Same-Old-Stuff' is not valid under any of the given schemas", + r"edges.tsv line 7: '2.' does not match .*?", + r"edges.tsv line 8: 'raNetv2-DC_' is not valid under any of the given schemas", + r"edges.tsv line 10: 'score!' does not match .*?" + ], + # invalid node type + 'nodes': [ + "nodes.csv line 5: 'Monkey' is not valid under any of the given schemas", + ], + 'clusters': [ + "markov2_named.tsv line 7: 'HoneyNutCluster3' does not match" + ] + } + self.test_errors(parser, errs) def test_load_col_count_errors(self): """ test files with invalid numbers of columns """ @@ -187,17 +178,18 @@ def test_load_col_count_errors(self): RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, 'djornl', 'col_count_errors') parser = self.init_parser_with_path(RES_ROOT_DATA_PATH) - # not enough cols - edge_err_msg = 'merged_edges-AMW-060820_AF.tsv line 6: expected 5 cols, found 3' - with self.assertRaisesRegex(RuntimeError, edge_err_msg): - parser.load_edges() - - # too many cols - node_err_msg = 'aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv line 3: expected 20 cols, found 22' - with self.assertRaisesRegex(RuntimeError, node_err_msg): - parser.load_nodes() + errs = { + 'edges': [ + 'merged_edges-AMW-060820_AF.tsv line 6: expected 5 cols, found 3' + ], + 'nodes': [ + 'aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv line 3: expected 20 cols, found 22' + ] + } + self.test_errors(parser, errs) def test_load_valid_edge_data(self): + """ensure that valid edge data can be parsed""" RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, 'djornl', 'test_data') parser = self.init_parser_with_path(RES_ROOT_DATA_PATH) @@ -211,22 +203,24 @@ def test_load_valid_edge_data(self): self.assertEqual(edge_data, expected) - def test_load_valid_node_metadata(self): + def test_load_valid_node_data(self): + """ensure that valid node data can be parsed""" RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, 'djornl', 'test_data') parser = self.init_parser_with_path(RES_ROOT_DATA_PATH) - node_metadata = parser.load_nodes() + node_data = parser.load_nodes() expected = self.json_data["load_nodes"] - for data_structure in [node_metadata, expected]: + for data_structure in [node_data, expected]: for k in data_structure.keys(): data_structure[k] = sorted(data_structure[k], key=lambda n: n['_key']) data_structure[k] = [n['_key'] for n in data_structure[k]] - self.assertEqual(node_metadata, expected) + self.assertEqual(node_data, expected) def test_load_valid_cluster_data(self): + """ensure that valid cluster data can be parsed""" RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, 'djornl', 'test_data') parser = self.init_parser_with_path(RES_ROOT_DATA_PATH) @@ -237,28 +231,22 @@ def test_load_valid_cluster_data(self): self.json_data["load_clusters"] ) - def test_duplicate_edge_data(self): - """ test files with duplicate edge data, which should throw an error """ - - RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, 'djornl', 'duplicate_data') - parser = self.init_parser_with_path(RES_ROOT_DATA_PATH) - - err_msg = "\n".join([ - "hithruput-edges.csv line 5: duplicate data for edge AT1G01010__AT1G01030__AraNetv2-HT_.*?", - "hithruput-edges.csv line 9: duplicate data for edge AT1G01030__AT1G01050__AraNetv2-CX_.*?" - ]) - with self.assertRaisesRegex(RuntimeError, err_msg): - parser.load_edges() - - def test_duplicate_node_data(self): - """ test files with duplicate node data, which should throw an error """ + def test_duplicate_data(self): + """ test files with duplicate data that should throw an error """ RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, 'djornl', 'duplicate_data') parser = self.init_parser_with_path(RES_ROOT_DATA_PATH) - err_msg = "extra_node.tsv line 5: duplicate data for node AT1G01080" - with self.assertRaisesRegex(RuntimeError, err_msg): - parser.load_nodes() + errs = { + 'edges': [ + "hithruput-edges.csv line 5: duplicate data for edge AT1G01010__AT1G01030__AraNetv2-HT_.*?", + "hithruput-edges.csv line 9: duplicate data for edge AT1G01030__AT1G01050__AraNetv2-CX_.*?" + ], + 'nodes': [ + "extra_node.tsv line 5: duplicate data for node AT1G01080" + ], + } + self.test_errors(parser, errs) def test_duplicate_cluster_data(self): """ test files with duplicate cluster data, which should be seamlessly merged """ From 2203ee1e9f4ea07dae3d9cce78dbe917c4855c10 Mon Sep 17 00:00:00 2001 From: ialarmedalien Date: Mon, 5 Oct 2020 16:35:13 -0700 Subject: [PATCH 609/732] A more sophisticated node merge --- importers/djornl/parser.py | 86 ++++++++++++++++++++++++++-- importers/test/test_djornl_parser.py | 80 ++++++++++++++++++++++++++ 2 files changed, 161 insertions(+), 5 deletions(-) diff --git a/importers/djornl/parser.py b/importers/djornl/parser.py index c62c6793..bad3ee05 100644 --- a/importers/djornl/parser.py +++ b/importers/djornl/parser.py @@ -288,6 +288,78 @@ def store_edges(datum): 'edges': edge_ix.values(), } + def _try_node_merge(self, existing_node, new_node, path=[]): + """ + Try to merge two data structures. These should be JSON compatible, so they will be limited + to lists, dicts, and scalar data types. + + This method tests the keys/values of the two dict objects provided and depending on the type + of the values, merges them or records an error: + + - scalar (strings, ints, floats, etc.): record an error on mismatches + - list: merge list contents, removing duplicates and preserving order + - dict: run _try_node_merge recursively on it + - mismatch of data types between the two nodes: record an error + + :param existing_node: (dict) existing node + :param new_node: (dict) node data to be merged into it + :param path: (list) path to this node in a larger data structure + + :return (merge, err_list): (tuple) + If successful, the method returns the merged dict and [] + If there were errors, err_list will be populated with the + keys/values where mismatches occurred. + """ + + # merge the dictionaries + merge = {**existing_node, **new_node} + + # find the shared keys -- keys in both existing and new nodes where the values differ + shared_keys = [i for i in new_node if i in existing_node and new_node[i] != existing_node[i]] + + # if there were no shared keys, return the merged list + if not shared_keys: + return (merge, []) + + # otherwise, we need to remove the shared keys and examine them individually + for k in shared_keys: + del merge[k] + + err_list = [] + # go through the dict keys, checking their type + for k in sorted(shared_keys): + value_type = type(existing_node[k]) + + # do the types match? If not, these values cannot be merged + if type(new_node[k]) != value_type: + err_list.append("/".join(path+[k])) + continue + + if value_type == list: + # merge lists, preserving order. Data type agnostic. + merge[k] = [] + for i in existing_node[k] + new_node[k]: + if i not in merge[k]: + merge[k].append(i) + continue + + elif value_type == dict: + # recursively check dict data using _try_node_merge + (k_merged, k_errs) = self._try_node_merge(existing_node[k], new_node[k], path+[k]) + if k_errs: + err_list = err_list + k_errs + continue + merge[k] = k_merged + + else: + # this is a scalar (string, number, etc.) so it can't be merged + err_list.append("/".join(path+[k])) + + # at some point, it may be useful to examine these errors in more detail + if err_list: + merge = None + return (merge, err_list) + def load_nodes(self): """Load node metadata""" @@ -332,11 +404,15 @@ def go_terms(row): def store_nodes(datum): # check whether we have this node already if datum['_key'] in node_ix: - # report non-matching data - if datum != node_ix[datum['_key']]: - return f"duplicate data for node {datum['_key']}" - # otherwise, it's duplicated line: ignore - return None + # identical data: ignore it + if datum == node_ix[datum['_key']]: + return None + + # try merging the data + (merged, err_list) = self._try_node_merge(node_ix[datum['_key']], datum) + if err_list: + return "duplicate data for node " + datum['_key'] + datum = merged node_ix[datum['_key']] = datum return None diff --git a/importers/test/test_djornl_parser.py b/importers/test/test_djornl_parser.py index 4f95f645..789f6737 100644 --- a/importers/test/test_djornl_parser.py +++ b/importers/test/test_djornl_parser.py @@ -240,3 +240,83 @@ def test_duplicate_cluster_data(self): cluster_data, self.json_data["load_clusters"] ) + + def test_try_node_merge(self): + """test node merging""" + + RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, 'djornl', 'test_data') + parser = self.init_parser_with_path(RES_ROOT_DATA_PATH) + + tests = [ + { + 'desc': 'existing node is just a _key', + 'old': {'_key': 'abcde'}, + 'new': {'_key': 'abcde', 'node_type': 'gene', 'node_quality': 'highest'}, + 'out': ({'_key': 'abcde', 'node_type': 'gene', 'node_quality': 'highest'}, []), + }, + { + 'desc': 'new node is just a _key', + 'old': {'_key': 'abcde', 'node_type': 'gene'}, + 'new': {'_key': 'abcde'}, + 'out': ({'_key': 'abcde', 'node_type': 'gene'}, []), + }, + { + 'desc': 'no overlapping keys', + 'old': {'_key': 'abcde', 'node_type': 'gene'}, + 'new': {'_key': 'abcde', 'node_size': 24}, + 'out': ({'_key': 'abcde', 'node_type': 'gene', 'node_size': 24}, []), + }, + { + 'desc': 'mergeable fields', + 'old': {'_key': 'abcde', 'go_terms': ['this', 'that'], 'colour': 'pink'}, + 'new': {'_key': 'abcde', 'go_terms': ['the other']}, + 'out': ({'_key': 'abcde', 'go_terms': ['this', 'that', 'the other'], 'colour': 'pink'}, []), + }, + { + 'desc': 'mergeable fields, removing list duplicates', + 'old': {'_key': 'abcde', 'go_terms': ['this', 'that', 'this', 'that', 'the'], 'colour': 'pink'}, + 'new': {'_key': 'abcde', 'go_terms': ['this', 'the', 'that', 'that', 'other', 'other']}, + 'out': ({'_key': 'abcde', 'go_terms': ['this', 'that', 'the', 'other'], 'colour': 'pink'}, []), + }, + { + 'desc': 'mergeable fields, complex list contents, removing list duplicates', + 'old': {'_key': 123, 'list': [{'a': 'b'}, {'a': 'b'}, {'c': 'd'}]}, + 'new': {'_key': 123, 'list': [{'a': 'b'}, {'a': 'c'}, {'c': 'd'}]}, + 'out': ({'_key': 123, 'list': [{'a': 'b'}, {'c': 'd'}, {'a': 'c'}]}, []), + }, + { + 'desc': 'mergeable fields, no overlapping keys, nested version', + 'old': {'_key': 'abcde', 'type': 'gene', 'info': {'teeth': 16}}, + 'new': {'_key': 'abcde', 'size': 24, 'info': {'colour': 'pinkish'}}, + 'out': ({'_key': 'abcde', 'type': 'gene', 'size': 24, 'info': {'teeth': 16, 'colour': 'pinkish'}}, []), + }, + { + 'desc': 'single field error: duplicate', + 'old': {'_key': 'abcde', 'node_type': 'gene'}, + 'new': {'_key': 'abcde', 'node_type': 'pheno'}, + 'out': (None, ['node_type']), + }, + { + 'desc': 'single field error: type mismatch', + 'old': {'_key': 'abcde', 'node_type': 'gene'}, + 'new': {'_key': 'abcde', 'node_type': ['pheno']}, + 'out': (None, ['node_type']), + }, + { + 'desc': 'multiple field errors', + 'old': {'_key': 'abcde', 'node_type': 'gene', 'shark': 'Jaws'}, + 'new': {'_key': 'abcde', 'node_type': 'pheno', 'shark': 'Loan', 'fish': 'guppy'}, + 'out': (None, ['node_type', 'shark']), + }, + { + 'desc': 'multiple field errors, nested dicts', + 'old': {'_key': 123, 'a': 'A', 'b': {'c': {'d': 'D'}, 'e': {}, 'f': 'F'}}, + 'new': {'_key': 123, 'a': 'A', 'b': {'c': {'d': ['D']}, 'e': 'E', 'f': 'f'}}, + 'out': (None, ['b/c/d', 'b/e', 'b/f']), + } + ] + + for t in tests: + with self.subTest(desc=t['desc']): + output = parser._try_node_merge(t['old'], t['new']) + self.assertEqual(output, t['out']) From 6be7c1a6451d1944f0198c25cb6c746bd8871242 Mon Sep 17 00:00:00 2001 From: ialarmedalien Date: Tue, 6 Oct 2020 08:07:11 -0700 Subject: [PATCH 610/732] Property name changes: nodes: pheno_ref => pheno_reference edges: edge => score, layer_descrip => edge_type --- importers/djornl/parser.py | 8 +++--- spec/collections/djornl/djornl_node.yaml | 4 +-- spec/datasets/djornl/csv_edge.yaml | 6 ++-- spec/datasets/djornl/csv_node.yaml | 4 +-- spec/datasets/djornl/definitions.yaml | 2 +- ...aragwas-MERGED-AMW-v2_091319_nodeTable.csv | 2 +- .../merged_edges-AMW-060820_AF.tsv | 2 +- spec/test/djornl/duplicate_data/edges.tsv | 2 +- .../djornl/duplicate_data/hithruput-edges.csv | 2 +- spec/test/djornl/duplicate_data/nodes.csv | 2 +- .../djornl/duplicate_data/pheno_nodes.csv | 2 +- ...aragwas-MERGED-AMW-v2_091319_nodeTable.csv | 2 +- spec/test/djornl/invalid_types/edges.tsv | 2 +- spec/test/djornl/invalid_types/nodes.csv | 2 +- spec/test/djornl/results.json | 28 +++++++++---------- spec/test/djornl/test_data/edges.tsv | 2 +- .../test/djornl/test_data/hithruput-edges.csv | 2 +- spec/test/djornl/test_data/nodes.csv | 2 +- spec/test/djornl/test_data/pheno_nodes.csv | 2 +- spec/views/djornl/djornl_node_view.json | 2 +- 20 files changed, 40 insertions(+), 40 deletions(-) diff --git a/importers/djornl/parser.py b/importers/djornl/parser.py index c62c6793..29404b34 100644 --- a/importers/djornl/parser.py +++ b/importers/djornl/parser.py @@ -241,13 +241,13 @@ def load_edges(self): # appropriate values to go into Arango remap_functions = { # create a unique key for each record - '_key': lambda row: '__'.join([row[_] for _ in ['node1', 'node2', 'layer_descrip', 'edge']]), + '_key': lambda row: '__'.join([row[_] for _ in ['node1', 'node2', 'edge_type', 'score']]), 'node1': None, # this will be deleted in the 'store' step 'node2': None, # as will this '_from': lambda row: node_name + '/' + row['node1'], '_to': lambda row: node_name + '/' + row['node2'], - 'score': lambda row: float(row['edge']), - 'edge_type': lambda row: row['layer_descrip'], + 'score': lambda row: float(row['score']), + 'edge_type': None, } # store edge data, checking for potential duplicates @@ -316,7 +316,7 @@ def go_terms(row): 'pheno_description': None, 'pheno_pto_description': None, 'pheno_pto_name': None, - 'pheno_ref': None, + 'pheno_reference': None, 'tair_computational_description': None, 'tair_curator_summary': None, 'tair_short_description': None, diff --git a/spec/collections/djornl/djornl_node.yaml b/spec/collections/djornl/djornl_node.yaml index cf7e4d9d..eb85040b 100644 --- a/spec/collections/djornl/djornl_node.yaml +++ b/spec/collections/djornl/djornl_node.yaml @@ -52,7 +52,7 @@ schema: $ref: ../../datasets/djornl/definitions.yaml#/definitions/djornl_node/pheno_pto_name pheno_pto_description: $ref: ../../datasets/djornl/definitions.yaml#/definitions/djornl_node/pheno_pto_description - pheno_ref: - $ref: ../../datasets/djornl/definitions.yaml#/definitions/djornl_node/pheno_ref + pheno_reference: + $ref: ../../datasets/djornl/definitions.yaml#/definitions/djornl_node/pheno_reference user_notes: $ref: ../../datasets/djornl/definitions.yaml#/definitions/djornl_node/user_notes diff --git a/spec/datasets/djornl/csv_edge.yaml b/spec/datasets/djornl/csv_edge.yaml index 19617c5b..c166eb66 100644 --- a/spec/datasets/djornl/csv_edge.yaml +++ b/spec/datasets/djornl/csv_edge.yaml @@ -3,16 +3,16 @@ name: csv_edge title: CSV edge file syntax description: Jacobson lab Arabidopsis edge data file columns for generic node-to-node edges with scores type: object -required: [node1, node2, edge, layer_descrip] +required: [node1, node2, score, edge_type] properties: node1: $ref: definitions.yaml#/definitions/djornl_edge/_from node2: $ref: definitions.yaml#/definitions/djornl_edge/_to - edge: + score: # pre-transformation, the parser treats this as a string type: string format: regex pattern: ^\d+(\.\d+)?$ - layer_descrip: + edge_type: $ref: edge_type.yaml diff --git a/spec/datasets/djornl/csv_node.yaml b/spec/datasets/djornl/csv_node.yaml index b245d623..99d33a68 100644 --- a/spec/datasets/djornl/csv_node.yaml +++ b/spec/datasets/djornl/csv_node.yaml @@ -50,7 +50,7 @@ properties: $ref: definitions.yaml#/definitions/djornl_node/pheno_pto_name pheno_pto_description: $ref: definitions.yaml#/definitions/djornl_node/pheno_pto_description - pheno_ref: - $ref: definitions.yaml#/definitions/djornl_node/pheno_ref + pheno_reference: + $ref: definitions.yaml#/definitions/djornl_node/pheno_reference user_notes: $ref: definitions.yaml#/definitions/djornl_node/user_notes diff --git a/spec/datasets/djornl/definitions.yaml b/spec/datasets/djornl/definitions.yaml index da9b5dc4..9998af82 100644 --- a/spec/datasets/djornl/definitions.yaml +++ b/spec/datasets/djornl/definitions.yaml @@ -114,7 +114,7 @@ definitions: title: PTO description description: Plant Trait Ontology description examples: ["A mineral and ion content related trait (TO:0000465) which is the concentration of arsenic (CHEBI:22632) in some plant structure (PO:0009011). [GR:Karthik]"] - pheno_ref: + pheno_reference: type: string title: Phenotype reference examples: ["Atwell et. al, Nature 2010"] diff --git a/spec/test/djornl/col_count_errors/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv b/spec/test/djornl/col_count_errors/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv index e989f2ca..4edd51f5 100644 --- a/spec/test/djornl/col_count_errors/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv +++ b/spec/test/djornl/col_count_errors/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv @@ -1,4 +1,4 @@ -node_id,node_type,transcript,gene_symbol,gene_full_name,gene_model_type,TAIR_Computational_description,TAIR_Curator_summary,TAIR_short_description,GO_description,GO_terms,MapMan_bin,MapMan_name,MapMan_description,pheno_AraGWAS_ID,pheno_description,pheno_pto_name,pheno_pto_description,pheno_ref,User_Notes +node_id,node_type,transcript,gene_symbol,gene_full_name,gene_model_type,TAIR_Computational_description,TAIR_Curator_summary,TAIR_short_description,GO_description,GO_terms,MapMan_bin,MapMan_name,MapMan_description,pheno_AraGWAS_ID,pheno_description,pheno_pto_name,pheno_pto_description,pheno_reference,User_Notes As2,pheno,,,,,,,,,,,,,10.21958/phenotype:103,,bacterial disease resistance,The resistance exhibited by a plant or a group of plants (population) in response to the disease caused by a bacterial pathogen infection as compared to the susceptible and/or the reference plants of the same species. [GR:pj],"Atwell et. al, Nature 2010", As75,pheno,,,,,,,,,,,,,,,10.21958/phenotype:67,"Arsenic concentrations in leaves, grown in soil. Elemental analysis was performed with an ICP-MS (PerkinElmer). Sample normalized to calculated weights as described in Baxter et al., 2008",arsenic concentration,A mineral and ion content related trait (TO:0000465) which is the concentration of arsenic (CHEBI:22632) in some plant structure (PO:0009011). [GR:Karthik],"Atwell et. al, Nature 2010", AT1G01020,gene,AT1G01020.6,ARV1,,protein_coding,ARV1 family protein;(source:Araport11),,,molecular_function,GO:0003674,35.1,not assigned.annotated,(original description: pep chromosome:TAIR10:1:6788:8737:-1 gene:AT1G01020 transcript:AT1G01020.6 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:ARV1 description:ARV1 family protein [Source:UniProtKB/TrEMBL;Acc:Q5MK24]) & no description available(sp|q5mk24|arv1_arath : 99.4),,,,,, diff --git a/spec/test/djornl/col_count_errors/merged_edges-AMW-060820_AF.tsv b/spec/test/djornl/col_count_errors/merged_edges-AMW-060820_AF.tsv index a2d07a73..0cb3f090 100644 --- a/spec/test/djornl/col_count_errors/merged_edges-AMW-060820_AF.tsv +++ b/spec/test/djornl/col_count_errors/merged_edges-AMW-060820_AF.tsv @@ -1,4 +1,4 @@ -node1 node2 edge edge_descrip layer_descrip +node1 node2 score edge_descrip edge_type As2 AT1G01040 5.422046084731258 AraGWAS-Association_score AraGWAS-Phenotype_Associations As75 AT1G01020 39.98573324312915 AraGWAS-Association_score AraGWAS-Phenotype_Associations AT1G01010 AT1G01020 2.39322646755088 AraNetv2_log-likelihood-score AraNetv2-HT_high-throughput-ppi diff --git a/spec/test/djornl/duplicate_data/edges.tsv b/spec/test/djornl/duplicate_data/edges.tsv index 432c2deb..be7a654a 100644 --- a/spec/test/djornl/duplicate_data/edges.tsv +++ b/spec/test/djornl/duplicate_data/edges.tsv @@ -1,4 +1,4 @@ -node1 node2 edge edge_descrip layer_descrip +node1 node2 score edge_descrip edge_type As2 AT1G01020 8.4 AraGWAS-Association_score AraGWAS-Phenotype_Associations As2 AT1G01040 5.4 AraGWAS-Association_score AraGWAS-Phenotype_Associations As75 AT1G01020 39.9 AraGWAS-Association_score AraGWAS-Phenotype_Associations diff --git a/spec/test/djornl/duplicate_data/hithruput-edges.csv b/spec/test/djornl/duplicate_data/hithruput-edges.csv index c11caa3d..07e9c80f 100644 --- a/spec/test/djornl/duplicate_data/hithruput-edges.csv +++ b/spec/test/djornl/duplicate_data/hithruput-edges.csv @@ -1,4 +1,4 @@ -node1,node2,edge,edge_descrip,layer_descrip +node1,node2,score,edge_descrip,edge_type AT1G01010,AT1G01020,2.3,AraNetv2_log-likelihood-score,AraNetv2-HT_high-throughput-ppi AT1G01010,AT1G01030,2.4,AraNetv2_log-likelihood-score,AraNetv2-HT_high-throughput-ppi # potentially erroneous line diff --git a/spec/test/djornl/duplicate_data/nodes.csv b/spec/test/djornl/duplicate_data/nodes.csv index b1938272..bfb26a70 100644 --- a/spec/test/djornl/duplicate_data/nodes.csv +++ b/spec/test/djornl/duplicate_data/nodes.csv @@ -1,5 +1,5 @@ # data_type: node -node_id,node_type,transcript,gene_symbol,gene_full_name,gene_model_type,TAIR_Computational_description,TAIR_Curator_summary,TAIR_short_description,GO_description,GO_terms,MapMan_bin,MapMan_name,MapMan_description,pheno_AraGWAS_ID,pheno_description,pheno_pto_name,pheno_pto_description,pheno_ref,User_Notes +node_id,node_type,transcript,gene_symbol,gene_full_name,gene_model_type,TAIR_Computational_description,TAIR_Curator_summary,TAIR_short_description,GO_description,GO_terms,MapMan_bin,MapMan_name,MapMan_description,pheno_AraGWAS_ID,pheno_description,pheno_pto_name,pheno_pto_description,pheno_reference,User_Notes AT1G01010,gene,AT1G01010.1,NTL10,NAC domain containing protein 1,protein_coding,NAC domain containing protein 1;(source:Araport11),,NAC domain containing protein 1,"DNA-binding transcription factor activity, DNA binding","GO:0003700, GO:0003677",15.5.17,.RNA biosynthesis.transcriptional regulation.transcription factor (NAC),transcription factor (NAC) (original description: pep chromosome:TAIR10:1:3631:5899:1 gene:AT1G01010 transcript:AT1G01010.1 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:NAC001 description:NAC domain-containing protein 1 [Source:UniProtKB/Swiss-Prot;Acc:Q0WV96]),,,,,, AT1G01020,gene,AT1G01020.6,ARV1,,protein_coding,ARV1 family protein;(source:Araport11),,,molecular_function,GO:0003674,35.1,not assigned.annotated,(original description: pep chromosome:TAIR10:1:6788:8737:-1 gene:AT1G01020 transcript:AT1G01020.6 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:ARV1 description:ARV1 family protein [Source:UniProtKB/TrEMBL;Acc:Q5MK24]) & no description available(sp|q5mk24|arv1_arath : 99.4),,,,,, AT1G01030,gene,AT1G01030.2,NGA3,NGATHA3,protein_coding,AP2/B3-like transcriptional factor family protein;(source:Araport11),,,"DNA-binding transcription factor activity, DNA binding","GO:0003700, GO:0003677",15.5.5.3,.RNA biosynthesis.transcriptional regulation.B3 transcription factor superfamily.transcription factor (RAV/NGATHA),transcription factor (RAV/NGATHA) (original description: pep chromosome:TAIR10:1:11649:13714:-1 gene:AT1G01030 transcript:AT1G01030.2 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:NGA3 description:B3 domain-containing transcription factor NGA3 [Source:UniProtKB/Swiss-Prot;Acc:Q9MAN1]),,,,,, diff --git a/spec/test/djornl/duplicate_data/pheno_nodes.csv b/spec/test/djornl/duplicate_data/pheno_nodes.csv index 83fbf4be..9add7b7d 100644 --- a/spec/test/djornl/duplicate_data/pheno_nodes.csv +++ b/spec/test/djornl/duplicate_data/pheno_nodes.csv @@ -1,4 +1,4 @@ -node_id,node_type,pheno_AraGWAS_ID,pheno_description,pheno_pto_name,pheno_pto_description,pheno_ref,User_Notes +node_id,node_type,pheno_AraGWAS_ID,pheno_description,pheno_pto_name,pheno_pto_description,pheno_reference,User_Notes As2,pheno,10.21958/phenotype:103,,bacterial disease resistance,The resistance exhibited by a plant or a group of plants (population) in response to the disease caused by a bacterial pathogen infection as compared to the susceptible and/or the reference plants of the same species. [GR:pj],"Atwell et. al, Nature 2010", As75,pheno,10.21958/phenotype:67,"Arsenic concentrations in leaves, grown in soil. Elemental analysis was performed with an ICP-MS (PerkinElmer). Sample normalized to calculated weights as described in Baxter et al., 2008",arsenic concentration,A mineral and ion content related trait (TO:0000465) which is the concentration of arsenic (CHEBI:22632) in some plant structure (PO:0009011). [GR:Karthik],"Atwell et. al, Nature 2010", Na23,pheno,10.21958/phenotype:5,"Sodium concentrations in leaves, grown in soil. Elemental analysis was performed with an ICP-MS (PerkinElmer). Sample normalized to calculated weights as described in Baxter et al., 2008",sodium concentration,The total sodium ion concentration measured in a given volume of a plant or a plant part or plant extract. [GR:pj],"Atwell et. al, Nature 2010", diff --git a/spec/test/djornl/empty_files/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv b/spec/test/djornl/empty_files/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv index ab31e045..7fe64278 100644 --- a/spec/test/djornl/empty_files/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv +++ b/spec/test/djornl/empty_files/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv @@ -1 +1 @@ -node_id,node_type,transcript,gene_symbol,gene_full_name,gene_model_type,TAIR_Computational_description,TAIR_Curator_summary,TAIR_short_description,GO_description,GO_terms,MapMan_bin,MapMan_name,MapMan_description,pheno_AraGWAS_ID,pheno_description,pheno_pto_name,pheno_pto_description,pheno_ref,User_Notes +node_id,node_type,transcript,gene_symbol,gene_full_name,gene_model_type,TAIR_Computational_description,TAIR_Curator_summary,TAIR_short_description,GO_description,GO_terms,MapMan_bin,MapMan_name,MapMan_description,pheno_AraGWAS_ID,pheno_description,pheno_pto_name,pheno_pto_description,pheno_reference,User_Notes diff --git a/spec/test/djornl/invalid_types/edges.tsv b/spec/test/djornl/invalid_types/edges.tsv index 06bbe9fd..bad2b9b4 100644 --- a/spec/test/djornl/invalid_types/edges.tsv +++ b/spec/test/djornl/invalid_types/edges.tsv @@ -1,5 +1,5 @@ # data_type: edge -node1 node2 edge edge_descrip layer_descrip +node1 node2 score edge_descrip edge_type As2 AT1G01020 8.422046084731258 AraGWAS-Association_score Same-Old-Stuff As2 AT1G01040 6 AraGWAS-Association_score AraGWAS-Phenotype_Associations As75 AT1G01020 39.98573324312915 AraGWAS-Association_score AraGWAS-Phenotype_Associations diff --git a/spec/test/djornl/invalid_types/nodes.csv b/spec/test/djornl/invalid_types/nodes.csv index e469f003..ff99ff01 100644 --- a/spec/test/djornl/invalid_types/nodes.csv +++ b/spec/test/djornl/invalid_types/nodes.csv @@ -1,4 +1,4 @@ -node_id,node_type,transcript,gene_symbol,gene_full_name,gene_model_type,TAIR_Computational_description,TAIR_Curator_summary,TAIR_short_description,GO_description,GO_terms,MapMan_bin,MapMan_name,MapMan_description,pheno_AraGWAS_ID,pheno_description,pheno_pto_name,pheno_pto_description,pheno_ref,User_Notes +node_id,node_type,transcript,gene_symbol,gene_full_name,gene_model_type,TAIR_Computational_description,TAIR_Curator_summary,TAIR_short_description,GO_description,GO_terms,MapMan_bin,MapMan_name,MapMan_description,pheno_AraGWAS_ID,pheno_description,pheno_pto_name,pheno_pto_description,pheno_reference,User_Notes # data_type: node As2,pheno,,,,,,,,,,,,,10.21958/phenotype:103,,bacterial disease resistance,The resistance exhibited by a plant or a group of plants (population) in response to the disease caused by a bacterial pathogen infection as compared to the susceptible and/or the reference plants of the same species. [GR:pj],"Atwell et. al, Nature 2010", As75,pheno,,,,,,,,,,,,,10.21958/phenotype:67,"Arsenic concentrations in leaves, grown in soil. Elemental analysis was performed with an ICP-MS (PerkinElmer). Sample normalized to calculated weights as described in Baxter et al., 2008",arsenic concentration,A mineral and ion content related trait (TO:0000465) which is the concentration of arsenic (CHEBI:22632) in some plant structure (PO:0009011). [GR:Karthik],"Atwell et. al, Nature 2010", diff --git a/spec/test/djornl/results.json b/spec/test/djornl/results.json index 9baeed2f..4771d764 100644 --- a/spec/test/djornl/results.json +++ b/spec/test/djornl/results.json @@ -40,20 +40,20 @@ }, "load_nodes": { "nodes": [ - {"_key": "As2", "node_type": "pheno", "transcript": "", "gene_symbol": "", "gene_full_name": "", "gene_model_type": "", "tair_computational_description": "", "tair_curator_summary": "", "tair_short_description": "", "go_description": "", "go_terms": [], "mapman_bin": "", "mapman_name": "", "mapman_description": "", "pheno_aragwas_id": "10.21958/phenotype:103", "pheno_description": "", "pheno_pto_name": "bacterial disease resistance", "pheno_pto_description": "The resistance exhibited by a plant or a group of plants (population) in response to the disease caused by a bacterial pathogen infection as compared to the susceptible and/or the reference plants of the same species. [GR:pj]", "pheno_ref": "Atwell et. al, Nature 2010", "user_notes": ""}, - {"_key": "As75", "node_type": "pheno", "transcript": "", "gene_symbol": "", "gene_full_name": "", "gene_model_type": "", "tair_computational_description": "", "tair_curator_summary": "", "tair_short_description": "", "go_description": "", "go_terms": [], "mapman_bin": "", "mapman_name": "", "mapman_description": "", "pheno_aragwas_id": "10.21958/phenotype:67", "pheno_description": "Arsenic concentrations in leaves, grown in soil. Elemental analysis was performed with an ICP-MS (PerkinElmer). Sample normalized to calculated weights as described in Baxter et al., 2008", "pheno_pto_name": "arsenic concentration", "pheno_pto_description": "A mineral and ion content related trait (TO:0000465) which is the concentration of arsenic (CHEBI:22632) in some plant structure (PO:0009011). [GR:Karthik]", "pheno_ref": "Atwell et. al, Nature 2010", "user_notes": ""}, - {"_key": "AT1G01010", "node_type": "gene", "transcript": "AT1G01010.1", "gene_symbol": "NTL10", "gene_full_name": "NAC domain containing protein 1", "gene_model_type": "protein_coding", "tair_computational_description": "NAC domain containing protein 1;(source:Araport11)", "tair_curator_summary": "", "tair_short_description": "NAC domain containing protein 1", "go_description": "DNA-binding transcription factor activity, DNA binding", "go_terms": ["GO:0003700", "GO:0003677"], "mapman_bin": "15.5.17", "mapman_name": ".RNA biosynthesis.transcriptional regulation.transcription factor (NAC)", "mapman_description": "transcription factor (NAC) (original description: pep chromosome:TAIR10:1:3631:5899:1 gene:AT1G01010 transcript:AT1G01010.1 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:NAC001 description:NAC domain-containing protein 1 [Source:UniProtKB/Swiss-Prot;Acc:Q0WV96])", "pheno_aragwas_id": "", "pheno_description": "", "pheno_pto_name": "", "pheno_pto_description": "", "pheno_ref": "", "user_notes": ""}, - {"_key": "AT1G01020", "node_type": "gene", "transcript": "AT1G01020.6", "gene_symbol": "ARV1", "gene_full_name": "", "gene_model_type": "protein_coding", "tair_computational_description": "ARV1 family protein;(source:Araport11)", "tair_curator_summary": "", "tair_short_description": "", "go_description": "molecular_function", "go_terms": ["GO:0003674"], "mapman_bin": "35.1", "mapman_name": "not assigned.annotated", "mapman_description": "(original description: pep chromosome:TAIR10:1:6788:8737:-1 gene:AT1G01020 transcript:AT1G01020.6 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:ARV1 description:ARV1 family protein [Source:UniProtKB/TrEMBL;Acc:Q5MK24]) & no description available(sp|q5mk24|arv1_arath : 99.4)", "pheno_aragwas_id": "", "pheno_description": "", "pheno_pto_name": "", "pheno_pto_description": "", "pheno_ref": "", "user_notes": ""}, - {"_key": "AT1G01030", "node_type": "gene", "transcript": "AT1G01030.2", "gene_symbol": "NGA3", "gene_full_name": "NGATHA3", "gene_model_type": "protein_coding", "tair_computational_description": "AP2/B3-like transcriptional factor family protein;(source:Araport11)", "tair_curator_summary": "", "tair_short_description": "", "go_description": "DNA-binding transcription factor activity, DNA binding", "go_terms": ["GO:0003700", "GO:0003677"], "mapman_bin": "15.5.5.3", "mapman_name": ".RNA biosynthesis.transcriptional regulation.B3 transcription factor superfamily.transcription factor (RAV/NGATHA)", "mapman_description": "transcription factor (RAV/NGATHA) (original description: pep chromosome:TAIR10:1:11649:13714:-1 gene:AT1G01030 transcript:AT1G01030.2 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:NGA3 description:B3 domain-containing transcription factor NGA3 [Source:UniProtKB/Swiss-Prot;Acc:Q9MAN1])", "pheno_aragwas_id": "", "pheno_description": "", "pheno_pto_name": "", "pheno_pto_description": "", "pheno_ref": "", "user_notes": ""}, - {"_key": "AT1G01040", "node_type": "gene", "transcript": "AT1G01040.2", "gene_symbol": "SUS1", "gene_full_name": "SUSPENSOR 1", "gene_model_type": "protein_coding", "tair_computational_description": "dicer-like 1;(source:Araport11)", "tair_curator_summary": "Encodes a Dicer homolog. Dicer is a RNA helicase involved in microRNA processing. Mutations in this locus can result in embryo lethality. Embryo shape at seed maturity is globular-elongate. Other mutants convert the floral meristems to an indeterminate state, others yet show defects in ovule development. mRNA is expressed in all shoot tissues. DCL1 is able to produce miRNAs and siRNAs. The mRNA is cell-to-cell mobile.", "tair_short_description": "dicer-like 1", "go_description": "metal ion binding, protein binding, ribonuclease III activity, ATP-dependent helicase activity, ATP binding, RNA binding, helicase activity, double-stranded RNA binding, DNA binding", "go_terms": ["GO:0046872", "GO:0005515", "GO:0004525", "GO:0008026", "GO:0005524", "GO:0003723", "GO:0004386", "GO:0003725", "GO:0003677"], "mapman_bin": "16.10.2.1.1", "mapman_name": ".RNA processing.mRNA silencing.miRNA pathway.DCL1-HYL1 miRNA biogenesis complex.endoribonuclease component DCL1", "mapman_description": "endoribonuclease component DCL1 of DCL1-HYL1 miRNA biogenesis complex (original description: pep chromosome:TAIR10:1:23416:31120:1 gene:AT1G01040 transcript:AT1G01040.2 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:DCL1 description:Dicer-like 1 [Source:UniProtKB/TrEMBL;Acc:F4HQG6])", "pheno_aragwas_id": "", "pheno_description": "", "pheno_pto_name": "", "pheno_pto_description": "", "pheno_ref": "", "user_notes": ""}, - {"_key": "AT1G01050", "node_type": "gene", "transcript": "AT1G01050.2", "gene_symbol": "PPa1", "gene_full_name": "pyrophosphorylase 1", "gene_model_type": "protein_coding", "tair_computational_description": "pyrophosphorylase 1;(source:Araport11)", "tair_curator_summary": "", "tair_short_description": "", "go_description": "inorganic diphosphatase activity", "go_terms": ["GO:0004427"], "mapman_bin": "35.1", "mapman_name": "not assigned.annotated", "mapman_description": "(original description: pep chromosome:TAIR10:1:31382:33009:-1 gene:AT1G01050 transcript:AT1G01050.2 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:PPA1 description:Soluble inorganic pyrophosphatase 1 [Source:UniProtKB/Swiss-Prot;Acc:Q93V56]) & Soluble inorganic pyrophosphatase 1 OS=Arabidopsis thaliana (sp|q93v56|ipyr1_arath : 419.0)", "pheno_aragwas_id": "", "pheno_description": "", "pheno_pto_name": "", "pheno_pto_description": "", "pheno_ref": "", "user_notes": ""}, - {"_key": "AT1G01060", "node_type": "gene", "transcript": "AT1G01060.8", "gene_symbol": "LHY1", "gene_full_name": "LATE ELONGATED HYPOCOTYL 1", "gene_model_type": "protein_coding", "tair_computational_description": "Homeodomain-like superfamily protein;(source:Araport11)", "tair_curator_summary": "", "tair_short_description": "", "go_description": "DNA-binding transcription factor activity, DNA binding, transcription regulatory region DNA binding", "go_terms": ["GO:0003700", "GO:0003677", "GO:0044212"], "mapman_bin": "27.1.1", "mapman_name": ".Multi-process regulation.circadian clock system.core oscillator protein (LHY|CCA1)", "mapman_description": "circadian clock core oscillator protein (LHY|CCA1) (original description: pep chromosome:TAIR10:1:33967:37230:-1 gene:AT1G01060 transcript:AT1G01060.8 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:LHY description:LHY1 [Source:UniProtKB/TrEMBL;Acc:A0A178W761])", "pheno_aragwas_id": "", "pheno_description": "", "pheno_pto_name": "", "pheno_pto_description": "", "pheno_ref": "", "user_notes": ""}, - {"_key": "AT1G01070", "node_type": "gene", "transcript": "AT1G01070.2", "gene_symbol": "UMAMIT28", "gene_full_name": "Usually multiple acids move in and out Transporters 28", "gene_model_type": "protein_coding", "tair_computational_description": "nodulin MtN21 /EamA-like transporter family protein;(source:Araport11)", "tair_curator_summary": "Encodes a plasma membrane-localized amino acid transporter likely involved in amino acid export in the developing seed.", "tair_short_description": "nodulin MtN21 /EamA-like transporter family protein", "go_description": "L-glutamine transmembrane transporter activity", "go_terms": ["GO:0015186"], "mapman_bin": "24.2.1.5", "mapman_name": ".Solute transport.carrier-mediated transport.DMT superfamily.solute transporter (UmamiT)", "mapman_description": "solute transporter (UmamiT) (original description: pep chromosome:TAIR10:1:38752:40945:-1 gene:AT1G01070 transcript:AT1G01070.2 gene_biotype:protein_coding transcript_biotype:protein_coding description:WAT1-related protein [Source:UniProtKB/TrEMBL;Acc:A0A178WFU3])", "pheno_aragwas_id": "", "pheno_description": "", "pheno_pto_name": "", "pheno_pto_description": "", "pheno_ref": "", "user_notes": ""}, - {"_key": "AT1G01080", "node_type": "gene", "transcript": "AT1G01080.3", "gene_symbol": "", "gene_full_name": "", "gene_model_type": "protein_coding", "tair_computational_description": "RNA-binding (RRM/RBD/RNP motifs) family protein;(source:Araport11)", "tair_curator_summary": "", "tair_short_description": "", "go_description": "RNA binding, mRNA binding", "go_terms": ["GO:0003723", "GO:0003729"], "mapman_bin": "35.1", "mapman_name": "not assigned.annotated", "mapman_description": "(original description: pep chromosome:TAIR10:1:44970:47059:-1 gene:AT1G01080 transcript:AT1G01080.3 gene_biotype:protein_coding transcript_biotype:protein_coding description:RNA-binding (RRM/RBD/RNP motifs) family protein [Source:UniProtKB/TrEMBL;Acc:F4HQH8]) & 33 kDa ribonucleoprotein, chloroplastic OS=Nicotiana sylvestris (sp|p19684|roc5_nicsy : 109.0)", "pheno_aragwas_id": "", "pheno_description": "", "pheno_pto_name": "", "pheno_pto_description": "", "pheno_ref": "", "user_notes": ""}, - {"_key": "AT1G01090", "node_type": "gene", "transcript": "AT1G01090.1", "gene_symbol": "PDH-E1 ALPHA", "gene_full_name": "pyruvate dehydrogenase E1 alpha", "gene_model_type": "protein_coding", "tair_computational_description": "pyruvate dehydrogenase E1 alpha;(source:Araport11)", "tair_curator_summary": "pyruvate dehydrogenase E1 alpha subunit", "tair_short_description": "pyruvate dehydrogenase E1 alpha", "go_description": "pyruvate dehydrogenase (acetyl-transferring) activity, protein binding", "go_terms": ["GO:0004739", "GO:0005515"], "mapman_bin": "5.1.2.2.1.1", "mapman_name": ".Lipid metabolism.fatty acid biosynthesis.acetyl-CoA generation.plastidial pyruvate dehydrogenase complex.E1 pyruvate dehydrogenase subcomplex.subunit alpha", "mapman_description": "subunit alpha of E1 pyruvate dehydrogenase component (original description: pep chromosome:TAIR10:1:47234:49304:-1 gene:AT1G01090 transcript:AT1G01090.1 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:PDH-E1 ALPHA description:Pyruvate dehydrogenase E1 component subunit alpha [Source:UniProtKB/TrEMBL;Acc:A0A178W8A7])", "pheno_aragwas_id": "", "pheno_description": "", "pheno_pto_name": "", "pheno_pto_description": "", "pheno_ref": "", "user_notes": ""}, - {"_key": "AT1G01100", "node_type": "gene", "transcript": "AT1G01100.4", "gene_symbol": "", "gene_full_name": "", "gene_model_type": "protein_coding", "tair_computational_description": "60S acidic ribosomal protein family;(source:Araport11)", "tair_curator_summary": "", "tair_short_description": "60S acidic ribosomal protein family", "go_description": "structural constituent of ribosome, ribonucleoprotein complex binding, protein kinase activator activity", "go_terms": ["GO:0003735", "GO:0043021", "GO:0030295"], "mapman_bin": "17.1.2.1.46", "mapman_name": ".Protein biosynthesis.ribosome biogenesis.large ribosomal subunit (LSU).LSU proteome.component RPP1", "mapman_description": "component RPP1 of LSU proteome component (original description: pep chromosome:TAIR10:1:50090:51187:-1 gene:AT1G01100 transcript:AT1G01100.4 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:RPP1A description:60S acidic ribosomal protein P1-1 [Source:UniProtKB/Swiss-Prot;Acc:Q8LCW9])", "pheno_aragwas_id": "", "pheno_description": "", "pheno_pto_name": "", "pheno_pto_description": "", "pheno_ref": "", "user_notes": ""}, - {"_key": "Na23", "node_type": "pheno", "transcript": "", "gene_symbol": "", "gene_full_name": "", "gene_model_type": "", "tair_computational_description": "", "tair_curator_summary": "", "tair_short_description": "", "go_description": "", "go_terms": [], "mapman_bin": "", "mapman_name": "", "mapman_description": "", "pheno_aragwas_id": "10.21958/phenotype:5", "pheno_description": "Sodium concentrations in leaves, grown in soil. Elemental analysis was performed with an ICP-MS (PerkinElmer). Sample normalized to calculated weights as described in Baxter et al., 2008", "pheno_pto_name": "sodium concentration", "pheno_pto_description": "The total sodium ion concentration measured in a given volume of a plant or a plant part or plant extract. [GR:pj]", "pheno_ref": "Atwell et. al, Nature 2010", "user_notes": ""}, - {"_key": "SDV", "node_type": "pheno", "transcript": "", "gene_symbol": "", "gene_full_name": "", "gene_model_type": "", "tair_computational_description": "", "tair_curator_summary": "", "tair_short_description": "", "go_description": "", "go_terms": [], "mapman_bin": "", "mapman_name": "", "mapman_description": "", "pheno_aragwas_id": "10.21958/phenotype:104", "pheno_description": "Number of days following stratification to opening of first flower. The experiment was stopped at 200 d, and accessions that had not flowered at that point were assigned a value of 200", "pheno_pto_name": "days to flowering trait", "pheno_pto_description": "A flowering time trait (TO:0002616)which is the number of days required for an individual flower (PO:0009046), a whole plant (PO:0000003) or a plant population to reach flowering stage (PO:0007616) from a predetermined time point (e.g. the date of seed sowing, seedling transplant, or seedling emergence). [GR:pj, TO:cooperl]", "pheno_ref": "Atwell et. al, Nature 2010", "user_notes": ""} + {"_key": "As2", "node_type": "pheno", "transcript": "", "gene_symbol": "", "gene_full_name": "", "gene_model_type": "", "tair_computational_description": "", "tair_curator_summary": "", "tair_short_description": "", "go_description": "", "go_terms": [], "mapman_bin": "", "mapman_name": "", "mapman_description": "", "pheno_aragwas_id": "10.21958/phenotype:103", "pheno_description": "", "pheno_pto_name": "bacterial disease resistance", "pheno_pto_description": "The resistance exhibited by a plant or a group of plants (population) in response to the disease caused by a bacterial pathogen infection as compared to the susceptible and/or the reference plants of the same species. [GR:pj]", "pheno_reference": "Atwell et. al, Nature 2010", "user_notes": ""}, + {"_key": "As75", "node_type": "pheno", "transcript": "", "gene_symbol": "", "gene_full_name": "", "gene_model_type": "", "tair_computational_description": "", "tair_curator_summary": "", "tair_short_description": "", "go_description": "", "go_terms": [], "mapman_bin": "", "mapman_name": "", "mapman_description": "", "pheno_aragwas_id": "10.21958/phenotype:67", "pheno_description": "Arsenic concentrations in leaves, grown in soil. Elemental analysis was performed with an ICP-MS (PerkinElmer). Sample normalized to calculated weights as described in Baxter et al., 2008", "pheno_pto_name": "arsenic concentration", "pheno_pto_description": "A mineral and ion content related trait (TO:0000465) which is the concentration of arsenic (CHEBI:22632) in some plant structure (PO:0009011). [GR:Karthik]", "pheno_reference": "Atwell et. al, Nature 2010", "user_notes": ""}, + {"_key": "AT1G01010", "node_type": "gene", "transcript": "AT1G01010.1", "gene_symbol": "NTL10", "gene_full_name": "NAC domain containing protein 1", "gene_model_type": "protein_coding", "tair_computational_description": "NAC domain containing protein 1;(source:Araport11)", "tair_curator_summary": "", "tair_short_description": "NAC domain containing protein 1", "go_description": "DNA-binding transcription factor activity, DNA binding", "go_terms": ["GO:0003700", "GO:0003677"], "mapman_bin": "15.5.17", "mapman_name": ".RNA biosynthesis.transcriptional regulation.transcription factor (NAC)", "mapman_description": "transcription factor (NAC) (original description: pep chromosome:TAIR10:1:3631:5899:1 gene:AT1G01010 transcript:AT1G01010.1 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:NAC001 description:NAC domain-containing protein 1 [Source:UniProtKB/Swiss-Prot;Acc:Q0WV96])", "pheno_aragwas_id": "", "pheno_description": "", "pheno_pto_name": "", "pheno_pto_description": "", "pheno_reference": "", "user_notes": ""}, + {"_key": "AT1G01020", "node_type": "gene", "transcript": "AT1G01020.6", "gene_symbol": "ARV1", "gene_full_name": "", "gene_model_type": "protein_coding", "tair_computational_description": "ARV1 family protein;(source:Araport11)", "tair_curator_summary": "", "tair_short_description": "", "go_description": "molecular_function", "go_terms": ["GO:0003674"], "mapman_bin": "35.1", "mapman_name": "not assigned.annotated", "mapman_description": "(original description: pep chromosome:TAIR10:1:6788:8737:-1 gene:AT1G01020 transcript:AT1G01020.6 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:ARV1 description:ARV1 family protein [Source:UniProtKB/TrEMBL;Acc:Q5MK24]) & no description available(sp|q5mk24|arv1_arath : 99.4)", "pheno_aragwas_id": "", "pheno_description": "", "pheno_pto_name": "", "pheno_pto_description": "", "pheno_reference": "", "user_notes": ""}, + {"_key": "AT1G01030", "node_type": "gene", "transcript": "AT1G01030.2", "gene_symbol": "NGA3", "gene_full_name": "NGATHA3", "gene_model_type": "protein_coding", "tair_computational_description": "AP2/B3-like transcriptional factor family protein;(source:Araport11)", "tair_curator_summary": "", "tair_short_description": "", "go_description": "DNA-binding transcription factor activity, DNA binding", "go_terms": ["GO:0003700", "GO:0003677"], "mapman_bin": "15.5.5.3", "mapman_name": ".RNA biosynthesis.transcriptional regulation.B3 transcription factor superfamily.transcription factor (RAV/NGATHA)", "mapman_description": "transcription factor (RAV/NGATHA) (original description: pep chromosome:TAIR10:1:11649:13714:-1 gene:AT1G01030 transcript:AT1G01030.2 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:NGA3 description:B3 domain-containing transcription factor NGA3 [Source:UniProtKB/Swiss-Prot;Acc:Q9MAN1])", "pheno_aragwas_id": "", "pheno_description": "", "pheno_pto_name": "", "pheno_pto_description": "", "pheno_reference": "", "user_notes": ""}, + {"_key": "AT1G01040", "node_type": "gene", "transcript": "AT1G01040.2", "gene_symbol": "SUS1", "gene_full_name": "SUSPENSOR 1", "gene_model_type": "protein_coding", "tair_computational_description": "dicer-like 1;(source:Araport11)", "tair_curator_summary": "Encodes a Dicer homolog. Dicer is a RNA helicase involved in microRNA processing. Mutations in this locus can result in embryo lethality. Embryo shape at seed maturity is globular-elongate. Other mutants convert the floral meristems to an indeterminate state, others yet show defects in ovule development. mRNA is expressed in all shoot tissues. DCL1 is able to produce miRNAs and siRNAs. The mRNA is cell-to-cell mobile.", "tair_short_description": "dicer-like 1", "go_description": "metal ion binding, protein binding, ribonuclease III activity, ATP-dependent helicase activity, ATP binding, RNA binding, helicase activity, double-stranded RNA binding, DNA binding", "go_terms": ["GO:0046872", "GO:0005515", "GO:0004525", "GO:0008026", "GO:0005524", "GO:0003723", "GO:0004386", "GO:0003725", "GO:0003677"], "mapman_bin": "16.10.2.1.1", "mapman_name": ".RNA processing.mRNA silencing.miRNA pathway.DCL1-HYL1 miRNA biogenesis complex.endoribonuclease component DCL1", "mapman_description": "endoribonuclease component DCL1 of DCL1-HYL1 miRNA biogenesis complex (original description: pep chromosome:TAIR10:1:23416:31120:1 gene:AT1G01040 transcript:AT1G01040.2 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:DCL1 description:Dicer-like 1 [Source:UniProtKB/TrEMBL;Acc:F4HQG6])", "pheno_aragwas_id": "", "pheno_description": "", "pheno_pto_name": "", "pheno_pto_description": "", "pheno_reference": "", "user_notes": ""}, + {"_key": "AT1G01050", "node_type": "gene", "transcript": "AT1G01050.2", "gene_symbol": "PPa1", "gene_full_name": "pyrophosphorylase 1", "gene_model_type": "protein_coding", "tair_computational_description": "pyrophosphorylase 1;(source:Araport11)", "tair_curator_summary": "", "tair_short_description": "", "go_description": "inorganic diphosphatase activity", "go_terms": ["GO:0004427"], "mapman_bin": "35.1", "mapman_name": "not assigned.annotated", "mapman_description": "(original description: pep chromosome:TAIR10:1:31382:33009:-1 gene:AT1G01050 transcript:AT1G01050.2 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:PPA1 description:Soluble inorganic pyrophosphatase 1 [Source:UniProtKB/Swiss-Prot;Acc:Q93V56]) & Soluble inorganic pyrophosphatase 1 OS=Arabidopsis thaliana (sp|q93v56|ipyr1_arath : 419.0)", "pheno_aragwas_id": "", "pheno_description": "", "pheno_pto_name": "", "pheno_pto_description": "", "pheno_reference": "", "user_notes": ""}, + {"_key": "AT1G01060", "node_type": "gene", "transcript": "AT1G01060.8", "gene_symbol": "LHY1", "gene_full_name": "LATE ELONGATED HYPOCOTYL 1", "gene_model_type": "protein_coding", "tair_computational_description": "Homeodomain-like superfamily protein;(source:Araport11)", "tair_curator_summary": "", "tair_short_description": "", "go_description": "DNA-binding transcription factor activity, DNA binding, transcription regulatory region DNA binding", "go_terms": ["GO:0003700", "GO:0003677", "GO:0044212"], "mapman_bin": "27.1.1", "mapman_name": ".Multi-process regulation.circadian clock system.core oscillator protein (LHY|CCA1)", "mapman_description": "circadian clock core oscillator protein (LHY|CCA1) (original description: pep chromosome:TAIR10:1:33967:37230:-1 gene:AT1G01060 transcript:AT1G01060.8 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:LHY description:LHY1 [Source:UniProtKB/TrEMBL;Acc:A0A178W761])", "pheno_aragwas_id": "", "pheno_description": "", "pheno_pto_name": "", "pheno_pto_description": "", "pheno_reference": "", "user_notes": ""}, + {"_key": "AT1G01070", "node_type": "gene", "transcript": "AT1G01070.2", "gene_symbol": "UMAMIT28", "gene_full_name": "Usually multiple acids move in and out Transporters 28", "gene_model_type": "protein_coding", "tair_computational_description": "nodulin MtN21 /EamA-like transporter family protein;(source:Araport11)", "tair_curator_summary": "Encodes a plasma membrane-localized amino acid transporter likely involved in amino acid export in the developing seed.", "tair_short_description": "nodulin MtN21 /EamA-like transporter family protein", "go_description": "L-glutamine transmembrane transporter activity", "go_terms": ["GO:0015186"], "mapman_bin": "24.2.1.5", "mapman_name": ".Solute transport.carrier-mediated transport.DMT superfamily.solute transporter (UmamiT)", "mapman_description": "solute transporter (UmamiT) (original description: pep chromosome:TAIR10:1:38752:40945:-1 gene:AT1G01070 transcript:AT1G01070.2 gene_biotype:protein_coding transcript_biotype:protein_coding description:WAT1-related protein [Source:UniProtKB/TrEMBL;Acc:A0A178WFU3])", "pheno_aragwas_id": "", "pheno_description": "", "pheno_pto_name": "", "pheno_pto_description": "", "pheno_reference": "", "user_notes": ""}, + {"_key": "AT1G01080", "node_type": "gene", "transcript": "AT1G01080.3", "gene_symbol": "", "gene_full_name": "", "gene_model_type": "protein_coding", "tair_computational_description": "RNA-binding (RRM/RBD/RNP motifs) family protein;(source:Araport11)", "tair_curator_summary": "", "tair_short_description": "", "go_description": "RNA binding, mRNA binding", "go_terms": ["GO:0003723", "GO:0003729"], "mapman_bin": "35.1", "mapman_name": "not assigned.annotated", "mapman_description": "(original description: pep chromosome:TAIR10:1:44970:47059:-1 gene:AT1G01080 transcript:AT1G01080.3 gene_biotype:protein_coding transcript_biotype:protein_coding description:RNA-binding (RRM/RBD/RNP motifs) family protein [Source:UniProtKB/TrEMBL;Acc:F4HQH8]) & 33 kDa ribonucleoprotein, chloroplastic OS=Nicotiana sylvestris (sp|p19684|roc5_nicsy : 109.0)", "pheno_aragwas_id": "", "pheno_description": "", "pheno_pto_name": "", "pheno_pto_description": "", "pheno_reference": "", "user_notes": ""}, + {"_key": "AT1G01090", "node_type": "gene", "transcript": "AT1G01090.1", "gene_symbol": "PDH-E1 ALPHA", "gene_full_name": "pyruvate dehydrogenase E1 alpha", "gene_model_type": "protein_coding", "tair_computational_description": "pyruvate dehydrogenase E1 alpha;(source:Araport11)", "tair_curator_summary": "pyruvate dehydrogenase E1 alpha subunit", "tair_short_description": "pyruvate dehydrogenase E1 alpha", "go_description": "pyruvate dehydrogenase (acetyl-transferring) activity, protein binding", "go_terms": ["GO:0004739", "GO:0005515"], "mapman_bin": "5.1.2.2.1.1", "mapman_name": ".Lipid metabolism.fatty acid biosynthesis.acetyl-CoA generation.plastidial pyruvate dehydrogenase complex.E1 pyruvate dehydrogenase subcomplex.subunit alpha", "mapman_description": "subunit alpha of E1 pyruvate dehydrogenase component (original description: pep chromosome:TAIR10:1:47234:49304:-1 gene:AT1G01090 transcript:AT1G01090.1 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:PDH-E1 ALPHA description:Pyruvate dehydrogenase E1 component subunit alpha [Source:UniProtKB/TrEMBL;Acc:A0A178W8A7])", "pheno_aragwas_id": "", "pheno_description": "", "pheno_pto_name": "", "pheno_pto_description": "", "pheno_reference": "", "user_notes": ""}, + {"_key": "AT1G01100", "node_type": "gene", "transcript": "AT1G01100.4", "gene_symbol": "", "gene_full_name": "", "gene_model_type": "protein_coding", "tair_computational_description": "60S acidic ribosomal protein family;(source:Araport11)", "tair_curator_summary": "", "tair_short_description": "60S acidic ribosomal protein family", "go_description": "structural constituent of ribosome, ribonucleoprotein complex binding, protein kinase activator activity", "go_terms": ["GO:0003735", "GO:0043021", "GO:0030295"], "mapman_bin": "17.1.2.1.46", "mapman_name": ".Protein biosynthesis.ribosome biogenesis.large ribosomal subunit (LSU).LSU proteome.component RPP1", "mapman_description": "component RPP1 of LSU proteome component (original description: pep chromosome:TAIR10:1:50090:51187:-1 gene:AT1G01100 transcript:AT1G01100.4 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:RPP1A description:60S acidic ribosomal protein P1-1 [Source:UniProtKB/Swiss-Prot;Acc:Q8LCW9])", "pheno_aragwas_id": "", "pheno_description": "", "pheno_pto_name": "", "pheno_pto_description": "", "pheno_reference": "", "user_notes": ""}, + {"_key": "Na23", "node_type": "pheno", "transcript": "", "gene_symbol": "", "gene_full_name": "", "gene_model_type": "", "tair_computational_description": "", "tair_curator_summary": "", "tair_short_description": "", "go_description": "", "go_terms": [], "mapman_bin": "", "mapman_name": "", "mapman_description": "", "pheno_aragwas_id": "10.21958/phenotype:5", "pheno_description": "Sodium concentrations in leaves, grown in soil. Elemental analysis was performed with an ICP-MS (PerkinElmer). Sample normalized to calculated weights as described in Baxter et al., 2008", "pheno_pto_name": "sodium concentration", "pheno_pto_description": "The total sodium ion concentration measured in a given volume of a plant or a plant part or plant extract. [GR:pj]", "pheno_reference": "Atwell et. al, Nature 2010", "user_notes": ""}, + {"_key": "SDV", "node_type": "pheno", "transcript": "", "gene_symbol": "", "gene_full_name": "", "gene_model_type": "", "tair_computational_description": "", "tair_curator_summary": "", "tair_short_description": "", "go_description": "", "go_terms": [], "mapman_bin": "", "mapman_name": "", "mapman_description": "", "pheno_aragwas_id": "10.21958/phenotype:104", "pheno_description": "Number of days following stratification to opening of first flower. The experiment was stopped at 200 d, and accessions that had not flowered at that point were assigned a value of 200", "pheno_pto_name": "days to flowering trait", "pheno_pto_description": "A flowering time trait (TO:0002616)which is the number of days required for an individual flower (PO:0009046), a whole plant (PO:0000003) or a plant population to reach flowering stage (PO:0007616) from a predetermined time point (e.g. the date of seed sowing, seedling transplant, or seedling emergence). [GR:pj, TO:cooperl]", "pheno_reference": "Atwell et. al, Nature 2010", "user_notes": ""} ] }, "queries": { diff --git a/spec/test/djornl/test_data/edges.tsv b/spec/test/djornl/test_data/edges.tsv index ee443140..3fc69278 100644 --- a/spec/test/djornl/test_data/edges.tsv +++ b/spec/test/djornl/test_data/edges.tsv @@ -1,4 +1,4 @@ -node1 node2 edge edge_descrip layer_descrip +node1 node2 score edge_descrip edge_type As2 AT1G01020 8.4 AraGWAS-Association_score AraGWAS-Phenotype_Associations As2 AT1G01040 5.4 AraGWAS-Association_score AraGWAS-Phenotype_Associations As75 AT1G01020 39.9 AraGWAS-Association_score AraGWAS-Phenotype_Associations diff --git a/spec/test/djornl/test_data/hithruput-edges.csv b/spec/test/djornl/test_data/hithruput-edges.csv index 586476ab..cf771db2 100644 --- a/spec/test/djornl/test_data/hithruput-edges.csv +++ b/spec/test/djornl/test_data/hithruput-edges.csv @@ -1,3 +1,3 @@ -node1,node2,edge,edge_descrip,layer_descrip +node1,node2,score,edge_descrip,edge_type AT1G01010,AT1G01020,2.3,AraNetv2_log-likelihood-score,AraNetv2-HT_high-throughput-ppi AT1G01010,AT1G01030,2.4,AraNetv2_log-likelihood-score,AraNetv2-HT_high-throughput-ppi diff --git a/spec/test/djornl/test_data/nodes.csv b/spec/test/djornl/test_data/nodes.csv index 92f60761..678a6657 100644 --- a/spec/test/djornl/test_data/nodes.csv +++ b/spec/test/djornl/test_data/nodes.csv @@ -1,5 +1,5 @@ # data_type: node -node_id,node_type,transcript,gene_symbol,gene_full_name,gene_model_type,TAIR_Computational_description,TAIR_Curator_summary,TAIR_short_description,GO_description,GO_terms,MapMan_bin,MapMan_name,MapMan_description,pheno_AraGWAS_ID,pheno_description,pheno_pto_name,pheno_pto_description,pheno_ref,User_Notes +node_id,node_type,transcript,gene_symbol,gene_full_name,gene_model_type,TAIR_Computational_description,TAIR_Curator_summary,TAIR_short_description,GO_description,GO_terms,MapMan_bin,MapMan_name,MapMan_description,pheno_AraGWAS_ID,pheno_description,pheno_pto_name,pheno_pto_description,pheno_reference,User_Notes AT1G01010,gene,AT1G01010.1,NTL10,NAC domain containing protein 1,protein_coding,NAC domain containing protein 1;(source:Araport11),,NAC domain containing protein 1,"DNA-binding transcription factor activity, DNA binding","GO:0003700, GO:0003677",15.5.17,.RNA biosynthesis.transcriptional regulation.transcription factor (NAC),transcription factor (NAC) (original description: pep chromosome:TAIR10:1:3631:5899:1 gene:AT1G01010 transcript:AT1G01010.1 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:NAC001 description:NAC domain-containing protein 1 [Source:UniProtKB/Swiss-Prot;Acc:Q0WV96]),,,,,, AT1G01020,gene,AT1G01020.6,ARV1,,protein_coding,ARV1 family protein;(source:Araport11),,,molecular_function,GO:0003674,35.1,not assigned.annotated,(original description: pep chromosome:TAIR10:1:6788:8737:-1 gene:AT1G01020 transcript:AT1G01020.6 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:ARV1 description:ARV1 family protein [Source:UniProtKB/TrEMBL;Acc:Q5MK24]) & no description available(sp|q5mk24|arv1_arath : 99.4),,,,,, AT1G01030,gene,AT1G01030.2,NGA3,NGATHA3,protein_coding,AP2/B3-like transcriptional factor family protein;(source:Araport11),,,"DNA-binding transcription factor activity, DNA binding","GO:0003700, GO:0003677",15.5.5.3,.RNA biosynthesis.transcriptional regulation.B3 transcription factor superfamily.transcription factor (RAV/NGATHA),transcription factor (RAV/NGATHA) (original description: pep chromosome:TAIR10:1:11649:13714:-1 gene:AT1G01030 transcript:AT1G01030.2 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:NGA3 description:B3 domain-containing transcription factor NGA3 [Source:UniProtKB/Swiss-Prot;Acc:Q9MAN1]),,,,,, diff --git a/spec/test/djornl/test_data/pheno_nodes.csv b/spec/test/djornl/test_data/pheno_nodes.csv index 83fbf4be..9add7b7d 100644 --- a/spec/test/djornl/test_data/pheno_nodes.csv +++ b/spec/test/djornl/test_data/pheno_nodes.csv @@ -1,4 +1,4 @@ -node_id,node_type,pheno_AraGWAS_ID,pheno_description,pheno_pto_name,pheno_pto_description,pheno_ref,User_Notes +node_id,node_type,pheno_AraGWAS_ID,pheno_description,pheno_pto_name,pheno_pto_description,pheno_reference,User_Notes As2,pheno,10.21958/phenotype:103,,bacterial disease resistance,The resistance exhibited by a plant or a group of plants (population) in response to the disease caused by a bacterial pathogen infection as compared to the susceptible and/or the reference plants of the same species. [GR:pj],"Atwell et. al, Nature 2010", As75,pheno,10.21958/phenotype:67,"Arsenic concentrations in leaves, grown in soil. Elemental analysis was performed with an ICP-MS (PerkinElmer). Sample normalized to calculated weights as described in Baxter et al., 2008",arsenic concentration,A mineral and ion content related trait (TO:0000465) which is the concentration of arsenic (CHEBI:22632) in some plant structure (PO:0009011). [GR:Karthik],"Atwell et. al, Nature 2010", Na23,pheno,10.21958/phenotype:5,"Sodium concentrations in leaves, grown in soil. Elemental analysis was performed with an ICP-MS (PerkinElmer). Sample normalized to calculated weights as described in Baxter et al., 2008",sodium concentration,The total sodium ion concentration measured in a given volume of a plant or a plant part or plant extract. [GR:pj],"Atwell et. al, Nature 2010", diff --git a/spec/views/djornl/djornl_node_view.json b/spec/views/djornl/djornl_node_view.json index 2287f615..8dc30052 100644 --- a/spec/views/djornl/djornl_node_view.json +++ b/spec/views/djornl/djornl_node_view.json @@ -61,7 +61,7 @@ "text_en" ] }, - "pheno_ref": {}, + "pheno_reference": {}, "user_notes": { "analyzers": [ "text_en" From 71b81943bb8c061de6ee91eba0bcc9d0f95764a8 Mon Sep 17 00:00:00 2001 From: ialarmedalien Date: Tue, 6 Oct 2020 08:07:11 -0700 Subject: [PATCH 611/732] Property name changes: nodes: pheno_ref => pheno_reference edges: edge => score, layer_descrip => edge_type --- importers/djornl/parser.py | 8 +++--- spec/collections/djornl/djornl_node.yaml | 4 +-- spec/datasets/djornl/csv_edge.yaml | 6 ++-- spec/datasets/djornl/csv_node.yaml | 4 +-- spec/datasets/djornl/definitions.yaml | 2 +- ...aragwas-MERGED-AMW-v2_091319_nodeTable.csv | 2 +- .../merged_edges-AMW-060820_AF.tsv | 2 +- spec/test/djornl/duplicate_data/edges.tsv | 2 +- .../djornl/duplicate_data/hithruput-edges.csv | 2 +- spec/test/djornl/duplicate_data/nodes.csv | 2 +- .../djornl/duplicate_data/pheno_nodes.csv | 2 +- ...aragwas-MERGED-AMW-v2_091319_nodeTable.csv | 2 +- spec/test/djornl/invalid_types/edges.tsv | 2 +- spec/test/djornl/invalid_types/nodes.csv | 2 +- spec/test/djornl/results.json | 28 +++++++++---------- spec/test/djornl/test_data/edges.tsv | 2 +- .../test/djornl/test_data/hithruput-edges.csv | 2 +- spec/test/djornl/test_data/nodes.csv | 2 +- spec/test/djornl/test_data/pheno_nodes.csv | 2 +- spec/views/djornl/djornl_node_view.json | 2 +- 20 files changed, 40 insertions(+), 40 deletions(-) diff --git a/importers/djornl/parser.py b/importers/djornl/parser.py index c62c6793..29404b34 100644 --- a/importers/djornl/parser.py +++ b/importers/djornl/parser.py @@ -241,13 +241,13 @@ def load_edges(self): # appropriate values to go into Arango remap_functions = { # create a unique key for each record - '_key': lambda row: '__'.join([row[_] for _ in ['node1', 'node2', 'layer_descrip', 'edge']]), + '_key': lambda row: '__'.join([row[_] for _ in ['node1', 'node2', 'edge_type', 'score']]), 'node1': None, # this will be deleted in the 'store' step 'node2': None, # as will this '_from': lambda row: node_name + '/' + row['node1'], '_to': lambda row: node_name + '/' + row['node2'], - 'score': lambda row: float(row['edge']), - 'edge_type': lambda row: row['layer_descrip'], + 'score': lambda row: float(row['score']), + 'edge_type': None, } # store edge data, checking for potential duplicates @@ -316,7 +316,7 @@ def go_terms(row): 'pheno_description': None, 'pheno_pto_description': None, 'pheno_pto_name': None, - 'pheno_ref': None, + 'pheno_reference': None, 'tair_computational_description': None, 'tair_curator_summary': None, 'tair_short_description': None, diff --git a/spec/collections/djornl/djornl_node.yaml b/spec/collections/djornl/djornl_node.yaml index cf7e4d9d..eb85040b 100644 --- a/spec/collections/djornl/djornl_node.yaml +++ b/spec/collections/djornl/djornl_node.yaml @@ -52,7 +52,7 @@ schema: $ref: ../../datasets/djornl/definitions.yaml#/definitions/djornl_node/pheno_pto_name pheno_pto_description: $ref: ../../datasets/djornl/definitions.yaml#/definitions/djornl_node/pheno_pto_description - pheno_ref: - $ref: ../../datasets/djornl/definitions.yaml#/definitions/djornl_node/pheno_ref + pheno_reference: + $ref: ../../datasets/djornl/definitions.yaml#/definitions/djornl_node/pheno_reference user_notes: $ref: ../../datasets/djornl/definitions.yaml#/definitions/djornl_node/user_notes diff --git a/spec/datasets/djornl/csv_edge.yaml b/spec/datasets/djornl/csv_edge.yaml index 19617c5b..c166eb66 100644 --- a/spec/datasets/djornl/csv_edge.yaml +++ b/spec/datasets/djornl/csv_edge.yaml @@ -3,16 +3,16 @@ name: csv_edge title: CSV edge file syntax description: Jacobson lab Arabidopsis edge data file columns for generic node-to-node edges with scores type: object -required: [node1, node2, edge, layer_descrip] +required: [node1, node2, score, edge_type] properties: node1: $ref: definitions.yaml#/definitions/djornl_edge/_from node2: $ref: definitions.yaml#/definitions/djornl_edge/_to - edge: + score: # pre-transformation, the parser treats this as a string type: string format: regex pattern: ^\d+(\.\d+)?$ - layer_descrip: + edge_type: $ref: edge_type.yaml diff --git a/spec/datasets/djornl/csv_node.yaml b/spec/datasets/djornl/csv_node.yaml index b245d623..99d33a68 100644 --- a/spec/datasets/djornl/csv_node.yaml +++ b/spec/datasets/djornl/csv_node.yaml @@ -50,7 +50,7 @@ properties: $ref: definitions.yaml#/definitions/djornl_node/pheno_pto_name pheno_pto_description: $ref: definitions.yaml#/definitions/djornl_node/pheno_pto_description - pheno_ref: - $ref: definitions.yaml#/definitions/djornl_node/pheno_ref + pheno_reference: + $ref: definitions.yaml#/definitions/djornl_node/pheno_reference user_notes: $ref: definitions.yaml#/definitions/djornl_node/user_notes diff --git a/spec/datasets/djornl/definitions.yaml b/spec/datasets/djornl/definitions.yaml index da9b5dc4..9998af82 100644 --- a/spec/datasets/djornl/definitions.yaml +++ b/spec/datasets/djornl/definitions.yaml @@ -114,7 +114,7 @@ definitions: title: PTO description description: Plant Trait Ontology description examples: ["A mineral and ion content related trait (TO:0000465) which is the concentration of arsenic (CHEBI:22632) in some plant structure (PO:0009011). [GR:Karthik]"] - pheno_ref: + pheno_reference: type: string title: Phenotype reference examples: ["Atwell et. al, Nature 2010"] diff --git a/spec/test/djornl/col_count_errors/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv b/spec/test/djornl/col_count_errors/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv index e989f2ca..4edd51f5 100644 --- a/spec/test/djornl/col_count_errors/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv +++ b/spec/test/djornl/col_count_errors/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv @@ -1,4 +1,4 @@ -node_id,node_type,transcript,gene_symbol,gene_full_name,gene_model_type,TAIR_Computational_description,TAIR_Curator_summary,TAIR_short_description,GO_description,GO_terms,MapMan_bin,MapMan_name,MapMan_description,pheno_AraGWAS_ID,pheno_description,pheno_pto_name,pheno_pto_description,pheno_ref,User_Notes +node_id,node_type,transcript,gene_symbol,gene_full_name,gene_model_type,TAIR_Computational_description,TAIR_Curator_summary,TAIR_short_description,GO_description,GO_terms,MapMan_bin,MapMan_name,MapMan_description,pheno_AraGWAS_ID,pheno_description,pheno_pto_name,pheno_pto_description,pheno_reference,User_Notes As2,pheno,,,,,,,,,,,,,10.21958/phenotype:103,,bacterial disease resistance,The resistance exhibited by a plant or a group of plants (population) in response to the disease caused by a bacterial pathogen infection as compared to the susceptible and/or the reference plants of the same species. [GR:pj],"Atwell et. al, Nature 2010", As75,pheno,,,,,,,,,,,,,,,10.21958/phenotype:67,"Arsenic concentrations in leaves, grown in soil. Elemental analysis was performed with an ICP-MS (PerkinElmer). Sample normalized to calculated weights as described in Baxter et al., 2008",arsenic concentration,A mineral and ion content related trait (TO:0000465) which is the concentration of arsenic (CHEBI:22632) in some plant structure (PO:0009011). [GR:Karthik],"Atwell et. al, Nature 2010", AT1G01020,gene,AT1G01020.6,ARV1,,protein_coding,ARV1 family protein;(source:Araport11),,,molecular_function,GO:0003674,35.1,not assigned.annotated,(original description: pep chromosome:TAIR10:1:6788:8737:-1 gene:AT1G01020 transcript:AT1G01020.6 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:ARV1 description:ARV1 family protein [Source:UniProtKB/TrEMBL;Acc:Q5MK24]) & no description available(sp|q5mk24|arv1_arath : 99.4),,,,,, diff --git a/spec/test/djornl/col_count_errors/merged_edges-AMW-060820_AF.tsv b/spec/test/djornl/col_count_errors/merged_edges-AMW-060820_AF.tsv index a2d07a73..0cb3f090 100644 --- a/spec/test/djornl/col_count_errors/merged_edges-AMW-060820_AF.tsv +++ b/spec/test/djornl/col_count_errors/merged_edges-AMW-060820_AF.tsv @@ -1,4 +1,4 @@ -node1 node2 edge edge_descrip layer_descrip +node1 node2 score edge_descrip edge_type As2 AT1G01040 5.422046084731258 AraGWAS-Association_score AraGWAS-Phenotype_Associations As75 AT1G01020 39.98573324312915 AraGWAS-Association_score AraGWAS-Phenotype_Associations AT1G01010 AT1G01020 2.39322646755088 AraNetv2_log-likelihood-score AraNetv2-HT_high-throughput-ppi diff --git a/spec/test/djornl/duplicate_data/edges.tsv b/spec/test/djornl/duplicate_data/edges.tsv index 432c2deb..be7a654a 100644 --- a/spec/test/djornl/duplicate_data/edges.tsv +++ b/spec/test/djornl/duplicate_data/edges.tsv @@ -1,4 +1,4 @@ -node1 node2 edge edge_descrip layer_descrip +node1 node2 score edge_descrip edge_type As2 AT1G01020 8.4 AraGWAS-Association_score AraGWAS-Phenotype_Associations As2 AT1G01040 5.4 AraGWAS-Association_score AraGWAS-Phenotype_Associations As75 AT1G01020 39.9 AraGWAS-Association_score AraGWAS-Phenotype_Associations diff --git a/spec/test/djornl/duplicate_data/hithruput-edges.csv b/spec/test/djornl/duplicate_data/hithruput-edges.csv index c11caa3d..07e9c80f 100644 --- a/spec/test/djornl/duplicate_data/hithruput-edges.csv +++ b/spec/test/djornl/duplicate_data/hithruput-edges.csv @@ -1,4 +1,4 @@ -node1,node2,edge,edge_descrip,layer_descrip +node1,node2,score,edge_descrip,edge_type AT1G01010,AT1G01020,2.3,AraNetv2_log-likelihood-score,AraNetv2-HT_high-throughput-ppi AT1G01010,AT1G01030,2.4,AraNetv2_log-likelihood-score,AraNetv2-HT_high-throughput-ppi # potentially erroneous line diff --git a/spec/test/djornl/duplicate_data/nodes.csv b/spec/test/djornl/duplicate_data/nodes.csv index b1938272..bfb26a70 100644 --- a/spec/test/djornl/duplicate_data/nodes.csv +++ b/spec/test/djornl/duplicate_data/nodes.csv @@ -1,5 +1,5 @@ # data_type: node -node_id,node_type,transcript,gene_symbol,gene_full_name,gene_model_type,TAIR_Computational_description,TAIR_Curator_summary,TAIR_short_description,GO_description,GO_terms,MapMan_bin,MapMan_name,MapMan_description,pheno_AraGWAS_ID,pheno_description,pheno_pto_name,pheno_pto_description,pheno_ref,User_Notes +node_id,node_type,transcript,gene_symbol,gene_full_name,gene_model_type,TAIR_Computational_description,TAIR_Curator_summary,TAIR_short_description,GO_description,GO_terms,MapMan_bin,MapMan_name,MapMan_description,pheno_AraGWAS_ID,pheno_description,pheno_pto_name,pheno_pto_description,pheno_reference,User_Notes AT1G01010,gene,AT1G01010.1,NTL10,NAC domain containing protein 1,protein_coding,NAC domain containing protein 1;(source:Araport11),,NAC domain containing protein 1,"DNA-binding transcription factor activity, DNA binding","GO:0003700, GO:0003677",15.5.17,.RNA biosynthesis.transcriptional regulation.transcription factor (NAC),transcription factor (NAC) (original description: pep chromosome:TAIR10:1:3631:5899:1 gene:AT1G01010 transcript:AT1G01010.1 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:NAC001 description:NAC domain-containing protein 1 [Source:UniProtKB/Swiss-Prot;Acc:Q0WV96]),,,,,, AT1G01020,gene,AT1G01020.6,ARV1,,protein_coding,ARV1 family protein;(source:Araport11),,,molecular_function,GO:0003674,35.1,not assigned.annotated,(original description: pep chromosome:TAIR10:1:6788:8737:-1 gene:AT1G01020 transcript:AT1G01020.6 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:ARV1 description:ARV1 family protein [Source:UniProtKB/TrEMBL;Acc:Q5MK24]) & no description available(sp|q5mk24|arv1_arath : 99.4),,,,,, AT1G01030,gene,AT1G01030.2,NGA3,NGATHA3,protein_coding,AP2/B3-like transcriptional factor family protein;(source:Araport11),,,"DNA-binding transcription factor activity, DNA binding","GO:0003700, GO:0003677",15.5.5.3,.RNA biosynthesis.transcriptional regulation.B3 transcription factor superfamily.transcription factor (RAV/NGATHA),transcription factor (RAV/NGATHA) (original description: pep chromosome:TAIR10:1:11649:13714:-1 gene:AT1G01030 transcript:AT1G01030.2 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:NGA3 description:B3 domain-containing transcription factor NGA3 [Source:UniProtKB/Swiss-Prot;Acc:Q9MAN1]),,,,,, diff --git a/spec/test/djornl/duplicate_data/pheno_nodes.csv b/spec/test/djornl/duplicate_data/pheno_nodes.csv index 83fbf4be..9add7b7d 100644 --- a/spec/test/djornl/duplicate_data/pheno_nodes.csv +++ b/spec/test/djornl/duplicate_data/pheno_nodes.csv @@ -1,4 +1,4 @@ -node_id,node_type,pheno_AraGWAS_ID,pheno_description,pheno_pto_name,pheno_pto_description,pheno_ref,User_Notes +node_id,node_type,pheno_AraGWAS_ID,pheno_description,pheno_pto_name,pheno_pto_description,pheno_reference,User_Notes As2,pheno,10.21958/phenotype:103,,bacterial disease resistance,The resistance exhibited by a plant or a group of plants (population) in response to the disease caused by a bacterial pathogen infection as compared to the susceptible and/or the reference plants of the same species. [GR:pj],"Atwell et. al, Nature 2010", As75,pheno,10.21958/phenotype:67,"Arsenic concentrations in leaves, grown in soil. Elemental analysis was performed with an ICP-MS (PerkinElmer). Sample normalized to calculated weights as described in Baxter et al., 2008",arsenic concentration,A mineral and ion content related trait (TO:0000465) which is the concentration of arsenic (CHEBI:22632) in some plant structure (PO:0009011). [GR:Karthik],"Atwell et. al, Nature 2010", Na23,pheno,10.21958/phenotype:5,"Sodium concentrations in leaves, grown in soil. Elemental analysis was performed with an ICP-MS (PerkinElmer). Sample normalized to calculated weights as described in Baxter et al., 2008",sodium concentration,The total sodium ion concentration measured in a given volume of a plant or a plant part or plant extract. [GR:pj],"Atwell et. al, Nature 2010", diff --git a/spec/test/djornl/empty_files/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv b/spec/test/djornl/empty_files/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv index ab31e045..7fe64278 100644 --- a/spec/test/djornl/empty_files/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv +++ b/spec/test/djornl/empty_files/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv @@ -1 +1 @@ -node_id,node_type,transcript,gene_symbol,gene_full_name,gene_model_type,TAIR_Computational_description,TAIR_Curator_summary,TAIR_short_description,GO_description,GO_terms,MapMan_bin,MapMan_name,MapMan_description,pheno_AraGWAS_ID,pheno_description,pheno_pto_name,pheno_pto_description,pheno_ref,User_Notes +node_id,node_type,transcript,gene_symbol,gene_full_name,gene_model_type,TAIR_Computational_description,TAIR_Curator_summary,TAIR_short_description,GO_description,GO_terms,MapMan_bin,MapMan_name,MapMan_description,pheno_AraGWAS_ID,pheno_description,pheno_pto_name,pheno_pto_description,pheno_reference,User_Notes diff --git a/spec/test/djornl/invalid_types/edges.tsv b/spec/test/djornl/invalid_types/edges.tsv index 06bbe9fd..bad2b9b4 100644 --- a/spec/test/djornl/invalid_types/edges.tsv +++ b/spec/test/djornl/invalid_types/edges.tsv @@ -1,5 +1,5 @@ # data_type: edge -node1 node2 edge edge_descrip layer_descrip +node1 node2 score edge_descrip edge_type As2 AT1G01020 8.422046084731258 AraGWAS-Association_score Same-Old-Stuff As2 AT1G01040 6 AraGWAS-Association_score AraGWAS-Phenotype_Associations As75 AT1G01020 39.98573324312915 AraGWAS-Association_score AraGWAS-Phenotype_Associations diff --git a/spec/test/djornl/invalid_types/nodes.csv b/spec/test/djornl/invalid_types/nodes.csv index e469f003..ff99ff01 100644 --- a/spec/test/djornl/invalid_types/nodes.csv +++ b/spec/test/djornl/invalid_types/nodes.csv @@ -1,4 +1,4 @@ -node_id,node_type,transcript,gene_symbol,gene_full_name,gene_model_type,TAIR_Computational_description,TAIR_Curator_summary,TAIR_short_description,GO_description,GO_terms,MapMan_bin,MapMan_name,MapMan_description,pheno_AraGWAS_ID,pheno_description,pheno_pto_name,pheno_pto_description,pheno_ref,User_Notes +node_id,node_type,transcript,gene_symbol,gene_full_name,gene_model_type,TAIR_Computational_description,TAIR_Curator_summary,TAIR_short_description,GO_description,GO_terms,MapMan_bin,MapMan_name,MapMan_description,pheno_AraGWAS_ID,pheno_description,pheno_pto_name,pheno_pto_description,pheno_reference,User_Notes # data_type: node As2,pheno,,,,,,,,,,,,,10.21958/phenotype:103,,bacterial disease resistance,The resistance exhibited by a plant or a group of plants (population) in response to the disease caused by a bacterial pathogen infection as compared to the susceptible and/or the reference plants of the same species. [GR:pj],"Atwell et. al, Nature 2010", As75,pheno,,,,,,,,,,,,,10.21958/phenotype:67,"Arsenic concentrations in leaves, grown in soil. Elemental analysis was performed with an ICP-MS (PerkinElmer). Sample normalized to calculated weights as described in Baxter et al., 2008",arsenic concentration,A mineral and ion content related trait (TO:0000465) which is the concentration of arsenic (CHEBI:22632) in some plant structure (PO:0009011). [GR:Karthik],"Atwell et. al, Nature 2010", diff --git a/spec/test/djornl/results.json b/spec/test/djornl/results.json index 9baeed2f..4771d764 100644 --- a/spec/test/djornl/results.json +++ b/spec/test/djornl/results.json @@ -40,20 +40,20 @@ }, "load_nodes": { "nodes": [ - {"_key": "As2", "node_type": "pheno", "transcript": "", "gene_symbol": "", "gene_full_name": "", "gene_model_type": "", "tair_computational_description": "", "tair_curator_summary": "", "tair_short_description": "", "go_description": "", "go_terms": [], "mapman_bin": "", "mapman_name": "", "mapman_description": "", "pheno_aragwas_id": "10.21958/phenotype:103", "pheno_description": "", "pheno_pto_name": "bacterial disease resistance", "pheno_pto_description": "The resistance exhibited by a plant or a group of plants (population) in response to the disease caused by a bacterial pathogen infection as compared to the susceptible and/or the reference plants of the same species. [GR:pj]", "pheno_ref": "Atwell et. al, Nature 2010", "user_notes": ""}, - {"_key": "As75", "node_type": "pheno", "transcript": "", "gene_symbol": "", "gene_full_name": "", "gene_model_type": "", "tair_computational_description": "", "tair_curator_summary": "", "tair_short_description": "", "go_description": "", "go_terms": [], "mapman_bin": "", "mapman_name": "", "mapman_description": "", "pheno_aragwas_id": "10.21958/phenotype:67", "pheno_description": "Arsenic concentrations in leaves, grown in soil. Elemental analysis was performed with an ICP-MS (PerkinElmer). Sample normalized to calculated weights as described in Baxter et al., 2008", "pheno_pto_name": "arsenic concentration", "pheno_pto_description": "A mineral and ion content related trait (TO:0000465) which is the concentration of arsenic (CHEBI:22632) in some plant structure (PO:0009011). [GR:Karthik]", "pheno_ref": "Atwell et. al, Nature 2010", "user_notes": ""}, - {"_key": "AT1G01010", "node_type": "gene", "transcript": "AT1G01010.1", "gene_symbol": "NTL10", "gene_full_name": "NAC domain containing protein 1", "gene_model_type": "protein_coding", "tair_computational_description": "NAC domain containing protein 1;(source:Araport11)", "tair_curator_summary": "", "tair_short_description": "NAC domain containing protein 1", "go_description": "DNA-binding transcription factor activity, DNA binding", "go_terms": ["GO:0003700", "GO:0003677"], "mapman_bin": "15.5.17", "mapman_name": ".RNA biosynthesis.transcriptional regulation.transcription factor (NAC)", "mapman_description": "transcription factor (NAC) (original description: pep chromosome:TAIR10:1:3631:5899:1 gene:AT1G01010 transcript:AT1G01010.1 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:NAC001 description:NAC domain-containing protein 1 [Source:UniProtKB/Swiss-Prot;Acc:Q0WV96])", "pheno_aragwas_id": "", "pheno_description": "", "pheno_pto_name": "", "pheno_pto_description": "", "pheno_ref": "", "user_notes": ""}, - {"_key": "AT1G01020", "node_type": "gene", "transcript": "AT1G01020.6", "gene_symbol": "ARV1", "gene_full_name": "", "gene_model_type": "protein_coding", "tair_computational_description": "ARV1 family protein;(source:Araport11)", "tair_curator_summary": "", "tair_short_description": "", "go_description": "molecular_function", "go_terms": ["GO:0003674"], "mapman_bin": "35.1", "mapman_name": "not assigned.annotated", "mapman_description": "(original description: pep chromosome:TAIR10:1:6788:8737:-1 gene:AT1G01020 transcript:AT1G01020.6 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:ARV1 description:ARV1 family protein [Source:UniProtKB/TrEMBL;Acc:Q5MK24]) & no description available(sp|q5mk24|arv1_arath : 99.4)", "pheno_aragwas_id": "", "pheno_description": "", "pheno_pto_name": "", "pheno_pto_description": "", "pheno_ref": "", "user_notes": ""}, - {"_key": "AT1G01030", "node_type": "gene", "transcript": "AT1G01030.2", "gene_symbol": "NGA3", "gene_full_name": "NGATHA3", "gene_model_type": "protein_coding", "tair_computational_description": "AP2/B3-like transcriptional factor family protein;(source:Araport11)", "tair_curator_summary": "", "tair_short_description": "", "go_description": "DNA-binding transcription factor activity, DNA binding", "go_terms": ["GO:0003700", "GO:0003677"], "mapman_bin": "15.5.5.3", "mapman_name": ".RNA biosynthesis.transcriptional regulation.B3 transcription factor superfamily.transcription factor (RAV/NGATHA)", "mapman_description": "transcription factor (RAV/NGATHA) (original description: pep chromosome:TAIR10:1:11649:13714:-1 gene:AT1G01030 transcript:AT1G01030.2 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:NGA3 description:B3 domain-containing transcription factor NGA3 [Source:UniProtKB/Swiss-Prot;Acc:Q9MAN1])", "pheno_aragwas_id": "", "pheno_description": "", "pheno_pto_name": "", "pheno_pto_description": "", "pheno_ref": "", "user_notes": ""}, - {"_key": "AT1G01040", "node_type": "gene", "transcript": "AT1G01040.2", "gene_symbol": "SUS1", "gene_full_name": "SUSPENSOR 1", "gene_model_type": "protein_coding", "tair_computational_description": "dicer-like 1;(source:Araport11)", "tair_curator_summary": "Encodes a Dicer homolog. Dicer is a RNA helicase involved in microRNA processing. Mutations in this locus can result in embryo lethality. Embryo shape at seed maturity is globular-elongate. Other mutants convert the floral meristems to an indeterminate state, others yet show defects in ovule development. mRNA is expressed in all shoot tissues. DCL1 is able to produce miRNAs and siRNAs. The mRNA is cell-to-cell mobile.", "tair_short_description": "dicer-like 1", "go_description": "metal ion binding, protein binding, ribonuclease III activity, ATP-dependent helicase activity, ATP binding, RNA binding, helicase activity, double-stranded RNA binding, DNA binding", "go_terms": ["GO:0046872", "GO:0005515", "GO:0004525", "GO:0008026", "GO:0005524", "GO:0003723", "GO:0004386", "GO:0003725", "GO:0003677"], "mapman_bin": "16.10.2.1.1", "mapman_name": ".RNA processing.mRNA silencing.miRNA pathway.DCL1-HYL1 miRNA biogenesis complex.endoribonuclease component DCL1", "mapman_description": "endoribonuclease component DCL1 of DCL1-HYL1 miRNA biogenesis complex (original description: pep chromosome:TAIR10:1:23416:31120:1 gene:AT1G01040 transcript:AT1G01040.2 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:DCL1 description:Dicer-like 1 [Source:UniProtKB/TrEMBL;Acc:F4HQG6])", "pheno_aragwas_id": "", "pheno_description": "", "pheno_pto_name": "", "pheno_pto_description": "", "pheno_ref": "", "user_notes": ""}, - {"_key": "AT1G01050", "node_type": "gene", "transcript": "AT1G01050.2", "gene_symbol": "PPa1", "gene_full_name": "pyrophosphorylase 1", "gene_model_type": "protein_coding", "tair_computational_description": "pyrophosphorylase 1;(source:Araport11)", "tair_curator_summary": "", "tair_short_description": "", "go_description": "inorganic diphosphatase activity", "go_terms": ["GO:0004427"], "mapman_bin": "35.1", "mapman_name": "not assigned.annotated", "mapman_description": "(original description: pep chromosome:TAIR10:1:31382:33009:-1 gene:AT1G01050 transcript:AT1G01050.2 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:PPA1 description:Soluble inorganic pyrophosphatase 1 [Source:UniProtKB/Swiss-Prot;Acc:Q93V56]) & Soluble inorganic pyrophosphatase 1 OS=Arabidopsis thaliana (sp|q93v56|ipyr1_arath : 419.0)", "pheno_aragwas_id": "", "pheno_description": "", "pheno_pto_name": "", "pheno_pto_description": "", "pheno_ref": "", "user_notes": ""}, - {"_key": "AT1G01060", "node_type": "gene", "transcript": "AT1G01060.8", "gene_symbol": "LHY1", "gene_full_name": "LATE ELONGATED HYPOCOTYL 1", "gene_model_type": "protein_coding", "tair_computational_description": "Homeodomain-like superfamily protein;(source:Araport11)", "tair_curator_summary": "", "tair_short_description": "", "go_description": "DNA-binding transcription factor activity, DNA binding, transcription regulatory region DNA binding", "go_terms": ["GO:0003700", "GO:0003677", "GO:0044212"], "mapman_bin": "27.1.1", "mapman_name": ".Multi-process regulation.circadian clock system.core oscillator protein (LHY|CCA1)", "mapman_description": "circadian clock core oscillator protein (LHY|CCA1) (original description: pep chromosome:TAIR10:1:33967:37230:-1 gene:AT1G01060 transcript:AT1G01060.8 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:LHY description:LHY1 [Source:UniProtKB/TrEMBL;Acc:A0A178W761])", "pheno_aragwas_id": "", "pheno_description": "", "pheno_pto_name": "", "pheno_pto_description": "", "pheno_ref": "", "user_notes": ""}, - {"_key": "AT1G01070", "node_type": "gene", "transcript": "AT1G01070.2", "gene_symbol": "UMAMIT28", "gene_full_name": "Usually multiple acids move in and out Transporters 28", "gene_model_type": "protein_coding", "tair_computational_description": "nodulin MtN21 /EamA-like transporter family protein;(source:Araport11)", "tair_curator_summary": "Encodes a plasma membrane-localized amino acid transporter likely involved in amino acid export in the developing seed.", "tair_short_description": "nodulin MtN21 /EamA-like transporter family protein", "go_description": "L-glutamine transmembrane transporter activity", "go_terms": ["GO:0015186"], "mapman_bin": "24.2.1.5", "mapman_name": ".Solute transport.carrier-mediated transport.DMT superfamily.solute transporter (UmamiT)", "mapman_description": "solute transporter (UmamiT) (original description: pep chromosome:TAIR10:1:38752:40945:-1 gene:AT1G01070 transcript:AT1G01070.2 gene_biotype:protein_coding transcript_biotype:protein_coding description:WAT1-related protein [Source:UniProtKB/TrEMBL;Acc:A0A178WFU3])", "pheno_aragwas_id": "", "pheno_description": "", "pheno_pto_name": "", "pheno_pto_description": "", "pheno_ref": "", "user_notes": ""}, - {"_key": "AT1G01080", "node_type": "gene", "transcript": "AT1G01080.3", "gene_symbol": "", "gene_full_name": "", "gene_model_type": "protein_coding", "tair_computational_description": "RNA-binding (RRM/RBD/RNP motifs) family protein;(source:Araport11)", "tair_curator_summary": "", "tair_short_description": "", "go_description": "RNA binding, mRNA binding", "go_terms": ["GO:0003723", "GO:0003729"], "mapman_bin": "35.1", "mapman_name": "not assigned.annotated", "mapman_description": "(original description: pep chromosome:TAIR10:1:44970:47059:-1 gene:AT1G01080 transcript:AT1G01080.3 gene_biotype:protein_coding transcript_biotype:protein_coding description:RNA-binding (RRM/RBD/RNP motifs) family protein [Source:UniProtKB/TrEMBL;Acc:F4HQH8]) & 33 kDa ribonucleoprotein, chloroplastic OS=Nicotiana sylvestris (sp|p19684|roc5_nicsy : 109.0)", "pheno_aragwas_id": "", "pheno_description": "", "pheno_pto_name": "", "pheno_pto_description": "", "pheno_ref": "", "user_notes": ""}, - {"_key": "AT1G01090", "node_type": "gene", "transcript": "AT1G01090.1", "gene_symbol": "PDH-E1 ALPHA", "gene_full_name": "pyruvate dehydrogenase E1 alpha", "gene_model_type": "protein_coding", "tair_computational_description": "pyruvate dehydrogenase E1 alpha;(source:Araport11)", "tair_curator_summary": "pyruvate dehydrogenase E1 alpha subunit", "tair_short_description": "pyruvate dehydrogenase E1 alpha", "go_description": "pyruvate dehydrogenase (acetyl-transferring) activity, protein binding", "go_terms": ["GO:0004739", "GO:0005515"], "mapman_bin": "5.1.2.2.1.1", "mapman_name": ".Lipid metabolism.fatty acid biosynthesis.acetyl-CoA generation.plastidial pyruvate dehydrogenase complex.E1 pyruvate dehydrogenase subcomplex.subunit alpha", "mapman_description": "subunit alpha of E1 pyruvate dehydrogenase component (original description: pep chromosome:TAIR10:1:47234:49304:-1 gene:AT1G01090 transcript:AT1G01090.1 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:PDH-E1 ALPHA description:Pyruvate dehydrogenase E1 component subunit alpha [Source:UniProtKB/TrEMBL;Acc:A0A178W8A7])", "pheno_aragwas_id": "", "pheno_description": "", "pheno_pto_name": "", "pheno_pto_description": "", "pheno_ref": "", "user_notes": ""}, - {"_key": "AT1G01100", "node_type": "gene", "transcript": "AT1G01100.4", "gene_symbol": "", "gene_full_name": "", "gene_model_type": "protein_coding", "tair_computational_description": "60S acidic ribosomal protein family;(source:Araport11)", "tair_curator_summary": "", "tair_short_description": "60S acidic ribosomal protein family", "go_description": "structural constituent of ribosome, ribonucleoprotein complex binding, protein kinase activator activity", "go_terms": ["GO:0003735", "GO:0043021", "GO:0030295"], "mapman_bin": "17.1.2.1.46", "mapman_name": ".Protein biosynthesis.ribosome biogenesis.large ribosomal subunit (LSU).LSU proteome.component RPP1", "mapman_description": "component RPP1 of LSU proteome component (original description: pep chromosome:TAIR10:1:50090:51187:-1 gene:AT1G01100 transcript:AT1G01100.4 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:RPP1A description:60S acidic ribosomal protein P1-1 [Source:UniProtKB/Swiss-Prot;Acc:Q8LCW9])", "pheno_aragwas_id": "", "pheno_description": "", "pheno_pto_name": "", "pheno_pto_description": "", "pheno_ref": "", "user_notes": ""}, - {"_key": "Na23", "node_type": "pheno", "transcript": "", "gene_symbol": "", "gene_full_name": "", "gene_model_type": "", "tair_computational_description": "", "tair_curator_summary": "", "tair_short_description": "", "go_description": "", "go_terms": [], "mapman_bin": "", "mapman_name": "", "mapman_description": "", "pheno_aragwas_id": "10.21958/phenotype:5", "pheno_description": "Sodium concentrations in leaves, grown in soil. Elemental analysis was performed with an ICP-MS (PerkinElmer). Sample normalized to calculated weights as described in Baxter et al., 2008", "pheno_pto_name": "sodium concentration", "pheno_pto_description": "The total sodium ion concentration measured in a given volume of a plant or a plant part or plant extract. [GR:pj]", "pheno_ref": "Atwell et. al, Nature 2010", "user_notes": ""}, - {"_key": "SDV", "node_type": "pheno", "transcript": "", "gene_symbol": "", "gene_full_name": "", "gene_model_type": "", "tair_computational_description": "", "tair_curator_summary": "", "tair_short_description": "", "go_description": "", "go_terms": [], "mapman_bin": "", "mapman_name": "", "mapman_description": "", "pheno_aragwas_id": "10.21958/phenotype:104", "pheno_description": "Number of days following stratification to opening of first flower. The experiment was stopped at 200 d, and accessions that had not flowered at that point were assigned a value of 200", "pheno_pto_name": "days to flowering trait", "pheno_pto_description": "A flowering time trait (TO:0002616)which is the number of days required for an individual flower (PO:0009046), a whole plant (PO:0000003) or a plant population to reach flowering stage (PO:0007616) from a predetermined time point (e.g. the date of seed sowing, seedling transplant, or seedling emergence). [GR:pj, TO:cooperl]", "pheno_ref": "Atwell et. al, Nature 2010", "user_notes": ""} + {"_key": "As2", "node_type": "pheno", "transcript": "", "gene_symbol": "", "gene_full_name": "", "gene_model_type": "", "tair_computational_description": "", "tair_curator_summary": "", "tair_short_description": "", "go_description": "", "go_terms": [], "mapman_bin": "", "mapman_name": "", "mapman_description": "", "pheno_aragwas_id": "10.21958/phenotype:103", "pheno_description": "", "pheno_pto_name": "bacterial disease resistance", "pheno_pto_description": "The resistance exhibited by a plant or a group of plants (population) in response to the disease caused by a bacterial pathogen infection as compared to the susceptible and/or the reference plants of the same species. [GR:pj]", "pheno_reference": "Atwell et. al, Nature 2010", "user_notes": ""}, + {"_key": "As75", "node_type": "pheno", "transcript": "", "gene_symbol": "", "gene_full_name": "", "gene_model_type": "", "tair_computational_description": "", "tair_curator_summary": "", "tair_short_description": "", "go_description": "", "go_terms": [], "mapman_bin": "", "mapman_name": "", "mapman_description": "", "pheno_aragwas_id": "10.21958/phenotype:67", "pheno_description": "Arsenic concentrations in leaves, grown in soil. Elemental analysis was performed with an ICP-MS (PerkinElmer). Sample normalized to calculated weights as described in Baxter et al., 2008", "pheno_pto_name": "arsenic concentration", "pheno_pto_description": "A mineral and ion content related trait (TO:0000465) which is the concentration of arsenic (CHEBI:22632) in some plant structure (PO:0009011). [GR:Karthik]", "pheno_reference": "Atwell et. al, Nature 2010", "user_notes": ""}, + {"_key": "AT1G01010", "node_type": "gene", "transcript": "AT1G01010.1", "gene_symbol": "NTL10", "gene_full_name": "NAC domain containing protein 1", "gene_model_type": "protein_coding", "tair_computational_description": "NAC domain containing protein 1;(source:Araport11)", "tair_curator_summary": "", "tair_short_description": "NAC domain containing protein 1", "go_description": "DNA-binding transcription factor activity, DNA binding", "go_terms": ["GO:0003700", "GO:0003677"], "mapman_bin": "15.5.17", "mapman_name": ".RNA biosynthesis.transcriptional regulation.transcription factor (NAC)", "mapman_description": "transcription factor (NAC) (original description: pep chromosome:TAIR10:1:3631:5899:1 gene:AT1G01010 transcript:AT1G01010.1 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:NAC001 description:NAC domain-containing protein 1 [Source:UniProtKB/Swiss-Prot;Acc:Q0WV96])", "pheno_aragwas_id": "", "pheno_description": "", "pheno_pto_name": "", "pheno_pto_description": "", "pheno_reference": "", "user_notes": ""}, + {"_key": "AT1G01020", "node_type": "gene", "transcript": "AT1G01020.6", "gene_symbol": "ARV1", "gene_full_name": "", "gene_model_type": "protein_coding", "tair_computational_description": "ARV1 family protein;(source:Araport11)", "tair_curator_summary": "", "tair_short_description": "", "go_description": "molecular_function", "go_terms": ["GO:0003674"], "mapman_bin": "35.1", "mapman_name": "not assigned.annotated", "mapman_description": "(original description: pep chromosome:TAIR10:1:6788:8737:-1 gene:AT1G01020 transcript:AT1G01020.6 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:ARV1 description:ARV1 family protein [Source:UniProtKB/TrEMBL;Acc:Q5MK24]) & no description available(sp|q5mk24|arv1_arath : 99.4)", "pheno_aragwas_id": "", "pheno_description": "", "pheno_pto_name": "", "pheno_pto_description": "", "pheno_reference": "", "user_notes": ""}, + {"_key": "AT1G01030", "node_type": "gene", "transcript": "AT1G01030.2", "gene_symbol": "NGA3", "gene_full_name": "NGATHA3", "gene_model_type": "protein_coding", "tair_computational_description": "AP2/B3-like transcriptional factor family protein;(source:Araport11)", "tair_curator_summary": "", "tair_short_description": "", "go_description": "DNA-binding transcription factor activity, DNA binding", "go_terms": ["GO:0003700", "GO:0003677"], "mapman_bin": "15.5.5.3", "mapman_name": ".RNA biosynthesis.transcriptional regulation.B3 transcription factor superfamily.transcription factor (RAV/NGATHA)", "mapman_description": "transcription factor (RAV/NGATHA) (original description: pep chromosome:TAIR10:1:11649:13714:-1 gene:AT1G01030 transcript:AT1G01030.2 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:NGA3 description:B3 domain-containing transcription factor NGA3 [Source:UniProtKB/Swiss-Prot;Acc:Q9MAN1])", "pheno_aragwas_id": "", "pheno_description": "", "pheno_pto_name": "", "pheno_pto_description": "", "pheno_reference": "", "user_notes": ""}, + {"_key": "AT1G01040", "node_type": "gene", "transcript": "AT1G01040.2", "gene_symbol": "SUS1", "gene_full_name": "SUSPENSOR 1", "gene_model_type": "protein_coding", "tair_computational_description": "dicer-like 1;(source:Araport11)", "tair_curator_summary": "Encodes a Dicer homolog. Dicer is a RNA helicase involved in microRNA processing. Mutations in this locus can result in embryo lethality. Embryo shape at seed maturity is globular-elongate. Other mutants convert the floral meristems to an indeterminate state, others yet show defects in ovule development. mRNA is expressed in all shoot tissues. DCL1 is able to produce miRNAs and siRNAs. The mRNA is cell-to-cell mobile.", "tair_short_description": "dicer-like 1", "go_description": "metal ion binding, protein binding, ribonuclease III activity, ATP-dependent helicase activity, ATP binding, RNA binding, helicase activity, double-stranded RNA binding, DNA binding", "go_terms": ["GO:0046872", "GO:0005515", "GO:0004525", "GO:0008026", "GO:0005524", "GO:0003723", "GO:0004386", "GO:0003725", "GO:0003677"], "mapman_bin": "16.10.2.1.1", "mapman_name": ".RNA processing.mRNA silencing.miRNA pathway.DCL1-HYL1 miRNA biogenesis complex.endoribonuclease component DCL1", "mapman_description": "endoribonuclease component DCL1 of DCL1-HYL1 miRNA biogenesis complex (original description: pep chromosome:TAIR10:1:23416:31120:1 gene:AT1G01040 transcript:AT1G01040.2 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:DCL1 description:Dicer-like 1 [Source:UniProtKB/TrEMBL;Acc:F4HQG6])", "pheno_aragwas_id": "", "pheno_description": "", "pheno_pto_name": "", "pheno_pto_description": "", "pheno_reference": "", "user_notes": ""}, + {"_key": "AT1G01050", "node_type": "gene", "transcript": "AT1G01050.2", "gene_symbol": "PPa1", "gene_full_name": "pyrophosphorylase 1", "gene_model_type": "protein_coding", "tair_computational_description": "pyrophosphorylase 1;(source:Araport11)", "tair_curator_summary": "", "tair_short_description": "", "go_description": "inorganic diphosphatase activity", "go_terms": ["GO:0004427"], "mapman_bin": "35.1", "mapman_name": "not assigned.annotated", "mapman_description": "(original description: pep chromosome:TAIR10:1:31382:33009:-1 gene:AT1G01050 transcript:AT1G01050.2 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:PPA1 description:Soluble inorganic pyrophosphatase 1 [Source:UniProtKB/Swiss-Prot;Acc:Q93V56]) & Soluble inorganic pyrophosphatase 1 OS=Arabidopsis thaliana (sp|q93v56|ipyr1_arath : 419.0)", "pheno_aragwas_id": "", "pheno_description": "", "pheno_pto_name": "", "pheno_pto_description": "", "pheno_reference": "", "user_notes": ""}, + {"_key": "AT1G01060", "node_type": "gene", "transcript": "AT1G01060.8", "gene_symbol": "LHY1", "gene_full_name": "LATE ELONGATED HYPOCOTYL 1", "gene_model_type": "protein_coding", "tair_computational_description": "Homeodomain-like superfamily protein;(source:Araport11)", "tair_curator_summary": "", "tair_short_description": "", "go_description": "DNA-binding transcription factor activity, DNA binding, transcription regulatory region DNA binding", "go_terms": ["GO:0003700", "GO:0003677", "GO:0044212"], "mapman_bin": "27.1.1", "mapman_name": ".Multi-process regulation.circadian clock system.core oscillator protein (LHY|CCA1)", "mapman_description": "circadian clock core oscillator protein (LHY|CCA1) (original description: pep chromosome:TAIR10:1:33967:37230:-1 gene:AT1G01060 transcript:AT1G01060.8 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:LHY description:LHY1 [Source:UniProtKB/TrEMBL;Acc:A0A178W761])", "pheno_aragwas_id": "", "pheno_description": "", "pheno_pto_name": "", "pheno_pto_description": "", "pheno_reference": "", "user_notes": ""}, + {"_key": "AT1G01070", "node_type": "gene", "transcript": "AT1G01070.2", "gene_symbol": "UMAMIT28", "gene_full_name": "Usually multiple acids move in and out Transporters 28", "gene_model_type": "protein_coding", "tair_computational_description": "nodulin MtN21 /EamA-like transporter family protein;(source:Araport11)", "tair_curator_summary": "Encodes a plasma membrane-localized amino acid transporter likely involved in amino acid export in the developing seed.", "tair_short_description": "nodulin MtN21 /EamA-like transporter family protein", "go_description": "L-glutamine transmembrane transporter activity", "go_terms": ["GO:0015186"], "mapman_bin": "24.2.1.5", "mapman_name": ".Solute transport.carrier-mediated transport.DMT superfamily.solute transporter (UmamiT)", "mapman_description": "solute transporter (UmamiT) (original description: pep chromosome:TAIR10:1:38752:40945:-1 gene:AT1G01070 transcript:AT1G01070.2 gene_biotype:protein_coding transcript_biotype:protein_coding description:WAT1-related protein [Source:UniProtKB/TrEMBL;Acc:A0A178WFU3])", "pheno_aragwas_id": "", "pheno_description": "", "pheno_pto_name": "", "pheno_pto_description": "", "pheno_reference": "", "user_notes": ""}, + {"_key": "AT1G01080", "node_type": "gene", "transcript": "AT1G01080.3", "gene_symbol": "", "gene_full_name": "", "gene_model_type": "protein_coding", "tair_computational_description": "RNA-binding (RRM/RBD/RNP motifs) family protein;(source:Araport11)", "tair_curator_summary": "", "tair_short_description": "", "go_description": "RNA binding, mRNA binding", "go_terms": ["GO:0003723", "GO:0003729"], "mapman_bin": "35.1", "mapman_name": "not assigned.annotated", "mapman_description": "(original description: pep chromosome:TAIR10:1:44970:47059:-1 gene:AT1G01080 transcript:AT1G01080.3 gene_biotype:protein_coding transcript_biotype:protein_coding description:RNA-binding (RRM/RBD/RNP motifs) family protein [Source:UniProtKB/TrEMBL;Acc:F4HQH8]) & 33 kDa ribonucleoprotein, chloroplastic OS=Nicotiana sylvestris (sp|p19684|roc5_nicsy : 109.0)", "pheno_aragwas_id": "", "pheno_description": "", "pheno_pto_name": "", "pheno_pto_description": "", "pheno_reference": "", "user_notes": ""}, + {"_key": "AT1G01090", "node_type": "gene", "transcript": "AT1G01090.1", "gene_symbol": "PDH-E1 ALPHA", "gene_full_name": "pyruvate dehydrogenase E1 alpha", "gene_model_type": "protein_coding", "tair_computational_description": "pyruvate dehydrogenase E1 alpha;(source:Araport11)", "tair_curator_summary": "pyruvate dehydrogenase E1 alpha subunit", "tair_short_description": "pyruvate dehydrogenase E1 alpha", "go_description": "pyruvate dehydrogenase (acetyl-transferring) activity, protein binding", "go_terms": ["GO:0004739", "GO:0005515"], "mapman_bin": "5.1.2.2.1.1", "mapman_name": ".Lipid metabolism.fatty acid biosynthesis.acetyl-CoA generation.plastidial pyruvate dehydrogenase complex.E1 pyruvate dehydrogenase subcomplex.subunit alpha", "mapman_description": "subunit alpha of E1 pyruvate dehydrogenase component (original description: pep chromosome:TAIR10:1:47234:49304:-1 gene:AT1G01090 transcript:AT1G01090.1 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:PDH-E1 ALPHA description:Pyruvate dehydrogenase E1 component subunit alpha [Source:UniProtKB/TrEMBL;Acc:A0A178W8A7])", "pheno_aragwas_id": "", "pheno_description": "", "pheno_pto_name": "", "pheno_pto_description": "", "pheno_reference": "", "user_notes": ""}, + {"_key": "AT1G01100", "node_type": "gene", "transcript": "AT1G01100.4", "gene_symbol": "", "gene_full_name": "", "gene_model_type": "protein_coding", "tair_computational_description": "60S acidic ribosomal protein family;(source:Araport11)", "tair_curator_summary": "", "tair_short_description": "60S acidic ribosomal protein family", "go_description": "structural constituent of ribosome, ribonucleoprotein complex binding, protein kinase activator activity", "go_terms": ["GO:0003735", "GO:0043021", "GO:0030295"], "mapman_bin": "17.1.2.1.46", "mapman_name": ".Protein biosynthesis.ribosome biogenesis.large ribosomal subunit (LSU).LSU proteome.component RPP1", "mapman_description": "component RPP1 of LSU proteome component (original description: pep chromosome:TAIR10:1:50090:51187:-1 gene:AT1G01100 transcript:AT1G01100.4 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:RPP1A description:60S acidic ribosomal protein P1-1 [Source:UniProtKB/Swiss-Prot;Acc:Q8LCW9])", "pheno_aragwas_id": "", "pheno_description": "", "pheno_pto_name": "", "pheno_pto_description": "", "pheno_reference": "", "user_notes": ""}, + {"_key": "Na23", "node_type": "pheno", "transcript": "", "gene_symbol": "", "gene_full_name": "", "gene_model_type": "", "tair_computational_description": "", "tair_curator_summary": "", "tair_short_description": "", "go_description": "", "go_terms": [], "mapman_bin": "", "mapman_name": "", "mapman_description": "", "pheno_aragwas_id": "10.21958/phenotype:5", "pheno_description": "Sodium concentrations in leaves, grown in soil. Elemental analysis was performed with an ICP-MS (PerkinElmer). Sample normalized to calculated weights as described in Baxter et al., 2008", "pheno_pto_name": "sodium concentration", "pheno_pto_description": "The total sodium ion concentration measured in a given volume of a plant or a plant part or plant extract. [GR:pj]", "pheno_reference": "Atwell et. al, Nature 2010", "user_notes": ""}, + {"_key": "SDV", "node_type": "pheno", "transcript": "", "gene_symbol": "", "gene_full_name": "", "gene_model_type": "", "tair_computational_description": "", "tair_curator_summary": "", "tair_short_description": "", "go_description": "", "go_terms": [], "mapman_bin": "", "mapman_name": "", "mapman_description": "", "pheno_aragwas_id": "10.21958/phenotype:104", "pheno_description": "Number of days following stratification to opening of first flower. The experiment was stopped at 200 d, and accessions that had not flowered at that point were assigned a value of 200", "pheno_pto_name": "days to flowering trait", "pheno_pto_description": "A flowering time trait (TO:0002616)which is the number of days required for an individual flower (PO:0009046), a whole plant (PO:0000003) or a plant population to reach flowering stage (PO:0007616) from a predetermined time point (e.g. the date of seed sowing, seedling transplant, or seedling emergence). [GR:pj, TO:cooperl]", "pheno_reference": "Atwell et. al, Nature 2010", "user_notes": ""} ] }, "queries": { diff --git a/spec/test/djornl/test_data/edges.tsv b/spec/test/djornl/test_data/edges.tsv index ee443140..3fc69278 100644 --- a/spec/test/djornl/test_data/edges.tsv +++ b/spec/test/djornl/test_data/edges.tsv @@ -1,4 +1,4 @@ -node1 node2 edge edge_descrip layer_descrip +node1 node2 score edge_descrip edge_type As2 AT1G01020 8.4 AraGWAS-Association_score AraGWAS-Phenotype_Associations As2 AT1G01040 5.4 AraGWAS-Association_score AraGWAS-Phenotype_Associations As75 AT1G01020 39.9 AraGWAS-Association_score AraGWAS-Phenotype_Associations diff --git a/spec/test/djornl/test_data/hithruput-edges.csv b/spec/test/djornl/test_data/hithruput-edges.csv index 586476ab..cf771db2 100644 --- a/spec/test/djornl/test_data/hithruput-edges.csv +++ b/spec/test/djornl/test_data/hithruput-edges.csv @@ -1,3 +1,3 @@ -node1,node2,edge,edge_descrip,layer_descrip +node1,node2,score,edge_descrip,edge_type AT1G01010,AT1G01020,2.3,AraNetv2_log-likelihood-score,AraNetv2-HT_high-throughput-ppi AT1G01010,AT1G01030,2.4,AraNetv2_log-likelihood-score,AraNetv2-HT_high-throughput-ppi diff --git a/spec/test/djornl/test_data/nodes.csv b/spec/test/djornl/test_data/nodes.csv index 92f60761..678a6657 100644 --- a/spec/test/djornl/test_data/nodes.csv +++ b/spec/test/djornl/test_data/nodes.csv @@ -1,5 +1,5 @@ # data_type: node -node_id,node_type,transcript,gene_symbol,gene_full_name,gene_model_type,TAIR_Computational_description,TAIR_Curator_summary,TAIR_short_description,GO_description,GO_terms,MapMan_bin,MapMan_name,MapMan_description,pheno_AraGWAS_ID,pheno_description,pheno_pto_name,pheno_pto_description,pheno_ref,User_Notes +node_id,node_type,transcript,gene_symbol,gene_full_name,gene_model_type,TAIR_Computational_description,TAIR_Curator_summary,TAIR_short_description,GO_description,GO_terms,MapMan_bin,MapMan_name,MapMan_description,pheno_AraGWAS_ID,pheno_description,pheno_pto_name,pheno_pto_description,pheno_reference,User_Notes AT1G01010,gene,AT1G01010.1,NTL10,NAC domain containing protein 1,protein_coding,NAC domain containing protein 1;(source:Araport11),,NAC domain containing protein 1,"DNA-binding transcription factor activity, DNA binding","GO:0003700, GO:0003677",15.5.17,.RNA biosynthesis.transcriptional regulation.transcription factor (NAC),transcription factor (NAC) (original description: pep chromosome:TAIR10:1:3631:5899:1 gene:AT1G01010 transcript:AT1G01010.1 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:NAC001 description:NAC domain-containing protein 1 [Source:UniProtKB/Swiss-Prot;Acc:Q0WV96]),,,,,, AT1G01020,gene,AT1G01020.6,ARV1,,protein_coding,ARV1 family protein;(source:Araport11),,,molecular_function,GO:0003674,35.1,not assigned.annotated,(original description: pep chromosome:TAIR10:1:6788:8737:-1 gene:AT1G01020 transcript:AT1G01020.6 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:ARV1 description:ARV1 family protein [Source:UniProtKB/TrEMBL;Acc:Q5MK24]) & no description available(sp|q5mk24|arv1_arath : 99.4),,,,,, AT1G01030,gene,AT1G01030.2,NGA3,NGATHA3,protein_coding,AP2/B3-like transcriptional factor family protein;(source:Araport11),,,"DNA-binding transcription factor activity, DNA binding","GO:0003700, GO:0003677",15.5.5.3,.RNA biosynthesis.transcriptional regulation.B3 transcription factor superfamily.transcription factor (RAV/NGATHA),transcription factor (RAV/NGATHA) (original description: pep chromosome:TAIR10:1:11649:13714:-1 gene:AT1G01030 transcript:AT1G01030.2 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:NGA3 description:B3 domain-containing transcription factor NGA3 [Source:UniProtKB/Swiss-Prot;Acc:Q9MAN1]),,,,,, diff --git a/spec/test/djornl/test_data/pheno_nodes.csv b/spec/test/djornl/test_data/pheno_nodes.csv index 83fbf4be..9add7b7d 100644 --- a/spec/test/djornl/test_data/pheno_nodes.csv +++ b/spec/test/djornl/test_data/pheno_nodes.csv @@ -1,4 +1,4 @@ -node_id,node_type,pheno_AraGWAS_ID,pheno_description,pheno_pto_name,pheno_pto_description,pheno_ref,User_Notes +node_id,node_type,pheno_AraGWAS_ID,pheno_description,pheno_pto_name,pheno_pto_description,pheno_reference,User_Notes As2,pheno,10.21958/phenotype:103,,bacterial disease resistance,The resistance exhibited by a plant or a group of plants (population) in response to the disease caused by a bacterial pathogen infection as compared to the susceptible and/or the reference plants of the same species. [GR:pj],"Atwell et. al, Nature 2010", As75,pheno,10.21958/phenotype:67,"Arsenic concentrations in leaves, grown in soil. Elemental analysis was performed with an ICP-MS (PerkinElmer). Sample normalized to calculated weights as described in Baxter et al., 2008",arsenic concentration,A mineral and ion content related trait (TO:0000465) which is the concentration of arsenic (CHEBI:22632) in some plant structure (PO:0009011). [GR:Karthik],"Atwell et. al, Nature 2010", Na23,pheno,10.21958/phenotype:5,"Sodium concentrations in leaves, grown in soil. Elemental analysis was performed with an ICP-MS (PerkinElmer). Sample normalized to calculated weights as described in Baxter et al., 2008",sodium concentration,The total sodium ion concentration measured in a given volume of a plant or a plant part or plant extract. [GR:pj],"Atwell et. al, Nature 2010", diff --git a/spec/views/djornl/djornl_node_view.json b/spec/views/djornl/djornl_node_view.json index 2287f615..8dc30052 100644 --- a/spec/views/djornl/djornl_node_view.json +++ b/spec/views/djornl/djornl_node_view.json @@ -61,7 +61,7 @@ "text_en" ] }, - "pheno_ref": {}, + "pheno_reference": {}, "user_notes": { "analyzers": [ "text_en" From 44e368f80e955b9bd657db9df43c6f47b92faa5b Mon Sep 17 00:00:00 2001 From: ialarmedalien Date: Tue, 6 Oct 2020 08:32:20 -0700 Subject: [PATCH 612/732] Adding in header validation to the DJORNL parser --- importers/djornl/parser.py | 101 ++++++++++++++---- importers/test/test_djornl_parser.py | 46 ++++++-- .../djornl/duplicate_data/hithruput-edges.csv | 4 +- .../missing_required_headers/I2_named.tsv | 8 ++ .../missing_required_headers/I4_named.tsv | 5 + .../missing_required_headers/I6_named.tsv | 8 ++ .../djornl/missing_required_headers/edges.tsv | 9 ++ .../missing_required_headers/extra_node.tsv | 3 + .../hithruput-edges.csv | 3 + .../missing_required_headers/manifest.yaml | 35 ++++++ .../djornl/missing_required_headers/nodes.csv | 11 ++ .../missing_required_headers/pheno_nodes.csv | 5 + 12 files changed, 208 insertions(+), 30 deletions(-) create mode 100644 spec/test/djornl/missing_required_headers/I2_named.tsv create mode 100644 spec/test/djornl/missing_required_headers/I4_named.tsv create mode 100644 spec/test/djornl/missing_required_headers/I6_named.tsv create mode 100644 spec/test/djornl/missing_required_headers/edges.tsv create mode 100644 spec/test/djornl/missing_required_headers/extra_node.tsv create mode 100644 spec/test/djornl/missing_required_headers/hithruput-edges.csv create mode 100644 spec/test/djornl/missing_required_headers/manifest.yaml create mode 100644 spec/test/djornl/missing_required_headers/nodes.csv create mode 100644 spec/test/djornl/missing_required_headers/pheno_nodes.csv diff --git a/importers/djornl/parser.py b/importers/djornl/parser.py index 29404b34..e93e30ea 100644 --- a/importers/djornl/parser.py +++ b/importers/djornl/parser.py @@ -1,8 +1,19 @@ """ -Loads the Dan Jacobson/ORNL group's gene and phenotype network data into -arangodb. +Loads the Dan Jacobson/ORNL group's gene and phenotype network data into arangodb. Running this requires a set of source files provided by the ORNL group. + +The parser sets up its configuration, including the files it will parse, from the RES_ROOT_DATA_PATH +environment variable once per instantiation. To parse a set of files from a different directory, +create a new parser with RES_ROOT_DATA_PATH set appropriately. + +Sample usage: + +from the command line: + +# load files from /path/to/data/dir +RES_ROOT_DATA_PATH=/path/to/data/dir python -m importers.djornl.parser + """ import json import requests @@ -144,9 +155,46 @@ def parser_gen(self, file): msg = f"expected {expected_col_count} cols, found {col_count}" yield(line_no, None, f"{file['path']} line {line_no}: {msg}") + def check_headers(self, headers, validator=None): + """ + Ensure that the file headers contain required columns for the data type. Checks the schema + in the validator to ensure that all required fields are present in the headers. + + :param headers: (list) list containing headers + + :param validator: (obj) validator object, with the appropriate schema loaded + + :return missing_headers: (list) list of required headers that are missing from the input. + If the list of headers supplied is valid--i.e. it + contains all the fields marked as required in the validator + schema--or no validator has been supplied, the method + returns an empty list + """ + + if validator is None: + return [] + + # check that each required header in the schema is present in headers + required_props = validator.schema['required'] + return [i for i in required_props if i not in headers] + def remap_object(self, raw_data, remap_functions): - """ Given a dict, raw_data, create a new dict, remapped_data, using the functions in the - dictionary `remap_functions`. """ + """ + Given a dict, raw_data, create a new dict, remapped_data, using the functions in the + dictionary `remap_functions`. + + :param raw_data: (dict) input data for remapping + + :param remap_fn: (dict) mapping of output param names to functions + + Each function should take the raw_data object as an + argument and return the value for the output parameter. + For parameters that can be copied over to the output + object without modification, set the value to `None` + instead of a function. + + :return remapped_data: (dict) the remapped data! + """ remapped_data = {} for (key, function) in remap_functions.items(): # these keys get copied over unchanged to the new object if they exist in the input obj @@ -189,6 +237,12 @@ def process_file(self, file, remap_fn, store_fn, err_list, validator=None): err_list.append(f"{file['path']}: no header line found") return + missing_headers = self.check_headers(cols, validator) + if missing_headers: + err_list.append( + f"{file['path']}: missing required headers: " + ", ".join(sorted(missing_headers)) + ) + return headers = cols n_stored = 0 for (line_no, cols, err_str) in file_parser: @@ -210,8 +264,15 @@ def process_file(self, file, remap_fn, store_fn, err_list, validator=None): err_list.append(err_msg) continue - # transform it using the remap_functions - datum = self.remap_object(row_object, remap_fn) + try: + # transform it using the remap_functions + datum = self.remap_object(row_object, remap_fn) + except Exception as err: + err_type = type(err) + err_list.append( + f"{file['path']} line {line_no}: error remapping data: {err_type} {err}" + ) + continue # and store it storage_error = store_fn(datum) @@ -239,6 +300,8 @@ def load_edges(self): node_name = self.config('node_name') # these functions remap the values in the columns of the input file to # appropriate values to go into Arango + # note that the functions that assume the presence of a certain key in the input + # can do so because that key is in a 'required' property in the CSV spec file remap_functions = { # create a unique key for each record '_key': lambda row: '__'.join([row[_] for _ in ['node1', 'node2', 'edge_type', 'score']]), @@ -254,7 +317,7 @@ def load_edges(self): def store_edges(datum): # there should only be one value for each node<->node edge of a given type, # so use these values as an index key - edge_key = "__".join([datum['node1'], datum['node2'], datum['edge_type']]) + edge_key = "__".join([*sorted([datum['node1'], datum['node2']]), datum['edge_type']]) if edge_key in edge_ix: # duplicate lines can be ignored @@ -265,7 +328,7 @@ def store_edges(datum): # keep track of the nodes mentioned in this edge set for node_n in ["1", "2"]: - node_ix[datum[f"node{node_n}"]] = 1 + node_ix[datum[f"node{node_n}"]] = {'_key': datum[f"node{node_n}"]} del datum[f"node{node_n}"] edge_ix[edge_key] = datum @@ -284,7 +347,7 @@ def store_edges(datum): raise RuntimeError('\n'.join(err_list)) return { - 'nodes': [{'_key': n} for n in node_ix.keys()], + 'nodes': node_ix.values(), 'edges': edge_ix.values(), } @@ -366,19 +429,21 @@ def load_clusters(self): # these functions remap the values in the columns of the input file to # appropriate values to go into Arango + # the 'cluster_id' remap function is assigned below on a per-file basis remap_functions = { 'node_ids': lambda row: [n.strip() for n in row['node_ids'].split(',')] } - # store clusters in a dictionary with key node_id and value list of cluster IDs to which - # the node is assigned + # store cluster IDs in a list under the key 'clusters' def store_clusters(datum): cluster_id = datum['cluster_id'] for node_id in datum['node_ids']: if node_id not in node_ix: - node_ix[node_id] = [cluster_id] - elif cluster_id not in node_ix[node_id]: - node_ix[node_id].append(cluster_id) + node_ix[node_id] = {'_key': node_id, 'clusters': [cluster_id]} + elif 'clusters' not in node_ix[node_id]: + node_ix[node_id]['clusters'] = [cluster_id] + elif cluster_id not in node_ix[node_id]['clusters']: + node_ix[node_id]['clusters'].append(cluster_id) return None for file in self.config('cluster_files'): @@ -396,13 +461,7 @@ def store_clusters(datum): if len(err_list): raise RuntimeError('\n'.join(err_list)) - # gather a list of cluster IDs for each node - nodes = [{ - '_key': key, - 'clusters': cluster_data - } for (key, cluster_data) in node_ix.items()] - - return {'nodes': nodes} + return {'nodes': list(node_ix.values())} def save_dataset(self, dataset): diff --git a/importers/test/test_djornl_parser.py b/importers/test/test_djornl_parser.py index 4f95f645..4e0c68ee 100644 --- a/importers/test/test_djornl_parser.py +++ b/importers/test/test_djornl_parser.py @@ -72,6 +72,15 @@ def test_load_invalid_file(self): with self.assertRaisesRegex(RuntimeError, err_str): self.init_parser_with_path(RES_ROOT_DATA_PATH) + def test_load_missing_files(self): + """ test loading when files cannot be found """ + + RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, 'djornl', 'missing_files') + # not found + err_str = os.path.join(RES_ROOT_DATA_PATH, "edges.tsv") + ': file does not exist' + with self.assertRaisesRegex(RuntimeError, err_str): + self.init_parser_with_path(RES_ROOT_DATA_PATH) + def test_load_empty_files(self): """ test loading files containing no data """ @@ -98,14 +107,37 @@ def test_load_empty_files(self): with self.assertRaisesRegex(RuntimeError, err_str): parser.load_clusters() - def test_load_missing_files(self): - """ test loading when files cannot be found """ + def test_load_missing_headers(self): + """ test loading when files lack required headers """ - RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, 'djornl', 'missing_files') - # not found - err_str = os.path.join(RES_ROOT_DATA_PATH, "edges.tsv") + ': file does not exist' - with self.assertRaisesRegex(RuntimeError, err_str): - self.init_parser_with_path(RES_ROOT_DATA_PATH) + RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, 'djornl', 'missing_required_headers') + parser = self.init_parser_with_path(RES_ROOT_DATA_PATH) + + def create_err(args): + (file_name, missing_list) = args + return f"{file_name}: missing required headers: " + ", ".join(sorted(missing_list)) + + errs = { + 'clusters': [ + # tuple containing file name and list of column headers missing in that file + ("I2_named.tsv", ["cluster_id", "node_ids"]) + ], + 'edges': [ + ("edges.tsv", ["score"]), + ("hithruput-edges.csv", ["edge_type"]) + ], + 'nodes': [ + ("extra_node.tsv", ["node_type"]), + ("pheno_nodes.csv", ["node_id"]), + ], + } + + for data_type in errs.keys(): + with self.subTest(data_type=data_type): + method = f"load_{data_type}" + err_str = "\n".join(map(create_err, errs[data_type])) + with self.assertRaisesRegex(RuntimeError, err_str): + getattr(parser, method)() def test_load_invalid_edges(self): """ test file format errors """ diff --git a/spec/test/djornl/duplicate_data/hithruput-edges.csv b/spec/test/djornl/duplicate_data/hithruput-edges.csv index 07e9c80f..e02aad44 100644 --- a/spec/test/djornl/duplicate_data/hithruput-edges.csv +++ b/spec/test/djornl/duplicate_data/hithruput-edges.csv @@ -4,6 +4,6 @@ AT1G01010,AT1G01030,2.4,AraNetv2_log-likelihood-score,AraNetv2-HT_high-throughpu # potentially erroneous line AT1G01010,AT1G01030,2.7,AraNetv2_log-likelihood-score,AraNetv2-HT_high-throughput-ppi # duplicated line from the other file -AT1G01050,AT1G01060,2.7,AraNetv2_log-likelihood-score,AraNetv2-LC_lit-curated-ppi +AT1G01060,AT1G01050,2.7,AraNetv2_log-likelihood-score,AraNetv2-LC_lit-curated-ppi # potentially erroneous duplication from the other file -AT1G01030,AT1G01050,2.6000001,AraNetv2_log-likelihood-score,AraNetv2-CX_pairwise-gene-coexpression +AT1G01050,AT1G01030,2.6000001,AraNetv2_log-likelihood-score,AraNetv2-CX_pairwise-gene-coexpression diff --git a/spec/test/djornl/missing_required_headers/I2_named.tsv b/spec/test/djornl/missing_required_headers/I2_named.tsv new file mode 100644 index 00000000..3767347f --- /dev/null +++ b/spec/test/djornl/missing_required_headers/I2_named.tsv @@ -0,0 +1,8 @@ +cluster node_list +# data_type: cluster +# cluster_prefix: markov_i2 +# title: Markov clustering, inflation = 2 +Cluster1 AT1G01010,AT1G01030,AT1G01040 +Cluster2 AT1G01050,AT1G01060,AT1G01070 +Cluster3 AT1G01090 +Cluster5 AT1G01020 diff --git a/spec/test/djornl/missing_required_headers/I4_named.tsv b/spec/test/djornl/missing_required_headers/I4_named.tsv new file mode 100644 index 00000000..6e7d91e4 --- /dev/null +++ b/spec/test/djornl/missing_required_headers/I4_named.tsv @@ -0,0 +1,5 @@ +cluster_id node_ids +# cluster_prefix: markov_i4 +# title: Markov clustering, inflation = 4 +# data_type: cluster +Cluster3 AT1G01080 diff --git a/spec/test/djornl/missing_required_headers/I6_named.tsv b/spec/test/djornl/missing_required_headers/I6_named.tsv new file mode 100644 index 00000000..e7688f17 --- /dev/null +++ b/spec/test/djornl/missing_required_headers/I6_named.tsv @@ -0,0 +1,8 @@ +cluster_id node_ids +# data_type: cluster +# cluster_prefix: markov_i6 +# title: Markov clustering, inflation = 6 +Cluster1 AT1G01040,AT1G01090 +Cluster2 AT1G01070 +Cluster3 AT1G01010,AT1G01020,AT1G01030 +# Cluster4 diff --git a/spec/test/djornl/missing_required_headers/edges.tsv b/spec/test/djornl/missing_required_headers/edges.tsv new file mode 100644 index 00000000..1d37c927 --- /dev/null +++ b/spec/test/djornl/missing_required_headers/edges.tsv @@ -0,0 +1,9 @@ +node1 node2 edge edge_descrip edge_type +As2 AT1G01020 8.4 AraGWAS-Association_score AraGWAS-Phenotype_Associations +As2 AT1G01040 5.4 AraGWAS-Association_score AraGWAS-Phenotype_Associations +As75 AT1G01020 39.9 AraGWAS-Association_score AraGWAS-Phenotype_Associations +AT1G01010 AT1G01040 2.5 AraNetv2_log-likelihood-score AraNetv2-DC_domain-co-occurrence +AT1G01010 AT1G01040 170.5 AraNetv2_log-likelihood-score AraNetv2-LC_lit-curated-ppi +AT1G01030 AT1G01050 2.6 AraNetv2_log-likelihood-score AraNetv2-CX_pairwise-gene-coexpression +AT1G01050 AT1G01060 2.7 AraNetv2_log-likelihood-score AraNetv2-LC_lit-curated-ppi +AT1G01080 AT1G01090 2.8 AraNetv2_log-likelihood-score AraNetv2-LC_lit-curated-ppi diff --git a/spec/test/djornl/missing_required_headers/extra_node.tsv b/spec/test/djornl/missing_required_headers/extra_node.tsv new file mode 100644 index 00000000..d09b410f --- /dev/null +++ b/spec/test/djornl/missing_required_headers/extra_node.tsv @@ -0,0 +1,3 @@ +# data_type: node +node_id node_types transcript gene_symbol gene_full_name gene_model_type TAIR_Computational_description TAIR_Curator_summary TAIR_short_description GO_description GO_terms MapMan_bin MapMan_name MapMan_description +AT1G01100 gene AT1G01100.4 protein_coding 60S acidic ribosomal protein family;(source:Araport11) 60S acidic ribosomal protein family structural constituent of ribosome, ribonucleoprotein complex binding, protein kinase activator activity GO:0003735, GO:0043021, GO:0030295 17.1.2.1.46 .Protein biosynthesis.ribosome biogenesis.large ribosomal subunit (LSU).LSU proteome.component RPP1 component RPP1 of LSU proteome component (original description: pep chromosome:TAIR10:1:50090:51187:-1 gene:AT1G01100 transcript:AT1G01100.4 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:RPP1A description:60S acidic ribosomal protein P1-1 [Source:UniProtKB/Swiss-Prot;Acc:Q8LCW9]) diff --git a/spec/test/djornl/missing_required_headers/hithruput-edges.csv b/spec/test/djornl/missing_required_headers/hithruput-edges.csv new file mode 100644 index 00000000..e4dbc008 --- /dev/null +++ b/spec/test/djornl/missing_required_headers/hithruput-edges.csv @@ -0,0 +1,3 @@ +node1,node2,score,edge_descrip,layer_descrip +AT1G01010,AT1G01020,2.3,AraNetv2_log-likelihood-score,AraNetv2-HT_high-throughput-ppi +AT1G01010,AT1G01030,2.4,AraNetv2_log-likelihood-score,AraNetv2-HT_high-throughput-ppi diff --git a/spec/test/djornl/missing_required_headers/manifest.yaml b/spec/test/djornl/missing_required_headers/manifest.yaml new file mode 100644 index 00000000..88098f82 --- /dev/null +++ b/spec/test/djornl/missing_required_headers/manifest.yaml @@ -0,0 +1,35 @@ +name: Dan Jacobson Exascale data +release_date: "2020-06-06" +home_url: "https://github.com/kbase/exascale_data" +file_list: + - data_type: edge + path: edges.tsv + date: "2020-12-25" + + - data_type: edge + path: hithruput-edges.csv + date: "2020-12-25" + + - data_type: node + path: nodes.csv + date: "2019-01-01" + + - data_type: cluster + cluster_prefix: markov_i2 + path: I2_named.tsv + + - data_type: cluster + cluster_prefix: markov_i4 + path: I4_named.tsv + + - data_type: cluster + cluster_prefix: markov_i6 + path: I6_named.tsv + + - data_type: node + path: extra_node.tsv + date: "2019-01-01" + + - data_type: node + path: pheno_nodes.csv + date: "2019-01-01" diff --git a/spec/test/djornl/missing_required_headers/nodes.csv b/spec/test/djornl/missing_required_headers/nodes.csv new file mode 100644 index 00000000..678a6657 --- /dev/null +++ b/spec/test/djornl/missing_required_headers/nodes.csv @@ -0,0 +1,11 @@ +# data_type: node +node_id,node_type,transcript,gene_symbol,gene_full_name,gene_model_type,TAIR_Computational_description,TAIR_Curator_summary,TAIR_short_description,GO_description,GO_terms,MapMan_bin,MapMan_name,MapMan_description,pheno_AraGWAS_ID,pheno_description,pheno_pto_name,pheno_pto_description,pheno_reference,User_Notes +AT1G01010,gene,AT1G01010.1,NTL10,NAC domain containing protein 1,protein_coding,NAC domain containing protein 1;(source:Araport11),,NAC domain containing protein 1,"DNA-binding transcription factor activity, DNA binding","GO:0003700, GO:0003677",15.5.17,.RNA biosynthesis.transcriptional regulation.transcription factor (NAC),transcription factor (NAC) (original description: pep chromosome:TAIR10:1:3631:5899:1 gene:AT1G01010 transcript:AT1G01010.1 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:NAC001 description:NAC domain-containing protein 1 [Source:UniProtKB/Swiss-Prot;Acc:Q0WV96]),,,,,, +AT1G01020,gene,AT1G01020.6,ARV1,,protein_coding,ARV1 family protein;(source:Araport11),,,molecular_function,GO:0003674,35.1,not assigned.annotated,(original description: pep chromosome:TAIR10:1:6788:8737:-1 gene:AT1G01020 transcript:AT1G01020.6 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:ARV1 description:ARV1 family protein [Source:UniProtKB/TrEMBL;Acc:Q5MK24]) & no description available(sp|q5mk24|arv1_arath : 99.4),,,,,, +AT1G01030,gene,AT1G01030.2,NGA3,NGATHA3,protein_coding,AP2/B3-like transcriptional factor family protein;(source:Araport11),,,"DNA-binding transcription factor activity, DNA binding","GO:0003700, GO:0003677",15.5.5.3,.RNA biosynthesis.transcriptional regulation.B3 transcription factor superfamily.transcription factor (RAV/NGATHA),transcription factor (RAV/NGATHA) (original description: pep chromosome:TAIR10:1:11649:13714:-1 gene:AT1G01030 transcript:AT1G01030.2 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:NGA3 description:B3 domain-containing transcription factor NGA3 [Source:UniProtKB/Swiss-Prot;Acc:Q9MAN1]),,,,,, +AT1G01040,gene,AT1G01040.2,SUS1,SUSPENSOR 1,protein_coding,dicer-like 1;(source:Araport11),"Encodes a Dicer homolog. Dicer is a RNA helicase involved in microRNA processing. Mutations in this locus can result in embryo lethality. Embryo shape at seed maturity is globular-elongate. Other mutants convert the floral meristems to an indeterminate state, others yet show defects in ovule development. mRNA is expressed in all shoot tissues. DCL1 is able to produce miRNAs and siRNAs. The mRNA is cell-to-cell mobile.",dicer-like 1,"metal ion binding, protein binding, ribonuclease III activity, ATP-dependent helicase activity, ATP binding, RNA binding, helicase activity, double-stranded RNA binding, DNA binding","GO:0046872, GO:0005515, GO:0004525, GO:0008026, GO:0005524, GO:0003723, GO:0004386, GO:0003725, GO:0003677",16.10.2.1.1,.RNA processing.mRNA silencing.miRNA pathway.DCL1-HYL1 miRNA biogenesis complex.endoribonuclease component DCL1,endoribonuclease component DCL1 of DCL1-HYL1 miRNA biogenesis complex (original description: pep chromosome:TAIR10:1:23416:31120:1 gene:AT1G01040 transcript:AT1G01040.2 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:DCL1 description:Dicer-like 1 [Source:UniProtKB/TrEMBL;Acc:F4HQG6]),,,,,, +AT1G01050,gene,AT1G01050.2,PPa1,pyrophosphorylase 1,protein_coding,pyrophosphorylase 1;(source:Araport11),,,inorganic diphosphatase activity,GO:0004427,35.1,not assigned.annotated,(original description: pep chromosome:TAIR10:1:31382:33009:-1 gene:AT1G01050 transcript:AT1G01050.2 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:PPA1 description:Soluble inorganic pyrophosphatase 1 [Source:UniProtKB/Swiss-Prot;Acc:Q93V56]) & Soluble inorganic pyrophosphatase 1 OS=Arabidopsis thaliana (sp|q93v56|ipyr1_arath : 419.0),,,,,, +AT1G01060,gene,AT1G01060.8,LHY1,LATE ELONGATED HYPOCOTYL 1,protein_coding,Homeodomain-like superfamily protein;(source:Araport11),,,"DNA-binding transcription factor activity, DNA binding, transcription regulatory region DNA binding","GO:0003700, GO:0003677, GO:0044212",27.1.1,.Multi-process regulation.circadian clock system.core oscillator protein (LHY|CCA1),circadian clock core oscillator protein (LHY|CCA1) (original description: pep chromosome:TAIR10:1:33967:37230:-1 gene:AT1G01060 transcript:AT1G01060.8 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:LHY description:LHY1 [Source:UniProtKB/TrEMBL;Acc:A0A178W761]),,,,,, +AT1G01070,gene,AT1G01070.2,UMAMIT28,Usually multiple acids move in and out Transporters 28,protein_coding,nodulin MtN21 /EamA-like transporter family protein;(source:Araport11),Encodes a plasma membrane-localized amino acid transporter likely involved in amino acid export in the developing seed.,nodulin MtN21 /EamA-like transporter family protein,L-glutamine transmembrane transporter activity,GO:0015186,24.2.1.5,.Solute transport.carrier-mediated transport.DMT superfamily.solute transporter (UmamiT),solute transporter (UmamiT) (original description: pep chromosome:TAIR10:1:38752:40945:-1 gene:AT1G01070 transcript:AT1G01070.2 gene_biotype:protein_coding transcript_biotype:protein_coding description:WAT1-related protein [Source:UniProtKB/TrEMBL;Acc:A0A178WFU3]),,,,,, +AT1G01080,gene,AT1G01080.3,,,protein_coding,RNA-binding (RRM/RBD/RNP motifs) family protein;(source:Araport11),,,"RNA binding, mRNA binding","GO:0003723, GO:0003729",35.1,not assigned.annotated,"(original description: pep chromosome:TAIR10:1:44970:47059:-1 gene:AT1G01080 transcript:AT1G01080.3 gene_biotype:protein_coding transcript_biotype:protein_coding description:RNA-binding (RRM/RBD/RNP motifs) family protein [Source:UniProtKB/TrEMBL;Acc:F4HQH8]) & 33 kDa ribonucleoprotein, chloroplastic OS=Nicotiana sylvestris (sp|p19684|roc5_nicsy : 109.0)",,,,,, +AT1G01090,gene,AT1G01090.1,PDH-E1 ALPHA,pyruvate dehydrogenase E1 alpha,protein_coding,pyruvate dehydrogenase E1 alpha;(source:Araport11),pyruvate dehydrogenase E1 alpha subunit,pyruvate dehydrogenase E1 alpha,"pyruvate dehydrogenase (acetyl-transferring) activity, protein binding","GO:0004739, GO:0005515",5.1.2.2.1.1,.Lipid metabolism.fatty acid biosynthesis.acetyl-CoA generation.plastidial pyruvate dehydrogenase complex.E1 pyruvate dehydrogenase subcomplex.subunit alpha,subunit alpha of E1 pyruvate dehydrogenase component (original description: pep chromosome:TAIR10:1:47234:49304:-1 gene:AT1G01090 transcript:AT1G01090.1 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:PDH-E1 ALPHA description:Pyruvate dehydrogenase E1 component subunit alpha [Source:UniProtKB/TrEMBL;Acc:A0A178W8A7]),,,,,, diff --git a/spec/test/djornl/missing_required_headers/pheno_nodes.csv b/spec/test/djornl/missing_required_headers/pheno_nodes.csv new file mode 100644 index 00000000..8e516db2 --- /dev/null +++ b/spec/test/djornl/missing_required_headers/pheno_nodes.csv @@ -0,0 +1,5 @@ +id,node_type,pheno_AraGWAS_ID,pheno_description,pheno_pto_name,pheno_pto_description,pheno_reference,User_Notes +As2,pheno,10.21958/phenotype:103,,bacterial disease resistance,The resistance exhibited by a plant or a group of plants (population) in response to the disease caused by a bacterial pathogen infection as compared to the susceptible and/or the reference plants of the same species. [GR:pj],"Atwell et. al, Nature 2010", +As75,pheno,10.21958/phenotype:67,"Arsenic concentrations in leaves, grown in soil. Elemental analysis was performed with an ICP-MS (PerkinElmer). Sample normalized to calculated weights as described in Baxter et al., 2008",arsenic concentration,A mineral and ion content related trait (TO:0000465) which is the concentration of arsenic (CHEBI:22632) in some plant structure (PO:0009011). [GR:Karthik],"Atwell et. al, Nature 2010", +Na23,pheno,10.21958/phenotype:5,"Sodium concentrations in leaves, grown in soil. Elemental analysis was performed with an ICP-MS (PerkinElmer). Sample normalized to calculated weights as described in Baxter et al., 2008",sodium concentration,The total sodium ion concentration measured in a given volume of a plant or a plant part or plant extract. [GR:pj],"Atwell et. al, Nature 2010", +SDV,pheno,10.21958/phenotype:104,"Number of days following stratification to opening of first flower. The experiment was stopped at 200 d, and accessions that had not flowered at that point were assigned a value of 200",days to flowering trait,"A flowering time trait (TO:0002616)which is the number of days required for an individual flower (PO:0009046), a whole plant (PO:0000003) or a plant population to reach flowering stage (PO:0007616) from a predetermined time point (e.g. the date of seed sowing, seedling transplant, or seedling emergence). [GR:pj, TO:cooperl]","Atwell et. al, Nature 2010", From b7100cc53a3b9dc804df8f56bac2842f1a2b25e5 Mon Sep 17 00:00:00 2001 From: John Miller Date: Tue, 6 Oct 2020 13:06:02 -0400 Subject: [PATCH 613/732] Update edge types for networks from Jacobson Lab --- spec/datasets/djornl/edge_type.yaml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/spec/datasets/djornl/edge_type.yaml b/spec/datasets/djornl/edge_type.yaml index 3ac6d62a..ab440612 100644 --- a/spec/datasets/djornl/edge_type.yaml +++ b/spec/datasets/djornl/edge_type.yaml @@ -23,3 +23,32 @@ oneOf: - const: AraNetv2-LC_lit-curated-ppi title: AraNetv2 literature-curated protein-protein interaction description: A layer of protein-protein interaction values from literature-curated small- to medium-scale experimental data; from the Arabidopsis AraNetv2 database. The LLS scores that serve as edge values were calculated to normalize the data for comparison across studies and different types of data layers (Lee et al, 2015). + + - const: BIOGRID-ORGANISM-Arabidopsis-thaliana-Columbia-3-5-188-tab3_PPI + title: BIOGRID ORGANISM Arabidopsis thaliana Columbia 3.5.188 tab3 PPI + description: BioGRID interactions are relationships between two proteins or genes; the term “interaction” includes direct physical binding of two proteins, and co-existence in a stable complex and genetic interaction. see https://wiki.thebiogrid.org/doku.php/experimental_systems + + - const: AtPIN_PPI + title: AtPIN PPI + description: The interactions database includes all interactions present at the Arabidopsis thaliana Protein Interactome Database, the Predicted Interactome for Arabidopsis, Arabidopsis protein-protein interaction data curated from the literature by TAIR curators, BIOGRID and IntAct. https://atpin.bioinfoguy.net/cgi-bin/atpin.pl + + - const: mentha-AT-3702-040319_PPI + title: Mentha AT 3702 040319 PPI + description: Mentha archives evidence collected from different sources and presents these data in a complete and comprehensive way. Its data comes from manually curated protein-protein interaction databases that have adhered to the IMEx consortium and assigns to each interaction a reliability score that takes into account all the supporting evidence. https://mentha.uniroma2.it/about.php + + - const: aranetv2-subnet-AT-LC_PPI + title: AraNetv2 subnet AT-LC PPI + description: Literature curated PPI of A. thaliana. https://www.inetbio.org/aranet/dl.php?f=AT-LC + + - const: Wu2016-s015-Gene-to-Metab_GeneToPhenotype + title: Wu2016 s015 Gene-to-Metab GeneToPhenotype + description: GWAS hits ftom a Gene-to-Metaboiltes GWAS. Phenotypes (metabolites) have a unique ID from the Wu 2016 study and need to be given our own UID for future use. + + - const: AraGWAS-subnet-permsig-geni_GeneToPhenotype + title: AraGWAS subnet permsig geni GeneToPhenotype + description: Phenotypes mapped to SNP position and GeneID if available from AraGWAS database filtered for overFDR threshold. + + - const: ATRM-TF-to-Target-LitCurated-01082020_TranscriptionFactorToGene + title: ATRM TF to Target LitCurated 01082020 TranscriptionFactorToGene + description: Contains literature mined and manually curated TF regulatory interactions for A.thaliana from 1701 TFFs from PlantTFDB 2.0 and 4663 TF-associated interactions. These were manually filtered (e.g. FPs, PPI interactions removed). They then added some from other sources. Downloaded from http://atrm.cbi.pku.edu.cn/download.php + From a3e3847f44aed705781652b59925ece2a33342e4 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 6 Oct 2020 11:37:10 -0700 Subject: [PATCH 614/732] WIP --- CHANGELOG.md | 5 +++++ Dockerfile | 4 ++++ VERSION | 2 +- relation_engine_server/README.md | 2 +- relation_engine_server/api_versions/api_v1.py | 4 +++- relation_engine_server/test/test_api_v1.py | 1 - relation_engine_server/utils/config.py | 7 +++++-- relation_engine_server/utils/pull_spec.py | 2 +- scripts/docker_deploy | 6 ++++++ 9 files changed, 26 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b4e2293b..ad6edad2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.0.9] - 2020-10-05 +## Changed +- Clean up some of the config slightly, and add the `SPEC_REPO_URL` env var instead of hard-coding +- Bundle the spec tarball in the docker image so other programs can use the image for testing + ## [0.0.9] - 2020-10-05 ## Fixed - Fixed the function that concatenates parts of the query for the API diff --git a/Dockerfile b/Dockerfile index 42dc4189..53b34cbc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -26,6 +26,10 @@ RUN apk --update add --virtual build-dependencies build-base python3-dev && \ COPY . /app +# Create tarball of the test spec directory +RUN cd /app/relation_engine_server/test/spec_release && \ + tar czvf spec.tar.gz sample_spec_release + LABEL org.label-schema.build-date=$BUILD_DATE \ org.label-schema.vcs-url="https://github.com/kbase/relation_engine_api" \ org.label-schema.vcs-ref=$VCS_REF \ diff --git a/VERSION b/VERSION index c5d54ec3..7c1886bb 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.0.9 +0.0.10 diff --git a/relation_engine_server/README.md b/relation_engine_server/README.md index e500b29a..8a3369df 100644 --- a/relation_engine_server/README.md +++ b/relation_engine_server/README.md @@ -200,7 +200,7 @@ curl {root_url}/api/v1/update_specs _Query params_ * `init_collections` - optional - boolean - defaults to true - whether to initialize any new collections in arango (also creates indexes and views) -* `spec_url` - optional - string - the specific url of the release to download and use (as a tarball). If left blank, then the latest release from github is used (not including any pre-releases or drafts). +* `release_url` - optional - string - the specific url of the release to download and use (as a tarball). If left blank, then the latest release from github is used (not including any pre-releases or drafts). Every call to update specs will reset the spec data (do a clean download and overwrite). diff --git a/relation_engine_server/api_versions/api_v1.py b/relation_engine_server/api_versions/api_v1.py index 5dd4e699..dddeb42c 100644 --- a/relation_engine_server/api_versions/api_v1.py +++ b/relation_engine_server/api_versions/api_v1.py @@ -170,7 +170,9 @@ def show_config(): 'kbase_endpoint': conf['kbase_endpoint'], 'db_url': conf['db_url'], 'db_name': conf['db_name'], - 'spec_url': conf['spec_url'] + 'spec_repo_url': conf['spec_repo_url'], + 'spec_release_url': conf['spec_release_url'], + 'spec_release_path': conf['spec_release_path'], }) diff --git a/relation_engine_server/test/test_api_v1.py b/relation_engine_server/test/test_api_v1.py index b309fe23..b754211f 100644 --- a/relation_engine_server/test/test_api_v1.py +++ b/relation_engine_server/test/test_api_v1.py @@ -113,7 +113,6 @@ def test_config(self): self.assertTrue(len(resp_json['kbase_endpoint'])) self.assertTrue(len(resp_json['db_url'])) self.assertTrue(len(resp_json['db_name'])) - self.assertTrue(len(resp_json['spec_url'])) def test_update_specs(self): """Test the endpoint that triggers an update on the specs.""" diff --git a/relation_engine_server/utils/config.py b/relation_engine_server/utils/config.py index 7756b2ef..08d85443 100644 --- a/relation_engine_server/utils/config.py +++ b/relation_engine_server/utils/config.py @@ -11,8 +11,11 @@ def get_config(): """Load environment configuration data.""" spec_path = os.environ.get('SPEC_PATH', '/spec') # /spec - spec_url = 'https://api.github.com/repos/kbase/relation_engine_spec' + # The root url of a remote git repo that holds the specifications (ie. this repo) + spec_repo_url = os.environ.get('SPEC_REPO_URL') + # The specific URL of the spec tarball spec_release_url = os.environ.get('SPEC_RELEASE_URL') + # The specific local path of the spec tarball spec_release_path = os.environ.get('SPEC_RELEASE_PATH') kbase_endpoint = os.environ.get('KBASE_ENDPOINT', 'https://ci.kbase.us/services') @@ -38,7 +41,7 @@ def get_config(): 'db_pass': db_pass, 'db_readonly_user': db_readonly_user, 'db_readonly_pass': db_readonly_pass, - 'spec_url': spec_url, + 'spec_repo_url': spec_repo_url, 'spec_release_url': spec_release_url, 'spec_release_path': spec_release_path, 'spec_paths': { diff --git a/relation_engine_server/utils/pull_spec.py b/relation_engine_server/utils/pull_spec.py index 9b874a35..baf3cd43 100644 --- a/relation_engine_server/utils/pull_spec.py +++ b/relation_engine_server/utils/pull_spec.py @@ -72,7 +72,7 @@ def do_init_views(): def _fetch_github_release_url(): """Find the latest relation engine spec release using the github api.""" # Download information about the latest release - release_resp = requests.get(_CONF['spec_url'] + '/releases/latest') + release_resp = requests.get(_CONF['spec_repo_url'] + '/releases/latest') release_info = release_resp.json() if release_resp.status_code != 200: # This may be a github API rate usage limit, or some other error diff --git a/scripts/docker_deploy b/scripts/docker_deploy index 7c4c0a10..80d5c8e7 100755 --- a/scripts/docker_deploy +++ b/scripts/docker_deploy @@ -9,6 +9,7 @@ set -o xtrace ver=$(cat VERSION) export IMAGE_NAME="kbase/relation_engine_api:$ver" export BRANCH=`git symbolic-ref --short HEAD` +export BRANCH_IMAGE_NAME="kbase/relation_engine_api:$BRANCH" export DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` export COMMIT=`git rev-parse --short HEAD` docker build --build-arg BUILD_DATE=$DATE \ @@ -16,3 +17,8 @@ docker build --build-arg BUILD_DATE=$DATE \ --build-arg BRANCH=$BRANCH \ -t ${IMAGE_NAME} . docker push $IMAGE_NAME +docker build --build-arg BUILD_DATE=$DATE \ + --build-arg VCS_REF=$COMMIT \ + --build-arg BRANCH=$BRANCH \ + -t ${BRANCH_IMAGE_NAME} . +docker push $BRANCH_IMAGE_NAME From 541ad51b8b339e6310a15186f84b6ee217d51a39 Mon Sep 17 00:00:00 2001 From: ialarmedalien Date: Wed, 7 Oct 2020 08:41:56 -0700 Subject: [PATCH 615/732] Alter DJORNL parser to have the node and edge indexes as attributes. Redo the dataset summary, taking this into account. Return a list of errors from each type of file parse, and throw all errors at the end. --- importers/djornl/parser.py | 281 +++++++++++------- importers/test/test_djornl_parser.py | 106 +++++-- spec/test/djornl/invalid_types/manifest.yaml | 3 + .../test/djornl/invalid_types/pheno_nodes.csv | 4 + .../djornl/missing_required_headers/nodes.csv | 2 +- .../missing_required_headers/pheno_nodes.csv | 2 +- 6 files changed, 261 insertions(+), 137 deletions(-) create mode 100644 spec/test/djornl/invalid_types/pheno_nodes.csv diff --git a/importers/djornl/parser.py b/importers/djornl/parser.py index 24c2596d..6350dccd 100644 --- a/importers/djornl/parser.py +++ b/importers/djornl/parser.py @@ -27,6 +27,16 @@ class DJORNL_Parser(object): + def __init__(self): + + # dict of nodes, indexed by node ID (node1 and node2 from the file) + self.node_ix = {} + # dict of edges, indexed by node1__node2__edge_type + self.edge_ix = {} + + # the order in which to parse the different data files + self.parse_order = ['edges', 'nodes', 'clusters'] + def config(self, value): if not hasattr(self, '_config'): self._configure() @@ -176,6 +186,9 @@ def check_headers(self, headers, validator=None): # check that each required header in the schema is present in headers required_props = validator.schema['required'] + + # TODO: check if additional properties are allowed + return [i for i in required_props if i not in headers] def remap_object(self, raw_data, remap_functions): @@ -229,6 +242,7 @@ def process_file(self, file, remap_fn, store_fn, err_list, validator=None): :param validator: (Validator) jsonschema validator object """ + print("Parsing " + file['data_type'] + " file " + file['file_path']) file_parser = self.parser_gen(file) try: (line_no, cols, err_str) = next(file_parser) @@ -284,13 +298,42 @@ def process_file(self, file, remap_fn, store_fn, err_list, validator=None): if not n_stored: err_list.append(f"{file['path']}: no valid data found") + def store_parsed_edge_data(self, datum): + """ + store node and edge data in the node (node_ix) and edge (edge_ix) indexes respectively + + Nodes are indexed by the '_key' attribute. Parsed edge data only contains node '_key' values. + + Edges are indexed by the unique combination of the two node IDs and the edge type. It is + assumed that if there is more than one score for a given combination of node IDs and edge + type, the datum is erroneous. + """ + + # there should only be one value for each node<->node edge of a given type, + # so use these values as an index key + # sort the nodes to ensure no dupes slip through + edge_key = "__".join([*sorted([datum['node1'], datum['node2']]), datum['edge_type']]) + + if edge_key in self.edge_ix: + # duplicate lines can be ignored + if datum['score'] == self.edge_ix[edge_key]['score']: + return None + # report non-matching data + return f"duplicate data for edge {edge_key}" + + # keep track of the nodes mentioned in this edge set + for node_n in ["1", "2"]: + _key = datum[f"node{node_n}"] + if _key not in self.node_ix: + self.node_ix[_key] = {"_key": _key} + del datum[f"node{node_n}"] + + self.edge_ix[edge_key] = datum + return None + def load_edges(self): """Load edge data from the set of edge files""" - # dict of nodes, indexed by node ID (node1 and node2 from the file) - node_ix = {} - # dict of edges, indexed by node1__node2__edge_type - edge_ix = {} # error accumulator err_list = [] @@ -313,42 +356,19 @@ def load_edges(self): 'edge_type': None, } - # store edge data, checking for potential duplicates - def store_edges(datum): - # there should only be one value for each node<->node edge of a given type, - # so use these values as an index key - edge_key = "__".join([*sorted([datum['node1'], datum['node2']]), datum['edge_type']]) - - if edge_key in edge_ix: - # duplicate lines can be ignored - if datum['score'] == edge_ix[edge_key]['score']: - return None - # report non-matching data - return f"duplicate data for edge {edge_key}" - - # keep track of the nodes mentioned in this edge set - for node_n in ["1", "2"]: - node_ix[datum[f"node{node_n}"]] = {'_key': datum[f"node{node_n}"]} - del datum[f"node{node_n}"] - - edge_ix[edge_key] = datum - return None - for file in self.config('edge_files'): self.process_file( file=file, remap_fn=remap_functions, - store_fn=store_edges, + store_fn=self.store_parsed_edge_data, err_list=err_list, validator=validator, ) - if len(err_list): - raise RuntimeError('\n'.join(err_list)) - return { - 'nodes': node_ix.values(), - 'edges': edge_ix.values(), + 'nodes': self.node_ix.values(), + 'edges': self.edge_ix.values(), + 'err_list': err_list, } def _try_node_merge(self, existing_node, new_node, path=[]): @@ -423,10 +443,30 @@ def _try_node_merge(self, existing_node, new_node, path=[]): merge = None return (merge, err_list) + def store_parsed_node_data(self, datum): + """ + store node data in the node index, node_ix, indexed by the node _key + + If a node is already present, new data is checked for conflicts with existing data + """ + # check whether we have this node already + if datum['_key'] in self.node_ix: + # identical data: ignore it + if datum == self.node_ix[datum['_key']]: + return None + + # try merging the data + (merged, err_list) = self._try_node_merge(self.node_ix[datum['_key']], datum) + if err_list: + return "duplicate data for node " + datum['_key'] + datum = merged + + self.node_ix[datum['_key']] = datum + return None + def load_nodes(self): """Load node metadata""" - node_ix = {} err_list = [] schema_file = os.path.join(self._get_dataset_schema_dir(), 'csv_node.yaml') @@ -463,41 +503,45 @@ def go_terms(row): 'go_terms': go_terms, } - # store nodes in a dict indexed by _key - def store_nodes(datum): - # check whether we have this node already - if datum['_key'] in node_ix: - # identical data: ignore it - if datum == node_ix[datum['_key']]: - return None - - # try merging the data - (merged, err_list) = self._try_node_merge(node_ix[datum['_key']], datum) - if err_list: - return "duplicate data for node " + datum['_key'] - datum = merged - - node_ix[datum['_key']] = datum - return None - for file in self.config('node_files'): self.process_file( file=file, remap_fn=remap_functions, - store_fn=store_nodes, + store_fn=self.store_parsed_node_data, err_list=err_list, validator=validator, ) - if len(err_list): - raise RuntimeError('\n'.join(err_list)) - return {'nodes': node_ix.values()} + return { + 'nodes': self.node_ix.values(), + 'err_list': err_list, + } + + def store_parsed_cluster_data(self, datum): + """ + store remapped cluster data + + The input is in the form + + {'cluster_id': cluster_id, 'node_ids': [node_id_1, node_id_2, node_id_3, ...]} + + Cluster IDs are stored in the 'clusters' node attribute as a list, with new IDs added to + (rather than replacing) existing IDs + """ + cluster_id = datum['cluster_id'] + # gather a list of cluster IDs for each node + for node_id in datum['node_ids']: + if node_id not in self.node_ix: + self.node_ix[node_id] = {'_key': node_id, 'clusters': [cluster_id]} + elif 'clusters' not in self.node_ix[node_id]: + self.node_ix[node_id]['clusters'] = [cluster_id] + elif cluster_id not in self.node_ix[node_id]['clusters']: + self.node_ix[node_id]['clusters'].append(cluster_id) + return None def load_clusters(self): """Annotate genes with cluster ID fields.""" - # index of nodes - node_ix = {} err_list = [] schema_file = os.path.join(self._get_dataset_schema_dir(), 'csv_cluster.yaml') @@ -510,18 +554,6 @@ def load_clusters(self): 'node_ids': lambda row: [n.strip() for n in row['node_ids'].split(',')] } - # store cluster IDs in a list under the key 'clusters' - def store_clusters(datum): - cluster_id = datum['cluster_id'] - for node_id in datum['node_ids']: - if node_id not in node_ix: - node_ix[node_id] = {'_key': node_id, 'clusters': [cluster_id]} - elif 'clusters' not in node_ix[node_id]: - node_ix[node_id]['clusters'] = [cluster_id] - elif cluster_id not in node_ix[node_id]['clusters']: - node_ix[node_id]['clusters'].append(cluster_id) - return None - for file in self.config('cluster_files'): prefix = file['cluster_prefix'] remap_functions['cluster_id'] = lambda row: prefix + ':' + row['cluster_id'].replace('Cluster', '') @@ -529,17 +561,23 @@ def store_clusters(datum): self.process_file( file=file, remap_fn=remap_functions, - store_fn=store_clusters, + store_fn=self.store_parsed_cluster_data, err_list=err_list, validator=validator, ) - if len(err_list): - raise RuntimeError('\n'.join(err_list)) + return { + 'nodes': list(self.node_ix.values()), + 'err_list': err_list, + } - return {'nodes': list(node_ix.values())} + def save_dataset(self, dataset=None): - def save_dataset(self, dataset): + if dataset is None: + dataset = { + 'nodes': list(self.node_ix.values()), + 'edges': list(self.edge_ix.values()), + } if 'nodes' in dataset and len(dataset['nodes']) > 0: self.save_docs(self.config('node_name'), dataset['nodes']) @@ -563,45 +601,82 @@ def save_docs(self, coll_name, docs, on_dupe='update'): print('=' * 80) return resp - def load_data(self): - self.save_dataset(self.load_edges()) - self.save_dataset(self.load_nodes()) - self.save_dataset(self.load_clusters()) - return True + def load_data(self, dry_run=False): + all_errs = [] + method_ix = { + 'clusters': self.load_clusters, + 'edges': self.load_edges, + 'nodes': self.load_nodes, + } + for data_type in self.parse_order: + output = method_ix[data_type]() + if output['err_list']: + all_errs = all_errs + output['err_list'] - def check_data_delta(self): - edge_data = self.load_edges() - node_data = self.load_nodes() - clusters = self.load_clusters() + if all_errs: + raise RuntimeError("\n".join(all_errs)) - self.check_deltas(edge_data=edge_data, node_data=node_data, cluster_data=clusters) + if dry_run: + # report stats on the data that has been gathered + return self.summarise_dataset() - def check_deltas(self, edge_data={}, node_data={}, cluster_data={}): + # otherwise, save the dataset + self.save_dataset() + return True - edges_nodelist = set([e['_key'] for e in edge_data['nodes']]) - nodes_nodelist = set([e['_key'] for e in node_data['nodes']]) - clusters_nodelist = set([e['_key'] for e in cluster_data['nodes']]) - all_nodes = edges_nodelist.union(nodes_nodelist).union(clusters_nodelist) + def summarise_dataset(self): + """summarise the data that has been loaded""" - # check all nodes in cluster_data have node data - cluster_no_node_set = clusters_nodelist.difference(nodes_nodelist) - if cluster_no_node_set: - print({'clusters with no node metadata': cluster_no_node_set}) + # go through the node index, checking for nodes that only have one attribute ('_key') or + # were loaded from the clusters files, with their only attributes being '_key' and 'clusters' - # check all nodes in the edge_data have node data - edge_no_node_set = edges_nodelist.difference(nodes_nodelist) - if edge_no_node_set: - print({'edges with no node metadata': edge_no_node_set}) + node_type_ix = { + '__NO_TYPE__': 0 + } + node_data = { + 'key_only': [], + 'cluster': [], + 'full': [] + } - # check all nodes are in the edge_data set - node_no_edge_set = nodes_nodelist.difference(edges_nodelist) - if node_no_edge_set: - print({'nodes not in an edge': node_no_edge_set}) + for node in self.node_ix.values(): + if len(node.keys()) == 2 and 'clusters' in node: + node_data['cluster'].append(node) + elif len(node.keys()) == 1: + node_data['key_only'].append(node) + else: + node_data['full'].append(node) + + if 'node_type' in node: + if node['node_type'] in node_type_ix: + node_type_ix[node['node_type']] += 1 + else: + node_type_ix[node['node_type']] = 1 + else: + node_type_ix['__NO_TYPE__'] += 1 + + nodes_in_edge_ix = {} + edge_type_ix = {} + for edge in self.edge_ix.values(): + nodes_in_edge_ix[edge['_from']] = 1 + nodes_in_edge_ix[edge['_to']] = 1 + if edge['edge_type'] in edge_type_ix: + edge_type_ix[edge['edge_type']] += 1 + else: + edge_type_ix[edge['edge_type']] = 1 - # count all edges - print("Dataset contains " + str(len(edge_data['edges'])) + " edges") - # count all nodes - print("Dataset contains " + str(len(all_nodes)) + " nodes") + return { + 'nodes_total': len(self.node_ix.keys()), + 'edges_total': len(self.edge_ix.keys()), + 'nodes_in_edge': len(nodes_in_edge_ix.keys()), + 'node_type_count': node_type_ix, + 'edge_type_count': edge_type_ix, + 'node_data_available': { + 'key_only': len(node_data['key_only']), + 'cluster': len(node_data['cluster']), + 'full': len(node_data['full']) + }, + } if __name__ == '__main__': diff --git a/importers/test/test_djornl_parser.py b/importers/test/test_djornl_parser.py index cee1a60d..83121b42 100644 --- a/importers/test/test_djornl_parser.py +++ b/importers/test/test_djornl_parser.py @@ -40,12 +40,28 @@ def test_errors(self, parser=None, errs={}): self.assertTrue(True) return - for data_type in errs.keys(): - with self.subTest(data_type=data_type): + all_errs = [] + for data_type in parser.parse_order: + if data_type not in errs: + continue + + all_errs = all_errs + errs[data_type] + for data_type in errs.keys(): method = f"load_{data_type}" - err_str = "\n".join(errs[data_type]) - with self.assertRaisesRegex(RuntimeError, err_str): - getattr(parser, method)() + output = getattr(parser, method)() + with self.subTest(data_type=data_type): + self.assertEqual( + output['err_list'], + errs[data_type] + ) + + with self.subTest(data_type="all types"): + # test all errors + with self.assertRaisesRegex(RuntimeError, all_errs[0]) as cm: + parser.load_data() + exception = cm.exception + err_list = exception.split("\n") + self.assertEqual(err_list, all_errs) def test_missing_required_env_var(self): '''test that the parser exits with code 1 if the RES_ROOT_DATA_PATH env var is not set''' @@ -118,31 +134,24 @@ def test_load_missing_headers(self): RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, 'djornl', 'missing_required_headers') parser = self.init_parser_with_path(RES_ROOT_DATA_PATH) - def create_err(args): - (file_name, missing_list) = args + def create_err(file_name, missing_list): return f"{file_name}: missing required headers: " + ", ".join(sorted(missing_list)) errs = { 'clusters': [ # tuple containing file name and list of column headers missing in that file - ("I2_named.tsv", ["cluster_id", "node_ids"]) + create_err("I2_named.tsv", ["cluster_id", "node_ids"]) ], 'edges': [ - ("edges.tsv", ["score"]), - ("hithruput-edges.csv", ["edge_type"]) + create_err("edges.tsv", ["score"]), + create_err("hithruput-edges.csv", ["edge_type"]) ], 'nodes': [ - ("extra_node.tsv", ["node_type"]), - ("pheno_nodes.csv", ["node_id"]), + create_err("extra_node.tsv", ["node_type"]), + create_err("pheno_nodes.csv", ["node_id"]), ], } - - for data_type in errs.keys(): - with self.subTest(data_type=data_type): - method = f"load_{data_type}" - err_str = "\n".join(map(create_err, errs[data_type])) - with self.assertRaisesRegex(RuntimeError, err_str): - getattr(parser, method)() + self.test_errors(parser, errs) def test_load_invalid_types(self): """ test file format errors """ @@ -155,16 +164,21 @@ def test_load_invalid_types(self): # invalid edge type, invalid scores 'edges': [ r"edges.tsv line 3: 'Same-Old-Stuff' is not valid under any of the given schemas", - r"edges.tsv line 7: '2.' does not match .*?", + r"edges.tsv line 7: '2.' does not match '^\\d+(\\.\\d+)?$'", r"edges.tsv line 8: 'raNetv2-DC_' is not valid under any of the given schemas", - r"edges.tsv line 10: 'score!' does not match .*?" + r"edges.tsv line 10: 'score!' does not match '^\\d+(\\.\\d+)?$'" ], - # invalid node type 'nodes': [ - "nodes.csv line 5: 'Monkey' is not valid under any of the given schemas", + # invalid node type + r"nodes.csv line 5: 'Monkey' is not valid under any of the given schemas", + # invalid extra header property + r"pheno_nodes.csv line 3: Additional properties are not allowed ('pheno_ref' was unexpected)", + r"pheno_nodes.csv line 4: Additional properties are not allowed ('pheno_ref' was unexpected)", + r"pheno_nodes.csv: no valid data found" ], 'clusters': [ - "markov2_named.tsv line 7: 'HoneyNutCluster3' does not match" + r"markov2_named.tsv line 7: 'HoneyNutCluster3' does not match '^Cluster\\d+$'", + r'markov2_named.tsv line 8: expected 2 cols, found 1', ] } self.test_errors(parser, errs) @@ -198,6 +212,7 @@ def test_load_valid_edge_data(self): for data_structure in [edge_data, expected]: for k in data_structure.keys(): data_structure[k] = sorted(data_structure[k], key=lambda n: n['_key']) + expected['err_list'] = [] self.assertEqual(edge_data, expected) @@ -214,6 +229,7 @@ def test_load_valid_node_data(self): for k in data_structure.keys(): data_structure[k] = sorted(data_structure[k], key=lambda n: n['_key']) data_structure[k] = [n['_key'] for n in data_structure[k]] + expected['err_list'] = [] self.assertEqual(node_data, expected) @@ -224,10 +240,10 @@ def test_load_valid_cluster_data(self): parser = self.init_parser_with_path(RES_ROOT_DATA_PATH) cluster_data = parser.load_clusters() - self.assertEqual( - cluster_data, - self.json_data["load_clusters"] - ) + expected = self.json_data["load_clusters"] + expected['err_list'] = [] + + self.assertEqual(cluster_data, expected) def test_duplicate_data(self): """ test files with duplicate data that should throw an error """ @@ -237,8 +253,10 @@ def test_duplicate_data(self): errs = { 'edges': [ - "hithruput-edges.csv line 5: duplicate data for edge AT1G01010__AT1G01030__AraNetv2-HT_.*?", - "hithruput-edges.csv line 9: duplicate data for edge AT1G01030__AT1G01050__AraNetv2-CX_.*?" + "hithruput-edges.csv line 5: duplicate data for edge " + + "AT1G01010__AT1G01030__AraNetv2-HT_high-throughput-ppi", + "hithruput-edges.csv line 9: duplicate data for edge " + + "AT1G01030__AT1G01050__AraNetv2-CX_pairwise-gene-coexpression" ], 'nodes': [ "extra_node.tsv line 5: duplicate data for node AT1G01080" @@ -254,9 +272,33 @@ def test_duplicate_cluster_data(self): parser = self.init_parser_with_path(RES_ROOT_DATA_PATH) cluster_data = parser.load_clusters() + expected = self.json_data["load_clusters"] + expected['err_list'] = [] + + self.assertEqual(cluster_data, expected) + + def test_dry_run(self): + + RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, 'djornl', 'test_data') + parser = self.init_parser_with_path(RES_ROOT_DATA_PATH) + + output = parser.load_data(dry_run=True) self.assertEqual( - cluster_data, - self.json_data["load_clusters"] + { + 'edge_type_count': { + 'AraGWAS-Phenotype_Associations': 3, + 'AraNetv2-CX_pairwise-gene-coexpression': 1, + 'AraNetv2-DC_domain-co-occurrence': 1, + 'AraNetv2-HT_high-throughput-ppi': 2, + 'AraNetv2-LC_lit-curated-ppi': 3 + }, + 'edges_total': 10, + 'node_data_available': {'cluster': 0, 'full': 14, 'key_only': 0}, + 'node_type_count': {'__NO_TYPE__': 0, 'gene': 10, 'pheno': 4}, + 'nodes_in_edge': 10, + 'nodes_total': 14 + }, + output ) def test_try_node_merge(self): diff --git a/spec/test/djornl/invalid_types/manifest.yaml b/spec/test/djornl/invalid_types/manifest.yaml index e37ca783..8e50d86b 100644 --- a/spec/test/djornl/invalid_types/manifest.yaml +++ b/spec/test/djornl/invalid_types/manifest.yaml @@ -10,3 +10,6 @@ file_list: - data_type: cluster path: markov2_named.tsv cluster_prefix: markov_i2 + + - data_type: node + path: pheno_nodes.csv diff --git a/spec/test/djornl/invalid_types/pheno_nodes.csv b/spec/test/djornl/invalid_types/pheno_nodes.csv new file mode 100644 index 00000000..d89450e5 --- /dev/null +++ b/spec/test/djornl/invalid_types/pheno_nodes.csv @@ -0,0 +1,4 @@ +# unexpected header +node_id,node_type,pheno_AraGWAS_ID,pheno_description,pheno_pto_name,pheno_pto_description,pheno_ref,User_Notes +As2,pheno,10.21958/phenotype:103,,bacterial disease resistance,The resistance exhibited by a plant or a group of plants (population) in response to the disease caused by a bacterial pathogen infection as compared to the susceptible and/or the reference plants of the same species. [GR:pj],"Atwell et. al, Nature 2010", +As75,pheno,10.21958/phenotype:67,"Arsenic concentrations in leaves, grown in soil. Elemental analysis was performed with an ICP-MS (PerkinElmer). Sample normalized to calculated weights as described in Baxter et al., 2008",arsenic concentration,A mineral and ion content related trait (TO:0000465) which is the concentration of arsenic (CHEBI:22632) in some plant structure (PO:0009011). [GR:Karthik],"Atwell et. al, Nature 2010", diff --git a/spec/test/djornl/missing_required_headers/nodes.csv b/spec/test/djornl/missing_required_headers/nodes.csv index 92f60761..678a6657 100644 --- a/spec/test/djornl/missing_required_headers/nodes.csv +++ b/spec/test/djornl/missing_required_headers/nodes.csv @@ -1,5 +1,5 @@ # data_type: node -node_id,node_type,transcript,gene_symbol,gene_full_name,gene_model_type,TAIR_Computational_description,TAIR_Curator_summary,TAIR_short_description,GO_description,GO_terms,MapMan_bin,MapMan_name,MapMan_description,pheno_AraGWAS_ID,pheno_description,pheno_pto_name,pheno_pto_description,pheno_ref,User_Notes +node_id,node_type,transcript,gene_symbol,gene_full_name,gene_model_type,TAIR_Computational_description,TAIR_Curator_summary,TAIR_short_description,GO_description,GO_terms,MapMan_bin,MapMan_name,MapMan_description,pheno_AraGWAS_ID,pheno_description,pheno_pto_name,pheno_pto_description,pheno_reference,User_Notes AT1G01010,gene,AT1G01010.1,NTL10,NAC domain containing protein 1,protein_coding,NAC domain containing protein 1;(source:Araport11),,NAC domain containing protein 1,"DNA-binding transcription factor activity, DNA binding","GO:0003700, GO:0003677",15.5.17,.RNA biosynthesis.transcriptional regulation.transcription factor (NAC),transcription factor (NAC) (original description: pep chromosome:TAIR10:1:3631:5899:1 gene:AT1G01010 transcript:AT1G01010.1 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:NAC001 description:NAC domain-containing protein 1 [Source:UniProtKB/Swiss-Prot;Acc:Q0WV96]),,,,,, AT1G01020,gene,AT1G01020.6,ARV1,,protein_coding,ARV1 family protein;(source:Araport11),,,molecular_function,GO:0003674,35.1,not assigned.annotated,(original description: pep chromosome:TAIR10:1:6788:8737:-1 gene:AT1G01020 transcript:AT1G01020.6 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:ARV1 description:ARV1 family protein [Source:UniProtKB/TrEMBL;Acc:Q5MK24]) & no description available(sp|q5mk24|arv1_arath : 99.4),,,,,, AT1G01030,gene,AT1G01030.2,NGA3,NGATHA3,protein_coding,AP2/B3-like transcriptional factor family protein;(source:Araport11),,,"DNA-binding transcription factor activity, DNA binding","GO:0003700, GO:0003677",15.5.5.3,.RNA biosynthesis.transcriptional regulation.B3 transcription factor superfamily.transcription factor (RAV/NGATHA),transcription factor (RAV/NGATHA) (original description: pep chromosome:TAIR10:1:11649:13714:-1 gene:AT1G01030 transcript:AT1G01030.2 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:NGA3 description:B3 domain-containing transcription factor NGA3 [Source:UniProtKB/Swiss-Prot;Acc:Q9MAN1]),,,,,, diff --git a/spec/test/djornl/missing_required_headers/pheno_nodes.csv b/spec/test/djornl/missing_required_headers/pheno_nodes.csv index 88e15082..8e516db2 100644 --- a/spec/test/djornl/missing_required_headers/pheno_nodes.csv +++ b/spec/test/djornl/missing_required_headers/pheno_nodes.csv @@ -1,4 +1,4 @@ -id,node_type,pheno_AraGWAS_ID,pheno_description,pheno_pto_name,pheno_pto_description,pheno_ref,User_Notes +id,node_type,pheno_AraGWAS_ID,pheno_description,pheno_pto_name,pheno_pto_description,pheno_reference,User_Notes As2,pheno,10.21958/phenotype:103,,bacterial disease resistance,The resistance exhibited by a plant or a group of plants (population) in response to the disease caused by a bacterial pathogen infection as compared to the susceptible and/or the reference plants of the same species. [GR:pj],"Atwell et. al, Nature 2010", As75,pheno,10.21958/phenotype:67,"Arsenic concentrations in leaves, grown in soil. Elemental analysis was performed with an ICP-MS (PerkinElmer). Sample normalized to calculated weights as described in Baxter et al., 2008",arsenic concentration,A mineral and ion content related trait (TO:0000465) which is the concentration of arsenic (CHEBI:22632) in some plant structure (PO:0009011). [GR:Karthik],"Atwell et. al, Nature 2010", Na23,pheno,10.21958/phenotype:5,"Sodium concentrations in leaves, grown in soil. Elemental analysis was performed with an ICP-MS (PerkinElmer). Sample normalized to calculated weights as described in Baxter et al., 2008",sodium concentration,The total sodium ion concentration measured in a given volume of a plant or a plant part or plant extract. [GR:pj],"Atwell et. al, Nature 2010", From 217b67f80f3a319544f23e813ff64ed59d416c4a Mon Sep 17 00:00:00 2001 From: ialarmedalien Date: Wed, 7 Oct 2020 14:26:41 -0700 Subject: [PATCH 616/732] Add in checks for additional incorrect headers and for duplicated headers --- .github/pull_request_template.md | 8 ++- importers/djornl/parser.py | 53 +++++++++++++++---- importers/test/test_djornl_parser.py | 43 ++++++++------- importers/tox.ini | 3 -- .../test/djornl/invalid_types/pheno_nodes.csv | 8 +-- .../missing_required_headers/I4_named.tsv | 2 +- .../missing_required_headers/I6_named.tsv | 2 +- .../missing_required_headers/pheno_nodes.csv | 2 +- 8 files changed, 81 insertions(+), 40 deletions(-) delete mode 100644 importers/tox.ini diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index bd4ec908..bfc22517 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -1,4 +1,8 @@ - [ ] I updated the README.md docs to reflect this change. -- [ ] This is not a breaking API change OR -- [ ] This is a breaking API change and I have incremented the API version. + +For changes to the codebase: + +- [ ] I have written tests to cover this change. +- [ ] This is not a breaking API change OR +- [ ] This is a breaking API change and I have incremented the API version and added a summary to CHANGELOG.md. diff --git a/importers/djornl/parser.py b/importers/djornl/parser.py index 6350dccd..6607e0d2 100644 --- a/importers/djornl/parser.py +++ b/importers/djornl/parser.py @@ -174,22 +174,46 @@ def check_headers(self, headers, validator=None): :param validator: (obj) validator object, with the appropriate schema loaded - :return missing_headers: (list) list of required headers that are missing from the input. + :return header_errs: (dict) dict of header errors: + 'missing': required headers that are missing from the input + 'invalid': additional headers that should not be in the input + 'duplicate': duplicated headers (content would be overwritten) If the list of headers supplied is valid--i.e. it contains all the fields marked as required in the validator schema--or no validator has been supplied, the method - returns an empty list + returns an empty dict """ if validator is None: - return [] + return {} + + header_errs = {} + + all_headers = {} + # ensure we don't have any duplicate headers + for h in headers: + if h in all_headers: + all_headers[h] += 1 + else: + all_headers[h] = 1 + + duplicate_headers = [h for h in all_headers.keys() if all_headers[h] != 1] + if duplicate_headers: + header_errs['duplicate'] = duplicate_headers # check that each required header in the schema is present in headers required_props = validator.schema['required'] + missing_headers = [i for i in required_props if i not in headers] + if missing_headers: + header_errs['missing'] = missing_headers - # TODO: check if additional properties are allowed + if 'additionalProperties' in validator.schema and validator.schema['additionalProperties'] is False: + all_props = validator.schema['properties'].keys() + extra_headers = [i for i in headers if i not in all_props] + if extra_headers: + header_errs['invalid'] = extra_headers - return [i for i in required_props if i not in headers] + return header_errs def remap_object(self, raw_data, remap_functions): """ @@ -251,12 +275,21 @@ def process_file(self, file, remap_fn, store_fn, err_list, validator=None): err_list.append(f"{file['path']}: no header line found") return - missing_headers = self.check_headers(cols, validator) - if missing_headers: - err_list.append( - f"{file['path']}: missing required headers: " + ", ".join(sorted(missing_headers)) - ) + header_errors = self.check_headers(cols, validator) + if header_errors.keys(): + err_str = { + 'duplicate': 'duplicate', + 'missing': 'missing required', + 'invalid': 'invalid additional', + } + for err_type in ['missing', 'invalid', 'duplicate']: + if err_type in header_errors: + err_list.append( + f"{file['path']}: {err_str[err_type]} headers: " + + ", ".join(sorted(header_errors[err_type])) + ) return + headers = cols n_stored = 0 for (line_no, cols, err_str) in file_parser: diff --git a/importers/test/test_djornl_parser.py b/importers/test/test_djornl_parser.py index 83121b42..7c6910e3 100644 --- a/importers/test/test_djornl_parser.py +++ b/importers/test/test_djornl_parser.py @@ -46,14 +46,13 @@ def test_errors(self, parser=None, errs={}): continue all_errs = all_errs + errs[data_type] - for data_type in errs.keys(): - method = f"load_{data_type}" - output = getattr(parser, method)() - with self.subTest(data_type=data_type): - self.assertEqual( - output['err_list'], - errs[data_type] - ) + method = f"load_{data_type}" + output = getattr(parser, method)() + with self.subTest(data_type=data_type): + self.assertEqual( + output['err_list'], + errs[data_type] + ) with self.subTest(data_type="all types"): # test all errors @@ -134,21 +133,32 @@ def test_load_missing_headers(self): RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, 'djornl', 'missing_required_headers') parser = self.init_parser_with_path(RES_ROOT_DATA_PATH) - def create_err(file_name, missing_list): - return f"{file_name}: missing required headers: " + ", ".join(sorted(missing_list)) + def invalid_err(file_name, header_list): + return f"{file_name}: invalid additional headers: " + ", ".join(sorted(header_list)) + + def missing_err(file_name, header_list): + return f"{file_name}: missing required headers: " + ", ".join(sorted(header_list)) + + def dupe_err(file_name, header_list): + return f"{file_name}: duplicate headers: " + ", ".join(sorted(header_list)) errs = { 'clusters': [ # tuple containing file name and list of column headers missing in that file - create_err("I2_named.tsv", ["cluster_id", "node_ids"]) + missing_err("I2_named.tsv", ["cluster_id", "node_ids"]), + invalid_err("I2_named.tsv", ["cluster", "node_list"]), + invalid_err("I4_named.tsv", ["other cool stuff"]), + dupe_err("I6_named.tsv", ["node_ids"]), ], 'edges': [ - create_err("edges.tsv", ["score"]), - create_err("hithruput-edges.csv", ["edge_type"]) + missing_err("edges.tsv", ["score"]), + missing_err("hithruput-edges.csv", ["edge_type"]) ], 'nodes': [ - create_err("extra_node.tsv", ["node_type"]), - create_err("pheno_nodes.csv", ["node_id"]), + missing_err("extra_node.tsv", ["node_type"]), + invalid_err("extra_node.tsv", ["node_types"]), + missing_err("pheno_nodes.csv", ["node_id"]), + invalid_err("pheno_nodes.csv", ["id", "pheno_ref", "usernotes"]), ], } self.test_errors(parser, errs) @@ -171,9 +181,6 @@ def test_load_invalid_types(self): 'nodes': [ # invalid node type r"nodes.csv line 5: 'Monkey' is not valid under any of the given schemas", - # invalid extra header property - r"pheno_nodes.csv line 3: Additional properties are not allowed ('pheno_ref' was unexpected)", - r"pheno_nodes.csv line 4: Additional properties are not allowed ('pheno_ref' was unexpected)", r"pheno_nodes.csv: no valid data found" ], 'clusters': [ diff --git a/importers/tox.ini b/importers/tox.ini deleted file mode 100644 index 0c2d49bb..00000000 --- a/importers/tox.ini +++ /dev/null @@ -1,3 +0,0 @@ -[flake8] -; ignore line length -ignore = E501 diff --git a/spec/test/djornl/invalid_types/pheno_nodes.csv b/spec/test/djornl/invalid_types/pheno_nodes.csv index d89450e5..d695313d 100644 --- a/spec/test/djornl/invalid_types/pheno_nodes.csv +++ b/spec/test/djornl/invalid_types/pheno_nodes.csv @@ -1,4 +1,4 @@ -# unexpected header -node_id,node_type,pheno_AraGWAS_ID,pheno_description,pheno_pto_name,pheno_pto_description,pheno_ref,User_Notes -As2,pheno,10.21958/phenotype:103,,bacterial disease resistance,The resistance exhibited by a plant or a group of plants (population) in response to the disease caused by a bacterial pathogen infection as compared to the susceptible and/or the reference plants of the same species. [GR:pj],"Atwell et. al, Nature 2010", -As75,pheno,10.21958/phenotype:67,"Arsenic concentrations in leaves, grown in soil. Elemental analysis was performed with an ICP-MS (PerkinElmer). Sample normalized to calculated weights as described in Baxter et al., 2008",arsenic concentration,A mineral and ion content related trait (TO:0000465) which is the concentration of arsenic (CHEBI:22632) in some plant structure (PO:0009011). [GR:Karthik],"Atwell et. al, Nature 2010", +node_id,node_type,pheno_AraGWAS_ID,pheno_description,pheno_pto_name,pheno_pto_description,pheno_reference,User_Notes +# no +# valid +# data diff --git a/spec/test/djornl/missing_required_headers/I4_named.tsv b/spec/test/djornl/missing_required_headers/I4_named.tsv index 6e7d91e4..1fa92267 100644 --- a/spec/test/djornl/missing_required_headers/I4_named.tsv +++ b/spec/test/djornl/missing_required_headers/I4_named.tsv @@ -1,4 +1,4 @@ -cluster_id node_ids +cluster_id node_ids other cool stuff # cluster_prefix: markov_i4 # title: Markov clustering, inflation = 4 # data_type: cluster diff --git a/spec/test/djornl/missing_required_headers/I6_named.tsv b/spec/test/djornl/missing_required_headers/I6_named.tsv index e7688f17..85b7aa81 100644 --- a/spec/test/djornl/missing_required_headers/I6_named.tsv +++ b/spec/test/djornl/missing_required_headers/I6_named.tsv @@ -1,4 +1,4 @@ -cluster_id node_ids +cluster_id node_ids node_ids # data_type: cluster # cluster_prefix: markov_i6 # title: Markov clustering, inflation = 6 diff --git a/spec/test/djornl/missing_required_headers/pheno_nodes.csv b/spec/test/djornl/missing_required_headers/pheno_nodes.csv index 8e516db2..f7ba6de1 100644 --- a/spec/test/djornl/missing_required_headers/pheno_nodes.csv +++ b/spec/test/djornl/missing_required_headers/pheno_nodes.csv @@ -1,4 +1,4 @@ -id,node_type,pheno_AraGWAS_ID,pheno_description,pheno_pto_name,pheno_pto_description,pheno_reference,User_Notes +id,node_type,pheno_AraGWAS_ID,pheno_description,pheno_pto_name,pheno_pto_description,pheno_ref,UserNotes As2,pheno,10.21958/phenotype:103,,bacterial disease resistance,The resistance exhibited by a plant or a group of plants (population) in response to the disease caused by a bacterial pathogen infection as compared to the susceptible and/or the reference plants of the same species. [GR:pj],"Atwell et. al, Nature 2010", As75,pheno,10.21958/phenotype:67,"Arsenic concentrations in leaves, grown in soil. Elemental analysis was performed with an ICP-MS (PerkinElmer). Sample normalized to calculated weights as described in Baxter et al., 2008",arsenic concentration,A mineral and ion content related trait (TO:0000465) which is the concentration of arsenic (CHEBI:22632) in some plant structure (PO:0009011). [GR:Karthik],"Atwell et. al, Nature 2010", Na23,pheno,10.21958/phenotype:5,"Sodium concentrations in leaves, grown in soil. Elemental analysis was performed with an ICP-MS (PerkinElmer). Sample normalized to calculated weights as described in Baxter et al., 2008",sodium concentration,The total sodium ion concentration measured in a given volume of a plant or a plant part or plant extract. [GR:pj],"Atwell et. al, Nature 2010", From a156d3af6e8e31d35a53ffbe8f8d15420a13add4 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Wed, 7 Oct 2020 18:32:50 -0700 Subject: [PATCH 617/732] Get the wait_for on arangodb working more reliably --- .gitignore | 4 ++-- Dockerfile | 5 ++--- relation_engine_server/utils/arango_client.py | 9 ++++++--- relation_engine_server/utils/wait_for.py | 14 +++++++++++--- scripts/docker_deploy | 6 ------ 5 files changed, 21 insertions(+), 17 deletions(-) diff --git a/.gitignore b/.gitignore index 56534d99..d93382fe 100644 --- a/.gitignore +++ b/.gitignore @@ -13,5 +13,5 @@ coverage_report/ .coverage *.egg-info/ -# Test spec archive -/relation_engine_server/test/spec_release/spec.tar.gz +# Spec archives +spec.tar.gz diff --git a/Dockerfile b/Dockerfile index 53b34cbc..b97e3bba 100644 --- a/Dockerfile +++ b/Dockerfile @@ -26,9 +26,8 @@ RUN apk --update add --virtual build-dependencies build-base python3-dev && \ COPY . /app -# Create tarball of the test spec directory -RUN cd /app/relation_engine_server/test/spec_release && \ - tar czvf spec.tar.gz sample_spec_release +# Create tarball of the spec directory so we have it cached in the image +RUN tar czvf /app/spec.tar.gz /app/spec LABEL org.label-schema.build-date=$BUILD_DATE \ org.label-schema.vcs-url="https://github.com/kbase/relation_engine_api" \ diff --git a/relation_engine_server/utils/arango_client.py b/relation_engine_server/utils/arango_client.py index 3606ec38..1c592f50 100644 --- a/relation_engine_server/utils/arango_client.py +++ b/relation_engine_server/utils/arango_client.py @@ -82,7 +82,8 @@ def create_collection(name, config): 'keyOptions': {'allowUserKeys': True}, 'name': name, 'type': collection_type, - 'numberOfShards': num_shards + 'numberOfShards': num_shards, + 'waitForSync': True, }) resp = requests.post(url, data, auth=(_CONF['db_user'], _CONF['db_pass'])) resp_json = resp.json() @@ -90,6 +91,7 @@ def create_collection(name, config): if 'duplicate' not in resp_json['errorMessage']: # Unable to create a collection raise ArangoServerError(resp.text) + print(f'Successfully created index {name}') if config.get('indexes'): _create_indexes(name, config) @@ -109,15 +111,16 @@ def _create_indexes(coll_name, config): idx_type = idx_conf['type'] idx_url = url + '#' + idx_type idx_conf['type'] = idx_type + print(f'Creating {idx_type} index for collection {coll_name}: {idx_conf}') resp = requests.post( idx_url, params={'collection': coll_name}, data=json.dumps(idx_conf), - auth=(_CONF['db_user'], _CONF['db_pass']) + auth=auth, ) if not resp.ok: raise RuntimeError(resp.text) - print(f'Created new {idx_type} index on {idx_conf["fields"]} for {coll_name}.') + print(f'Successfully created {idx_type} index on {idx_conf["fields"]} for {coll_name}.') def _index_exists(idx_conf, indexes): diff --git a/relation_engine_server/utils/wait_for.py b/relation_engine_server/utils/wait_for.py index 9ea9a821..ca734508 100644 --- a/relation_engine_server/utils/wait_for.py +++ b/relation_engine_server/utils/wait_for.py @@ -21,7 +21,9 @@ def wait_for_service(service_list): name = service['name'] url = service['url'] if service['auth'] is not None: - requests.get(service['url'], auth=service['auth']).raise_for_status() + resp = requests.get(service['url'], auth=service['auth']).raise_for_status() + if service.get('callback') is not None: + service['callback'](resp) else: # auth and workspace both return 500, so don't raise_for_status requests.get(service['url']) @@ -38,7 +40,8 @@ def get_service_conf(service_name): service_conf = { 'arangodb': { - 'url': _CONF['db_url'], + 'url': _CONF['api_url'] + '/database/current', + 'callback': _assert_content, }, 'auth': { 'url': _CONF['auth_url'], @@ -64,7 +67,6 @@ def get_service_conf(service_name): def wait_for_arangodb(): '''wait for arangodb to be ready''' - wait_for_service(['arangodb']) @@ -81,6 +83,12 @@ def wait_for_api(): wait_for_service(['localhost']) +def _assert_content(resp): + """Assert that a response body is non-empty""" + if len(resp.content) == 0: + raise RuntimeError("No content in response") + + if __name__ == '__main__': if sys.argv[1] == 'services': wait_for_services() diff --git a/scripts/docker_deploy b/scripts/docker_deploy index 80d5c8e7..7c4c0a10 100755 --- a/scripts/docker_deploy +++ b/scripts/docker_deploy @@ -9,7 +9,6 @@ set -o xtrace ver=$(cat VERSION) export IMAGE_NAME="kbase/relation_engine_api:$ver" export BRANCH=`git symbolic-ref --short HEAD` -export BRANCH_IMAGE_NAME="kbase/relation_engine_api:$BRANCH" export DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` export COMMIT=`git rev-parse --short HEAD` docker build --build-arg BUILD_DATE=$DATE \ @@ -17,8 +16,3 @@ docker build --build-arg BUILD_DATE=$DATE \ --build-arg BRANCH=$BRANCH \ -t ${IMAGE_NAME} . docker push $IMAGE_NAME -docker build --build-arg BUILD_DATE=$DATE \ - --build-arg VCS_REF=$COMMIT \ - --build-arg BRANCH=$BRANCH \ - -t ${BRANCH_IMAGE_NAME} . -docker push $BRANCH_IMAGE_NAME From a68cfb7cd652f94cf90b46589f562fe3eda23673 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Thu, 8 Oct 2020 11:18:39 -0700 Subject: [PATCH 618/732] Some fixes for waiting on dependent services --- Dockerfile | 3 +- docker-compose.yaml | 7 +- relation_engine_server/utils/arango_client.py | 2 +- relation_engine_server/utils/wait_for.py | 96 +++++++++---------- 4 files changed, 48 insertions(+), 60 deletions(-) diff --git a/Dockerfile b/Dockerfile index b97e3bba..7ba06bc0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,7 +27,8 @@ RUN apk --update add --virtual build-dependencies build-base python3-dev && \ COPY . /app # Create tarball of the spec directory so we have it cached in the image -RUN tar czvf /app/spec.tar.gz /app/spec +RUN tar czvf /opt/spec.tar.gz /app/spec +ENV SPEC_RELEASE_PATH=/opt/spec.tar.gz LABEL org.label-schema.build-date=$BUILD_DATE \ org.label-schema.vcs-url="https://github.com/kbase/relation_engine_api" \ diff --git a/docker-compose.yaml b/docker-compose.yaml index 55fab70c..c213e1c8 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -13,10 +13,8 @@ services: DEVELOPMENT: 1 ports: - "127.0.0.1:5000:5000" -# uncomment to mount local directories -# volumes: -# - ${PWD}:/app -# - "./spec:/spec" + volumes: + - ${PWD}:/app depends_on: - auth - workspace @@ -29,7 +27,6 @@ services: - KBASE_AUTH_URL=http://auth:5000 - KBASE_WORKSPACE_URL=http://workspace:5000 - PYTHONUNBUFFERED=true - - SPEC_RELEASE_PATH=/app/relation_engine_server/test/spec_release/spec.tar.gz - DB_URL=http://arangodb:8529 - DB_USER=root - RE_API_URL=http://127.0.0.1:5000 diff --git a/relation_engine_server/utils/arango_client.py b/relation_engine_server/utils/arango_client.py index 1c592f50..18cbafbc 100644 --- a/relation_engine_server/utils/arango_client.py +++ b/relation_engine_server/utils/arango_client.py @@ -91,7 +91,7 @@ def create_collection(name, config): if 'duplicate' not in resp_json['errorMessage']: # Unable to create a collection raise ArangoServerError(resp.text) - print(f'Successfully created index {name}') + print(f'Successfully created collection {name}') if config.get('indexes'): _create_indexes(name, config) diff --git a/relation_engine_server/utils/wait_for.py b/relation_engine_server/utils/wait_for.py index ca734508..38168005 100644 --- a/relation_engine_server/utils/wait_for.py +++ b/relation_engine_server/utils/wait_for.py @@ -12,57 +12,27 @@ def wait_for_service(service_list): '''wait for a service or list of services to start up''' timeout = int(time.time()) + 60 - - service_conf_list = [get_service_conf(s) for s in service_list] - - while True: - try: - for service in service_conf_list: - name = service['name'] - url = service['url'] - if service['auth'] is not None: - resp = requests.get(service['url'], auth=service['auth']).raise_for_status() - if service.get('callback') is not None: - service['callback'](resp) - else: - # auth and workspace both return 500, so don't raise_for_status - requests.get(service['url']) - break - except Exception: - print(f"Waiting for {name} to start...") - if int(time.time()) > timeout: - raise RuntimeError(f"Timed out waiting for {name}, {url}") - time.sleep(3) - print(f"{name} started!") - - -def get_service_conf(service_name): - - service_conf = { - 'arangodb': { - 'url': _CONF['api_url'] + '/database/current', - 'callback': _assert_content, - }, - 'auth': { - 'url': _CONF['auth_url'], - }, - 'workspace': { - 'url': _CONF['workspace_url'], - }, - 'localhost': { - 'url': 'http://127.0.0.1:5000', - } - } - - if service_name not in service_conf: - raise KeyError(f'Configuration for {service_name} not found') - - return { - 'name': service_name, - # auth defaults to None if there is nothing set - 'auth': service_conf[service_name].get('auth'), - 'url': service_conf[service_name]['url'], - } + services_pending = set(service_list) + + while services_pending: + still_pending = set() + for name in services_pending: + try: + conf = _SERVICE_CONF[name] + resp = requests.get(conf['url'], auth=conf.get('auth')) + if conf.get('raise_for_status'): + resp.raise_for_status() + if conf.get('callback') is not None: + conf['callback'](resp) + # The service is up + except Exception: + print(f"Still waiting for {name} to start...") + if int(time.time()) > timeout: + raise RuntimeError(f"Timed out waiting for {name} to start") + still_pending.add(name) + time.sleep(3) + services_pending = still_pending + print(f"{', '.join(service_list)} started!") def wait_for_arangodb(): @@ -83,10 +53,30 @@ def wait_for_api(): wait_for_service(['localhost']) -def _assert_content(resp): - """Assert that a response body is non-empty""" +def _assert_json_content(resp): + """Assert that a response body has non-empty JSON content.""" if len(resp.content) == 0: raise RuntimeError("No content in response") + resp.json() + + +_SERVICE_CONF = { + 'arangodb': { + 'url': _CONF['api_url'] + '/collection', + 'callback': _assert_json_content, + 'raise_for_status': True, + }, + 'auth': { + 'url': _CONF['auth_url'], + }, + 'workspace': { + 'url': _CONF['workspace_url'], + }, + 'localhost': { + 'url': 'http://127.0.0.1:5000', + 'raise_for_status': True, + } +} if __name__ == '__main__': From ca506fae5a722512082499b74dcab1435515e671 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Thu, 8 Oct 2020 14:58:34 -0700 Subject: [PATCH 619/732] Update CHANGELOG.md --- CHANGELOG.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ad6edad2..58162e35 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,13 +5,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [0.0.9] - 2020-10-05 -## Changed -- Clean up some of the config slightly, and add the `SPEC_REPO_URL` env var instead of hard-coding +## [0.0.10] - 2020-10-08 +### Changed +- Clean up some of the configuration logic, and add the `SPEC_REPO_URL` env var instead of hard-coding - Bundle the spec tarball in the docker image so other programs can use the image for testing ## [0.0.9] - 2020-10-05 -## Fixed +### Fixed - Fixed the function that concatenates parts of the query for the API ## [0.0.8] - 2020-09-18 From b2d36ac9582842a27ca0ff7af3d702a3090fe1f7 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Thu, 8 Oct 2020 14:59:24 -0700 Subject: [PATCH 620/732] Restore spec release url in the docker-compose --- docker-compose.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index c213e1c8..77f41d37 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -27,7 +27,7 @@ services: - KBASE_AUTH_URL=http://auth:5000 - KBASE_WORKSPACE_URL=http://workspace:5000 - PYTHONUNBUFFERED=true - - DB_URL=http://arangodb:8529 + - SPEC_RELEASE_PATH=/app/relation_engine_server/test/spec_release/spec.tar.gz- DB_URL=http://arangodb:8529 - DB_USER=root - RE_API_URL=http://127.0.0.1:5000 From 465566d9b8f12a023ee666db80bee10cab0bbdc0 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Thu, 8 Oct 2020 15:14:42 -0700 Subject: [PATCH 621/732] Fix docker-compose; gitignore test coverage dir; clean up test script --- .gitignore | 3 +++ docker-compose.yaml | 3 ++- scripts/run_tests.sh | 10 +++------- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index d93382fe..59a9ce73 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,9 @@ # Environment variables .env +# Test coverage +/htmlcov/ + # Caches and temp dirs /build/ /dist/ diff --git a/docker-compose.yaml b/docker-compose.yaml index 77f41d37..e1739190 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -27,7 +27,8 @@ services: - KBASE_AUTH_URL=http://auth:5000 - KBASE_WORKSPACE_URL=http://workspace:5000 - PYTHONUNBUFFERED=true - - SPEC_RELEASE_PATH=/app/relation_engine_server/test/spec_release/spec.tar.gz- DB_URL=http://arangodb:8529 + - SPEC_RELEASE_PATH=/app/relation_engine_server/test/spec_release/spec.tar.gz + - DB_URL=http://arangodb:8529 - DB_USER=root - RE_API_URL=http://127.0.0.1:5000 diff --git a/scripts/run_tests.sh b/scripts/run_tests.sh index 59499134..ee65152c 100644 --- a/scripts/run_tests.sh +++ b/scripts/run_tests.sh @@ -9,17 +9,13 @@ set -e flake8 --max-complexity 15 /app mypy --ignore-missing-imports /app bandit -r /app -rm -rf /spec -mkdir /spec -mkdir /spec/repo -cp -r /app/spec/* /spec/repo/ # start server, using the specs in /spec/repo sh /app/scripts/start_server.sh & coverage erase # spec validation -python -m spec.validate && +python -m spec.validate # run importer/, relation_engine_server/, and spec/ tests -coverage run --branch -m unittest discover -v && +coverage run --branch -m unittest discover -v # RE client tests -PYTHONPATH=client_src python -m unittest discover client_src/test && +PYTHONPATH=client_src python -m unittest discover client_src/test coverage html --omit=*/test_* From 51053a1a81412fa4f17a497749b454cf7ba56b50 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Thu, 8 Oct 2020 15:31:51 -0700 Subject: [PATCH 622/732] Add a couple type hints --- relation_engine_server/utils/wait_for.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/relation_engine_server/utils/wait_for.py b/relation_engine_server/utils/wait_for.py index 38168005..b8d08031 100644 --- a/relation_engine_server/utils/wait_for.py +++ b/relation_engine_server/utils/wait_for.py @@ -5,11 +5,12 @@ import time import sys from relation_engine_server.utils.config import get_config +from typing import List _CONF = get_config() -def wait_for_service(service_list): +def wait_for_service(service_list: List[str]) -> None: '''wait for a service or list of services to start up''' timeout = int(time.time()) + 60 services_pending = set(service_list) @@ -53,7 +54,7 @@ def wait_for_api(): wait_for_service(['localhost']) -def _assert_json_content(resp): +def _assert_json_content(resp: requests.models.Response) -> None: """Assert that a response body has non-empty JSON content.""" if len(resp.content) == 0: raise RuntimeError("No content in response") From 6a4b40d95054c95ff83ffb11d918eb694a9c40da Mon Sep 17 00:00:00 2001 From: ialarmedalien Date: Tue, 20 Oct 2020 08:32:17 -0700 Subject: [PATCH 623/732] DJORNL edges renamed --- importers/test/test_djornl_parser.py | 14 +- spec/datasets/djornl/edge_type.yaml | 12 +- spec/datasets/djornl/edge_types_filter.yaml | 4 +- .../djornl/djornl_fetch_all.yaml | 4 +- .../djornl/djornl_fetch_clusters.yaml | 4 +- .../djornl/djornl_fetch_genes.yaml | 4 +- .../djornl/djornl_fetch_phenotypes.yaml | 4 +- .../djornl/djornl_search_nodes.yaml | 4 +- .../merged_edges-AMW-060820_AF.tsv | 12 +- spec/test/djornl/duplicate_data/edges.tsv | 18 +- .../djornl/duplicate_data/hithruput-edges.csv | 10 +- spec/test/djornl/invalid_types/edges.tsv | 12 +- .../djornl/missing_required_headers/edges.tsv | 16 +- .../hithruput-edges.csv | 4 +- spec/test/djornl/results.json | 354 +++++++++--------- spec/test/djornl/test_data/edges.tsv | 16 +- .../test/djornl/test_data/hithruput-edges.csv | 4 +- 17 files changed, 248 insertions(+), 248 deletions(-) diff --git a/importers/test/test_djornl_parser.py b/importers/test/test_djornl_parser.py index 7c6910e3..90a84967 100644 --- a/importers/test/test_djornl_parser.py +++ b/importers/test/test_djornl_parser.py @@ -261,9 +261,9 @@ def test_duplicate_data(self): errs = { 'edges': [ "hithruput-edges.csv line 5: duplicate data for edge " - + "AT1G01010__AT1G01030__AraNetv2-HT_high-throughput-ppi", + + "AT1G01010__AT1G01030__protein-protein-interaction_high-throughput_AraNet_v2", "hithruput-edges.csv line 9: duplicate data for edge " - + "AT1G01030__AT1G01050__AraNetv2-CX_pairwise-gene-coexpression" + + "AT1G01030__AT1G01050__pairwise-gene-coexpression_AraNet_v2" ], 'nodes': [ "extra_node.tsv line 5: duplicate data for node AT1G01080" @@ -293,11 +293,11 @@ def test_dry_run(self): self.assertEqual( { 'edge_type_count': { - 'AraGWAS-Phenotype_Associations': 3, - 'AraNetv2-CX_pairwise-gene-coexpression': 1, - 'AraNetv2-DC_domain-co-occurrence': 1, - 'AraNetv2-HT_high-throughput-ppi': 2, - 'AraNetv2-LC_lit-curated-ppi': 3 + 'phenotype-association_AraGWAS': 3, + 'pairwise-gene-coexpression_AraNet_v2': 1, + 'domain-co-occurrence_AraNet_v2': 1, + 'protein-protein-interaction_high-throughput_AraNet_v2': 2, + 'protein-protein-interaction_literature-curation_AraNet_v2': 3 }, 'edges_total': 10, 'node_data_available': {'cluster': 0, 'full': 14, 'key_only': 0}, diff --git a/spec/datasets/djornl/edge_type.yaml b/spec/datasets/djornl/edge_type.yaml index 3ac6d62a..3842532b 100644 --- a/spec/datasets/djornl/edge_type.yaml +++ b/spec/datasets/djornl/edge_type.yaml @@ -4,22 +4,22 @@ title: Edge Type description: Edge types in Dan Jacobson Arabidopsis Exascale dataset type: string oneOf: - - const: AraGWAS-Phenotype_Associations - title: AraGWAS phenotype associations + - const: phenotype-association_AraGWAS + title: AraGWAS phenotype association description: GWAS associations produced by analyzing a subset of phenotypes and SNPs in the Arabidopsis 1001 Genomes database. Edge values are significant association scores after FDR correction. - - const: AraNetv2-CX_pairwise-gene-coexpression + - const: pairwise-gene-coexpression_AraNet_v2 title: AraNetv2 pairwise gene coexpression description: A subset of pairwise gene coexpression values from the Arabidopsis AraNetv2 database. The LLS scores that serve as edge values were calculated from Pearson correlation coefficients to normalize the data for comparison across studies and different types of data layers (Lee et al, 2015). - - const: AraNetv2-DC_domain-co-occurrence + - const: domain-co-occurrence_AraNet_v2 title: AraNetv2 domain co-occurrence description: A layer of protein domain co-occurrence values from the Arabidopsis AraNetv2 database. The LLS scores that serve as edge values were calculated from weighted mutual information scores to normalize the data for comparison across studies and different types of data layers (Lee et al, 2015). - - const: AraNetv2-HT_high-throughput-ppi + - const: protein-protein-interaction_high-throughput_AraNet_v2 title: AraNetv2 high-throughput protein-protein interaction description: Log likelihood score. A layer of protein-protein interaction values derived from four high-throughput PPI screening experiments; from the Arabidopsis AraNetv2 database. The LLS scores that serve as edge values were calculated to normalize the data for comparison across studies and different types of data layers (Lee et al, 2015). - - const: AraNetv2-LC_lit-curated-ppi + - const: protein-protein-interaction_literature-curation_AraNet_v2 title: AraNetv2 literature-curated protein-protein interaction description: A layer of protein-protein interaction values from literature-curated small- to medium-scale experimental data; from the Arabidopsis AraNetv2 database. The LLS scores that serve as edge values were calculated to normalize the data for comparison across studies and different types of data layers (Lee et al, 2015). diff --git a/spec/datasets/djornl/edge_types_filter.yaml b/spec/datasets/djornl/edge_types_filter.yaml index 6c090052..4685008a 100644 --- a/spec/datasets/djornl/edge_types_filter.yaml +++ b/spec/datasets/djornl/edge_types_filter.yaml @@ -8,6 +8,6 @@ items: default: [] uniqueItems: true examples: - - ['AraNetv2-HT_high-throughput-ppi', 'AraNetv2-LC_lit-curated-ppi'] - - ['AraGWAS-Phenotype_Associations'] + - ['protein-protein-interaction_high-throughput_AraNet_v2', 'protein-protein-interaction_literature-curation_AraNet_v2'] + - ['phenotype-association_AraGWAS'] - [] diff --git a/spec/stored_queries/djornl/djornl_fetch_all.yaml b/spec/stored_queries/djornl/djornl_fetch_all.yaml index 6a0a0b35..1e8911c7 100644 --- a/spec/stored_queries/djornl/djornl_fetch_all.yaml +++ b/spec/stored_queries/djornl/djornl_fetch_all.yaml @@ -13,8 +13,8 @@ params: default: [] uniqueItems: true examples: - - ['AraNetv2-HT_high-throughput-ppi', 'AraNetv2-LC_lit-curated-ppi'] - - ['AraGWAS-Phenotype_Associations'] + - ['protein-protein-interaction_high-throughput_AraNet_v2', 'protein-protein-interaction_literature-curation_AraNet_v2'] + - ['phenotype-association_AraGWAS'] - [] query: | LET nodes = ( diff --git a/spec/stored_queries/djornl/djornl_fetch_clusters.yaml b/spec/stored_queries/djornl/djornl_fetch_clusters.yaml index 9a3aab28..5677f3a9 100644 --- a/spec/stored_queries/djornl/djornl_fetch_clusters.yaml +++ b/spec/stored_queries/djornl/djornl_fetch_clusters.yaml @@ -32,8 +32,8 @@ params: default: [] uniqueItems: true examples: - - ['AraNetv2-HT_high-throughput-ppi', 'AraNetv2-LC_lit-curated-ppi'] - - ['AraGWAS-Phenotype_Associations'] + - ['protein-protein-interaction_high-throughput_AraNet_v2', 'protein-protein-interaction_literature-curation_AraNet_v2'] + - ['phenotype-association_AraGWAS'] - [] query: | LET node_ids = ( diff --git a/spec/stored_queries/djornl/djornl_fetch_genes.yaml b/spec/stored_queries/djornl/djornl_fetch_genes.yaml index c12178ab..7ebba435 100644 --- a/spec/stored_queries/djornl/djornl_fetch_genes.yaml +++ b/spec/stored_queries/djornl/djornl_fetch_genes.yaml @@ -32,8 +32,8 @@ params: default: [] uniqueItems: true examples: - - ['AraNetv2-HT_high-throughput-ppi', 'AraNetv2-LC_lit-curated-ppi'] - - ['AraGWAS-Phenotype_Associations'] + - ['protein-protein-interaction_high-throughput_AraNet_v2', 'protein-protein-interaction_literature-curation_AraNet_v2'] + - ['phenotype-association_AraGWAS'] - [] query: | LET node_ids = ( diff --git a/spec/stored_queries/djornl/djornl_fetch_phenotypes.yaml b/spec/stored_queries/djornl/djornl_fetch_phenotypes.yaml index ce5bfecc..0758bc8b 100644 --- a/spec/stored_queries/djornl/djornl_fetch_phenotypes.yaml +++ b/spec/stored_queries/djornl/djornl_fetch_phenotypes.yaml @@ -32,8 +32,8 @@ params: default: [] uniqueItems: true examples: - - ['AraNetv2-HT_high-throughput-ppi', 'AraNetv2-LC_lit-curated-ppi'] - - ['AraGWAS-Phenotype_Associations'] + - ['protein-protein-interaction_high-throughput_AraNet_v2', 'protein-protein-interaction_literature-curation_AraNet_v2'] + - ['phenotype-association_AraGWAS'] - [] query: | LET node_ids = ( diff --git a/spec/stored_queries/djornl/djornl_search_nodes.yaml b/spec/stored_queries/djornl/djornl_search_nodes.yaml index 877b8dc5..b113bcf8 100644 --- a/spec/stored_queries/djornl/djornl_search_nodes.yaml +++ b/spec/stored_queries/djornl/djornl_search_nodes.yaml @@ -28,8 +28,8 @@ params: default: [] uniqueItems: true examples: - - ['AraNetv2-HT_high-throughput-ppi', 'AraNetv2-LC_lit-curated-ppi'] - - ['AraGWAS-Phenotype_Associations'] + - ['protein-protein-interaction_high-throughput_AraNet_v2', 'protein-protein-interaction_literature-curation_AraNet_v2'] + - ['phenotype-association_AraGWAS'] - [] query: | LET node_ids = ( diff --git a/spec/test/djornl/col_count_errors/merged_edges-AMW-060820_AF.tsv b/spec/test/djornl/col_count_errors/merged_edges-AMW-060820_AF.tsv index 0cb3f090..8e8c6f1b 100644 --- a/spec/test/djornl/col_count_errors/merged_edges-AMW-060820_AF.tsv +++ b/spec/test/djornl/col_count_errors/merged_edges-AMW-060820_AF.tsv @@ -1,8 +1,8 @@ node1 node2 score edge_descrip edge_type -As2 AT1G01040 5.422046084731258 AraGWAS-Association_score AraGWAS-Phenotype_Associations -As75 AT1G01020 39.98573324312915 AraGWAS-Association_score AraGWAS-Phenotype_Associations -AT1G01010 AT1G01020 2.39322646755088 AraNetv2_log-likelihood-score AraNetv2-HT_high-throughput-ppi -AT1G01010 AT1G01030 2.39322646755088 AraNetv2_log-likelihood-score AraNetv2-HT_high-throughput-ppi +As2 AT1G01040 5.422046084731258 AraGWAS-Association_score phenotype-association_AraGWAS +As75 AT1G01020 39.98573324312915 AraGWAS-Association_score phenotype-association_AraGWAS +AT1G01010 AT1G01020 2.39322646755088 AraNetv2_log-likelihood-score protein-protein-interaction_high-throughput_AraNet_v2 +AT1G01010 AT1G01030 2.39322646755088 AraNetv2_log-likelihood-score protein-protein-interaction_high-throughput_AraNet_v2 AT1G01010 AT1G01040 2.39322646755088 -AT1G01030 AT1G01050 2.5494618241936697 AraNetv2_log-likelihood-score AraNetv2-CX_pairwise-gene-coexpression -AT1G01050 AT1G01060 4.34242054808616 AraNetv2_log-likelihood-score AraNetv2-LC_lit-curated-ppi +AT1G01030 AT1G01050 2.5494618241936697 AraNetv2_log-likelihood-score pairwise-gene-coexpression_AraNet_v2 +AT1G01050 AT1G01060 4.34242054808616 AraNetv2_log-likelihood-score protein-protein-interaction_literature-curation_AraNet_v2 diff --git a/spec/test/djornl/duplicate_data/edges.tsv b/spec/test/djornl/duplicate_data/edges.tsv index be7a654a..552d74e6 100644 --- a/spec/test/djornl/duplicate_data/edges.tsv +++ b/spec/test/djornl/duplicate_data/edges.tsv @@ -1,11 +1,11 @@ node1 node2 score edge_descrip edge_type -As2 AT1G01020 8.4 AraGWAS-Association_score AraGWAS-Phenotype_Associations -As2 AT1G01040 5.4 AraGWAS-Association_score AraGWAS-Phenotype_Associations -As75 AT1G01020 39.9 AraGWAS-Association_score AraGWAS-Phenotype_Associations -AT1G01010 AT1G01040 2.5 AraNetv2_log-likelihood-score AraNetv2-DC_domain-co-occurrence -AT1G01010 AT1G01040 170.5 AraNetv2_log-likelihood-score AraNetv2-LC_lit-curated-ppi -AT1G01030 AT1G01050 2.6 AraNetv2_log-likelihood-score AraNetv2-CX_pairwise-gene-coexpression -AT1G01050 AT1G01060 2.7 AraNetv2_log-likelihood-score AraNetv2-LC_lit-curated-ppi +As2 AT1G01020 8.4 AraGWAS-Association_score phenotype-association_AraGWAS +As2 AT1G01040 5.4 AraGWAS-Association_score phenotype-association_AraGWAS +As75 AT1G01020 39.9 AraGWAS-Association_score phenotype-association_AraGWAS +AT1G01010 AT1G01040 2.5 AraNetv2_log-likelihood-score domain-co-occurrence_AraNet_v2 +AT1G01010 AT1G01040 170.5 AraNetv2_log-likelihood-score protein-protein-interaction_literature-curation_AraNet_v2 +AT1G01030 AT1G01050 2.6 AraNetv2_log-likelihood-score pairwise-gene-coexpression_AraNet_v2 +AT1G01050 AT1G01060 2.7 AraNetv2_log-likelihood-score protein-protein-interaction_literature-curation_AraNet_v2 # duplicated line -AT1G01010 AT1G01040 2.5 AraNetv2_log-likelihood-score AraNetv2-DC_domain-co-occurrence -AT1G01080 AT1G01090 2.8 AraNetv2_log-likelihood-score AraNetv2-LC_lit-curated-ppi +AT1G01010 AT1G01040 2.5 AraNetv2_log-likelihood-score domain-co-occurrence_AraNet_v2 +AT1G01080 AT1G01090 2.8 AraNetv2_log-likelihood-score protein-protein-interaction_literature-curation_AraNet_v2 diff --git a/spec/test/djornl/duplicate_data/hithruput-edges.csv b/spec/test/djornl/duplicate_data/hithruput-edges.csv index e02aad44..197becd5 100644 --- a/spec/test/djornl/duplicate_data/hithruput-edges.csv +++ b/spec/test/djornl/duplicate_data/hithruput-edges.csv @@ -1,9 +1,9 @@ node1,node2,score,edge_descrip,edge_type -AT1G01010,AT1G01020,2.3,AraNetv2_log-likelihood-score,AraNetv2-HT_high-throughput-ppi -AT1G01010,AT1G01030,2.4,AraNetv2_log-likelihood-score,AraNetv2-HT_high-throughput-ppi +AT1G01010,AT1G01020,2.3,AraNetv2_log-likelihood-score,protein-protein-interaction_high-throughput_AraNet_v2 +AT1G01010,AT1G01030,2.4,AraNetv2_log-likelihood-score,protein-protein-interaction_high-throughput_AraNet_v2 # potentially erroneous line -AT1G01010,AT1G01030,2.7,AraNetv2_log-likelihood-score,AraNetv2-HT_high-throughput-ppi +AT1G01010,AT1G01030,2.7,AraNetv2_log-likelihood-score,protein-protein-interaction_high-throughput_AraNet_v2 # duplicated line from the other file -AT1G01060,AT1G01050,2.7,AraNetv2_log-likelihood-score,AraNetv2-LC_lit-curated-ppi +AT1G01060,AT1G01050,2.7,AraNetv2_log-likelihood-score,protein-protein-interaction_literature-curation_AraNet_v2 # potentially erroneous duplication from the other file -AT1G01050,AT1G01030,2.6000001,AraNetv2_log-likelihood-score,AraNetv2-CX_pairwise-gene-coexpression +AT1G01050,AT1G01030,2.6000001,AraNetv2_log-likelihood-score,pairwise-gene-coexpression_AraNet_v2 diff --git a/spec/test/djornl/invalid_types/edges.tsv b/spec/test/djornl/invalid_types/edges.tsv index bad2b9b4..57fda99d 100644 --- a/spec/test/djornl/invalid_types/edges.tsv +++ b/spec/test/djornl/invalid_types/edges.tsv @@ -1,10 +1,10 @@ # data_type: edge node1 node2 score edge_descrip edge_type As2 AT1G01020 8.422046084731258 AraGWAS-Association_score Same-Old-Stuff -As2 AT1G01040 6 AraGWAS-Association_score AraGWAS-Phenotype_Associations -As75 AT1G01020 39.98573324312915 AraGWAS-Association_score AraGWAS-Phenotype_Associations -AT1G01010 AT1G01020 2.39322646755088 AraNetv2_log-likelihood-score AraNetv2-HT_high-throughput-ppi -AT1G01010 AT1G01030 2. AraNetv2_log-likelihood-score AraNetv2-HT_high-throughput-ppi +As2 AT1G01040 6 AraGWAS-Association_score phenotype-association_AraGWAS +As75 AT1G01020 39.98573324312915 AraGWAS-Association_score phenotype-association_AraGWAS +AT1G01010 AT1G01020 2.39322646755088 AraNetv2_log-likelihood-score protein-protein-interaction_high-throughput_AraNet_v2 +AT1G01010 AT1G01030 2. AraNetv2_log-likelihood-score protein-protein-interaction_high-throughput_AraNet_v2 AT1G01010 AT1G01040 "2.39322646755088" AraNetv2_log-likelihood-score raNetv2-DC_ -AT1G01030 AT1G01050 25494618241936697 AraNetv2_log-likelihood-score AraNetv2-CX_pairwise-gene-coexpression -AT1G01050 AT1G01060 score! AraNetv2_log-likelihood-score AraNetv2-LC_lit-curated-ppi +AT1G01030 AT1G01050 25494618241936697 AraNetv2_log-likelihood-score pairwise-gene-coexpression_AraNet_v2 +AT1G01050 AT1G01060 score! AraNetv2_log-likelihood-score protein-protein-interaction_literature-curation_AraNet_v2 diff --git a/spec/test/djornl/missing_required_headers/edges.tsv b/spec/test/djornl/missing_required_headers/edges.tsv index 1d37c927..f824869a 100644 --- a/spec/test/djornl/missing_required_headers/edges.tsv +++ b/spec/test/djornl/missing_required_headers/edges.tsv @@ -1,9 +1,9 @@ node1 node2 edge edge_descrip edge_type -As2 AT1G01020 8.4 AraGWAS-Association_score AraGWAS-Phenotype_Associations -As2 AT1G01040 5.4 AraGWAS-Association_score AraGWAS-Phenotype_Associations -As75 AT1G01020 39.9 AraGWAS-Association_score AraGWAS-Phenotype_Associations -AT1G01010 AT1G01040 2.5 AraNetv2_log-likelihood-score AraNetv2-DC_domain-co-occurrence -AT1G01010 AT1G01040 170.5 AraNetv2_log-likelihood-score AraNetv2-LC_lit-curated-ppi -AT1G01030 AT1G01050 2.6 AraNetv2_log-likelihood-score AraNetv2-CX_pairwise-gene-coexpression -AT1G01050 AT1G01060 2.7 AraNetv2_log-likelihood-score AraNetv2-LC_lit-curated-ppi -AT1G01080 AT1G01090 2.8 AraNetv2_log-likelihood-score AraNetv2-LC_lit-curated-ppi +As2 AT1G01020 8.4 AraGWAS-Association_score phenotype-association_AraGWAS +As2 AT1G01040 5.4 AraGWAS-Association_score phenotype-association_AraGWAS +As75 AT1G01020 39.9 AraGWAS-Association_score phenotype-association_AraGWAS +AT1G01010 AT1G01040 2.5 AraNetv2_log-likelihood-score domain-co-occurrence_AraNet_v2 +AT1G01010 AT1G01040 170.5 AraNetv2_log-likelihood-score protein-protein-interaction_literature-curation_AraNet_v2 +AT1G01030 AT1G01050 2.6 AraNetv2_log-likelihood-score pairwise-gene-coexpression_AraNet_v2 +AT1G01050 AT1G01060 2.7 AraNetv2_log-likelihood-score protein-protein-interaction_literature-curation_AraNet_v2 +AT1G01080 AT1G01090 2.8 AraNetv2_log-likelihood-score protein-protein-interaction_literature-curation_AraNet_v2 diff --git a/spec/test/djornl/missing_required_headers/hithruput-edges.csv b/spec/test/djornl/missing_required_headers/hithruput-edges.csv index e4dbc008..e57fae35 100644 --- a/spec/test/djornl/missing_required_headers/hithruput-edges.csv +++ b/spec/test/djornl/missing_required_headers/hithruput-edges.csv @@ -1,3 +1,3 @@ node1,node2,score,edge_descrip,layer_descrip -AT1G01010,AT1G01020,2.3,AraNetv2_log-likelihood-score,AraNetv2-HT_high-throughput-ppi -AT1G01010,AT1G01030,2.4,AraNetv2_log-likelihood-score,AraNetv2-HT_high-throughput-ppi +AT1G01010,AT1G01020,2.3,AraNetv2_log-likelihood-score,protein-protein-interaction_high-throughput_AraNet_v2 +AT1G01010,AT1G01030,2.4,AraNetv2_log-likelihood-score,protein-protein-interaction_high-throughput_AraNet_v2 diff --git a/spec/test/djornl/results.json b/spec/test/djornl/results.json index 4771d764..eda91194 100644 --- a/spec/test/djornl/results.json +++ b/spec/test/djornl/results.json @@ -13,16 +13,16 @@ {"_key": "AT1G01090"} ], "edges": [ - {"_key": "As2__AT1G01020__AraGWAS-Phenotype_Associations__8.4", "_from": "djornl_node/As2", "_to": "djornl_node/AT1G01020", "edge_type": "AraGWAS-Phenotype_Associations", "score": 8.4}, - {"_key": "As2__AT1G01040__AraGWAS-Phenotype_Associations__5.4", "_from": "djornl_node/As2", "_to": "djornl_node/AT1G01040", "edge_type": "AraGWAS-Phenotype_Associations", "score": 5.4}, - {"_key": "As75__AT1G01020__AraGWAS-Phenotype_Associations__39.9", "_from": "djornl_node/As75", "_to": "djornl_node/AT1G01020", "edge_type": "AraGWAS-Phenotype_Associations", "score": 39.9}, - {"_key": "AT1G01010__AT1G01020__AraNetv2-HT_high-throughput-ppi__2.3", "_from": "djornl_node/AT1G01010", "_to": "djornl_node/AT1G01020", "edge_type": "AraNetv2-HT_high-throughput-ppi", "score": 2.3}, - {"_key": "AT1G01010__AT1G01030__AraNetv2-HT_high-throughput-ppi__2.4", "_from": "djornl_node/AT1G01010", "_to": "djornl_node/AT1G01030", "edge_type": "AraNetv2-HT_high-throughput-ppi", "score": 2.4}, - {"_key": "AT1G01010__AT1G01040__AraNetv2-DC_domain-co-occurrence__2.5", "_from": "djornl_node/AT1G01010", "_to": "djornl_node/AT1G01040", "edge_type": "AraNetv2-DC_domain-co-occurrence", "score": 2.5}, - {"_key": "AT1G01010__AT1G01040__AraNetv2-LC_lit-curated-ppi__170.5", "_from": "djornl_node/AT1G01010", "_to": "djornl_node/AT1G01040", "edge_type": "AraNetv2-LC_lit-curated-ppi", "score": 170.5}, - {"_key": "AT1G01030__AT1G01050__AraNetv2-CX_pairwise-gene-coexpression__2.6", "_from": "djornl_node/AT1G01030", "_to": "djornl_node/AT1G01050", "edge_type": "AraNetv2-CX_pairwise-gene-coexpression", "score": 2.6}, - {"_key": "AT1G01050__AT1G01060__AraNetv2-LC_lit-curated-ppi__2.7", "_from": "djornl_node/AT1G01050", "_to": "djornl_node/AT1G01060", "edge_type": "AraNetv2-LC_lit-curated-ppi", "score": 2.7}, - {"_key": "AT1G01080__AT1G01090__AraNetv2-LC_lit-curated-ppi__2.8", "_from": "djornl_node/AT1G01080", "_to": "djornl_node/AT1G01090", "edge_type": "AraNetv2-LC_lit-curated-ppi", "score": 2.8} + {"_key": "As2__AT1G01020__phenotype-association_AraGWAS__8.4", "_from": "djornl_node/As2", "_to": "djornl_node/AT1G01020", "edge_type": "phenotype-association_AraGWAS", "score": 8.4}, + {"_key": "As2__AT1G01040__phenotype-association_AraGWAS__5.4", "_from": "djornl_node/As2", "_to": "djornl_node/AT1G01040", "edge_type": "phenotype-association_AraGWAS", "score": 5.4}, + {"_key": "As75__AT1G01020__phenotype-association_AraGWAS__39.9", "_from": "djornl_node/As75", "_to": "djornl_node/AT1G01020", "edge_type": "phenotype-association_AraGWAS", "score": 39.9}, + {"_key": "AT1G01010__AT1G01020__protein-protein-interaction_high-throughput_AraNet_v2__2.3", "_from": "djornl_node/AT1G01010", "_to": "djornl_node/AT1G01020", "edge_type": "protein-protein-interaction_high-throughput_AraNet_v2", "score": 2.3}, + {"_key": "AT1G01010__AT1G01030__protein-protein-interaction_high-throughput_AraNet_v2__2.4", "_from": "djornl_node/AT1G01010", "_to": "djornl_node/AT1G01030", "edge_type": "protein-protein-interaction_high-throughput_AraNet_v2", "score": 2.4}, + {"_key": "AT1G01010__AT1G01040__domain-co-occurrence_AraNet_v2__2.5", "_from": "djornl_node/AT1G01010", "_to": "djornl_node/AT1G01040", "edge_type": "domain-co-occurrence_AraNet_v2", "score": 2.5}, + {"_key": "AT1G01010__AT1G01040__protein-protein-interaction_literature-curation_AraNet_v2__170.5", "_from": "djornl_node/AT1G01010", "_to": "djornl_node/AT1G01040", "edge_type": "protein-protein-interaction_literature-curation_AraNet_v2", "score": 170.5}, + {"_key": "AT1G01030__AT1G01050__pairwise-gene-coexpression_AraNet_v2__2.6", "_from": "djornl_node/AT1G01030", "_to": "djornl_node/AT1G01050", "edge_type": "pairwise-gene-coexpression_AraNet_v2", "score": 2.6}, + {"_key": "AT1G01050__AT1G01060__protein-protein-interaction_literature-curation_AraNet_v2__2.7", "_from": "djornl_node/AT1G01050", "_to": "djornl_node/AT1G01060", "edge_type": "protein-protein-interaction_literature-curation_AraNet_v2", "score": 2.7}, + {"_key": "AT1G01080__AT1G01090__protein-protein-interaction_literature-curation_AraNet_v2__2.8", "_from": "djornl_node/AT1G01080", "_to": "djornl_node/AT1G01090", "edge_type": "protein-protein-interaction_literature-curation_AraNet_v2", "score": 2.8} ] }, "load_clusters": { @@ -88,16 +88,16 @@ "SDV" ], "edges": [ - "As2__AT1G01020__AraGWAS-Phenotype_Associations__8.4", - "As2__AT1G01040__AraGWAS-Phenotype_Associations__5.4", - "As75__AT1G01020__AraGWAS-Phenotype_Associations__39.9", - "AT1G01010__AT1G01020__AraNetv2-HT_high-throughput-ppi__2.3", - "AT1G01010__AT1G01030__AraNetv2-HT_high-throughput-ppi__2.4", - "AT1G01010__AT1G01040__AraNetv2-DC_domain-co-occurrence__2.5", - "AT1G01010__AT1G01040__AraNetv2-LC_lit-curated-ppi__170.5", - "AT1G01030__AT1G01050__AraNetv2-CX_pairwise-gene-coexpression__2.6", - "AT1G01050__AT1G01060__AraNetv2-LC_lit-curated-ppi__2.7", - "AT1G01080__AT1G01090__AraNetv2-LC_lit-curated-ppi__2.8" + "As2__AT1G01020__phenotype-association_AraGWAS__8.4", + "As2__AT1G01040__phenotype-association_AraGWAS__5.4", + "As75__AT1G01020__phenotype-association_AraGWAS__39.9", + "AT1G01010__AT1G01020__protein-protein-interaction_high-throughput_AraNet_v2__2.3", + "AT1G01010__AT1G01030__protein-protein-interaction_high-throughput_AraNet_v2__2.4", + "AT1G01010__AT1G01040__domain-co-occurrence_AraNet_v2__2.5", + "AT1G01010__AT1G01040__protein-protein-interaction_literature-curation_AraNet_v2__170.5", + "AT1G01030__AT1G01050__pairwise-gene-coexpression_AraNet_v2__2.6", + "AT1G01050__AT1G01060__protein-protein-interaction_literature-curation_AraNet_v2__2.7", + "AT1G01080__AT1G01090__protein-protein-interaction_literature-curation_AraNet_v2__2.8" ] } }, @@ -139,21 +139,21 @@ "SDV" ], "edges": [ - "As2__AT1G01020__AraGWAS-Phenotype_Associations__8.4", - "As2__AT1G01040__AraGWAS-Phenotype_Associations__5.4", - "As75__AT1G01020__AraGWAS-Phenotype_Associations__39.9", - "AT1G01010__AT1G01020__AraNetv2-HT_high-throughput-ppi__2.3", - "AT1G01010__AT1G01030__AraNetv2-HT_high-throughput-ppi__2.4", - "AT1G01010__AT1G01040__AraNetv2-DC_domain-co-occurrence__2.5", - "AT1G01010__AT1G01040__AraNetv2-LC_lit-curated-ppi__170.5", - "AT1G01030__AT1G01050__AraNetv2-CX_pairwise-gene-coexpression__2.6", - "AT1G01050__AT1G01060__AraNetv2-LC_lit-curated-ppi__2.7", - "AT1G01080__AT1G01090__AraNetv2-LC_lit-curated-ppi__2.8" + "As2__AT1G01020__phenotype-association_AraGWAS__8.4", + "As2__AT1G01040__phenotype-association_AraGWAS__5.4", + "As75__AT1G01020__phenotype-association_AraGWAS__39.9", + "AT1G01010__AT1G01020__protein-protein-interaction_high-throughput_AraNet_v2__2.3", + "AT1G01010__AT1G01030__protein-protein-interaction_high-throughput_AraNet_v2__2.4", + "AT1G01010__AT1G01040__domain-co-occurrence_AraNet_v2__2.5", + "AT1G01010__AT1G01040__protein-protein-interaction_literature-curation_AraNet_v2__170.5", + "AT1G01030__AT1G01050__pairwise-gene-coexpression_AraNet_v2__2.6", + "AT1G01050__AT1G01060__protein-protein-interaction_literature-curation_AraNet_v2__2.7", + "AT1G01080__AT1G01090__protein-protein-interaction_literature-curation_AraNet_v2__2.8" ] } }, { - "params": {"edge_types": ["AraGWAS-Phenotype_Associations"]}, + "params": {"edge_types": ["phenotype-association_AraGWAS"]}, "results": { "nodes": [ "As2", @@ -172,14 +172,14 @@ "SDV" ], "edges": [ - "As2__AT1G01020__AraGWAS-Phenotype_Associations__8.4", - "As2__AT1G01040__AraGWAS-Phenotype_Associations__5.4", - "As75__AT1G01020__AraGWAS-Phenotype_Associations__39.9" + "As2__AT1G01020__phenotype-association_AraGWAS__8.4", + "As2__AT1G01040__phenotype-association_AraGWAS__5.4", + "As75__AT1G01020__phenotype-association_AraGWAS__39.9" ] } }, { - "params": {"edge_types": ["AraGWAS-Phenotype_Associations", "AraNetv2-HT_high-throughput-ppi", "AraNetv2-LC_lit-curated-ppi"]}, + "params": {"edge_types": ["phenotype-association_AraGWAS", "protein-protein-interaction_high-throughput_AraNet_v2", "protein-protein-interaction_literature-curation_AraNet_v2"]}, "results": { "nodes": [ "As2", @@ -198,14 +198,14 @@ "SDV" ], "edges": [ - "As2__AT1G01020__AraGWAS-Phenotype_Associations__8.4", - "As2__AT1G01040__AraGWAS-Phenotype_Associations__5.4", - "As75__AT1G01020__AraGWAS-Phenotype_Associations__39.9", - "AT1G01010__AT1G01020__AraNetv2-HT_high-throughput-ppi__2.3", - "AT1G01010__AT1G01030__AraNetv2-HT_high-throughput-ppi__2.4", - "AT1G01010__AT1G01040__AraNetv2-LC_lit-curated-ppi__170.5", - "AT1G01050__AT1G01060__AraNetv2-LC_lit-curated-ppi__2.7", - "AT1G01080__AT1G01090__AraNetv2-LC_lit-curated-ppi__2.8" + "As2__AT1G01020__phenotype-association_AraGWAS__8.4", + "As2__AT1G01040__phenotype-association_AraGWAS__5.4", + "As75__AT1G01020__phenotype-association_AraGWAS__39.9", + "AT1G01010__AT1G01020__protein-protein-interaction_high-throughput_AraNet_v2__2.3", + "AT1G01010__AT1G01030__protein-protein-interaction_high-throughput_AraNet_v2__2.4", + "AT1G01010__AT1G01040__protein-protein-interaction_literature-curation_AraNet_v2__170.5", + "AT1G01050__AT1G01060__protein-protein-interaction_literature-curation_AraNet_v2__2.7", + "AT1G01080__AT1G01090__protein-protein-interaction_literature-curation_AraNet_v2__2.8" ] } } @@ -267,10 +267,10 @@ "AT1G01040" ], "edges": [ - "AT1G01010__AT1G01020__AraNetv2-HT_high-throughput-ppi__2.3", - "AT1G01010__AT1G01030__AraNetv2-HT_high-throughput-ppi__2.4", - "AT1G01010__AT1G01040__AraNetv2-DC_domain-co-occurrence__2.5", - "AT1G01010__AT1G01040__AraNetv2-LC_lit-curated-ppi__170.5" + "AT1G01010__AT1G01020__protein-protein-interaction_high-throughput_AraNet_v2__2.3", + "AT1G01010__AT1G01030__protein-protein-interaction_high-throughput_AraNet_v2__2.4", + "AT1G01010__AT1G01040__domain-co-occurrence_AraNet_v2__2.5", + "AT1G01010__AT1G01040__protein-protein-interaction_literature-curation_AraNet_v2__170.5" ] } }, @@ -279,15 +279,15 @@ "results": { "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060"], "edges": [ - "As2__AT1G01020__AraGWAS-Phenotype_Associations__8.4", - "As2__AT1G01040__AraGWAS-Phenotype_Associations__5.4", - "As75__AT1G01020__AraGWAS-Phenotype_Associations__39.9", - "AT1G01010__AT1G01020__AraNetv2-HT_high-throughput-ppi__2.3", - "AT1G01010__AT1G01030__AraNetv2-HT_high-throughput-ppi__2.4", - "AT1G01010__AT1G01040__AraNetv2-DC_domain-co-occurrence__2.5", - "AT1G01010__AT1G01040__AraNetv2-LC_lit-curated-ppi__170.5", - "AT1G01030__AT1G01050__AraNetv2-CX_pairwise-gene-coexpression__2.6", - "AT1G01050__AT1G01060__AraNetv2-LC_lit-curated-ppi__2.7" + "As2__AT1G01020__phenotype-association_AraGWAS__8.4", + "As2__AT1G01040__phenotype-association_AraGWAS__5.4", + "As75__AT1G01020__phenotype-association_AraGWAS__39.9", + "AT1G01010__AT1G01020__protein-protein-interaction_high-throughput_AraNet_v2__2.3", + "AT1G01010__AT1G01030__protein-protein-interaction_high-throughput_AraNet_v2__2.4", + "AT1G01010__AT1G01040__domain-co-occurrence_AraNet_v2__2.5", + "AT1G01010__AT1G01040__protein-protein-interaction_literature-curation_AraNet_v2__170.5", + "AT1G01030__AT1G01050__pairwise-gene-coexpression_AraNet_v2__2.6", + "AT1G01050__AT1G01060__protein-protein-interaction_literature-curation_AraNet_v2__2.7" ] } }, @@ -296,15 +296,15 @@ "results": { "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060"], "edges": [ - "As2__AT1G01020__AraGWAS-Phenotype_Associations__8.4", - "As2__AT1G01040__AraGWAS-Phenotype_Associations__5.4", - "As75__AT1G01020__AraGWAS-Phenotype_Associations__39.9", - "AT1G01010__AT1G01020__AraNetv2-HT_high-throughput-ppi__2.3", - "AT1G01010__AT1G01030__AraNetv2-HT_high-throughput-ppi__2.4", - "AT1G01010__AT1G01040__AraNetv2-DC_domain-co-occurrence__2.5", - "AT1G01010__AT1G01040__AraNetv2-LC_lit-curated-ppi__170.5", - "AT1G01030__AT1G01050__AraNetv2-CX_pairwise-gene-coexpression__2.6", - "AT1G01050__AT1G01060__AraNetv2-LC_lit-curated-ppi__2.7" + "As2__AT1G01020__phenotype-association_AraGWAS__8.4", + "As2__AT1G01040__phenotype-association_AraGWAS__5.4", + "As75__AT1G01020__phenotype-association_AraGWAS__39.9", + "AT1G01010__AT1G01020__protein-protein-interaction_high-throughput_AraNet_v2__2.3", + "AT1G01010__AT1G01030__protein-protein-interaction_high-throughput_AraNet_v2__2.4", + "AT1G01010__AT1G01040__domain-co-occurrence_AraNet_v2__2.5", + "AT1G01010__AT1G01040__protein-protein-interaction_literature-curation_AraNet_v2__170.5", + "AT1G01030__AT1G01050__pairwise-gene-coexpression_AraNet_v2__2.6", + "AT1G01050__AT1G01060__protein-protein-interaction_literature-curation_AraNet_v2__2.7" ] } }, @@ -320,19 +320,19 @@ "results": { "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01070"], "edges": [ - "As2__AT1G01020__AraGWAS-Phenotype_Associations__8.4", - "As75__AT1G01020__AraGWAS-Phenotype_Associations__39.9", - "AT1G01010__AT1G01020__AraNetv2-HT_high-throughput-ppi__2.3" + "As2__AT1G01020__phenotype-association_AraGWAS__8.4", + "As75__AT1G01020__phenotype-association_AraGWAS__39.9", + "AT1G01010__AT1G01020__protein-protein-interaction_high-throughput_AraNet_v2__2.3" ] } }, { - "params": {"gene_keys": ["AT1G01020", "AT1G01070"], "distance": 1, "edge_types": ["AraGWAS-Phenotype_Associations"] }, + "params": {"gene_keys": ["AT1G01020", "AT1G01070"], "distance": 1, "edge_types": ["phenotype-association_AraGWAS"] }, "results": { "nodes": ["As2", "As75", "AT1G01020", "AT1G01070"], "edges": [ - "As2__AT1G01020__AraGWAS-Phenotype_Associations__8.4", - "As75__AT1G01020__AraGWAS-Phenotype_Associations__39.9" + "As2__AT1G01020__phenotype-association_AraGWAS__8.4", + "As75__AT1G01020__phenotype-association_AraGWAS__39.9" ] } }, @@ -341,15 +341,15 @@ "results": { "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060", "AT1G01070"], "edges": [ - "As2__AT1G01020__AraGWAS-Phenotype_Associations__8.4", - "As2__AT1G01040__AraGWAS-Phenotype_Associations__5.4", - "As75__AT1G01020__AraGWAS-Phenotype_Associations__39.9", - "AT1G01010__AT1G01020__AraNetv2-HT_high-throughput-ppi__2.3", - "AT1G01010__AT1G01030__AraNetv2-HT_high-throughput-ppi__2.4", - "AT1G01010__AT1G01040__AraNetv2-DC_domain-co-occurrence__2.5", - "AT1G01010__AT1G01040__AraNetv2-LC_lit-curated-ppi__170.5", - "AT1G01030__AT1G01050__AraNetv2-CX_pairwise-gene-coexpression__2.6", - "AT1G01050__AT1G01060__AraNetv2-LC_lit-curated-ppi__2.7" + "As2__AT1G01020__phenotype-association_AraGWAS__8.4", + "As2__AT1G01040__phenotype-association_AraGWAS__5.4", + "As75__AT1G01020__phenotype-association_AraGWAS__39.9", + "AT1G01010__AT1G01020__protein-protein-interaction_high-throughput_AraNet_v2__2.3", + "AT1G01010__AT1G01030__protein-protein-interaction_high-throughput_AraNet_v2__2.4", + "AT1G01010__AT1G01040__domain-co-occurrence_AraNet_v2__2.5", + "AT1G01010__AT1G01040__protein-protein-interaction_literature-curation_AraNet_v2__170.5", + "AT1G01030__AT1G01050__pairwise-gene-coexpression_AraNet_v2__2.6", + "AT1G01050__AT1G01060__protein-protein-interaction_literature-curation_AraNet_v2__2.7" ] } }, @@ -357,15 +357,15 @@ "params": { "gene_keys": ["AT1G01020", "AT1G01070"], "distance": 5, - "edge_types": ["AraNetv2-CX_pairwise-gene-coexpression", "AraNetv2-DC_domain-co-occurrence", "AraNetv2-HT_high-throughput-ppi"] + "edge_types": ["pairwise-gene-coexpression_AraNet_v2", "domain-co-occurrence_AraNet_v2", "protein-protein-interaction_high-throughput_AraNet_v2"] }, "results": { "nodes": ["AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01070"], "edges": [ - "AT1G01010__AT1G01020__AraNetv2-HT_high-throughput-ppi__2.3", - "AT1G01010__AT1G01030__AraNetv2-HT_high-throughput-ppi__2.4", - "AT1G01010__AT1G01040__AraNetv2-DC_domain-co-occurrence__2.5", - "AT1G01030__AT1G01050__AraNetv2-CX_pairwise-gene-coexpression__2.6" + "AT1G01010__AT1G01020__protein-protein-interaction_high-throughput_AraNet_v2__2.3", + "AT1G01010__AT1G01030__protein-protein-interaction_high-throughput_AraNet_v2__2.4", + "AT1G01010__AT1G01040__domain-co-occurrence_AraNet_v2__2.5", + "AT1G01030__AT1G01050__pairwise-gene-coexpression_AraNet_v2__2.6" ] } } @@ -412,8 +412,8 @@ "results": { "nodes": ["As2", "AT1G01020", "AT1G01040"], "edges": [ - "As2__AT1G01020__AraGWAS-Phenotype_Associations__8.4", - "As2__AT1G01040__AraGWAS-Phenotype_Associations__5.4" + "As2__AT1G01020__phenotype-association_AraGWAS__8.4", + "As2__AT1G01040__phenotype-association_AraGWAS__5.4" ] } }, @@ -422,15 +422,15 @@ "results": { "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060"], "edges": [ - "As2__AT1G01020__AraGWAS-Phenotype_Associations__8.4", - "As2__AT1G01040__AraGWAS-Phenotype_Associations__5.4", - "As75__AT1G01020__AraGWAS-Phenotype_Associations__39.9", - "AT1G01010__AT1G01020__AraNetv2-HT_high-throughput-ppi__2.3", - "AT1G01010__AT1G01030__AraNetv2-HT_high-throughput-ppi__2.4", - "AT1G01010__AT1G01040__AraNetv2-DC_domain-co-occurrence__2.5", - "AT1G01010__AT1G01040__AraNetv2-LC_lit-curated-ppi__170.5", - "AT1G01030__AT1G01050__AraNetv2-CX_pairwise-gene-coexpression__2.6", - "AT1G01050__AT1G01060__AraNetv2-LC_lit-curated-ppi__2.7" + "As2__AT1G01020__phenotype-association_AraGWAS__8.4", + "As2__AT1G01040__phenotype-association_AraGWAS__5.4", + "As75__AT1G01020__phenotype-association_AraGWAS__39.9", + "AT1G01010__AT1G01020__protein-protein-interaction_high-throughput_AraNet_v2__2.3", + "AT1G01010__AT1G01030__protein-protein-interaction_high-throughput_AraNet_v2__2.4", + "AT1G01010__AT1G01040__domain-co-occurrence_AraNet_v2__2.5", + "AT1G01010__AT1G01040__protein-protein-interaction_literature-curation_AraNet_v2__170.5", + "AT1G01030__AT1G01050__pairwise-gene-coexpression_AraNet_v2__2.6", + "AT1G01050__AT1G01060__protein-protein-interaction_literature-curation_AraNet_v2__2.7" ] } }, @@ -446,8 +446,8 @@ "results": { "nodes": ["As2", "Na23", "AT1G01020", "AT1G01040"], "edges": [ - "As2__AT1G01020__AraGWAS-Phenotype_Associations__8.4", - "As2__AT1G01040__AraGWAS-Phenotype_Associations__5.4" + "As2__AT1G01020__phenotype-association_AraGWAS__8.4", + "As2__AT1G01040__phenotype-association_AraGWAS__5.4" ] } }, @@ -456,15 +456,15 @@ "results": { "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060", "Na23"], "edges": [ - "As2__AT1G01020__AraGWAS-Phenotype_Associations__8.4", - "As2__AT1G01040__AraGWAS-Phenotype_Associations__5.4", - "As75__AT1G01020__AraGWAS-Phenotype_Associations__39.9", - "AT1G01010__AT1G01020__AraNetv2-HT_high-throughput-ppi__2.3", - "AT1G01010__AT1G01030__AraNetv2-HT_high-throughput-ppi__2.4", - "AT1G01010__AT1G01040__AraNetv2-DC_domain-co-occurrence__2.5", - "AT1G01010__AT1G01040__AraNetv2-LC_lit-curated-ppi__170.5", - "AT1G01030__AT1G01050__AraNetv2-CX_pairwise-gene-coexpression__2.6", - "AT1G01050__AT1G01060__AraNetv2-LC_lit-curated-ppi__2.7" + "As2__AT1G01020__phenotype-association_AraGWAS__8.4", + "As2__AT1G01040__phenotype-association_AraGWAS__5.4", + "As75__AT1G01020__phenotype-association_AraGWAS__39.9", + "AT1G01010__AT1G01020__protein-protein-interaction_high-throughput_AraNet_v2__2.3", + "AT1G01010__AT1G01030__protein-protein-interaction_high-throughput_AraNet_v2__2.4", + "AT1G01010__AT1G01040__domain-co-occurrence_AraNet_v2__2.5", + "AT1G01010__AT1G01040__protein-protein-interaction_literature-curation_AraNet_v2__170.5", + "AT1G01030__AT1G01050__pairwise-gene-coexpression_AraNet_v2__2.6", + "AT1G01050__AT1G01060__protein-protein-interaction_literature-curation_AraNet_v2__2.7" ] } }, @@ -479,7 +479,7 @@ "params": { "phenotype_keys": ["As2", "Na23"], "distance": 5, - "edge_types": ["AraNetv2-CX_pairwise-gene-coexpression", "AraNetv2-DC_domain-co-occurrence", "AraNetv2-HT_high-throughput-ppi", "AraNetv2-LC_lit-curated-ppi"] + "edge_types": ["pairwise-gene-coexpression_AraNet_v2", "domain-co-occurrence_AraNet_v2", "protein-protein-interaction_high-throughput_AraNet_v2", "protein-protein-interaction_literature-curation_AraNet_v2"] }, "results": { "nodes": ["As2", "Na23"], @@ -490,14 +490,14 @@ "params": { "phenotype_keys": ["As2", "Na23"], "distance": 5, - "edge_types": ["AraGWAS-Phenotype_Associations"] + "edge_types": ["phenotype-association_AraGWAS"] }, "results": { "nodes": ["As2", "As75", "AT1G01020", "AT1G01040", "Na23"], "edges": [ - "As2__AT1G01020__AraGWAS-Phenotype_Associations__8.4", - "As2__AT1G01040__AraGWAS-Phenotype_Associations__5.4", - "As75__AT1G01020__AraGWAS-Phenotype_Associations__39.9" + "As2__AT1G01020__phenotype-association_AraGWAS__8.4", + "As2__AT1G01040__phenotype-association_AraGWAS__5.4", + "As75__AT1G01020__phenotype-association_AraGWAS__39.9" ] } } @@ -545,10 +545,10 @@ "results": { "nodes": ["As2", "AT1G01010", "AT1G01040", "AT1G01080", "AT1G01090"], "edges": [ - "As2__AT1G01040__AraGWAS-Phenotype_Associations__5.4", - "AT1G01010__AT1G01040__AraNetv2-DC_domain-co-occurrence__2.5", - "AT1G01010__AT1G01040__AraNetv2-LC_lit-curated-ppi__170.5", - "AT1G01080__AT1G01090__AraNetv2-LC_lit-curated-ppi__2.8" + "As2__AT1G01040__phenotype-association_AraGWAS__5.4", + "AT1G01010__AT1G01040__domain-co-occurrence_AraNet_v2__2.5", + "AT1G01010__AT1G01040__protein-protein-interaction_literature-curation_AraNet_v2__170.5", + "AT1G01080__AT1G01090__protein-protein-interaction_literature-curation_AraNet_v2__2.8" ] } }, @@ -557,43 +557,43 @@ "results": { "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060", "AT1G01080", "AT1G01090"], "edges": [ - "As2__AT1G01020__AraGWAS-Phenotype_Associations__8.4", - "As2__AT1G01040__AraGWAS-Phenotype_Associations__5.4", - "As75__AT1G01020__AraGWAS-Phenotype_Associations__39.9", - "AT1G01010__AT1G01020__AraNetv2-HT_high-throughput-ppi__2.3", - "AT1G01010__AT1G01030__AraNetv2-HT_high-throughput-ppi__2.4", - "AT1G01010__AT1G01040__AraNetv2-DC_domain-co-occurrence__2.5", - "AT1G01010__AT1G01040__AraNetv2-LC_lit-curated-ppi__170.5", - "AT1G01030__AT1G01050__AraNetv2-CX_pairwise-gene-coexpression__2.6", - "AT1G01050__AT1G01060__AraNetv2-LC_lit-curated-ppi__2.7", - "AT1G01080__AT1G01090__AraNetv2-LC_lit-curated-ppi__2.8" + "As2__AT1G01020__phenotype-association_AraGWAS__8.4", + "As2__AT1G01040__phenotype-association_AraGWAS__5.4", + "As75__AT1G01020__phenotype-association_AraGWAS__39.9", + "AT1G01010__AT1G01020__protein-protein-interaction_high-throughput_AraNet_v2__2.3", + "AT1G01010__AT1G01030__protein-protein-interaction_high-throughput_AraNet_v2__2.4", + "AT1G01010__AT1G01040__domain-co-occurrence_AraNet_v2__2.5", + "AT1G01010__AT1G01040__protein-protein-interaction_literature-curation_AraNet_v2__170.5", + "AT1G01030__AT1G01050__pairwise-gene-coexpression_AraNet_v2__2.6", + "AT1G01050__AT1G01060__protein-protein-interaction_literature-curation_AraNet_v2__2.7", + "AT1G01080__AT1G01090__protein-protein-interaction_literature-curation_AraNet_v2__2.8" ] } }, { - "params": {"search_text": "GO:0005515", "distance": 0, "edge_types": ["AraGWAS-Phenotype_Associations"]}, + "params": {"search_text": "GO:0005515", "distance": 0, "edge_types": ["phenotype-association_AraGWAS"]}, "results": { "nodes": ["AT1G01040", "AT1G01090"], "edges": [] } }, { - "params": {"search_text": "GO:0005515", "distance": 1, "edge_types": ["AraGWAS-Phenotype_Associations"]}, + "params": {"search_text": "GO:0005515", "distance": 1, "edge_types": ["phenotype-association_AraGWAS"]}, "results": { "nodes": ["As2", "AT1G01040", "AT1G01090"], "edges": [ - "As2__AT1G01040__AraGWAS-Phenotype_Associations__5.4" + "As2__AT1G01040__phenotype-association_AraGWAS__5.4" ] } }, { - "params": {"search_text": "GO:0005515", "distance": 5, "edge_types": ["AraGWAS-Phenotype_Associations"]}, + "params": {"search_text": "GO:0005515", "distance": 5, "edge_types": ["phenotype-association_AraGWAS"]}, "results": { "nodes": ["As2", "As75", "AT1G01020", "AT1G01040", "AT1G01090"], "edges": [ - "As2__AT1G01020__AraGWAS-Phenotype_Associations__8.4", - "As2__AT1G01040__AraGWAS-Phenotype_Associations__5.4", - "As75__AT1G01020__AraGWAS-Phenotype_Associations__39.9" + "As2__AT1G01020__phenotype-association_AraGWAS__8.4", + "As2__AT1G01040__phenotype-association_AraGWAS__5.4", + "As75__AT1G01020__phenotype-association_AraGWAS__39.9" ] } } @@ -650,10 +650,10 @@ "results": { "nodes": ["As2", "AT1G01010", "AT1G01040", "AT1G01080", "AT1G01090"], "edges": [ - "As2__AT1G01040__AraGWAS-Phenotype_Associations__5.4", - "AT1G01010__AT1G01040__AraNetv2-DC_domain-co-occurrence__2.5", - "AT1G01010__AT1G01040__AraNetv2-LC_lit-curated-ppi__170.5", - "AT1G01080__AT1G01090__AraNetv2-LC_lit-curated-ppi__2.8" + "As2__AT1G01040__phenotype-association_AraGWAS__5.4", + "AT1G01010__AT1G01040__domain-co-occurrence_AraNet_v2__2.5", + "AT1G01010__AT1G01040__protein-protein-interaction_literature-curation_AraNet_v2__170.5", + "AT1G01080__AT1G01090__protein-protein-interaction_literature-curation_AraNet_v2__2.8" ] } }, @@ -662,16 +662,16 @@ "results": { "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060", "AT1G01080", "AT1G01090"], "edges": [ - "As2__AT1G01020__AraGWAS-Phenotype_Associations__8.4", - "As2__AT1G01040__AraGWAS-Phenotype_Associations__5.4", - "As75__AT1G01020__AraGWAS-Phenotype_Associations__39.9", - "AT1G01010__AT1G01020__AraNetv2-HT_high-throughput-ppi__2.3", - "AT1G01010__AT1G01030__AraNetv2-HT_high-throughput-ppi__2.4", - "AT1G01010__AT1G01040__AraNetv2-DC_domain-co-occurrence__2.5", - "AT1G01010__AT1G01040__AraNetv2-LC_lit-curated-ppi__170.5", - "AT1G01030__AT1G01050__AraNetv2-CX_pairwise-gene-coexpression__2.6", - "AT1G01050__AT1G01060__AraNetv2-LC_lit-curated-ppi__2.7", - "AT1G01080__AT1G01090__AraNetv2-LC_lit-curated-ppi__2.8" + "As2__AT1G01020__phenotype-association_AraGWAS__8.4", + "As2__AT1G01040__phenotype-association_AraGWAS__5.4", + "As75__AT1G01020__phenotype-association_AraGWAS__39.9", + "AT1G01010__AT1G01020__protein-protein-interaction_high-throughput_AraNet_v2__2.3", + "AT1G01010__AT1G01030__protein-protein-interaction_high-throughput_AraNet_v2__2.4", + "AT1G01010__AT1G01040__domain-co-occurrence_AraNet_v2__2.5", + "AT1G01010__AT1G01040__protein-protein-interaction_literature-curation_AraNet_v2__170.5", + "AT1G01030__AT1G01050__pairwise-gene-coexpression_AraNet_v2__2.6", + "AT1G01050__AT1G01060__protein-protein-interaction_literature-curation_AraNet_v2__2.7", + "AT1G01080__AT1G01090__protein-protein-interaction_literature-curation_AraNet_v2__2.8" ] } }, @@ -694,9 +694,9 @@ "results": { "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01070"], "edges": [ - "As2__AT1G01020__AraGWAS-Phenotype_Associations__8.4", - "As75__AT1G01020__AraGWAS-Phenotype_Associations__39.9", - "AT1G01010__AT1G01020__AraNetv2-HT_high-throughput-ppi__2.3" + "As2__AT1G01020__phenotype-association_AraGWAS__8.4", + "As75__AT1G01020__phenotype-association_AraGWAS__39.9", + "AT1G01010__AT1G01020__protein-protein-interaction_high-throughput_AraNet_v2__2.3" ] } }, @@ -705,15 +705,15 @@ "results": { "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060", "AT1G01070"], "edges": [ - "As2__AT1G01020__AraGWAS-Phenotype_Associations__8.4", - "As2__AT1G01040__AraGWAS-Phenotype_Associations__5.4", - "As75__AT1G01020__AraGWAS-Phenotype_Associations__39.9", - "AT1G01010__AT1G01020__AraNetv2-HT_high-throughput-ppi__2.3", - "AT1G01010__AT1G01030__AraNetv2-HT_high-throughput-ppi__2.4", - "AT1G01010__AT1G01040__AraNetv2-DC_domain-co-occurrence__2.5", - "AT1G01010__AT1G01040__AraNetv2-LC_lit-curated-ppi__170.5", - "AT1G01030__AT1G01050__AraNetv2-CX_pairwise-gene-coexpression__2.6", - "AT1G01050__AT1G01060__AraNetv2-LC_lit-curated-ppi__2.7" + "As2__AT1G01020__phenotype-association_AraGWAS__8.4", + "As2__AT1G01040__phenotype-association_AraGWAS__5.4", + "As75__AT1G01020__phenotype-association_AraGWAS__39.9", + "AT1G01010__AT1G01020__protein-protein-interaction_high-throughput_AraNet_v2__2.3", + "AT1G01010__AT1G01030__protein-protein-interaction_high-throughput_AraNet_v2__2.4", + "AT1G01010__AT1G01040__domain-co-occurrence_AraNet_v2__2.5", + "AT1G01010__AT1G01040__protein-protein-interaction_literature-curation_AraNet_v2__170.5", + "AT1G01030__AT1G01050__pairwise-gene-coexpression_AraNet_v2__2.6", + "AT1G01050__AT1G01060__protein-protein-interaction_literature-curation_AraNet_v2__2.7" ] } }, @@ -721,7 +721,7 @@ "params": { "cluster_ids": ["markov_i2:5", "markov_i6:2"], "distance": 0, - "edge_types": ["AraNetv2-HT_high-throughput-ppi"] + "edge_types": ["protein-protein-interaction_high-throughput_AraNet_v2"] }, "results": { "nodes": ["AT1G01020", "AT1G01070"], @@ -732,12 +732,12 @@ "params": { "cluster_ids": ["markov_i2:5", "markov_i6:2"], "distance": 1, - "edge_types": ["AraNetv2-HT_high-throughput-ppi"] + "edge_types": ["protein-protein-interaction_high-throughput_AraNet_v2"] }, "results": { "nodes": ["AT1G01010", "AT1G01020", "AT1G01070"], "edges": [ - "AT1G01010__AT1G01020__AraNetv2-HT_high-throughput-ppi__2.3" + "AT1G01010__AT1G01020__protein-protein-interaction_high-throughput_AraNet_v2__2.3" ] } }, @@ -745,13 +745,13 @@ "params": { "cluster_ids": ["markov_i2:5", "markov_i6:2"], "distance": 5, - "edge_types": ["AraNetv2-HT_high-throughput-ppi"] + "edge_types": ["protein-protein-interaction_high-throughput_AraNet_v2"] }, "results": { "nodes": ["AT1G01010", "AT1G01020", "AT1G01030", "AT1G01070"], "edges": [ - "AT1G01010__AT1G01020__AraNetv2-HT_high-throughput-ppi__2.3", - "AT1G01010__AT1G01030__AraNetv2-HT_high-throughput-ppi__2.4" + "AT1G01010__AT1G01020__protein-protein-interaction_high-throughput_AraNet_v2__2.3", + "AT1G01010__AT1G01030__protein-protein-interaction_high-throughput_AraNet_v2__2.4" ] } }, @@ -760,23 +760,23 @@ "cluster_ids": ["markov_i2:5", "markov_i6:2"], "distance": 5, "edge_types": [ - "AraGWAS-Phenotype_Associations", - "AraNetv2-HT_high-throughput-ppi", - "AraNetv2-LC_lit-curated-ppi", - "AraNetv2-CX_pairwise-gene-coexpression" + "phenotype-association_AraGWAS", + "protein-protein-interaction_high-throughput_AraNet_v2", + "protein-protein-interaction_literature-curation_AraNet_v2", + "pairwise-gene-coexpression_AraNet_v2" ] }, "results": { "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060", "AT1G01070"], "edges": [ - "As2__AT1G01020__AraGWAS-Phenotype_Associations__8.4", - "As2__AT1G01040__AraGWAS-Phenotype_Associations__5.4", - "As75__AT1G01020__AraGWAS-Phenotype_Associations__39.9", - "AT1G01010__AT1G01020__AraNetv2-HT_high-throughput-ppi__2.3", - "AT1G01010__AT1G01030__AraNetv2-HT_high-throughput-ppi__2.4", - "AT1G01010__AT1G01040__AraNetv2-LC_lit-curated-ppi__170.5", - "AT1G01030__AT1G01050__AraNetv2-CX_pairwise-gene-coexpression__2.6", - "AT1G01050__AT1G01060__AraNetv2-LC_lit-curated-ppi__2.7" + "As2__AT1G01020__phenotype-association_AraGWAS__8.4", + "As2__AT1G01040__phenotype-association_AraGWAS__5.4", + "As75__AT1G01020__phenotype-association_AraGWAS__39.9", + "AT1G01010__AT1G01020__protein-protein-interaction_high-throughput_AraNet_v2__2.3", + "AT1G01010__AT1G01030__protein-protein-interaction_high-throughput_AraNet_v2__2.4", + "AT1G01010__AT1G01040__protein-protein-interaction_literature-curation_AraNet_v2__170.5", + "AT1G01030__AT1G01050__pairwise-gene-coexpression_AraNet_v2__2.6", + "AT1G01050__AT1G01060__protein-protein-interaction_literature-curation_AraNet_v2__2.7" ] } } diff --git a/spec/test/djornl/test_data/edges.tsv b/spec/test/djornl/test_data/edges.tsv index 3fc69278..3762bc9d 100644 --- a/spec/test/djornl/test_data/edges.tsv +++ b/spec/test/djornl/test_data/edges.tsv @@ -1,9 +1,9 @@ node1 node2 score edge_descrip edge_type -As2 AT1G01020 8.4 AraGWAS-Association_score AraGWAS-Phenotype_Associations -As2 AT1G01040 5.4 AraGWAS-Association_score AraGWAS-Phenotype_Associations -As75 AT1G01020 39.9 AraGWAS-Association_score AraGWAS-Phenotype_Associations -AT1G01010 AT1G01040 2.5 AraNetv2_log-likelihood-score AraNetv2-DC_domain-co-occurrence -AT1G01010 AT1G01040 170.5 AraNetv2_log-likelihood-score AraNetv2-LC_lit-curated-ppi -AT1G01030 AT1G01050 2.6 AraNetv2_log-likelihood-score AraNetv2-CX_pairwise-gene-coexpression -AT1G01050 AT1G01060 2.7 AraNetv2_log-likelihood-score AraNetv2-LC_lit-curated-ppi -AT1G01080 AT1G01090 2.8 AraNetv2_log-likelihood-score AraNetv2-LC_lit-curated-ppi +As2 AT1G01020 8.4 AraGWAS-Association_score phenotype-association_AraGWAS +As2 AT1G01040 5.4 AraGWAS-Association_score phenotype-association_AraGWAS +As75 AT1G01020 39.9 AraGWAS-Association_score phenotype-association_AraGWAS +AT1G01010 AT1G01040 2.5 AraNetv2_log-likelihood-score domain-co-occurrence_AraNet_v2 +AT1G01010 AT1G01040 170.5 AraNetv2_log-likelihood-score protein-protein-interaction_literature-curation_AraNet_v2 +AT1G01030 AT1G01050 2.6 AraNetv2_log-likelihood-score pairwise-gene-coexpression_AraNet_v2 +AT1G01050 AT1G01060 2.7 AraNetv2_log-likelihood-score protein-protein-interaction_literature-curation_AraNet_v2 +AT1G01080 AT1G01090 2.8 AraNetv2_log-likelihood-score protein-protein-interaction_literature-curation_AraNet_v2 diff --git a/spec/test/djornl/test_data/hithruput-edges.csv b/spec/test/djornl/test_data/hithruput-edges.csv index cf771db2..fc27ac76 100644 --- a/spec/test/djornl/test_data/hithruput-edges.csv +++ b/spec/test/djornl/test_data/hithruput-edges.csv @@ -1,3 +1,3 @@ node1,node2,score,edge_descrip,edge_type -AT1G01010,AT1G01020,2.3,AraNetv2_log-likelihood-score,AraNetv2-HT_high-throughput-ppi -AT1G01010,AT1G01030,2.4,AraNetv2_log-likelihood-score,AraNetv2-HT_high-throughput-ppi +AT1G01010,AT1G01020,2.3,AraNetv2_log-likelihood-score,protein-protein-interaction_high-throughput_AraNet_v2 +AT1G01010,AT1G01030,2.4,AraNetv2_log-likelihood-score,protein-protein-interaction_high-throughput_AraNet_v2 From afd0a65fbf9e5da80a63264762111e8ee679795c Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Tue, 20 Oct 2020 11:11:16 -0700 Subject: [PATCH 624/732] Add some table of contents links in the spec readme --- spec/collections/README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/spec/collections/README.md b/spec/collections/README.md index d9b27976..82379e44 100644 --- a/spec/collections/README.md +++ b/spec/collections/README.md @@ -17,3 +17,16 @@ can also run `make test-schemas` or `make test-schema ` to test sch ## Resources - Quickly validate JSON schemas: https://www.jsonschemavalidator.net/ + +## Data + +### Ontologies + +* Gene Ontology (GO): **[go/](/spec/collections/GO)** +* Environmental Ontology (ENVO): **[envo/](/spec/collections/ENVO)** + +### Taxonomies + +* Genome Taxonomy Database (GTDB): **[gtdb/](/spec/collections/gtdb)** +* Ribosomal Database Project (RDP): **[rdp/](/spec/collections/rdp)** +* SILVA: **[silva/](/spec/collections/silva)** From cf17e3e33fcafa3357f7313c8802dcabbd16ba92 Mon Sep 17 00:00:00 2001 From: John Miller Date: Tue, 20 Oct 2020 16:43:57 -0400 Subject: [PATCH 625/732] Rename edges to put the connection first For more info see comment: https://github.com/kbase/relation_engine/pull/51#pullrequestreview-510484268 --- spec/datasets/djornl/edge_type.yaml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/spec/datasets/djornl/edge_type.yaml b/spec/datasets/djornl/edge_type.yaml index ab440612..558a5b05 100644 --- a/spec/datasets/djornl/edge_type.yaml +++ b/spec/datasets/djornl/edge_type.yaml @@ -4,51 +4,51 @@ title: Edge Type description: Edge types in Dan Jacobson Arabidopsis Exascale dataset type: string oneOf: - - const: AraGWAS-Phenotype_Associations + - const: phenotype-association_AraGWAS title: AraGWAS phenotype associations description: GWAS associations produced by analyzing a subset of phenotypes and SNPs in the Arabidopsis 1001 Genomes database. Edge values are significant association scores after FDR correction. - - const: AraNetv2-CX_pairwise-gene-coexpression + - const: pairwise-gene-coexpression_AraNet_v2 title: AraNetv2 pairwise gene coexpression description: A subset of pairwise gene coexpression values from the Arabidopsis AraNetv2 database. The LLS scores that serve as edge values were calculated from Pearson correlation coefficients to normalize the data for comparison across studies and different types of data layers (Lee et al, 2015). - - const: AraNetv2-DC_domain-co-occurrence + - const: domain-co-occurrence_AraNet_v2 title: AraNetv2 domain co-occurrence description: A layer of protein domain co-occurrence values from the Arabidopsis AraNetv2 database. The LLS scores that serve as edge values were calculated from weighted mutual information scores to normalize the data for comparison across studies and different types of data layers (Lee et al, 2015). - - const: AraNetv2-HT_high-throughput-ppi + - const: protein-protein-interaction_high-throughput_AraNet_v2 title: AraNetv2 high-throughput protein-protein interaction description: Log likelihood score. A layer of protein-protein interaction values derived from four high-throughput PPI screening experiments; from the Arabidopsis AraNetv2 database. The LLS scores that serve as edge values were calculated to normalize the data for comparison across studies and different types of data layers (Lee et al, 2015). - - const: AraNetv2-LC_lit-curated-ppi + - const: protein-protein-interaction_literature-curated_AraNet_v2 title: AraNetv2 literature-curated protein-protein interaction description: A layer of protein-protein interaction values from literature-curated small- to medium-scale experimental data; from the Arabidopsis AraNetv2 database. The LLS scores that serve as edge values were calculated to normalize the data for comparison across studies and different types of data layers (Lee et al, 2015). - - const: BIOGRID-ORGANISM-Arabidopsis-thaliana-Columbia-3-5-188-tab3_PPI + - const: protein-protein-interaction_biogrid_date/release3.5.188 title: BIOGRID ORGANISM Arabidopsis thaliana Columbia 3.5.188 tab3 PPI description: BioGRID interactions are relationships between two proteins or genes; the term “interaction” includes direct physical binding of two proteins, and co-existence in a stable complex and genetic interaction. see https://wiki.thebiogrid.org/doku.php/experimental_systems - - const: AtPIN_PPI + - const: protein-protein-interaction_AtPIN title: AtPIN PPI description: The interactions database includes all interactions present at the Arabidopsis thaliana Protein Interactome Database, the Predicted Interactome for Arabidopsis, Arabidopsis protein-protein interaction data curated from the literature by TAIR curators, BIOGRID and IntAct. https://atpin.bioinfoguy.net/cgi-bin/atpin.pl - - const: mentha-AT-3702-040319_PPI + - const: protein-protein-interaction_Mentha_A_thaliana_3702_040319 title: Mentha AT 3702 040319 PPI description: Mentha archives evidence collected from different sources and presents these data in a complete and comprehensive way. Its data comes from manually curated protein-protein interaction databases that have adhered to the IMEx consortium and assigns to each interaction a reliability score that takes into account all the supporting evidence. https://mentha.uniroma2.it/about.php - - const: aranetv2-subnet-AT-LC_PPI + - const: protein-protein-interaction_literature_curated_AraNet_v2_subnet title: AraNetv2 subnet AT-LC PPI description: Literature curated PPI of A. thaliana. https://www.inetbio.org/aranet/dl.php?f=AT-LC - - const: Wu2016-s015-Gene-to-Metab_GeneToPhenotype + - const: phenotype-association_GWAS_gene_to_metabolite_10.1371/journal.pgen.1006363 title: Wu2016 s015 Gene-to-Metab GeneToPhenotype description: GWAS hits ftom a Gene-to-Metaboiltes GWAS. Phenotypes (metabolites) have a unique ID from the Wu 2016 study and need to be given our own UID for future use. - - const: AraGWAS-subnet-permsig-geni_GeneToPhenotype + - const: phenotype-association_AraGWAS_subnet_permsig_geni title: AraGWAS subnet permsig geni GeneToPhenotype description: Phenotypes mapped to SNP position and GeneID if available from AraGWAS database filtered for overFDR threshold. - - const: ATRM-TF-to-Target-LitCurated-01082020_TranscriptionFactorToGene + - const: transcription-factor-regulatory-interaction_literature_curated_ATRM_01082020 title: ATRM TF to Target LitCurated 01082020 TranscriptionFactorToGene description: Contains literature mined and manually curated TF regulatory interactions for A.thaliana from 1701 TFFs from PlantTFDB 2.0 and 4663 TF-associated interactions. These were manually filtered (e.g. FPs, PPI interactions removed). They then added some from other sources. Downloaded from http://atrm.cbi.pku.edu.cn/download.php From 0c7f3eec06c0301b47eaf2c0153541aa92e99eb6 Mon Sep 17 00:00:00 2001 From: ialarmedalien Date: Thu, 19 Nov 2020 06:52:31 -0800 Subject: [PATCH 626/732] Moving conf and service conf inside method for easier mocking --- relation_engine_server/utils/wait_for.py | 44 +++++++++++++----------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/relation_engine_server/utils/wait_for.py b/relation_engine_server/utils/wait_for.py index b8d08031..42b84a74 100644 --- a/relation_engine_server/utils/wait_for.py +++ b/relation_engine_server/utils/wait_for.py @@ -7,19 +7,40 @@ from relation_engine_server.utils.config import get_config from typing import List -_CONF = get_config() + +def get_service_conf(): + + _CONF = get_config() + return { + 'arangodb': { + 'url': _CONF['api_url'] + '/collection', + 'callback': _assert_json_content, + 'raise_for_status': True, + }, + 'auth': { + 'url': _CONF['auth_url'], + }, + 'workspace': { + 'url': _CONF['workspace_url'], + }, + 'localhost': { + 'url': 'http://127.0.0.1:5000', + 'raise_for_status': True, + } + } def wait_for_service(service_list: List[str]) -> None: '''wait for a service or list of services to start up''' timeout = int(time.time()) + 60 services_pending = set(service_list) + service_conf = get_service_conf() while services_pending: still_pending = set() for name in services_pending: try: - conf = _SERVICE_CONF[name] + conf = service_conf[name] resp = requests.get(conf['url'], auth=conf.get('auth')) if conf.get('raise_for_status'): resp.raise_for_status() @@ -61,25 +82,6 @@ def _assert_json_content(resp: requests.models.Response) -> None: resp.json() -_SERVICE_CONF = { - 'arangodb': { - 'url': _CONF['api_url'] + '/collection', - 'callback': _assert_json_content, - 'raise_for_status': True, - }, - 'auth': { - 'url': _CONF['auth_url'], - }, - 'workspace': { - 'url': _CONF['workspace_url'], - }, - 'localhost': { - 'url': 'http://127.0.0.1:5000', - 'raise_for_status': True, - } -} - - if __name__ == '__main__': if sys.argv[1] == 'services': wait_for_services() From 3c8f0fa6fc4360e51e2edc1eb847b5d6d4310133 Mon Sep 17 00:00:00 2001 From: ialarmedalien Date: Thu, 19 Nov 2020 07:26:51 -0800 Subject: [PATCH 627/732] Adding black code formatter to dev requirements and running it prior to running the test suite. Adding the 2020 resolver to the pip command as suggested by pip warning messages --- Dockerfile | 4 +- client_src/relation_engine_client/__init__.py | 2 +- .../relation_engine_client/exceptions.py | 1 - client_src/relation_engine_client/main.py | 54 +- client_src/setup.py | 12 +- client_src/test/test_integration.py | 108 +-- dev-requirements.txt | 4 +- importers/djornl/parser.py | 326 ++++--- importers/test/test_djornl_parser.py | 316 ++++--- .../test/test_djornl_parser_integration.py | 7 +- importers/utils/config.py | 8 +- relation_engine_server/api_versions/api_v1.py | 180 ++-- relation_engine_server/main.py | 105 ++- relation_engine_server/test/test_api_v1.py | 768 ++++++++------- .../test/test_json_validation.py | 386 ++++---- .../test/test_spec_loader.py | 136 +-- relation_engine_server/utils/arango_client.py | 132 +-- relation_engine_server/utils/auth.py | 38 +- relation_engine_server/utils/bulk_import.py | 12 +- relation_engine_server/utils/config.py | 74 +- .../utils/json_validation.py | 37 +- relation_engine_server/utils/pull_spec.py | 40 +- relation_engine_server/utils/spec_loader.py | 56 +- relation_engine_server/utils/wait_for.py | 52 +- scripts/run_tests.sh | 2 + spec/test/collections/test_djornl.py | 55 +- spec/test/collections/test_silva.py | 338 ++++--- spec/test/helpers.py | 38 +- spec/test/stored_queries/test_djornl.py | 88 +- .../stored_queries/test_list_test_vertices.py | 55 +- spec/test/stored_queries/test_ncbi_tax.py | 630 ++++++++----- spec/test/stored_queries/test_taxonomy.py | 888 +++++++++++------- spec/test/stored_queries/test_ws.py | 125 ++- spec/test/test_manifest_schema.py | 55 +- spec/test/test_validate.py | 134 +-- spec/validate.py | 151 +-- 36 files changed, 3014 insertions(+), 2403 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7ba06bc0..6489905f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,8 +20,8 @@ RUN apk --update add --virtual build-dependencies curl tar gzip && \ # Install dependencies RUN apk --update add --virtual build-dependencies build-base python3-dev && \ pip install --upgrade pip && \ - pip install --no-cache-dir -r /tmp/requirements.txt && \ - if [ "$DEVELOPMENT" ]; then pip install --no-cache-dir -r /tmp/dev-requirements.txt; fi && \ + pip install --use-feature=2020-resolver --no-cache-dir -r /tmp/requirements.txt && \ + if [ "$DEVELOPMENT" ]; then pip install --use-feature=2020-resolver --no-cache-dir -r /tmp/dev-requirements.txt; fi && \ apk del build-dependencies COPY . /app diff --git a/client_src/relation_engine_client/__init__.py b/client_src/relation_engine_client/__init__.py index 939f6d1b..ac0de15e 100644 --- a/client_src/relation_engine_client/__init__.py +++ b/client_src/relation_engine_client/__init__.py @@ -1,3 +1,3 @@ from .main import REClient -__all__ = ['REClient'] +__all__ = ["REClient"] diff --git a/client_src/relation_engine_client/exceptions.py b/client_src/relation_engine_client/exceptions.py index c963acf4..58b29943 100644 --- a/client_src/relation_engine_client/exceptions.py +++ b/client_src/relation_engine_client/exceptions.py @@ -1,4 +1,3 @@ - class REServerError(Exception): """Server-originated error from RE API (ie. 500+)""" diff --git a/client_src/relation_engine_client/main.py b/client_src/relation_engine_client/main.py index 98d7400d..8ffa7017 100644 --- a/client_src/relation_engine_client/main.py +++ b/client_src/relation_engine_client/main.py @@ -4,14 +4,13 @@ from .exceptions import REServerError, RERequestError, RENotFound -_QUERY_METHOD = 'POST' -_QUERY_ENDPOINT = '/api/v1/query_results' -_SAVE_METHOD = 'PUT' -_SAVE_ENDPOINT = '/api/v1/documents' +_QUERY_METHOD = "POST" +_QUERY_ENDPOINT = "/api/v1/query_results" +_SAVE_METHOD = "PUT" +_SAVE_ENDPOINT = "/api/v1/documents" class REClient: - def __init__(self, api_url: str, token: str = None): self.api_url = api_url self.token = token @@ -19,7 +18,7 @@ def __init__(self, api_url: str, token: str = None): if not self.api_url or not isinstance(self.api_url, str): raise TypeError("The Relation Engine API URL was not provided.") # Remove any trailing slash in the API URL so we can append paths - self.api_url = self.api_url.strip('/') + self.api_url = self.api_url.strip("/") def admin_query(self, query: str, bind_vars: dict, raise_not_found=False): """ @@ -42,14 +41,15 @@ def admin_query(self, query: str, bind_vars: dict, raise_not_found=False): raise TypeError("`raise_not_found` argument must be a bool") # Construct and execute the request req_body = dict(bind_vars) - req_body['query'] = query + req_body["query"] = query url = str(self.api_url) + _QUERY_ENDPOINT resp = self._make_request( method=_QUERY_METHOD, url=url, data=json.dumps(req_body), params={}, - raise_not_found=raise_not_found) + raise_not_found=raise_not_found, + ) return resp def stored_query(self, stored_query: str, bind_vars: dict, raise_not_found=False): @@ -78,15 +78,17 @@ def stored_query(self, stored_query: str, bind_vars: dict, raise_not_found=False method=_QUERY_METHOD, url=url, data=json.dumps(req_body), - params={'stored_query': stored_query}, - raise_not_found=raise_not_found) + params={"stored_query": stored_query}, + raise_not_found=raise_not_found, + ) def save_docs( - self, - coll: str, - docs: Union[Dict, List[Dict]], - on_duplicate: Optional[str] = None, - display_errors=False): + self, + coll: str, + docs: Union[Dict, List[Dict]], + on_duplicate: Optional[str] = None, + display_errors=False, + ): """ Save documents to a collection in the relation engine. Requires an auth token with RE admin privileges. @@ -113,18 +115,19 @@ def save_docs( raise TypeError("`on_duplicate` argument must bea str") if not isinstance(display_errors, bool): raise TypeError("`display_errors` argument must be a bool") - params = {'collection': coll} + params = {"collection": coll} if display_errors: - params['display_errors'] = '1' - params['on_duplicate'] = on_duplicate or 'error' - req_body = '\n'.join(json.dumps(d) for d in docs) + params["display_errors"] = "1" + params["on_duplicate"] = on_duplicate or "error" + req_body = "\n".join(json.dumps(d) for d in docs) url = str(self.api_url) + _SAVE_ENDPOINT return self._make_request( method=_SAVE_METHOD, url=url, data=req_body, params=params, - raise_not_found=False) + raise_not_found=False, + ) def _make_request(self, method, url, data, params, raise_not_found): """ @@ -133,8 +136,10 @@ def _make_request(self, method, url, data, params, raise_not_found): """ headers = {} if self.token: - headers['Authorization'] = self.token - resp = requests.request(method=method, url=url, data=data, params=params, headers=headers) + headers["Authorization"] = self.token + resp = requests.request( + method=method, url=url, data=data, params=params, headers=headers + ) if resp.status_code >= 500: # Server error raise REServerError(resp) @@ -143,9 +148,10 @@ def _make_request(self, method, url, data, params, raise_not_found): raise RERequestError(resp) elif not resp.ok: raise RuntimeError( - f"Unknown RE API error:\nURL: {resp.url}\nMethod: {method}\n{resp.text}") + f"Unknown RE API error:\nURL: {resp.url}\nMethod: {method}\n{resp.text}" + ) resp_json = resp.json() - if raise_not_found and not len(resp_json['results']): + if raise_not_found and not len(resp_json["results"]): # Results were required to be non-empty raise RENotFound(req_body=data, req_params=params) return resp_json diff --git a/client_src/setup.py b/client_src/setup.py index 7a9d33d7..f6b4d08a 100644 --- a/client_src/setup.py +++ b/client_src/setup.py @@ -2,10 +2,10 @@ setup( - name='releng-client', - version='0.0.1', - description='KBase Relation Engine API Client Module', - url='https://github.com/kbase/relation_engine_api', - packages=['relation_engine_client'], - install_requires=['requests>=2'], + name="releng-client", + version="0.0.1", + description="KBase Relation Engine API Client Module", + url="https://github.com/kbase/relation_engine_api", + packages=["relation_engine_client"], + install_requires=["requests>=2"], ) diff --git a/client_src/test/test_integration.py b/client_src/test/test_integration.py index 40cf1bdb..baa17e97 100644 --- a/client_src/test/test_integration.py +++ b/client_src/test/test_integration.py @@ -5,16 +5,16 @@ from relation_engine_client import REClient from relation_engine_client.exceptions import RERequestError, RENotFound -_API_URL = os.environ.get('RE_API_URL', 'http://localhost:5000') +_API_URL = os.environ.get("RE_API_URL", "http://localhost:5000") # See the test schemas here: # https://github.com/kbase/relation_engine/tree/develop/spec/collections/test -_VERT_COLL = 'test_vertex' -_EDGE_COLL = 'test_edge' +_VERT_COLL = "test_vertex" +_EDGE_COLL = "test_edge" # See the docker-compose.yaml file in the root of this repo # See the mock auth endpoints in relation_engine_server/test/mock_auth/*.json -_TOK_ADMIN = 'admin_token' -_TOK_USER = 'non_admin_token' -_TOK_INVALID = 'invalid_token' +_TOK_ADMIN = "admin_token" +_TOK_USER = "non_admin_token" +_TOK_INVALID = "invalid_token" class TestREClientIntegration(unittest.TestCase): @@ -26,37 +26,37 @@ def setUpClass(cls): def test_admin_query_ok(self): _id = self._save_test_vert() - bind_vars = {'id': _id} + bind_vars = {"id": _id} query = f"FOR vert IN {_VERT_COLL} FILTER vert._key == @id RETURN vert" result = self.client.admin_query(query, bind_vars) - self.assertEqual(result['count'], 1) - self.assertEqual(result['results'][0]['_key'], _id) + self.assertEqual(result["count"], 1) + self.assertEqual(result["results"][0]["_key"], _id) def test_admin_query_empty_auth(self): client2 = REClient(_API_URL) query = f"FOR vert IN {_VERT_COLL} FILTER vert._key == @id RETURN vert" with self.assertRaises(RERequestError) as ctx: - client2.admin_query(query, {'id': 'xyz'}) + client2.admin_query(query, {"id": "xyz"}) self.assertEqual(ctx.exception.resp.status_code, 400) # Mostly make sure that the __str__ method does not throw any errs - self.assertTrue('Missing header: Authorization' in str(ctx.exception)) + self.assertTrue("Missing header: Authorization" in str(ctx.exception)) def test_admin_query_invalid_auth(self): - client2 = REClient(_API_URL, 'xyz') + client2 = REClient(_API_URL, "xyz") query = f"FOR vert IN {_VERT_COLL} FILTER vert._key == @id RETURN vert" with self.assertRaises(RERequestError) as ctx: - client2.admin_query(query, {'id': 'xyz'}) + client2.admin_query(query, {"id": "xyz"}) self.assertEqual(ctx.exception.resp.status_code, 403) # Mostly make sure that the __str__ method does not throw any errs - self.assertTrue('Unauthorized' in str(ctx.exception)) + self.assertTrue("Unauthorized" in str(ctx.exception)) def test_admin_empty_query(self): - bind_vars = {'id': 'xyz'} + bind_vars = {"id": "xyz"} with self.assertRaises(RERequestError) as ctx: self.client.admin_query("", bind_vars) self.assertEqual(ctx.exception.resp.status_code, 400) # Mostly make sure that the __str__ method does not throw any errs - self.assertTrue('Response:' in str(ctx.exception)) + self.assertTrue("Response:" in str(ctx.exception)) def test_admin_missing_param(self): query = f"FOR vert IN {_VERT_COLL} FILTER vert._key == @id RETURN vert" @@ -64,17 +64,17 @@ def test_admin_missing_param(self): self.client.admin_query(query, bind_vars={}) self.assertEqual(ctx.exception.resp.status_code, 400) # Mostly make sure that the __str__ method does not throw any errs - self.assertTrue('Response:' in str(ctx.exception)) + self.assertTrue("Response:" in str(ctx.exception)) def test_admin_raise_not_found(self): query = f"FOR vert IN {_VERT_COLL} FILTER vert._key == @id RETURN vert" _id = str(uuid4()) - bind_vars = {'id': _id} + bind_vars = {"id": _id} with self.assertRaises(RENotFound) as ctx: self.client.admin_query(query, bind_vars, raise_not_found=True) self.assertTrue(_id in ctx.exception.req_body) # Mostly make sure that the __str__ method does not throw any errs - self.assertTrue('Request body:' in str(ctx.exception)) + self.assertTrue("Request body:" in str(ctx.exception)) def test_admin_invalid_args(self): # No params @@ -89,11 +89,11 @@ def test_admin_invalid_args(self): def test_stored_query_ok(self): _id = self._save_test_vert() - bind_vars = {'key': _id} - qname = 'fetch_test_vertex' + bind_vars = {"key": _id} + qname = "fetch_test_vertex" result = self.client.stored_query(qname, bind_vars) - self.assertEqual(result['count'], 1) - self.assertEqual(result['results'][0]['_key'], _id) + self.assertEqual(result["count"], 1) + self.assertEqual(result["results"][0]["_key"], _id) def test_stored_query_invalid_args(self): with self.assertRaises(TypeError): @@ -104,58 +104,58 @@ def test_stored_query_invalid_args(self): self.client.stored_query("") def test_stored_query_unknown_query(self): - qname = 'xyz123' + qname = "xyz123" with self.assertRaises(RERequestError) as ctx: - self.client.admin_query(qname, bind_vars={'key': 0}) + self.client.admin_query(qname, bind_vars={"key": 0}) self.assertEqual(ctx.exception.resp.status_code, 400) # Mostly make sure that the __str__ method does not throw any errs - self.assertTrue('Response:' in str(ctx.exception)) + self.assertTrue("Response:" in str(ctx.exception)) def test_stored_query_missing_bind_vars(self): - qname = 'fetch_test_vertex' + qname = "fetch_test_vertex" with self.assertRaises(RERequestError) as ctx: - self.client.admin_query(qname, bind_vars={'x': 'y'}) + self.client.admin_query(qname, bind_vars={"x": "y"}) self.assertEqual(ctx.exception.resp.status_code, 400) # Mostly make sure that the __str__ method does not throw any errs - self.assertTrue('Response:' in str(ctx.exception)) + self.assertTrue("Response:" in str(ctx.exception)) def test_stored_query_raise_not_found(self): _id = str(uuid4()) - bind_vars = {'key': _id} - qname = 'fetch_test_vertex' + bind_vars = {"key": _id} + qname = "fetch_test_vertex" with self.assertRaises(RENotFound) as ctx: self.client.stored_query(qname, bind_vars, raise_not_found=True) self.assertTrue(_id in ctx.exception.req_body) # Mostly make sure that the __str__ method does not throw any errs - self.assertTrue('Request body:' in str(ctx.exception)) + self.assertTrue("Request body:" in str(ctx.exception)) def test_save_docs_ok(self): _id = str(uuid4()) - docs = [{'_key': _id}] + docs = [{"_key": _id}] results = self.client.save_docs(coll=_VERT_COLL, docs=docs) - self.assertEqual(results['created'], 1) - self.assertFalse(results['error']) - self.assertEqual(results['errors'], 0) - self.assertEqual(results['ignored'], 0) - self.assertEqual(results['updated'], 0) + self.assertEqual(results["created"], 1) + self.assertFalse(results["error"]) + self.assertEqual(results["errors"], 0) + self.assertEqual(results["ignored"], 0) + self.assertEqual(results["updated"], 0) def test_save_docs_empty_auth(self): client2 = REClient(_API_URL) - docs = [{'_key': 'xyz'}] + docs = [{"_key": "xyz"}] with self.assertRaises(RERequestError) as ctx: client2.save_docs(coll=_VERT_COLL, docs=docs) self.assertEqual(ctx.exception.resp.status_code, 400) # Mostly make sure that the __str__ method does not throw any errs - self.assertTrue('Missing header: Authorization' in str(ctx.exception)) + self.assertTrue("Missing header: Authorization" in str(ctx.exception)) def test_save_docs_invalid_auth(self): - client2 = REClient(_API_URL, 'xyz') - docs = [{'_key': 'xyz'}] + client2 = REClient(_API_URL, "xyz") + docs = [{"_key": "xyz"}] with self.assertRaises(RERequestError) as ctx: client2.save_docs(coll=_VERT_COLL, docs=docs) self.assertEqual(ctx.exception.resp.status_code, 403) # Mostly make sure that the __str__ method does not throw any errs - self.assertTrue('Unauthorized' in str(ctx.exception)) + self.assertTrue("Unauthorized" in str(ctx.exception)) def test_save_docs_invalid_args(self): with self.assertRaises(TypeError): @@ -168,35 +168,35 @@ def test_save_docs_invalid_args(self): def test_save_docs_unknown_coll(self): with self.assertRaises(RERequestError) as ctx: - self.client.save_docs('xyz123', [{'_key': 0}]) + self.client.save_docs("xyz123", [{"_key": 0}]) self.assertEqual(ctx.exception.resp.status_code, 404) self.assertEqual( ctx.exception.resp.json(), { - 'error': { - 'message': 'Not found', - 'details': "Collection 'xyz123' does not exist.", - 'name': 'xyz123', + "error": { + "message": "Not found", + "details": "Collection 'xyz123' does not exist.", + "name": "xyz123", } - } + }, ) # Mostly make sure that the __str__ method does not throw any errs - self.assertTrue('Response:' in str(ctx.exception)) + self.assertTrue("Response:" in str(ctx.exception)) def test_save_docs_invalid_docs(self): with self.assertRaises(RERequestError) as ctx: - self.client.save_docs(_VERT_COLL, [{'hi': 0}]) + self.client.save_docs(_VERT_COLL, [{"hi": 0}]) self.assertEqual(ctx.exception.resp.status_code, 400) # Mostly make sure that the __str__ method does not throw any errs - self.assertTrue('Response:' in str(ctx.exception)) + self.assertTrue("Response:" in str(ctx.exception)) # -- Test helpers def _save_test_vert(self): """Create a test vertex with a random & unique id.""" _id = str(uuid4()) - docs = [{'_key': _id}] + docs = [{"_key": _id}] results = self.client.save_docs(coll=_VERT_COLL, docs=docs) - if results['error']: + if results["error"]: raise RuntimeError(results) return _id diff --git a/dev-requirements.txt b/dev-requirements.txt index 399563a0..ca42c76e 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,6 +1,8 @@ -mypy==0.630 +mypy>=0.630 bandit==1.5.1 mccabe==0.6.1 flake8==3.5.0 grequests==0.3.0 coverage==5.2.1 +typed-ast>=1.4.0 +black==20.8b1 diff --git a/importers/djornl/parser.py b/importers/djornl/parser.py index 6607e0d2..c7b1b4b8 100644 --- a/importers/djornl/parser.py +++ b/importers/djornl/parser.py @@ -22,11 +22,13 @@ import yaml import importers.utils.config as config -from relation_engine_server.utils.json_validation import run_validator, get_schema_validator +from relation_engine_server.utils.json_validation import ( + run_validator, + get_schema_validator, +) class DJORNL_Parser(object): - def __init__(self): # dict of nodes, indexed by node ID (node1 and node2 from the file) @@ -35,33 +37,33 @@ def __init__(self): self.edge_ix = {} # the order in which to parse the different data files - self.parse_order = ['edges', 'nodes', 'clusters'] + self.parse_order = ["edges", "nodes", "clusters"] def config(self, value): - if not hasattr(self, '_config'): + if not hasattr(self, "_config"): self._configure() if value not in self._config: - raise KeyError(f'No such config value: {value}') + raise KeyError(f"No such config value: {value}") return self._config[value] def _configure(self): - configuration = config.load_from_env(extra_required=['ROOT_DATA_PATH']) + configuration = config.load_from_env(extra_required=["ROOT_DATA_PATH"]) # Collection name config - configuration['node_name'] = 'djornl_node' - configuration['edge_name'] = 'djornl_edge' + configuration["node_name"] = "djornl_node" + configuration["edge_name"] = "djornl_edge" # fetch the manifest and make sure all the files listed actually exist manifest = self._get_manifest(configuration) - for type in ['node', 'edge', 'cluster']: - configuration[type + '_files'] = [] + for type in ["node", "edge", "cluster"]: + configuration[type + "_files"] = [] error_list = [] - for file in manifest['file_list']: - file_path = os.path.join(configuration['ROOT_DATA_PATH'], file['path']) + for file in manifest["file_list"]: + file_path = os.path.join(configuration["ROOT_DATA_PATH"], file["path"]) if not os.path.exists(file_path): error_list.append(f"{file_path}: file does not exist") @@ -72,8 +74,8 @@ def _configure(self): continue # add the file to the appropriate list - file['file_path'] = file_path - configuration[file['data_type'] + '_files'].append(file) + file["file_path"] = file_path + configuration[file["data_type"] + "_files"].append(file) if error_list: raise RuntimeError("\n".join(error_list)) @@ -83,13 +85,15 @@ def _configure(self): def _get_manifest_schema_file(self): - return os.path.join(self._get_dataset_schema_dir(), 'manifest.schema.json') + return os.path.join(self._get_dataset_schema_dir(), "manifest.schema.json") def _get_dataset_schema_dir(self): - if not hasattr(self, '_dataset_schema_dir'): + if not hasattr(self, "_dataset_schema_dir"): dir_path = os.path.dirname(os.path.realpath(__file__)) - self._dataset_schema_dir = os.path.join(dir_path, '../', '../', 'spec', 'datasets', 'djornl') + self._dataset_schema_dir = os.path.join( + dir_path, "../", "../", "spec", "datasets", "djornl" + ) return self._dataset_schema_dir @@ -102,7 +106,7 @@ def _get_manifest(self, configuration): schema_file = self._get_manifest_schema_file() # load the manifest and validate it against the schema - manifest_file = os.path.join(configuration['ROOT_DATA_PATH'], 'manifest.yaml') + manifest_file = os.path.join(configuration["ROOT_DATA_PATH"], "manifest.yaml") try: with open(manifest_file) as fd: @@ -115,10 +119,7 @@ def _get_manifest(self, configuration): ) try: - validated_manifest = run_validator( - schema_file=schema_file, - data=manifest - ) + validated_manifest = run_validator(schema_file=schema_file, data=manifest) except Exception as err: print(err) raise RuntimeError( @@ -128,22 +129,26 @@ def _get_manifest(self, configuration): return validated_manifest def _get_file_reader(self, fd, file): - '''Given a dict containing file information, instantiate the correct type of parser''' - - delimiter = '\t' - if 'file_format' in file and file['file_format'].lower() == 'csv' or file['path'].lower().endswith('.csv'): - delimiter = ',' + """Given a dict containing file information, instantiate the correct type of parser""" + + delimiter = "\t" + if ( + "file_format" in file + and file["file_format"].lower() == "csv" + or file["path"].lower().endswith(".csv") + ): + delimiter = "," return csv.reader(fd, delimiter=delimiter) def parser_gen(self, file): """generator function to parse a file""" expected_col_count = 0 - with open(file['file_path'], newline='') as fd: + with open(file["file_path"], newline="") as fd: csv_reader = self._get_file_reader(fd, file) line_no = 0 for row in csv_reader: line_no += 1 - if not len(row) or row[0][0] == '#': + if not len(row) or row[0][0] == "#": # comment / metadata continue @@ -163,7 +168,7 @@ def parser_gen(self, file): # otherwise, this row does not have the correct number of columns col_count = len(cols) msg = f"expected {expected_col_count} cols, found {col_count}" - yield(line_no, None, f"{file['path']} line {line_no}: {msg}") + yield (line_no, None, f"{file['path']} line {line_no}: {msg}") def check_headers(self, headers, validator=None): """ @@ -199,19 +204,22 @@ def check_headers(self, headers, validator=None): duplicate_headers = [h for h in all_headers.keys() if all_headers[h] != 1] if duplicate_headers: - header_errs['duplicate'] = duplicate_headers + header_errs["duplicate"] = duplicate_headers # check that each required header in the schema is present in headers - required_props = validator.schema['required'] + required_props = validator.schema["required"] missing_headers = [i for i in required_props if i not in headers] if missing_headers: - header_errs['missing'] = missing_headers + header_errs["missing"] = missing_headers - if 'additionalProperties' in validator.schema and validator.schema['additionalProperties'] is False: - all_props = validator.schema['properties'].keys() + if ( + "additionalProperties" in validator.schema + and validator.schema["additionalProperties"] is False + ): + all_props = validator.schema["properties"].keys() extra_headers = [i for i in headers if i not in all_props] if extra_headers: - header_errs['invalid'] = extra_headers + header_errs["invalid"] = extra_headers return header_errs @@ -244,7 +252,7 @@ def remap_object(self, raw_data, remap_functions): return remapped_data def process_file(self, file, remap_fn, store_fn, err_list, validator=None): - """ process an input file to generate a dataset and possibly an error list + """process an input file to generate a dataset and possibly an error list Each valid line in the file is turned into a dictionary using the header row, and then validated against the csv validation schema in spec/datasets/djornl/csv_. @@ -266,7 +274,7 @@ def process_file(self, file, remap_fn, store_fn, err_list, validator=None): :param validator: (Validator) jsonschema validator object """ - print("Parsing " + file['data_type'] + " file " + file['file_path']) + print("Parsing " + file["data_type"] + " file " + file["file_path"]) file_parser = self.parser_gen(file) try: (line_no, cols, err_str) = next(file_parser) @@ -278,11 +286,11 @@ def process_file(self, file, remap_fn, store_fn, err_list, validator=None): header_errors = self.check_headers(cols, validator) if header_errors.keys(): err_str = { - 'duplicate': 'duplicate', - 'missing': 'missing required', - 'invalid': 'invalid additional', + "duplicate": "duplicate", + "missing": "missing required", + "invalid": "invalid additional", } - for err_type in ['missing', 'invalid', 'duplicate']: + for err_type in ["missing", "invalid", "duplicate"]: if err_type in header_errors: err_list.append( f"{file['path']}: {err_str[err_type]} headers: " @@ -345,11 +353,13 @@ def store_parsed_edge_data(self, datum): # there should only be one value for each node<->node edge of a given type, # so use these values as an index key # sort the nodes to ensure no dupes slip through - edge_key = "__".join([*sorted([datum['node1'], datum['node2']]), datum['edge_type']]) + edge_key = "__".join( + [*sorted([datum["node1"], datum["node2"]]), datum["edge_type"]] + ) if edge_key in self.edge_ix: # duplicate lines can be ignored - if datum['score'] == self.edge_ix[edge_key]['score']: + if datum["score"] == self.edge_ix[edge_key]["score"]: return None # report non-matching data return f"duplicate data for edge {edge_key}" @@ -370,26 +380,28 @@ def load_edges(self): # error accumulator err_list = [] - schema_file = os.path.join(self._get_dataset_schema_dir(), 'csv_edge.yaml') + schema_file = os.path.join(self._get_dataset_schema_dir(), "csv_edge.yaml") validator = get_schema_validator(schema_file=schema_file) - node_name = self.config('node_name') + node_name = self.config("node_name") # these functions remap the values in the columns of the input file to # appropriate values to go into Arango # note that the functions that assume the presence of a certain key in the input # can do so because that key is in a 'required' property in the CSV spec file remap_functions = { # create a unique key for each record - '_key': lambda row: '__'.join([row[_] for _ in ['node1', 'node2', 'edge_type', 'score']]), - 'node1': None, # this will be deleted in the 'store' step - 'node2': None, # as will this - '_from': lambda row: node_name + '/' + row['node1'], - '_to': lambda row: node_name + '/' + row['node2'], - 'score': lambda row: float(row['score']), - 'edge_type': None, + "_key": lambda row: "__".join( + [row[_] for _ in ["node1", "node2", "edge_type", "score"]] + ), + "node1": None, # this will be deleted in the 'store' step + "node2": None, # as will this + "_from": lambda row: node_name + "/" + row["node1"], + "_to": lambda row: node_name + "/" + row["node2"], + "score": lambda row: float(row["score"]), + "edge_type": None, } - for file in self.config('edge_files'): + for file in self.config("edge_files"): self.process_file( file=file, remap_fn=remap_functions, @@ -399,9 +411,9 @@ def load_edges(self): ) return { - 'nodes': self.node_ix.values(), - 'edges': self.edge_ix.values(), - 'err_list': err_list, + "nodes": self.node_ix.values(), + "edges": self.edge_ix.values(), + "err_list": err_list, } def _try_node_merge(self, existing_node, new_node, path=[]): @@ -431,7 +443,11 @@ def _try_node_merge(self, existing_node, new_node, path=[]): merge = {**existing_node, **new_node} # find the shared keys -- keys in both existing and new nodes where the values differ - shared_keys = [i for i in new_node if i in existing_node and new_node[i] != existing_node[i]] + shared_keys = [ + i + for i in new_node + if i in existing_node and new_node[i] != existing_node[i] + ] # if there were no shared keys, return the merged list if not shared_keys: @@ -448,7 +464,7 @@ def _try_node_merge(self, existing_node, new_node, path=[]): # do the types match? If not, these values cannot be merged if type(new_node[k]) != value_type: - err_list.append("/".join(path+[k])) + err_list.append("/".join(path + [k])) continue if value_type == list: @@ -461,7 +477,9 @@ def _try_node_merge(self, existing_node, new_node, path=[]): elif value_type == dict: # recursively check dict data using _try_node_merge - (k_merged, k_errs) = self._try_node_merge(existing_node[k], new_node[k], path+[k]) + (k_merged, k_errs) = self._try_node_merge( + existing_node[k], new_node[k], path + [k] + ) if k_errs: err_list = err_list + k_errs continue @@ -469,7 +487,7 @@ def _try_node_merge(self, existing_node, new_node, path=[]): else: # this is a scalar (string, number, etc.) so it can't be merged - err_list.append("/".join(path+[k])) + err_list.append("/".join(path + [k])) # at some point, it may be useful to examine these errors in more detail if err_list: @@ -483,18 +501,20 @@ def store_parsed_node_data(self, datum): If a node is already present, new data is checked for conflicts with existing data """ # check whether we have this node already - if datum['_key'] in self.node_ix: + if datum["_key"] in self.node_ix: # identical data: ignore it - if datum == self.node_ix[datum['_key']]: + if datum == self.node_ix[datum["_key"]]: return None # try merging the data - (merged, err_list) = self._try_node_merge(self.node_ix[datum['_key']], datum) + (merged, err_list) = self._try_node_merge( + self.node_ix[datum["_key"]], datum + ) if err_list: - return "duplicate data for node " + datum['_key'] + return "duplicate data for node " + datum["_key"] datum = merged - self.node_ix[datum['_key']] = datum + self.node_ix[datum["_key"]] = datum return None def load_nodes(self): @@ -502,41 +522,41 @@ def load_nodes(self): err_list = [] - schema_file = os.path.join(self._get_dataset_schema_dir(), 'csv_node.yaml') + schema_file = os.path.join(self._get_dataset_schema_dir(), "csv_node.yaml") validator = get_schema_validator(schema_file=schema_file) def go_terms(row): - if 'go_terms' in row and len(row['go_terms']): - return [c.strip() for c in row['go_terms'].split(',')] + if "go_terms" in row and len(row["go_terms"]): + return [c.strip() for c in row["go_terms"].split(",")] return [] remap_functions = { # these pass straight through - 'gene_full_name': None, - 'gene_model_type': None, - 'gene_symbol': None, - 'go_description': None, - 'mapman_bin': None, - 'mapman_description': None, - 'mapman_name': None, - 'node_type': None, - 'pheno_aragwas_id': None, - 'pheno_description': None, - 'pheno_pto_description': None, - 'pheno_pto_name': None, - 'pheno_reference': None, - 'tair_computational_description': None, - 'tair_curator_summary': None, - 'tair_short_description': None, - 'transcript': None, - 'user_notes': None, + "gene_full_name": None, + "gene_model_type": None, + "gene_symbol": None, + "go_description": None, + "mapman_bin": None, + "mapman_description": None, + "mapman_name": None, + "node_type": None, + "pheno_aragwas_id": None, + "pheno_description": None, + "pheno_pto_description": None, + "pheno_pto_name": None, + "pheno_reference": None, + "tair_computational_description": None, + "tair_curator_summary": None, + "tair_short_description": None, + "transcript": None, + "user_notes": None, # rename - '_key': lambda row: row['node_id'], + "_key": lambda row: row["node_id"], # see functions above - 'go_terms': go_terms, + "go_terms": go_terms, } - for file in self.config('node_files'): + for file in self.config("node_files"): self.process_file( file=file, remap_fn=remap_functions, @@ -546,8 +566,8 @@ def go_terms(row): ) return { - 'nodes': self.node_ix.values(), - 'err_list': err_list, + "nodes": self.node_ix.values(), + "err_list": err_list, } def store_parsed_cluster_data(self, datum): @@ -561,15 +581,15 @@ def store_parsed_cluster_data(self, datum): Cluster IDs are stored in the 'clusters' node attribute as a list, with new IDs added to (rather than replacing) existing IDs """ - cluster_id = datum['cluster_id'] + cluster_id = datum["cluster_id"] # gather a list of cluster IDs for each node - for node_id in datum['node_ids']: + for node_id in datum["node_ids"]: if node_id not in self.node_ix: - self.node_ix[node_id] = {'_key': node_id, 'clusters': [cluster_id]} - elif 'clusters' not in self.node_ix[node_id]: - self.node_ix[node_id]['clusters'] = [cluster_id] - elif cluster_id not in self.node_ix[node_id]['clusters']: - self.node_ix[node_id]['clusters'].append(cluster_id) + self.node_ix[node_id] = {"_key": node_id, "clusters": [cluster_id]} + elif "clusters" not in self.node_ix[node_id]: + self.node_ix[node_id]["clusters"] = [cluster_id] + elif cluster_id not in self.node_ix[node_id]["clusters"]: + self.node_ix[node_id]["clusters"].append(cluster_id) return None def load_clusters(self): @@ -577,19 +597,21 @@ def load_clusters(self): err_list = [] - schema_file = os.path.join(self._get_dataset_schema_dir(), 'csv_cluster.yaml') + schema_file = os.path.join(self._get_dataset_schema_dir(), "csv_cluster.yaml") validator = get_schema_validator(schema_file=schema_file) # these functions remap the values in the columns of the input file to # appropriate values to go into Arango # the 'cluster_id' remap function is assigned below on a per-file basis remap_functions = { - 'node_ids': lambda row: [n.strip() for n in row['node_ids'].split(',')] + "node_ids": lambda row: [n.strip() for n in row["node_ids"].split(",")] } - for file in self.config('cluster_files'): - prefix = file['cluster_prefix'] - remap_functions['cluster_id'] = lambda row: prefix + ':' + row['cluster_id'].replace('Cluster', '') + for file in self.config("cluster_files"): + prefix = file["cluster_prefix"] + remap_functions["cluster_id"] = ( + lambda row: prefix + ":" + row["cluster_id"].replace("Cluster", "") + ) self.process_file( file=file, @@ -600,51 +622,51 @@ def load_clusters(self): ) return { - 'nodes': list(self.node_ix.values()), - 'err_list': err_list, + "nodes": list(self.node_ix.values()), + "err_list": err_list, } def save_dataset(self, dataset=None): if dataset is None: dataset = { - 'nodes': list(self.node_ix.values()), - 'edges': list(self.edge_ix.values()), + "nodes": list(self.node_ix.values()), + "edges": list(self.edge_ix.values()), } - if 'nodes' in dataset and len(dataset['nodes']) > 0: - self.save_docs(self.config('node_name'), dataset['nodes']) + if "nodes" in dataset and len(dataset["nodes"]) > 0: + self.save_docs(self.config("node_name"), dataset["nodes"]) - if 'edges' in dataset and len(dataset['edges']) > 0: - self.save_docs(self.config('edge_name'), dataset['edges']) + if "edges" in dataset and len(dataset["edges"]) > 0: + self.save_docs(self.config("edge_name"), dataset["edges"]) - def save_docs(self, coll_name, docs, on_dupe='update'): + def save_docs(self, coll_name, docs, on_dupe="update"): resp = requests.put( - self.config('API_URL') + '/api/v1/documents', - params={'collection': coll_name, 'on_duplicate': on_dupe}, - headers={'Authorization': self.config('AUTH_TOKEN')}, - data='\n'.join(json.dumps(d) for d in docs) + self.config("API_URL") + "/api/v1/documents", + params={"collection": coll_name, "on_duplicate": on_dupe}, + headers={"Authorization": self.config("AUTH_TOKEN")}, + data="\n".join(json.dumps(d) for d in docs), ) if not resp.ok: raise RuntimeError(resp.text) print(f"Saved docs to collection {coll_name}!") print(resp.text) - print('=' * 80) + print("=" * 80) return resp def load_data(self, dry_run=False): all_errs = [] method_ix = { - 'clusters': self.load_clusters, - 'edges': self.load_edges, - 'nodes': self.load_nodes, + "clusters": self.load_clusters, + "edges": self.load_edges, + "nodes": self.load_nodes, } for data_type in self.parse_order: output = method_ix[data_type]() - if output['err_list']: - all_errs = all_errs + output['err_list'] + if output["err_list"]: + all_errs = all_errs + output["err_list"] if all_errs: raise RuntimeError("\n".join(all_errs)) @@ -663,56 +685,50 @@ def summarise_dataset(self): # go through the node index, checking for nodes that only have one attribute ('_key') or # were loaded from the clusters files, with their only attributes being '_key' and 'clusters' - node_type_ix = { - '__NO_TYPE__': 0 - } - node_data = { - 'key_only': [], - 'cluster': [], - 'full': [] - } + node_type_ix = {"__NO_TYPE__": 0} + node_data = {"key_only": [], "cluster": [], "full": []} for node in self.node_ix.values(): - if len(node.keys()) == 2 and 'clusters' in node: - node_data['cluster'].append(node) + if len(node.keys()) == 2 and "clusters" in node: + node_data["cluster"].append(node) elif len(node.keys()) == 1: - node_data['key_only'].append(node) + node_data["key_only"].append(node) else: - node_data['full'].append(node) + node_data["full"].append(node) - if 'node_type' in node: - if node['node_type'] in node_type_ix: - node_type_ix[node['node_type']] += 1 + if "node_type" in node: + if node["node_type"] in node_type_ix: + node_type_ix[node["node_type"]] += 1 else: - node_type_ix[node['node_type']] = 1 + node_type_ix[node["node_type"]] = 1 else: - node_type_ix['__NO_TYPE__'] += 1 + node_type_ix["__NO_TYPE__"] += 1 nodes_in_edge_ix = {} edge_type_ix = {} for edge in self.edge_ix.values(): - nodes_in_edge_ix[edge['_from']] = 1 - nodes_in_edge_ix[edge['_to']] = 1 - if edge['edge_type'] in edge_type_ix: - edge_type_ix[edge['edge_type']] += 1 + nodes_in_edge_ix[edge["_from"]] = 1 + nodes_in_edge_ix[edge["_to"]] = 1 + if edge["edge_type"] in edge_type_ix: + edge_type_ix[edge["edge_type"]] += 1 else: - edge_type_ix[edge['edge_type']] = 1 + edge_type_ix[edge["edge_type"]] = 1 return { - 'nodes_total': len(self.node_ix.keys()), - 'edges_total': len(self.edge_ix.keys()), - 'nodes_in_edge': len(nodes_in_edge_ix.keys()), - 'node_type_count': node_type_ix, - 'edge_type_count': edge_type_ix, - 'node_data_available': { - 'key_only': len(node_data['key_only']), - 'cluster': len(node_data['cluster']), - 'full': len(node_data['full']) + "nodes_total": len(self.node_ix.keys()), + "edges_total": len(self.edge_ix.keys()), + "nodes_in_edge": len(nodes_in_edge_ix.keys()), + "node_type_count": node_type_ix, + "edge_type_count": edge_type_ix, + "node_data_available": { + "key_only": len(node_data["key_only"]), + "cluster": len(node_data["cluster"]), + "full": len(node_data["full"]), }, } -if __name__ == '__main__': +if __name__ == "__main__": parser = DJORNL_Parser() try: parser.load_data() diff --git a/importers/test/test_djornl_parser.py b/importers/test/test_djornl_parser.py index 90a84967..186990ae 100644 --- a/importers/test/test_djornl_parser.py +++ b/importers/test/test_djornl_parser.py @@ -13,15 +13,14 @@ from importers.djornl.parser import DJORNL_Parser from spec.test.helpers import modified_environ -_TEST_DIR = '/app/spec/test' +_TEST_DIR = "/app/spec/test" class Test_DJORNL_Parser(unittest.TestCase): - @classmethod def setUpClass(cls): # import the results file - results_file = os.path.join(_TEST_DIR, 'djornl', 'results.json') + results_file = os.path.join(_TEST_DIR, "djornl", "results.json") with open(results_file) as fh: cls.json_data = json.load(fh) @@ -49,10 +48,7 @@ def test_errors(self, parser=None, errs={}): method = f"load_{data_type}" output = getattr(parser, method)() with self.subTest(data_type=data_type): - self.assertEqual( - output['err_list'], - errs[data_type] - ) + self.assertEqual(output["err_list"], errs[data_type]) with self.subTest(data_type="all types"): # test all errors @@ -63,28 +59,32 @@ def test_errors(self, parser=None, errs={}): self.assertEqual(err_list, all_errs) def test_missing_required_env_var(self): - '''test that the parser exits with code 1 if the RES_ROOT_DATA_PATH env var is not set''' - with self.assertRaisesRegex(RuntimeError, 'Missing required env var: RES_ROOT_DATA_PATH'): + """test that the parser exits with code 1 if the RES_ROOT_DATA_PATH env var is not set""" + with self.assertRaisesRegex( + RuntimeError, "Missing required env var: RES_ROOT_DATA_PATH" + ): parser = DJORNL_Parser() parser.load_edges() def test_config(self): - '''test that the parser raises an error if a config value cannot be found''' - RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, 'djornl', 'test_data') + """test that the parser raises an error if a config value cannot be found""" + RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, "djornl", "test_data") parser = self.init_parser_with_path(RES_ROOT_DATA_PATH) - with self.assertRaisesRegex(KeyError, 'No such config value: bananas'): - parser.config('bananas') + with self.assertRaisesRegex(KeyError, "No such config value: bananas"): + parser.config("bananas") def test_load_no_manifest(self): """ test loading when the manifest does not exist """ - RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, 'djornl', 'no_manifest') - err_str = 'No manifest file found at ' + os.path.join(RES_ROOT_DATA_PATH, 'manifest.yaml') + RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, "djornl", "no_manifest") + err_str = "No manifest file found at " + os.path.join( + RES_ROOT_DATA_PATH, "manifest.yaml" + ) with self.assertRaisesRegex(RuntimeError, err_str): self.init_parser_with_path(RES_ROOT_DATA_PATH) def test_load_invalid_manifest(self): """ test an invalid manifest file """ - RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, 'djornl', 'invalid_manifest') + RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, "djornl", "invalid_manifest") err_str = "The manifest file failed validation" with self.assertRaisesRegex(RuntimeError, err_str): self.init_parser_with_path(RES_ROOT_DATA_PATH) @@ -92,7 +92,7 @@ def test_load_invalid_manifest(self): def test_load_invalid_file(self): """ test loading when what is supposed to be a file is actually a directory """ - RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, 'djornl', 'invalid_file') + RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, "djornl", "invalid_file") # edges: directory, not a file err_str = os.path.join(RES_ROOT_DATA_PATH, "edges.tsv") + ": not a file" @@ -101,9 +101,11 @@ def test_load_invalid_file(self): def test_load_missing_files(self): """ test loading when files cannot be found """ - RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, 'djornl', 'missing_files') + RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, "djornl", "missing_files") # not found - err_str = os.path.join(RES_ROOT_DATA_PATH, "edges.tsv") + ': file does not exist' + err_str = ( + os.path.join(RES_ROOT_DATA_PATH, "edges.tsv") + ": file does not exist" + ) with self.assertRaisesRegex(RuntimeError, err_str): self.init_parser_with_path(RES_ROOT_DATA_PATH) @@ -111,50 +113,58 @@ def test_load_empty_files(self): """ test loading files containing no data """ # path: test/djornl/empty_files - RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, 'djornl', 'empty_files') + RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, "djornl", "empty_files") parser = self.init_parser_with_path(RES_ROOT_DATA_PATH) errs = { # mix of problems - 'clusters': [ - 'cluster_data/headers_only.tsv: no valid data found', - 'cluster_data/no_content.tsv: no header line found', - 'cluster_data/comment_only.tsv: no header line found', + "clusters": [ + "cluster_data/headers_only.tsv: no valid data found", + "cluster_data/no_content.tsv: no header line found", + "cluster_data/comment_only.tsv: no header line found", ], # comments only - 'edges': ['merged_edges-AMW-060820_AF.tsv: no header line found'], + "edges": ["merged_edges-AMW-060820_AF.tsv: no header line found"], # header only, no content - 'nodes': ['aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv: no valid data found'], + "nodes": [ + "aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv: no valid data found" + ], } self.test_errors(parser, errs) def test_load_missing_headers(self): """ test loading when files lack required headers """ - RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, 'djornl', 'missing_required_headers') + RES_ROOT_DATA_PATH = os.path.join( + _TEST_DIR, "djornl", "missing_required_headers" + ) parser = self.init_parser_with_path(RES_ROOT_DATA_PATH) def invalid_err(file_name, header_list): - return f"{file_name}: invalid additional headers: " + ", ".join(sorted(header_list)) + return f"{file_name}: invalid additional headers: " + ", ".join( + sorted(header_list) + ) def missing_err(file_name, header_list): - return f"{file_name}: missing required headers: " + ", ".join(sorted(header_list)) + return f"{file_name}: missing required headers: " + ", ".join( + sorted(header_list) + ) def dupe_err(file_name, header_list): return f"{file_name}: duplicate headers: " + ", ".join(sorted(header_list)) errs = { - 'clusters': [ + "clusters": [ # tuple containing file name and list of column headers missing in that file missing_err("I2_named.tsv", ["cluster_id", "node_ids"]), invalid_err("I2_named.tsv", ["cluster", "node_list"]), invalid_err("I4_named.tsv", ["other cool stuff"]), dupe_err("I6_named.tsv", ["node_ids"]), ], - 'edges': [ + "edges": [ missing_err("edges.tsv", ["score"]), - missing_err("hithruput-edges.csv", ["edge_type"]) + missing_err("hithruput-edges.csv", ["edge_type"]), ], - 'nodes': [ + "nodes": [ missing_err("extra_node.tsv", ["node_type"]), invalid_err("extra_node.tsv", ["node_types"]), missing_err("pheno_nodes.csv", ["node_id"]), @@ -167,26 +177,26 @@ def test_load_invalid_types(self): """ test file format errors """ # path: test/djornl/invalid_types - RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, 'djornl', 'invalid_types') + RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, "djornl", "invalid_types") parser = self.init_parser_with_path(RES_ROOT_DATA_PATH) errs = { # invalid edge type, invalid scores - 'edges': [ + "edges": [ r"edges.tsv line 3: 'Same-Old-Stuff' is not valid under any of the given schemas", r"edges.tsv line 7: '2.' does not match '^\\d+(\\.\\d+)?$'", r"edges.tsv line 8: 'raNetv2-DC_' is not valid under any of the given schemas", - r"edges.tsv line 10: 'score!' does not match '^\\d+(\\.\\d+)?$'" + r"edges.tsv line 10: 'score!' does not match '^\\d+(\\.\\d+)?$'", ], - 'nodes': [ + "nodes": [ # invalid node type r"nodes.csv line 5: 'Monkey' is not valid under any of the given schemas", - r"pheno_nodes.csv: no valid data found" + r"pheno_nodes.csv: no valid data found", ], - 'clusters': [ + "clusters": [ r"markov2_named.tsv line 7: 'HoneyNutCluster3' does not match '^Cluster\\d+$'", - r'markov2_named.tsv line 8: expected 2 cols, found 1', - ] + r"markov2_named.tsv line 8: expected 2 cols, found 1", + ], } self.test_errors(parser, errs) @@ -194,23 +204,23 @@ def test_load_col_count_errors(self): """ test files with invalid numbers of columns """ # path: test/djornl/col_count_errors - RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, 'djornl', 'col_count_errors') + RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, "djornl", "col_count_errors") parser = self.init_parser_with_path(RES_ROOT_DATA_PATH) errs = { - 'edges': [ - 'merged_edges-AMW-060820_AF.tsv line 6: expected 5 cols, found 3' + "edges": [ + "merged_edges-AMW-060820_AF.tsv line 6: expected 5 cols, found 3" + ], + "nodes": [ + "aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv line 3: expected 20 cols, found 22" ], - 'nodes': [ - 'aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv line 3: expected 20 cols, found 22' - ] } self.test_errors(parser, errs) def test_load_valid_edge_data(self): """ensure that valid edge data can be parsed""" - RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, 'djornl', 'test_data') + RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, "djornl", "test_data") parser = self.init_parser_with_path(RES_ROOT_DATA_PATH) edge_data = parser.load_edges() @@ -218,15 +228,15 @@ def test_load_valid_edge_data(self): for data_structure in [edge_data, expected]: for k in data_structure.keys(): - data_structure[k] = sorted(data_structure[k], key=lambda n: n['_key']) - expected['err_list'] = [] + data_structure[k] = sorted(data_structure[k], key=lambda n: n["_key"]) + expected["err_list"] = [] self.assertEqual(edge_data, expected) def test_load_valid_node_data(self): """ensure that valid node data can be parsed""" - RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, 'djornl', 'test_data') + RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, "djornl", "test_data") parser = self.init_parser_with_path(RES_ROOT_DATA_PATH) node_data = parser.load_nodes() @@ -234,40 +244,38 @@ def test_load_valid_node_data(self): for data_structure in [node_data, expected]: for k in data_structure.keys(): - data_structure[k] = sorted(data_structure[k], key=lambda n: n['_key']) - data_structure[k] = [n['_key'] for n in data_structure[k]] - expected['err_list'] = [] + data_structure[k] = sorted(data_structure[k], key=lambda n: n["_key"]) + data_structure[k] = [n["_key"] for n in data_structure[k]] + expected["err_list"] = [] self.assertEqual(node_data, expected) def test_load_valid_cluster_data(self): """ensure that valid cluster data can be parsed""" - RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, 'djornl', 'test_data') + RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, "djornl", "test_data") parser = self.init_parser_with_path(RES_ROOT_DATA_PATH) cluster_data = parser.load_clusters() expected = self.json_data["load_clusters"] - expected['err_list'] = [] + expected["err_list"] = [] self.assertEqual(cluster_data, expected) def test_duplicate_data(self): """ test files with duplicate data that should throw an error """ - RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, 'djornl', 'duplicate_data') + RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, "djornl", "duplicate_data") parser = self.init_parser_with_path(RES_ROOT_DATA_PATH) errs = { - 'edges': [ + "edges": [ "hithruput-edges.csv line 5: duplicate data for edge " + "AT1G01010__AT1G01030__protein-protein-interaction_high-throughput_AraNet_v2", "hithruput-edges.csv line 9: duplicate data for edge " - + "AT1G01030__AT1G01050__pairwise-gene-coexpression_AraNet_v2" - ], - 'nodes': [ - "extra_node.tsv line 5: duplicate data for node AT1G01080" + + "AT1G01030__AT1G01050__pairwise-gene-coexpression_AraNet_v2", ], + "nodes": ["extra_node.tsv line 5: duplicate data for node AT1G01080"], } self.test_errors(parser, errs) @@ -275,115 +283,171 @@ def test_duplicate_cluster_data(self): """ test files with duplicate cluster data, which should be seamlessly merged """ # path: test/djornl/col_count_errors - RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, 'djornl', 'duplicate_data') + RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, "djornl", "duplicate_data") parser = self.init_parser_with_path(RES_ROOT_DATA_PATH) cluster_data = parser.load_clusters() expected = self.json_data["load_clusters"] - expected['err_list'] = [] + expected["err_list"] = [] self.assertEqual(cluster_data, expected) def test_dry_run(self): - RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, 'djornl', 'test_data') + RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, "djornl", "test_data") parser = self.init_parser_with_path(RES_ROOT_DATA_PATH) output = parser.load_data(dry_run=True) self.assertEqual( { - 'edge_type_count': { - 'phenotype-association_AraGWAS': 3, - 'pairwise-gene-coexpression_AraNet_v2': 1, - 'domain-co-occurrence_AraNet_v2': 1, - 'protein-protein-interaction_high-throughput_AraNet_v2': 2, - 'protein-protein-interaction_literature-curation_AraNet_v2': 3 + "edge_type_count": { + "phenotype-association_AraGWAS": 3, + "pairwise-gene-coexpression_AraNet_v2": 1, + "domain-co-occurrence_AraNet_v2": 1, + "protein-protein-interaction_high-throughput_AraNet_v2": 2, + "protein-protein-interaction_literature-curation_AraNet_v2": 3, }, - 'edges_total': 10, - 'node_data_available': {'cluster': 0, 'full': 14, 'key_only': 0}, - 'node_type_count': {'__NO_TYPE__': 0, 'gene': 10, 'pheno': 4}, - 'nodes_in_edge': 10, - 'nodes_total': 14 + "edges_total": 10, + "node_data_available": {"cluster": 0, "full": 14, "key_only": 0}, + "node_type_count": {"__NO_TYPE__": 0, "gene": 10, "pheno": 4}, + "nodes_in_edge": 10, + "nodes_total": 14, }, - output + output, ) def test_try_node_merge(self): """test node merging""" - RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, 'djornl', 'test_data') + RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, "djornl", "test_data") parser = self.init_parser_with_path(RES_ROOT_DATA_PATH) tests = [ { - 'desc': 'existing node is just a _key', - 'old': {'_key': 'abcde'}, - 'new': {'_key': 'abcde', 'node_type': 'gene', 'node_quality': 'highest'}, - 'out': ({'_key': 'abcde', 'node_type': 'gene', 'node_quality': 'highest'}, []), + "desc": "existing node is just a _key", + "old": {"_key": "abcde"}, + "new": { + "_key": "abcde", + "node_type": "gene", + "node_quality": "highest", + }, + "out": ( + {"_key": "abcde", "node_type": "gene", "node_quality": "highest"}, + [], + ), }, { - 'desc': 'new node is just a _key', - 'old': {'_key': 'abcde', 'node_type': 'gene'}, - 'new': {'_key': 'abcde'}, - 'out': ({'_key': 'abcde', 'node_type': 'gene'}, []), + "desc": "new node is just a _key", + "old": {"_key": "abcde", "node_type": "gene"}, + "new": {"_key": "abcde"}, + "out": ({"_key": "abcde", "node_type": "gene"}, []), }, { - 'desc': 'no overlapping keys', - 'old': {'_key': 'abcde', 'node_type': 'gene'}, - 'new': {'_key': 'abcde', 'node_size': 24}, - 'out': ({'_key': 'abcde', 'node_type': 'gene', 'node_size': 24}, []), + "desc": "no overlapping keys", + "old": {"_key": "abcde", "node_type": "gene"}, + "new": {"_key": "abcde", "node_size": 24}, + "out": ({"_key": "abcde", "node_type": "gene", "node_size": 24}, []), }, { - 'desc': 'mergeable fields', - 'old': {'_key': 'abcde', 'go_terms': ['this', 'that'], 'colour': 'pink'}, - 'new': {'_key': 'abcde', 'go_terms': ['the other']}, - 'out': ({'_key': 'abcde', 'go_terms': ['this', 'that', 'the other'], 'colour': 'pink'}, []), + "desc": "mergeable fields", + "old": { + "_key": "abcde", + "go_terms": ["this", "that"], + "colour": "pink", + }, + "new": {"_key": "abcde", "go_terms": ["the other"]}, + "out": ( + { + "_key": "abcde", + "go_terms": ["this", "that", "the other"], + "colour": "pink", + }, + [], + ), }, { - 'desc': 'mergeable fields, removing list duplicates', - 'old': {'_key': 'abcde', 'go_terms': ['this', 'that', 'this', 'that', 'the'], 'colour': 'pink'}, - 'new': {'_key': 'abcde', 'go_terms': ['this', 'the', 'that', 'that', 'other', 'other']}, - 'out': ({'_key': 'abcde', 'go_terms': ['this', 'that', 'the', 'other'], 'colour': 'pink'}, []), + "desc": "mergeable fields, removing list duplicates", + "old": { + "_key": "abcde", + "go_terms": ["this", "that", "this", "that", "the"], + "colour": "pink", + }, + "new": { + "_key": "abcde", + "go_terms": ["this", "the", "that", "that", "other", "other"], + }, + "out": ( + { + "_key": "abcde", + "go_terms": ["this", "that", "the", "other"], + "colour": "pink", + }, + [], + ), }, { - 'desc': 'mergeable fields, complex list contents, removing list duplicates', - 'old': {'_key': 123, 'list': [{'a': 'b'}, {'a': 'b'}, {'c': 'd'}]}, - 'new': {'_key': 123, 'list': [{'a': 'b'}, {'a': 'c'}, {'c': 'd'}]}, - 'out': ({'_key': 123, 'list': [{'a': 'b'}, {'c': 'd'}, {'a': 'c'}]}, []), + "desc": "mergeable fields, complex list contents, removing list duplicates", + "old": {"_key": 123, "list": [{"a": "b"}, {"a": "b"}, {"c": "d"}]}, + "new": {"_key": 123, "list": [{"a": "b"}, {"a": "c"}, {"c": "d"}]}, + "out": ( + {"_key": 123, "list": [{"a": "b"}, {"c": "d"}, {"a": "c"}]}, + [], + ), }, { - 'desc': 'mergeable fields, no overlapping keys, nested version', - 'old': {'_key': 'abcde', 'type': 'gene', 'info': {'teeth': 16}}, - 'new': {'_key': 'abcde', 'size': 24, 'info': {'colour': 'pinkish'}}, - 'out': ({'_key': 'abcde', 'type': 'gene', 'size': 24, 'info': {'teeth': 16, 'colour': 'pinkish'}}, []), + "desc": "mergeable fields, no overlapping keys, nested version", + "old": {"_key": "abcde", "type": "gene", "info": {"teeth": 16}}, + "new": {"_key": "abcde", "size": 24, "info": {"colour": "pinkish"}}, + "out": ( + { + "_key": "abcde", + "type": "gene", + "size": 24, + "info": {"teeth": 16, "colour": "pinkish"}, + }, + [], + ), }, { - 'desc': 'single field error: duplicate', - 'old': {'_key': 'abcde', 'node_type': 'gene'}, - 'new': {'_key': 'abcde', 'node_type': 'pheno'}, - 'out': (None, ['node_type']), + "desc": "single field error: duplicate", + "old": {"_key": "abcde", "node_type": "gene"}, + "new": {"_key": "abcde", "node_type": "pheno"}, + "out": (None, ["node_type"]), }, { - 'desc': 'single field error: type mismatch', - 'old': {'_key': 'abcde', 'node_type': 'gene'}, - 'new': {'_key': 'abcde', 'node_type': ['pheno']}, - 'out': (None, ['node_type']), + "desc": "single field error: type mismatch", + "old": {"_key": "abcde", "node_type": "gene"}, + "new": {"_key": "abcde", "node_type": ["pheno"]}, + "out": (None, ["node_type"]), }, { - 'desc': 'multiple field errors', - 'old': {'_key': 'abcde', 'node_type': 'gene', 'shark': 'Jaws'}, - 'new': {'_key': 'abcde', 'node_type': 'pheno', 'shark': 'Loan', 'fish': 'guppy'}, - 'out': (None, ['node_type', 'shark']), + "desc": "multiple field errors", + "old": {"_key": "abcde", "node_type": "gene", "shark": "Jaws"}, + "new": { + "_key": "abcde", + "node_type": "pheno", + "shark": "Loan", + "fish": "guppy", + }, + "out": (None, ["node_type", "shark"]), }, { - 'desc': 'multiple field errors, nested dicts', - 'old': {'_key': 123, 'a': 'A', 'b': {'c': {'d': 'D'}, 'e': {}, 'f': 'F'}}, - 'new': {'_key': 123, 'a': 'A', 'b': {'c': {'d': ['D']}, 'e': 'E', 'f': 'f'}}, - 'out': (None, ['b/c/d', 'b/e', 'b/f']), - } + "desc": "multiple field errors, nested dicts", + "old": { + "_key": 123, + "a": "A", + "b": {"c": {"d": "D"}, "e": {}, "f": "F"}, + }, + "new": { + "_key": 123, + "a": "A", + "b": {"c": {"d": ["D"]}, "e": "E", "f": "f"}, + }, + "out": (None, ["b/c/d", "b/e", "b/f"]), + }, ] for t in tests: - with self.subTest(desc=t['desc']): - output = parser._try_node_merge(t['old'], t['new']) - self.assertEqual(output, t['out']) + with self.subTest(desc=t["desc"]): + output = parser._try_node_merge(t["old"], t["new"]) + self.assertEqual(output, t["out"]) diff --git a/importers/test/test_djornl_parser_integration.py b/importers/test/test_djornl_parser_integration.py index e7e758e8..fb184684 100644 --- a/importers/test/test_djornl_parser_integration.py +++ b/importers/test/test_djornl_parser_integration.py @@ -10,18 +10,19 @@ from importers.djornl.parser import DJORNL_Parser from spec.test.helpers import modified_environ, check_spec_test_env -_TEST_DIR = '/app/spec/test' +_TEST_DIR = "/app/spec/test" class Test_DJORNL_Parser_Integration(unittest.TestCase): - @classmethod def setUpClass(cls): check_spec_test_env() def test_the_full_shebang(self): - with modified_environ(RES_ROOT_DATA_PATH=os.path.join(_TEST_DIR, 'djornl', 'test_data')): + with modified_environ( + RES_ROOT_DATA_PATH=os.path.join(_TEST_DIR, "djornl", "test_data") + ): parser = DJORNL_Parser() parser.load_data() self.assertEqual(True, parser.load_data()) diff --git a/importers/utils/config.py b/importers/utils/config.py index 1f30080e..c5131b95 100644 --- a/importers/utils/config.py +++ b/importers/utils/config.py @@ -6,14 +6,14 @@ REQUIRED = [] -OPTIONAL = ['AUTH_TOKEN', 'API_URL'] +OPTIONAL = ["AUTH_TOKEN", "API_URL"] DEFAULTS = { - 'AUTH_TOKEN': 'admin_token', # test default - 'API_URL': 'http://localhost:5000', # test default + "AUTH_TOKEN": "admin_token", # test default + "API_URL": "http://localhost:5000", # test default } -def load_from_env(extra_required=None, extra_optional=None, prefix='RES_'): +def load_from_env(extra_required=None, extra_optional=None, prefix="RES_"): """Load all configuration vars from environment variables""" conf = dict(DEFAULTS) required = list(REQUIRED) + (extra_required or []) diff --git a/relation_engine_server/api_versions/api_v1.py b/relation_engine_server/api_versions/api_v1.py index dddeb42c..05561321 100644 --- a/relation_engine_server/api_versions/api_v1.py +++ b/relation_engine_server/api_versions/api_v1.py @@ -6,63 +6,65 @@ bulk_import, pull_spec, config, - parse_json + parse_json, ) from relation_engine_server.utils.json_validation import run_validator from relation_engine_server.exceptions import InvalidParameters -api_v1 = flask.Blueprint('api_v1', __name__) +api_v1 = flask.Blueprint("api_v1", __name__) -@api_v1.route("/data_sources", methods=['GET']) +@api_v1.route("/data_sources", methods=["GET"]) def list_data_sources(): # note the custom response format is used by the frontend, so this endpoint is provided # in addition to the /specs/data_sources endpoint - data_sources = spec_loader.get_names('data_sources') - return flask.jsonify({'data_sources': data_sources}) + data_sources = spec_loader.get_names("data_sources") + return flask.jsonify({"data_sources": data_sources}) -@api_v1.route("/data_sources/", methods=['GET']) +@api_v1.route("/data_sources/", methods=["GET"]) def fetch_data_source(name): - data_source = spec_loader.get_schema('data_source', name) - return flask.jsonify({'data_source': data_source}) + data_source = spec_loader.get_schema("data_source", name) + return flask.jsonify({"data_source": data_source}) -@api_v1.route('/specs/data_sources', methods=['GET']) +@api_v1.route("/specs/data_sources", methods=["GET"]) def show_data_sources(): """Show the current data sources loaded from the spec.""" - name = flask.request.args.get('name') + name = flask.request.args.get("name") if name: - return flask.jsonify(spec_loader.get_schema('data_source', name)) - return flask.jsonify(spec_loader.get_names('data_sources')) + return flask.jsonify(spec_loader.get_schema("data_source", name)) + return flask.jsonify(spec_loader.get_names("data_sources")) -@api_v1.route('/specs/stored_queries', methods=['GET']) +@api_v1.route("/specs/stored_queries", methods=["GET"]) def show_stored_queries(): """Show the current stored query names loaded from the spec.""" - name = flask.request.args.get('name') + name = flask.request.args.get("name") if name: - return flask.jsonify({'stored_query': spec_loader.get_schema('stored_query', name)}) - return flask.jsonify(spec_loader.get_names('stored_query')) + return flask.jsonify( + {"stored_query": spec_loader.get_schema("stored_query", name)} + ) + return flask.jsonify(spec_loader.get_names("stored_query")) -@api_v1.route('/specs/collections', methods=['GET']) -@api_v1.route('/specs/schemas', methods=['GET']) +@api_v1.route("/specs/collections", methods=["GET"]) +@api_v1.route("/specs/schemas", methods=["GET"]) def show_collections(): """Show the names of the (document) collections (edges and vertices) loaded from the spec.""" - name = flask.request.args.get('name') - doc_id = flask.request.args.get('doc_id') + name = flask.request.args.get("name") + doc_id = flask.request.args.get("doc_id") if name: - return flask.jsonify(spec_loader.get_schema('collection', name)) + return flask.jsonify(spec_loader.get_schema("collection", name)) elif doc_id: return flask.jsonify(spec_loader.get_schema_for_doc(doc_id)) else: - return flask.jsonify(spec_loader.get_names('collection')) + return flask.jsonify(spec_loader.get_names("collection")) -@api_v1.route('/query_results', methods=['POST']) +@api_v1.route("/query_results", methods=["POST"]) def run_query(): """ Run a stored query as a query against the database. @@ -72,115 +74,123 @@ def run_query(): """ json_body = parse_json.get_json_body() or {} # 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) + batch_size = int(flask.request.args.get("batch_size", 10000)) + full_count = flask.request.args.get("full_count", False) - if 'query' in json_body: + 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'] - if 'ws_ids' in query_text: + auth.require_auth_token(roles=["RE_ADMIN"]) + query_text = _preprocess_stored_query(json_body["query"], json_body) + del json_body["query"] + 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) + 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: + 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') + query_name = flask.request.args.get("stored_query") or flask.request.args.get( + "view" + ) stored_query = spec_loader.get_stored_query(query_name) - if 'params' in stored_query: + if "params" in stored_query: # Validate the user params for the query 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') - - stored_query_source = _preprocess_stored_query(stored_query['query'], stored_query) - if 'ws_ids' in stored_query_source: + run_validator( + schema_file=stored_query_path, data=json_body, validate_at="/params" + ) + + 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) + 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: + if "cursor_id" in flask.request.args: # Run a query from a cursor ID - cursor_id = flask.request.args['cursor_id'] + cursor_id = flask.request.args["cursor_id"] resp_body = arango_client.run_query(cursor_id=cursor_id) return flask.jsonify(resp_body) # No valid options were passed - raise InvalidParameters('Pass in a query name or a cursor_id') + raise InvalidParameters("Pass in a query name or a cursor_id") -@api_v1.route('/specs', methods=['PUT']) +@api_v1.route("/specs", methods=["PUT"]) def update_specs(): """ Manually check for updates, download spec releases, and init new collections. Auth: admin """ - auth.require_auth_token(['RE_ADMIN']) - init_collections = 'init_collections' in flask.request.args - release_url = flask.request.args.get('release_url') + auth.require_auth_token(["RE_ADMIN"]) + init_collections = "init_collections" in flask.request.args + release_url = flask.request.args.get("release_url") pull_spec.download_specs(init_collections, release_url, reset=True) - return flask.jsonify({'status': 'updated'}) + return flask.jsonify({"status": "updated"}) -@api_v1.route('/documents', methods=['PUT']) +@api_v1.route("/documents", methods=["PUT"]) def save_documents(): """ Create, update, or replace many documents in a batch. Auth: admin """ - auth.require_auth_token(['RE_ADMIN']) - collection_name = flask.request.args['collection'] - query = {'collection': collection_name, 'type': 'documents'} - if flask.request.args.get('display_errors'): + auth.require_auth_token(["RE_ADMIN"]) + collection_name = flask.request.args["collection"] + query = {"collection": collection_name, "type": "documents"} + if flask.request.args.get("display_errors"): # Display an array of error messages - query['details'] = 'true' - if flask.request.args.get('on_duplicate'): - query['onDuplicate'] = flask.request.args['on_duplicate'] - if flask.request.args.get('overwrite'): - query['overwrite'] = 'true' + query["details"] = "true" + if flask.request.args.get("on_duplicate"): + query["onDuplicate"] = flask.request.args["on_duplicate"] + if flask.request.args.get("overwrite"): + query["overwrite"] = "true" resp = bulk_import.bulk_import(query) - if resp.get('errors') > 0: + if resp.get("errors") > 0: return (flask.jsonify(resp), 400) else: return flask.jsonify(resp) -@api_v1.route('/config', methods=['GET']) +@api_v1.route("/config", methods=["GET"]) def show_config(): """Show public config data.""" conf = config.get_config() - return flask.jsonify({ - 'auth_url': conf['auth_url'], - 'workspace_url': conf['workspace_url'], - 'kbase_endpoint': conf['kbase_endpoint'], - 'db_url': conf['db_url'], - 'db_name': conf['db_name'], - 'spec_repo_url': conf['spec_repo_url'], - 'spec_release_url': conf['spec_release_url'], - 'spec_release_path': conf['spec_release_path'], - }) + return flask.jsonify( + { + "auth_url": conf["auth_url"], + "workspace_url": conf["workspace_url"], + "kbase_endpoint": conf["kbase_endpoint"], + "db_url": conf["db_url"], + "db_name": conf["db_name"], + "spec_repo_url": conf["spec_repo_url"], + "spec_release_url": conf["spec_release_url"], + "spec_release_path": conf["spec_release_path"], + } + ) 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 '\n'.join([ - config.get('query_prefix', ''), - ws_id_text, - query_text - ]) + ws_id_text = " LET ws_ids = @ws_ids " if "ws_ids" in query_text else "" + return "\n".join([config.get("query_prefix", ""), ws_id_text, query_text]) diff --git a/relation_engine_server/main.py b/relation_engine_server/main.py index 00a0c2f8..e359dc6b 100644 --- a/relation_engine_server/main.py +++ b/relation_engine_server/main.py @@ -7,15 +7,20 @@ from jsonschema.exceptions import ValidationError from relation_engine_server.api_versions.api_v1 import api_v1 -from relation_engine_server.exceptions import MissingHeader, UnauthorizedAccess, InvalidParameters, NotFound +from relation_engine_server.exceptions import ( + MissingHeader, + UnauthorizedAccess, + InvalidParameters, + NotFound, +) from relation_engine_server.utils.spec_loader import SchemaNonexistent from relation_engine_server.utils import arango_client app = flask.Flask(__name__) -app.config['DEBUG'] = os.environ.get('FLASK_DEBUG', True) -app.config['SECRET_KEY'] = os.environ.get('FLASK_SECRET_KEY', str(uuid4())) +app.config["DEBUG"] = os.environ.get("FLASK_DEBUG", True) +app.config["SECRET_KEY"] = os.environ.get("FLASK_SECRET_KEY", str(uuid4())) app.url_map.strict_slashes = False # allow both `get /v1/` and `get /v1` -app.register_blueprint(api_v1, url_prefix='/api/v1') +app.register_blueprint(api_v1, url_prefix="/api/v1") def return_error(error_dict, code): @@ -32,23 +37,23 @@ def return_error(error_dict, code): This helper wraps the whole structure in an extra dict under the key 'error'. """ - return (flask.jsonify({'error': error_dict}), code) + return (flask.jsonify({"error": error_dict}), code) -@app.route('/', methods=['GET']) +@app.route("/", methods=["GET"]) def root(): """Server status.""" - if os.path.exists('.git/refs/heads/master'): - with open('.git/refs/heads/master', 'r') as fd: + if os.path.exists(".git/refs/heads/master"): + with open(".git/refs/heads/master", "r") as fd: commit_hash = fd.read().strip() else: - commit_hash = 'unknown' + commit_hash = "unknown" arangodb_status = arango_client.server_status() - repo_url = 'https://github.com/kbase/relation_engine_api.git' + repo_url = "https://github.com/kbase/relation_engine_api.git" body = { - 'arangodb_status': arangodb_status, - 'commit_hash': commit_hash, - 'repo_url': repo_url + "arangodb_status": arangodb_status, + "commit_hash": commit_hash, + "repo_url": repo_url, } return flask.jsonify(body) @@ -57,11 +62,11 @@ def root(): def json_decode_error(err): """A problem parsing json.""" resp = { - 'message': 'Unable to parse JSON', - 'source_json': err.doc, - 'pos': err.pos, - 'lineno': err.lineno, - 'colno': err.colno, + "message": "Unable to parse JSON", + "source_json": err.doc, + "pos": err.pos, + "lineno": err.lineno, + "colno": err.colno, } return return_error(resp, 400) @@ -69,8 +74,8 @@ def json_decode_error(err): @app.errorhandler(arango_client.ArangoServerError) def arango_server_error(err): resp = { - 'message': str(err), - 'arango_message': err.resp_json['errorMessage'], + "message": str(err), + "arango_message": err.resp_json["errorMessage"], } return return_error(resp, 400) @@ -80,7 +85,7 @@ def arango_server_error(err): @app.errorhandler(InvalidParameters) def generic_400(err): resp = { - 'message': str(err), + "message": str(err), } return return_error(resp, 400) @@ -91,10 +96,10 @@ def validation_error(err): # Refer to the documentation on jsonschema.exceptions.ValidationError: # https://python-jsonschema.readthedocs.io/en/stable/errors/ resp = { - 'message': err.message, - 'failed_validator': err.validator, - 'value': err.instance, - 'path': list(err.absolute_path), + "message": err.message, + "failed_validator": err.validator, + "value": err.instance, + "path": list(err.absolute_path), } return return_error(resp, 400) @@ -102,9 +107,9 @@ def validation_error(err): @app.errorhandler(UnauthorizedAccess) def unauthorized_access(err): resp = { - 'message': 'Unauthorized', - 'auth_url': err.auth_url, - 'auth_response': err.response, + "message": "Unauthorized", + "auth_url": err.auth_url, + "auth_response": err.response, } return return_error(resp, 403) @@ -113,9 +118,9 @@ def unauthorized_access(err): def schema_does_not_exist(err): """General error cases.""" resp = { - 'message': 'Not found', - 'details': str(err), - 'name': err.name, + "message": "Not found", + "details": str(err), + "name": err.name, } return return_error(resp, 404) @@ -124,17 +129,17 @@ def schema_does_not_exist(err): @app.errorhandler(404) def page_not_found(err): resp = { - 'message': 'Not found', + "message": "Not found", } - if hasattr(err, 'details'): - resp['details'] = err.details + if hasattr(err, "details"): + resp["details"] = err.details return return_error(resp, 404) @app.errorhandler(405) def method_not_allowed(err): resp = { - 'message': 'Method not allowed', + "message": "Method not allowed", } return return_error(resp, 405) @@ -143,29 +148,29 @@ def method_not_allowed(err): @app.errorhandler(Exception) @app.errorhandler(500) def server_error(err): - print('=' * 80) - print('500 Unexpected Server Error') - print('-' * 80) + print("=" * 80) + print("500 Unexpected Server Error") + print("-" * 80) traceback.print_exc() - print('=' * 80) - resp = { - 'message': 'Unexpected server error' - } + print("=" * 80) + resp = {"message": "Unexpected server error"} # TODO only set below two fields in dev mode - resp['class'] = err.__class__.__name__ - resp['details'] = str(err) + resp["class"] = err.__class__.__name__ + resp["details"] = str(err) return return_error(resp, 500) @app.after_request def after_request(resp): # Log request - print(' '.join([flask.request.method, flask.request.path, '->', resp.status])) + print(" ".join([flask.request.method, flask.request.path, "->", resp.status])) # Enable CORS - resp.headers['Access-Control-Allow-Origin'] = '*' - env_allowed_headers = os.environ.get('HTTP_ACCESS_CONTROL_REQUEST_HEADERS', 'Authorization, Content-Type') - resp.headers['Access-Control-Allow-Headers'] = env_allowed_headers + resp.headers["Access-Control-Allow-Origin"] = "*" + env_allowed_headers = os.environ.get( + "HTTP_ACCESS_CONTROL_REQUEST_HEADERS", "Authorization, Content-Type" + ) + resp.headers["Access-Control-Allow-Headers"] = env_allowed_headers # Set JSON content type and response length - resp.headers['Content-Type'] = 'application/json' - resp.headers['Content-Length'] = resp.calculate_content_length() + resp.headers["Content-Type"] = "application/json" + resp.headers["Content-Length"] = resp.calculate_content_length() return resp diff --git a/relation_engine_server/test/test_api_v1.py b/relation_engine_server/test/test_api_v1.py index b754211f..1afdc896 100644 --- a/relation_engine_server/test/test_api_v1.py +++ b/relation_engine_server/test/test_api_v1.py @@ -13,58 +13,76 @@ _CONF = get_config() # Use the mock auth tokens -NON_ADMIN_TOKEN = 'non_admin_token' -ADMIN_TOKEN = 'admin_token' -INVALID_TOKEN = 'invalid_token' +NON_ADMIN_TOKEN = "non_admin_token" +ADMIN_TOKEN = "admin_token" +INVALID_TOKEN = "invalid_token" # Use the docker-compose url of the running flask server -URL = os.environ.get('TEST_URL', 'http://localhost:5000') -VERSION = 'v1' -API_URL = '/'.join([URL, 'api', VERSION]) +URL = os.environ.get("TEST_URL", "http://localhost:5000") +VERSION = "v1" +API_URL = "/".join([URL, "api", VERSION]) -HEADERS_NON_ADMIN = {'Authorization': 'Bearer ' + NON_ADMIN_TOKEN, 'Content-Type': 'application/json'} -HEADERS_ADMIN = {'Authorization': 'Bearer ' + ADMIN_TOKEN, 'Content-Type': 'application/json'} +HEADERS_NON_ADMIN = { + "Authorization": "Bearer " + NON_ADMIN_TOKEN, + "Content-Type": "application/json", +} +HEADERS_ADMIN = { + "Authorization": "Bearer " + ADMIN_TOKEN, + "Content-Type": "application/json", +} def create_test_docs(count): """Produce some test documents.""" + def doc(i): return '{"name": "name", "_key": "%s", "is_public": true}' % i - return '\n'.join(doc(i) for i in range(0, count)) + + return "\n".join(doc(i) for i in range(0, count)) def create_test_edges(count): """Produce some test edges.""" + def doc(i): return '{"_from": "test_vertex/%s", "_to": "test_vertex/%s"}' % (i, i) - return '\n'.join(doc(i) for i in range(0, count)) + + return "\n".join(doc(i) for i in range(0, count)) def save_test_docs(count, edges=False): if edges: docs = create_test_edges(count) - collection = 'test_edge' + collection = "test_edge" else: docs = create_test_docs(count) - collection = 'test_vertex' + collection = "test_vertex" return requests.put( - API_URL + '/documents', - params={'overwrite': True, 'collection': collection}, + API_URL + "/documents", + params={"overwrite": True, "collection": collection}, data=docs, - headers=HEADERS_ADMIN + headers=HEADERS_ADMIN, ).json() class TestApi(unittest.TestCase): - @classmethod def setUpClass(cls): wait_for_api() cls.maxDiff = None - def test_request(self, url=None, params=None, data=None, headers=None, method='get', - status_code=200, resp_json=None, resp_test=None): - '''test a request to the server + def test_request( + self, + url=None, + params=None, + data=None, + headers=None, + method="get", + status_code=200, + resp_json=None, + resp_test=None, + ): + """test a request to the server arguments: url url to be appended to API_URL (i.e. request will be made to API_URL + url) @@ -74,7 +92,7 @@ def test_request(self, url=None, params=None, data=None, headers=None, method='g status_code expected response status; defaults to 200 resp_json expected response content (JSON) resp_test a function to perform on the response to test that it is as expected - ''' + """ # this method should only be run from another test method if url is None: @@ -90,76 +108,75 @@ def test_request(self, url=None, params=None, data=None, headers=None, method='g ) self.assertEqual(resp.status_code, status_code) if resp_json: - self.assertEqual( - resp_json, - resp.json() - ) + self.assertEqual(resp_json, resp.json()) if resp_test: resp_test(self, resp) def test_root(self): """Test root path for api.""" - resp_json = requests.get(URL + '/').json() - self.assertEqual(resp_json['arangodb_status'], 'connected_authorized') - self.assertTrue(resp_json['commit_hash']) - self.assertTrue(resp_json['repo_url']) + resp_json = requests.get(URL + "/").json() + self.assertEqual(resp_json["arangodb_status"], "connected_authorized") + self.assertTrue(resp_json["commit_hash"]) + self.assertTrue(resp_json["repo_url"]) def test_config(self): """Test config fetch.""" - resp_json = requests.get(API_URL + '/config').json() - self.assertTrue(len(resp_json['auth_url'])) - self.assertTrue(len(resp_json['workspace_url'])) - self.assertTrue(len(resp_json['kbase_endpoint'])) - self.assertTrue(len(resp_json['db_url'])) - self.assertTrue(len(resp_json['db_name'])) + resp_json = requests.get(API_URL + "/config").json() + self.assertTrue(len(resp_json["auth_url"])) + self.assertTrue(len(resp_json["workspace_url"])) + self.assertTrue(len(resp_json["kbase_endpoint"])) + self.assertTrue(len(resp_json["db_url"])) + self.assertTrue(len(resp_json["db_name"])) def test_update_specs(self): """Test the endpoint that triggers an update on the specs.""" resp = requests.put( - API_URL + '/specs', + API_URL + "/specs", headers=HEADERS_ADMIN, - params={'reset': '1', 'init_collections': '1'} + params={"reset": "1", "init_collections": "1"}, ) resp_json = resp.json() self.assertEqual(resp.status_code, 200) - self.assertTrue(len(resp_json['status'])) + self.assertTrue(len(resp_json["status"])) # delete the SPEC_TEST_READY env var as it is no longer true - os.environ.pop('SPEC_TEST_READY', None) + os.environ.pop("SPEC_TEST_READY", None) # Test that the indexes get created and not duplicated - url = _CONF['db_url'] + '/_api/index' - auth = (_CONF['db_user'], _CONF['db_pass']) - resp = requests.get(url, params={'collection': 'ncbi_taxon'}, auth=auth) + url = _CONF["db_url"] + "/_api/index" + auth = (_CONF["db_user"], _CONF["db_pass"]) + resp = requests.get(url, params={"collection": "ncbi_taxon"}, auth=auth) resp_json = resp.json() - indexes = resp_json['indexes'] + indexes = resp_json["indexes"] self.assertEqual(len(indexes), 4) - fields = [i['fields'] for i in indexes] - self.assertEqual(set(tuple(f) for f in fields), { - ('_key',), - ('scientific_name',), - ('id', 'expired', 'created'), - ('expired', 'created', 'last_version') - }) + fields = [i["fields"] for i in indexes] + self.assertEqual( + set(tuple(f) for f in fields), + { + ("_key",), + ("scientific_name",), + ("id", "expired", "created"), + ("expired", "created", "last_version"), + }, + ) def check_list_contains(self, the_list, must_contain): - '''ensure the_list contains the items in must_contain''' + """ensure the_list contains the items in must_contain""" for item in must_contain: self.assertIn(item, the_list) def test_list_collections(self): """Test the listing out of registered collection schemas for vertices and edges.""" - for variant in ['schemas', 'collections']: + for variant in ["schemas", "collections"]: def check_resp_json_contains(self, resp): resp_json = resp.json() - self.check_list_contains(resp_json, ['test_edge', 'test_vertex', 'ncbi_taxon']) + self.check_list_contains( + resp_json, ["test_edge", "test_vertex", "ncbi_taxon"] + ) - self.test_request( - '/specs/' + variant, - resp_test=check_resp_json_contains - ) + self.test_request("/specs/" + variant, resp_test=check_resp_json_contains) def test_list_data_sources(self): """test the data source listing endpoints""" @@ -168,7 +185,7 @@ def test_list_data_sources(self): # /data_sources is used by the UI and requires slightly different response formatting # /specs/data_sources is in the standard /specs format used by collections and stored_queries - data_sources = ['ncbi_taxonomy'] + data_sources = ["ncbi_taxonomy"] # /spec/data_sources endpoint def check_resp_json_spec_endpoint(self, resp): @@ -179,8 +196,7 @@ def check_resp_json_spec_endpoint(self, resp): ) self.test_request( - '/specs/data_sources', - resp_test=check_resp_json_spec_endpoint + "/specs/data_sources", resp_test=check_resp_json_spec_endpoint ) def test_list_stored_queries(self): @@ -190,193 +206,192 @@ def check_resp_json_contains(self, resp): resp_json = resp.json() self.check_list_contains( resp_json, - ['fetch_test_vertex', 'list_test_vertices', 'ncbi_fetch_taxon'] + ["fetch_test_vertex", "list_test_vertices", "ncbi_fetch_taxon"], ) self.test_request( - '/specs/stored_queries', + "/specs/stored_queries", resp_test=check_resp_json_contains, ) def test_fetch_collection_and_fetch_schema_for_doc(self): """Given a collection name or a document ID, fetch its schema.""" - name = 'test_vertex' - collection_params = {'name': name} # valid collection - document_params = {'doc_id': name + '/123'} # valid document + name = "test_vertex" + collection_params = {"name": name} # valid collection + document_params = {"doc_id": name + "/123"} # valid document def check_resp_json(self, resp): resp_json = resp.json() - self.assertEqual(resp_json['name'], name) - self.assertEqual(resp_json['type'], 'vertex') - self.assertTrue(resp_json['schema']) + self.assertEqual(resp_json["name"], name) + self.assertEqual(resp_json["type"], "vertex") + self.assertTrue(resp_json["schema"]) - for variant in ['schemas', 'collections']: + for variant in ["schemas", "collections"]: for params in [document_params, collection_params]: self.test_request( - '/specs/' + variant, + "/specs/" + variant, params=params, resp_test=check_resp_json, ) def test_fetch_data_source(self): - '''fetch a data source by name''' + """fetch a data source by name""" - name = 'ncbi_taxonomy' + name = "ncbi_taxonomy" def check_resp_json(self, resp): resp_json = resp.json() self.assertEqual(type(resp_json), dict) - self.assertEqual(set(resp_json.keys()), { - 'name', 'category', 'title', 'home_url', 'data_url', 'logo_url' - }) + self.assertEqual( + set(resp_json.keys()), + {"name", "category", "title", "home_url", "data_url", "logo_url"}, + ) self.assertTrue( - '/ui-assets/images/third-party-data-sources/ncbi' in resp_json['logo_url'] + "/ui-assets/images/third-party-data-sources/ncbi" + in resp_json["logo_url"] ) self.test_request( - '/specs/data_sources', - {'name': name}, - resp_test=check_resp_json + "/specs/data_sources", {"name": name}, resp_test=check_resp_json ) def test_fetch_stored_query(self): - '''fetch a stored query by name''' + """fetch a stored query by name""" - name = 'fetch_test_vertex' + name = "fetch_test_vertex" # note that the stored_queries endpoint returns the query data in a dict # under the key 'stored_query' def check_resp_json(self, resp): resp_json = resp.json() - self.assertEqual(type(resp_json['stored_query']), dict) - self.assertEqual(resp_json['stored_query']['name'], name) - self.assertEqual(set(resp_json['stored_query'].keys()), { - 'name', 'query', 'params' - }) + self.assertEqual(type(resp_json["stored_query"]), dict) + self.assertEqual(resp_json["stored_query"]["name"], name) + self.assertEqual( + set(resp_json["stored_query"].keys()), {"name", "query", "params"} + ) self.test_request( - '/specs/stored_queries', - {'name': name}, - resp_test=check_resp_json + "/specs/stored_queries", {"name": name}, resp_test=check_resp_json ) def test_fetch_invalid_data_source(self): """Unknown data source name should yield 404 status.""" - name = 'invalid_data_source' + name = "invalid_data_source" self.test_request( - '/specs/data_sources', - {'name': name}, + "/specs/data_sources", + {"name": name}, status_code=404, resp_json={ - 'error': { - 'message': 'Not found', - 'details': f"Data source '{name}' does not exist.", - 'name': name, + "error": { + "message": "Not found", + "details": f"Data source '{name}' does not exist.", + "name": name, } - } + }, ) def test_fetch_invalid_collections_and_documents(self): """Test the case where the collection or document does not exist.""" - name = 'fake_collection' - collection_params = {'name': name} # fetch an invalid collection - document_params = {'doc_id': name + '/123'} # fetch an invalid document - for variant in ['schemas', 'collections']: + name = "fake_collection" + collection_params = {"name": name} # fetch an invalid collection + document_params = {"doc_id": name + "/123"} # fetch an invalid document + for variant in ["schemas", "collections"]: for params in [document_params, collection_params]: self.test_request( - '/specs/' + variant, + "/specs/" + variant, params=params, status_code=404, resp_json={ - 'error': { - 'message': 'Not found', - 'details': f"Collection '{name}' does not exist.", - 'name': name, + "error": { + "message": "Not found", + "details": f"Collection '{name}' does not exist.", + "name": name, } - } + }, ) def test_fetch_invalid_stored_queries(self): """Test the case where the stored query does not exist.""" - name = 'made_up_stored_query' + name = "made_up_stored_query" self.test_request( - '/specs/stored_queries', - params={'name': name}, + "/specs/stored_queries", + params={"name": name}, status_code=404, resp_json={ - 'error': { - 'message': 'Not found', - 'details': f"Stored query '{name}' does not exist.", - 'name': name, + "error": { + "message": "Not found", + "details": f"Stored query '{name}' does not exist.", + "name": name, } - } + }, ) def test_show_data_sources(self): - resp = requests.get(API_URL + '/data_sources') + resp = requests.get(API_URL + "/data_sources") self.assertTrue(resp.ok) resp_json = resp.json() - self.assertTrue(len(resp_json['data_sources']) > 0) - self.assertEqual(set(type(x) for x in resp_json['data_sources']), {str}) + self.assertTrue(len(resp_json["data_sources"]) > 0) + self.assertEqual(set(type(x) for x in resp_json["data_sources"]), {str}) def test_show_data_source(self): - name = 'ncbi_taxonomy' + name = "ncbi_taxonomy" def check_resp_json(self, resp): resp_json = resp.json() - self.assertEqual(type(resp_json['data_source']), dict) - self.assertEqual(set(resp_json['data_source'].keys()), { - 'name', 'category', 'title', 'home_url', 'data_url', 'logo_url' - }) + self.assertEqual(type(resp_json["data_source"]), dict) + self.assertEqual( + set(resp_json["data_source"].keys()), + {"name", "category", "title", "home_url", "data_url", "logo_url"}, + ) self.assertTrue( - '/ui-assets/images/third-party-data-sources/ncbi' in resp_json['data_source']['logo_url'] + "/ui-assets/images/third-party-data-sources/ncbi" + in resp_json["data_source"]["logo_url"] ) - self.test_request( - '/data_sources/' + name, - resp_test=check_resp_json - ) + self.test_request("/data_sources/" + name, resp_test=check_resp_json) - resp = requests.get(API_URL + '/data_sources/ncbi_taxonomy') + resp = requests.get(API_URL + "/data_sources/ncbi_taxonomy") self.assertTrue(resp.ok) resp_json = resp.json() - self.assertEqual(type(resp_json['data_source']), dict) - self.assertEqual(set(resp_json['data_source'].keys()), { - 'name', 'category', 'title', 'home_url', 'data_url', 'logo_url' - }) + self.assertEqual(type(resp_json["data_source"]), dict) + self.assertEqual( + set(resp_json["data_source"].keys()), + {"name", "category", "title", "home_url", "data_url", "logo_url"}, + ) self.assertTrue( - '/ui-assets/images/third-party-data-sources/ncbi' in resp_json['data_source']['logo_url'] + "/ui-assets/images/third-party-data-sources/ncbi" + in resp_json["data_source"]["logo_url"] ) def test_show_data_source_unknown(self): """Unknown data source name should yield 404 status.""" - name = 'xyzyxz' + name = "xyzyxz" self.test_request( f"/data_sources/{name}", status_code=404, resp_json={ - 'error': { - 'message': 'Not found', - 'details': f"Data source '{name}' does not exist.", - 'name': name, + "error": { + "message": "Not found", + "details": f"Data source '{name}' does not exist.", + "name": name, } - } + }, ) def test_save_documents_missing_auth(self): """Test an invalid attempt to save a doc with a missing auth token.""" self.test_request( - '/documents?on_duplicate=error&overwrite=true&collection', - method='put', + "/documents?on_duplicate=error&overwrite=true&collection", + method="put", status_code=400, - resp_json={'error': {'message': 'Missing header: Authorization'}}, + resp_json={"error": {"message": "Missing header: Authorization"}}, ) def test_save_documents_invalid_auth(self): @@ -391,34 +406,36 @@ def test_save_documents_invalid_auth(self): "apperror": "Invalid token", "message": "10020 Invalid token", "callid": "1757210147564211", - "time": 1542737889450 + "time": 1542737889450, } } self.test_request( - '/documents?on_duplicate=error&overwrite=true&collection', - headers={'Authorization': 'Bearer ' + INVALID_TOKEN}, - method='put', + "/documents?on_duplicate=error&overwrite=true&collection", + headers={"Authorization": "Bearer " + INVALID_TOKEN}, + method="put", status_code=403, - resp_json={'error': { - 'message': 'Unauthorized', - 'auth_url': 'http://auth:5000', - 'auth_response': json.dumps(auth_response) - }}, + resp_json={ + "error": { + "message": "Unauthorized", + "auth_url": "http://auth:5000", + "auth_response": json.dumps(auth_response), + } + }, ) def test_save_documents_non_admin(self): """Test an invalid attempt to save a doc as a non-admin.""" self.test_request( - '/documents?on_duplicate=error&overwrite=true&collection', + "/documents?on_duplicate=error&overwrite=true&collection", headers=HEADERS_NON_ADMIN, - method='put', + method="put", status_code=403, resp_json={ - 'error': { - 'auth_response': 'Missing role', - 'auth_url': 'http://auth:5000', - 'message': 'Unauthorized' + "error": { + "auth_response": "Missing role", + "auth_url": "http://auth:5000", + "message": "Unauthorized", } }, ) @@ -427,262 +444,319 @@ def test_save_documents_invalid_schema(self): """Test the case where some documents fail against their schema.""" self.test_request( - '/documents', - params={'on_duplicate': 'ignore', 'collection': 'test_vertex'}, + "/documents", + params={"on_duplicate": "ignore", "collection": "test_vertex"}, data='{"name": "x"}\n{"name": "y"}', headers=HEADERS_ADMIN, - method='put', + method="put", status_code=400, - resp_json={'error': { - 'message': "'_key' is a required property", - 'value': {'name': 'x'}, - 'path': [], - 'failed_validator': 'required', - }}, + resp_json={ + "error": { + "message": "'_key' is a required property", + "value": {"name": "x"}, + "path": [], + "failed_validator": "required", + } + }, ) def test_save_documents_missing_schema(self): """Test the case where the collection/schema does not exist.""" - name = 'fake_collection' + name = "fake_collection" self.test_request( - '/documents', - method='put', - params={'collection': name}, - data='', + "/documents", + method="put", + params={"collection": name}, + data="", headers=HEADERS_ADMIN, status_code=404, resp_json={ - 'error': { - 'message': 'Not found', - 'details': f"Collection '{name}' does not exist.", - 'name': name, + "error": { + "message": "Not found", + "details": f"Collection '{name}' does not exist.", + "name": name, } - } + }, ) def test_save_documents_invalid_json(self): """Test an attempt to save documents with an invalid JSON body.""" resp_json = requests.put( - API_URL + '/documents', - params={'collection': 'test_vertex'}, - data='\n', - headers=HEADERS_ADMIN + API_URL + "/documents", + params={"collection": "test_vertex"}, + data="\n", + headers=HEADERS_ADMIN, ).json() - self.assertTrue('Unable to parse' in resp_json['error']['message']) - self.assertEqual(resp_json['error']['pos'], 1) - self.assertEqual(resp_json['error']['source_json'], '\n') + self.assertTrue("Unable to parse" in resp_json["error"]["message"]) + self.assertEqual(resp_json["error"]["pos"], 1) + self.assertEqual(resp_json["error"]["source_json"], "\n") def test_create_documents(self): """Test all valid cases for saving documents.""" resp = save_test_docs(3) - expected = {'created': 3, 'errors': 0, 'empty': 0, 'updated': 0, 'ignored': 0, 'error': False} + expected = { + "created": 3, + "errors": 0, + "empty": 0, + "updated": 0, + "ignored": 0, + "error": False, + } self.assertEqual(resp, expected) def test_create_edges(self): """Test all valid cases for saving edges.""" resp = save_test_docs(3, edges=True) - expected = {'created': 3, 'errors': 0, 'empty': 0, 'updated': 0, 'ignored': 0, 'error': False} + expected = { + "created": 3, + "errors": 0, + "empty": 0, + "updated": 0, + "ignored": 0, + "error": False, + } self.assertEqual(resp, expected) def test_update_documents(self): """Test updating existing documents.""" resp_json = requests.put( - API_URL + '/documents', - params={'on_duplicate': 'update', 'collection': 'test_vertex'}, + API_URL + "/documents", + params={"on_duplicate": "update", "collection": "test_vertex"}, data=create_test_docs(3), - headers=HEADERS_ADMIN + headers=HEADERS_ADMIN, ).json() - expected = {'created': 0, 'errors': 0, 'empty': 0, 'updated': 3, 'ignored': 0, 'error': False} + expected = { + "created": 0, + "errors": 0, + "empty": 0, + "updated": 3, + "ignored": 0, + "error": False, + } self.assertEqual(resp_json, expected) def test_update_edge(self): """Test updating existing edge.""" edges = create_test_edges(3) resp = requests.put( - API_URL + '/documents', - params={'on_duplicate': 'update', 'collection': 'test_edge'}, + API_URL + "/documents", + params={"on_duplicate": "update", "collection": "test_edge"}, data=create_test_edges(3), - headers=HEADERS_ADMIN + headers=HEADERS_ADMIN, ) self.assertTrue(resp.ok) resp_json = requests.put( - API_URL + '/documents', - params={'on_duplicate': 'update', 'collection': 'test_edge'}, + API_URL + "/documents", + params={"on_duplicate": "update", "collection": "test_edge"}, data=edges, - headers=HEADERS_ADMIN + headers=HEADERS_ADMIN, ).json() - expected = {'created': 0, 'errors': 0, 'empty': 0, 'updated': 3, 'ignored': 0, 'error': False} + expected = { + "created": 0, + "errors": 0, + "empty": 0, + "updated": 3, + "ignored": 0, + "error": False, + } self.assertEqual(resp_json, expected) def test_replace_documents(self): """Test replacing of existing documents.""" resp_json = requests.put( - API_URL + '/documents', - params={'on_duplicate': 'replace', 'collection': 'test_vertex'}, + API_URL + "/documents", + params={"on_duplicate": "replace", "collection": "test_vertex"}, data=create_test_docs(3), - headers=HEADERS_ADMIN + headers=HEADERS_ADMIN, ).json() - expected = {'created': 0, 'errors': 0, 'empty': 0, 'updated': 3, 'ignored': 0, 'error': False} + expected = { + "created": 0, + "errors": 0, + "empty": 0, + "updated": 3, + "ignored": 0, + "error": False, + } self.assertEqual(resp_json, expected) def test_save_documents_dupe_errors(self): """Test where we want to raise errors on duplicate documents.""" save_test_docs(3) resp_json = requests.put( - API_URL + '/documents', - params={'on_duplicate': 'error', 'collection': 'test_vertex', 'display_errors': '1'}, + API_URL + "/documents", + params={ + "on_duplicate": "error", + "collection": "test_vertex", + "display_errors": "1", + }, data=create_test_docs(3), - headers=HEADERS_ADMIN + headers=HEADERS_ADMIN, ).json() - self.assertEqual(resp_json['created'], 0) - self.assertEqual(resp_json['errors'], 3) - self.assertTrue(resp_json['details']) + self.assertEqual(resp_json["created"], 0) + self.assertEqual(resp_json["errors"], 3) + self.assertTrue(resp_json["details"]) def test_save_documents_ignore_dupes(self): """Test ignoring duplicate, existing documents when saving.""" resp_json = requests.put( - API_URL + '/documents', - params={'on_duplicate': 'ignore', 'collection': 'test_vertex'}, + API_URL + "/documents", + params={"on_duplicate": "ignore", "collection": "test_vertex"}, data=create_test_docs(3), - headers=HEADERS_ADMIN + headers=HEADERS_ADMIN, ).json() - expected = {'created': 0, 'errors': 0, 'empty': 0, 'updated': 0, 'ignored': 3, 'error': False} + expected = { + "created": 0, + "errors": 0, + "empty": 0, + "updated": 0, + "ignored": 3, + "error": False, + } self.assertEqual(resp_json, expected) def test_admin_query(self): """Test an ad-hoc query made by an admin.""" save_test_docs(1) - query = 'for v in test_vertex sort rand() limit @count return v._id' + query = "for v in test_vertex sort rand() limit @count return v._id" resp_json = requests.post( - API_URL + '/query_results', + API_URL + "/query_results", params={}, headers=HEADERS_ADMIN, - data=json.dumps({'query': query, 'count': 1}) + data=json.dumps({"query": query, "count": 1}), ).json() - self.assertEqual(resp_json['count'], 1) - self.assertEqual(len(resp_json['results']), 1) + self.assertEqual(resp_json["count"], 1) + self.assertEqual(len(resp_json["results"]), 1) def test_admin_query_non_admin(self): """Test an ad-hoc query error as a non-admin.""" - query = 'for v in test_vertex sort rand() limit @count return v._id' + query = "for v in test_vertex sort rand() limit @count return v._id" self.test_request( - '/query_results', - method='post', + "/query_results", + method="post", params={}, headers=HEADERS_NON_ADMIN, - data=json.dumps({'query': query, 'count': 1}), + data=json.dumps({"query": query, "count": 1}), status_code=403, - resp_json={'error': { - 'message': 'Unauthorized', - 'auth_url': 'http://auth:5000', - 'auth_response': 'Missing role' - }}, + resp_json={ + "error": { + "message": "Unauthorized", + "auth_url": "http://auth:5000", + "auth_response": "Missing role", + } + }, ) def test_admin_query_invalid_auth(self): """Test the error response for an ad-hoc admin query without auth.""" # see ./mock_auth/auth_invalid.json for response - query = 'for v in test_vertex sort rand() limit @count return v._id' + query = "for v in test_vertex sort rand() limit @count return v._id" self.test_request( - '/query_results', - method='post', + "/query_results", + method="post", params={}, - headers={'Authorization': INVALID_TOKEN}, - data=json.dumps({'query': query, 'count': 1}), + headers={"Authorization": INVALID_TOKEN}, + data=json.dumps({"query": query, "count": 1}), status_code=403, resp_json={ - 'error': { - 'message': 'Unauthorized', - 'auth_url': 'http://auth:5000', - 'auth_response': json.dumps({ - "error": { - "httpcode": 401, - "httpstatus": "Unauthorized", - "appcode": 10020, - "apperror": "Invalid token", - "message": "10020 Invalid token", - "callid": "1757210147564211", - "time": 1542737889450 + "error": { + "message": "Unauthorized", + "auth_url": "http://auth:5000", + "auth_response": json.dumps( + { + "error": { + "httpcode": 401, + "httpstatus": "Unauthorized", + "appcode": 10020, + "apperror": "Invalid token", + "message": "10020 Invalid token", + "callid": "1757210147564211", + "time": 1542737889450, + } } - }) + ), } - } + }, ) def test_query_with_cursor(self): """Test getting more data via a query cursor and setting batch size.""" save_test_docs(count=20) resp_json = requests.post( - API_URL + '/query_results', - params={'stored_query': 'list_test_vertices', 'batch_size': 10, 'full_count': True} + API_URL + "/query_results", + params={ + "stored_query": "list_test_vertices", + "batch_size": 10, + "full_count": True, + }, ).json() - self.assertTrue(resp_json['cursor_id']) - self.assertEqual(resp_json['has_more'], True) - self.assertEqual(resp_json['count'], 20) - self.assertEqual(resp_json['stats']['fullCount'], 20) - self.assertTrue(len(resp_json['results']), 10) + self.assertTrue(resp_json["cursor_id"]) + self.assertEqual(resp_json["has_more"], True) + self.assertEqual(resp_json["count"], 20) + self.assertEqual(resp_json["stats"]["fullCount"], 20) + self.assertTrue(len(resp_json["results"]), 10) - cursor_id = resp_json['cursor_id'] + cursor_id = resp_json["cursor_id"] resp_json = requests.post( - API_URL + '/query_results', - params={'cursor_id': cursor_id} + API_URL + "/query_results", params={"cursor_id": cursor_id} ).json() - self.assertEqual(resp_json['count'], 20) - self.assertEqual(resp_json['stats']['fullCount'], 20) - self.assertEqual(resp_json['has_more'], False) - self.assertEqual(resp_json['cursor_id'], None) - self.assertTrue(len(resp_json['results']), 10) + self.assertEqual(resp_json["count"], 20) + self.assertEqual(resp_json["stats"]["fullCount"], 20) + self.assertEqual(resp_json["has_more"], False) + self.assertEqual(resp_json["cursor_id"], None) + self.assertTrue(len(resp_json["results"]), 10) # Try to get the same cursor again self.test_request( - '/query_results', - method='post', - params={'cursor_id': cursor_id}, + "/query_results", + method="post", + params={"cursor_id": cursor_id}, status_code=400, resp_json={ - 'error': { - 'message': 'ArangoDB server error.', - 'arango_message': 'cursor not found', + "error": { + "message": "ArangoDB server error.", + "arango_message": "cursor not found", } - } + }, ) def test_query_no_name(self): """Test a query error with a stored query name that does not exist.""" - name = 'nonexistent' + name = "nonexistent" self.test_request( - '/query_results', - method='post', - params={'stored_query': name}, + "/query_results", + method="post", + params={"stored_query": name}, status_code=404, resp_json={ - 'error': { - 'message': 'Not found', - 'details': f"Stored query '{name}' does not exist.", - 'name': name, + "error": { + "message": "Not found", + "details": f"Stored query '{name}' does not exist.", + "name": name, } - } + }, ) def test_query_missing_bind_var(self): """Test a query error with a missing bind variable.""" - arango_msg = "AQL: bind parameter 'xyz' was not declared in the query (while parsing)" + arango_msg = ( + "AQL: bind parameter 'xyz' was not declared in the query (while parsing)" + ) self.test_request( - '/query_results', - method='post', - params={'stored_query': 'list_test_vertices'}, - data=json.dumps({'xyz': 'test_vertex'}), + "/query_results", + method="post", + params={"stored_query": "list_test_vertices"}, + data=json.dumps({"xyz": "test_vertex"}), status_code=400, resp_json={ - 'error': { - 'message': 'ArangoDB server error.', - 'arango_message': arango_msg, + "error": { + "message": "ArangoDB server error.", + "arango_message": arango_msg, } - } + }, ) def test_auth_query_with_access(self): @@ -690,117 +764,121 @@ def test_auth_query_with_access(self): ws_id = 3 # Remove all test vertices and create one with a ws_id requests.put( - API_URL + '/documents', - params={'overwrite': True, 'collection': 'test_vertex'}, - data=json.dumps({ - 'name': 'requires_auth', - '_key': '123', - 'ws_id': ws_id - }), - headers=HEADERS_ADMIN + API_URL + "/documents", + params={"overwrite": True, "collection": "test_vertex"}, + data=json.dumps({"name": "requires_auth", "_key": "123", "ws_id": ws_id}), + headers=HEADERS_ADMIN, ) resp_json = requests.post( - API_URL + '/query_results', - params={'stored_query': 'list_test_vertices'}, - headers={'Authorization': 'valid_token'} # see ./mock_workspace/endpoints.json + API_URL + "/query_results", + params={"stored_query": "list_test_vertices"}, + headers={ + "Authorization": "valid_token" + }, # see ./mock_workspace/endpoints.json ).json() - self.assertEqual(resp_json['count'], 1) - self.assertEqual(resp_json['results'][0]['ws_id'], ws_id) + self.assertEqual(resp_json["count"], 1) + self.assertEqual(resp_json["results"][0]["ws_id"], ws_id) def test_auth_query_no_access(self): """Test the case where we try to query a collection without the right workspace access.""" # Remove all test vertices and create one with a ws_id requests.put( - API_URL + '/documents', - params={'overwrite': True, 'collection': 'test_vertex'}, + API_URL + "/documents", + params={"overwrite": True, "collection": "test_vertex"}, data='{"name": "requires_auth", "_key": "1", "ws_id": 9999}', - headers=HEADERS_ADMIN + headers=HEADERS_ADMIN, ) resp_json = requests.post( - API_URL + '/query_results', - params={'stored_query': 'list_test_vertices'}, - headers={'Authorization': 'valid_token'} # see ./mock_workspace/endpoints.json + API_URL + "/query_results", + params={"stored_query": "list_test_vertices"}, + headers={ + "Authorization": "valid_token" + }, # see ./mock_workspace/endpoints.json ).json() - self.assertEqual(resp_json['count'], 0) + self.assertEqual(resp_json["count"], 0) def test_query_cannot_pass_ws_ids(self): """Test that users cannot set the ws_ids param.""" ws_id = 99 requests.put( - API_URL + '/documents', - params={'overwrite': True, 'collection': 'test_vertex'}, + API_URL + "/documents", + params={"overwrite": True, "collection": "test_vertex"}, data='{"name": "requires_auth", "_key": "1", "ws_id": 99}', - headers=HEADERS_ADMIN + headers=HEADERS_ADMIN, ) resp_json = requests.post( - API_URL + '/query_results', - params={'view': 'list_test_vertices'}, - data=json.dumps({'ws_ids': [ws_id]}), - headers={'Authorization': 'valid_token'} + API_URL + "/query_results", + params={"view": "list_test_vertices"}, + data=json.dumps({"ws_ids": [ws_id]}), + headers={"Authorization": "valid_token"}, ).json() - self.assertEqual(resp_json['count'], 0) + self.assertEqual(resp_json["count"], 0) def test_auth_query_invalid_token(self): """Test the case where we try to authorize a query using an invalid auth token.""" requests.put( - API_URL + '/documents', - params={'overwrite': True, 'collection': 'test_vertex'}, + API_URL + "/documents", + params={"overwrite": True, "collection": "test_vertex"}, data='{"name": "requires_auth", "_key": "1", "ws_id": 99}', - headers=HEADERS_ADMIN + headers=HEADERS_ADMIN, ) # see ./mock_workspace/list_workspace_ids_invalid.json for response self.test_request( - '/query_results', - params={'view': 'list_test_vertices'}, - data=json.dumps({'ws_ids': [1]}), - headers={'Authorization': INVALID_TOKEN}, - method='post', + "/query_results", + params={"view": "list_test_vertices"}, + data=json.dumps({"ws_ids": [1]}), + headers={"Authorization": INVALID_TOKEN}, + method="post", status_code=403, resp_json={ - 'error': { - 'message': 'Unauthorized', - 'auth_url': 'http://workspace:5000', - 'auth_response': json.dumps({ - "version": "1.1", - "error": { - "name": "JSONRPCError", - "code": -32400, - "message": "Token validation failed!", - "error": "..." + "error": { + "message": "Unauthorized", + "auth_url": "http://workspace:5000", + "auth_response": json.dumps( + { + "version": "1.1", + "error": { + "name": "JSONRPCError", + "code": -32400, + "message": "Token validation failed!", + "error": "...", + }, } - }) + ), } - } + }, ) def test_auth_adhoc_query(self): """Test that the 'ws_ids' bind-var is set for RE_ADMINs.""" ws_id = 99 requests.put( - API_URL + '/documents', - params={'overwrite': True, 'collection': 'test_vertex'}, - data=json.dumps({'name': 'requires_auth', 'key': '1', 'ws_id': ws_id}), - headers={'Authorization': 'valid_token'} + API_URL + "/documents", + params={"overwrite": True, "collection": "test_vertex"}, + data=json.dumps({"name": "requires_auth", "key": "1", "ws_id": ws_id}), + headers={"Authorization": "valid_token"}, ) # This is the same query as list_test_vertices.aql in the spec - query = 'for o in test_vertex filter o.is_public || o.ws_id IN ws_ids return o' + query = "for o in test_vertex filter o.is_public || o.ws_id IN ws_ids return o" resp_json = requests.post( - API_URL + '/query_results', - data=json.dumps({'query': query}), - headers={'Authorization': ADMIN_TOKEN} # see ./mock_workspace/endpoints.json + API_URL + "/query_results", + data=json.dumps({"query": query}), + headers={ + "Authorization": ADMIN_TOKEN + }, # see ./mock_workspace/endpoints.json ).json() - self.assertEqual(resp_json['count'], 1) + self.assertEqual(resp_json["count"], 1) def test_save_docs_invalid(self): """Test that an invalid bulk save returns a 400 response""" - doc = {'_from': '|||', '_to': '|||'} + doc = {"_from": "|||", "_to": "|||"} resp = requests.put( - API_URL + '/documents', - params={'overwrite': True, 'collection': 'test_edge', 'display_errors': 1}, + API_URL + "/documents", + params={"overwrite": True, "collection": "test_edge", "display_errors": 1}, data=json.dumps(doc), - headers=HEADERS_ADMIN + headers=HEADERS_ADMIN, ) self.assertEqual(resp.status_code, 400) resp_json = resp.json() - self.assertEqual(resp_json['errors'], 1) + self.assertEqual(resp_json["errors"], 1) diff --git a/relation_engine_server/test/test_json_validation.py b/relation_engine_server/test/test_json_validation.py index 501b786f..fab461cd 100644 --- a/relation_engine_server/test/test_json_validation.py +++ b/relation_engine_server/test/test_json_validation.py @@ -22,95 +22,94 @@ from jsonschema.exceptions import ValidationError, RefResolutionError from jsonpointer import JsonPointerException -test_data_dirs = ['/app', 'relation_engine_server', 'test', 'data'] -json_validation_dir = os_path.join(*(test_data_dirs + ['json_validation'])) -schema_refs_dir = os_path.join(*(test_data_dirs + ['schema_refs'])) +test_data_dirs = ["/app", "relation_engine_server", "test", "data"] +json_validation_dir = os_path.join(*(test_data_dirs + ["json_validation"])) +schema_refs_dir = os_path.join(*(test_data_dirs + ["schema_refs"])) test_schema = { - 'properties': { - 'params': { - 'type': 'object', - 'properties': { - 'name': { - 'type': 'string', - 'format': 'regex', - 'pattern': '^\\w+$', - 'default': 'blank', + "properties": { + "params": { + "type": "object", + "properties": { + "name": { + "type": "string", + "format": "regex", + "pattern": "^\\w+$", + "default": "blank", }, - 'distance': { - 'type': 'integer', - 'minimum': 0, - 'maximum': 10, - 'default': 1, + "distance": { + "type": "integer", + "minimum": 0, + "maximum": 10, + "default": 1, }, - 'home_page': { - 'type': 'string', - 'format': 'uri', + "home_page": { + "type": "string", + "format": "uri", }, - 'date': { - 'title': 'date', - 'description': 'A type of dried fruit', - 'type': 'string', - 'format': 'date', + "date": { + "title": "date", + "description": "A type of dried fruit", + "type": "string", + "format": "date", }, - 'fruits': { - 'type': 'array', - 'items': { - 'name': 'fruit', - 'type': 'string', - 'oneOf': [ - {'const': 'peach'}, - {'const': 'plum'}, - {'const': 'pear'}, - {'const': 'strawberry'}, - ] + "fruits": { + "type": "array", + "items": { + "name": "fruit", + "type": "string", + "oneOf": [ + {"const": "peach"}, + {"const": "plum"}, + {"const": "pear"}, + {"const": "strawberry"}, + ], }, - 'default': [], - 'uniqueItems': True - } - } + "default": [], + "uniqueItems": True, + }, + }, } } } fruits_explicit = { - 'type': 'array', - 'items': { - 'name': 'fruit', - 'type': 'string', - 'oneOf': [ - {'const': 'peach'}, - {'const': 'plum'}, - {'const': 'pear'}, - {'const': 'strawberry'}, - ] + "type": "array", + "items": { + "name": "fruit", + "type": "string", + "oneOf": [ + {"const": "peach"}, + {"const": "plum"}, + {"const": "pear"}, + {"const": "strawberry"}, + ], }, - 'default': [], - 'uniqueItems': True + "default": [], + "uniqueItems": True, } fruits_array_ref = { - '$ref': 'file://' + os_path.join(json_validation_dir, 'fruits_array.yaml') + - '#/definitions/fruits' + "$ref": "file://" + + os_path.join(json_validation_dir, "fruits_array.yaml") + + "#/definitions/fruits" } fruit_ref = { - 'type': 'array', - 'items': { - '$ref': 'file://' + os_path.join(json_validation_dir, 'fruit.yaml') - }, - 'default': [], - 'uniqueItems': True + "type": "array", + "items": {"$ref": "file://" + os_path.join(json_validation_dir, "fruit.yaml")}, + "default": [], + "uniqueItems": True, } -valid_json_loc = '/properties/params' -schema_defaults = {'name': 'blank', 'distance': 1, 'fruits': []} +valid_json_loc = "/properties/params" +schema_defaults = {"name": "blank", "distance": 1, "fruits": []} test_schema_list = [ - ['schema', test_schema], - ['schema_file', os_path.join(json_validation_dir, 'test_schema.json')], - ['schema_file', os_path.join(json_validation_dir, 'test_schema.yaml')], + ["schema", test_schema], + ["schema_file", os_path.join(json_validation_dir, "test_schema.json")], + ["schema_file", os_path.join(json_validation_dir, "test_schema.yaml")], ] valid_edge_data = { @@ -131,9 +130,8 @@ class TestJsonValidation(unittest.TestCase): - def test_non_validation_validator_errors(self): - '''test errors in the validator that are unrelated to the validation functionality''' + """test errors in the validator that are unrelated to the validation functionality""" err_str = "Please supply either a schema or a schema file path" with self.assertRaisesRegex(ValueError, err_str): @@ -144,45 +142,43 @@ def test_non_validation_validator_errors(self): # only supply one of schema or schema_file with self.assertRaisesRegex(ValueError, err_str): - run_validator(schema={}, schema_file='/path/to/file') + run_validator(schema={}, schema_file="/path/to/file") err_str = "Please supply either a data structure or a data file path" with self.assertRaisesRegex(ValueError, err_str): run_validator(schema={}) with self.assertRaisesRegex(ValueError, err_str): - run_validator(schema={}, data={}, data_file='') + run_validator(schema={}, data={}, data_file="") with self.assertRaisesRegex(ValueError, err_str): run_validator(schema={}, data=None, data_file=None) # invalid file type - test_file = os_path.join(*(test_data_dirs + ['test_file.md'])) - err_msg = f'Unknown file type encountered: {test_file}' + test_file = os_path.join(*(test_data_dirs + ["test_file.md"])) + err_msg = f"Unknown file type encountered: {test_file}" with self.assertRaisesRegex(TypeError, err_msg): run_validator(schema_file=test_file, data={}) # invalid jsonpointer string - note the grammar error is from jsonpointer - err_str = 'location must starts with /' - json_loc = 'start validating here' + err_str = "location must starts with /" + json_loc = "start validating here" with self.assertRaisesRegex(JsonPointerException, err_str): run_validator(schema=test_schema, data={}, validate_at=json_loc) # invalid jsonpointer ref err_str = "member 'property' not found in" - json_loc = '/properties/params/property' + json_loc = "/properties/params/property" with self.assertRaisesRegex(JsonPointerException, err_str): run_validator(schema=test_schema, data={}, validate_at=json_loc) # finally!! output = run_validator( - schema=test_schema, - data={'name': 'name', 'distance': 3}, - validate_at=valid_json_loc) - self.assertEqual( - output, - {**schema_defaults, **{'name': 'name', 'distance': 3}} + schema=test_schema, + data={"name": "name", "distance": 3}, + validate_at=valid_json_loc, ) + self.assertEqual(output, {**schema_defaults, **{"name": "name", "distance": 3}}) def test_json_validation(self): """ Generic JSON validation tests to ensure that all is working as expected """ @@ -199,7 +195,7 @@ def test_json_validation(self): for test_schema in test_schema_list: schema_file_arg = schema_arg = test_schema[1] - if test_schema[0] == 'schema': + if test_schema[0] == "schema": schema_file_arg = None else: schema_arg = None @@ -208,26 +204,29 @@ def test_json_validation(self): with self.subTest(test_name=test_name.__name__): test_name(schema_arg, schema_file_arg) - def execute_tests(self, schema_arg, schema_file_arg, tests, file_types=[None, 'json', 'yaml']): + def execute_tests( + self, schema_arg, schema_file_arg, tests, file_types=[None, "json", "yaml"] + ): for t in tests: for file_ext in file_types: - data = t['input'] + data = t["input"] data_file = os_path.join(json_validation_dir, f"{t['file']}.{file_ext}") if file_ext is None: data_file = None else: data = None - with self.subTest(input=t['input'], file_type=file_ext): - if 'err_str' in t: - with self.assertRaisesRegex(ValidationError, t['err_str']): + with self.subTest(input=t["input"], file_type=file_ext): + if "err_str" in t: + with self.assertRaisesRegex(ValidationError, t["err_str"]): run_validator( schema=schema_arg, schema_file=schema_file_arg, data=data, data_file=data_file, - validate_at=valid_json_loc) + validate_at=valid_json_loc, + ) else: output = run_validator( @@ -235,14 +234,9 @@ def execute_tests(self, schema_arg, schema_file_arg, tests, file_types=[None, 'j schema_file=schema_file_arg, data=data, data_file=data_file, - validate_at=valid_json_loc) - self.assertEqual( - output, - { - **schema_defaults, - **t['output'] - } + validate_at=valid_json_loc, ) + self.assertEqual(output, {**schema_defaults, **t["output"]}) def test_add_defaults(self, schema_arg=None, schema_file_arg=None): """Test that the jsonschema validator sets default values.""" @@ -254,16 +248,16 @@ def test_add_defaults(self, schema_arg=None, schema_file_arg=None): tests = [ { - 'input': {}, - 'file': 'defaults', - 'output': schema_defaults, + "input": {}, + "file": "defaults", + "output": schema_defaults, } ] self.execute_tests(schema_arg, schema_file_arg, tests) def test_pattern_validation(self, schema_arg=None, schema_file_arg=None): - '''Test pattern validation''' + """Test pattern validation""" # skip if the test is not being called from test_json_validation if schema_arg is None and schema_file_arg is None: @@ -272,23 +266,26 @@ def test_pattern_validation(self, schema_arg=None, schema_file_arg=None): tests = [ { - 'input': {"name": "what's-the-problem with-this-string?", "distance": 3}, - 'file': 'invalid_pattern', - 'err_str': '"what\'s-the-problem with-this-string\?" does not match .*?', + "input": { + "name": "what's-the-problem with-this-string?", + "distance": 3, + }, + "file": "invalid_pattern", + "err_str": '"what\'s-the-problem with-this-string\?" does not match .*?', }, { - 'input': {"name": "No_problem_with_this_string", "distance": 3}, - 'file': 'valid_pattern', - 'output': { - 'name': 'No_problem_with_this_string', - 'distance': 3, - } - } + "input": {"name": "No_problem_with_this_string", "distance": 3}, + "file": "valid_pattern", + "output": { + "name": "No_problem_with_this_string", + "distance": 3, + }, + }, ] self.execute_tests(schema_arg, schema_file_arg, tests) def test_uri_validation(self, schema_arg=None, schema_file_arg=None): - '''Test URI validation is operational''' + """Test URI validation is operational""" # skip if the test is not being called from test_json_validation if schema_arg is None and schema_file_arg is None: @@ -297,29 +294,29 @@ def test_uri_validation(self, schema_arg=None, schema_file_arg=None): tests = [ { - 'input': { - 'name': 'valid_uri', - 'distance': 3, - "home_page": "http://json-validation.com:5000/this/is/valid" + "input": { + "name": "valid_uri", + "distance": 3, + "home_page": "http://json-validation.com:5000/this/is/valid", + }, + "file": "valid_uri", + "output": { + "name": "valid_uri", + "distance": 3, + "home_page": "http://json-validation.com:5000/this/is/valid", }, - 'file': 'valid_uri', - 'output': { - 'name': 'valid_uri', - 'distance': 3, - "home_page": "http://json-validation.com:5000/this/is/valid" - } }, { - 'input': {'name': 'invalid_uri', 'home_page': 'where is it?'}, - 'file': 'invalid_uri', - 'err_str': "'where is it\?' is not a 'uri'" + "input": {"name": "invalid_uri", "home_page": "where is it?"}, + "file": "invalid_uri", + "err_str": "'where is it\?' is not a 'uri'", }, ] self.execute_tests(schema_arg, schema_file_arg, tests) def test_date_format_validation(self, schema_arg=None, schema_file_arg=None): - '''ensure that fancy date formats are correctly validated''' + """ensure that fancy date formats are correctly validated""" # skip if the test is not being called from test_json_validation if schema_arg is None and schema_file_arg is None: @@ -328,38 +325,39 @@ def test_date_format_validation(self, schema_arg=None, schema_file_arg=None): tests = [ { - 'input': {'date': '20200606'}, - 'file': 'invalid_date', - 'err_str': "'20200606' is not a 'date'", + "input": {"date": "20200606"}, + "file": "invalid_date", + "err_str": "'20200606' is not a 'date'", }, { - 'input': {'date': 20200606}, - 'file': 'invalid_date_type', - 'err_str': "20200606 is not of type 'string'" + "input": {"date": 20200606}, + "file": "invalid_date_type", + "err_str": "20200606 is not of type 'string'", }, { - 'input': {"name": "valid_date", "date": "2020-06-06", "distance": 3}, - 'file': 'valid_date', - 'output': { + "input": {"name": "valid_date", "date": "2020-06-06", "distance": 3}, + "file": "valid_date", + "output": { **schema_defaults, "name": "valid_date", "date": "2020-06-06", "distance": 3, - } - } + }, + }, ] self.execute_tests(schema_arg, schema_file_arg, tests) # pyyaml-specific issue: dates get automatically parsed into datetime objects (doh!) - file_path = os_path.join(json_validation_dir, 'unquoted_date.yaml') + file_path = os_path.join(json_validation_dir, "unquoted_date.yaml") err_str = "datetime.date\(2020, 6, 6\) is not of type 'string'" with self.assertRaisesRegex(ValidationError, err_str): run_validator( schema=schema_arg, schema_file=schema_file_arg, data_file=file_path, - validate_at=valid_json_loc) + validate_at=valid_json_loc, + ) def test_array_validation(self, schema_arg=None, schema_file_arg=None): """ @@ -384,69 +382,56 @@ def test_array_validation(self, schema_arg=None, schema_file_arg=None): # test the use of refs when populating defaults tests = [ { - 'fruits': fruit_ref, - 'name': 'using fruit.yaml -- array item is a ref', - 'output': { - 'params': { - 'name': 'name', - 'distance': 1, - 'fruits': [] - } - } + "fruits": fruit_ref, + "name": "using fruit.yaml -- array item is a ref", + "output": {"params": {"name": "name", "distance": 1, "fruits": []}}, }, { # N.b. the default does not get populated in this case! # This is a change from the expected functionality - 'fruits': fruits_array_ref, - 'name': 'using fruits_array.yaml -- the array is a ref', - 'output': { - 'params': { - 'name': 'name', - 'distance': 1, + "fruits": fruits_array_ref, + "name": "using fruits_array.yaml -- the array is a ref", + "output": { + "params": { + "name": "name", + "distance": 1, } - } + }, }, { - 'fruits': fruits_explicit, - 'name': 'with no references', - 'output': { - 'params': { - 'name': 'name', - 'distance': 1, - 'fruits': [] - } - } - } + "fruits": fruits_explicit, + "name": "with no references", + "output": {"params": {"name": "name", "distance": 1, "fruits": []}}, + }, ] for t in tests: - with self.subTest(desc=t['name']): - test_schema['properties']['params']['properties']['fruits'] = t['fruits'] + with self.subTest(desc=t["name"]): + test_schema["properties"]["params"]["properties"]["fruits"] = t[ + "fruits" + ] output = run_validator( - schema=test_schema, - data={'params': {'name': 'name'}} + schema=test_schema, data={"params": {"name": "name"}} ) - self.assertEqual(output, t['output']) + self.assertEqual(output, t["output"]) # restore the original value - test_schema['properties']['params']['properties']['fruits'] = fruits_explicit + test_schema["properties"]["params"]["properties"]["fruits"] = fruits_explicit def test_schema_references(self): """Ensure referenced schemas, including those written in yaml, can be accessed.""" # same schema in different places - path_list = [ - [], - ['level_1'], - ['level_1', 'level_2'] - ] + path_list = [[], ["level_1"], ["level_1", "level_2"]] err_msg = "'whatever' is not valid under any of the given schemas" for path in path_list: - for file_ext in ['json', 'yaml']: + for file_ext in ["json", "yaml"]: with self.subTest(file_ext=file_ext): - file_path = os_path.join(*(test_data_dirs + ['schema_refs'] + path), 'edge.' + file_ext) + file_path = os_path.join( + *(test_data_dirs + ["schema_refs"] + path), "edge." + file_ext + ) # fails due to invalid data with self.assertRaisesRegex(ValidationError, err_msg): @@ -461,58 +446,59 @@ def test_schema_references(self): schema_file=file_path, data=valid_edge_data, ), - valid_edge_data + valid_edge_data, ) # validate using the schema instead of the schema_file with open(file_path) as fd: - contents = yaml.safe_load(fd) if file_ext == 'yaml' else json.load(fd) + contents = ( + yaml.safe_load(fd) if file_ext == "yaml" else json.load(fd) + ) # if there is no $id in the schema, the ref resolver won't know # where the schema file is located and will not resolve relative references - with self.assertRaisesRegex(RefResolutionError, 'No such file or directory'): - run_validator( - schema=contents, - data=valid_edge_data - ) + with self.assertRaisesRegex( + RefResolutionError, "No such file or directory" + ): + run_validator(schema=contents, data=valid_edge_data) # inject an $id with the current file path - contents['$id'] = file_path + contents["$id"] = file_path self.assertEqual( run_validator( schema=contents, data=valid_edge_data, ), - valid_edge_data + valid_edge_data, ) def test_complex_schema_references(self): """test validation with complex references that reference other references""" valid_data = { - 'node': { - 'id': 'TAIR:19830', - 'type': 'gene', - }, - 'edge': valid_edge_data, - 'marks_out_of_ten': 5 + "node": { + "id": "TAIR:19830", + "type": "gene", + }, + "edge": valid_edge_data, + "marks_out_of_ten": 5, } invalid_data = { - 'node': { - 'id': 'TAIR:19830', - 'type': 'gene', - }, - 'edge': invalid_edge_data, - 'marks_out_of_ten': 5 + "node": { + "id": "TAIR:19830", + "type": "gene", + }, + "edge": invalid_edge_data, + "marks_out_of_ten": 5, } err_msg = "'whatever' is not valid under any of the given schemas" - for file_ext in ['json', 'yaml']: + for file_ext in ["json", "yaml"]: with self.subTest(file_ext=file_ext): file_path = os_path.join( - *(test_data_dirs + ['schema_refs', 'level_1']), - 'test_object.' + file_ext + *(test_data_dirs + ["schema_refs", "level_1"]), + "test_object." + file_ext, ) # data fails validation @@ -527,5 +513,5 @@ def test_complex_schema_references(self): schema_file=file_path, data=valid_data, ), - valid_data + valid_data, ) diff --git a/relation_engine_server/test/test_spec_loader.py b/relation_engine_server/test/test_spec_loader.py index 4b21b628..746949b1 100644 --- a/relation_engine_server/test/test_spec_loader.py +++ b/relation_engine_server/test/test_spec_loader.py @@ -12,29 +12,28 @@ class TestSpecLoader(unittest.TestCase): - @classmethod def setUpClass(cls): - cls.test_dir = os_path.join('/app', 'relation_engine_server', 'test') - cls.test_spec_dir = os_path.join(cls.test_dir, 'spec_release', 'sample_spec_release', 'spec') + cls.test_dir = os_path.join("/app", "relation_engine_server", "test") + cls.test_spec_dir = os_path.join( + cls.test_dir, "spec_release", "sample_spec_release", "spec" + ) cls.config = get_config() - cls.repo_path = cls.config['spec_paths']['root'] - for key in cls.config['spec_paths'].keys(): - if cls.repo_path in cls.config['spec_paths'][key]: - cls.config['spec_paths'][key] = cls.config['spec_paths'][key].replace( - cls.repo_path, - cls.test_spec_dir + cls.repo_path = cls.config["spec_paths"]["root"] + for key in cls.config["spec_paths"].keys(): + if cls.repo_path in cls.config["spec_paths"][key]: + cls.config["spec_paths"][key] = cls.config["spec_paths"][key].replace( + cls.repo_path, cls.test_spec_dir ) @classmethod def tearDownClass(cls): # undo all the config changes - for key in cls.config['spec_paths'].keys(): - if cls.test_spec_dir in cls.config['spec_paths'][key]: - cls.config['spec_paths'][key] = cls.config['spec_paths'][key].replace( - cls.test_spec_dir, - cls.repo_path + for key in cls.config["spec_paths"].keys(): + if cls.test_spec_dir in cls.config["spec_paths"][key]: + cls.config["spec_paths"][key] = cls.config["spec_paths"][key].replace( + cls.test_spec_dir, cls.repo_path ) def test_get_names(self, schema_type_names=[], expected=[]): @@ -47,23 +46,27 @@ def test_get_names(self, schema_type_names=[], expected=[]): schema_type_singular = schema_type_names[0] schema_type_plural = schema_type_names[1] - method = getattr(spec_loader, 'get_' + schema_type_singular + '_names') + method = getattr(spec_loader, "get_" + schema_type_singular + "_names") # save the original value - original_config_dir = self.config['spec_paths'][schema_type_plural] + original_config_dir = self.config["spec_paths"][schema_type_plural] # set the config to the test directory - self.config['spec_paths'][schema_type_plural] = os_path.join(self.test_dir, 'data', schema_type_plural) + self.config["spec_paths"][schema_type_plural] = os_path.join( + self.test_dir, "data", schema_type_plural + ) got_names_method = method() got_names_singular = spec_loader.get_names(schema_type_singular) got_names_plural = spec_loader.get_names(schema_type_plural) - self.config['spec_paths'][schema_type_plural] = os_path.join(self.test_dir, 'data', 'empty') + self.config["spec_paths"][schema_type_plural] = os_path.join( + self.test_dir, "data", "empty" + ) got_names_method_empty = method() got_names_empty = spec_loader.get_names(schema_type_singular) # restore the original value before running tests - self.config['spec_paths'][schema_type_plural] = original_config_dir + self.config["spec_paths"][schema_type_plural] = original_config_dir # ensure the results are as expected # get_collection_names @@ -88,42 +91,48 @@ def test_run_spec_loading_tests(self, schema_type_names=[], test_name=None): schema_type_singular = schema_type_names[0] schema_type_plural = schema_type_names[1] # e.g. 'spec_loader.get_collection' - method = getattr(spec_loader, 'get_' + schema_type_singular) + method = getattr(spec_loader, "get_" + schema_type_singular) # get the path of the requested file result_path = method(test_name, path_only=True) self.assertIsInstance(result_path, str) self.assertIn(test_name, result_path) self.assertIn( - self.config['spec_paths'][schema_type_plural], + self.config["spec_paths"][schema_type_plural], result_path, ) # use get_schema directly to get the file path for schema_type in schema_type_names: self.assertEqual( - result_path, - spec_loader.get_schema(schema_type, test_name, True) + result_path, spec_loader.get_schema(schema_type, test_name, True) ) # get the file contents result_obj = method(test_name) self.assertIs(type(result_obj), dict) - self.assertEqual(result_obj['name'], test_name) + self.assertEqual(result_obj["name"], test_name) # check the contents of the dict when getting a data source - if schema_type_singular == 'data_source': + if schema_type_singular == "data_source": # logo_url should start with the same base as config['kbase_endpoint'] - endpoint = urlparse(self.config['kbase_endpoint']) - self.assertIn(endpoint.scheme + '://' + endpoint.netloc, result_obj['logo_url']) + endpoint = urlparse(self.config["kbase_endpoint"]) + self.assertIn( + endpoint.scheme + "://" + endpoint.netloc, result_obj["logo_url"] + ) # logo_path is deleted - self.assertNotIn('logo_path', result_obj.keys()) + self.assertNotIn("logo_path", result_obj.keys()) # a nonexistent file raises the appropriate error - fake_name = 'test/test_node' - err_msg = schema_type_singular.capitalize().replace("_", " ") + " '" + fake_name + "' does not exist." + fake_name = "test/test_node" + err_msg = ( + schema_type_singular.capitalize().replace("_", " ") + + " '" + + fake_name + + "' does not exist." + ) with self.assertRaisesRegex(SchemaNonexistent, err_msg): method(fake_name, path_only=True) @@ -133,56 +142,65 @@ def test_get_schemas_of_various_types(self): schema_type_list = [ { # schema_type_names: singular, plural - 'schema_type_names': ['collection', 'collections'], - 'example': 'ncbi_taxon', - 'names': ['core', 'edge', 'point', 'test_another_node', 'test_edge', 'test_node'], + "schema_type_names": ["collection", "collections"], + "example": "ncbi_taxon", + "names": [ + "core", + "edge", + "point", + "test_another_node", + "test_edge", + "test_node", + ], }, { - 'schema_type_names': ['data_source', 'data_sources'], - 'example': 'ncbi_taxonomy', + "schema_type_names": ["data_source", "data_sources"], + "example": "ncbi_taxonomy", }, { - 'schema_type_names': ['stored_query', 'stored_queries'], - 'example': 'ncbi_fetch_taxon', + "schema_type_names": ["stored_query", "stored_queries"], + "example": "ncbi_fetch_taxon", }, { - 'schema_type_names': ['view', 'views'], - 'example': 'test_vertices', - } + "schema_type_names": ["view", "views"], + "example": "test_vertices", + }, ] for schema in schema_type_list: - with self.subTest(schema=schema['schema_type_names'][0]): - self.test_run_spec_loading_tests(schema['schema_type_names'], schema['example']) - if 'names' in schema: - self.test_get_names(schema['schema_type_names'], schema['names']) + with self.subTest(schema=schema["schema_type_names"][0]): + self.test_run_spec_loading_tests( + schema["schema_type_names"], schema["example"] + ) + if "names" in schema: + self.test_get_names(schema["schema_type_names"], schema["names"]) def test_non_existent_schema(self): - err_msg = 'Reality does not exist' + err_msg = "Reality does not exist" with self.assertRaisesRegex(SchemaNonexistent, err_msg): - spec_loader.get_names('Reality') + spec_loader.get_names("Reality") def test_get_schema_for_doc(self): """test getting the schema for a specific document""" - test_name = 'ncbi_taxon' - test_doc = test_name + '/12345' + test_name = "ncbi_taxon" + test_doc = test_name + "/12345" # get the path of the requested file result_path = spec_loader.get_schema_for_doc(test_doc, path_only=True) self.assertIsInstance(result_path, str) self.assertIn(test_name, result_path) self.assertIn( - self.config['spec_paths']['collections'], + self.config["spec_paths"]["collections"], result_path, ) # get the file contents result_obj = spec_loader.get_schema_for_doc(test_doc) self.assertIs(type(result_obj), dict) - self.assertEqual(result_obj['name'], test_name) + self.assertEqual(result_obj["name"], test_name) - fake_name = 'fake_name/12345' + fake_name = "fake_name/12345" # a nonexistent file raises the appropriate error err_msg = f"Collection 'fake_name' does not exist." with self.assertRaisesRegex(SchemaNonexistent, err_msg): @@ -194,15 +212,21 @@ def test_prevent_non_spec_dir_access(self): """ # this query is OK as the file is still in the spec repo - path_in_spec_repo = '../../../../../**/fetch_test_vertex' - result = spec_loader.get_schema('stored_queries', path_in_spec_repo, path_only=True) + path_in_spec_repo = "../../../../../**/fetch_test_vertex" + result = spec_loader.get_schema( + "stored_queries", path_in_spec_repo, path_only=True + ) self.assertEqual( result, - os_path.join(self.test_spec_dir, 'stored_queries', 'test', 'fetch_test_vertex.yaml') + os_path.join( + self.test_spec_dir, "stored_queries", "test", "fetch_test_vertex.yaml" + ), ) # this matches a file in one of the other test data dirs => should throw an error - path_outside_spec_repo = '../../../../data/collections/test_node' + path_outside_spec_repo = "../../../../data/collections/test_node" err_msg = f"Stored query '{path_outside_spec_repo}' does not exist" with self.assertRaisesRegex(SchemaNonexistent, err_msg): - spec_loader.get_schema('stored_queries', path_outside_spec_repo, path_only=True) + spec_loader.get_schema( + "stored_queries", path_outside_spec_repo, path_only=True + ) diff --git a/relation_engine_server/utils/arango_client.py b/relation_engine_server/utils/arango_client.py index 18cbafbc..6bdba09c 100644 --- a/relation_engine_server/utils/arango_client.py +++ b/relation_engine_server/utils/arango_client.py @@ -13,54 +13,56 @@ def server_status(): """Get the status of our connection and authorization to the ArangoDB server.""" - auth = (_CONF['db_user'], _CONF['db_pass']) + auth = (_CONF["db_user"], _CONF["db_pass"]) adb_url = f"{_CONF['api_url']}/version" try: resp = requests.get(adb_url, auth=auth) except requests.exceptions.ConnectionError: - return 'no_connection' + return "no_connection" if resp.ok: - return 'connected_authorized' + return "connected_authorized" elif resp.status_code == 401: - return 'unauthorized' + return "unauthorized" else: - return 'unknown_failure' + return "unknown_failure" -def run_query(query_text=None, cursor_id=None, bind_vars=None, batch_size=10000, full_count=False): +def run_query( + query_text=None, cursor_id=None, bind_vars=None, batch_size=10000, full_count=False +): """Run a query using the arangodb http api. Can return a cursor to get more results.""" - url = _CONF['api_url'] + '/cursor' + url = _CONF["api_url"] + "/cursor" req_json = { - 'batchSize': min(5000, batch_size), - 'memoryLimit': 16000000000, # 16gb + "batchSize": min(5000, batch_size), + "memoryLimit": 16000000000, # 16gb } if cursor_id: - method = 'PUT' - url += '/' + cursor_id + method = "PUT" + url += "/" + cursor_id else: - method = 'POST' - req_json['count'] = True - req_json['query'] = query_text + method = "POST" + req_json["count"] = True + req_json["query"] = query_text if full_count: - req_json['options'] = {'fullCount': True} + req_json["options"] = {"fullCount": True} if bind_vars: - req_json['bindVars'] = bind_vars + req_json["bindVars"] = bind_vars # Run the query as the readonly user resp = requests.request( method, url, data=json.dumps(req_json), - auth=(_CONF['db_readonly_user'], _CONF['db_readonly_pass']) + auth=(_CONF["db_readonly_user"], _CONF["db_readonly_pass"]), ) resp_json = resp.json() - if not resp.ok or resp_json['error']: + if not resp.ok or resp_json["error"]: raise ArangoServerError(resp.text) return { - 'results': resp_json['result'], - 'count': resp_json['count'], - 'has_more': resp_json['hasMore'], - 'cursor_id': resp_json.get('id'), - 'stats': resp_json['extra']['stats'] + "results": resp_json["result"], + "count": resp_json["count"], + "has_more": resp_json["hasMore"], + "cursor_id": resp_json.get("id"), + "stats": resp_json["extra"]["stats"], } @@ -70,57 +72,61 @@ def create_collection(name, config): We ignore duplicates. For any other server error, an exception is thrown. Shard the new collection based on the number of db nodes (10 shards for each). """ - is_edge = config['type'] == 'edge' - num_shards = int(os.environ.get('SHARD_COUNT', 30)) - url = _CONF['api_url'] + '/collection' + is_edge = config["type"] == "edge" + num_shards = int(os.environ.get("SHARD_COUNT", 30)) + url = _CONF["api_url"] + "/collection" # collection types: # 2 is a document collection # 3 is an edge collection collection_type = 3 if is_edge else 2 print(f"Creating collection {name} (edge: {is_edge})") - data = json.dumps({ - 'keyOptions': {'allowUserKeys': True}, - 'name': name, - 'type': collection_type, - 'numberOfShards': num_shards, - 'waitForSync': True, - }) - resp = requests.post(url, data, auth=(_CONF['db_user'], _CONF['db_pass'])) + data = json.dumps( + { + "keyOptions": {"allowUserKeys": True}, + "name": name, + "type": collection_type, + "numberOfShards": num_shards, + "waitForSync": True, + } + ) + resp = requests.post(url, data, auth=(_CONF["db_user"], _CONF["db_pass"])) resp_json = resp.json() if not resp.ok: - if 'duplicate' not in resp_json['errorMessage']: + if "duplicate" not in resp_json["errorMessage"]: # Unable to create a collection raise ArangoServerError(resp.text) - print(f'Successfully created collection {name}') - if config.get('indexes'): + print(f"Successfully created collection {name}") + if config.get("indexes"): _create_indexes(name, config) def _create_indexes(coll_name, config): """Create indexes for a collection""" - url = _CONF['api_url'] + '/index' + url = _CONF["api_url"] + "/index" # Fetch existing indexes - auth = (_CONF['db_user'], _CONF['db_pass']) - resp = requests.get(url, params={'collection': coll_name}, auth=auth) + auth = (_CONF["db_user"], _CONF["db_pass"]) + resp = requests.get(url, params={"collection": coll_name}, auth=auth) if not resp.ok: raise RuntimeError(resp.text) - indexes = resp.json()['indexes'] - for idx_conf in config['indexes']: + indexes = resp.json()["indexes"] + for idx_conf in config["indexes"]: if _index_exists(idx_conf, indexes): continue - idx_type = idx_conf['type'] - idx_url = url + '#' + idx_type - idx_conf['type'] = idx_type - print(f'Creating {idx_type} index for collection {coll_name}: {idx_conf}') + idx_type = idx_conf["type"] + idx_url = url + "#" + idx_type + idx_conf["type"] = idx_type + print(f"Creating {idx_type} index for collection {coll_name}: {idx_conf}") resp = requests.post( idx_url, - params={'collection': coll_name}, + params={"collection": coll_name}, data=json.dumps(idx_conf), auth=auth, ) if not resp.ok: raise RuntimeError(resp.text) - print(f'Successfully created {idx_type} index on {idx_conf["fields"]} for {coll_name}.') + print( + f'Successfully created {idx_type} index on {idx_conf["fields"]} for {coll_name}.' + ) def _index_exists(idx_conf, indexes): @@ -130,27 +136,27 @@ def _index_exists(idx_conf, indexes): indexes - result of request to arangodb's /_api/index?collection=coll_name """ for idx in indexes: - if idx_conf['fields'] == idx['fields'] and idx_conf['type'] == idx['type']: + if idx_conf["fields"] == idx["fields"] and idx_conf["type"] == idx["type"]: return True return False def import_from_file(file_path, query): """Import documents from a file.""" - with open(file_path, 'rb') as file_desc: + with open(file_path, "rb") as file_desc: resp = requests.post( - _CONF['api_url'] + '/import', + _CONF["api_url"] + "/import", data=file_desc, - auth=(_CONF['db_user'], _CONF['db_pass']), - params=query + auth=(_CONF["db_user"], _CONF["db_pass"]), + params=query, ) if not resp.ok: raise ArangoServerError(resp.text) resp_json = resp.json() - if resp_json.get('errors', 0) > 0: + if resp_json.get("errors", 0) > 0: err_msg = f"{resp_json['errors']} errors creating documents\n" sys.stderr.write(err_msg) - details = resp_json.get('details') + details = resp_json.get("details") if details: sys.stderr.write(f"Error details:\n{details[0]}\n") return resp_json @@ -162,18 +168,18 @@ def create_view(name, config): For any other server error, an exception is thrown. """ - url = _CONF['api_url'] + '/view#arangosearch' + url = _CONF["api_url"] + "/view#arangosearch" - if 'name' not in config: - config['name'] = name - if 'type' not in config: - config['type'] = 'arangosearch' + if "name" not in config: + config["name"] = name + if "type" not in config: + config["type"] = "arangosearch" print(f"Creating view {name}") data = json.dumps(config) - resp = requests.post(url, data, auth=(_CONF['db_user'], _CONF['db_pass'])) + resp = requests.post(url, data, auth=(_CONF["db_user"], _CONF["db_pass"])) resp_json = resp.json() if not resp.ok: - if 'duplicate' not in resp_json['errorMessage']: + if "duplicate" not in resp_json["errorMessage"]: # Unable to create the view raise ArangoServerError(resp.text) @@ -186,4 +192,4 @@ def __init__(self, resp_text): self.resp_json = json.loads(resp_text) def __str__(self): - return 'ArangoDB server error.' + return "ArangoDB server error." diff --git a/relation_engine_server/utils/auth.py b/relation_engine_server/utils/auth.py index d3a3f991..9d8f3096 100644 --- a/relation_engine_server/utils/auth.py +++ b/relation_engine_server/utils/auth.py @@ -18,32 +18,34 @@ def require_auth_token(roles=[]): Raises some exception if any auth requirement is not met. """ config = get_config() - if not flask.request.headers.get('Authorization'): + if not flask.request.headers.get("Authorization"): # No authorization token was provided in the headers - raise MissingHeader('Authorization') + raise MissingHeader("Authorization") token = get_auth_header() # Make an authorization request to the kbase auth2 server - headers = {'Authorization': token} - auth_url = config['auth_url'] + '/api/V2/me' + headers = {"Authorization": token} + auth_url = config["auth_url"] + "/api/V2/me" auth_resp = requests.get(auth_url, headers=headers) if not auth_resp.ok: - print('-' * 80) + print("-" * 80) print(auth_resp.text) - raise UnauthorizedAccess(config['auth_url'], auth_resp.text) + raise UnauthorizedAccess(config["auth_url"], auth_resp.text) auth_json = auth_resp.json() if len(roles): - check_roles(required=roles, given=auth_json['customroles'], auth_url=config['auth_url']) + check_roles( + required=roles, given=auth_json["customroles"], auth_url=config["auth_url"] + ) def check_roles(required, given, auth_url): for role in required: if role in given: return - raise UnauthorizedAccess(auth_url, 'Missing role') + raise UnauthorizedAccess(auth_url, "Missing role") def get_auth_header(): - return flask.request.headers.get('Authorization', '').replace('Bearer', '').strip() + return flask.request.headers.get("Authorization", "").replace("Bearer", "").strip() def get_workspace_ids(auth_token): @@ -52,19 +54,15 @@ def get_workspace_ids(auth_token): if not auth_token: return [] # anonymous users config = get_config() - ws_url = config['workspace_url'] + ws_url = config["workspace_url"] # Make an admin request to the workspace (command is 'listWorkspaceIds') payload = { - 'method': 'Workspace.list_workspace_ids', - 'version': '1.1', - 'params': [{'perm': 'r'}] + "method": "Workspace.list_workspace_ids", + "version": "1.1", + "params": [{"perm": "r"}], } - headers = {'Authorization': auth_token} - resp = requests.post( - ws_url, - data=json.dumps(payload), - headers=headers - ) + headers = {"Authorization": auth_token} + resp = requests.post(ws_url, data=json.dumps(payload), headers=headers) if not resp.ok: raise UnauthorizedAccess(ws_url, resp.text) - return resp.json()['result'][0]['workspaces'] + return resp.json()["result"][0]["workspaces"] diff --git a/relation_engine_server/utils/bulk_import.py b/relation_engine_server/utils/bulk_import.py index fbd1c6c3..543ffba0 100644 --- a/relation_engine_server/utils/bulk_import.py +++ b/relation_engine_server/utils/bulk_import.py @@ -16,12 +16,12 @@ def bulk_import(query_params): schema, then write them into a temporary file that can be passed into the arango client. """ - schema_file = get_collection(query_params['collection'], path_only=True) - validator = get_schema_validator(schema_file=schema_file, validate_at='/schema') + schema_file = get_collection(query_params["collection"], path_only=True) + validator = get_schema_validator(schema_file=schema_file, validate_at="/schema") # We can't use a context manager here # We need to close the file to have the file contents readable # and we need to prevent deletion of the temp file on close (default behavior of tempfiles) - temp_fd = tempfile.NamedTemporaryFile(mode='a', delete=False) + temp_fd = tempfile.NamedTemporaryFile(mode="a", delete=False) try: # Stream request data line-by-line # Parse each line to json, validate the schema, and write to a file @@ -29,8 +29,8 @@ def bulk_import(query_params): json_line = json.loads(line) validator.validate(json_line) json_line = _write_edge_key(json_line) - json_line['updated_at'] = int(time.time() * 1000) - temp_fd.write(json.dumps(json_line) + '\n') + json_line["updated_at"] = int(time.time() * 1000) + temp_fd.write(json.dumps(json_line) + "\n") temp_fd.close() resp_json = import_from_file(temp_fd.name, query_params) finally: @@ -42,7 +42,7 @@ def bulk_import(query_params): def _write_edge_key(json_line): """For edges, we want a deterministic key so there are no duplicates.""" if "_key" not in json_line and "_from" in json_line and "_to" in json_line: - json_line['_key'] = hashlib.blake2b( + json_line["_key"] = hashlib.blake2b( json_line["_from"].encode() + json_line["_to"].encode(), digest_size=8 ).hexdigest() return json_line diff --git a/relation_engine_server/utils/config.py b/relation_engine_server/utils/config.py index 08d85443..322f8790 100644 --- a/relation_engine_server/utils/config.py +++ b/relation_engine_server/utils/config.py @@ -9,48 +9,50 @@ @functools.lru_cache(maxsize=1) def get_config(): """Load environment configuration data.""" - spec_path = os.environ.get('SPEC_PATH', '/spec') # /spec + spec_path = os.environ.get("SPEC_PATH", "/spec") # /spec # The root url of a remote git repo that holds the specifications (ie. this repo) - spec_repo_url = os.environ.get('SPEC_REPO_URL') + spec_repo_url = os.environ.get("SPEC_REPO_URL") # The specific URL of the spec tarball - spec_release_url = os.environ.get('SPEC_RELEASE_URL') + spec_release_url = os.environ.get("SPEC_RELEASE_URL") # The specific local path of the spec tarball - spec_release_path = os.environ.get('SPEC_RELEASE_PATH') + spec_release_path = os.environ.get("SPEC_RELEASE_PATH") - kbase_endpoint = os.environ.get('KBASE_ENDPOINT', 'https://ci.kbase.us/services') - auth_url = os.environ.get('KBASE_AUTH_URL', urljoin(kbase_endpoint + '/', 'auth')) - workspace_url = os.environ.get('KBASE_WORKSPACE_URL', urljoin(kbase_endpoint + '/', 'ws')) + kbase_endpoint = os.environ.get("KBASE_ENDPOINT", "https://ci.kbase.us/services") + auth_url = os.environ.get("KBASE_AUTH_URL", urljoin(kbase_endpoint + "/", "auth")) + workspace_url = os.environ.get( + "KBASE_WORKSPACE_URL", urljoin(kbase_endpoint + "/", "ws") + ) - db_url = os.environ.get('DB_URL', 'http://arangodb:8529') - db_name = os.environ.get('DB_NAME', '_system') - db_user = os.environ.get('DB_USER', 'root') - db_pass = os.environ.get('DB_PASS', '') - db_readonly_user = os.environ.get('DB_READONLY_USER', db_user) - db_readonly_pass = os.environ.get('DB_READONLY_PASS', db_pass) - api_url = db_url + '/_db/' + db_name + '/_api' + db_url = os.environ.get("DB_URL", "http://arangodb:8529") + db_name = os.environ.get("DB_NAME", "_system") + db_user = os.environ.get("DB_USER", "root") + db_pass = os.environ.get("DB_PASS", "") + db_readonly_user = os.environ.get("DB_READONLY_USER", db_user) + db_readonly_pass = os.environ.get("DB_READONLY_PASS", db_pass) + api_url = db_url + "/_db/" + db_name + "/_api" return { - 'auth_url': auth_url, - 'workspace_url': workspace_url, - 'kbase_endpoint': kbase_endpoint, - 'db_url': db_url, - 'api_url': api_url, - 'db_name': db_name, - 'db_user': db_user, - 'db_pass': db_pass, - 'db_readonly_user': db_readonly_user, - 'db_readonly_pass': db_readonly_pass, - 'spec_repo_url': spec_repo_url, - 'spec_release_url': spec_release_url, - 'spec_release_path': spec_release_path, - 'spec_paths': { - 'root': spec_path, # /spec - 'release_id': os.path.join(spec_path, '.release_id'), - 'collections': os.path.join(spec_path, 'collections'), # /spec/collections - 'datasets': os.path.join(spec_path, 'datasets'), - 'data_sources': os.path.join(spec_path, 'data_sources'), - 'stored_queries': os.path.join(spec_path, 'stored_queries'), - 'views': os.path.join(spec_path, 'views'), - } + "auth_url": auth_url, + "workspace_url": workspace_url, + "kbase_endpoint": kbase_endpoint, + "db_url": db_url, + "api_url": api_url, + "db_name": db_name, + "db_user": db_user, + "db_pass": db_pass, + "db_readonly_user": db_readonly_user, + "db_readonly_pass": db_readonly_pass, + "spec_repo_url": spec_repo_url, + "spec_release_url": spec_release_url, + "spec_release_path": spec_release_path, + "spec_paths": { + "root": spec_path, # /spec + "release_id": os.path.join(spec_path, ".release_id"), + "collections": os.path.join(spec_path, "collections"), # /spec/collections + "datasets": os.path.join(spec_path, "datasets"), + "data_sources": os.path.join(spec_path, "data_sources"), + "stored_queries": os.path.join(spec_path, "stored_queries"), + "views": os.path.join(spec_path, "views"), + }, } diff --git a/relation_engine_server/utils/json_validation.py b/relation_engine_server/utils/json_validation.py index da2f9c79..1860220e 100644 --- a/relation_engine_server/utils/json_validation.py +++ b/relation_engine_server/utils/json_validation.py @@ -57,7 +57,12 @@ def get_schema_validator(schema=None, schema_file=None, validate_at=""): """ - if schema == schema_file and schema is None or schema is not None and schema_file is not None: + if ( + schema == schema_file + and schema is None + or schema is not None + and schema_file is not None + ): raise ValueError("Please supply either a schema or a schema file path") # schema to validate against @@ -73,13 +78,18 @@ def get_schema_validator(schema=None, schema_file=None, validate_at=""): resolver = ExtendedRefResolver.from_schema(schema) return Validator( - validation_schema, - format_checker=FormatChecker(), - resolver=resolver + validation_schema, format_checker=FormatChecker(), resolver=resolver ) -def run_validator(schema=None, schema_file=None, validate_at="", data=None, data_file=None, nicer_errors=False): +def run_validator( + schema=None, + schema_file=None, + validate_at="", + data=None, + data_file=None, + nicer_errors=False, +): """ Validate data against a schema, filling in defaults if appropriate @@ -119,7 +129,9 @@ def run_validator(schema=None, schema_file=None, validate_at="", data=None, data # this will throw a ValidationError validator.validate(data) - err_msg = "".join(e.message + "\n" for e in sorted(validator.iter_errors(data), key=str)) + err_msg = "".join( + e.message + "\n" for e in sorted(validator.iter_errors(data), key=str) + ) raise ValidationError(err_msg) @@ -128,23 +140,22 @@ def _load_json_schema(file): """ Loads the given schema file """ with open(file) as fd: - if file.endswith('.yaml') or file.endswith('.yml'): + if file.endswith(".yaml") or file.endswith(".yml"): return yaml.safe_load(fd) - if file.endswith('.json'): + if file.endswith(".json"): return json.load(fd) - raise TypeError('Unknown file type encountered: ' + file) + raise TypeError("Unknown file type encountered: " + file) class ExtendedRefResolver(RefResolver): - def resolve_remote(self, uri): scheme = urlsplit(uri).scheme # if there's no scheme, it's a local file, so prefix it with "file://" - if scheme == '': - uri = 'file://' + uri + if scheme == "": + uri = "file://" + uri if scheme in self.handlers: result = self.handlers[scheme](uri) @@ -156,7 +167,7 @@ def resolve_remote(self, uri): # Otherwise, pass off to urllib and assume utf-8 with urlopen(uri) as url: content = url.read().decode("utf-8") - if uri.endswith('.yaml') or uri.endswith('.yml'): + if uri.endswith(".yaml") or uri.endswith(".yml"): result = yaml.safe_load(content) else: result = json.loads(content) diff --git a/relation_engine_server/utils/pull_spec.py b/relation_engine_server/utils/pull_spec.py index baf3cd43..344da84c 100644 --- a/relation_engine_server/utils/pull_spec.py +++ b/relation_engine_server/utils/pull_spec.py @@ -16,17 +16,17 @@ def download_specs(init_collections=True, release_url=None, reset=False): """Check and download the latest spec and extract it to the spec path.""" - if reset or not os.path.exists(_CONF['spec_paths']['root']): + if reset or not os.path.exists(_CONF["spec_paths"]["root"]): # Remove the spec directory, ignoring if it is already missing - shutil.rmtree(_CONF['spec_paths']['root'], ignore_errors=True) + shutil.rmtree(_CONF["spec_paths"]["root"], ignore_errors=True) # Directory to extract into temp_dir = tempfile.mkdtemp() # Download and extract a new release to /spec/repo - if _CONF['spec_release_path']: - _extract_tarball(_CONF['spec_release_path'], temp_dir) + if _CONF["spec_release_path"]: + _extract_tarball(_CONF["spec_release_path"], temp_dir) else: - if _CONF['spec_release_url']: - tarball_url = _CONF['spec_release_url'] + if _CONF["spec_release_url"]: + tarball_url = _CONF["spec_release_url"] else: tarball_url = _fetch_github_release_url() resp = requests.get(tarball_url, stream=True) @@ -40,7 +40,7 @@ def download_specs(init_collections=True, release_url=None, reset=False): # Get the top-level directory name from the tarball subdir = os.listdir(temp_dir)[0] # Move /tmp/temp_dir/x/spec into /spec - shutil.move(os.path.join(temp_dir, subdir, 'spec'), _CONF['spec_paths']['root']) + shutil.move(os.path.join(temp_dir, subdir, "spec"), _CONF["spec_paths"]["root"]) # Remove our temporary extraction directory shutil.rmtree(temp_dir) # Initialize all the collections @@ -51,7 +51,7 @@ def download_specs(init_collections=True, release_url=None, reset=False): def do_init_collections(): """Initialize any uninitialized collections in the database from a set of collection schemas.""" - pattern = os.path.join(_CONF['spec_paths']['collections'], '**', '*.yaml') + pattern = os.path.join(_CONF["spec_paths"]["collections"], "**", "*.yaml") for path in glob.iglob(pattern): coll_name = os.path.basename(os.path.splitext(path)[0]) with open(path) as fd: @@ -61,7 +61,7 @@ def do_init_collections(): def do_init_views(): """Initialize any uninitialized views in the database from a set of schemas.""" - pattern = os.path.join(_CONF['spec_paths']['views'], '**', '*.json') + pattern = os.path.join(_CONF["spec_paths"]["views"], "**", "*.json") for path in glob.iglob(pattern): view_name = os.path.basename(os.path.splitext(path)[0]) with open(path) as fd: @@ -72,32 +72,32 @@ def do_init_views(): def _fetch_github_release_url(): """Find the latest relation engine spec release using the github api.""" # Download information about the latest release - release_resp = requests.get(_CONF['spec_repo_url'] + '/releases/latest') + release_resp = requests.get(_CONF["spec_repo_url"] + "/releases/latest") release_info = release_resp.json() if release_resp.status_code != 200: # This may be a github API rate usage limit, or some other error - raise RuntimeError(release_info['message']) - return release_info['tarball_url'] + raise RuntimeError(release_info["message"]) + return release_info["tarball_url"] def _download_file(resp, path): """Download a streaming response as a file to path.""" - with open(path, 'wb') as tar_file: + with open(path, "wb") as tar_file: for chunk in resp.iter_content(chunk_size=1024): tar_file.write(chunk) def _extract_tarball(tar_path, dest_dir): """Extract a gzipped tarball to a destination directory.""" - with tarfile.open(tar_path, 'r:gz') as tar: + with tarfile.open(tar_path, "r:gz") as tar: tar.extractall(path=dest_dir) def _has_latest_spec(info): """Check if downloaded release info matches the latest downloaded spec.""" - release_id = str(info['id']) - if os.path.exists(_CONF['spec_paths']['release_id']): - with open(_CONF['spec_paths']['release_id'], 'r') as fd: + release_id = str(info["id"]) + if os.path.exists(_CONF["spec_paths"]["release_id"]): + with open(_CONF["spec_paths"]["release_id"], "r") as fd: current_release_id = fd.read() if release_id == current_release_id: return True @@ -106,11 +106,11 @@ def _has_latest_spec(info): def _save_release_id(info): """Save a release ID as the latest downloaded spec.""" - release_id = str(info['id']) + release_id = str(info["id"]) # Write the release ID to /spec/.release_id - with open(_CONF['spec_release_id_path'], 'w') as fd: + with open(_CONF["spec_release_id_path"], "w") as fd: fd.write(release_id) -if __name__ == '__main__': +if __name__ == "__main__": download_specs() diff --git a/relation_engine_server/utils/spec_loader.py b/relation_engine_server/utils/spec_loader.py index bcf0bb93..8e2863da 100644 --- a/relation_engine_server/utils/spec_loader.py +++ b/relation_engine_server/utils/spec_loader.py @@ -13,12 +13,12 @@ _schema_types = { # singular version of schema_type names - 'singular': ['collection', 'dataset', 'data_source', 'stored_query', 'view'], + "singular": ["collection", "dataset", "data_source", "stored_query", "view"], # plural version of schema_type names - 'plural': ['collections', 'datasets', 'data_sources', 'stored_queries', 'views'] + "plural": ["collections", "datasets", "data_sources", "stored_queries", "views"], } -_VALID_SCHEMA_TYPES = _schema_types['singular'] + _schema_types['plural'] +_VALID_SCHEMA_TYPES = _schema_types["singular"] + _schema_types["plural"] def _switch_schema_type_name(schema_type, to_form): @@ -31,19 +31,19 @@ def _switch_schema_type_name(schema_type, to_form): if schema_type in _schema_types[to_form]: return schema_type - from_form = 'singular' if to_form == 'plural' else 'plural' + from_form = "singular" if to_form == "plural" else "plural" ix = _schema_types[from_form].index(schema_type) return _schema_types[to_form][ix] def pluralise_schema_type(schema_type): """ensure a schema_type is in the plural form""" - return _switch_schema_type_name(schema_type, 'plural') + return _switch_schema_type_name(schema_type, "plural") def singularise_schema_type(schema_type): """ensure a schema_type is in the singular form""" - return _switch_schema_type_name(schema_type, 'singular') + return _switch_schema_type_name(schema_type, "singular") def get_names(schema_type): @@ -56,8 +56,8 @@ def get_names(schema_type): # ensure that the name is in the plural form schema_search_type = pluralise_schema_type(schema_type) - yaml_paths = _find_paths(_CONF['spec_paths'][schema_search_type], '*.yaml') - json_paths = _find_paths(_CONF['spec_paths'][schema_search_type], '*.json') + yaml_paths = _find_paths(_CONF["spec_paths"][schema_search_type], "*.yaml") + json_paths = _find_paths(_CONF["spec_paths"][schema_search_type], "*.json") names = [_get_file_name(path) for path in sorted(yaml_paths + json_paths)] @@ -74,11 +74,11 @@ def get_schema(schema_type, name, path_only=False): schema_search_type = pluralise_schema_type(schema_type) - yaml_paths = _find_paths(_CONF['spec_paths'][schema_search_type], f'{name}.yaml') - json_paths = _find_paths(_CONF['spec_paths'][schema_search_type], f'{name}.json') + yaml_paths = _find_paths(_CONF["spec_paths"][schema_search_type], f"{name}.yaml") + json_paths = _find_paths(_CONF["spec_paths"][schema_search_type], f"{name}.json") # ensure we're using the canonical path and that all paths are unique # we are only interested in paths that are in the designated spec repo - repo_path = os.path.abspath(_CONF['spec_paths']['root']) + repo_path = os.path.abspath(_CONF["spec_paths"]["root"]) all_paths_set = set(os.path.abspath(path) for path in yaml_paths + json_paths) all_paths = [p for p in all_paths_set if p.startswith(repo_path)] @@ -91,64 +91,66 @@ def get_schema(schema_type, name, path_only=False): return path with open(path) as fd: - if path.endswith('.json'): + if path.endswith(".json"): contents = json.load(fd) else: contents = yaml.safe_load(fd) - if schema_search_type == 'data_sources' and 'logo_path' in contents: + if schema_search_type == "data_sources" and "logo_path" in contents: # Append the logo root url to be the ui-assets server url with the correct environment - base_logo_url = re.sub(r'\/services\/?', '/ui-assets', _CONF['kbase_endpoint']) - contents['logo_url'] = base_logo_url + contents['logo_path'] - del contents['logo_path'] + base_logo_url = re.sub( + r"\/services\/?", "/ui-assets", _CONF["kbase_endpoint"] + ) + contents["logo_url"] = base_logo_url + contents["logo_path"] + del contents["logo_path"] return contents def get_collection_names(): """Return a dict of vertex and edge base names.""" - return get_names('collections') + return get_names("collections") def get_data_source_names(): """Return an array of all the data source names.""" - return get_names('data_sources') + return get_names("data_sources") def get_stored_query_names(): """Return an array of all stored queries base names.""" - return get_names('stored_queries') + return get_names("stored_queries") def get_view_names(): """Return an array of all view base names.""" - return get_names('views') + return get_names("views") def get_collection(name, path_only=False): """Get YAML content (or file path) for a specific collection. Throws an error if nonexistent.""" - return get_schema('collection', name, path_only) + return get_schema("collection", name, path_only) def get_schema_for_doc(doc_id, path_only=False): """Get the schema for a particular document by its full ID.""" - (coll_name, _) = doc_id.split('/') - return get_schema('collection', coll_name, path_only) + (coll_name, _) = doc_id.split("/") + return get_schema("collection", coll_name, path_only) def get_data_source(name, path_only=False): """Get YAML content (or file path) for a data source. Throws an error if it does not exist.""" - return get_schema('data_source', name, path_only) + return get_schema("data_source", name, path_only) def get_stored_query(name, path_only=False): """Get AQL content or file path for a specific stored query. Throws an error if nonexistent.""" - return get_schema('stored_query', name, path_only) + return get_schema("stored_query", name, path_only) def get_view(name, path_only=False): """Get content or file path for a view file. Throws an error if nonexistent.""" - return get_schema('view', name, path_only) + return get_schema("view", name, path_only) def _find_paths(dir_path, file_pattern): @@ -156,7 +158,7 @@ def _find_paths(dir_path, file_pattern): Return all file paths from a filename pattern, starting from a parent directory and looking in all subdirectories. """ - pattern = os.path.join(dir_path, '**', file_pattern) + pattern = os.path.join(dir_path, "**", file_pattern) return glob.glob(pattern, recursive=True) diff --git a/relation_engine_server/utils/wait_for.py b/relation_engine_server/utils/wait_for.py index 42b84a74..572fa8ec 100644 --- a/relation_engine_server/utils/wait_for.py +++ b/relation_engine_server/utils/wait_for.py @@ -12,26 +12,26 @@ def get_service_conf(): _CONF = get_config() return { - 'arangodb': { - 'url': _CONF['api_url'] + '/collection', - 'callback': _assert_json_content, - 'raise_for_status': True, + "arangodb": { + "url": _CONF["api_url"] + "/collection", + "callback": _assert_json_content, + "raise_for_status": True, }, - 'auth': { - 'url': _CONF['auth_url'], + "auth": { + "url": _CONF["auth_url"], }, - 'workspace': { - 'url': _CONF['workspace_url'], + "workspace": { + "url": _CONF["workspace_url"], + }, + "localhost": { + "url": "http://127.0.0.1:5000", + "raise_for_status": True, }, - 'localhost': { - 'url': 'http://127.0.0.1:5000', - 'raise_for_status': True, - } } def wait_for_service(service_list: List[str]) -> None: - '''wait for a service or list of services to start up''' + """wait for a service or list of services to start up""" timeout = int(time.time()) + 60 services_pending = set(service_list) service_conf = get_service_conf() @@ -41,11 +41,11 @@ def wait_for_service(service_list: List[str]) -> None: for name in services_pending: try: conf = service_conf[name] - resp = requests.get(conf['url'], auth=conf.get('auth')) - if conf.get('raise_for_status'): + resp = requests.get(conf["url"], auth=conf.get("auth")) + if conf.get("raise_for_status"): resp.raise_for_status() - if conf.get('callback') is not None: - conf['callback'](resp) + if conf.get("callback") is not None: + conf["callback"](resp) # The service is up except Exception: print(f"Still waiting for {name} to start...") @@ -58,21 +58,21 @@ def wait_for_service(service_list: List[str]) -> None: def wait_for_arangodb(): - '''wait for arangodb to be ready''' - wait_for_service(['arangodb']) + """wait for arangodb to be ready""" + wait_for_service(["arangodb"]) def wait_for_services(): - '''wait for the workspace, auth, and arango to start up''' + """wait for the workspace, auth, and arango to start up""" - wait_for_service(['auth', 'workspace', 'arangodb']) + wait_for_service(["auth", "workspace", "arangodb"]) def wait_for_api(): - '''wait for the workspace, auth, arango, AND localhost:5000 to start up''' + """wait for the workspace, auth, arango, AND localhost:5000 to start up""" wait_for_services() - wait_for_service(['localhost']) + wait_for_service(["localhost"]) def _assert_json_content(resp: requests.models.Response) -> None: @@ -82,8 +82,8 @@ def _assert_json_content(resp: requests.models.Response) -> None: resp.json() -if __name__ == '__main__': - if sys.argv[1] == 'services': +if __name__ == "__main__": + if sys.argv[1] == "services": wait_for_services() - elif sys.argv[1] == 'api': + elif sys.argv[1] == "api": wait_for_api() diff --git a/scripts/run_tests.sh b/scripts/run_tests.sh index ee65152c..c9946b71 100644 --- a/scripts/run_tests.sh +++ b/scripts/run_tests.sh @@ -6,9 +6,11 @@ set -e (cd /app/relation_engine_server/test/spec_release && \ tar czvf spec.tar.gz sample_spec_release) +black . flake8 --max-complexity 15 /app mypy --ignore-missing-imports /app bandit -r /app + # start server, using the specs in /spec/repo sh /app/scripts/start_server.sh & coverage erase diff --git a/spec/test/collections/test_djornl.py b/spec/test/collections/test_djornl.py index a481a546..73305df7 100644 --- a/spec/test/collections/test_djornl.py +++ b/spec/test/collections/test_djornl.py @@ -12,61 +12,56 @@ from relation_engine_server.utils.json_validation import get_schema_validator from jsonschema.exceptions import ValidationError -_BASE_DIR = os_path_join('/app', 'spec') +_BASE_DIR = os_path_join("/app", "spec") class Test_DJORNL_Collections(unittest.TestCase): - @classmethod def setUpClass(cls): cls.maxDiff = None cls.config = get_config() - cls.repo_path = cls.config['spec_paths']['root'] - for key in cls.config['spec_paths'].keys(): - if cls.repo_path in cls.config['spec_paths'][key]: - cls.config['spec_paths'][key] = cls.config['spec_paths'][key].replace( - cls.repo_path, - _BASE_DIR + cls.repo_path = cls.config["spec_paths"]["root"] + for key in cls.config["spec_paths"].keys(): + if cls.repo_path in cls.config["spec_paths"][key]: + cls.config["spec_paths"][key] = cls.config["spec_paths"][key].replace( + cls.repo_path, _BASE_DIR ) @classmethod def tearDownClass(cls): # undo all the config changes - for key in cls.config['spec_paths'].keys(): - if _BASE_DIR in cls.config['spec_paths'][key]: - cls.config['spec_paths'][key] = cls.config['spec_paths'][key].replace( - _BASE_DIR, - cls.repo_path + for key in cls.config["spec_paths"].keys(): + if _BASE_DIR in cls.config["spec_paths"][key]: + cls.config["spec_paths"][key] = cls.config["spec_paths"][key].replace( + _BASE_DIR, cls.repo_path ) def test_node(self, query_name=None, test_data=None): """ ensure node data validates correctly """ - schema_file = get_schema('collection', 'djornl_node', path_only=True) - validator = get_schema_validator(schema_file=schema_file, validate_at='/schema') + schema_file = get_schema("collection", "djornl_node", path_only=True) + validator = get_schema_validator(schema_file=schema_file, validate_at="/schema") test_data = [ { - 'data': {'_key': 'AT1G01010', 'go_terms': ['GO:0003700', 'GO:0003677']}, - 'valid': True, + "data": {"_key": "AT1G01010", "go_terms": ["GO:0003700", "GO:0003677"]}, + "valid": True, }, { - 'data': {'_key': 'ABCDE', 'node_type': 'vertex'}, - 'valid': False, - 'error': "'vertex' is not valid under any of the given schemas", + "data": {"_key": "ABCDE", "node_type": "vertex"}, + "valid": False, + "error": "'vertex' is not valid under any of the given schemas", }, { - 'data': {'_key': 'ABCDE', 'clusters': ['GO:0003700', 'GO:0003700']}, - 'valid': False, - 'error': "\\['GO:0003700', 'GO:0003700'\\] has non-unique elements" - } + "data": {"_key": "ABCDE", "clusters": ["GO:0003700", "GO:0003700"]}, + "valid": False, + "error": "\\['GO:0003700', 'GO:0003700'\\] has non-unique elements", + }, ] for test in test_data: - if test['valid']: - self.assertTrue( - validator.is_valid(test['data']) - ) + if test["valid"]: + self.assertTrue(validator.is_valid(test["data"])) else: - with self.assertRaisesRegex(ValidationError, test['error']): - validator.validate(test['data']) + with self.assertRaisesRegex(ValidationError, test["error"]): + validator.validate(test["data"]) diff --git a/spec/test/collections/test_silva.py b/spec/test/collections/test_silva.py index 983285e5..267db322 100644 --- a/spec/test/collections/test_silva.py +++ b/spec/test/collections/test_silva.py @@ -5,192 +5,218 @@ import unittest cwd = os.path.dirname(os.path.abspath(__file__)) -yaml_drpth = os.path.join(cwd, '../../collections/silva') -node_yaml_flpth = os.path.join(yaml_drpth, 'silva_taxon.yaml') -edge_yaml_flpth = os.path.join(yaml_drpth, 'silva_child_of_taxon.yaml') +yaml_drpth = os.path.join(cwd, "../../collections/silva") +node_yaml_flpth = os.path.join(yaml_drpth, "silva_taxon.yaml") +edge_yaml_flpth = os.path.join(yaml_drpth, "silva_child_of_taxon.yaml") class SILVATreeJSONSchemaTest(unittest.TestCase): - ''' + """ Test the API of the nodes and edges representing SILVA taxonomy tree All information is from SILVA (arb-silva.de) See their documentation for more details - ''' + """ @classmethod def setUpClass(cls): - cls.validator_node = get_schema_validator(schema_file=node_yaml_flpth, validate_at='/schema') - cls.validator_edge = get_schema_validator(schema_file=edge_yaml_flpth, validate_at='/schema') + cls.validator_node = get_schema_validator( + schema_file=node_yaml_flpth, validate_at="/schema" + ) + cls.validator_edge = get_schema_validator( + schema_file=edge_yaml_flpth, validate_at="/schema" + ) cls.nodes_valid = [ { - 'id': '0', # Root's info is assigned by API, since SILVA doesn't seem to have a root node - 'name': 'Root', - 'rank': 'root_rank', - }, { - 'id': '2', - 'name': 'Archea', - 'rank': 'domain', - }, { - 'id': '47023', - 'name': 'BCP clade', - 'rank': 'major_clade', - 'release': 138, - }, { - 'id': '42919', - 'name': 'Asgardarchaeota', - 'rank': 'phylum', - 'release': 138, - }, { - 'id': '4155', - 'name': 'Amb-18S-504', - 'rank': 'order', - 'release': 119.1, - }, { - 'id': '47162', - 'name': 'Japygoidea', - 'rank': 'superfamily', - 'release': 138, - }, { - 'id': '47142', - 'name': 'Tantulocarida', - 'rank': 'subclass', - 'release': 138, - }, { - 'id': 'HM032797.1.1344', - 'name': 'Yeosuana aromativorans', - 'rank': 'sequence', - 'sequence': 'gattaca', - 'dataset': ['parc', 'ref', 'nr99'] - }, { - 'id': 'CRQV01000019.5091.6588', - 'name': 'Streptococcus penumoniae', - 'rank': 'sequence', - 'sequence': 'gattaca', - 'dataset': ['parc', 'ref'], # actually in nr99 - }, { - 'id': 'HQ216288.1.1242', - 'name': 'uncultured bacterium', - 'rank': 'sequence', - 'sequence': 'gattaca', - 'dataset': ['parc'], # actually in nr99 - } + "id": "0", # Root's info is assigned by API, since SILVA doesn't seem to have a root node + "name": "Root", + "rank": "root_rank", + }, + { + "id": "2", + "name": "Archea", + "rank": "domain", + }, + { + "id": "47023", + "name": "BCP clade", + "rank": "major_clade", + "release": 138, + }, + { + "id": "42919", + "name": "Asgardarchaeota", + "rank": "phylum", + "release": 138, + }, + { + "id": "4155", + "name": "Amb-18S-504", + "rank": "order", + "release": 119.1, + }, + { + "id": "47162", + "name": "Japygoidea", + "rank": "superfamily", + "release": 138, + }, + { + "id": "47142", + "name": "Tantulocarida", + "rank": "subclass", + "release": 138, + }, + { + "id": "HM032797.1.1344", + "name": "Yeosuana aromativorans", + "rank": "sequence", + "sequence": "gattaca", + "dataset": ["parc", "ref", "nr99"], + }, + { + "id": "CRQV01000019.5091.6588", + "name": "Streptococcus penumoniae", + "rank": "sequence", + "sequence": "gattaca", + "dataset": ["parc", "ref"], # actually in nr99 + }, + { + "id": "HQ216288.1.1242", + "name": "uncultured bacterium", + "rank": "sequence", + "sequence": "gattaca", + "dataset": ["parc"], # actually in nr99 + }, ] cls.nodes_invalid_errors = [ ( { # missing - 'id': 'id', - 'name': 'name', + "id": "id", + "name": "name", }, "'rank' is a required property", - ), ( + ), + ( { # missing - 'id': 'id', - 'rank': 'kingdom', + "id": "id", + "rank": "kingdom", }, "'name' is a required property", - ), ( + ), + ( { # missing - 'name': 'name', - 'rank': 'major_clade', + "name": "name", + "rank": "major_clade", }, "'id' is a required property", - ), ( + ), + ( { # type - 'id': 1, - 'name': 'name', - 'rank': 'subphylum', + "id": 1, + "name": "name", + "rank": "subphylum", }, "1 is not of type 'string'", - ), ( + ), + ( { # type - 'id': 'id', - 'name': 1, - 'rank': 'subkingdom', + "id": "id", + "name": 1, + "rank": "subkingdom", }, "1 is not of type 'string'", - ), ( + ), + ( { # type - 'id': 'id', - 'name': 'name', - 'rank': 1, + "id": "id", + "name": "name", + "rank": 1, }, "1 is not of type 'string'", - ), ( + ), + ( { # type - 'id': 'id', - 'name': 'name', - 'rank': 'infraphylum', - 'release': '119', + "id": "id", + "name": "name", + "rank": "infraphylum", + "release": "119", }, "'119' is not of type 'number'", - ), ( + ), + ( { # type - 'id': 'id', - 'name': 'name', - 'rank': 'sequence', - 'sequence': 1, + "id": "id", + "name": "name", + "rank": "sequence", + "sequence": 1, }, "1 is not of type 'string'", - ), ( + ), + ( { # type - 'id': 'id', - 'name': 'name', - 'rank': 'subphylum', - 'dataset': 1, + "id": "id", + "name": "name", + "rank": "subphylum", + "dataset": 1, }, "1 is not of type 'array'", - ), ( + ), + ( { # enum - 'id': 'id', - 'name': 'name', - 'rank': 'fictional_rank', + "id": "id", + "name": "name", + "rank": "fictional_rank", }, - "'fictional_rank' is not one of ['superfamily', 'subphylum', 'subfamily', " + \ - "'phylum', 'order', 'major_clade', 'infraclass', 'suborder', 'family', " + \ - "'superkingdom', 'domain', 'superphylum', 'superorder', 'superclass', " + \ - "'infraphylum', 'subclass', 'genus', 'class', 'kingdom', 'subkingdom', " + \ - "'root_rank', 'sequence']", - ), ( + "'fictional_rank' is not one of ['superfamily', 'subphylum', 'subfamily', " + + "'phylum', 'order', 'major_clade', 'infraclass', 'suborder', 'family', " + + "'superkingdom', 'domain', 'superphylum', 'superorder', 'superclass', " + + "'infraphylum', 'subclass', 'genus', 'class', 'kingdom', 'subkingdom', " + + "'root_rank', 'sequence']", + ), + ( { # enum - 'id': 'id', - 'name': 'name', - 'rank': 'superclass', - 'dataset': ['nr99', 'ref', 'parc'], # array in wrong order + "id": "id", + "name": "name", + "rank": "superclass", + "dataset": ["nr99", "ref", "parc"], # array in wrong order }, "['nr99', 'ref', 'parc'] is not one of [['parc'], ['parc', 'ref'], ['parc', 'ref', 'nr99']]", - ) + ), ] cls.edges_valid = [ { - 'id': '2', - 'from': '2', - 'to': '0', - }, { - 'id': '42919', - 'from': '42919', - 'to': '2', - }, { - 'id': 'HM032797.1.1344', - 'from': 'HM032797.1.1344', - 'to': '44300', - }, { - 'id': 'CRQV01000019.5091.6588', - 'from': 'CRQV01000019.5091.6588', - 'to': '1853', + "id": "2", + "from": "2", + "to": "0", + }, + { + "id": "42919", + "from": "42919", + "to": "2", + }, + { + "id": "HM032797.1.1344", + "from": "HM032797.1.1344", + "to": "44300", + }, + { + "id": "CRQV01000019.5091.6588", + "from": "CRQV01000019.5091.6588", + "to": "1853", }, ] @@ -198,49 +224,54 @@ def setUpClass(cls): ( { # missing - 'from': '2', - 'to': '0', + "from": "2", + "to": "0", }, "'id' is a required property", - ), ( + ), + ( { # missing - 'id': '2', - 'to': '0', + "id": "2", + "to": "0", }, "'from' is a required property", - ), ( + ), + ( { # missing - 'id': '2', - 'from': '2', + "id": "2", + "from": "2", }, "'to' is a required property", - ), ( + ), + ( { # type - 'id': 2, - 'from': '2', - 'to': '0', + "id": 2, + "from": "2", + "to": "0", }, "2 is not of type 'string'", - ), ( + ), + ( { # type - 'id': '2', - 'from': 2, - 'to': '0', + "id": "2", + "from": 2, + "to": "0", }, "2 is not of type 'string'", - ), ( + ), + ( { # type - 'id': '2', - 'from': '2', - 'to': 0, + "id": "2", + "from": "2", + "to": 0, }, "0 is not of type 'string'", - ) + ), ] def _test_type(self, validator, insts_valid, insts_invalid_errors): @@ -248,20 +279,21 @@ def _test_type(self, validator, insts_valid, insts_invalid_errors): with self.subTest(inst=inst): validator.validate(inst) - print('v', end='') - print() - for inst, err_expected in insts_invalid_errors: with self.subTest(inst=inst): - with self.assertRaisesRegex(ValidationError, '^' + re.escape(err_expected) + '\n'): + with self.assertRaisesRegex( + ValidationError, "^" + re.escape(err_expected) + "\n" + ): validator.validate(inst) - print(err_expected) - def test(self): - self._test_type(self.validator_node, self.nodes_valid, self.nodes_invalid_errors) - self._test_type(self.validator_edge, self.edges_valid, self.edges_invalid_errors) + self._test_type( + self.validator_node, self.nodes_valid, self.nodes_invalid_errors + ) + self._test_type( + self.validator_edge, self.edges_valid, self.edges_invalid_errors + ) -if __name__ == '__main__': +if __name__ == "__main__": unittest.main() diff --git a/spec/test/helpers.py b/spec/test/helpers.py index b29f6753..3d79f066 100644 --- a/spec/test/helpers.py +++ b/spec/test/helpers.py @@ -18,22 +18,22 @@ def get_config(): """Return configuration data for tests.""" return { - 're_api_url': os.environ['RE_API_URL'], - 're_query_results_url': os.environ['RE_API_URL'] + '/api/v1/query_results', - 'db_url': os.environ['DB_URL'], - 'db_auth': (os.environ['DB_USER'], os.environ.get('DB_PASS', '')) + "re_api_url": os.environ["RE_API_URL"], + "re_query_results_url": os.environ["RE_API_URL"] + "/api/v1/query_results", + "db_url": os.environ["DB_URL"], + "db_auth": (os.environ["DB_USER"], os.environ.get("DB_PASS", "")), } def run_query(query_name, query_data={}): """submit a database query""" - query_results_url = get_config()['re_query_results_url'] + query_results_url = get_config()["re_query_results_url"] return requests.post( query_results_url, - params={'stored_query': query_name}, - data=json.dumps(query_data) + params={"stored_query": query_name}, + data=json.dumps(query_data), ).json() @@ -45,20 +45,20 @@ def assert_subset(testCls, subset, _dict): def create_test_docs(coll_name, docs, update_on_dupe=False): """Create a set of documents for use in tests.""" - body = '\n'.join([json.dumps(d) for d in docs]) - params = {'overwrite': True, 'collection': coll_name, 'display_errors': '1'} + body = "\n".join([json.dumps(d) for d in docs]) + params = {"overwrite": True, "collection": coll_name, "display_errors": "1"} if update_on_dupe: - del params['overwrite'] - params['on_duplicate'] = 'update' + del params["overwrite"] + params["on_duplicate"] = "update" conf = get_config() resp = requests.put( - conf['re_api_url'] + '/api/v1/documents', + conf["re_api_url"] + "/api/v1/documents", params=params, data=body, - headers={'Authorization': 'admin_token'} + headers={"Authorization": "admin_token"}, ) if not resp.ok: raise RuntimeError(resp.text) @@ -68,18 +68,18 @@ def create_test_docs(coll_name, docs, update_on_dupe=False): def check_spec_test_env(): """ ensure that the environment is prepared for running the spec tests """ - if os.environ.get('SPEC_TEST_READY', None) is None: + if os.environ.get("SPEC_TEST_READY", None) is None: wait_for_api() _CONF = get_re_config() # Remove the spec directory, ignoring if it is already missing - shutil.rmtree(_CONF['spec_paths']['root'], ignore_errors=True) + shutil.rmtree(_CONF["spec_paths"]["root"], ignore_errors=True) # Recreate the spec directory so we have a clean slate, avoiding name conflicts - os.makedirs(_CONF['spec_paths']['root']) + os.makedirs(_CONF["spec_paths"]["root"]) # copy the contents of /app/spec into /spec - shutil.rmtree(_CONF['spec_paths']['root'], ignore_errors=True) - shutil.copytree('/app/spec', _CONF['spec_paths']['root']) + shutil.rmtree(_CONF["spec_paths"]["root"], ignore_errors=True) + shutil.copytree("/app/spec", _CONF["spec_paths"]["root"]) download_specs() - os.environ.update({'SPEC_TEST_READY': "Done"}) + os.environ.update({"SPEC_TEST_READY": "Done"}) def capture_stdout(function, *args, **kwargs): diff --git a/spec/test/stored_queries/test_djornl.py b/spec/test/stored_queries/test_djornl.py index 94a57680..eca29b1c 100644 --- a/spec/test/stored_queries/test_djornl.py +++ b/spec/test/stored_queries/test_djornl.py @@ -7,11 +7,17 @@ import unittest import os -from spec.test.helpers import get_config, modified_environ, create_test_docs, run_query, check_spec_test_env +from spec.test.helpers import ( + get_config, + modified_environ, + create_test_docs, + run_query, + check_spec_test_env, +) from importers.djornl.parser import DJORNL_Parser _CONF = get_config() -_TEST_DIR = '/app/spec/test' +_TEST_DIR = "/app/spec/test" _VERBOSE = 0 @@ -20,42 +26,41 @@ def print_db_update(response, collection): return print(f"Saved docs to collection {collection}!") print(response.text) - print('=' * 80) + print("=" * 80) class Test_DJORNL_Stored_Queries(unittest.TestCase): - @classmethod def setUpClass(cls): check_spec_test_env() # import the results file - results_file = os.path.join(_TEST_DIR, 'djornl', 'results.json') + results_file = os.path.join(_TEST_DIR, "djornl", "results.json") with open(results_file) as fh: cls.json_data = json.load(fh) - cls.no_results = {'nodes': [], 'edges': []} + cls.no_results = {"nodes": [], "edges": []} cls.maxDiff = None # load the DB - root_path = os.path.join(_TEST_DIR, 'djornl', 'test_data') + root_path = os.path.join(_TEST_DIR, "djornl", "test_data") with modified_environ(RES_ROOT_DATA_PATH=root_path): parser = DJORNL_Parser() - node_name = parser.config('node_name') - edge_name = parser.config('edge_name') + node_name = parser.config("node_name") + edge_name = parser.config("edge_name") edge_data = parser.load_edges() - r = create_test_docs(node_name, edge_data['nodes']) + r = create_test_docs(node_name, edge_data["nodes"]) print_db_update(r, node_name) - r = create_test_docs(edge_name, edge_data['edges']) + r = create_test_docs(edge_name, edge_data["edges"]) print_db_update(r, edge_name) node_metadata = parser.load_nodes() - r = create_test_docs(node_name, node_metadata['nodes'], True) + r = create_test_docs(node_name, node_metadata["nodes"], True) print_db_update(r, node_name) cluster_data = parser.load_clusters() - r = create_test_docs(node_name, cluster_data['nodes'], True) + r = create_test_docs(node_name, cluster_data["nodes"], True) print_db_update(r, node_name) def test_expected_results(self, query_name=None, test_data=None): @@ -66,43 +71,43 @@ def test_expected_results(self, query_name=None, test_data=None): return # ensure we have either 'results' or 'error' in the test data - self.assertTrue('results' in test_data or 'error' in test_data) + self.assertTrue("results" in test_data or "error" in test_data) params = {} - if 'params' in test_data: - params = test_data['params'] + if "params" in test_data: + params = test_data["params"] response = run_query(query_name, params) if _VERBOSE: print("Running query " + query_name) - if 'params' in test_data: - print({'params': params}) + if "params" in test_data: + print({"params": params}) # expecting an error response - if 'error' in test_data: - if 'error' not in response: - print({'response': response}) + if "error" in test_data: + if "error" not in response: + print({"response": response}) - self.assertIn('error', response) - self.assertEqual(response['error'], test_data['error']) + self.assertIn("error", response) + self.assertEqual(response["error"], test_data["error"]) return response # expecting a valid response - if 'results' not in response: - print({'response': response}) + if "results" not in response: + print({"response": response}) - self.assertIn('results', response) - results = response['results'][0] + self.assertIn("results", response) + results = response["results"][0] self.assertEqual( - set([n["_key"] for n in results['nodes']]), - set(test_data['results']['nodes']) + set([n["_key"] for n in results["nodes"]]), + set(test_data["results"]["nodes"]), ) self.assertEqual( - set([e["_key"] for e in results['edges']]), - set(test_data['results']['edges']) + set([e["_key"] for e in results["edges"]]), + set(test_data["results"]["edges"]), ) return response @@ -120,24 +125,23 @@ def test_expected_results(self, query_name=None, test_data=None): # edges are objects with keys _to, _from, edge_type and score def test_fetch_all(self): - '''Ensure that data returned by the fetch all query has all the information that we expect''' + """Ensure that data returned by the fetch all query has all the information that we expect""" response = self.test_expected_results( - "djornl_fetch_all", - self.json_data['queries']['djornl_fetch_all'][0] + "djornl_fetch_all", self.json_data["queries"]["djornl_fetch_all"][0] ) # ensure that all the cluster data is returned OK - node_data = response['results'][0]['nodes'] - expected_node_data = self.json_data['load_clusters']['nodes'] + node_data = response["results"][0]["nodes"] + expected_node_data = self.json_data["load_clusters"]["nodes"] self.assertEqual( - {n['_key']: n['clusters'] for n in node_data if 'clusters' in n}, - {n['_key']: n['clusters'] for n in expected_node_data if 'clusters' in n}, + {n["_key"]: n["clusters"] for n in node_data if "clusters" in n}, + {n["_key"]: n["clusters"] for n in expected_node_data if "clusters" in n}, ) def test_queries(self): - '''Run parameterised queries and check for results or error messages''' + """Run parameterised queries and check for results or error messages""" - for query in self.json_data['queries'].keys(): - for test in self.json_data['queries'][query]: - with self.subTest(query=query, params=test['params']): + for query in self.json_data["queries"].keys(): + for test in self.json_data["queries"][query]: + with self.subTest(query=query, params=test["params"]): self.test_expected_results(query, test) diff --git a/spec/test/stored_queries/test_list_test_vertices.py b/spec/test/stored_queries/test_list_test_vertices.py index 1644b600..e4f5ae0e 100644 --- a/spec/test/stored_queries/test_list_test_vertices.py +++ b/spec/test/stored_queries/test_list_test_vertices.py @@ -11,11 +11,10 @@ from spec.test.helpers import create_test_docs, get_config, check_spec_test_env _CONF = get_config() -_QUERY_URL = _CONF['re_api_url'] + '/api/v1/query_results?view=list_test_vertices' +_QUERY_URL = _CONF["re_api_url"] + "/api/v1/query_results?view=list_test_vertices" class TestListTestVertices(unittest.TestCase): - @classmethod def setUpClass(cls): check_spec_test_env() @@ -23,40 +22,58 @@ def setUpClass(cls): def test_valid(self): """Test a valid query.""" docs_created = create_test_docs( - 'test_vertex', + "test_vertex", [ - {'is_public': True, '_key': 'a', 'ws_id': 10}, # public access - {'is_public': False, '_key': 'b', 'ws_id': 1}, # private access - {'is_public': False, '_key': 'c', 'ws_id': 99} # no access - ] + {"is_public": True, "_key": "a", "ws_id": 10}, # public access + {"is_public": False, "_key": "b", "ws_id": 1}, # private access + {"is_public": False, "_key": "c", "ws_id": 99}, # no access + ], ) self.assertEqual( docs_created.json(), - {'created': 3, 'details': [], 'empty': 0, 'error': False, 'errors': 0, 'ignored': 0, 'updated': 0}, + { + "created": 3, + "details": [], + "empty": 0, + "error": False, + "errors": 0, + "ignored": 0, + "updated": 0, + }, ) resp = requests.post( _QUERY_URL, - headers={'Authorization': 'valid_token'} # gives access to workspaces [1,2,3] + headers={ + "Authorization": "valid_token" + }, # gives access to workspaces [1,2,3] ).json() - self.assertEqual(resp['count'], 2) + self.assertEqual(resp["count"], 2) # 'c' is inaccessible - self.assertEqual({r['_key'] for r in resp['results']}, {'a', 'b'}) + self.assertEqual({r["_key"] for r in resp["results"]}, {"a", "b"}) def test_no_auth(self): """Test with blank auth.""" docs_created = create_test_docs( - 'test_vertex', + "test_vertex", [ - {'is_public': True, '_key': 'a', 'ws_id': 10}, # public access - {'is_public': False, '_key': 'b', 'ws_id': 1}, # private access - {'is_public': False, '_key': 'c', 'ws_id': 99} # no access - ] + {"is_public": True, "_key": "a", "ws_id": 10}, # public access + {"is_public": False, "_key": "b", "ws_id": 1}, # private access + {"is_public": False, "_key": "c", "ws_id": 99}, # no access + ], ) self.assertEqual( docs_created.json(), - {'created': 3, 'details': [], 'empty': 0, 'error': False, 'errors': 0, 'ignored': 0, 'updated': 0}, + { + "created": 3, + "details": [], + "empty": 0, + "error": False, + "errors": 0, + "ignored": 0, + "updated": 0, + }, ) resp = requests.post(_QUERY_URL).json() - self.assertEqual(resp['count'], 1) + self.assertEqual(resp["count"], 1) # 'b' and 'c' are inaccessible - self.assertEqual([r['_key'] for r in resp['results']], ['a']) + self.assertEqual([r["_key"] for r in resp["results"]], ["a"]) diff --git a/spec/test/stored_queries/test_ncbi_tax.py b/spec/test/stored_queries/test_ncbi_tax.py index 9daf5550..8e420e11 100644 --- a/spec/test/stored_queries/test_ncbi_tax.py +++ b/spec/test/stored_queries/test_ncbi_tax.py @@ -8,14 +8,18 @@ import unittest import requests -from spec.test.helpers import get_config, assert_subset, create_test_docs, check_spec_test_env +from spec.test.helpers import ( + get_config, + assert_subset, + create_test_docs, + check_spec_test_env, +) _CONF = get_config() _NOW = int(time.time() * 1000) class TestNcbiTax(unittest.TestCase): - @classmethod def setUpClass(cls): """Create test documents""" @@ -23,24 +27,106 @@ def setUpClass(cls): check_spec_test_env() taxon_docs = [ - {'_key': '1', 'scientific_name': 'Bacteria', 'rank': 'Domain', 'strain': False}, - {'_key': '2', 'scientific_name': 'Firmicutes', 'rank': 'Phylum', 'strain': False}, - {'_key': '3', 'scientific_name': 'Bacilli', 'rank': 'Class', 'strain': False}, - {'_key': '4', 'scientific_name': 'Proteobacteria', 'rank': 'Phylum', 'strain': False}, - {'_key': '5', 'scientific_name': 'Alphaproteobacteria', 'rank': 'Class', 'strain': False}, - {'_key': '6', 'scientific_name': 'Gammaproteobacteria', 'rank': 'Class', 'strain': False}, - {'_key': '7', 'scientific_name': 'Deltaproteobacteria', 'rank': 'Class', 'strain': False}, - {'_key': '8', 'scientific_name': 'Bacillus subtilis 168', 'rank': 'no rank', 'strain': True}, + { + "_key": "1", + "scientific_name": "Bacteria", + "rank": "Domain", + "strain": False, + }, + { + "_key": "2", + "scientific_name": "Firmicutes", + "rank": "Phylum", + "strain": False, + }, + { + "_key": "3", + "scientific_name": "Bacilli", + "rank": "Class", + "strain": False, + }, + { + "_key": "4", + "scientific_name": "Proteobacteria", + "rank": "Phylum", + "strain": False, + }, + { + "_key": "5", + "scientific_name": "Alphaproteobacteria", + "rank": "Class", + "strain": False, + }, + { + "_key": "6", + "scientific_name": "Gammaproteobacteria", + "rank": "Class", + "strain": False, + }, + { + "_key": "7", + "scientific_name": "Deltaproteobacteria", + "rank": "Class", + "strain": False, + }, + { + "_key": "8", + "scientific_name": "Bacillus subtilis 168", + "rank": "no rank", + "strain": True, + }, ] child_docs = [ - {'_from': 'ncbi_taxon/2', '_to': 'ncbi_taxon/1', 'from': '2', 'to': '1', 'id': '2'}, - {'_from': 'ncbi_taxon/4', '_to': 'ncbi_taxon/1', 'from': '4', 'to': '1', 'id': '4'}, - {'_from': 'ncbi_taxon/3', '_to': 'ncbi_taxon/2', 'from': '3', 'to': '2', 'id': '3'}, - {'_from': 'ncbi_taxon/5', '_to': 'ncbi_taxon/4', 'from': '5', 'to': '4', 'id': '5'}, - {'_from': 'ncbi_taxon/6', '_to': 'ncbi_taxon/4', 'from': '6', 'to': '4', 'id': '6'}, - {'_from': 'ncbi_taxon/7', '_to': 'ncbi_taxon/4', 'from': '7', 'to': '4', 'id': '7'}, + { + "_from": "ncbi_taxon/2", + "_to": "ncbi_taxon/1", + "from": "2", + "to": "1", + "id": "2", + }, + { + "_from": "ncbi_taxon/4", + "_to": "ncbi_taxon/1", + "from": "4", + "to": "1", + "id": "4", + }, + { + "_from": "ncbi_taxon/3", + "_to": "ncbi_taxon/2", + "from": "3", + "to": "2", + "id": "3", + }, + { + "_from": "ncbi_taxon/5", + "_to": "ncbi_taxon/4", + "from": "5", + "to": "4", + "id": "5", + }, + { + "_from": "ncbi_taxon/6", + "_to": "ncbi_taxon/4", + "from": "6", + "to": "4", + "id": "6", + }, + { + "_from": "ncbi_taxon/7", + "_to": "ncbi_taxon/4", + "from": "7", + "to": "4", + "id": "7", + }, # a few levels missing here - {'_from': 'ncbi_taxon/8', '_to': 'ncbi_taxon/3', 'from': '8', 'to': '3', 'id': '8'}, + { + "_from": "ncbi_taxon/8", + "_to": "ncbi_taxon/3", + "from": "8", + "to": "3", + "id": "8", + }, ] obj_ver_docs = [ _construct_ws_obj_ver(1, 1, 1, is_public=True), @@ -52,189 +138,230 @@ def setUpClass(cls): _construct_ws_obj(2, 1, is_public=False), ] obj_to_taxa_docs = [ - {'_from': 'ws_object_version/1:1:1', '_to': 'ncbi_taxon/1', 'assigned_by': 'assn1'}, - {'_from': 'ws_object_version/1:1:2', '_to': 'ncbi_taxon/1', 'assigned_by': 'assn2'}, - {'_from': 'ws_object_version/2:1:1', '_to': 'ncbi_taxon/1', 'assigned_by': 'assn2'}, + { + "_from": "ws_object_version/1:1:1", + "_to": "ncbi_taxon/1", + "assigned_by": "assn1", + }, + { + "_from": "ws_object_version/1:1:2", + "_to": "ncbi_taxon/1", + "assigned_by": "assn2", + }, + { + "_from": "ws_object_version/2:1:1", + "_to": "ncbi_taxon/1", + "assigned_by": "assn2", + }, ] # Create workspace objects associated to taxa ws_docs = [ - _ws_defaults({'_key': '1', 'is_public': True}), - _ws_defaults({'_key': '2', 'is_public': False}), + _ws_defaults({"_key": "1", "is_public": True}), + _ws_defaults({"_key": "2", "is_public": False}), ] ws_to_obj = [ - {'_from': 'ws_workspace/1', '_to': 'ws_object/1:1'}, - {'_from': 'ws_workspace/2', '_to': 'ws_object/2:1'}, + {"_from": "ws_workspace/1", "_to": "ws_object/1:1"}, + {"_from": "ws_workspace/2", "_to": "ws_object/2:1"}, ] ws_type_version_docs = [ - {'_key': 'KBaseGenomes.Genome-99.77', 'module_name': 'KBaseGenomes', - 'type_name': 'Genome', 'maj_ver': 99, 'min_ver': 77} + { + "_key": "KBaseGenomes.Genome-99.77", + "module_name": "KBaseGenomes", + "type_name": "Genome", + "maj_ver": 99, + "min_ver": 77, + } ] ws_obj_instance_of_type_docs = [ - {'_from': 'ws_object_version/1:1:1', '_to': 'ws_type_version/KBaseGenomes.Genome-99.77'}, - {'_from': 'ws_object_version/1:1:2', '_to': 'ws_type_version/KBaseGenomes.Genome-99.77'} + { + "_from": "ws_object_version/1:1:1", + "_to": "ws_type_version/KBaseGenomes.Genome-99.77", + }, + { + "_from": "ws_object_version/1:1:2", + "_to": "ws_type_version/KBaseGenomes.Genome-99.77", + }, ] - _create_delta_test_docs('ncbi_taxon', taxon_docs) - _create_delta_test_docs('ncbi_child_of_taxon', child_docs, edge=True) - create_test_docs('ws_obj_version_has_taxon', obj_to_taxa_docs) - create_test_docs('ws_object', obj_docs) - create_test_docs('ws_workspace', ws_docs) - create_test_docs('ws_workspace_contains_obj', ws_to_obj) - create_test_docs('ws_object_version', obj_ver_docs) - create_test_docs('ws_obj_instance_of_type', ws_obj_instance_of_type_docs) - create_test_docs('ws_type_version', ws_type_version_docs) + _create_delta_test_docs("ncbi_taxon", taxon_docs) + _create_delta_test_docs("ncbi_child_of_taxon", child_docs, edge=True) + create_test_docs("ws_obj_version_has_taxon", obj_to_taxa_docs) + create_test_docs("ws_object", obj_docs) + create_test_docs("ws_workspace", ws_docs) + create_test_docs("ws_workspace_contains_obj", ws_to_obj) + create_test_docs("ws_object_version", obj_ver_docs) + create_test_docs("ws_obj_instance_of_type", ws_obj_instance_of_type_docs) + create_test_docs("ws_type_version", ws_type_version_docs) def test_get_lineage_valid(self): """Test a valid query of taxon lineage.""" resp = requests.post( - _CONF['re_api_url'] + '/api/v1/query_results', - params={'stored_query': 'ncbi_taxon_get_lineage'}, - data=json.dumps({'ts': _NOW, 'id': '7', 'select': ['rank', 'scientific_name']}), + _CONF["re_api_url"] + "/api/v1/query_results", + params={"stored_query": "ncbi_taxon_get_lineage"}, + data=json.dumps( + {"ts": _NOW, "id": "7", "select": ["rank", "scientific_name"]} + ), ).json() - self.assertEqual(resp['count'], 2) - ranks = [r['rank'] for r in resp['results']] - names = [r['scientific_name'] for r in resp['results']] - self.assertEqual(ranks, ['Domain', 'Phylum']) - self.assertEqual(names, ['Bacteria', 'Proteobacteria']) + self.assertEqual(resp["count"], 2) + ranks = [r["rank"] for r in resp["results"]] + names = [r["scientific_name"] for r in resp["results"]] + self.assertEqual(ranks, ["Domain", "Phylum"]) + self.assertEqual(names, ["Bacteria", "Proteobacteria"]) def test_get_children(self): """Test a valid query of taxon descendants.""" resp = requests.post( - _CONF['re_api_url'] + '/api/v1/query_results', - params={'stored_query': 'ncbi_taxon_get_children'}, - data=json.dumps({ - 'id': '1', - 'ts': _NOW, - 'search_text': 'firmicutes,|proteobacteria', - 'select': ['rank', 'scientific_name'] - }), + _CONF["re_api_url"] + "/api/v1/query_results", + params={"stored_query": "ncbi_taxon_get_children"}, + data=json.dumps( + { + "id": "1", + "ts": _NOW, + "search_text": "firmicutes,|proteobacteria", + "select": ["rank", "scientific_name"], + } + ), ).json() - result = resp['results'][0] - self.assertEqual(result['total_count'], 2) - ranks = {r['rank'] for r in result['results']} - names = [r['scientific_name'] for r in result['results']] - self.assertEqual(ranks, {'Phylum'}) - self.assertEqual(names, ['Firmicutes', 'Proteobacteria']) + result = resp["results"][0] + self.assertEqual(result["total_count"], 2) + ranks = {r["rank"] for r in result["results"]} + names = [r["scientific_name"] for r in result["results"]] + self.assertEqual(ranks, {"Phylum"}) + self.assertEqual(names, ["Firmicutes", "Proteobacteria"]) def test_get_children_cursor(self): """Test a valid query to get children with a cursor.""" resp = requests.post( - _CONF['re_api_url'] + '/api/v1/query_results', - params={'stored_query': 'ncbi_taxon_get_children_cursor'}, - data=json.dumps({'ts': _NOW, 'id': '1'}) + _CONF["re_api_url"] + "/api/v1/query_results", + params={"stored_query": "ncbi_taxon_get_children_cursor"}, + data=json.dumps({"ts": _NOW, "id": "1"}), ).json() - self.assertEqual(len(resp['results']), 2) + self.assertEqual(len(resp["results"]), 2) def test_siblings_valid(self): """Test a valid query for siblings.""" # Querying from "Alphaproteobacteria" resp = requests.post( - _CONF['re_api_url'] + '/api/v1/query_results', - params={'stored_query': 'ncbi_taxon_get_siblings'}, - data=json.dumps({ - 'ts': _NOW, - 'id': '5', - 'select': ['rank', 'scientific_name'] - }) + _CONF["re_api_url"] + "/api/v1/query_results", + params={"stored_query": "ncbi_taxon_get_siblings"}, + data=json.dumps( + {"ts": _NOW, "id": "5", "select": ["rank", "scientific_name"]} + ), ).json() - result = resp['results'][0] - self.assertEqual(result['total_count'], 2) - ranks = {r['rank'] for r in result['results']} - names = [r['scientific_name'] for r in result['results']] - self.assertEqual(ranks, {'Class'}) - self.assertEqual(names, ['Deltaproteobacteria', 'Gammaproteobacteria']) + result = resp["results"][0] + self.assertEqual(result["total_count"], 2) + ranks = {r["rank"] for r in result["results"]} + names = [r["scientific_name"] for r in result["results"]] + self.assertEqual(ranks, {"Class"}) + self.assertEqual(names, ["Deltaproteobacteria", "Gammaproteobacteria"]) def test_siblings_root(self): """Test a query for siblings on the root node with no parent.""" resp = requests.post( - _CONF['re_api_url'] + '/api/v1/query_results', - params={'stored_query': 'ncbi_taxon_get_siblings'}, - data=json.dumps({'ts': _NOW, 'id': '1'}), # Querying from "Bacteria" + _CONF["re_api_url"] + "/api/v1/query_results", + params={"stored_query": "ncbi_taxon_get_siblings"}, + data=json.dumps({"ts": _NOW, "id": "1"}), # Querying from "Bacteria" ).json() - self.assertEqual(resp['results'][0]['total_count'], 0) + self.assertEqual(resp["results"][0]["total_count"], 0) def test_siblings_nonexistent_node(self): """Test a query for siblings on the root node with no parent.""" resp = requests.post( - _CONF['re_api_url'] + '/api/v1/query_results', - params={'stored_query': 'ncbi_taxon_get_siblings'}, - data=json.dumps({'ts': _NOW, 'id': 'xyz'}), # Nonexistent node + _CONF["re_api_url"] + "/api/v1/query_results", + params={"stored_query": "ncbi_taxon_get_siblings"}, + data=json.dumps({"ts": _NOW, "id": "xyz"}), # Nonexistent node ).json() - self.assertEqual(resp['results'][0]['total_count'], 0) + self.assertEqual(resp["results"][0]["total_count"], 0) def test_search_sciname_prefix(self): """Test a query to search sciname.""" resp = requests.post( - _CONF['re_api_url'] + '/api/v1/query_results', - params={'stored_query': 'ncbi_taxon_search_sci_name'}, - data=json.dumps({'ts': _NOW, 'search_text': 'prefix:bact', 'select': ['scientific_name']}), + _CONF["re_api_url"] + "/api/v1/query_results", + params={"stored_query": "ncbi_taxon_search_sci_name"}, + data=json.dumps( + { + "ts": _NOW, + "search_text": "prefix:bact", + "select": ["scientific_name"], + } + ), ).json() - result = resp['results'][0] - self.assertEqual(result['total_count'], 1) - self.assertEqual(result['results'][0]['scientific_name'], 'Bacteria') + result = resp["results"][0] + self.assertEqual(result["total_count"], 1) + self.assertEqual(result["results"][0]["scientific_name"], "Bacteria") def test_search_sciname_nonexistent(self): """Test a query to search sciname for empty results.""" resp = requests.post( - _CONF['re_api_url'] + '/api/v1/query_results', - params={'stored_query': 'ncbi_taxon_search_sci_name'}, - data=json.dumps({'ts': _NOW, 'search_text': 'xyzabc'}), + _CONF["re_api_url"] + "/api/v1/query_results", + params={"stored_query": "ncbi_taxon_search_sci_name"}, + data=json.dumps({"ts": _NOW, "search_text": "xyzabc"}), ).json() - self.assertEqual(resp['results'][0]['total_count'], 0) + self.assertEqual(resp["results"][0]["total_count"], 0) def test_search_sciname_wrong_type(self): """Test a query to search sciname with the wrong type for the search_text param.""" resp = requests.post( - _CONF['re_api_url'] + '/api/v1/query_results', - params={'stored_query': 'ncbi_taxon_search_sci_name'}, - data=json.dumps({'ts': _NOW, 'search_text': 123}) + _CONF["re_api_url"] + "/api/v1/query_results", + params={"stored_query": "ncbi_taxon_search_sci_name"}, + data=json.dumps({"ts": _NOW, "search_text": 123}), ) self.assertEqual(resp.status_code, 400) - self.assertEqual(resp.json()['error']['message'], "123 is not of type 'string'") + self.assertEqual(resp.json()["error"]["message"], "123 is not of type 'string'") def test_search_sciname_missing_search(self): """Test a query to search sciname with the search_text param missing.""" resp = requests.post( - _CONF['re_api_url'] + '/api/v1/query_results', - params={'stored_query': 'ncbi_taxon_search_sci_name'}, - data=json.dumps({'ts': _NOW}) + _CONF["re_api_url"] + "/api/v1/query_results", + params={"stored_query": "ncbi_taxon_search_sci_name"}, + data=json.dumps({"ts": _NOW}), ) self.assertEqual(resp.status_code, 400) - self.assertEqual(resp.json()['error']['message'], "'search_text' is a required property") + self.assertEqual( + resp.json()["error"]["message"], "'search_text' is a required property" + ) def test_search_sciname_more_complicated(self): """Test a query to search sciname with some more keyword options.""" resp = requests.post( - _CONF['re_api_url'] + '/api/v1/query_results', - params={'stored_query': 'ncbi_taxon_search_sci_name'}, - data=json.dumps({ - 'ts': _NOW, - 'search_text': "prefix:gamma,|prefix:alpha,|prefix:delta" - }) + _CONF["re_api_url"] + "/api/v1/query_results", + params={"stored_query": "ncbi_taxon_search_sci_name"}, + data=json.dumps( + {"ts": _NOW, "search_text": "prefix:gamma,|prefix:alpha,|prefix:delta"} + ), ).json() - result = resp['results'][0] - self.assertEqual(result['total_count'], 3) - names = {r['scientific_name'] for r in result['results']} - self.assertEqual(names, {'Gammaproteobacteria', 'Alphaproteobacteria', 'Deltaproteobacteria'}) + result = resp["results"][0] + self.assertEqual(result["total_count"], 3) + names = {r["scientific_name"] for r in result["results"]} + self.assertEqual( + names, {"Gammaproteobacteria", "Alphaproteobacteria", "Deltaproteobacteria"} + ) def test_search_sciname_offset_max(self): """Test a query to search sciname with an invalid offset (greater than max).""" resp = requests.post( - _CONF['re_api_url'] + '/api/v1/query_results', - params={'stored_query': 'ncbi_taxon_search_sci_name'}, - data=json.dumps({'ts': _NOW, 'search_text': "prefix:bact", "offset": 100001}) + _CONF["re_api_url"] + "/api/v1/query_results", + params={"stored_query": "ncbi_taxon_search_sci_name"}, + data=json.dumps( + {"ts": _NOW, "search_text": "prefix:bact", "offset": 100001} + ), ) self.assertEqual(resp.status_code, 400) - self.assertEqual(resp.json()['error']['message'], "100001 is greater than the maximum of 100000") + self.assertEqual( + resp.json()["error"]["message"], + "100001 is greater than the maximum of 100000", + ) def test_search_sciname_limit_max(self): """Test a query to search sciname with an invalid offset (greater than max).""" resp = requests.post( - _CONF['re_api_url'] + '/api/v1/query_results', - params={'stored_query': 'ncbi_taxon_search_sci_name'}, - data=json.dumps({'ts': _NOW, 'search_text': "prefix:bact", "limit": 1001}) + _CONF["re_api_url"] + "/api/v1/query_results", + params={"stored_query": "ncbi_taxon_search_sci_name"}, + data=json.dumps({"ts": _NOW, "search_text": "prefix:bact", "limit": 1001}), ) self.assertEqual(resp.status_code, 400) - self.assertEqual(resp.json()['error']['message'], "1001 is greater than the maximum of 1000") + self.assertEqual( + resp.json()["error"]["message"], "1001 is greater than the maximum of 1000" + ) def test_search_sciname_limit_ranks_implicit_defaults(self): """ Test queries where the results are limited by the rank or strain flag. """ @@ -243,7 +370,8 @@ def test_search_sciname_limit_ranks_implicit_defaults(self): ranks=None, include_strains=None, expected_count=3, - expected_sci_names={'Bacteria', 'Bacilli', 'Bacillus subtilis 168'}) + expected_sci_names={"Bacteria", "Bacilli", "Bacillus subtilis 168"}, + ) def test_search_sciname_limit_ranks_explicit_defaults(self): """ Test queries where the results are limited by the rank or strain flag. """ @@ -252,66 +380,68 @@ def test_search_sciname_limit_ranks_explicit_defaults(self): ranks=[], include_strains=False, expected_count=3, - expected_sci_names={'Bacteria', 'Bacilli', 'Bacillus subtilis 168'}) + expected_sci_names={"Bacteria", "Bacilli", "Bacillus subtilis 168"}, + ) def test_search_sciname_limit_ranks_2(self): """ Test queries where the results are limited by the rank or strain flag. """ _run_search_sciname( self, - ranks=['Domain', 'Class'], + ranks=["Domain", "Class"], include_strains=None, expected_count=2, - expected_sci_names={'Bacteria', 'Bacilli'}) + expected_sci_names={"Bacteria", "Bacilli"}, + ) def test_search_sciname_limit_ranks_1(self): """ Test queries where the results are limited by the rank or strain flag. """ _run_search_sciname( self, - ranks=['Class'], + ranks=["Class"], include_strains=None, expected_count=1, - expected_sci_names={'Bacilli'}) + expected_sci_names={"Bacilli"}, + ) def test_search_sciname_limit_ranks_1_with_strain(self): """ Test queries where the results are limited by the rank or strain flag. """ _run_search_sciname( self, - ranks=['Class'], + ranks=["Class"], include_strains=True, expected_count=2, - expected_sci_names={'Bacilli', 'Bacillus subtilis 168'}) + expected_sci_names={"Bacilli", "Bacillus subtilis 168"}, + ) def test_search_sciname_limit_ranks_1_with_false_strain(self): """ Test queries where the results are limited by the rank or strain flag. """ _run_search_sciname( self, - ranks=['Class'], + ranks=["Class"], include_strains=False, expected_count=1, - expected_sci_names={'Bacilli'}) + expected_sci_names={"Bacilli"}, + ) def test_select_fields(self): """Test that the 'select' works properly for one query.""" resp = requests.post( - _CONF['re_api_url'] + '/api/v1/query_results', - params={'stored_query': 'ncbi_taxon_get_lineage'}, - data=json.dumps({'ts': _NOW, 'id': '7', 'select': ['rank']}) + _CONF["re_api_url"] + "/api/v1/query_results", + params={"stored_query": "ncbi_taxon_get_lineage"}, + data=json.dumps({"ts": _NOW, "id": "7", "select": ["rank"]}), ).json() - self.assertEqual(resp['count'], 2) - self.assertEqual(resp['results'], [ - {'rank': 'Domain'}, - {'rank': 'Phylum'} - ]) + self.assertEqual(resp["count"], 2) + self.assertEqual(resp["results"], [{"rank": "Domain"}, {"rank": "Phylum"}]) def test_fetch_taxon(self): """Test a valid query to fetch a taxon.""" resp = requests.post( - _CONF['re_api_url'] + '/api/v1/query_results', - params={'stored_query': 'ncbi_fetch_taxon'}, - data=json.dumps({'ts': _NOW, 'id': '1'}) + _CONF["re_api_url"] + "/api/v1/query_results", + params={"stored_query": "ncbi_fetch_taxon"}, + data=json.dumps({"ts": _NOW, "id": "1"}), ).json() - self.assertEqual(resp['count'], 1) - self.assertEqual(resp['results'][0]['id'], '1') + self.assertEqual(resp["count"], 1) + self.assertEqual(resp["results"][0]["id"], "1") def test_get_associated_objs(self): """ @@ -319,125 +449,141 @@ def test_get_associated_objs(self): Two objects are public and one is private, so total_count will be 3 while only the public objects are returned. """ resp = requests.post( - _CONF['re_api_url'] + '/api/v1/query_results', - params={'stored_query': 'ncbi_taxon_get_associated_ws_objects'}, - data=json.dumps({'ts': _NOW, 'taxon_id': '1', 'select_obj': ['_id', 'type', 'ws_info'], - 'select_edge': ['assigned_by']}), + _CONF["re_api_url"] + "/api/v1/query_results", + params={"stored_query": "ncbi_taxon_get_associated_ws_objects"}, + data=json.dumps( + { + "ts": _NOW, + "taxon_id": "1", + "select_obj": ["_id", "type", "ws_info"], + "select_edge": ["assigned_by"], + } + ), ).json() - self.assertEqual(resp['count'], 1) - results = resp['results'][0] - self.assertEqual(results['total_count'], 3) - self.assertEqual(len(results['results']), 2) - assignments = {ret['edge']['assigned_by'] for ret in results['results']} - ids = {ret['ws_obj']['_id'] for ret in results['results']} - self.assertEqual(assignments, {'assn1', 'assn2'}) - self.assertEqual(ids, {'ws_object_version/1:1:1', 'ws_object_version/1:1:2'}) - self.assertEqual(results['results'][0]['ws_obj']['type'], { - 'type_name': 'Genome', - 'module_name': 'KBaseGenomes', - 'maj_ver': 99, - 'min_ver': 77, - '_key': 'KBaseGenomes.Genome-99.77' - }) - self.assertEqual(results['results'][0]['ws_obj']['ws_info'], { - 'owner': 'owner', - 'metadata': {'narrative_nice_name': 'narrname'}, - 'is_public': True, - 'mod_epoch': 1 - }) + self.assertEqual(resp["count"], 1) + results = resp["results"][0] + self.assertEqual(results["total_count"], 3) + self.assertEqual(len(results["results"]), 2) + assignments = {ret["edge"]["assigned_by"] for ret in results["results"]} + ids = {ret["ws_obj"]["_id"] for ret in results["results"]} + self.assertEqual(assignments, {"assn1", "assn2"}) + self.assertEqual(ids, {"ws_object_version/1:1:1", "ws_object_version/1:1:2"}) + self.assertEqual( + results["results"][0]["ws_obj"]["type"], + { + "type_name": "Genome", + "module_name": "KBaseGenomes", + "maj_ver": 99, + "min_ver": 77, + "_key": "KBaseGenomes.Genome-99.77", + }, + ) + self.assertEqual( + results["results"][0]["ws_obj"]["ws_info"], + { + "owner": "owner", + "metadata": {"narrative_nice_name": "narrname"}, + "is_public": True, + "mod_epoch": 1, + }, + ) def test_get_taxon_from_ws_obj(self): """Fetch the taxon vertex from a workspace versioned id.""" resp = requests.post( - _CONF['re_api_url'] + '/api/v1/query_results', - params={'stored_query': 'ncbi_taxon_get_taxon_from_ws_obj'}, - data=json.dumps({'ts': _NOW, 'obj_ref': '1:1:1'}) + _CONF["re_api_url"] + "/api/v1/query_results", + params={"stored_query": "ncbi_taxon_get_taxon_from_ws_obj"}, + data=json.dumps({"ts": _NOW, "obj_ref": "1:1:1"}), ).json() - self.assertEqual(resp['count'], 1) - assert_subset(self, { - 'id': '1', - 'scientific_name': 'Bacteria', - 'rank': 'Domain' - }, resp['results'][0]) + self.assertEqual(resp["count"], 1) + assert_subset( + self, + {"id": "1", "scientific_name": "Bacteria", "rank": "Domain"}, + resp["results"][0], + ) def test_fetch_taxon_by_sciname(self): """Test the ncbi_fetch_taxon_by_sciname query.""" - sciname = 'Deltaproteobacteria' + sciname = "Deltaproteobacteria" resp = requests.post( - _CONF['re_api_url'] + '/api/v1/query_results', - params={'stored_query': 'ncbi_fetch_taxon_by_sciname'}, - data=json.dumps({'ts': _NOW, 'sciname': 'Deltaproteobacteria'}) + _CONF["re_api_url"] + "/api/v1/query_results", + params={"stored_query": "ncbi_fetch_taxon_by_sciname"}, + data=json.dumps({"ts": _NOW, "sciname": "Deltaproteobacteria"}), ).json() - self.assertEqual(resp['count'], 1) - assert_subset(self, { - 'id': '7', - 'scientific_name': sciname, - 'rank': 'Class', - }, resp['results'][0]) + self.assertEqual(resp["count"], 1) + assert_subset( + self, + { + "id": "7", + "scientific_name": sciname, + "rank": "Class", + }, + resp["results"][0], + ) def test_fetch_taxon_by_sciname_failures(self): """Test invalid cases for ncbi_fetch_taxon_by_sciname.""" # No sciname resp = requests.post( - _CONF['re_api_url'] + '/api/v1/query_results', - params={'stored_query': 'ncbi_fetch_taxon_by_sciname'}, - data=json.dumps({'ts': _NOW}) + _CONF["re_api_url"] + "/api/v1/query_results", + params={"stored_query": "ncbi_fetch_taxon_by_sciname"}, + data=json.dumps({"ts": _NOW}), ).json() - self.assertEqual(resp['error']['message'], "'sciname' is a required property") + self.assertEqual(resp["error"]["message"], "'sciname' is a required property") # No ts resp = requests.post( - _CONF['re_api_url'] + '/api/v1/query_results', - params={'stored_query': 'ncbi_fetch_taxon_by_sciname'}, - data=json.dumps({'sciname': 'Deltaproteobacteria'}) + _CONF["re_api_url"] + "/api/v1/query_results", + params={"stored_query": "ncbi_fetch_taxon_by_sciname"}, + data=json.dumps({"sciname": "Deltaproteobacteria"}), ).json() - self.assertEqual(resp['error']['message'], "'ts' is a required property") + self.assertEqual(resp["error"]["message"], "'ts' is a required property") # sciname not found resp = requests.post( - _CONF['re_api_url'] + '/api/v1/query_results', - params={'stored_query': 'ncbi_fetch_taxon_by_sciname'}, - data=json.dumps({'ts': _NOW, 'sciname': 'xyzabc'}) + _CONF["re_api_url"] + "/api/v1/query_results", + params={"stored_query": "ncbi_fetch_taxon_by_sciname"}, + data=json.dumps({"ts": _NOW, "sciname": "xyzabc"}), ).json() - self.assertEqual(resp['count'], 0) - self.assertEqual(len(resp['results']), 0) + self.assertEqual(resp["count"], 0) + self.assertEqual(len(resp["results"]), 0) # -- Test helpers -def _run_search_sciname(self, ranks, include_strains, expected_count, expected_sci_names): + +def _run_search_sciname( + self, ranks, include_strains, expected_count, expected_sci_names +): """ Helper to run the ncbi_taxon_search_sci_name query and make some standard assertions on the response. """ - data = { - 'ts': _NOW, - 'search_text': "prefix:bac" - } + data = {"ts": _NOW, "search_text": "prefix:bac"} if ranks is not None: - data['ranks'] = ranks + data["ranks"] = ranks if include_strains is not None: - data['include_strains'] = include_strains + data["include_strains"] = include_strains resp = requests.post( - _CONF['re_api_url'] + '/api/v1/query_results', - params={'stored_query': 'ncbi_taxon_search_sci_name'}, - data=json.dumps(data) - ).json() - result = resp['results'][0] - self.assertEqual(result['total_count'], expected_count) - names = {r['scientific_name'] for r in result['results']} + _CONF["re_api_url"] + "/api/v1/query_results", + params={"stored_query": "ncbi_taxon_search_sci_name"}, + data=json.dumps(data), + ).json() + result = resp["results"][0] + self.assertEqual(result["total_count"], expected_count) + names = {r["scientific_name"] for r in result["results"]} self.assertEqual(names, expected_sci_names) def _ws_defaults(data): """Set some defaults for the required workspace fields.""" defaults = { - 'owner': 'owner', - 'max_obj_id': 1, - 'lock_status': 'n', - 'name': 'wsname', - 'mod_epoch': 1, - 'is_public': True, - 'is_deleted': False, - 'metadata': {'narrative_nice_name': 'narrname'}, + "owner": "owner", + "max_obj_id": 1, + "lock_status": "n", + "name": "wsname", + "mod_epoch": 1, + "is_public": True, + "is_deleted": False, + "metadata": {"narrative_nice_name": "narrname"}, } # Merge the data with the above defaults return dict(defaults, **data) @@ -446,27 +592,27 @@ def _ws_defaults(data): def _construct_ws_obj_ver(wsid, objid, ver, is_public=False): """Test helper to create a ws_object_version vertex.""" return { - '_key': f"{wsid}:{objid}:{ver}", - 'workspace_id': wsid, - 'object_id': objid, - 'version': ver, - 'name': f'obj_name{objid}', - 'hash': 'xyz', - 'size': 100, - 'epoch': 0, - 'deleted': False, - 'is_public': is_public, + "_key": f"{wsid}:{objid}:{ver}", + "workspace_id": wsid, + "object_id": objid, + "version": ver, + "name": f"obj_name{objid}", + "hash": "xyz", + "size": 100, + "epoch": 0, + "deleted": False, + "is_public": is_public, } def _construct_ws_obj(wsid, objid, is_public=False): """Test helper to create a ws_object vertex.""" return { - '_key': f"{wsid}:{objid}", - 'workspace_id': wsid, - 'object_id': objid, - 'deleted': False, - 'is_public': is_public, + "_key": f"{wsid}:{objid}", + "workspace_id": wsid, + "object_id": objid, + "deleted": False, + "is_public": is_public, } @@ -475,12 +621,12 @@ def _create_delta_test_docs(coll_name, docs, edge=False): if edge: for doc in docs: # Replicate the time-travel system by just setting 'from' and 'to' to the keys - doc['from'] = doc['_from'].split('/')[1] - doc['to'] = doc['_to'].split('/')[1] + doc["from"] = doc["_from"].split("/")[1] + doc["to"] = doc["_to"].split("/")[1] else: for doc in docs: - doc['id'] = doc['_key'] + doc["id"] = doc["_key"] for doc in docs: - doc['expired'] = 9007199254740991 - doc['created'] = 0 + doc["expired"] = 9007199254740991 + doc["created"] = 0 create_test_docs(coll_name, docs) diff --git a/spec/test/stored_queries/test_taxonomy.py b/spec/test/stored_queries/test_taxonomy.py index 27025b18..8cb71733 100644 --- a/spec/test/stored_queries/test_taxonomy.py +++ b/spec/test/stored_queries/test_taxonomy.py @@ -8,41 +8,127 @@ import unittest import requests -from spec.test.helpers import get_config, assert_subset, create_test_docs, check_spec_test_env +from spec.test.helpers import ( + get_config, + assert_subset, + create_test_docs, + check_spec_test_env, +) _CONF = get_config() _NOW = int(time.time() * 1000) class TestTaxonomy(unittest.TestCase): - @classmethod def setUpClass(cls): """Create test documents""" check_spec_test_env() taxon_docs = [ - {'_key': '1', 'scientific_name': 'Bacteria', 'rank': 'Domain', 'strain': False}, - {'_key': '2', 'scientific_name': 'Firmicutes', 'rank': 'Phylum', 'strain': False}, - {'_key': '3', 'scientific_name': 'Bacilli', 'rank': 'Class', 'strain': False}, - {'_key': '4', 'scientific_name': 'Proteobacteria', 'rank': 'Phylum', 'strain': False}, - {'_key': '5', 'scientific_name': 'Alphaproteobacteria', 'rank': 'Class', 'strain': False}, - {'_key': '6', 'scientific_name': 'Gammaproteobacteria', 'rank': 'Class', 'strain': False}, - {'_key': '7', 'scientific_name': 'Deltaproteobacteria', 'rank': 'Class', 'strain': False}, - {'_key': '8', 'scientific_name': 'Bacillus subtilis 168', 'rank': 'no rank', 'strain': True}, + { + "_key": "1", + "scientific_name": "Bacteria", + "rank": "Domain", + "strain": False, + }, + { + "_key": "2", + "scientific_name": "Firmicutes", + "rank": "Phylum", + "strain": False, + }, + { + "_key": "3", + "scientific_name": "Bacilli", + "rank": "Class", + "strain": False, + }, + { + "_key": "4", + "scientific_name": "Proteobacteria", + "rank": "Phylum", + "strain": False, + }, + { + "_key": "5", + "scientific_name": "Alphaproteobacteria", + "rank": "Class", + "strain": False, + }, + { + "_key": "6", + "scientific_name": "Gammaproteobacteria", + "rank": "Class", + "strain": False, + }, + { + "_key": "7", + "scientific_name": "Deltaproteobacteria", + "rank": "Class", + "strain": False, + }, + { + "_key": "8", + "scientific_name": "Bacillus subtilis 168", + "rank": "no rank", + "strain": True, + }, ] gtdb_taxon_docs = [ - {'_key': '1', 'scientific_name': 'Bacteria', 'rank': 'Domain'}, + {"_key": "1", "scientific_name": "Bacteria", "rank": "Domain"}, ] child_docs = [ - {'_from': 'ncbi_taxon/2', '_to': 'ncbi_taxon/1', 'from': '2', 'to': '1', 'id': '2'}, - {'_from': 'ncbi_taxon/4', '_to': 'ncbi_taxon/1', 'from': '4', 'to': '1', 'id': '4'}, - {'_from': 'ncbi_taxon/3', '_to': 'ncbi_taxon/2', 'from': '3', 'to': '2', 'id': '3'}, - {'_from': 'ncbi_taxon/5', '_to': 'ncbi_taxon/4', 'from': '5', 'to': '4', 'id': '5'}, - {'_from': 'ncbi_taxon/6', '_to': 'ncbi_taxon/4', 'from': '6', 'to': '4', 'id': '6'}, - {'_from': 'ncbi_taxon/7', '_to': 'ncbi_taxon/4', 'from': '7', 'to': '4', 'id': '7'}, + { + "_from": "ncbi_taxon/2", + "_to": "ncbi_taxon/1", + "from": "2", + "to": "1", + "id": "2", + }, + { + "_from": "ncbi_taxon/4", + "_to": "ncbi_taxon/1", + "from": "4", + "to": "1", + "id": "4", + }, + { + "_from": "ncbi_taxon/3", + "_to": "ncbi_taxon/2", + "from": "3", + "to": "2", + "id": "3", + }, + { + "_from": "ncbi_taxon/5", + "_to": "ncbi_taxon/4", + "from": "5", + "to": "4", + "id": "5", + }, + { + "_from": "ncbi_taxon/6", + "_to": "ncbi_taxon/4", + "from": "6", + "to": "4", + "id": "6", + }, + { + "_from": "ncbi_taxon/7", + "_to": "ncbi_taxon/4", + "from": "7", + "to": "4", + "id": "7", + }, # a few levels missing here - {'_from': 'ncbi_taxon/8', '_to': 'ncbi_taxon/3', 'from': '8', 'to': '3', 'id': '8'}, + { + "_from": "ncbi_taxon/8", + "_to": "ncbi_taxon/3", + "from": "8", + "to": "3", + "id": "8", + }, ] obj_ver_docs = [ _construct_ws_obj_ver(1, 1, 1, is_public=True), @@ -54,285 +140,345 @@ def setUpClass(cls): _construct_ws_obj(2, 1, is_public=False), ] obj_to_taxa_docs = [ - {'_from': 'ws_object_version/1:1:1', '_to': 'ncbi_taxon/1', 'assigned_by': 'assn1'}, - {'_from': 'ws_object_version/1:1:2', '_to': 'ncbi_taxon/1', 'assigned_by': 'assn2'}, - {'_from': 'ws_object_version/2:1:1', '_to': 'ncbi_taxon/1', 'assigned_by': 'assn2'}, + { + "_from": "ws_object_version/1:1:1", + "_to": "ncbi_taxon/1", + "assigned_by": "assn1", + }, + { + "_from": "ws_object_version/1:1:2", + "_to": "ncbi_taxon/1", + "assigned_by": "assn2", + }, + { + "_from": "ws_object_version/2:1:1", + "_to": "ncbi_taxon/1", + "assigned_by": "assn2", + }, ] # Create workspace objects associated to taxa ws_docs = [ - _ws_defaults({'_key': '1', 'is_public': True}), - _ws_defaults({'_key': '2', 'is_public': False}), + _ws_defaults({"_key": "1", "is_public": True}), + _ws_defaults({"_key": "2", "is_public": False}), ] ws_to_obj = [ - {'_from': 'ws_workspace/1', '_to': 'ws_object/1:1'}, - {'_from': 'ws_workspace/2', '_to': 'ws_object/2:1'}, + {"_from": "ws_workspace/1", "_to": "ws_object/1:1"}, + {"_from": "ws_workspace/2", "_to": "ws_object/2:1"}, ] ws_type_version_docs = [ - {'_key': 'KBaseGenomes.Genome-99.77', 'module_name': 'KBaseGenomes', - 'type_name': 'Genome', 'maj_ver': 99, 'min_ver': 77} + { + "_key": "KBaseGenomes.Genome-99.77", + "module_name": "KBaseGenomes", + "type_name": "Genome", + "maj_ver": 99, + "min_ver": 77, + } ] ws_obj_instance_of_type_docs = [ - {'_from': 'ws_object_version/1:1:1', '_to': 'ws_type_version/KBaseGenomes.Genome-99.77'}, - {'_from': 'ws_object_version/1:1:2', '_to': 'ws_type_version/KBaseGenomes.Genome-99.77'} + { + "_from": "ws_object_version/1:1:1", + "_to": "ws_type_version/KBaseGenomes.Genome-99.77", + }, + { + "_from": "ws_object_version/1:1:2", + "_to": "ws_type_version/KBaseGenomes.Genome-99.77", + }, ] - _create_delta_test_docs('ncbi_taxon', taxon_docs) - _create_delta_test_docs('gtdb_taxon', gtdb_taxon_docs) - _create_delta_test_docs('ncbi_child_of_taxon', child_docs, edge=True) - create_test_docs('ws_obj_version_has_taxon', obj_to_taxa_docs) - create_test_docs('ws_object', obj_docs) - create_test_docs('ws_workspace', ws_docs) - create_test_docs('ws_workspace_contains_obj', ws_to_obj) - create_test_docs('ws_object_version', obj_ver_docs) - create_test_docs('ws_obj_instance_of_type', ws_obj_instance_of_type_docs) - create_test_docs('ws_type_version', ws_type_version_docs) + _create_delta_test_docs("ncbi_taxon", taxon_docs) + _create_delta_test_docs("gtdb_taxon", gtdb_taxon_docs) + _create_delta_test_docs("ncbi_child_of_taxon", child_docs, edge=True) + create_test_docs("ws_obj_version_has_taxon", obj_to_taxa_docs) + create_test_docs("ws_object", obj_docs) + create_test_docs("ws_workspace", ws_docs) + create_test_docs("ws_workspace_contains_obj", ws_to_obj) + create_test_docs("ws_object_version", obj_ver_docs) + create_test_docs("ws_obj_instance_of_type", ws_obj_instance_of_type_docs) + create_test_docs("ws_type_version", ws_type_version_docs) def test_get_lineage_valid(self): """Test a valid query of taxon lineage.""" resp = requests.post( - _CONF['re_api_url'] + '/api/v1/query_results', - params={'stored_query': 'taxonomy_get_lineage'}, - data=json.dumps({ - 'ts': _NOW, - 'id': '7', - 'select': ['rank', 'scientific_name'], - '@taxon_coll': 'ncbi_taxon', - '@taxon_child_of': 'ncbi_child_of_taxon' - }), + _CONF["re_api_url"] + "/api/v1/query_results", + params={"stored_query": "taxonomy_get_lineage"}, + data=json.dumps( + { + "ts": _NOW, + "id": "7", + "select": ["rank", "scientific_name"], + "@taxon_coll": "ncbi_taxon", + "@taxon_child_of": "ncbi_child_of_taxon", + } + ), ).json() - self.assertEqual(resp['count'], 2) - ranks = [r['rank'] for r in resp['results']] - names = [r['scientific_name'] for r in resp['results']] - self.assertEqual(ranks, ['Domain', 'Phylum']) - self.assertEqual(names, ['Bacteria', 'Proteobacteria']) + self.assertEqual(resp["count"], 2) + ranks = [r["rank"] for r in resp["results"]] + names = [r["scientific_name"] for r in resp["results"]] + self.assertEqual(ranks, ["Domain", "Phylum"]) + self.assertEqual(names, ["Bacteria", "Proteobacteria"]) def test_get_children(self): """Test a valid query of taxon descendants.""" resp = requests.post( - _CONF['re_api_url'] + '/api/v1/query_results', - params={'stored_query': 'taxonomy_get_children'}, - data=json.dumps({ - 'id': '1', - 'ts': _NOW, - 'search_text': 'firmicutes,|proteobacteria', - 'select': ['rank', 'scientific_name'], - 'sciname_field': 'scientific_name', - '@taxon_coll': 'ncbi_taxon', - '@taxon_child_of': 'ncbi_child_of_taxon', - }), + _CONF["re_api_url"] + "/api/v1/query_results", + params={"stored_query": "taxonomy_get_children"}, + data=json.dumps( + { + "id": "1", + "ts": _NOW, + "search_text": "firmicutes,|proteobacteria", + "select": ["rank", "scientific_name"], + "sciname_field": "scientific_name", + "@taxon_coll": "ncbi_taxon", + "@taxon_child_of": "ncbi_child_of_taxon", + } + ), ).json() - result = resp['results'][0] - self.assertEqual(result['total_count'], 2) - ranks = {r['rank'] for r in result['results']} - names = [r['scientific_name'] for r in result['results']] - self.assertEqual(ranks, {'Phylum'}) - self.assertEqual(names, ['Firmicutes', 'Proteobacteria']) + result = resp["results"][0] + self.assertEqual(result["total_count"], 2) + ranks = {r["rank"] for r in result["results"]} + names = [r["scientific_name"] for r in result["results"]] + self.assertEqual(ranks, {"Phylum"}) + self.assertEqual(names, ["Firmicutes", "Proteobacteria"]) def test_get_children_cursor(self): """Test a valid query to get children with a cursor.""" resp = requests.post( - _CONF['re_api_url'] + '/api/v1/query_results', - params={'stored_query': 'taxonomy_get_children_cursor'}, - data=json.dumps({ - 'ts': _NOW, - 'id': '1', - '@taxon_coll': 'ncbi_taxon', - '@taxon_child_of': 'ncbi_child_of_taxon' - }) + _CONF["re_api_url"] + "/api/v1/query_results", + params={"stored_query": "taxonomy_get_children_cursor"}, + data=json.dumps( + { + "ts": _NOW, + "id": "1", + "@taxon_coll": "ncbi_taxon", + "@taxon_child_of": "ncbi_child_of_taxon", + } + ), ).json() - self.assertEqual(len(resp['results']), 2) + self.assertEqual(len(resp["results"]), 2) def test_siblings_valid(self): """Test a valid query for siblings.""" # Querying from "Alphaproteobacteria" resp = requests.post( - _CONF['re_api_url'] + '/api/v1/query_results', - params={'stored_query': 'taxonomy_get_siblings'}, - data=json.dumps({ - 'ts': _NOW, - 'id': '5', - 'select': ['rank', 'scientific_name'], - 'sciname_field': 'scientific_name', - '@taxon_coll': 'ncbi_taxon', - '@taxon_child_of': 'ncbi_child_of_taxon', - }) + _CONF["re_api_url"] + "/api/v1/query_results", + params={"stored_query": "taxonomy_get_siblings"}, + data=json.dumps( + { + "ts": _NOW, + "id": "5", + "select": ["rank", "scientific_name"], + "sciname_field": "scientific_name", + "@taxon_coll": "ncbi_taxon", + "@taxon_child_of": "ncbi_child_of_taxon", + } + ), ).json() - result = resp['results'][0] - self.assertEqual(result['total_count'], 2) - ranks = {r['rank'] for r in result['results']} - names = [r['scientific_name'] for r in result['results']] - self.assertEqual(ranks, {'Class'}) - self.assertEqual(names, ['Deltaproteobacteria', 'Gammaproteobacteria']) + result = resp["results"][0] + self.assertEqual(result["total_count"], 2) + ranks = {r["rank"] for r in result["results"]} + names = [r["scientific_name"] for r in result["results"]] + self.assertEqual(ranks, {"Class"}) + self.assertEqual(names, ["Deltaproteobacteria", "Gammaproteobacteria"]) def test_siblings_root(self): """Test a query for siblings on the root node with no parent.""" resp = requests.post( - _CONF['re_api_url'] + '/api/v1/query_results', - params={'stored_query': 'taxonomy_get_siblings'}, - data=json.dumps({ - 'ts': _NOW, - 'id': '1', - 'sciname_field': 'scientific_name', - '@taxon_coll': 'ncbi_taxon', - '@taxon_child_of': 'ncbi_child_of_taxon', - }), # Querying from "Bacteria" + _CONF["re_api_url"] + "/api/v1/query_results", + params={"stored_query": "taxonomy_get_siblings"}, + data=json.dumps( + { + "ts": _NOW, + "id": "1", + "sciname_field": "scientific_name", + "@taxon_coll": "ncbi_taxon", + "@taxon_child_of": "ncbi_child_of_taxon", + } + ), # Querying from "Bacteria" ).json() - self.assertEqual(resp['results'][0]['total_count'], 0) + self.assertEqual(resp["results"][0]["total_count"], 0) def test_siblings_nonexistent_node(self): """Test a query for siblings on the root node with no parent.""" resp = requests.post( - _CONF['re_api_url'] + '/api/v1/query_results', - params={'stored_query': 'taxonomy_get_siblings'}, - data=json.dumps({ - 'ts': _NOW, - 'id': 'xyz', # Nonexistent node - 'sciname_field': 'scientific_name', - '@taxon_coll': 'ncbi_taxon', - '@taxon_child_of': 'ncbi_child_of_taxon', - }) + _CONF["re_api_url"] + "/api/v1/query_results", + params={"stored_query": "taxonomy_get_siblings"}, + data=json.dumps( + { + "ts": _NOW, + "id": "xyz", # Nonexistent node + "sciname_field": "scientific_name", + "@taxon_coll": "ncbi_taxon", + "@taxon_child_of": "ncbi_child_of_taxon", + } + ), ).json() - self.assertEqual(resp['results'][0]['total_count'], 0) + self.assertEqual(resp["results"][0]["total_count"], 0) def test_search_sci_name_no_count(self): """Test a valid query to search sciname without a count.""" resp = requests.post( - _CONF['re_api_url'] + '/api/v1/query_results', - params={'stored_query': 'taxonomy_search_sci_name'}, - data=json.dumps({ - 'ts': _NOW, - 'no_count': True, - 'search_text': 'prefix:bact', - 'select': ['scientific_name'], - 'sciname_field': 'scientific_name', - 'ranks': ['Domain'], - '@taxon_coll': 'ncbi_taxon', - }), + _CONF["re_api_url"] + "/api/v1/query_results", + params={"stored_query": "taxonomy_search_sci_name"}, + data=json.dumps( + { + "ts": _NOW, + "no_count": True, + "search_text": "prefix:bact", + "select": ["scientific_name"], + "sciname_field": "scientific_name", + "ranks": ["Domain"], + "@taxon_coll": "ncbi_taxon", + } + ), ).json() - result = resp['results'][0] - self.assertTrue('total_count' not in result) - self.assertEqual(result['results'][0]['scientific_name'], 'Bacteria') + result = resp["results"][0] + self.assertTrue("total_count" not in result) + self.assertEqual(result["results"][0]["scientific_name"], "Bacteria") def test_search_sciname_prefix(self): """Test a query to search sciname.""" resp = requests.post( - _CONF['re_api_url'] + '/api/v1/query_results', - params={'stored_query': 'taxonomy_search_sci_name'}, - data=json.dumps({ - 'ts': _NOW, - 'search_text': 'prefix:bact', - 'select': ['scientific_name'], - 'sciname_field': 'scientific_name', - '@taxon_coll': 'ncbi_taxon', - }), + _CONF["re_api_url"] + "/api/v1/query_results", + params={"stored_query": "taxonomy_search_sci_name"}, + data=json.dumps( + { + "ts": _NOW, + "search_text": "prefix:bact", + "select": ["scientific_name"], + "sciname_field": "scientific_name", + "@taxon_coll": "ncbi_taxon", + } + ), ).json() - result = resp['results'][0] - self.assertEqual(result['total_count'], 1) - self.assertEqual(result['results'][0]['scientific_name'], 'Bacteria') + result = resp["results"][0] + self.assertEqual(result["total_count"], 1) + self.assertEqual(result["results"][0]["scientific_name"], "Bacteria") def test_search_sciname_gtdb(self): """Test a search on scientific name against the gtdb taxonomy.""" resp = requests.post( - _CONF['re_api_url'] + '/api/v1/query_results', - params={'stored_query': 'taxonomy_search_sci_name'}, - data=json.dumps({ - 'ts': _NOW, - 'search_text': 'prefix:bact', - 'select': ['scientific_name'], - 'sciname_field': 'scientific_name', - '@taxon_coll': 'gtdb_taxon', - }), + _CONF["re_api_url"] + "/api/v1/query_results", + params={"stored_query": "taxonomy_search_sci_name"}, + data=json.dumps( + { + "ts": _NOW, + "search_text": "prefix:bact", + "select": ["scientific_name"], + "sciname_field": "scientific_name", + "@taxon_coll": "gtdb_taxon", + } + ), ).json() - result = resp['results'][0] - self.assertEqual(result['total_count'], 1) - self.assertEqual(result['results'][0]['scientific_name'], 'Bacteria') + result = resp["results"][0] + self.assertEqual(result["total_count"], 1) + self.assertEqual(result["results"][0]["scientific_name"], "Bacteria") def test_search_sciname_nonexistent(self): """Test a query to search sciname for empty results.""" resp = requests.post( - _CONF['re_api_url'] + '/api/v1/query_results', - params={'stored_query': 'taxonomy_search_sci_name'}, - data=json.dumps({ - 'ts': _NOW, - 'search_text': 'xyzabc', - 'sciname_field': 'scientific_name', - '@taxon_coll': 'ncbi_taxon' - }), + _CONF["re_api_url"] + "/api/v1/query_results", + params={"stored_query": "taxonomy_search_sci_name"}, + data=json.dumps( + { + "ts": _NOW, + "search_text": "xyzabc", + "sciname_field": "scientific_name", + "@taxon_coll": "ncbi_taxon", + } + ), ).json() - self.assertEqual(resp['results'][0]['total_count'], 0) + self.assertEqual(resp["results"][0]["total_count"], 0) def test_search_sciname_wrong_type(self): """Test a query to search sciname with the wrong type for the search_text param.""" resp = requests.post( - _CONF['re_api_url'] + '/api/v1/query_results', - params={'stored_query': 'taxonomy_search_sci_name'}, - data=json.dumps({ - 'ts': _NOW, - 'search_text': 123, - '@taxon_coll': 'ncbi_taxon', - 'sciname_field': 'scientific_name', - }) + _CONF["re_api_url"] + "/api/v1/query_results", + params={"stored_query": "taxonomy_search_sci_name"}, + data=json.dumps( + { + "ts": _NOW, + "search_text": 123, + "@taxon_coll": "ncbi_taxon", + "sciname_field": "scientific_name", + } + ), ) self.assertEqual(resp.status_code, 400) - self.assertEqual(resp.json()['error']['message'], "123 is not of type 'string'") + self.assertEqual(resp.json()["error"]["message"], "123 is not of type 'string'") def test_search_sciname_missing_search(self): """Test a query to search sciname with the search_text param missing.""" resp = requests.post( - _CONF['re_api_url'] + '/api/v1/query_results', - params={'stored_query': 'taxonomy_search_sci_name'}, - data=json.dumps({'ts': _NOW, '@taxon_coll': 'ncbi_taxon'}) + _CONF["re_api_url"] + "/api/v1/query_results", + params={"stored_query": "taxonomy_search_sci_name"}, + data=json.dumps({"ts": _NOW, "@taxon_coll": "ncbi_taxon"}), ) self.assertEqual(resp.status_code, 400) - self.assertEqual(resp.json()['error']['message'], "'search_text' is a required property") + self.assertEqual( + resp.json()["error"]["message"], "'search_text' is a required property" + ) def test_search_sciname_more_complicated(self): """Test a query to search sciname with some more keyword options.""" resp = requests.post( - _CONF['re_api_url'] + '/api/v1/query_results', - params={'stored_query': 'taxonomy_search_sci_name'}, - data=json.dumps({ - 'ts': _NOW, - 'search_text': "prefix:gamma,|prefix:alpha,|prefix:delta", - 'sciname_field': 'scientific_name', - '@taxon_coll': 'ncbi_taxon', - }) + _CONF["re_api_url"] + "/api/v1/query_results", + params={"stored_query": "taxonomy_search_sci_name"}, + data=json.dumps( + { + "ts": _NOW, + "search_text": "prefix:gamma,|prefix:alpha,|prefix:delta", + "sciname_field": "scientific_name", + "@taxon_coll": "ncbi_taxon", + } + ), ).json() - result = resp['results'][0] - self.assertEqual(result['total_count'], 3) - names = {r['scientific_name'] for r in result['results']} - self.assertEqual(names, {'Gammaproteobacteria', 'Alphaproteobacteria', 'Deltaproteobacteria'}) + result = resp["results"][0] + self.assertEqual(result["total_count"], 3) + names = {r["scientific_name"] for r in result["results"]} + self.assertEqual( + names, {"Gammaproteobacteria", "Alphaproteobacteria", "Deltaproteobacteria"} + ) def test_search_sciname_offset_max(self): """Test a query to search sciname with an invalid offset (greater than max).""" resp = requests.post( - _CONF['re_api_url'] + '/api/v1/query_results', - params={'stored_query': 'taxonomy_search_sci_name'}, - data=json.dumps({ - 'ts': _NOW, - 'search_text': "prefix:bact", - "offset": 100001, - '@taxon_coll': 'ncbi_taxon', - 'sciname_field': 'scientific_name', - }) + _CONF["re_api_url"] + "/api/v1/query_results", + params={"stored_query": "taxonomy_search_sci_name"}, + data=json.dumps( + { + "ts": _NOW, + "search_text": "prefix:bact", + "offset": 100001, + "@taxon_coll": "ncbi_taxon", + "sciname_field": "scientific_name", + } + ), ) self.assertEqual(resp.status_code, 400) - self.assertEqual(resp.json()['error']['message'], "100001 is greater than the maximum of 100000") + self.assertEqual( + resp.json()["error"]["message"], + "100001 is greater than the maximum of 100000", + ) def test_search_sciname_limit_max(self): """Test a query to search sciname with an invalid offset (greater than max).""" resp = requests.post( - _CONF['re_api_url'] + '/api/v1/query_results', - params={'stored_query': 'taxonomy_search_sci_name'}, - data=json.dumps({ - 'ts': _NOW, - 'search_text': "prefix:bact", - "limit": 1001, - '@taxon_coll': 'ncbi_taxon', - 'sciname_field': 'scientific_name', - }) + _CONF["re_api_url"] + "/api/v1/query_results", + params={"stored_query": "taxonomy_search_sci_name"}, + data=json.dumps( + { + "ts": _NOW, + "search_text": "prefix:bact", + "limit": 1001, + "@taxon_coll": "ncbi_taxon", + "sciname_field": "scientific_name", + } + ), ) self.assertEqual(resp.status_code, 400) - self.assertEqual(resp.json()['error']['message'], "1001 is greater than the maximum of 1000") + self.assertEqual( + resp.json()["error"]["message"], "1001 is greater than the maximum of 1000" + ) def test_search_sciname_limit_ranks_implicit_defaults(self): """ Test queries where the results are limited by the rank or strain flag. """ @@ -341,7 +487,8 @@ def test_search_sciname_limit_ranks_implicit_defaults(self): ranks=None, include_strains=None, expected_count=3, - expected_sci_names={'Bacteria', 'Bacilli', 'Bacillus subtilis 168'}) + expected_sci_names={"Bacteria", "Bacilli", "Bacillus subtilis 168"}, + ) def test_search_sciname_limit_ranks_explicit_defaults(self): """ Test queries where the results are limited by the rank or strain flag. """ @@ -350,72 +497,76 @@ def test_search_sciname_limit_ranks_explicit_defaults(self): ranks=[], include_strains=False, expected_count=3, - expected_sci_names={'Bacteria', 'Bacilli', 'Bacillus subtilis 168'}) + expected_sci_names={"Bacteria", "Bacilli", "Bacillus subtilis 168"}, + ) def test_search_sciname_limit_ranks_2(self): """ Test queries where the results are limited by the rank or strain flag. """ _run_search_sciname( self, - ranks=['Domain', 'Class'], + ranks=["Domain", "Class"], include_strains=None, expected_count=2, - expected_sci_names={'Bacteria', 'Bacilli'}) + expected_sci_names={"Bacteria", "Bacilli"}, + ) def test_search_sciname_limit_ranks_1(self): """ Test queries where the results are limited by the rank or strain flag. """ _run_search_sciname( self, - ranks=['Class'], + ranks=["Class"], include_strains=None, expected_count=1, - expected_sci_names={'Bacilli'}) + expected_sci_names={"Bacilli"}, + ) def test_search_sciname_limit_ranks_1_with_strain(self): """ Test queries where the results are limited by the rank or strain flag. """ _run_search_sciname( self, - ranks=['Class'], + ranks=["Class"], include_strains=True, expected_count=2, - expected_sci_names={'Bacilli', 'Bacillus subtilis 168'}) + expected_sci_names={"Bacilli", "Bacillus subtilis 168"}, + ) def test_search_sciname_limit_ranks_1_with_false_strain(self): """ Test queries where the results are limited by the rank or strain flag. """ _run_search_sciname( self, - ranks=['Class'], + ranks=["Class"], include_strains=False, expected_count=1, - expected_sci_names={'Bacilli'}) + expected_sci_names={"Bacilli"}, + ) def test_select_fields(self): """Test that the 'select' works properly for one query.""" resp = requests.post( - _CONF['re_api_url'] + '/api/v1/query_results', - params={'stored_query': 'taxonomy_get_lineage'}, - data=json.dumps({ - 'ts': _NOW, - 'id': '7', - 'select': ['rank'], - '@taxon_coll': 'ncbi_taxon', - '@taxon_child_of': 'ncbi_child_of_taxon', - }) + _CONF["re_api_url"] + "/api/v1/query_results", + params={"stored_query": "taxonomy_get_lineage"}, + data=json.dumps( + { + "ts": _NOW, + "id": "7", + "select": ["rank"], + "@taxon_coll": "ncbi_taxon", + "@taxon_child_of": "ncbi_child_of_taxon", + } + ), ).json() - self.assertEqual(resp['count'], 2) - self.assertEqual(resp['results'], [ - {'rank': 'Domain'}, - {'rank': 'Phylum'} - ]) + self.assertEqual(resp["count"], 2) + self.assertEqual(resp["results"], [{"rank": "Domain"}, {"rank": "Phylum"}]) def test_fetch_taxon(self): """Test a valid query to fetch a taxon.""" resp = requests.post( - _CONF['re_api_url'] + '/api/v1/query_results', - params={'stored_query': 'taxonomy_fetch_taxon'}, - data=json.dumps({'ts': _NOW, 'id': '1', '@taxon_coll': 'ncbi_taxon'}) + _CONF["re_api_url"] + "/api/v1/query_results", + params={"stored_query": "taxonomy_fetch_taxon"}, + data=json.dumps({"ts": _NOW, "id": "1", "@taxon_coll": "ncbi_taxon"}), ).json() - self.assertEqual(resp['count'], 1) - self.assertEqual(resp['results'][0]['id'], '1') + self.assertEqual(resp["count"], 1) + self.assertEqual(resp["results"][0]["id"], "1") def test_get_associated_objs(self): """ @@ -423,146 +574,175 @@ def test_get_associated_objs(self): Two objects are public and one is private, so total_count will be 3 while only the public objects are returned. """ resp = requests.post( - _CONF['re_api_url'] + '/api/v1/query_results', - params={'stored_query': 'taxonomy_get_associated_ws_objects'}, - data=json.dumps({ - 'ts': _NOW, - 'taxon_id': '1', - 'select_obj': ['_id', 'type', 'ws_info'], - 'select_edge': ['assigned_by'], - '@taxon_coll': 'ncbi_taxon', - }), + _CONF["re_api_url"] + "/api/v1/query_results", + params={"stored_query": "taxonomy_get_associated_ws_objects"}, + data=json.dumps( + { + "ts": _NOW, + "taxon_id": "1", + "select_obj": ["_id", "type", "ws_info"], + "select_edge": ["assigned_by"], + "@taxon_coll": "ncbi_taxon", + } + ), ).json() - self.assertEqual(resp['count'], 1) - results = resp['results'][0] - self.assertEqual(results['total_count'], 3) - self.assertEqual(len(results['results']), 2) - assignments = {ret['edge']['assigned_by'] for ret in results['results']} - ids = {ret['ws_obj']['_id'] for ret in results['results']} - self.assertEqual(assignments, {'assn1', 'assn2'}) - self.assertEqual(ids, {'ws_object_version/1:1:1', 'ws_object_version/1:1:2'}) - self.assertEqual(results['results'][0]['ws_obj']['type'], { - 'type_name': 'Genome', - 'module_name': 'KBaseGenomes', - 'maj_ver': 99, - 'min_ver': 77, - '_key': 'KBaseGenomes.Genome-99.77' - }) - self.assertEqual(results['results'][0]['ws_obj']['ws_info'], { - 'owner': 'owner', - 'metadata': {'narrative_nice_name': 'narrname'}, - 'is_public': True, - 'mod_epoch': 1 - }) + self.assertEqual(resp["count"], 1) + results = resp["results"][0] + self.assertEqual(results["total_count"], 3) + self.assertEqual(len(results["results"]), 2) + assignments = {ret["edge"]["assigned_by"] for ret in results["results"]} + ids = {ret["ws_obj"]["_id"] for ret in results["results"]} + self.assertEqual(assignments, {"assn1", "assn2"}) + self.assertEqual(ids, {"ws_object_version/1:1:1", "ws_object_version/1:1:2"}) + self.assertEqual( + results["results"][0]["ws_obj"]["type"], + { + "type_name": "Genome", + "module_name": "KBaseGenomes", + "maj_ver": 99, + "min_ver": 77, + "_key": "KBaseGenomes.Genome-99.77", + }, + ) + self.assertEqual( + results["results"][0]["ws_obj"]["ws_info"], + { + "owner": "owner", + "metadata": {"narrative_nice_name": "narrname"}, + "is_public": True, + "mod_epoch": 1, + }, + ) def test_get_taxon_from_ws_obj(self): """Fetch the taxon vertex from a workspace versioned id.""" resp = requests.post( - _CONF['re_api_url'] + '/api/v1/query_results', - params={'stored_query': 'taxonomy_get_taxon_from_ws_obj'}, - data=json.dumps({'ts': _NOW, 'obj_ref': '1:1:1', '@taxon_coll': 'ncbi_taxon'}) + _CONF["re_api_url"] + "/api/v1/query_results", + params={"stored_query": "taxonomy_get_taxon_from_ws_obj"}, + data=json.dumps( + {"ts": _NOW, "obj_ref": "1:1:1", "@taxon_coll": "ncbi_taxon"} + ), ).json() - self.assertEqual(resp['count'], 1) - assert_subset(self, { - 'id': '1', - 'scientific_name': 'Bacteria', - 'rank': 'Domain' - }, resp['results'][0]) + self.assertEqual(resp["count"], 1) + assert_subset( + self, + {"id": "1", "scientific_name": "Bacteria", "rank": "Domain"}, + resp["results"][0], + ) def test_fetch_taxon_by_sciname(self): """Test the ncbi_fetch_taxon_by_sciname query.""" - sciname = 'Deltaproteobacteria' + sciname = "Deltaproteobacteria" resp = requests.post( - _CONF['re_api_url'] + '/api/v1/query_results', - params={'stored_query': 'taxonomy_fetch_taxon_by_sciname'}, - data=json.dumps({ - 'ts': _NOW, - 'sciname': 'Deltaproteobacteria', - 'sciname_field': 'scientific_name', - '@taxon_coll': 'ncbi_taxon' - }) + _CONF["re_api_url"] + "/api/v1/query_results", + params={"stored_query": "taxonomy_fetch_taxon_by_sciname"}, + data=json.dumps( + { + "ts": _NOW, + "sciname": "Deltaproteobacteria", + "sciname_field": "scientific_name", + "@taxon_coll": "ncbi_taxon", + } + ), ).json() - self.assertEqual(resp['count'], 1) - assert_subset(self, { - 'id': '7', - 'scientific_name': sciname, - 'rank': 'Class', - }, resp['results'][0]) + self.assertEqual(resp["count"], 1) + assert_subset( + self, + { + "id": "7", + "scientific_name": sciname, + "rank": "Class", + }, + resp["results"][0], + ) def test_fetch_taxon_by_sciname_failures(self): """Test invalid cases for ncbi_fetch_taxon_by_sciname.""" # No sciname resp = requests.post( - _CONF['re_api_url'] + '/api/v1/query_results', - params={'stored_query': 'taxonomy_fetch_taxon_by_sciname'}, - data=json.dumps({'ts': _NOW, 'sciname_field': 'scientific_name', '@taxon_coll': 'ncbi_taxon'}) + _CONF["re_api_url"] + "/api/v1/query_results", + params={"stored_query": "taxonomy_fetch_taxon_by_sciname"}, + data=json.dumps( + { + "ts": _NOW, + "sciname_field": "scientific_name", + "@taxon_coll": "ncbi_taxon", + } + ), ).json() - self.assertEqual(resp['error']['message'], "'sciname' is a required property") + self.assertEqual(resp["error"]["message"], "'sciname' is a required property") # No ts resp = requests.post( - _CONF['re_api_url'] + '/api/v1/query_results', - params={'stored_query': 'ncbi_fetch_taxon_by_sciname'}, - data=json.dumps({ - 'sciname': 'Deltaproteobacteria', - 'sciname_field': 'scientific_name', - '@taxon_coll': 'ncbi_taxon' - }) + _CONF["re_api_url"] + "/api/v1/query_results", + params={"stored_query": "ncbi_fetch_taxon_by_sciname"}, + data=json.dumps( + { + "sciname": "Deltaproteobacteria", + "sciname_field": "scientific_name", + "@taxon_coll": "ncbi_taxon", + } + ), ).json() - self.assertEqual(resp['error']['message'], "'ts' is a required property") + self.assertEqual(resp["error"]["message"], "'ts' is a required property") # sciname not found resp = requests.post( - _CONF['re_api_url'] + '/api/v1/query_results', - params={'stored_query': 'taxonomy_fetch_taxon_by_sciname'}, - data=json.dumps({ - 'ts': _NOW, - 'sciname': 'xyzabc', - 'sciname_field': 'scientific_name', - '@taxon_coll': 'ncbi_taxon', - }) + _CONF["re_api_url"] + "/api/v1/query_results", + params={"stored_query": "taxonomy_fetch_taxon_by_sciname"}, + data=json.dumps( + { + "ts": _NOW, + "sciname": "xyzabc", + "sciname_field": "scientific_name", + "@taxon_coll": "ncbi_taxon", + } + ), ).json() - self.assertEqual(resp['count'], 0) - self.assertEqual(len(resp['results']), 0) + self.assertEqual(resp["count"], 0) + self.assertEqual(len(resp["results"]), 0) # -- Test helpers -def _run_search_sciname(self, ranks, include_strains, expected_count, expected_sci_names): + +def _run_search_sciname( + self, ranks, include_strains, expected_count, expected_sci_names +): """ Helper to run the taxonomy_search_sci_name query and make some standard assertions on the response. """ data = { - 'ts': _NOW, - 'search_text': "prefix:bac", - '@taxon_coll': 'ncbi_taxon', - 'sciname_field': 'scientific_name', + "ts": _NOW, + "search_text": "prefix:bac", + "@taxon_coll": "ncbi_taxon", + "sciname_field": "scientific_name", } if ranks is not None: - data['ranks'] = ranks + data["ranks"] = ranks if include_strains is not None: - data['include_strains'] = include_strains + data["include_strains"] = include_strains resp = requests.post( - _CONF['re_api_url'] + '/api/v1/query_results', - params={'stored_query': 'taxonomy_search_sci_name'}, - data=json.dumps(data) - ).json() - result = resp['results'][0] - self.assertEqual(result['total_count'], expected_count) - names = {r['scientific_name'] for r in result['results']} + _CONF["re_api_url"] + "/api/v1/query_results", + params={"stored_query": "taxonomy_search_sci_name"}, + data=json.dumps(data), + ).json() + result = resp["results"][0] + self.assertEqual(result["total_count"], expected_count) + names = {r["scientific_name"] for r in result["results"]} self.assertEqual(names, expected_sci_names) def _ws_defaults(data): """Set some defaults for the required workspace fields.""" defaults = { - 'owner': 'owner', - 'max_obj_id': 1, - 'lock_status': 'n', - 'name': 'wsname', - 'mod_epoch': 1, - 'is_public': True, - 'is_deleted': False, - 'metadata': {'narrative_nice_name': 'narrname'}, + "owner": "owner", + "max_obj_id": 1, + "lock_status": "n", + "name": "wsname", + "mod_epoch": 1, + "is_public": True, + "is_deleted": False, + "metadata": {"narrative_nice_name": "narrname"}, } # Merge the data with the above defaults return dict(defaults, **data) @@ -571,27 +751,27 @@ def _ws_defaults(data): def _construct_ws_obj_ver(wsid, objid, ver, is_public=False): """Test helper to create a ws_object_version vertex.""" return { - '_key': f"{wsid}:{objid}:{ver}", - 'workspace_id': wsid, - 'object_id': objid, - 'version': ver, - 'name': f'obj_name{objid}', - 'hash': 'xyz', - 'size': 100, - 'epoch': 0, - 'deleted': False, - 'is_public': is_public, + "_key": f"{wsid}:{objid}:{ver}", + "workspace_id": wsid, + "object_id": objid, + "version": ver, + "name": f"obj_name{objid}", + "hash": "xyz", + "size": 100, + "epoch": 0, + "deleted": False, + "is_public": is_public, } def _construct_ws_obj(wsid, objid, is_public=False): """Test helper to create a ws_object vertex.""" return { - '_key': f"{wsid}:{objid}", - 'workspace_id': wsid, - 'object_id': objid, - 'deleted': False, - 'is_public': is_public, + "_key": f"{wsid}:{objid}", + "workspace_id": wsid, + "object_id": objid, + "deleted": False, + "is_public": is_public, } @@ -600,12 +780,12 @@ def _create_delta_test_docs(coll_name, docs, edge=False): if edge: for doc in docs: # Replicate the time-travel system by just setting 'from' and 'to' to the keys - doc['from'] = doc['_from'].split('/')[1] - doc['to'] = doc['_to'].split('/')[1] + doc["from"] = doc["_from"].split("/")[1] + doc["to"] = doc["_to"].split("/")[1] else: for doc in docs: - doc['id'] = doc['_key'] + doc["id"] = doc["_key"] for doc in docs: - doc['expired'] = 9007199254740991 - doc['created'] = 0 + doc["expired"] = 9007199254740991 + doc["created"] = 0 create_test_docs(coll_name, docs) diff --git a/spec/test/stored_queries/test_ws.py b/spec/test/stored_queries/test_ws.py index 15672cf7..573a3981 100644 --- a/spec/test/stored_queries/test_ws.py +++ b/spec/test/stored_queries/test_ws.py @@ -15,21 +15,20 @@ def _ws_obj(wsid, objid, ver, is_public=True): """Create data for a dummy test workspace obj""" return { - '_key': ':'.join((str(n) for n in (wsid, objid, ver))), - 'name': 'obj', - 'workspace_id': wsid, - 'object_id': objid, - 'version': ver, - 'hash': 'x', - 'size': 0, - 'epoch': 0, - 'deleted': False, - 'is_public': is_public, + "_key": ":".join((str(n) for n in (wsid, objid, ver))), + "name": "obj", + "workspace_id": wsid, + "object_id": objid, + "version": ver, + "hash": "x", + "size": 0, + "epoch": 0, + "deleted": False, + "is_public": is_public, } class TestWs(unittest.TestCase): - @classmethod def setUpClass(cls): """ @@ -47,31 +46,43 @@ def setUpClass(cls): _ws_obj(1, 6, 1, is_public=False), # private prov obj _ws_obj(1, 7, 1, is_public=False), # private ref obj ] - create_test_docs('ws_object_version', ws_object_version) - ws_type_version = [{'_key': 'Module.Type1-1.0'}] - create_test_docs('ws_type_version', ws_type_version) + create_test_docs("ws_object_version", ws_object_version) + ws_type_version = [{"_key": "Module.Type1-1.0"}] + create_test_docs("ws_type_version", ws_type_version) ws_obj_instance_of_type = [ - {'_from': 'ws_object_version/1:1:1', '_to': 'ws_type_version/Module.Type1-1.0'}, - {'_from': 'ws_object_version/1:2:1', '_to': 'ws_type_version/Module.Type1-1.0'}, - {'_from': 'ws_object_version/1:3:1', '_to': 'ws_type_version/Module.Type1-1.0'}, - {'_from': 'ws_object_version/1:4:1', '_to': 'ws_type_version/Module.Type1-1.0'}, + { + "_from": "ws_object_version/1:1:1", + "_to": "ws_type_version/Module.Type1-1.0", + }, + { + "_from": "ws_object_version/1:2:1", + "_to": "ws_type_version/Module.Type1-1.0", + }, + { + "_from": "ws_object_version/1:3:1", + "_to": "ws_type_version/Module.Type1-1.0", + }, + { + "_from": "ws_object_version/1:4:1", + "_to": "ws_type_version/Module.Type1-1.0", + }, ] - create_test_docs('ws_obj_instance_of_type', ws_obj_instance_of_type) + create_test_docs("ws_obj_instance_of_type", ws_obj_instance_of_type) ws_prov_descendant_of = [ - {'_from': 'ws_object_version/1:1:1', '_to': 'ws_object_version/1:3:1'}, - {'_from': 'ws_object_version/1:1:1', '_to': 'ws_object_version/1:6:1'}, + {"_from": "ws_object_version/1:1:1", "_to": "ws_object_version/1:3:1"}, + {"_from": "ws_object_version/1:1:1", "_to": "ws_object_version/1:6:1"}, ] - create_test_docs('ws_prov_descendant_of', ws_prov_descendant_of) + create_test_docs("ws_prov_descendant_of", ws_prov_descendant_of) ws_refers_to = [ - {'_from': 'ws_object_version/1:1:1', '_to': 'ws_object_version/1:4:1'}, - {'_from': 'ws_object_version/1:1:1', '_to': 'ws_object_version/1:7:1'}, + {"_from": "ws_object_version/1:1:1", "_to": "ws_object_version/1:4:1"}, + {"_from": "ws_object_version/1:1:1", "_to": "ws_object_version/1:7:1"}, ] - create_test_docs('ws_refers_to', ws_refers_to) + create_test_docs("ws_refers_to", ws_refers_to) ws_copied_from = [ - {'_from': 'ws_object_version/1:1:1', '_to': 'ws_object_version/1:2:1'}, - {'_from': 'ws_object_version/1:1:1', '_to': 'ws_object_version/1:5:1'}, + {"_from": "ws_object_version/1:1:1", "_to": "ws_object_version/1:2:1"}, + {"_from": "ws_object_version/1:1:1", "_to": "ws_object_version/1:5:1"}, ] - create_test_docs('ws_copied_from', ws_copied_from) + create_test_docs("ws_copied_from", ws_copied_from) def test_fetch_related_data_valid(self): """ @@ -79,31 +90,43 @@ def test_fetch_related_data_valid(self): This also covers the case of private-scope object results, which will be hidden from results. """ resp = requests.post( - _CONF['re_api_url'] + '/api/v1/query_results', - params={'stored_query': 'ws_fetch_related_data', 'show_public': True}, - data=json.dumps({'obj_key': '1:1:1'}) + _CONF["re_api_url"] + "/api/v1/query_results", + params={"stored_query": "ws_fetch_related_data", "show_public": True}, + data=json.dumps({"obj_key": "1:1:1"}), ).json() - self.assertEqual(resp['count'], 1) - self.assertEqual(resp['has_more'], False) - res = resp['results'][0] + self.assertEqual(resp["count"], 1) + self.assertEqual(resp["has_more"], False) + res = resp["results"][0] # Check the root object results - self.assertEqual(res['obj']['_key'], '1:1:1') - self.assertEqual(res['obj_type']['_key'], 'Module.Type1-1.0') + self.assertEqual(res["obj"]["_key"], "1:1:1") + self.assertEqual(res["obj_type"]["_key"], "Module.Type1-1.0") # Check the copy results - self.assertEqual(res['copies']['count'], 1) - self.assertEqual(len(res['copies']['data']), 1) - self.assertEqual(res['copies']['data'][0]['data']['_id'], 'ws_object_version/1:2:1') - self.assertEqual(res['copies']['data'][0]['hops'], 1) - self.assertEqual(res['copies']['data'][0]['type']['_id'], 'ws_type_version/Module.Type1-1.0') + self.assertEqual(res["copies"]["count"], 1) + self.assertEqual(len(res["copies"]["data"]), 1) + self.assertEqual( + res["copies"]["data"][0]["data"]["_id"], "ws_object_version/1:2:1" + ) + self.assertEqual(res["copies"]["data"][0]["hops"], 1) + self.assertEqual( + res["copies"]["data"][0]["type"]["_id"], "ws_type_version/Module.Type1-1.0" + ) # Check the provenance results - self.assertEqual(res['prov']['count'], 1) - self.assertEqual(len(res['prov']['data']), 1) - self.assertEqual(res['prov']['data'][0]['data']['_id'], 'ws_object_version/1:3:1') - self.assertEqual(res['prov']['data'][0]['hops'], 1) - self.assertEqual(res['prov']['data'][0]['type']['_id'], 'ws_type_version/Module.Type1-1.0') + self.assertEqual(res["prov"]["count"], 1) + self.assertEqual(len(res["prov"]["data"]), 1) + self.assertEqual( + res["prov"]["data"][0]["data"]["_id"], "ws_object_version/1:3:1" + ) + self.assertEqual(res["prov"]["data"][0]["hops"], 1) + self.assertEqual( + res["prov"]["data"][0]["type"]["_id"], "ws_type_version/Module.Type1-1.0" + ) # Check the ref results - self.assertEqual(res['refs']['count'], 1) - self.assertEqual(len(res['refs']['data']), 1) - self.assertEqual(res['refs']['data'][0]['data']['_id'], 'ws_object_version/1:4:1') - self.assertEqual(res['refs']['data'][0]['hops'], 1) - self.assertEqual(res['refs']['data'][0]['type']['_id'], 'ws_type_version/Module.Type1-1.0') + self.assertEqual(res["refs"]["count"], 1) + self.assertEqual(len(res["refs"]["data"]), 1) + self.assertEqual( + res["refs"]["data"][0]["data"]["_id"], "ws_object_version/1:4:1" + ) + self.assertEqual(res["refs"]["data"][0]["hops"], 1) + self.assertEqual( + res["refs"]["data"][0]["type"]["_id"], "ws_type_version/Module.Type1-1.0" + ) diff --git a/spec/test/test_manifest_schema.py b/spec/test/test_manifest_schema.py index c00eeb77..54bc8ea4 100644 --- a/spec/test/test_manifest_schema.py +++ b/spec/test/test_manifest_schema.py @@ -10,75 +10,70 @@ from relation_engine_server.utils.json_validation import run_validator from jsonschema.exceptions import ValidationError -schema_file = os_path.join('/app', 'spec', 'datasets', 'djornl', 'manifest.schema.json') -_TEST_DIR = os_path.join('/app', 'spec', 'test', 'djornl') +schema_file = os_path.join("/app", "spec", "datasets", "djornl", "manifest.schema.json") +_TEST_DIR = os_path.join("/app", "spec", "test", "djornl") class Test_Manifest_Schema(unittest.TestCase): - def test_load_invalid_manifest(self): """ test an invalid manifest file """ - invalid_dir = os_path.join(_TEST_DIR, 'invalid_manifest') + invalid_dir = os_path.join(_TEST_DIR, "invalid_manifest") error_list = [ { # no file list provided - 'file': 'no_file_list', - 'msg': "'file_list' is a required property", + "file": "no_file_list", + "msg": "'file_list' is a required property", }, { # a cluster file entry should have a prefix - 'file': 'cluster_no_prefix', - 'msg': r"{'data_type': 'cluster', 'path': 'I2_named.tsv'} is not valid under any of the given schemas", + "file": "cluster_no_prefix", + "msg": r"{'data_type': 'cluster', 'path': 'I2_named.tsv'} is not valid under any of the given schemas", }, { # each file_list entry has to have a path - 'file': 'missing_path', - 'msg': "'path' is a required property", + "file": "missing_path", + "msg": "'path' is a required property", }, { # if the date is not quoted, pyyaml will turn it into a date object. Doh! - 'file': 'date_not_in_quotes', - 'msg': "datetime.date\(2020, 12, 25\) is not of type 'string'", + "file": "date_not_in_quotes", + "msg": "datetime.date\(2020, 12, 25\) is not of type 'string'", }, { # file format is invalid - 'file': 'invalid_format', - 'msg': "'txt' is not one of \['tsv', 'csv'\]" + "file": "invalid_format", + "msg": "'txt' is not one of \['tsv', 'csv'\]", }, { # there must be an indicator of file format - 'file': 'no_file_format', - 'msg': r"{'data_type': 'edge', 'date': '2020-12-25', 'path': 'edge_data'}" - + " is not valid under any of the given schemas", + "file": "no_file_format", + "msg": r"{'data_type': 'edge', 'date': '2020-12-25', 'path': 'edge_data'}" + + " is not valid under any of the given schemas", }, ] for entry in error_list: - data_file = os_path.join(invalid_dir, entry['file'] + '.yaml') - print('looking at ' + data_file) + data_file = os_path.join(invalid_dir, entry["file"] + ".yaml") + print("looking at " + data_file) - with self.assertRaisesRegex(ValidationError, entry['msg']): + with self.assertRaisesRegex(ValidationError, entry["msg"]): run_validator( - schema_file=schema_file, - data_file=data_file, - nicer_errors=True + schema_file=schema_file, data_file=data_file, nicer_errors=True ) def test_load_valid_manifests(self): - valid_dir = os_path.join(_TEST_DIR, 'valid_manifest') - file_list = ['with_descriptions', 'no_file_ext', 'no_file_format'] + valid_dir = os_path.join(_TEST_DIR, "valid_manifest") + file_list = ["with_descriptions", "no_file_ext", "no_file_format"] for file in file_list: - data_file = os_path.join(valid_dir, file + '.yaml') - print('looking at ' + data_file) + data_file = os_path.join(valid_dir, file + ".yaml") + print("looking at " + data_file) self.assertTrue( run_validator( - schema_file=schema_file, - data_file=data_file, - nicer_errors=True + schema_file=schema_file, data_file=data_file, nicer_errors=True ) ) diff --git a/spec/test/test_validate.py b/spec/test/test_validate.py index 4c6dacaf..70784406 100644 --- a/spec/test/test_validate.py +++ b/spec/test/test_validate.py @@ -19,11 +19,10 @@ validate_all_by_type, ) -_TEST_DIR = '/app/spec/test/sample_schemas' +_TEST_DIR = "/app/spec/test/sample_schemas" class TestValidate(unittest.TestCase): - @classmethod def setUpClass(cls): wait_for_arangodb() @@ -33,53 +32,53 @@ def test_validate_schema(self): err_msg = "No validation schema found for 'made-up_schema'" with self.assertRaisesRegex(ValueError, err_msg): - validate_schema('/path/to/file', 'made-up_schema') + validate_schema("/path/to/file", "made-up_schema") def test_validate_collection_errors(self): """Testing collection-specific schema errors""" - base_dir = os_path.join(_TEST_DIR, 'collections') + base_dir = os_path.join(_TEST_DIR, "collections") error_list = [ { - 'msg': "Name key should match filename: test_nodes vs wrong_name", - 'file': 'wrong_name.yaml', - 'err': ValueError + "msg": "Name key should match filename: test_nodes vs wrong_name", + "file": "wrong_name.yaml", + "err": ValueError, }, { - 'msg': "'http://json-schema.org/draft-07/schema#' is not of type 'object'", - 'file': 'schema_not_object.yaml', + "msg": "'http://json-schema.org/draft-07/schema#' is not of type 'object'", + "file": "schema_not_object.yaml", }, { - 'msg': "Additional properties are not allowed \('title' was unexpected\)", - 'file': 'extra_top_level_entries.yaml', + "msg": "Additional properties are not allowed \('title' was unexpected\)", + "file": "extra_top_level_entries.yaml", }, { - 'msg': 'Time-travel edge schemas must require "from" and "to" attributes in ', - 'file': 'edge_delta_missing_to_from.yaml', + "msg": 'Time-travel edge schemas must require "from" and "to" attributes in ', + "file": "edge_delta_missing_to_from.yaml", }, { - 'msg': 'Edge schemas must require "_from" and "_to" attributes in ', - 'file': 'edge_missing_to_from.yaml', + "msg": 'Edge schemas must require "_from" and "_to" attributes in ', + "file": "edge_missing_to_from.yaml", }, { - 'msg': 'Vertex schemas must require the "_key" attribute in ', - 'file': 'vertex_missing_key.yaml', + "msg": 'Vertex schemas must require the "_key" attribute in ', + "file": "vertex_missing_key.yaml", }, { - 'msg': 'Time-travel vertex schemas must require the "id" attribute in ', - 'file': 'vertex_missing_id.yaml', + "msg": 'Time-travel vertex schemas must require the "id" attribute in ', + "file": "vertex_missing_id.yaml", }, ] for entry in error_list: - err_type = entry['err'] if 'err' in entry else ValidationError + err_type = entry["err"] if "err" in entry else ValidationError # generic method, requires schema type - with self.assertRaisesRegex(err_type, entry['msg']): - validate_schema(os_path.join(base_dir, entry['file']), 'collection') + with self.assertRaisesRegex(err_type, entry["msg"]): + validate_schema(os_path.join(base_dir, entry["file"]), "collection") # specific method - with self.assertRaisesRegex(err_type, entry['msg']): - validate_collection(os_path.join(base_dir, entry['file'])) + with self.assertRaisesRegex(err_type, entry["msg"]): + validate_collection(os_path.join(base_dir, entry["file"])) # TODO: add an example of a schema that validates but where data['schema'] is # not a valid json schema. @@ -87,119 +86,120 @@ def test_validate_collection_errors(self): def test_validate_collection(self): """Testing collection-specific schema errors""" - base_dir = os_path.join(_TEST_DIR, 'collections') + base_dir = os_path.join(_TEST_DIR, "collections") # valid schemas -- check delta is set appropriately - for type in ['edge', 'vertex']: - data = validate_collection(os_path.join(base_dir, 'test_' + type + '.yaml')) - self.assertEqual(data['delta'], False) + for type in ["edge", "vertex"]: + data = validate_collection(os_path.join(base_dir, "test_" + type + ".yaml")) + self.assertEqual(data["delta"], False) # delta is true: - data = validate_collection(os_path.join(base_dir, 'test_delta_' + type + '.yaml')) - self.assertEqual(data['delta'], True) + data = validate_collection( + os_path.join(base_dir, "test_delta_" + type + ".yaml") + ) + self.assertEqual(data["delta"], True) def test_validate_data_source(self): - base_dir = os_path.join(_TEST_DIR, 'data_sources') + base_dir = os_path.join(_TEST_DIR, "data_sources") # working example - output = validate_data_source(os_path.join(base_dir, 'minimal.yaml')) + output = validate_data_source(os_path.join(base_dir, "minimal.yaml")) self.assertEqual( output, { "name": "minimal", "category": "network", "title": "Example minimal data source", - } + }, ) error_list = [ { - 'msg': "Additional properties are not allowed \('type' was unexpected\)", - 'file': 'invalid_additional_property.json', + "msg": "Additional properties are not allowed \('type' was unexpected\)", + "file": "invalid_additional_property.json", }, { - 'msg': "'this is not a valid URI' is not a 'uri'", - 'file': 'uri_validation.json', - - } + "msg": "'this is not a valid URI' is not a 'uri'", + "file": "uri_validation.json", + }, ] for entry in error_list: - err_type = entry['err'] if 'err' in entry else ValidationError + err_type = entry["err"] if "err" in entry else ValidationError # generic method - with self.assertRaisesRegex(err_type, entry['msg']): - validate_schema(os_path.join(base_dir, entry['file']), 'data_source') + with self.assertRaisesRegex(err_type, entry["msg"]): + validate_schema(os_path.join(base_dir, entry["file"]), "data_source") # same thing as above via specific method - with self.assertRaisesRegex(err_type, entry['msg']): - validate_data_source(os_path.join(base_dir, entry['file'])) + with self.assertRaisesRegex(err_type, entry["msg"]): + validate_data_source(os_path.join(base_dir, entry["file"])) def test_validate_stored_query(self): - base_dir = os_path.join(_TEST_DIR, 'stored_queries') + base_dir = os_path.join(_TEST_DIR, "stored_queries") err_str = "False is not of type 'object'" with self.assertRaisesRegex(ValidationError, err_str): - validate_stored_query(os_path.join(base_dir, 'params_not_object.yaml')) + validate_stored_query(os_path.join(base_dir, "params_not_object.yaml")) # total nonsense instead of AQL - err_str = 'syntax error, unexpected identifier, expecting assignment' + err_str = "syntax error, unexpected identifier, expecting assignment" with self.assertRaisesRegex(ValueError, err_str): - validate_stored_query(os_path.join(base_dir, 'invalid_aql.yaml')) + validate_stored_query(os_path.join(base_dir, "invalid_aql.yaml")) # invalid bind params - err_str = 'Bind vars are invalid' + err_str = "Bind vars are invalid" with self.assertRaisesRegex(ValueError, err_str): - validate_stored_query(os_path.join(base_dir, 'invalid_bind_params.yaml')) + validate_stored_query(os_path.join(base_dir, "invalid_bind_params.yaml")) def test_validate_view(self): - base_dir = os_path.join(_TEST_DIR, 'views') + base_dir = os_path.join(_TEST_DIR, "views") output = { "name": "minimal", "type": "arangosearch", } self.assertEqual( - validate_schema(os_path.join(base_dir, 'minimal.json'), 'view'), - output + validate_schema(os_path.join(base_dir, "minimal.json"), "view"), output ) - self.assertEqual( - validate_view(os_path.join(base_dir, 'minimal.json')), - output - ) + self.assertEqual(validate_view(os_path.join(base_dir, "minimal.json")), output) err_str = "'from the shore' is not one of \['arangosearch'\]" with self.assertRaisesRegex(ValidationError, err_str): - validate_view(os_path.join(base_dir, 'wrong_type.json')) + validate_view(os_path.join(base_dir, "wrong_type.json")) def test_validate_all(self): """test all the files in a directory""" - with self.assertRaisesRegex(ValueError, "No validation schema found for 'muffins'"): - validate_all('muffins') + with self.assertRaisesRegex( + ValueError, "No validation schema found for 'muffins'" + ): + validate_all("muffins") def validate_all_duplicate_names(self): - with self.assertRaisesRegex(ValidationError, "duplicate_names failed validation"): - validate_all('collection', os_path.join(_TEST_DIR, 'duplicate_names')) + with self.assertRaisesRegex( + ValidationError, "duplicate_names failed validation" + ): + validate_all("collection", os_path.join(_TEST_DIR, "duplicate_names")) stdout = capture_stdout(validate_all_duplicate_names, self) self.assertRegex(stdout, "Duplicate queries named 'test_vertex'") sample_schemas = { - 'collection': 'collections', - 'stored_query': 'stored_queries', - 'view': 'views', - 'data_source': 'data_sources', + "collection": "collections", + "stored_query": "stored_queries", + "view": "views", + "data_source": "data_sources", } for (schema_type, directory) in sample_schemas.items(): # n.b. this assumes all the schemas in /spec are valid! stdout = capture_stdout(validate_all, schema_type) - self.assertRegex(stdout, r'...all valid') + self.assertRegex(stdout, r"...all valid") with self.assertRaises(Exception): validate_all(schema_type, os_path.join(_TEST_DIR, directory)) diff --git a/spec/validate.py b/spec/validate.py index 62fa273e..e8531c28 100644 --- a/spec/validate.py +++ b/spec/validate.py @@ -13,24 +13,24 @@ from relation_engine_server.utils.json_validation import run_validator _CONF = get_config() -_BASE_DIR = '/app/spec' +_BASE_DIR = "/app/spec" _VALID_SCHEMA_TYPES = { - 'data_source': { - 'file': os.path.join(_BASE_DIR, 'data_source_schema.yaml'), - 'plural': 'data_sources', + "data_source": { + "file": os.path.join(_BASE_DIR, "data_source_schema.yaml"), + "plural": "data_sources", }, - 'stored_query': { - 'file': os.path.join(_BASE_DIR, 'stored_query_schema.yaml'), - 'plural': 'stored_queries', + "stored_query": { + "file": os.path.join(_BASE_DIR, "stored_query_schema.yaml"), + "plural": "stored_queries", }, - 'collection': { - 'file': os.path.join(_BASE_DIR, 'collection_schema.yaml'), - 'plural': 'collections', + "collection": { + "file": os.path.join(_BASE_DIR, "collection_schema.yaml"), + "plural": "collections", }, - 'view': { - 'file': os.path.join(_BASE_DIR, 'view_schema.yaml'), - 'plural': 'views', + "view": { + "file": os.path.join(_BASE_DIR, "view_schema.yaml"), + "plural": "views", }, } @@ -51,18 +51,18 @@ def validate_all(schema_type, directory=None): n_files = 0 names = set() # type: set if directory is None: - type_dir_name = _VALID_SCHEMA_TYPES[schema_type]['plural'] - directory = _CONF['spec_paths'][type_dir_name] + type_dir_name = _VALID_SCHEMA_TYPES[schema_type]["plural"] + directory = _CONF["spec_paths"][type_dir_name] - print(f'Validating {schema_type} schemas in {directory}...') + print(f"Validating {schema_type} schemas in {directory}...") - for path in glob.iglob(os.path.join(directory, '**', '*.*'), recursive=True): - if path.endswith('.yaml') or path.endswith('.json'): + for path in glob.iglob(os.path.join(directory, "**", "*.*"), recursive=True): + if path.endswith(".yaml") or path.endswith(".json"): n_files += 1 try: data = validate_schema(path, schema_type) # Check for any duplicate schema names - name = data['name'] + name = data["name"] if name in names: raise ValueError(f"Duplicate queries named '{name}'") else: @@ -74,19 +74,17 @@ def validate_all(schema_type, directory=None): err_files.append([path, err]) if not n_files: - print(f'No schema files found') + print(f"No schema files found") return if err_files: - err_file_str = '\n'.join([i[0] for i in err_files]) + err_file_str = "\n".join([i[0] for i in err_files]) raise ValidationError( - f'{directory} failed validation\n' - f'files with errors:\n' - f'{err_file_str}' + f"{directory} failed validation\n" f"files with errors:\n" f"{err_file_str}" ) # all's well - print('...all valid.') + print("...all valid.") return @@ -113,8 +111,7 @@ def validate_all_by_type(validation_base_dir=None): validate_all(schema_type) else: directory = os.path.join( - validation_base_dir, - _VALID_SCHEMA_TYPES[schema_type]['plural'] + validation_base_dir, _VALID_SCHEMA_TYPES[schema_type]["plural"] ) validate_all(schema_type, directory) except Exception as err: @@ -122,10 +119,10 @@ def validate_all_by_type(validation_base_dir=None): print("\n") if n_errors: - print('Validation failed!\n') + print("Validation failed!\n") print("\n\n".join([str(n) for n in n_errors])) else: - print('Validation succeeded!') + print("Validation succeeded!") return len(n_errors) @@ -140,10 +137,10 @@ def validate_schema(path, schema_type): def validate_collection(path): - print(f' validating {path}..') + print(f" validating {path}..") # JSON schema for vertex and edge collection schemas found in /schema - collection_schema_file = _VALID_SCHEMA_TYPES['collection']['file'] + collection_schema_file = _VALID_SCHEMA_TYPES["collection"]["file"] data = run_validator(schema_file=collection_schema_file, data_file=path) namecheck_schema(path, data) @@ -151,109 +148,119 @@ def validate_collection(path): # If the schema is invalid, a SchemaError will get raised # Otherwise, the schema will work and a ValidationError will get raised (what we want) try: - run_validator(data={}, schema=data['schema']) + run_validator(data={}, schema=data["schema"]) except ValidationError: pass except Exception as err: - print('=' * 80) - print('Unable to load schema in ' + path) + print("=" * 80) + print("Unable to load schema in " + path) raise err - required = data['schema'].get('required', []) + required = data["schema"].get("required", []) # Edges must require _from and _to while vertices must require _key - has_edge_fields = ('_from' in required and '_to' in required) - has_delta_edge_fields = ('from' in required and 'to' in required) - - if data['type'] == 'edge' and data.get('delta') and not has_delta_edge_fields: - raise ValidationError('Time-travel edge schemas must require "from" and "to" attributes in ' + path) - elif data['type'] == 'edge' and not data.get('delta') and not has_edge_fields: - raise ValidationError('Edge schemas must require "_from" and "_to" attributes in ' + path) - elif data['type'] == 'vertex' and data.get('delta') and 'id' not in required: - raise ValidationError('Time-travel vertex schemas must require the "id" attribute in ' + path) - elif data['type'] == 'vertex' and not data.get('delta') and '_key' not in required: - raise ValidationError('Vertex schemas must require the "_key" attribute in ' + path) - - print(f'✓ {path} is valid.') + has_edge_fields = "_from" in required and "_to" in required + has_delta_edge_fields = "from" in required and "to" in required + + if data["type"] == "edge" and data.get("delta") and not has_delta_edge_fields: + raise ValidationError( + 'Time-travel edge schemas must require "from" and "to" attributes in ' + + path + ) + elif data["type"] == "edge" and not data.get("delta") and not has_edge_fields: + raise ValidationError( + 'Edge schemas must require "_from" and "_to" attributes in ' + path + ) + elif data["type"] == "vertex" and data.get("delta") and "id" not in required: + raise ValidationError( + 'Time-travel vertex schemas must require the "id" attribute in ' + path + ) + elif data["type"] == "vertex" and not data.get("delta") and "_key" not in required: + raise ValidationError( + 'Vertex schemas must require the "_key" attribute in ' + path + ) + + print(f"✓ {path} is valid.") return data def validate_data_source(path): - print(f' validating {path}..') + print(f" validating {path}..") # JSON schema for data source files in /data_sources - data_source_schema_file = _VALID_SCHEMA_TYPES['data_source']['file'] + data_source_schema_file = _VALID_SCHEMA_TYPES["data_source"]["file"] data = run_validator(schema_file=data_source_schema_file, data_file=path) namecheck_schema(path, data) - print(f'✓ {path} is valid.') + print(f"✓ {path} is valid.") return data def validate_stored_query(path): - print(f' validating {path}..') + print(f" validating {path}..") - stored_queries_schema_file = _VALID_SCHEMA_TYPES['stored_query']['file'] + stored_queries_schema_file = _VALID_SCHEMA_TYPES["stored_query"]["file"] data = run_validator(schema_file=stored_queries_schema_file, data_file=path) namecheck_schema(path, data) # Make sure `params` can be used as a JSON schema - if data.get('params'): + if data.get("params"): # If the schema is invalid, a SchemaError will get raised # Otherwise, the schema will work and a ValidationError will get raised try: - run_validator(data={}, schema=data['params']) + run_validator(data={}, schema=data["params"]) except ValidationError: pass # check that the query is valid AQL validate_aql_on_arango(data) - print(f'✓ {path} is valid.') + print(f"✓ {path} is valid.") return data def validate_view(path): """Validate the structure and syntax of an arangodb view""" - print(f' validating {path}..') + print(f" validating {path}..") # JSON schema for /views - view_schema_file = _VALID_SCHEMA_TYPES['view']['file'] + view_schema_file = _VALID_SCHEMA_TYPES["view"]["file"] data = run_validator(data_file=path, schema_file=view_schema_file) namecheck_schema(path, data) - print(f'✓ {path} is valid.') + print(f"✓ {path} is valid.") return data def namecheck_schema(path, data): - '''Ensure that the schema "name" is the same as the file name minus extensions''' - name = data['name'] + """Ensure that the schema "name" is the same as the file name minus extensions""" + name = data["name"] filename = os.path.splitext(os.path.basename(path))[0] if name != filename: - raise ValueError(f'Name key should match filename: {name} vs {filename}') + raise ValueError(f"Name key should match filename: {name} vs {filename}") def validate_aql_on_arango(data): """Validate a string as valid AQL syntax by running it on the ArangoDB""" - query = data.get('query_prefix', '') + ' ' + data['query'] - url = _CONF['db_url'] + '/_api/query' - auth = (_CONF['db_user'], _CONF['db_pass']) + query = data.get("query_prefix", "") + " " + data["query"] + url = _CONF["db_url"] + "/_api/query" + auth = (_CONF["db_user"], _CONF["db_pass"]) - resp = requests.post(url, data=json.dumps({'query': query}), auth=auth) + resp = requests.post(url, data=json.dumps({"query": query}), auth=auth) parsed = resp.json() - if parsed['error']: - raise ValueError(parsed['errorMessage']) - query_bind_vars = set(parsed['bindVars']) - params = set(data.get('params', {}).get('properties', {}).keys()) + if parsed["error"]: + raise ValueError(parsed["errorMessage"]) + query_bind_vars = set(parsed["bindVars"]) + params = set(data.get("params", {}).get("properties", {}).keys()) if params != query_bind_vars: raise ValueError( f"Bind vars are invalid.\n" + f" Extra vars in query: {query_bind_vars - params}.\n" - + f" Extra params in schema: {params - query_bind_vars}") + + f" Extra params in schema: {params - query_bind_vars}" + ) -if __name__ == '__main__': +if __name__ == "__main__": validation_base_dir = None if len(sys.argv) > 1: From e39f83a14608455d87e171f2669c4e0f01a41281 Mon Sep 17 00:00:00 2001 From: ialarmedalien Date: Thu, 19 Nov 2020 11:19:53 -0800 Subject: [PATCH 628/732] Updating the parser to parse edge directedness, plus adding tests for this --- importers/djornl/parser.py | 48 +- importers/test/test_djornl_parser.py | 43 +- spec/collections/djornl/djornl_edge.yaml | 4 +- spec/datasets/djornl/csv_edge.yaml | 7 + spec/datasets/djornl/definitions.yaml | 15 +- .../col_count_errors/directed_edges.tsv | 8 + ...rged_edges-AMW-060820_AF.tsv => edges.tsv} | 2 +- .../djornl/col_count_errors/manifest.yaml | 7 +- ...-AMW-v2_091319_nodeTable.csv => nodes.csv} | 0 spec/test/djornl/duplicate_data/edges.tsv | 26 +- .../djornl/duplicate_data/hithruput-edges.csv | 15 +- .../djornl/invalid_types/directed_edges.tsv | 10 + spec/test/djornl/invalid_types/edges.tsv | 6 +- spec/test/djornl/invalid_types/manifest.yaml | 3 + spec/test/djornl/invalid_types/nodes.csv | 2 +- spec/test/djornl/results.json | 428 +++++++++++------- spec/test/djornl/test_data/directed_edges.tsv | 4 + .../test/djornl/test_data/hithruput-edges.csv | 6 +- spec/test/djornl/test_data/manifest.yaml | 4 + spec/test/djornl/test_data/nodes.csv | 20 +- 20 files changed, 428 insertions(+), 230 deletions(-) create mode 100644 spec/test/djornl/col_count_errors/directed_edges.tsv rename spec/test/djornl/col_count_errors/{merged_edges-AMW-060820_AF.tsv => edges.tsv} (96%) rename spec/test/djornl/col_count_errors/{aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv => nodes.csv} (100%) create mode 100644 spec/test/djornl/invalid_types/directed_edges.tsv create mode 100644 spec/test/djornl/test_data/directed_edges.tsv diff --git a/importers/djornl/parser.py b/importers/djornl/parser.py index c7b1b4b8..b1d0de27 100644 --- a/importers/djornl/parser.py +++ b/importers/djornl/parser.py @@ -148,7 +148,7 @@ def parser_gen(self, file): line_no = 0 for row in csv_reader: line_no += 1 - if not len(row) or row[0][0] == "#": + if not len(row) or len(row[0]) and row[0][0] == "#": # comment / metadata continue @@ -312,11 +312,8 @@ def process_file(self, file, remap_fn, store_fn, err_list, validator=None): if validator is not None: # validate the object if not validator.is_valid(row_object): - err_msg = "".join( - f"{file['path']} line {line_no}: " + e.message - for e in sorted(validator.iter_errors(row_object), key=str) - ) - err_list.append(err_msg) + for e in sorted(validator.iter_errors(row_object), key=str): + err_list.append(f"{file['path']} line {line_no}: " + e.message) continue try: @@ -345,17 +342,29 @@ def store_parsed_edge_data(self, datum): Nodes are indexed by the '_key' attribute. Parsed edge data only contains node '_key' values. - Edges are indexed by the unique combination of the two node IDs and the edge type. It is - assumed that if there is more than one score for a given combination of node IDs and edge - type, the datum is erroneous. + Edges are indexed by the unique combination of the two node IDs, the edge type, and whether + or not it is a directed edge. It is assumed that if there is more than one score for a given + combination of node IDs and edge type, the datum is erroneous. """ # there should only be one value for each node<->node edge of a given type, # so use these values as an index key - # sort the nodes to ensure no dupes slip through - edge_key = "__".join( - [*sorted([datum["node1"], datum["node2"]]), datum["edge_type"]] - ) + if datum["directed"]: + property_array = [ + datum["node1"], + datum["node2"], + datum["edge_type"], + str(datum["directed"]), + ] + else: + # sort undirected nodes to ensure no dupes slip through + property_array = [ + *sorted([datum["node1"], datum["node2"]]), + datum["edge_type"], + str(datum["directed"]), + ] + + edge_key = "__".join(property_array) if edge_key in self.edge_ix: # duplicate lines can be ignored @@ -364,6 +373,14 @@ def store_parsed_edge_data(self, datum): # report non-matching data return f"duplicate data for edge {edge_key}" + # create a unique key for the DB for this record + datum["_key"] = "__".join( + [ + str(datum[_]) + for _ in ["node1", "node2", "edge_type", "directed", "score"] + ] + ) + # keep track of the nodes mentioned in this edge set for node_n in ["1", "2"]: _key = datum[f"node{node_n}"] @@ -389,16 +406,13 @@ def load_edges(self): # note that the functions that assume the presence of a certain key in the input # can do so because that key is in a 'required' property in the CSV spec file remap_functions = { - # create a unique key for each record - "_key": lambda row: "__".join( - [row[_] for _ in ["node1", "node2", "edge_type", "score"]] - ), "node1": None, # this will be deleted in the 'store' step "node2": None, # as will this "_from": lambda row: node_name + "/" + row["node1"], "_to": lambda row: node_name + "/" + row["node2"], "score": lambda row: float(row["score"]), "edge_type": None, + "directed": lambda row: True if row.get("directed", "") == "1" else False, } for file in self.config("edge_files"): diff --git a/importers/test/test_djornl_parser.py b/importers/test/test_djornl_parser.py index 186990ae..e2c7f665 100644 --- a/importers/test/test_djornl_parser.py +++ b/importers/test/test_djornl_parser.py @@ -154,7 +154,7 @@ def dupe_err(file_name, header_list): errs = { "clusters": [ - # tuple containing file name and list of column headers missing in that file + # tuple containing file name and list of invalid column headers in that file missing_err("I2_named.tsv", ["cluster_id", "node_ids"]), invalid_err("I2_named.tsv", ["cluster", "node_list"]), invalid_err("I4_named.tsv", ["other cool stuff"]), @@ -181,16 +181,30 @@ def test_load_invalid_types(self): parser = self.init_parser_with_path(RES_ROOT_DATA_PATH) errs = { - # invalid edge type, invalid scores "edges": [ + # invalid edge type r"edges.tsv line 3: 'Same-Old-Stuff' is not valid under any of the given schemas", + # empty to/from + r"edges.tsv line 4: '' does not match '^\\S{2,}.*$'", + r"edges.tsv line 5: '' does not match '^\\S{2,}.*$'", + # empty edge type + r"edges.tsv line 6: '' is not valid under any of the given schemas", + # invalid score r"edges.tsv line 7: '2.' does not match '^\\d+(\\.\\d+)?$'", + # invalid edge type r"edges.tsv line 8: 'raNetv2-DC_' is not valid under any of the given schemas", + # invalid score r"edges.tsv line 10: 'score!' does not match '^\\d+(\\.\\d+)?$'", + # various permutations of edge directedness + r"directed_edges.tsv line 4: 'true' is not one of ['1', '0']", + r"directed_edges.tsv line 5: '' is not one of ['1', '0']", + r"directed_edges.tsv line 6: 'directed' is not one of ['1', '0']", + r"directed_edges.tsv line 8: 'false' is not one of ['1', '0']", ], "nodes": [ # invalid node type r"nodes.csv line 5: 'Monkey' is not valid under any of the given schemas", + r"nodes.csv line 7: 'A' does not match '^\\S{2,}.*$'", r"pheno_nodes.csv: no valid data found", ], "clusters": [ @@ -209,11 +223,12 @@ def test_load_col_count_errors(self): errs = { "edges": [ - "merged_edges-AMW-060820_AF.tsv line 6: expected 5 cols, found 3" - ], - "nodes": [ - "aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv line 3: expected 20 cols, found 22" + "edges.tsv line 2: expected 5 cols, found 6", + "edges.tsv line 6: expected 5 cols, found 3", + "directed_edges.tsv line 4: expected 6 cols, found 5", + "directed_edges.tsv line 6: expected 6 cols, found 3", ], + "nodes": ["nodes.csv line 3: expected 20 cols, found 22"], } self.test_errors(parser, errs) @@ -270,10 +285,14 @@ def test_duplicate_data(self): errs = { "edges": [ + "edges.tsv line 17: duplicate data for edge " + + "AT1G01100__SDV__protein-protein-interaction_literature-curation_AraNet_v2__False", "hithruput-edges.csv line 5: duplicate data for edge " - + "AT1G01010__AT1G01030__protein-protein-interaction_high-throughput_AraNet_v2", + + "AT1G01010__AT1G01030__protein-protein-interaction_high-throughput_AraNet_v2__False", "hithruput-edges.csv line 9: duplicate data for edge " - + "AT1G01030__AT1G01050__pairwise-gene-coexpression_AraNet_v2", + + "AT1G01030__AT1G01050__pairwise-gene-coexpression_AraNet_v2__False", + "hithruput-edges.csv line 11: duplicate data for edge " + + "SDV__AT1G01100__protein-protein-interaction_literature-curation_AraNet_v2__True", ], "nodes": ["extra_node.tsv line 5: duplicate data for node AT1G01080"], } @@ -282,7 +301,7 @@ def test_duplicate_data(self): def test_duplicate_cluster_data(self): """ test files with duplicate cluster data, which should be seamlessly merged """ - # path: test/djornl/col_count_errors + # path: test/djornl/duplicate_data RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, "djornl", "duplicate_data") parser = self.init_parser_with_path(RES_ROOT_DATA_PATH) @@ -305,12 +324,12 @@ def test_dry_run(self): "pairwise-gene-coexpression_AraNet_v2": 1, "domain-co-occurrence_AraNet_v2": 1, "protein-protein-interaction_high-throughput_AraNet_v2": 2, - "protein-protein-interaction_literature-curation_AraNet_v2": 3, + "protein-protein-interaction_literature-curation_AraNet_v2": 6, }, - "edges_total": 10, + "edges_total": 13, "node_data_available": {"cluster": 0, "full": 14, "key_only": 0}, "node_type_count": {"__NO_TYPE__": 0, "gene": 10, "pheno": 4}, - "nodes_in_edge": 10, + "nodes_in_edge": 12, "nodes_total": 14, }, output, diff --git a/spec/collections/djornl/djornl_edge.yaml b/spec/collections/djornl/djornl_edge.yaml index 57c2affd..8576e811 100644 --- a/spec/collections/djornl/djornl_edge.yaml +++ b/spec/collections/djornl/djornl_edge.yaml @@ -13,7 +13,7 @@ schema: title: Arabidopsis gene-gene or gene-phenotype edge description: Generic gene-to-gene or gene-to-phenotype edge for Dan Jacobson Arabidopsis data type: object - required: [score, edge_type, _from, _to, _key] + required: [score, edge_type, _from, _to, _key, directed] additionalProperties: false properties: _key: @@ -26,3 +26,5 @@ schema: $ref: ../../datasets/djornl/definitions.yaml#/definitions/djornl_edge/score edge_type: $ref: ../../datasets/djornl/definitions.yaml#/definitions/djornl_edge/edge_type + directed: + $ref: ../../datasets/djornl/definitions.yaml#/definitions/djornl_edge/directed diff --git a/spec/datasets/djornl/csv_edge.yaml b/spec/datasets/djornl/csv_edge.yaml index c166eb66..a5495c75 100644 --- a/spec/datasets/djornl/csv_edge.yaml +++ b/spec/datasets/djornl/csv_edge.yaml @@ -16,3 +16,10 @@ properties: pattern: ^\d+(\.\d+)?$ edge_type: $ref: edge_type.yaml + directed: + # pre-transform: parser treats this as a string + type: string + default: "0" + enum: + - "1" + - "0" diff --git a/spec/datasets/djornl/definitions.yaml b/spec/datasets/djornl/definitions.yaml index 9998af82..cc59e82a 100644 --- a/spec/datasets/djornl/definitions.yaml +++ b/spec/datasets/djornl/definitions.yaml @@ -21,20 +21,31 @@ definitions: pattern: ^(\S+__){3}(\S+)$ _from: type: string - title: Gene ID + title: Node ID + format: regex + pattern: ^\S{2,}.*$ _to: type: string - title: Gene or Phenotype ID + title: Node ID + format: regex + pattern: ^\S{2,}.*$ score: title: Edge Score (Weight) # (float) type: number edge_type: $ref: edge_type.yaml + directed: + type: boolean + title: Directed edge + description: Whether or not the edge is directed + default: false djornl_node: _key: type: string title: Key + format: regex + pattern: ^\S{2,}.*$ examples: ["AT1G01010", "As2"] clusters: type: array diff --git a/spec/test/djornl/col_count_errors/directed_edges.tsv b/spec/test/djornl/col_count_errors/directed_edges.tsv new file mode 100644 index 00000000..1192356b --- /dev/null +++ b/spec/test/djornl/col_count_errors/directed_edges.tsv @@ -0,0 +1,8 @@ +node1 node2 score edge_descrip edge_type directed +As2 AT1G01040 5.422046084731258 AraGWAS-Association_score phenotype-association_AraGWAS 1 +As75 AT1G01020 39.98573324312915 AraGWAS-Association_score phenotype-association_AraGWAS 0 +AT1G01010 AT1G01020 2.39322646755088 AraNetv2_log-likelihood-score protein-protein-interaction_high-throughput_AraNet_v2 +AT1G01010 AT1G01030 2.39322646755088 AraNetv2_log-likelihood-score protein-protein-interaction_high-throughput_AraNet_v2 1 +AT1G01010 AT1G01040 2.39322646755088 +AT1G01030 AT1G01050 2.5494618241936697 AraNetv2_log-likelihood-score pairwise-gene-coexpression_AraNet_v2 1 +AT1G01050 AT1G01060 4.34242054808616 AraNetv2_log-likelihood-score protein-protein-interaction_literature-curation_AraNet_v2 1 diff --git a/spec/test/djornl/col_count_errors/merged_edges-AMW-060820_AF.tsv b/spec/test/djornl/col_count_errors/edges.tsv similarity index 96% rename from spec/test/djornl/col_count_errors/merged_edges-AMW-060820_AF.tsv rename to spec/test/djornl/col_count_errors/edges.tsv index 8e8c6f1b..50071e12 100644 --- a/spec/test/djornl/col_count_errors/merged_edges-AMW-060820_AF.tsv +++ b/spec/test/djornl/col_count_errors/edges.tsv @@ -1,5 +1,5 @@ node1 node2 score edge_descrip edge_type -As2 AT1G01040 5.422046084731258 AraGWAS-Association_score phenotype-association_AraGWAS +As2 AT1G01040 5.422046084731258 AraGWAS-Association_score phenotype-association_AraGWAS 1 As75 AT1G01020 39.98573324312915 AraGWAS-Association_score phenotype-association_AraGWAS AT1G01010 AT1G01020 2.39322646755088 AraNetv2_log-likelihood-score protein-protein-interaction_high-throughput_AraNet_v2 AT1G01010 AT1G01030 2.39322646755088 AraNetv2_log-likelihood-score protein-protein-interaction_high-throughput_AraNet_v2 diff --git a/spec/test/djornl/col_count_errors/manifest.yaml b/spec/test/djornl/col_count_errors/manifest.yaml index 50c5f454..589fca7c 100644 --- a/spec/test/djornl/col_count_errors/manifest.yaml +++ b/spec/test/djornl/col_count_errors/manifest.yaml @@ -2,7 +2,10 @@ name: Dan Jacobson Exascale data release_date: "2020-06-06" file_list: - data_type: edge - path: merged_edges-AMW-060820_AF.tsv + path: edges.tsv + + - data_type: edge + path: directed_edges.tsv - data_type: node - path: aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv + path: nodes.csv diff --git a/spec/test/djornl/col_count_errors/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv b/spec/test/djornl/col_count_errors/nodes.csv similarity index 100% rename from spec/test/djornl/col_count_errors/aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv rename to spec/test/djornl/col_count_errors/nodes.csv diff --git a/spec/test/djornl/duplicate_data/edges.tsv b/spec/test/djornl/duplicate_data/edges.tsv index 552d74e6..61da1e35 100644 --- a/spec/test/djornl/duplicate_data/edges.tsv +++ b/spec/test/djornl/duplicate_data/edges.tsv @@ -1,11 +1,17 @@ -node1 node2 score edge_descrip edge_type -As2 AT1G01020 8.4 AraGWAS-Association_score phenotype-association_AraGWAS -As2 AT1G01040 5.4 AraGWAS-Association_score phenotype-association_AraGWAS -As75 AT1G01020 39.9 AraGWAS-Association_score phenotype-association_AraGWAS -AT1G01010 AT1G01040 2.5 AraNetv2_log-likelihood-score domain-co-occurrence_AraNet_v2 -AT1G01010 AT1G01040 170.5 AraNetv2_log-likelihood-score protein-protein-interaction_literature-curation_AraNet_v2 -AT1G01030 AT1G01050 2.6 AraNetv2_log-likelihood-score pairwise-gene-coexpression_AraNet_v2 -AT1G01050 AT1G01060 2.7 AraNetv2_log-likelihood-score protein-protein-interaction_literature-curation_AraNet_v2 +node1 node2 score directed edge_type +As2 AT1G01020 8.4 0 phenotype-association_AraGWAS +As2 AT1G01040 5.4 0 phenotype-association_AraGWAS +As75 AT1G01020 39.9 0 phenotype-association_AraGWAS +AT1G01010 AT1G01040 2.5 0 domain-co-occurrence_AraNet_v2 +AT1G01010 AT1G01040 170.5 0 protein-protein-interaction_literature-curation_AraNet_v2 +AT1G01030 AT1G01050 2.6 0 pairwise-gene-coexpression_AraNet_v2 +AT1G01050 AT1G01060 2.7 0 protein-protein-interaction_literature-curation_AraNet_v2 # duplicated line -AT1G01010 AT1G01040 2.5 AraNetv2_log-likelihood-score domain-co-occurrence_AraNet_v2 -AT1G01080 AT1G01090 2.8 AraNetv2_log-likelihood-score protein-protein-interaction_literature-curation_AraNet_v2 +AT1G01010 AT1G01040 2.5 0 domain-co-occurrence_AraNet_v2 +AT1G01080 AT1G01090 2.8 0 protein-protein-interaction_literature-curation_AraNet_v2 +# these are OK +SDV AT1G01100 8.4 0 protein-protein-interaction_literature-curation_AraNet_v2 +SDV AT1G01100 5.4 1 protein-protein-interaction_literature-curation_AraNet_v2 +AT1G01100 SDV 2.4 1 protein-protein-interaction_literature-curation_AraNet_v2 +# this is a dupe! +AT1G01100 SDV 8.5 0 protein-protein-interaction_literature-curation_AraNet_v2 diff --git a/spec/test/djornl/duplicate_data/hithruput-edges.csv b/spec/test/djornl/duplicate_data/hithruput-edges.csv index 197becd5..0bf626c2 100644 --- a/spec/test/djornl/duplicate_data/hithruput-edges.csv +++ b/spec/test/djornl/duplicate_data/hithruput-edges.csv @@ -1,9 +1,12 @@ -node1,node2,score,edge_descrip,edge_type -AT1G01010,AT1G01020,2.3,AraNetv2_log-likelihood-score,protein-protein-interaction_high-throughput_AraNet_v2 -AT1G01010,AT1G01030,2.4,AraNetv2_log-likelihood-score,protein-protein-interaction_high-throughput_AraNet_v2 +node1,node2,score,edge_descrip,edge_type,directed +AT1G01010,AT1G01020,2.3,AraNetv2_log-likelihood-score,protein-protein-interaction_high-throughput_AraNet_v2,0 +AT1G01010,AT1G01030,2.4,AraNetv2_log-likelihood-score,protein-protein-interaction_high-throughput_AraNet_v2,0 # potentially erroneous line -AT1G01010,AT1G01030,2.7,AraNetv2_log-likelihood-score,protein-protein-interaction_high-throughput_AraNet_v2 +AT1G01010,AT1G01030,2.7,AraNetv2_log-likelihood-score,protein-protein-interaction_high-throughput_AraNet_v2,0 # duplicated line from the other file -AT1G01060,AT1G01050,2.7,AraNetv2_log-likelihood-score,protein-protein-interaction_literature-curation_AraNet_v2 +AT1G01060,AT1G01050,2.7,AraNetv2_log-likelihood-score,protein-protein-interaction_literature-curation_AraNet_v2,0 # potentially erroneous duplication from the other file -AT1G01050,AT1G01030,2.6000001,AraNetv2_log-likelihood-score,pairwise-gene-coexpression_AraNet_v2 +AT1G01050,AT1G01030,2.6000001,AraNetv2_log-likelihood-score,pairwise-gene-coexpression_AraNet_v2,0 +# directed edge dupe +SDV,AT1G01100,2001,whatever,protein-protein-interaction_literature-curation_AraNet_v2,1 + diff --git a/spec/test/djornl/invalid_types/directed_edges.tsv b/spec/test/djornl/invalid_types/directed_edges.tsv new file mode 100644 index 00000000..76459ec5 --- /dev/null +++ b/spec/test/djornl/invalid_types/directed_edges.tsv @@ -0,0 +1,10 @@ +# data_type: edge +node1 node2 score edge_descrip edge_type directed +As2 AT1G01020 8.4 AraGWAS-Association_score phenotype-association_AraGWAS 1 +As2 AT1G01040 5.4 AraGWAS-Association_score phenotype-association_AraGWAS true +As75 AT1G01020 39.9 AraGWAS-Association_score phenotype-association_AraGWAS "" +AT1G01010 AT1G01040 2.5 AraNetv2_log-likelihood-score domain-co-occurrence_AraNet_v2 directed +AT1G01010 AT1G01040 170.5 AraNetv2_log-likelihood-score protein-protein-interaction_literature-curation_AraNet_v2 "0" +AT1G01030 AT1G01050 2.6 AraNetv2_log-likelihood-score pairwise-gene-coexpression_AraNet_v2 false +AT1G01050 AT1G01060 2.7 AraNetv2_log-likelihood-score protein-protein-interaction_literature-curation_AraNet_v2 "1" +AT1G01080 AT1G01090 2.8 AraNetv2_log-likelihood-score protein-protein-interaction_literature-curation_AraNet_v2 0 diff --git a/spec/test/djornl/invalid_types/edges.tsv b/spec/test/djornl/invalid_types/edges.tsv index 57fda99d..a9762362 100644 --- a/spec/test/djornl/invalid_types/edges.tsv +++ b/spec/test/djornl/invalid_types/edges.tsv @@ -1,9 +1,9 @@ # data_type: edge node1 node2 score edge_descrip edge_type As2 AT1G01020 8.422046084731258 AraGWAS-Association_score Same-Old-Stuff -As2 AT1G01040 6 AraGWAS-Association_score phenotype-association_AraGWAS -As75 AT1G01020 39.98573324312915 AraGWAS-Association_score phenotype-association_AraGWAS -AT1G01010 AT1G01020 2.39322646755088 AraNetv2_log-likelihood-score protein-protein-interaction_high-throughput_AraNet_v2 + AT1G01040 6 AraGWAS-Association_score phenotype-association_AraGWAS +As75 39.98573324312915 AraGWAS-Association_score phenotype-association_AraGWAS +AT1G01010 AT1G01020 2.39322646755088 AT1G01010 AT1G01030 2. AraNetv2_log-likelihood-score protein-protein-interaction_high-throughput_AraNet_v2 AT1G01010 AT1G01040 "2.39322646755088" AraNetv2_log-likelihood-score raNetv2-DC_ AT1G01030 AT1G01050 25494618241936697 AraNetv2_log-likelihood-score pairwise-gene-coexpression_AraNet_v2 diff --git a/spec/test/djornl/invalid_types/manifest.yaml b/spec/test/djornl/invalid_types/manifest.yaml index 8e50d86b..2c007b84 100644 --- a/spec/test/djornl/invalid_types/manifest.yaml +++ b/spec/test/djornl/invalid_types/manifest.yaml @@ -4,6 +4,9 @@ file_list: - data_type: edge path: edges.tsv + - data_type: edge + path: directed_edges.tsv + - data_type: node path: nodes.csv diff --git a/spec/test/djornl/invalid_types/nodes.csv b/spec/test/djornl/invalid_types/nodes.csv index ff99ff01..db64e077 100644 --- a/spec/test/djornl/invalid_types/nodes.csv +++ b/spec/test/djornl/invalid_types/nodes.csv @@ -4,7 +4,7 @@ As2,pheno,,,,,,,,,,,,,10.21958/phenotype:103,,bacterial disease resistance,The r As75,pheno,,,,,,,,,,,,,10.21958/phenotype:67,"Arsenic concentrations in leaves, grown in soil. Elemental analysis was performed with an ICP-MS (PerkinElmer). Sample normalized to calculated weights as described in Baxter et al., 2008",arsenic concentration,A mineral and ion content related trait (TO:0000465) which is the concentration of arsenic (CHEBI:22632) in some plant structure (PO:0009011). [GR:Karthik],"Atwell et. al, Nature 2010", AT1G01010,Monkey,AT1G01010.1,NTL10,NAC domain containing protein 1,protein_coding,NAC domain containing protein 1;(source:Araport11),,NAC domain containing protein 1,"DNA-binding transcription factor activity, DNA binding","GO:0003700, GO:0003677",15.5.17,.RNA biosynthesis.transcriptional regulation.transcription factor (NAC),transcription factor (NAC) (original description: pep chromosome:TAIR10:1:3631:5899:1 gene:AT1G01010 transcript:AT1G01010.1 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:NAC001 description:NAC domain-containing protein 1 [Source:UniProtKB/Swiss-Prot;Acc:Q0WV96]),,,,,, AT1G01020,gene,AT1G01020.6,ARV1,,protein_coding,ARV1 family protein;(source:Araport11),,,molecular_function,GO:0003674,35.1,not assigned.annotated,(original description: pep chromosome:TAIR10:1:6788:8737:-1 gene:AT1G01020 transcript:AT1G01020.6 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:ARV1 description:ARV1 family protein [Source:UniProtKB/TrEMBL;Acc:Q5MK24]) & no description available(sp|q5mk24|arv1_arath : 99.4),,,,,, -AT1G01030,gene,AT1G01030.2,NGA3,NGATHA3,protein_coding,AP2/B3-like transcriptional factor family protein;(source:Araport11),,,"DNA-binding transcription factor activity, DNA binding","GO:0003700, GO:0003677",15.5.5.3,.RNA biosynthesis.transcriptional regulation.B3 transcription factor superfamily.transcription factor (RAV/NGATHA),transcription factor (RAV/NGATHA) (original description: pep chromosome:TAIR10:1:11649:13714:-1 gene:AT1G01030 transcript:AT1G01030.2 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:NGA3 description:B3 domain-containing transcription factor NGA3 [Source:UniProtKB/Swiss-Prot;Acc:Q9MAN1]),,,,,, +A,gene,AT1G01030.2,NGA3,NGATHA3,protein_coding,AP2/B3-like transcriptional factor family protein;(source:Araport11),,,"DNA-binding transcription factor activity, DNA binding","GO:0003700, GO:0003677",15.5.5.3,.RNA biosynthesis.transcriptional regulation.B3 transcription factor superfamily.transcription factor (RAV/NGATHA),transcription factor (RAV/NGATHA) (original description: pep chromosome:TAIR10:1:11649:13714:-1 gene:AT1G01030 transcript:AT1G01030.2 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:NGA3 description:B3 domain-containing transcription factor NGA3 [Source:UniProtKB/Swiss-Prot;Acc:Q9MAN1]),,,,,, AT1G01040,gene,AT1G01040.2,SUS1,SUSPENSOR 1,protein_coding,dicer-like 1;(source:Araport11),"Encodes a Dicer homolog. Dicer is a RNA helicase involved in microRNA processing. Mutations in this locus can result in embryo lethality. Embryo shape at seed maturity is globular-elongate. Other mutants convert the floral meristems to an indeterminate state, others yet show defects in ovule development. mRNA is expressed in all shoot tissues. DCL1 is able to produce miRNAs and siRNAs. The mRNA is cell-to-cell mobile.",dicer-like 1,"metal ion binding, protein binding, ribonuclease III activity, ATP-dependent helicase activity, ATP binding, RNA binding, helicase activity, double-stranded RNA binding, DNA binding","GO:0046872, GO:0005515, GO:0004525, GO:0008026, GO:0005524, GO:0003723, GO:0004386, GO:0003725, GO:0003677",16.10.2.1.1,.RNA processing.mRNA silencing.miRNA pathway.DCL1-HYL1 miRNA biogenesis complex.endoribonuclease component DCL1,endoribonuclease component DCL1 of DCL1-HYL1 miRNA biogenesis complex (original description: pep chromosome:TAIR10:1:23416:31120:1 gene:AT1G01040 transcript:AT1G01040.2 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:DCL1 description:Dicer-like 1 [Source:UniProtKB/TrEMBL;Acc:F4HQG6]),,,,,, AT1G01050,gene,AT1G01050.2,PPa1,pyrophosphorylase 1,protein_coding,pyrophosphorylase 1;(source:Araport11),,,inorganic diphosphatase activity,GO:0004427,35.1,not assigned.annotated,(original description: pep chromosome:TAIR10:1:31382:33009:-1 gene:AT1G01050 transcript:AT1G01050.2 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:PPA1 description:Soluble inorganic pyrophosphatase 1 [Source:UniProtKB/Swiss-Prot;Acc:Q93V56]) & Soluble inorganic pyrophosphatase 1 OS=Arabidopsis thaliana (sp|q93v56|ipyr1_arath : 419.0),,,,,, AT1G01060,gene,AT1G01060.8,LHY1,LATE ELONGATED HYPOCOTYL 1,protein_coding,Homeodomain-like superfamily protein;(source:Araport11),,,"DNA-binding transcription factor activity, DNA binding, transcription regulatory region DNA binding","GO:0003700, GO:0003677, GO:0044212",27.1.1,.Multi-process regulation.circadian clock system.core oscillator protein (LHY|CCA1),circadian clock core oscillator protein (LHY|CCA1) (original description: pep chromosome:TAIR10:1:33967:37230:-1 gene:AT1G01060 transcript:AT1G01060.8 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:LHY description:LHY1 [Source:UniProtKB/TrEMBL;Acc:A0A178W761]),,,,,, diff --git a/spec/test/djornl/results.json b/spec/test/djornl/results.json index eda91194..d0052d46 100644 --- a/spec/test/djornl/results.json +++ b/spec/test/djornl/results.json @@ -10,19 +10,114 @@ {"_key": "AT1G01050"}, {"_key": "AT1G01060"}, {"_key": "AT1G01080"}, - {"_key": "AT1G01090"} + {"_key": "AT1G01090"}, + {"_key": "AT1G01100"}, + {"_key": "SDV"} ], "edges": [ - {"_key": "As2__AT1G01020__phenotype-association_AraGWAS__8.4", "_from": "djornl_node/As2", "_to": "djornl_node/AT1G01020", "edge_type": "phenotype-association_AraGWAS", "score": 8.4}, - {"_key": "As2__AT1G01040__phenotype-association_AraGWAS__5.4", "_from": "djornl_node/As2", "_to": "djornl_node/AT1G01040", "edge_type": "phenotype-association_AraGWAS", "score": 5.4}, - {"_key": "As75__AT1G01020__phenotype-association_AraGWAS__39.9", "_from": "djornl_node/As75", "_to": "djornl_node/AT1G01020", "edge_type": "phenotype-association_AraGWAS", "score": 39.9}, - {"_key": "AT1G01010__AT1G01020__protein-protein-interaction_high-throughput_AraNet_v2__2.3", "_from": "djornl_node/AT1G01010", "_to": "djornl_node/AT1G01020", "edge_type": "protein-protein-interaction_high-throughput_AraNet_v2", "score": 2.3}, - {"_key": "AT1G01010__AT1G01030__protein-protein-interaction_high-throughput_AraNet_v2__2.4", "_from": "djornl_node/AT1G01010", "_to": "djornl_node/AT1G01030", "edge_type": "protein-protein-interaction_high-throughput_AraNet_v2", "score": 2.4}, - {"_key": "AT1G01010__AT1G01040__domain-co-occurrence_AraNet_v2__2.5", "_from": "djornl_node/AT1G01010", "_to": "djornl_node/AT1G01040", "edge_type": "domain-co-occurrence_AraNet_v2", "score": 2.5}, - {"_key": "AT1G01010__AT1G01040__protein-protein-interaction_literature-curation_AraNet_v2__170.5", "_from": "djornl_node/AT1G01010", "_to": "djornl_node/AT1G01040", "edge_type": "protein-protein-interaction_literature-curation_AraNet_v2", "score": 170.5}, - {"_key": "AT1G01030__AT1G01050__pairwise-gene-coexpression_AraNet_v2__2.6", "_from": "djornl_node/AT1G01030", "_to": "djornl_node/AT1G01050", "edge_type": "pairwise-gene-coexpression_AraNet_v2", "score": 2.6}, - {"_key": "AT1G01050__AT1G01060__protein-protein-interaction_literature-curation_AraNet_v2__2.7", "_from": "djornl_node/AT1G01050", "_to": "djornl_node/AT1G01060", "edge_type": "protein-protein-interaction_literature-curation_AraNet_v2", "score": 2.7}, - {"_key": "AT1G01080__AT1G01090__protein-protein-interaction_literature-curation_AraNet_v2__2.8", "_from": "djornl_node/AT1G01080", "_to": "djornl_node/AT1G01090", "edge_type": "protein-protein-interaction_literature-curation_AraNet_v2", "score": 2.8} + { + "_key": "As2__AT1G01020__phenotype-association_AraGWAS__False__8.4", + "_from": "djornl_node/As2", + "_to": "djornl_node/AT1G01020", + "edge_type": "phenotype-association_AraGWAS", + "score": 8.4, + "directed": false + }, + { + "_key": "As2__AT1G01040__phenotype-association_AraGWAS__False__5.4", + "_from": "djornl_node/As2", + "_to": "djornl_node/AT1G01040", + "edge_type": "phenotype-association_AraGWAS", + "score": 5.4, "directed": false + }, + { + "_key": "As75__AT1G01020__phenotype-association_AraGWAS__False__39.9", + "_from": "djornl_node/As75", + "_to": "djornl_node/AT1G01020", + "edge_type": "phenotype-association_AraGWAS", + "score": 39.9, + "directed": false + }, + { + "_key": "AT1G01010__AT1G01020__protein-protein-interaction_high-throughput_AraNet_v2__False__2.3", + "_from": "djornl_node/AT1G01010", + "_to": "djornl_node/AT1G01020", + "edge_type": "protein-protein-interaction_high-throughput_AraNet_v2", + "score": 2.3, + "directed": false + }, + { + "_key": "AT1G01010__AT1G01030__protein-protein-interaction_high-throughput_AraNet_v2__False__2.4", + "_from": "djornl_node/AT1G01010", + "_to": "djornl_node/AT1G01030", + "edge_type": "protein-protein-interaction_high-throughput_AraNet_v2", + "score": 2.4, + "directed": false + }, + { + "_key": "AT1G01010__AT1G01040__domain-co-occurrence_AraNet_v2__False__2.5", + "_from": "djornl_node/AT1G01010", + "_to": "djornl_node/AT1G01040", + "edge_type": "domain-co-occurrence_AraNet_v2", + "score": 2.5, + "directed": false + }, + { + "_key": "AT1G01010__AT1G01040__protein-protein-interaction_literature-curation_AraNet_v2__False__170.5", + "_from": "djornl_node/AT1G01010", + "_to": "djornl_node/AT1G01040", + "edge_type": "protein-protein-interaction_literature-curation_AraNet_v2", + "score": 170.5, + "directed": false + }, + { + "_key": "AT1G01030__AT1G01050__pairwise-gene-coexpression_AraNet_v2__False__2.6", + "_from": "djornl_node/AT1G01030", + "_to": "djornl_node/AT1G01050", + "edge_type": "pairwise-gene-coexpression_AraNet_v2", + "score": 2.6, + "directed": false + }, + { + "_key": "AT1G01050__AT1G01060__protein-protein-interaction_literature-curation_AraNet_v2__False__2.7", + "_from": "djornl_node/AT1G01050", + "_to": "djornl_node/AT1G01060", + "edge_type": "protein-protein-interaction_literature-curation_AraNet_v2", + "score": 2.7, + "directed": false + }, + { + "_key": "AT1G01080__AT1G01090__protein-protein-interaction_literature-curation_AraNet_v2__False__2.8", + "_from": "djornl_node/AT1G01080", + "_to": "djornl_node/AT1G01090", + "edge_type": "protein-protein-interaction_literature-curation_AraNet_v2", + "score": 2.8, + "directed": false + }, + { + "_key": "AT1G01100__SDV__protein-protein-interaction_literature-curation_AraNet_v2__True__2.4", + "_from": "djornl_node/AT1G01100", + "_to": "djornl_node/SDV", + "edge_type": "protein-protein-interaction_literature-curation_AraNet_v2", + "score": 2.4, + "directed": true + }, + { + "_key": "SDV__AT1G01100__protein-protein-interaction_literature-curation_AraNet_v2__False__8.4", + "_from": "djornl_node/SDV", + "_to": "djornl_node/AT1G01100", + "edge_type": "protein-protein-interaction_literature-curation_AraNet_v2", + "score": 8.4, + "directed": false + }, + { + "_key": "SDV__AT1G01100__protein-protein-interaction_literature-curation_AraNet_v2__True__5.4", + "_from": "djornl_node/SDV", + "_to": "djornl_node/AT1G01100", + "edge_type": "protein-protein-interaction_literature-curation_AraNet_v2", + "score": 5.4, + "directed": true + } ] }, "load_clusters": { @@ -88,16 +183,19 @@ "SDV" ], "edges": [ - "As2__AT1G01020__phenotype-association_AraGWAS__8.4", - "As2__AT1G01040__phenotype-association_AraGWAS__5.4", - "As75__AT1G01020__phenotype-association_AraGWAS__39.9", - "AT1G01010__AT1G01020__protein-protein-interaction_high-throughput_AraNet_v2__2.3", - "AT1G01010__AT1G01030__protein-protein-interaction_high-throughput_AraNet_v2__2.4", - "AT1G01010__AT1G01040__domain-co-occurrence_AraNet_v2__2.5", - "AT1G01010__AT1G01040__protein-protein-interaction_literature-curation_AraNet_v2__170.5", - "AT1G01030__AT1G01050__pairwise-gene-coexpression_AraNet_v2__2.6", - "AT1G01050__AT1G01060__protein-protein-interaction_literature-curation_AraNet_v2__2.7", - "AT1G01080__AT1G01090__protein-protein-interaction_literature-curation_AraNet_v2__2.8" + "As2__AT1G01020__phenotype-association_AraGWAS__False__8.4", + "As2__AT1G01040__phenotype-association_AraGWAS__False__5.4", + "As75__AT1G01020__phenotype-association_AraGWAS__False__39.9", + "AT1G01010__AT1G01020__protein-protein-interaction_high-throughput_AraNet_v2__False__2.3", + "AT1G01010__AT1G01030__protein-protein-interaction_high-throughput_AraNet_v2__False__2.4", + "AT1G01010__AT1G01040__domain-co-occurrence_AraNet_v2__False__2.5", + "AT1G01010__AT1G01040__protein-protein-interaction_literature-curation_AraNet_v2__False__170.5", + "AT1G01030__AT1G01050__pairwise-gene-coexpression_AraNet_v2__False__2.6", + "AT1G01050__AT1G01060__protein-protein-interaction_literature-curation_AraNet_v2__False__2.7", + "AT1G01080__AT1G01090__protein-protein-interaction_literature-curation_AraNet_v2__False__2.8", + "AT1G01100__SDV__protein-protein-interaction_literature-curation_AraNet_v2__True__2.4", + "SDV__AT1G01100__protein-protein-interaction_literature-curation_AraNet_v2__False__8.4", + "SDV__AT1G01100__protein-protein-interaction_literature-curation_AraNet_v2__True__5.4" ] } }, @@ -139,16 +237,19 @@ "SDV" ], "edges": [ - "As2__AT1G01020__phenotype-association_AraGWAS__8.4", - "As2__AT1G01040__phenotype-association_AraGWAS__5.4", - "As75__AT1G01020__phenotype-association_AraGWAS__39.9", - "AT1G01010__AT1G01020__protein-protein-interaction_high-throughput_AraNet_v2__2.3", - "AT1G01010__AT1G01030__protein-protein-interaction_high-throughput_AraNet_v2__2.4", - "AT1G01010__AT1G01040__domain-co-occurrence_AraNet_v2__2.5", - "AT1G01010__AT1G01040__protein-protein-interaction_literature-curation_AraNet_v2__170.5", - "AT1G01030__AT1G01050__pairwise-gene-coexpression_AraNet_v2__2.6", - "AT1G01050__AT1G01060__protein-protein-interaction_literature-curation_AraNet_v2__2.7", - "AT1G01080__AT1G01090__protein-protein-interaction_literature-curation_AraNet_v2__2.8" + "As2__AT1G01020__phenotype-association_AraGWAS__False__8.4", + "As2__AT1G01040__phenotype-association_AraGWAS__False__5.4", + "As75__AT1G01020__phenotype-association_AraGWAS__False__39.9", + "AT1G01010__AT1G01020__protein-protein-interaction_high-throughput_AraNet_v2__False__2.3", + "AT1G01010__AT1G01030__protein-protein-interaction_high-throughput_AraNet_v2__False__2.4", + "AT1G01010__AT1G01040__domain-co-occurrence_AraNet_v2__False__2.5", + "AT1G01010__AT1G01040__protein-protein-interaction_literature-curation_AraNet_v2__False__170.5", + "AT1G01030__AT1G01050__pairwise-gene-coexpression_AraNet_v2__False__2.6", + "AT1G01050__AT1G01060__protein-protein-interaction_literature-curation_AraNet_v2__False__2.7", + "AT1G01080__AT1G01090__protein-protein-interaction_literature-curation_AraNet_v2__False__2.8", + "AT1G01100__SDV__protein-protein-interaction_literature-curation_AraNet_v2__True__2.4", + "SDV__AT1G01100__protein-protein-interaction_literature-curation_AraNet_v2__False__8.4", + "SDV__AT1G01100__protein-protein-interaction_literature-curation_AraNet_v2__True__5.4" ] } }, @@ -172,9 +273,9 @@ "SDV" ], "edges": [ - "As2__AT1G01020__phenotype-association_AraGWAS__8.4", - "As2__AT1G01040__phenotype-association_AraGWAS__5.4", - "As75__AT1G01020__phenotype-association_AraGWAS__39.9" + "As2__AT1G01020__phenotype-association_AraGWAS__False__8.4", + "As2__AT1G01040__phenotype-association_AraGWAS__False__5.4", + "As75__AT1G01020__phenotype-association_AraGWAS__False__39.9" ] } }, @@ -198,14 +299,17 @@ "SDV" ], "edges": [ - "As2__AT1G01020__phenotype-association_AraGWAS__8.4", - "As2__AT1G01040__phenotype-association_AraGWAS__5.4", - "As75__AT1G01020__phenotype-association_AraGWAS__39.9", - "AT1G01010__AT1G01020__protein-protein-interaction_high-throughput_AraNet_v2__2.3", - "AT1G01010__AT1G01030__protein-protein-interaction_high-throughput_AraNet_v2__2.4", - "AT1G01010__AT1G01040__protein-protein-interaction_literature-curation_AraNet_v2__170.5", - "AT1G01050__AT1G01060__protein-protein-interaction_literature-curation_AraNet_v2__2.7", - "AT1G01080__AT1G01090__protein-protein-interaction_literature-curation_AraNet_v2__2.8" + "As2__AT1G01020__phenotype-association_AraGWAS__False__8.4", + "As2__AT1G01040__phenotype-association_AraGWAS__False__5.4", + "As75__AT1G01020__phenotype-association_AraGWAS__False__39.9", + "AT1G01010__AT1G01020__protein-protein-interaction_high-throughput_AraNet_v2__False__2.3", + "AT1G01010__AT1G01030__protein-protein-interaction_high-throughput_AraNet_v2__False__2.4", + "AT1G01010__AT1G01040__protein-protein-interaction_literature-curation_AraNet_v2__False__170.5", + "AT1G01050__AT1G01060__protein-protein-interaction_literature-curation_AraNet_v2__False__2.7", + "AT1G01080__AT1G01090__protein-protein-interaction_literature-curation_AraNet_v2__False__2.8", + "AT1G01100__SDV__protein-protein-interaction_literature-curation_AraNet_v2__True__2.4", + "SDV__AT1G01100__protein-protein-interaction_literature-curation_AraNet_v2__False__8.4", + "SDV__AT1G01100__protein-protein-interaction_literature-curation_AraNet_v2__True__5.4" ] } } @@ -267,10 +371,10 @@ "AT1G01040" ], "edges": [ - "AT1G01010__AT1G01020__protein-protein-interaction_high-throughput_AraNet_v2__2.3", - "AT1G01010__AT1G01030__protein-protein-interaction_high-throughput_AraNet_v2__2.4", - "AT1G01010__AT1G01040__domain-co-occurrence_AraNet_v2__2.5", - "AT1G01010__AT1G01040__protein-protein-interaction_literature-curation_AraNet_v2__170.5" + "AT1G01010__AT1G01020__protein-protein-interaction_high-throughput_AraNet_v2__False__2.3", + "AT1G01010__AT1G01030__protein-protein-interaction_high-throughput_AraNet_v2__False__2.4", + "AT1G01010__AT1G01040__domain-co-occurrence_AraNet_v2__False__2.5", + "AT1G01010__AT1G01040__protein-protein-interaction_literature-curation_AraNet_v2__False__170.5" ] } }, @@ -279,15 +383,15 @@ "results": { "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060"], "edges": [ - "As2__AT1G01020__phenotype-association_AraGWAS__8.4", - "As2__AT1G01040__phenotype-association_AraGWAS__5.4", - "As75__AT1G01020__phenotype-association_AraGWAS__39.9", - "AT1G01010__AT1G01020__protein-protein-interaction_high-throughput_AraNet_v2__2.3", - "AT1G01010__AT1G01030__protein-protein-interaction_high-throughput_AraNet_v2__2.4", - "AT1G01010__AT1G01040__domain-co-occurrence_AraNet_v2__2.5", - "AT1G01010__AT1G01040__protein-protein-interaction_literature-curation_AraNet_v2__170.5", - "AT1G01030__AT1G01050__pairwise-gene-coexpression_AraNet_v2__2.6", - "AT1G01050__AT1G01060__protein-protein-interaction_literature-curation_AraNet_v2__2.7" + "As2__AT1G01020__phenotype-association_AraGWAS__False__8.4", + "As2__AT1G01040__phenotype-association_AraGWAS__False__5.4", + "As75__AT1G01020__phenotype-association_AraGWAS__False__39.9", + "AT1G01010__AT1G01020__protein-protein-interaction_high-throughput_AraNet_v2__False__2.3", + "AT1G01010__AT1G01030__protein-protein-interaction_high-throughput_AraNet_v2__False__2.4", + "AT1G01010__AT1G01040__domain-co-occurrence_AraNet_v2__False__2.5", + "AT1G01010__AT1G01040__protein-protein-interaction_literature-curation_AraNet_v2__False__170.5", + "AT1G01030__AT1G01050__pairwise-gene-coexpression_AraNet_v2__False__2.6", + "AT1G01050__AT1G01060__protein-protein-interaction_literature-curation_AraNet_v2__False__2.7" ] } }, @@ -296,15 +400,15 @@ "results": { "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060"], "edges": [ - "As2__AT1G01020__phenotype-association_AraGWAS__8.4", - "As2__AT1G01040__phenotype-association_AraGWAS__5.4", - "As75__AT1G01020__phenotype-association_AraGWAS__39.9", - "AT1G01010__AT1G01020__protein-protein-interaction_high-throughput_AraNet_v2__2.3", - "AT1G01010__AT1G01030__protein-protein-interaction_high-throughput_AraNet_v2__2.4", - "AT1G01010__AT1G01040__domain-co-occurrence_AraNet_v2__2.5", - "AT1G01010__AT1G01040__protein-protein-interaction_literature-curation_AraNet_v2__170.5", - "AT1G01030__AT1G01050__pairwise-gene-coexpression_AraNet_v2__2.6", - "AT1G01050__AT1G01060__protein-protein-interaction_literature-curation_AraNet_v2__2.7" + "As2__AT1G01020__phenotype-association_AraGWAS__False__8.4", + "As2__AT1G01040__phenotype-association_AraGWAS__False__5.4", + "As75__AT1G01020__phenotype-association_AraGWAS__False__39.9", + "AT1G01010__AT1G01020__protein-protein-interaction_high-throughput_AraNet_v2__False__2.3", + "AT1G01010__AT1G01030__protein-protein-interaction_high-throughput_AraNet_v2__False__2.4", + "AT1G01010__AT1G01040__domain-co-occurrence_AraNet_v2__False__2.5", + "AT1G01010__AT1G01040__protein-protein-interaction_literature-curation_AraNet_v2__False__170.5", + "AT1G01030__AT1G01050__pairwise-gene-coexpression_AraNet_v2__False__2.6", + "AT1G01050__AT1G01060__protein-protein-interaction_literature-curation_AraNet_v2__False__2.7" ] } }, @@ -320,9 +424,9 @@ "results": { "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01070"], "edges": [ - "As2__AT1G01020__phenotype-association_AraGWAS__8.4", - "As75__AT1G01020__phenotype-association_AraGWAS__39.9", - "AT1G01010__AT1G01020__protein-protein-interaction_high-throughput_AraNet_v2__2.3" + "As2__AT1G01020__phenotype-association_AraGWAS__False__8.4", + "As75__AT1G01020__phenotype-association_AraGWAS__False__39.9", + "AT1G01010__AT1G01020__protein-protein-interaction_high-throughput_AraNet_v2__False__2.3" ] } }, @@ -331,8 +435,8 @@ "results": { "nodes": ["As2", "As75", "AT1G01020", "AT1G01070"], "edges": [ - "As2__AT1G01020__phenotype-association_AraGWAS__8.4", - "As75__AT1G01020__phenotype-association_AraGWAS__39.9" + "As2__AT1G01020__phenotype-association_AraGWAS__False__8.4", + "As75__AT1G01020__phenotype-association_AraGWAS__False__39.9" ] } }, @@ -341,15 +445,15 @@ "results": { "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060", "AT1G01070"], "edges": [ - "As2__AT1G01020__phenotype-association_AraGWAS__8.4", - "As2__AT1G01040__phenotype-association_AraGWAS__5.4", - "As75__AT1G01020__phenotype-association_AraGWAS__39.9", - "AT1G01010__AT1G01020__protein-protein-interaction_high-throughput_AraNet_v2__2.3", - "AT1G01010__AT1G01030__protein-protein-interaction_high-throughput_AraNet_v2__2.4", - "AT1G01010__AT1G01040__domain-co-occurrence_AraNet_v2__2.5", - "AT1G01010__AT1G01040__protein-protein-interaction_literature-curation_AraNet_v2__170.5", - "AT1G01030__AT1G01050__pairwise-gene-coexpression_AraNet_v2__2.6", - "AT1G01050__AT1G01060__protein-protein-interaction_literature-curation_AraNet_v2__2.7" + "As2__AT1G01020__phenotype-association_AraGWAS__False__8.4", + "As2__AT1G01040__phenotype-association_AraGWAS__False__5.4", + "As75__AT1G01020__phenotype-association_AraGWAS__False__39.9", + "AT1G01010__AT1G01020__protein-protein-interaction_high-throughput_AraNet_v2__False__2.3", + "AT1G01010__AT1G01030__protein-protein-interaction_high-throughput_AraNet_v2__False__2.4", + "AT1G01010__AT1G01040__domain-co-occurrence_AraNet_v2__False__2.5", + "AT1G01010__AT1G01040__protein-protein-interaction_literature-curation_AraNet_v2__False__170.5", + "AT1G01030__AT1G01050__pairwise-gene-coexpression_AraNet_v2__False__2.6", + "AT1G01050__AT1G01060__protein-protein-interaction_literature-curation_AraNet_v2__False__2.7" ] } }, @@ -362,10 +466,10 @@ "results": { "nodes": ["AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01070"], "edges": [ - "AT1G01010__AT1G01020__protein-protein-interaction_high-throughput_AraNet_v2__2.3", - "AT1G01010__AT1G01030__protein-protein-interaction_high-throughput_AraNet_v2__2.4", - "AT1G01010__AT1G01040__domain-co-occurrence_AraNet_v2__2.5", - "AT1G01030__AT1G01050__pairwise-gene-coexpression_AraNet_v2__2.6" + "AT1G01010__AT1G01020__protein-protein-interaction_high-throughput_AraNet_v2__False__2.3", + "AT1G01010__AT1G01030__protein-protein-interaction_high-throughput_AraNet_v2__False__2.4", + "AT1G01010__AT1G01040__domain-co-occurrence_AraNet_v2__False__2.5", + "AT1G01030__AT1G01050__pairwise-gene-coexpression_AraNet_v2__False__2.6" ] } } @@ -412,8 +516,8 @@ "results": { "nodes": ["As2", "AT1G01020", "AT1G01040"], "edges": [ - "As2__AT1G01020__phenotype-association_AraGWAS__8.4", - "As2__AT1G01040__phenotype-association_AraGWAS__5.4" + "As2__AT1G01020__phenotype-association_AraGWAS__False__8.4", + "As2__AT1G01040__phenotype-association_AraGWAS__False__5.4" ] } }, @@ -422,15 +526,15 @@ "results": { "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060"], "edges": [ - "As2__AT1G01020__phenotype-association_AraGWAS__8.4", - "As2__AT1G01040__phenotype-association_AraGWAS__5.4", - "As75__AT1G01020__phenotype-association_AraGWAS__39.9", - "AT1G01010__AT1G01020__protein-protein-interaction_high-throughput_AraNet_v2__2.3", - "AT1G01010__AT1G01030__protein-protein-interaction_high-throughput_AraNet_v2__2.4", - "AT1G01010__AT1G01040__domain-co-occurrence_AraNet_v2__2.5", - "AT1G01010__AT1G01040__protein-protein-interaction_literature-curation_AraNet_v2__170.5", - "AT1G01030__AT1G01050__pairwise-gene-coexpression_AraNet_v2__2.6", - "AT1G01050__AT1G01060__protein-protein-interaction_literature-curation_AraNet_v2__2.7" + "As2__AT1G01020__phenotype-association_AraGWAS__False__8.4", + "As2__AT1G01040__phenotype-association_AraGWAS__False__5.4", + "As75__AT1G01020__phenotype-association_AraGWAS__False__39.9", + "AT1G01010__AT1G01020__protein-protein-interaction_high-throughput_AraNet_v2__False__2.3", + "AT1G01010__AT1G01030__protein-protein-interaction_high-throughput_AraNet_v2__False__2.4", + "AT1G01010__AT1G01040__domain-co-occurrence_AraNet_v2__False__2.5", + "AT1G01010__AT1G01040__protein-protein-interaction_literature-curation_AraNet_v2__False__170.5", + "AT1G01030__AT1G01050__pairwise-gene-coexpression_AraNet_v2__False__2.6", + "AT1G01050__AT1G01060__protein-protein-interaction_literature-curation_AraNet_v2__False__2.7" ] } }, @@ -446,8 +550,8 @@ "results": { "nodes": ["As2", "Na23", "AT1G01020", "AT1G01040"], "edges": [ - "As2__AT1G01020__phenotype-association_AraGWAS__8.4", - "As2__AT1G01040__phenotype-association_AraGWAS__5.4" + "As2__AT1G01020__phenotype-association_AraGWAS__False__8.4", + "As2__AT1G01040__phenotype-association_AraGWAS__False__5.4" ] } }, @@ -456,15 +560,15 @@ "results": { "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060", "Na23"], "edges": [ - "As2__AT1G01020__phenotype-association_AraGWAS__8.4", - "As2__AT1G01040__phenotype-association_AraGWAS__5.4", - "As75__AT1G01020__phenotype-association_AraGWAS__39.9", - "AT1G01010__AT1G01020__protein-protein-interaction_high-throughput_AraNet_v2__2.3", - "AT1G01010__AT1G01030__protein-protein-interaction_high-throughput_AraNet_v2__2.4", - "AT1G01010__AT1G01040__domain-co-occurrence_AraNet_v2__2.5", - "AT1G01010__AT1G01040__protein-protein-interaction_literature-curation_AraNet_v2__170.5", - "AT1G01030__AT1G01050__pairwise-gene-coexpression_AraNet_v2__2.6", - "AT1G01050__AT1G01060__protein-protein-interaction_literature-curation_AraNet_v2__2.7" + "As2__AT1G01020__phenotype-association_AraGWAS__False__8.4", + "As2__AT1G01040__phenotype-association_AraGWAS__False__5.4", + "As75__AT1G01020__phenotype-association_AraGWAS__False__39.9", + "AT1G01010__AT1G01020__protein-protein-interaction_high-throughput_AraNet_v2__False__2.3", + "AT1G01010__AT1G01030__protein-protein-interaction_high-throughput_AraNet_v2__False__2.4", + "AT1G01010__AT1G01040__domain-co-occurrence_AraNet_v2__False__2.5", + "AT1G01010__AT1G01040__protein-protein-interaction_literature-curation_AraNet_v2__False__170.5", + "AT1G01030__AT1G01050__pairwise-gene-coexpression_AraNet_v2__False__2.6", + "AT1G01050__AT1G01060__protein-protein-interaction_literature-curation_AraNet_v2__False__2.7" ] } }, @@ -495,9 +599,9 @@ "results": { "nodes": ["As2", "As75", "AT1G01020", "AT1G01040", "Na23"], "edges": [ - "As2__AT1G01020__phenotype-association_AraGWAS__8.4", - "As2__AT1G01040__phenotype-association_AraGWAS__5.4", - "As75__AT1G01020__phenotype-association_AraGWAS__39.9" + "As2__AT1G01020__phenotype-association_AraGWAS__False__8.4", + "As2__AT1G01040__phenotype-association_AraGWAS__False__5.4", + "As75__AT1G01020__phenotype-association_AraGWAS__False__39.9" ] } } @@ -545,10 +649,10 @@ "results": { "nodes": ["As2", "AT1G01010", "AT1G01040", "AT1G01080", "AT1G01090"], "edges": [ - "As2__AT1G01040__phenotype-association_AraGWAS__5.4", - "AT1G01010__AT1G01040__domain-co-occurrence_AraNet_v2__2.5", - "AT1G01010__AT1G01040__protein-protein-interaction_literature-curation_AraNet_v2__170.5", - "AT1G01080__AT1G01090__protein-protein-interaction_literature-curation_AraNet_v2__2.8" + "As2__AT1G01040__phenotype-association_AraGWAS__False__5.4", + "AT1G01010__AT1G01040__domain-co-occurrence_AraNet_v2__False__2.5", + "AT1G01010__AT1G01040__protein-protein-interaction_literature-curation_AraNet_v2__False__170.5", + "AT1G01080__AT1G01090__protein-protein-interaction_literature-curation_AraNet_v2__False__2.8" ] } }, @@ -557,16 +661,16 @@ "results": { "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060", "AT1G01080", "AT1G01090"], "edges": [ - "As2__AT1G01020__phenotype-association_AraGWAS__8.4", - "As2__AT1G01040__phenotype-association_AraGWAS__5.4", - "As75__AT1G01020__phenotype-association_AraGWAS__39.9", - "AT1G01010__AT1G01020__protein-protein-interaction_high-throughput_AraNet_v2__2.3", - "AT1G01010__AT1G01030__protein-protein-interaction_high-throughput_AraNet_v2__2.4", - "AT1G01010__AT1G01040__domain-co-occurrence_AraNet_v2__2.5", - "AT1G01010__AT1G01040__protein-protein-interaction_literature-curation_AraNet_v2__170.5", - "AT1G01030__AT1G01050__pairwise-gene-coexpression_AraNet_v2__2.6", - "AT1G01050__AT1G01060__protein-protein-interaction_literature-curation_AraNet_v2__2.7", - "AT1G01080__AT1G01090__protein-protein-interaction_literature-curation_AraNet_v2__2.8" + "As2__AT1G01020__phenotype-association_AraGWAS__False__8.4", + "As2__AT1G01040__phenotype-association_AraGWAS__False__5.4", + "As75__AT1G01020__phenotype-association_AraGWAS__False__39.9", + "AT1G01010__AT1G01020__protein-protein-interaction_high-throughput_AraNet_v2__False__2.3", + "AT1G01010__AT1G01030__protein-protein-interaction_high-throughput_AraNet_v2__False__2.4", + "AT1G01010__AT1G01040__domain-co-occurrence_AraNet_v2__False__2.5", + "AT1G01010__AT1G01040__protein-protein-interaction_literature-curation_AraNet_v2__False__170.5", + "AT1G01030__AT1G01050__pairwise-gene-coexpression_AraNet_v2__False__2.6", + "AT1G01050__AT1G01060__protein-protein-interaction_literature-curation_AraNet_v2__False__2.7", + "AT1G01080__AT1G01090__protein-protein-interaction_literature-curation_AraNet_v2__False__2.8" ] } }, @@ -582,7 +686,7 @@ "results": { "nodes": ["As2", "AT1G01040", "AT1G01090"], "edges": [ - "As2__AT1G01040__phenotype-association_AraGWAS__5.4" + "As2__AT1G01040__phenotype-association_AraGWAS__False__5.4" ] } }, @@ -591,9 +695,9 @@ "results": { "nodes": ["As2", "As75", "AT1G01020", "AT1G01040", "AT1G01090"], "edges": [ - "As2__AT1G01020__phenotype-association_AraGWAS__8.4", - "As2__AT1G01040__phenotype-association_AraGWAS__5.4", - "As75__AT1G01020__phenotype-association_AraGWAS__39.9" + "As2__AT1G01020__phenotype-association_AraGWAS__False__8.4", + "As2__AT1G01040__phenotype-association_AraGWAS__False__5.4", + "As75__AT1G01020__phenotype-association_AraGWAS__False__39.9" ] } } @@ -650,10 +754,10 @@ "results": { "nodes": ["As2", "AT1G01010", "AT1G01040", "AT1G01080", "AT1G01090"], "edges": [ - "As2__AT1G01040__phenotype-association_AraGWAS__5.4", - "AT1G01010__AT1G01040__domain-co-occurrence_AraNet_v2__2.5", - "AT1G01010__AT1G01040__protein-protein-interaction_literature-curation_AraNet_v2__170.5", - "AT1G01080__AT1G01090__protein-protein-interaction_literature-curation_AraNet_v2__2.8" + "As2__AT1G01040__phenotype-association_AraGWAS__False__5.4", + "AT1G01010__AT1G01040__domain-co-occurrence_AraNet_v2__False__2.5", + "AT1G01010__AT1G01040__protein-protein-interaction_literature-curation_AraNet_v2__False__170.5", + "AT1G01080__AT1G01090__protein-protein-interaction_literature-curation_AraNet_v2__False__2.8" ] } }, @@ -662,16 +766,16 @@ "results": { "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060", "AT1G01080", "AT1G01090"], "edges": [ - "As2__AT1G01020__phenotype-association_AraGWAS__8.4", - "As2__AT1G01040__phenotype-association_AraGWAS__5.4", - "As75__AT1G01020__phenotype-association_AraGWAS__39.9", - "AT1G01010__AT1G01020__protein-protein-interaction_high-throughput_AraNet_v2__2.3", - "AT1G01010__AT1G01030__protein-protein-interaction_high-throughput_AraNet_v2__2.4", - "AT1G01010__AT1G01040__domain-co-occurrence_AraNet_v2__2.5", - "AT1G01010__AT1G01040__protein-protein-interaction_literature-curation_AraNet_v2__170.5", - "AT1G01030__AT1G01050__pairwise-gene-coexpression_AraNet_v2__2.6", - "AT1G01050__AT1G01060__protein-protein-interaction_literature-curation_AraNet_v2__2.7", - "AT1G01080__AT1G01090__protein-protein-interaction_literature-curation_AraNet_v2__2.8" + "As2__AT1G01020__phenotype-association_AraGWAS__False__8.4", + "As2__AT1G01040__phenotype-association_AraGWAS__False__5.4", + "As75__AT1G01020__phenotype-association_AraGWAS__False__39.9", + "AT1G01010__AT1G01020__protein-protein-interaction_high-throughput_AraNet_v2__False__2.3", + "AT1G01010__AT1G01030__protein-protein-interaction_high-throughput_AraNet_v2__False__2.4", + "AT1G01010__AT1G01040__domain-co-occurrence_AraNet_v2__False__2.5", + "AT1G01010__AT1G01040__protein-protein-interaction_literature-curation_AraNet_v2__False__170.5", + "AT1G01030__AT1G01050__pairwise-gene-coexpression_AraNet_v2__False__2.6", + "AT1G01050__AT1G01060__protein-protein-interaction_literature-curation_AraNet_v2__False__2.7", + "AT1G01080__AT1G01090__protein-protein-interaction_literature-curation_AraNet_v2__False__2.8" ] } }, @@ -694,9 +798,9 @@ "results": { "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01070"], "edges": [ - "As2__AT1G01020__phenotype-association_AraGWAS__8.4", - "As75__AT1G01020__phenotype-association_AraGWAS__39.9", - "AT1G01010__AT1G01020__protein-protein-interaction_high-throughput_AraNet_v2__2.3" + "As2__AT1G01020__phenotype-association_AraGWAS__False__8.4", + "As75__AT1G01020__phenotype-association_AraGWAS__False__39.9", + "AT1G01010__AT1G01020__protein-protein-interaction_high-throughput_AraNet_v2__False__2.3" ] } }, @@ -705,15 +809,15 @@ "results": { "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060", "AT1G01070"], "edges": [ - "As2__AT1G01020__phenotype-association_AraGWAS__8.4", - "As2__AT1G01040__phenotype-association_AraGWAS__5.4", - "As75__AT1G01020__phenotype-association_AraGWAS__39.9", - "AT1G01010__AT1G01020__protein-protein-interaction_high-throughput_AraNet_v2__2.3", - "AT1G01010__AT1G01030__protein-protein-interaction_high-throughput_AraNet_v2__2.4", - "AT1G01010__AT1G01040__domain-co-occurrence_AraNet_v2__2.5", - "AT1G01010__AT1G01040__protein-protein-interaction_literature-curation_AraNet_v2__170.5", - "AT1G01030__AT1G01050__pairwise-gene-coexpression_AraNet_v2__2.6", - "AT1G01050__AT1G01060__protein-protein-interaction_literature-curation_AraNet_v2__2.7" + "As2__AT1G01020__phenotype-association_AraGWAS__False__8.4", + "As2__AT1G01040__phenotype-association_AraGWAS__False__5.4", + "As75__AT1G01020__phenotype-association_AraGWAS__False__39.9", + "AT1G01010__AT1G01020__protein-protein-interaction_high-throughput_AraNet_v2__False__2.3", + "AT1G01010__AT1G01030__protein-protein-interaction_high-throughput_AraNet_v2__False__2.4", + "AT1G01010__AT1G01040__domain-co-occurrence_AraNet_v2__False__2.5", + "AT1G01010__AT1G01040__protein-protein-interaction_literature-curation_AraNet_v2__False__170.5", + "AT1G01030__AT1G01050__pairwise-gene-coexpression_AraNet_v2__False__2.6", + "AT1G01050__AT1G01060__protein-protein-interaction_literature-curation_AraNet_v2__False__2.7" ] } }, @@ -737,7 +841,7 @@ "results": { "nodes": ["AT1G01010", "AT1G01020", "AT1G01070"], "edges": [ - "AT1G01010__AT1G01020__protein-protein-interaction_high-throughput_AraNet_v2__2.3" + "AT1G01010__AT1G01020__protein-protein-interaction_high-throughput_AraNet_v2__False__2.3" ] } }, @@ -750,8 +854,8 @@ "results": { "nodes": ["AT1G01010", "AT1G01020", "AT1G01030", "AT1G01070"], "edges": [ - "AT1G01010__AT1G01020__protein-protein-interaction_high-throughput_AraNet_v2__2.3", - "AT1G01010__AT1G01030__protein-protein-interaction_high-throughput_AraNet_v2__2.4" + "AT1G01010__AT1G01020__protein-protein-interaction_high-throughput_AraNet_v2__False__2.3", + "AT1G01010__AT1G01030__protein-protein-interaction_high-throughput_AraNet_v2__False__2.4" ] } }, @@ -769,14 +873,14 @@ "results": { "nodes": ["As2", "As75", "AT1G01010", "AT1G01020", "AT1G01030", "AT1G01040", "AT1G01050", "AT1G01060", "AT1G01070"], "edges": [ - "As2__AT1G01020__phenotype-association_AraGWAS__8.4", - "As2__AT1G01040__phenotype-association_AraGWAS__5.4", - "As75__AT1G01020__phenotype-association_AraGWAS__39.9", - "AT1G01010__AT1G01020__protein-protein-interaction_high-throughput_AraNet_v2__2.3", - "AT1G01010__AT1G01030__protein-protein-interaction_high-throughput_AraNet_v2__2.4", - "AT1G01010__AT1G01040__protein-protein-interaction_literature-curation_AraNet_v2__170.5", - "AT1G01030__AT1G01050__pairwise-gene-coexpression_AraNet_v2__2.6", - "AT1G01050__AT1G01060__protein-protein-interaction_literature-curation_AraNet_v2__2.7" + "As2__AT1G01020__phenotype-association_AraGWAS__False__8.4", + "As2__AT1G01040__phenotype-association_AraGWAS__False__5.4", + "As75__AT1G01020__phenotype-association_AraGWAS__False__39.9", + "AT1G01010__AT1G01020__protein-protein-interaction_high-throughput_AraNet_v2__False__2.3", + "AT1G01010__AT1G01030__protein-protein-interaction_high-throughput_AraNet_v2__False__2.4", + "AT1G01010__AT1G01040__protein-protein-interaction_literature-curation_AraNet_v2__False__170.5", + "AT1G01030__AT1G01050__pairwise-gene-coexpression_AraNet_v2__False__2.6", + "AT1G01050__AT1G01060__protein-protein-interaction_literature-curation_AraNet_v2__False__2.7" ] } } diff --git a/spec/test/djornl/test_data/directed_edges.tsv b/spec/test/djornl/test_data/directed_edges.tsv new file mode 100644 index 00000000..e3d20071 --- /dev/null +++ b/spec/test/djornl/test_data/directed_edges.tsv @@ -0,0 +1,4 @@ +node1 node2 score edge_descrip edge_type directed +SDV AT1G01100 8.4 AraGWAS-Association_score protein-protein-interaction_literature-curation_AraNet_v2 0 +SDV AT1G01100 5.4 AraGWAS-Association_score protein-protein-interaction_literature-curation_AraNet_v2 1 +AT1G01100 SDV 2.4 AraGWAS-Association_score protein-protein-interaction_literature-curation_AraNet_v2 1 diff --git a/spec/test/djornl/test_data/hithruput-edges.csv b/spec/test/djornl/test_data/hithruput-edges.csv index fc27ac76..79a7deba 100644 --- a/spec/test/djornl/test_data/hithruput-edges.csv +++ b/spec/test/djornl/test_data/hithruput-edges.csv @@ -1,3 +1,3 @@ -node1,node2,score,edge_descrip,edge_type -AT1G01010,AT1G01020,2.3,AraNetv2_log-likelihood-score,protein-protein-interaction_high-throughput_AraNet_v2 -AT1G01010,AT1G01030,2.4,AraNetv2_log-likelihood-score,protein-protein-interaction_high-throughput_AraNet_v2 +node1,node2,score,edge_descrip,edge_type,directed +AT1G01010,AT1G01020,2.3,AraNetv2_log-likelihood-score,protein-protein-interaction_high-throughput_AraNet_v2,0 +AT1G01010,AT1G01030,2.4,AraNetv2_log-likelihood-score,protein-protein-interaction_high-throughput_AraNet_v2,0 diff --git a/spec/test/djornl/test_data/manifest.yaml b/spec/test/djornl/test_data/manifest.yaml index 1762a86d..2d3d63e2 100644 --- a/spec/test/djornl/test_data/manifest.yaml +++ b/spec/test/djornl/test_data/manifest.yaml @@ -10,6 +10,10 @@ file_list: path: hithruput-edges.csv date: "2020-12-25" + - data_type: edge + path: directed_edges.tsv + date: "2020-12-25" + - data_type: node path: nodes.csv date: "2019-01-01" diff --git a/spec/test/djornl/test_data/nodes.csv b/spec/test/djornl/test_data/nodes.csv index 678a6657..eef9e060 100644 --- a/spec/test/djornl/test_data/nodes.csv +++ b/spec/test/djornl/test_data/nodes.csv @@ -1,11 +1,11 @@ # data_type: node -node_id,node_type,transcript,gene_symbol,gene_full_name,gene_model_type,TAIR_Computational_description,TAIR_Curator_summary,TAIR_short_description,GO_description,GO_terms,MapMan_bin,MapMan_name,MapMan_description,pheno_AraGWAS_ID,pheno_description,pheno_pto_name,pheno_pto_description,pheno_reference,User_Notes -AT1G01010,gene,AT1G01010.1,NTL10,NAC domain containing protein 1,protein_coding,NAC domain containing protein 1;(source:Araport11),,NAC domain containing protein 1,"DNA-binding transcription factor activity, DNA binding","GO:0003700, GO:0003677",15.5.17,.RNA biosynthesis.transcriptional regulation.transcription factor (NAC),transcription factor (NAC) (original description: pep chromosome:TAIR10:1:3631:5899:1 gene:AT1G01010 transcript:AT1G01010.1 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:NAC001 description:NAC domain-containing protein 1 [Source:UniProtKB/Swiss-Prot;Acc:Q0WV96]),,,,,, -AT1G01020,gene,AT1G01020.6,ARV1,,protein_coding,ARV1 family protein;(source:Araport11),,,molecular_function,GO:0003674,35.1,not assigned.annotated,(original description: pep chromosome:TAIR10:1:6788:8737:-1 gene:AT1G01020 transcript:AT1G01020.6 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:ARV1 description:ARV1 family protein [Source:UniProtKB/TrEMBL;Acc:Q5MK24]) & no description available(sp|q5mk24|arv1_arath : 99.4),,,,,, -AT1G01030,gene,AT1G01030.2,NGA3,NGATHA3,protein_coding,AP2/B3-like transcriptional factor family protein;(source:Araport11),,,"DNA-binding transcription factor activity, DNA binding","GO:0003700, GO:0003677",15.5.5.3,.RNA biosynthesis.transcriptional regulation.B3 transcription factor superfamily.transcription factor (RAV/NGATHA),transcription factor (RAV/NGATHA) (original description: pep chromosome:TAIR10:1:11649:13714:-1 gene:AT1G01030 transcript:AT1G01030.2 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:NGA3 description:B3 domain-containing transcription factor NGA3 [Source:UniProtKB/Swiss-Prot;Acc:Q9MAN1]),,,,,, -AT1G01040,gene,AT1G01040.2,SUS1,SUSPENSOR 1,protein_coding,dicer-like 1;(source:Araport11),"Encodes a Dicer homolog. Dicer is a RNA helicase involved in microRNA processing. Mutations in this locus can result in embryo lethality. Embryo shape at seed maturity is globular-elongate. Other mutants convert the floral meristems to an indeterminate state, others yet show defects in ovule development. mRNA is expressed in all shoot tissues. DCL1 is able to produce miRNAs and siRNAs. The mRNA is cell-to-cell mobile.",dicer-like 1,"metal ion binding, protein binding, ribonuclease III activity, ATP-dependent helicase activity, ATP binding, RNA binding, helicase activity, double-stranded RNA binding, DNA binding","GO:0046872, GO:0005515, GO:0004525, GO:0008026, GO:0005524, GO:0003723, GO:0004386, GO:0003725, GO:0003677",16.10.2.1.1,.RNA processing.mRNA silencing.miRNA pathway.DCL1-HYL1 miRNA biogenesis complex.endoribonuclease component DCL1,endoribonuclease component DCL1 of DCL1-HYL1 miRNA biogenesis complex (original description: pep chromosome:TAIR10:1:23416:31120:1 gene:AT1G01040 transcript:AT1G01040.2 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:DCL1 description:Dicer-like 1 [Source:UniProtKB/TrEMBL;Acc:F4HQG6]),,,,,, -AT1G01050,gene,AT1G01050.2,PPa1,pyrophosphorylase 1,protein_coding,pyrophosphorylase 1;(source:Araport11),,,inorganic diphosphatase activity,GO:0004427,35.1,not assigned.annotated,(original description: pep chromosome:TAIR10:1:31382:33009:-1 gene:AT1G01050 transcript:AT1G01050.2 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:PPA1 description:Soluble inorganic pyrophosphatase 1 [Source:UniProtKB/Swiss-Prot;Acc:Q93V56]) & Soluble inorganic pyrophosphatase 1 OS=Arabidopsis thaliana (sp|q93v56|ipyr1_arath : 419.0),,,,,, -AT1G01060,gene,AT1G01060.8,LHY1,LATE ELONGATED HYPOCOTYL 1,protein_coding,Homeodomain-like superfamily protein;(source:Araport11),,,"DNA-binding transcription factor activity, DNA binding, transcription regulatory region DNA binding","GO:0003700, GO:0003677, GO:0044212",27.1.1,.Multi-process regulation.circadian clock system.core oscillator protein (LHY|CCA1),circadian clock core oscillator protein (LHY|CCA1) (original description: pep chromosome:TAIR10:1:33967:37230:-1 gene:AT1G01060 transcript:AT1G01060.8 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:LHY description:LHY1 [Source:UniProtKB/TrEMBL;Acc:A0A178W761]),,,,,, -AT1G01070,gene,AT1G01070.2,UMAMIT28,Usually multiple acids move in and out Transporters 28,protein_coding,nodulin MtN21 /EamA-like transporter family protein;(source:Araport11),Encodes a plasma membrane-localized amino acid transporter likely involved in amino acid export in the developing seed.,nodulin MtN21 /EamA-like transporter family protein,L-glutamine transmembrane transporter activity,GO:0015186,24.2.1.5,.Solute transport.carrier-mediated transport.DMT superfamily.solute transporter (UmamiT),solute transporter (UmamiT) (original description: pep chromosome:TAIR10:1:38752:40945:-1 gene:AT1G01070 transcript:AT1G01070.2 gene_biotype:protein_coding transcript_biotype:protein_coding description:WAT1-related protein [Source:UniProtKB/TrEMBL;Acc:A0A178WFU3]),,,,,, -AT1G01080,gene,AT1G01080.3,,,protein_coding,RNA-binding (RRM/RBD/RNP motifs) family protein;(source:Araport11),,,"RNA binding, mRNA binding","GO:0003723, GO:0003729",35.1,not assigned.annotated,"(original description: pep chromosome:TAIR10:1:44970:47059:-1 gene:AT1G01080 transcript:AT1G01080.3 gene_biotype:protein_coding transcript_biotype:protein_coding description:RNA-binding (RRM/RBD/RNP motifs) family protein [Source:UniProtKB/TrEMBL;Acc:F4HQH8]) & 33 kDa ribonucleoprotein, chloroplastic OS=Nicotiana sylvestris (sp|p19684|roc5_nicsy : 109.0)",,,,,, -AT1G01090,gene,AT1G01090.1,PDH-E1 ALPHA,pyruvate dehydrogenase E1 alpha,protein_coding,pyruvate dehydrogenase E1 alpha;(source:Araport11),pyruvate dehydrogenase E1 alpha subunit,pyruvate dehydrogenase E1 alpha,"pyruvate dehydrogenase (acetyl-transferring) activity, protein binding","GO:0004739, GO:0005515",5.1.2.2.1.1,.Lipid metabolism.fatty acid biosynthesis.acetyl-CoA generation.plastidial pyruvate dehydrogenase complex.E1 pyruvate dehydrogenase subcomplex.subunit alpha,subunit alpha of E1 pyruvate dehydrogenase component (original description: pep chromosome:TAIR10:1:47234:49304:-1 gene:AT1G01090 transcript:AT1G01090.1 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:PDH-E1 ALPHA description:Pyruvate dehydrogenase E1 component subunit alpha [Source:UniProtKB/TrEMBL;Acc:A0A178W8A7]),,,,,, +User_Notes,node_id,node_type,transcript,gene_symbol,gene_full_name,gene_model_type,TAIR_Computational_description,TAIR_Curator_summary,TAIR_short_description,GO_description,GO_terms,MapMan_bin,MapMan_name,MapMan_description,pheno_AraGWAS_ID,pheno_description,pheno_pto_name,pheno_pto_description,pheno_reference +,AT1G01010,gene,AT1G01010.1,NTL10,NAC domain containing protein 1,protein_coding,NAC domain containing protein 1;(source:Araport11),,NAC domain containing protein 1,"DNA-binding transcription factor activity, DNA binding","GO:0003700, GO:0003677",15.5.17,.RNA biosynthesis.transcriptional regulation.transcription factor (NAC),transcription factor (NAC) (original description: pep chromosome:TAIR10:1:3631:5899:1 gene:AT1G01010 transcript:AT1G01010.1 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:NAC001 description:NAC domain-containing protein 1 [Source:UniProtKB/Swiss-Prot;Acc:Q0WV96]),,,,, +,AT1G01020,gene,AT1G01020.6,ARV1,,protein_coding,ARV1 family protein;(source:Araport11),,,molecular_function,GO:0003674,35.1,not assigned.annotated,(original description: pep chromosome:TAIR10:1:6788:8737:-1 gene:AT1G01020 transcript:AT1G01020.6 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:ARV1 description:ARV1 family protein [Source:UniProtKB/TrEMBL;Acc:Q5MK24]) & no description available(sp|q5mk24|arv1_arath : 99.4),,,,, +,AT1G01030,gene,AT1G01030.2,NGA3,NGATHA3,protein_coding,AP2/B3-like transcriptional factor family protein;(source:Araport11),,,"DNA-binding transcription factor activity, DNA binding","GO:0003700, GO:0003677",15.5.5.3,.RNA biosynthesis.transcriptional regulation.B3 transcription factor superfamily.transcription factor (RAV/NGATHA),transcription factor (RAV/NGATHA) (original description: pep chromosome:TAIR10:1:11649:13714:-1 gene:AT1G01030 transcript:AT1G01030.2 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:NGA3 description:B3 domain-containing transcription factor NGA3 [Source:UniProtKB/Swiss-Prot;Acc:Q9MAN1]),,,,, +,AT1G01040,gene,AT1G01040.2,SUS1,SUSPENSOR 1,protein_coding,dicer-like 1;(source:Araport11),"Encodes a Dicer homolog. Dicer is a RNA helicase involved in microRNA processing. Mutations in this locus can result in embryo lethality. Embryo shape at seed maturity is globular-elongate. Other mutants convert the floral meristems to an indeterminate state, others yet show defects in ovule development. mRNA is expressed in all shoot tissues. DCL1 is able to produce miRNAs and siRNAs. The mRNA is cell-to-cell mobile.",dicer-like 1,"metal ion binding, protein binding, ribonuclease III activity, ATP-dependent helicase activity, ATP binding, RNA binding, helicase activity, double-stranded RNA binding, DNA binding","GO:0046872, GO:0005515, GO:0004525, GO:0008026, GO:0005524, GO:0003723, GO:0004386, GO:0003725, GO:0003677",16.10.2.1.1,.RNA processing.mRNA silencing.miRNA pathway.DCL1-HYL1 miRNA biogenesis complex.endoribonuclease component DCL1,endoribonuclease component DCL1 of DCL1-HYL1 miRNA biogenesis complex (original description: pep chromosome:TAIR10:1:23416:31120:1 gene:AT1G01040 transcript:AT1G01040.2 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:DCL1 description:Dicer-like 1 [Source:UniProtKB/TrEMBL;Acc:F4HQG6]),,,,, +,AT1G01050,gene,AT1G01050.2,PPa1,pyrophosphorylase 1,protein_coding,pyrophosphorylase 1;(source:Araport11),,,inorganic diphosphatase activity,GO:0004427,35.1,not assigned.annotated,(original description: pep chromosome:TAIR10:1:31382:33009:-1 gene:AT1G01050 transcript:AT1G01050.2 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:PPA1 description:Soluble inorganic pyrophosphatase 1 [Source:UniProtKB/Swiss-Prot;Acc:Q93V56]) & Soluble inorganic pyrophosphatase 1 OS=Arabidopsis thaliana (sp|q93v56|ipyr1_arath : 419.0),,,,, +,AT1G01060,gene,AT1G01060.8,LHY1,LATE ELONGATED HYPOCOTYL 1,protein_coding,Homeodomain-like superfamily protein;(source:Araport11),,,"DNA-binding transcription factor activity, DNA binding, transcription regulatory region DNA binding","GO:0003700, GO:0003677, GO:0044212",27.1.1,.Multi-process regulation.circadian clock system.core oscillator protein (LHY|CCA1),circadian clock core oscillator protein (LHY|CCA1) (original description: pep chromosome:TAIR10:1:33967:37230:-1 gene:AT1G01060 transcript:AT1G01060.8 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:LHY description:LHY1 [Source:UniProtKB/TrEMBL;Acc:A0A178W761]),,,,, +,AT1G01070,gene,AT1G01070.2,UMAMIT28,Usually multiple acids move in and out Transporters 28,protein_coding,nodulin MtN21 /EamA-like transporter family protein;(source:Araport11),Encodes a plasma membrane-localized amino acid transporter likely involved in amino acid export in the developing seed.,nodulin MtN21 /EamA-like transporter family protein,L-glutamine transmembrane transporter activity,GO:0015186,24.2.1.5,.Solute transport.carrier-mediated transport.DMT superfamily.solute transporter (UmamiT),solute transporter (UmamiT) (original description: pep chromosome:TAIR10:1:38752:40945:-1 gene:AT1G01070 transcript:AT1G01070.2 gene_biotype:protein_coding transcript_biotype:protein_coding description:WAT1-related protein [Source:UniProtKB/TrEMBL;Acc:A0A178WFU3]),,,,, +,AT1G01080,gene,AT1G01080.3,,,protein_coding,RNA-binding (RRM/RBD/RNP motifs) family protein;(source:Araport11),,,"RNA binding, mRNA binding","GO:0003723, GO:0003729",35.1,not assigned.annotated,"(original description: pep chromosome:TAIR10:1:44970:47059:-1 gene:AT1G01080 transcript:AT1G01080.3 gene_biotype:protein_coding transcript_biotype:protein_coding description:RNA-binding (RRM/RBD/RNP motifs) family protein [Source:UniProtKB/TrEMBL;Acc:F4HQH8]) & 33 kDa ribonucleoprotein, chloroplastic OS=Nicotiana sylvestris (sp|p19684|roc5_nicsy : 109.0)",,,,, +,AT1G01090,gene,AT1G01090.1,PDH-E1 ALPHA,pyruvate dehydrogenase E1 alpha,protein_coding,pyruvate dehydrogenase E1 alpha;(source:Araport11),pyruvate dehydrogenase E1 alpha subunit,pyruvate dehydrogenase E1 alpha,"pyruvate dehydrogenase (acetyl-transferring) activity, protein binding","GO:0004739, GO:0005515",5.1.2.2.1.1,.Lipid metabolism.fatty acid biosynthesis.acetyl-CoA generation.plastidial pyruvate dehydrogenase complex.E1 pyruvate dehydrogenase subcomplex.subunit alpha,subunit alpha of E1 pyruvate dehydrogenase component (original description: pep chromosome:TAIR10:1:47234:49304:-1 gene:AT1G01090 transcript:AT1G01090.1 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:PDH-E1 ALPHA description:Pyruvate dehydrogenase E1 component subunit alpha [Source:UniProtKB/TrEMBL;Acc:A0A178W8A7]),,,,, From c6ddf99709ec169efcfca85d32015d4d1f59846a Mon Sep 17 00:00:00 2001 From: ialarmedalien Date: Thu, 19 Nov 2020 11:27:03 -0800 Subject: [PATCH 629/732] Upping the version and updating the changelog --- CHANGELOG.md | 5 +++++ VERSION | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 58162e35..2993cc02 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.0.11] - 2020-11-19 +### Changed +- DJORNL edge spec (`spec/collections/djornl/djornl_edge.yaml``) updated to indicate whether or not the edge is directed. +- DJORNL parser and test suite updated accordingly. + ## [0.0.10] - 2020-10-08 ### Changed - Clean up some of the configuration logic, and add the `SPEC_REPO_URL` env var instead of hard-coding diff --git a/VERSION b/VERSION index 7c1886bb..2cfabea2 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.0.10 +0.0.11 From b224bf49a88ee9f6d0a1ca5feb14d3a0a7705324 Mon Sep 17 00:00:00 2001 From: Dakota Blair Date: Fri, 20 Nov 2020 13:55:50 -0500 Subject: [PATCH 630/732] Add --dry-run command line parameter. This commit fixes issue #56 by adding the --dry-run parameter to validate the input data and print an output summary even in the presence of errors. To this end, the --output parameter is also introduced to give an option to display the summary as JSON or in a more user-friendly text format. Data should not be loaded if there are errors or if this command is invoked with --dry-run. --- importers/djornl/parser.py | 159 ++++++++++++++---- importers/test/test_djornl_parser.py | 10 +- .../test/test_djornl_parser_integration.py | 2 +- 3 files changed, 129 insertions(+), 42 deletions(-) diff --git a/importers/djornl/parser.py b/importers/djornl/parser.py index b1d0de27..9b7474d4 100644 --- a/importers/djornl/parser.py +++ b/importers/djornl/parser.py @@ -15,10 +15,11 @@ RES_ROOT_DATA_PATH=/path/to/data/dir python -m importers.djornl.parser """ +import argparse +import csv import json -import requests import os -import csv +import requests import yaml import importers.utils.config as config @@ -132,11 +133,9 @@ def _get_file_reader(self, fd, file): """Given a dict containing file information, instantiate the correct type of parser""" delimiter = "\t" - if ( - "file_format" in file - and file["file_format"].lower() == "csv" - or file["path"].lower().endswith(".csv") - ): + if file.get("file_format", "").lower() == "csv" or file[ + "path" + ].lower().endswith(".csv"): delimiter = "," return csv.reader(fd, delimiter=delimiter) @@ -181,8 +180,8 @@ def check_headers(self, headers, validator=None): :return header_errs: (dict) dict of header errors: 'missing': required headers that are missing from the input - 'invalid': additional headers that should not be in the input - 'duplicate': duplicated headers (content would be overwritten) + 'invalid': headers that should not be in the input + 'duplicate': duplicated headers (data would be overwritten) If the list of headers supplied is valid--i.e. it contains all the fields marked as required in the validator schema--or no validator has been supplied, the method @@ -212,10 +211,7 @@ def check_headers(self, headers, validator=None): if missing_headers: header_errs["missing"] = missing_headers - if ( - "additionalProperties" in validator.schema - and validator.schema["additionalProperties"] is False - ): + if not validator.schema.get("additionalProperties", True): all_props = validator.schema["properties"].keys() extra_headers = [i for i in headers if i not in all_props] if extra_headers: @@ -276,11 +272,16 @@ def process_file(self, file, remap_fn, store_fn, err_list, validator=None): """ print("Parsing " + file["data_type"] + " file " + file["file_path"]) file_parser = self.parser_gen(file) + + def add_error(error): + print(error) + err_list.append(error) + try: (line_no, cols, err_str) = next(file_parser) except StopIteration: # no valid lines found in the file - err_list.append(f"{file['path']}: no header line found") + add_error(f"{file['path']}: no header line found") return header_errors = self.check_headers(cols, validator) @@ -292,7 +293,7 @@ def process_file(self, file, remap_fn, store_fn, err_list, validator=None): } for err_type in ["missing", "invalid", "duplicate"]: if err_type in header_errors: - err_list.append( + add_error( f"{file['path']}: {err_str[err_type]} headers: " + ", ".join(sorted(header_errors[err_type])) ) @@ -303,7 +304,7 @@ def process_file(self, file, remap_fn, store_fn, err_list, validator=None): for (line_no, cols, err_str) in file_parser: # mismatch in number of cols if cols is None: - err_list.append(err_str) + add_error(err_str) continue # merge headers with cols to create an object @@ -313,7 +314,7 @@ def process_file(self, file, remap_fn, store_fn, err_list, validator=None): # validate the object if not validator.is_valid(row_object): for e in sorted(validator.iter_errors(row_object), key=str): - err_list.append(f"{file['path']} line {line_no}: " + e.message) + add_error(f"{file['path']} line {line_no}: " + e.message) continue try: @@ -321,7 +322,7 @@ def process_file(self, file, remap_fn, store_fn, err_list, validator=None): datum = self.remap_object(row_object, remap_fn) except Exception as err: err_type = type(err) - err_list.append( + add_error( f"{file['path']} line {line_no}: error remapping data: {err_type} {err}" ) continue @@ -331,16 +332,16 @@ def process_file(self, file, remap_fn, store_fn, err_list, validator=None): if storage_error is None: n_stored += 1 else: - err_list.append(f"{file['path']} line {line_no}: " + storage_error) + add_error(f"{file['path']} line {line_no}: " + storage_error) if not n_stored: - err_list.append(f"{file['path']}: no valid data found") + add_error(f"{file['path']}: no valid data found") def store_parsed_edge_data(self, datum): """ store node and edge data in the node (node_ix) and edge (edge_ix) indexes respectively - - Nodes are indexed by the '_key' attribute. Parsed edge data only contains node '_key' values. + Nodes are indexed by the '_key' attribute. + Parsed edge data only contains node '_key' values. Edges are indexed by the unique combination of the two node IDs, the edge type, and whether or not it is a directed edge. It is assumed that if there is more than one score for a given @@ -682,22 +683,18 @@ def load_data(self, dry_run=False): if output["err_list"]: all_errs = all_errs + output["err_list"] - if all_errs: - raise RuntimeError("\n".join(all_errs)) - - if dry_run: - # report stats on the data that has been gathered - return self.summarise_dataset() + # if there are no errors then save the dataset unless this is a dry run + if len(all_errs) == 0 and not dry_run: + self.save_dataset() - # otherwise, save the dataset - self.save_dataset() - return True + # report stats on the data that has been gathered + return self.summarise_dataset(all_errs) - def summarise_dataset(self): + def summarise_dataset(self, errs): """summarise the data that has been loaded""" # go through the node index, checking for nodes that only have one attribute ('_key') or - # were loaded from the clusters files, with their only attributes being '_key' and 'clusters' + # were loaded from the clusters files, with only '_key' and 'clusters' attributes node_type_ix = {"__NO_TYPE__": 0} node_data = {"key_only": [], "cluster": [], "full": []} @@ -739,13 +736,103 @@ def summarise_dataset(self): "cluster": len(node_data["cluster"]), "full": len(node_data["full"]), }, + "errors_total": len(errs), + "errors": errs, } -if __name__ == "__main__": +def format_summary(summary, output): + if output == "json": + return json.dumps(summary) + node_type_counts = [count for count in summary["node_type_count"].values()] + edge_type_counts = [count for count in summary["node_type_count"].values()] + values = ( + [ + summary["nodes_total"], + summary["edges_total"], + summary["nodes_in_edge"], + summary["node_data_available"]["key_only"], + summary["node_data_available"]["cluster"], + summary["node_data_available"]["full"], + summary.get("errors_total"), + ] + + node_type_counts + + edge_type_counts + ) + value_width = max([len(str(value)) for value in values]) + node_type_names = dict(__NO_TYPE__="No type") + node_types = "\n".join( + [ + ( + f"{count:{value_width}} {node_type_names.get(ntype, ntype)}".format( + value_width + ) + ) + for ntype, count in summary["node_type_count"].items() + ] + ) + edge_type_names = dict() + edge_types = "\n".join( + [ + ( + f"{count:{value_width}} {edge_type_names.get(etype, etype)}".format( + value_width + ) + ) + for etype, count in summary["edge_type_count"].items() + ] + ) + text_summary = f""" +{summary["nodes_total"]:{value_width}} Total nodes +{summary["edges_total"]:{value_width}} Total edges +{summary["nodes_in_edge"]:{value_width}} Nodes in edge +--- +Node Types +{node_types:{value_width}} +--- +Edge Types +{edge_types:{value_width}} +--- +Node data available +{summary["node_data_available"]["key_only"]:{value_width}} Key only +{summary["node_data_available"]["cluster"]:{value_width}} Cluster +{summary["node_data_available"]["full"]:{value_width}} Full +--- +{summary.get("errors_total"):{value_width}} Errors +""".format( + value_width + ) + return text_summary + + +def main(): + argparser = argparse.ArgumentParser(description="Load DJORNL data") + argparser.add_argument( + "--dry-run", + dest="dry", + action="store_true", + help="Perform all actions of the parser, except loading the data.", + ) + argparser.add_argument( + "--output", + default="text", + help="Specify the format of any output generated. (text or json)", + ) + args = argparser.parse_args() parser = DJORNL_Parser() + summary = dict() try: - parser.load_data() + summary = parser.load_data(dry_run=args.dry) except Exception as err: - print(err) + print("Unhandled exception", err) exit(1) + errors = summary.get("errors") + if summary: + print(format_summary(summary, args.output)) + if errors: + error_output = f"Aborted with {len(errors)} errors.\n" + raise RuntimeError(error_output) + + +if __name__ == "__main__": + main() diff --git a/importers/test/test_djornl_parser.py b/importers/test/test_djornl_parser.py index e2c7f665..79ec783d 100644 --- a/importers/test/test_djornl_parser.py +++ b/importers/test/test_djornl_parser.py @@ -52,11 +52,9 @@ def test_errors(self, parser=None, errs={}): with self.subTest(data_type="all types"): # test all errors - with self.assertRaisesRegex(RuntimeError, all_errs[0]) as cm: - parser.load_data() - exception = cm.exception - err_list = exception.split("\n") - self.assertEqual(err_list, all_errs) + summary = parser.load_data(dry_run=True) + err_list = summary["errors"] + self.assertEqual(err_list, all_errs) def test_missing_required_env_var(self): """test that the parser exits with code 1 if the RES_ROOT_DATA_PATH env var is not set""" @@ -331,6 +329,8 @@ def test_dry_run(self): "node_type_count": {"__NO_TYPE__": 0, "gene": 10, "pheno": 4}, "nodes_in_edge": 12, "nodes_total": 14, + "errors_total": 0, + "errors": [], }, output, ) diff --git a/importers/test/test_djornl_parser_integration.py b/importers/test/test_djornl_parser_integration.py index fb184684..d98ee1d9 100644 --- a/importers/test/test_djornl_parser_integration.py +++ b/importers/test/test_djornl_parser_integration.py @@ -25,4 +25,4 @@ def test_the_full_shebang(self): ): parser = DJORNL_Parser() parser.load_data() - self.assertEqual(True, parser.load_data()) + self.assertTrue(bool(parser.load_data())) From c8236ccae4e363098b97824772de264849fd6a2d Mon Sep 17 00:00:00 2001 From: Dakota Blair Date: Fri, 20 Nov 2020 14:14:55 -0500 Subject: [PATCH 631/732] Bumping flake8 max-complexity up to 20. --- scripts/run_tests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/run_tests.sh b/scripts/run_tests.sh index c9946b71..58bc1382 100644 --- a/scripts/run_tests.sh +++ b/scripts/run_tests.sh @@ -7,7 +7,7 @@ set -e tar czvf spec.tar.gz sample_spec_release) black . -flake8 --max-complexity 15 /app +flake8 --max-complexity 20 /app mypy --ignore-missing-imports /app bandit -r /app From 4fc9f514e86d5432f2bd4b833c3d23045c188984 Mon Sep 17 00:00:00 2001 From: Dakota Blair Date: Tue, 24 Nov 2020 16:15:58 -0500 Subject: [PATCH 632/732] Removing print so that errors only print once. This was a vestige of an earlier approach which used more fine grain logging parameters. Now the add_error function only does one thing, but it will be semantically useful for providing the user with more options for debugging. --- importers/djornl/parser.py | 1 - 1 file changed, 1 deletion(-) diff --git a/importers/djornl/parser.py b/importers/djornl/parser.py index 9b7474d4..00f980aa 100644 --- a/importers/djornl/parser.py +++ b/importers/djornl/parser.py @@ -274,7 +274,6 @@ def process_file(self, file, remap_fn, store_fn, err_list, validator=None): file_parser = self.parser_gen(file) def add_error(error): - print(error) err_list.append(error) try: From 9eebfb47dab2c9eba6024aa9a23faffcb0b43bf8 Mon Sep 17 00:00:00 2001 From: slebras Date: Tue, 15 Dec 2020 14:20:47 -0800 Subject: [PATCH 633/732] adding spec for sample_ontology_link collection in new samples folder. --- .../samples/sample_ontology_link.yaml | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 spec/collections/samples/sample_ontology_link.yaml diff --git a/spec/collections/samples/sample_ontology_link.yaml b/spec/collections/samples/sample_ontology_link.yaml new file mode 100644 index 00000000..9fb5fc21 --- /dev/null +++ b/spec/collections/samples/sample_ontology_link.yaml @@ -0,0 +1,47 @@ +name: sample_ontology_link +type: edge +schema: + "$schema": http://json-schema.org/draft-07/schema# + type: object + required: [_from, _to, created] + description: The _from sample node is associated with the _to taxon. + properties: + _from: + type: string + description: the sample node _id (as found in sample_nodes collection) + _to: + type: string + description: The _id of an ontology vertex, such as from ENVO, GO, etc. + created: + type: integer + description: timestamp of when the link was created + createdby: + type: string + description: Who made this sample-ontology link? + expired: + type: integer + description: timestamp of when this link expires + sample_id: + type: string + description: uui identifier for sample object. corresponds to sample id provided by SampleService + sample_version: + type: integer + description: integer version of sample object (1, 2, etc.) + sample_version_uuid: + type: string + description: uuid identifier for sample object version in sample version collection + sample_node_name: + type: string + description: name of sample node in Sample + sample_node_uuid: + type: string + description: uuid identifier for sample node in sample nodes collection + sample_metadata_term: + type: integer + description: metadata term in sample associated with ontology term + ontology_term: + type: string + description: identifier for term in ontology_collection + ontology_collection: + type: string + description: name of collection containing ontology_term From 8a24351875a9c38b63d970e0c5630b4d9b397184 Mon Sep 17 00:00:00 2001 From: ialarmedalien Date: Wed, 16 Dec 2020 07:16:52 -0800 Subject: [PATCH 634/732] Add errors to DJORNL parser text output --- importers/djornl/parser.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/importers/djornl/parser.py b/importers/djornl/parser.py index 00f980aa..41b671eb 100644 --- a/importers/djornl/parser.py +++ b/importers/djornl/parser.py @@ -801,6 +801,8 @@ def format_summary(summary, output): """.format( value_width ) + if summary.get("errors_total") > 0: + text_summary = text_summary + "\n" + "\n".join(summary.get("errors")) return text_summary From a42279cf103cfbe4444dde1e3516b676de1190c3 Mon Sep 17 00:00:00 2001 From: ialarmedalien Date: Wed, 16 Dec 2020 08:08:22 -0800 Subject: [PATCH 635/732] Small fixes to DJORNL edge file --- spec/datasets/djornl/edge_type.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/spec/datasets/djornl/edge_type.yaml b/spec/datasets/djornl/edge_type.yaml index 7ac25aff..9294d336 100644 --- a/spec/datasets/djornl/edge_type.yaml +++ b/spec/datasets/djornl/edge_type.yaml @@ -20,21 +20,21 @@ oneOf: title: AraNetv2 high-throughput protein-protein interaction description: Log likelihood score. A layer of protein-protein interaction values derived from four high-throughput PPI screening experiments; from the Arabidopsis AraNetv2 database. The LLS scores that serve as edge values were calculated to normalize the data for comparison across studies and different types of data layers (Lee et al, 2015). - - const: protein-protein-interaction_literature-curation_AraNet_v2 + - const: protein-protein-interaction_literature-curated_AraNet_v2 title: AraNetv2 literature-curated protein-protein interaction description: A layer of protein-protein interaction values from literature-curated small- to medium-scale experimental data; from the Arabidopsis AraNetv2 database. The LLS scores that serve as edge values were calculated to normalize the data for comparison across studies and different types of data layers (Lee et al, 2015). - const: protein-protein-interaction_biogrid_date/release3.5.188 title: BIOGRID ORGANISM Arabidopsis thaliana Columbia 3.5.188 tab3 PPI - description: BioGRID interactions are relationships between two proteins or genes; the term “interaction” includes direct physical binding of two proteins, and co-existence in a stable complex and genetic interaction. see https://wiki.thebiogrid.org/doku.php/experimental_systems + description: BioGRID interactions are relationships between two proteins or genes; the term 'interaction' includes direct physical binding of two proteins, and co-existence in a stable complex and genetic interaction. https://wiki.thebiogrid.org/doku.php/experimental_systems. - const: protein-protein-interaction_AtPIN title: AtPIN PPI description: The interactions database includes all interactions present at the Arabidopsis thaliana Protein Interactome Database, the Predicted Interactome for Arabidopsis, Arabidopsis protein-protein interaction data curated from the literature by TAIR curators, BIOGRID and IntAct. https://atpin.bioinfoguy.net/cgi-bin/atpin.pl - + - const: protein-protein-interaction_Mentha_A_thaliana_3702_040319 title: Mentha AT 3702 040319 PPI - description: Mentha archives evidence collected from different sources and presents these data in a complete and comprehensive way. Its data comes from manually curated protein-protein interaction databases that have adhered to the IMEx consortium and assigns to each interaction a reliability score that takes into account all the supporting evidence. https://mentha.uniroma2.it/about.php + description: Mentha archives evidence collected from different sources and presents these data in a complete and comprehensive way. Data comes from manually curated protein-protein interaction databases that have adhered to the IMEx consortium and assigns to each interaction a reliability score that takes into account all the supporting evidence. https://mentha.uniroma2.it/about.php - const: protein-protein-interaction_literature_curated_AraNet_v2_subnet title: AraNetv2 subnet AT-LC PPI @@ -42,7 +42,7 @@ oneOf: - const: phenotype-association_GWAS_gene_to_metabolite_10.1371/journal.pgen.1006363 title: Wu2016 s015 Gene-to-Metab GeneToPhenotype - description: GWAS hits ftom a Gene-to-Metaboiltes GWAS. Phenotypes (metabolites) have a unique ID from the Wu 2016 study and need to be given our own UID for future use. + description: GWAS hits ftom a Gene-to-Metaboiltes GWAS. Phenotypes (metabolites) have a unique ID from the Wu 2016 study (doi:10.1371/journal.pgen.1006363) and need to be given our own UID for future use. - const: phenotype-association_AraGWAS_subnet_permsig_geni title: AraGWAS subnet permsig geni GeneToPhenotype From 3595199ce3988cfe5dc90739a68ef42b6cfcdd94 Mon Sep 17 00:00:00 2001 From: ialarmedalien Date: Wed, 16 Dec 2020 08:34:40 -0800 Subject: [PATCH 636/732] Updating edge files to account for changed names --- importers/test/test_djornl_parser.py | 6 +- spec/datasets/djornl/edge_types_filter.yaml | 2 +- .../djornl/djornl_fetch_all.yaml | 2 +- .../djornl/djornl_fetch_clusters.yaml | 2 +- .../djornl/djornl_fetch_genes.yaml | 2 +- .../djornl/djornl_fetch_phenotypes.yaml | 2 +- .../djornl/djornl_search_nodes.yaml | 2 +- .../col_count_errors/directed_edges.tsv | 2 +- spec/test/djornl/col_count_errors/edges.tsv | 2 +- spec/test/djornl/duplicate_data/edges.tsv | 14 +-- .../djornl/duplicate_data/hithruput-edges.csv | 4 +- .../djornl/invalid_types/directed_edges.tsv | 6 +- spec/test/djornl/invalid_types/edges.tsv | 2 +- .../djornl/missing_required_headers/edges.tsv | 6 +- spec/test/djornl/results.json | 116 +++++++++--------- spec/test/djornl/test_data/directed_edges.tsv | 6 +- spec/test/djornl/test_data/edges.tsv | 6 +- 17 files changed, 91 insertions(+), 91 deletions(-) diff --git a/importers/test/test_djornl_parser.py b/importers/test/test_djornl_parser.py index 79ec783d..11dd0fff 100644 --- a/importers/test/test_djornl_parser.py +++ b/importers/test/test_djornl_parser.py @@ -284,13 +284,13 @@ def test_duplicate_data(self): errs = { "edges": [ "edges.tsv line 17: duplicate data for edge " - + "AT1G01100__SDV__protein-protein-interaction_literature-curation_AraNet_v2__False", + + "AT1G01100__SDV__protein-protein-interaction_literature-curated_AraNet_v2__False", "hithruput-edges.csv line 5: duplicate data for edge " + "AT1G01010__AT1G01030__protein-protein-interaction_high-throughput_AraNet_v2__False", "hithruput-edges.csv line 9: duplicate data for edge " + "AT1G01030__AT1G01050__pairwise-gene-coexpression_AraNet_v2__False", "hithruput-edges.csv line 11: duplicate data for edge " - + "SDV__AT1G01100__protein-protein-interaction_literature-curation_AraNet_v2__True", + + "SDV__AT1G01100__protein-protein-interaction_literature-curated_AraNet_v2__True", ], "nodes": ["extra_node.tsv line 5: duplicate data for node AT1G01080"], } @@ -322,7 +322,7 @@ def test_dry_run(self): "pairwise-gene-coexpression_AraNet_v2": 1, "domain-co-occurrence_AraNet_v2": 1, "protein-protein-interaction_high-throughput_AraNet_v2": 2, - "protein-protein-interaction_literature-curation_AraNet_v2": 6, + "protein-protein-interaction_literature-curated_AraNet_v2": 6, }, "edges_total": 13, "node_data_available": {"cluster": 0, "full": 14, "key_only": 0}, diff --git a/spec/datasets/djornl/edge_types_filter.yaml b/spec/datasets/djornl/edge_types_filter.yaml index 4685008a..dae0bd71 100644 --- a/spec/datasets/djornl/edge_types_filter.yaml +++ b/spec/datasets/djornl/edge_types_filter.yaml @@ -8,6 +8,6 @@ items: default: [] uniqueItems: true examples: - - ['protein-protein-interaction_high-throughput_AraNet_v2', 'protein-protein-interaction_literature-curation_AraNet_v2'] + - ['protein-protein-interaction_high-throughput_AraNet_v2', 'protein-protein-interaction_literature-curated_AraNet_v2'] - ['phenotype-association_AraGWAS'] - [] diff --git a/spec/stored_queries/djornl/djornl_fetch_all.yaml b/spec/stored_queries/djornl/djornl_fetch_all.yaml index 1e8911c7..b190bb6b 100644 --- a/spec/stored_queries/djornl/djornl_fetch_all.yaml +++ b/spec/stored_queries/djornl/djornl_fetch_all.yaml @@ -13,7 +13,7 @@ params: default: [] uniqueItems: true examples: - - ['protein-protein-interaction_high-throughput_AraNet_v2', 'protein-protein-interaction_literature-curation_AraNet_v2'] + - ['protein-protein-interaction_high-throughput_AraNet_v2', 'protein-protein-interaction_literature-curated_AraNet_v2'] - ['phenotype-association_AraGWAS'] - [] query: | diff --git a/spec/stored_queries/djornl/djornl_fetch_clusters.yaml b/spec/stored_queries/djornl/djornl_fetch_clusters.yaml index 5677f3a9..9442767d 100644 --- a/spec/stored_queries/djornl/djornl_fetch_clusters.yaml +++ b/spec/stored_queries/djornl/djornl_fetch_clusters.yaml @@ -32,7 +32,7 @@ params: default: [] uniqueItems: true examples: - - ['protein-protein-interaction_high-throughput_AraNet_v2', 'protein-protein-interaction_literature-curation_AraNet_v2'] + - ['protein-protein-interaction_high-throughput_AraNet_v2', 'protein-protein-interaction_literature-curated_AraNet_v2'] - ['phenotype-association_AraGWAS'] - [] query: | diff --git a/spec/stored_queries/djornl/djornl_fetch_genes.yaml b/spec/stored_queries/djornl/djornl_fetch_genes.yaml index 7ebba435..5f4ddb0e 100644 --- a/spec/stored_queries/djornl/djornl_fetch_genes.yaml +++ b/spec/stored_queries/djornl/djornl_fetch_genes.yaml @@ -32,7 +32,7 @@ params: default: [] uniqueItems: true examples: - - ['protein-protein-interaction_high-throughput_AraNet_v2', 'protein-protein-interaction_literature-curation_AraNet_v2'] + - ['protein-protein-interaction_high-throughput_AraNet_v2', 'protein-protein-interaction_literature-curated_AraNet_v2'] - ['phenotype-association_AraGWAS'] - [] query: | diff --git a/spec/stored_queries/djornl/djornl_fetch_phenotypes.yaml b/spec/stored_queries/djornl/djornl_fetch_phenotypes.yaml index 0758bc8b..13c79fed 100644 --- a/spec/stored_queries/djornl/djornl_fetch_phenotypes.yaml +++ b/spec/stored_queries/djornl/djornl_fetch_phenotypes.yaml @@ -32,7 +32,7 @@ params: default: [] uniqueItems: true examples: - - ['protein-protein-interaction_high-throughput_AraNet_v2', 'protein-protein-interaction_literature-curation_AraNet_v2'] + - ['protein-protein-interaction_high-throughput_AraNet_v2', 'protein-protein-interaction_literature-curated_AraNet_v2'] - ['phenotype-association_AraGWAS'] - [] query: | diff --git a/spec/stored_queries/djornl/djornl_search_nodes.yaml b/spec/stored_queries/djornl/djornl_search_nodes.yaml index b113bcf8..7e377848 100644 --- a/spec/stored_queries/djornl/djornl_search_nodes.yaml +++ b/spec/stored_queries/djornl/djornl_search_nodes.yaml @@ -28,7 +28,7 @@ params: default: [] uniqueItems: true examples: - - ['protein-protein-interaction_high-throughput_AraNet_v2', 'protein-protein-interaction_literature-curation_AraNet_v2'] + - ['protein-protein-interaction_high-throughput_AraNet_v2', 'protein-protein-interaction_literature-curated_AraNet_v2'] - ['phenotype-association_AraGWAS'] - [] query: | diff --git a/spec/test/djornl/col_count_errors/directed_edges.tsv b/spec/test/djornl/col_count_errors/directed_edges.tsv index 1192356b..ff8713e3 100644 --- a/spec/test/djornl/col_count_errors/directed_edges.tsv +++ b/spec/test/djornl/col_count_errors/directed_edges.tsv @@ -5,4 +5,4 @@ AT1G01010 AT1G01020 2.39322646755088 AraNetv2_log-likelihood-score protein-prote AT1G01010 AT1G01030 2.39322646755088 AraNetv2_log-likelihood-score protein-protein-interaction_high-throughput_AraNet_v2 1 AT1G01010 AT1G01040 2.39322646755088 AT1G01030 AT1G01050 2.5494618241936697 AraNetv2_log-likelihood-score pairwise-gene-coexpression_AraNet_v2 1 -AT1G01050 AT1G01060 4.34242054808616 AraNetv2_log-likelihood-score protein-protein-interaction_literature-curation_AraNet_v2 1 +AT1G01050 AT1G01060 4.34242054808616 AraNetv2_log-likelihood-score protein-protein-interaction_literature-curated_AraNet_v2 1 diff --git a/spec/test/djornl/col_count_errors/edges.tsv b/spec/test/djornl/col_count_errors/edges.tsv index 50071e12..51953490 100644 --- a/spec/test/djornl/col_count_errors/edges.tsv +++ b/spec/test/djornl/col_count_errors/edges.tsv @@ -5,4 +5,4 @@ AT1G01010 AT1G01020 2.39322646755088 AraNetv2_log-likelihood-score protein-prote AT1G01010 AT1G01030 2.39322646755088 AraNetv2_log-likelihood-score protein-protein-interaction_high-throughput_AraNet_v2 AT1G01010 AT1G01040 2.39322646755088 AT1G01030 AT1G01050 2.5494618241936697 AraNetv2_log-likelihood-score pairwise-gene-coexpression_AraNet_v2 -AT1G01050 AT1G01060 4.34242054808616 AraNetv2_log-likelihood-score protein-protein-interaction_literature-curation_AraNet_v2 +AT1G01050 AT1G01060 4.34242054808616 AraNetv2_log-likelihood-score protein-protein-interaction_literature-curated_AraNet_v2 diff --git a/spec/test/djornl/duplicate_data/edges.tsv b/spec/test/djornl/duplicate_data/edges.tsv index 61da1e35..270cab3d 100644 --- a/spec/test/djornl/duplicate_data/edges.tsv +++ b/spec/test/djornl/duplicate_data/edges.tsv @@ -3,15 +3,15 @@ As2 AT1G01020 8.4 0 phenotype-association_AraGWAS As2 AT1G01040 5.4 0 phenotype-association_AraGWAS As75 AT1G01020 39.9 0 phenotype-association_AraGWAS AT1G01010 AT1G01040 2.5 0 domain-co-occurrence_AraNet_v2 -AT1G01010 AT1G01040 170.5 0 protein-protein-interaction_literature-curation_AraNet_v2 +AT1G01010 AT1G01040 170.5 0 protein-protein-interaction_literature-curated_AraNet_v2 AT1G01030 AT1G01050 2.6 0 pairwise-gene-coexpression_AraNet_v2 -AT1G01050 AT1G01060 2.7 0 protein-protein-interaction_literature-curation_AraNet_v2 +AT1G01050 AT1G01060 2.7 0 protein-protein-interaction_literature-curated_AraNet_v2 # duplicated line AT1G01010 AT1G01040 2.5 0 domain-co-occurrence_AraNet_v2 -AT1G01080 AT1G01090 2.8 0 protein-protein-interaction_literature-curation_AraNet_v2 +AT1G01080 AT1G01090 2.8 0 protein-protein-interaction_literature-curated_AraNet_v2 # these are OK -SDV AT1G01100 8.4 0 protein-protein-interaction_literature-curation_AraNet_v2 -SDV AT1G01100 5.4 1 protein-protein-interaction_literature-curation_AraNet_v2 -AT1G01100 SDV 2.4 1 protein-protein-interaction_literature-curation_AraNet_v2 +SDV AT1G01100 8.4 0 protein-protein-interaction_literature-curated_AraNet_v2 +SDV AT1G01100 5.4 1 protein-protein-interaction_literature-curated_AraNet_v2 +AT1G01100 SDV 2.4 1 protein-protein-interaction_literature-curated_AraNet_v2 # this is a dupe! -AT1G01100 SDV 8.5 0 protein-protein-interaction_literature-curation_AraNet_v2 +AT1G01100 SDV 8.5 0 protein-protein-interaction_literature-curated_AraNet_v2 diff --git a/spec/test/djornl/duplicate_data/hithruput-edges.csv b/spec/test/djornl/duplicate_data/hithruput-edges.csv index 0bf626c2..94129f85 100644 --- a/spec/test/djornl/duplicate_data/hithruput-edges.csv +++ b/spec/test/djornl/duplicate_data/hithruput-edges.csv @@ -4,9 +4,9 @@ AT1G01010,AT1G01030,2.4,AraNetv2_log-likelihood-score,protein-protein-interactio # potentially erroneous line AT1G01010,AT1G01030,2.7,AraNetv2_log-likelihood-score,protein-protein-interaction_high-throughput_AraNet_v2,0 # duplicated line from the other file -AT1G01060,AT1G01050,2.7,AraNetv2_log-likelihood-score,protein-protein-interaction_literature-curation_AraNet_v2,0 +AT1G01060,AT1G01050,2.7,AraNetv2_log-likelihood-score,protein-protein-interaction_literature-curated_AraNet_v2,0 # potentially erroneous duplication from the other file AT1G01050,AT1G01030,2.6000001,AraNetv2_log-likelihood-score,pairwise-gene-coexpression_AraNet_v2,0 # directed edge dupe -SDV,AT1G01100,2001,whatever,protein-protein-interaction_literature-curation_AraNet_v2,1 +SDV,AT1G01100,2001,whatever,protein-protein-interaction_literature-curated_AraNet_v2,1 diff --git a/spec/test/djornl/invalid_types/directed_edges.tsv b/spec/test/djornl/invalid_types/directed_edges.tsv index 76459ec5..d5f80dfa 100644 --- a/spec/test/djornl/invalid_types/directed_edges.tsv +++ b/spec/test/djornl/invalid_types/directed_edges.tsv @@ -4,7 +4,7 @@ As2 AT1G01020 8.4 AraGWAS-Association_score phenotype-association_AraGWAS 1 As2 AT1G01040 5.4 AraGWAS-Association_score phenotype-association_AraGWAS true As75 AT1G01020 39.9 AraGWAS-Association_score phenotype-association_AraGWAS "" AT1G01010 AT1G01040 2.5 AraNetv2_log-likelihood-score domain-co-occurrence_AraNet_v2 directed -AT1G01010 AT1G01040 170.5 AraNetv2_log-likelihood-score protein-protein-interaction_literature-curation_AraNet_v2 "0" +AT1G01010 AT1G01040 170.5 AraNetv2_log-likelihood-score protein-protein-interaction_literature-curated_AraNet_v2 "0" AT1G01030 AT1G01050 2.6 AraNetv2_log-likelihood-score pairwise-gene-coexpression_AraNet_v2 false -AT1G01050 AT1G01060 2.7 AraNetv2_log-likelihood-score protein-protein-interaction_literature-curation_AraNet_v2 "1" -AT1G01080 AT1G01090 2.8 AraNetv2_log-likelihood-score protein-protein-interaction_literature-curation_AraNet_v2 0 +AT1G01050 AT1G01060 2.7 AraNetv2_log-likelihood-score protein-protein-interaction_literature-curated_AraNet_v2 "1" +AT1G01080 AT1G01090 2.8 AraNetv2_log-likelihood-score protein-protein-interaction_literature-curated_AraNet_v2 0 diff --git a/spec/test/djornl/invalid_types/edges.tsv b/spec/test/djornl/invalid_types/edges.tsv index a9762362..fdb7b00d 100644 --- a/spec/test/djornl/invalid_types/edges.tsv +++ b/spec/test/djornl/invalid_types/edges.tsv @@ -7,4 +7,4 @@ AT1G01010 AT1G01020 2.39322646755088 AT1G01010 AT1G01030 2. AraNetv2_log-likelihood-score protein-protein-interaction_high-throughput_AraNet_v2 AT1G01010 AT1G01040 "2.39322646755088" AraNetv2_log-likelihood-score raNetv2-DC_ AT1G01030 AT1G01050 25494618241936697 AraNetv2_log-likelihood-score pairwise-gene-coexpression_AraNet_v2 -AT1G01050 AT1G01060 score! AraNetv2_log-likelihood-score protein-protein-interaction_literature-curation_AraNet_v2 +AT1G01050 AT1G01060 score! AraNetv2_log-likelihood-score protein-protein-interaction_literature-curated_AraNet_v2 diff --git a/spec/test/djornl/missing_required_headers/edges.tsv b/spec/test/djornl/missing_required_headers/edges.tsv index f824869a..468172a4 100644 --- a/spec/test/djornl/missing_required_headers/edges.tsv +++ b/spec/test/djornl/missing_required_headers/edges.tsv @@ -3,7 +3,7 @@ As2 AT1G01020 8.4 AraGWAS-Association_score phenotype-association_AraGWAS As2 AT1G01040 5.4 AraGWAS-Association_score phenotype-association_AraGWAS As75 AT1G01020 39.9 AraGWAS-Association_score phenotype-association_AraGWAS AT1G01010 AT1G01040 2.5 AraNetv2_log-likelihood-score domain-co-occurrence_AraNet_v2 -AT1G01010 AT1G01040 170.5 AraNetv2_log-likelihood-score protein-protein-interaction_literature-curation_AraNet_v2 +AT1G01010 AT1G01040 170.5 AraNetv2_log-likelihood-score protein-protein-interaction_literature-curated_AraNet_v2 AT1G01030 AT1G01050 2.6 AraNetv2_log-likelihood-score pairwise-gene-coexpression_AraNet_v2 -AT1G01050 AT1G01060 2.7 AraNetv2_log-likelihood-score protein-protein-interaction_literature-curation_AraNet_v2 -AT1G01080 AT1G01090 2.8 AraNetv2_log-likelihood-score protein-protein-interaction_literature-curation_AraNet_v2 +AT1G01050 AT1G01060 2.7 AraNetv2_log-likelihood-score protein-protein-interaction_literature-curated_AraNet_v2 +AT1G01080 AT1G01090 2.8 AraNetv2_log-likelihood-score protein-protein-interaction_literature-curated_AraNet_v2 diff --git a/spec/test/djornl/results.json b/spec/test/djornl/results.json index d0052d46..5b694916 100644 --- a/spec/test/djornl/results.json +++ b/spec/test/djornl/results.json @@ -63,10 +63,10 @@ "directed": false }, { - "_key": "AT1G01010__AT1G01040__protein-protein-interaction_literature-curation_AraNet_v2__False__170.5", + "_key": "AT1G01010__AT1G01040__protein-protein-interaction_literature-curated_AraNet_v2__False__170.5", "_from": "djornl_node/AT1G01010", "_to": "djornl_node/AT1G01040", - "edge_type": "protein-protein-interaction_literature-curation_AraNet_v2", + "edge_type": "protein-protein-interaction_literature-curated_AraNet_v2", "score": 170.5, "directed": false }, @@ -79,42 +79,42 @@ "directed": false }, { - "_key": "AT1G01050__AT1G01060__protein-protein-interaction_literature-curation_AraNet_v2__False__2.7", + "_key": "AT1G01050__AT1G01060__protein-protein-interaction_literature-curated_AraNet_v2__False__2.7", "_from": "djornl_node/AT1G01050", "_to": "djornl_node/AT1G01060", - "edge_type": "protein-protein-interaction_literature-curation_AraNet_v2", + "edge_type": "protein-protein-interaction_literature-curated_AraNet_v2", "score": 2.7, "directed": false }, { - "_key": "AT1G01080__AT1G01090__protein-protein-interaction_literature-curation_AraNet_v2__False__2.8", + "_key": "AT1G01080__AT1G01090__protein-protein-interaction_literature-curated_AraNet_v2__False__2.8", "_from": "djornl_node/AT1G01080", "_to": "djornl_node/AT1G01090", - "edge_type": "protein-protein-interaction_literature-curation_AraNet_v2", + "edge_type": "protein-protein-interaction_literature-curated_AraNet_v2", "score": 2.8, "directed": false }, { - "_key": "AT1G01100__SDV__protein-protein-interaction_literature-curation_AraNet_v2__True__2.4", + "_key": "AT1G01100__SDV__protein-protein-interaction_literature-curated_AraNet_v2__True__2.4", "_from": "djornl_node/AT1G01100", "_to": "djornl_node/SDV", - "edge_type": "protein-protein-interaction_literature-curation_AraNet_v2", + "edge_type": "protein-protein-interaction_literature-curated_AraNet_v2", "score": 2.4, "directed": true }, { - "_key": "SDV__AT1G01100__protein-protein-interaction_literature-curation_AraNet_v2__False__8.4", + "_key": "SDV__AT1G01100__protein-protein-interaction_literature-curated_AraNet_v2__False__8.4", "_from": "djornl_node/SDV", "_to": "djornl_node/AT1G01100", - "edge_type": "protein-protein-interaction_literature-curation_AraNet_v2", + "edge_type": "protein-protein-interaction_literature-curated_AraNet_v2", "score": 8.4, "directed": false }, { - "_key": "SDV__AT1G01100__protein-protein-interaction_literature-curation_AraNet_v2__True__5.4", + "_key": "SDV__AT1G01100__protein-protein-interaction_literature-curated_AraNet_v2__True__5.4", "_from": "djornl_node/SDV", "_to": "djornl_node/AT1G01100", - "edge_type": "protein-protein-interaction_literature-curation_AraNet_v2", + "edge_type": "protein-protein-interaction_literature-curated_AraNet_v2", "score": 5.4, "directed": true } @@ -189,13 +189,13 @@ "AT1G01010__AT1G01020__protein-protein-interaction_high-throughput_AraNet_v2__False__2.3", "AT1G01010__AT1G01030__protein-protein-interaction_high-throughput_AraNet_v2__False__2.4", "AT1G01010__AT1G01040__domain-co-occurrence_AraNet_v2__False__2.5", - "AT1G01010__AT1G01040__protein-protein-interaction_literature-curation_AraNet_v2__False__170.5", + "AT1G01010__AT1G01040__protein-protein-interaction_literature-curated_AraNet_v2__False__170.5", "AT1G01030__AT1G01050__pairwise-gene-coexpression_AraNet_v2__False__2.6", - "AT1G01050__AT1G01060__protein-protein-interaction_literature-curation_AraNet_v2__False__2.7", - "AT1G01080__AT1G01090__protein-protein-interaction_literature-curation_AraNet_v2__False__2.8", - "AT1G01100__SDV__protein-protein-interaction_literature-curation_AraNet_v2__True__2.4", - "SDV__AT1G01100__protein-protein-interaction_literature-curation_AraNet_v2__False__8.4", - "SDV__AT1G01100__protein-protein-interaction_literature-curation_AraNet_v2__True__5.4" + "AT1G01050__AT1G01060__protein-protein-interaction_literature-curated_AraNet_v2__False__2.7", + "AT1G01080__AT1G01090__protein-protein-interaction_literature-curated_AraNet_v2__False__2.8", + "AT1G01100__SDV__protein-protein-interaction_literature-curated_AraNet_v2__True__2.4", + "SDV__AT1G01100__protein-protein-interaction_literature-curated_AraNet_v2__False__8.4", + "SDV__AT1G01100__protein-protein-interaction_literature-curated_AraNet_v2__True__5.4" ] } }, @@ -243,13 +243,13 @@ "AT1G01010__AT1G01020__protein-protein-interaction_high-throughput_AraNet_v2__False__2.3", "AT1G01010__AT1G01030__protein-protein-interaction_high-throughput_AraNet_v2__False__2.4", "AT1G01010__AT1G01040__domain-co-occurrence_AraNet_v2__False__2.5", - "AT1G01010__AT1G01040__protein-protein-interaction_literature-curation_AraNet_v2__False__170.5", + "AT1G01010__AT1G01040__protein-protein-interaction_literature-curated_AraNet_v2__False__170.5", "AT1G01030__AT1G01050__pairwise-gene-coexpression_AraNet_v2__False__2.6", - "AT1G01050__AT1G01060__protein-protein-interaction_literature-curation_AraNet_v2__False__2.7", - "AT1G01080__AT1G01090__protein-protein-interaction_literature-curation_AraNet_v2__False__2.8", - "AT1G01100__SDV__protein-protein-interaction_literature-curation_AraNet_v2__True__2.4", - "SDV__AT1G01100__protein-protein-interaction_literature-curation_AraNet_v2__False__8.4", - "SDV__AT1G01100__protein-protein-interaction_literature-curation_AraNet_v2__True__5.4" + "AT1G01050__AT1G01060__protein-protein-interaction_literature-curated_AraNet_v2__False__2.7", + "AT1G01080__AT1G01090__protein-protein-interaction_literature-curated_AraNet_v2__False__2.8", + "AT1G01100__SDV__protein-protein-interaction_literature-curated_AraNet_v2__True__2.4", + "SDV__AT1G01100__protein-protein-interaction_literature-curated_AraNet_v2__False__8.4", + "SDV__AT1G01100__protein-protein-interaction_literature-curated_AraNet_v2__True__5.4" ] } }, @@ -280,7 +280,7 @@ } }, { - "params": {"edge_types": ["phenotype-association_AraGWAS", "protein-protein-interaction_high-throughput_AraNet_v2", "protein-protein-interaction_literature-curation_AraNet_v2"]}, + "params": {"edge_types": ["phenotype-association_AraGWAS", "protein-protein-interaction_high-throughput_AraNet_v2", "protein-protein-interaction_literature-curated_AraNet_v2"]}, "results": { "nodes": [ "As2", @@ -304,12 +304,12 @@ "As75__AT1G01020__phenotype-association_AraGWAS__False__39.9", "AT1G01010__AT1G01020__protein-protein-interaction_high-throughput_AraNet_v2__False__2.3", "AT1G01010__AT1G01030__protein-protein-interaction_high-throughput_AraNet_v2__False__2.4", - "AT1G01010__AT1G01040__protein-protein-interaction_literature-curation_AraNet_v2__False__170.5", - "AT1G01050__AT1G01060__protein-protein-interaction_literature-curation_AraNet_v2__False__2.7", - "AT1G01080__AT1G01090__protein-protein-interaction_literature-curation_AraNet_v2__False__2.8", - "AT1G01100__SDV__protein-protein-interaction_literature-curation_AraNet_v2__True__2.4", - "SDV__AT1G01100__protein-protein-interaction_literature-curation_AraNet_v2__False__8.4", - "SDV__AT1G01100__protein-protein-interaction_literature-curation_AraNet_v2__True__5.4" + "AT1G01010__AT1G01040__protein-protein-interaction_literature-curated_AraNet_v2__False__170.5", + "AT1G01050__AT1G01060__protein-protein-interaction_literature-curated_AraNet_v2__False__2.7", + "AT1G01080__AT1G01090__protein-protein-interaction_literature-curated_AraNet_v2__False__2.8", + "AT1G01100__SDV__protein-protein-interaction_literature-curated_AraNet_v2__True__2.4", + "SDV__AT1G01100__protein-protein-interaction_literature-curated_AraNet_v2__False__8.4", + "SDV__AT1G01100__protein-protein-interaction_literature-curated_AraNet_v2__True__5.4" ] } } @@ -374,7 +374,7 @@ "AT1G01010__AT1G01020__protein-protein-interaction_high-throughput_AraNet_v2__False__2.3", "AT1G01010__AT1G01030__protein-protein-interaction_high-throughput_AraNet_v2__False__2.4", "AT1G01010__AT1G01040__domain-co-occurrence_AraNet_v2__False__2.5", - "AT1G01010__AT1G01040__protein-protein-interaction_literature-curation_AraNet_v2__False__170.5" + "AT1G01010__AT1G01040__protein-protein-interaction_literature-curated_AraNet_v2__False__170.5" ] } }, @@ -389,9 +389,9 @@ "AT1G01010__AT1G01020__protein-protein-interaction_high-throughput_AraNet_v2__False__2.3", "AT1G01010__AT1G01030__protein-protein-interaction_high-throughput_AraNet_v2__False__2.4", "AT1G01010__AT1G01040__domain-co-occurrence_AraNet_v2__False__2.5", - "AT1G01010__AT1G01040__protein-protein-interaction_literature-curation_AraNet_v2__False__170.5", + "AT1G01010__AT1G01040__protein-protein-interaction_literature-curated_AraNet_v2__False__170.5", "AT1G01030__AT1G01050__pairwise-gene-coexpression_AraNet_v2__False__2.6", - "AT1G01050__AT1G01060__protein-protein-interaction_literature-curation_AraNet_v2__False__2.7" + "AT1G01050__AT1G01060__protein-protein-interaction_literature-curated_AraNet_v2__False__2.7" ] } }, @@ -406,9 +406,9 @@ "AT1G01010__AT1G01020__protein-protein-interaction_high-throughput_AraNet_v2__False__2.3", "AT1G01010__AT1G01030__protein-protein-interaction_high-throughput_AraNet_v2__False__2.4", "AT1G01010__AT1G01040__domain-co-occurrence_AraNet_v2__False__2.5", - "AT1G01010__AT1G01040__protein-protein-interaction_literature-curation_AraNet_v2__False__170.5", + "AT1G01010__AT1G01040__protein-protein-interaction_literature-curated_AraNet_v2__False__170.5", "AT1G01030__AT1G01050__pairwise-gene-coexpression_AraNet_v2__False__2.6", - "AT1G01050__AT1G01060__protein-protein-interaction_literature-curation_AraNet_v2__False__2.7" + "AT1G01050__AT1G01060__protein-protein-interaction_literature-curated_AraNet_v2__False__2.7" ] } }, @@ -451,9 +451,9 @@ "AT1G01010__AT1G01020__protein-protein-interaction_high-throughput_AraNet_v2__False__2.3", "AT1G01010__AT1G01030__protein-protein-interaction_high-throughput_AraNet_v2__False__2.4", "AT1G01010__AT1G01040__domain-co-occurrence_AraNet_v2__False__2.5", - "AT1G01010__AT1G01040__protein-protein-interaction_literature-curation_AraNet_v2__False__170.5", + "AT1G01010__AT1G01040__protein-protein-interaction_literature-curated_AraNet_v2__False__170.5", "AT1G01030__AT1G01050__pairwise-gene-coexpression_AraNet_v2__False__2.6", - "AT1G01050__AT1G01060__protein-protein-interaction_literature-curation_AraNet_v2__False__2.7" + "AT1G01050__AT1G01060__protein-protein-interaction_literature-curated_AraNet_v2__False__2.7" ] } }, @@ -532,9 +532,9 @@ "AT1G01010__AT1G01020__protein-protein-interaction_high-throughput_AraNet_v2__False__2.3", "AT1G01010__AT1G01030__protein-protein-interaction_high-throughput_AraNet_v2__False__2.4", "AT1G01010__AT1G01040__domain-co-occurrence_AraNet_v2__False__2.5", - "AT1G01010__AT1G01040__protein-protein-interaction_literature-curation_AraNet_v2__False__170.5", + "AT1G01010__AT1G01040__protein-protein-interaction_literature-curated_AraNet_v2__False__170.5", "AT1G01030__AT1G01050__pairwise-gene-coexpression_AraNet_v2__False__2.6", - "AT1G01050__AT1G01060__protein-protein-interaction_literature-curation_AraNet_v2__False__2.7" + "AT1G01050__AT1G01060__protein-protein-interaction_literature-curated_AraNet_v2__False__2.7" ] } }, @@ -566,9 +566,9 @@ "AT1G01010__AT1G01020__protein-protein-interaction_high-throughput_AraNet_v2__False__2.3", "AT1G01010__AT1G01030__protein-protein-interaction_high-throughput_AraNet_v2__False__2.4", "AT1G01010__AT1G01040__domain-co-occurrence_AraNet_v2__False__2.5", - "AT1G01010__AT1G01040__protein-protein-interaction_literature-curation_AraNet_v2__False__170.5", + "AT1G01010__AT1G01040__protein-protein-interaction_literature-curated_AraNet_v2__False__170.5", "AT1G01030__AT1G01050__pairwise-gene-coexpression_AraNet_v2__False__2.6", - "AT1G01050__AT1G01060__protein-protein-interaction_literature-curation_AraNet_v2__False__2.7" + "AT1G01050__AT1G01060__protein-protein-interaction_literature-curated_AraNet_v2__False__2.7" ] } }, @@ -583,7 +583,7 @@ "params": { "phenotype_keys": ["As2", "Na23"], "distance": 5, - "edge_types": ["pairwise-gene-coexpression_AraNet_v2", "domain-co-occurrence_AraNet_v2", "protein-protein-interaction_high-throughput_AraNet_v2", "protein-protein-interaction_literature-curation_AraNet_v2"] + "edge_types": ["pairwise-gene-coexpression_AraNet_v2", "domain-co-occurrence_AraNet_v2", "protein-protein-interaction_high-throughput_AraNet_v2", "protein-protein-interaction_literature-curated_AraNet_v2"] }, "results": { "nodes": ["As2", "Na23"], @@ -651,8 +651,8 @@ "edges": [ "As2__AT1G01040__phenotype-association_AraGWAS__False__5.4", "AT1G01010__AT1G01040__domain-co-occurrence_AraNet_v2__False__2.5", - "AT1G01010__AT1G01040__protein-protein-interaction_literature-curation_AraNet_v2__False__170.5", - "AT1G01080__AT1G01090__protein-protein-interaction_literature-curation_AraNet_v2__False__2.8" + "AT1G01010__AT1G01040__protein-protein-interaction_literature-curated_AraNet_v2__False__170.5", + "AT1G01080__AT1G01090__protein-protein-interaction_literature-curated_AraNet_v2__False__2.8" ] } }, @@ -667,10 +667,10 @@ "AT1G01010__AT1G01020__protein-protein-interaction_high-throughput_AraNet_v2__False__2.3", "AT1G01010__AT1G01030__protein-protein-interaction_high-throughput_AraNet_v2__False__2.4", "AT1G01010__AT1G01040__domain-co-occurrence_AraNet_v2__False__2.5", - "AT1G01010__AT1G01040__protein-protein-interaction_literature-curation_AraNet_v2__False__170.5", + "AT1G01010__AT1G01040__protein-protein-interaction_literature-curated_AraNet_v2__False__170.5", "AT1G01030__AT1G01050__pairwise-gene-coexpression_AraNet_v2__False__2.6", - "AT1G01050__AT1G01060__protein-protein-interaction_literature-curation_AraNet_v2__False__2.7", - "AT1G01080__AT1G01090__protein-protein-interaction_literature-curation_AraNet_v2__False__2.8" + "AT1G01050__AT1G01060__protein-protein-interaction_literature-curated_AraNet_v2__False__2.7", + "AT1G01080__AT1G01090__protein-protein-interaction_literature-curated_AraNet_v2__False__2.8" ] } }, @@ -756,8 +756,8 @@ "edges": [ "As2__AT1G01040__phenotype-association_AraGWAS__False__5.4", "AT1G01010__AT1G01040__domain-co-occurrence_AraNet_v2__False__2.5", - "AT1G01010__AT1G01040__protein-protein-interaction_literature-curation_AraNet_v2__False__170.5", - "AT1G01080__AT1G01090__protein-protein-interaction_literature-curation_AraNet_v2__False__2.8" + "AT1G01010__AT1G01040__protein-protein-interaction_literature-curated_AraNet_v2__False__170.5", + "AT1G01080__AT1G01090__protein-protein-interaction_literature-curated_AraNet_v2__False__2.8" ] } }, @@ -772,10 +772,10 @@ "AT1G01010__AT1G01020__protein-protein-interaction_high-throughput_AraNet_v2__False__2.3", "AT1G01010__AT1G01030__protein-protein-interaction_high-throughput_AraNet_v2__False__2.4", "AT1G01010__AT1G01040__domain-co-occurrence_AraNet_v2__False__2.5", - "AT1G01010__AT1G01040__protein-protein-interaction_literature-curation_AraNet_v2__False__170.5", + "AT1G01010__AT1G01040__protein-protein-interaction_literature-curated_AraNet_v2__False__170.5", "AT1G01030__AT1G01050__pairwise-gene-coexpression_AraNet_v2__False__2.6", - "AT1G01050__AT1G01060__protein-protein-interaction_literature-curation_AraNet_v2__False__2.7", - "AT1G01080__AT1G01090__protein-protein-interaction_literature-curation_AraNet_v2__False__2.8" + "AT1G01050__AT1G01060__protein-protein-interaction_literature-curated_AraNet_v2__False__2.7", + "AT1G01080__AT1G01090__protein-protein-interaction_literature-curated_AraNet_v2__False__2.8" ] } }, @@ -815,9 +815,9 @@ "AT1G01010__AT1G01020__protein-protein-interaction_high-throughput_AraNet_v2__False__2.3", "AT1G01010__AT1G01030__protein-protein-interaction_high-throughput_AraNet_v2__False__2.4", "AT1G01010__AT1G01040__domain-co-occurrence_AraNet_v2__False__2.5", - "AT1G01010__AT1G01040__protein-protein-interaction_literature-curation_AraNet_v2__False__170.5", + "AT1G01010__AT1G01040__protein-protein-interaction_literature-curated_AraNet_v2__False__170.5", "AT1G01030__AT1G01050__pairwise-gene-coexpression_AraNet_v2__False__2.6", - "AT1G01050__AT1G01060__protein-protein-interaction_literature-curation_AraNet_v2__False__2.7" + "AT1G01050__AT1G01060__protein-protein-interaction_literature-curated_AraNet_v2__False__2.7" ] } }, @@ -866,7 +866,7 @@ "edge_types": [ "phenotype-association_AraGWAS", "protein-protein-interaction_high-throughput_AraNet_v2", - "protein-protein-interaction_literature-curation_AraNet_v2", + "protein-protein-interaction_literature-curated_AraNet_v2", "pairwise-gene-coexpression_AraNet_v2" ] }, @@ -878,9 +878,9 @@ "As75__AT1G01020__phenotype-association_AraGWAS__False__39.9", "AT1G01010__AT1G01020__protein-protein-interaction_high-throughput_AraNet_v2__False__2.3", "AT1G01010__AT1G01030__protein-protein-interaction_high-throughput_AraNet_v2__False__2.4", - "AT1G01010__AT1G01040__protein-protein-interaction_literature-curation_AraNet_v2__False__170.5", + "AT1G01010__AT1G01040__protein-protein-interaction_literature-curated_AraNet_v2__False__170.5", "AT1G01030__AT1G01050__pairwise-gene-coexpression_AraNet_v2__False__2.6", - "AT1G01050__AT1G01060__protein-protein-interaction_literature-curation_AraNet_v2__False__2.7" + "AT1G01050__AT1G01060__protein-protein-interaction_literature-curated_AraNet_v2__False__2.7" ] } } diff --git a/spec/test/djornl/test_data/directed_edges.tsv b/spec/test/djornl/test_data/directed_edges.tsv index e3d20071..83d970f5 100644 --- a/spec/test/djornl/test_data/directed_edges.tsv +++ b/spec/test/djornl/test_data/directed_edges.tsv @@ -1,4 +1,4 @@ node1 node2 score edge_descrip edge_type directed -SDV AT1G01100 8.4 AraGWAS-Association_score protein-protein-interaction_literature-curation_AraNet_v2 0 -SDV AT1G01100 5.4 AraGWAS-Association_score protein-protein-interaction_literature-curation_AraNet_v2 1 -AT1G01100 SDV 2.4 AraGWAS-Association_score protein-protein-interaction_literature-curation_AraNet_v2 1 +SDV AT1G01100 8.4 AraGWAS-Association_score protein-protein-interaction_literature-curated_AraNet_v2 0 +SDV AT1G01100 5.4 AraGWAS-Association_score protein-protein-interaction_literature-curated_AraNet_v2 1 +AT1G01100 SDV 2.4 AraGWAS-Association_score protein-protein-interaction_literature-curated_AraNet_v2 1 diff --git a/spec/test/djornl/test_data/edges.tsv b/spec/test/djornl/test_data/edges.tsv index 3762bc9d..5924b991 100644 --- a/spec/test/djornl/test_data/edges.tsv +++ b/spec/test/djornl/test_data/edges.tsv @@ -3,7 +3,7 @@ As2 AT1G01020 8.4 AraGWAS-Association_score phenotype-association_AraGWAS As2 AT1G01040 5.4 AraGWAS-Association_score phenotype-association_AraGWAS As75 AT1G01020 39.9 AraGWAS-Association_score phenotype-association_AraGWAS AT1G01010 AT1G01040 2.5 AraNetv2_log-likelihood-score domain-co-occurrence_AraNet_v2 -AT1G01010 AT1G01040 170.5 AraNetv2_log-likelihood-score protein-protein-interaction_literature-curation_AraNet_v2 +AT1G01010 AT1G01040 170.5 AraNetv2_log-likelihood-score protein-protein-interaction_literature-curated_AraNet_v2 AT1G01030 AT1G01050 2.6 AraNetv2_log-likelihood-score pairwise-gene-coexpression_AraNet_v2 -AT1G01050 AT1G01060 2.7 AraNetv2_log-likelihood-score protein-protein-interaction_literature-curation_AraNet_v2 -AT1G01080 AT1G01090 2.8 AraNetv2_log-likelihood-score protein-protein-interaction_literature-curation_AraNet_v2 +AT1G01050 AT1G01060 2.7 AraNetv2_log-likelihood-score protein-protein-interaction_literature-curated_AraNet_v2 +AT1G01080 AT1G01090 2.8 AraNetv2_log-likelihood-score protein-protein-interaction_literature-curated_AraNet_v2 From d499cca1bc96ccd1206d7c2247cad9f8bfe62b70 Mon Sep 17 00:00:00 2001 From: ialarmedalien Date: Wed, 16 Dec 2020 10:53:41 -0800 Subject: [PATCH 637/732] Update the set-env command to the new version --- .github/workflows/run_tests.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/run_tests.yaml b/.github/workflows/run_tests.yaml index 40d2dd71..1b864459 100644 --- a/.github/workflows/run_tests.yaml +++ b/.github/workflows/run_tests.yaml @@ -34,9 +34,9 @@ jobs: - name: set env vars shell: bash run: | - echo ::set-env name=DATE::$(date -u +"%Y-%m-%dT%H:%M:%SZ") - echo ::set-env name=BRANCH::$(git symbolic-ref --short HEAD) - echo ::set-env name=COMMIT::$(git rev-parse --short HEAD) + echo "DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")" >> $GITHUB_ENV + echo "BRANCH=$(git symbolic-ref --short HEAD)" >> $GITHUB_ENV + echo "COMMIT=$(git rev-parse --short HEAD)" >> $GITHUB_ENV - name: build and push to dockerhub uses: opspresso/action-docker@master From 2d37d72b60ca10e6ad9c54b10f1bca7018de3f56 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Fri, 18 Dec 2020 11:05:30 -0800 Subject: [PATCH 638/732] Print error on timeout waiting for service --- relation_engine_server/utils/wait_for.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/relation_engine_server/utils/wait_for.py b/relation_engine_server/utils/wait_for.py index 572fa8ec..05d7fb53 100644 --- a/relation_engine_server/utils/wait_for.py +++ b/relation_engine_server/utils/wait_for.py @@ -9,7 +9,6 @@ def get_service_conf(): - _CONF = get_config() return { "arangodb": { @@ -35,7 +34,6 @@ def wait_for_service(service_list: List[str]) -> None: timeout = int(time.time()) + 60 services_pending = set(service_list) service_conf = get_service_conf() - while services_pending: still_pending = set() for name in services_pending: @@ -47,10 +45,10 @@ def wait_for_service(service_list: List[str]) -> None: if conf.get("callback") is not None: conf["callback"](resp) # The service is up - except Exception: + except Exception as err: print(f"Still waiting for {name} to start...") if int(time.time()) > timeout: - raise RuntimeError(f"Timed out waiting for {name} to start") + raise RuntimeError(f"Timed out waiting for {name} to start with error: {err}") still_pending.add(name) time.sleep(3) services_pending = still_pending @@ -64,13 +62,11 @@ def wait_for_arangodb(): def wait_for_services(): """wait for the workspace, auth, and arango to start up""" - wait_for_service(["auth", "workspace", "arangodb"]) def wait_for_api(): """wait for the workspace, auth, arango, AND localhost:5000 to start up""" - wait_for_services() wait_for_service(["localhost"]) From 2e05ba7c16d3776ddb72bcabc0abe5b9731c6295 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Fri, 18 Dec 2020 14:01:49 -0800 Subject: [PATCH 639/732] Fix auth in wait_for.py --- relation_engine_server/utils/wait_for.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/relation_engine_server/utils/wait_for.py b/relation_engine_server/utils/wait_for.py index 05d7fb53..2cd35587 100644 --- a/relation_engine_server/utils/wait_for.py +++ b/relation_engine_server/utils/wait_for.py @@ -39,7 +39,8 @@ def wait_for_service(service_list: List[str]) -> None: for name in services_pending: try: conf = service_conf[name] - resp = requests.get(conf["url"], auth=conf.get("auth")) + auth = (conf.get("db_user"), conf.get("db_pass")) + resp = requests.get(conf["url"], auth=auth) if conf.get("raise_for_status"): resp.raise_for_status() if conf.get("callback") is not None: @@ -48,7 +49,9 @@ def wait_for_service(service_list: List[str]) -> None: except Exception as err: print(f"Still waiting for {name} to start...") if int(time.time()) > timeout: - raise RuntimeError(f"Timed out waiting for {name} to start with error: {err}") + raise RuntimeError( + f"Timed out waiting for {name} to start with error: {err}" + ) still_pending.add(name) time.sleep(3) services_pending = still_pending From 5e941bdf23e6035f0a546b27d482ec8959d2e123 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Fri, 18 Dec 2020 14:15:48 -0800 Subject: [PATCH 640/732] Debugging CI --- importers/djornl/parser.py | 2 +- relation_engine_server/utils/config.py | 2 +- relation_engine_server/utils/wait_for.py | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/importers/djornl/parser.py b/importers/djornl/parser.py index 41b671eb..ae79f23f 100644 --- a/importers/djornl/parser.py +++ b/importers/djornl/parser.py @@ -802,7 +802,7 @@ def format_summary(summary, output): value_width ) if summary.get("errors_total") > 0: - text_summary = text_summary + "\n" + "\n".join(summary.get("errors")) + text_summary = text_summary + "\n" + "\n".join(summary.get("errors")) return text_summary diff --git a/relation_engine_server/utils/config.py b/relation_engine_server/utils/config.py index 322f8790..d81accc6 100644 --- a/relation_engine_server/utils/config.py +++ b/relation_engine_server/utils/config.py @@ -31,7 +31,7 @@ def get_config(): db_readonly_user = os.environ.get("DB_READONLY_USER", db_user) db_readonly_pass = os.environ.get("DB_READONLY_PASS", db_pass) api_url = db_url + "/_db/" + db_name + "/_api" - + print(db_user, db_pass) return { "auth_url": auth_url, "workspace_url": workspace_url, diff --git a/relation_engine_server/utils/wait_for.py b/relation_engine_server/utils/wait_for.py index 2cd35587..2fe81d97 100644 --- a/relation_engine_server/utils/wait_for.py +++ b/relation_engine_server/utils/wait_for.py @@ -40,6 +40,7 @@ def wait_for_service(service_list: List[str]) -> None: try: conf = service_conf[name] auth = (conf.get("db_user"), conf.get("db_pass")) + print("auth is", auth) resp = requests.get(conf["url"], auth=auth) if conf.get("raise_for_status"): resp.raise_for_status() From 2575741854d2d3f740e0a1605688ecbfe4a93544 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Fri, 18 Dec 2020 14:31:08 -0800 Subject: [PATCH 641/732] Fix auth --- relation_engine_server/utils/wait_for.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/relation_engine_server/utils/wait_for.py b/relation_engine_server/utils/wait_for.py index 2fe81d97..4aed73c2 100644 --- a/relation_engine_server/utils/wait_for.py +++ b/relation_engine_server/utils/wait_for.py @@ -7,9 +7,10 @@ from relation_engine_server.utils.config import get_config from typing import List +_CONF = get_config() + def get_service_conf(): - _CONF = get_config() return { "arangodb": { "url": _CONF["api_url"] + "/collection", @@ -39,7 +40,7 @@ def wait_for_service(service_list: List[str]) -> None: for name in services_pending: try: conf = service_conf[name] - auth = (conf.get("db_user"), conf.get("db_pass")) + auth = (_CONF["db_user"], _CONF["db_pass"]) print("auth is", auth) resp = requests.get(conf["url"], auth=auth) if conf.get("raise_for_status"): From 122a8245f582e6f6ee6af9dc107567805d9d213b Mon Sep 17 00:00:00 2001 From: slebras Date: Mon, 21 Dec 2020 08:43:22 -0800 Subject: [PATCH 642/732] Adding examples and some basic validation to _from and _to fields --- .../samples/sample_ontology_link.yaml | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/spec/collections/samples/sample_ontology_link.yaml b/spec/collections/samples/sample_ontology_link.yaml index 9fb5fc21..1d811784 100644 --- a/spec/collections/samples/sample_ontology_link.yaml +++ b/spec/collections/samples/sample_ontology_link.yaml @@ -4,44 +4,58 @@ schema: "$schema": http://json-schema.org/draft-07/schema# type: object required: [_from, _to, created] - description: The _from sample node is associated with the _to taxon. + description: minimum necessary terms for sample -> ontology edge link. properties: _from: type: string description: the sample node _id (as found in sample_nodes collection) + examples: ["samples_nodes/465b1476-3699-4e6c-a06b-8d384fcc41f3_6d5999ee-42fb-4bad-a3b9-901aa1b490c5_f4bc367798eb923f77d7405031723908"] + pattern: ^[\w-]+\/[\w-]+_[\w-]+_[\w-]+ _to: type: string description: The _id of an ontology vertex, such as from ENVO, GO, etc. + examples: ["ENVO_terms/ENVO:01000221_v2019-03-14", 'GO_terms/GO:0047161_v2019-01-01'] + pattern: ^[\w-]+\/[\w-:]+ created: type: integer - description: timestamp of when the link was created + description: unix epoch of when the link was created + minimum: 0 createdby: type: string description: Who made this sample-ontology link? expired: type: integer - description: timestamp of when this link expires + description: unix epoch of when this link expires + minimum: 0 sample_id: type: string - description: uui identifier for sample object. corresponds to sample id provided by SampleService + description: uuid identifier for sample object. corresponds to sample id provided by SampleService + examples: ['465b1476-3699-4e6c-a06b-8d384fcc41f3'] sample_version: type: integer description: integer version of sample object (1, 2, etc.) + examples: [1, 2, 3] sample_version_uuid: type: string description: uuid identifier for sample object version in sample version collection + examples: ['6d5999ee-42fb-4bad-a3b9-901aa1b490c5'] sample_node_name: type: string description: name of sample node in Sample + examples: ['HRV003M16'] sample_node_uuid: type: string description: uuid identifier for sample node in sample nodes collection + examples: ['f4bc367798eb923f77d7405031723908'] sample_metadata_term: type: integer description: metadata term in sample associated with ontology term + examples: ['biome', 'ENIGMA:material', 'feature'] ontology_term: type: string description: identifier for term in ontology_collection + examples: ['ENVO:01000221', 'GO:0047161'] ontology_collection: type: string description: name of collection containing ontology_term + examples: ['ENVO_terms', 'GO_terms'] From 024f03bdaa0936f17566b1ea3865458aa2c7fefe Mon Sep 17 00:00:00 2001 From: slebras Date: Mon, 21 Dec 2020 09:13:19 -0800 Subject: [PATCH 643/732] changing sample_ontology_link to be a delta time-travel --- spec/collections/samples/sample_ontology_link.yaml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/spec/collections/samples/sample_ontology_link.yaml b/spec/collections/samples/sample_ontology_link.yaml index 1d811784..272bae62 100644 --- a/spec/collections/samples/sample_ontology_link.yaml +++ b/spec/collections/samples/sample_ontology_link.yaml @@ -1,17 +1,18 @@ name: sample_ontology_link type: edge +delta: true schema: "$schema": http://json-schema.org/draft-07/schema# type: object - required: [_from, _to, created] + required: [from, to, created, expired, sample_metadata_term] description: minimum necessary terms for sample -> ontology edge link. properties: - _from: + from: type: string description: the sample node _id (as found in sample_nodes collection) examples: ["samples_nodes/465b1476-3699-4e6c-a06b-8d384fcc41f3_6d5999ee-42fb-4bad-a3b9-901aa1b490c5_f4bc367798eb923f77d7405031723908"] pattern: ^[\w-]+\/[\w-]+_[\w-]+_[\w-]+ - _to: + to: type: string description: The _id of an ontology vertex, such as from ENVO, GO, etc. examples: ["ENVO_terms/ENVO:01000221_v2019-03-14", 'GO_terms/GO:0047161_v2019-01-01'] From 1d305d6776b4f7ee408f4a3a25c3c83809780f8f Mon Sep 17 00:00:00 2001 From: Zhenyuan Lu Date: Wed, 13 Jan 2021 16:56:39 -0500 Subject: [PATCH 644/732] add ontology_get_associated_samples --- ...yaml => GO_get_associated_ws_genomes.yaml} | 2 +- ...yaml => GO_get_terms_from_ws_objects.yaml} | 2 +- .../ontology_get_associated_samples.yaml | 50 +++++++++++++++++++ 3 files changed, 52 insertions(+), 2 deletions(-) rename spec/stored_queries/GO/{GO_get_associated_ws_objects.yaml => GO_get_associated_ws_genomes.yaml} (97%) rename spec/stored_queries/GO/{GO_get_terms_from_ws_obj.yaml => GO_get_terms_from_ws_objects.yaml} (97%) create mode 100644 spec/stored_queries/ontology/ontology_get_associated_samples.yaml diff --git a/spec/stored_queries/GO/GO_get_associated_ws_objects.yaml b/spec/stored_queries/GO/GO_get_associated_ws_genomes.yaml similarity index 97% rename from spec/stored_queries/GO/GO_get_associated_ws_objects.yaml rename to spec/stored_queries/GO/GO_get_associated_ws_genomes.yaml index 01e58914..195f53b3 100644 --- a/spec/stored_queries/GO/GO_get_associated_ws_objects.yaml +++ b/spec/stored_queries/GO/GO_get_associated_ws_genomes.yaml @@ -1,6 +1,6 @@ # Get the associated ws objects of this term -name: GO_get_associated_ws_objects +name: GO_get_associated_ws_genomes params: type: object required: [id, ts] diff --git a/spec/stored_queries/GO/GO_get_terms_from_ws_obj.yaml b/spec/stored_queries/GO/GO_get_terms_from_ws_objects.yaml similarity index 97% rename from spec/stored_queries/GO/GO_get_terms_from_ws_obj.yaml rename to spec/stored_queries/GO/GO_get_terms_from_ws_objects.yaml index f4c91999..7ccd5164 100644 --- a/spec/stored_queries/GO/GO_get_terms_from_ws_obj.yaml +++ b/spec/stored_queries/GO/GO_get_terms_from_ws_objects.yaml @@ -1,6 +1,6 @@ # Get the terms from a workspace object reference -name: GO_get_terms_from_ws_obj +name: GO_get_terms_from_ws_objects params: type: object required: [obj_ref, ts] diff --git a/spec/stored_queries/ontology/ontology_get_associated_samples.yaml b/spec/stored_queries/ontology/ontology_get_associated_samples.yaml new file mode 100644 index 00000000..2cdbeff7 --- /dev/null +++ b/spec/stored_queries/ontology/ontology_get_associated_samples.yaml @@ -0,0 +1,50 @@ +# Get all samples reference this term + +name: ontology_get_associated_samples +params: + type: object + required: [id, ts, "@onto_terms"] + properties: + id: + type: string + title: Document ID + description: Ontology id of the term you want to get all the ancestors of + limit: + type: integer + default: 20 + description: Maximum result limit + maximum: 1000 + offset: + type: integer + default: 0 + description: Result offset for pagination + maximum: 100000 + ts: + type: integer + title: Versioning timestamp + "@onto_terms": + type: string + title: Ontology terms collection name +query_prefix: WITH samples_nodes +query: | + LET results=( + FOR t in @@onto_terms + FILTER t.id == @id + FILTER t.created <= @ts AND t.expired > @ts + limit 1 + FOR v, e, p IN 1 INBOUND t sample_ontology_link + FILTER v.saved * 1000 >= t.created AND v.saved * 1000 < t.expired + AND e.created * 1000 <= @ts AND e.expired * 1000 > @ts + SORT v.id ASC + RETURN { + sample: v, + sample_metadata_key: e.sample_metadata_term + } + ) + LET total_count=COUNT(results) + LET limited=( + FOR r in results + LIMIT @offset, @limit + RETURN r + ) + RETURN {results: limited, total_count} From 8c76820d06a6fc76e51052cabfb3be4e00ec088f Mon Sep 17 00:00:00 2001 From: Zhenyuan Lu Date: Thu, 14 Jan 2021 01:35:09 -0500 Subject: [PATCH 645/732] rename GO_get_terms_from_ws_objects to GO_get_terms_from_ws_object --- ...ms_from_ws_objects.yaml => GO_get_terms_from_ws_object.yaml} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename spec/stored_queries/GO/{GO_get_terms_from_ws_objects.yaml => GO_get_terms_from_ws_object.yaml} (97%) diff --git a/spec/stored_queries/GO/GO_get_terms_from_ws_objects.yaml b/spec/stored_queries/GO/GO_get_terms_from_ws_object.yaml similarity index 97% rename from spec/stored_queries/GO/GO_get_terms_from_ws_objects.yaml rename to spec/stored_queries/GO/GO_get_terms_from_ws_object.yaml index 7ccd5164..ba2a40a7 100644 --- a/spec/stored_queries/GO/GO_get_terms_from_ws_objects.yaml +++ b/spec/stored_queries/GO/GO_get_terms_from_ws_object.yaml @@ -1,6 +1,6 @@ # Get the terms from a workspace object reference -name: GO_get_terms_from_ws_objects +name: GO_get_terms_from_ws_object params: type: object required: [obj_ref, ts] From 95756633d340a1a1da6d4e149a382b1e4a4d1949 Mon Sep 17 00:00:00 2001 From: Zhenyuan Lu Date: Wed, 20 Jan 2021 11:01:12 -0500 Subject: [PATCH 646/732] clarify @onto_terms --- .../ontology/ontology_get_associated_samples.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spec/stored_queries/ontology/ontology_get_associated_samples.yaml b/spec/stored_queries/ontology/ontology_get_associated_samples.yaml index 2cdbeff7..ad79488d 100644 --- a/spec/stored_queries/ontology/ontology_get_associated_samples.yaml +++ b/spec/stored_queries/ontology/ontology_get_associated_samples.yaml @@ -8,7 +8,7 @@ params: id: type: string title: Document ID - description: Ontology id of the term you want to get all the ancestors of + description: Ontology ID of the term you want to get all the associated samples limit: type: integer default: 20 @@ -25,6 +25,8 @@ params: "@onto_terms": type: string title: Ontology terms collection name + description: the name of the vertex collection holding the ontology term data + examples: [ENVO_terms, GO_terms] query_prefix: WITH samples_nodes query: | LET results=( From 2c7e9d72dee9cbafc19730c69c8fe643ff4830c3 Mon Sep 17 00:00:00 2001 From: Zhenyuan Lu Date: Thu, 28 Jan 2021 10:59:22 -0500 Subject: [PATCH 647/732] add samples acl info retrieval in ontology_get_associated_samples query --- .../ontology/ontology_get_associated_samples.yaml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/spec/stored_queries/ontology/ontology_get_associated_samples.yaml b/spec/stored_queries/ontology/ontology_get_associated_samples.yaml index ad79488d..e3054ef1 100644 --- a/spec/stored_queries/ontology/ontology_get_associated_samples.yaml +++ b/spec/stored_queries/ontology/ontology_get_associated_samples.yaml @@ -27,20 +27,21 @@ params: title: Ontology terms collection name description: the name of the vertex collection holding the ontology term data examples: [ENVO_terms, GO_terms] -query_prefix: WITH samples_nodes +query_prefix: WITH samples_nodes, samples_version, samples_sample query: | LET results=( FOR t in @@onto_terms FILTER t.id == @id FILTER t.created <= @ts AND t.expired > @ts limit 1 - FOR v, e, p IN 1 INBOUND t sample_ontology_link - FILTER v.saved * 1000 >= t.created AND v.saved * 1000 < t.expired - AND e.created * 1000 <= @ts AND e.expired * 1000 > @ts - SORT v.id ASC + FOR v, e, p IN 3 OUTBOUND t INBOUND sample_ontology_link, samples_nodes_edge, samples_ver_edge + FILTER p.vertices[1].saved * 1000 >= t.created AND p.vertices[1].saved * 1000 < t.expired + AND p.edges[0].created * 1000 <= @ts AND p.edges[0].expired * 1000 > @ts + SORT p.vertices[1].id ASC RETURN { - sample: v, - sample_metadata_key: e.sample_metadata_term + sample: p.vertices[1], + sample_metadata_key: p.edges[0].sample_metadata_term, + sample_access: v } ) LET total_count=COUNT(results) From c803d3f5e417c513909f87c0a833943410ccc5ad Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Thu, 28 Jan 2021 15:28:21 -0800 Subject: [PATCH 648/732] Additional collections for WITH clause to fix query --- spec/stored_queries/ws/ws_fetch_related_data.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/stored_queries/ws/ws_fetch_related_data.yaml b/spec/stored_queries/ws/ws_fetch_related_data.yaml index 38a8d64f..67215233 100644 --- a/spec/stored_queries/ws/ws_fetch_related_data.yaml +++ b/spec/stored_queries/ws/ws_fetch_related_data.yaml @@ -6,7 +6,7 @@ params: obj_key: type: string description: Key of the wsprov_object to search on -query_prefix: WITH ws_type_version +query_prefix: WITH ws_type_version, ws_object, ws_workspace query: | LET obj_id = concat('ws_object_version/', @obj_key) FOR obj IN ws_object_version From 782b4164066ce7508d487c09a90d65256b1a85a8 Mon Sep 17 00:00:00 2001 From: Shane Canon Date: Thu, 28 Jan 2021 21:55:23 -0800 Subject: [PATCH 649/732] Update config.py Add annotation for type to hopefully fix error --- importers/utils/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/importers/utils/config.py b/importers/utils/config.py index c5131b95..47804b50 100644 --- a/importers/utils/config.py +++ b/importers/utils/config.py @@ -5,7 +5,7 @@ import os -REQUIRED = [] +REQUIRED = [] # type: List[str] OPTIONAL = ["AUTH_TOKEN", "API_URL"] DEFAULTS = { "AUTH_TOKEN": "admin_token", # test default From e545f243098d60d12ce3730fcf1524b0cf78064a Mon Sep 17 00:00:00 2001 From: Shane Canon Date: Thu, 28 Jan 2021 22:54:22 -0800 Subject: [PATCH 650/732] Update config.py Add import for list type --- importers/utils/config.py | 1 + 1 file changed, 1 insertion(+) diff --git a/importers/utils/config.py b/importers/utils/config.py index 47804b50..a52f549e 100644 --- a/importers/utils/config.py +++ b/importers/utils/config.py @@ -3,6 +3,7 @@ variables and a set of default values. """ import os +from typing import List REQUIRED = [] # type: List[str] From 4cf5770a3b67ff6ef0e6ee815647aa86e96c4777 Mon Sep 17 00:00:00 2001 From: Shane Canon Date: Thu, 28 Jan 2021 23:06:26 -0800 Subject: [PATCH 651/732] Update config.py Try to avoid another complaint about an unused import. --- importers/utils/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/importers/utils/config.py b/importers/utils/config.py index a52f549e..da906885 100644 --- a/importers/utils/config.py +++ b/importers/utils/config.py @@ -6,7 +6,7 @@ from typing import List -REQUIRED = [] # type: List[str] +REQUIRED: List[str] = [] OPTIONAL = ["AUTH_TOKEN", "API_URL"] DEFAULTS = { "AUTH_TOKEN": "admin_token", # test default From c569ea94bf962c6558dd0b0da5df7dc4e5712552 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Fri, 29 Jan 2021 15:09:20 -0800 Subject: [PATCH 652/732] Show the source (file path or URL) of the specs that we update --- relation_engine_server/api_versions/api_v1.py | 9 +++++++-- relation_engine_server/test/test_api_v1.py | 6 +++++- relation_engine_server/utils/pull_spec.py | 18 +++++++++++++++--- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/relation_engine_server/api_versions/api_v1.py b/relation_engine_server/api_versions/api_v1.py index 05561321..6f18fe58 100644 --- a/relation_engine_server/api_versions/api_v1.py +++ b/relation_engine_server/api_versions/api_v1.py @@ -145,8 +145,13 @@ def update_specs(): auth.require_auth_token(["RE_ADMIN"]) init_collections = "init_collections" in flask.request.args release_url = flask.request.args.get("release_url") - pull_spec.download_specs(init_collections, release_url, reset=True) - return flask.jsonify({"status": "updated"}) + update_name = pull_spec.download_specs(init_collections, release_url, reset=True) + return flask.jsonify( + { + "status": "updated", + "updated_from": update_name, + } + ) @api_v1.route("/documents", methods=["PUT"]) diff --git a/relation_engine_server/test/test_api_v1.py b/relation_engine_server/test/test_api_v1.py index 1afdc896..d0f68695 100644 --- a/relation_engine_server/test/test_api_v1.py +++ b/relation_engine_server/test/test_api_v1.py @@ -138,7 +138,11 @@ def test_update_specs(self): ) resp_json = resp.json() self.assertEqual(resp.status_code, 200) - self.assertTrue(len(resp_json["status"])) + self.assertEqual(resp_json["status"], "updated") + self.assertEqual( + resp_json["updated_from"], + "/app/relation_engine_server/test/spec_release/spec.tar.gz", + ) # delete the SPEC_TEST_READY env var as it is no longer true os.environ.pop("SPEC_TEST_READY", None) diff --git a/relation_engine_server/utils/pull_spec.py b/relation_engine_server/utils/pull_spec.py index 344da84c..cc96bff7 100644 --- a/relation_engine_server/utils/pull_spec.py +++ b/relation_engine_server/utils/pull_spec.py @@ -6,7 +6,7 @@ import json import glob import yaml - +from typing import Optional from relation_engine_server.utils import arango_client from relation_engine_server.utils.config import get_config @@ -14,8 +14,17 @@ _CONF = get_config() -def download_specs(init_collections=True, release_url=None, reset=False): - """Check and download the latest spec and extract it to the spec path.""" +def download_specs( + init_collections: bool = True, + release_url: Optional[str] = None, + reset: bool = False, +) -> Optional[str]: + """ + Check and download the latest spec and extract it to the spec path. + Returns: + The name or path of the release used to update the specs + """ + update_name: Optional[str] = None if reset or not os.path.exists(_CONF["spec_paths"]["root"]): # Remove the spec directory, ignoring if it is already missing shutil.rmtree(_CONF["spec_paths"]["root"], ignore_errors=True) @@ -23,12 +32,14 @@ def download_specs(init_collections=True, release_url=None, reset=False): temp_dir = tempfile.mkdtemp() # Download and extract a new release to /spec/repo if _CONF["spec_release_path"]: + update_name = _CONF["spec_release_path"] _extract_tarball(_CONF["spec_release_path"], temp_dir) else: if _CONF["spec_release_url"]: tarball_url = _CONF["spec_release_url"] else: tarball_url = _fetch_github_release_url() + update_name = tarball_url resp = requests.get(tarball_url, stream=True) with tempfile.NamedTemporaryFile() as temp_file: # The temp file will be closed/deleted when the context ends @@ -47,6 +58,7 @@ def download_specs(init_collections=True, release_url=None, reset=False): if init_collections: do_init_collections() do_init_views() + return update_name def do_init_collections(): From 16a114db2d62bf07ef6fb4035a7fd8b9208ea5a2 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Fri, 29 Jan 2021 15:11:05 -0800 Subject: [PATCH 653/732] Update changelog and version for the API --- CHANGELOG.md | 4 ++++ VERSION | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2993cc02..332041bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.0.12] - 2021-01-29 +### Added +- In the API, show the source file path or URL when updating the specs + ## [0.0.11] - 2020-11-19 ### Changed - DJORNL edge spec (`spec/collections/djornl/djornl_edge.yaml``) updated to indicate whether or not the edge is directed. diff --git a/VERSION b/VERSION index 2cfabea2..8cbf02c3 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.0.11 +0.0.12 From 9557414ab2b791e8b02441a9cec0c06ee14903c1 Mon Sep 17 00:00:00 2001 From: Zhenyuan Lu Date: Thu, 4 Feb 2021 11:44:31 -0500 Subject: [PATCH 654/732] add sample acls check logic to ontology_get_associated_samples --- .../ontology_get_associated_samples.yaml | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/spec/stored_queries/ontology/ontology_get_associated_samples.yaml b/spec/stored_queries/ontology/ontology_get_associated_samples.yaml index e3054ef1..d890eeed 100644 --- a/spec/stored_queries/ontology/ontology_get_associated_samples.yaml +++ b/spec/stored_queries/ontology/ontology_get_associated_samples.yaml @@ -3,12 +3,16 @@ name: ontology_get_associated_samples params: type: object - required: [id, ts, "@onto_terms"] + required: [id, ts, user_id, "@onto_terms"] properties: id: type: string title: Document ID description: Ontology ID of the term you want to get all the associated samples + user_id: + type: string + title: User ID + description: User ID used for checking samples access control limit: type: integer default: 20 @@ -45,9 +49,18 @@ query: | } ) LET total_count=COUNT(results) - LET limited=( + LET filtered=( FOR r in results + FILTER @user_id == r.sample_access.acls.owner + OR @user_id IN r.sample_access.acls.admin + OR @user_id IN r.sample_access.acls.read + OR r.sample_access_acls.pubread + RETURN KEEP(r, 'sample', 'sample_metadata_key') + ) + LET total_accessible_count=COUNT(filtered) + LET limited=( + FOR r in filtered LIMIT @offset, @limit RETURN r ) - RETURN {results: limited, total_count} + RETURN {results: limited, total_count, total_accessible_count} From a64e1f9ce31d28d03afdee85243356cfbc0e8b30 Mon Sep 17 00:00:00 2001 From: Zhenyuan Lu Date: Fri, 5 Feb 2021 10:32:55 -0500 Subject: [PATCH 655/732] minor bug fix --- .../ontology/ontology_get_associated_samples.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/stored_queries/ontology/ontology_get_associated_samples.yaml b/spec/stored_queries/ontology/ontology_get_associated_samples.yaml index d890eeed..8df7b506 100644 --- a/spec/stored_queries/ontology/ontology_get_associated_samples.yaml +++ b/spec/stored_queries/ontology/ontology_get_associated_samples.yaml @@ -54,7 +54,7 @@ query: | FILTER @user_id == r.sample_access.acls.owner OR @user_id IN r.sample_access.acls.admin OR @user_id IN r.sample_access.acls.read - OR r.sample_access_acls.pubread + OR r.sample_access.acls.pubread RETURN KEEP(r, 'sample', 'sample_metadata_key') ) LET total_accessible_count=COUNT(filtered) From 9e7806b7fa0262caee312ad69b09a17cb02ab130 Mon Sep 17 00:00:00 2001 From: Zhenyuan Lu Date: Fri, 19 Feb 2021 19:56:49 -0500 Subject: [PATCH 656/732] returning sample acls info in ontology_get_associated_samples --- .../ontology/ontology_get_associated_samples.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/stored_queries/ontology/ontology_get_associated_samples.yaml b/spec/stored_queries/ontology/ontology_get_associated_samples.yaml index 8df7b506..86db9e7d 100644 --- a/spec/stored_queries/ontology/ontology_get_associated_samples.yaml +++ b/spec/stored_queries/ontology/ontology_get_associated_samples.yaml @@ -55,7 +55,7 @@ query: | OR @user_id IN r.sample_access.acls.admin OR @user_id IN r.sample_access.acls.read OR r.sample_access.acls.pubread - RETURN KEEP(r, 'sample', 'sample_metadata_key') + RETURN r ) LET total_accessible_count=COUNT(filtered) LET limited=( From 872ec8a20c5d3821d8aed175408bbfe58cf13b38 Mon Sep 17 00:00:00 2001 From: slebras Date: Wed, 3 Mar 2021 17:27:04 -0800 Subject: [PATCH 657/732] removing regexes --- spec/collections/samples/sample_ontology_link.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/spec/collections/samples/sample_ontology_link.yaml b/spec/collections/samples/sample_ontology_link.yaml index 272bae62..f38232df 100644 --- a/spec/collections/samples/sample_ontology_link.yaml +++ b/spec/collections/samples/sample_ontology_link.yaml @@ -11,12 +11,10 @@ schema: type: string description: the sample node _id (as found in sample_nodes collection) examples: ["samples_nodes/465b1476-3699-4e6c-a06b-8d384fcc41f3_6d5999ee-42fb-4bad-a3b9-901aa1b490c5_f4bc367798eb923f77d7405031723908"] - pattern: ^[\w-]+\/[\w-]+_[\w-]+_[\w-]+ to: type: string description: The _id of an ontology vertex, such as from ENVO, GO, etc. examples: ["ENVO_terms/ENVO:01000221_v2019-03-14", 'GO_terms/GO:0047161_v2019-01-01'] - pattern: ^[\w-]+\/[\w-:]+ created: type: integer description: unix epoch of when the link was created From 4d35aff414457e99abec746dd68a946a614835ca Mon Sep 17 00:00:00 2001 From: slebras Date: Thu, 4 Mar 2021 11:42:39 -0800 Subject: [PATCH 658/732] fixing type information for sample_metadata_term in sample_ontology_link.yaml --- spec/collections/samples/sample_ontology_link.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/collections/samples/sample_ontology_link.yaml b/spec/collections/samples/sample_ontology_link.yaml index f38232df..cd2f6082 100644 --- a/spec/collections/samples/sample_ontology_link.yaml +++ b/spec/collections/samples/sample_ontology_link.yaml @@ -47,7 +47,7 @@ schema: description: uuid identifier for sample node in sample nodes collection examples: ['f4bc367798eb923f77d7405031723908'] sample_metadata_term: - type: integer + type: string description: metadata term in sample associated with ontology term examples: ['biome', 'ENIGMA:material', 'feature'] ontology_term: From f565981cb2443704a713138f30b500a8039a4c57 Mon Sep 17 00:00:00 2001 From: slebras Date: Thu, 4 Mar 2021 13:52:12 -0800 Subject: [PATCH 659/732] removing deltaloader requirement and changing from and to fields --- spec/collections/samples/sample_ontology_link.yaml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/spec/collections/samples/sample_ontology_link.yaml b/spec/collections/samples/sample_ontology_link.yaml index cd2f6082..1236def3 100644 --- a/spec/collections/samples/sample_ontology_link.yaml +++ b/spec/collections/samples/sample_ontology_link.yaml @@ -1,17 +1,16 @@ name: sample_ontology_link type: edge -delta: true schema: "$schema": http://json-schema.org/draft-07/schema# type: object required: [from, to, created, expired, sample_metadata_term] description: minimum necessary terms for sample -> ontology edge link. properties: - from: + _from: type: string description: the sample node _id (as found in sample_nodes collection) examples: ["samples_nodes/465b1476-3699-4e6c-a06b-8d384fcc41f3_6d5999ee-42fb-4bad-a3b9-901aa1b490c5_f4bc367798eb923f77d7405031723908"] - to: + _to: type: string description: The _id of an ontology vertex, such as from ENVO, GO, etc. examples: ["ENVO_terms/ENVO:01000221_v2019-03-14", 'GO_terms/GO:0047161_v2019-01-01'] From 43b200b1b67648fa9702cecfeb657d1a44025e91 Mon Sep 17 00:00:00 2001 From: slebras Date: Thu, 4 Mar 2021 14:02:03 -0800 Subject: [PATCH 660/732] changing sample_ontology_link required fields --- spec/collections/samples/sample_ontology_link.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/collections/samples/sample_ontology_link.yaml b/spec/collections/samples/sample_ontology_link.yaml index 1236def3..8af7ae92 100644 --- a/spec/collections/samples/sample_ontology_link.yaml +++ b/spec/collections/samples/sample_ontology_link.yaml @@ -3,7 +3,7 @@ type: edge schema: "$schema": http://json-schema.org/draft-07/schema# type: object - required: [from, to, created, expired, sample_metadata_term] + required: [_from, _to, created, expired, sample_metadata_term] description: minimum necessary terms for sample -> ontology edge link. properties: _from: From 209d18955c7663d9dad853980e52f33335d6115b Mon Sep 17 00:00:00 2001 From: Zhenyuan Lu Date: Fri, 5 Mar 2021 10:58:55 -0500 Subject: [PATCH 661/732] update get_associated_samples for changes in sample_ontology_link edge --- .../ontology/ontology_get_associated_samples.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/stored_queries/ontology/ontology_get_associated_samples.yaml b/spec/stored_queries/ontology/ontology_get_associated_samples.yaml index 86db9e7d..09cf9ee1 100644 --- a/spec/stored_queries/ontology/ontology_get_associated_samples.yaml +++ b/spec/stored_queries/ontology/ontology_get_associated_samples.yaml @@ -40,7 +40,7 @@ query: | limit 1 FOR v, e, p IN 3 OUTBOUND t INBOUND sample_ontology_link, samples_nodes_edge, samples_ver_edge FILTER p.vertices[1].saved * 1000 >= t.created AND p.vertices[1].saved * 1000 < t.expired - AND p.edges[0].created * 1000 <= @ts AND p.edges[0].expired * 1000 > @ts + AND p.edges[0].created <= @ts AND p.edges[0].expired > @ts SORT p.vertices[1].id ASC RETURN { sample: p.vertices[1], From b8403706294c140c833072ef5cd3c2c28539924f Mon Sep 17 00:00:00 2001 From: Zhenyuan Lu Date: Mon, 22 Mar 2021 12:22:41 -0400 Subject: [PATCH 662/732] update ontology_get_associated_samples for update in sample service --- .../ontology/ontology_get_associated_samples.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/stored_queries/ontology/ontology_get_associated_samples.yaml b/spec/stored_queries/ontology/ontology_get_associated_samples.yaml index 09cf9ee1..50ff2715 100644 --- a/spec/stored_queries/ontology/ontology_get_associated_samples.yaml +++ b/spec/stored_queries/ontology/ontology_get_associated_samples.yaml @@ -39,7 +39,7 @@ query: | FILTER t.created <= @ts AND t.expired > @ts limit 1 FOR v, e, p IN 3 OUTBOUND t INBOUND sample_ontology_link, samples_nodes_edge, samples_ver_edge - FILTER p.vertices[1].saved * 1000 >= t.created AND p.vertices[1].saved * 1000 < t.expired + FILTER p.vertices[1].saved >= t.created AND p.vertices[1].saved < t.expired AND p.edges[0].created <= @ts AND p.edges[0].expired > @ts SORT p.vertices[1].id ASC RETURN { From 2b11a0625e594ca76f23a1e94e21ea84c39305ab Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 26 Mar 2021 00:20:56 +0000 Subject: [PATCH 663/732] Bump pyyaml from 5.1.1 to 5.4 Bumps [pyyaml](https://github.com/yaml/pyyaml) from 5.1.1 to 5.4. - [Release notes](https://github.com/yaml/pyyaml/releases) - [Changelog](https://github.com/yaml/pyyaml/blob/master/CHANGES) - [Commits](https://github.com/yaml/pyyaml/compare/5.1.1...5.4) Signed-off-by: dependabot[bot] --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 4b48e947..53c43343 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,5 +8,5 @@ requests==2.20.0 jsonpointer==2.0 jsonschema==3.2.0 jsonschema[format]==3.2.0 -pyyaml==5.1.1 +pyyaml==5.4 rfc3987==1.3.8 From da641cd2678620551cfd096724659a5b14ff7533 Mon Sep 17 00:00:00 2001 From: Zhenyuan Lu Date: Tue, 20 Apr 2021 13:14:08 -0400 Subject: [PATCH 664/732] add ontology_get_term_by_name query --- .../ontology/ontology_get_term_by_name.yaml | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 spec/stored_queries/ontology/ontology_get_term_by_name.yaml diff --git a/spec/stored_queries/ontology/ontology_get_term_by_name.yaml b/spec/stored_queries/ontology/ontology_get_term_by_name.yaml new file mode 100644 index 00000000..3cbe5aea --- /dev/null +++ b/spec/stored_queries/ontology/ontology_get_term_by_name.yaml @@ -0,0 +1,41 @@ +# Get ontology term by searching name + +name: ontology_get_term_by_name +params: + type: object + required: [name, ts, "@onto_terms", "@onto_edges"] + properties: + name: + type: string + title: Ontology term's name + description: Name of the Ontology term you want to get + examples: ["terrestrial biome"] + ancestor_term: + type: string + title: Ancestor ontology term + description: Optional ancestor ontology term + examples: ["ENVO:00000428"] + ts: + type: integer + title: Versioning timestamp + "@onto_terms": + type: string + title: Ontology terms collection name + examples: ["ENVO_terms"] + "@onto_edges": + type: string + title: Ontology edges collection name + examples: ["ENVO_edges"] +query_prefix: WITH @@onto_terms +query: | + LET ancestor_term_null=IS_NULL(@ancestor_term) OR LENGTH(@ancestor_term) == 0 + FOR t in @@onto_terms + FILTER LOWER(t.name) == LOWER(@name) + FILTER t.created <= @ts AND t.expired >= @ts + limit 1 + FOR v, e, p IN 1..100 OUTBOUND t @@onto_edges + FILTER ancestor_term_null OR v.id == @ancestor_term + FILTER p.edges[*].created ALL <= @ts + AND p.edges[*].expired ALL >= @ts + AND p.edges[*].type ALL == "is_a" + RETURN DISTINCT t From b1592bb58a0880a94977f342218369a53775d99f Mon Sep 17 00:00:00 2001 From: Zhenyuan Lu Date: Thu, 22 Apr 2021 12:58:37 -0400 Subject: [PATCH 665/732] add tests for stored_queries for ontology --- spec/test/stored_queries/test_ontology.py | 389 ++++++++++++++++++++++ 1 file changed, 389 insertions(+) create mode 100644 spec/test/stored_queries/test_ontology.py diff --git a/spec/test/stored_queries/test_ontology.py b/spec/test/stored_queries/test_ontology.py new file mode 100644 index 00000000..e19e8871 --- /dev/null +++ b/spec/test/stored_queries/test_ontology.py @@ -0,0 +1,389 @@ +""" +Tests for the ontology stored queries. + +These tests run within the re_api docker image, and require access to the ArangoDB, auth, and workspace images. +""" +import json +import time +import unittest +import requests + +from spec.test.helpers import ( + get_config, + create_test_docs, + check_spec_test_env, +) + +_CONF = get_config() +_NOW = int(time.time() * 1000) + + +class TestOntology(unittest.TestCase): + @classmethod + def setUpClass(cls): + """Create test documents""" + + check_spec_test_env() + term_docs = [ + { + "_key": "1", + "id": "ENVO:00000446", + "name": "terrestrial biome", + "type": "CLASS", + "namespace": "ENVO", + "alt_ids": [], + "def": {"val": ""}, + "comments": [], + "subsets": [], + "synonyms": [], + "xrefs": [], + }, + { + "_key": "2", + "id": "ENVO:00000428", + "name": "biome", + "type": "CLASS", + "namespace": "ENVO", + "alt_ids": [], + "def": {"val": ""}, + "comments": [], + "subsets": [], + "synonyms": [], + "xrefs": [], + }, + { + "_key": "3", + "id": "ENVO:01001110", + "name": "ecosystem", + "type": "CLASS", + "namespace": "ENVO", + "alt_ids": [], + "def": {"val": ""}, + "comments": [], + "subsets": [], + "synonyms": [], + "xrefs": [], + }, + { + "_key": "4", + "id": "ENVO:01000254", + "name": "environmental system", + "type": "CLASS", + "namespace": "ENVO", + "alt_ids": [], + "def": {"val": ""}, + "comments": [], + "subsets": [], + "synonyms": [], + "xrefs": [], + }, + { + "_key": "5", + "id": "ENVO:00002030", + "name": "aquatic biome", + "type": "CLASS", + "namespace": "ENVO", + "alt_ids": [], + "def": {"val": ""}, + "comments": [], + "subsets": [], + "synonyms": [], + "xrefs": [], + }, + ] + edge_docs = [ + { + "_from": "ENVO_terms/1", + "_to": "ENVO_terms/2", + "from": "1", + "to": "2", + "id": "1", + "type": "is_a", + }, + { + "_from": "ENVO_terms/2", + "_to": "ENVO_terms/3", + "from": "2", + "to": "3", + "id": "2", + "type": "is_a", + }, + { + "_from": "ENVO_terms/3", + "_to": "ENVO_terms/4", + "from": "3", + "to": "4", + "id": "3", + "type": "is_a", + }, + { + "_from": "ENVO_terms/5", + "_to": "ENVO_terms/2", + "from": "5", + "to": "2", + "id": "4", + "type": "is_a", + }, + ] + _create_delta_test_docs("ENVO_terms", term_docs) + _create_delta_test_docs("ENVO_edges", edge_docs, edge=True) + + def test_get_term_by_name(self): + """Test query of retrieving onotlogy term by searching name""" + resp1 = requests.post( + _CONF["re_api_url"] + "/api/v1/query_results", + params={"stored_query": "ontology_get_term_by_name"}, + data=json.dumps( + { + "ts": _NOW, + "name": "terrestrial biome", + "ancestor_term": "ENVO:01001110", + "@onto_terms": "ENVO_terms", + "@onto_edges": "ENVO_edges", + } + ), + ).json() + self.assertEqual(resp1["count"], 1) + ids = [r["id"] for r in resp1["results"]] + self.assertEqual(ids, ["ENVO:00000446"]) + + resp2 = requests.post( + _CONF["re_api_url"] + "/api/v1/query_results", + params={"stored_query": "ontology_get_term_by_name"}, + data=json.dumps( + { + "ts": _NOW, + "name": "terrestrial", + "ancestor_term": "ENVO:01001110", + "@onto_terms": "ENVO_terms", + "@onto_edges": "ENVO_edges", + } + ), + ).json() + self.assertEqual(resp2["count"], 0) + + resp3 = requests.post( + _CONF["re_api_url"] + "/api/v1/query_results", + params={"stored_query": "ontology_get_term_by_name"}, + data=json.dumps( + { + "ts": _NOW, + "name": "terrestrial biome", + "ancestor_term": "ENVO:00002030", + "@onto_terms": "ENVO_terms", + "@onto_edges": "ENVO_edges", + } + ), + ).json() + self.assertEqual(resp3["count"], 0) + + resp4 = requests.post( + _CONF["re_api_url"] + "/api/v1/query_results", + params={"stored_query": "ontology_get_term_by_name"}, + data=json.dumps( + { + "ts": _NOW, + "name": "terrestrial biome", + "ancestor_term": "", + "@onto_terms": "ENVO_terms", + "@onto_edges": "ENVO_edges", + } + ), + ).json() + self.assertEqual(resp4["count"], 1) + ids = [r["id"] for r in resp4["results"]] + self.assertEqual(ids, ["ENVO:00000446"]) + + def test_get_children(self): + """Test query of ontology children.""" + resp = requests.post( + _CONF["re_api_url"] + "/api/v1/query_results", + params={"stored_query": "ontology_get_children"}, + data=json.dumps( + { + "id": "ENVO:00000428", + "ts": _NOW, + "@onto_terms": "ENVO_terms", + "@onto_edges": "ENVO_edges", + } + ), + ).json() + self.assertEqual(resp["count"], 2) + ids = [r["term"]["id"] for r in resp["results"]] + self.assertEqual(ids, ["ENVO:00000446", "ENVO:00002030"]) + + def test_get_parents(self): + """Test query of ontology parents.""" + resp = requests.post( + _CONF["re_api_url"] + "/api/v1/query_results", + params={"stored_query": "ontology_get_parents"}, + data=json.dumps( + { + "id": "ENVO:00000428", + "ts": _NOW, + "@onto_terms": "ENVO_terms", + "@onto_edges": "ENVO_edges", + } + ), + ).json() + self.assertEqual(resp["count"], 1) + ids = [r["term"]["id"] for r in resp["results"]] + self.assertEqual(ids, ["ENVO:01001110"]) + + def test_get_descendants(self): + """Test query of ontology descendants.""" + resp = requests.post( + _CONF["re_api_url"] + "/api/v1/query_results", + params={"stored_query": "ontology_get_descendants"}, + data=json.dumps( + { + "id": "ENVO:01001110", + "ts": _NOW, + "@onto_terms": "ENVO_terms", + "@onto_edges": "ENVO_edges", + } + ), + ).json() + self.assertEqual(resp["count"], 3) + ids = [r["term"]["id"] for r in resp["results"]] + self.assertEqual(ids, ["ENVO:00000446", "ENVO:00000428", "ENVO:00002030"]) + + def test_get_ancestors(self): + """Test query of ontology ancestors.""" + resp = requests.post( + _CONF["re_api_url"] + "/api/v1/query_results", + params={"stored_query": "ontology_get_ancestors"}, + data=json.dumps( + { + "id": "ENVO:00000446", + "ts": _NOW, + "@onto_terms": "ENVO_terms", + "@onto_edges": "ENVO_edges", + } + ), + ).json() + self.assertEqual(resp["count"], 3) + ids = [r["term"]["id"] for r in resp["results"]] + self.assertEqual(ids, ["ENVO:00000428", "ENVO:01000254", "ENVO:01001110"]) + + def test_get_siblings(self): + """Test query of ontology siblings.""" + resp = requests.post( + _CONF["re_api_url"] + "/api/v1/query_results", + params={"stored_query": "ontology_get_siblings"}, + data=json.dumps( + { + "id": "ENVO:00000446", + "ts": _NOW, + "@onto_terms": "ENVO_terms", + "@onto_edges": "ENVO_edges", + } + ), + ).json() + self.assertEqual(resp["count"], 1) + ids = [r["id"] for r in resp["results"]] + self.assertEqual(ids, ["ENVO:00002030"]) + + def test_get_terms(self): + """Test query of ontology terms.""" + resp = requests.post( + _CONF["re_api_url"] + "/api/v1/query_results", + params={"stored_query": "ontology_get_terms"}, + data=json.dumps( + { + "ids": ["ENVO:00000446", "ENVO:00002030", "abcd"], + "ts": _NOW, + "@onto_terms": "ENVO_terms", + } + ), + ).json() + self.assertEqual(resp["count"], 2) + ids = [r["id"] for r in resp["results"]] + self.assertEqual(ids, ["ENVO:00000446", "ENVO:00002030"]) + + +# -- Test helpers + + +def _run_search_sciname( + self, ranks, include_strains, expected_count, expected_sci_names +): + """ + Helper to run the taxonomy_search_sci_name query and make some standard + assertions on the response. + """ + data = { + "ts": _NOW, + "search_text": "prefix:bac", + "@taxon_coll": "ncbi_taxon", + "sciname_field": "scientific_name", + } + if ranks is not None: + data["ranks"] = ranks + if include_strains is not None: + data["include_strains"] = include_strains + resp = requests.post( + _CONF["re_api_url"] + "/api/v1/query_results", + params={"stored_query": "taxonomy_search_sci_name"}, + data=json.dumps(data), + ).json() + result = resp["results"][0] + self.assertEqual(result["total_count"], expected_count) + names = {r["scientific_name"] for r in result["results"]} + self.assertEqual(names, expected_sci_names) + + +def _ws_defaults(data): + """Set some defaults for the required workspace fields.""" + defaults = { + "owner": "owner", + "max_obj_id": 1, + "lock_status": "n", + "name": "wsname", + "mod_epoch": 1, + "is_public": True, + "is_deleted": False, + "metadata": {"narrative_nice_name": "narrname"}, + } + # Merge the data with the above defaults + return dict(defaults, **data) + + +def _construct_ws_obj_ver(wsid, objid, ver, is_public=False): + """Test helper to create a ws_object_version vertex.""" + return { + "_key": f"{wsid}:{objid}:{ver}", + "workspace_id": wsid, + "object_id": objid, + "version": ver, + "name": f"obj_name{objid}", + "hash": "xyz", + "size": 100, + "epoch": 0, + "deleted": False, + "is_public": is_public, + } + + +def _construct_ws_obj(wsid, objid, is_public=False): + """Test helper to create a ws_object vertex.""" + return { + "_key": f"{wsid}:{objid}", + "workspace_id": wsid, + "object_id": objid, + "deleted": False, + "is_public": is_public, + } + + +def _create_delta_test_docs(coll_name, docs, edge=False): + """Add in delta required fields.""" + if edge: + for doc in docs: + # Replicate the time-travel system by just setting 'from' and 'to' to the keys + doc["from"] = doc["_from"].split("/")[1] + doc["to"] = doc["_to"].split("/")[1] + for doc in docs: + doc["expired"] = 9007199254740991 + doc["created"] = 0 + create_test_docs(coll_name, docs) From f727ed80b971fd37b9ee646da762fed3f36feb9a Mon Sep 17 00:00:00 2001 From: Zhenyuan Lu Date: Thu, 22 Apr 2021 13:18:33 -0400 Subject: [PATCH 666/732] fix bug in tests --- spec/test/stored_queries/test_ontology.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/test/stored_queries/test_ontology.py b/spec/test/stored_queries/test_ontology.py index e19e8871..7f6f5263 100644 --- a/spec/test/stored_queries/test_ontology.py +++ b/spec/test/stored_queries/test_ontology.py @@ -210,7 +210,7 @@ def test_get_children(self): ).json() self.assertEqual(resp["count"], 2) ids = [r["term"]["id"] for r in resp["results"]] - self.assertEqual(ids, ["ENVO:00000446", "ENVO:00002030"]) + self.assertCountEqual(ids, ["ENVO:00000446", "ENVO:00002030"]) def test_get_parents(self): """Test query of ontology parents.""" @@ -246,7 +246,7 @@ def test_get_descendants(self): ).json() self.assertEqual(resp["count"], 3) ids = [r["term"]["id"] for r in resp["results"]] - self.assertEqual(ids, ["ENVO:00000446", "ENVO:00000428", "ENVO:00002030"]) + self.assertCountEqual(ids, ["ENVO:00000446", "ENVO:00000428", "ENVO:00002030"]) def test_get_ancestors(self): """Test query of ontology ancestors.""" @@ -264,7 +264,7 @@ def test_get_ancestors(self): ).json() self.assertEqual(resp["count"], 3) ids = [r["term"]["id"] for r in resp["results"]] - self.assertEqual(ids, ["ENVO:00000428", "ENVO:01000254", "ENVO:01001110"]) + self.assertCountEqual(ids, ["ENVO:00000428", "ENVO:01000254", "ENVO:01001110"]) def test_get_siblings(self): """Test query of ontology siblings.""" @@ -299,7 +299,7 @@ def test_get_terms(self): ).json() self.assertEqual(resp["count"], 2) ids = [r["id"] for r in resp["results"]] - self.assertEqual(ids, ["ENVO:00000446", "ENVO:00002030"]) + self.assertCountEqual(ids, ["ENVO:00000446", "ENVO:00002030"]) # -- Test helpers From ee5e6ca7935588054e2ade5d877563b7441a40bb Mon Sep 17 00:00:00 2001 From: Zhenyuan Lu Date: Wed, 12 May 2021 11:07:52 -0400 Subject: [PATCH 667/732] adding gaz_ontology collection --- spec/collections/GAZ/GAZ_edges.yaml | 42 ++++++++ spec/collections/GAZ/GAZ_merges.yaml | 42 ++++++++ spec/collections/GAZ/GAZ_terms.yaml | 146 +++++++++++++++++++++++++++ spec/data_sources/gaz_ontology.yaml | 5 + 4 files changed, 235 insertions(+) create mode 100644 spec/collections/GAZ/GAZ_edges.yaml create mode 100644 spec/collections/GAZ/GAZ_merges.yaml create mode 100644 spec/collections/GAZ/GAZ_terms.yaml create mode 100644 spec/data_sources/gaz_ontology.yaml diff --git a/spec/collections/GAZ/GAZ_edges.yaml b/spec/collections/GAZ/GAZ_edges.yaml new file mode 100644 index 00000000..ec2ea87a --- /dev/null +++ b/spec/collections/GAZ/GAZ_edges.yaml @@ -0,0 +1,42 @@ +name: GAZ_edges +type: edge +delta: true + +indexes: + - type: persistent + fields: [id, expired, created] + - type: persistent + fields: [expired, created, last_version] + +schema: + "$schema": http://json-schema.org/draft-07/schema# + title: GAZ_edges + type: object + description: A entry for edges in the Gazetteer Ontology (GAZ) hierarchy + properties: + id: + type: string + description: an edge ID, consisting of from::to::type + examples: + - GAZ:00563959::GAZ:00562535::located_in + - GAZ:00514533::GAZ:00513052::located_in + type: + type: string + description: GAZ edge type + examples: + - located_in + from: + type: string + description: GAZ id + examples: + - GAZ:00563959 + to: + type: string + title: GAZ id + examples: + - GAZ:00562535 + required: + - id + - type + - from + - to diff --git a/spec/collections/GAZ/GAZ_merges.yaml b/spec/collections/GAZ/GAZ_merges.yaml new file mode 100644 index 00000000..06068328 --- /dev/null +++ b/spec/collections/GAZ/GAZ_merges.yaml @@ -0,0 +1,42 @@ +name: GAZ_merges +type: edge +delta: true + +indexes: + - type: persistent + fields: [id, expired, created] + - type: persistent + fields: [expired, created, last_version] + +schema: + "$schema": http://json-schema.org/draft-07/schema# + title: GAZ_merges + type: object + description: A entry for merge edges in the Gazetteer Ontology (GAZ) hierarchy + properties: + id: + type: string + description: an edge ID, consisting of from::to::type + examples: + - GAZ:00563959::GAZ:00562535::consider + type: + type: string + description: GAZ merge edge type + examples: + - consider + - replaced_by + from: + type: string + description: GAZ id + examples: + - GAZ:00563959 + to: + type: string + title: GAZ id + examples: + - GAZ:00562535 + required: + - id + - type + - from + - to diff --git a/spec/collections/GAZ/GAZ_terms.yaml b/spec/collections/GAZ/GAZ_terms.yaml new file mode 100644 index 00000000..33a45b5e --- /dev/null +++ b/spec/collections/GAZ/GAZ_terms.yaml @@ -0,0 +1,146 @@ +name: GAZ_terms +type: vertex +delta: true + +indexes: + - type: persistent + fields: [id, expired, created] + - type: persistent + fields: [expired, created, last_version] + +schema: + "$schema": http://json-schema.org/draft-07/schema# + title: GAZ_terms + type: object + description: A entry for vertices in the Gazetteer Ontology (GAZ) hierarchy + properties: + id: + type: string + description: The unique id of the current term. + examples: + - GAZ:00140691 + - GAZ:00140650 + type: + type: string + description: The type of the node. + examples: + - CLASS + - PROPERTY + name: + type: ["null", "string"] # some OBO classes have no label + description: The term name. + examples: + - ice cap dome + - horse manure + namespace: + type: ["null", "string"] # some OBO classes have no namespace + description: The namespace of the term. + examples: + - GAZ + alt_ids: + type: array + items: + type: string + description: Defines an alternate id for this term. A term may have any number + of alternate ids. + examples: + - ["GAZ:00140691"] + - ["GAZ:00140650"] + def: + type: ["null", "object"] # some OBO classes have no definition + description: The definition of the current term. + required: + - val + properties: + pred: + type: string + description: The definition predicate + val: + type: string + description: The definition value + examples: + - A natural/cultural feature of outstanding or unique value because of its inherent + rarity, representative of aesthetic qualities or cultural significance. + xrefs: + type: array + description: A dbxref that describes an analagous term in another vocabulary + items: + type: string + examples: + - ["Geonames:feature"] + - ["https://en.wikipedia.org/wiki/Natural_Monument"] + comments: + type: array + items: + type: string + description: Comments for this term. + examples: + - ["This class refers to strictly sealed enclosures such as Biosphere 2 (https://en.wikipedia.org/wiki/Biosphere_2), rather than vivaria which allow matter exchange with external environmental systems."] + subsets: + type: array + items: + type: string + description: This tag indicates a term subset to which this term belongs. + examples: + - ["wwfBiome"] + - ["environmental_hazards"] + synonyms: + description: This tag gives a synonym for this term, some xrefs to describe the + origins of the synonym, and may indicate a synonym category or scope information. + type: array + items: + type: object + required: + - val + properties: + pred: + type: string + description: The synonym predicate + examples: + - hasBroadSynonym + - hasNarrowSynonym + val: + type: string + description: The synonym value + examples: + - HydrothermalVents + xrefs: + type: array + description: A dbxref that describes an analagous term in another vocabulary + items: + type: string + examples: + - ["NASA:earthrealm"] + xrefs: + description: DBxrefs that describes an analagous term in another vocabulary + type: array + items: + type: object + required: + - val + properties: + pred: + type: string + description: The xref predicate + val: + type: string + description: The xref value + examples: + - SPIRE:Soil + - https://en.wikipedia.org/wiki/Soil + xrefs: + type: array + description: A dbxref that describes an analagous term in another vocabulary + items: + type: string + required: + - id + - type + - name + - namespace + - alt_ids + - def + - comments + - subsets + - synonyms + - xrefs diff --git a/spec/data_sources/gaz_ontology.yaml b/spec/data_sources/gaz_ontology.yaml new file mode 100644 index 00000000..4034b021 --- /dev/null +++ b/spec/data_sources/gaz_ontology.yaml @@ -0,0 +1,5 @@ +name: gaz_ontology +category: ontology +title: Gazetteer Ontology +home_url: "http://environmentontology.github.io/gaz/" +data_url: "http://environmentontology.github.io/gaz/" From 599b4f5ef7f3d8d8b3f0aebd0d18163bba706bc0 Mon Sep 17 00:00:00 2001 From: Zhenyuan Lu Date: Fri, 14 May 2021 14:03:57 -0400 Subject: [PATCH 668/732] adding uo_ontology and po_ontology collections and data_sources --- spec/collections/PO/PO_edges.yaml | 41 ++++++++ spec/collections/PO/PO_merges.yaml | 42 +++++++++ spec/collections/PO/PO_terms.yaml | 141 ++++++++++++++++++++++++++++ spec/collections/UO/UO_edges.yaml | 41 ++++++++ spec/collections/UO/UO_merges.yaml | 42 +++++++++ spec/collections/UO/UO_terms.yaml | 141 ++++++++++++++++++++++++++++ spec/data_sources/gaz_ontology.yaml | 2 +- spec/data_sources/po_ontology.yaml | 5 + spec/data_sources/uo_ontology.yaml | 5 + 9 files changed, 459 insertions(+), 1 deletion(-) create mode 100644 spec/collections/PO/PO_edges.yaml create mode 100644 spec/collections/PO/PO_merges.yaml create mode 100644 spec/collections/PO/PO_terms.yaml create mode 100644 spec/collections/UO/UO_edges.yaml create mode 100644 spec/collections/UO/UO_merges.yaml create mode 100644 spec/collections/UO/UO_terms.yaml create mode 100644 spec/data_sources/po_ontology.yaml create mode 100644 spec/data_sources/uo_ontology.yaml diff --git a/spec/collections/PO/PO_edges.yaml b/spec/collections/PO/PO_edges.yaml new file mode 100644 index 00000000..4f408692 --- /dev/null +++ b/spec/collections/PO/PO_edges.yaml @@ -0,0 +1,41 @@ +name: PO_edges +type: edge +delta: true + +indexes: + - type: persistent + fields: [id, expired, created] + - type: persistent + fields: [expired, created, last_version] + +schema: + "$schema": http://json-schema.org/draft-07/schema# + title: PO_edges + type: object + description: A entry for edges in the Plant Ontology (PO) hierarchy + properties: + id: + type: string + description: an edge ID, consisting of from::to::type + examples: + - PO:0005024::PO:0006063::is_a + type: + type: string + description: PO edge type + examples: + - is_a + from: + type: string + description: PO id + examples: + - PO:0005024 + to: + type: string + title: PO id + examples: + - PO:0006063 + required: + - id + - type + - from + - to diff --git a/spec/collections/PO/PO_merges.yaml b/spec/collections/PO/PO_merges.yaml new file mode 100644 index 00000000..7af63933 --- /dev/null +++ b/spec/collections/PO/PO_merges.yaml @@ -0,0 +1,42 @@ +name: PO_merges +type: edge +delta: true + +indexes: + - type: persistent + fields: [id, expired, created] + - type: persistent + fields: [expired, created, last_version] + +schema: + "$schema": http://json-schema.org/draft-07/schema# + title: PO_merges + type: object + description: A entry for merge edges in the Plant Ontology (PO) hierarchy + properties: + id: + type: string + description: an edge ID, consisting of from::to::type + examples: + - PO:00563959::PO:00562535::consider + type: + type: string + description: PO merge edge type + examples: + - consider + - replaced_by + from: + type: string + description: PO id + examples: + - PO:00563959 + to: + type: string + title: PO id + examples: + - PO:00562535 + required: + - id + - type + - from + - to diff --git a/spec/collections/PO/PO_terms.yaml b/spec/collections/PO/PO_terms.yaml new file mode 100644 index 00000000..de70a51b --- /dev/null +++ b/spec/collections/PO/PO_terms.yaml @@ -0,0 +1,141 @@ +name: PO_terms +type: vertex +delta: true + +indexes: + - type: persistent + fields: [id, expired, created] + - type: persistent + fields: [expired, created, last_version] + +schema: + "$schema": http://json-schema.org/draft-07/schema# + title: PO_terms + type: object + description: A entry for vertices in the Plant Ontology (PO) hierarchy + properties: + id: + type: string + description: The unique id of the current term. + examples: + - PO:0006070 + type: + type: string + description: The type of the node. + examples: + - CLASS + - PROPERTY + name: + type: ["null", "string"] # some OBO classes have no label + description: The term name. + examples: + - mesophyll + namespace: + type: ["null", "string"] # some OBO classes have no namespace + description: The namespace of the term. + examples: + - PO + alt_ids: + type: array + items: + type: string + description: Defines an alternate id for this term. A term may have any number + of alternate ids. + examples: + - ["PO:0006070"] + def: + type: ["null", "object"] # some OBO classes have no definition + description: The definition of the current term. + required: + - val + properties: + pred: + type: string + description: The definition predicate + val: + type: string + description: The definition value + examples: + - The chloroplast-containing, photosynthetic parenchymatous tissue situated + between the two epidermal layers of the leaf or leaf like organs. + xrefs: + type: array + description: A dbxref that describes an analagous term in another vocabulary + items: + type: string + examples: + - ["Gramene:Pankaj_Jaiswal"] + comments: + type: array + items: + type: string + description: Comments for this term. + examples: + - ["This class refers to strictly sealed enclosures such as Biosphere 2 (https://en.wikipedia.org/wiki/Biosphere_2), rather than vivaria which allow matter exchange with external environmental systems."] + subsets: + type: array + items: + type: string + description: This tag indicates a term subset to which this term belongs. + examples: + - ["http://purl.obolibrary.org/obo/po#TraitNet"] + synonyms: + description: This tag gives a synonym for this term, some xrefs to describe the + origins of the synonym, and may indicate a synonym category or scope information. + type: array + items: + type: object + required: + - val + properties: + pred: + type: string + description: The synonym predicate + examples: + - hasBroadSynonym + - hasNarrowSynonym + val: + type: string + description: The synonym value + examples: + - HydrothermalVents + xrefs: + type: array + description: A dbxref that describes an analagous term in another vocabulary + items: + type: string + examples: + - ["NASA:earthrealm"] + xrefs: + description: DBxrefs that describes an analagous term in another vocabulary + type: array + items: + type: object + required: + - val + properties: + pred: + type: string + description: The xref predicate + val: + type: string + description: The xref value + examples: + - SPIRE:Soil + - https://en.wikipedia.org/wiki/Soil + xrefs: + type: array + description: A dbxref that describes an analagous term in another vocabulary + items: + type: string + required: + - id + - type + - name + - namespace + - alt_ids + - def + - comments + - subsets + - synonyms + - xrefs diff --git a/spec/collections/UO/UO_edges.yaml b/spec/collections/UO/UO_edges.yaml new file mode 100644 index 00000000..1f602d2a --- /dev/null +++ b/spec/collections/UO/UO_edges.yaml @@ -0,0 +1,41 @@ +name: UO_edges +type: edge +delta: true + +indexes: + - type: persistent + fields: [id, expired, created] + - type: persistent + fields: [expired, created, last_version] + +schema: + "$schema": http://json-schema.org/draft-07/schema# + title: UO_edges + type: object + description: A entry for edges in the Unit Ontology (UO) hierarchy + properties: + id: + type: string + description: an edge ID, consisting of from::to::type + examples: + - UO:0000271::UO:0000270::is_a + type: + type: string + description: UO edge type + examples: + - is_a + from: + type: string + description: UO id + examples: + - UO:0000271 + to: + type: string + title: UO id + examples: + - UO:0000270 + required: + - id + - type + - from + - to diff --git a/spec/collections/UO/UO_merges.yaml b/spec/collections/UO/UO_merges.yaml new file mode 100644 index 00000000..c5cfdddf --- /dev/null +++ b/spec/collections/UO/UO_merges.yaml @@ -0,0 +1,42 @@ +name: UO_merges +type: edge +delta: true + +indexes: + - type: persistent + fields: [id, expired, created] + - type: persistent + fields: [expired, created, last_version] + +schema: + "$schema": http://json-schema.org/draft-07/schema# + title: UO_merges + type: object + description: A entry for merge edges in the Unit Ontology (UO) hierarchy + properties: + id: + type: string + description: an edge ID, consisting of from::to::type + examples: + - UO:00563959::UO:00562535::consider + type: + type: string + description: UO merge edge type + examples: + - consider + - replaced_by + from: + type: string + description: UO id + examples: + - UO:00563959 + to: + type: string + title: UO id + examples: + - UO:00562535 + required: + - id + - type + - from + - to diff --git a/spec/collections/UO/UO_terms.yaml b/spec/collections/UO/UO_terms.yaml new file mode 100644 index 00000000..fa5e8c7d --- /dev/null +++ b/spec/collections/UO/UO_terms.yaml @@ -0,0 +1,141 @@ +name: UO_terms +type: vertex +delta: true + +indexes: + - type: persistent + fields: [id, expired, created] + - type: persistent + fields: [expired, created, last_version] + +schema: + "$schema": http://json-schema.org/draft-07/schema# + title: UO_terms + type: object + description: A entry for vertices in the Unit Ontology (UO) hierarchy + properties: + id: + type: string + description: The unique id of the current term. + examples: + - UO:0010035 + type: + type: string + description: The type of the node. + examples: + - CLASS + - PROPERTY + name: + type: ["null", "string"] # some OBO classes have no label + description: The term name. + examples: + - quarter + namespace: + type: ["null", "string"] # some OBO classes have no namespace + description: The namespace of the term. + examples: + - UO + alt_ids: + type: array + items: + type: string + description: Defines an alternate id for this term. A term may have any number + of alternate ids. + examples: + - ["UO:0000231"] + def: + type: ["null", "object"] # some OBO classes have no definition + description: The definition of the current term. + required: + - val + properties: + pred: + type: string + description: The definition predicate + val: + type: string + description: The definition value + examples: + - A natural/cultural feature of outstanding or unique value because of its inherent + rarity, representative of aesthetic qualities or cultural significance. + xrefs: + type: array + description: A dbxref that describes an analagous term in another vocabulary + items: + type: string + examples: + - ["https://en.wikipedia.org/wiki/Natural_Monument"] + comments: + type: array + items: + type: string + description: Comments for this term. + examples: + - ["This class refers to strictly sealed enclosures such as Biosphere 2 (https://en.wikipedia.org/wiki/Biosphere_2), rather than vivaria which allow matter exchange with external environmental systems."] + subsets: + type: array + items: + type: string + description: This tag indicates a term subset to which this term belongs. + examples: + - ["http://purl.obolibrary.org/obo/uo#unit_group_slim"] + synonyms: + description: This tag gives a synonym for this term, some xrefs to describe the + origins of the synonym, and may indicate a synonym category or scope information. + type: array + items: + type: object + required: + - val + properties: + pred: + type: string + description: The synonym predicate + examples: + - hasBroadSynonym + - hasNarrowSynonym + val: + type: string + description: The synonym value + examples: + - HydrothermalVents + xrefs: + type: array + description: A dbxref that describes an analagous term in another vocabulary + items: + type: string + examples: + - ["NASA:earthrealm"] + xrefs: + description: DBxrefs that describes an analagous term in another vocabulary + type: array + items: + type: object + required: + - val + properties: + pred: + type: string + description: The xref predicate + val: + type: string + description: The xref value + examples: + - SPIRE:Soil + - https://en.wikipedia.org/wiki/Soil + xrefs: + type: array + description: A dbxref that describes an analagous term in another vocabulary + items: + type: string + required: + - id + - type + - name + - namespace + - alt_ids + - def + - comments + - subsets + - synonyms + - xrefs diff --git a/spec/data_sources/gaz_ontology.yaml b/spec/data_sources/gaz_ontology.yaml index 4034b021..c7030a70 100644 --- a/spec/data_sources/gaz_ontology.yaml +++ b/spec/data_sources/gaz_ontology.yaml @@ -2,4 +2,4 @@ name: gaz_ontology category: ontology title: Gazetteer Ontology home_url: "http://environmentontology.github.io/gaz/" -data_url: "http://environmentontology.github.io/gaz/" +data_url: "http://purl.obolibrary.org/obo/gaz.obo" diff --git a/spec/data_sources/po_ontology.yaml b/spec/data_sources/po_ontology.yaml new file mode 100644 index 00000000..40802950 --- /dev/null +++ b/spec/data_sources/po_ontology.yaml @@ -0,0 +1,5 @@ +name: po_ontology +category: ontology +title: Plant Ontology +home_url: "http://browser.planteome.org/amigo" +data_url: "http://purl.obolibrary.org/obo/po.obo" diff --git a/spec/data_sources/uo_ontology.yaml b/spec/data_sources/uo_ontology.yaml new file mode 100644 index 00000000..7c909341 --- /dev/null +++ b/spec/data_sources/uo_ontology.yaml @@ -0,0 +1,5 @@ +name: uo_ontology +category: ontology +title: Units of measurement ontology +home_url: "https://github.com/bio-ontology-research-group/unit-ontology" +data_url: "http://purl.obolibrary.org/obo/uo.obo" From fe50d8d2817c58c1aa5ec77e80acd24be71fb1c0 Mon Sep 17 00:00:00 2001 From: John Miller Date: Thu, 20 May 2021 16:08:42 -0400 Subject: [PATCH 669/732] Update edge_type.yaml in conjunction with update to exascale_data --- spec/datasets/djornl/edge_type.yaml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/spec/datasets/djornl/edge_type.yaml b/spec/datasets/djornl/edge_type.yaml index 9294d336..156e96e1 100644 --- a/spec/datasets/djornl/edge_type.yaml +++ b/spec/datasets/djornl/edge_type.yaml @@ -52,3 +52,20 @@ oneOf: title: ATRM TF to Target LitCurated 01082020 TranscriptionFactorToGene description: Contains literature mined and manually curated TF regulatory interactions for A.thaliana from 1701 TFFs from PlantTFDB 2.0 and 4663 TF-associated interactions. These were manually filtered (e.g. FPs, PPI interactions removed). They then added some from other sources. Downloaded from http://atrm.cbi.pku.edu.cn/download.php + - const : 'Metabolic_AraCyc_Gene_to_Gene' + title : 'AraCyc_Gene_to_Gene' + description : "AraCyc. GeneA connects to GeneB if they are both enzymes and are linked by a common substrate or product. E.g. RXNA (GeneA) → Compound1 → RXNB (GeneB). Here GeneA connects to GeneB due to Compound1. Date accessed 03/18/2021. All enzymatic reactions and associated genes (enzymes) and compounds were downloaded from AraCyc as smarttables, and transformed by custom R script to generate the appropriate network format linking gene to gene based on intermediary compounds. Bringing to-spec, 322 non-standard edges were removed and 3,243 duplicates were removed." + - const : 'GO' + title : 'Athal_GOSemSim_BP_WangResCombined.score0.3' + description : "GO networks are Gene-Gene networks where an edge indicates that two genes are similar to each other based on shared GO terms. D.Kainer used the GoSemSim R package to get pairwise similarity between all GO annotated genes. Only GO annotations with solid evidence codes were used. The following GO codes were dropped: badcodes <- c(IEA,ISS,NAS,ND,RCA) Two Semantic Similarity measures were used: 1. Wang: a graph-based measure 2. Resnik: a simple Information Content based measure. The average was used as the final score." + - const : 'PPI_At_PPI_6merged' + title : 'At_PPI_6merged' + description : "Made by taking the union of 6 different PPI networks: AraNet2 LC, AraNet2 HT, AraPPInet2 0.60, BIOGRID 4.3.194 physical, AtPIN, Mentha. These 6 were all relatively good scoring with GOintersect. StringDB scored badly so was not included. dkainer (4-26-2021)" + - const : 'Knockout_Oellrich_2015_supp9_Athal_gene_gene_phenosemsim' + title : 'Oellrich_2015_supp9_Athal_gene-gene-phenosemsim' + description : "This is a network provided in the paper Oellrich 2015. The study took the experimentally known phenotypes of over 2000 mutant konockout lines from Lloyd 2012 paper, and annotated them using the PATO trait ontology system. They then ran semantic similarity pairwise between each mutated gene resulting in a network of about 450,000 edges where an edge shows that two knocked out genes cause a phenotype that is semantically similar (0 > weight >= 1). Uploaded by DKainer on Nov 16, 2020." + - const : 'Regulation_Plantregmap_predicted_merged_Ath_minscore3_unweighted' + title : 'Plantregmap_predicted_merged_Ath.minscore3_unweighted' + description : "Downloaded TF-to-gene data from http://plantregmap.cbi.pku.edu.cn/download.php#networks. Contains predicted TF-Target relationships based on motifs, algorithms, ChipSeq. Plus some lit curated edges.. DK removed all Lit curated edges and then gave one point to each line of evidence (e.g. Motif, TFBS, ChipSeq...) for an edge. Then summed them up to give an edge weight.. Highest scoring regulatory edges have 5. Lowest scoring have 1. Networks are named for their score threshold. e.g. minscore3 means there were atleast 3 supporting lines of evidence for the TF-Gene relationship." + + From 789cf94cf99db1cbfc82d5583627f4bc21b90f0d Mon Sep 17 00:00:00 2001 From: John Miller Date: Tue, 1 Jun 2021 10:27:25 -0400 Subject: [PATCH 670/732] Update edge_type based on suggested edits --- spec/datasets/djornl/edge_type.yaml | 34 ++++++++++++++++------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/spec/datasets/djornl/edge_type.yaml b/spec/datasets/djornl/edge_type.yaml index 156e96e1..b968c825 100644 --- a/spec/datasets/djornl/edge_type.yaml +++ b/spec/datasets/djornl/edge_type.yaml @@ -52,20 +52,24 @@ oneOf: title: ATRM TF to Target LitCurated 01082020 TranscriptionFactorToGene description: Contains literature mined and manually curated TF regulatory interactions for A.thaliana from 1701 TFFs from PlantTFDB 2.0 and 4663 TF-associated interactions. These were manually filtered (e.g. FPs, PPI interactions removed). They then added some from other sources. Downloaded from http://atrm.cbi.pku.edu.cn/download.php - - const : 'Metabolic_AraCyc_Gene_to_Gene' - title : 'AraCyc_Gene_to_Gene' - description : "AraCyc. GeneA connects to GeneB if they are both enzymes and are linked by a common substrate or product. E.g. RXNA (GeneA) → Compound1 → RXNB (GeneB). Here GeneA connects to GeneB due to Compound1. Date accessed 03/18/2021. All enzymatic reactions and associated genes (enzymes) and compounds were downloaded from AraCyc as smarttables, and transformed by custom R script to generate the appropriate network format linking gene to gene based on intermediary compounds. Bringing to-spec, 322 non-standard edges were removed and 3,243 duplicates were removed." - - const : 'GO' - title : 'Athal_GOSemSim_BP_WangResCombined.score0.3' - description : "GO networks are Gene-Gene networks where an edge indicates that two genes are similar to each other based on shared GO terms. D.Kainer used the GoSemSim R package to get pairwise similarity between all GO annotated genes. Only GO annotations with solid evidence codes were used. The following GO codes were dropped: badcodes <- c(IEA,ISS,NAS,ND,RCA) Two Semantic Similarity measures were used: 1. Wang: a graph-based measure 2. Resnik: a simple Information Content based measure. The average was used as the final score." - - const : 'PPI_At_PPI_6merged' - title : 'At_PPI_6merged' - description : "Made by taking the union of 6 different PPI networks: AraNet2 LC, AraNet2 HT, AraPPInet2 0.60, BIOGRID 4.3.194 physical, AtPIN, Mentha. These 6 were all relatively good scoring with GOintersect. StringDB scored badly so was not included. dkainer (4-26-2021)" - - const : 'Knockout_Oellrich_2015_supp9_Athal_gene_gene_phenosemsim' - title : 'Oellrich_2015_supp9_Athal_gene-gene-phenosemsim' - description : "This is a network provided in the paper Oellrich 2015. The study took the experimentally known phenotypes of over 2000 mutant konockout lines from Lloyd 2012 paper, and annotated them using the PATO trait ontology system. They then ran semantic similarity pairwise between each mutated gene resulting in a network of about 450,000 edges where an edge shows that two knocked out genes cause a phenotype that is semantically similar (0 > weight >= 1). Uploaded by DKainer on Nov 16, 2020." - - const : 'Regulation_Plantregmap_predicted_merged_Ath_minscore3_unweighted' - title : 'Plantregmap_predicted_merged_Ath.minscore3_unweighted' - description : "Downloaded TF-to-gene data from http://plantregmap.cbi.pku.edu.cn/download.php#networks. Contains predicted TF-Target relationships based on motifs, algorithms, ChipSeq. Plus some lit curated edges.. DK removed all Lit curated edges and then gave one point to each line of evidence (e.g. Motif, TFBS, ChipSeq...) for an edge. Then summed them up to give an edge weight.. Highest scoring regulatory edges have 5. Lowest scoring have 1. Networks are named for their score threshold. e.g. minscore3 means there were atleast 3 supporting lines of evidence for the TF-Gene relationship." + - const : "GO" + title : "GO" + description : "GeneA connects to GeneB if the two genes have semantically similar GO terms (with a similarity score > 0). This network is used to evaluate other networks for biological functional content. DOI: [TODO]" + + - const : "Knockout" + title : "Knockout" + description : "GeneA connects to GeneB if the phenotypic effect of knocking out GeneA is similar to the phenotypic effect of knocking out GeneB. Similarity is based on Phenotype Ontology semantic similarity. DOI: https://doi.org/10.1186/s13007-015-0053-y" + + - const : "Metabolic-AraCyc" + title : "Metabolic-AraCyc" + description : "GeneA connects to GeneB if they are both enzymes and are linked by a common substrate or product. E.g. RXNA (GeneA) → Compound1 → RXNB (GeneB). Here GeneA connects to GeneB due to Compound1. DOI: [TODO]" + + - const : "PPI-6merged" + title : "PPI-6merged" + description : "GeneA connects to GeneB if their protein products have been shown to bind to interact with each other, typically through experimental evidence. The PPI-6merged network is the union of 6 different A.thaliana PPI networks: AraNet2 LC, AraNet2 HT, AraPPInet2 0.60, BIOGRID 4.3.194 physical, AtPIN, Mentha. These 6 were all relatively high scoring with GOintersect. DOI: [TODO]" + + - const : "Regulation-ATRM" + title : "Regulation-ATRM" + description : "GeneA connects to GeneB if GeneA is a Transcription Factor (TF) that is shown to interact with GeneB (which may or may not be a TF). This dataset contains literature mined and manually curated TF regulatory interactions for A.thaliana. Started from 1701 TFs from PlantTFDB 2.0 and retrieved 4663 TF-associated interactions. These were manually filtered (e.g. FPs, PPI interactions removed). They then added some from other sources. Final result is 1431 confirmed TF regulatory interactions, of which 637 are TF-TF. Data origin: http://atrm.cbi.pku.edu.cn/download.php DOI: [TODO]" From 1caa1690436a1ff43758614b7163ed22ec67b051 Mon Sep 17 00:00:00 2001 From: Zhenyuan Lu Date: Fri, 25 Jun 2021 13:30:51 -0400 Subject: [PATCH 671/732] adding script to auto-generate ontology yaml files --- scripts/data/edges.yaml | 33 +++++ scripts/data/merges.yaml | 33 +++++ scripts/data/terms.yaml | 111 ++++++++++++++++ scripts/prepare_ontology.py | 71 ++++++++++ scripts/test/data_sources.json | 185 +++++++++++++++++++++++++++ spec/collections/GAZ/GAZ_edges.yaml | 73 +++++------ spec/collections/GAZ/GAZ_merges.yaml | 73 +++++------ spec/collections/GAZ/GAZ_terms.yaml | 157 ++++++++++------------- spec/data_sources/gaz_ontology.yaml | 8 +- 9 files changed, 571 insertions(+), 173 deletions(-) create mode 100644 scripts/data/edges.yaml create mode 100644 scripts/data/merges.yaml create mode 100644 scripts/data/terms.yaml create mode 100644 scripts/prepare_ontology.py create mode 100644 scripts/test/data_sources.json diff --git a/scripts/data/edges.yaml b/scripts/data/edges.yaml new file mode 100644 index 00000000..8d36c3e0 --- /dev/null +++ b/scripts/data/edges.yaml @@ -0,0 +1,33 @@ +name: __NAME___edges +type: edge +delta: true + +indexes: + - type: persistent + fields: [id, expired, created] + - type: persistent + fields: [expired, created, last_version] + +schema: + "$schema": http://json-schema.org/draft-07/schema# + title: __NAME___edges + type: object + description: A entry for edges in the __NAME__ ontology hierarchy + properties: + id: + type: string + description: an edge ID, consisting of from::to::type + type: + type: string + description: __NAME__ edge type + from: + type: string + description: __NAME__ id + to: + type: string + description: __NAME__ id + required: + - id + - type + - from + - to diff --git a/scripts/data/merges.yaml b/scripts/data/merges.yaml new file mode 100644 index 00000000..fe32ff7c --- /dev/null +++ b/scripts/data/merges.yaml @@ -0,0 +1,33 @@ +name: __NAME___merges +type: edge +delta: true + +indexes: + - type: persistent + fields: [id, expired, created] + - type: persistent + fields: [expired, created, last_version] + +schema: + "$schema": http://json-schema.org/draft-07/schema# + title: __NAME___merges + type: object + description: A entry for merge edges in the __NAME__ ontology hierarchy + properties: + id: + type: string + description: an edge ID, consisting of from::to::type + type: + type: string + description: __NAME__ merge edge type + from: + type: string + description: __NAME__ id + to: + type: string + description: __NAME__ id + required: + - id + - type + - from + - to diff --git a/scripts/data/terms.yaml b/scripts/data/terms.yaml new file mode 100644 index 00000000..a838ee2b --- /dev/null +++ b/scripts/data/terms.yaml @@ -0,0 +1,111 @@ +name: __NAME___terms +type: vertex +delta: true + +indexes: + - type: persistent + fields: [id, expired, created] + - type: persistent + fields: [expired, created, last_version] + +schema: + "$schema": http://json-schema.org/draft-07/schema# + title: __NAME___terms + type: object + description: A entry for vertices in the __NAME__ ontology hierarchy + properties: + id: + type: string + description: The unique id of the current term. + type: + type: string + description: The type of the node. + name: + type: ["null", "string"] # some OBO classes have no label + description: The term name. + namespace: + type: ["null", "string"] # some OBO classes have no namespace + description: The namespace of the term. + alt_ids: + type: array + items: + type: string + description: Defines an alternate id for this term. A term may have any number + of alternate ids. + def: + type: ["null", "object"] # some OBO classes have no definition + description: The definition of the current term. + required: + - val + properties: + pred: + type: string + description: The definition predicate + val: + type: string + description: The definition value + xrefs: + type: array + description: A dbxref that describes an analagous term in another vocabulary + items: + type: string + comments: + type: array + items: + type: string + description: Comments for this term. + subsets: + type: array + items: + type: string + description: This tag indicates a term subset to which this term belongs. + synonyms: + description: This tag gives a synonym for this term, some xrefs to describe the + origins of the synonym, and may indicate a synonym category or scope information. + type: array + items: + type: object + required: + - val + properties: + pred: + type: string + description: The synonym predicate + val: + type: string + description: The synonym value + xrefs: + type: array + description: A dbxref that describes an analagous term in another vocabulary + items: + type: string + xrefs: + description: DBxrefs that describes an analagous term in another vocabulary + type: array + items: + type: object + required: + - val + properties: + pred: + type: string + description: The xref predicate + val: + type: string + description: The xref value + xrefs: + type: array + description: A dbxref that describes an analagous term in another vocabulary + items: + type: string + required: + - id + - type + - name + - namespace + - alt_ids + - def + - comments + - subsets + - synonyms + - xrefs diff --git a/scripts/prepare_ontology.py b/scripts/prepare_ontology.py new file mode 100644 index 00000000..549c6525 --- /dev/null +++ b/scripts/prepare_ontology.py @@ -0,0 +1,71 @@ +import sys +import os +import yaml +import json +''' +python3 scripts/prepare_ontology.py scripts/test/data_sources.json gaz_ontology +''' + +__NAME = '__NAME__' +__BIN_PATH = os.path.dirname(os.path.abspath(__file__)) +__COLLECTIONS_PATH = os.path.join(__BIN_PATH, '../spec/collections') +__DATASOURCES_PATH = os.path.join(__BIN_PATH, '../spec/data_sources') +__DATAFILES_PATH = os.path.join(__BIN_PATH, 'data') +__COLLECTIONS_DATAFILES = ['terms', 'edges', 'merges'] + + +def main(): + input = sys.argv[1] + ns = sys.argv[2] + datasource = parse_input(input, ns) + + prepare_collections_file(datasource, __COLLECTIONS_PATH) + prepare_data_sources_file(datasource, __DATASOURCES_PATH) + + return + + +def parse_input(input, name): + with open(input) as file: + for d in json.load(file): + if d.get('ns') == name: + return d + + +def prepare_collections_file(datasource, collections_path): + name, type = parse_namespace(datasource['ns']) + target_dir = os.path.join(collections_path, name.upper()) + os.makedirs(target_dir, exist_ok=True) + for f in __COLLECTIONS_DATAFILES: + source_file = os.path.join(__DATAFILES_PATH, f + '.yaml') + target_file = os.path.join(target_dir, name.upper() + '_' + f + '.yaml') + data = "" + with open(source_file, 'r') as source: + data = yaml.safe_load(source.read().replace(__NAME, name.upper())) + if not os.path.exists(target_file): + with open(target_file, 'w') as target: + yaml.dump(data, target) + return + + +def prepare_data_sources_file(datasource, datasources_path): + name, type = parse_namespace(datasource['ns']) + target_file = os.path.join(datasources_path, datasource['ns'] + '.yaml') + data = {'name': datasource['ns'], + 'category': type, + 'title': datasource['title'], + 'home_url': datasource['home_url'], + 'data_url': datasource['data_url'] + } + if not os.path.exists(target_file): + with open(target_file, 'w') as target: + yaml.dump(data, target) + return + + +def parse_namespace(ns): + return tuple(ns.split('_')) + + +if __name__ == "__main__": + main() diff --git a/scripts/test/data_sources.json b/scripts/test/data_sources.json new file mode 100644 index 00000000..8fa070b3 --- /dev/null +++ b/scripts/test/data_sources.json @@ -0,0 +1,185 @@ +[ + { + "ns": "ncbi_taxonomy", + "type": "taxonomy", + "title": "National Center for Biotechnology Information", + "short_title": "NCBI", + "data_url": "ftp://ftp.ncbi.nlm.nih.gov/pub/taxonomy/", + "home_url": "https://www.ncbi.nlm.nih.gov/taxonomy", + "logo_url": "https://ci.kbase.us/ui-assets/images/third-party-data-sources/ncbi/logo-51-64.png", + "license": null, + "item_link": { + "url_template": "https://www.ncbi.nlm.nih.gov/Taxonomy/Browser/wwwtax.cgi?id={{id}}", + "label": "NCBI Taxonomy" + }, + "citation": "Schoch CL, et al. NCBI Taxonomy: a comprehensive update on curation, resources and tools. Database (Oxford). 2020: baaa062. [PubMed](https://www.ncbi.nlm.nih.gov/pubmed/32761142)\n\nSayers EW, et al. GenBank. Nucleic Acids Res. 2019. 47(D1):D94-D99. [PubMed](https://www.ncbi.nlm.nih.gov/pubmed/30365038)", + "additional_fields": [ + { + "id": "ncbi_taxon_id", + "type": "number", + "label": "NCBI ID", + "tooltip": "ID for this taxon at NCBI", + "description": "" + }, + { + "id": "gencode", + "type": "number", + "label": "Genetic Code", + "tooltip": "NCBI Genetic code", + "description": "" + }, + { + "id": "aliases", + "type": "array", + "label": "Aliases", + "tooltip": "Aliases for this taxon", + "description": "" + } + ] + }, + { + "ns": "gtdb", + "type": "taxonomy", + "title": "Genome Taxonomy Database", + "short_title": "GTDB", + "data_url": "https://data.ace.uq.edu.au/public/gtdb/data/releases/", + "home_url": "https://gtdb.ecogenomic.org", + "logo_url": "https://ci.kbase.us/ui-assets/images/third-party-data-sources/gtdb/logo-128-64.png", + "license": { + "url": "http://creativecommons.org/licenses/by-sa/4.0/", + "label": "Creative Commons Attribution-ShareAlike 4.0 International License" + }, + "item_link": { + "url_template": "https://gtdb.ecogenomic.org/genomes?gid={{id}}", + "label": "GTDB Taxonomy" + }, + "citation": "Parks, D.H., et al. (2020). [\"A complete domain-to-species taxonomy for Bacteria and Archaea.\"](https://rdcu.be/b3OI7) Nature Biotechnology, https://doi.org/10.1038/s41587-020-0501-8.\n\nParks, D.H., et al. (2018). [\"A standardized bacterial taxonomy based on genome phylogeny substantially revises the tree of life.\"](https://www.nature.com/articles/nbt.4229) Nature Biotechnology, 36: 996-1004.", + "additional_fields": [] + }, + { + "ns": "rdp_taxonomy", + "type": "taxonomy", + "title": "Ribosomal Database Project", + "short_title": "RDP", + "data_url": "http://rdp.cme.msu.edu/misc/resources.jsp", + "home_url": "http://rdp.cme.msu.edu/taxomatic/main.spr", + "logo_url": "http://rdp.cme.msu.edu/images/rdpinsider108x81.png", + "license": { + "url": "http://creativecommons.org/licenses/by-sa/3.0/", + "label": "Creative Commons Attribution-ShareAlike 3.0 Unported License" + }, + "item_link": null, + "citation": "Cole, J. R., Q. Wang, J. A. Fish, B. Chai, D. M. McGarrell, Y. Sun, C. T. Brown, A. Porras-Alfaro, C. R. Kuske, and J. M. Tiedje. 2014. Ribosomal Database Project: data and tools for high throughput rRNA analysis Nucl. Acids Res. 42(Database issue):D633-D642; doi: [10.1093/nar/gkt1244](http://dx.doi.org/10.1093/nar/gkt1244) [[PMID: 24288368]](http://www.ncbi.nlm.nih.gov/pubmed/24288368)", + "additional_fields": [ + { + "id": "incertae_sedis", + "type": "boolean", + "label": "Incertae Sedis?", + "tooltip": "ID for this taxon at NCBI", + "description": "Indicates a taxonomic group where its broader relationships are unknown or undefined" + }, + { + "id": "molecule", + "type": "string", + "label": "Molecule", + "tooltip": "", + "description": "" + }, + { + "id": "unclassified", + "type": "boolean", + "label": "Unclassified?", + "tooltip": "", + "description": "" + } + ] + }, + { + "ns": "silva_taxonomy", + "type": "taxonomy", + "title": "SILVA", + "short_title": "SILVA", + "data_url": "https://arb-silva.de/no_cache/download/archive/", + "home_url": "https://arb-silva.de", + "logo_url": "https://www.arb-silva.de/fileadmin/graphics_general/main/logos/silva-subtitle.svg", + "license": { + "url": "https://creativecommons.org/licenses/by/4.0/", + "label": "Create Commons Attribution 4.0 (CC-BY 4.0)" + }, + "item_link": { + "url_template": "https://www.arb-silva.de/browser/ssu/silva/{{id}}", + "label": "SILVA Taxonomy" + }, + "citation": "Quast C, Pruesse E, Yilmaz P, Gerken J, Schweer T, Yarza P, Peplies J, Glöckner FO (2013) The SILVA ribosomal RNA gene database project: improved data processing and web-based tools. [Nucl. Acids Res. 41 (D1): D590-D596](http://nar.oxfordjournals.org/content/41/D1/D590).\n\nYilmaz P, Parfrey LW, Yarza P, Gerken J, Pruesse E, Quast C, Schweer T, Peplies J, Ludwig W, Glöckner FO (2014) The SILVA and \"All-species Living Tree Project (LTP)\" taxonomic frameworks. [Nucl. Acids Res. 42:D643-D648](http://nar.oxfordjournals.org/content/42/D1/D643.full)\n\nGlöckner FO, Yilmaz P, Quast C, Gerken J, Beccati A, Ciuprina A, Bruns G, Yarza P, Peplies J, Westram R, Ludwig W (2017) 25 years of serving the community with ribosomal RNA gene reference databases and tools. [J. Biotechnol](http://www.sciencedirect.com/science/article/pii/S0168165617314943).", + "additional_fields": [ + { + "id": "datasets", + "type": "array", + "label": "Data Sets", + "tooltip": "", + "description": "" + }, + { + "id": "sequence", + "type": "sequence", + "label": "Sequence", + "tooltip": "", + "description": "" + } + ] + }, + { + "ns": "go_ontology", + "type": "ontology", + "title": "Gene Ontology", + "short_title": "GO", + "data_url": "http://release.geneontology.org/", + "home_url": "http://geneontology.org/", + "logo_url": "https://ci.kbase.us/ui-assets/images/third-party-data-sources/go/logo-248-64.png", + "license": { + "url": "https://creativecommons.org/licenses/by/4.0/legalcode", + "label": "Creative Commons Attribution 4.0 Unported License" + }, + "citation": "Ashburner et al. Gene ontology: tool for the unification of biology. Nat Genet. May 2000;25(1):25-9. [[abstract](https://www.ncbi.nlm.nih.gov/pubmed/10802651) | [full text](https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3037419/)]\n\nThe Gene Ontology Consortium. The Gene Ontology Resource: 20 years and still GOing strong. Nucleic Acids Res. Jan 2019;47(D1):D330-D338. [[abstract](https://www.ncbi.nlm.nih.gov/pubmed/30395331) | [full text](https://academic.oup.com/nar/article/47/D1/D330/5160994)]", + "item_link": { + "url_template": "http://amigo.geneontology.org/amigo/term/{{term}}", + "label": "Gene Ontology AmiGO" + }, + "additional_fields": [ + { + "id": "synonyms", + "type": "array", + "label": "Synonyms", + "tooltip": "", + "description": "" + } + ] + }, + { + "ns": "envo_ontology", + "type": "ontology", + "title": "Environmental Ontology", + "short_title": "ENVO", + "data_url": "https://github.com/EnvironmentOntology/envo/releases", + "home_url": "https://sites.google.com/site/environmentontology/", + "logo_url": "https://ci.kbase.us/ui-assets/images/third-party-data-sources/envo/logo-119-64.png", + "license": { + "url": "https://creativecommons.org/licenses/by/3.0/", + "label": "Attribution 3.0 Unported (CC BY 3.0)" + }, + "citation": "Buttigieg, P. L., Morrison, N., Smith, B., Mungall, C. J., & Lewis, S. E. (2013). The environment ontology: contextualising biological and biomedical entities. Journal of Biomedical Semantics, 4(1), 43. [doi:10.1186/2041-1480-4-43](http://www.dx.doi.org/10.1186/2041-1480-4-43)\n \nButtigieg, P. L., Pafilis, E., Lewis, S. E., Schildhauer, M. P., Walls, R. L., & Mungall, C. J. (2016). The environment ontology in 2016: bridging domains with increased scope, semantic density, and interoperation. Journal of Biomedical Semantics, 7(1), 57. [doi:10.1186/s13326-016-0097-6](https://doi.org/10.1186/s13326-016-0097-6)\n ", + "item_link": { + "url_template": "http://purl.obolibrary.org/obo/{{term}}", + "label": "ENVO Ontology Ontobee" + }, + "additional_fields": [] + }, + { + "ns": "gaz_ontology", + "type": "ontology", + "title": "Gazetteer Ontology", + "short_title": "GAZ", + "home_url": "http://environmentontology.github.io/gaz/", + "data_url": "http://purl.obolibrary.org/obo/gaz.obo" + } +] diff --git a/spec/collections/GAZ/GAZ_edges.yaml b/spec/collections/GAZ/GAZ_edges.yaml index ec2ea87a..32a15f07 100644 --- a/spec/collections/GAZ/GAZ_edges.yaml +++ b/spec/collections/GAZ/GAZ_edges.yaml @@ -1,42 +1,37 @@ -name: GAZ_edges -type: edge delta: true - indexes: - - type: persistent - fields: [id, expired, created] - - type: persistent - fields: [expired, created, last_version] - +- fields: + - id + - expired + - created + type: persistent +- fields: + - expired + - created + - last_version + type: persistent +name: GAZ_edges schema: - "$schema": http://json-schema.org/draft-07/schema# - title: GAZ_edges - type: object - description: A entry for edges in the Gazetteer Ontology (GAZ) hierarchy - properties: - id: - type: string - description: an edge ID, consisting of from::to::type - examples: - - GAZ:00563959::GAZ:00562535::located_in - - GAZ:00514533::GAZ:00513052::located_in - type: - type: string - description: GAZ edge type - examples: - - located_in - from: - type: string - description: GAZ id - examples: - - GAZ:00563959 - to: - type: string - title: GAZ id - examples: - - GAZ:00562535 - required: - - id - - type - - from - - to + $schema: http://json-schema.org/draft-07/schema# + description: A entry for edges in the GAZ ontology hierarchy + properties: + from: + description: GAZ id + type: string + id: + description: an edge ID, consisting of from::to::type + type: string + to: + description: GAZ id + type: string + type: + description: GAZ edge type + type: string + required: + - id + - type + - from + - to + title: GAZ_edges + type: object +type: edge diff --git a/spec/collections/GAZ/GAZ_merges.yaml b/spec/collections/GAZ/GAZ_merges.yaml index 06068328..e05bccd7 100644 --- a/spec/collections/GAZ/GAZ_merges.yaml +++ b/spec/collections/GAZ/GAZ_merges.yaml @@ -1,42 +1,37 @@ -name: GAZ_merges -type: edge delta: true - indexes: - - type: persistent - fields: [id, expired, created] - - type: persistent - fields: [expired, created, last_version] - +- fields: + - id + - expired + - created + type: persistent +- fields: + - expired + - created + - last_version + type: persistent +name: GAZ_merges schema: - "$schema": http://json-schema.org/draft-07/schema# - title: GAZ_merges - type: object - description: A entry for merge edges in the Gazetteer Ontology (GAZ) hierarchy - properties: - id: - type: string - description: an edge ID, consisting of from::to::type - examples: - - GAZ:00563959::GAZ:00562535::consider - type: - type: string - description: GAZ merge edge type - examples: - - consider - - replaced_by - from: - type: string - description: GAZ id - examples: - - GAZ:00563959 - to: - type: string - title: GAZ id - examples: - - GAZ:00562535 - required: - - id - - type - - from - - to + $schema: http://json-schema.org/draft-07/schema# + description: A entry for merge edges in the GAZ ontology hierarchy + properties: + from: + description: GAZ id + type: string + id: + description: an edge ID, consisting of from::to::type + type: string + to: + description: GAZ id + type: string + type: + description: GAZ merge edge type + type: string + required: + - id + - type + - from + - to + title: GAZ_merges + type: object +type: edge diff --git a/spec/collections/GAZ/GAZ_terms.yaml b/spec/collections/GAZ/GAZ_terms.yaml index 33a45b5e..810f7026 100644 --- a/spec/collections/GAZ/GAZ_terms.yaml +++ b/spec/collections/GAZ/GAZ_terms.yaml @@ -1,138 +1,110 @@ -name: GAZ_terms -type: vertex delta: true - indexes: - - type: persistent - fields: [id, expired, created] - - type: persistent - fields: [expired, created, last_version] - +- fields: + - id + - expired + - created + type: persistent +- fields: + - expired + - created + - last_version + type: persistent +name: GAZ_terms schema: - "$schema": http://json-schema.org/draft-07/schema# - title: GAZ_terms - type: object - description: A entry for vertices in the Gazetteer Ontology (GAZ) hierarchy + $schema: http://json-schema.org/draft-07/schema# + description: A entry for vertices in the GAZ ontology hierarchy properties: - id: - type: string - description: The unique id of the current term. - examples: - - GAZ:00140691 - - GAZ:00140650 - type: - type: string - description: The type of the node. - examples: - - CLASS - - PROPERTY - name: - type: ["null", "string"] # some OBO classes have no label - description: The term name. - examples: - - ice cap dome - - horse manure - namespace: - type: ["null", "string"] # some OBO classes have no namespace - description: The namespace of the term. - examples: - - GAZ alt_ids: + description: Defines an alternate id for this term. A term may have any number + of alternate ids. + items: + type: string type: array + comments: + description: Comments for this term. items: type: string - description: Defines an alternate id for this term. A term may have any number - of alternate ids. - examples: - - ["GAZ:00140691"] - - ["GAZ:00140650"] + type: array def: - type: ["null", "object"] # some OBO classes have no definition description: The definition of the current term. - required: - - val properties: pred: - type: string description: The definition predicate - val: type: string + val: description: The definition value - examples: - - A natural/cultural feature of outstanding or unique value because of its inherent - rarity, representative of aesthetic qualities or cultural significance. + type: string xrefs: - type: array description: A dbxref that describes an analagous term in another vocabulary items: type: string - examples: - - ["Geonames:feature"] - - ["https://en.wikipedia.org/wiki/Natural_Monument"] - comments: - type: array - items: - type: string - description: Comments for this term. - examples: - - ["This class refers to strictly sealed enclosures such as Biosphere 2 (https://en.wikipedia.org/wiki/Biosphere_2), rather than vivaria which allow matter exchange with external environmental systems."] + type: array + required: + - val + type: + - 'null' + - object + id: + description: The unique id of the current term. + type: string + name: + description: The term name. + type: + - 'null' + - string + namespace: + description: The namespace of the term. + type: + - 'null' + - string subsets: - type: array + description: This tag indicates a term subset to which this term belongs. items: type: string - description: This tag indicates a term subset to which this term belongs. - examples: - - ["wwfBiome"] - - ["environmental_hazards"] - synonyms: - description: This tag gives a synonym for this term, some xrefs to describe the - origins of the synonym, and may indicate a synonym category or scope information. type: array + synonyms: + description: This tag gives a synonym for this term, some xrefs to describe + the origins of the synonym, and may indicate a synonym category or scope information. items: - type: object - required: - - val properties: pred: - type: string description: The synonym predicate - examples: - - hasBroadSynonym - - hasNarrowSynonym - val: type: string + val: description: The synonym value - examples: - - HydrothermalVents + type: string xrefs: - type: array description: A dbxref that describes an analagous term in another vocabulary items: type: string - examples: - - ["NASA:earthrealm"] - xrefs: - description: DBxrefs that describes an analagous term in another vocabulary + type: array + required: + - val + type: object type: array + type: + description: The type of the node. + type: string + xrefs: + description: DBxrefs that describes an analagous term in another vocabulary items: - type: object - required: - - val properties: pred: - type: string description: The xref predicate - val: type: string + val: description: The xref value - examples: - - SPIRE:Soil - - https://en.wikipedia.org/wiki/Soil + type: string xrefs: - type: array description: A dbxref that describes an analagous term in another vocabulary items: type: string + type: array + required: + - val + type: object + type: array required: - id - type @@ -144,3 +116,6 @@ schema: - subsets - synonyms - xrefs + title: GAZ_terms + type: object +type: vertex diff --git a/spec/data_sources/gaz_ontology.yaml b/spec/data_sources/gaz_ontology.yaml index c7030a70..f2c82185 100644 --- a/spec/data_sources/gaz_ontology.yaml +++ b/spec/data_sources/gaz_ontology.yaml @@ -1,5 +1,5 @@ -name: gaz_ontology category: ontology -title: Gazetteer Ontology -home_url: "http://environmentontology.github.io/gaz/" -data_url: "http://purl.obolibrary.org/obo/gaz.obo" +data_url: http://purl.obolibrary.org/obo/gaz.obo +home_url: http://environmentontology.github.io/gaz/ +name: gaz_ontology +title: Gazetteer Ontology From cc2874a47f3f6bb8be916cda972e78e276a68ea5 Mon Sep 17 00:00:00 2001 From: Zhenyuan Lu Date: Thu, 1 Jul 2021 16:04:16 -0400 Subject: [PATCH 672/732] adding script to auto-generate ontology yaml files --- scripts/prepare_ontology.py | 48 +++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/scripts/prepare_ontology.py b/scripts/prepare_ontology.py index 549c6525..6222b787 100644 --- a/scripts/prepare_ontology.py +++ b/scripts/prepare_ontology.py @@ -2,16 +2,17 @@ import os import yaml import json -''' + +""" python3 scripts/prepare_ontology.py scripts/test/data_sources.json gaz_ontology -''' +""" -__NAME = '__NAME__' +__NAME = "__NAME__" __BIN_PATH = os.path.dirname(os.path.abspath(__file__)) -__COLLECTIONS_PATH = os.path.join(__BIN_PATH, '../spec/collections') -__DATASOURCES_PATH = os.path.join(__BIN_PATH, '../spec/data_sources') -__DATAFILES_PATH = os.path.join(__BIN_PATH, 'data') -__COLLECTIONS_DATAFILES = ['terms', 'edges', 'merges'] +__COLLECTIONS_PATH = os.path.join(__BIN_PATH, "../spec/collections") +__DATASOURCES_PATH = os.path.join(__BIN_PATH, "../spec/data_sources") +__DATAFILES_PATH = os.path.join(__BIN_PATH, "data") +__COLLECTIONS_DATAFILES = ["terms", "edges", "merges"] def main(): @@ -28,43 +29,44 @@ def main(): def parse_input(input, name): with open(input) as file: for d in json.load(file): - if d.get('ns') == name: + if d.get("ns") == name: return d def prepare_collections_file(datasource, collections_path): - name, type = parse_namespace(datasource['ns']) + name, type = parse_namespace(datasource["ns"]) target_dir = os.path.join(collections_path, name.upper()) os.makedirs(target_dir, exist_ok=True) for f in __COLLECTIONS_DATAFILES: - source_file = os.path.join(__DATAFILES_PATH, f + '.yaml') - target_file = os.path.join(target_dir, name.upper() + '_' + f + '.yaml') + source_file = os.path.join(__DATAFILES_PATH, f + ".yaml") + target_file = os.path.join(target_dir, name.upper() + "_" + f + ".yaml") data = "" - with open(source_file, 'r') as source: + with open(source_file, "r") as source: data = yaml.safe_load(source.read().replace(__NAME, name.upper())) if not os.path.exists(target_file): - with open(target_file, 'w') as target: + with open(target_file, "w") as target: yaml.dump(data, target) return def prepare_data_sources_file(datasource, datasources_path): - name, type = parse_namespace(datasource['ns']) - target_file = os.path.join(datasources_path, datasource['ns'] + '.yaml') - data = {'name': datasource['ns'], - 'category': type, - 'title': datasource['title'], - 'home_url': datasource['home_url'], - 'data_url': datasource['data_url'] - } + name, type = parse_namespace(datasource["ns"]) + target_file = os.path.join(datasources_path, datasource["ns"] + ".yaml") + data = { + "name": datasource["ns"], + "category": type, + "title": datasource["title"], + "home_url": datasource["home_url"], + "data_url": datasource["data_url"], + } if not os.path.exists(target_file): - with open(target_file, 'w') as target: + with open(target_file, "w") as target: yaml.dump(data, target) return def parse_namespace(ns): - return tuple(ns.split('_')) + return tuple(ns.split("_")) if __name__ == "__main__": From 15d10fbf7eb8d69d8052718a433da2f7eb09fc1f Mon Sep 17 00:00:00 2001 From: Zhenyuan Lu Date: Tue, 27 Jul 2021 13:30:16 -0400 Subject: [PATCH 673/732] adding tests on script for auto-generate ontology yaml files --- scripts/__init__.py | 0 scripts/prepare_ontology.py | 16 ++++++-- scripts/test/__init__.py | 0 scripts/test/{ => data}/data_sources.json | 10 ++--- scripts/test/test_prepare_ontology.py | 46 +++++++++++++++++++++++ 5 files changed, 63 insertions(+), 9 deletions(-) create mode 100644 scripts/__init__.py create mode 100644 scripts/test/__init__.py rename scripts/test/{ => data}/data_sources.json (97%) create mode 100644 scripts/test/test_prepare_ontology.py diff --git a/scripts/__init__.py b/scripts/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/scripts/prepare_ontology.py b/scripts/prepare_ontology.py index 6222b787..33bb87a5 100644 --- a/scripts/prepare_ontology.py +++ b/scripts/prepare_ontology.py @@ -2,9 +2,10 @@ import os import yaml import json +import shutil """ -python3 scripts/prepare_ontology.py scripts/test/data_sources.json gaz_ontology +python3 scripts/prepare_ontology.py scripts/test/data/data_sources.json fake_ontology """ __NAME = "__NAME__" @@ -22,7 +23,6 @@ def main(): prepare_collections_file(datasource, __COLLECTIONS_PATH) prepare_data_sources_file(datasource, __DATASOURCES_PATH) - return @@ -46,7 +46,7 @@ def prepare_collections_file(datasource, collections_path): if not os.path.exists(target_file): with open(target_file, "w") as target: yaml.dump(data, target) - return + return target_dir def prepare_data_sources_file(datasource, datasources_path): @@ -62,12 +62,20 @@ def prepare_data_sources_file(datasource, datasources_path): if not os.path.exists(target_file): with open(target_file, "w") as target: yaml.dump(data, target) - return + return target_file def parse_namespace(ns): return tuple(ns.split("_")) +def clean_up_data(path): + if os.path.exists(path): + if os.path.isfile(path): + os.remove(path) + elif os.path.isdir(path): + shutil.rmtree(path) + + if __name__ == "__main__": main() diff --git a/scripts/test/__init__.py b/scripts/test/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/scripts/test/data_sources.json b/scripts/test/data/data_sources.json similarity index 97% rename from scripts/test/data_sources.json rename to scripts/test/data/data_sources.json index 8fa070b3..fb21bb4f 100644 --- a/scripts/test/data_sources.json +++ b/scripts/test/data/data_sources.json @@ -175,11 +175,11 @@ "additional_fields": [] }, { - "ns": "gaz_ontology", + "ns": "fake_ontology", "type": "ontology", - "title": "Gazetteer Ontology", - "short_title": "GAZ", - "home_url": "http://environmentontology.github.io/gaz/", - "data_url": "http://purl.obolibrary.org/obo/gaz.obo" + "title": "Fake Ontology", + "short_title": "FAKE", + "home_url": "http://environmentontology.github.io/fake/", + "data_url": "http://purl.obolibrary.org/obo/fake.obo" } ] diff --git a/scripts/test/test_prepare_ontology.py b/scripts/test/test_prepare_ontology.py new file mode 100644 index 00000000..1cb6e122 --- /dev/null +++ b/scripts/test/test_prepare_ontology.py @@ -0,0 +1,46 @@ +""" +Tests for the prepare_ontology + +These tests run within the re_api docker image. +""" +import unittest +import os +from scripts.prepare_ontology import ( + prepare_collections_file, + prepare_data_sources_file, + parse_input, + parse_namespace, + clean_up_data, +) + +_TEST_DIR = "/app/scripts/test" +_TEST_NAMESPACE = "fake_ontology" + + +class Test_prepare_ontology(unittest.TestCase): + @classmethod + def setUpClass(self): + self.data_sources_file = os.path.join(_TEST_DIR, "data", "data_sources.json") + + def test_parse_input(self): + d = parse_input(self.data_sources_file, _TEST_NAMESPACE) + self.assertEqual(d["ns"], _TEST_NAMESPACE) + + def test_parse_namespace(self): + n, t = parse_namespace(_TEST_NAMESPACE) + self.assertEqual(n, "fake") + self.assertEqual(t, "ontology") + + def test_data_sources_file(self): + d = parse_input(self.data_sources_file, _TEST_NAMESPACE) + ret = prepare_data_sources_file(d, _TEST_DIR) + self.assertTrue(os.path.exists(ret)) + clean_up_data(ret) + self.assertFalse(os.path.exists(ret)) + + def test_collections_file(self): + d = parse_input(self.data_sources_file, _TEST_NAMESPACE) + ret = prepare_collections_file(d, _TEST_DIR) + self.assertTrue(os.path.exists(ret)) + clean_up_data(ret) + self.assertFalse(os.path.exists(ret)) From d9aca2a869babde52e043dbcaf148517e8c38d31 Mon Sep 17 00:00:00 2001 From: Zhenyuan Lu Date: Thu, 29 Jul 2021 10:51:36 -0400 Subject: [PATCH 674/732] remove GAZ, UO, PO files --- spec/collections/GAZ/GAZ_edges.yaml | 37 ------- spec/collections/GAZ/GAZ_merges.yaml | 37 ------- spec/collections/GAZ/GAZ_terms.yaml | 121 ----------------------- spec/collections/PO/PO_edges.yaml | 41 -------- spec/collections/PO/PO_merges.yaml | 42 -------- spec/collections/PO/PO_terms.yaml | 141 --------------------------- spec/collections/UO/UO_edges.yaml | 41 -------- spec/collections/UO/UO_merges.yaml | 42 -------- spec/collections/UO/UO_terms.yaml | 141 --------------------------- spec/data_sources/gaz_ontology.yaml | 5 - spec/data_sources/po_ontology.yaml | 5 - spec/data_sources/uo_ontology.yaml | 5 - 12 files changed, 658 deletions(-) delete mode 100644 spec/collections/GAZ/GAZ_edges.yaml delete mode 100644 spec/collections/GAZ/GAZ_merges.yaml delete mode 100644 spec/collections/GAZ/GAZ_terms.yaml delete mode 100644 spec/collections/PO/PO_edges.yaml delete mode 100644 spec/collections/PO/PO_merges.yaml delete mode 100644 spec/collections/PO/PO_terms.yaml delete mode 100644 spec/collections/UO/UO_edges.yaml delete mode 100644 spec/collections/UO/UO_merges.yaml delete mode 100644 spec/collections/UO/UO_terms.yaml delete mode 100644 spec/data_sources/gaz_ontology.yaml delete mode 100644 spec/data_sources/po_ontology.yaml delete mode 100644 spec/data_sources/uo_ontology.yaml diff --git a/spec/collections/GAZ/GAZ_edges.yaml b/spec/collections/GAZ/GAZ_edges.yaml deleted file mode 100644 index 32a15f07..00000000 --- a/spec/collections/GAZ/GAZ_edges.yaml +++ /dev/null @@ -1,37 +0,0 @@ -delta: true -indexes: -- fields: - - id - - expired - - created - type: persistent -- fields: - - expired - - created - - last_version - type: persistent -name: GAZ_edges -schema: - $schema: http://json-schema.org/draft-07/schema# - description: A entry for edges in the GAZ ontology hierarchy - properties: - from: - description: GAZ id - type: string - id: - description: an edge ID, consisting of from::to::type - type: string - to: - description: GAZ id - type: string - type: - description: GAZ edge type - type: string - required: - - id - - type - - from - - to - title: GAZ_edges - type: object -type: edge diff --git a/spec/collections/GAZ/GAZ_merges.yaml b/spec/collections/GAZ/GAZ_merges.yaml deleted file mode 100644 index e05bccd7..00000000 --- a/spec/collections/GAZ/GAZ_merges.yaml +++ /dev/null @@ -1,37 +0,0 @@ -delta: true -indexes: -- fields: - - id - - expired - - created - type: persistent -- fields: - - expired - - created - - last_version - type: persistent -name: GAZ_merges -schema: - $schema: http://json-schema.org/draft-07/schema# - description: A entry for merge edges in the GAZ ontology hierarchy - properties: - from: - description: GAZ id - type: string - id: - description: an edge ID, consisting of from::to::type - type: string - to: - description: GAZ id - type: string - type: - description: GAZ merge edge type - type: string - required: - - id - - type - - from - - to - title: GAZ_merges - type: object -type: edge diff --git a/spec/collections/GAZ/GAZ_terms.yaml b/spec/collections/GAZ/GAZ_terms.yaml deleted file mode 100644 index 810f7026..00000000 --- a/spec/collections/GAZ/GAZ_terms.yaml +++ /dev/null @@ -1,121 +0,0 @@ -delta: true -indexes: -- fields: - - id - - expired - - created - type: persistent -- fields: - - expired - - created - - last_version - type: persistent -name: GAZ_terms -schema: - $schema: http://json-schema.org/draft-07/schema# - description: A entry for vertices in the GAZ ontology hierarchy - properties: - alt_ids: - description: Defines an alternate id for this term. A term may have any number - of alternate ids. - items: - type: string - type: array - comments: - description: Comments for this term. - items: - type: string - type: array - def: - description: The definition of the current term. - properties: - pred: - description: The definition predicate - type: string - val: - description: The definition value - type: string - xrefs: - description: A dbxref that describes an analagous term in another vocabulary - items: - type: string - type: array - required: - - val - type: - - 'null' - - object - id: - description: The unique id of the current term. - type: string - name: - description: The term name. - type: - - 'null' - - string - namespace: - description: The namespace of the term. - type: - - 'null' - - string - subsets: - description: This tag indicates a term subset to which this term belongs. - items: - type: string - type: array - synonyms: - description: This tag gives a synonym for this term, some xrefs to describe - the origins of the synonym, and may indicate a synonym category or scope information. - items: - properties: - pred: - description: The synonym predicate - type: string - val: - description: The synonym value - type: string - xrefs: - description: A dbxref that describes an analagous term in another vocabulary - items: - type: string - type: array - required: - - val - type: object - type: array - type: - description: The type of the node. - type: string - xrefs: - description: DBxrefs that describes an analagous term in another vocabulary - items: - properties: - pred: - description: The xref predicate - type: string - val: - description: The xref value - type: string - xrefs: - description: A dbxref that describes an analagous term in another vocabulary - items: - type: string - type: array - required: - - val - type: object - type: array - required: - - id - - type - - name - - namespace - - alt_ids - - def - - comments - - subsets - - synonyms - - xrefs - title: GAZ_terms - type: object -type: vertex diff --git a/spec/collections/PO/PO_edges.yaml b/spec/collections/PO/PO_edges.yaml deleted file mode 100644 index 4f408692..00000000 --- a/spec/collections/PO/PO_edges.yaml +++ /dev/null @@ -1,41 +0,0 @@ -name: PO_edges -type: edge -delta: true - -indexes: - - type: persistent - fields: [id, expired, created] - - type: persistent - fields: [expired, created, last_version] - -schema: - "$schema": http://json-schema.org/draft-07/schema# - title: PO_edges - type: object - description: A entry for edges in the Plant Ontology (PO) hierarchy - properties: - id: - type: string - description: an edge ID, consisting of from::to::type - examples: - - PO:0005024::PO:0006063::is_a - type: - type: string - description: PO edge type - examples: - - is_a - from: - type: string - description: PO id - examples: - - PO:0005024 - to: - type: string - title: PO id - examples: - - PO:0006063 - required: - - id - - type - - from - - to diff --git a/spec/collections/PO/PO_merges.yaml b/spec/collections/PO/PO_merges.yaml deleted file mode 100644 index 7af63933..00000000 --- a/spec/collections/PO/PO_merges.yaml +++ /dev/null @@ -1,42 +0,0 @@ -name: PO_merges -type: edge -delta: true - -indexes: - - type: persistent - fields: [id, expired, created] - - type: persistent - fields: [expired, created, last_version] - -schema: - "$schema": http://json-schema.org/draft-07/schema# - title: PO_merges - type: object - description: A entry for merge edges in the Plant Ontology (PO) hierarchy - properties: - id: - type: string - description: an edge ID, consisting of from::to::type - examples: - - PO:00563959::PO:00562535::consider - type: - type: string - description: PO merge edge type - examples: - - consider - - replaced_by - from: - type: string - description: PO id - examples: - - PO:00563959 - to: - type: string - title: PO id - examples: - - PO:00562535 - required: - - id - - type - - from - - to diff --git a/spec/collections/PO/PO_terms.yaml b/spec/collections/PO/PO_terms.yaml deleted file mode 100644 index de70a51b..00000000 --- a/spec/collections/PO/PO_terms.yaml +++ /dev/null @@ -1,141 +0,0 @@ -name: PO_terms -type: vertex -delta: true - -indexes: - - type: persistent - fields: [id, expired, created] - - type: persistent - fields: [expired, created, last_version] - -schema: - "$schema": http://json-schema.org/draft-07/schema# - title: PO_terms - type: object - description: A entry for vertices in the Plant Ontology (PO) hierarchy - properties: - id: - type: string - description: The unique id of the current term. - examples: - - PO:0006070 - type: - type: string - description: The type of the node. - examples: - - CLASS - - PROPERTY - name: - type: ["null", "string"] # some OBO classes have no label - description: The term name. - examples: - - mesophyll - namespace: - type: ["null", "string"] # some OBO classes have no namespace - description: The namespace of the term. - examples: - - PO - alt_ids: - type: array - items: - type: string - description: Defines an alternate id for this term. A term may have any number - of alternate ids. - examples: - - ["PO:0006070"] - def: - type: ["null", "object"] # some OBO classes have no definition - description: The definition of the current term. - required: - - val - properties: - pred: - type: string - description: The definition predicate - val: - type: string - description: The definition value - examples: - - The chloroplast-containing, photosynthetic parenchymatous tissue situated - between the two epidermal layers of the leaf or leaf like organs. - xrefs: - type: array - description: A dbxref that describes an analagous term in another vocabulary - items: - type: string - examples: - - ["Gramene:Pankaj_Jaiswal"] - comments: - type: array - items: - type: string - description: Comments for this term. - examples: - - ["This class refers to strictly sealed enclosures such as Biosphere 2 (https://en.wikipedia.org/wiki/Biosphere_2), rather than vivaria which allow matter exchange with external environmental systems."] - subsets: - type: array - items: - type: string - description: This tag indicates a term subset to which this term belongs. - examples: - - ["http://purl.obolibrary.org/obo/po#TraitNet"] - synonyms: - description: This tag gives a synonym for this term, some xrefs to describe the - origins of the synonym, and may indicate a synonym category or scope information. - type: array - items: - type: object - required: - - val - properties: - pred: - type: string - description: The synonym predicate - examples: - - hasBroadSynonym - - hasNarrowSynonym - val: - type: string - description: The synonym value - examples: - - HydrothermalVents - xrefs: - type: array - description: A dbxref that describes an analagous term in another vocabulary - items: - type: string - examples: - - ["NASA:earthrealm"] - xrefs: - description: DBxrefs that describes an analagous term in another vocabulary - type: array - items: - type: object - required: - - val - properties: - pred: - type: string - description: The xref predicate - val: - type: string - description: The xref value - examples: - - SPIRE:Soil - - https://en.wikipedia.org/wiki/Soil - xrefs: - type: array - description: A dbxref that describes an analagous term in another vocabulary - items: - type: string - required: - - id - - type - - name - - namespace - - alt_ids - - def - - comments - - subsets - - synonyms - - xrefs diff --git a/spec/collections/UO/UO_edges.yaml b/spec/collections/UO/UO_edges.yaml deleted file mode 100644 index 1f602d2a..00000000 --- a/spec/collections/UO/UO_edges.yaml +++ /dev/null @@ -1,41 +0,0 @@ -name: UO_edges -type: edge -delta: true - -indexes: - - type: persistent - fields: [id, expired, created] - - type: persistent - fields: [expired, created, last_version] - -schema: - "$schema": http://json-schema.org/draft-07/schema# - title: UO_edges - type: object - description: A entry for edges in the Unit Ontology (UO) hierarchy - properties: - id: - type: string - description: an edge ID, consisting of from::to::type - examples: - - UO:0000271::UO:0000270::is_a - type: - type: string - description: UO edge type - examples: - - is_a - from: - type: string - description: UO id - examples: - - UO:0000271 - to: - type: string - title: UO id - examples: - - UO:0000270 - required: - - id - - type - - from - - to diff --git a/spec/collections/UO/UO_merges.yaml b/spec/collections/UO/UO_merges.yaml deleted file mode 100644 index c5cfdddf..00000000 --- a/spec/collections/UO/UO_merges.yaml +++ /dev/null @@ -1,42 +0,0 @@ -name: UO_merges -type: edge -delta: true - -indexes: - - type: persistent - fields: [id, expired, created] - - type: persistent - fields: [expired, created, last_version] - -schema: - "$schema": http://json-schema.org/draft-07/schema# - title: UO_merges - type: object - description: A entry for merge edges in the Unit Ontology (UO) hierarchy - properties: - id: - type: string - description: an edge ID, consisting of from::to::type - examples: - - UO:00563959::UO:00562535::consider - type: - type: string - description: UO merge edge type - examples: - - consider - - replaced_by - from: - type: string - description: UO id - examples: - - UO:00563959 - to: - type: string - title: UO id - examples: - - UO:00562535 - required: - - id - - type - - from - - to diff --git a/spec/collections/UO/UO_terms.yaml b/spec/collections/UO/UO_terms.yaml deleted file mode 100644 index fa5e8c7d..00000000 --- a/spec/collections/UO/UO_terms.yaml +++ /dev/null @@ -1,141 +0,0 @@ -name: UO_terms -type: vertex -delta: true - -indexes: - - type: persistent - fields: [id, expired, created] - - type: persistent - fields: [expired, created, last_version] - -schema: - "$schema": http://json-schema.org/draft-07/schema# - title: UO_terms - type: object - description: A entry for vertices in the Unit Ontology (UO) hierarchy - properties: - id: - type: string - description: The unique id of the current term. - examples: - - UO:0010035 - type: - type: string - description: The type of the node. - examples: - - CLASS - - PROPERTY - name: - type: ["null", "string"] # some OBO classes have no label - description: The term name. - examples: - - quarter - namespace: - type: ["null", "string"] # some OBO classes have no namespace - description: The namespace of the term. - examples: - - UO - alt_ids: - type: array - items: - type: string - description: Defines an alternate id for this term. A term may have any number - of alternate ids. - examples: - - ["UO:0000231"] - def: - type: ["null", "object"] # some OBO classes have no definition - description: The definition of the current term. - required: - - val - properties: - pred: - type: string - description: The definition predicate - val: - type: string - description: The definition value - examples: - - A natural/cultural feature of outstanding or unique value because of its inherent - rarity, representative of aesthetic qualities or cultural significance. - xrefs: - type: array - description: A dbxref that describes an analagous term in another vocabulary - items: - type: string - examples: - - ["https://en.wikipedia.org/wiki/Natural_Monument"] - comments: - type: array - items: - type: string - description: Comments for this term. - examples: - - ["This class refers to strictly sealed enclosures such as Biosphere 2 (https://en.wikipedia.org/wiki/Biosphere_2), rather than vivaria which allow matter exchange with external environmental systems."] - subsets: - type: array - items: - type: string - description: This tag indicates a term subset to which this term belongs. - examples: - - ["http://purl.obolibrary.org/obo/uo#unit_group_slim"] - synonyms: - description: This tag gives a synonym for this term, some xrefs to describe the - origins of the synonym, and may indicate a synonym category or scope information. - type: array - items: - type: object - required: - - val - properties: - pred: - type: string - description: The synonym predicate - examples: - - hasBroadSynonym - - hasNarrowSynonym - val: - type: string - description: The synonym value - examples: - - HydrothermalVents - xrefs: - type: array - description: A dbxref that describes an analagous term in another vocabulary - items: - type: string - examples: - - ["NASA:earthrealm"] - xrefs: - description: DBxrefs that describes an analagous term in another vocabulary - type: array - items: - type: object - required: - - val - properties: - pred: - type: string - description: The xref predicate - val: - type: string - description: The xref value - examples: - - SPIRE:Soil - - https://en.wikipedia.org/wiki/Soil - xrefs: - type: array - description: A dbxref that describes an analagous term in another vocabulary - items: - type: string - required: - - id - - type - - name - - namespace - - alt_ids - - def - - comments - - subsets - - synonyms - - xrefs diff --git a/spec/data_sources/gaz_ontology.yaml b/spec/data_sources/gaz_ontology.yaml deleted file mode 100644 index f2c82185..00000000 --- a/spec/data_sources/gaz_ontology.yaml +++ /dev/null @@ -1,5 +0,0 @@ -category: ontology -data_url: http://purl.obolibrary.org/obo/gaz.obo -home_url: http://environmentontology.github.io/gaz/ -name: gaz_ontology -title: Gazetteer Ontology diff --git a/spec/data_sources/po_ontology.yaml b/spec/data_sources/po_ontology.yaml deleted file mode 100644 index 40802950..00000000 --- a/spec/data_sources/po_ontology.yaml +++ /dev/null @@ -1,5 +0,0 @@ -name: po_ontology -category: ontology -title: Plant Ontology -home_url: "http://browser.planteome.org/amigo" -data_url: "http://purl.obolibrary.org/obo/po.obo" diff --git a/spec/data_sources/uo_ontology.yaml b/spec/data_sources/uo_ontology.yaml deleted file mode 100644 index 7c909341..00000000 --- a/spec/data_sources/uo_ontology.yaml +++ /dev/null @@ -1,5 +0,0 @@ -name: uo_ontology -category: ontology -title: Units of measurement ontology -home_url: "https://github.com/bio-ontology-research-group/unit-ontology" -data_url: "http://purl.obolibrary.org/obo/uo.obo" From a4bb68362a4c6d400bb04709d83527f3decd82c7 Mon Sep 17 00:00:00 2001 From: ialarmedalien Date: Thu, 29 Jul 2021 12:23:45 -0700 Subject: [PATCH 675/732] Running black on files --- importers/test/test_djornl_parser.py | 20 +++++++++---------- .../test/test_json_validation.py | 2 +- .../utils/json_validation.py | 2 +- spec/test/collections/test_djornl.py | 2 +- spec/test/helpers.py | 2 +- spec/test/stored_queries/test_ncbi_tax.py | 12 +++++------ spec/test/stored_queries/test_taxonomy.py | 12 +++++------ spec/test/test_manifest_schema.py | 2 +- 8 files changed, 27 insertions(+), 27 deletions(-) diff --git a/importers/test/test_djornl_parser.py b/importers/test/test_djornl_parser.py index 11dd0fff..281fb0fc 100644 --- a/importers/test/test_djornl_parser.py +++ b/importers/test/test_djornl_parser.py @@ -72,7 +72,7 @@ def test_config(self): parser.config("bananas") def test_load_no_manifest(self): - """ test loading when the manifest does not exist """ + """test loading when the manifest does not exist""" RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, "djornl", "no_manifest") err_str = "No manifest file found at " + os.path.join( RES_ROOT_DATA_PATH, "manifest.yaml" @@ -81,14 +81,14 @@ def test_load_no_manifest(self): self.init_parser_with_path(RES_ROOT_DATA_PATH) def test_load_invalid_manifest(self): - """ test an invalid manifest file """ + """test an invalid manifest file""" RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, "djornl", "invalid_manifest") err_str = "The manifest file failed validation" with self.assertRaisesRegex(RuntimeError, err_str): self.init_parser_with_path(RES_ROOT_DATA_PATH) def test_load_invalid_file(self): - """ test loading when what is supposed to be a file is actually a directory """ + """test loading when what is supposed to be a file is actually a directory""" RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, "djornl", "invalid_file") @@ -98,7 +98,7 @@ def test_load_invalid_file(self): self.init_parser_with_path(RES_ROOT_DATA_PATH) def test_load_missing_files(self): - """ test loading when files cannot be found """ + """test loading when files cannot be found""" RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, "djornl", "missing_files") # not found err_str = ( @@ -108,7 +108,7 @@ def test_load_missing_files(self): self.init_parser_with_path(RES_ROOT_DATA_PATH) def test_load_empty_files(self): - """ test loading files containing no data """ + """test loading files containing no data""" # path: test/djornl/empty_files RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, "djornl", "empty_files") @@ -131,7 +131,7 @@ def test_load_empty_files(self): self.test_errors(parser, errs) def test_load_missing_headers(self): - """ test loading when files lack required headers """ + """test loading when files lack required headers""" RES_ROOT_DATA_PATH = os.path.join( _TEST_DIR, "djornl", "missing_required_headers" ) @@ -172,7 +172,7 @@ def dupe_err(file_name, header_list): self.test_errors(parser, errs) def test_load_invalid_types(self): - """ test file format errors """ + """test file format errors""" # path: test/djornl/invalid_types RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, "djornl", "invalid_types") @@ -213,7 +213,7 @@ def test_load_invalid_types(self): self.test_errors(parser, errs) def test_load_col_count_errors(self): - """ test files with invalid numbers of columns """ + """test files with invalid numbers of columns""" # path: test/djornl/col_count_errors RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, "djornl", "col_count_errors") @@ -276,7 +276,7 @@ def test_load_valid_cluster_data(self): self.assertEqual(cluster_data, expected) def test_duplicate_data(self): - """ test files with duplicate data that should throw an error """ + """test files with duplicate data that should throw an error""" RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, "djornl", "duplicate_data") parser = self.init_parser_with_path(RES_ROOT_DATA_PATH) @@ -297,7 +297,7 @@ def test_duplicate_data(self): self.test_errors(parser, errs) def test_duplicate_cluster_data(self): - """ test files with duplicate cluster data, which should be seamlessly merged """ + """test files with duplicate cluster data, which should be seamlessly merged""" # path: test/djornl/duplicate_data RES_ROOT_DATA_PATH = os.path.join(_TEST_DIR, "djornl", "duplicate_data") diff --git a/relation_engine_server/test/test_json_validation.py b/relation_engine_server/test/test_json_validation.py index fab461cd..f5a57d0b 100644 --- a/relation_engine_server/test/test_json_validation.py +++ b/relation_engine_server/test/test_json_validation.py @@ -181,7 +181,7 @@ def test_non_validation_validator_errors(self): self.assertEqual(output, {**schema_defaults, **{"name": "name", "distance": 3}}) def test_json_validation(self): - """ Generic JSON validation tests to ensure that all is working as expected """ + """Generic JSON validation tests to ensure that all is working as expected""" # run these tests with the schema as a data structure, as JSON, and as YAML test_list = [ diff --git a/relation_engine_server/utils/json_validation.py b/relation_engine_server/utils/json_validation.py index 1860220e..3b156698 100644 --- a/relation_engine_server/utils/json_validation.py +++ b/relation_engine_server/utils/json_validation.py @@ -137,7 +137,7 @@ def run_validator( def _load_json_schema(file): - """ Loads the given schema file """ + """Loads the given schema file""" with open(file) as fd: if file.endswith(".yaml") or file.endswith(".yml"): diff --git a/spec/test/collections/test_djornl.py b/spec/test/collections/test_djornl.py index 73305df7..a517098c 100644 --- a/spec/test/collections/test_djornl.py +++ b/spec/test/collections/test_djornl.py @@ -37,7 +37,7 @@ def tearDownClass(cls): ) def test_node(self, query_name=None, test_data=None): - """ ensure node data validates correctly """ + """ensure node data validates correctly""" schema_file = get_schema("collection", "djornl_node", path_only=True) validator = get_schema_validator(schema_file=schema_file, validate_at="/schema") diff --git a/spec/test/helpers.py b/spec/test/helpers.py index 3d79f066..a01a7888 100644 --- a/spec/test/helpers.py +++ b/spec/test/helpers.py @@ -67,7 +67,7 @@ def create_test_docs(coll_name, docs, update_on_dupe=False): def check_spec_test_env(): - """ ensure that the environment is prepared for running the spec tests """ + """ensure that the environment is prepared for running the spec tests""" if os.environ.get("SPEC_TEST_READY", None) is None: wait_for_api() _CONF = get_re_config() diff --git a/spec/test/stored_queries/test_ncbi_tax.py b/spec/test/stored_queries/test_ncbi_tax.py index 8e420e11..b37a57a4 100644 --- a/spec/test/stored_queries/test_ncbi_tax.py +++ b/spec/test/stored_queries/test_ncbi_tax.py @@ -364,7 +364,7 @@ def test_search_sciname_limit_max(self): ) def test_search_sciname_limit_ranks_implicit_defaults(self): - """ Test queries where the results are limited by the rank or strain flag. """ + """Test queries where the results are limited by the rank or strain flag.""" _run_search_sciname( self, ranks=None, @@ -374,7 +374,7 @@ def test_search_sciname_limit_ranks_implicit_defaults(self): ) def test_search_sciname_limit_ranks_explicit_defaults(self): - """ Test queries where the results are limited by the rank or strain flag. """ + """Test queries where the results are limited by the rank or strain flag.""" _run_search_sciname( self, ranks=[], @@ -384,7 +384,7 @@ def test_search_sciname_limit_ranks_explicit_defaults(self): ) def test_search_sciname_limit_ranks_2(self): - """ Test queries where the results are limited by the rank or strain flag. """ + """Test queries where the results are limited by the rank or strain flag.""" _run_search_sciname( self, ranks=["Domain", "Class"], @@ -394,7 +394,7 @@ def test_search_sciname_limit_ranks_2(self): ) def test_search_sciname_limit_ranks_1(self): - """ Test queries where the results are limited by the rank or strain flag. """ + """Test queries where the results are limited by the rank or strain flag.""" _run_search_sciname( self, ranks=["Class"], @@ -404,7 +404,7 @@ def test_search_sciname_limit_ranks_1(self): ) def test_search_sciname_limit_ranks_1_with_strain(self): - """ Test queries where the results are limited by the rank or strain flag. """ + """Test queries where the results are limited by the rank or strain flag.""" _run_search_sciname( self, ranks=["Class"], @@ -414,7 +414,7 @@ def test_search_sciname_limit_ranks_1_with_strain(self): ) def test_search_sciname_limit_ranks_1_with_false_strain(self): - """ Test queries where the results are limited by the rank or strain flag. """ + """Test queries where the results are limited by the rank or strain flag.""" _run_search_sciname( self, ranks=["Class"], diff --git a/spec/test/stored_queries/test_taxonomy.py b/spec/test/stored_queries/test_taxonomy.py index 8cb71733..4d307ca5 100644 --- a/spec/test/stored_queries/test_taxonomy.py +++ b/spec/test/stored_queries/test_taxonomy.py @@ -481,7 +481,7 @@ def test_search_sciname_limit_max(self): ) def test_search_sciname_limit_ranks_implicit_defaults(self): - """ Test queries where the results are limited by the rank or strain flag. """ + """Test queries where the results are limited by the rank or strain flag.""" _run_search_sciname( self, ranks=None, @@ -491,7 +491,7 @@ def test_search_sciname_limit_ranks_implicit_defaults(self): ) def test_search_sciname_limit_ranks_explicit_defaults(self): - """ Test queries where the results are limited by the rank or strain flag. """ + """Test queries where the results are limited by the rank or strain flag.""" _run_search_sciname( self, ranks=[], @@ -501,7 +501,7 @@ def test_search_sciname_limit_ranks_explicit_defaults(self): ) def test_search_sciname_limit_ranks_2(self): - """ Test queries where the results are limited by the rank or strain flag. """ + """Test queries where the results are limited by the rank or strain flag.""" _run_search_sciname( self, ranks=["Domain", "Class"], @@ -511,7 +511,7 @@ def test_search_sciname_limit_ranks_2(self): ) def test_search_sciname_limit_ranks_1(self): - """ Test queries where the results are limited by the rank or strain flag. """ + """Test queries where the results are limited by the rank or strain flag.""" _run_search_sciname( self, ranks=["Class"], @@ -521,7 +521,7 @@ def test_search_sciname_limit_ranks_1(self): ) def test_search_sciname_limit_ranks_1_with_strain(self): - """ Test queries where the results are limited by the rank or strain flag. """ + """Test queries where the results are limited by the rank or strain flag.""" _run_search_sciname( self, ranks=["Class"], @@ -531,7 +531,7 @@ def test_search_sciname_limit_ranks_1_with_strain(self): ) def test_search_sciname_limit_ranks_1_with_false_strain(self): - """ Test queries where the results are limited by the rank or strain flag. """ + """Test queries where the results are limited by the rank or strain flag.""" _run_search_sciname( self, ranks=["Class"], diff --git a/spec/test/test_manifest_schema.py b/spec/test/test_manifest_schema.py index 54bc8ea4..6c00bf2d 100644 --- a/spec/test/test_manifest_schema.py +++ b/spec/test/test_manifest_schema.py @@ -16,7 +16,7 @@ class Test_Manifest_Schema(unittest.TestCase): def test_load_invalid_manifest(self): - """ test an invalid manifest file """ + """test an invalid manifest file""" invalid_dir = os_path.join(_TEST_DIR, "invalid_manifest") From 2514e15f2e840e39beeee30b287c45e2959b227c Mon Sep 17 00:00:00 2001 From: ialarmedalien Date: Thu, 29 Jul 2021 12:24:05 -0700 Subject: [PATCH 676/732] Updating codeowners and Dockerfile --- CODEOWNERS | 4 ++-- Dockerfile | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CODEOWNERS b/CODEOWNERS index d70d24cd..45d24230 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -1,3 +1,3 @@ -* @jayrbolton @ialarmedalien +* @ialarmedalien @zhlu9890 @eapearson -relation_engine_server/* @jayrbolton @slebras +relation_engine_server/* @ialarmedalien @slebras diff --git a/Dockerfile b/Dockerfile index 6489905f..7ba06bc0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,8 +20,8 @@ RUN apk --update add --virtual build-dependencies curl tar gzip && \ # Install dependencies RUN apk --update add --virtual build-dependencies build-base python3-dev && \ pip install --upgrade pip && \ - pip install --use-feature=2020-resolver --no-cache-dir -r /tmp/requirements.txt && \ - if [ "$DEVELOPMENT" ]; then pip install --use-feature=2020-resolver --no-cache-dir -r /tmp/dev-requirements.txt; fi && \ + pip install --no-cache-dir -r /tmp/requirements.txt && \ + if [ "$DEVELOPMENT" ]; then pip install --no-cache-dir -r /tmp/dev-requirements.txt; fi && \ apk del build-dependencies COPY . /app From 860cbdc23a0959b84a2e821355f44bfd8d5f3b11 Mon Sep 17 00:00:00 2001 From: ialarmedalien Date: Thu, 29 Jul 2021 12:33:31 -0700 Subject: [PATCH 677/732] attempt to fix mypy probs --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 7ba06bc0..1e211a06 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,7 +22,8 @@ RUN apk --update add --virtual build-dependencies build-base python3-dev && \ pip install --upgrade pip && \ pip install --no-cache-dir -r /tmp/requirements.txt && \ if [ "$DEVELOPMENT" ]; then pip install --no-cache-dir -r /tmp/dev-requirements.txt; fi && \ - apk del build-dependencies + apk del build-dependencies && \ + mypy --install-types COPY . /app From d66638d5d2e0a7e0b46e49920d6fa54ac1a55d55 Mon Sep 17 00:00:00 2001 From: ialarmedalien Date: Thu, 29 Jul 2021 12:39:09 -0700 Subject: [PATCH 678/732] attempt II to fix mypy probs --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 1e211a06..c2a3fce0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,7 +23,7 @@ RUN apk --update add --virtual build-dependencies build-base python3-dev && \ pip install --no-cache-dir -r /tmp/requirements.txt && \ if [ "$DEVELOPMENT" ]; then pip install --no-cache-dir -r /tmp/dev-requirements.txt; fi && \ apk del build-dependencies && \ - mypy --install-types + pip install types-requests types-PyYAML COPY . /app From 9106586d8834c50125e9319ed98efd0291a09794 Mon Sep 17 00:00:00 2001 From: Zhenyuan Lu Date: Mon, 2 Aug 2021 13:10:19 -0400 Subject: [PATCH 679/732] adding GAZ, UO, PO yaml files --- scripts/test/data/data_sources.json | 24 ++++++ spec/collections/GAZ/GAZ_edges.yaml | 37 ++++++++ spec/collections/GAZ/GAZ_merges.yaml | 37 ++++++++ spec/collections/GAZ/GAZ_terms.yaml | 121 +++++++++++++++++++++++++++ spec/collections/PO/PO_edges.yaml | 37 ++++++++ spec/collections/PO/PO_merges.yaml | 37 ++++++++ spec/collections/PO/PO_terms.yaml | 121 +++++++++++++++++++++++++++ spec/collections/UO/UO_edges.yaml | 37 ++++++++ spec/collections/UO/UO_merges.yaml | 37 ++++++++ spec/collections/UO/UO_terms.yaml | 121 +++++++++++++++++++++++++++ spec/data_sources/gaz_ontology.yaml | 5 ++ spec/data_sources/po_ontology.yaml | 5 ++ spec/data_sources/uo_ontology.yaml | 5 ++ 13 files changed, 624 insertions(+) create mode 100644 spec/collections/GAZ/GAZ_edges.yaml create mode 100644 spec/collections/GAZ/GAZ_merges.yaml create mode 100644 spec/collections/GAZ/GAZ_terms.yaml create mode 100644 spec/collections/PO/PO_edges.yaml create mode 100644 spec/collections/PO/PO_merges.yaml create mode 100644 spec/collections/PO/PO_terms.yaml create mode 100644 spec/collections/UO/UO_edges.yaml create mode 100644 spec/collections/UO/UO_merges.yaml create mode 100644 spec/collections/UO/UO_terms.yaml create mode 100644 spec/data_sources/gaz_ontology.yaml create mode 100644 spec/data_sources/po_ontology.yaml create mode 100644 spec/data_sources/uo_ontology.yaml diff --git a/scripts/test/data/data_sources.json b/scripts/test/data/data_sources.json index fb21bb4f..1ad34c47 100644 --- a/scripts/test/data/data_sources.json +++ b/scripts/test/data/data_sources.json @@ -174,6 +174,30 @@ }, "additional_fields": [] }, + { + "ns": "gaz_ontology", + "type": "ontology", + "title": "Gazetteer Ontology", + "short_title": "GAZ", + "home_url": "http://environmentontology.github.io/gaz/", + "data_url": "http://purl.obolibrary.org/obo/gaz.obo" + }, + { + "ns": "uo_ontology", + "type": "ontology", + "title": "Units of measurement ontology", + "short_title": "UO", + "home_url": "https://github.com/bio-ontology-research-group/unit-ontology", + "data_url": "http://purl.obolibrary.org/obo/uo.obo" + }, + { + "ns": "po_ontology", + "type": "ontology", + "title": "Plant Ontology", + "short_title": "PO", + "home_url": "http://browser.planteome.org/amigo", + "data_url": "http://purl.obolibrary.org/obo/po.obo" + }, { "ns": "fake_ontology", "type": "ontology", diff --git a/spec/collections/GAZ/GAZ_edges.yaml b/spec/collections/GAZ/GAZ_edges.yaml new file mode 100644 index 00000000..32a15f07 --- /dev/null +++ b/spec/collections/GAZ/GAZ_edges.yaml @@ -0,0 +1,37 @@ +delta: true +indexes: +- fields: + - id + - expired + - created + type: persistent +- fields: + - expired + - created + - last_version + type: persistent +name: GAZ_edges +schema: + $schema: http://json-schema.org/draft-07/schema# + description: A entry for edges in the GAZ ontology hierarchy + properties: + from: + description: GAZ id + type: string + id: + description: an edge ID, consisting of from::to::type + type: string + to: + description: GAZ id + type: string + type: + description: GAZ edge type + type: string + required: + - id + - type + - from + - to + title: GAZ_edges + type: object +type: edge diff --git a/spec/collections/GAZ/GAZ_merges.yaml b/spec/collections/GAZ/GAZ_merges.yaml new file mode 100644 index 00000000..e05bccd7 --- /dev/null +++ b/spec/collections/GAZ/GAZ_merges.yaml @@ -0,0 +1,37 @@ +delta: true +indexes: +- fields: + - id + - expired + - created + type: persistent +- fields: + - expired + - created + - last_version + type: persistent +name: GAZ_merges +schema: + $schema: http://json-schema.org/draft-07/schema# + description: A entry for merge edges in the GAZ ontology hierarchy + properties: + from: + description: GAZ id + type: string + id: + description: an edge ID, consisting of from::to::type + type: string + to: + description: GAZ id + type: string + type: + description: GAZ merge edge type + type: string + required: + - id + - type + - from + - to + title: GAZ_merges + type: object +type: edge diff --git a/spec/collections/GAZ/GAZ_terms.yaml b/spec/collections/GAZ/GAZ_terms.yaml new file mode 100644 index 00000000..810f7026 --- /dev/null +++ b/spec/collections/GAZ/GAZ_terms.yaml @@ -0,0 +1,121 @@ +delta: true +indexes: +- fields: + - id + - expired + - created + type: persistent +- fields: + - expired + - created + - last_version + type: persistent +name: GAZ_terms +schema: + $schema: http://json-schema.org/draft-07/schema# + description: A entry for vertices in the GAZ ontology hierarchy + properties: + alt_ids: + description: Defines an alternate id for this term. A term may have any number + of alternate ids. + items: + type: string + type: array + comments: + description: Comments for this term. + items: + type: string + type: array + def: + description: The definition of the current term. + properties: + pred: + description: The definition predicate + type: string + val: + description: The definition value + type: string + xrefs: + description: A dbxref that describes an analagous term in another vocabulary + items: + type: string + type: array + required: + - val + type: + - 'null' + - object + id: + description: The unique id of the current term. + type: string + name: + description: The term name. + type: + - 'null' + - string + namespace: + description: The namespace of the term. + type: + - 'null' + - string + subsets: + description: This tag indicates a term subset to which this term belongs. + items: + type: string + type: array + synonyms: + description: This tag gives a synonym for this term, some xrefs to describe + the origins of the synonym, and may indicate a synonym category or scope information. + items: + properties: + pred: + description: The synonym predicate + type: string + val: + description: The synonym value + type: string + xrefs: + description: A dbxref that describes an analagous term in another vocabulary + items: + type: string + type: array + required: + - val + type: object + type: array + type: + description: The type of the node. + type: string + xrefs: + description: DBxrefs that describes an analagous term in another vocabulary + items: + properties: + pred: + description: The xref predicate + type: string + val: + description: The xref value + type: string + xrefs: + description: A dbxref that describes an analagous term in another vocabulary + items: + type: string + type: array + required: + - val + type: object + type: array + required: + - id + - type + - name + - namespace + - alt_ids + - def + - comments + - subsets + - synonyms + - xrefs + title: GAZ_terms + type: object +type: vertex diff --git a/spec/collections/PO/PO_edges.yaml b/spec/collections/PO/PO_edges.yaml new file mode 100644 index 00000000..3f917b6e --- /dev/null +++ b/spec/collections/PO/PO_edges.yaml @@ -0,0 +1,37 @@ +delta: true +indexes: +- fields: + - id + - expired + - created + type: persistent +- fields: + - expired + - created + - last_version + type: persistent +name: PO_edges +schema: + $schema: http://json-schema.org/draft-07/schema# + description: A entry for edges in the PO ontology hierarchy + properties: + from: + description: PO id + type: string + id: + description: an edge ID, consisting of from::to::type + type: string + to: + description: PO id + type: string + type: + description: PO edge type + type: string + required: + - id + - type + - from + - to + title: PO_edges + type: object +type: edge diff --git a/spec/collections/PO/PO_merges.yaml b/spec/collections/PO/PO_merges.yaml new file mode 100644 index 00000000..63b6fc98 --- /dev/null +++ b/spec/collections/PO/PO_merges.yaml @@ -0,0 +1,37 @@ +delta: true +indexes: +- fields: + - id + - expired + - created + type: persistent +- fields: + - expired + - created + - last_version + type: persistent +name: PO_merges +schema: + $schema: http://json-schema.org/draft-07/schema# + description: A entry for merge edges in the PO ontology hierarchy + properties: + from: + description: PO id + type: string + id: + description: an edge ID, consisting of from::to::type + type: string + to: + description: PO id + type: string + type: + description: PO merge edge type + type: string + required: + - id + - type + - from + - to + title: PO_merges + type: object +type: edge diff --git a/spec/collections/PO/PO_terms.yaml b/spec/collections/PO/PO_terms.yaml new file mode 100644 index 00000000..f874c9fc --- /dev/null +++ b/spec/collections/PO/PO_terms.yaml @@ -0,0 +1,121 @@ +delta: true +indexes: +- fields: + - id + - expired + - created + type: persistent +- fields: + - expired + - created + - last_version + type: persistent +name: PO_terms +schema: + $schema: http://json-schema.org/draft-07/schema# + description: A entry for vertices in the PO ontology hierarchy + properties: + alt_ids: + description: Defines an alternate id for this term. A term may have any number + of alternate ids. + items: + type: string + type: array + comments: + description: Comments for this term. + items: + type: string + type: array + def: + description: The definition of the current term. + properties: + pred: + description: The definition predicate + type: string + val: + description: The definition value + type: string + xrefs: + description: A dbxref that describes an analagous term in another vocabulary + items: + type: string + type: array + required: + - val + type: + - 'null' + - object + id: + description: The unique id of the current term. + type: string + name: + description: The term name. + type: + - 'null' + - string + namespace: + description: The namespace of the term. + type: + - 'null' + - string + subsets: + description: This tag indicates a term subset to which this term belongs. + items: + type: string + type: array + synonyms: + description: This tag gives a synonym for this term, some xrefs to describe + the origins of the synonym, and may indicate a synonym category or scope information. + items: + properties: + pred: + description: The synonym predicate + type: string + val: + description: The synonym value + type: string + xrefs: + description: A dbxref that describes an analagous term in another vocabulary + items: + type: string + type: array + required: + - val + type: object + type: array + type: + description: The type of the node. + type: string + xrefs: + description: DBxrefs that describes an analagous term in another vocabulary + items: + properties: + pred: + description: The xref predicate + type: string + val: + description: The xref value + type: string + xrefs: + description: A dbxref that describes an analagous term in another vocabulary + items: + type: string + type: array + required: + - val + type: object + type: array + required: + - id + - type + - name + - namespace + - alt_ids + - def + - comments + - subsets + - synonyms + - xrefs + title: PO_terms + type: object +type: vertex diff --git a/spec/collections/UO/UO_edges.yaml b/spec/collections/UO/UO_edges.yaml new file mode 100644 index 00000000..525ff5b1 --- /dev/null +++ b/spec/collections/UO/UO_edges.yaml @@ -0,0 +1,37 @@ +delta: true +indexes: +- fields: + - id + - expired + - created + type: persistent +- fields: + - expired + - created + - last_version + type: persistent +name: UO_edges +schema: + $schema: http://json-schema.org/draft-07/schema# + description: A entry for edges in the UO ontology hierarchy + properties: + from: + description: UO id + type: string + id: + description: an edge ID, consisting of from::to::type + type: string + to: + description: UO id + type: string + type: + description: UO edge type + type: string + required: + - id + - type + - from + - to + title: UO_edges + type: object +type: edge diff --git a/spec/collections/UO/UO_merges.yaml b/spec/collections/UO/UO_merges.yaml new file mode 100644 index 00000000..42303972 --- /dev/null +++ b/spec/collections/UO/UO_merges.yaml @@ -0,0 +1,37 @@ +delta: true +indexes: +- fields: + - id + - expired + - created + type: persistent +- fields: + - expired + - created + - last_version + type: persistent +name: UO_merges +schema: + $schema: http://json-schema.org/draft-07/schema# + description: A entry for merge edges in the UO ontology hierarchy + properties: + from: + description: UO id + type: string + id: + description: an edge ID, consisting of from::to::type + type: string + to: + description: UO id + type: string + type: + description: UO merge edge type + type: string + required: + - id + - type + - from + - to + title: UO_merges + type: object +type: edge diff --git a/spec/collections/UO/UO_terms.yaml b/spec/collections/UO/UO_terms.yaml new file mode 100644 index 00000000..0d38690a --- /dev/null +++ b/spec/collections/UO/UO_terms.yaml @@ -0,0 +1,121 @@ +delta: true +indexes: +- fields: + - id + - expired + - created + type: persistent +- fields: + - expired + - created + - last_version + type: persistent +name: UO_terms +schema: + $schema: http://json-schema.org/draft-07/schema# + description: A entry for vertices in the UO ontology hierarchy + properties: + alt_ids: + description: Defines an alternate id for this term. A term may have any number + of alternate ids. + items: + type: string + type: array + comments: + description: Comments for this term. + items: + type: string + type: array + def: + description: The definition of the current term. + properties: + pred: + description: The definition predicate + type: string + val: + description: The definition value + type: string + xrefs: + description: A dbxref that describes an analagous term in another vocabulary + items: + type: string + type: array + required: + - val + type: + - 'null' + - object + id: + description: The unique id of the current term. + type: string + name: + description: The term name. + type: + - 'null' + - string + namespace: + description: The namespace of the term. + type: + - 'null' + - string + subsets: + description: This tag indicates a term subset to which this term belongs. + items: + type: string + type: array + synonyms: + description: This tag gives a synonym for this term, some xrefs to describe + the origins of the synonym, and may indicate a synonym category or scope information. + items: + properties: + pred: + description: The synonym predicate + type: string + val: + description: The synonym value + type: string + xrefs: + description: A dbxref that describes an analagous term in another vocabulary + items: + type: string + type: array + required: + - val + type: object + type: array + type: + description: The type of the node. + type: string + xrefs: + description: DBxrefs that describes an analagous term in another vocabulary + items: + properties: + pred: + description: The xref predicate + type: string + val: + description: The xref value + type: string + xrefs: + description: A dbxref that describes an analagous term in another vocabulary + items: + type: string + type: array + required: + - val + type: object + type: array + required: + - id + - type + - name + - namespace + - alt_ids + - def + - comments + - subsets + - synonyms + - xrefs + title: UO_terms + type: object +type: vertex diff --git a/spec/data_sources/gaz_ontology.yaml b/spec/data_sources/gaz_ontology.yaml new file mode 100644 index 00000000..f2c82185 --- /dev/null +++ b/spec/data_sources/gaz_ontology.yaml @@ -0,0 +1,5 @@ +category: ontology +data_url: http://purl.obolibrary.org/obo/gaz.obo +home_url: http://environmentontology.github.io/gaz/ +name: gaz_ontology +title: Gazetteer Ontology diff --git a/spec/data_sources/po_ontology.yaml b/spec/data_sources/po_ontology.yaml new file mode 100644 index 00000000..c6206071 --- /dev/null +++ b/spec/data_sources/po_ontology.yaml @@ -0,0 +1,5 @@ +category: ontology +data_url: http://purl.obolibrary.org/obo/po.obo +home_url: http://browser.planteome.org/amigo +name: po_ontology +title: Plant Ontology diff --git a/spec/data_sources/uo_ontology.yaml b/spec/data_sources/uo_ontology.yaml new file mode 100644 index 00000000..547ed20b --- /dev/null +++ b/spec/data_sources/uo_ontology.yaml @@ -0,0 +1,5 @@ +category: ontology +data_url: http://purl.obolibrary.org/obo/uo.obo +home_url: https://github.com/bio-ontology-research-group/unit-ontology +name: uo_ontology +title: Units of measurement ontology From 3f308eaf54353574520b4d523dc589589f3474ec Mon Sep 17 00:00:00 2001 From: Dakota Blair Date: Wed, 4 Aug 2021 16:30:22 -0400 Subject: [PATCH 680/732] Added TSV node file schema. --- importers/djornl/parser.py | 34 ++++++++++++---------- spec/datasets/djornl/tsv_node.yaml | 45 ++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 14 deletions(-) create mode 100644 spec/datasets/djornl/tsv_node.yaml diff --git a/importers/djornl/parser.py b/importers/djornl/parser.py index ae79f23f..5be62ac1 100644 --- a/importers/djornl/parser.py +++ b/importers/djornl/parser.py @@ -383,9 +383,9 @@ def store_parsed_edge_data(self, datum): # keep track of the nodes mentioned in this edge set for node_n in ["1", "2"]: - _key = datum[f"node{node_n}"] - if _key not in self.node_ix: - self.node_ix[_key] = {"_key": _key} + _node_key = datum[f"node{node_n}"] + if _node_key not in self.node_ix: + self.node_ix[_node_key] = {"_key": _node_key} del datum[f"node{node_n}"] self.edge_ix[edge_key] = datum @@ -510,34 +510,40 @@ def _try_node_merge(self, existing_node, new_node, path=[]): def store_parsed_node_data(self, datum): """ - store node data in the node index, node_ix, indexed by the node _key + store node data in the node index, node_ix, indexed by the node _key or gid If a node is already present, new data is checked for conflicts with existing data """ + node_ix = datum.get("gid", datum.get("_key")) + if not node_ix: return # check whether we have this node already - if datum["_key"] in self.node_ix: + if node_ix in self.node_ix: # identical data: ignore it - if datum == self.node_ix[datum["_key"]]: + if datum == self.node_ix[node_ix]: return None # try merging the data (merged, err_list) = self._try_node_merge( - self.node_ix[datum["_key"]], datum + self.node_ix[node_ix], datum ) if err_list: - return "duplicate data for node " + datum["_key"] + return "duplicate data for node " + node_ix datum = merged - self.node_ix[datum["_key"]] = datum - return None + self.node_ix[node_ix] = datum def load_nodes(self): """Load node metadata""" err_list = [] - schema_file = os.path.join(self._get_dataset_schema_dir(), "csv_node.yaml") - validator = get_schema_validator(schema_file=schema_file) + schema_file = os.path.join( + self._get_dataset_schema_dir(), "{file_format}_node.yaml" + ) + def _get_node_validator(file_format): + return get_schema_validator(schema_file=schema_file.format( + file_format=file_format + )) def go_terms(row): if "go_terms" in row and len(row["go_terms"]): @@ -565,7 +571,7 @@ def go_terms(row): "transcript": None, "user_notes": None, # rename - "_key": lambda row: row["node_id"], + "_key": lambda row: row["gid"] if "gid" in row else row["node_id"], # see functions above "go_terms": go_terms, } @@ -576,7 +582,7 @@ def go_terms(row): remap_fn=remap_functions, store_fn=self.store_parsed_node_data, err_list=err_list, - validator=validator, + validator=_get_node_validator(file_format=file['file_format']), ) return { diff --git a/spec/datasets/djornl/tsv_node.yaml b/spec/datasets/djornl/tsv_node.yaml new file mode 100644 index 00000000..35d6b4ad --- /dev/null +++ b/spec/datasets/djornl/tsv_node.yaml @@ -0,0 +1,45 @@ +$schema: http://json-schema.org/draft-07/schema# +name: tsv_node +title: TSV node file syntax +description: Jacobson lab Arabidopsis gene and phenotype data file columns +type: object +required: [gid] +additionalProperties: false +properties: + defline: + examples: ["NAC domain containing protein 1"] + title: Defline + type: string + gid: + examples: ["AT1G01010", "AT4G09995", "AT4G03060-CVI", "SU(RGN)"] + format: regex + pattern: ^(AT[0-9CM][0-9G]+|[- ().0-9A-Z]{,13})$ + title: Gene ID + type: string + go: + pattern: ^((NA|GO:\d{7})\|?)+$ + type: string + godesc: + pattern: ^((NA|[- ()+,'./0-9>:A-z_])\|?)+$ + type: string + ko_effect: + pattern: ^((NA|[- %,()/0-9:A-z])\|?)+$ + type: string + mapman_code: + pattern: ^((NA|[0-9]{,2}\.?))+$ + type: string + mapman_desc: + type: string + mapman_name: + type: string + names: + pattern: !!str "^\\|?(([\ + - \\#&\"'()+,./0-9:;?A-Z\\[\\\\\\]_a-z{}\ + \xa0\xad\xb3\xc2\xc3\xdf\xf3\ + ])\\|?)*$" + type: string + symbols: + examples: ["ANAC001 | NAC001 | NTL10", "NA"] + format: regex + pattern: ^((NA|[- \#&'()*,./0-9:;A-Z\[\]_a-z{}])\|?)+$ + type: string From b73511d889285f91b5a3052442a850985c1bfc47 Mon Sep 17 00:00:00 2001 From: Dakota Blair Date: Thu, 5 Aug 2021 13:52:00 -0400 Subject: [PATCH 681/732] Updated test manifests for TSV files. --- importers/djornl/parser.py | 16 ++++++++-------- importers/test/test_djornl_parser.py | 6 +++--- spec/test/djornl/col_count_errors/manifest.yaml | 1 + spec/test/djornl/duplicate_data/extra_node.csv | 5 +++++ spec/test/djornl/duplicate_data/extra_node.tsv | 5 ----- spec/test/djornl/duplicate_data/manifest.yaml | 9 ++++++--- spec/test/djornl/empty_files/manifest.yaml | 1 + spec/test/djornl/invalid_file/manifest.yaml | 1 + spec/test/djornl/invalid_types/manifest.yaml | 2 ++ .../missing_required_headers/extra_node.csv | 3 +++ .../missing_required_headers/manifest.yaml | 9 ++++++--- spec/test/djornl/test_data/extra_node.csv | 3 +++ spec/test/djornl/test_data/manifest.yaml | 9 ++++++--- 13 files changed, 45 insertions(+), 25 deletions(-) create mode 100644 spec/test/djornl/duplicate_data/extra_node.csv delete mode 100644 spec/test/djornl/duplicate_data/extra_node.tsv create mode 100644 spec/test/djornl/missing_required_headers/extra_node.csv create mode 100644 spec/test/djornl/test_data/extra_node.csv diff --git a/importers/djornl/parser.py b/importers/djornl/parser.py index 5be62ac1..6f4de607 100644 --- a/importers/djornl/parser.py +++ b/importers/djornl/parser.py @@ -515,7 +515,8 @@ def store_parsed_node_data(self, datum): If a node is already present, new data is checked for conflicts with existing data """ node_ix = datum.get("gid", datum.get("_key")) - if not node_ix: return + if not node_ix: + return # check whether we have this node already if node_ix in self.node_ix: # identical data: ignore it @@ -523,9 +524,7 @@ def store_parsed_node_data(self, datum): return None # try merging the data - (merged, err_list) = self._try_node_merge( - self.node_ix[node_ix], datum - ) + (merged, err_list) = self._try_node_merge(self.node_ix[node_ix], datum) if err_list: return "duplicate data for node " + node_ix datum = merged @@ -540,10 +539,11 @@ def load_nodes(self): schema_file = os.path.join( self._get_dataset_schema_dir(), "{file_format}_node.yaml" ) + def _get_node_validator(file_format): - return get_schema_validator(schema_file=schema_file.format( - file_format=file_format - )) + return get_schema_validator( + schema_file=schema_file.format(file_format=file_format) + ) def go_terms(row): if "go_terms" in row and len(row["go_terms"]): @@ -582,7 +582,7 @@ def go_terms(row): remap_fn=remap_functions, store_fn=self.store_parsed_node_data, err_list=err_list, - validator=_get_node_validator(file_format=file['file_format']), + validator=_get_node_validator(file_format=file["file_format"]), ) return { diff --git a/importers/test/test_djornl_parser.py b/importers/test/test_djornl_parser.py index 281fb0fc..4c119e69 100644 --- a/importers/test/test_djornl_parser.py +++ b/importers/test/test_djornl_parser.py @@ -163,8 +163,8 @@ def dupe_err(file_name, header_list): missing_err("hithruput-edges.csv", ["edge_type"]), ], "nodes": [ - missing_err("extra_node.tsv", ["node_type"]), - invalid_err("extra_node.tsv", ["node_types"]), + missing_err("extra_node.csv", ["node_type"]), + invalid_err("extra_node.csv", ["node_types"]), missing_err("pheno_nodes.csv", ["node_id"]), invalid_err("pheno_nodes.csv", ["id", "pheno_ref", "usernotes"]), ], @@ -292,7 +292,7 @@ def test_duplicate_data(self): "hithruput-edges.csv line 11: duplicate data for edge " + "SDV__AT1G01100__protein-protein-interaction_literature-curated_AraNet_v2__True", ], - "nodes": ["extra_node.tsv line 5: duplicate data for node AT1G01080"], + "nodes": ["extra_node.csv line 5: duplicate data for node AT1G01080"], } self.test_errors(parser, errs) diff --git a/spec/test/djornl/col_count_errors/manifest.yaml b/spec/test/djornl/col_count_errors/manifest.yaml index 589fca7c..e7d615e5 100644 --- a/spec/test/djornl/col_count_errors/manifest.yaml +++ b/spec/test/djornl/col_count_errors/manifest.yaml @@ -8,4 +8,5 @@ file_list: path: directed_edges.tsv - data_type: node + file_format: csv path: nodes.csv diff --git a/spec/test/djornl/duplicate_data/extra_node.csv b/spec/test/djornl/duplicate_data/extra_node.csv new file mode 100644 index 00000000..9dbcdf54 --- /dev/null +++ b/spec/test/djornl/duplicate_data/extra_node.csv @@ -0,0 +1,5 @@ +# data_type: node +node_id,node_type,transcript,gene_symbol,gene_full_name,gene_model_type,TAIR_Computational_description,TAIR_Curator_summary,TAIR_short_description,GO_description,GO_terms,MapMan_bin,MapMan_name,MapMan_description +AT1G01100,gene,AT1G01100.4,,,protein_coding,60S acidic ribosomal protein family;(source:Araport11),,60S acidic ribosomal protein family,"structural constituent of ribosome, ribonucleoprotein complex binding, protein kinase activator activity","GO:0003735, GO:0043021, GO:0030295",17.1.2.1.46,.Protein biosynthesis.ribosome biogenesis.large ribosomal subunit (LSU).LSU proteome.component RPP1,component RPP1 of LSU proteome component (original description: pep chromosome:TAIR10:1:50090:51187:-1 gene:AT1G01100 transcript:AT1G01100.4 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:RPP1A description:60S acidic ribosomal protein P1-1 [Source:UniProtKB/Swiss-Prot;Acc:Q8LCW9]) +# duplicated line with alterations +AT1G01080,gene,AT1G01080.3,whatever!,,protein_coding,RNA-binding (RRM/RBD/RNP motifs) family protein;(source:Araport11),,,"RNA binding, mRNA binding","GO:0003723, GO:0003729",35.1,not assigned.annotated,"(original description: pep chromosome:TAIR10:1:44970:47059:-1 gene:AT1G01080 transcript:AT1G01080.3 gene_biotype:protein_coding transcript_biotype:protein_coding description:RNA-binding (RRM/RBD/RNP motifs) family protein [Source:UniProtKB/TrEMBL;Acc:F4HQH8]) & 33 kDa ribonucleoprotein, chloroplastic OS=Nicotiana sylvestris (sp|p19684|roc5_nicsy : 109.0)" diff --git a/spec/test/djornl/duplicate_data/extra_node.tsv b/spec/test/djornl/duplicate_data/extra_node.tsv deleted file mode 100644 index a1a28b69..00000000 --- a/spec/test/djornl/duplicate_data/extra_node.tsv +++ /dev/null @@ -1,5 +0,0 @@ -# data_type: node -node_id node_type transcript gene_symbol gene_full_name gene_model_type TAIR_Computational_description TAIR_Curator_summary TAIR_short_description GO_description GO_terms MapMan_bin MapMan_name MapMan_description -AT1G01100 gene AT1G01100.4 protein_coding 60S acidic ribosomal protein family;(source:Araport11) 60S acidic ribosomal protein family structural constituent of ribosome, ribonucleoprotein complex binding, protein kinase activator activity GO:0003735, GO:0043021, GO:0030295 17.1.2.1.46 .Protein biosynthesis.ribosome biogenesis.large ribosomal subunit (LSU).LSU proteome.component RPP1 component RPP1 of LSU proteome component (original description: pep chromosome:TAIR10:1:50090:51187:-1 gene:AT1G01100 transcript:AT1G01100.4 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:RPP1A description:60S acidic ribosomal protein P1-1 [Source:UniProtKB/Swiss-Prot;Acc:Q8LCW9]) -# duplicated line with alterations -AT1G01080 gene AT1G01080.3 whatever! protein_coding RNA-binding (RRM/RBD/RNP motifs) family protein;(source:Araport11) "RNA binding, mRNA binding" "GO:0003723, GO:0003729" 35.1 not assigned.annotated "(original description: pep chromosome:TAIR10:1:44970:47059:-1 gene:AT1G01080 transcript:AT1G01080.3 gene_biotype:protein_coding transcript_biotype:protein_coding description:RNA-binding (RRM/RBD/RNP motifs) family protein [Source:UniProtKB/TrEMBL;Acc:F4HQH8]) & 33 kDa ribonucleoprotein chloroplastic OS=Nicotiana sylvestris (sp|p19684|roc5_nicsy : 109.0)" diff --git a/spec/test/djornl/duplicate_data/manifest.yaml b/spec/test/djornl/duplicate_data/manifest.yaml index beffb367..0197cad7 100644 --- a/spec/test/djornl/duplicate_data/manifest.yaml +++ b/spec/test/djornl/duplicate_data/manifest.yaml @@ -11,8 +11,9 @@ file_list: date: "2020-12-25" - data_type: node - path: nodes.csv date: "2019-01-01" + file_format: csv + path: nodes.csv - data_type: cluster cluster_prefix: markov_i2 @@ -31,9 +32,11 @@ file_list: path: I6_copy.csv - data_type: node - path: pheno_nodes.csv date: "2019-01-01" + file_format: csv + path: pheno_nodes.csv - data_type: node - path: extra_node.tsv date: "2019-01-01" + file_format: csv + path: extra_node.csv diff --git a/spec/test/djornl/empty_files/manifest.yaml b/spec/test/djornl/empty_files/manifest.yaml index ae04f7a4..498ab523 100644 --- a/spec/test/djornl/empty_files/manifest.yaml +++ b/spec/test/djornl/empty_files/manifest.yaml @@ -5,6 +5,7 @@ file_list: path: merged_edges-AMW-060820_AF.tsv - data_type: node + file_format: csv path: aranet2-aragwas-MERGED-AMW-v2_091319_nodeTable.csv - data_type: cluster diff --git a/spec/test/djornl/invalid_file/manifest.yaml b/spec/test/djornl/invalid_file/manifest.yaml index d79e76a7..985f458a 100644 --- a/spec/test/djornl/invalid_file/manifest.yaml +++ b/spec/test/djornl/invalid_file/manifest.yaml @@ -5,6 +5,7 @@ file_list: path: edges.tsv - data_type: node + file_format: csv path: nodes.csv - data_type: cluster diff --git a/spec/test/djornl/invalid_types/manifest.yaml b/spec/test/djornl/invalid_types/manifest.yaml index 2c007b84..6b5d90e7 100644 --- a/spec/test/djornl/invalid_types/manifest.yaml +++ b/spec/test/djornl/invalid_types/manifest.yaml @@ -8,6 +8,7 @@ file_list: path: directed_edges.tsv - data_type: node + file_format: csv path: nodes.csv - data_type: cluster @@ -15,4 +16,5 @@ file_list: cluster_prefix: markov_i2 - data_type: node + file_format: csv path: pheno_nodes.csv diff --git a/spec/test/djornl/missing_required_headers/extra_node.csv b/spec/test/djornl/missing_required_headers/extra_node.csv new file mode 100644 index 00000000..f33c19f7 --- /dev/null +++ b/spec/test/djornl/missing_required_headers/extra_node.csv @@ -0,0 +1,3 @@ +# data_type: node +node_id,node_types,transcript,gene_symbol,gene_full_name,gene_model_type,TAIR_Computational_description,TAIR_Curator_summary,TAIR_short_description,GO_description,GO_terms,MapMan_bin,MapMan_name,MapMan_description +AT1G01100,gene,AT1G01100.4,,,protein_coding,60S acidic ribosomal protein family;(source:Araport11),,60S acidic ribosomal protein family,"structural constituent of ribosome, ribonucleoprotein complex binding, protein kinase activator activity","GO:0003735, GO:0043021, GO:0030295",17.1.2.1.46,.Protein biosynthesis.ribosome biogenesis.large ribosomal subunit (LSU).LSU proteome.component RPP1,component RPP1 of LSU proteome component (original description: pep chromosome:TAIR10:1:50090:51187:-1 gene:AT1G01100 transcript:AT1G01100.4 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:RPP1A description:60S acidic ribosomal protein P1-1 [Source:UniProtKB/Swiss-Prot;Acc:Q8LCW9]) diff --git a/spec/test/djornl/missing_required_headers/manifest.yaml b/spec/test/djornl/missing_required_headers/manifest.yaml index 88098f82..0d761213 100644 --- a/spec/test/djornl/missing_required_headers/manifest.yaml +++ b/spec/test/djornl/missing_required_headers/manifest.yaml @@ -11,8 +11,9 @@ file_list: date: "2020-12-25" - data_type: node - path: nodes.csv date: "2019-01-01" + file_format: csv + path: nodes.csv - data_type: cluster cluster_prefix: markov_i2 @@ -27,9 +28,11 @@ file_list: path: I6_named.tsv - data_type: node - path: extra_node.tsv date: "2019-01-01" + file_format: csv + path: extra_node.csv - data_type: node - path: pheno_nodes.csv date: "2019-01-01" + file_format: csv + path: pheno_nodes.csv diff --git a/spec/test/djornl/test_data/extra_node.csv b/spec/test/djornl/test_data/extra_node.csv new file mode 100644 index 00000000..b9c0529c --- /dev/null +++ b/spec/test/djornl/test_data/extra_node.csv @@ -0,0 +1,3 @@ +# data_type: node +node_id,node_type,transcript,gene_symbol,gene_full_name,gene_model_type,TAIR_Computational_description,TAIR_Curator_summary,TAIR_short_description,GO_description,GO_terms,MapMan_bin,MapMan_name,MapMan_description +AT1G01100,gene,AT1G01100.4,,,protein_coding,60S acidic ribosomal protein family;(source:Araport11),,60S acidic ribosomal protein family,"structural constituent of ribosome, ribonucleoprotein complex binding, protein kinase activator activity","GO:0003735, GO:0043021, GO:0030295",17.1.2.1.46,.Protein biosynthesis.ribosome biogenesis.large ribosomal subunit (LSU).LSU proteome.component RPP1,component RPP1 of LSU proteome component (original description: pep chromosome:TAIR10:1:50090:51187:-1 gene:AT1G01100 transcript:AT1G01100.4 gene_biotype:protein_coding transcript_biotype:protein_coding gene_symbol:RPP1A description:60S acidic ribosomal protein P1-1 [Source:UniProtKB/Swiss-Prot;Acc:Q8LCW9]) diff --git a/spec/test/djornl/test_data/manifest.yaml b/spec/test/djornl/test_data/manifest.yaml index 2d3d63e2..2bddf5f3 100644 --- a/spec/test/djornl/test_data/manifest.yaml +++ b/spec/test/djornl/test_data/manifest.yaml @@ -15,8 +15,9 @@ file_list: date: "2020-12-25" - data_type: node - path: nodes.csv date: "2019-01-01" + file_format: csv + path: nodes.csv - data_type: cluster cluster_prefix: markov_i2 @@ -31,9 +32,11 @@ file_list: path: I6_named.tsv - data_type: node - path: pheno_nodes.csv date: "2019-01-01" + file_format: csv + path: pheno_nodes.csv - data_type: node - path: extra_node.tsv date: "2019-01-01" + file_format: csv + path: extra_node.csv From 3020026c103b7d6ce611e550f595d6ef9fdae6a2 Mon Sep 17 00:00:00 2001 From: Dakota Blair Date: Mon, 9 Aug 2021 13:32:31 -0400 Subject: [PATCH 682/732] Update edge_type.yaml to align with edge_data repo --- spec/datasets/djornl/edge_type.yaml | 48 ++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 15 deletions(-) diff --git a/spec/datasets/djornl/edge_type.yaml b/spec/datasets/djornl/edge_type.yaml index b968c825..6aa648eb 100644 --- a/spec/datasets/djornl/edge_type.yaml +++ b/spec/datasets/djornl/edge_type.yaml @@ -52,24 +52,42 @@ oneOf: title: ATRM TF to Target LitCurated 01082020 TranscriptionFactorToGene description: Contains literature mined and manually curated TF regulatory interactions for A.thaliana from 1701 TFFs from PlantTFDB 2.0 and 4663 TF-associated interactions. These were manually filtered (e.g. FPs, PPI interactions removed). They then added some from other sources. Downloaded from http://atrm.cbi.pku.edu.cn/download.php - - const : "GO" - title : "GO" - description : "GeneA connects to GeneB if the two genes have semantically similar GO terms (with a similarity score > 0). This network is used to evaluate other networks for biological functional content. DOI: [TODO]" + - const : AT-UU-GO-03-AA-01 + title : GO + description: GeneA connects to GeneB if the two genes have semantically similar GO terms (with a similarity score > 0). This network is used to evaluate other networks for biological functional content. - - const : "Knockout" - title : "Knockout" - description : "GeneA connects to GeneB if the phenotypic effect of knocking out GeneA is similar to the phenotypic effect of knocking out GeneB. Similarity is based on Phenotype Ontology semantic similarity. DOI: https://doi.org/10.1186/s13007-015-0053-y" + - const : AT-UU-KS-00-AA-01 + title : Knockout Similarity + description: GeneA connects to GeneB if the phenotypic effect of knocking out GeneA is similar to the phenotypic effect of knocking out GeneB. Similarity is based on Phenotype Ontology semantic similarity. - - const : "Metabolic-AraCyc" - title : "Metabolic-AraCyc" - description : "GeneA connects to GeneB if they are both enzymes and are linked by a common substrate or product. E.g. RXNA (GeneA) → Compound1 → RXNB (GeneB). Here GeneA connects to GeneB due to Compound1. DOI: [TODO]" + - const : AT-UU-PX-01-AA-01 + title : PEN-Diversity + description: GeneA connects to GeneB if the expression vector of GeneA is an important predictor of the expression vector of GeneB in an iRF model, where all other genes’ expression are included as covariates. The iRF model is a feature-selection version of Random Forest. - - const : "PPI-6merged" - title : "PPI-6merged" - description : "GeneA connects to GeneB if their protein products have been shown to bind to interact with each other, typically through experimental evidence. The PPI-6merged network is the union of 6 different A.thaliana PPI networks: AraNet2 LC, AraNet2 HT, AraPPInet2 0.60, BIOGRID 4.3.194 physical, AtPIN, Mentha. These 6 were all relatively high scoring with GOintersect. DOI: [TODO]" + - const : AT-UU-GA-01-AA-01 + title : Coex Gene-Atlas + description: Coexpression network obtained from AtGenie.org. It uses expression array data from multiple tissues to calculate the correlation between genes. - - const : "Regulation-ATRM" - title : "Regulation-ATRM" - description : "GeneA connects to GeneB if GeneA is a Transcription Factor (TF) that is shown to interact with GeneB (which may or may not be a TF). This dataset contains literature mined and manually curated TF regulatory interactions for A.thaliana. Started from 1701 TFs from PlantTFDB 2.0 and retrieved 4663 TF-associated interactions. These were manually filtered (e.g. FPs, PPI interactions removed). They then added some from other sources. Final result is 1431 confirmed TF regulatory interactions, of which 637 are TF-TF. Data origin: http://atrm.cbi.pku.edu.cn/download.php DOI: [TODO]" + - const : AT-UU-PP-00-AA-01 + title : PPI-6merged + description: "GeneA connects to GeneB if their protein products have been shown to bind to interact with each other, typically through experimental evidence. The PPI-6merged network is the union of 6 different A.thaliana PPI networks: AraNet2 LC, AraNet2 HT, AraPPInet2 0.60, BIOGRID 4.3.194 physical, AtPIN, Mentha. These 6 were all relatively high scoring with GOintersect. StringDB scored badly so was not included" + - const : AT-UU-RE-00-AA-01 + title : Regulation-ATRM + description: GeneA connects to GeneB if GeneA is a Transcription Factor (TF) that is shown to interact with GeneB (which may or may not be a TF). This dataset contains literature mined and manually curated TF regulatory interactions for A.thaliana. Started from 1701 TFs from PlantTFDB 2.0 and retrieved 4663 TF-associated interactions. These were manually filtered (e.g. FPs, PPI interactions removed). They then added some from other sources. Final result is 1431 confirmed TF regulatory interactions, of which 637 are TF-TF. + - const : AT-UU-RP-03-AA-01 + title : Regulation-Plantregmap + description: This network contains computationally predicted TF-Target relationships based on motifs, binding sites, ChipSeq data + + - const : AT-UU-DU-07-AA-01 + title : CoEvolution-DUO + description: GeneA connects to GeneB if a SNP in GeneA is correlated with a SNP in GeneB using the DUO metric (cite). SNP data is from the full 1001 Genomes. + + - const : AT-UU-CD-00-AA-01 + title : CoDomain + description: GeneA connects to GeneB if they share one or more common protein domains. Network was obtained from AraNet2. + + - const : AT-UU-RX-00-AA-01 + title : Metabolic-AraCyc + description: GeneA connects to GeneB if they are both enzymatic and are linked by a common substrate or product. E.g. RXNA (GeneA) → Compound1 → RXNB (GeneB). Here GeneA connects to GeneB due to Compound1. From 290903c0b19e4ed5396363cf6ba521ca35dda024 Mon Sep 17 00:00:00 2001 From: Zhenyuan Lu Date: Mon, 16 Aug 2021 15:49:29 -0400 Subject: [PATCH 683/732] add more tests --- scripts/prepare_ontology.py | 39 +++++++++++++++++---------- scripts/test/test_prepare_ontology.py | 15 +++++++++++ 2 files changed, 40 insertions(+), 14 deletions(-) diff --git a/scripts/prepare_ontology.py b/scripts/prepare_ontology.py index 33bb87a5..1b4e9f48 100644 --- a/scripts/prepare_ontology.py +++ b/scripts/prepare_ontology.py @@ -3,26 +3,28 @@ import yaml import json import shutil +import warnings """ python3 scripts/prepare_ontology.py scripts/test/data/data_sources.json fake_ontology """ -__NAME = "__NAME__" -__BIN_PATH = os.path.dirname(os.path.abspath(__file__)) -__COLLECTIONS_PATH = os.path.join(__BIN_PATH, "../spec/collections") -__DATASOURCES_PATH = os.path.join(__BIN_PATH, "../spec/data_sources") -__DATAFILES_PATH = os.path.join(__BIN_PATH, "data") -__COLLECTIONS_DATAFILES = ["terms", "edges", "merges"] +PLACEHOLDER = "__NAME__" +BIN_PATH = os.path.dirname(os.path.abspath(__file__)) +COLLECTIONS_PATH = os.path.join(BIN_PATH, "../spec/collections") +DATASOURCES_PATH = os.path.join(BIN_PATH, "../spec/data_sources") +DATAFILES_PATH = os.path.join(BIN_PATH, "data") +COLLECTIONS_DATAFILES = ["terms", "edges", "merges"] def main(): - input = sys.argv[1] - ns = sys.argv[2] - datasource = parse_input(input, ns) + if len(sys.argv) <= 2: + raise ValueError("data_source and/or namespace are missing") - prepare_collections_file(datasource, __COLLECTIONS_PATH) - prepare_data_sources_file(datasource, __DATASOURCES_PATH) + datasource = parse_input(sys.argv[1], sys.argv[2]) + + prepare_collections_file(datasource, COLLECTIONS_PATH) + prepare_data_sources_file(datasource, DATASOURCES_PATH) return @@ -31,25 +33,32 @@ def parse_input(input, name): for d in json.load(file): if d.get("ns") == name: return d + raise ValueError("no namespace: " + name) def prepare_collections_file(datasource, collections_path): + if not os.path.exists(collections_path): + raise FileNotFoundError(collections_path + " doesn't exists") name, type = parse_namespace(datasource["ns"]) target_dir = os.path.join(collections_path, name.upper()) os.makedirs(target_dir, exist_ok=True) - for f in __COLLECTIONS_DATAFILES: - source_file = os.path.join(__DATAFILES_PATH, f + ".yaml") + for f in COLLECTIONS_DATAFILES: + source_file = os.path.join(DATAFILES_PATH, f + ".yaml") target_file = os.path.join(target_dir, name.upper() + "_" + f + ".yaml") data = "" with open(source_file, "r") as source: - data = yaml.safe_load(source.read().replace(__NAME, name.upper())) + data = yaml.safe_load(source.read().replace(PLACEHOLDER, name.upper())) if not os.path.exists(target_file): with open(target_file, "w") as target: yaml.dump(data, target) + else: + warnings.warn(target_file + " exists") return target_dir def prepare_data_sources_file(datasource, datasources_path): + if not os.path.exists(datasources_path): + raise FileNotFoundError(datasources_path + " doesn't exists") name, type = parse_namespace(datasource["ns"]) target_file = os.path.join(datasources_path, datasource["ns"] + ".yaml") data = { @@ -62,6 +71,8 @@ def prepare_data_sources_file(datasource, datasources_path): if not os.path.exists(target_file): with open(target_file, "w") as target: yaml.dump(data, target) + else: + warnings.warn(target_file + " exists") return target_file diff --git a/scripts/test/test_prepare_ontology.py b/scripts/test/test_prepare_ontology.py index 1cb6e122..a800bfe1 100644 --- a/scripts/test/test_prepare_ontology.py +++ b/scripts/test/test_prepare_ontology.py @@ -25,6 +25,11 @@ def setUpClass(self): def test_parse_input(self): d = parse_input(self.data_sources_file, _TEST_NAMESPACE) self.assertEqual(d["ns"], _TEST_NAMESPACE) + with self.assertRaises(FileNotFoundError): + parse_input("non_exist_file", _TEST_NAMESPACE) + with self.assertRaises(ValueError) as ctx: + parse_input(self.data_sources_file, "non_exist_ns") + self.assertEqual("no namespace: non_exist_ns", str(ctx.exception)) def test_parse_namespace(self): n, t = parse_namespace(_TEST_NAMESPACE) @@ -35,12 +40,22 @@ def test_data_sources_file(self): d = parse_input(self.data_sources_file, _TEST_NAMESPACE) ret = prepare_data_sources_file(d, _TEST_DIR) self.assertTrue(os.path.exists(ret)) + with self.assertWarns(UserWarning): + prepare_data_sources_file(d, _TEST_DIR) clean_up_data(ret) self.assertFalse(os.path.exists(ret)) + with self.assertRaises(FileNotFoundError) as ctx: + prepare_data_sources_file(d, "non_exist_path") + self.assertEqual("non_exist_path doesn't exists", str(ctx.exception)) def test_collections_file(self): d = parse_input(self.data_sources_file, _TEST_NAMESPACE) ret = prepare_collections_file(d, _TEST_DIR) self.assertTrue(os.path.exists(ret)) + with self.assertWarns(UserWarning): + prepare_collections_file(d, _TEST_DIR) clean_up_data(ret) self.assertFalse(os.path.exists(ret)) + with self.assertRaises(FileNotFoundError) as ctx: + prepare_collections_file(d, "non_exist_path") + self.assertEqual("non_exist_path doesn't exists", str(ctx.exception)) From c20bca289d4c352348264fd9c66cf2c3c51e73df Mon Sep 17 00:00:00 2001 From: Zhenyuan Lu Date: Wed, 22 Sep 2021 12:01:08 -0400 Subject: [PATCH 684/732] adding ontology loading procedure documentataion --- importers/ONTOLOGY_LOAD.md | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 importers/ONTOLOGY_LOAD.md diff --git a/importers/ONTOLOGY_LOAD.md b/importers/ONTOLOGY_LOAD.md new file mode 100644 index 00000000..4a5cbc57 --- /dev/null +++ b/importers/ONTOLOGY_LOAD.md @@ -0,0 +1,38 @@ +# Loading ontology procedure + +#### Downloading obo file. +* Ex. PO obo was downloaded from http://purl.obolibrary.org/obo/po.obo + +#### Converting obo to obograph. +* Cloning https://github.com/ontodev/robot +* Running it do conversion, Ex. + +```sh +docker run -v `pwd`:`pwd` --user $(id -u) -w `pwd` robot convert \ +--input ~/tmp/gaz.obo --output ~/tmp/gaz.json +``` + +#### Running scripts/prepare_ontology.py to generate yaml files for ontology +```sh +python3 scripts/prepare_ontology.py scripts/test/data/data_sources.json po_ontology +``` + +#### Preparing PR with generated ontology yaml files and requesting for merge and deployment +* Corresponding collections should be created in arango + +#### Preparing relation_engine_importers +* Cloning https://github.com/kbase/relation_engine_importers +* setup ssh tunnel for arangodb + +#### Loading with obograph_delta_loader.py +```sh +relation_engine/ontologies/obograph/loaders/obograph_delta_loader.py \ +--file ~/package/plant-ontology/po.json --onto-id-prefix PO \ +--arango-url http://127.0.0.1:48000/ --database luj_test --load-namespace po_ontology \ +--node-collection PO_terms --edge-collection PO_edges --merge-edge-collection PO_merges \ +--load-version release_999 --load-registry-collection delta_load_registry \ +--load-timestamp $(( $(date '+%s%N') / 1000000)) --release-timestamp $(( $(date '+%s%N') / 1000000)) \ +--user $USER --pwd-file passfile --graph-id "http://purl.obolibrary.org/obo/po.owl" +``` +* The passfile contains user's arango password. +* The “--graph-id” is required if there are more than one graphs in obograph file. From f90e1c23d80c95102cd545318a9fd9ced268e5c2 Mon Sep 17 00:00:00 2001 From: n1mus Date: Wed, 12 Jan 2022 17:42:21 -0800 Subject: [PATCH 685/732] fulltext search stored query + icu_tokenize analyzer --- README.md | 2 +- .../spec/collections/ncbi/ncbi_taxon.yaml | 1 + relation_engine_server/utils/arango_client.py | 44 +- relation_engine_server/utils/config.py | 1 + relation_engine_server/utils/pull_spec.py | 10 + requirements.txt | 1 + spec/README.md | 1 + spec/analyzer_schema.yaml | 11 + spec/analyzers/README.md | 3 + spec/analyzers/icu_tokenize.json | 11 + spec/collections/gtdb/gtdb_taxon.yaml | 1 + spec/collections/ncbi/ncbi_taxon.yaml | 1 + spec/collections/rdp/rdp_taxon.yaml | 1 + spec/collections/silva/silva_taxon.yaml | 1 + .../generic/fulltext_search.yaml | 86 + spec/test/data/ncbi_taxon.json | 2264 +++++++++++++++++ .../stored_queries/test_fulltext_search.py | 278 ++ spec/views/README.md | 2 +- 18 files changed, 2707 insertions(+), 12 deletions(-) create mode 100644 spec/analyzer_schema.yaml create mode 100644 spec/analyzers/README.md create mode 100644 spec/analyzers/icu_tokenize.json create mode 100644 spec/stored_queries/generic/fulltext_search.yaml create mode 100644 spec/test/data/ncbi_taxon.json create mode 100644 spec/test/stored_queries/test_fulltext_search.py diff --git a/README.md b/README.md index 37a5b67f..32cfa10a 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ This repo holds the code associated with the KBase relation engine, previously h ## Relation Engine Spec ### `spec/` -The `spec/` directory holds the schemas for [stored queries](spec/stored_queries), [collections](spec/collections), [views](spec/views) and [migrations](spec/migrations) for the relation engine graph database service. +The `spec/` directory holds the schemas for [stored queries](spec/stored_queries), [collections](spec/collections), [views](spec/views), [analyzers](spec/analyzers), and [migrations](spec/migrations) for the relation engine graph database service. These specifications are used by the [Relation Engine API](relation_engine_server). diff --git a/relation_engine_server/test/spec_release/sample_spec_release/spec/collections/ncbi/ncbi_taxon.yaml b/relation_engine_server/test/spec_release/sample_spec_release/spec/collections/ncbi/ncbi_taxon.yaml index 39c97168..18810eba 100644 --- a/relation_engine_server/test/spec_release/sample_spec_release/spec/collections/ncbi/ncbi_taxon.yaml +++ b/relation_engine_server/test/spec_release/sample_spec_release/spec/collections/ncbi/ncbi_taxon.yaml @@ -5,6 +5,7 @@ delta: true indexes: - type: fulltext fields: [scientific_name] + minLength: 1 - type: persistent fields: [id, expired, created] - type: persistent diff --git a/relation_engine_server/utils/arango_client.py b/relation_engine_server/utils/arango_client.py index 6bdba09c..918954d1 100644 --- a/relation_engine_server/utils/arango_client.py +++ b/relation_engine_server/utils/arango_client.py @@ -100,27 +100,35 @@ def create_collection(name, config): _create_indexes(name, config) -def _create_indexes(coll_name, config): - """Create indexes for a collection""" - url = _CONF["api_url"] + "/index" - # Fetch existing indexes - auth = (_CONF["db_user"], _CONF["db_pass"]) - resp = requests.get(url, params={"collection": coll_name}, auth=auth) +def _get_indexes(coll_name): + """Fetch existing indexes for a collection""" + resp = requests.get( + url=_CONF["api_url"] + "/index", + params={"collection": coll_name}, + auth=(_CONF["db_user"], _CONF["db_pass"]), + ) if not resp.ok: raise RuntimeError(resp.text) indexes = resp.json()["indexes"] + return indexes + + +def _create_indexes(coll_name, config): + """Create indexes for a collection""" + url = _CONF["api_url"] + "/index" + indexes = _get_indexes(coll_name) for idx_conf in config["indexes"]: - if _index_exists(idx_conf, indexes): - continue idx_type = idx_conf["type"] idx_url = url + "#" + idx_type - idx_conf["type"] = idx_type + if _index_exists(idx_conf, indexes): + # POSTing again would not overwrite anyway + continue print(f"Creating {idx_type} index for collection {coll_name}: {idx_conf}") resp = requests.post( idx_url, params={"collection": coll_name}, data=json.dumps(idx_conf), - auth=auth, + auth=(_CONF["db_user"], _CONF["db_pass"]), ) if not resp.ok: raise RuntimeError(resp.text) @@ -184,6 +192,22 @@ def create_view(name, config): raise ArangoServerError(resp.text) +def get_analyzers(name): + pass + + +def create_analyzer(name, config): + print(f"Creating analyzer {name}") + resp = requests.post( + url=_CONF["api_url"] + "/analyzer", + data=json.dumps(config), + auth=(_CONF["db_user"], _CONF["db_pass"]), + ) + if not resp.ok: + if "duplicate" not in resp.json()["errorMessage"]: + raise ArangoServerError(resp.text) + + class ArangoServerError(Exception): """A request to the ArangoDB server has failed (non-2xx).""" diff --git a/relation_engine_server/utils/config.py b/relation_engine_server/utils/config.py index d81accc6..a548fe39 100644 --- a/relation_engine_server/utils/config.py +++ b/relation_engine_server/utils/config.py @@ -54,5 +54,6 @@ def get_config(): "data_sources": os.path.join(spec_path, "data_sources"), "stored_queries": os.path.join(spec_path, "stored_queries"), "views": os.path.join(spec_path, "views"), + "analyzers": os.path.join(spec_path, "analyzers"), }, } diff --git a/relation_engine_server/utils/pull_spec.py b/relation_engine_server/utils/pull_spec.py index cc96bff7..b2cc194d 100644 --- a/relation_engine_server/utils/pull_spec.py +++ b/relation_engine_server/utils/pull_spec.py @@ -58,6 +58,7 @@ def download_specs( if init_collections: do_init_collections() do_init_views() + do_init_analyzers() return update_name @@ -81,6 +82,15 @@ def do_init_views(): arango_client.create_view(view_name, config) +def do_init_analyzers(): + pattern = os.path.join(_CONF["spec_paths"]["analyzers"], "*.json") + for path in glob.iglob(pattern): + analyzer_name = os.path.basename(os.path.splitext(path)[0]) + with open(path) as fd: + config = json.load(fd) + arango_client.create_analyzer(analyzer_name, config) + + def _fetch_github_release_url(): """Find the latest relation engine spec release using the github api.""" # Download information about the latest release diff --git a/requirements.txt b/requirements.txt index 53c43343..9bd3975d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,6 +3,7 @@ greenlet==0.4.16 gunicorn==19.9.0 gevent==1.3.7 simplejson==3.16.0 +pytest==6.2.5 python-dotenv==0.9.1 requests==2.20.0 jsonpointer==2.0 diff --git a/spec/README.md b/spec/README.md index 27b2c8ee..3266d3e4 100644 --- a/spec/README.md +++ b/spec/README.md @@ -10,6 +10,7 @@ by KBase apps to fetch data from the database. * **[Datasets](spec/datasets)** contain partial and full schemas specific to a certain dataset. * **[Data sources](spec/data_sources)** contain general information about where some of our imported data comes from. * **[Views](spec/views)** are raw ArangoSearch view configuration files +* **[Analyzers](spec/analyzers)** are analyzer configuration files ## Development diff --git a/spec/analyzer_schema.yaml b/spec/analyzer_schema.yaml new file mode 100644 index 00000000..ec724819 --- /dev/null +++ b/spec/analyzer_schema.yaml @@ -0,0 +1,11 @@ +name: analyzer_schema +type: object +required: ['name', 'type'] +properties: + name: + type: string + title: Analyzer name + type: + type: string + title: Analyzer type + examples: ['identity', 'text'] diff --git a/spec/analyzers/README.md b/spec/analyzers/README.md new file mode 100644 index 00000000..e7905e26 --- /dev/null +++ b/spec/analyzers/README.md @@ -0,0 +1,3 @@ +# Analyzers + +These are json files for Arango analyzers. The data in them is used by the [Relation Engine API](https://github.com/kbase/relation_engine) to create views via the `POST /_api/analyzer` endpoint of the ArangoDB HTTP interface. Please [see the ArangoDB docs](https://www.arangodb.com/docs/3.5/http/analyzers.html) for the full set of parameters available. diff --git a/spec/analyzers/icu_tokenize.json b/spec/analyzers/icu_tokenize.json new file mode 100644 index 00000000..3f69a950 --- /dev/null +++ b/spec/analyzers/icu_tokenize.json @@ -0,0 +1,11 @@ +{ + "name": "icu_tokenize", + "type": "text", + "properties": { + "locale": "c.utf-8", + "accent": false, + "case": "lower", + "stemming": false, + "stopwords": [] + } +} \ No newline at end of file diff --git a/spec/collections/gtdb/gtdb_taxon.yaml b/spec/collections/gtdb/gtdb_taxon.yaml index 33fa5fc1..80d5bec6 100644 --- a/spec/collections/gtdb/gtdb_taxon.yaml +++ b/spec/collections/gtdb/gtdb_taxon.yaml @@ -5,6 +5,7 @@ delta: true indexes: - type: fulltext fields: [scientific_name] + minLength: 1 - type: persistent fields: [id, expired, created] - type: persistent diff --git a/spec/collections/ncbi/ncbi_taxon.yaml b/spec/collections/ncbi/ncbi_taxon.yaml index 39c97168..18810eba 100644 --- a/spec/collections/ncbi/ncbi_taxon.yaml +++ b/spec/collections/ncbi/ncbi_taxon.yaml @@ -5,6 +5,7 @@ delta: true indexes: - type: fulltext fields: [scientific_name] + minLength: 1 - type: persistent fields: [id, expired, created] - type: persistent diff --git a/spec/collections/rdp/rdp_taxon.yaml b/spec/collections/rdp/rdp_taxon.yaml index 71b13d38..b5523db2 100644 --- a/spec/collections/rdp/rdp_taxon.yaml +++ b/spec/collections/rdp/rdp_taxon.yaml @@ -5,6 +5,7 @@ delta: true indexes: - type: fulltext fields: [name] + minLength: 1 - type: persistent fields: [id, expired, created] - type: persistent diff --git a/spec/collections/silva/silva_taxon.yaml b/spec/collections/silva/silva_taxon.yaml index 8e01ed41..64915433 100644 --- a/spec/collections/silva/silva_taxon.yaml +++ b/spec/collections/silva/silva_taxon.yaml @@ -5,6 +5,7 @@ delta: true indexes: - type: fulltext fields: [name] + minLength: 1 - type: persistent fields: [id, expired, created] - type: persistent diff --git a/spec/stored_queries/generic/fulltext_search.yaml b/spec/stored_queries/generic/fulltext_search.yaml new file mode 100644 index 00000000..714948a8 --- /dev/null +++ b/spec/stored_queries/generic/fulltext_search.yaml @@ -0,0 +1,86 @@ +# Search a collection with a fulltext index with an attribute name and search text +name: fulltext_search +params: + type: object + required: ["@coll", search_attrkey, search_text] + properties: + "@coll": + type: string + title: Collection name + examples: [ncbi_taxon, gtdb_taxon] + search_attrkey: + type: string + title: Search attribute key + examples: [scientific_name, name] + search_text: + type: string + title: Search text + examples: [escherichia, es] + description: Text to search on the search attribute values + ts: + type: [integer, "null"] + title: Versioning timestamp + default: null + filter_attr_expr: + type: [array, "null"] + title: Filter by document attribute equality + items: + type: object + maxItems: 50 + examples: [ + [{"rank": "species"}, {"rank": "strain"}, {"strain": true}], + [{"rank": "species", "strain": false}] + ] + default: null + description: | + An array of single-level objects. + In each item object, the key-value pairs would restrict the documents to those containing all the attribute key-value pairs. + But if any item object in the array satisfies the document, the document is filtered into the results. + Basically works like a boolean expression where each key-value pair is a boolean value, each item object is a boolean term, and the array is a sum of boolean terms + offset: + type: [integer, "null"] + title: Paging offset + maximum: 100000 + default: 0 + limit: + type: [integer, "null"] + title: Max results to return + default: 20 + maximum: 1000 + select: + type: [string, array, "null"] + items: + type: string + examples: [scientific_name, [scientific_name, id]] + default: null + description: Document attributes to keep in the results +query: | + LET search_text__norm = REGEX_REPLACE(LOWER(TRIM(@search_text)), "\\s+", " ") + LET search_text__first_exact_tok = REGEX_SPLIT(search_text__norm, " ")[0] + LET search_text__icu_toks = TOKENS(@search_text, "_system::icu_tokenize") + LET search_text__wordboundmod_icu_toks = ( + FOR tok IN search_text__icu_toks + RETURN REGEX_REPLACE(tok, ",.*", "") /* commas cannot be escaped */ + ) + LET search_text__fulltext = CONCAT_SEPARATOR(", ", + FOR tok IN search_text__wordboundmod_icu_toks + RETURN CONCAT("prefix:", tok) + ) + LET filter_attr_expr = @filter_attr_expr ? @filter_attr_expr : [] /* null to [] */ + LET search_text__wildcard = CONCAT("%", CONCAT_SEPARATOR("%", search_text__icu_toks), "%") + FOR doc IN FULLTEXT(@@coll, @search_attrkey, search_text__fulltext) + FILTER @ts ? doc.created <= @ts AND doc.expired >= @ts : true + FILTER LENGTH(filter_attr_expr) > 0 ? ( + FOR term IN filter_attr_expr + RETURN MATCHES(doc, term) + ) ANY == true : true + LET attrval__norm = REGEX_REPLACE(LOWER(TRIM(doc.@search_attrkey)), "\\s+", " ") + LET attrval__icu_toks = TOKENS(doc.@search_attrkey, "_system::icu_tokenize") + SORT LIKE(doc.@search_attrkey, search_text__wildcard, true) DESC, /* icu tok ordering */ + /* TODO - icu tok ordering with no insertions? */ + CONTAINS(attrval__icu_toks[0], search_text__icu_toks[0], true) == 0 DESC, /* first icu tok */ + CONTAINS(attrval__norm, search_text__first_exact_tok, true) == 0 DESC, /* first exact tok */ + CONTAINS(attrval__norm, search_text__norm, true) == 0 DESC, /* exact match */ + doc.@search_attrkey /* lexical */ + LIMIT @offset ? @offset : 0, @limit ? @limit : 20 + RETURN @select ? KEEP(doc, @select) : doc diff --git a/spec/test/data/ncbi_taxon.json b/spec/test/data/ncbi_taxon.json new file mode 100644 index 00000000..9a4092f8 --- /dev/null +++ b/spec/test/data/ncbi_taxon.json @@ -0,0 +1,2264 @@ +[ + { + "_key": "863172_2021-02-01", + "_id": "ncbi_taxon/863172_2021-02-01", + "_rev": "_b2kgpUK---", + "id": "863172", + "scientific_name": "Influenza A virus (A/Pavia/2789/2009(H3N2))", + "rank": "no rank", + "strain": false, + "aliases": [], + "ncbi_taxon_id": 863172, + "gencode": 1, + "first_version": "2021-02-01", + "last_version": "2021-02-01", + "created": 1612915015847, + "expired": 9007199254740991, + "release_created": 1612137600000, + "release_expired": 9007199254740991 + }, + { + "_key": "1964177_2018-11-01", + "_id": "ncbi_taxon/1964177_2018-11-01", + "_rev": "_b2nMRlW--_", + "id": "1964177", + "scientific_name": "Inga virgultosa", + "rank": "species", + "strain": false, + "aliases": [ + { + "category": "authority", + "name": "Inga virgultosa (Vahl) Desv., 1826" + } + ], + "ncbi_taxon_id": 1964177, + "gencode": 1, + "first_version": "2018-11-01", + "last_version": "2021-02-01", + "created": 1541030460000, + "expired": 9007199254740991, + "release_created": 1541030400000, + "release_expired": 9007199254740991 + }, + { + "_key": "10247_2021-02-01", + "_id": "ncbi_taxon/10247_2021-02-01", + "_rev": "_b2i7Ehu---", + "id": "10247", + "scientific_name": "Vaccinia virus WR 65-16", + "rank": "no rank", + "strain": true, + "aliases": [ + { + "category": "equivalent name", + "name": "Vaccinia virus (strain WR 65-16)" + } + ], + "ncbi_taxon_id": 10247, + "gencode": 1, + "first_version": "2021-02-01", + "last_version": "2021-02-01", + "created": 1612915015847, + "expired": 9007199254740991, + "release_created": 1612137600000, + "release_expired": 9007199254740991 + }, + { + "_key": "1863603_2018-11-01", + "_id": "ncbi_taxon/1863603_2018-11-01", + "_rev": "_b2m9Oj2--_", + "id": "1863603", + "scientific_name": "Cicadellidae sp. BOLD:ACL9911", + "rank": "species", + "strain": false, + "aliases": [], + "ncbi_taxon_id": 1863603, + "gencode": 1, + "first_version": "2018-11-01", + "last_version": "2021-02-01", + "created": 1541030460000, + "expired": 9007199254740991, + "release_created": 1541030400000, + "release_expired": 9007199254740991 + }, + { + "_key": "2314225_2018-11-01", + "_id": "ncbi_taxon/2314225_2018-11-01", + "_rev": "_b2nig46--_", + "id": "2314225", + "scientific_name": "Rhamphomyia sp. BIOUG24867-G07", + "rank": "species", + "strain": false, + "aliases": [], + "ncbi_taxon_id": 2314225, + "gencode": 1, + "first_version": "2018-11-01", + "last_version": "2021-02-01", + "created": 1541030460000, + "expired": 9007199254740991, + "release_created": 1541030400000, + "release_expired": 9007199254740991 + }, + { + "_key": "279812_2018-11-01", + "_id": "ncbi_taxon/279812_2018-11-01", + "_rev": "_b2jVMUW--H", + "id": "279812", + "scientific_name": "Roseobacter sp. YS-57", + "rank": "species", + "strain": false, + "aliases": [], + "ncbi_taxon_id": 279812, + "gencode": 11, + "first_version": "2018-11-01", + "last_version": "2021-02-01", + "created": 1541030460000, + "expired": 9007199254740991, + "release_created": 1541030400000, + "release_expired": 9007199254740991 + }, + { + "_key": "1627_2021-02-01", + "_id": "ncbi_taxon/1627_2021-02-01", + "_rev": "_b2i6Xii---", + "id": "1627", + "scientific_name": "Lactobacillus sp. 'thermophilus'", + "rank": "species", + "strain": false, + "aliases": [ + { + "category": "authority", + "name": "\"Lactobacillus thermophilus\" Ayers and Johnson" + }, + { + "category": "synonym", + "name": "'Lactobacillus thermophilus'" + } + ], + "ncbi_taxon_id": 1627, + "gencode": 11, + "first_version": "2021-02-01", + "last_version": "2021-02-01", + "created": 1612915015847, + "expired": 9007199254740991, + "release_created": 1612137600000, + "release_expired": 9007199254740991 + }, + { + "_key": "184426_2018-11-01", + "_id": "ncbi_taxon/184426_2018-11-01", + "_rev": "_b2jLY96--_", + "id": "184426", + "scientific_name": "environmental samples", + "rank": "no rank", + "strain": true, + "aliases": [], + "ncbi_taxon_id": 184426, + "gencode": 11, + "first_version": "2018-11-01", + "last_version": "2021-02-01", + "created": 1541030460000, + "expired": 9007199254740991, + "release_created": 1541030400000, + "release_expired": 9007199254740991 + }, + { + "_key": "329529_2018-11-01", + "_id": "ncbi_taxon/329529_2018-11-01", + "_rev": "_b2jZwWS--_", + "id": "329529", + "scientific_name": "environmental samples", + "rank": "no rank", + "strain": true, + "aliases": [], + "ncbi_taxon_id": 329529, + "gencode": 11, + "first_version": "2018-11-01", + "last_version": "2021-02-01", + "created": 1541030460000, + "expired": 9007199254740991, + "release_created": 1541030400000, + "release_expired": 9007199254740991 + }, + { + "_key": "2233698_2020-03-01", + "_id": "ncbi_taxon/2233698_2020-03-01", + "_rev": "_b2ngQMq--D", + "id": "2233698", + "scientific_name": "Porphyrogenes calathana", + "rank": "species", + "strain": false, + "aliases": [ + { + "category": "authority", + "name": "Ocyba calathana (Hewitson, 1868)" + }, + { + "category": "authority", + "name": "Porphyrogenes calathana (Hewitson, 1868)" + }, + { + "category": "synonym", + "name": "Ocyba calathana" + }, + { + "category": "includes", + "name": "Porphyrogenes sp. 1 WL-2018" + } + ], + "ncbi_taxon_id": 2233698, + "gencode": 1, + "first_version": "2020-03-01", + "last_version": "2021-02-01", + "created": 1584487952760, + "expired": 9007199254740991, + "release_created": 1583020800000, + "release_expired": 9007199254740991 + }, + { + "_key": "1231195_2018-11-01", + "_id": "ncbi_taxon/1231195_2018-11-01", + "_rev": "_b2ld-Iq--_", + "id": "1231195", + "scientific_name": "environmental samples", + "rank": "no rank", + "strain": true, + "aliases": [], + "ncbi_taxon_id": 1231195, + "gencode": 1, + "first_version": "2018-11-01", + "last_version": "2021-02-01", + "created": 1541030460000, + "expired": 9007199254740991, + "release_created": 1541030400000, + "release_expired": 9007199254740991 + }, + { + "_key": "1232375_2018-11-01", + "_id": "ncbi_taxon/1232375_2018-11-01", + "_rev": "_b2ld-iW--_", + "id": "1232375", + "scientific_name": "Streptomyces sp. 11719", + "rank": "species", + "strain": false, + "aliases": [], + "ncbi_taxon_id": 1232375, + "gencode": 11, + "first_version": "2018-11-01", + "last_version": "2021-02-01", + "created": 1541030460000, + "expired": 9007199254740991, + "release_created": 1541030400000, + "release_expired": 9007199254740991 + }, + { + "_key": "1359250_2018-11-01", + "_id": "ncbi_taxon/1359250_2018-11-01", + "_rev": "_b2l4Yau--B", + "id": "1359250", + "scientific_name": "Calliandra calycina", + "rank": "species", + "strain": false, + "aliases": [ + { + "category": "authority", + "name": "Calliandra calycina Benth." + } + ], + "ncbi_taxon_id": 1359250, + "gencode": 1, + "first_version": "2018-11-01", + "last_version": "2021-02-01", + "created": 1541030460000, + "expired": 9007199254740991, + "release_created": 1541030400000, + "release_expired": 9007199254740991 + }, + { + "_key": "2452716_2018-12-01", + "_id": "ncbi_taxon/2452716_2018-12-01", + "_rev": "_b2nktie--_", + "id": "2452716", + "scientific_name": "Brachystomellidae sp. BIOUG28261-E12", + "rank": "species", + "strain": false, + "aliases": [], + "ncbi_taxon_id": 2452716, + "gencode": 1, + "first_version": "2018-12-01", + "last_version": "2021-02-01", + "created": 1543622460000, + "expired": 9007199254740991, + "release_created": 1543622400000, + "release_expired": 9007199254740991 + }, + { + "_key": "576250_2018-11-01", + "_id": "ncbi_taxon/576250_2018-11-01", + "_rev": "_b2kAI_a--B", + "id": "576250", + "scientific_name": "environmental samples", + "rank": "no rank", + "strain": true, + "aliases": [], + "ncbi_taxon_id": 576250, + "gencode": 1, + "first_version": "2018-11-01", + "last_version": "2021-02-01", + "created": 1541030460000, + "expired": 9007199254740991, + "release_created": 1541030400000, + "release_expired": 9007199254740991 + }, + { + "_key": "1899338_2018-11-01", + "_id": "ncbi_taxon/1899338_2018-11-01", + "_rev": "_b2nAhaK--_", + "id": "1899338", + "scientific_name": "Hydrocotyle hydrophila", + "rank": "species", + "strain": false, + "aliases": [ + { + "category": "authority", + "name": "Hydrocotyle hydrophila Petrie" + } + ], + "ncbi_taxon_id": 1899338, + "gencode": 1, + "first_version": "2018-11-01", + "last_version": "2021-02-01", + "created": 1541030460000, + "expired": 9007199254740991, + "release_created": 1541030400000, + "release_expired": 9007199254740991 + }, + { + "_key": "1449683_2018-11-01", + "_id": "ncbi_taxon/1449683_2018-11-01", + "_rev": "_b2mMzWe--_", + "id": "1449683", + "scientific_name": "environmental samples", + "rank": "no rank", + "strain": true, + "aliases": [], + "ncbi_taxon_id": 1449683, + "gencode": 11, + "first_version": "2018-11-01", + "last_version": "2021-02-01", + "created": 1541030460000, + "expired": 9007199254740991, + "release_created": 1541030400000, + "release_expired": 9007199254740991 + }, + { + "_key": "562_2021-02-01", + "_id": "ncbi_taxon/562_2021-02-01", + "_rev": "_b2i6X-W--C", + "id": "562", + "scientific_name": "Escherichia coli", + "rank": "species", + "strain": false, + "aliases": [ + { + "category": "type material", + "name": "ATCC 11775" + }, + { + "category": "type material", + "name": "CCUG 24" + }, + { + "category": "type material", + "name": "CCUG 29300" + }, + { + "category": "type material", + "name": "CIP 54.8" + }, + { + "category": "type material", + "name": "DSM 30083" + }, + { + "category": "type material", + "name": "IAM 12119" + }, + { + "category": "type material", + "name": "JCM 1649" + }, + { + "category": "type material", + "name": "LMG 2092" + }, + { + "category": "type material", + "name": "LMG:2092" + }, + { + "category": "type material", + "name": "NBRC 102203" + }, + { + "category": "type material", + "name": "NCCB 54008" + }, + { + "category": "type material", + "name": "NCTC 9001" + }, + { + "category": "type material", + "name": "strain U5/41" + }, + { + "category": "authority", + "name": "\"Bacillus coli\" Migula 1895" + }, + { + "category": "authority", + "name": "\"Bacterium coli commune\" Escherich 1885" + }, + { + "category": "authority", + "name": "\"Bacterium coli\" (Migula 1895) Lehmann and Neumann 1896" + }, + { + "category": "authority", + "name": "Escherichia coli (Migula 1895) Castellani and Chalmers 1919" + }, + { + "category": "synonym", + "name": "Bacillus coli" + }, + { + "category": "synonym", + "name": "Bacterium coli commune" + }, + { + "category": "synonym", + "name": "Bacterium coli" + }, + { + "category": "synonym", + "name": "Enterococcus coli" + }, + { + "category": "includes", + "name": "bacterium 10a" + }, + { + "category": "includes", + "name": "bacterium E3" + }, + { + "category": "includes", + "name": "Escherichia sp. 3_2_53FAA" + }, + { + "category": "includes", + "name": "Escherichia sp. MAR" + }, + { + "category": "common name", + "name": "E. coli" + }, + { + "category": "equivalent name", + "name": "Escherichia/Shigella coli" + } + ], + "ncbi_taxon_id": 562, + "gencode": 11, + "first_version": "2021-02-01", + "last_version": "2021-02-01", + "created": 1612915015847, + "expired": 9007199254740991, + "release_created": 1612137600000, + "release_expired": 9007199254740991 + }, + { + "_key": "134371_2018-11-01", + "_id": "ncbi_taxon/134371_2018-11-01", + "_rev": "_b2jG1wS--D", + "id": "134371", + "scientific_name": "Influenza A virus PX8-XIII(A/USSR/90/77(H1N1)xA/Pintail Duck/Primorie/695/76(H2N3))", + "rank": "no rank", + "strain": true, + "aliases": [], + "ncbi_taxon_id": 134371, + "gencode": 1, + "first_version": "2018-11-01", + "last_version": "2021-02-01", + "created": 1541030460000, + "expired": 9007199254740991, + "release_created": 1541030400000, + "release_expired": 9007199254740991 + }, + { + "_key": "699252_2020-03-01", + "_id": "ncbi_taxon/699252_2020-03-01", + "_rev": "_b2kULKW--B", + "id": "699252", + "scientific_name": "environmental samples", + "rank": "no rank", + "strain": true, + "aliases": [], + "ncbi_taxon_id": 699252, + "gencode": 11, + "first_version": "2020-03-01", + "last_version": "2021-02-01", + "created": 1584487952760, + "expired": 9007199254740991, + "release_created": 1583020800000, + "release_expired": 9007199254740991 + }, + { + "_key": "576326_2018-11-01", + "_id": "ncbi_taxon/576326_2018-11-01", + "_rev": "_b2kAICO--_", + "id": "576326", + "scientific_name": "Sobarocephala atricornis", + "rank": "species", + "strain": false, + "aliases": [ + { + "category": "authority", + "name": "Sobarocephala atricornis Sabrosky, 1974" + } + ], + "ncbi_taxon_id": 576326, + "gencode": 1, + "first_version": "2018-11-01", + "last_version": "2021-02-01", + "created": 1541030460000, + "expired": 9007199254740991, + "release_created": 1541030400000, + "release_expired": 9007199254740991 + }, + { + "_key": "446434_2018-11-01", + "_id": "ncbi_taxon/446434_2018-11-01", + "_rev": "_b2jq3Su--_", + "id": "446434", + "scientific_name": "Cyrnus flavidus", + "rank": "species", + "strain": false, + "aliases": [ + { + "category": "authority", + "name": "Cyrnus flavidus McLachlan, 1864" + } + ], + "ncbi_taxon_id": 446434, + "gencode": 1, + "first_version": "2018-11-01", + "last_version": "2021-02-01", + "created": 1541030460000, + "expired": 9007199254740991, + "release_created": 1541030400000, + "release_expired": 9007199254740991 + }, + { + "_key": "364520_2018-11-01", + "_id": "ncbi_taxon/364520_2018-11-01", + "_rev": "_b2jee32--_", + "id": "364520", + "scientific_name": "environmental samples", + "rank": "no rank", + "strain": true, + "aliases": [], + "ncbi_taxon_id": 364520, + "gencode": 1, + "first_version": "2018-11-01", + "last_version": "2021-02-01", + "created": 1541030460000, + "expired": 9007199254740991, + "release_created": 1541030400000, + "release_expired": 9007199254740991 + }, + { + "_key": "2653369_2020-03-01", + "_id": "ncbi_taxon/2653369_2020-03-01", + "_rev": "_b2nyp1i--_", + "id": "2653369", + "scientific_name": "Typhlodromus ernesti", + "rank": "species", + "strain": false, + "aliases": [ + { + "category": "authority", + "name": "Typhlodromus ernesti Ragusa & Swirski, 1978" + }, + { + "category": "synonym", + "name": "Typhlodromus (Typhlodromus) ernesti" + } + ], + "ncbi_taxon_id": 2653369, + "gencode": 1, + "first_version": "2020-03-01", + "last_version": "2021-02-01", + "created": 1584487952760, + "expired": 9007199254740991, + "release_created": 1583020800000, + "release_expired": 9007199254740991 + }, + { + "_key": "88974_2018-11-01", + "_id": "ncbi_taxon/88974_2018-11-01", + "_rev": "_b2jDItq--F", + "id": "88974", + "scientific_name": "uncultured alpha proteobacterium DCM-FREE-27", + "rank": "species", + "strain": false, + "aliases": [], + "ncbi_taxon_id": 88974, + "gencode": 11, + "first_version": "2018-11-01", + "last_version": "2021-02-01", + "created": 1541030460000, + "expired": 9007199254740991, + "release_created": 1541030400000, + "release_expired": 9007199254740991 + }, + { + "_key": "1794445_2018-11-01", + "_id": "ncbi_taxon/1794445_2018-11-01", + "_rev": "_b2m1vLe--D", + "id": "1794445", + "scientific_name": "Bacillus sp. 987B6_12ACASO", + "rank": "species", + "strain": false, + "aliases": [], + "ncbi_taxon_id": 1794445, + "gencode": 11, + "first_version": "2018-11-01", + "last_version": "2021-02-01", + "created": 1541030460000, + "expired": 9007199254740991, + "release_created": 1541030400000, + "release_expired": 9007199254740991 + }, + { + "_key": "82145_2018-11-01", + "_id": "ncbi_taxon/82145_2018-11-01", + "_rev": "_b2jCIFS--B", + "id": "82145", + "scientific_name": "Balanopaceae", + "rank": "family", + "strain": false, + "aliases": [ + { + "category": "authority", + "name": "Balanopaceae Benth. & Hook.f., 1880" + } + ], + "ncbi_taxon_id": 82145, + "gencode": 1, + "first_version": "2018-11-01", + "last_version": "2021-02-01", + "created": 1541030460000, + "expired": 9007199254740991, + "release_created": 1541030400000, + "release_expired": 9007199254740991 + }, + { + "_key": "2558586_2019-05-01", + "_id": "ncbi_taxon/2558586_2019-05-01", + "_rev": "_b2nrQEe--_", + "id": "2558586", + "scientific_name": "Streptococcus satellite phage Javan236", + "rank": "species", + "strain": false, + "aliases": [], + "ncbi_taxon_id": 2558586, + "gencode": 11, + "first_version": "2019-05-01", + "last_version": "2021-02-01", + "created": 1556668860000, + "expired": 9007199254740991, + "release_created": 1556668800000, + "release_expired": 9007199254740991 + }, + { + "_key": "1194471_2018-11-01", + "_id": "ncbi_taxon/1194471_2018-11-01", + "_rev": "_b2lTKk6--D", + "id": "1194471", + "scientific_name": "Leptothrix sp. FH_36", + "rank": "species", + "strain": false, + "aliases": [], + "ncbi_taxon_id": 1194471, + "gencode": 11, + "first_version": "2018-11-01", + "last_version": "2021-02-01", + "created": 1541030460000, + "expired": 9007199254740991, + "release_created": 1541030400000, + "release_expired": 9007199254740991 + }, + { + "_key": "206622_2018-11-01", + "_id": "ncbi_taxon/206622_2018-11-01", + "_rev": "_b2jNhmm--B", + "id": "206622", + "scientific_name": "Cymopterus beckii", + "rank": "species", + "strain": false, + "aliases": [ + { + "category": "authority", + "name": "Cymopterus beckii S.L.Welsh & Goodrich" + } + ], + "ncbi_taxon_id": 206622, + "gencode": 1, + "first_version": "2018-11-01", + "last_version": "2021-02-01", + "created": 1541030460000, + "expired": 9007199254740991, + "release_created": 1541030400000, + "release_expired": 9007199254740991 + }, + { + "_key": "2689249_2021-02-01", + "_id": "ncbi_taxon/2689249_2021-02-01", + "_rev": "_b2n1hOG--I", + "id": "2689249", + "scientific_name": "Troglohyphantes jamatus", + "rank": "species", + "strain": false, + "aliases": [ + { + "category": "authority", + "name": "Troglohyphantes jamatus Roewer, 1931" + } + ], + "ncbi_taxon_id": 2689249, + "gencode": 1, + "first_version": "2021-02-01", + "last_version": "2021-02-01", + "created": 1612915015847, + "expired": 9007199254740991, + "release_created": 1612137600000, + "release_expired": 9007199254740991 + }, + { + "_key": "844482_2018-11-01", + "_id": "ncbi_taxon/844482_2018-11-01", + "_rev": "_b2kgBA6--B", + "id": "844482", + "scientific_name": "Lepidoptera sp. BOLD:AAF9521", + "rank": "species", + "strain": false, + "aliases": [], + "ncbi_taxon_id": 844482, + "gencode": 1, + "first_version": "2018-11-01", + "last_version": "2021-02-01", + "created": 1541030460000, + "expired": 9007199254740991, + "release_created": 1541030400000, + "release_expired": 9007199254740991 + }, + { + "_key": "406715_2018-11-01", + "_id": "ncbi_taxon/406715_2018-11-01", + "_rev": "_b2jmSNy--_", + "id": "406715", + "scientific_name": "Leptofauchea chiloensis", + "rank": "species", + "strain": false, + "aliases": [], + "ncbi_taxon_id": 406715, + "gencode": 1, + "first_version": "2018-11-01", + "last_version": "2021-02-01", + "created": 1541030460000, + "expired": 9007199254740991, + "release_created": 1541030400000, + "release_expired": 9007199254740991 + }, + { + "_key": "179932_2018-11-01", + "_id": "ncbi_taxon/179932_2018-11-01", + "_rev": "_b2jLY-y--F", + "id": "179932", + "scientific_name": "Avenionia", + "rank": "genus", + "strain": false, + "aliases": [], + "ncbi_taxon_id": 179932, + "gencode": 1, + "first_version": "2018-11-01", + "last_version": "2021-02-01", + "created": 1541030460000, + "expired": 9007199254740991, + "release_created": 1541030400000, + "release_expired": 9007199254740991 + }, + { + "_key": "1378707_2018-11-01", + "_id": "ncbi_taxon/1378707_2018-11-01", + "_rev": "_b2l5hDu--_", + "id": "1378707", + "scientific_name": "Impatiens cf. drepanophora Suksathan 4681", + "rank": "species", + "strain": false, + "aliases": [], + "ncbi_taxon_id": 1378707, + "gencode": 1, + "first_version": "2018-11-01", + "last_version": "2021-02-01", + "created": 1541030460000, + "expired": 9007199254740991, + "release_created": 1541030400000, + "release_expired": 9007199254740991 + }, + { + "_key": "11566_2021-02-01", + "_id": "ncbi_taxon/11566_2021-02-01", + "_rev": "_b2i7S9y---", + "id": "11566", + "scientific_name": "Influenza C virus (C/PIG/Beijing/439/1982)", + "rank": "no rank", + "strain": true, + "aliases": [ + { + "category": "equivalent name", + "name": "Influenza C virus (STRAIN C/PIG/BEIJING/439/82)" + } + ], + "ncbi_taxon_id": 11566, + "gencode": 1, + "first_version": "2021-02-01", + "last_version": "2021-02-01", + "created": 1612915015847, + "expired": 9007199254740991, + "release_created": 1612137600000, + "release_expired": 9007199254740991 + }, + { + "_key": "1388837_2018-11-01", + "_id": "ncbi_taxon/1388837_2018-11-01", + "_rev": "_b2l8ENu--B", + "id": "1388837", + "scientific_name": "Amynthas sp. GD201106-05", + "rank": "species", + "strain": false, + "aliases": [], + "ncbi_taxon_id": 1388837, + "gencode": 1, + "first_version": "2018-11-01", + "last_version": "2021-02-01", + "created": 1541030460000, + "expired": 9007199254740991, + "release_created": 1541030400000, + "release_expired": 9007199254740991 + }, + { + "_key": "707363_2018-11-01", + "_id": "ncbi_taxon/707363_2018-11-01", + "_rev": "_b2kUNni--B", + "id": "707363", + "scientific_name": "Ulva sp. EE2", + "rank": "species", + "strain": false, + "aliases": [], + "ncbi_taxon_id": 707363, + "gencode": 1, + "first_version": "2018-11-01", + "last_version": "2021-02-01", + "created": 1541030460000, + "expired": 9007199254740991, + "release_created": 1541030400000, + "release_expired": 9007199254740991 + }, + { + "_key": "2412393_2018-11-01", + "_id": "ncbi_taxon/2412393_2018-11-01", + "_rev": "_b2nkL0m--D", + "id": "2412393", + "scientific_name": "Psychodidae sp. BIOUG23100-F11", + "rank": "species", + "strain": false, + "aliases": [], + "ncbi_taxon_id": 2412393, + "gencode": 1, + "first_version": "2018-11-01", + "last_version": "2021-02-01", + "created": 1541030460000, + "expired": 9007199254740991, + "release_created": 1541030400000, + "release_expired": 9007199254740991 + }, + { + "_key": "11150_2021-02-01", + "_id": "ncbi_taxon/11150_2021-02-01", + "_rev": "_b2i7PPa---", + "id": "11150", + "scientific_name": "Porcine transmissible gastroenteritis coronavirus strain FS772/70", + "rank": "no rank", + "strain": true, + "aliases": [ + { + "category": "equivalent name", + "name": "Porcine transmissible gastroenteritis coronavirus (STRAIN FS772/70)" + } + ], + "ncbi_taxon_id": 11150, + "gencode": 1, + "first_version": "2021-02-01", + "last_version": "2021-02-01", + "created": 1612915015847, + "expired": 9007199254740991, + "release_created": 1612137600000, + "release_expired": 9007199254740991 + }, + { + "_key": "1523177_2021-02-01", + "_id": "ncbi_taxon/1523177_2021-02-01", + "_rev": "_b2mWP9q---", + "id": "1523177", + "scientific_name": "Influenza A virus (A/Hangzhou/779/2010(H3N2))", + "rank": "no rank", + "strain": false, + "aliases": [], + "ncbi_taxon_id": 1523177, + "gencode": 1, + "first_version": "2021-02-01", + "last_version": "2021-02-01", + "created": 1612915015847, + "expired": 9007199254740991, + "release_created": 1612137600000, + "release_expired": 9007199254740991 + }, + { + "_key": "2601701_2019-09-01", + "_id": "ncbi_taxon/2601701_2019-09-01", + "_rev": "_b2nxHvK--_", + "id": "2601701", + "scientific_name": "Habenaria macrandra", + "rank": "species", + "strain": false, + "aliases": [ + { + "category": "authority", + "name": "Habenaria macrandra Lindl., 1862" + } + ], + "ncbi_taxon_id": 2601701, + "gencode": 1, + "first_version": "2019-09-01", + "last_version": "2021-02-01", + "created": 1567296060000, + "expired": 9007199254740991, + "release_created": 1567296000000, + "release_expired": 9007199254740991 + }, + { + "_key": "2718644_2021-02-01", + "_id": "ncbi_taxon/2718644_2021-02-01", + "_rev": "_b2n6tHK--K", + "id": "2718644", + "scientific_name": "Listeria sp. FSL_L7-1519", + "rank": "species", + "strain": false, + "aliases": [], + "ncbi_taxon_id": 2718644, + "gencode": 11, + "first_version": "2021-02-01", + "last_version": "2021-02-01", + "created": 1612915015847, + "expired": 9007199254740991, + "release_created": 1612137600000, + "release_expired": 9007199254740991 + }, + { + "_key": "880422_2021-02-01", + "_id": "ncbi_taxon/880422_2021-02-01", + "_rev": "_b2kkp5i---", + "id": "880422", + "scientific_name": "Influenza A virus (A/Habana/14720/2010(H3N2))", + "rank": "no rank", + "strain": false, + "aliases": [], + "ncbi_taxon_id": 880422, + "gencode": 1, + "first_version": "2021-02-01", + "last_version": "2021-02-01", + "created": 1612915015847, + "expired": 9007199254740991, + "release_created": 1612137600000, + "release_expired": 9007199254740991 + }, + { + "_key": "1497341_2018-11-01", + "_id": "ncbi_taxon/1497341_2018-11-01", + "_rev": "_b2mUStW--D", + "id": "1497341", + "scientific_name": "Pseudomonas sp. enrichment culture clone PF1", + "rank": "species", + "strain": false, + "aliases": [], + "ncbi_taxon_id": 1497341, + "gencode": 11, + "first_version": "2018-11-01", + "last_version": "2021-02-01", + "created": 1541030460000, + "expired": 9007199254740991, + "release_created": 1541030400000, + "release_expired": 9007199254740991 + }, + { + "_key": "10272_2021-02-01", + "_id": "ncbi_taxon/10272_2021-02-01", + "_rev": "_b2i7Eym---", + "id": "10272", + "scientific_name": "Rabbit fibroma virus (strain Kasza)", + "rank": "no rank", + "strain": true, + "aliases": [ + { + "category": "equivalent name", + "name": "Shope fibroma virus (STRAIN KASZA)" + } + ], + "ncbi_taxon_id": 10272, + "gencode": 1, + "first_version": "2021-02-01", + "last_version": "2021-02-01", + "created": 1612915015847, + "expired": 9007199254740991, + "release_created": 1612137600000, + "release_expired": 9007199254740991 + }, + { + "_key": "4758_2018-11-01", + "_id": "ncbi_taxon/4758_2018-11-01", + "_rev": "_b2i7oIW--_", + "id": "4758", + "scientific_name": "Neocallimastix patriciarum", + "rank": "species", + "strain": false, + "aliases": [], + "ncbi_taxon_id": 4758, + "gencode": 1, + "first_version": "2018-11-01", + "last_version": "2021-02-01", + "created": 1541030460000, + "expired": 9007199254740991, + "release_created": 1541030400000, + "release_expired": 9007199254740991 + }, + { + "_key": "2713500_2021-02-01", + "_id": "ncbi_taxon/2713500_2021-02-01", + "_rev": "_b2n6rv----", + "id": "2713500", + "scientific_name": "Listeria sp. FSL_L7-0091", + "rank": "species", + "strain": false, + "aliases": [], + "ncbi_taxon_id": 2713500, + "gencode": 11, + "first_version": "2021-02-01", + "last_version": "2021-02-01", + "created": 1612915015847, + "expired": 9007199254740991, + "release_created": 1612137600000, + "release_expired": 9007199254740991 + }, + { + "_key": "1132808_2018-11-01", + "_id": "ncbi_taxon/1132808_2018-11-01", + "_rev": "_b2lFoQ2--_", + "id": "1132808", + "scientific_name": "Alocasia scalprum", + "rank": "species", + "strain": false, + "aliases": [ + { + "category": "authority", + "name": "Alocasia scalprum A.Hay" + } + ], + "ncbi_taxon_id": 1132808, + "gencode": 1, + "first_version": "2018-11-01", + "last_version": "2021-02-01", + "created": 1541030460000, + "expired": 9007199254740991, + "release_created": 1541030400000, + "release_expired": 9007199254740991 + }, + { + "_key": "1231191_2018-11-01", + "_id": "ncbi_taxon/1231191_2018-11-01", + "_rev": "_b2ld-Ii--_", + "id": "1231191", + "scientific_name": "environmental samples", + "rank": "no rank", + "strain": true, + "aliases": [], + "ncbi_taxon_id": 1231191, + "gencode": 1, + "first_version": "2018-11-01", + "last_version": "2021-02-01", + "created": 1541030460000, + "expired": 9007199254740991, + "release_created": 1541030400000, + "release_expired": 9007199254740991 + }, + { + "_key": "578129_2021-02-01", + "_id": "ncbi_taxon/578129_2021-02-01", + "_rev": "_b2kAKTW---", + "id": "578129", + "scientific_name": "Heteroliodon occipitalis", + "rank": "species", + "strain": false, + "aliases": [ + { + "category": "type material", + "name": "BMNH 1946.1.12.28" + }, + { + "category": "authority", + "name": "Pseudoxyrhopus occipitalis Boulenger, 1896" + }, + { + "category": "synonym", + "name": "Pseudoxyrhopus occipitalis" + } + ], + "ncbi_taxon_id": 578129, + "gencode": 1, + "first_version": "2021-02-01", + "last_version": "2021-02-01", + "created": 1612915015847, + "expired": 9007199254740991, + "release_created": 1612137600000, + "release_expired": 9007199254740991 + }, + { + "_key": "2727498_2021-02-01", + "_id": "ncbi_taxon/2727498_2021-02-01", + "_rev": "_b2n6up6--W", + "id": "2727498", + "scientific_name": "Caulastrocecis interstratella", + "rank": "species", + "strain": false, + "aliases": [ + { + "category": "authority", + "name": "Caulastrocecis interstratella (Christoph, 1872)" + } + ], + "ncbi_taxon_id": 2727498, + "gencode": 1, + "first_version": "2021-02-01", + "last_version": "2021-02-01", + "created": 1612915015847, + "expired": 9007199254740991, + "release_created": 1612137600000, + "release_expired": 9007199254740991 + }, + { + "_key": "2651177_2020-03-01", + "_id": "ncbi_taxon/2651177_2020-03-01", + "_rev": "_b2nypS6--B", + "id": "2651177", + "scientific_name": "environmental samples", + "rank": "no rank", + "strain": true, + "aliases": [], + "ncbi_taxon_id": 2651177, + "gencode": 1, + "first_version": "2020-03-01", + "last_version": "2021-02-01", + "created": 1584487952760, + "expired": 9007199254740991, + "release_created": 1583020800000, + "release_expired": 9007199254740991 + }, + { + "_key": "219650_2018-11-01", + "_id": "ncbi_taxon/219650_2018-11-01", + "_rev": "_b2jPl6W--_", + "id": "219650", + "scientific_name": "environmental samples", + "rank": "no rank", + "strain": true, + "aliases": [], + "ncbi_taxon_id": 219650, + "gencode": 11, + "first_version": "2018-11-01", + "last_version": "2021-02-01", + "created": 1541030460000, + "expired": 9007199254740991, + "release_created": 1541030400000, + "release_expired": 9007199254740991 + }, + { + "_key": "10324_2021-02-01", + "_id": "ncbi_taxon/10324_2021-02-01", + "_rev": "_b2i7Fqu---", + "id": "10324", + "scientific_name": "Bovine herpesvirus type 1.1 (strain P8-2)", + "rank": "no rank", + "strain": true, + "aliases": [ + { + "category": "equivalent name", + "name": "Bovine herpesvirus type 1 (strain P8-2)" + } + ], + "ncbi_taxon_id": 10324, + "gencode": 1, + "first_version": "2021-02-01", + "last_version": "2021-02-01", + "created": 1612915015847, + "expired": 9007199254740991, + "release_created": 1612137600000, + "release_expired": 9007199254740991 + }, + { + "_key": "1744050_2018-11-01", + "_id": "ncbi_taxon/1744050_2018-11-01", + "_rev": "_b2mxbKa--_", + "id": "1744050", + "scientific_name": "Spilogona sp. BOLD:ACC9483", + "rank": "species", + "strain": false, + "aliases": [], + "ncbi_taxon_id": 1744050, + "gencode": 1, + "first_version": "2018-11-01", + "last_version": "2021-02-01", + "created": 1541030460000, + "expired": 9007199254740991, + "release_created": 1541030400000, + "release_expired": 9007199254740991 + }, + { + "_key": "11065_2021-02-01", + "_id": "ncbi_taxon/11065_2021-02-01", + "_rev": "_b2i7N0m---", + "id": "11065", + "scientific_name": "Dengue virus 2 Thailand/NGS-C/1944", + "rank": "no rank", + "strain": true, + "aliases": [ + { + "category": "equivalent name", + "name": "Dengue virus NGC" + }, + { + "category": "equivalent name", + "name": "Dengue virus prototype strain New Guinea C (NGC)" + }, + { + "category": "equivalent name", + "name": "Dengue virus type 2 (NGC-prototype)" + }, + { + "category": "equivalent name", + "name": "Dengue virus type 2 (strain New Guinea C)" + }, + { + "category": "equivalent name", + "name": "Dengue virus type 2 Thailand/NGS-C/1944" + } + ], + "ncbi_taxon_id": 11065, + "gencode": 1, + "first_version": "2021-02-01", + "last_version": "2021-02-01", + "created": 1612915015847, + "expired": 9007199254740991, + "release_created": 1612137600000, + "release_expired": 9007199254740991 + }, + { + "_key": "379362_2018-11-01", + "_id": "ncbi_taxon/379362_2018-11-01", + "_rev": "_b2jgWoK--_", + "id": "379362", + "scientific_name": "environmental samples", + "rank": "no rank", + "strain": true, + "aliases": [], + "ncbi_taxon_id": 379362, + "gencode": 11, + "first_version": "2018-11-01", + "last_version": "2021-02-01", + "created": 1541030460000, + "expired": 9007199254740991, + "release_created": 1541030400000, + "release_expired": 9007199254740991 + }, + { + "_key": "1356674_2018-11-01", + "_id": "ncbi_taxon/1356674_2018-11-01", + "_rev": "_b2l4Xc6--D", + "id": "1356674", + "scientific_name": "methanogenic prokaryote enrichment culture B19_144", + "rank": "species", + "strain": false, + "aliases": [], + "ncbi_taxon_id": 1356674, + "gencode": 1, + "first_version": "2018-11-01", + "last_version": "2021-02-01", + "created": 1541030460000, + "expired": 9007199254740991, + "release_created": 1541030400000, + "release_expired": 9007199254740991 + }, + { + "_key": "35683_2018-11-01", + "_id": "ncbi_taxon/35683_2018-11-01", + "_rev": "_b2i9AW6--B", + "id": "35683", + "scientific_name": "Pseudopedinella", + "rank": "genus", + "strain": false, + "aliases": [], + "ncbi_taxon_id": 35683, + "gencode": 1, + "first_version": "2018-11-01", + "last_version": "2021-02-01", + "created": 1541030460000, + "expired": 9007199254740991, + "release_created": 1541030400000, + "release_expired": 9007199254740991 + }, + { + "_key": "819947_2018-11-01", + "_id": "ncbi_taxon/819947_2018-11-01", + "_rev": "_b2kfzke--B", + "id": "819947", + "scientific_name": "Diptera sp. BOLD:AAG2430", + "rank": "species", + "strain": false, + "aliases": [], + "ncbi_taxon_id": 819947, + "gencode": 1, + "first_version": "2018-11-01", + "last_version": "2021-02-01", + "created": 1541030460000, + "expired": 9007199254740991, + "release_created": 1541030400000, + "release_expired": 9007199254740991 + }, + { + "_key": "2038696_2018-11-01", + "_id": "ncbi_taxon/2038696_2018-11-01", + "_rev": "_b2nVysS--_", + "id": "2038696", + "scientific_name": "Erica grandiflora", + "rank": "species", + "strain": false, + "aliases": [ + { + "category": "authority", + "name": "Erica grandiflora L.f., 1781" + } + ], + "ncbi_taxon_id": 2038696, + "gencode": 1, + "first_version": "2018-11-01", + "last_version": "2021-02-01", + "created": 1541030460000, + "expired": 9007199254740991, + "release_created": 1541030400000, + "release_expired": 9007199254740991 + }, + { + "_key": "1220632_2018-11-01", + "_id": "ncbi_taxon/1220632_2018-11-01", + "_rev": "_b2lZJbu--B", + "id": "1220632", + "scientific_name": "Citrobacter sp. 003.13", + "rank": "species", + "strain": false, + "aliases": [], + "ncbi_taxon_id": 1220632, + "gencode": 11, + "first_version": "2018-11-01", + "last_version": "2021-02-01", + "created": 1541030460000, + "expired": 9007199254740991, + "release_created": 1541030400000, + "release_expired": 9007199254740991 + }, + { + "_key": "310254_2018-11-01", + "_id": "ncbi_taxon/310254_2018-11-01", + "_rev": "_b2jXGIO--_", + "id": "310254", + "scientific_name": "Elymus gmelinii", + "rank": "species", + "strain": false, + "aliases": [ + { + "category": "authority", + "name": "Elymus gmelinii (Ledeb.) Tzvelev, 1968" + } + ], + "ncbi_taxon_id": 310254, + "gencode": 1, + "first_version": "2018-11-01", + "last_version": "2021-02-01", + "created": 1541030460000, + "expired": 9007199254740991, + "release_created": 1541030400000, + "release_expired": 9007199254740991 + }, + { + "_key": "79696_2021-02-01", + "_id": "ncbi_taxon/79696_2021-02-01", + "_rev": "_b2jBeOO---", + "id": "79696", + "scientific_name": "Influenza B virus (B/Ann Arbor/1/1966 [cold-adapted and wild- type])", + "rank": "no rank", + "strain": true, + "aliases": [ + { + "category": "equivalent name", + "name": "Influenza B virus (strain B/Ann Arbor/1/66 [cold-adapted and wild- type])" + } + ], + "ncbi_taxon_id": 79696, + "gencode": 1, + "first_version": "2021-02-01", + "last_version": "2021-02-01", + "created": 1612915015847, + "expired": 9007199254740991, + "release_created": 1612137600000, + "release_expired": 9007199254740991 + }, + { + "_key": "2333206_2018-11-01", + "_id": "ncbi_taxon/2333206_2018-11-01", + "_rev": "_b2nirGu--B", + "id": "2333206", + "scientific_name": "Phronia sp. JSDIP316-10", + "rank": "species", + "strain": false, + "aliases": [], + "ncbi_taxon_id": 2333206, + "gencode": 1, + "first_version": "2018-11-01", + "last_version": "2021-02-01", + "created": 1541030460000, + "expired": 9007199254740991, + "release_created": 1541030400000, + "release_expired": 9007199254740991 + }, + { + "_key": "2310952_2018-11-01", + "_id": "ncbi_taxon/2310952_2018-11-01", + "_rev": "_b2niMzm--D", + "id": "2310952", + "scientific_name": "Gymnopternus sp. BIOUG25014-A04", + "rank": "species", + "strain": false, + "aliases": [], + "ncbi_taxon_id": 2310952, + "gencode": 1, + "first_version": "2018-11-01", + "last_version": "2021-02-01", + "created": 1541030460000, + "expired": 9007199254740991, + "release_created": 1541030400000, + "release_expired": 9007199254740991 + }, + { + "_key": "1474010_2018-11-01", + "_id": "ncbi_taxon/1474010_2018-11-01", + "_rev": "_b2mR25S--B", + "id": "1474010", + "scientific_name": "Sciaridae sp. BOLD:ACA7925", + "rank": "species", + "strain": false, + "aliases": [], + "ncbi_taxon_id": 1474010, + "gencode": 1, + "first_version": "2018-11-01", + "last_version": "2021-02-01", + "created": 1541030460000, + "expired": 9007199254740991, + "release_created": 1541030400000, + "release_expired": 9007199254740991 + }, + { + "_key": "1230346_2018-11-01", + "_id": "ncbi_taxon/1230346_2018-11-01", + "_rev": "_b2lc90m--B", + "id": "1230346", + "scientific_name": "environmental samples", + "rank": "no rank", + "strain": true, + "aliases": [], + "ncbi_taxon_id": 1230346, + "gencode": 11, + "first_version": "2018-11-01", + "last_version": "2021-02-01", + "created": 1541030460000, + "expired": 9007199254740991, + "release_created": 1541030400000, + "release_expired": 9007199254740991 + }, + { + "_key": "1674892_2018-11-01", + "_id": "ncbi_taxon/1674892_2018-11-01", + "_rev": "_b2mra9O--D", + "id": "1674892", + "scientific_name": "Anaerolineales bacterium Chloro_03", + "rank": "species", + "strain": false, + "aliases": [], + "ncbi_taxon_id": 1674892, + "gencode": 11, + "first_version": "2018-11-01", + "last_version": "2021-02-01", + "created": 1541030460000, + "expired": 9007199254740991, + "release_created": 1541030400000, + "release_expired": 9007199254740991 + }, + { + "_key": "699250_2019-06-01", + "_id": "ncbi_taxon/699250_2019-06-01", + "_rev": "_b2kULKW--_", + "id": "699250", + "scientific_name": "environmental samples", + "rank": "no rank", + "strain": true, + "aliases": [], + "ncbi_taxon_id": 699250, + "gencode": 11, + "first_version": "2019-06-01", + "last_version": "2021-02-01", + "created": 1559347260000, + "expired": 9007199254740991, + "release_created": 1559347200000, + "release_expired": 9007199254740991 + }, + { + "_key": "563569_2018-11-01", + "_id": "ncbi_taxon/563569_2018-11-01", + "_rev": "_b2j98-u--_", + "id": "563569", + "scientific_name": "Streptomyces sp. 13665B", + "rank": "species", + "strain": false, + "aliases": [], + "ncbi_taxon_id": 563569, + "gencode": 11, + "first_version": "2018-11-01", + "last_version": "2021-02-01", + "created": 1541030460000, + "expired": 9007199254740991, + "release_created": 1541030400000, + "release_expired": 9007199254740991 + }, + { + "_key": "1125656_2018-11-01", + "_id": "ncbi_taxon/1125656_2018-11-01", + "_rev": "_b2lFlwy--B", + "id": "1125656", + "scientific_name": "Tetrathiobacter sp. LC417", + "rank": "species", + "strain": false, + "aliases": [], + "ncbi_taxon_id": 1125656, + "gencode": 11, + "first_version": "2018-11-01", + "last_version": "2021-02-01", + "created": 1541030460000, + "expired": 9007199254740991, + "release_created": 1541030400000, + "release_expired": 9007199254740991 + }, + { + "_key": "157696_2018-11-01", + "_id": "ncbi_taxon/157696_2018-11-01", + "_rev": "_b2jI89G--B", + "id": "157696", + "scientific_name": "Alicyclobacillus sp. DSM 6481", + "rank": "species", + "strain": false, + "aliases": [], + "ncbi_taxon_id": 157696, + "gencode": 11, + "first_version": "2018-11-01", + "last_version": "2021-02-01", + "created": 1541030460000, + "expired": 9007199254740991, + "release_created": 1541030400000, + "release_expired": 9007199254740991 + }, + { + "_key": "190758_2020-03-01", + "_id": "ncbi_taxon/190758_2020-03-01", + "_rev": "_b2jMhti--D", + "id": "190758", + "scientific_name": "Leucaena salvadorensis", + "rank": "species", + "strain": false, + "aliases": [ + { + "category": "common name", + "name": "aserillo" + }, + { + "category": "common name", + "name": "sepia vaina" + }, + { + "category": "authority", + "name": "Leucaena salvadorensis Standl. ex Britton & Rose" + } + ], + "ncbi_taxon_id": 190758, + "gencode": 1, + "first_version": "2020-03-01", + "last_version": "2021-02-01", + "created": 1584487952760, + "expired": 9007199254740991, + "release_created": 1583020800000, + "release_expired": 9007199254740991 + }, + { + "_key": "2051570_2018-11-01", + "_id": "ncbi_taxon/2051570_2018-11-01", + "_rev": "_b2nZ-GS--_", + "id": "2051570", + "scientific_name": "Influenza B virus (B/Brisbane/FSS700/2017)", + "rank": "no rank", + "strain": true, + "aliases": [], + "ncbi_taxon_id": 2051570, + "gencode": 1, + "first_version": "2018-11-01", + "last_version": "2021-02-01", + "created": 1541030460000, + "expired": 9007199254740991, + "release_created": 1541030400000, + "release_expired": 9007199254740991 + }, + { + "_key": "1424688_2018-11-01", + "_id": "ncbi_taxon/1424688_2018-11-01", + "_rev": "_b2mGzQi--B", + "id": "1424688", + "scientific_name": "Angraecum cf. moandense CM-2013", + "rank": "species", + "strain": false, + "aliases": [], + "ncbi_taxon_id": 1424688, + "gencode": 1, + "first_version": "2018-11-01", + "last_version": "2021-02-01", + "created": 1541030460000, + "expired": 9007199254740991, + "release_created": 1541030400000, + "release_expired": 9007199254740991 + }, + { + "_key": "2718636_2021-02-01", + "_id": "ncbi_taxon/2718636_2021-02-01", + "_rev": "_b2n6tHG--M", + "id": "2718636", + "scientific_name": "Listeria sp. FSL_L7-0091", + "rank": "species", + "strain": false, + "aliases": [], + "ncbi_taxon_id": 2718636, + "gencode": 11, + "first_version": "2021-02-01", + "last_version": "2021-02-01", + "created": 1612915015847, + "expired": 9007199254740991, + "release_created": 1612137600000, + "release_expired": 9007199254740991 + }, + { + "_key": "1652495_2018-11-01", + "_id": "ncbi_taxon/1652495_2018-11-01", + "_rev": "_b2mo7-q--B", + "id": "1652495", + "scientific_name": "Corynebacterium crudilactis", + "rank": "species", + "strain": false, + "aliases": [ + { + "category": "type material", + "name": "CCUG 69192" + }, + { + "category": "type material", + "name": "DSM 100882" + }, + { + "category": "type material", + "name": "LMG 29813" + }, + { + "category": "type material", + "name": "LMG:29813" + }, + { + "category": "type material", + "name": "strain JZ16" + }, + { + "category": "authority", + "name": "Corynebacterium crudilactis Zimmermann et al. 2016" + }, + { + "category": "includes", + "name": "Corynebacterium sp. DSM 100882" + }, + { + "category": "includes", + "name": "Corynebacterium sp. JZ16" + } + ], + "ncbi_taxon_id": 1652495, + "gencode": 11, + "first_version": "2018-11-01", + "last_version": "2021-02-01", + "created": 1541030460000, + "expired": 9007199254740991, + "release_created": 1541030400000, + "release_expired": 9007199254740991 + }, + { + "_key": "576247_2018-11-01", + "_id": "ncbi_taxon/576247_2018-11-01", + "_rev": "_b2kAI_W--D", + "id": "576247", + "scientific_name": "environmental samples", + "rank": "no rank", + "strain": true, + "aliases": [], + "ncbi_taxon_id": 576247, + "gencode": 1, + "first_version": "2018-11-01", + "last_version": "2021-02-01", + "created": 1541030460000, + "expired": 9007199254740991, + "release_created": 1541030400000, + "release_expired": 9007199254740991 + }, + { + "_key": "2030720_2018-11-01", + "_id": "ncbi_taxon/2030720_2018-11-01", + "_rev": "_b2nVw-a--_", + "id": "2030720", + "scientific_name": "Deyeuxia ovata var. ovata", + "rank": "varietas", + "strain": false, + "aliases": [], + "ncbi_taxon_id": 2030720, + "gencode": 1, + "first_version": "2018-11-01", + "last_version": "2021-02-01", + "created": 1541030460000, + "expired": 9007199254740991, + "release_created": 1541030400000, + "release_expired": 9007199254740991 + }, + { + "_key": "1973755_2021-02-01", + "_id": "ncbi_taxon/1973755_2021-02-01", + "_rev": "_b2nMEP----", + "id": "1973755", + "scientific_name": "Influenza A virus (A/Connecticut/07/2017(H1N1))", + "rank": "no rank", + "strain": false, + "aliases": [], + "ncbi_taxon_id": 1973755, + "gencode": 1, + "first_version": "2021-02-01", + "last_version": "2021-02-01", + "created": 1612915015847, + "expired": 9007199254740991, + "release_created": 1612137600000, + "release_expired": 9007199254740991 + }, + { + "_key": "106193_2021-02-01", + "_id": "ncbi_taxon/106193_2021-02-01", + "_rev": "_b2jDxa----", + "id": "106193", + "scientific_name": "Temnothorax luteus", + "rank": "species", + "strain": false, + "aliases": [ + { + "category": "synonym", + "name": "Leptothorax luteus" + }, + { + "category": "authority", + "name": "Temnothorax luteus (Forel, 1874)" + } + ], + "ncbi_taxon_id": 106193, + "gencode": 1, + "first_version": "2021-02-01", + "last_version": "2021-02-01", + "created": 1612915015847, + "expired": 9007199254740991, + "release_created": 1612137600000, + "release_expired": 9007199254740991 + }, + { + "_key": "1231197_2018-11-01", + "_id": "ncbi_taxon/1231197_2018-11-01", + "_rev": "_b2ld-Iu--_", + "id": "1231197", + "scientific_name": "environmental samples", + "rank": "no rank", + "strain": true, + "aliases": [], + "ncbi_taxon_id": 1231197, + "gencode": 1, + "first_version": "2018-11-01", + "last_version": "2021-02-01", + "created": 1541030460000, + "expired": 9007199254740991, + "release_created": 1541030400000, + "release_expired": 9007199254740991 + }, + { + "_key": "11064_2021-02-01", + "_id": "ncbi_taxon/11064_2021-02-01", + "_rev": "_b2i7Nze---", + "id": "11064", + "scientific_name": "Dengue virus 2 Jamaica/1409/1983", + "rank": "no rank", + "strain": true, + "aliases": [ + { + "category": "equivalent name", + "name": "Dengue virus type 2 Jamaica/1409/1983" + }, + { + "category": "equivalent name", + "name": "Dengue virus type 2 (strain Jamaica)" + } + ], + "ncbi_taxon_id": 11064, + "gencode": 1, + "first_version": "2021-02-01", + "last_version": "2021-02-01", + "created": 1612915015847, + "expired": 9007199254740991, + "release_created": 1612137600000, + "release_expired": 9007199254740991 + }, + { + "_key": "133823_2018-11-01", + "_id": "ncbi_taxon/133823_2018-11-01", + "_rev": "_b2jG1pS--H", + "id": "133823", + "scientific_name": "environmental samples", + "rank": "no rank", + "strain": true, + "aliases": [], + "ncbi_taxon_id": 133823, + "gencode": 11, + "first_version": "2018-11-01", + "last_version": "2021-02-01", + "created": 1541030460000, + "expired": 9007199254740991, + "release_created": 1541030400000, + "release_expired": 9007199254740991 + }, + { + "_key": "2418748_2018-11-01", + "_id": "ncbi_taxon/2418748_2018-11-01", + "_rev": "_b2nkTeS--_", + "id": "2418748", + "scientific_name": "Tanypodinae sp. BIOUG27705-C01", + "rank": "species", + "strain": false, + "aliases": [], + "ncbi_taxon_id": 2418748, + "gencode": 1, + "first_version": "2018-11-01", + "last_version": "2021-02-01", + "created": 1541030460000, + "expired": 9007199254740991, + "release_created": 1541030400000, + "release_expired": 9007199254740991 + }, + { + "_key": "72806_2018-11-01", + "_id": "ncbi_taxon/72806_2018-11-01", + "_rev": "_b2jBN3a--_", + "id": "72806", + "scientific_name": "Williamsia maris", + "rank": "species", + "strain": false, + "aliases": [ + { + "category": "type material", + "name": "DSM 44693" + }, + { + "category": "type material", + "name": "JCM 12070" + }, + { + "category": "type material", + "name": "NCIMB 13945" + }, + { + "category": "type material", + "name": "strain SJS0289/JS1" + }, + { + "category": "includes", + "name": "Gordona sp. SJS0289-JS1" + }, + { + "category": "includes", + "name": "Gordonia sp. SJS0289-JS1" + }, + { + "category": "authority", + "name": "Williamsia maris Stach et al. 2004" + } + ], + "ncbi_taxon_id": 72806, + "gencode": 11, + "first_version": "2018-11-01", + "last_version": "2021-02-01", + "created": 1541030460000, + "expired": 9007199254740991, + "release_created": 1541030400000, + "release_expired": 9007199254740991 + }, + { + "_key": "41524_2018-11-01", + "_id": "ncbi_taxon/41524_2018-11-01", + "_rev": "_b2j-aOG--_", + "id": "41524", + "scientific_name": "Salmonella enterica subsp. houtenae serovar 16:z4,z32:--", + "rank": "no rank", + "strain": true, + "aliases": [ + { + "category": "synonym", + "name": "Salmonella enterica IV 16:z4,z32:--" + }, + { + "category": "synonym", + "name": "Salmonella enterica serovar IV 16:z4,z32:--" + } + ], + "ncbi_taxon_id": 41524, + "gencode": 11, + "first_version": "2018-11-01", + "last_version": "2021-02-01", + "created": 1541030460000, + "expired": 9007199254740991, + "release_created": 1541030400000, + "release_expired": 9007199254740991 + }, + { + "_key": "641932_2018-11-01", + "_id": "ncbi_taxon/641932_2018-11-01", + "_rev": "_b2kHS-a--_", + "id": "641932", + "scientific_name": "Streptomyces sp. ERI MA-01", + "rank": "species", + "strain": false, + "aliases": [], + "ncbi_taxon_id": 641932, + "gencode": 11, + "first_version": "2018-11-01", + "last_version": "2021-02-01", + "created": 1541030460000, + "expired": 9007199254740991, + "release_created": 1541030400000, + "release_expired": 9007199254740991 + }, + { + "_key": "2569359_2020-03-01", + "_id": "ncbi_taxon/2569359_2020-03-01", + "_rev": "_b2nsRK6--_", + "id": "2569359", + "scientific_name": "Clibanarius sp. AY-2019", + "rank": "species", + "strain": false, + "aliases": [], + "ncbi_taxon_id": 2569359, + "gencode": 1, + "first_version": "2020-03-01", + "last_version": "2021-02-01", + "created": 1584487952760, + "expired": 9007199254740991, + "release_created": 1583020800000, + "release_expired": 9007199254740991 + }, + { + "_key": "857244_2018-11-01", + "_id": "ncbi_taxon/857244_2018-11-01", + "_rev": "_b2kgXfy--_", + "id": "857244", + "scientific_name": "Pseudomonas sp. V219", + "rank": "species", + "strain": false, + "aliases": [], + "ncbi_taxon_id": 857244, + "gencode": 11, + "first_version": "2018-11-01", + "last_version": "2021-02-01", + "created": 1541030460000, + "expired": 9007199254740991, + "release_created": 1541030400000, + "release_expired": 9007199254740991 + }, + { + "_key": "691007_2021-02-01", + "_id": "ncbi_taxon/691007_2021-02-01", + "_rev": "_b2kP8ue---", + "id": "691007", + "scientific_name": "Influenza A virus (A/chicken/West Java/Smi-M6/2008(H5N1))", + "rank": "no rank", + "strain": false, + "aliases": [ + { + "category": "equivalent name", + "name": "Influenza virus (A/chicken/West Java/Smi-M6/2008(H5N1))" + } + ], + "ncbi_taxon_id": 691007, + "gencode": 1, + "first_version": "2021-02-01", + "last_version": "2021-02-01", + "created": 1612915015847, + "expired": 9007199254740991, + "release_created": 1612137600000, + "release_expired": 9007199254740991 + }, + { + "_key": "2713502_2021-02-01", + "_id": "ncbi_taxon/2713502_2021-02-01", + "_rev": "_b2n6rv---A", + "id": "2713502", + "scientific_name": "Listeria sp. FSL_L7-1519", + "rank": "species", + "strain": false, + "aliases": [], + "ncbi_taxon_id": 2713502, + "gencode": 11, + "first_version": "2021-02-01", + "last_version": "2021-02-01", + "created": 1612915015847, + "expired": 9007199254740991, + "release_created": 1612137600000, + "release_expired": 9007199254740991 + }, + { + "_key": "1148469_2018-11-01", + "_id": "ncbi_taxon/1148469_2018-11-01", + "_rev": "_b2lKR8q--B", + "id": "1148469", + "scientific_name": "Bradyrhizobium sp. SCNU 9", + "rank": "species", + "strain": false, + "aliases": [], + "ncbi_taxon_id": 1148469, + "gencode": 11, + "first_version": "2018-11-01", + "last_version": "2021-02-01", + "created": 1541030460000, + "expired": 9007199254740991, + "release_created": 1541030400000, + "release_expired": 9007199254740991 + }, + { + "_key": "1935312_2018-11-01", + "_id": "ncbi_taxon/1935312_2018-11-01", + "_rev": "_b2nIRUW--D", + "id": "1935312", + "scientific_name": "Corticiaceae sp.", + "rank": "species", + "strain": false, + "aliases": [], + "ncbi_taxon_id": 1935312, + "gencode": 1, + "first_version": "2018-11-01", + "last_version": "2021-02-01", + "created": 1541030460000, + "expired": 9007199254740991, + "release_created": 1541030400000, + "release_expired": 9007199254740991 + }, + { + "_key": "1635398_2018-11-01", + "_id": "ncbi_taxon/1635398_2018-11-01", + "_rev": "_b2mnjo2--C", + "id": "1635398", + "scientific_name": "Janthinobacterium sp. NA55", + "rank": "species", + "strain": false, + "aliases": [], + "ncbi_taxon_id": 1635398, + "gencode": 11, + "first_version": "2018-11-01", + "last_version": "2021-02-01", + "created": 1541030460000, + "expired": 9007199254740991, + "release_created": 1541030400000, + "release_expired": 9007199254740991 + }, + { + "_key": "292089_2018-11-01", + "_id": "ncbi_taxon/292089_2018-11-01", + "_rev": "_b2jWDpa--_", + "id": "292089", + "scientific_name": "Muraltia horrida", + "rank": "species", + "strain": false, + "aliases": [ + { + "category": "authority", + "name": "Muraltia horrida Diels" + } + ], + "ncbi_taxon_id": 292089, + "gencode": 1, + "first_version": "2018-11-01", + "last_version": "2021-02-01", + "created": 1541030460000, + "expired": 9007199254740991, + "release_created": 1541030400000, + "release_expired": 9007199254740991 + }, + { + "_key": "261389_2018-11-01", + "_id": "ncbi_taxon/261389_2018-11-01", + "_rev": "_b2jSxcW--_", + "id": "261389", + "scientific_name": "environmental samples", + "rank": "no rank", + "strain": true, + "aliases": [], + "ncbi_taxon_id": 261389, + "gencode": 11, + "first_version": "2018-11-01", + "last_version": "2021-02-01", + "created": 1541030460000, + "expired": 9007199254740991, + "release_created": 1541030400000, + "release_expired": 9007199254740991 + }, + { + "_key": "1636559_2019-06-01", + "_id": "ncbi_taxon/1636559_2019-06-01", + "_rev": "_b2mnkIK--B", + "id": "1636559", + "scientific_name": "Lactococcus phage 936 group phage Phi13.16", + "rank": "species", + "strain": false, + "aliases": [], + "ncbi_taxon_id": 1636559, + "gencode": 11, + "first_version": "2019-06-01", + "last_version": "2021-02-01", + "created": 1559347260000, + "expired": 9007199254740991, + "release_created": 1559347200000, + "release_expired": 9007199254740991 + }, + { + "_key": "1899424_2018-11-01", + "_id": "ncbi_taxon/1899424_2018-11-01", + "_rev": "_b2nAhcK--_", + "id": "1899424", + "scientific_name": "'Prunus dulcis' phytoplasma", + "rank": "species", + "strain": false, + "aliases": [], + "ncbi_taxon_id": 1899424, + "gencode": 11, + "first_version": "2018-11-01", + "last_version": "2021-02-01", + "created": 1541030460000, + "expired": 9007199254740991, + "release_created": 1541030400000, + "release_expired": 9007199254740991 + }, + { + "_key": "1604534_2018-11-01", + "_id": "ncbi_taxon/1604534_2018-11-01", + "_rev": "_Zc0PA0q--B", + "id": "1604534", + "scientific_name": "Pseudogobio cf. esocinus CBM:ZF:12684", + "rank": "species", + "strain": false, + "aliases": [], + "ncbi_taxon_id": 1604534, + "gencode": 1, + "first_version": "2018-11-01", + "last_version": "2019-06-01", + "created": 1541030460000, + "expired": 1561939259999, + "release_created": 1541030400000, + "release_expired": 1561939199999 + }, + { + "_key": "1329276_2018-11-01", + "_id": "ncbi_taxon/1329276_2018-11-01", + "_rev": "_ZcrE_9O--D", + "id": "1329276", + "scientific_name": "Klebsormidium sp. BIOTA 14615.5a", + "rank": "species", + "strain": false, + "aliases": [], + "ncbi_taxon_id": 1329276, + "gencode": 1, + "first_version": "2018-11-01", + "last_version": "2019-01-01", + "created": 1541030460000, + "expired": 1548979259999, + "release_created": 1541030400000, + "release_expired": 1548979199999 + }, + { + "_key": "508775_2018-11-01", + "_id": "ncbi_taxon/508775_2018-11-01", + "_rev": "_b2n7Xqu--B", + "id": "508775", + "scientific_name": "Norovirus GII.9", + "rank": "no rank", + "strain": true, + "aliases": [ + { + "category": "synonym", + "name": "Norovirus genogroup GII.9" + } + ], + "ncbi_taxon_id": 508775, + "gencode": 1, + "first_version": "2018-11-01", + "last_version": "2020-03-01", + "created": 1541030460000, + "expired": 1612915015846, + "release_created": 1541030400000, + "release_expired": 1612137599999 + } +] diff --git a/spec/test/stored_queries/test_fulltext_search.py b/spec/test/stored_queries/test_fulltext_search.py new file mode 100644 index 00000000..aa336f1e --- /dev/null +++ b/spec/test/stored_queries/test_fulltext_search.py @@ -0,0 +1,278 @@ +""" +Tests for the generic fulltext search + +These tests run within the re_api docker image, and require access to the ArangoDB, auth, and workspace images. +""" +import json +import time +import unittest +import requests +import os + +from spec.test.helpers import ( + get_config, + check_spec_test_env, + create_test_docs, +) + +_CONF = get_config() +_NOW = int(time.time() * 1000) +LIMIT = 20 # default + +TEST_DATA_DIR = os.path.normpath( + os.path.join(os.path.dirname(os.path.abspath(__file__)), "../data/") +) + +ncbi_taxon_fp = os.path.join(TEST_DATA_DIR, "ncbi_taxon.json") +with open(ncbi_taxon_fp) as fh: + ncbi_taxa = json.load(fh) + +# scinames_test_all are all the test scinames +scinames_test_all = [ + # --- Token preceded by punctuation --- + "Lactobacillus sp. 'thermophilus'", + "Rabbit fibroma virus (strain Kasza)", + "'Prunus dulcis' phytoplasma", + # --- Tokens joined by punctuation --- + "Lactococcus phage 936 group phage Phi13.16", + "Pseudogobio cf. esocinus CBM:ZF:12684", + "Klebsormidium sp. BIOTA 14615.5a", + # --- Misc gnarly --- + "Influenza C virus (C/PIG/Beijing/439/1982)", + "Bovine herpesvirus type 1.1 (strain P8-2)", + "Porcine transmissible gastroenteritis coronavirus strain FS772/70", + "Salmonella enterica subsp. houtenae serovar 16:z4,z32:--", + "Influenza A virus PX8-XIII(A/USSR/90/77(H1N1)xA/Pintail Duck/Primorie/695/76(H2N3))", + "Influenza B virus (B/Ann Arbor/1/1966 [cold-adapted and wild- type])", + # --- Prefix 1 --- + "Vaccinia virus WR 65-16", + "Dengue virus 2 Jamaica/1409/1983", + "Dengue virus 2 Thailand/NGS-C/1944", + # --- Dups (techinically only applicable to live data) --- + "environmental samples", + "Listeria sp. FSL_L7-0091", + "Listeria sp. FSL_L7-1519", + # --- Misc --- + "Norovirus GII.9", + "Corticiaceae sp.", + "Escherichia coli", +] +# scinames_test_latest are the test scinames that are compatible with a current timestamp +scinames_test_latest = [ + "Lactobacillus sp. 'thermophilus'", + "Rabbit fibroma virus (strain Kasza)", + "'Prunus dulcis' phytoplasma", + "Lactococcus phage 936 group phage Phi13.16", + "Influenza C virus (C/PIG/Beijing/439/1982)", + "Bovine herpesvirus type 1.1 (strain P8-2)", + "Porcine transmissible gastroenteritis coronavirus strain FS772/70", + "Salmonella enterica subsp. houtenae serovar 16:z4,z32:--", + "Influenza A virus PX8-XIII(A/USSR/90/77(H1N1)xA/Pintail Duck/Primorie/695/76(H2N3))", + "Influenza B virus (B/Ann Arbor/1/1966 [cold-adapted and wild- type])", + "Vaccinia virus WR 65-16", + "Dengue virus 2 Jamaica/1409/1983", + "Dengue virus 2 Thailand/NGS-C/1944", + "environmental samples", + "Listeria sp. FSL_L7-0091", + "Listeria sp. FSL_L7-1519", + "Corticiaceae sp.", + "Escherichia coli", +] + + +class Test(unittest.TestCase): + @classmethod + def setUpClass(cls): + check_spec_test_env() + create_test_docs("ncbi_taxon", ncbi_taxa) + + def test_ncbi_taxon_scinames(self): + """Happy path""" + for sciname in scinames_test_all: + _fulltext_query( + self, + coll="ncbi_taxon", + search_attrkey="scientific_name", + search_text=sciname, + ts=_NOW if sciname in scinames_test_latest else None, + filter_attr_expr=[ + {"rank": "species"}, + {"rank": "strain"}, + {"strain": True}, + ], + offset=None, + limit=LIMIT, + select="scientific_name", + # --- + expect_error=False, + expect_hit=True, + ) + + def test_null_bind_params(self): + """Leave off parameters""" + for sciname in scinames_test_all: + _fulltext_query( + self, + coll="ncbi_taxon", + search_attrkey="scientific_name", + search_text=sciname, + ts=None, + filter_attr_expr=None, + offset=None, + limit=None, + select=None, + # --- + expect_error=False, + expect_hit=True, + ) + + def test_fully_specified_bind_params(self): + """Specify all parameters""" + for sciname in scinames_test_all: + _fulltext_query( + self, + coll="ncbi_taxon", + search_attrkey="scientific_name", + search_text=sciname, + ts=_NOW if sciname in scinames_test_latest else None, + filter_attr_expr=[ + {"rank": "species"}, + {"rank": "strain"}, + {"strain": True}, + ], + offset=0, + limit=LIMIT, + select=["id", "scientific_name"], + # --- + expect_error=False, + expect_hit=True, + ) + + def test_stored_query_validation_fail(self): + # TODO stored query validation does not seem to work + return + with self.assertRaises(RuntimeError): + _fulltext_query( + self, + coll=[], + search_attrkey=42, + search_text={"hi": 1}, + ts=None, + filter_attr_expr=None, + offset=None, + limit=None, + select=None, + ) + + def test_aql_error(self): + for sciname in scinames_test_all: + _fulltext_query( + self, + coll="ncbi_taxon", + search_attrkey="fake_attrkey", + search_text=sciname, + ts=None, + filter_attr_expr=None, + offset=None, + limit=None, + select=None, + # --- + expect_error=True, + ) + + def test_no_hit(self): + for sciname in scinames_test_all: + _fulltext_query( + self, + coll="ncbi_taxon", + search_attrkey="scientific_name", + search_text=sciname[::-1], + ts=None, + filter_attr_expr=None, + offset=None, + limit=None, + select=None, + # --- + expect_error=False, + expect_hit=False, + expected_hits=[], + ) + + +# --- Test helpers --- + + +def _fulltext_query( + self, + coll, + search_attrkey, + search_text, + ts, + filter_attr_expr, + offset, + limit, + select, + expect_error=False, + expect_hit=True, + expected_hits=None, +): + """ + Run query against ArangoDB server + """ + data = { + "@coll": coll, + "search_attrkey": search_attrkey, + "search_text": search_text, + "ts": ts, + "filter_attr_expr": filter_attr_expr, + "offset": offset, + "limit": limit, + "select": select, + } + resp = requests.post( + _CONF["re_api_url"] + "/api/v1/query_results", + params={"stored_query": "fulltext_search"}, + data=json.dumps(data), + ) + + if expect_error: + self.assertIn("error", resp.json()) + + else: + docs = resp.json()["results"] + hits = [doc[search_attrkey] for doc in docs] + if expect_hit: + self.assertIn(search_text, hits, f"`{search_text}` not in `{hits}`") + self.assertFalse( + len(hits) == limit and len(set(hits) == 1) + ) # check not just overflowing with dups + else: + self.assertNotIn(search_text, hits) + + if expected_hits is not None: + self.assertEqual(expected_hits, hits) + + # Filter out null values + data = {k: v for k, v in data.items() if v is not None} + resp = requests.post( + _CONF["re_api_url"] + "/api/v1/query_results", + params={"stored_query": "fulltext_search"}, + data=json.dumps(data), + ) + + if expect_error: + self.assertIn("error", resp.json()) + + else: + docs = resp.json()["results"] + hits = [doc[search_attrkey] for doc in docs] + if expect_hit: + self.assertIn(search_text, hits, f"`{search_text}` not in `{hits}`") + self.assertFalse( + len(hits) == limit and len(set(hits) == 1) + ) # check not just overflowing with dups + else: + self.assertNotIn(search_text, hits) + + if expected_hits is not None: + self.assertEqual(expected_hits, hits) diff --git a/spec/views/README.md b/spec/views/README.md index 471c7821..34b767ac 100644 --- a/spec/views/README.md +++ b/spec/views/README.md @@ -1,3 +1,3 @@ # Views -These are json files for Arango views, which are required to perform searches on vertices or edges in Arango. The data in them is used by the [Relation Engine API](https://github.com/kbase/relation_engine_api) to create views via the `POST /_api/view#arangosearch` endpoint of the ArangoDB HTTP interface. Please [see the ArangoDB docs](https://www.arangodb.com/docs/3.5/http/views-arangosearch.html) for the full set of parameters available. \ No newline at end of file +These are json files for Arango views, which are required to perform searches on vertices or edges in Arango. The data in them is used by the [Relation Engine API](https://github.com/kbase/relation_engine) to create views via the `POST /_api/view#arangosearch` endpoint of the ArangoDB HTTP interface. Please [see the ArangoDB docs](https://www.arangodb.com/docs/3.5/http/views-arangosearch.html) for the full set of parameters available. From c4ae325cab252ed03742953068bfecaf45a2318b Mon Sep 17 00:00:00 2001 From: bio-boris Date: Fri, 14 Jan 2022 12:09:26 -0600 Subject: [PATCH 686/732] Create build_prodrc_pr.sh --- .github/workflows/scripts/build_prodrc_pr.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 .github/workflows/scripts/build_prodrc_pr.sh diff --git a/.github/workflows/scripts/build_prodrc_pr.sh b/.github/workflows/scripts/build_prodrc_pr.sh new file mode 100644 index 00000000..d888fc9d --- /dev/null +++ b/.github/workflows/scripts/build_prodrc_pr.sh @@ -0,0 +1,16 @@ +#! /usr/bin/env bash + +export MY_ORG=$(echo "${GITHUB_REPOSITORY}" | awk -F / '{print $1}') +export MY_APP=$(echo "${GITHUB_REPOSITORY}" | awk -F / '{print $2}') +export DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ") +export BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ") +export COMMIT=$(echo "$SHA" | cut -c -7) + +docker login -u "$DOCKER_ACTOR" -p "$DOCKER_TOKEN" ghcr.io +docker build --build-arg BUILD_DATE="$DATE" \ + --build-arg COMMIT="$COMMIT" \ + --build-arg BRANCH="$GITHUB_HEAD_REF" \ + --build-arg PULL_REQUEST="$PR" \ + --label us.kbase.vcs-pull-req="$PR" \ + -t ghcr.io/"$MY_ORG"/"$MY_APP":"pr-""$PR" . +docker push ghcr.io/"$MY_ORG"/"$MY_APP":"pr-""$PR" From c6ccc27150f5875472a3d0f906a141d5417a6c66 Mon Sep 17 00:00:00 2001 From: bio-boris Date: Fri, 14 Jan 2022 12:09:45 -0600 Subject: [PATCH 687/732] Create build_test_pr.sh --- .github/workflows/scripts/build_test_pr.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .github/workflows/scripts/build_test_pr.sh diff --git a/.github/workflows/scripts/build_test_pr.sh b/.github/workflows/scripts/build_test_pr.sh new file mode 100644 index 00000000..4fee0681 --- /dev/null +++ b/.github/workflows/scripts/build_test_pr.sh @@ -0,0 +1,17 @@ +#! /usr/bin/env bash + +export MY_ORG=$(echo "${GITHUB_REPOSITORY}" | awk -F / '{print $1}') +export MY_APP=$(echo $(echo "${GITHUB_REPOSITORY}" | awk -F / '{print $2}')"-develop") +export DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ") +export BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ") +export COMMIT=$(echo "$SHA" | cut -c -7) + +echo $DOCKER_TOKEN | docker login ghcr.io -u $DOCKER_ACTOR --password-stdin +docker build --build-arg BUILD_DATE="$DATE" \ + --build-arg COMMIT="$COMMIT" \ + --build-arg BRANCH="$GITHUB_HEAD_REF" \ + --build-arg PULL_REQUEST="$PR" \ + --label us.kbase.vcs-pull-req="$PR" \ + -t ghcr.io/"$MY_ORG"/"$MY_APP":"pr-""$PR" . +docker push ghcr.io/"$MY_ORG"/"$MY_APP":"pr-""$PR" + From 10218b5db9838f8079ce24bec90d1d944fb95e99 Mon Sep 17 00:00:00 2001 From: bio-boris Date: Fri, 14 Jan 2022 12:10:22 -0600 Subject: [PATCH 688/732] Create deploy_tag.sh --- .github/workflows/deploy_tag.sh | 34 +++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .github/workflows/deploy_tag.sh diff --git a/.github/workflows/deploy_tag.sh b/.github/workflows/deploy_tag.sh new file mode 100644 index 00000000..5fb928ab --- /dev/null +++ b/.github/workflows/deploy_tag.sh @@ -0,0 +1,34 @@ +#! /usr/bin/env bash + +# Usage: ./deploy_tag.sh -e TARGET -o ORG -r REPO -s DEV_PROD -t IMAGE_TAG +# +# Example 1: ./deploy_tag.sh -o "kbase" -r "narrative-traefiker" -s "dev" -t "pr-9001" -e "ci" +# Example 2: ./deploy_tag.sh -o "kbase" -r "narrative" -s "prod" -t "latest" -e "next" +# +# Where: +# -o ORG is the organization (`kbase`, `kbaseapps`, etc.) +# -r REPO is the repository (e.g. `narrative`) +# -s DEV_PROD determines whether to pull the development {APPNAME}-develop or production {APPNAME} image. +# -t IMAGE_TAG is the *current* Docker image tag, typically `pr-#` or `latest` +# -e TARGET is one of: `appdsshev`, `ci`, or `next` +# +# Be sure to set $TOKEN first! +# See: https://docs.github.com/en/packages/getting-started-with-github-container-registry/migrating-to-github-container-registry-for-docker-images#authenticating-with-the-container-registry + + +while getopts e:o:r:s:t: option + do + case "${option}" + in + e) TARGET=${OPTARG};; + o) ORG=${OPTARG};; + r) REPO=${OPTARG};; + s) DEV_PROD=${OPTARG};; + t) IMAGE_TAG=${OPTARG};; + esac +done + +curl -H "Authorization: token $TOKEN" \ + -H 'Accept: application/vnd.github.everest-preview+json' \ + "https://api.github.com/repos/$ORG/$REPO/dispatches" \ + -d '{"event_type":"Tag '"$DEV_PROD"' '"$IMAGE_TAG"' for '"$TARGET"'", "client_payload": {"image_tag": "'"$IMAGE_TAG"'","target": "'"$TARGET"'","dev_prod": "'"$DEV_PROD"'"}}' From 00be0907de63264647c5cc263018773972d1db7c Mon Sep 17 00:00:00 2001 From: bio-boris Date: Fri, 14 Jan 2022 12:10:45 -0600 Subject: [PATCH 689/732] Create tag_environments.sh --- .github/workflows/tag_environments.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/workflows/tag_environments.sh diff --git a/.github/workflows/tag_environments.sh b/.github/workflows/tag_environments.sh new file mode 100644 index 00000000..b39732a0 --- /dev/null +++ b/.github/workflows/tag_environments.sh @@ -0,0 +1,22 @@ + +#! /usr/bin/env bash +# Add vars for PR & environments to yaml, as called from external script + +export MY_ORG=$(echo "${GITHUB_REPOSITORY}" | awk -F / '{print $1}') +export MY_APP=$(echo "${GITHUB_REPOSITORY}" | awk -F / '{print $2}') +export DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ") +export BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ") +export COMMIT=$(echo "$SHA" | cut -c -7) + +if [ $DEV_PROD = "dev" ] || [ $DEV_PROD = "develop" ] +then + IMAGE=$MY_APP"-develop" +else + IMAGE=$MY_APP +fi + +echo "Dev or Prod:" $DEV_PROD +docker login -u "$DOCKER_ACTOR" -p "$DOCKER_TOKEN" ghcr.io +docker pull ghcr.io/"$MY_ORG"/"$IMAGE":"$IMAGE_TAG" +docker tag ghcr.io/"$MY_ORG"/"$IMAGE":"$IMAGE_TAG" ghcr.io/"$MY_ORG"/"$IMAGE":"$TARGET" +docker push ghcr.io/"$MY_ORG"/"$IMAGE":"$TARGET" From bf5e5dd95346e9fea137b314ec1f1f7a73e843e2 Mon Sep 17 00:00:00 2001 From: bio-boris Date: Fri, 14 Jan 2022 12:11:24 -0600 Subject: [PATCH 690/732] Rename .github/workflows/deploy_tag.sh to .github/workflows/scripts/deploy_tag.sh --- .github/workflows/{ => scripts}/deploy_tag.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{ => scripts}/deploy_tag.sh (100%) diff --git a/.github/workflows/deploy_tag.sh b/.github/workflows/scripts/deploy_tag.sh similarity index 100% rename from .github/workflows/deploy_tag.sh rename to .github/workflows/scripts/deploy_tag.sh From 6f42c9041569bca392aeeace07651c45317c9115 Mon Sep 17 00:00:00 2001 From: bio-boris Date: Fri, 14 Jan 2022 12:11:56 -0600 Subject: [PATCH 691/732] Rename .github/workflows/tag_environments.sh to .github/workflows/scripts/tag_environments.sh --- .github/workflows/{ => scripts}/tag_environments.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{ => scripts}/tag_environments.sh (100%) diff --git a/.github/workflows/tag_environments.sh b/.github/workflows/scripts/tag_environments.sh similarity index 100% rename from .github/workflows/tag_environments.sh rename to .github/workflows/scripts/tag_environments.sh From 2821c62602ad3c80d792a90cce6a107adb8972e0 Mon Sep 17 00:00:00 2001 From: bio-boris Date: Fri, 14 Jan 2022 12:14:00 -0600 Subject: [PATCH 692/732] Create tag_prod_latest.sh --- .github/workflows/scripts/tag_prod_latest.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 .github/workflows/scripts/tag_prod_latest.sh diff --git a/.github/workflows/scripts/tag_prod_latest.sh b/.github/workflows/scripts/tag_prod_latest.sh new file mode 100644 index 00000000..1390fd16 --- /dev/null +++ b/.github/workflows/scripts/tag_prod_latest.sh @@ -0,0 +1,12 @@ +#! /usr/bin/env bash + +export MY_ORG=$(echo "${GITHUB_REPOSITORY}" | awk -F / '{print $1}') +export MY_APP=$(echo "${GITHUB_REPOSITORY}" | awk -F / '{print $2}') +export DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ") +export BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ") +export COMMIT=$(echo "$SHA" | cut -c -7) + +docker login -u "$DOCKER_ACTOR" -p "$DOCKER_TOKEN" ghcr.io +docker pull ghcr.io/"$MY_ORG"/"$MY_APP":"pr-""$PR" +docker tag ghcr.io/"$MY_ORG"/"$MY_APP":"pr-""$PR" ghcr.io/"$MY_ORG"/"$MY_APP":"latest" +docker push ghcr.io/"$MY_ORG"/"$MY_APP":"latest" From 143a71e5b163241c6ed5d88e69bb7a2bd6099e40 Mon Sep 17 00:00:00 2001 From: bio-boris Date: Fri, 14 Jan 2022 12:14:21 -0600 Subject: [PATCH 693/732] Create tag_test_latest.sh --- .github/workflows/scripts/tag_test_latest.sh | 26 ++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .github/workflows/scripts/tag_test_latest.sh diff --git a/.github/workflows/scripts/tag_test_latest.sh b/.github/workflows/scripts/tag_test_latest.sh new file mode 100644 index 00000000..d8cac465 --- /dev/null +++ b/.github/workflows/scripts/tag_test_latest.sh @@ -0,0 +1,26 @@ +--- +name: Tag Latest Test Image +'on': + pull_request: + branches: + - develop + types: + - closed +jobs: + docker_tag: + runs-on: ubuntu-latest + steps: + - name: Check out GitHub Repo + if: github.event_name == 'pull_request' && github.event.action == 'closed' && + github.event.pull_request.merged == true + with: + ref: "${{ github.event.pull_request.head.sha }}" + uses: actions/checkout@v2 + - name: Build and Push to Packages + if: github.event.pull_request.draft == false + env: + PR: "${{ github.event.pull_request.number }}" + SHA: "${{ github.event.pull_request.head.sha }}" + DOCKER_ACTOR: "${{ secrets.GHCR_USERNAME }}" + DOCKER_TOKEN: "${{ secrets.GHCR_TOKEN }}" + run: "./.github/workflows/scripts/tag_test_latest.sh\n" From a97d83f2dbac2277d2037a15b2a14c5a0df0e4c9 Mon Sep 17 00:00:00 2001 From: bio-boris Date: Fri, 14 Jan 2022 12:14:40 -0600 Subject: [PATCH 694/732] Create tag_test_latest --- .github/workflows/scripts/tag_test_latest | 26 +++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .github/workflows/scripts/tag_test_latest diff --git a/.github/workflows/scripts/tag_test_latest b/.github/workflows/scripts/tag_test_latest new file mode 100644 index 00000000..d8cac465 --- /dev/null +++ b/.github/workflows/scripts/tag_test_latest @@ -0,0 +1,26 @@ +--- +name: Tag Latest Test Image +'on': + pull_request: + branches: + - develop + types: + - closed +jobs: + docker_tag: + runs-on: ubuntu-latest + steps: + - name: Check out GitHub Repo + if: github.event_name == 'pull_request' && github.event.action == 'closed' && + github.event.pull_request.merged == true + with: + ref: "${{ github.event.pull_request.head.sha }}" + uses: actions/checkout@v2 + - name: Build and Push to Packages + if: github.event.pull_request.draft == false + env: + PR: "${{ github.event.pull_request.number }}" + SHA: "${{ github.event.pull_request.head.sha }}" + DOCKER_ACTOR: "${{ secrets.GHCR_USERNAME }}" + DOCKER_TOKEN: "${{ secrets.GHCR_TOKEN }}" + run: "./.github/workflows/scripts/tag_test_latest.sh\n" From 28031c1b6c38c5b12ac64bc6146052edc8f7d34f Mon Sep 17 00:00:00 2001 From: bio-boris Date: Fri, 14 Jan 2022 12:15:28 -0600 Subject: [PATCH 695/732] Delete tag_test_latest --- .github/workflows/scripts/tag_test_latest | 26 ----------------------- 1 file changed, 26 deletions(-) delete mode 100644 .github/workflows/scripts/tag_test_latest diff --git a/.github/workflows/scripts/tag_test_latest b/.github/workflows/scripts/tag_test_latest deleted file mode 100644 index d8cac465..00000000 --- a/.github/workflows/scripts/tag_test_latest +++ /dev/null @@ -1,26 +0,0 @@ ---- -name: Tag Latest Test Image -'on': - pull_request: - branches: - - develop - types: - - closed -jobs: - docker_tag: - runs-on: ubuntu-latest - steps: - - name: Check out GitHub Repo - if: github.event_name == 'pull_request' && github.event.action == 'closed' && - github.event.pull_request.merged == true - with: - ref: "${{ github.event.pull_request.head.sha }}" - uses: actions/checkout@v2 - - name: Build and Push to Packages - if: github.event.pull_request.draft == false - env: - PR: "${{ github.event.pull_request.number }}" - SHA: "${{ github.event.pull_request.head.sha }}" - DOCKER_ACTOR: "${{ secrets.GHCR_USERNAME }}" - DOCKER_TOKEN: "${{ secrets.GHCR_TOKEN }}" - run: "./.github/workflows/scripts/tag_test_latest.sh\n" From 8096961e952c4a4f792c4980e8a48b2ae4b83e8d Mon Sep 17 00:00:00 2001 From: bio-boris Date: Fri, 14 Jan 2022 13:13:13 -0600 Subject: [PATCH 696/732] Create build_prodrc_pr.yaml --- .github/workflows/build_prodrc_pr.yaml | 28 ++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .github/workflows/build_prodrc_pr.yaml diff --git a/.github/workflows/build_prodrc_pr.yaml b/.github/workflows/build_prodrc_pr.yaml new file mode 100644 index 00000000..58a911fa --- /dev/null +++ b/.github/workflows/build_prodrc_pr.yaml @@ -0,0 +1,28 @@ +--- +name: Build Prod RC Image +'on': + pull_request: + branches: + - master + - main + types: + - opened + - synchronize + - ready_for_review +jobs: + docker_build: + runs-on: ubuntu-latest + steps: + - name: Check out GitHub Repo + if: github.event.pull_request.draft == false + with: + ref: "${{ github.event.pull_request.head.sha }}" + uses: actions/checkout@v2 + - name: Build and Push to Packages + if: github.event.pull_request.draft == false + env: + PR: "${{ github.event.pull_request.number }}" + SHA: "${{ github.event.pull_request.head.sha }}" + DOCKER_ACTOR: "${{ secrets.GHCR_USERNAME }}" + DOCKER_TOKEN: "${{ secrets.GHCR_TOKEN }}" + run: "./.github/workflows/scripts/build_prodrc_pr.sh\n" From d97fbc3ecce18f896dec6db6bd17ce1d1179e479 Mon Sep 17 00:00:00 2001 From: bio-boris Date: Fri, 14 Jan 2022 13:14:06 -0600 Subject: [PATCH 697/732] Create build_test_pr.yaml --- .github/workflows/build_test_pr.yaml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .github/workflows/build_test_pr.yaml diff --git a/.github/workflows/build_test_pr.yaml b/.github/workflows/build_test_pr.yaml new file mode 100644 index 00000000..b6b53286 --- /dev/null +++ b/.github/workflows/build_test_pr.yaml @@ -0,0 +1,27 @@ +--- +name: Build Test Image +'on': + pull_request: + branches: + - develop + types: + - opened + - synchronize + - ready_for_review +jobs: + docker_build: + runs-on: ubuntu-latest + steps: + - name: Check out GitHub Repo + if: github.event.pull_request.draft == false + with: + ref: "${{ github.event.pull_request.head.sha }}" + uses: actions/checkout@v2 + - name: Build and Push to Packages + if: github.event.pull_request.draft == false + env: + PR: "${{ github.event.pull_request.number }}" + SHA: "${{ github.event.pull_request.head.sha }}" + DOCKER_ACTOR: "${{ secrets.GHCR_USERNAME }}" + DOCKER_TOKEN: "${{ secrets.GHCR_TOKEN }}" + run: "./.github/workflows/scripts/build_test_pr.sh\n" From fdfd23d2f18fff5b61a04f5938ab62a986f986bc Mon Sep 17 00:00:00 2001 From: bio-boris Date: Fri, 14 Jan 2022 13:14:26 -0600 Subject: [PATCH 698/732] Create tag_environments.yaml --- .github/workflows/tag_environments.yaml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 .github/workflows/tag_environments.yaml diff --git a/.github/workflows/tag_environments.yaml b/.github/workflows/tag_environments.yaml new file mode 100644 index 00000000..6dba7431 --- /dev/null +++ b/.github/workflows/tag_environments.yaml @@ -0,0 +1,19 @@ +--- +name: Tag Image For Deploy +'on': + repository_dispatch +jobs: + tag_environments: + runs-on: ubuntu-latest + steps: + - name: Check out GitHub Repo + uses: actions/checkout@v2 + - name: Tag Deploy Environments + env: + DOCKER_ACTOR: "${{ secrets.GHCR_USERNAME }}" + DOCKER_TOKEN: ${{ secrets.GHCR_TOKEN }} + IMAGE_TAG: ${{ github.event.client_payload.image_tag }} + SHA: ${{ github.event.pull_request.head.sha }} + TARGET: ${{ github.event.client_payload.target }} + DEV_PROD: ${{ github.event.client_payload.dev_prod }} + run: './.github/workflows/scripts/tag_environments.sh' From b81781aece27cd0ede86a426e3bff9021d53a1f7 Mon Sep 17 00:00:00 2001 From: bio-boris Date: Fri, 14 Jan 2022 13:14:47 -0600 Subject: [PATCH 699/732] Create tag_prod_latest.yaml --- .github/workflows/tag_prod_latest.yaml | 27 ++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .github/workflows/tag_prod_latest.yaml diff --git a/.github/workflows/tag_prod_latest.yaml b/.github/workflows/tag_prod_latest.yaml new file mode 100644 index 00000000..12b23df0 --- /dev/null +++ b/.github/workflows/tag_prod_latest.yaml @@ -0,0 +1,27 @@ +--- +name: Tag Prod Latest +'on': + pull_request: + branches: + - master + - main + types: + - closed +jobs: + docker_tag: + runs-on: ubuntu-latest + steps: + - name: Check out GitHub Repo + if: github.event_name == 'pull_request' && github.event.action == 'closed' && + github.event.pull_request.merged == true + with: + ref: "${{ github.event.pull_request.head.sha }}" + uses: actions/checkout@v2 + - name: Build and Push to Packages + if: github.event.pull_request.draft == false + env: + PR: "${{ github.event.pull_request.number }}" + SHA: "${{ github.event.pull_request.head.sha }}" + DOCKER_ACTOR: "${{ secrets.GHCR_USERNAME }}" + DOCKER_TOKEN: "${{ secrets.GHCR_TOKEN }}" + run: "./.github/workflows/scripts/tag_prod_latest.sh\n" From b6bbe32341d7e2a44b909cb2058d2baf7589876d Mon Sep 17 00:00:00 2001 From: bio-boris Date: Fri, 14 Jan 2022 13:15:08 -0600 Subject: [PATCH 700/732] Create tag_test_latest.yaml --- .github/workflows/tag_test_latest.yaml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .github/workflows/tag_test_latest.yaml diff --git a/.github/workflows/tag_test_latest.yaml b/.github/workflows/tag_test_latest.yaml new file mode 100644 index 00000000..d8cac465 --- /dev/null +++ b/.github/workflows/tag_test_latest.yaml @@ -0,0 +1,26 @@ +--- +name: Tag Latest Test Image +'on': + pull_request: + branches: + - develop + types: + - closed +jobs: + docker_tag: + runs-on: ubuntu-latest + steps: + - name: Check out GitHub Repo + if: github.event_name == 'pull_request' && github.event.action == 'closed' && + github.event.pull_request.merged == true + with: + ref: "${{ github.event.pull_request.head.sha }}" + uses: actions/checkout@v2 + - name: Build and Push to Packages + if: github.event.pull_request.draft == false + env: + PR: "${{ github.event.pull_request.number }}" + SHA: "${{ github.event.pull_request.head.sha }}" + DOCKER_ACTOR: "${{ secrets.GHCR_USERNAME }}" + DOCKER_TOKEN: "${{ secrets.GHCR_TOKEN }}" + run: "./.github/workflows/scripts/tag_test_latest.sh\n" From f17c5f9ff6bd967283aafa78bee55f014ab9acbd Mon Sep 17 00:00:00 2001 From: bio-boris Date: Fri, 14 Jan 2022 13:18:07 -0600 Subject: [PATCH 701/732] Update perms --- .github/workflows/scripts/build_prodrc_pr.sh | 0 .github/workflows/scripts/build_test_pr.sh | 0 .github/workflows/scripts/deploy_tag.sh | 0 .github/workflows/scripts/tag_environments.sh | 0 .github/workflows/scripts/tag_prod_latest.sh | 0 .github/workflows/scripts/tag_test_latest.sh | 0 6 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 .github/workflows/scripts/build_prodrc_pr.sh mode change 100644 => 100755 .github/workflows/scripts/build_test_pr.sh mode change 100644 => 100755 .github/workflows/scripts/deploy_tag.sh mode change 100644 => 100755 .github/workflows/scripts/tag_environments.sh mode change 100644 => 100755 .github/workflows/scripts/tag_prod_latest.sh mode change 100644 => 100755 .github/workflows/scripts/tag_test_latest.sh diff --git a/.github/workflows/scripts/build_prodrc_pr.sh b/.github/workflows/scripts/build_prodrc_pr.sh old mode 100644 new mode 100755 diff --git a/.github/workflows/scripts/build_test_pr.sh b/.github/workflows/scripts/build_test_pr.sh old mode 100644 new mode 100755 diff --git a/.github/workflows/scripts/deploy_tag.sh b/.github/workflows/scripts/deploy_tag.sh old mode 100644 new mode 100755 diff --git a/.github/workflows/scripts/tag_environments.sh b/.github/workflows/scripts/tag_environments.sh old mode 100644 new mode 100755 diff --git a/.github/workflows/scripts/tag_prod_latest.sh b/.github/workflows/scripts/tag_prod_latest.sh old mode 100644 new mode 100755 diff --git a/.github/workflows/scripts/tag_test_latest.sh b/.github/workflows/scripts/tag_test_latest.sh old mode 100644 new mode 100755 From 422d6849c905c161e8a606897edafdc3c81ee5d9 Mon Sep 17 00:00:00 2001 From: bio-boris Date: Fri, 14 Jan 2022 15:15:42 -0600 Subject: [PATCH 702/732] Update CHANGELOG.md --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 332041bf..c5c02b91 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [0.0.16] - 2022-01-14 +### Added +- Added github actions to build docker images + + + ## [0.0.12] - 2021-01-29 ### Added - In the API, show the source file path or URL when updating the specs From bca4ca8be8e025540b3dbe0bff51729a23a37fd0 Mon Sep 17 00:00:00 2001 From: bio-boris Date: Fri, 14 Jan 2022 15:32:16 -0600 Subject: [PATCH 703/732] Update tag_test_latest.sh --- .github/workflows/scripts/tag_test_latest.sh | 38 +++++++------------- 1 file changed, 12 insertions(+), 26 deletions(-) diff --git a/.github/workflows/scripts/tag_test_latest.sh b/.github/workflows/scripts/tag_test_latest.sh index d8cac465..c0dc504a 100755 --- a/.github/workflows/scripts/tag_test_latest.sh +++ b/.github/workflows/scripts/tag_test_latest.sh @@ -1,26 +1,12 @@ ---- -name: Tag Latest Test Image -'on': - pull_request: - branches: - - develop - types: - - closed -jobs: - docker_tag: - runs-on: ubuntu-latest - steps: - - name: Check out GitHub Repo - if: github.event_name == 'pull_request' && github.event.action == 'closed' && - github.event.pull_request.merged == true - with: - ref: "${{ github.event.pull_request.head.sha }}" - uses: actions/checkout@v2 - - name: Build and Push to Packages - if: github.event.pull_request.draft == false - env: - PR: "${{ github.event.pull_request.number }}" - SHA: "${{ github.event.pull_request.head.sha }}" - DOCKER_ACTOR: "${{ secrets.GHCR_USERNAME }}" - DOCKER_TOKEN: "${{ secrets.GHCR_TOKEN }}" - run: "./.github/workflows/scripts/tag_test_latest.sh\n" +#! /usr/bin/env bash + +export MY_ORG=$(echo "${GITHUB_REPOSITORY}" | awk -F / '{print $1}') +export MY_APP=$(echo $(echo "${GITHUB_REPOSITORY}" | awk -F / '{print $2}')"-develop") +export DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ") +export BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ") +export COMMIT=$(echo "$SHA" | cut -c -7) + +docker login -u "$DOCKER_ACTOR" -p "$DOCKER_TOKEN" ghcr.io +docker pull ghcr.io/"$MY_ORG"/"$MY_APP":"pr-""$PR" +docker tag ghcr.io/"$MY_ORG"/"$MY_APP":"pr-""$PR" ghcr.io/"$MY_ORG"/"$MY_APP":"latest" +docker push ghcr.io/"$MY_ORG"/"$MY_APP":"latest" From 8ae02d99e2784f9d19b97899edc0030b9b8e4e72 Mon Sep 17 00:00:00 2001 From: bio-boris Date: Fri, 14 Jan 2022 16:08:58 -0600 Subject: [PATCH 704/732] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c5c02b91..a0728366 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [0.0.16] - 2022-01-14 ### Added -- Added github actions to build docker images +- Added github actions to build docker images on ghcr.io From 3355276884a2335fdacce6d37eef85035bb9d635 Mon Sep 17 00:00:00 2001 From: n1mus <709030+n1mus@users.noreply.github.com> Date: Sat, 15 Jan 2022 00:47:59 +0000 Subject: [PATCH 705/732] ensure specs --- Makefile | 7 +- relation_engine_server/api_versions/api_v1.py | 7 + relation_engine_server/test/test_api_v1.py | 12 + relation_engine_server/utils/arango_client.py | 229 ++++++++++++++- relation_engine_server/utils/ensure_specs.py | 260 ++++++++++++++++++ .../utils/json_validation.py | 8 +- relation_engine_server/utils/pull_spec.py | 20 +- scripts/run_tests_simple.sh | 13 + .../generic/fulltext_search.yaml | 4 +- .../stored_queries/test_fulltext_search.py | 60 +++- spec/test/test_ensure_specs.py | 229 +++++++++++++++ spec/validate.py | 73 +++-- 12 files changed, 859 insertions(+), 63 deletions(-) create mode 100644 relation_engine_server/utils/ensure_specs.py create mode 100644 scripts/run_tests_simple.sh create mode 100644 spec/test/test_ensure_specs.py diff --git a/Makefile b/Makefile index 86023d46..26e2db0f 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,15 @@ -.PHONY: test reset +.PHONY: test test_simple reset test: docker-compose build docker-compose run re_api sh scripts/run_tests.sh docker-compose down --remove-orphans +test_simple: + docker-compose build + docker-compose run re_api sh scripts/run_tests_simple.sh + docker-compose down --remove-orphans + shell: docker-compose down --remove-orphans docker-compose build diff --git a/relation_engine_server/api_versions/api_v1.py b/relation_engine_server/api_versions/api_v1.py index 6f18fe58..8400e3cf 100644 --- a/relation_engine_server/api_versions/api_v1.py +++ b/relation_engine_server/api_versions/api_v1.py @@ -7,6 +7,7 @@ pull_spec, config, parse_json, + ensure_specs as ensure_specs_, ) from relation_engine_server.utils.json_validation import run_validator from relation_engine_server.exceptions import InvalidParameters @@ -195,6 +196,12 @@ def show_config(): ) +@api_v1.route("/ensure_specs", methods=["GET"]) +def ensure_specs(): + failed_names = ensure_specs_.ensure_all() + return flask.jsonify(failed_names) + + 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 "" diff --git a/relation_engine_server/test/test_api_v1.py b/relation_engine_server/test/test_api_v1.py index d0f68695..4de6b799 100644 --- a/relation_engine_server/test/test_api_v1.py +++ b/relation_engine_server/test/test_api_v1.py @@ -335,6 +335,18 @@ def test_fetch_invalid_stored_queries(self): }, ) + def test_ensure_specs(self): + """Test endpoint for testing local specs against server specs""" + + self.test_request( + "/ensure_specs", + resp_json={ + "indexes": [], + "views": [], + "analyzers": [], + }, + ) + def test_show_data_sources(self): resp = requests.get(API_URL + "/data_sources") self.assertTrue(resp.ok) diff --git a/relation_engine_server/utils/arango_client.py b/relation_engine_server/utils/arango_client.py index 918954d1..45851142 100644 --- a/relation_engine_server/utils/arango_client.py +++ b/relation_engine_server/utils/arango_client.py @@ -9,6 +9,20 @@ from relation_engine_server.utils.config import get_config _CONF = get_config() +adb_url = _CONF["api_url"] +auth = (_CONF["db_user"], _CONF["db_pass"]) + + +def adb_request(req_method, url_append, **kw): + """Make HTTP request to ArangoDB server""" + resp = req_method( + adb_url + url_append, + auth=auth, + **kw, + ) + if not resp.ok or resp.json()["error"]: + raise ArangoServerError(resp.text) + return resp.json() def server_status(): @@ -66,6 +80,36 @@ def run_query( } +def get_all_collections(): + """ + Fetch information for all existing non-system collections + + Resp to GET /_api/collection is + { + "error": False, + "code": 200, + "result": [ + { + "id": str of int, + "name": str, + "status": int, + "type": int, + "isSystem": bool, + "globallyUniqueId": str, + }, + ... + ] + } + """ + resp_json = adb_request( + req_method=requests.get, + url_append="/collection", + # --- + params={"excludeSystem": True}, + ) + return resp_json + + def create_collection(name, config): """ Create a single collection by name using some basic defaults. @@ -100,23 +144,77 @@ def create_collection(name, config): _create_indexes(name, config) -def _get_indexes(coll_name): - """Fetch existing indexes for a collection""" - resp = requests.get( - url=_CONF["api_url"] + "/index", +def get_all_indexes(): + """ + Fetch all existing indexes for all non-system collections + + Returns + { + "coll_name_0": + [ + { + "deduplicate" : true, + "estimates" : true, + "fields" : [ + "price" + ], + "id" : "products/68128", + "name" : "idx_1721606625944403968", + "selectivityEstimate" : 1, + "sparse" : true, + "type" : "skiplist", + "unique" : false + }, + ... + ], + ... + } + """ + coll_names = [coll["name"] for coll in get_all_collections()["result"]] + all_indexes = {} + for coll_name in coll_names: + all_indexes[coll_name] = _get_coll_indexes(coll_name) + return all_indexes + + +def _get_coll_indexes(coll_name): + """ + Fetch existing indexes for a collection + Resp to GET /_api/index is + { + "error" : False, + "code" : 200, + "indexes" : [ + { + "deduplicate" : true, + "estimates" : true, + "fields" : [ + "price" + ], + "id" : "products/68128", + "name" : "idx_1721606625944403968", + "selectivityEstimate" : 1, + "sparse" : true, + "type" : "skiplist", + "unique" : false + }, + ... + ], + ... + } + """ + resp_json = adb_request( + req_method=requests.get, + url_append="/index", params={"collection": coll_name}, - auth=(_CONF["db_user"], _CONF["db_pass"]), ) - if not resp.ok: - raise RuntimeError(resp.text) - indexes = resp.json()["indexes"] - return indexes + return resp_json["indexes"] def _create_indexes(coll_name, config): """Create indexes for a collection""" url = _CONF["api_url"] + "/index" - indexes = _get_indexes(coll_name) + indexes = _get_coll_indexes(coll_name) for idx_conf in config["indexes"]: idx_type = idx_conf["type"] idx_url = url + "#" + idx_type @@ -170,6 +268,74 @@ def import_from_file(file_path, query): return resp_json +def get_all_views(): + """ + Fetch all existing views from server + + Resp to GET /_api/view is + { + "error": false, + "code": 200, + "result": [ + {"id": str, "name": str, "type": str}, + ... + ] + } + + Resp to GET /_api/view/{view_name}/properties is + { + "error" : false, + "code" : 200, + "writebufferIdle" : 64, + "type" : "arangosearch", + "writebufferSizeMax" : 33554432, + "consolidationPolicy" : { + "type" : "tier", + "segmentsBytesFloor" : 2097152, + "segmentsBytesMax" : 5368709120, + "segmentsMax" : 10, + "segmentsMin" : 1, + "minScore" : 0 + }, + "name" : "products", + "primarySort" : [ ], + "globallyUniqueId" : "hA5F3C05BE80C/68910", + "id" : "68910", + "storedValues" : [ ], + "writebufferActive" : 0, + "consolidationIntervalMsec" : 1000, + "cleanupIntervalStep" : 2, + "commitIntervalMsec" : 1000, + "links" : { + }, + "primarySortCompression" : "lz4" + } + + Returns + [ + {}, + {}, + ... + ] + where each item is the properties dict (from above) + """ + resp_json = adb_request( + req_method=requests.get, + url_append="/view", + ) + view_names = [view["name"] for view in resp_json["result"]] + + view_properties = [] + for view_name in view_names: + resp_json = adb_request( + req_method=requests.get, + url_append=f"/view/{view_name}/properties", + ) + view_properties.append(resp_json) + + return view_properties + + def create_view(name, config): """ Create a view by name, ignoring duplicates. @@ -192,8 +358,47 @@ def create_view(name, config): raise ArangoServerError(resp.text) -def get_analyzers(name): - pass +def get_all_analyzers(): + """ + Fetch all existing analyzers from server + Resp to GET /_api/analyzer is + { + "error" : false, + "code" : 200, + "result" : [ + { + "name" : "text_pt", + "type" : "text", + "properties" : { + "locale" : "pt.utf-8", + "case" : "lower", + "stopwords" : [ ], + "accent" : false, + "stemming" : true + }, + "features" : [ + "frequency", + "norm", + "position" + ] + }, + ... + ] + } + + Returns + [ + { ... } + ] + """ + resp = requests.get( + url=_CONF["api_url"] + "/analyzer", + auth=(_CONF["db_user"], _CONF["db_pass"]), + ) + if not resp.ok: + raise RuntimeError(resp.text) + analyzers = resp.json()["result"] + return analyzers def create_analyzer(name, config): diff --git a/relation_engine_server/utils/ensure_specs.py b/relation_engine_server/utils/ensure_specs.py new file mode 100644 index 00000000..cab27553 --- /dev/null +++ b/relation_engine_server/utils/ensure_specs.py @@ -0,0 +1,260 @@ +import json +from typing import Union, Callable + +from relation_engine_server.utils.json_validation import load_json_yaml +from relation_engine_server.utils import arango_client +from spec.validate import get_schema_type_paths + + +def get_local_coll_indexes(): + """ + Read all schemas for the collection schema type + Return just collection name and indexes + """ + coll_spec_paths = [] + coll_name_2_indexes = {} + for coll_spec_path in get_schema_type_paths("collection"): + coll = load_json_yaml(coll_spec_path) + if "indexes" not in coll: + continue + coll_spec_paths.append(coll_spec_path) + coll_name_2_indexes[coll["name"]] = coll["indexes"] + return coll_spec_paths, coll_name_2_indexes + + +def ensure_indexes(): + """ + Returns tuple + First item is list of borked index names, e.g. + [ + "coll_name_3/fulltext/['scientific_name']", + "coll_name_4/persistent/['id', 'key']", + ] + Second item is struct of failed indexes, e.g., + { + coll_name_3: [ + {"type": "fulltext", "fields": ["scientific_name"] ...} + ], + coll_name_4: [ + {"type": "persistent", "fields": ["id", "key"] ...} + ] + } + """ + coll_name_2_indexes_server = arango_client.get_all_indexes() + coll_spec_paths, coll_name_2_indexes_local = get_local_coll_indexes() + + failed_specs = {} + for coll_spec_path, (coll_name, indexes_local) in zip( + coll_spec_paths, coll_name_2_indexes_local.items() + ): + print(f"Ensuring indexes for {coll_spec_path}") + if coll_name not in coll_name_2_indexes_server: + failed_specs[coll_name] = indexes_local + continue + else: + failed_specs[coll_name] = [] + indexes_server = coll_name_2_indexes_server[coll_name] + for index_local in indexes_local: + match = False + for index_server in indexes_server: + if index_local.items() <= index_server.items(): + match = True + break + if match is False: + failed_specs[coll_name] = index_local + + failed_specs = { + k: v for k, v in failed_specs.items() if v + } # filter out 0-failure colls + if failed_specs: + print_failed_vs_server("indexes", failed_specs, coll_name_2_indexes_server) + else: + print("All index specs ensured") + + return get_names(failed_specs, "indexes"), failed_specs + + +def ensure_views(): + """ + Returns tuple + First item is list of failed view names, e.g., + [ + "Compounds/arangosearch" + ] + Second item is list of failed specs, e.g., + [ + {"name": "Compounds", "type": "arangosearch", ...} + ] + """ + all_views_server = arango_client.get_all_views() + mod_obj_literal(all_views_server, float, round_float) + view_spec_paths = get_schema_type_paths("view") + + failed_specs = [] + for view_spec_path in view_spec_paths: + print(f"Ensuring view {view_spec_path}") + view_local = load_json_yaml(view_spec_path) + match = False + for view_server in all_views_server: + if view_local.items() <= view_server.items(): + match = True + break + if match is False: + failed_specs.append(view_local) + + if failed_specs: + print_failed_vs_server("views", failed_specs, all_views_server) + else: + print("All view specs ensured") + + return get_names(failed_specs, "views"), failed_specs + + +def ensure_analyzers(): + """ + Returns tuple + First item is list of failed view names, e.g., + [ + "icu_tokenize/text" + ] + Second item is list of failed specs, e.g., + [ + {"name": "icu_tokenize", "type": "text", ...} + ] + """ + all_analyzers_server = arango_client.get_all_analyzers() + mod_obj_literal(all_analyzers_server, str, excise_namespace) + analyzer_spec_paths = get_schema_type_paths("analyzer") + + failed_specs = [] + for analyzer_spec_path in analyzer_spec_paths: + print(f"Ensuring analyzer {analyzer_spec_path}") + analyzer_local = load_json_yaml(analyzer_spec_path) + for analyzer_server in all_analyzers_server: + match = False + if analyzer_local.items() <= analyzer_server.items(): + match = True + break + if match is False: + failed_specs.append(analyzer_local) + + if failed_specs: + print_failed_vs_server("analyzers", failed_specs, all_analyzers_server) + else: + print("All analyzer specs ensured") + + return get_names(failed_specs, "analyzers"), failed_specs + + +def ensure_all(): + """ + Return names of failed specs if any, e.g., + { + "indexes": [ + ], + "views": [ + "Coumpounds/arangosearch", + "Reactions/arangosearch", + ], + "analyzers": [ + "icu_tokenize/text", + ], + } + """ + failed_indexes_names, _ = ensure_indexes() + failed_views_names, _ = ensure_views() + failed_analyzers_names, _ = ensure_analyzers() + + return { + "indexes": failed_indexes_names, + "views": failed_views_names, + "analyzers": failed_analyzers_names, + } + + +def get_names(specs, schema_type): + """ + Given views/analyzers/collections, collate names using required properties + """ + names = [] + if schema_type in ["views", "analyzers"]: + for spec in specs: + names.append(f"{spec['name']}/{spec['type']}") + elif schema_type in ["indexes"]: + for coll_name, indexes in specs.items(): + for index in indexes: + names.append(f"{coll_name}/{index['type']}/{index['fields']}") + else: + raise RuntimeError(f'Unknown schema type "{schema_type}"') + return names + + +def print_failed_vs_server(schema_type, failed_specs, server_specs): + """ + Print message with names and contents of failed local specs and all server specs + """ + dec = "*" * 80 + + def format_json(jo): + return json.dumps(jo, indent=4) + + fail_msg = ( + dec + "\n" + f"----------> failed ({len(failed_specs)} {schema_type}) ---------->" + "\n" + f"----------> names: {get_names(failed_specs, schema_type)} ---------->" + "\n" + format_json(failed_specs) + "\n" + f"----------> server ({len(server_specs)} {schema_type}) ---------->" + "\n" + f"----------> names: {get_names(server_specs, schema_type)} ---------->" + "\n" + format_json(server_specs) + "\n" + dec + ) + + print(fail_msg) + + +def round_float(num: float) -> float: + """ + For round-off error in floats + Arbitrarily chose 7 places + """ + return round(num, 7) + + +def excise_namespace(analyzer_name: str) -> str: + """ + Remove namespace prefix, e.g., + namespace::thing -> thing + """ + return analyzer_name.split("::")[-1] + + +def mod_obj_literal( + spec_unit: Union[list, dict], + literal_type: type, + func: Callable[[Union[float, str]], Union[float, str]], +) -> None: + """ + Modify dict in-place recursively + Some specs won't match because of + * round-off error in floats + * namespacing in analyzers, e.g., "_system::icu_tokenize" + + Parameters + ---------- + spec_unit - recursively accessed data structure unit of JSON obj + literal_type - str or float + func - function called to modify that str or float in-place + """ + if isinstance(spec_unit, dict): + for k, v in spec_unit.items(): + if isinstance(v, dict) or isinstance(v, list): + mod_obj_literal(v, literal_type, func) + elif isinstance(v, literal_type): + spec_unit[k] = func(v) # type: ignore + elif isinstance(spec_unit, list): + for i, v in enumerate(spec_unit): + if isinstance(v, dict) or isinstance(v, list): + mod_obj_literal(v, literal_type, func) + elif isinstance(v, literal_type): + spec_unit[i] = func(v) # type: ignore diff --git a/relation_engine_server/utils/json_validation.py b/relation_engine_server/utils/json_validation.py index 3b156698..c44538f5 100644 --- a/relation_engine_server/utils/json_validation.py +++ b/relation_engine_server/utils/json_validation.py @@ -67,7 +67,7 @@ def get_schema_validator(schema=None, schema_file=None, validate_at=""): # schema to validate against if schema is None: - schema = _load_json_schema(schema_file) + schema = load_json_yaml(schema_file) # get the appropriate location in the schema validation_schema = resolve_pointer(schema, validate_at) @@ -120,7 +120,7 @@ def run_validator( # data to validate if data is None: - data = _load_json_schema(data_file) + data = load_json_yaml(data_file) if validator.is_valid(data): return data @@ -136,8 +136,8 @@ def run_validator( raise ValidationError(err_msg) -def _load_json_schema(file): - """Loads the given schema file""" +def load_json_yaml(file): + """Loads the given JSON/YAML file""" with open(file) as fd: if file.endswith(".yaml") or file.endswith(".yml"): diff --git a/relation_engine_server/utils/pull_spec.py b/relation_engine_server/utils/pull_spec.py index b2cc194d..ec924ffb 100644 --- a/relation_engine_server/utils/pull_spec.py +++ b/relation_engine_server/utils/pull_spec.py @@ -62,10 +62,20 @@ def download_specs( return update_name +def _glob_specs(spec_type): + patterns = [ + os.path.join(_CONF["spec_paths"][spec_type], "*.json"), + os.path.join(_CONF["spec_paths"][spec_type], "*.yaml"), + os.path.join(_CONF["spec_paths"][spec_type], "**", "*.json"), + os.path.join(_CONF["spec_paths"][spec_type], "**", "*.yaml"), + ] + for pattern in patterns: + yield from glob.iglob(pattern) + + def do_init_collections(): """Initialize any uninitialized collections in the database from a set of collection schemas.""" - pattern = os.path.join(_CONF["spec_paths"]["collections"], "**", "*.yaml") - for path in glob.iglob(pattern): + for path in _glob_specs("collections"): coll_name = os.path.basename(os.path.splitext(path)[0]) with open(path) as fd: config = yaml.safe_load(fd) @@ -74,8 +84,7 @@ def do_init_collections(): def do_init_views(): """Initialize any uninitialized views in the database from a set of schemas.""" - pattern = os.path.join(_CONF["spec_paths"]["views"], "**", "*.json") - for path in glob.iglob(pattern): + for path in _glob_specs("views"): view_name = os.path.basename(os.path.splitext(path)[0]) with open(path) as fd: config = json.load(fd) @@ -83,8 +92,7 @@ def do_init_views(): def do_init_analyzers(): - pattern = os.path.join(_CONF["spec_paths"]["analyzers"], "*.json") - for path in glob.iglob(pattern): + for path in _glob_specs("analyzers"): analyzer_name = os.path.basename(os.path.splitext(path)[0]) with open(path) as fd: config = json.load(fd) diff --git a/scripts/run_tests_simple.sh b/scripts/run_tests_simple.sh new file mode 100644 index 00000000..0b511b61 --- /dev/null +++ b/scripts/run_tests_simple.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +set -e + +# Create tarball of the test spec directory +(cd /app/relation_engine_server/test/spec_release && \ + tar czvf spec.tar.gz sample_spec_release) + +# start server, using the specs in /spec/repo +sh /app/scripts/start_server.sh & +python -m pytest -s relation_engine_server/test/test_api_v1.py +#python -m pytest -s spec/test/test_ensure_specs.py +#python -m pytest -s spec/test/stored_queries/test_fulltext_search.py diff --git a/spec/stored_queries/generic/fulltext_search.yaml b/spec/stored_queries/generic/fulltext_search.yaml index 714948a8..9b90fa02 100644 --- a/spec/stored_queries/generic/fulltext_search.yaml +++ b/spec/stored_queries/generic/fulltext_search.yaml @@ -3,6 +3,7 @@ name: fulltext_search params: type: object required: ["@coll", search_attrkey, search_text] + additionalProperties: false properties: "@coll": type: string @@ -37,6 +38,7 @@ params: In each item object, the key-value pairs would restrict the documents to those containing all the attribute key-value pairs. But if any item object in the array satisfies the document, the document is filtered into the results. Basically works like a boolean expression where each key-value pair is a boolean value, each item object is a boolean term, and the array is a sum of boolean terms + Null or empty arrays have no filtering effect. offset: type: [integer, "null"] title: Paging offset @@ -57,7 +59,7 @@ params: query: | LET search_text__norm = REGEX_REPLACE(LOWER(TRIM(@search_text)), "\\s+", " ") LET search_text__first_exact_tok = REGEX_SPLIT(search_text__norm, " ")[0] - LET search_text__icu_toks = TOKENS(@search_text, "_system::icu_tokenize") + LET search_text__icu_toks = TOKENS(@search_text, "icu_tokenize") LET search_text__wordboundmod_icu_toks = ( FOR tok IN search_text__icu_toks RETURN REGEX_REPLACE(tok, ",.*", "") /* commas cannot be escaped */ diff --git a/spec/test/stored_queries/test_fulltext_search.py b/spec/test/stored_queries/test_fulltext_search.py index aa336f1e..259438b2 100644 --- a/spec/test/stored_queries/test_fulltext_search.py +++ b/spec/test/stored_queries/test_fulltext_search.py @@ -148,21 +148,41 @@ def test_fully_specified_bind_params(self): expect_hit=True, ) - def test_stored_query_validation_fail(self): - # TODO stored query validation does not seem to work - return - with self.assertRaises(RuntimeError): - _fulltext_query( - self, - coll=[], - search_attrkey=42, - search_text={"hi": 1}, - ts=None, - filter_attr_expr=None, - offset=None, - limit=None, - select=None, - ) + def test_extra_params(self): + """Extra params not in spec/aql""" + _fulltext_query( + self, + coll="ncbi_taxon", + search_attrkey="scientific_name", + search_text="esch", + ts=None, + filter_attr_expr=[ + {"rank": "species"}, + {"rank": "strain"}, + {"strain": True}, + ], + offset=0, + limit=LIMIT, + select=["id", "scientific_name"], + extra_unused_param=42, + # --- + expect_error=("Additional properties are not allowed"), + ) + + def test_validation_fail(self): + _fulltext_query( + self, + coll=[], + search_attrkey=42, + search_text={"hi": 1}, + ts=None, + filter_attr_expr=None, + offset=None, + limit=None, + select=None, + # --- + expect_error="[] is not of type 'string'", + ) def test_aql_error(self): for sciname in scinames_test_all: @@ -215,6 +235,7 @@ def _fulltext_query( expect_error=False, expect_hit=True, expected_hits=None, + **kw, ): """ Run query against ArangoDB server @@ -228,6 +249,7 @@ def _fulltext_query( "offset": offset, "limit": limit, "select": select, + **kw, } resp = requests.post( _CONF["re_api_url"] + "/api/v1/query_results", @@ -237,8 +259,12 @@ def _fulltext_query( if expect_error: self.assertIn("error", resp.json()) + if isinstance(expect_error, str): + self.assertIn(expect_error, json.dumps(resp.json())) else: + self.assertNotIn("error", resp.json(), json.dumps(resp.json(), indent=4)) + docs = resp.json()["results"] hits = [doc[search_attrkey] for doc in docs] if expect_hit: @@ -262,8 +288,12 @@ def _fulltext_query( if expect_error: self.assertIn("error", resp.json()) + if isinstance(expect_error, str): + self.assertIn(expect_error, json.dumps(resp.json())) else: + self.assertNotIn("error", resp.json(), json.dumps(resp.json(), indent=4)) + docs = resp.json()["results"] hits = [doc[search_attrkey] for doc in docs] if expect_hit: diff --git a/spec/test/test_ensure_specs.py b/spec/test/test_ensure_specs.py new file mode 100644 index 00000000..405ffe0b --- /dev/null +++ b/spec/test/test_ensure_specs.py @@ -0,0 +1,229 @@ +import unittest +from unittest import mock +import copy + +from relation_engine_server.utils import arango_client +from relation_engine_server.utils.ensure_specs import ( + ensure_indexes, + ensure_views, + ensure_analyzers, + ensure_all, + mod_obj_literal, + round_float, + excise_namespace, + get_names, +) +from spec.test.helpers import ( + check_spec_test_env, +) + + +def ensure_borked_indexes(): + """Get all the test server indexes, but with 1st one borked""" + coll_name_2_indexes_server = arango_client.get_all_indexes() + borked_coll_name = list(coll_name_2_indexes_server.keys())[0] + borked_index = coll_name_2_indexes_server[borked_coll_name][0] + borked_index["type"] = "fake_type" + borked_name = f"{borked_coll_name}/{borked_index['type']}/{borked_index['fields']}" + return ([borked_name], {borked_coll_name: [borked_index]}) + + +def ensure_borked_views(): + """Get all the test server views, but with 1st one borked""" + all_views_server = arango_client.get_all_views() + borked_view = all_views_server[0] + borked_view["type"] = "fake_type" + borked_name = f"{borked_view['name']}/{borked_view['type']}" + return ([borked_name], [borked_view]) + + +def ensure_borked_analyzers(): + """Get all the test server analyzers, but with 1st one borked""" + all_analyzers_server = arango_client.get_all_analyzers() + borked_analyzer = all_analyzers_server[0] + borked_analyzer["type"] = "fake_type" + borked_name = f"{borked_analyzer['name']}/{borked_analyzer['type']}" + return ([borked_name], [borked_analyzer]) + + +class TestEnsureSpecs(unittest.TestCase): + @classmethod + def setUpClass(cls): + cls.maxDiff = None + check_spec_test_env() + + def test_ensure_indexes(self): + failed_names, failed_specs = ensure_indexes() + self.assertFalse(len(failed_names)) + self.assertFalse(len(failed_specs)) + + def test_ensure_views(self): + failed_names, failed_specs = ensure_views() + self.assertFalse(len(failed_names)) + self.assertFalse(len(failed_specs)) + + def test_ensure_analyzers(self): + failed_names, failed_specs = ensure_analyzers() + self.assertFalse(len(failed_names)) + self.assertFalse(len(failed_specs)) + + def test_ensure_all(self): + failed_names = ensure_all() + self.assertEqual( + failed_names, + { + "indexes": [], + "views": [], + "analyzers": [], + }, + ) + + @mock.patch( + "relation_engine_server.utils.ensure_specs.ensure_indexes", + ensure_borked_indexes, + ) + @mock.patch( + "relation_engine_server.utils.ensure_specs.ensure_views", ensure_borked_views + ) + @mock.patch( + "relation_engine_server.utils.ensure_specs.ensure_analyzers", + ensure_borked_analyzers, + ) + def test_ensure_all__fail(self): + """Mock server spec fetches so that 1st spec of each type is borked""" + borked_index_names, _ = ensure_borked_indexes() + borked_view_names, _ = ensure_borked_views() + borked_analyzer_names, _ = ensure_borked_analyzers() + failed_names = ensure_all() + + self.assertEqual( + { + "indexes": borked_index_names, + "views": borked_view_names, + "analyzers": borked_analyzer_names, + }, + failed_names, + ) + + # ------------------ + # --- Unit tests --- + # ------------------ + + def _copy_mod_obj_literal(self, obj, literal_type, func): + obj = copy.deepcopy(obj) + mod_obj_literal(obj, literal_type, func) + return obj + + def test_mod_obj_literal__round_float(self): + """Test recursively finding floats in obj to correct round off error""" + obj = { + "english": { + "hello": "hello", + "one": 1.00000, + }, + "spanish": { + "hello": "hola", + "one": 1.0000000089, + "_castilian": { + "hello": "hola", + "one": 1, + }, + }, + "japanese": { + "hello": "konichiwa", + "one": 0.999999999999, + }, + } + + exp = { + "english": { + "hello": "hello", + "one": 1.0, + }, + "spanish": { + "hello": "hola", + "one": 1.0, + "_castilian": { + "hello": "hola", + "one": 1, + }, + }, + "japanese": { + "hello": "konichiwa", + "one": 1.0, + }, + } + + self.assertEqual(exp, self._copy_mod_obj_literal(obj, float, round_float)) + + def test_mod_obj_literal__excise_namespace(self): + """Test recursively find namespace::name strings in obj to excise namespace prefix""" + obj = { + "english": { + "hello": "hello", + "thing": "thing", + }, + "spanish": { + "hello": "hola", + "thing": "spanish::cosa", + "_castilian": { + "hello": "hola", + "thing": "spanish_castilian::cosa", + }, + }, + "japanese": { + "hello": "konichiwa", + "thing": "japanese::mono", + }, + } + + exp = { + "english": { + "hello": "hello", + "thing": "thing", + }, + "spanish": { + "hello": "hola", + "thing": "cosa", + "_castilian": { + "hello": "hola", + "thing": "cosa", + }, + }, + "japanese": { + "hello": "konichiwa", + "thing": "mono", + }, + } + + self.assertEqual(exp, self._copy_mod_obj_literal(obj, str, excise_namespace)) + + def test_get_view_analyzer_names(self): + """Test getting names of list of analyzer/view properties""" + views_analyzers = [ + {"name": "thing0", "type": "type0"}, + {"name": "thing1", "type": "type1"}, + ] + + self.assertEqual( + get_names(views_analyzers, "views"), ["thing0/type0", "thing1/type1"] + ) + + def test_get_coll_names(self): + """Test getting names of dict of list of index properties""" + coll_names_2_indexes = { + "coll0": [ + {"type": "type00", "fields": ["fields000", "fields001"]}, + {"type": "type01", "fields": ["fields010"]}, + ], + "coll1": [{"type": "type10", "fields": ["fields100"]}], + } + + self.assertEqual( + get_names(coll_names_2_indexes, "indexes"), + [ + "coll0/type00/['fields000', 'fields001']", + "coll0/type01/['fields010']", + "coll1/type10/['fields100']", + ], + ) diff --git a/spec/validate.py b/spec/validate.py index e8531c28..25c3bc85 100644 --- a/spec/validate.py +++ b/spec/validate.py @@ -32,9 +32,28 @@ "file": os.path.join(_BASE_DIR, "view_schema.yaml"), "plural": "views", }, + "analyzer": { + "file": os.path.join(_BASE_DIR, "analyzer_schema.yaml"), + "plural": "analyzers", + }, } +def get_schema_type_paths(schema_type, directory=None): + if schema_type not in _VALID_SCHEMA_TYPES.keys(): + raise ValueError(f"No validation schema found for '{schema_type}'") + if directory is None: + type_dir_name = _VALID_SCHEMA_TYPES[schema_type]["plural"] + directory = _CONF["spec_paths"][type_dir_name] + + paths = [] + for path in glob.iglob(os.path.join(directory, "**", "*.*"), recursive=True): + if path.endswith(".yaml") or path.endswith(".json"): + paths.append(path) + + return sorted(paths) + + def validate_all(schema_type, directory=None): """ Validate the syntax of all schemas of type schema_type in a specified directory @@ -44,37 +63,30 @@ def validate_all(schema_type, directory=None): If not specified, the default directory for the schema_type will be used. """ - if schema_type not in _VALID_SCHEMA_TYPES.keys(): - raise ValueError(f"No validation schema found for '{schema_type}'") - err_files = [] n_files = 0 names = set() # type: set - if directory is None: - type_dir_name = _VALID_SCHEMA_TYPES[schema_type]["plural"] - directory = _CONF["spec_paths"][type_dir_name] print(f"Validating {schema_type} schemas in {directory}...") - for path in glob.iglob(os.path.join(directory, "**", "*.*"), recursive=True): - if path.endswith(".yaml") or path.endswith(".json"): - n_files += 1 - try: - data = validate_schema(path, schema_type) - # Check for any duplicate schema names - name = data["name"] - if name in names: - raise ValueError(f"Duplicate queries named '{name}'") - else: - names.add(name) - - except Exception as err: - print(f"✕ {path} failed validation") - print(err) - err_files.append([path, err]) + for path in get_schema_type_paths(schema_type, directory): + n_files += 1 + try: + data = validate_schema(path, schema_type) + # Check for any duplicate schema names + name = data["name"] + if name in names: + raise ValueError(f"Duplicate queries named '{name}'") + else: + names.add(name) + + except Exception as err: + print(f"✕ {path} failed validation") + print(err) + err_files.append([path, err]) if not n_files: - print(f"No schema files found") + print("No schema files found") return if err_files: @@ -232,6 +244,19 @@ def validate_view(path): return data +def validate_analyzer(path): + """Validate ArangoDB analyzer config""" + print(f" validating {path}..") + + # JSON schema for /analyzers + analyzer_schema_file = _VALID_SCHEMA_TYPES["analyzer"]["file"] + data = run_validator(data_file=path, schema_file=analyzer_schema_file) + namecheck_schema(path, data) + + print(f"✓ {path} is valid.") + return data + + def namecheck_schema(path, data): """Ensure that the schema "name" is the same as the file name minus extensions""" name = data["name"] @@ -254,7 +279,7 @@ def validate_aql_on_arango(data): params = set(data.get("params", {}).get("properties", {}).keys()) if params != query_bind_vars: raise ValueError( - f"Bind vars are invalid.\n" + "Bind vars are invalid.\n" + f" Extra vars in query: {query_bind_vars - params}.\n" + f" Extra params in schema: {params - query_bind_vars}" ) From 1dd5b3286f1ba2cb9215047e431b9dfe85ebc1db Mon Sep 17 00:00:00 2001 From: n1mus <709030+n1mus@users.noreply.github.com> Date: Wed, 26 Jan 2022 19:51:13 +0000 Subject: [PATCH 706/732] integrate ensure specs & test --- CHANGELOG.md | 10 ++++- VERSION | 2 +- dev-requirements.txt | 1 + relation_engine_server/test/test_pull_spec.py | 37 +++++++++++++++++++ relation_engine_server/utils/ensure_specs.py | 5 +++ relation_engine_server/utils/pull_spec.py | 29 +++++++-------- requirements.txt | 1 - scripts/run_tests_simple.sh | 6 +-- spec/test/test_ensure_specs.py | 4 +- 9 files changed, 68 insertions(+), 27 deletions(-) create mode 100644 relation_engine_server/test/test_pull_spec.py diff --git a/CHANGELOG.md b/CHANGELOG.md index a0728366..54d762c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,11 +6,17 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [0.0.17] - 2022-01-25 +### Added +- Ensure local specs match server specs +### Changed +- Remove explicit namespace from "icu_tokenize" analyzer + ## [0.0.16] - 2022-01-14 ### Added - Added github actions to build docker images on ghcr.io - - +- Added generic fulltext search stored query ## [0.0.12] - 2021-01-29 ### Added diff --git a/VERSION b/VERSION index 8cbf02c3..cd231804 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.0.12 +0.0.17 diff --git a/dev-requirements.txt b/dev-requirements.txt index ca42c76e..de91a89d 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -6,3 +6,4 @@ grequests==0.3.0 coverage==5.2.1 typed-ast>=1.4.0 black==20.8b1 +pytest==6.2.5 diff --git a/relation_engine_server/test/test_pull_spec.py b/relation_engine_server/test/test_pull_spec.py new file mode 100644 index 00000000..ef0b5f53 --- /dev/null +++ b/relation_engine_server/test/test_pull_spec.py @@ -0,0 +1,37 @@ +import unittest +from unittest import mock +import re + +from relation_engine_server.utils.pull_spec import download_specs +from relation_engine_server.utils.wait_for import wait_for_api +from spec.test.test_ensure_specs import ensure_borked_indexes + + +class Test(unittest.TestCase): + @classmethod + def setUpClass(cls): + wait_for_api() + + def test_download_specs(self): + download_specs(init_collections=True, reset=True) + + @mock.patch( + "relation_engine_server.utils.ensure_specs.ensure_indexes", + ensure_borked_indexes, + ) + def test_download_specs__fail(self): + with self.assertRaisesRegex( + RuntimeError, + re.escape( + """Some local specs have no matching server specs: +{ + "indexes": [ + "%s" + ], + "views": [], + "analyzers": [] +}""" + % ensure_borked_indexes()[0][0] + ), + ): + download_specs(init_collections=True, reset=True) diff --git a/relation_engine_server/utils/ensure_specs.py b/relation_engine_server/utils/ensure_specs.py index cab27553..d9538dbd 100644 --- a/relation_engine_server/utils/ensure_specs.py +++ b/relation_engine_server/utils/ensure_specs.py @@ -1,3 +1,8 @@ +""" +Ensure that all the specs in the spec/**/*.json and spec/**/*.yaml are +present in the server, with the top-level fields of the local specs being +a subset of the top-level fields of the server specs +""" import json from typing import Union, Callable diff --git a/relation_engine_server/utils/pull_spec.py b/relation_engine_server/utils/pull_spec.py index ec924ffb..6677ef1c 100644 --- a/relation_engine_server/utils/pull_spec.py +++ b/relation_engine_server/utils/pull_spec.py @@ -4,12 +4,13 @@ import tempfile import shutil import json -import glob import yaml from typing import Optional from relation_engine_server.utils import arango_client from relation_engine_server.utils.config import get_config +from relation_engine_server.utils.ensure_specs import ensure_all +from spec.validate import get_schema_type_paths _CONF = get_config() @@ -59,23 +60,21 @@ def download_specs( do_init_collections() do_init_views() do_init_analyzers() + # Check that local specs have matching server specs + # Necessary because creating resources like indexes + # does not overwrite + failed_names = ensure_all() + if any([name for schema_type, names in failed_names.items() for name in names]): + raise RuntimeError( + "Some local specs have no matching server specs:" + "\n" + json.dumps(failed_names, indent=4) + ) return update_name -def _glob_specs(spec_type): - patterns = [ - os.path.join(_CONF["spec_paths"][spec_type], "*.json"), - os.path.join(_CONF["spec_paths"][spec_type], "*.yaml"), - os.path.join(_CONF["spec_paths"][spec_type], "**", "*.json"), - os.path.join(_CONF["spec_paths"][spec_type], "**", "*.yaml"), - ] - for pattern in patterns: - yield from glob.iglob(pattern) - - def do_init_collections(): """Initialize any uninitialized collections in the database from a set of collection schemas.""" - for path in _glob_specs("collections"): + for path in get_schema_type_paths("collection"): coll_name = os.path.basename(os.path.splitext(path)[0]) with open(path) as fd: config = yaml.safe_load(fd) @@ -84,7 +83,7 @@ def do_init_collections(): def do_init_views(): """Initialize any uninitialized views in the database from a set of schemas.""" - for path in _glob_specs("views"): + for path in get_schema_type_paths("view"): view_name = os.path.basename(os.path.splitext(path)[0]) with open(path) as fd: config = json.load(fd) @@ -92,7 +91,7 @@ def do_init_views(): def do_init_analyzers(): - for path in _glob_specs("analyzers"): + for path in get_schema_type_paths("analyzer"): analyzer_name = os.path.basename(os.path.splitext(path)[0]) with open(path) as fd: config = json.load(fd) diff --git a/requirements.txt b/requirements.txt index 9bd3975d..53c43343 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,7 +3,6 @@ greenlet==0.4.16 gunicorn==19.9.0 gevent==1.3.7 simplejson==3.16.0 -pytest==6.2.5 python-dotenv==0.9.1 requests==2.20.0 jsonpointer==2.0 diff --git a/scripts/run_tests_simple.sh b/scripts/run_tests_simple.sh index 0b511b61..a87249a2 100644 --- a/scripts/run_tests_simple.sh +++ b/scripts/run_tests_simple.sh @@ -2,12 +2,8 @@ set -e -# Create tarball of the test spec directory -(cd /app/relation_engine_server/test/spec_release && \ - tar czvf spec.tar.gz sample_spec_release) - # start server, using the specs in /spec/repo sh /app/scripts/start_server.sh & -python -m pytest -s relation_engine_server/test/test_api_v1.py +python -m pytest -s relation_engine_server/test/test_pull_spec.py #python -m pytest -s spec/test/test_ensure_specs.py #python -m pytest -s spec/test/stored_queries/test_fulltext_search.py diff --git a/spec/test/test_ensure_specs.py b/spec/test/test_ensure_specs.py index 405ffe0b..70f30856 100644 --- a/spec/test/test_ensure_specs.py +++ b/spec/test/test_ensure_specs.py @@ -13,9 +13,7 @@ excise_namespace, get_names, ) -from spec.test.helpers import ( - check_spec_test_env, -) +from spec.test.helpers import check_spec_test_env def ensure_borked_indexes(): From 370878afdf918641c04ae975ce98bf5d2a6d3f64 Mon Sep 17 00:00:00 2001 From: n1mus <709030+n1mus@users.noreply.github.com> Date: Fri, 28 Jan 2022 18:32:51 +0000 Subject: [PATCH 707/732] revisions --- Makefile | 7 +---- relation_engine_server/api_versions/api_v1.py | 11 +++++--- relation_engine_server/test/test_api_v1.py | 15 +++++++++- relation_engine_server/test/test_pull_spec.py | 12 ++++++-- relation_engine_server/utils/arango_client.py | 16 ++++------- relation_engine_server/utils/ensure_specs.py | 28 +++++++------------ relation_engine_server/utils/pull_spec.py | 2 +- scripts/run_tests_simple.sh | 9 ------ .../generic/fulltext_search.yaml | 7 +++-- .../stored_queries/test_fulltext_search.py | 2 +- spec/validate.py | 10 +++---- 11 files changed, 58 insertions(+), 61 deletions(-) delete mode 100644 scripts/run_tests_simple.sh diff --git a/Makefile b/Makefile index 26e2db0f..86023d46 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,10 @@ -.PHONY: test test_simple reset +.PHONY: test reset test: docker-compose build docker-compose run re_api sh scripts/run_tests.sh docker-compose down --remove-orphans -test_simple: - docker-compose build - docker-compose run re_api sh scripts/run_tests_simple.sh - docker-compose down --remove-orphans - shell: docker-compose down --remove-orphans docker-compose build diff --git a/relation_engine_server/api_versions/api_v1.py b/relation_engine_server/api_versions/api_v1.py index 8400e3cf..0116bb9b 100644 --- a/relation_engine_server/api_versions/api_v1.py +++ b/relation_engine_server/api_versions/api_v1.py @@ -7,7 +7,7 @@ pull_spec, config, parse_json, - ensure_specs as ensure_specs_, + ensure_specs, ) from relation_engine_server.utils.json_validation import run_validator from relation_engine_server.exceptions import InvalidParameters @@ -197,9 +197,12 @@ def show_config(): @api_v1.route("/ensure_specs", methods=["GET"]) -def ensure_specs(): - failed_names = ensure_specs_.ensure_all() - return flask.jsonify(failed_names) +def ensure_all_specs(): + failed_names = ensure_specs.ensure_all() + if any([name for schema_type, names in failed_names.items() for name in names]): + return flask.jsonify(failed_names), 500 + else: + return flask.jsonify(failed_names) def _preprocess_stored_query(query_text, config): diff --git a/relation_engine_server/test/test_api_v1.py b/relation_engine_server/test/test_api_v1.py index 4de6b799..113471f5 100644 --- a/relation_engine_server/test/test_api_v1.py +++ b/relation_engine_server/test/test_api_v1.py @@ -7,8 +7,10 @@ import requests import json import os + from relation_engine_server.utils.config import get_config from relation_engine_server.utils.wait_for import wait_for_api +from spec.test.test_ensure_specs import ensure_borked_indexes _CONF = get_config() @@ -337,7 +339,6 @@ def test_fetch_invalid_stored_queries(self): def test_ensure_specs(self): """Test endpoint for testing local specs against server specs""" - self.test_request( "/ensure_specs", resp_json={ @@ -347,6 +348,18 @@ def test_ensure_specs(self): }, ) + @unittest.skip("TODO - DELETE index") + def test_ensure_specs_fail(self): + self.test_request( + "/ensure_specs", + status_code=500, + resp_json={ + "indexes": ensure_borked_indexes()[0], + "views": [], + "analyzers": [], + }, + ) + def test_show_data_sources(self): resp = requests.get(API_URL + "/data_sources") self.assertTrue(resp.ok) diff --git a/relation_engine_server/test/test_pull_spec.py b/relation_engine_server/test/test_pull_spec.py index ef0b5f53..7ca658d7 100644 --- a/relation_engine_server/test/test_pull_spec.py +++ b/relation_engine_server/test/test_pull_spec.py @@ -4,22 +4,28 @@ from relation_engine_server.utils.pull_spec import download_specs from relation_engine_server.utils.wait_for import wait_for_api +from relation_engine_server.utils.config import get_config from spec.test.test_ensure_specs import ensure_borked_indexes +_CONF = get_config() -class Test(unittest.TestCase): + +class TestPullSpec(unittest.TestCase): @classmethod def setUpClass(cls): wait_for_api() - def test_download_specs(self): - download_specs(init_collections=True, reset=True) + def test_download_specs__success(self): + """Test ensure specs in `download_specs` for success case""" + update_name = download_specs(init_collections=True, reset=True) + self.assertEqual(_CONF["spec_release_path"], update_name) @mock.patch( "relation_engine_server.utils.ensure_specs.ensure_indexes", ensure_borked_indexes, ) def test_download_specs__fail(self): + """Test ensure specs in `download_specs` for fail case""" with self.assertRaisesRegex( RuntimeError, re.escape( diff --git a/relation_engine_server/utils/arango_client.py b/relation_engine_server/utils/arango_client.py index 45851142..82558208 100644 --- a/relation_engine_server/utils/arango_client.py +++ b/relation_engine_server/utils/arango_client.py @@ -9,15 +9,13 @@ from relation_engine_server.utils.config import get_config _CONF = get_config() -adb_url = _CONF["api_url"] -auth = (_CONF["db_user"], _CONF["db_pass"]) def adb_request(req_method, url_append, **kw): """Make HTTP request to ArangoDB server""" resp = req_method( - adb_url + url_append, - auth=auth, + _CONF["api_url"] + url_append, + auth=(_CONF["db_user"], _CONF["db_pass"]), **kw, ) if not resp.ok or resp.json()["error"]: @@ -391,13 +389,11 @@ def get_all_analyzers(): { ... } ] """ - resp = requests.get( - url=_CONF["api_url"] + "/analyzer", - auth=(_CONF["db_user"], _CONF["db_pass"]), + resp_json = adb_request( + requests.get, + url_append="/analyzer", ) - if not resp.ok: - raise RuntimeError(resp.text) - analyzers = resp.json()["result"] + analyzers = resp_json["result"] return analyzers diff --git a/relation_engine_server/utils/ensure_specs.py b/relation_engine_server/utils/ensure_specs.py index d9538dbd..6f315d14 100644 --- a/relation_engine_server/utils/ensure_specs.py +++ b/relation_engine_server/utils/ensure_specs.py @@ -11,6 +11,13 @@ from spec.validate import get_schema_type_paths +def match(spec_local, specs_server): + for spec_server in specs_server: + if spec_local.items() <= spec_server.items(): + return True + return False + + def get_local_coll_indexes(): """ Read all schemas for the collection schema type @@ -60,12 +67,7 @@ def ensure_indexes(): failed_specs[coll_name] = [] indexes_server = coll_name_2_indexes_server[coll_name] for index_local in indexes_local: - match = False - for index_server in indexes_server: - if index_local.items() <= index_server.items(): - match = True - break - if match is False: + if not match(index_local, indexes_server): failed_specs[coll_name] = index_local failed_specs = { @@ -99,12 +101,7 @@ def ensure_views(): for view_spec_path in view_spec_paths: print(f"Ensuring view {view_spec_path}") view_local = load_json_yaml(view_spec_path) - match = False - for view_server in all_views_server: - if view_local.items() <= view_server.items(): - match = True - break - if match is False: + if not match(view_local, all_views_server): failed_specs.append(view_local) if failed_specs: @@ -135,12 +132,7 @@ def ensure_analyzers(): for analyzer_spec_path in analyzer_spec_paths: print(f"Ensuring analyzer {analyzer_spec_path}") analyzer_local = load_json_yaml(analyzer_spec_path) - for analyzer_server in all_analyzers_server: - match = False - if analyzer_local.items() <= analyzer_server.items(): - match = True - break - if match is False: + if not match(analyzer_local, all_analyzers_server): failed_specs.append(analyzer_local) if failed_specs: diff --git a/relation_engine_server/utils/pull_spec.py b/relation_engine_server/utils/pull_spec.py index 6677ef1c..e75f0a41 100644 --- a/relation_engine_server/utils/pull_spec.py +++ b/relation_engine_server/utils/pull_spec.py @@ -62,7 +62,7 @@ def download_specs( do_init_analyzers() # Check that local specs have matching server specs # Necessary because creating resources like indexes - # does not overwrite + # does not overwrite any pre-existing indexes failed_names = ensure_all() if any([name for schema_type, names in failed_names.items() for name in names]): raise RuntimeError( diff --git a/scripts/run_tests_simple.sh b/scripts/run_tests_simple.sh deleted file mode 100644 index a87249a2..00000000 --- a/scripts/run_tests_simple.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh - -set -e - -# start server, using the specs in /spec/repo -sh /app/scripts/start_server.sh & -python -m pytest -s relation_engine_server/test/test_pull_spec.py -#python -m pytest -s spec/test/test_ensure_specs.py -#python -m pytest -s spec/test/stored_queries/test_fulltext_search.py diff --git a/spec/stored_queries/generic/fulltext_search.yaml b/spec/stored_queries/generic/fulltext_search.yaml index 9b90fa02..42d637b3 100644 --- a/spec/stored_queries/generic/fulltext_search.yaml +++ b/spec/stored_queries/generic/fulltext_search.yaml @@ -59,7 +59,7 @@ params: query: | LET search_text__norm = REGEX_REPLACE(LOWER(TRIM(@search_text)), "\\s+", " ") LET search_text__first_exact_tok = REGEX_SPLIT(search_text__norm, " ")[0] - LET search_text__icu_toks = TOKENS(@search_text, "icu_tokenize") + LET search_text__icu_toks = TOKENS(@search_text, "icu_tokenize") /* db analyzer icu_tokenize */ LET search_text__wordboundmod_icu_toks = ( FOR tok IN search_text__icu_toks RETURN REGEX_REPLACE(tok, ",.*", "") /* commas cannot be escaped */ @@ -69,15 +69,16 @@ query: | RETURN CONCAT("prefix:", tok) ) LET filter_attr_expr = @filter_attr_expr ? @filter_attr_expr : [] /* null to [] */ - LET search_text__wildcard = CONCAT("%", CONCAT_SEPARATOR("%", search_text__icu_toks), "%") + LET search_text__wildcard = CONCAT("%", CONCAT_SEPARATOR("%", search_text__icu_toks), "%") /* e.g., %tok0%tok1%tokn% */ FOR doc IN FULLTEXT(@@coll, @search_attrkey, search_text__fulltext) FILTER @ts ? doc.created <= @ts AND doc.expired >= @ts : true + /* keep doc if any obj in filter_attr_expr is a sub-obj of doc */ FILTER LENGTH(filter_attr_expr) > 0 ? ( FOR term IN filter_attr_expr RETURN MATCHES(doc, term) ) ANY == true : true LET attrval__norm = REGEX_REPLACE(LOWER(TRIM(doc.@search_attrkey)), "\\s+", " ") - LET attrval__icu_toks = TOKENS(doc.@search_attrkey, "_system::icu_tokenize") + LET attrval__icu_toks = TOKENS(doc.@search_attrkey, "icu_tokenize") SORT LIKE(doc.@search_attrkey, search_text__wildcard, true) DESC, /* icu tok ordering */ /* TODO - icu tok ordering with no insertions? */ CONTAINS(attrval__icu_toks[0], search_text__icu_toks[0], true) == 0 DESC, /* first icu tok */ diff --git a/spec/test/stored_queries/test_fulltext_search.py b/spec/test/stored_queries/test_fulltext_search.py index 259438b2..0ff13fc6 100644 --- a/spec/test/stored_queries/test_fulltext_search.py +++ b/spec/test/stored_queries/test_fulltext_search.py @@ -235,7 +235,7 @@ def _fulltext_query( expect_error=False, expect_hit=True, expected_hits=None, - **kw, + **kw, # for testing passing disallowed properties ): """ Run query against ArangoDB server diff --git a/spec/validate.py b/spec/validate.py index 25c3bc85..1a7064be 100644 --- a/spec/validate.py +++ b/spec/validate.py @@ -149,7 +149,7 @@ def validate_schema(path, schema_type): def validate_collection(path): - print(f" validating {path}..") + print(f" validating {path}...") # JSON schema for vertex and edge collection schemas found in /schema collection_schema_file = _VALID_SCHEMA_TYPES["collection"]["file"] @@ -197,7 +197,7 @@ def validate_collection(path): def validate_data_source(path): - print(f" validating {path}..") + print(f" validating {path}...") # JSON schema for data source files in /data_sources data_source_schema_file = _VALID_SCHEMA_TYPES["data_source"]["file"] @@ -209,7 +209,7 @@ def validate_data_source(path): def validate_stored_query(path): - print(f" validating {path}..") + print(f" validating {path}...") stored_queries_schema_file = _VALID_SCHEMA_TYPES["stored_query"]["file"] data = run_validator(schema_file=stored_queries_schema_file, data_file=path) @@ -233,7 +233,7 @@ def validate_stored_query(path): def validate_view(path): """Validate the structure and syntax of an arangodb view""" - print(f" validating {path}..") + print(f" validating {path}...") # JSON schema for /views view_schema_file = _VALID_SCHEMA_TYPES["view"]["file"] @@ -246,7 +246,7 @@ def validate_view(path): def validate_analyzer(path): """Validate ArangoDB analyzer config""" - print(f" validating {path}..") + print(f" validating {path}...") # JSON schema for /analyzers analyzer_schema_file = _VALID_SCHEMA_TYPES["analyzer"]["file"] From 7268234695f3b7871f0566a0a0afff008e426345 Mon Sep 17 00:00:00 2001 From: n1mus <709030+n1mus@users.noreply.github.com> Date: Mon, 31 Jan 2022 23:51:27 +0000 Subject: [PATCH 708/732] docs, tests, etc. --- relation_engine_server/api_versions/api_v1.py | 5 +++ relation_engine_server/utils/arango_client.py | 11 ++++- relation_engine_server/utils/ensure_specs.py | 42 +++++++++++-------- spec/test/test_ensure_specs.py | 27 +++++++++++- 4 files changed, 63 insertions(+), 22 deletions(-) diff --git a/relation_engine_server/api_versions/api_v1.py b/relation_engine_server/api_versions/api_v1.py index 0116bb9b..9057f3d7 100644 --- a/relation_engine_server/api_versions/api_v1.py +++ b/relation_engine_server/api_versions/api_v1.py @@ -198,6 +198,11 @@ def show_config(): @api_v1.route("/ensure_specs", methods=["GET"]) def ensure_all_specs(): + """ + This endpoint is not strictly necessary, as the ensure_specs.ensure_all() + code should triggered in startup scripts. This is more insurance in case + one wishes to ensure the specs without re-deployment + """ failed_names = ensure_specs.ensure_all() if any([name for schema_type, names in failed_names.items() for name in names]): return flask.jsonify(failed_names), 500 diff --git a/relation_engine_server/utils/arango_client.py b/relation_engine_server/utils/arango_client.py index 82558208..920cab6c 100644 --- a/relation_engine_server/utils/arango_client.py +++ b/relation_engine_server/utils/arango_client.py @@ -98,6 +98,13 @@ def get_all_collections(): ... ] } + + Returns + [ + {"id": ..., ...}, + {"id": ..., ...}, + ... + ] """ resp_json = adb_request( req_method=requests.get, @@ -105,7 +112,7 @@ def get_all_collections(): # --- params={"excludeSystem": True}, ) - return resp_json + return resp_json["result"] def create_collection(name, config): @@ -168,7 +175,7 @@ def get_all_indexes(): ... } """ - coll_names = [coll["name"] for coll in get_all_collections()["result"]] + coll_names = [coll["name"] for coll in get_all_collections()] all_indexes = {} for coll_name in coll_names: all_indexes[coll_name] = _get_coll_indexes(coll_name) diff --git a/relation_engine_server/utils/ensure_specs.py b/relation_engine_server/utils/ensure_specs.py index 6f315d14..6878b499 100644 --- a/relation_engine_server/utils/ensure_specs.py +++ b/relation_engine_server/utils/ensure_specs.py @@ -34,6 +34,20 @@ def get_local_coll_indexes(): return coll_spec_paths, coll_name_2_indexes +def get_local_views(): + view_spec_paths = get_schema_type_paths("view") + view_specs = [load_json_yaml(view_spec_path) for view_spec_path in view_spec_paths] + return view_spec_paths, view_specs + + +def get_local_analyzers(): + analyzer_spec_paths = get_schema_type_paths("analyzer") + analyzer_specs = [ + load_json_yaml(analyzer_spec_path) for analyzer_spec_path in analyzer_spec_paths + ] + return analyzer_spec_paths, analyzer_specs + + def ensure_indexes(): """ Returns tuple @@ -74,7 +88,7 @@ def ensure_indexes(): k: v for k, v in failed_specs.items() if v } # filter out 0-failure colls if failed_specs: - print_failed_vs_server("indexes", failed_specs, coll_name_2_indexes_server) + print_failed_specs("indexes", failed_specs) else: print("All index specs ensured") @@ -95,17 +109,15 @@ def ensure_views(): """ all_views_server = arango_client.get_all_views() mod_obj_literal(all_views_server, float, round_float) - view_spec_paths = get_schema_type_paths("view") failed_specs = [] - for view_spec_path in view_spec_paths: + for view_spec_path, view_local in zip(*get_local_views()): print(f"Ensuring view {view_spec_path}") - view_local = load_json_yaml(view_spec_path) if not match(view_local, all_views_server): failed_specs.append(view_local) if failed_specs: - print_failed_vs_server("views", failed_specs, all_views_server) + print_failed_specs("views", failed_specs) else: print("All view specs ensured") @@ -126,17 +138,15 @@ def ensure_analyzers(): """ all_analyzers_server = arango_client.get_all_analyzers() mod_obj_literal(all_analyzers_server, str, excise_namespace) - analyzer_spec_paths = get_schema_type_paths("analyzer") failed_specs = [] - for analyzer_spec_path in analyzer_spec_paths: + for analyzer_spec_path, analyzer_local in zip(*get_local_analyzers()): print(f"Ensuring analyzer {analyzer_spec_path}") - analyzer_local = load_json_yaml(analyzer_spec_path) if not match(analyzer_local, all_analyzers_server): failed_specs.append(analyzer_local) if failed_specs: - print_failed_vs_server("analyzers", failed_specs, all_analyzers_server) + print_failed_specs("analyzers", failed_specs) else: print("All analyzer specs ensured") @@ -186,25 +196,21 @@ def get_names(specs, schema_type): return names -def print_failed_vs_server(schema_type, failed_specs, server_specs): +def print_failed_specs(schema_type, failed_specs): """ - Print message with names and contents of failed local specs and all server specs + Print message with names of failed local specs """ - dec = "*" * 80 def format_json(jo): return json.dumps(jo, indent=4) fail_msg = ( - dec + "\n" - f"----------> failed ({len(failed_specs)} {schema_type}) ---------->" + "\n" + f"----------> {len(failed_specs)} {schema_type} failed ---------->" "\n" f"----------> names: {get_names(failed_specs, schema_type)} ---------->" - "\n" + format_json(failed_specs) + "\n" - f"----------> server ({len(server_specs)} {schema_type}) ---------->" "\n" - f"----------> names: {get_names(server_specs, schema_type)} ---------->" - "\n" + format_json(server_specs) + "\n" + dec + f"----------> Please compare local/server specs ---------->" ) print(fail_msg) diff --git a/spec/test/test_ensure_specs.py b/spec/test/test_ensure_specs.py index 70f30856..a6e85bbe 100644 --- a/spec/test/test_ensure_specs.py +++ b/spec/test/test_ensure_specs.py @@ -4,6 +4,9 @@ from relation_engine_server.utils import arango_client from relation_engine_server.utils.ensure_specs import ( + get_local_coll_indexes, + get_local_views, + get_local_analyzers, ensure_indexes, ensure_views, ensure_analyzers, @@ -87,8 +90,8 @@ def test_ensure_all(self): "relation_engine_server.utils.ensure_specs.ensure_analyzers", ensure_borked_analyzers, ) - def test_ensure_all__fail(self): - """Mock server spec fetches so that 1st spec of each type is borked""" + def test_ensure_all__fail__mock_ensure_things(self): + """Mock ensure_things calls so that 1st spec is borked""" borked_index_names, _ = ensure_borked_indexes() borked_view_names, _ = ensure_borked_views() borked_analyzer_names, _ = ensure_borked_analyzers() @@ -103,6 +106,26 @@ def test_ensure_all__fail(self): failed_names, ) + @mock.patch( + "relation_engine_server.utils.arango_client.get_all_indexes", lambda: {} + ) + @mock.patch("relation_engine_server.utils.arango_client.get_all_views", lambda: []) + @mock.patch( + "relation_engine_server.utils.arango_client.get_all_analyzers", lambda: [] + ) + def test_ensure_all__fail__mock_arango_client_get_all_things(self): + """Mock more upstream in server spec fetches""" + failed_names = ensure_all() + + self.assertEqual( + { + "indexes": get_names(get_local_coll_indexes()[1], "indexes"), + "views": get_names(get_local_views()[1], "views"), + "analyzers": get_names(get_local_analyzers()[1], "analyzers"), + }, + failed_names, + ) + # ------------------ # --- Unit tests --- # ------------------ From bd01e66cf11205701d888e16d9a60334e2dff7d3 Mon Sep 17 00:00:00 2001 From: n1mus <709030+n1mus@users.noreply.github.com> Date: Tue, 1 Feb 2022 17:42:20 +0000 Subject: [PATCH 709/732] unused local variable --- relation_engine_server/utils/ensure_specs.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/relation_engine_server/utils/ensure_specs.py b/relation_engine_server/utils/ensure_specs.py index 6878b499..584d5cdc 100644 --- a/relation_engine_server/utils/ensure_specs.py +++ b/relation_engine_server/utils/ensure_specs.py @@ -3,7 +3,6 @@ present in the server, with the top-level fields of the local specs being a subset of the top-level fields of the server specs """ -import json from typing import Union, Callable from relation_engine_server.utils.json_validation import load_json_yaml @@ -201,9 +200,6 @@ def print_failed_specs(schema_type, failed_specs): Print message with names of failed local specs """ - def format_json(jo): - return json.dumps(jo, indent=4) - fail_msg = ( "\n" f"----------> {len(failed_specs)} {schema_type} failed ---------->" From 0f04f7984286944f76dc39c7dcffa0209f2db292 Mon Sep 17 00:00:00 2001 From: Mikaela Cashman Date: Wed, 2 Feb 2022 11:00:23 -0500 Subject: [PATCH 710/732] updated edge_type.yaml to match data repo --- spec/datasets/djornl/edge_type.yaml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/spec/datasets/djornl/edge_type.yaml b/spec/datasets/djornl/edge_type.yaml index 6aa648eb..a5dd72a8 100644 --- a/spec/datasets/djornl/edge_type.yaml +++ b/spec/datasets/djornl/edge_type.yaml @@ -52,7 +52,7 @@ oneOf: title: ATRM TF to Target LitCurated 01082020 TranscriptionFactorToGene description: Contains literature mined and manually curated TF regulatory interactions for A.thaliana from 1701 TFFs from PlantTFDB 2.0 and 4663 TF-associated interactions. These were manually filtered (e.g. FPs, PPI interactions removed). They then added some from other sources. Downloaded from http://atrm.cbi.pku.edu.cn/download.php - - const : AT-UU-GO-03-AA-01 + - const : AT-UU-GO-05-AA-01 title : GO description: GeneA connects to GeneB if the two genes have semantically similar GO terms (with a similarity score > 0). This network is used to evaluate other networks for biological functional content. @@ -80,9 +80,9 @@ oneOf: title : Regulation-Plantregmap description: This network contains computationally predicted TF-Target relationships based on motifs, binding sites, ChipSeq data - - const : AT-UU-DU-07-AA-01 + - const : AT-UU-DU-67-AA-01 title : CoEvolution-DUO - description: GeneA connects to GeneB if a SNP in GeneA is correlated with a SNP in GeneB using the DUO metric (cite). SNP data is from the full 1001 Genomes. + description: GeneA connects to GeneB if a SNP in GeneA is correlated with a SNP in GeneB using the DUO metric (https://doi.org/10.1101/2020.01.28.923730). SNP data is from the full 1001 Genomes. - const : AT-UU-CD-00-AA-01 title : CoDomain @@ -91,3 +91,7 @@ oneOf: - const : AT-UU-RX-00-AA-01 title : Metabolic-AraCyc description: GeneA connects to GeneB if they are both enzymatic and are linked by a common substrate or product. E.g. RXNA (GeneA) → Compound1 → RXNB (GeneB). Here GeneA connects to GeneB due to Compound1. + + - const : AT-UU-PY-01-LF-01 + title : Predictive CG Methylation + description: GeneA connects to GeneB if the CG methylation vector of GeneA is an important predictor of the CG methylation vector of GeneB in an iRF model, where all other genes' CG methylation states are included as covariates. The iRF model is an expansion on Random Forest, a feature selection model. From 9b734ccdcd2544fb8ba62c30ff8d4be96c9df6ef Mon Sep 17 00:00:00 2001 From: n1mus <709030+n1mus@users.noreply.github.com> Date: Wed, 2 Feb 2022 20:56:35 +0000 Subject: [PATCH 711/732] docs --- relation_engine_server/api_versions/api_v1.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/relation_engine_server/api_versions/api_v1.py b/relation_engine_server/api_versions/api_v1.py index 9057f3d7..8cccfb3c 100644 --- a/relation_engine_server/api_versions/api_v1.py +++ b/relation_engine_server/api_versions/api_v1.py @@ -199,9 +199,19 @@ def show_config(): @api_v1.route("/ensure_specs", methods=["GET"]) def ensure_all_specs(): """ + Ensure that the local index/view/analyzer specs under spec/ have a + corresponding spec on the server. + This endpoint is not strictly necessary, as the ensure_specs.ensure_all() code should triggered in startup scripts. This is more insurance in case one wishes to ensure the specs without re-deployment + + Example ensure_specs.ensure_all() return value: + { + "indexes": [], + "views": ["Compounds/arangosearch", "Reactions/arangosearch"], + "analyzers": ["icu_tokenize/text"] + } """ failed_names = ensure_specs.ensure_all() if any([name for schema_type, names in failed_names.items() for name in names]): From b953e5175a84380088950019eabddcb458f2c97e Mon Sep 17 00:00:00 2001 From: bio-boris Date: Thu, 3 Feb 2022 12:50:59 -0600 Subject: [PATCH 712/732] Update README.md --- README.md | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 32cfa10a..bda0edb2 100644 --- a/README.md +++ b/README.md @@ -19,4 +19,20 @@ The relation engine server (`relation_engine_server/`) is a simple API that allo ## Relation Engine builds -The Relation Engine is available on dockerhub as `kbase/relation_engine_api`. Automated builds are performed whenever there is a new push to `master` or `develop`. +The Relation Engine is available on github packages. These images are built by the configs in the .github repo. +The develop tags are located at https://github.com/kbase/relation_engine/pkgs/container/relation_engine-develop +e.g. +``` +docker pull ghcr.io/kbase/relation_engine-develop:latest (Built upon merging a PR) +docker pull ghcr.io/kbase/relation_engine-develop:pr-93 (Built upon creating a PR) +``` + +## How to Deploy in CI +The CI service is available in the `relationapi` service +* Press Upgrade Arrow +* Ensure the relationapi service uses `ghcr.io/kbase/relation_engine-develop:latest` +* Ensure the `Always pull image before creating` box is ticked +* Press `Upgrade` button +* If the deployment suceeded, you can finish the upgrade. If not, you can press the rollback button. +* +(For deployments to other environments, request help from the #devops channel) From 02eced60d210648eb21bc78ff4346814270f6256 Mon Sep 17 00:00:00 2001 From: bio-boris Date: Thu, 3 Feb 2022 12:51:43 -0600 Subject: [PATCH 713/732] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bda0edb2..3a26d0e7 100644 --- a/README.md +++ b/README.md @@ -34,5 +34,5 @@ The CI service is available in the `relationapi` service * Ensure the `Always pull image before creating` box is ticked * Press `Upgrade` button * If the deployment suceeded, you can finish the upgrade. If not, you can press the rollback button. -* + (For deployments to other environments, request help from the #devops channel) From 7e75e0437347c307f295a007265cae5fffc39bdb Mon Sep 17 00:00:00 2001 From: n1mus <709030+n1mus@users.noreply.github.com> Date: Tue, 8 Feb 2022 04:51:07 +0000 Subject: [PATCH 714/732] recursive obj subsetting --- relation_engine_server/main.py | 4 +- relation_engine_server/utils/config.py | 1 - relation_engine_server/utils/ensure_specs.py | 21 +++- relation_engine_server/utils/wait_for.py | 1 - spec/test/test_ensure_specs.py | 116 +++++++++++++++++++ 5 files changed, 138 insertions(+), 5 deletions(-) diff --git a/relation_engine_server/main.py b/relation_engine_server/main.py index e359dc6b..1a924577 100644 --- a/relation_engine_server/main.py +++ b/relation_engine_server/main.py @@ -43,8 +43,8 @@ def return_error(error_dict, code): @app.route("/", methods=["GET"]) def root(): """Server status.""" - if os.path.exists(".git/refs/heads/master"): - with open(".git/refs/heads/master", "r") as fd: + if os.path.exists(".git/refs/heads/develop"): + with open(".git/refs/heads/develop", "r") as fd: commit_hash = fd.read().strip() else: commit_hash = "unknown" diff --git a/relation_engine_server/utils/config.py b/relation_engine_server/utils/config.py index a548fe39..fdea1b05 100644 --- a/relation_engine_server/utils/config.py +++ b/relation_engine_server/utils/config.py @@ -31,7 +31,6 @@ def get_config(): db_readonly_user = os.environ.get("DB_READONLY_USER", db_user) db_readonly_pass = os.environ.get("DB_READONLY_PASS", db_pass) api_url = db_url + "/_db/" + db_name + "/_api" - print(db_user, db_pass) return { "auth_url": auth_url, "workspace_url": workspace_url, diff --git a/relation_engine_server/utils/ensure_specs.py b/relation_engine_server/utils/ensure_specs.py index 584d5cdc..835deb06 100644 --- a/relation_engine_server/utils/ensure_specs.py +++ b/relation_engine_server/utils/ensure_specs.py @@ -12,7 +12,7 @@ def match(spec_local, specs_server): for spec_server in specs_server: - if spec_local.items() <= spec_server.items(): + if is_obj_subset_rec(spec_local, spec_server): return True return False @@ -228,6 +228,25 @@ def excise_namespace(analyzer_name: str) -> str: return analyzer_name.split("::")[-1] +def is_obj_subset_rec( + l: Union[dict, list, float, str, int], + r: Union[dict, list, float, str, int], +): + """ + Compare two JSON objects, to see if, essentially, l <= r + If comparing dicts, recursively compare + If comparing lists, shallowly compare. For now, YAGN more + """ + if isinstance(l, dict) and isinstance(r, dict): + return all( + [k in r.keys() and is_obj_subset_rec(l[k], r[k]) for k in l.keys()] + ) # ignore: typing + elif isinstance(l, list) and isinstance(r, list): + return all([le in r for le in l]) + else: + return l == r # noqa: E741 + + def mod_obj_literal( spec_unit: Union[list, dict], literal_type: type, diff --git a/relation_engine_server/utils/wait_for.py b/relation_engine_server/utils/wait_for.py index 4aed73c2..06b4a59a 100644 --- a/relation_engine_server/utils/wait_for.py +++ b/relation_engine_server/utils/wait_for.py @@ -41,7 +41,6 @@ def wait_for_service(service_list: List[str]) -> None: try: conf = service_conf[name] auth = (_CONF["db_user"], _CONF["db_pass"]) - print("auth is", auth) resp = requests.get(conf["url"], auth=auth) if conf.get("raise_for_status"): resp.raise_for_status() diff --git a/spec/test/test_ensure_specs.py b/spec/test/test_ensure_specs.py index a6e85bbe..3f95cad9 100644 --- a/spec/test/test_ensure_specs.py +++ b/spec/test/test_ensure_specs.py @@ -1,6 +1,7 @@ import unittest from unittest import mock import copy +import json from relation_engine_server.utils import arango_client from relation_engine_server.utils.ensure_specs import ( @@ -11,6 +12,7 @@ ensure_views, ensure_analyzers, ensure_all, + is_obj_subset_rec, mod_obj_literal, round_float, excise_namespace, @@ -130,6 +132,120 @@ def test_ensure_all__fail__mock_arango_client_get_all_things(self): # --- Unit tests --- # ------------------ + def test_is_obj_subset_rec(self): + """ + For comparing JSON objects + Roughly check l <= r, with recursive checks done with dicts + """ + exp_pass = [ + ({"hi": 1}, {"hi": 1}), + ({"hi": 1}, {"hi": 1, "hello": 2}), + ({}, {}), + ({}, {"hi": 1}), + ( + {"hi": 1, "hello": {"cat": 3, "sat": 2}}, + { + "hi": 1, + "hello": {"cat": 3, "sat": 2, "hat": 3, "bat": {}, "map": []}, + "hey": 5, + "aloha": [{}], + }, + ), + ] + exp_fail = [ + ({"hi": 1}, {}), + ({"hi": {}}, {}), + ({"hi": 1}, {"hi": {}}), + ({"hi": 1, "hello": 2}, {"hi": 1}), + ( + {"hi": 1, "hello": {"cat": 3, "sat": 2, "hat": 3}}, + {"hi": 1, "hello": {"cat": 3, "sat": 2}}, + ), + ( + {"hi": 1, "hello": {"cat": 3, "sat": {}}}, + {"hi": 1, "hello": {"cat": 3, "sat": 2}}, + ), + ( + {"hi": 1, "hello": {"cat": 3}, "hey": 5}, + {"hi": 1, "hello": {"cat": 3, "sat": 2}}, + ), + ( + { + "hi": 1, + "hello": {"cat": 3, "sat": 2, "hat": 3}, + "hey": 5, + "howdy": 6, + }, + {"hi": 1, "hello": {"cat": 3, "sat": 2}}, + ), + ] + + for loc, srv in exp_pass: + self.assertTrue(is_obj_subset_rec(loc, srv)) + for loc, srv in exp_fail: + self.assertFalse(is_obj_subset_rec(loc, srv)) + + def test_is_obj_subset_rec__Reactions(self): + """ + Test the recursive subset functions using Reactions.json view spec + """ + # Local spec + local = [view for view in get_local_views()[1] if view["name"] == "Reactions"][ + 0 + ] + # Server spec + # From Aardvark, but with "name" key/field added + # as seems to happen with GET + server = json.loads( + """ +{ + "name": "Reactions", + "writebufferIdle": 64, + "writebufferActive": 0, + "type": "arangosearch", + "primarySort": [], + "writebufferSizeMax": 33554432, + "commitIntervalMsec": 1000, + "consolidationPolicy": { + "type": "bytes_accum", + "threshold": 0.10000000149011612 + }, + "globallyUniqueId": "h5455DEB9D2A1/9853332", + "cleanupIntervalStep": 10, + "id": "9853332", + "links": { + "rxn_reaction": { + "analyzers": [ + "identity" + ], + "fields": { + "name": { + "analyzers": [ + "text_en" + ] + }, + "aliases": { + "analyzers": [ + "text_en" + ] + }, + "id": { + "analyzers": [ + "text_en" + ] + } + }, + "includeAllFields": true, + "storeValues": "none", + "trackListPositions": false + } + }, + "consolidationIntervalMsec": 60000 +}""" + ) + mod_obj_literal(server, float, round_float) + self.assertTrue(is_obj_subset_rec(local, server)) + def _copy_mod_obj_literal(self, obj, literal_type, func): obj = copy.deepcopy(obj) mod_obj_literal(obj, literal_type, func) From d13620be2f355f8b8cb163864dc3eeca10ff9e35 Mon Sep 17 00:00:00 2001 From: ialarmedalien Date: Tue, 8 Feb 2022 07:24:14 -0800 Subject: [PATCH 715/732] Updating codeowners --- CODEOWNERS | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/CODEOWNERS b/CODEOWNERS index 45d24230..c45e98cf 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -1,3 +1 @@ -* @ialarmedalien @zhlu9890 @eapearson - -relation_engine_server/* @ialarmedalien @slebras +* @ialarmedalien @eapearson @n1mus From 2e406f0386d900f0efb4de28f1d15866df1e8f7e Mon Sep 17 00:00:00 2001 From: n1mus <709030+n1mus@users.noreply.github.com> Date: Tue, 8 Feb 2022 17:52:06 +0000 Subject: [PATCH 716/732] doc func --- relation_engine_server/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/relation_engine_server/main.py b/relation_engine_server/main.py index 1a924577..e2f14a5f 100644 --- a/relation_engine_server/main.py +++ b/relation_engine_server/main.py @@ -42,7 +42,7 @@ def return_error(error_dict, code): @app.route("/", methods=["GET"]) def root(): - """Server status.""" + """Server status. develop is default branch""" if os.path.exists(".git/refs/heads/develop"): with open(".git/refs/heads/develop", "r") as fd: commit_hash = fd.read().strip() From d6a1bed301520c9fb6f1441009f952f8a38f2950 Mon Sep 17 00:00:00 2001 From: Sumin <709030+n1mus@users.noreply.github.com> Date: Tue, 1 Feb 2022 16:35:38 -0800 Subject: [PATCH 717/732] query testing & split for sorting --- .gitignore | 3 + Makefile | 10 +- dev-requirements.txt | 2 + scripts/run_tests.sh | 4 +- .../taxonomy/taxonomy_ncbi_species.yaml | 55 +++ .../taxonomy_ncbi_species_no_sort.yaml | 50 ++ spec/test/stored_queries/test_query.py | 436 ++++++++++++++++++ 7 files changed, 557 insertions(+), 3 deletions(-) create mode 100644 spec/stored_queries/taxonomy/taxonomy_ncbi_species.yaml create mode 100644 spec/stored_queries/taxonomy/taxonomy_ncbi_species_no_sort.yaml create mode 100644 spec/test/stored_queries/test_query.py diff --git a/.gitignore b/.gitignore index 59a9ce73..02727e6d 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,6 @@ coverage_report/ # Spec archives spec.tar.gz + +# Creds +arango_live_server_config.json diff --git a/Makefile b/Makefile index 86023d46..b67c0831 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,6 @@ -.PHONY: test reset +QUERY_TESTING_FILE = spec/test/stored_queries/test_query.py + +.PHONY: test reset full_query_testing sampling_query_testing test: docker-compose build @@ -13,3 +15,9 @@ shell: reset: docker-compose --rmi all -v docker-compose build + +full_query_testing: + DO_QUERY_TESTING=full time python -m pytest -s $(QUERY_TESTING_FILE) + +sampling_query_testing: + DO_QUERY_TESTING=sampling time python -m pytest -s $(QUERY_TESTING_FILE) diff --git a/dev-requirements.txt b/dev-requirements.txt index de91a89d..96007184 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -7,3 +7,5 @@ coverage==5.2.1 typed-ast>=1.4.0 black==20.8b1 pytest==6.2.5 +python-arango==5.4.0 +numpy==1.21.2 diff --git a/scripts/run_tests.sh b/scripts/run_tests.sh index 58bc1382..6dff8759 100644 --- a/scripts/run_tests.sh +++ b/scripts/run_tests.sh @@ -17,7 +17,7 @@ coverage erase # spec validation python -m spec.validate # run importer/, relation_engine_server/, and spec/ tests -coverage run --branch -m unittest discover -v +coverage run --branch -m pytest # RE client tests -PYTHONPATH=client_src python -m unittest discover client_src/test +PYTHONPATH=client_src python -m pytest client_src/test coverage html --omit=*/test_* diff --git a/spec/stored_queries/taxonomy/taxonomy_ncbi_species.yaml b/spec/stored_queries/taxonomy/taxonomy_ncbi_species.yaml new file mode 100644 index 00000000..655fa8f2 --- /dev/null +++ b/spec/stored_queries/taxonomy/taxonomy_ncbi_species.yaml @@ -0,0 +1,55 @@ +# Search ncbi_taxon collection for species/strains by scientific name +name: taxonomy_ncbi_species +params: + type: object + required: [search_text] + additionalProperties: false + properties: + search_text: + type: string + title: Search text + examples: [escherichia, es] + description: Text to search on the search attribute values + ts: + type: [integer, "null"] + title: Versioning timestamp + default: null + offset: + type: [integer, "null"] + title: Paging offset + maximum: 100000 + default: 0 + limit: + type: [integer, "null"] + title: Max results to return + default: 20 + maximum: 1000 + select: + type: [string, array, "null"] + items: + type: string + examples: [scientific_name, [scientific_name, id]] + default: null + description: Document attributes to keep in the results +query: | + LET search_text__norm = REGEX_REPLACE(LOWER(TRIM(@search_text)), "\\s+", " ") + LET search_text__first_exact_tok = REGEX_SPLIT(search_text__norm, " ")[0] + LET search_text__icu_toks = TOKENS(@search_text, "icu_tokenize") // analyzer + LET search_text__wordboundmod_icu_toks = ( + FOR tok IN search_text__icu_toks + RETURN REGEX_REPLACE(tok, ",.*", "") // commas cannot be escaped in fulltext search + ) + LET search_text__fulltext = CONCAT_SEPARATOR(", ", // comma delimit + FOR tok IN search_text__wordboundmod_icu_toks // prepend "prefix:" + RETURN CONCAT("prefix:", tok) + ) + FOR doc IN FULLTEXT(ncbi_taxon, "scientific_name", search_text__fulltext) + FILTER @ts ? doc.created <= @ts AND doc.expired >= @ts : true + FILTER doc.rank IN ["species", "strain"] OR doc.strain + LET doc_sciname__norm = REGEX_REPLACE(LOWER(TRIM(doc.scientific_name)), "\\s+", " ") // for exact matching + LET contains_ind = CONTAINS(doc_sciname__norm, search_text__norm, true) + SORT contains_ind == 0 DESC, // prefix match + doc_sciname__norm == search_text__norm DESC, // exact match + doc.scientific_name // lexical + LIMIT @offset ? @offset : 0, @limit ? @limit : 20 + RETURN @select ? KEEP(doc, @select) : doc diff --git a/spec/stored_queries/taxonomy/taxonomy_ncbi_species_no_sort.yaml b/spec/stored_queries/taxonomy/taxonomy_ncbi_species_no_sort.yaml new file mode 100644 index 00000000..21a3cbdf --- /dev/null +++ b/spec/stored_queries/taxonomy/taxonomy_ncbi_species_no_sort.yaml @@ -0,0 +1,50 @@ +# Search ncbi_taxon collection for species/strains by scientific name +# Except do not sort, just return the first however many documents +# Useful for short prefixes (e.g., "s") that would be expensive yet not meaningful to sort +name: taxonomy_ncbi_species_no_sort +params: + type: object + required: [search_text] + additionalProperties: false + properties: + search_text: + type: string + title: Search text + examples: [escherichia, es] + description: Text to search on the search attribute values + ts: + type: [integer, "null"] + title: Versioning timestamp + default: null + offset: + type: [integer, "null"] + title: Paging offset + maximum: 100000 + default: 0 + limit: + type: [integer, "null"] + title: Max results to return + default: 20 + maximum: 1000 + select: + type: [string, array, "null"] + items: + type: string + examples: [scientific_name, [scientific_name, id]] + default: null + description: Document attributes to keep in the results +query: | + LET search_text__icu_toks = TOKENS(@search_text, "icu_tokenize") // analyzer + LET search_text__wordboundmod_icu_toks = ( + FOR tok IN search_text__icu_toks + RETURN REGEX_REPLACE(tok, ",.*", "") // commas cannot be escaped in fulltext search + ) + LET search_text__fulltext = CONCAT_SEPARATOR(", ", // comma delimit + FOR tok IN search_text__wordboundmod_icu_toks // prepend "prefix:" + RETURN CONCAT("prefix:", tok) + ) + FOR doc IN FULLTEXT(ncbi_taxon, "scientific_name", search_text__fulltext) + FILTER @ts ? doc.created <= @ts AND doc.expired >= @ts : true + FILTER doc.rank IN ["species", "strain"] OR doc.strain + LIMIT @offset ? @offset : 0, @limit ? @limit : 20 + RETURN @select ? KEEP(doc, @select) : doc diff --git a/spec/test/stored_queries/test_query.py b/spec/test/stored_queries/test_query.py new file mode 100644 index 00000000..8179d0fd --- /dev/null +++ b/spec/test/stored_queries/test_query.py @@ -0,0 +1,436 @@ +import traceback as tb +import sys +import os +import json +import datetime +import time +import random +import textwrap +import warnings +import pytest +from typing import Tuple, List +from requests.exceptions import ReadTimeout + +from arango import ArangoClient +import numpy as np + +from relation_engine_server.utils import json_validation + +warnings.filterwarnings("ignore") + +# Directories and files +ROOT_DIR = os.getcwd() +CURR_DIR = os.path.join(ROOT_DIR, "spec/test/stored_queries") +CONFIG_FP = os.path.join(ROOT_DIR, "arango_live_server_config.json") +TEST_DATA_DIR = os.path.join(CURR_DIR, "../data") +TMP_OUT_DIR = os.path.join(ROOT_DIR, "tmp") +SCINAMES_LATEST_FP = os.path.join(TMP_OUT_DIR, "ncbi_scinames_latest.json") +SAMPLINGS_FP = os.path.join(TMP_OUT_DIR, "samplings.json") +STORED_QUERY_FP = os.path.join( + ROOT_DIR, "spec/stored_queries/taxonomy/taxonomy_ncbi_species.yaml" +) +STORED_QUERY_NO_SORT_FP = os.path.join( + ROOT_DIR, "spec/stored_queries/taxonomy/taxonomy_ncbi_species_no_sort.yaml" +) + +if not os.path.exists(TMP_OUT_DIR): + os.mkdir(TMP_OUT_DIR) + +try: + with open(CONFIG_FP) as fh: + CONFIG = json.load(fh) + if not CONFIG["host"] or not CONFIG["username"] or not CONFIG["password"]: + raise RuntimeError("Missing config fields") + CLIENT = ArangoClient(hosts=CONFIG["host"]) + DB = CLIENT.db("ci", username=CONFIG["username"], password=CONFIG["password"]) +except Exception as e: + help = """ +Please set host URL, username, and password in arango_live_server_config.json, e.g., +{ + "username": "doe_j", + "password": "cat-sat-hat", + "host": "http://10.58.1.211:8532" +} +Note: if you are on a local machine +you may have to proxy into the live ArangoDB server first, e.g., +`ssh -L 8532:10.58.1.211:8532 j_doe@login1.berkeley.kbase.us` +Then, the url would be `http://localhost:8532` +""" + print(help) + raise (e) +NCBI_TAXON = DB.collection("ncbi_taxon") + +# Load the queries +QUERY = json_validation.load_json_yaml(STORED_QUERY_FP)["query"] +QUERY_NO_SORT = json_validation.load_json_yaml(STORED_QUERY_NO_SORT_FP)["query"] + +LIMIT = 20 +NOW = time.time() * 1000 + +# Load/cache the scinames +if os.path.isfile(SCINAMES_LATEST_FP): + with open(SCINAMES_LATEST_FP) as fh: + SCINAMES_LATEST = json.load(fh) +else: + print("Fetching latest NCBI scinames ...") + try: + taxa_all = list(NCBI_TAXON.all()) + except ReadTimeout: + print("Sorry, there is a read timeout. Please try again on a different machine") + sys.exit() + SCINAMES_LATEST = [ + taxa["scientific_name"] + for taxa in taxa_all + if (taxa["rank"] in ["species", "strain"] or taxa["strain"]) + and taxa["created"] <= NOW + and NOW <= taxa["expired"] + ] + with open(SCINAMES_LATEST_FP, "w") as fh: + json.dump(SCINAMES_LATEST, fh) + + +def use_sort(search_text): + return len(search_text) > 3 + + +def is_simple(search_text): + """ + Somewhat arbitrary determination of whether a fulltext's search text is "simple" + relative to its search time + """ + return len(search_text.split()) == 2 and all( + [tok.isalnum() and len(tok) >= 3 for tok in search_text.split()] + ) + + +def jprint(jo, dry=False): + txt = json.dumps(jo, indent=3) + if dry: + return txt + else: + print(txt) + + +def fulltext_search_ncbi_scinames(search_text): + """""" + cursor = DB.aql.execute( + QUERY if use_sort(search_text) else QUERY_NO_SORT, + bind_vars={ + "search_text": search_text, + "ts": NOW, + "offset": None, + "limit": LIMIT, + "select": ["scientific_name"], + }, + ) + return { + "results": [e["scientific_name"] for e in list(cursor.batch())], + **cursor.statistics(), + } + + +def get_search_text_samplings( + resample=True, + cap_scinames=2000, + cap_scinames_prefixes=5000, +): + """ + Get samplings of scinames or prefixes thereof to gauge execution time + + Things to include: + * Simple genus/species epithets with two non-short words + * "Wild" scientific names, defined as the exclusion of the simple scientific names + * All prefixes of all the preceding, respectively, and deduplicated + * 36 alphanumeric characters + * Any edge cases? + """ + # Read if cached + if not resample and os.path.isfile(SAMPLINGS_FP): + with open(SAMPLINGS_FP) as fh: + samplings = json.load(fh) + return samplings + + print("Sampling search texts and prefixes thereof ...") + + seen_prefixes = set() + + def get_capped_samplings(styp: str) -> Tuple[list, list]: + """ + Randomly sample scinames + Then take all prefixes (not already seen in accumulated prefixes) + "Wild" just means the exclusion of "simple" + """ + if styp not in ["simple", "wild"]: + raise RuntimeError(f"Unknown sampling type {styp}") + print(f"Sampling {styp} scinames ...") + + sampling = [ + sciname + for sciname in SCINAMES_LATEST + if is_simple(sciname) == (styp == "simple") + ] + random.shuffle(sampling) + sampling = sampling[:cap_scinames] + sampling_prefixes = [ + sciname[:i] for sciname in sampling for i in range(1, len(sciname)) + ] + sampling_prefixes = [ + sciname + for sciname in sampling_prefixes + if sciname not in seen_prefixes + and not seen_prefixes.add( + sciname + ) # latter operand always evaluates to true + ] + return sampling, sampling_prefixes[:cap_scinames_prefixes] + + scinames_simple, scinames_simple_prefixes = get_capped_samplings("simple") + scinames_wild, scinames_wild_prefixes = get_capped_samplings("wild") + alphanum_chars = list("abcdefghijklmnopqrstuvwxyz0123456789") + edge_cases = [ + "~!@#$%^&*()_+hi", + "hi~!@#$%^&*()_+", + ] # would cause AQL issue: "", "~!@#$%^&*()_+", "[", + + # Aggregate + samplings = { + "scinames_simple": scinames_simple, + "scinames_wild": scinames_wild, + "scinames_simple_prefixes": scinames_simple_prefixes, + "scinames_wild_prefixes": scinames_wild_prefixes, + "alphanum_chars": alphanum_chars, + "edge_cases": edge_cases, + } + + # Manual peek to stdout + peek_len = 10 + print( + json.dumps( + { + styp: sampling[:peek_len] + + (["..."] if len(sampling) > peek_len else []) + for styp, sampling in samplings.items() + }, + indent=3, + ) + ) + + # Cache samplings + with open(SAMPLINGS_FP, "w") as fh: + json.dump(samplings, fh) + + return samplings + + +def handle_err(msg, dat, failed): + """ + During sampling/sciname/query loops, + if error arises, + log/record + """ + print(msg) + tb.print_exc() + jprint(dat) + failed.append(dat) + + +def update_print_timekeepers(i, t0, exe_times, sampling, failed): + """ + Calculate and print + * Running average time per iteration + * Running average time per query execition + * Running median time per query execution + + Precondition: t0, exe_times + """ + if i == 0: + tper_iter, tper_exe, tmed_exe, tmin_exe, tmax_exe = 0, 0, 0, 0, 0 + else: + tper_iter = (time.time() - t0) / i + tper_exe = np.mean(exe_times) + tmed_exe = np.median(exe_times) + tmin_exe = np.min(exe_times) + tmax_exe = np.max(exe_times) + print( + f"[{datetime.datetime.now().strftime('%b%d %H:%M').upper()}]", + "...", + f"{i}/{len(sampling)} search texts tested", + "...", + f"{'%.3fs' % tmin_exe} (min)", + "|", + f"{'%.3fs' % tper_exe} (mean)", + "|", + f"{'%.3fs' % tmed_exe} (median)", + "|", + f"{'%.3fs' % tmax_exe} (max) exe time", + "...", + f"{'%.3fs' % tper_iter} per round trip", + "...", + f"{'%d/%d' % (len(failed), i)} failed", + ) + + +################################################################################ +################################################################################ +def do_query_testing( + samplings: dict, + expect_hits: list = [ + "scinames_simple", + "scinames_wild", + "scinames_latest", + "scinames_latest_permute", + ], + update_period: int = 100, +): + """ + Test search texts, gather statistics, and check for hits + Periodically outputs accumulated mean and median execution times + """ + # Permute since the scinames tend to start out simpler + for styp, sampling in samplings.items(): + samplings[styp] = sampling[:] + random.shuffle(samplings[styp]) + + # Get some nice stats to print out + samplings_metadata = [ + {"styp": styp, "num": len(sampling)} for styp, sampling in samplings.items() + ] + total_num_queries = sum([len(sampling) for sampling in samplings.values()]) + + # Print some preliminary info + w = 120 + dec = "=" * w + prelude = textwrap.wrap( + "\n".join( + [ + f"samplings_num_queries={samplings_metadata},", + f"total_num_queries={total_num_queries},", + ] + ), + width=w, + ) + print("\n\n") + print(dec) + print(dec) + print(*prelude, sep="\n") + print(dec) + print(dec) + print() + + # Data structures accumulating all info + data_all = dict() # For all queries + failed_all = dict() # For failed queries + + try: + + for j, (styp, sampling) in enumerate(samplings.items()): + failed: List[dict] = [] + failed_all[styp] = failed + data: List[dict] = [] + data_all[styp] = data + + t0 = time.time() # Wall clock start time for this sampling + exe_times: List[float] = [] # Query execution times for this sampling + + print( + f"\nTesting with sampling_metadata={samplings_metadata[j]},", + f"sampling_assert_hit={styp in expect_hits},", + "...", + ) + print(dec) + + # Traverse all samples in sampling + for i, search_text in enumerate(sampling): + # Calculate and print running time stats + if not i % update_period: + update_print_timekeepers(i, t0, exe_times, sampling, failed) + + dat = { + "styp": styp, + "i": i, + "search_text": search_text, + } + data.append(dat) + + try: + query_res = fulltext_search_ncbi_scinames(search_text) + except Exception: + handle_err("Something went wrong in the query!", dat, failed) + + exe_times.append(query_res["execution_time"]) + dat.update(query_res) + + if styp in expect_hits: + try: + hits = query_res["results"] + # Given that limit=20, + # test that sciname is in top 20, + # and they aren't >20 duplicates. + # Raise to get traceback in stdout + if search_text not in hits or ( + len(hits) == LIMIT + and all([hit == search_text for hit in hits]) + ): + raise AssertionError( + "Target sciname not in results " + "or results are all duplicates" + ) + except AssertionError: + handle_err( + "Something went wrong in the expect hit assertion!", + dat, + failed, + ) + + # One last time after all of sampling has run + update_print_timekeepers(i + 1, t0, exe_times, sampling, failed) + + except Exception: + handle_err( + "Something went wrong in the samplings/scinames/query loops!", dat, failed + ) + + finally: + results_fp = os.path.join( + TMP_OUT_DIR, + ( + "res" + "__" + f"{datetime.datetime.now().strftime('%d%b%Y_%H:%M').upper()}" + "__" + f"{len(samplings)}_samplings" + "__" + f"{total_num_queries}_search_texts" + ".json" + ), + ) + data_meta = { + "samplings": list(samplings.keys()), + "expect_hits": expect_hits, + "total_num_queries": total_num_queries, + "sampling": styp, + "i": i, + "data_all": data_all, + "failed_all": failed_all, + } + print(f"\nWriting results/failures to {results_fp}") + with open(results_fp, "w") as fh: + json.dump(data_meta, fh, indent=3) + + return data_meta + + +@pytest.mark.skipif( + not os.environ.get("DO_QUERY_TESTING") == "full", + reason="This can take a couple days, and only needs to be ascertained once", +) +def test_all_ncbi_latest_scinames(): + do_query_testing({"scinames_latest": SCINAMES_LATEST}) + + +@pytest.mark.skipif( + not os.environ.get("DO_QUERY_TESTING") == "sampling", + reason="This can take a few hours, and only needs to be ascertained once", +) +def test_samplings(): + do_query_testing(get_search_text_samplings()) From dc288005dd2f45cde44f76ab2b43a53cee599c80 Mon Sep 17 00:00:00 2001 From: n1mus <709030+n1mus@users.noreply.github.com> Date: Tue, 22 Feb 2022 18:19:38 +0000 Subject: [PATCH 718/732] cleanup; ignore long test module --- scripts/run_tests.sh | 4 ++-- spec/test/stored_queries/test_query.py | 14 +++++--------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/scripts/run_tests.sh b/scripts/run_tests.sh index 6dff8759..d77bfe25 100644 --- a/scripts/run_tests.sh +++ b/scripts/run_tests.sh @@ -16,8 +16,8 @@ sh /app/scripts/start_server.sh & coverage erase # spec validation python -m spec.validate -# run importer/, relation_engine_server/, and spec/ tests -coverage run --branch -m pytest +# run importer/, relation_engine_server/, and spec/ tests, skip test_query.py +coverage run --branch -m pytest --ignore=spec/test/stored_queries/test_query.py # RE client tests PYTHONPATH=client_src python -m pytest client_src/test coverage html --omit=*/test_* diff --git a/spec/test/stored_queries/test_query.py b/spec/test/stored_queries/test_query.py index 8179d0fd..7fe06af6 100644 --- a/spec/test/stored_queries/test_query.py +++ b/spec/test/stored_queries/test_query.py @@ -204,15 +204,11 @@ def get_capped_samplings(styp: str) -> Tuple[list, list]: # Manual peek to stdout peek_len = 10 - print( - json.dumps( - { - styp: sampling[:peek_len] - + (["..."] if len(sampling) > peek_len else []) - for styp, sampling in samplings.items() - }, - indent=3, - ) + jprint( + { + styp: sampling[:peek_len] + (["..."] if len(sampling) > peek_len else []) + for styp, sampling in samplings.items() + } ) # Cache samplings From 79b954bc0822edba5d9b068f0017304cc0c05d21 Mon Sep 17 00:00:00 2001 From: n1mus <709030+n1mus@users.noreply.github.com> Date: Tue, 22 Feb 2022 19:22:15 +0000 Subject: [PATCH 719/732] fix itsdangerous package --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index 53c43343..98194623 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,5 @@ Flask==1.0.2 +itsdangerous==2.0.1 greenlet==0.4.16 gunicorn==19.9.0 gevent==1.3.7 From b4460f7a1e4f9d245941b7ba725d76c679570c02 Mon Sep 17 00:00:00 2001 From: n1mus <709030+n1mus@users.noreply.github.com> Date: Thu, 24 Feb 2022 00:37:44 +0000 Subject: [PATCH 720/732] don't restrict species search to ncbi --- scripts/run_tests.sh | 4 +- .../generic/fulltext_search.yaml | 2 + .../taxonomy/taxonomy_search_sci_name.yaml | 2 + .../taxonomy/taxonomy_search_species.yaml | 2 + ...ml => taxonomy_search_species_strain.yaml} | 14 +- ...xonomy_search_species_strain_no_sort.yaml} | 14 +- .../stored_queries/test_fulltext_search.py | 252 +++++++++++++++++- spec/test/stored_queries/test_query.py | 35 ++- 8 files changed, 293 insertions(+), 32 deletions(-) rename spec/stored_queries/taxonomy/{taxonomy_ncbi_species.yaml => taxonomy_search_species_strain.yaml} (83%) rename spec/stored_queries/taxonomy/{taxonomy_ncbi_species_no_sort.yaml => taxonomy_search_species_strain_no_sort.yaml} (80%) diff --git a/scripts/run_tests.sh b/scripts/run_tests.sh index d77bfe25..6dff8759 100644 --- a/scripts/run_tests.sh +++ b/scripts/run_tests.sh @@ -16,8 +16,8 @@ sh /app/scripts/start_server.sh & coverage erase # spec validation python -m spec.validate -# run importer/, relation_engine_server/, and spec/ tests, skip test_query.py -coverage run --branch -m pytest --ignore=spec/test/stored_queries/test_query.py +# run importer/, relation_engine_server/, and spec/ tests +coverage run --branch -m pytest # RE client tests PYTHONPATH=client_src python -m pytest client_src/test coverage html --omit=*/test_* diff --git a/spec/stored_queries/generic/fulltext_search.yaml b/spec/stored_queries/generic/fulltext_search.yaml index 42d637b3..b8a31b0a 100644 --- a/spec/stored_queries/generic/fulltext_search.yaml +++ b/spec/stored_queries/generic/fulltext_search.yaml @@ -1,4 +1,6 @@ # Search a collection with a fulltext index with an attribute name and search text +# Also supports filtering by outer-level attributes +# Not recommended for fast searching because it can be very slow and even timeout at 60s name: fulltext_search params: type: object diff --git a/spec/stored_queries/taxonomy/taxonomy_search_sci_name.yaml b/spec/stored_queries/taxonomy/taxonomy_search_sci_name.yaml index 0e43164c..8217fdf2 100644 --- a/spec/stored_queries/taxonomy/taxonomy_search_sci_name.yaml +++ b/spec/stored_queries/taxonomy/taxonomy_search_sci_name.yaml @@ -1,3 +1,5 @@ +# Should be REVISED then DEPRECATED +# # Search for a taxon with a scientific name # Offset is limited to 10k name: taxonomy_search_sci_name diff --git a/spec/stored_queries/taxonomy/taxonomy_search_species.yaml b/spec/stored_queries/taxonomy/taxonomy_search_species.yaml index fe7eebd0..0e5fbb82 100644 --- a/spec/stored_queries/taxonomy/taxonomy_search_species.yaml +++ b/spec/stored_queries/taxonomy/taxonomy_search_species.yaml @@ -1,3 +1,5 @@ +# DEPRECATED. See taxonomy_search_species_strains and taxonomy_search_species_strains_no_sort +# # Search for a species/strain. Similar to search_sci_name, but simpler and quicker name: taxonomy_search_species params: diff --git a/spec/stored_queries/taxonomy/taxonomy_ncbi_species.yaml b/spec/stored_queries/taxonomy/taxonomy_search_species_strain.yaml similarity index 83% rename from spec/stored_queries/taxonomy/taxonomy_ncbi_species.yaml rename to spec/stored_queries/taxonomy/taxonomy_search_species_strain.yaml index 655fa8f2..6ad6ee75 100644 --- a/spec/stored_queries/taxonomy/taxonomy_ncbi_species.yaml +++ b/spec/stored_queries/taxonomy/taxonomy_search_species_strain.yaml @@ -1,15 +1,23 @@ # Search ncbi_taxon collection for species/strains by scientific name -name: taxonomy_ncbi_species +name: taxonomy_search_species_strain params: type: object - required: [search_text] + required: ["@taxon_coll", sciname_field, search_text] additionalProperties: false properties: + "@taxon_coll": + type: string + title: Taxon collection name + examples: [ncbi_taxon, gtdb_taxon] search_text: type: string title: Search text examples: [escherichia, es] description: Text to search on the search attribute values + sciname_field: + type: string + title: Scientific name field name + examples: [scientific_name, name] ts: type: [integer, "null"] title: Versioning timestamp @@ -43,7 +51,7 @@ query: | FOR tok IN search_text__wordboundmod_icu_toks // prepend "prefix:" RETURN CONCAT("prefix:", tok) ) - FOR doc IN FULLTEXT(ncbi_taxon, "scientific_name", search_text__fulltext) + FOR doc IN FULLTEXT(@@taxon_coll, @sciname_field, search_text__fulltext) FILTER @ts ? doc.created <= @ts AND doc.expired >= @ts : true FILTER doc.rank IN ["species", "strain"] OR doc.strain LET doc_sciname__norm = REGEX_REPLACE(LOWER(TRIM(doc.scientific_name)), "\\s+", " ") // for exact matching diff --git a/spec/stored_queries/taxonomy/taxonomy_ncbi_species_no_sort.yaml b/spec/stored_queries/taxonomy/taxonomy_search_species_strain_no_sort.yaml similarity index 80% rename from spec/stored_queries/taxonomy/taxonomy_ncbi_species_no_sort.yaml rename to spec/stored_queries/taxonomy/taxonomy_search_species_strain_no_sort.yaml index 21a3cbdf..b9c0a56c 100644 --- a/spec/stored_queries/taxonomy/taxonomy_ncbi_species_no_sort.yaml +++ b/spec/stored_queries/taxonomy/taxonomy_search_species_strain_no_sort.yaml @@ -1,12 +1,20 @@ # Search ncbi_taxon collection for species/strains by scientific name # Except do not sort, just return the first however many documents # Useful for short prefixes (e.g., "s") that would be expensive yet not meaningful to sort -name: taxonomy_ncbi_species_no_sort +name: taxonomy_search_species_strain_no_sort params: type: object - required: [search_text] + required: ["@taxon_coll", sciname_field, search_text] additionalProperties: false properties: + "@taxon_coll": + type: string + title: Taxon collection name + examples: [ncbi_taxon, gtdb_taxon] + sciname_field: + type: string + title: Scientific name field name + examples: [scientific_name, name] search_text: type: string title: Search text @@ -43,7 +51,7 @@ query: | FOR tok IN search_text__wordboundmod_icu_toks // prepend "prefix:" RETURN CONCAT("prefix:", tok) ) - FOR doc IN FULLTEXT(ncbi_taxon, "scientific_name", search_text__fulltext) + FOR doc IN FULLTEXT(@@taxon_coll, @sciname_field, search_text__fulltext) FILTER @ts ? doc.created <= @ts AND doc.expired >= @ts : true FILTER doc.rank IN ["species", "strain"] OR doc.strain LIMIT @offset ? @offset : 0, @limit ? @limit : 20 diff --git a/spec/test/stored_queries/test_fulltext_search.py b/spec/test/stored_queries/test_fulltext_search.py index 0ff13fc6..e0340d02 100644 --- a/spec/test/stored_queries/test_fulltext_search.py +++ b/spec/test/stored_queries/test_fulltext_search.py @@ -1,5 +1,12 @@ """ -Tests for the generic fulltext search +Tests for stored queries involving a fulltext search: +* Generic fulltext_search (should be used with caution because it can be slow and timeout at 60s) +* Taxonomy taxonomy_search_species_strain +* Taxonomy taxonomy_search_species_strain_no_sort + +The latter two are switched between depending on the length of the search text. +These stored query tests are all bundled in one test file because their original purpose is to do a species/strain +name search on the ncbi_taxon collection These tests run within the re_api docker image, and require access to the ArangoDB, auth, and workspace images. """ @@ -80,7 +87,149 @@ ] -class Test(unittest.TestCase): +class TestTaxonomySearchSpeciesStrainStoredQueries(unittest.TestCase): + @classmethod + def setUpClass(cls): + check_spec_test_env() + create_test_docs("ncbi_taxon", ncbi_taxa) + + def test_ncbi_taxon_scinames(self): + """Happy path""" + for sciname in scinames_test_all: + _taxonomy_search_species_strain_queries( + self, + taxon_coll="ncbi_taxon", + sciname_field="scientific_name", + search_text=sciname, + ts=_NOW if sciname in scinames_test_latest else None, + offset=None, + limit=LIMIT, + select="scientific_name", + # --- + expect_error=False, + expect_hit=True, + ) + + def test_null_bind_params(self): + """Leave off parameters""" + for sciname in scinames_test_all: + _taxonomy_search_species_strain_queries( + self, + taxon_coll="ncbi_taxon", + sciname_field="scientific_name", + search_text=sciname, + ts=None, + offset=None, + limit=None, + select=None, + # --- + expect_error=False, + expect_hit=True, + ) + + def test_fully_specified_bind_params(self): + """Specify all parameters""" + for sciname in scinames_test_all: + _taxonomy_search_species_strain_queries( + self, + taxon_coll="ncbi_taxon", + sciname_field="scientific_name", + search_text=sciname, + ts=_NOW if sciname in scinames_test_latest else None, + offset=0, + limit=LIMIT, + select=["id", "scientific_name"], + # --- + expect_error=False, + expect_hit=True, + ) + + def test_extra_params(self): + """Extra params not in spec/aql""" + _taxonomy_search_species_strain_queries( + self, + taxon_coll="ncbi_taxon", + sciname_field="scientific_name", + search_text="esch", + ts=None, + offset=0, + limit=LIMIT, + select=["id", "scientific_name"], + extra_unused_param=42, + # --- + expect_error=("Additional properties are not allowed"), + ) + + def test_validation_fail(self): + _taxonomy_search_species_strain_queries( + self, + taxon_coll=[], + sciname_field=42, + search_text={"hi": 1}, + ts=None, + offset=None, + limit=None, + select=None, + # --- + expect_error="[] is not of type 'string'", + ) + + def test_aql_error(self): + for sciname in scinames_test_all: + _taxonomy_search_species_strain_queries( + self, + taxon_coll="ncbi_taxon", + sciname_field="fake_attrkey", + search_text=sciname, + ts=None, + offset=None, + limit=None, + select=None, + # --- + expect_error=True, + ) + + def test_no_hit(self): + for sciname in scinames_test_all: + _taxonomy_search_species_strain_queries( + self, + taxon_coll="ncbi_taxon", + sciname_field="scientific_name", + search_text=sciname[::-1], + ts=None, + offset=None, + limit=None, + select=None, + # --- + expect_error=False, + expect_hit=False, + expected_hits=[], + ) + + def test_prefix_hit(self): + """Test search text len being lte 3""" + _taxonomy_search_species_strain_queries( + self, + taxon_coll="ncbi_taxon", + sciname_field="scientific_name", + search_text="inf", + ts=None, + offset=None, + limit=None, + select=None, + # --- + expect_error=False, + expect_hit=False, + expected_hits=[ + "Influenza A virus PX8-XIII(A/USSR/90/77(H1N1)xA/Pintail Duck/Primorie/695/76(H2N3))", + "Influenza C virus (C/PIG/Beijing/439/1982)", + "Influenza B virus (B/Ann Arbor/1/1966 [cold-adapted and wild- type])", + "Influenza B virus (B/Brisbane/FSS700/2017)", + ], + ) + + +class TestFulltextSearchStoredQuery(unittest.TestCase): @classmethod def setUpClass(cls): check_spec_test_env() @@ -89,7 +238,7 @@ def setUpClass(cls): def test_ncbi_taxon_scinames(self): """Happy path""" for sciname in scinames_test_all: - _fulltext_query( + _fulltext_search_query( self, coll="ncbi_taxon", search_attrkey="scientific_name", @@ -111,7 +260,7 @@ def test_ncbi_taxon_scinames(self): def test_null_bind_params(self): """Leave off parameters""" for sciname in scinames_test_all: - _fulltext_query( + _fulltext_search_query( self, coll="ncbi_taxon", search_attrkey="scientific_name", @@ -129,7 +278,7 @@ def test_null_bind_params(self): def test_fully_specified_bind_params(self): """Specify all parameters""" for sciname in scinames_test_all: - _fulltext_query( + _fulltext_search_query( self, coll="ncbi_taxon", search_attrkey="scientific_name", @@ -150,7 +299,7 @@ def test_fully_specified_bind_params(self): def test_extra_params(self): """Extra params not in spec/aql""" - _fulltext_query( + _fulltext_search_query( self, coll="ncbi_taxon", search_attrkey="scientific_name", @@ -170,7 +319,7 @@ def test_extra_params(self): ) def test_validation_fail(self): - _fulltext_query( + _fulltext_search_query( self, coll=[], search_attrkey=42, @@ -186,7 +335,7 @@ def test_validation_fail(self): def test_aql_error(self): for sciname in scinames_test_all: - _fulltext_query( + _fulltext_search_query( self, coll="ncbi_taxon", search_attrkey="fake_attrkey", @@ -202,7 +351,7 @@ def test_aql_error(self): def test_no_hit(self): for sciname in scinames_test_all: - _fulltext_query( + _fulltext_search_query( self, coll="ncbi_taxon", search_attrkey="scientific_name", @@ -222,7 +371,56 @@ def test_no_hit(self): # --- Test helpers --- -def _fulltext_query( +def _switch_taxonomy_search_species_strain_queries(search_text): + return ( + "taxonomy_search_species_strain_no_sort" + if len(search_text) <= 3 + else "taxonomy_search_species_strain" + ) + + +def _taxonomy_search_species_strain_queries( + self, + taxon_coll, + sciname_field, + search_text, + ts, + offset, + limit, + select, + expect_error=False, + expect_hit=True, + expected_hits=None, + **kw, # for testing passing disallowed properties +): + """ + Run query against ArangoDB server + """ + data = { + "@taxon_coll": taxon_coll, + "sciname_field": sciname_field, + "search_text": search_text, + "ts": ts, + "offset": offset, + "limit": limit, + "select": select, + **kw, + } + stored_query = _switch_taxonomy_search_species_strain_queries(search_text) + _check_query_results( + self, + data, + stored_query, + sciname_field, + search_text, + limit, + expect_error, + expect_hit, + expected_hits, + ) + + +def _fulltext_search_query( self, coll, search_attrkey, @@ -251,9 +449,34 @@ def _fulltext_query( "select": select, **kw, } + stored_query = "fulltext_search" + _check_query_results( + self, + data, + stored_query, + search_attrkey, + search_text, + limit, + expect_error, + expect_hit, + expected_hits, + ) + + +def _check_query_results( + self, + data, + stored_query, + search_attrkey, + search_text, + limit, + expect_error, + expect_hit, + expected_hits, +): resp = requests.post( _CONF["re_api_url"] + "/api/v1/query_results", - params={"stored_query": "fulltext_search"}, + params={"stored_query": stored_query}, data=json.dumps(data), ) @@ -276,13 +499,14 @@ def _fulltext_query( self.assertNotIn(search_text, hits) if expected_hits is not None: - self.assertEqual(expected_hits, hits) + self.assertCountEqual(expected_hits, hits) # Filter out null values + # to see if their default null values would kick in properly data = {k: v for k, v in data.items() if v is not None} resp = requests.post( _CONF["re_api_url"] + "/api/v1/query_results", - params={"stored_query": "fulltext_search"}, + params={"stored_query": stored_query}, data=json.dumps(data), ) @@ -305,4 +529,4 @@ def _fulltext_query( self.assertNotIn(search_text, hits) if expected_hits is not None: - self.assertEqual(expected_hits, hits) + self.assertCountEqual(expected_hits, hits) diff --git a/spec/test/stored_queries/test_query.py b/spec/test/stored_queries/test_query.py index 7fe06af6..cf0dbe49 100644 --- a/spec/test/stored_queries/test_query.py +++ b/spec/test/stored_queries/test_query.py @@ -10,12 +10,19 @@ import pytest from typing import Tuple, List from requests.exceptions import ReadTimeout +import unittest from arango import ArangoClient import numpy as np from relation_engine_server.utils import json_validation +# Skip entire module if env var not set +if not os.environ.get("DO_QUERY_TESTING"): + raise unittest.SkipTest( + "Env var DO_QUERY_TESTING not set. Skipping query testing module" + ) + warnings.filterwarnings("ignore") # Directories and files @@ -27,24 +34,23 @@ SCINAMES_LATEST_FP = os.path.join(TMP_OUT_DIR, "ncbi_scinames_latest.json") SAMPLINGS_FP = os.path.join(TMP_OUT_DIR, "samplings.json") STORED_QUERY_FP = os.path.join( - ROOT_DIR, "spec/stored_queries/taxonomy/taxonomy_ncbi_species.yaml" + ROOT_DIR, "spec/stored_queries/taxonomy/taxonomy_search_species_strain.yaml" ) STORED_QUERY_NO_SORT_FP = os.path.join( - ROOT_DIR, "spec/stored_queries/taxonomy/taxonomy_ncbi_species_no_sort.yaml" + ROOT_DIR, "spec/stored_queries/taxonomy/taxonomy_search_species_strain_no_sort.yaml" ) if not os.path.exists(TMP_OUT_DIR): os.mkdir(TMP_OUT_DIR) +# Read config try: with open(CONFIG_FP) as fh: CONFIG = json.load(fh) - if not CONFIG["host"] or not CONFIG["username"] or not CONFIG["password"]: - raise RuntimeError("Missing config fields") CLIENT = ArangoClient(hosts=CONFIG["host"]) DB = CLIENT.db("ci", username=CONFIG["username"], password=CONFIG["password"]) except Exception as e: - help = """ + help_msg = """ Please set host URL, username, and password in arango_live_server_config.json, e.g., { "username": "doe_j", @@ -56,18 +62,23 @@ `ssh -L 8532:10.58.1.211:8532 j_doe@login1.berkeley.kbase.us` Then, the url would be `http://localhost:8532` """ - print(help) - raise (e) + print(help_msg) + raise + +# Get pointer to collection NCBI_TAXON = DB.collection("ncbi_taxon") # Load the queries QUERY = json_validation.load_json_yaml(STORED_QUERY_FP)["query"] QUERY_NO_SORT = json_validation.load_json_yaml(STORED_QUERY_NO_SORT_FP)["query"] +# Set query bind parameters LIMIT = 20 NOW = time.time() * 1000 # Load/cache the scinames +# This probably won't work well and will need some fiddling/improvement +# because doing it this way can lead to a timeout on some machine setups if os.path.isfile(SCINAMES_LATEST_FP): with open(SCINAMES_LATEST_FP) as fh: SCINAMES_LATEST = json.load(fh) @@ -85,11 +96,13 @@ and taxa["created"] <= NOW and NOW <= taxa["expired"] ] + # Cache latest scinames with open(SCINAMES_LATEST_FP, "w") as fh: json.dump(SCINAMES_LATEST, fh) def use_sort(search_text): + """Determine whether to use the sorting or non-sorting query""" return len(search_text) > 3 @@ -111,11 +124,13 @@ def jprint(jo, dry=False): print(txt) -def fulltext_search_ncbi_scinames(search_text): - """""" +def taxonomy_search_species_strain(search_text): + """Make the query""" cursor = DB.aql.execute( QUERY if use_sort(search_text) else QUERY_NO_SORT, bind_vars={ + "@taxon_coll": "ncbi_taxon", + "sciname_field": "scientific_name", "search_text": search_text, "ts": NOW, "offset": None, @@ -349,7 +364,7 @@ def do_query_testing( data.append(dat) try: - query_res = fulltext_search_ncbi_scinames(search_text) + query_res = taxonomy_search_species_strain(search_text) except Exception: handle_err("Something went wrong in the query!", dat, failed) From a0a8372e62d3642201a3441746875a4d46ff4960 Mon Sep 17 00:00:00 2001 From: n1mus <709030+n1mus@users.noreply.github.com> Date: Wed, 2 Mar 2022 10:57:04 -0800 Subject: [PATCH 721/732] prep release and DATAUP-706-doc-startup --- CHANGELOG.md | 4 ++++ README.md | 8 ++++++++ VERSION | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 54d762c0..151b6d57 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 +##[0.0.18] - 2022-03-02 +### Added +- taxonomy_search_species_strain and taxonomy_search_species_strain_no_sort stored queries + ## [0.0.17] - 2022-01-25 ### Added - Ensure local specs match server specs diff --git a/README.md b/README.md index 3a26d0e7..85a97cb8 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,14 @@ These specifications are used by the [Relation Engine API](relation_engine_serve The relation engine server (`relation_engine_server/`) is a simple API that allows KBase community developers to interact with the Relation Engine graph database. You can run stored queries or do bulk updates on documents. +## Relation Engine Startup +* Docker image is built with environment variable `SPEC_RELEASE_PATH=/opt/spec.tar.gz'. This contains the specs from the repo itself. +* Wait for response from auth, workspace, and arangodb services, as they are set up +* Specs are set up. Either the repo specs or remote specs are loaded into the specs root path +* Collections, views, and analyzers from the specs are added to the ArangoDB server. If the collection, view, or analyzer already exists, but in a different configuration, it will _not_ be overwritten. +* Collections, views, and analyzers from the loaded specs are compared to those on the ArangoDB server. If the loaded specs' attributes are not recursively a subset of the server specs, then an exception is raise. (This is just preliminary validation behavior.) + + ## Relation Engine builds The Relation Engine is available on github packages. These images are built by the configs in the .github repo. diff --git a/VERSION b/VERSION index cd231804..32786aa4 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.0.17 +0.0.18 From 6ae669d53524ab7850740cc2083f603f84f82130 Mon Sep 17 00:00:00 2001 From: n1mus <709030+n1mus@users.noreply.github.com> Date: Thu, 3 Mar 2022 15:46:00 -0800 Subject: [PATCH 722/732] compare stored query exe times with violin plots --- Makefile | 11 +- spec/test/stored_queries/test_query.py | 230 ++++++++++++++++++------- 2 files changed, 180 insertions(+), 61 deletions(-) diff --git a/Makefile b/Makefile index b67c0831..e4d49ecd 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ QUERY_TESTING_FILE = spec/test/stored_queries/test_query.py -.PHONY: test reset full_query_testing sampling_query_testing +.PHONY: test reset full_query_testing sampling_query_testing graph_query_testing test: docker-compose build @@ -21,3 +21,12 @@ full_query_testing: sampling_query_testing: DO_QUERY_TESTING=sampling time python -m pytest -s $(QUERY_TESTING_FILE) + +compare_query_testing: + DO_QUERY_TESTING=compare time python -m pytest -s $(QUERY_TESTING_FILE) + +graph_query_testing: + # invocation example: + # make graph_query_testing data_new_fp="tmp/blah.json" data_old_fp="tmp/bleh.json" + # where `data_new_fp` and `data_old_fp` are generated by `make compare_query_testing` + DO_QUERY_TESTING=graph python $(QUERY_TESTING_FILE) $(data_new_fp) $(data_old_fp) diff --git a/spec/test/stored_queries/test_query.py b/spec/test/stored_queries/test_query.py index cf0dbe49..a391c072 100644 --- a/spec/test/stored_queries/test_query.py +++ b/spec/test/stored_queries/test_query.py @@ -14,6 +14,9 @@ from arango import ArangoClient import numpy as np +import pandas as pd +import seaborn as sns +import matplotlib.pyplot as plt from relation_engine_server.utils import json_validation @@ -39,6 +42,9 @@ STORED_QUERY_NO_SORT_FP = os.path.join( ROOT_DIR, "spec/stored_queries/taxonomy/taxonomy_search_species_strain_no_sort.yaml" ) +STORED_QUERY_OLD_FP = os.path.join( + ROOT_DIR, "spec/stored_queries/taxonomy/taxonomy_search_species.yaml" +) if not os.path.exists(TMP_OUT_DIR): os.mkdir(TMP_OUT_DIR) @@ -49,7 +55,7 @@ CONFIG = json.load(fh) CLIENT = ArangoClient(hosts=CONFIG["host"]) DB = CLIENT.db("ci", username=CONFIG["username"], password=CONFIG["password"]) -except Exception as e: +except Exception: help_msg = """ Please set host URL, username, and password in arango_live_server_config.json, e.g., { @@ -71,6 +77,7 @@ # Load the queries QUERY = json_validation.load_json_yaml(STORED_QUERY_FP)["query"] QUERY_NO_SORT = json_validation.load_json_yaml(STORED_QUERY_NO_SORT_FP)["query"] +QUERY_OLD = json_validation.load_json_yaml(STORED_QUERY_OLD_FP)["query"] # Set query bind parameters LIMIT = 20 @@ -124,8 +131,27 @@ def jprint(jo, dry=False): print(txt) -def taxonomy_search_species_strain(search_text): - """Make the query""" +def do_taxonomy_search_species_query(search_text): + cursor = DB.aql.execute( + QUERY_OLD, + bind_vars={ + "@taxon_coll": "ncbi_taxon", + "sciname_field": "scientific_name", + "search_text": search_text, + "ts": NOW, + "offset": None, + "limit": LIMIT, + "select": ["scientific_name"], + }, + ) + return { + "results": [e["scientific_name"] for e in list(cursor.batch())], + **cursor.statistics(), + } + + +def do_taxonomy_search_species_strain_query(search_text): + """Do the query""" cursor = DB.aql.execute( QUERY if use_sort(search_text) else QUERY_NO_SORT, bind_vars={ @@ -146,8 +172,8 @@ def taxonomy_search_species_strain(search_text): def get_search_text_samplings( resample=True, - cap_scinames=2000, - cap_scinames_prefixes=5000, + cap_scinames=1000, + cap_scinames_prefixes=1000, ): """ Get samplings of scinames or prefixes thereof to gauge execution time @@ -165,11 +191,9 @@ def get_search_text_samplings( samplings = json.load(fh) return samplings - print("Sampling search texts and prefixes thereof ...") - - seen_prefixes = set() + print("\nSampling search texts and prefixes thereof ...") - def get_capped_samplings(styp: str) -> Tuple[list, list]: + def get_capped_samplings(styp: str, uniq_prefixes=True) -> Tuple[list, list]: """ Randomly sample scinames Then take all prefixes (not already seen in accumulated prefixes) @@ -185,18 +209,21 @@ def get_capped_samplings(styp: str) -> Tuple[list, list]: if is_simple(sciname) == (styp == "simple") ] random.shuffle(sampling) - sampling = sampling[:cap_scinames] + sampling = sampling[:cap_scinames] # cap this first to avoid generating overabundant prefixes sampling_prefixes = [ sciname[:i] for sciname in sampling for i in range(1, len(sciname)) ] - sampling_prefixes = [ - sciname - for sciname in sampling_prefixes - if sciname not in seen_prefixes - and not seen_prefixes.add( + if uniq_prefixes: + seen_prefixes = set() + sampling_prefixes = [ sciname - ) # latter operand always evaluates to true - ] + for sciname in sampling_prefixes + if sciname not in seen_prefixes + and not seen_prefixes.add( + sciname + ) # latter operand always evaluates to true + ] + random.shuffle(sampling_prefixes) return sampling, sampling_prefixes[:cap_scinames_prefixes] scinames_simple, scinames_simple_prefixes = get_capped_samplings("simple") @@ -233,7 +260,7 @@ def get_capped_samplings(styp: str) -> Tuple[list, list]: return samplings -def handle_err(msg, dat, failed): +def handle_err(msg, dat): """ During sampling/sciname/query loops, if error arises, @@ -241,11 +268,11 @@ def handle_err(msg, dat, failed): """ print(msg) tb.print_exc() + dat["failed"] = True jprint(dat) - failed.append(dat) -def update_print_timekeepers(i, t0, exe_times, sampling, failed): +def update_print_timekeepers(i, t0, exe_times, sampling, num_failed): """ Calculate and print * Running average time per iteration @@ -277,14 +304,15 @@ def update_print_timekeepers(i, t0, exe_times, sampling, failed): "...", f"{'%.3fs' % tper_iter} per round trip", "...", - f"{'%d/%d' % (len(failed), i)} failed", + f"{'%d/%d' % (num_failed, i)} failed", ) -################################################################################ -################################################################################ +######################################################################################################################## +######################################################################################################################## def do_query_testing( samplings: dict, + do_query_func=do_taxonomy_search_species_strain_query, expect_hits: list = [ "scinames_simple", "scinames_wild", @@ -312,11 +340,10 @@ def do_query_testing( w = 120 dec = "=" * w prelude = textwrap.wrap( - "\n".join( - [ - f"samplings_num_queries={samplings_metadata},", - f"total_num_queries={total_num_queries},", - ] + ( + f"do_query_func={do_query_func.__name__}, " + f"samplings_num_queries={samplings_metadata}, " + f"total_num_queries={total_num_queries}, " ), width=w, ) @@ -330,13 +357,11 @@ def do_query_testing( # Data structures accumulating all info data_all = dict() # For all queries - failed_all = dict() # For failed queries try: for j, (styp, sampling) in enumerate(samplings.items()): - failed: List[dict] = [] - failed_all[styp] = failed + num_failed: int = 0 data: List[dict] = [] data_all[styp] = data @@ -354,51 +379,44 @@ def do_query_testing( for i, search_text in enumerate(sampling): # Calculate and print running time stats if not i % update_period: - update_print_timekeepers(i, t0, exe_times, sampling, failed) + update_print_timekeepers(i, t0, exe_times, sampling, num_failed) dat = { - "styp": styp, "i": i, "search_text": search_text, + "failed": False, } data.append(dat) try: - query_res = taxonomy_search_species_strain(search_text) + query_res = do_query_func(search_text) except Exception: - handle_err("Something went wrong in the query!", dat, failed) + handle_err("Something went wrong in the query!", dat) exe_times.append(query_res["execution_time"]) dat.update(query_res) if styp in expect_hits: - try: - hits = query_res["results"] - # Given that limit=20, - # test that sciname is in top 20, - # and they aren't >20 duplicates. - # Raise to get traceback in stdout - if search_text not in hits or ( - len(hits) == LIMIT - and all([hit == search_text for hit in hits]) - ): - raise AssertionError( - "Target sciname not in results " - "or results are all duplicates" - ) - except AssertionError: + hits = query_res["results"] + # Given that limit=20, + # test that sciname is in top 20, + # and they aren't >20 duplicates. + # Raise to get traceback in stdout + if search_text not in hits or ( + len(hits) == LIMIT and all([hit == search_text for hit in hits]) + ): + num_failed += 1 handle_err( "Something went wrong in the expect hit assertion!", dat, - failed, ) # One last time after all of sampling has run - update_print_timekeepers(i + 1, t0, exe_times, sampling, failed) + update_print_timekeepers(i + 1, t0, exe_times, sampling, num_failed) except Exception: handle_err( - "Something went wrong in the samplings/scinames/query loops!", dat, failed + "Something went wrong in the samplings/scinames/query loops!", dat ) finally: @@ -409,6 +427,8 @@ def do_query_testing( "__" f"{datetime.datetime.now().strftime('%d%b%Y_%H:%M').upper()}" "__" + f"{do_query_func.__name__}" + "__" f"{len(samplings)}_samplings" "__" f"{total_num_queries}_search_texts" @@ -416,24 +436,28 @@ def do_query_testing( ), ) data_meta = { + "do_query_func": do_query_func.__name__, "samplings": list(samplings.keys()), "expect_hits": expect_hits, "total_num_queries": total_num_queries, - "sampling": styp, - "i": i, + "_sampling": styp, # where it may have + "_i": i, # stopped at "data_all": data_all, - "failed_all": failed_all, } - print(f"\nWriting results/failures to {results_fp}") + print(dec) + print(f"\nWriting results to {results_fp}") + print(dec) with open(results_fp, "w") as fh: json.dump(data_meta, fh, indent=3) return data_meta +######################################################################################################################## +######################################################################################################################## @pytest.mark.skipif( not os.environ.get("DO_QUERY_TESTING") == "full", - reason="This can take a couple days, and only needs to be ascertained once", + reason="This can take a couple days, and only needs to be ascertained sporadically", ) def test_all_ncbi_latest_scinames(): do_query_testing({"scinames_latest": SCINAMES_LATEST}) @@ -441,7 +465,93 @@ def test_all_ncbi_latest_scinames(): @pytest.mark.skipif( not os.environ.get("DO_QUERY_TESTING") == "sampling", - reason="This can take a few hours, and only needs to be ascertained once", + reason="This can take an hour or so, and only needs to be ascertained sporadically", ) def test_samplings(): - do_query_testing(get_search_text_samplings()) + do_query_testing( + samplings=get_search_text_samplings(resample=True), + do_query_func=do_taxonomy_search_species_strain_query, + ) + + +@pytest.mark.skipif( + not os.environ.get("DO_QUERY_TESTING") == "compare", + reason="This can take an hour or so, and only needs to be ascertained sporadically", +) +def test_compare_queries(): + do_query_testing( + samplings=get_search_text_samplings(resample=True), + do_query_func=do_taxonomy_search_species_strain_query, + ) + do_query_testing( + samplings=get_search_text_samplings(resample=False), + do_query_func=do_taxonomy_search_species_query, + ) + + +def do_graph(data_new_fp, data_old_fp): + """ + { + "data_all": { + "styp0": [ + { + "i": int, # index in sampling + "search_text": str, + "failed": bool, + "results": [ # resulting scinames + ... + ], + "execution_time": float, # s + ... + } + ], + "styp1": [ + ... + ], + ... + }, + ... + } + """ + with open(data_new_fp) as fh: + data_new = json.load(fh)["data_all"] + with open(data_old_fp) as fh: + data_old = json.load(fh)["data_all"] + + for (styp0, data0), (styp1, data1) in zip(data_new.items(), data_old.items()): + assert styp0 == styp1 + assert len(data0) == len(data1) + + df_data = [] + df_columns = ["exe_time_ms", "stored_query", "styp", "failed"] + for sq, data_epoch in zip(["new", "old"], [data_new, data_old]): + for styp, data in data_epoch.items(): + for dat in data: + df_row = [ + int(dat["execution_time"] * 1000), + sq, + styp, + dat["failed"], + ] + df_data.append(df_row) + + df = pd.DataFrame(df_data, columns=df_columns) + + g = sns.catplot( + x="stored_query", + y="exe_time_ms", + # hue="failed", + # scale="count", + # scale_hue=False, + col="styp", + data=df, + kind="violin", + # split=True, + aspect=0.7, + ) + + plt.show() + + +if __name__ == "__main__": + do_graph(sys.argv[1], sys.argv[2]) From 8087b8a811713a301531895c90f46d31d355d3a5 Mon Sep 17 00:00:00 2001 From: n1mus <709030+n1mus@users.noreply.github.com> Date: Fri, 11 Mar 2022 16:54:41 -0800 Subject: [PATCH 723/732] split plots by old query failing/having results --- dev-requirements.txt | 2 - spec/test/stored_queries/test_query.py | 210 +++++++++++++++++-------- 2 files changed, 142 insertions(+), 70 deletions(-) diff --git a/dev-requirements.txt b/dev-requirements.txt index 96007184..de91a89d 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -7,5 +7,3 @@ coverage==5.2.1 typed-ast>=1.4.0 black==20.8b1 pytest==6.2.5 -python-arango==5.4.0 -numpy==1.21.2 diff --git a/spec/test/stored_queries/test_query.py b/spec/test/stored_queries/test_query.py index a391c072..c9fb973c 100644 --- a/spec/test/stored_queries/test_query.py +++ b/spec/test/stored_queries/test_query.py @@ -1,31 +1,40 @@ -import traceback as tb -import sys +""" +This script can be run from `make` +Essentially it was created to run stored queries against the ncbi_taxon collection +and collect data and stats. +""" + import os -import json -import datetime -import time -import random -import textwrap -import warnings -import pytest -from typing import Tuple, List -from requests.exceptions import ReadTimeout import unittest -from arango import ArangoClient -import numpy as np -import pandas as pd -import seaborn as sns -import matplotlib.pyplot as plt - -from relation_engine_server.utils import json_validation - # Skip entire module if env var not set +# to avoid non-Docker-container imports or otherwise +# specific/costly operations in script if not os.environ.get("DO_QUERY_TESTING"): raise unittest.SkipTest( "Env var DO_QUERY_TESTING not set. Skipping query testing module" ) +import traceback as tb # noqa E402 +import sys # noqa E402 +import json # noqa E402 +import datetime # noqa E402 +import time # noqa E402 +import random # noqa E402 +import textwrap # noqa E402 +import warnings # noqa E402 +import pytest # noqa E402 +from typing import Tuple, List # noqa E402 +from requests.exceptions import ReadTimeout # noqa E402 + +from arango import ArangoClient # noqa E402 +import numpy as np # noqa E402 +import pandas as pd # noqa E402 +import seaborn as sns # noqa E402 +import matplotlib.pyplot as plt # noqa E402 + +from relation_engine_server.utils import json_validation # noqa E402 + warnings.filterwarnings("ignore") # Directories and files @@ -109,7 +118,10 @@ def use_sort(search_text): - """Determine whether to use the sorting or non-sorting query""" + """ + Determine whether to use the sorting or non-sorting stored query for the new query. + Smaller search texts' results will not be sorted on. + """ return len(search_text) > 3 @@ -132,12 +144,13 @@ def jprint(jo, dry=False): def do_taxonomy_search_species_query(search_text): + """Do the old query""" cursor = DB.aql.execute( QUERY_OLD, bind_vars={ "@taxon_coll": "ncbi_taxon", "sciname_field": "scientific_name", - "search_text": search_text, + "search_text": "prefix:" + search_text, # how the old query was set up "ts": NOW, "offset": None, "limit": LIMIT, @@ -151,7 +164,7 @@ def do_taxonomy_search_species_query(search_text): def do_taxonomy_search_species_strain_query(search_text): - """Do the query""" + """Do the new query""" cursor = DB.aql.execute( QUERY if use_sort(search_text) else QUERY_NO_SORT, bind_vars={ @@ -193,10 +206,10 @@ def get_search_text_samplings( print("\nSampling search texts and prefixes thereof ...") - def get_capped_samplings(styp: str, uniq_prefixes=True) -> Tuple[list, list]: + def get_capped_samplings(styp: str) -> Tuple[list, list]: """ Randomly sample scinames - Then take all prefixes (not already seen in accumulated prefixes) + Then take all prefixes, deduplicated "Wild" just means the exclusion of "simple" """ if styp not in ["simple", "wild"]: @@ -209,22 +222,17 @@ def get_capped_samplings(styp: str, uniq_prefixes=True) -> Tuple[list, list]: if is_simple(sciname) == (styp == "simple") ] random.shuffle(sampling) - sampling = sampling[:cap_scinames] # cap this first to avoid generating overabundant prefixes - sampling_prefixes = [ - sciname[:i] for sciname in sampling for i in range(1, len(sciname)) - ] - if uniq_prefixes: - seen_prefixes = set() - sampling_prefixes = [ - sciname - for sciname in sampling_prefixes - if sciname not in seen_prefixes - and not seen_prefixes.add( - sciname - ) # latter operand always evaluates to true - ] + sampling = sampling[ + :cap_scinames + ] # cap this first to avoid generating overabundant prefixes + + sampling_prefixes = list( + set([sciname[:i] for sciname in sampling for i in range(1, len(sciname))]) + ) random.shuffle(sampling_prefixes) - return sampling, sampling_prefixes[:cap_scinames_prefixes] + sampling_prefixes = sampling_prefixes[:cap_scinames_prefixes] + + return sampling, sampling_prefixes scinames_simple, scinames_simple_prefixes = get_capped_samplings("simple") scinames_wild, scinames_wild_prefixes = get_capped_samplings("wild") @@ -260,7 +268,7 @@ def get_capped_samplings(styp: str, uniq_prefixes=True) -> Tuple[list, list]: return samplings -def handle_err(msg, dat): +def handle_err(msg, dat=None): """ During sampling/sciname/query loops, if error arises, @@ -268,8 +276,9 @@ def handle_err(msg, dat): """ print(msg) tb.print_exc() - dat["failed"] = True - jprint(dat) + if dat: + dat["failed"] = True + jprint(dat) def update_print_timekeepers(i, t0, exe_times, sampling, num_failed): @@ -285,10 +294,10 @@ def update_print_timekeepers(i, t0, exe_times, sampling, num_failed): tper_iter, tper_exe, tmed_exe, tmin_exe, tmax_exe = 0, 0, 0, 0, 0 else: tper_iter = (time.time() - t0) / i - tper_exe = np.mean(exe_times) - tmed_exe = np.median(exe_times) - tmin_exe = np.min(exe_times) - tmax_exe = np.max(exe_times) + tper_exe = np.nanmean(exe_times) + tmed_exe = np.nanmedian(exe_times) + tmin_exe = np.nanmin(exe_times) + tmax_exe = np.nanmax(exe_times) print( f"[{datetime.datetime.now().strftime('%b%d %H:%M').upper()}]", "...", @@ -319,6 +328,7 @@ def do_query_testing( "scinames_latest", "scinames_latest_permute", ], + permute: bool = True, update_period: int = 100, ): """ @@ -326,9 +336,10 @@ def do_query_testing( Periodically outputs accumulated mean and median execution times """ # Permute since the scinames tend to start out simpler - for styp, sampling in samplings.items(): - samplings[styp] = sampling[:] - random.shuffle(samplings[styp]) + if permute: + for styp, sampling in samplings.items(): + samplings[styp] = sampling[:] + random.shuffle(samplings[styp]) # Get some nice stats to print out samplings_metadata = [ @@ -392,19 +403,30 @@ def do_query_testing( query_res = do_query_func(search_text) except Exception: handle_err("Something went wrong in the query!", dat) + query_res = { + "execution_time": np.nan, + "results": [], + } exe_times.append(query_res["execution_time"]) dat.update(query_res) + # Set `has_results` + dat["has_results"] = len(query_res["results"]) > 0 + # Set `failed` if styp in expect_hits: hits = query_res["results"] # Given that limit=20, # test that sciname is in top 20, # and they aren't >20 duplicates. # Raise to get traceback in stdout - if search_text not in hits or ( - len(hits) == LIMIT and all([hit == search_text for hit in hits]) - ): + try: + assert search_text in hits + assert not ( + len(hits) == LIMIT + and all([hit == search_text for hit in hits]) + ) + except AssertionError: num_failed += 1 handle_err( "Something went wrong in the expect hit assertion!", @@ -415,9 +437,7 @@ def do_query_testing( update_print_timekeepers(i + 1, t0, exe_times, sampling, num_failed) except Exception: - handle_err( - "Something went wrong in the samplings/scinames/query loops!", dat - ) + handle_err("Something went wrong in the samplings/scinames/query loops!") finally: results_fp = os.path.join( @@ -440,8 +460,8 @@ def do_query_testing( "samplings": list(samplings.keys()), "expect_hits": expect_hits, "total_num_queries": total_num_queries, - "_sampling": styp, # where it may have - "_i": i, # stopped at + "_sampling": styp, # where it may have + "_i": i, # stopped at "data_all": data_all, } print(dec) @@ -480,12 +500,16 @@ def test_samplings(): ) def test_compare_queries(): do_query_testing( - samplings=get_search_text_samplings(resample=True), + samplings=get_search_text_samplings( + resample=True, cap_scinames=500, cap_scinames_prefixes=500 + ), do_query_func=do_taxonomy_search_species_strain_query, + permute=False, ) do_query_testing( samplings=get_search_text_samplings(resample=False), do_query_func=do_taxonomy_search_species_query, + permute=False, ) @@ -503,7 +527,8 @@ def do_graph(data_new_fp, data_old_fp): ], "execution_time": float, # s ... - } + }, + ... ], "styp1": [ ... @@ -518,36 +543,85 @@ def do_graph(data_new_fp, data_old_fp): with open(data_old_fp) as fh: data_old = json.load(fh)["data_all"] + # Not meaningful/large enough to make the figure + if "edge_cases" in data_new: + del data_new["edge_cases"] + if "edge_cases" in data_old: + del data_old["edge_cases"] + + # Count num queries where the old stored query `has_results`/`failed` + old_failed_counts = { + styp: ( + len([1 for dat in data if not dat["failed"]]), + len([1 for dat in data if dat["failed"]]), + ) + for styp, data in data_old.items() + } + old_has_results_counts = { + styp: ( + len([1 for dat in data if not dat["results"]]), + len([1 for dat in data if dat["results"]]), + ) + for styp, data in data_old.items() + } + + # Sanity checks + # Should have same ordering in `styp` and `search_text` for (styp0, data0), (styp1, data1) in zip(data_new.items(), data_old.items()): assert styp0 == styp1 assert len(data0) == len(data1) + for dat0, dat1 in zip(data0, data1): + assert dat0["search_text"] == dat1["search_text"] + assert not np.isnan(dat0["execution_time"]) + assert not np.isnan(dat1["execution_time"]) + # old_has_results and old_failed counts should add up + for counts in [old_failed_counts, old_has_results_counts]: + for styp, count in counts.items(): + assert sum(count) == len(data_old[styp]) df_data = [] - df_columns = ["exe_time_ms", "stored_query", "styp", "failed"] + df_columns = [ + "exe_time_ms", + "stored_query", + "sampling", + "failed", + "has_results", + "old_failed", + "old_has_results", + ] for sq, data_epoch in zip(["new", "old"], [data_new, data_old]): for styp, data in data_epoch.items(): - for dat in data: + for i, dat in enumerate(data): + # Toggle the literal strings here in tandem with + # toggling the `hue` below df_row = [ int(dat["execution_time"] * 1000), sq, - styp, + f"{styp}\nn = {len(data)} ({old_failed_counts[styp][0]}/{old_failed_counts[styp][1]})", + # f"{styp}\nn = {len(data)} ({old_has_results_counts[styp][0]}/{old_has_results_counts[styp][1]})", dat["failed"], + dat["has_results"], + data_old[styp][i]["failed"], + data_old[styp][i]["has_results"], ] df_data.append(df_row) df = pd.DataFrame(df_data, columns=df_columns) - g = sns.catplot( + sns.catplot( x="stored_query", y="exe_time_ms", - # hue="failed", - # scale="count", - # scale_hue=False, - col="styp", + hue="old_failed", # Toggle the `hue` here in tandem with + # hue="old_has_results", # toggling the literal strings n `df_row` above + scale="area", + scale_hue=False, + col="sampling", data=df, kind="violin", - # split=True, + split=True, + cut=0, aspect=0.7, + bw=0.2, ) plt.show() From 2cd48f00e9acf4bb29c3161cbd1ca4431cf338d9 Mon Sep 17 00:00:00 2001 From: n1mus <709030+n1mus@users.noreply.github.com> Date: Thu, 17 Mar 2022 21:22:50 +0000 Subject: [PATCH 724/732] ignore asserts in test file --- spec/test/stored_queries/test_query.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/spec/test/stored_queries/test_query.py b/spec/test/stored_queries/test_query.py index c9fb973c..e76d19f5 100644 --- a/spec/test/stored_queries/test_query.py +++ b/spec/test/stored_queries/test_query.py @@ -421,8 +421,8 @@ def do_query_testing( # and they aren't >20 duplicates. # Raise to get traceback in stdout try: - assert search_text in hits - assert not ( + assert search_text in hits # nosec B101 + assert not ( # nosec B101 len(hits) == LIMIT and all([hit == search_text for hit in hits]) ) @@ -568,16 +568,16 @@ def do_graph(data_new_fp, data_old_fp): # Sanity checks # Should have same ordering in `styp` and `search_text` for (styp0, data0), (styp1, data1) in zip(data_new.items(), data_old.items()): - assert styp0 == styp1 - assert len(data0) == len(data1) + assert styp0 == styp1 # nosec B101 + assert len(data0) == len(data1) # nosec B101 for dat0, dat1 in zip(data0, data1): - assert dat0["search_text"] == dat1["search_text"] - assert not np.isnan(dat0["execution_time"]) - assert not np.isnan(dat1["execution_time"]) + assert dat0["search_text"] == dat1["search_text"] # nosec B101 + assert not np.isnan(dat0["execution_time"]) # nosec B101 + assert not np.isnan(dat1["execution_time"]) # nosec B101 # old_has_results and old_failed counts should add up for counts in [old_failed_counts, old_has_results_counts]: for styp, count in counts.items(): - assert sum(count) == len(data_old[styp]) + assert sum(count) == len(data_old[styp]) # nosec B101 df_data = [] df_columns = [ From dd520a1909974d7d8579ece0866f19b2f4749fa9 Mon Sep 17 00:00:00 2001 From: n1mus <709030+n1mus@users.noreply.github.com> Date: Thu, 17 Mar 2022 23:18:09 +0000 Subject: [PATCH 725/732] special char fulltext tests --- spec/test/data/ncbi_taxon.json | 144 ++++++++++++++++++ .../stored_queries/test_fulltext_search.py | 9 ++ 2 files changed, 153 insertions(+) diff --git a/spec/test/data/ncbi_taxon.json b/spec/test/data/ncbi_taxon.json index 9a4092f8..e16451d6 100644 --- a/spec/test/data/ncbi_taxon.json +++ b/spec/test/data/ncbi_taxon.json @@ -2260,5 +2260,149 @@ "expired": 1612915015846, "release_created": 1541030400000, "release_expired": 1612137599999 + }, + { + "_key": "338794_2018-11-01", + "_id": "ncbi_taxon/338794_2018-11-01", + "_rev": "_b2jbO4G--D", + "id": "338794", + "scientific_name": "low G+C Gram-positive bacterium HTA462", + "rank": "species", + "strain": false, + "aliases": [], + "ncbi_taxon_id": 338794, + "gencode": 11, + "first_version": "2018-11-01", + "last_version": "2021-02-01", + "created": 1541030460000, + "expired": 9007199254740991, + "release_created": 1541030400000, + "release_expired": 9007199254740991 + }, + { + "_key": "586732_2018-11-01", + "_id": "ncbi_taxon/586732_2018-11-01", + "_rev": "_b2kB1gK--B", + "id": "586732", + "scientific_name": "Integrating expression vector pJEB403+drrA", + "rank": "species", + "strain": false, + "aliases": [], + "ncbi_taxon_id": 586732, + "gencode": 11, + "first_version": "2018-11-01", + "last_version": "2021-02-01", + "created": 1541030460000, + "expired": 9007199254740991, + "release_created": 1541030400000, + "release_expired": 9007199254740991 + }, + { + "_key": "1127597_2018-11-01", + "_id": "ncbi_taxon/1127597_2018-11-01", + "_rev": "_b2lFmce--B", + "id": "1127597", + "scientific_name": "Fusarium cf. solani 3+4-uuu DPGS-2011", + "rank": "species", + "strain": false, + "aliases": [], + "ncbi_taxon_id": 1127597, + "gencode": 1, + "first_version": "2018-11-01", + "last_version": "2021-02-01", + "created": 1541030460000, + "expired": 9007199254740991, + "release_created": 1541030400000, + "release_expired": 9007199254740991 + }, + { + "_key": "1173779_2018-11-01", + "_id": "ncbi_taxon/1173779_2018-11-01", + "_rev": "_b2lOxFa--_", + "id": "1173779", + "scientific_name": "Salmonella enterica subsp. diarizonae serovar 60:r:e,n,x,z15", + "rank": "no rank", + "strain": true, + "aliases": [], + "ncbi_taxon_id": 1173779, + "gencode": 11, + "first_version": "2018-11-01", + "last_version": "2021-02-01", + "created": 1541030460000, + "expired": 9007199254740991, + "release_created": 1541030400000, + "release_expired": 9007199254740991 + }, + { + "_key": "1906029_2018-11-01", + "_id": "ncbi_taxon/1906029_2018-11-01", + "_rev": "_b2nDL5---_", + "id": "1906029", + "scientific_name": "Nostoc sp. 'Peltigera sp. \"hawaiensis\" P1236 cyanobiont'", + "rank": "species", + "strain": false, + "aliases": [], + "ncbi_taxon_id": 1906029, + "gencode": 11, + "first_version": "2018-11-01", + "last_version": "2021-02-01", + "created": 1541030460000, + "expired": 9007199254740991, + "release_created": 1541030400000, + "release_expired": 9007199254740991 + }, + { + "_key": "1945188_2018-11-01", + "_id": "ncbi_taxon/1945188_2018-11-01", + "_rev": "_b2nJbF2--_", + "id": "1945188", + "scientific_name": "Reporter vector p1168hIL6mC/EBP-luc+", + "rank": "species", + "strain": false, + "aliases": [], + "ncbi_taxon_id": 1945188, + "gencode": 11, + "first_version": "2018-11-01", + "last_version": "2021-02-01", + "created": 1541030460000, + "expired": 9007199254740991, + "release_created": 1541030400000, + "release_expired": 9007199254740991 + }, + { + "_key": "1945295_2018-11-01", + "_id": "ncbi_taxon/1945295_2018-11-01", + "_rev": "_b2nJbIK--_", + "id": "1945295", + "scientific_name": "Vector pEntry-attR2-IRES-eGFP-luc+-pA-attL3", + "rank": "species", + "strain": false, + "aliases": [], + "ncbi_taxon_id": 1945295, + "gencode": 11, + "first_version": "2018-11-01", + "last_version": "2021-02-01", + "created": 1541030460000, + "expired": 9007199254740991, + "release_created": 1541030400000, + "release_expired": 9007199254740991 + }, + { + "_key": "2727889_2021-02-01", + "_id": "ncbi_taxon/2727889_2021-02-01", + "_rev": "_b2n6us---A", + "id": "2727889", + "scientific_name": "Pleurocapsales cyanobacterium 'Beach rock 4+5\"'", + "rank": "species", + "strain": false, + "aliases": [], + "ncbi_taxon_id": 2727889, + "gencode": 11, + "first_version": "2021-02-01", + "last_version": "2021-02-01", + "created": 1612915015847, + "expired": 9007199254740991, + "release_created": 1612137600000, + "release_expired": 9007199254740991 } ] diff --git a/spec/test/stored_queries/test_fulltext_search.py b/spec/test/stored_queries/test_fulltext_search.py index e0340d02..4cc9536a 100644 --- a/spec/test/stored_queries/test_fulltext_search.py +++ b/spec/test/stored_queries/test_fulltext_search.py @@ -55,6 +55,15 @@ "Vaccinia virus WR 65-16", "Dengue virus 2 Jamaica/1409/1983", "Dengue virus 2 Thailand/NGS-C/1944", + # --- Escape chars (,:+-|"') --- + "Salmonella enterica subsp. diarizonae serovar 60:r:e,n,x,z15", + "Fusarium cf. solani 3+4-uuu DPGS-2011", + "Integrating expression vector pJEB403+drrA", + "Vector pEntry-attR2-IRES-eGFP-luc+-pA-attL3", + "low G+C Gram-positive bacterium HTA462", + "Reporter vector p1168hIL6mC/EBP-luc+", + "Pleurocapsales cyanobacterium 'Beach rock 4+5\"'", + "Nostoc sp. 'Peltigera sp. \"hawaiensis\" P1236 cyanobiont'", # --- Dups (techinically only applicable to live data) --- "environmental samples", "Listeria sp. FSL_L7-0091", From 5d4feb8d04b160970165a3326645ec23851906cb Mon Sep 17 00:00:00 2001 From: n1mus <709030+n1mus@users.noreply.github.com> Date: Fri, 18 Mar 2022 01:36:05 +0000 Subject: [PATCH 726/732] test fake sciname with pipe (|) --- README.md | 2 +- spec/test/data/ncbi_taxon.json | 18 ++++++++++++++++++ .../stored_queries/test_fulltext_search.py | 15 ++++++++++++++- 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 85a97cb8..fa850c76 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ These specifications are used by the [Relation Engine API](relation_engine_serve The relation engine server (`relation_engine_server/`) is a simple API that allows KBase community developers to interact with the Relation Engine graph database. You can run stored queries or do bulk updates on documents. ## Relation Engine Startup -* Docker image is built with environment variable `SPEC_RELEASE_PATH=/opt/spec.tar.gz'. This contains the specs from the repo itself. +* Docker image is built with environment variable `SPEC_RELEASE_PATH=/opt/spec.tar.gz`. This contains the specs from the repo itself. * Wait for response from auth, workspace, and arangodb services, as they are set up * Specs are set up. Either the repo specs or remote specs are loaded into the specs root path * Collections, views, and analyzers from the specs are added to the ArangoDB server. If the collection, view, or analyzer already exists, but in a different configuration, it will _not_ be overwritten. diff --git a/spec/test/data/ncbi_taxon.json b/spec/test/data/ncbi_taxon.json index e16451d6..31866edb 100644 --- a/spec/test/data/ncbi_taxon.json +++ b/spec/test/data/ncbi_taxon.json @@ -2404,5 +2404,23 @@ "expired": 9007199254740991, "release_created": 1612137600000, "release_expired": 9007199254740991 + }, + { + "_key": "fake_2021-02-01", + "_id": "ncbi_taxon/fake_2021-02-01", + "_rev": "fake", + "id": "fake", + "scientific_name": "|Fake|fake|fake| ||fake||", + "rank": "species", + "strain": false, + "aliases": [], + "ncbi_taxon_id": -1, + "gencode": 11, + "first_version": "2021-02-01", + "last_version": "2021-02-01", + "created": 1612915015847, + "expired": 9007199254740991, + "release_created": 1612137600000, + "release_expired": 9007199254740991 } ] diff --git a/spec/test/stored_queries/test_fulltext_search.py b/spec/test/stored_queries/test_fulltext_search.py index 4cc9536a..86dc0d02 100644 --- a/spec/test/stored_queries/test_fulltext_search.py +++ b/spec/test/stored_queries/test_fulltext_search.py @@ -35,6 +35,7 @@ ncbi_taxa = json.load(fh) # scinames_test_all are all the test scinames +# These are selected from the ncbi_taxon collection scinames_test_all = [ # --- Token preceded by punctuation --- "Lactobacillus sp. 'thermophilus'", @@ -56,6 +57,7 @@ "Dengue virus 2 Jamaica/1409/1983", "Dengue virus 2 Thailand/NGS-C/1944", # --- Escape chars (,:+-|"') --- + # --- TODO sample scinames with the escape chars in different variety of syntaxes --- "Salmonella enterica subsp. diarizonae serovar 60:r:e,n,x,z15", "Fusarium cf. solani 3+4-uuu DPGS-2011", "Integrating expression vector pJEB403+drrA", @@ -64,6 +66,7 @@ "Reporter vector p1168hIL6mC/EBP-luc+", "Pleurocapsales cyanobacterium 'Beach rock 4+5\"'", "Nostoc sp. 'Peltigera sp. \"hawaiensis\" P1236 cyanobiont'", + "|Fake|fake|fake| ||fake||", # --- Dups (techinically only applicable to live data) --- "environmental samples", "Listeria sp. FSL_L7-0091", @@ -73,7 +76,8 @@ "Corticiaceae sp.", "Escherichia coli", ] -# scinames_test_latest are the test scinames that are compatible with a current timestamp +# scinames_test_latest are the test scinames that are not expired and +# compatible with a current timestamp scinames_test_latest = [ "Lactobacillus sp. 'thermophilus'", "Rabbit fibroma virus (strain Kasza)", @@ -88,6 +92,15 @@ "Vaccinia virus WR 65-16", "Dengue virus 2 Jamaica/1409/1983", "Dengue virus 2 Thailand/NGS-C/1944", + "Salmonella enterica subsp. diarizonae serovar 60:r:e,n,x,z15", + "Fusarium cf. solani 3+4-uuu DPGS-2011", + "Integrating expression vector pJEB403+drrA", + "Vector pEntry-attR2-IRES-eGFP-luc+-pA-attL3", + "low G+C Gram-positive bacterium HTA462", + "Reporter vector p1168hIL6mC/EBP-luc+", + "Pleurocapsales cyanobacterium 'Beach rock 4+5\"'", + "Nostoc sp. 'Peltigera sp. \"hawaiensis\" P1236 cyanobiont'", + "|Fake|fake|fake| ||fake||", "environmental samples", "Listeria sp. FSL_L7-0091", "Listeria sp. FSL_L7-1519", From b6ac528f9f917e7acfea0ed84f91ae96552824d2 Mon Sep 17 00:00:00 2001 From: n1mus <709030+n1mus@users.noreply.github.com> Date: Fri, 18 Mar 2022 01:38:40 +0000 Subject: [PATCH 727/732] doc generic fulltext search as problematic --- spec/stored_queries/generic/fulltext_search.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spec/stored_queries/generic/fulltext_search.yaml b/spec/stored_queries/generic/fulltext_search.yaml index b8a31b0a..6859add4 100644 --- a/spec/stored_queries/generic/fulltext_search.yaml +++ b/spec/stored_queries/generic/fulltext_search.yaml @@ -1,3 +1,6 @@ +# Should be REVISED or DEPRECATED. +# Is currently unused outside testing. +# # Search a collection with a fulltext index with an attribute name and search text # Also supports filtering by outer-level attributes # Not recommended for fast searching because it can be very slow and even timeout at 60s From fd93db42a7e97b4c7a620559338711f5abb129b6 Mon Sep 17 00:00:00 2001 From: n1mus <709030+n1mus@users.noreply.github.com> Date: Mon, 21 Mar 2022 20:53:43 +0000 Subject: [PATCH 728/732] correct docs --- spec/test/stored_queries/test_fulltext_search.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/test/stored_queries/test_fulltext_search.py b/spec/test/stored_queries/test_fulltext_search.py index 86dc0d02..99bd4d44 100644 --- a/spec/test/stored_queries/test_fulltext_search.py +++ b/spec/test/stored_queries/test_fulltext_search.py @@ -56,7 +56,7 @@ "Vaccinia virus WR 65-16", "Dengue virus 2 Jamaica/1409/1983", "Dengue virus 2 Thailand/NGS-C/1944", - # --- Escape chars (,:+-|"') --- + # --- Escape chars ( ,:+-|"' ) --- # --- TODO sample scinames with the escape chars in different variety of syntaxes --- "Salmonella enterica subsp. diarizonae serovar 60:r:e,n,x,z15", "Fusarium cf. solani 3+4-uuu DPGS-2011", @@ -67,7 +67,7 @@ "Pleurocapsales cyanobacterium 'Beach rock 4+5\"'", "Nostoc sp. 'Peltigera sp. \"hawaiensis\" P1236 cyanobiont'", "|Fake|fake|fake| ||fake||", - # --- Dups (techinically only applicable to live data) --- + # --- Dups (technically only applicable to live data) --- "environmental samples", "Listeria sp. FSL_L7-0091", "Listeria sp. FSL_L7-1519", From 32cda69423e45d07072a060a70b33684daaa5848 Mon Sep 17 00:00:00 2001 From: bio-boris Date: Wed, 23 Mar 2022 23:01:26 -0500 Subject: [PATCH 729/732] DEVOPS-755 GHA (#104) DEVOPS-755 Add Github Actions For Release --- .github/workflows/build_prodrc_pr.yaml | 7 ++-- .github/workflows/prod_release.yaml | 38 ++++++++++++++++++++ .github/workflows/scripts/build_prodrc_pr.sh | 1 + .github/workflows/scripts/build_test_pr.sh | 2 +- .github/workflows/scripts/prod_release.sh | 24 +++++++++++++ .github/workflows/scripts/tag_prod_latest.sh | 4 +-- 6 files changed, 71 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/prod_release.yaml create mode 100755 .github/workflows/scripts/prod_release.sh diff --git a/.github/workflows/build_prodrc_pr.yaml b/.github/workflows/build_prodrc_pr.yaml index 58a911fa..2e5034e7 100644 --- a/.github/workflows/build_prodrc_pr.yaml +++ b/.github/workflows/build_prodrc_pr.yaml @@ -13,13 +13,16 @@ jobs: docker_build: runs-on: ubuntu-latest steps: + - name: Verify merge is develop -> main + if: github.head_ref != 'develop' + run: echo "Must merge from develop -> main/master"; exit 1 - name: Check out GitHub Repo - if: github.event.pull_request.draft == false + if: github.event.pull_request.draft == false && github.head_ref == 'develop' with: ref: "${{ github.event.pull_request.head.sha }}" uses: actions/checkout@v2 - name: Build and Push to Packages - if: github.event.pull_request.draft == false + if: github.event.pull_request.draft == false && github.head_ref == 'develop' env: PR: "${{ github.event.pull_request.number }}" SHA: "${{ github.event.pull_request.head.sha }}" diff --git a/.github/workflows/prod_release.yaml b/.github/workflows/prod_release.yaml new file mode 100644 index 00000000..ffa14533 --- /dev/null +++ b/.github/workflows/prod_release.yaml @@ -0,0 +1,38 @@ +--- +name: Publish Release Image +'on': + release: + branches: + - main + - master + types: + - published +jobs: + docker_build: + runs-on: ubuntu-latest + steps: + - name: Check Tag + id: check-tag + run: |- + if [[ ${{ github.ref_name }} =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo ::set-output name=match::true + fi + - name: Report SemVer Check + if: steps.check-tag.outputs.match != 'true' + run: echo "Release version must follow semantic naming (e.g. 1.0.2)"; exit 1 + - name: Check Source Branch + if: github.event.release.target_commitish != 'master' && github.event.release.target_commitish != 'main' + run: echo "Releases must be built from master/main branch"; exit 1 + - name: Check out GitHub Repo + with: + ref: "${{ github.event.pull_request.head.sha }}" + uses: actions/checkout@v2 + - name: Build and Push to Packages + env: + ISH: "${{ github.event.release.target_commitish }}" + PR: "${{ github.event.pull_request.number }}" + SHA: "${{ github.event.pull_request.head.sha }}" + VER: "${{ github.event.release.tag_name }}" + DOCKER_ACTOR: "${{ secrets.GHCR_USERNAME }}" + DOCKER_TOKEN: "${{ secrets.GHCR_TOKEN }}" + run: "./.github/workflows/scripts/prod_release.sh\n" diff --git a/.github/workflows/scripts/build_prodrc_pr.sh b/.github/workflows/scripts/build_prodrc_pr.sh index d888fc9d..4c7bdf27 100755 --- a/.github/workflows/scripts/build_prodrc_pr.sh +++ b/.github/workflows/scripts/build_prodrc_pr.sh @@ -6,6 +6,7 @@ export DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ") export BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ") export COMMIT=$(echo "$SHA" | cut -c -7) +echo "Branch is:" ${GITHUB_HEAD_REF} docker login -u "$DOCKER_ACTOR" -p "$DOCKER_TOKEN" ghcr.io docker build --build-arg BUILD_DATE="$DATE" \ --build-arg COMMIT="$COMMIT" \ diff --git a/.github/workflows/scripts/build_test_pr.sh b/.github/workflows/scripts/build_test_pr.sh index 4fee0681..546b1b42 100755 --- a/.github/workflows/scripts/build_test_pr.sh +++ b/.github/workflows/scripts/build_test_pr.sh @@ -14,4 +14,4 @@ docker build --build-arg BUILD_DATE="$DATE" \ --label us.kbase.vcs-pull-req="$PR" \ -t ghcr.io/"$MY_ORG"/"$MY_APP":"pr-""$PR" . docker push ghcr.io/"$MY_ORG"/"$MY_APP":"pr-""$PR" - + \ No newline at end of file diff --git a/.github/workflows/scripts/prod_release.sh b/.github/workflows/scripts/prod_release.sh new file mode 100755 index 00000000..46d008c6 --- /dev/null +++ b/.github/workflows/scripts/prod_release.sh @@ -0,0 +1,24 @@ +#! /usr/bin/env bash + +export MY_ORG=$(echo "${GITHUB_REPOSITORY}" | awk -F / '{print $1}') +export MY_APP=$(echo "${GITHUB_REPOSITORY}" | awk -F / '{print $2}') +export DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ") +export BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ") +export COMMIT=$(echo "$SHA" | cut -c -7) + +echo "ISH is:" $ISH +echo "GITHUB_REF is:" $GITHUB_REF +echo "HEAD_REF is:" $GITHUB_HEAD_REF +echo "BASE_REF is:" $GITHUB_BASE_REF +echo "Release is:" $GITHUB_REF_NAME +echo $DOCKER_TOKEN | docker login ghcr.io -u $DOCKER_ACTOR --password-stdin +docker build --build-arg BUILD_DATE="$DATE" \ + --build-arg COMMIT="$COMMIT" \ + --build-arg BRANCH="$GITHUB_HEAD_REF" \ + --build-arg PULL_REQUEST="$PR" \ + --build-arg VERSION="$VER" \ + --label us.kbase.vcs-pull-req="$PR" \ + -t ghcr.io/"$MY_ORG"/"$MY_APP":"$VER" \ + -t ghcr.io/"$MY_ORG"/"$MY_APP":"latest" . +docker push ghcr.io/"$MY_ORG"/"$MY_APP":"$VER" +docker push ghcr.io/"$MY_ORG"/"$MY_APP":"latest" diff --git a/.github/workflows/scripts/tag_prod_latest.sh b/.github/workflows/scripts/tag_prod_latest.sh index 1390fd16..c3c42252 100755 --- a/.github/workflows/scripts/tag_prod_latest.sh +++ b/.github/workflows/scripts/tag_prod_latest.sh @@ -8,5 +8,5 @@ export COMMIT=$(echo "$SHA" | cut -c -7) docker login -u "$DOCKER_ACTOR" -p "$DOCKER_TOKEN" ghcr.io docker pull ghcr.io/"$MY_ORG"/"$MY_APP":"pr-""$PR" -docker tag ghcr.io/"$MY_ORG"/"$MY_APP":"pr-""$PR" ghcr.io/"$MY_ORG"/"$MY_APP":"latest" -docker push ghcr.io/"$MY_ORG"/"$MY_APP":"latest" +docker tag ghcr.io/"$MY_ORG"/"$MY_APP":"pr-""$PR" ghcr.io/"$MY_ORG"/"$MY_APP":"latest-rc" +docker push ghcr.io/"$MY_ORG"/"$MY_APP":"latest-rc" From a8ffb3e66081f3d72b6c915daa98897ef58f87fb Mon Sep 17 00:00:00 2001 From: bio-boris Date: Fri, 25 Mar 2022 12:57:12 -0500 Subject: [PATCH 730/732] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 151b6d57..8896d9a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 -##[0.0.18] - 2022-03-02 +## [0.0.18] - 2022-03-02 ### Added - taxonomy_search_species_strain and taxonomy_search_species_strain_no_sort stored queries From 44cc2a304a1987e24466a335a2a5e56a3718ed92 Mon Sep 17 00:00:00 2001 From: bio-boris Date: Tue, 29 Mar 2022 11:10:03 -0500 Subject: [PATCH 731/732] Update Jinja to fix Markup (#106) * Update requirements and dev requirements to fix markup --- dev-requirements.txt | 1 + requirements.txt | 1 + 2 files changed, 2 insertions(+) diff --git a/dev-requirements.txt b/dev-requirements.txt index de91a89d..8524746d 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -7,3 +7,4 @@ coverage==5.2.1 typed-ast>=1.4.0 black==20.8b1 pytest==6.2.5 +jinja2==3.0.3 diff --git a/requirements.txt b/requirements.txt index 98194623..0960d7cc 100644 --- a/requirements.txt +++ b/requirements.txt @@ -11,3 +11,4 @@ jsonschema==3.2.0 jsonschema[format]==3.2.0 pyyaml==5.4 rfc3987==1.3.8 +jinja2==3.0.3 From 088f72c696773ee87502c6e64023f31fa4b482bf Mon Sep 17 00:00:00 2001 From: bio-boris Date: Tue, 29 Mar 2022 12:44:00 -0500 Subject: [PATCH 732/732] Update dev-requirements.txt (#108) --- dev-requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev-requirements.txt b/dev-requirements.txt index 8524746d..618eea4e 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -5,6 +5,6 @@ flake8==3.5.0 grequests==0.3.0 coverage==5.2.1 typed-ast>=1.4.0 -black==20.8b1 +black==22.3.0 pytest==6.2.5 jinja2==3.0.3

fJ()8NS?u|l$mNuc?=>n@weADi_rsgfK7#nXngsKDxLeBBv1YXh z-aa`mr+^Qi7afnK0*AXuTk3XV956&Ya>dzr6m>BmI{1)ck6rGcpze&hOjIbC*Shsn zT&F5+yP`L~H>)r(FbwdR3ndyjt!ZL>@AdXu3hotauOGb@IGs_vj;U}5@l0O2IsUiX zq1KJ~^V@IgC#t;>H7*lzqUJSAtD^b{Y*PP31yZ}lWj38pBU*WH91P`{!+gK=B}~;DI1=|G~huWZ7Uyqy`T`d^Hb2; zpj0-0TJ<12wy;DAKh`5CR})R%fuJoChy}h91(p2h9cH=Qg0}ppR^Q8Wx+**u!;~vd zVq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`t}|JLq7O|y9vM!bH?R9tK3_G%UN%g9QY5cO#>YL+BO*lO_@4x6|m_F97xpE zwhfJZsR`UX<9+M$)6x}pqk*Zzb@BW^#jBkje%t#yG0N%TUTfZR^DSCJsn7YXo=?8- z4s1%>KdATTV*xs89dNco^jX>}1@+|jato(Cd17nbVRw0oL|*@jm8t&iAzvQkPd9h0IxP(2&`6t+pU+z0*myd>p(XH*Mk68Q!U}& zTF)-dz+mP%#}#;g8VG!VT)YWnML;ec2C~B7Hz+}_RtE|tn8L3l8&w7jkI?`D-4YGF zd2Td?fWu)l%YcJnvJDAN=2*d>mX5H2+zzopr0K}`km;e9( literal 0 HcmV?d00001 diff --git a/spec/data_sources/ncbi_taxonomy.yaml b/spec/data_sources/ncbi_taxonomy.yaml new file mode 100644 index 00000000..c94c3f28 --- /dev/null +++ b/spec/data_sources/ncbi_taxonomy.yaml @@ -0,0 +1,5 @@ +name: ncbi_taxonomy +category: taxonomy +namespace_title: NCBI Taxonomy +home_url: https://www.ncbi.nlm.nih.gov/taxonomy +data_url: ftp://ftp.ncbi.nlm.nih.gov/pub/taxonomy/ diff --git a/spec/data_sources/rdp_taxonomy.yaml b/spec/data_sources/rdp_taxonomy.yaml new file mode 100644 index 00000000..1d7cf12f --- /dev/null +++ b/spec/data_sources/rdp_taxonomy.yaml @@ -0,0 +1,5 @@ +name: rdp_taxonomy +category: taxonomy +namespace_title: Ribosomal Database Project +home_url: http://rdp.cme.msu.edu/taxomatic/main.spr +data_url: http://rdp.cme.msu.edu/misc/resources.jsp From 811fbdcf147bd3a4438d173f9a2be98ed6fa01a9 Mon Sep 17 00:00:00 2001 From: Jay R Bolton Date: Fri, 1 Nov 2019 14:51:54 -0700 Subject: [PATCH 456/732] Remove image dir --- spec/data_sources/img/ncbi_taxonomy.png | Bin 79970 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 spec/data_sources/img/ncbi_taxonomy.png diff --git a/spec/data_sources/img/ncbi_taxonomy.png b/spec/data_sources/img/ncbi_taxonomy.png deleted file mode 100644 index 56fa82851fef367a51b70c6cc43945b69967a750..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 79970 zcmeFZ_g9nY7B>6^aQAHX5# zw@(msruTP7@W~1>X&U^+_)J^l0dz|H^S&uR9(=;&qowKx&~=I z_}efbePhNyea1g{<#5k&I6@{zYOTq{eDhMIWM`X=#GjY%UHjuLZuX{jMVeP7is$f>0jFRJj_fX$L|EG@&sxs zuK44K(x*Dee&XSA;#lzf057aU2%HIeq|BDQu0luqXXBrA%;2xkdl$fEAn3Nt|9cyA$Q z57*Gn^Q}cVnXLCblHIl|rna>xnO(_JIjKGUQAB?kYUMl+@_=5pg%}3$%-lh5v%9Z{ zdmya9(UP#b>V#eTL$ttnqZ5K8czzRs<{L*J71?#>QuCPq#r~c-3=^pTJJcHS7w!9d`X=TM`h>p5%-1PX($~FF zx9s%v5qUb#OZJ|F)N~IV$YboI5jI5@L!P)RTZ_22ysOifUXbDFSU8GOhM>;>gr0#e z>fJAiI~cy@un<|=mqj@iF3i*Ij?^L)BoMUEKpxGst?E-%3sji%{q4asBB>J@ucYgx zP)^~G&Ooh|;3hT}RkCt+wC~={CU#WnF&2Rbh9*ZI5eGXvy1O--G$2Uc8A!49qfla8 zO1x5q4<#2-_R&l}M|iklYF)+5l9hYXnD`e2;ml~K?u23N#+Gm*8PbAS2YuYoL_F;` zs%q1DO^oOu300c(_yrT=ObryXSdFmD>5)dR{m(8zkgawrJ(QVmA!I+6fJ59LWqUSy zP+<+e=(u4+2dzGL?OQuAsC>4WP;4q8E4-|Gxdz?w=mD6L=C z$G(clLlC}XR@HuY;RfnW1IjsLESLma|YOIhytryeNrw6N}FQ zW?~jHqRy9ha_a_@oq-J9oB0?+70o4@gp6M`4a)>Y0!(8W}+u5GcgC}Q_0)1oHGLCjoLTHC=N$a54WLet^zPap}# zWr|KWKh|OC&814Og&&TNj#b-=5R@(m#Gw8+aG~UqcPYZgeZ3g0gM*pB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