Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Bump urllib3 from 1.24.1 to 1.24.2 in /greent #13

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 51 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,13 @@

### Tools Available:

## UberOnto API
### version h-bar/2

```
updates to follow
```

## Onto API
### To edit/execute Onto API locally:
Onto is a facility which aggregates lookup services that provide generic facts about ontologies. It leverages the Uberongraph RDB (a SPARQL-queried Uberongraph available at https://stars-app.renci.org/uberongraph/#query) for data.

### To edit/execute/test Onto API locally:

```
- TO EDIT:
$git clone [email protected]:NCATS-Translator/reasoner-tools

- make a virtual env and activate it, recommended as follows:
Expand All @@ -22,21 +18,41 @@ $source YOUR_ENV_NAME/bin/activate

$cd reasoner-tools

Make functionality changes in greent/services/ontology.py
Make front-end changes in greent/api/onto_gunicorn.py
The above two files should be considered in tandem.

Add unit test cases to greent/test/test_ontology.py


- TO RUN:
$pip install -r greent/requirements.txt
$export greent_conf=greent/greent.conf

- TO RUN:
$gunicorn onto_gunicorn:app --workers 1 --pythonpath=$PWD/greent/api
navigate to http://127.0.0.1:8000/apidocs
Navigate in your browser to http://127.0.0.1:8000/apidocs.


make functionality changes in greent/services/ontology.py
make front-end changes in greent/api/onto.py
the above two files should be considered in tandem
- TO TEST:
$cd reasoner-tools

- To run all unit tests:
pytest greent/test/test_ontology.py

- Remove warnings and get more information as tests run:
pytest -p no:warnings -vv greent/test/test_ontology.py

- Run a single unit test:
pytest greent/test/test_ontology.py -k <test_name>
pytest greent/test/test_ontology.py -k test_label
```

## BioNames API
BioNames is a generic facility which aggregates bio-ontology lookup services. It retrieve names from IDs or IDs based on Natural Language names.
### To edit/execute/test BioNames API locally:

```
- TO EDIT:
$git clone [email protected]:NCATS-Translator/reasoner-tools

- make a virtual env and activate it, recommended as follows:
Expand All @@ -45,13 +61,30 @@ $source YOUR_ENV_NAME/bin/activate

$cd reasoner-tools

Make functionality changes in greent/services/bionames.py
Make front-end changes in builder/api/naming.py
The above two files should be considered in tandem.

Add unit test cases to greent/test/test_bionames.py


- TO RUN:
$pip install -r greent/requirements.txt

- TO RUN VIA PYTHON:
$PYTHONPATH=$PWD python3 builder/api/naming.py
-navigate to localhost:5000/apidocs
- Navigate in your browser to localhost:5000/apidocs.

make functionality changes in greent/services/bionames.py
make front-end changes in builder/api/naming.py
the above two files should be considered in tandem

- TO TEST:
$cd reasoner-tools

- To run all unit tests:
pytest greent/test/test_bionames.py

- Remove warnings and get more information as tests run:
pytest -p no:warnings -vv greent/test/test_bionames.py

- Run a single unit test:
pytest greent/test/test_bionames.py -k <test_name>
pytest greent/test/test_bionames.py -k test_lookup_router
```
6 changes: 3 additions & 3 deletions builder/api/naming.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"swagger": "2.0",
"info": {
"title": "BioNames API",
"description": "Generic facility aggregating bio-ontology lookup services to retrieve names from IDs or IDs based on Natural Language names.",
"description": "Bionames is a generic facility which aggregates bio-ontology lookup services to retrieve names from IDs or IDs based on Natural Language names.",
"contact": {
"responsibleOrganization": "renci.org",
"responsibleDeveloper": "[email protected]",
Expand Down Expand Up @@ -125,7 +125,7 @@ def ID_to_label (ID):
return jsonify(result)

if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Rosetta Server')
parser = argparse.ArgumentParser(description='BioNames Server')
parser.add_argument('-p', '--port', type=int, help='Port to run service on.', default=5000)
parser.add_argument('-d', '--debug', help="Debug.", default=False)
parser.add_argument('-c', '--conf', help='GreenT config file to use.', default="greent.conf")
Expand All @@ -135,4 +135,4 @@ def ID_to_label (ID):
'config' : args.conf,
'debug' : args.debug
}
app.run(host='0.0.0.0', port=args.port, debug=True, threaded=True)
app.run(host='0.0.0.0', port=args.port, debug=True, threaded=True)
25 changes: 0 additions & 25 deletions greent/api/main.py

This file was deleted.

13 changes: 4 additions & 9 deletions greent/api/onto_gunicorn.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"swagger": "2.0",
"info": {
"title": "Generic Ontology API",
"description": "Generic facts about ontologies (Flask/Gunicorn). This interface utilizes flat file .obo files as well as leveraging the Uberongraph RDB (a SPARQL-queried Uberongraph available at https://stars-app.renci.org/uberongraph/#query)",
"description": "Onto is a facility which aggregates lookup services that provide generic facts about ontologies. It leverages the Uberongraph RDB (a SPARQL-queried Uberongraph available at https://stars-app.renci.org/uberongraph/#query) for data.",
"contact": {
"responsibleOrganization": "renci.org",
"responsibleDeveloper": "[email protected]",
Expand Down Expand Up @@ -466,10 +466,6 @@ def all_properties (curie):
ont = get_ontology_service()
return jsonify({"all_properties" : ont.all_properties(curie_normalize(curie))})

##################
# start of sparkle based access to the Uberongraph RDB
##################

@app.route('/descendants/<curie>')
def descendants(curie):
""" Get all cascading 'is_a' descendants of an input CURIE term.
Expand Down Expand Up @@ -565,7 +561,7 @@ def label(curie):

@app.route('/uri/<curie>')
def uri_from_curie(curie):
""" Exapnds a curie to uri.
""" Expands a curie to uri.
---
parameters:
- name: curie
Expand Down Expand Up @@ -602,11 +598,10 @@ def get_curie_uri_map():


if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Rosetta Server')
parser = argparse.ArgumentParser(description='Onto Server')
parser.add_argument('-p', '--port', type=int, help='Port to run service on.', default=5000)
parser.add_argument('-d', '--debug', help="Debug.", default=False)
parser.add_argument('-t', '--data', help="Ontology data source.", default="c:/Users/powen/PycharmProjects/Reasoner/reasoner-tools/")
# parser.add_argument('-t', '--data', help="Ontology data source.", default="/projects/stars/reasoner/var/ontologies/")
parser.add_argument('-t', '--data', help="Ontology data source.", default="/projects/stars/reasoner/var/ontologies/")
parser.add_argument('-c', '--conf', help='GreenT config file to use.', default="greent.conf")
args = parser.parse_args ()
app.config['SWAGGER']['greent_conf'] = args.greent_conf = args.conf
Expand Down
5 changes: 5 additions & 0 deletions greent/api/onto_wsgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# usage: gunicorn --workers=3 --timeout=120 --bind=0.0.0.0:5000 --pythonpath '../../' onto_wsgi:app
from onto_gunicorn import app

if __name__ == "__main__":
app.run()
2 changes: 1 addition & 1 deletion greent/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ rdflib==4.2.2
requests==2.21.0
six==1.12.0
SPARQLWrapper==1.8.2
urllib3==1.24.1
urllib3==1.24.2
Werkzeug==0.15.1
3 changes: 2 additions & 1 deletion greent/services/bionames.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ def _search_onto(self, q, concept=None):
try:
result = self.context.core.onto.search (q, is_regex=True, full=True)
if concept:
result = [r for r in result if r['type'] == concept]
# Added fix for KeyException when there's no 'type' key in dict r
result = [r for r in result if 'type' in r and r['type'] == concept]
except:
traceback.print_exc ()
return result
Expand Down
2 changes: 1 addition & 1 deletion greent/services/ontology.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def query_sparql(self, query_template, inputs, outputs):


def label(self,identifier):
"""Return the exitlabel for an identifier"""
"""Return the label for an identifier"""
query_text = f"""
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT DISTINCT ?labels
Expand Down
Loading