Skip to content

Commit

Permalink
Changes to existing files for taxonomic amendments
Browse files Browse the repository at this point in the history
  • Loading branch information
jimallman committed Jun 21, 2016
1 parent 2d713d3 commit 166f7b1
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -4,6 +4,7 @@ peyotl.egg-info
peyotl/test/data/mini_phyl
peyotl/test/data/mini_system
peyotl/test/data/mini_collections
peyotl/test/data/mini_amendments
env
dist
*~
Expand Down
6 changes: 6 additions & 0 deletions bootstrap.sh
Expand Up @@ -29,5 +29,11 @@ then
else
git clone https://github.com/jimallman/mini_collections.git || exit
fi
if test -d mini_amendments
then
echo "mini_amendments exists"
else
git clone https://github.com/jimallman/mini_amendments.git || exit
fi
cd .. || exit
cp -r template_mini_par mini_par
4 changes: 2 additions & 2 deletions extras/lock-phylesystem.py
Expand Up @@ -8,7 +8,7 @@
git_dir = os.path.join(repo, '.git')
assert os.path.isdir(git_dir)
except:
sys.exit('''Expecting a phylesystem or collections shard as the only argument.
sys.exit('''Expecting a phylesystem shard (or one for collections, amendments, etc.) as the only argument.
This script looks for the .git dir in the first argument, and locks that .git
dir to prevent simultaneous operations by the phylesystem-api.
Expand All @@ -30,4 +30,4 @@
finally:
print 'Lock released'
sys.exit(0)
sys.exit('timeout waiting for lock\n')
sys.exit('timeout waiting for lock\n')
1 change: 1 addition & 0 deletions peyotl/api/__init__.py
Expand Up @@ -5,5 +5,6 @@
from peyotl.api.phylografter import Phylografter
from peyotl.api.phylesystem_api import PhylesystemAPI
from peyotl.api.collections_api import TreeCollectionsAPI
from peyotl.api.amendments_api import TaxonomicAmendmentsAPI
from peyotl.api.oti import OTI

23 changes: 22 additions & 1 deletion peyotl/api/wrapper.py
Expand Up @@ -65,6 +65,7 @@ def __init__(self, **kwargs):
self._phylografter = 'http://www.reelab.net/phylografter'
self._phylesystem_api = kwargs.get('phylesystem')
self._collections_api = kwargs.get('collections')
self._amendments_api = kwargs.get('amendments')
self._taxomachine = kwargs.get('taxomachine')
self._treemachine = kwargs.get('treemachine')
@property
Expand All @@ -89,6 +90,13 @@ def collections_api(self):
'https://api.opentreeoflife.org')
return self._collections_api
@property
def amendments_api(self):
if self._amendments_api is None:
self._amendments_api = self._config.get_config_setting('apis',
'amendments_api',
'https://api.opentreeoflife.org')
return self._amendments_api
@property
def phylografter(self):
return self._phylografter
@property
Expand All @@ -115,13 +123,15 @@ class APIWrapper(object):
# deprecated service
# see https://github.com/OpenTreeOfLife/treemachine/issues/170
SUPPORTING_GET_SOURCE_TREE = False
def __init__(self, domains=None, phylesystem_api_kwargs=None, collections_api_kwargs=None, **kwargs):
def __init__(self, domains=None, phylesystem_api_kwargs=None, collections_api_kwargs=None, amendments_api_kwargs=None, **kwargs):
if domains is None:
domains = get_domains_obj(**kwargs)
self.domains = domains
self._phylografter = None
self._phylesystem_api = None
self._collections_api = None
self._amendments_api = None
self._amendments = None
self._taxomachine = None
self._treemachine = None
self._oti = None
Expand All @@ -140,6 +150,10 @@ def __init__(self, domains=None, phylesystem_api_kwargs=None, collections_api_kw
self._collections_api_kwargs = {}
else:
self._collections_api_kwargs = dict(collections_api_kwargs)
if amendments_api_kwargs is None:
self._amendments_api_kwargs = {}
else:
self._amendments_api_kwargs = dict(amendments_api_kwargs)
@property
def oti(self):
from peyotl.api.oti import _OTIWrapper #pylint: disable=R0401
Expand Down Expand Up @@ -191,12 +205,19 @@ def wrap_collections_api(self, **kwargs):
kwargs['config'] = self._config
self._collections_api = _TreeCollectionsAPIWrapper(self.domains.collections_api, **kwargs)
return self._collections_api
def wrap_amendments_api(self, **kwargs):
raise NotImplementedError("wrap_amendments_api not implemented yet!")
@property
def collections_api(self):
if self._collections_api is None:
self.wrap_collections_api()
return self._collections_api
@property
def amendments_api(self):
if self._amendments_api is None:
self.wrap_amendments_api()
return self._amendments_api
@property
def phylografter(self):
from peyotl.api.phylografter import _PhylografterWrapper
if self._phylografter is None:
Expand Down
2 changes: 1 addition & 1 deletion peyotl/collections/collections_umbrella.py
Expand Up @@ -87,7 +87,7 @@ def __init__(self,
Repos can be found by passing in a `repos_par` (a directory that is the parent of the repos)
or by trusting the `repos_dict` mapping of name to repo filepath.
`with_caching` should be True for non-debugging uses.
`assumed_doc_version` is optional. If specified all TreeCollectionStoreShard repos are assumed to store
`assumed_doc_version` is optional. If specified all TreeCollectionsShard repos are assumed to store
files of this version of nexson syntax.
`git_ssh` is the path of an executable for git-ssh operations.
`pkey` is the PKEY that has to be in the env for remote, authenticated operations to work
Expand Down
1 change: 1 addition & 0 deletions peyotl/default.conf
Expand Up @@ -6,6 +6,7 @@ formatter = rich
[apis]
phylesystem_api = https://devapi.opentreeoflife.org
collections_api = https://devapi.opentreeoflife.org
amendments_api = https://devapi.opentreeoflife.org
oti = https://devapi.opentreeoflife.org
taxomachine = https://api.opentreeoflife.org
treemachine = https://api.opentreeoflife.org
Expand Down
2 changes: 1 addition & 1 deletion peyotl/git_storage/git_action.py
Expand Up @@ -437,7 +437,7 @@ def _remove_document(self, gh_user, doc_id, parent_sha, author, commit_msg=None)
doc_dir = os.path.split(doc_filepath)[0]
#_LOG.debug("@@@@@@@@ GitActionBase._remove_document, doc_dir={}".format(doc_dir))
git(self.gitdir, self.gitwd, "rm", "-rf", doc_dir)
elif self.doc_type in ('collection', 'favorites'):
elif self.doc_type in ('collection', 'favorites', 'amendment'):
# delete just the target file
git(self.gitdir, self.gitwd, "rm", doc_filepath)
else:
Expand Down
4 changes: 3 additions & 1 deletion peyotl/sugar/__init__.py
Expand Up @@ -9,6 +9,7 @@
taxomachine = None
phylesystem_api = None
collections_api = None
amendments_api = None
#favorites_api = None
oti = None
tnrs = None
Expand All @@ -19,7 +20,7 @@


def _populate_globals():
global treemachine, oti, phylesystem_api, collections_api, taxomachine, tnrs, \
global treemachine, oti, phylesystem_api, collections_api, amendments_api, taxomachine, tnrs, \
taxonomy, tree_of_life, graph_of_life, studies
from peyotl.api import APIWrapper
api_wrapper = APIWrapper()
Expand All @@ -28,6 +29,7 @@ def _populate_globals():
taxomachine = api_wrapper.taxomachine
phylesystem_api = api_wrapper.phylesystem_api
collections_api = api_wrapper.collections_api
amendments_api = api_wrapper.amendments_api
#global favorites_api
#favorites_api = api_wrapper.favorites_api
tnrs = api_wrapper.tnrs
Expand Down

0 comments on commit 166f7b1

Please sign in to comment.