-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Conversation
3525f9f
to
a434165
Compare
573202b
to
a05baa3
Compare
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. |
There was a problem hiding this 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!
@reuben Could we imagine a way to be able to detect if the code has not been installed using |
@lissyx it will not run if the package has not been installed. |
There was a problem hiding this 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.
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. |
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 dopip 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 thecwd
is. For paths that are received directly from the user nothing needs to be done as they are already relative tocwd
.I've removed the
sys.path
hacks from the importers and fixed any importing inconsistencies. I've also left compatibility scripts inDeepSpeech.py
,evaluate.py
andutil/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 ofpython 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 thegit mv
s.