Open
Description
When trying to run tests under bazel bazel test //api/py:api_test --test_output=streamed
all tests are failing with import error. Example:
_________ ERROR collecting api/py/test/lineage/test_parse_group_by.py __________
ImportError while importing test module '/private/var/tmp/_bazel_omoskalenko/916470916a9b457c8ac69ce8ce573113/execroot/chronon/bazel-out/darwin_arm64-fastbuild/bin/api/py/api_test.runfiles/chronon/api/py/test/lineage/test_parse_group_by.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
../../../../../../../../../external/python_3_8_aarch64-apple-darwin/lib/python3.8/importlib/__init__.py:127: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
api/py/test/lineage/test_parse_group_by.py:18: in <module>
from ai.chronon import group_by
api/py/ai/chronon/group_by.py:20: in <module>
import ai.chronon.api.ttypes as ttypes
E ModuleNotFoundError: No module named 'ai.chronon.api'
The root cause of it: there are two identical Python modules named ai.chronon
created under two Bazel packages with outputs:
bazel-out/darwin_arm64-fastbuild/bin/api/py/api_test.runfiles/chronon/api/py/
bazel-out/darwin_arm64-fastbuild/bin/api/py/api_test.runfiles/chronon/api/thrift/
They both have structure:
ai/
chronon/
__init__.py
Both of them added to sys.path
. However, Python can't load both of them. When it discovers the first package under chronon/api/py/
it then looks for ai.chronon.api
only there.
Possible solutions:
- Rename module
ai.chronon.api
->ai.chronon_api
to work around the module loading issue. - Move bazel target generating thrift to
api/py
package.
Metadata
Metadata
Assignees
Labels
No labels