Skip to content
This repository has been archived by the owner on Sep 22, 2019. It is now read-only.

Api v2 #26

Merged
merged 14 commits into from Sep 11, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
65 changes: 65 additions & 0 deletions TESTS.md
@@ -0,0 +1,65 @@
Currently, there are no automated test procedures for OTI. You can however, fairly thoroughly test the performance manually. Run the following command to index the current phylesystem repo on devapi.opentreeoflife.org:

```bash
./index_current_repo.py http://devapi.opentreeoflife.org/oti http://devapi.opentreeoflife.org/api
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chinchliff: Oddly, I'm getting an error on exactly one study, pg_719 (all the others are indexed properly):

Indexing http://devapi.opentreeoflife.org/api/ study pg_719 from http://devapi.opentreeoflife.org/api/default/v1/study/pg_719.json
Calling "http://devapi.opentreeoflife.org/oti/ext/studies/graphdb/index_studies" with data="{'urls': ['http://devapi.opentreeoflife.org/api/default/v1/study/pg_719.json']}"

Indexing failed for URL "http://devapi.opentreeoflife.org/api/default/v1/study/pg_719.json", study http://devapi.opentreeoflife.org/api/default/v1/study/pg_719.json. Message = "More than one hit found for ot:studyId == 719. The database is probably corrupt."

Any chance this is confused by the presence of another "719" study? But I don't see a ot_719... at least not in the GitHub repo (will check the API server's "local" repo next).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugh. I expect it's because of the way the indexing was performed initially.
pg_719 is the first study to be indexed and it probably got screwed up
somehow. It would be nice not to have to re-build the entire db. We just
need to remove the study and then I expect indexing will proceed as
planned. I will think about this...

On Wed, Sep 10, 2014 at 10:33 PM, Jim Allman notifications@github.com
wrote:

In TESTS.md:

@@ -0,0 +1,65 @@
+Currently, there are no automated test procedures for OTI. You can however, fairly thoroughly test the performance manually. Run the following command to index the current phylesystem repo on devapi.opentreeoflife.org:
+
+```bash
+./index_current_repo.py http://devapi.opentreeoflife.org/oti http://devapi.opentreeoflife.org/api

@chinchliff https://github.com/chinchliff: Oddly, I'm getting an error
on exactly one study, pg_719 (all the others are indexed properly):

Indexing http://devapi.opentreeoflife.org/api/ study pg_719 from http://devapi.opentreeoflife.org/api/default/v1/study/pg_719.json
Calling "http://devapi.opentreeoflife.org/oti/ext/studies/graphdb/index_studies" with data="{'urls': ['http://devapi.opentreeoflife.org/api/default/v1/study/pg_719.json']}"

Indexing failed for URL "http://devapi.opentreeoflife.org/api/default/v1/study/pg_719.json", study http://devapi.opentreeoflife.org/api/default/v1/study/pg_719.json. Message = "More than one hit found for ot:studyId == 719. The database is probably corrupt."

Any chance this is confused by the presence of another "719" study? But I
don't see a ot_719... at least not in the GitHub repo (will check the
API server's "local" repo next).


Reply to this email directly or view it on GitHub
https://github.com/OpenTreeOfLife/oti/pull/26/files#r17401670.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the easiest way is just to write a custom method to remove this
study and then run it. If I don't remember to do this, please remind me...

On Wed, Sep 10, 2014 at 10:49 PM, Jim Allman notifications@github.com
wrote:

In TESTS.md:

@@ -0,0 +1,65 @@
+Currently, there are no automated test procedures for OTI. You can however, fairly thoroughly test the performance manually. Run the following command to index the current phylesystem repo on devapi.opentreeoflife.org:
+
+```bash
+./index_current_repo.py http://devapi.opentreeoflife.org/oti http://devapi.opentreeoflife.org/api

In case it helps, the error message seems to be coming from ot-base
https://github.com/OpenTreeOfLife/ot-base/blob/9c0352af452518de3a3e1e17a96ad0bbd959934e/src/main/java/org/opentree/graphdb/DatabaseUtils.java#L115
.


Reply to this email directly or view it on GitHub
https://github.com/OpenTreeOfLife/oti/pull/26/files#r17402013.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good. Meanwhile, there are two copies of the "Tippery N., 2011" study in oti. You can see them in the main study-list page by searching for its DOI: "10.1600/036364411X605092"

```

