Skip to content

Commit

Permalink
Merge pull request #140 from indralab/validation
Browse files Browse the repository at this point in the history
Add statement validation to knowledgebase manager
  • Loading branch information
pagreene committed Oct 21, 2020
2 parents 80ea8aa + b41861b commit 0061190
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion indra_db/client/principal/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def get_reader_output(db, ref_id, ref_type='tcid', reader=None,
reading_dict = defaultdict(lambda: defaultdict(lambda: []))
for tcid, reader, result in res:
unpacked_result = None
if len(result) == 0:
if not result:
logger.warning("Got reading result with zero content.")
else:
unpacked_result = unpack(result)
Expand Down
6 changes: 5 additions & 1 deletion indra_db/managers/knowledgebase_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import logging
import tempfile
from collections import defaultdict

from indra.statements.validate import assert_valid_statement
from indra_db.util import insert_db_stmts
from indra_db.util.distill_statements import extract_duplicates, KeyFunc

Expand All @@ -28,6 +28,10 @@ def upload(self, db):
"""Upload the content for this dataset into the database."""
dbid = self._check_reference(db)
stmts = self._get_statements()
# Raise any validity issues with statements as exceptions here
# to avoid uploading invalid content.
for stmt in stmts:
assert_valid_statement(stmt)
insert_db_stmts(db, stmts, dbid)
return

Expand Down

0 comments on commit 0061190

Please sign in to comment.