Skip to main content

App Builder [BETA]

🚧 Under Construction

The App Builder is an IDE to transform User Defined Functions (UDFs) into interactive, shareable apps.

Data scientists often need to make analytics interactive and accessible to broader audiences. However, building traditional React apps with maps and widgets can be impractical, especially considering prototypes might be discarded. Additionally, frontend frameworks are not well-suited for transforming data or handling large datasets.

With this in mind, the App Builder enables users to build and run apps with serverless Streamlit, an open source framework to deliver dynamic data apps with just a few lines of Python. These are some of its capabilities to keep in mind:

Build apps

You build apps by writing Python in the code editor, shown below. As you write code you'll notice the app automatically reruns as code and widgets change (configurable in the settings).

You may add input widgets that interact with UDFs, display data with data and text elements, and structure the app with layout components.


Try running the code snippets below to acquaint yourself with the App Builder.

import streamlit as st

st.write("Hello, *Fused!* :rocket:")

Dependencies

Click "Requirements" on the top-right menu of the code editor to set Python packages for the app. This is limited to packages compatible with Pyodide. Please get in touch if you need help with a specific package.

Furthermore, it can be useful to build apps without pre-installed dependencies. Use micropip to install packages at runtime. When using this approach, requests must be installed before fused_app is imported. This is also useful for GitHub Gists, which cannot install dependencies ahead of execution.

import micropip
await micropip.install("requests")
await micropip.install("pydeck")
import fused_app
import pydeck as pdk

Troubleshoot

Click "Reset app" on the top-right menu of the code editor in case things aren't working as expected.

Call UDFs

Apps may call UDFs and load their output into memory. This enables them to run resource-intensive operations and use libraries unsupported by Pyodide. These snippets illustrate a few ways to call UDFs.

With fused_app.run (beta)

Call a UDF with fused_app.run and pass parameters from a slider.

import fused_app
import streamlit as st

threshold = st.sidebar.slider("Threshold", 0, 1000, 250)
df = fused_app.run('dbd709c58f1d828bb06f3fc53991963910dc585ab45b692b5981bd78a78fa43a', threshold=threshold)

HTTP endpoints

Call UDF HTTP endpoints with the requests library and pass parameters from a dropdown selectbox.

import streamlit as st
import requests

city = st.selectbox("Select city", ("Boston", "Paris", "New York"))
url = f"https://staging.fused.io/server/v1/realtime-shared/fsh_1bkKoOETvhhQ7TtKfwOQ7i/run/file?dtype_out_vector=geojson&city={city}"
response = requests.get(url)
st.write(response.content)

Pandas

Create a pandas DataFrame from a UDF HTTP endpoint.

import streamlit as st
import pandas as pd

url = f"https://staging.fused.io/server/v1/realtime-shared/fsh_1bkKoOETvhhQ7TtKfwOQ7i/run/file?dtype_out_vector=csv&city=Boston"
df = pd.read_csv(url)
st.data_editor(df.head())

Pydeck

Create pydeck layers that call UDF HTTP endpoints.

import pydeck as pdk
import streamlit as st

url_overture = "https://www.fused.io/server/v1/realtime-shared/c8679490a7c130178e2781a45f4090208c9bcd8d8d7572532c4c39c4d0914467/run/tiles/{z}/{x}/{y}?dtype_out_vector=geojson&return_object=gdf_overture"
st.pydeck_chart(
pdk.Deck(
map_style="mapbox://styles/mapbox/dark-v9",
initial_view_state=pdk.ViewState(latitude=40.7431, longitude=-73.9874, zoom=14, pitch=25),
layers=[
pdk.Layer(
"TileLayer",
data=url_overture,
get_line_color=[255, 25, 2, 100],
stroked=True,
get_line_width=2,
pickable=True,
filled=False,
)
],
)
)

Caching

It can be helpful to cache the response of UDF calls. To cache a function in Streamlit, decorate it with @st.cache_data.

import fused_app
import streamlit as st

@st.cache_data
def call_udf():
return fused_app.run('dbd709c58f1d828bb06f3fc53991963910dc585ab45b692b5981bd78a78fa43a')

df = call_udf()

Share

The App Builder menu includes options to generate a URL that can be used to share or embed (<iframe>) an app.

  • Shared app URLs can run without authentication and include a token, such as https://www.fused.io/workbench#app/s/i/fa_45G5QVNVUPJPo4jr6k4mtY.
  • For private sharing, URLs encode the app code within the URL string, like https://www.fused.io/workbench#app/s/aH4sIAAAAAAAAA....

GitHub gists

Apps can be saved as GitHub Gists. They can be loaded from a Gist through the UI or by appending the Gist ID to the following URL.

https://www.fused.io/workbench#app/s/u/https://gist.github.com/pgzmnk/43045302f3b668ab5482d8a23f6f4de5