-
Notifications
You must be signed in to change notification settings - Fork 221
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
stubgen: Fix the detection of modules without spec. #940
base: master
Are you sure you want to change the base?
Conversation
This PR fixes the logic that tries to find which dot (`.`) separates the module from the class in a nested type name in `simplify_types`. The current logic flipped the components, creating invalid type names. Signed-off-by: Ingo Müller <[email protected]>
This PR changes the logic of `is_valid_module` used in `simplify_types`. That function uses `importlib.util.find_spec` and previously tested the return value for `is None`. However, (1) if the spec is actually `None`, then the function doesn't return `None` but raises `ValueError`, so that test never succeeded and (2) if a module with a `None` spec was found, we have still found a module, so `is_valid_module` should actually return `True` instead of `False`. Signed-off-by: Ingo Müller <[email protected]>
b47dd53
to
b44dda4
Compare
OK, I think I need some help now, or at least input from a discussion. Turns out that the importing of nested modules was broken in two different ways that hid each other. #939 fixes how nested modules are broken up into module and class; this PR fixes the detection of whether a module exists or not. For a module to be valid according to |
I haven't installed any of the big tensor frameworks on the CI since that makes things very slow (plus, there aren't any GPUs there to test non-CPU device paths). That means that stubgen may need to make stubs involving types of a package that hasn't been installed. |
I understand. This has another advantage: if detecting whether a string represents a valid module depends on the installed packages, then What is the solution, then? Do it only string-based? For |
I don't think that that works. I quickly implemented this; now this case isn't handled correctly anymore: I don't see how this can be handled without inspection of the actual module and I don't think that that, in turn, can be done without installing the packages. One option to handle that latter issue is to skip that test in CI (or in all but one target). |
b44dda4
to
7d1bc1b
Compare
This commit extracts the functions involving JAX and TensorFlow types from the module in `test_ndarray.cpp` into their own respective modules and sets up the boilerplate code to turn them into independent tests. This allows to put the corresponding stub generation tests behind a flag and deactivate them by default. Signed-off-by: Ingo Müller <[email protected]>
7d1bc1b
to
bcb866b
Compare
@wjakob, check out the latest version. I moved the JAX- and TensorFlow-related tests into dedicated files and put those behind a flag that isn't enabled in CI. WDYT? |
This PR is stacked on top and, therefor, contains the commits of #939.
This PR changes the logic of
is_valid_module
used insimplify_types
. That function usesimportlib.util.find_spec
and previously tested the return value foris None
. However, (1) if the spec is actuallyNone
, then the function doesn't returnNone
but raisesValueError
, so that test never succeeded and (2) if a module with aNone
spec was found, we have still found a module, sois_valid_module
should actually returnTrue
instead ofFalse
.