ontobio icon indicating copy to clipboard operation
ontobio copied to clipboard

Absent owltools error message should be more useful

Open lhannest opened this issue 5 years ago • 11 comments

If owltools is not installed then this produces an exception:

https://github.com/biolink/ontobio/blob/080eabca82e1d1de3f661e4d7996c543cfa700e9/ontobio/ontol_factory.py#L104-L106

  File "/home/lance/git/2019/January/wf2/venv/lib/python3.6/site-packages/ontobio/ontol_factory.py", line 106, in create_ontology
    cp = subprocess.run(cmd, check=True)
  File "/usr/lib/python3.6/subprocess.py", line 403, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/usr/lib/python3.6/subprocess.py", line 709, in __init__
    restore_signals, start_new_session)
  File "/usr/lib/python3.6/subprocess.py", line 1344, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'owltools': 'owltools'

This exception should be caught, and re-raised with a more useful error message like:

"Owltools is required but not installed, see installation documentation here: https://github.com/owlcollab/owltools/wiki/Install-OWLTools"

lhannest avatar Feb 11 '19 17:02 lhannest

We should actually use robot not owltools, robot is more standard, and easier to install, there is also a docker container

cmungall avatar Feb 11 '19 19:02 cmungall

And note that we should also be encouraging the use of the json file directly

cmungall avatar Feb 13 '19 20:02 cmungall

There is not mention in the docs that this is a requirement either..

matentzn avatar Sep 11 '20 12:09 matentzn

For quickfix: This is how I install owltools locally:

TOOLSDIR=~/tools # must be on path
OWLTOOLS=2020-04-06
wget https://github.com/owlcollab/owltools/releases/download/$OWLTOOLS/owltools -O $TOOLSDIR/owltools && \
    wget https://github.com/owlcollab/owltools/releases/download/$OWLTOOLS/ontology-release-runner -O $TOOLSDIR/ontology-release-runner && \
    wget https://github.com/owlcollab/owltools/releases/download/$OWLTOOLS/owltools-oort-all.jar -O $TOOLSDIR/owltools-oort-all.jar && \
    chmod +x $TOOLSDIR/owltools && \
    chmod +x $TOOLSDIR/ontology-release-runner && \
    chmod +x $TOOLSDIR/owltools-oort-all.jar

matentzn avatar Sep 11 '20 12:09 matentzn

Even with this I cant get it to work. I tried the instructions here.

from ontobio.ontol_factory import OntologyFactory
mondo_file="/Users/matentzn/ws/mondo/src/ontology/mondo-merged-robot.owl"
ofa = OntologyFactory()
ont = ofa.create(mondo_file)

I keep getting an error:

FileNotFoundError: [Errno 2] No such file or directory: 'owltools'

This error is caused by some part of the code that does:

~/opt/anaconda3/lib/python3.8/site-packages/ontobio/ontol_factory.py in translate_file_to_ontology(handle, **args)
    163         if not os.path.isfile(fn):
    164             cmd = ['owltools',handle,'-o','-f','json',fn]
--> 165             cp = subprocess.run(cmd, check=True)
    166             logger.info(cp)
    167         else:

@deepakunni3 @cmungall any idea?

For now, I am working around the issue by converting the ontology into obographs json myself and loading that (which does not need owltools).

matentzn avatar Sep 11 '20 13:09 matentzn

Hmm.. Given that I cant use obographs because of #468 and I cant use owl/obo because of this here problem, please let me know if you have an idea for a workaround - otherwise I cant build our amazing QC pipelines..

matentzn avatar Sep 11 '20 13:09 matentzn

@matentzn The owltools needs to be in your PATH as well. Ontobio can't find it in your PATH and thus raises the exception.

Yes, we have gone back and forth on whether to even have this dependency. But you are right. This needs to be documented better.

deepakunni3 avatar Sep 11 '20 16:09 deepakunni3

If I do:

import os
print(os.environ['PATH'])
stream = os.popen('owltools --help')
output = stream.read()
output

It just works.. What else do you mean I need to do?

matentzn avatar Sep 11 '20 17:09 matentzn

What I mean by the above is, owltools is found; while ontobio still fails.

matentzn avatar Sep 11 '20 17:09 matentzn

That's strange. So Ontobio still fails with owltools in PATH.

I'll take a look and see what's causing this. Thanks for the steps above for reproducing this issue.

deepakunni3 avatar Sep 11 '20 17:09 deepakunni3

Ok, rookie mistake:

I was using the ~/ in my path, which the system understand, but python does not. Works now! Thanks @deepakunni3

matentzn avatar Sep 30 '20 10:09 matentzn