Summary
I’m trying to make a custom python package usable inside a Redash query that use the python data source. The Redash server is self-hosted, running in a docker container (Debian GNU/Linux 10). The whole instance is managed by docker-compose. The Redash version is 9.0.0-beta (dev). For now, we are not able to update to a newer version of Redash.
What I tried
I created a test code python file, initially with only one method, let’s say test_method()
. I copied the file onto the docker container to “/home/username/custom-python-for-redash/test_code.py”.
Then I restarted the Redash instance and added this very same absolute path to the AdditionalModulesPaths option of the python data source. When I try to use the code in a query, e.g. by typing
from test_code import test_method
print(test_method())
I get
Error running query: <class 'Exception'> 'test_code' is not configured as a supported import module
I also tried to make my python module a package to rule out the possibility that only proper packages are supported for import in Redash. For that, I moved it into a subdirectory (say: test_package
) and created a __init__.py
file. Then I copied said subdirectory to the container, like above, this time to “/home/username/custom-python-for-redash/test_package”.
I restarted the Redash instance again and added this absolute path to the AdditionalModulesPaths option. However, this yields the same error as written above.
In my despair I also tried (semi-random) variations for the absolute path, e.g. including or omitting the .py
extension, using the path to the __init__.py
file, using the path to the package directory instead of the actual file in it, etc. but with no results.