Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct issue with corpus loading process #69

Merged
merged 3 commits into from
Oct 28, 2015
Merged

Correct issue with corpus loading process #69

merged 3 commits into from
Oct 28, 2015

Conversation

gunthercox
Copy link
Owner

This makes corrections to the loading process for loading corpus modules where an import error is occurring.

Previously, if tests failed, randomly named test databases could
be left behind. This change makes it so that all test data files
are created within a directory which is created and removed after
tests have finished. In the case on an exception, a directory is
easier to manually clean up than many data files.
@@ -1,4 +1,5 @@
import importlib
from importlib import import_module as import_string
from inspect import isclass
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this being used anywhere?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe so. I will make sure to remove them before this is merged. I'm currently getting better, results with these changes (basically attempting to use python modules for data instead of json files) but I'm still hitting an issue where importlib is returning a different sub-module depending on how it is called (works in tests, fails in application).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you aren't hitting the issue on Python 3, it might be an issue with relative imports vs absolute imports.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It appears to be both python ~2.7 and 3. I am planning on scrapping importing data files as python modules in favor of importing them as regular files. The advantage is that it is easier to traverse a directory and find all of the contained .json files than it is to traverse a python module to find all of the sub-modules.

Previously, corpus data modules were being treated as python modules.
This caused some strange issues with relative imports.
The problem has been fixed by redesigning the corpus loader to use
a data directory and traverse subdirectories to load any data files
contained within.
gunthercox added a commit that referenced this pull request Oct 28, 2015
Correct issue with corpus loading process
@gunthercox gunthercox merged commit af6e512 into master Oct 28, 2015
@gunthercox gunthercox deleted the imports branch October 28, 2015 00:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants