def __init__(self,
              name,
              path,
              assumed_doc_version=None,
              git_ssh=None,
              pkey=None,
              git_action_class=PhylesystemGitAction,
              push_mirror_repo_path=None,
              new_doc_prefix=None,  # IGNORED in this shard type
              infrastructure_commit_author='OpenTree API <*****@*****.**>',
              **kwargs):
     self.max_file_size = get_config_setting('phylesystem', 'max_file_size')
     TypeAwareGitShard.__init__(self,
                                name,
                                path,
                                doc_holder_subpath,
                                assumed_doc_version,
                                None,  # version detection
                                refresh_amendment_index,  # populates _doc_index
                                git_ssh,
                                pkey,
                                git_action_class,
                                push_mirror_repo_path,
                                infrastructure_commit_author,
                                **kwargs)
     self.filepath_for_doc_id_fn = filepath_for_amendment_id
     self._doc_counter_lock = Lock()
     self._next_ott_id = None
     self._id_minting_file = os.path.join(path, 'next_ott_id.json')
     # N.B. This is for minting invididual taxon (OTT) ids, not amendment ids!
     # We construct each amendment from its unique series of ottids.
     self.filepath_for_global_resource_fn = lambda frag: os.path.join(path, frag)
Example #2
0
 def __init__(
         self,
         name,
         path,
         assumed_doc_version=None,
         git_ssh=None,
         pkey=None,
         git_action_class=PhylesystemGitAction,
         push_mirror_repo_path=None,
         new_doc_prefix=None,  # IGNORED in this shard type
         infrastructure_commit_author='OpenTree API <*****@*****.**>',
         **kwargs):
     self.max_file_size = get_config_setting('phylesystem', 'max_file_size')
     TypeAwareGitShard.__init__(
         self,
         name,
         path,
         doc_holder_subpath,
         assumed_doc_version,
         None,  # version detection
         refresh_amendment_index,  # populates _doc_index
         git_ssh,
         pkey,
         git_action_class,
         push_mirror_repo_path,
         infrastructure_commit_author,
         **kwargs)
     self.filepath_for_doc_id_fn = filepath_for_amendment_id
     self._doc_counter_lock = Lock()
     self._next_ott_id = None
     self._id_minting_file = os.path.join(path, 'next_ott_id.json')
     # N.B. This is for minting invididual taxon (OTT) ids, not amendment ids!
     # We construct each amendment from its unique series of ottids.
     self.filepath_for_global_resource_fn = lambda frag: os.path.join(
         path, frag)
 def __init__(self,
              name,
              path,
              assumed_doc_version=None,
              git_ssh=None,
              pkey=None,
              git_action_class=PhylesystemGitAction,
              push_mirror_repo_path=None,
              new_doc_prefix=None,  # IGNORED in this shard type
              infrastructure_commit_author='OpenTree API <*****@*****.**>',
              **kwargs):
     self.max_file_size = get_config_setting('phylesystem', 'max_file_size')
     TypeAwareGitShard.__init__(self,
                                name,
                                path,
                                doc_holder_subpath,
                                assumed_doc_version,
                                None,  # version detection
                                refresh_collection_index,  # populates _doc_index
                                git_ssh,
                                pkey,
                                git_action_class,
                                push_mirror_repo_path,
                                infrastructure_commit_author,
                                **kwargs)
     self.filepath_for_doc_id_fn = filepath_for_collection_id
     self._doc_counter_lock = Lock()
     self.filepath_for_global_resource_fn = lambda frag: os.path.join(path, frag)
Example #4
0
def Phylesystem(repos_dict=None,
                repos_par=None,
                with_caching=True,
                repo_nexml2json=None,
                git_ssh=None,
                pkey=None,
                git_action_class=PhylesystemGitAction,
                mirror_info=None,
                new_study_prefix=None,
                infrastructure_commit_author='OpenTree API <*****@*****.**>'):
    """Factory function for a _Phylesystem object.

    A wrapper around the _Phylesystem class instantiation for
    the most common use case: a singleton _Phylesystem.
    If you need distinct _Phylesystem objects, you'll need to
    call that class directly.
    """
    if not repo_nexml2json:
        repo_nexml2json = get_config_setting('phylesystem', 'repo_nexml2json')
    global _THE_PHYLESYSTEM
    if _THE_PHYLESYSTEM is None:
        _THE_PHYLESYSTEM = _Phylesystem(repos_dict=repos_dict,
                                        repos_par=repos_par,
                                        with_caching=with_caching,
                                        repo_nexml2json=repo_nexml2json,
                                        git_ssh=git_ssh,
                                        pkey=pkey,
                                        git_action_class=git_action_class,
                                        mirror_info=mirror_info,
                                        new_study_prefix=new_study_prefix,
                                        infrastructure_commit_author=infrastructure_commit_author)
    return _THE_PHYLESYSTEM
