diff --git a/.travis.yml b/.travis.yml index 0e8b5169..323450d6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -48,3 +48,7 @@ script: after_success: - if [[ $HAS_COVERALLS && $TRAVIS_PYTHON_VERSION == 3.7 ]] ; then coveralls ; fi + +after_failure: + # for now we want converage even if things fail + - if [[ $HAS_COVERALLS && $TRAVIS_PYTHON_VERSION == 3.7 ]] ; then coveralls ; fi diff --git a/README.md b/README.md index efebe996..b7f912f9 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ from your local copy of this repo. 1. [~/.config/pyontutils/config.yaml](${HOME}/.config/pyontutils/config.yaml). This file can be used to augment the varibles defined in [auth-config.py](./pyontutils/auth-config.py). For more details about the config see the [orthauth guide](https://github.com/tgbugs/orthauth/blob/master/docs/guide.org). -2. [secrets.yaml](${HOME}/.config/pyontutils/secrets.yaml) that you can put wherever +2. [secrets.yaml](${HOME}/.config/orthauth/secrets.yaml) that you can put wherever you want by editing the `auth-stores: secrets: path:` entry in [config.yaml](${HOME}/.config/pyontutils/config.yaml). The file mode needs to be set to `0600` so that only you can read and write it. It is also advisable to place it inside a folder with a mode set to `0700` since diff --git a/pyontutils/__init__.py b/pyontutils/__init__.py index d83c2a9f..e160d939 100644 --- a/pyontutils/__init__.py +++ b/pyontutils/__init__.py @@ -1 +1 @@ -__version__ = '0.1.19' +__version__ = '0.1.20' diff --git a/pyontutils/make_catalog.py b/pyontutils/make_catalog.py index 23a65100..2e4f932c 100755 --- a/pyontutils/make_catalog.py +++ b/pyontutils/make_catalog.py @@ -1,4 +1,5 @@ #!/usr/bin/env python3 +from pyontutils.config import auth __doc__ = f"""Generate ttl/catalog-*.xml Usage: @@ -6,10 +7,11 @@ ont-catalog [options] ... Options: - -b --big when creating catalog also import big files - reccomend running this option with pypy3 - -j --jobs=NJOBS number of parallel jobs to run [default: 9] - -d --debug break at the end + -b --big when creating catalog also import big files + reccomend running this option with pypy3 + -j --jobs=NJOBS number of parallel jobs to run [default: 9] + -d --debug break at the end + -l --ontology-local-repo=OLR path to ontology [default: {auth.get_path('ontology-local-repo')}] """ import os @@ -19,7 +21,6 @@ from git import Repo from pyontutils.utils import anyMembers from pyontutils.core import displayTriples -from pyontutils.config import auth from pyontutils.ontload import local_imports try: breakpoint @@ -32,7 +33,7 @@ def main(): args = docopt(__doc__, version='ont-catalog 0.0.1') dobig = args['--big'] remote_base = 'http://ontology.neuinfo.org/NIF/ttl/' - olr = auth.get_path('ontology-local-repo') + olr = Path(args['--ontology-local-repo']) local_base = (olr / 'ttl').as_posix() + '/' #list of all nif ontologies diff --git a/pyontutils/ontutils.py b/pyontutils/ontutils.py index 0be7935b..500a74b0 100755 --- a/pyontutils/ontutils.py +++ b/pyontutils/ontutils.py @@ -323,10 +323,11 @@ def version_iri(filename, epoch): def make_version_iri_from_iri(iri, epoch): - pp = PurePath(iri) + head, tail = iri.split('/', 1) + pp = PurePath(tail) vp = (pp.with_suffix('') / 'version' / str(epoch) / pp.stem).with_suffix(pp.suffix) - versionIRI = rdflib.URIRef(str(vp)) - print(versionIRI) + viri = head + str(vp) + versionIRI = rdflib.URIRef(viri) return rdflib.URIRef(versionIRI) diff --git a/setup.py b/setup.py index 6d313c7a..512924c4 100644 --- a/setup.py +++ b/setup.py @@ -41,7 +41,7 @@ def find_version(filename): tests_require=tests_require, install_requires=[ 'appdirs', - 'augpathlib>=0.0.10', + 'augpathlib>=0.0.11', 'colorlog', 'docopt', 'gitpython', diff --git a/test/owl-test.ttl b/test/owl-test.ttl new file mode 100644 index 00000000..c3bebffd --- /dev/null +++ b/test/owl-test.ttl @@ -0,0 +1,7 @@ +@prefix : . +@prefix owl: . + + a owl:Ontology ; + :asdf . + +### Serialized using the ttlser deterministic serializer v1.2.0 diff --git a/test/test_integration.py b/test/test_integration.py index 0f67bc7b..35d14d5a 100644 --- a/test/test_integration.py +++ b/test/test_integration.py @@ -4,6 +4,7 @@ from pathlib import Path from importlib import import_module import pytest +import augpathlib as aug import pyontutils from pyontutils.utils import get_working_dir from pyontutils.config import auth @@ -30,6 +31,12 @@ def test_query(self): class TestScripts(Folders, _TestScriptsBase): """ woo ! """ + def setUp(self): + super().setUp() + _temp_git.init() + _test_ttl.copy_outto(_temp_git) + _test_owl.copy_outto(_temp_git) + TestScripts.temp_path = temp_path @@ -61,32 +68,73 @@ class TestScripts(Folders, _TestScriptsBase): import inspect sf = inspect.getsourcefile(pyontutils) working_dir = Path(sf).parent.parent - #working_dir = Path(__file__).parent.parent +else: + class RP(aug.RepoPath): + """ can't just change RepoPath._repo_class due to + fail in the no commit case """ + _repo_class = Repo + + RP._bind_flavours() + working_dir = RP(working_dir) glb = auth.get_path('git-local-base') olr = auth.get_path('ontology-local-repo') if olr.exists(): ont_repo = Repo(olr) - post_load = lambda : (ont_repo.remove_diff_untracked(), ont_repo.checkout_diff_tracked()) - post_main = lambda : (ont_repo.remove_diff_untracked(), ont_repo.checkout_diff_tracked()) - do_mains = True + if isinstance(working_dir, aug.RepoPath): + this_repo = working_dir.repo + post_load = lambda : (ont_repo.remove_diff_untracked(), + ont_repo.checkout_diff_tracked(), + this_repo.remove_diff_untracked(), + this_repo.checkout_diff_tracked(),) + post_main = lambda : (ont_repo.remove_diff_untracked(), + ont_repo.checkout_diff_tracked(), + this_repo.remove_diff_untracked(), + this_repo.checkout_diff_tracked(),) + else: + post_load = lambda : (ont_repo.remove_diff_untracked(), + ont_repo.checkout_diff_tracked()) + post_main = lambda : (ont_repo.remove_diff_untracked(), + ont_repo.checkout_diff_tracked()) else: - post_load = lambda : None - post_main = lambda : None - do_mains = True + if isinstance(working_dir, aug.RepoPath): + this_repo = working_dir.repo + post_load = lambda : (this_repo.remove_diff_untracked(), + this_repo.checkout_diff_tracked(),) + post_main = lambda : (this_repo.remove_diff_untracked(), + this_repo.checkout_diff_tracked(),) -### build mains + else: + post_load = lambda : None + post_main = lambda : None + + +do_mains = True + + +default_dir = aug.AugmentedPath(__file__).parent + +_test_ttl = (default_dir / 'graphload-test.ttl') +test_ttl = _test_ttl.as_posix() +_test_owl = (default_dir / 'owl-test.ttl') +test_owl = _test_owl.as_posix() +_temp_git = aug.RepoPath(temp_path) / 'git-test' +temp_git = _temp_git.as_posix() -test_ttl = (Path(__file__).parent / 'graphload-test.ttl').as_posix() -nifttl = (olr / 'ttl/nif.ttl').as_posix() nsmethodsobo = (glb / 'methodsOntology/source-material/ns_methods.obo').as_posix() + + +### build mains + mains = {'scigraph':None, 'combinators':None, 'hierarchies':None, 'googapis': None, 'closed_namespaces':None, #'docs':['ont-docs'], # can't seem to get this to work correctly on travis so leaving it out for now - 'make_catalog':['ont-catalog', '--jobs', '1'], # hits the network + 'make_catalog':['ont-catalog', + '-l', temp_git, + '--jobs', '1'], # hits the network 'graphml_to_ttl':['graphml-to-ttl', 'development/methods/methods_isa.graphml'], #['ilxcli', '--help'], 'obo_io':['obo-io', '--ttl', nsmethodsobo], # this should also fail, but doesn't ? @@ -99,18 +147,18 @@ class TestScripts(Folders, _TestScriptsBase): ], 'necromancy':['necromancy', '-l', temp_path_ap, '--mkdir', test_ttl], 'ontload':[['ontload', '--help'], - ['ontload', 'chain', 'NIF-Ontology', 'NIF', nifttl, + ['ontload', 'chain', 'NIF-Ontology', 'NIF', test_owl, '--zip-location', temp_path_ap], # this hits the network, so why doesn't it fail in sandbox? ['ontload', 'config', 'NIF-Ontology', 'NIF', '--zip-location', temp_path_ap,], ['ontload', 'graph', 'NIF-Ontology', 'NIF', '--zip-location', temp_path_ap, '--git-local', temp_path_ap, - '--graphload-ontologies', (Path(__file__).parent / 'ontologies-test.yaml').resolve().as_posix()], # FIXME cleanup + '--graphload-ontologies', (default_dir / 'ontologies-test.yaml').resolve().as_posix()], # FIXME cleanup ['ontload', 'imports', 'NIF-Ontology', 'NIF', test_ttl]], 'ontutils':[['ontutils', '--help'], - ['ontutils', 'deadlinks', nifttl], - ['ontutils', 'version-iri', nifttl], + ['ontutils', 'deadlinks', test_owl], + ['ontutils', 'version-iri', test_owl], #['ontutils', 'spell', test_ttl], # FIXME skipping for now due to huspell dependency #['ontutils', 'diff', 'test/diff-before.ttl', 'test/diff-after.ttl', 'definition:', 'skos:definition'], ],