And then (assuming indexing worked), query the database to test it. Here are some example queries using cURL, and their expected results.

### Return a list of all studies:

```bash
curl -X POST http://devapi.opentreeoflife.org/oti/ext/studies/graphdb/find_studies
```

```json
{
"matched_studies" : [ {
"ot:studyId" : "1354"
}, {
"ot:studyId" : "2189"
}, # snipped
{
"ot:studyId" : "2326"
}, {
"ot:studyId" : "1827"
} ]
}
```

### Search for studies with trees spanning the taxon with name "Annona glabra":

```bash
curl -X POST http://devapi.opentreeoflife.org/oti/ext/studies/graphdb/find_trees -H "content-type: application/json" -d '{"property":"ot:ottTaxonName","value":"Annona glabra"}'
```

```json
{
"matched_studies" : [ {
"matched_trees" : [ {
"nexson_id" : "tree3008",
"oti_tree_id" : "1495_tree3008"
}, {
"nexson_id" : "tree3009",
"oti_tree_id" : "1495_tree3009"
}, {
"nexson_id" : "tree3010",
"oti_tree_id" : "1495_tree3010"
} ],
"ot:studyId" : "1495"
} ]
}
```

### Get a list of properties available for searching studies and trees:

```bash
curl -X POST http://devapi.opentreeoflife.org/oti/ext/studies/graphdb/properties
```

```json
{
"tree_properties" : [ "ot:studyPublicationReference", "is_deprecated", "ot:focalCladeOTTTaxonName", "ot:studyLastEditor", "ot:studyModified", "ot:studyLabel", "ot:comment", "ot:studyId", "ot:dataDeposit", "ot:authorContributed", "ot:studyUploaded", "ot:studyYear", "ot:focalCladeTaxonName", "ot:tag", "ot:curatorName", "ot:studyPublication", "ot:focalCladeOTTId", "ot:focalClade" ],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is "is_deprecated" really a property? does it need an ot: namespace?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know. It can certainly be changed in oti if we feel that it would
be worth designating an ot: property. Currently, that property is set to
true if the tree is tagged with anything matching the search string "del*".
Obviously this is hacky and not ideal. It would be better to have an
explicit property, but maybe we don't need this property now that curators
can delete trees?

On Wed, Sep 10, 2014 at 4:33 PM, Mark T. Holder notifications@github.com
wrote:

In TESTS.md:

  •  "oti_tree_id" : "1495_tree3010"
    
  • } ],
  • "ot:studyId" : "1495"
  • } ]
    +}
    +`

+### Get a list of properties available for searching studies and trees:
+
+bash +curl -X POST http://devapi.opentreeolife.org/ext/studies/graphdb/properties +
+
+`json
+{

  • "tree_properties" : [ "ot:studyPublicationReference", "is_deprecated", "ot:focalCladeOTTTaxonName", "ot:studyLastEditor", "ot:studyModified", "ot:studyLabel", "ot:comment", "ot:studyId", "ot:dataDeposit", "ot:authorContributed", "ot:studyUploaded", "ot:studyYear", "ot:focalCladeTaxonName", "ot:tag", "ot:curatorName", "ot:studyPublication", "ot:focalCladeOTTId", "ot:focalClade" ],

Is "is_deprecated" really a property? does it need an ot: namespace?


Reply to this email directly or view it on GitHub
https://github.com/OpenTreeOfLife/oti/pull/26/files#r17386871.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we don't need this property now that curators can delete trees?

FWIW, the current curation app completely ignores the is_deprecated property. Also, I don't see any reference to this in the GitHub wiki or WikiSpaces wiki about NexSON.

It's briefly mentioned in this oti issue and it definitely sounds like legacy cruft.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On 9/10/14 5:01 PM, Jim Allman wrote:

In TESTS.md:

  •  "oti_tree_id" : "1495_tree3010"
    
  • } ],
  • "ot:studyId" : "1495"
  • } ]
    +}
    +`