Example #5
0
 def __init__(
         self,
         name,
         path,
         assumed_doc_version=None,
         git_ssh=None,
         pkey=None,
         git_action_class=PhylesystemGitAction,
         push_mirror_repo_path=None,
         new_doc_prefix=None,  # IGNORED in this shard type
         infrastructure_commit_author='OpenTree API <*****@*****.**>',
         **kwargs):
     self.max_file_size = get_config_setting('phylesystem', 'max_file_size')
     TypeAwareGitShard.__init__(
         self,
         name,
         path,
         doc_holder_subpath,
         assumed_doc_version,
         None,  # version detection
         refresh_collection_index,  # populates _doc_index
         git_ssh,
         pkey,
         git_action_class,
         push_mirror_repo_path,
         infrastructure_commit_author,
         **kwargs)
     self.filepath_for_doc_id_fn = filepath_for_collection_id
     self._doc_counter_lock = Lock()
     self.filepath_for_global_resource_fn = lambda frag: os.path.join(
         path, frag)
Example #6
0
def _get_phylesystem_parent_with_source(**kwargs):
    src = 'environment'
    try:
        phylesystem_parent = expand_path(get_config_setting('phylesystem', 'parent'))
        src = 'configfile'
    except:
        raise ValueError('No [phylesystem] "parent" specified in config or environmental variables')
    x = phylesystem_parent.split(':')  # TEMP hardcoded assumption that : does not occur in a path name
    return x, src
Example #7
0
 def __init__(
         self,
         name,
         path,
         assumed_doc_version=None,
         git_ssh=None,
         pkey=None,
         git_action_class=PhylesystemGitAction,
         push_mirror_repo_path=None,
         new_study_prefix=None,
         infrastructure_commit_author='OpenTree API <*****@*****.**>',
         **kwargs):
     self.max_file_size = get_config_setting('phylesystem', 'max_file_size')
     TypeAwareGitShard.__init__(
         self,
         name,
         path,
         doc_holder_subpath,
         assumed_doc_version,
         diagnose_repo_nexml2json,  # version detection
         refresh_study_index,  # populates 'study_index'
         git_ssh,
         pkey,
         git_action_class,
         push_mirror_repo_path,
         infrastructure_commit_author,
         **kwargs)
     self._doc_counter_lock = Lock()
     self._next_study_id = None
     self._new_study_prefix = new_study_prefix
     if self._new_study_prefix is None:
         prefix_file = os.path.join(path, 'new_study_prefix')
         if os.path.exists(prefix_file):
             with open(prefix_file, 'r') as f:
                 pre_content = f.read().strip()
             valid_pat = re.compile('^[a-zA-Z0-9]+_$')
             if len(pre_content) != 3 or not valid_pat.match(pre_content):
                 raise FailedShardCreationError(
                     'Expecting prefix in new_study_prefix file to be two '
                     'letters followed by an underscore')
             self._new_study_prefix = pre_content
         else:
             self._new_study_prefix = 'ot_'  # ot_ is the default if there is no file
     self._id_minting_file = os.path.join(path, 'next_study_id.json')
     self.filepath_for_global_resource_fn = lambda frag: os.path.join(
         path, frag)
 def __init__(self,
              name,
              path,
              assumed_doc_version=None,
              git_ssh=None,
              pkey=None,
              git_action_class=PhylesystemGitAction,
              push_mirror_repo_path=None,
              new_study_prefix=None,
              infrastructure_commit_author='OpenTree API <*****@*****.**>',
              **kwargs):
     self.max_file_size = get_config_setting('phylesystem', 'max_file_size')
     TypeAwareGitShard.__init__(self,
                                name,
                                path,
                                doc_holder_subpath,
                                assumed_doc_version,
                                diagnose_repo_nexml2json,  # version detection
                                refresh_study_index,  # populates 'study_index'
                                git_ssh,
                                pkey,
                                git_action_class,
                                push_mirror_repo_path,
                                infrastructure_commit_author,
                                **kwargs)
     self._doc_counter_lock = Lock()
     self._next_study_id = None
     self._new_study_prefix = new_study_prefix
     if self._new_study_prefix is None:
         prefix_file = os.path.join(path, 'new_study_prefix')
         if os.path.exists(prefix_file):
             with open(prefix_file, 'r') as f:
                 pre_content = f.read().strip()
             valid_pat = re.compile('^[a-zA-Z0-9]+_$')
             if len(pre_content) != 3 or not valid_pat.match(pre_content):
                 raise FailedShardCreationError('Expecting prefix in new_study_prefix file to be two '
                                                'letters followed by an underscore')
             self._new_study_prefix = pre_content
         else:
             self._new_study_prefix = 'ot_'  # ot_ is the default if there is no file
     self._id_minting_file = os.path.join(path, 'next_study_id.json')
     self.filepath_for_global_resource_fn = lambda frag: os.path.join(path, frag)