Skip to main content

Run app and get cluster proxy url for it in databricks clusters

Project description

dbtunnel

Proxy solution to run elegant Web UIs natively inside databricks notebooks.

YOU CAN ONLY USE THIS IN DATABRICKS NOTEBOOKS WITH A RUNNING CLUSTER

FOR SECURE ACCESS PLEASE USE A SINGLE USER CLUSTER (ANYONE WITH ATTACH CAN ACCESS THE UIs)

Description

Easy way to test the following things on a databricks cluster and notebooks

Framework Support

Easy way to test out llm chatbots; look in examples/gradio

File or Directory Support

This is to support decoupling your UI code from your databricks notebooks. Usually will have a script_path argument instead of directly passing your "app" object. This is convenient for shipping your app outside of a notebook.

Chatbot Support

You must use A10 GPU instances or higher

Custom ASGI Proxy Support for UIs that do not support proxy root paths

Forked ASGI proxy for chainlit UI rendering

Tunnel Support:

  • ngrok
  • devtunnels
  • cloudflared

Setup

Please do not use this in production!!

  1. Clone this repo into databricks repos
  2. Go to any of the examples to see how to use them
  3. Enjoy your proxy experience :-)
  4. If you want to share the link ensure that the other user has permission to attach to your cluster.

Exposing to internet using ngrok

WARNING: IT WILL BE PUBLICLY AVAILABLE TO ANYONE WITH THE LINK SO DO NOT EXPOSE ANYTHING SENSITIVE

The reason for doing this is to test something with a friend or colleague who is not logged in into databricks. The proxy option requires you to be logged in into databricks.

  1. Go to ngrok and create an account and get an api token and a tunnel auth token
    • You can get a tunnel token from here.
    • You can get an api token from here.
  2. Go to a databricks notebook:
  3. If you are using free tier of ngrok you can only have one tunnel and one session at a time so enable kill_all_tunnel_sessions=True

Take a look at the full example here streamlit-example-ngrok.py

from dbtunnel import dbtunnel

# again this example is with streamlit but works with any framework
dbtunnel.streamlit("<script_path>").share_to_internet_via_ngrok(
    ngrok_api_token="<ngrok api token>",
    ngrok_tunnel_auth_token="<ngrok tunnel auth token>"
).run()

# if you need to kill tunnels because you are on free tier:
# again this example is with streamlit but works with any framework
dbtunnel.streamlit("<script_path>").share_to_internet_via_ngrok(
    ngrok_api_token="<ngrok api token>",
    ngrok_tunnel_auth_token="<ngrok tunnel auth token>",
    kill_all_tunnel_sessions=True,
).run()

Disclaimer

dbtunnel is not developed, endorsed not supported by Databricks. It is provided as-is; no warranty is derived from using this package. For more details, please refer to the license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dbtunnel-0.9.0.tar.gz (39.1 kB view hashes)

Uploaded Source

Built Distribution

dbtunnel-0.9.0-py3-none-any.whl (32.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page