+### Get a list of properties available for searching studies and trees:
+
+bash +curl -X POST http://devapi.opentreeolife.org/ext/studies/graphdb/properties +
+
+`json
+{

  • "tree_properties" : [ "ot:studyPublicationReference", "is_deprecated", "ot:focalCladeOTTTaxonName", "ot:studyLastEditor", "ot:studyModified", "ot:studyLabel", "ot:comment", "ot:studyId", "ot:dataDeposit", "ot:authorContributed", "ot:studyUploaded", "ot:studyYear", "ot:focalCladeTaxonName", "ot:tag", "ot:curatorName", "ot:studyPublication", "ot:focalCladeOTTId", "ot:focalClade" ],
maybe we don't need this property now that curators can delete trees?

FWIW, the current curation app completely ignores the |is_deprecated|
property. Also, I don't see any reference to this in the GitHub wiki
https://github.com/OpenTreeOfLife/phylesystem-api/wiki/NexSON or
WikiSpaces wiki http://opentree.wikispaces.com/NexSON about NexSON.

It's briefly mentioned in this oti issue
#9 and it definitely
sounds like legacy cruft.

Yes, it was a work around for studies that could not be deleted before
phylografter supported deletion. Agree it's legacy cruft.

Reply to this email directly or view it on GitHub
https://github.com/OpenTreeOfLife/oti/pull/26/files#r17388582.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. I have made issue #27 to remove this property. Currently, I don't think it matters much if it's there, and the goal of this pull request is to get the new api services up and working this week. So it seems like now that we know what to do, we can deal with this later?

"study_properties" : [ "ot:studyPublicationReference", "is_deprecated", "ot:focalCladeOTTTaxonName", "ot:studyLastEditor", "ot:studyModified", "ot:studyLabel", "ot:comment", "ot:studyId", "ot:dataDeposit", "ot:authorContributed", "ot:studyUploaded", "ot:studyYear", "ot:focalCladeTaxonName", "ot:tag", "ot:curatorName", "ot:studyPublication", "ot:focalCladeOTTId", "ot:focalClade" ]
}
```
56 changes: 3 additions & 53 deletions index_current_repo.py
Expand Up @@ -3,7 +3,6 @@
# Command line arguments:
# - URL prefix for communicating with the OTI neo4j server
# - URL prefix for phylesystem API methods (not including 'v1/')
# - (future: URL for OTT tarball ?)

import json, os, requests, sys, tarfile, urllib2

Expand All @@ -15,7 +14,8 @@ def get_download_dir():

