Code Monkey home page Code Monkey logo

fast_dash's Introduction

Fast Dash

Open source, Python-based tool to build prototypes lightning fast โšก

Release Status CI Status MIT License Documentation Downloads



Fast Dash is a Python module that makes the development of web applications fast and easy. It can build web interfaces for Machine Learning models or to showcase any proof of concept without the hassle of developing UI from scratch.

FastDashDemo

Examples

With Fast Dash's decorator @fastdash, it's a breeze to deploy any Python function as a web app. Here's how to use it to write your first Fast Dash app:

from fast_dash import fastdash

@fastdash
def text_to_text_function(input_text):
    return input_text

# * Running on http://127.0.0.1:8080/ (Press CTRL+C to quit)

And just like that, we have a completely functional interactive app!

Output: Simple example

Fast Dash can read all the function details, like its name, input and output types, docstring, and uses this information to infer which components to use.

For example, here's how to deploy an app that takes a string and an integer as inputs and returns some text.

from fast_dash import fastdash

@fastdash
def display_selected_text_and_number(text: str, number: int) -> str:
    "Simply display the selected text and number"

    processed_text = f'Selected text is {text} and the number is {number}.'
    
    return processed_text

# * Running on http://127.0.0.1:8080/ (Press CTRL+C to quit)

Output: Simple example with multiple inputs

And with just a few more lines, we can add a title icon, subheader and other social branding details.


Output components can be arranged using a mosaic layout (ASCII art), inspired from Matplotlib's subplot_mosaic feature.

from fast_dash import fastdash, UploadImage, Graph
import matplotlib.pyplot as plt

mosaic = """
AB
AC
"""

@fastdash(mosaic=mosaic, theme="BOOTSTRAP")
def multiple_output_components(start_date: datetime.date, # Adds a date component
                            upload_image: UploadImage, # Adds an upload component
                            fips: str = [List of FIPs]) # Adds a single select dropdown
                            -> (Graph, plt.Figure, plt.Figure): 
                            # Output components are a Plotly graph, and two figure components

    "Fast Dash allows using mosaic arrays to arrange output components"

    choropleth_map = ...
    histogram = ...
    radar_chart = ...
    
    return chloropleth_map, histogram, radar_chart

# * Running on http://127.0.0.1:8080/ (Press CTRL+C to quit)

Simple example with multiple inputs

In just a few lines of code, you can also add a chat component.

Simple chat

You can use your favorite Python libraries. Here's an example of an advanced geospatial application built using geemap and Google Earth Engine.

Water spectral indices

About

Read different ways to build Fast Dash apps and additional details by navigating to the project documentation.

Key features

Duild and deploy a web app by adding a decorator only.

  • Components are inferred from function type hints. Allows using Dash components as type hints.
  • Use multiple input and output components simultaneously.
  • Build fast, share and iterate.

Community

Fast Dash is built using Plotly Dash and it's completely open-source.

fast_dash's People

Contributors

dkedar7 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

fast_dash's Issues

Heroku Deployment

  • Fast Dash version: 0.1.6
  • Python version: 3.7.8
  • Operating System: MacOS

Description

Trying to get fast-dash working with Heroku deployments. I would like to do something like this:

from fast_dash import FastDash
from fast_dash.Components import Text

# Step 1: Define your model inference
def text_to_text_function(input_text):
    return input_text

# Step 2: Specify the input and output components
app = FastDash(callback_fn=text_to_text_function, 
                inputs=Text, 
                outputs=Text, 
                title='App title')

# Declare server for Heroku deployment. Needed for Procfile.
server = app.server

if __name__ == '__main__':
    app.run()

Running the file gives me an error: AttributeError: 'FastDash' object has no attribute 'server'

Any advice?

simple example failed in Thonny IDE

  • Fast Dash version:
  • Python version:
  • Operating System:

Description

Describe what you were trying to get done.
Tell us what happened, what went wrong, and what you expected to happen.

What I Did

installing is ok. But the example:
from fast_dash import fastdash

@fastdash
def text_to_text_function(input_text):
return input_text

* Running on http://127.0.0.1:8080/ (Press CTRL+C to quit)

does not run. It was executed in the Thonny-IDE and gave the following errors:

%Run -c $EDITOR_CONTENT
Traceback (most recent call last):
File "", line 4, in
File "C:\Users\rwbdev\AppData\Roaming\Python\Python310\site-packages\fast_dash\fast_dash.py", line 539, in fastdash
return decorator_fastdash(_callback_fn)
File "C:\Users\rwbdev\AppData\Roaming\Python\Python310\site-packages\fast_dash\fast_dash.py", line 508, in decorator_fastdash
return wrapper_fastdash(
File "C:\Users\rwbdev\AppData\Roaming\Python\Python310\site-packages\fast_dash\fast_dash.py", line 504, in wrapper_fastdash
app = FastDash(callback_fn=callback_fn, **kwargs)
File "C:\Users\rwbdev\AppData\Roaming\Python\Python310\site-packages\fast_dash\fast_dash.py", line 140, in init
self.output_labels = _infer_variable_names(callback_fn)
File "C:\Users\rwbdev\AppData\Roaming\Python\Python310\site-packages\fast_dash\utils.py", line 421, in _infer_variable_names
s = inspect.getsource(func)
File "C:\Users\rwbdev\AppData\Local\Programs\Thonny\lib\inspect.py", line 1139, in getsource
lines, lnum = getsourcelines(object)
File "C:\Users\rwbdev\AppData\Local\Programs\Thonny\lib\inspect.py", line 1121, in getsourcelines
lines, lnum = findsource(object)
File "C:\Users\rwbdev\AppData\Local\Programs\Thonny\lib\inspect.py", line 958, in findsource
raise OSError('could not get source code')
OSError: could not get source code

Paste the command(s) you ran and the output.
If there was a crash, please include the traceback here.

"About" button cannot be customized

  • Fast Dash version: 0.2.6
  • Python version: 3.11.2
  • Operating System: MacOS Ventura Version 13.5

Description

I want to customize the "About" button (top-right of dashboard) so it links to a specified URL. I've searched for a solution in the documentation but cannot find one.

Screenshot 2023-10-19 at 7 11 58 AM

What I Did

app = FastDash(
    chatbot_callback,
    about='www.example.com'
)

change routing for better compatibility with dash workspaces

  • Fast Dash version: 0.2.6
  • Python version: 3.9
  • Operating System:

Description

Currently, fast-dash is not compatible with dash_proxy.
Workspaces (Dash IDE) apps can only be run in the default port (8050). When you try to use the fast_dash package in the Dash IDE, the web app will not render due to a port issue. The issue persists even when you specify the port like so: @fastdash(port=8050)

What I Did

Modify the routing code in fast dash to allow use of dash proxy ( and compatibility with Dash IDE)

   def run(self):
        #change from self.server to self.app
        self.app.run(  
            **self.run_kwargs
        ) if self.mode is None else self.app.run_server(
            mode=self.mode, **self.run_kwargs
        )

also allowing gunicorn support benefits users trying to deploy their apps into a production environment.

if __name__ == "__main__":
    app.run()

Upload PDF?

In 'docs/Examples/03_chat_over_documents.ipynb', how can I upload a PDF rather than using a PDF URL?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.