NextCenturyCorporation / AIDA-Interchange-Format

Java/python library and validator for the AIDA Interchange Format (AIF). Originally based on isi-vista/gaia-interchange.
MIT License
21 stars 11 forks source link

rdf_ontologies not included when Python package installed using setup.py #293

Closed charman closed 4 years ago

charman commented 4 years ago

TL;DR version

In the develop branch, when setup.py is used to install the aida_interchange package, aida_interchange.rdf_ontologies is not included in the package because there is no __init__.py file in python/aida_interchange/rdf_ontologies/.

Problem

The setup.py tool in python/ uses setuptools.find_packages() to find any (sub)packages. Per the setuptools documentation:

find_packages() walks the target directory, filtering by inclusion patterns, and finds Python packages (any directory). Packages are only recognized if they include an __init__.py file.

Because there is no python/aida_interchange/rdf_ontologies/__init__.py file, setup.py will not include the aida_interchange.rdf_ontologies package when installing aida_interchange.

The file aida_interchange/aifutils.py has an import statement that assumes that aida_interchange.rdf_ontologies is installed:

from aida_interchange.rdf_ontologies import interchange_ontology   

but if aida_interchange is installed via setup.py, the above import statement will fail with the exception:

ModuleNotFoundError: No module named 'aida_interchange.rdf_ontologies'

Solution

Create an empty python/aida_interchange/rdf_ontologies/__init__.py file.

charman commented 4 years ago

Please let me know if you want a unit test or pull request.

eaciv commented 4 years ago

@charman, thanks for finding this. The python constants were a recent addition and we must have missed this. A unit test is really what we need, but we haven't made unit tests part of our build process for python yet. If you have some suggestions for adding unit tests to this project, we would love to hear them. In the meantime, I will add the init.py file to the rdf_ontologies directory.

Please feel free to add more suggestions or submit pull requests for features that you've added and think the library/project would benefit from.

eaciv commented 4 years ago

@charman, Your solution for this should be 'implemented' now. Take a look when you get a chance and let us know if it works.

charman commented 4 years ago

@ecurley-nextcentury - I'm confirming that the changes in 618d6ae fixed the problem. Thanks!

Just for reference, I'm installing the code as a dependency by adding this line:

git+https://github.com/NextCenturyCorporation/AIDA-Interchange-Format@develop#subdirectory=python

to my requirements.txt file and then running pip install -r requirements.txt.

As for unit tests, does CACI(/NCC) have any institutional preferences for using Travis CI vs. GitHub Actions to run CI tests for code hosted on GitHub? Even if no one is actually writing unit tests, setting up CI to use tox to install the package in a clean virtual environment and pytest to scan for errors would have caught this particular Issue.

eaciv commented 4 years ago

Great! Thanks for confirming. We usually do our installation via virtual environments using pip install -e on the python directory.

We don't currently have any institutional preferences, but I've been wondering if Github actions could work for this project. Sadly, I haven't really had the time to look into it. Those are great suggestions and we'll definitely look into them. Thanks!

Closing this issue.