def submit_indexing_request(data):
'''Send a request to oti to index a single study. URL is set to default neo4j location'''
url = oti_url + "ext/IndexServices/graphdb/indexNexsons"
# url = oti_url + "ext/IndexServices/graphdb/indexNexsons"
url = oti_url + "ext/studies/graphdb/index_studies"
print 'Calling "{}" with data="{}"'.format(url, repr(data))
r = requests.post(url,
data=json.dumps(data),
Expand All @@ -25,53 +25,12 @@ def submit_indexing_request(data):
r.raise_for_status()
return r.json()

def load_taxonomy():
'''Install ott... Currently not used, we just supply a pre-built taxonomy database.'''

# setup stuff for the download
download_dir = get_download_dir()
ott_filename = ott_file_url.rsplit("/",1)[1]
ott_save_path = os.path.join(download_dir,ott_filename)

# download the taxonomy if necessary
if not os.path.exists(ott_save_path):
print("Downloading ott from " + ott_file_url + ".\nThis could take a while...")
req = urllib2.Request(ott_file_url)
f = urllib2.urlopen(req)

# write the taxonomy into the file
ottfile = file(ott_save_path, 'wb')
while True:
chunk = f.read(1000000)
if not chunk: break
ottfile.write (chunk)
ottfile.close()

# extract the taxonomy if necessary
tax_file_path = os.path.join(download_dir,"ott","taxonomy.tsv")
syn_file_path = os.path.join(download_dir,"ott","synonyms.tsv")
if not os.path.exists(tax_file_path) or not os.path.exists(syn_file_path):
os.chdir(download_dir)
tar = tarfile.open(ott_save_path)
tar.extractall()
tar.close()

# call the taxonomy loading routines
url = oti_url + "ext/ConfigurationServices/graphdb/installOTT"
data='{"taxonomyFile":"'+tax_file_path+'","synonymFile":"'+syn_file_path+'"}'
print('Calling "{}" with data="{}"'.format(url, repr(data)))
r = requests.post(url, data, headers={'Content-type': 'application/json'});

# We don't really need any data out of r.
# But do raise an error if something went wrong.
r.raise_for_status()

# default args
if len(sys.argv) > 1:
oti_url = sys.argv[1].rstrip("/") + "/"
# local oti url (example): http://localhost:7474/db/data/
else:
print("usage (with defaults): index_current_repo.py <oti_url> [<target_phylesystem_repo_name>](==http://localhost/api/) [<ott_file_url>](==http://files.opentreeoflife.org/ott/ott2.8draft3.tgz)")
print("usage (with defaults): index_current_repo.py <oti_url> [<target_phylesystem_repo_name>](==http://localhost/api/)")
sys.exit(0)
print("Using the oti instance at: " + oti_url)

Expand All @@ -82,12 +41,6 @@ def load_taxonomy():
#files_base_url = "https://raw.github.com/OpenTreeOfLife/%s/master"%(oti_repo)
print("Using the studies from: " + api_url)

if len(sys.argv) > 3:
ott_file_url = sys.argv[3]
else:
ott_file_url = "http://files.opentreeoflife.org/ott/ott2.8draft3.tgz"
#print("Using the ott taxonomy at: " + ott_file_url)

# Ignoring oti_mode for now, since we're using the local API to retrieve study
# ids and NexSON in the required format.
#
Expand All @@ -109,9 +62,6 @@ def load_taxonomy():
# PROBLEM: URL formation are rules in the two cases.

# right now we are not loading the taxonomy, any taxonomy must be provided as a pre-built database
load_taxonomy = False
if load_taxonomy:
load_taxonomy()

# retrieve the study list
r = requests.get(api_url + "study_list")
Expand Down
98 changes: 0 additions & 98 deletions src/main/java/org/opentree/oti/plugins/ConfigurationServices.java

This file was deleted.

3 changes: 3 additions & 0 deletions src/main/java/org/opentree/oti/plugins/IndexServices.java
Expand Up @@ -43,6 +43,7 @@
* @author cody
*
*/
@Deprecated
public class IndexServices extends ServerPlugin {

/**
Expand Down Expand Up @@ -80,6 +81,7 @@ public Representation indexSingleNexson(@Source GraphDatabaseService graphDb,
"previously indexed study, then the previous information for that study will be replaced by the incoming nexson. Returns an " +
"array containing the study ids for the studies that were successfully read and indexed.")
@PluginTarget(GraphDatabaseService.class)
@Deprecated
public Representation indexNexsons(@Source GraphDatabaseService graphDb,
@Description("remote nexson urls") @Parameter(name = "urls", optional = false) String[] urls) throws MalformedURLException, IOException {

Expand Down Expand Up @@ -121,6 +123,7 @@ public Representation indexNexsons(@Source GraphDatabaseService graphDb,
"the studies that were successfully removed from the index, and those that could " +
"not be found (and throws exceptions for those whose removal failed.")
@PluginTarget(GraphDatabaseService.class)
@Deprecated
public Representation unindexNexsons(@Source GraphDatabaseService graphDb,
@Description("doomed nexson ids") @Parameter(name = "ids", optional = false) String[] ids) throws IOException {

Expand Down
87 changes: 0 additions & 87 deletions src/main/java/org/opentree/oti/plugins/NexsonServices.java

This file was deleted.