Skip to content

Commit

Permalink
Merge pull request #167 from pagreene/api-update-db-side
Browse files Browse the repository at this point in the history
API Update: Database Side
  • Loading branch information
pagreene committed May 11, 2021
2 parents 6695d21 + f5c8365 commit d33d156
Show file tree
Hide file tree
Showing 16 changed files with 940 additions and 654 deletions.
78 changes: 78 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Tests

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Set up Python 3.6
uses: actions/setup-python@v2
with:
python-version: 3.6
- name: Install dependencies
run: |
echo $GITHUB_EVENT_NAME
export WRKDIR=`pwd`
echo "home dir:" $WRKDIR
sudo apt-get update
sudo apt-get install libstdc++6 graphviz python3-dev libgraphviz-dev pkg-config
# Install test/github-workflows-specific dependencies not covered elsewhere
pip install jsonschema coverage nose-timer doctest-ignore-unicode awscli pycodestyle
pip install cython psycopg2
# Now install INDRA DB with all its extras
pip install git+https://github.com/pagreene/indra.git@api-update
cd ..
git clone https://github.com/indralab/ui_util
cd ui_util/indralab_auth_tools
echo "indralab_auth_tools dir:" pwd
pip install .
cd $WRKDIR
echo "indra_db dir:" pwd
pip install .[all]
- name: Run API tests
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
INDRADBPRIMARY: ${{ secrets.INDRADBPRIMARY }}
INDRAROPRIMARY: ${{ secrets.INDRAROPRIMARY }}
SUPERSECRETSECREST: ${{ secrets.SUPERSECRETSECRET }}
run: |
# Set nose attributes based on the context in which we are running
export NOSEATTR="!notravis,!slow,!cron";
export NOSEATTR=$(if [ "$GITHUB_EVENT_NAME" == "pull_request" ]; then echo $NOSEATTR,!nonpublic; else echo $NOSEATTR; fi)
echo $NOSEATTR
# These are files that are ignored so that doctests don't fail
export NOSE_IGNORE_FILES="find_full_text_sentence.py";
echo $NOSEATTR
#- cd $TRAVIS_BUILD_DIR
# Now run all INDRA DB REST API tests
cd rest_api
nosetests -v -a $NOSEATTR --with-coverage --cover-inclusive --cover-package=indra --with-doctest --with-doctest-ignore-unicode --with-timer --timer-top-n 10 --processes=0
#- name: Run all other tests
# env:
# AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
# AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
# INDRADBPRIMARY: ${{ secrets.INDRADBPRIMARY }}
# INDRAROPRIMARY: ${{ secrets.INDRAROPRIMARY }}
# run: |
# # Set nose attributes based on the context in which we are running
# export NOSEATTR="!notravis,!slow,!cron";
# export NOSEATTR=$(if [ "$GITHUB_EVENT_NAME" == "pull_request" ]; then echo $NOSEATTR,!nonpublic; else echo $NOSEATTR; fi)
# echo $NOSEATTR
# # These are files that are ignored so that doctests don't fail
# export NOSE_IGNORE_FILES="find_full_text_sentence.py";
# echo $NOSEATTR
# #- cd $TRAVIS_BUILD_DIR
# # Now run all INDRA DB REST API tests
# cd indra_db
# nosetests -v -a $NOSEATTR --with-coverage --cover-inclusive --cover-package=indra --with-doctest --with-doctest-ignore-unicode --with-timer --timer-top-n 10 --processes=0

82 changes: 0 additions & 82 deletions .travis.yml

This file was deleted.

19 changes: 14 additions & 5 deletions indra_db/client/principal/curation.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
__all__ = ['submit_curation', 'get_curations', 'get_grounding_curations']

import re
import json
import logging
import datetime
from collections import Counter
Expand All @@ -14,7 +15,7 @@


def submit_curation(hash_val, tag, curator, ip, text=None, ev_hash=None,
source='direct_client', stmt_json=None, ev_json=None,
source='direct_client', pa_json=None, ev_json=None,
db=None):
"""Submit a curation for a given preassembled or raw extraction.
Expand All @@ -37,19 +38,27 @@ def submit_curation(hash_val, tag, curator, ip, text=None, ev_hash=None,
The name of the access point through which the curation was performed.
The default is 'direct_client', meaning this function was used
directly. Any higher-level application should identify itself here.
stmt_json : Optional[dict]
The JSON of a preassembled or raw statement that was curated.
pa_json : Optional[dict]
The JSON of a preassembled or raw statement that was curated. If None,
we will try to get the pa_json from the database.
ev_json : Optional[dict]
The JSON of the evidence that was curated.
The JSON of the evidence that was curated. This cannot be retrieved from
the database if not given.
db : DatabaseManager
A database manager object used to access the database.
"""
if db is None:
db = get_db('primary')

if pa_json is None:
pa_json_strs = db.select_one(db.PAStatements.json,
db.PAStatements.mk_hash == int(hash_val))
if pa_json_strs is not None:
pa_json = json.loads(pa_json_strs[0])

inp = {'tag': tag, 'text': text, 'curator': curator, 'ip': ip,
'source': source, 'pa_hash': hash_val, 'source_hash': ev_hash,
'pa_json': stmt_json, 'ev_json': ev_json}
'pa_json': pa_json, 'ev_json': ev_json}

logger.info("Adding curation: %s" % str(inp))

Expand Down

0 comments on commit d33d156

Please sign in to comment.