[BUG] [flytekit] _ModuleSanitizer returns a wrong name when site-packages/__init__.py
exists.
#6180
Open
2 tasks done
site-packages/__init__.py
exists.
#6180
Describe the bug
When a library puts
__init__.py
directly under thesite-packages
directory (maybe accidentally),_ModuleSanitizer.get_absolute_module_name
doesn't return the correct absolute module name. For example, forflytekit.core.python_auto_container.default_task_resolver
, it returnssite-packages.flytekit.core.python_auto_container.default_task_resolver
and this causespyflyte-execute
to fail because it's passed as--resolver
argument.I encountered this when torchsurv was installed.
Not sure if this is an issue Flyte needs to solve, or this library needs to be updated. Still, I'm currently deleting
site-packages/__init__.py
after installing the library, and it is brittle.A few fixes I can think of is,
__init__.py
doesn't exist in the dir, it can end the recursion when thedirname
matches what's insys.path
.flytekit
as a special case in the sanitizer.I'm not very familiar with this part, so my suggestions may break other usage, though. Happy to contribute a PR. Some pointers are really appreciated.
(a separate issue, but a counter example in the other direction may be namespace packages. a dir without
__init__.py
doesn't mean it's the root)Expected behavior
_ModuleSanitizer.get_absolute_module_name
always returnsflytekit.core.python_auto_container.default_task_resolver
for the default task resolver, even whensite-packages/__init__.py
exists.Additional context to reproduce
No response
Screenshots
No response
Are you sure this issue hasn't been raised already?
Have you read the Code of Conduct?
The text was updated successfully, but these errors were encountered: