rodricios / autocomplete

Autocomplete - an adult and kid friendly exercise in creating a predictive program
450 stars 74 forks source link

model.train_models(), et al currently save files in the library's install location #6

Closed saxbophone closed 2 years ago

saxbophone commented 7 years ago

In the context of models.py, os.path.dirname(__file__) will return the directory that the models.py is located. As a result, when models.train_models() (or any other function which writes to file in that module) is called, it invariably writes to the location that the library was installed to (if installed via pip).

This will cause permission denied errors if the module was installed to the system install location via sudo. Even if this is not the case, this will clutter up the directory that the module was installed to with user data (and there's also a possibility that it might actually overwrite one of the files that are a part of the library).

I have a patch for this in https://github.com/DecodedCo/autocomplete/commit/f13d3e9f7a6edf7ed1dbad8cd3cbfbd333ec0bb0, which I will open a pull request for once tested.