-
Notifications
You must be signed in to change notification settings - Fork 125
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
Rework the tensorflow hook to improve compatibility across different tensorflow versions #46
Conversation
Added two new tests for tensorflow in order to verify that at least the basic tensorflow functionality is both importable and functional: * a basic use of a Conv2D layer * a basic model training and validation on MNIST dataset
…fferent versions Clean and up and rework the tensorflow hook to improve compatibility across different tensorflow versions. Currently, the `tensorflow` hook collects the submodules from `tensorflow_core` in a rather roundabout way: by specifying `tensorflow_core` as a hidden import, and relying on this to pull in `tensorflow_core.python`. The hook for `tensorflow_core.python` is the one that actually collects data and submodules from `tensorflow_core`. This mechanism is brittle, and seems to break on: * tensorflow 1.15.x: due to import rerouting between `tensorflow_core` and `tensorflow`, the `tensorflow_core.python` is not pulled in * tensorflow 2.2.0+: the `tensorflow_core` module has been removed, and its contents now reside within `tensorflow` itself. To fix this issue and improve compatibility across different versions of tensorflow, the `tensorflow_core.python` hook is removed, and `tensorflow` hook is modified to collect data and submodules from either `tensorflow` or `tensorflow_core`, depending on version: * 1.14.x and earlier: collect from `tensorflow` * 1.15.x - 2.1.x: collect from `tensorflow_core` * 2.2x and later: collect from `tensorflow`
Skip tensorflow tests in modes other than onedir mode. With recent tensorflow versions, the resulting dist size could be up to 1.5 GB, which may cause onefile tests to timeout due to relatively long compression and decompression time.
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.
This is really good work. Only issue I see is you forgot the changelog entry 😝 :.
Ohh and there's that linter to appease. God forbid we allow a 95 character long line into our repository... |
Oh, one genuine problem: You forgot to add tensorflow to the Although, in the interest of keeping the CI reasonably quick, I might be tempted to leave it this way. I believe we've already run these tests on all platforms? Is there any need to keep re-running them? @rokm @Legorooj Thoughts on this? |
Thanks for the feedback! Yeah, I figured I'll add the changelog entry after the linter is appeased... (and to add insult to injury, the tests file already contains lines longer than the ones I added here :)) Two questions:
tf_pre_1_15_0 = is_module_satisfies("tensorflow < 1.15.0")
tf_post_1_15_0 = is_module_satisfies("tensorflow >= 1.15.0")
tf_pre_2_0_0 = is_module_satisfies("tensorflow < 2.0.0")
tf_pre_2_2_0 = is_module_satisfies("tensorflow < 2.2.0")
if tf_pre_1_15_0:
... and using those within the if/else clauses. Would that be OK?
As for On the other hand, with tensorflow, people will likely be using specific versions instead of the latest one due to incompatibilities and the fact that academic code usually doesn't get maintained after the paper publication... |
Umm, well we can circumvent PyInstaller slightly: from pkg_resources import get_distribution, Requirement
tf_version = get_distribution("tensorflow").version Then bizarrely you use tf_version in Requirement.parse("x>1.15") To be honest, I'd go with what you were suggesting, just because it's less confusing to read.
That's reassuring 🤣. And you're right in that we can only test one version with our current CI setup. I say we leave this one out then. If/when a significantly different update hits either PyInstaller or tensorflow then we can do another 1-shot bulk test again. I'll be sure not to delete that branch - although I have big plans for our CI to make that kind custom of one-off testing more accessible.
I think your last point is an important one. Normally we'd be able to forget about much older versions of packages but I guess in this case we can't. Ohh well... |
Ignore the linter failures - I've been meaning to adjust the limit to 100 chars. |
A minor cleanup; use `is_module_satisfies()` to define version related booleans, and then use those in the if/else blocks to make them easier to read.
Also grouped the tensorflow tests together in the test_libraries.py
OK, I moved those |
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.
Well, I'm happy. @Legorooj Ready to merge?
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.
Nice work!
This PR reworks the
tensorflow
hook to improve compatibility across differenttensorflow
versions, with aim to fix issues such as pyinstaller/pyinstaller#5002.Currently, the
tensorflow
hook collects the submodules fromtensorflow_core
in a rather roundabout way: by specifyingtensorflow_core
as a hidden import, and relying on this to pull intensorflow_core.python
. The hook fortensorflow_core.python
is the one that actually collects data and submodules fromtensorflow_core
.This mechanism is brittle, and seems to break on:
tensorflow_core
andtensorflow
, thetensorflow_core.python
is not pulled intensorflow_core
module has been removed, and its contents now reside withintensorflow
itself.To fix this issue and improve compatibility across different versions of tensorflow, the
tensorflow_core.python
hook is removed, andtensorflow
hook is modified to collect data and submodules from eithertensorflow
ortensorflow_core
, depending on version:tensorflow
tensorflow_core
tensorflow
The PR also adds two new tests for verifying that basic functionality of
tensorflow
actually works, and aim to uncover submodule-not-found errors that are not picked up by the existing (import) test.In addition, all three
tensorflow
tests inonefile
mode are now skipped, because the latest versions oftensorflow
are quite large (~1.5 GB), and theonefile
tests sometimes timeout due to compression/decompression times.