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

Package training code to avoid sys.path hacks #2856

Merged
merged 8 commits into from
Mar 31, 2020

Conversation

reuben
Copy link
Contributor

@reuben reuben commented Mar 25, 2020

This makes it so that the training code is actually installable, and avoids the need for sys.path hacks to import things. Now we have proper relative imports. For development, one should do pip install -e . in the root folder. This will install the training code in editable mode, meaning you can make changes to the code and they'll be reflected instantly (it's just a symbolic link).

The biggest catch here is assumptions about paths and cwd. Code should use file-relative paths instead of assuming what the cwd is. For paths that are received directly from the user nothing needs to be done as they are already relative to cwd.

I've removed the sys.path hacks from the importers and fixed any importing inconsistencies. I've also left compatibility scripts in DeepSpeech.py, evaluate.py and util/taskcluster.py, since we've been advertising these for a while. We can also deprecate them in favor of more robust solutions, such as adding entry points in the setup script which add PATH-visible commands, or simply telling users to use e.g. python -m deepspeech_training.train instead of python DeepSpeech.py.

I've also included some small linter fixes since it was throwing a bunch of problems, and fixed stats.py which was broken by the SDB PR. Sorry for not breaking it all in commits, I was working quickly and by the time things fell into place it was too late, specially with all the git mvs.

@reuben reuben force-pushed the training-install branch 6 times, most recently from 3525f9f to a434165 Compare March 25, 2020 19:28
@reuben
Copy link
Contributor Author

reuben commented Mar 25, 2020

I'm asking for review from y'all three mostly so you're aware of this big change. The vast majority of it is just shuffling code from one place to the other and adapting imports, so don't feel like you have to review line by line.

setup.py Outdated Show resolved Hide resolved
bin/gpu_usage_chart Outdated Show resolved Hide resolved
bin/build_sdb.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@lissyx lissyx left a comment

Choose a reason for hiding this comment

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

Thanks for that big piece!

@lissyx
Copy link
Collaborator

lissyx commented Mar 27, 2020

@reuben Could we imagine a way to be able to detect if the code has not been installed using pip when people try to run it ? So we can avoid all the long tail of those not reading the documentation and then complaining ?

@reuben
Copy link
Contributor Author

reuben commented Mar 27, 2020

@lissyx it will not run if the package has not been installed.

Copy link
Contributor

@kdavis-mozilla kdavis-mozilla left a comment

Choose a reason for hiding this comment

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

Generally looks good only saw a few little nits.

bin/import_fisher.py Outdated Show resolved Hide resolved
bin/import_freestmandarin.py Show resolved Hide resolved
bin/import_gram_vaani.py Show resolved Hide resolved
bin/import_librivox.py Show resolved Hide resolved
bin/import_lingua_libre.py Show resolved Hide resolved
bin/import_vctk.py Outdated Show resolved Hide resolved
bin/import_voxforge.py Show resolved Hide resolved
bin/import_voxforge.py Outdated Show resolved Hide resolved
setup.py Outdated Show resolved Hide resolved
tests/test_importers.py Show resolved Hide resolved
@reuben reuben merged commit 83d22e5 into mozilla:master Mar 31, 2020
@reuben reuben deleted the training-install branch March 31, 2020 13:42
@lock
Copy link

lock bot commented May 5, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators May 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants