Can't connect superset to dremio - apache-superset

I am running apache-superset using docker-compose by following the instructions here (https://superset.apache.org/docs/installation/installing-superset-using-docker-compose/) using docker-compose-non-dev.yml.
I have also added sqlalchemy-dremio to superset/docker/requirements-local.txt, in order to add dremio support as mentioned here (https://superset.apache.org/docs/databases/docker-add-drivers)
For dremio, I have a seperate container running on dremio/dremio-oss image using
docker run -p 9047:9047 -p 31010:31010 -p 45678:45678 -p 32010:32010 dremio/dremio-oss
and then made an account in dremio using the web interface at localhost:9047
But when I try to add dremio as a database in superset I get the following errors
on pressing test connection I get the following error
The connection string I'm using is
dremio+flight://dremio:dremio123#host.docker.internal:32010/dremio;SSL=0
At first I thought it might be a network error or an error in dremio, but I can connect to dremio using the python script here https://github.com/dremio-hub/arrow-flight-client-examples/blob/main/python/example.py
python example.py -host host.docker.internal -query 'SELECT 1'
This script runs successfully from both outside the container from host_os using localhost and from inside the superset_app container using host.docker.internal as host. Therefore I don't think its a network configuration problem, also this confirms that the sqlalchemy-dremio package was installed properly inside the superset containers.
Here is the docker logs for this error from superset_app container
2022-09-30 16:34:09,635:WARNING:superset.views.base:SupersetErrorsException
Traceback (most recent call last):
File "/app/superset/databases/commands/test_connection.py", line 123, in run
raise DBAPIError(None, None, None)
sqlalchemy.exc.DBAPIError: (builtins.NoneType) None
(Background on this error at: https://sqlalche.me/e/14/dbapi)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1516, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1502, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
File "/usr/local/lib/python3.8/site-packages/flask_appbuilder/security/decorators.py", line 89, in wraps
return f(self, *args, **kwargs)
File "/app/superset/views/base_api.py", line 114, in wraps
raise ex
File "/app/superset/views/base_api.py", line 111, in wraps
duration, response = time_function(f, self, *args, **kwargs)
File "/app/superset/utils/core.py", line 1572, in time_function
response = func(*args, **kwargs)
File "/app/superset/utils/log.py", line 244, in wrapper
value = f(*args, **kwargs)
File "/app/superset/views/base_api.py", line 84, in wraps
return f(self, *args, **kwargs)
File "/app/superset/databases/api.py", line 708, in test_connection
TestConnectionDatabaseCommand(item).run()
File "/app/superset/databases/commands/test_connection.py", line 148, in run
raise DatabaseTestConnectionFailedError(errors) from ex
superset.databases.commands.exceptions.DatabaseTestConnectionFailedError: [SupersetError(message='(builtins.NoneType) None\n(Background on this error at: https://sqlalche.me/e/14/dbapi)', error_type=<SupersetErrorType.GENERIC_DB_ENGINE_ERROR: 'GENERIC_DB_ENGINE_ERROR'>, level=<ErrorLevel.ERROR: 'error'>, extra={'engine_name': 'Dremio', 'issue_codes': [{'code': 1002, 'message': 'Issue 1002 - The database returned an unexpected error.'}]})]
***************
['UID=dremio', 'PWD=dremio123', 'HOST=host.docker.internal', 'PORT=32010', 'Schema=dremio', 'SSL=0']
***************

Ensure you are installing the latest version of sqlalchemy_dremio. You may need to install from source as setup.py wasn't updated accordingly (around time of writing). You will also need to add some SQLAlchemy base functions to sqlalchemy_dremio. Have a look at the following issue: https://github.com/narendrans/sqlalchemy_dremio/issues/20

Related

Flask-SocketIO WebSocket transport is not available

I've got a Flask server with Flask-SocketIO to do instant reloads on some pages. Now I'm getting this message in the console:
The WebSocket transport is not available, you must install a WebSocket server that is compatible with your async mode to enable it. See the documentation for details.
Like discribed here https://github.com/miguelgrinberg/Flask-SocketIO/issues/647 I tried to install gevent or eventlet, but neither one changed anything.
The code on the Client is like this:
import { io } from "https://cdn.socket.io/4.4.1/socket.io.esm.min.js";
var socket = io();
socket.emit(event,data,(response) => {response_func(response);})
On the Server:
#socketio.on(event)
def functionOnEvent(data):
functions(data)
return data
Both code samples are of course simplified, but there is no async call of any sort.
Update:
After installing eventlet again and manually setting the async_mode the message disappeared. But now I get the following error from eventlet:
ERROR:Error on request:
Traceback (most recent call last):
File "C:\...\venv\lib\site-packages\werkzeug\serving.py", line 319, in run_wsgi
execute(self.server.app)
File "C:\...\venv\lib\site-packages\werkzeug\serving.py", line 306, in execute
application_iter = app(environ, start_response)
File "C:\...\venv\lib\site-packages\flask\app.py", line 2095, in __call__
return self.wsgi_app(environ, start_response)
File "C:\...\venv\lib\site-packages\flask_socketio\__init__.py", line 43, in __call__
return super(_SocketIOMiddleware, self).__call__(environ,
File "C:\...\venv\lib\site-packages\engineio\middleware.py", line 63, in __call__
return self.engineio_app.handle_request(environ, start_response)
File "C:\...\venv\lib\site-packages\socketio\server.py", line 597, in handle_request
return self.eio.handle_request(environ, start_response)
File "C:\...\venv\lib\site-packages\engineio\server.py", line 411, in handle_request
packets = socket.handle_get_request(
File "C:\...\venv\lib\site-packages\engineio\socket.py", line 103, in handle_get_request
return getattr(self, '_upgrade_' + transport)(environ,
File "C:\...\venv\lib\site-packages\engineio\socket.py", line 158, in _upgrade_websocket
return ws(environ, start_response)
File "C:\...\venv\lib\site-packages\engineio\async_drivers\eventlet.py", line 16, in __call__
raise RuntimeError('You need to use the eventlet server. '
RuntimeError: You need to use the eventlet server. See the Deployment section of the documentation for more information.
As far as I unterstand and show in this example https://github.com/miguelgrinberg/Flask-SocketIO-Chat I thought when running the app like socketio.run(app), it should automatically run an eventlet server?

Django - deterministic=True requires SQLite 3.8.3 or higher upon running python manage.py runserver

I am running a linux red hat environment from AWS.
I have followed every instruction for upgrading sqlite3 to the "latest" version.
I am running python 3.9.2 (and have recompiled it with LD_RUN_PATH=/usr/local/lib ./configure) and django version 4.
I have set up a virtual environment to install and run django. I have changed the activate script to include export LD_LIBRARY_PATH="/usr/local/lib"
Upon running python manage.py runserver, I get the error django.db.utils.NotSupportedError: deterministic=True requires SQLite 3.8.3 or higher. I have opened the file /home/ec2-user/django/django/db/backends/sqlite3/base.py (where the error occurs) and right after the line with the error have include a print statement:
print("**************************\n" +
str(Database.sqlite_version) +
"\n" + str(Database.sqlite_version_info) +
"\n**************************")
which retruns:
**************************
3.28.0
(3, 28, 0)
**************************
**************************
3.28.0
(3, 28, 0)
**************************
Please let me know what additional information is needed. I have searched up and down the stack and can't find the right solution to pop this one off.
Thank you in advance!
EDIT
Here is the traceback:
Watching for file changes with StatReloader
Performing system checks...
System check identified no issues (0 silenced).
Exception in thread django-main-thread:
Traceback (most recent call last):
File "/home/ec2-user/django/django/db/backends/base/base.py", line 219, in ensure_connection
self.connect()
File "/home/ec2-user/django/django/utils/asyncio.py", 21 in inner
return func(*args, **kwargs)
File "/home/ec2-user/django/django/db/backends/base/base.py", line 200, in connect
self.connection = self.get_new_connection(conn_params)
File "/home/ec2-user/django/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/home/ec2-user/django/django/db/backends/sqlite3/base.py", line 210, in get_new_connection
create_deterministic_function('django_date_extract', 2, _sqlite_datetime_extract)
sqlite3.NotSupportedError: deterministic=True requires SQLite 3.8.3 or higher
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/opt/python/lib/python/3.9/threading.py", line 954, in _bootstrap_inner
self.run()
File "/opt/python39/lib/python3.9/threading.py", line 892, in run
self._target(*self._args, **self._kwargs)
File "/home/ec2-user/django/django/utils/autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "/home/ec2-user/django/django/core/management/commands/runserver.py", line 126, in inner_run
self.check_migrations()
File "/home/ec2-user/django/django/core/management/base.py", line 486, in check_migrations
executor = MigrationExecutor(connectsion[DEFAULT_DB_ALIAS])
File "/home/ec2-user/django/django/db/migrations/executor.py", line 18, in __init__
self.loader = MigrationLoader(self.connection)
File "/home/ec2-user/django/django/db/migrations/loader.py", line 53, in __init__
self.build_graph()
File "/home/ec2-user/django/django/db/migrations/loader.py", line 220, in build_graph
self.applied_migrations = recorder.applied_migrations()
File "/home/ec2-user/django/django/db/migrations/recorder.py", line 77, in applied_migrations
if self.has_table():
File "/home/ec2-user/django/django/db/migrations/recorder.py", line 55, in has_table
with self.connection.cursor() as cursor:
File "/home/ec2-user/django/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/home/ec2-user/django/django/db/backends/base/base.py", line 259, in cursor
return self._cursor()
File "/home/ec2-user/django/django/db/backends/base/base.py", line 235, in _cursor
self.ensure_connection()
File "/home/ec2-user/django/djanog/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/home/ec2-user/django/django/db/backends/base/base.py", line 219, in ensure_connection
self.connect()
File "/home/ec2-user/django/django/db/utils.py", line 90, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/home/ec2-user/django/django/db/backends/base/base.py", line 219, in ensure_connection
self.connect()
File "/home/ec2-user/django/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/home/ec2-user/django/django/db/backends/base/base.py", line 200, in connect
self.connection = self.get_new_connection(conn_params)
File "/home/ec2-user/django/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/home/ec2-user/django/django/db/backends/sqlite3/base.py", line 210, in get_new_connection
create_deterministic_function('django_date_extract', 2, _sqlite_datetime_extract)
django.db.utils.NotSupportedError: deterministic=True requires SQLite 3.8.3 or higher
I came across the same issue in my linux Centos7+python3.9.6+Django3.2.5.
Althougt the sqlite3 is updated to the lastest version. It seems that this is useless. A kind of solution is changing the database from sqlite3 to pysqlite3.
After acticate the virtualenv, install pysqlite
pip3 install pysqlite3
pip3 install pysqlite3-binary
and change db in base.py
vim python3.9.6/site-packages/django/db/backends/sqlite3/base.py
# from sqlite3 import dbapi2 as Database # annotation
from pysqlite3 import dbapi2 as Database # import pysqlite3
restart django server and it works.
I have got the same problem as yours. when I tried to deploy on Elastic Beanstalk.
In my case used Python 3.8 when I initialized EB CLI like this:
eb init -p python-3.8 django-project ⛔
and that not a good python version to run it on 64bit Amazon Linux 2 (default). change to python-3.7
eb init -p python-3.7 django-project ✅
It can be solved by recompiling python3 with the correct environment. Below are the commands for recompiling python3.
export C_INCLUDE_PATH=/PATH_TO_SQLITE/include
export CPLUS_INCLUDE_PATH=/PATH_TO_SQLITE/include
export LD_RUN_PATH=/PATH_TO_SQLITE/lib
./configure --prefix=/PATH_FOR_PYTHON
make
make install
Then a check can be done in python by the below commands
import sqlite3
conn = sqlite3.connect(':memory:')
conn.create_function('f', 2, lambda *args: None, deterministic=True)
The best I can figure at the moment is to go into /home/ec2-user/django/django/db/backends/sqlite3/base.py, change the function variable deterministic=True in get_new_connection() to deterministic=False...
This will remove the error, but seems like a super cheaty solution. If anyone has a better fix, please let me know.
Using PostgreSQL is a good choice as it does support python 3.8 and solves this error. Also as in this question is explained that it is better to use postgreSQL for production. Having said that I recommend this tutorial that teaches how to run postgres on eb. Despite it is a bit outdated it was for me very useful.
安装 pip3 install pysqlite3
打开文件/usr/local/python3/lib/python3.8/site-packages/django/db/backends/sqlite3/base.py,找到 from sqlite3 import dbapi2 as Database 注释它,替换为from pysqlite3 import dbapi2 as Database
vim /u01/apps/python3/lib/python3.10/site-packages/django/db/backends/sqlite3/_functions.py 将deterministic=True中的函数变量get_new_connection()更改为deterministic=False ..
然后
vim /u01/apps/python3/lib/python3.10/site-packages/django/db/backends/base/base.py# def : check_database_version_supported 里面的方法注释掉 写上pass
如:
def check_database_version_supported(self):
pass
"""
Raise an error if the database version isn't supported by this
version of Django.
"""

sam build --use-container failed mounting directory

There was no issue in building the project a little while back, but it started throwing below error.
RuntimeError: Container does not exist. Cannot get logs for this
container
Normally this happens when docker cannot mount the shared directory, but in this case even adding the lambda directory manually in the docker interface didn't help!
Complete debug log of sam build --use-container
Building function 'SAListManagerUrlLambda'
Fetching lambci/lambda:build-python3.7 Docker container image......
Mounting C:\Users\xxxx\xxxx\xxxx\xxxx\functions\xxxx-xxxx\xxxx-xxxx as /tmp/samcli/source:ro,delegated inside runtime container
Container was not created. Skipping deletion
Sending Telemetry: {'metrics': [{'commandRun': {'awsProfileProvided': False, 'debugFlagProvided': True, 'region': '', 'commandName': 'sam build', 'duration': 1292, 'exitReason': 'RuntimeError', 'exitCode': 255, 'requestId': 'cbfcd29c-16ae-xxxx-xxxx-b9ffec8de75a', 'installationId': 'fece8ccc-cb84-xxxx-xxxx-ac72820ef0c3', 'sessionId': 'e1cbc287-1850-xxxx-xxxx-3a235769f7fb', 'executionEnvironment': 'CLI', 'pyversion': '3.7.6', 'samcliVersion': '0.53.0'}}]}
HTTPSConnectionPool(host='aws-serverless-tools-telemetry.us-west-2.amazonaws.com', port=443): Read timed out. (read timeout=0.1)
Traceback (most recent call last):
File "D:\obj\windows-release\37amd64_Release\msi_python\zip_amd64\runpy.py", line 193, in _run_module_as_main
File "D:\obj\windows-release\37amd64_Release\msi_python\zip_amd64\runpy.py", line 85, in _run_code
File "C:\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\__main__.py", line 12, in <module>
cli(prog_name="sam")
File "C:\Amazon\AWSSAMCLI\runtime\lib\site-packages\click\core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "C:\Amazon\AWSSAMCLI\runtime\lib\site-packages\click\core.py", line 782, in main
rv = self.invoke(ctx)
File "C:\Amazon\AWSSAMCLI\runtime\lib\site-packages\click\core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "C:\Amazon\AWSSAMCLI\runtime\lib\site-packages\click\core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "C:\Amazon\AWSSAMCLI\runtime\lib\site-packages\click\core.py", line 610, in invoke
return callback(*args, **kwargs)
File "C:\Amazon\AWSSAMCLI\runtime\lib\site-packages\click\decorators.py", line 73, in new_func
return ctx.invoke(f, obj, *args, **kwargs)
File "C:\Amazon\AWSSAMCLI\runtime\lib\site-packages\click\core.py", line 610, in invoke
return callback(*args, **kwargs)
File "C:\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\lib\telemetry\metrics.py", line 96, in wrapped
raise exception # pylint: disable=raising-bad-type
File "C:\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\lib\telemetry\metrics.py", line 62, in wrapped
return_value = func(*args, **kwargs)
File "C:\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\commands\build\command.py", line 129, in cli
mode,
File "C:\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\commands\build\command.py", line 194, in do_cli
artifacts = builder.build()
File "C:\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\lib\build\app_builder.py", line 117, in build
function.metadata)
File "C:\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\lib\build\app_builder.py", line 271, in _build_function
options)
File "C:\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\lib\build\app_builder.py", line 369, in _build_function_on_container
container.wait_for_logs(stdout=stdout_stream, stderr=stderr_stream)
File "C:\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\local\docker\container.py", line 197, in wait_for_logs
raise RuntimeError("Container does not exist. Cannot get logs for this container")
RuntimeError: Container does not exist. Cannot get logs for this container
In my case the reason was different, Action Center's Focus Assist was set to Alarms Only.
This caused the share directory notification to fail, causing the build failure.
So, make sure your Focus Assist is set to OFF.
It seems that many situations can trigger the same error. For more information the --debug option can be used like this:
sam build --use-container --debug
I see that you are using it, because you got extra information like this:
Sending Telemetry: {'metrics': [{'commandRun': {'awsProfileProvided': False, 'debugFlagProvided': True, 'region': '', 'commandName': 'sam build', 'duration': 1292, 'exitReason': 'RuntimeError', 'exitCode': 255, 'requestId': 'cbfcd29c-16ae-xxxx-xxxx-b9ffec8de75a', 'installationId': 'fece8ccc-cb84-xxxx-xxxx-ac72820ef0c3', 'sessionId': 'e1cbc287-1850-xxxx-xxxx-3a235769f7fb', 'executionEnvironment': 'CLI', 'pyversion': '3.7.6', 'samcliVersion': '0.53.0'}}]}
HTTPSConnectionPool(host='aws-serverless-tools-telemetry.us-west-2.amazonaws.com', port=443): Read timed out. (read timeout=0.1)
Traceback (most recent call last):
In my case I did suppose that the error was sending the telemetry.
My guess is that somehow the build process need pass the region. In my case it is not us-west-2.
Anyway, I disabled it as specified in the documentation and it now works.
In my case local disk in my cloud9 was almost full, so I had to delete some docker images that comes pre-installed with cloud9.
To remove an image use
docker rmi Image
This will clear up space and your build will not fail the next time.

trying to use cookiecutter-django, getting errors and does not create anything

trying to get a Django project started using cookiecutter-django and can't seem to get it to generate anything.
using Python 3.6, Django 2.0.5, cookiecutter 1.6.0 (then created a virtualenv and entered a new, blank directory)
so I enter this command:
cookiecutter https://github.com/pydanny/cookiecutter-django
and get this error traceback:
Traceback (most recent call last):
File "c:\python\python36\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "c:\python\python36\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "c:\Python\python36\Scripts\cookiecutter.exe\__main__.py", line 9, in
<module>
File "c:\python\python36\lib\site-packages\click\core.py", line 722, in
__call__
return self.main(*args, **kwargs)
File "c:\python\python36\lib\site-packages\click\core.py", line 697, in main
rv = self.invoke(ctx)
File "c:\python\python36\lib\site-packages\click\core.py", line 895, in
invoke
return ctx.invoke(self.callback, **ctx.params)
File "c:\python\python36\lib\site-packages\click\core.py", line 535, in
invoke
return callback(*args, **kwargs)
File "c:\python\python36\lib\site-packages\cookiecutter\cli.py", line 120,
in main
password=os.environ.get('COOKIECUTTER_REPO_PASSWORD')
File "c:\python\python36\lib\site-packages\cookiecutter\main.py", line 63,
in cookiecutter
password=password
File "c:\python\python36\lib\site-packages\cookiecutter\repository.py", line
103, in determine_repo_dir
no_input=no_input,
File "c:\python\python36\lib\site-packages\cookiecutter\vcs.py", line 99, in
clone
stderr=subprocess.STDOUT,
File "c:\python\python36\lib\subprocess.py", line 336, in check_output
**kwargs).stdout
File "c:\python\python36\lib\subprocess.py", line 418, in run
output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['git', 'clone',
'https://github.com/pydanny/cookiecutter-django']' returned non-zero exit
status 128.
OK - figured out how to get this to work.
used Github desktop
from cookiecutter-django repository, right click
open it Git Shell
this opens a Powershell window.
CD to directory where project will be placed in.
cookiecutter https://github.com/pydanny/cookiecutter-django
and it works.
not sure exactly why this works when regular CMD and elevated CMD do not, but this was the only way I could get it to work.
This is a permission issue with github due to the need to setup ssh keys. By the way I'm using ubuntu 12.
https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/ - create a key first in your machine using the instructions in the link. Once you have your ssh key, proceed to step 2. (Step 2 is indicated in the first link as last step)
https://help.github.com/articles/adding-a-new-ssh-key-to-your-github-account - add the generated ssh key to your github account.

Difference running python in PyCharm and in terminal

I'm wondering what is the difference when I run a python program from PyCharm or from the command line.
Actually I'm using a library called wand-py (ImageMagick binding).
If I run my program from the command line it works.
Though if I use PyCharm Run or debug it doesn't and I get the following traceback.
/Users/alexisbenoist/Documents/python/papyrus/env/bin/python "/Applications/PyCharm CE.app/helpers/pydev/pydevd.py" --multiproc --client 127.0.0.1 --port 58993 --file /Users/alexisbenoist/Documents/python/papyrus/tets.py
Connected to pydev debugger (build 135.973)
pydev debugger: process 73166 is connecting
Traceback (most recent call last):
File "/Applications/PyCharm CE.app/helpers/pydev/pydevd.py", line 1733, in <module>
debugger.run(setup['file'], None, None)
File "/Applications/PyCharm CE.app/helpers/pydev/pydevd.py", line 1226, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "/Users/alexisbenoist/Documents/python/papyrus/tets.py", line 23, in <module>
blob = image_to_blob(PATH)
File "/Users/alexisbenoist/Documents/python/papyrus/tets.py", line 12, in image_to_blob
pdf.alpha_channel = False
File "/Users/alexisbenoist/Documents/python/papyrus/env/lib/python2.7/site-packages/wand/image.py", line 419, in wrapped
result = function(self, *args, **kwargs)
File "/Users/alexisbenoist/Documents/python/papyrus/env/lib/python2.7/site-packages/wand/image.py", line 992, in alpha_channel
self.raise_exception()
File "/Users/alexisbenoist/Documents/python/papyrus/env/lib/python2.7/site-packages/wand/resource.py", line 218, in raise_exception
raise e
wand.exceptions.WandError: wand contains no images `MagickWand-1' # error/magick-image.c/MagickSetImageAlphaChannel/9504
I'm using the same virtual env in the terminal and PyCharm.
Do you guys know what could cause the problem?
Thanks,
Alexis.