示例#1
0
    def _ontology_local_repo(self):
        try:
            stated_repo = Path(self.config['ontology_local_repo'])
        except (KeyError, TypeError, FileNotFoundError) as e:
            stated_repo = Path('/dev/null/does-not-exist')

        maybe_repo = self._maybe_repo
        if stated_repo.exists():
            return stated_repo
        elif maybe_repo.exists():
            return maybe_repo
        else:
            maybe_start = Path(__file__).parent.parent.parent.absolute()
            maybe_base = maybe_start
            fsroot = Path('/')
            while maybe_base != fsroot:
                maybe_repo = maybe_base / self.ontology_repo
                if maybe_repo.exists():
                    log.info(
                        tc.blue('INFO:') +
                        f'Ontology repository found at {maybe_repo}')
                    return maybe_repo
                else:
                    maybe_base = maybe_base.parent
            else:
                log.warning(
                    tc.red('WARNING:') +
                    f'No repository found in any parent directory of {maybe_start}'
                )

        return Path('/dev/null/does-not-exist')  # seems reaonsable ...
示例#2
0
 def secrets(self):
     try:
         return oa.stores.Secrets(self.secrets_file)
     except FileNotFoundError:
         log.warning(
             f'secrets file {self.secrets_file} does not exist. '
             'You can set an alternate path under the secrets_file: '
             f'variable in {self.config_file}')
示例#3
0
    def exists(self):
        e = Path(self.filename).exists()
        if not e:
            log.warning(
                f'secrets file {self.filename} does not exist. '
                'You can set an alternate path under the secrets_file: '
                f'variable in {self.devconfig.config_file}')

        return e
示例#4
0
from pathlib import Path
from tempfile import gettempdir
from functools import wraps
import orthauth as oa
from pyontutils.utils import TermColors as tc, log
from pyontutils.utils import get_working_dir

oa.utils.log.removeHandler(oa.utils.log.handlers[0])
oa.utils.log.addHandler(log.handlers[0])

auth = oa.configure_here('auth-config.py', __name__)

pyontutils_config_path = auth.dynamic_config._path.parent
if not pyontutils_config_path.parent.exists():
    log.warning(
        f'config path does not exist! Errors incoming! {pyontutils_config_path.parent}'
    )

default_config = pyontutils_config_path / 'devconfig.yaml'
working_dir = get_working_dir(__file__)
_data_curies_string = 'share/idlib/local-conventions/nifstd/curie_map.yaml'  # XXX
system_curies_path = Path(sys.prefix) / _data_curies_string
if working_dir is None:
    # we are not in git, we are probably testing or installed by a user
    default_curies = pyontutils_config_path / 'curie_map.yaml'
    # hardcoding the default api here to avoid importing the scigraph client
    default_scigraph_api = 'https://scicrunch.org/api/1/scigraph'
else:
    default_curies = working_dir / 'nifstd' / 'scigraph' / 'curie_map.yaml'
    default_scigraph_api = 'http://localhost:9000/scigraph'