Streamlit & Snowflake: Revolutionizing Data and AI App Development
Amidst escalating data complexity, the call for impactful data presentation has become imperative. The surge in AI/ML advancements has ignited a desire for immersive interactions with data and machine learning models. However, navigating the creation of these data applications has proven challenging. Data practitioners and product owners acknowledge the daunting journey required to forge a robust data app.
Enter Streamlit!
Streamlit, an open-source library, swiftly transforms Python scripts into web applications that are shareable within minutes. These applications are exclusively crafted in Python, eliminating the necessity for prior front-end expertise. In recent years, Streamlit has emerged as the top choice for constructing Python-based data apps. With an impressive 80% adoption rate among the Fortune 50, it has captured the attention of countless developers worldwide.
Beinex Reveals Its Exclusive Streamlit App!
Experience the 'Track Your Santa' app, Beinex's innovative creation leveraging Streamlit. This engaging application allows you to follow Santa's global journey, providing real-time updates on the flying reindeer's speed and the tally of gifts delivered. It's an enjoyable way to stay connected with Santa's worldwide expedition!
Inside the app, users can explore intricate details and images of eagerly awaiting children. These young ones have shared their good deeds, gift wishes, reflections on past actions, and their New Year resolutions. They're closely monitoring Santa's progress, eagerly anticipating the timely arrival of their gifts.
Explore the Beinex Santa Dashboard:
Streamlit: Transforming Your Data Experience
Streamlit breathes life into data and ML models, enabling interactive visualizations that surpass static displays. It empowers data teams to create a myriad of previously unattainable applications. Through Streamlit, builders craft interactive data apps featuring dynamic charting, data editing, collection, and write-back functions. These facilitate the creation of responsive, decision-centric tools for stakeholders.
2. Swift Iteration and Deployment
With Streamlit, rapid iteration, and deployment become effortless. Test new ideas seamlessly, integrate real-time stakeholder feedback with minimal code changes, and witness immediate output adjustments. Instead of investing time in a traditional web app with a frontend team, Streamlit allows the development of multiple tailored apps for diverse use cases simultaneously. This amplifies the output and impact of data teams significantly.
Streamlit in Snowflake enhances this experience by providing data practitioners with a fully managed environment. This allows them to focus on their core expertise—translating data into actionable insights—without the hassle of infrastructure management.
3. Types of Apps Can You Build with Streamlit
Building Streamlit Apps in Snowflake
Exploring Streamlit App Development in Snowflake entails a thorough investigation of crafting, altering, and distributing Streamlit applications within Snowflake.
1. Developing Applications
The process of developing Streamlit apps in Snowflake is smooth and organized. Snowflake takes charge of intricate tasks, handling the setup of foundational computing and storage for these apps. These applications function on Snowflake warehouses and utilize Snowflake stages for storing data and files.
Starting the app creation is simple: a click on the "+ Streamlit App" button initiates a dialogue box asking for basic app details.
Pro Tip: For optimization, starting with an xsmall warehouse suits most app requirements. For better monitoring of usage and costs, consider using a dedicated warehouse for your app.
Once users click the "Create" button, they enter an editing interface that displays the app's code on the left side and its output on the right. This arrangement allows app builders to smoothly edit the code and instantly see the changes by clicking the "Run" button. This real-time interaction enables builders to easily improve their app's functionality and appearance through iterative refinements.
To fully utilize the capabilities of the Python ecosystem in your Streamlit app, explore installing extra Python packages from the Snowflake Anaconda Channel. This enables access to a broader range of Python libraries, augmenting the functionality and potential of your Streamlit application.
2. Exploring Streamlit Apps in Snowflake
Within Snowflake, users can access the Streamlit tab to find an extensive catalog of all their Streamlit apps. These apps are regarded as Snowflake objects and follow role-based access control protocols. The catalog encompasses apps crafted within the user's role and those shared with it, providing a unified view of available Streamlit applications.
2. Streamlined Sharing of Streamlit Apps
Sharing Streamlit apps within your Snowflake account is an efficient process. Clicking on the share button initiates a sharing dialog. As Streamlit apps follow role-based access control, sharing involves a simple selection of the desired role and assigning permission levels for app visibility. This straightforward process guarantees efficient sharing within the Snowflake environment.
Developing Snowflake Native Apps using Streamlit
Streamlit acts as the user experience framework for constructing Snowflake Native Apps, which can be extensively shared via the Snowflake Marketplace.
Beinex + Snowflake Partnership
Beinex is a Snowflake Services Partner Premier Tier, and the partnership reaffirms Beinex's commitment to delivering exceptional data solutions and positions the company at the forefront of industry advancements. Harnessing the true potential of the data, the partnership drives innovation and success in the digital era. Belonging to Snowflake Services Partner Premier Tier, Beinex leverages Snowflake’s advanced capabilities and seamlessly integrates them into its comprehensive data solutions.
All Yours: Sharing the Code Snippet
# Import python packages
import streamlit as st
import time
import datetime
import pandas as pd
import numpy as np
import os
import random
from snowflake.snowpark.context import get_active_session
?
#Getting all map files from static folder
files_in_directory = os.listdir('static/')
map_files = [i for i in files_in_directory if i.startswith("Map")]
?
#setting default page config
st. set_page_config(layout="wide")
st.snow() #making it snow
?
#reading data from Snowflake
session = get_active_session()
deeds = session.table("christmas_deeds").to_pandas()
deed_dict = {}
for ind , row in deeds.iterrows():
??? md = f""" - :thumbsup: Good Deeds : {row['DEEDS']}
??? \n - :gift: Gifts : {row['GIFT']}
??? \n - :angry: Tantrums : {row['TANDRUMS']}
??? \n - :innocent: Resolutions : {row['RESOLUTIONS']}
??? """
??? deed_dict[row['NAME']] = md
?
#Design elements
st.image("static/bg.png")
main_col1 ,main_col2 = st.columns(2)
with main_col1:
??? with st.expander(label="Mia",expanded=True):
??????? c1 , c2 = st.columns(2)
??????? with c1 :
??????????? with st.container():
??????????????? st.write("""?? """)
??????????? with st.container():
??????????????? st.image(r"static/Frame 15599.png",use_column_width=True)
??????????? with st.container():
??????????????? st.write(" ")
??????? with c2:
??????????? with st.container():
??????????????? st.markdown(deed_dict['Mia'])
??????????? with st.container():
领英推荐
??????????????? st.markdown(""" """)???????????????
??? with st.expander(label="Sarah",expanded=True):
??????? c1 , c2 = st.columns(2)
??????? with c1 :
??????????? with st.container():
??????????????? st.image(r"static/Frame 15600.png",use_column_width=True)
??????? with c2:
??????????? with st.container():
??????????????? st.markdown(deed_dict['Sarah'])
??????????? with st.container():
??????????????? st.markdown("""
??????????????????????????? """)
??? with st.expander(label="Olivia",expanded=True):
??????? c1 , c2 = st.columns(2)
??????? with c1 :
??????????? with st.container():
??????????????? st.image(r"static/Frame 15596.png",use_column_width=True)
??????? with c2:
??????????? with st.container():
??????????????? st.markdown(deed_dict['Olivia'])
??????????? with st.container():
??????????????? st.markdown("""
??????????????????????????? """)
with main_col2:
??? with st.expander(label="Mewin",expanded=True):
??????? c1 , c2 = st.columns(2)
??????? with c1 :
??????????? with st.container():
??????????????? st.image(r"static/Frame 15601.png",use_column_width=True)
??????? with c2:
??????????? with st.container():
??????????????? st.markdown(deed_dict['Mewin'])
??????????? with st.container():
??????????????? st.markdown("""
??????????????????????????? """)?????
??????????????
??? with st.expander(label="Noah",expanded=True):
??????? c1 , c2 = st.columns(2)
??????? with c1 :
??????????? with st.container():
??????????????? st.image(r"static/Frame 15598.png",use_column_width=True)
??????? with c2:
??????????? with st.container():
??????????????? st.markdown(deed_dict['Noah'])
??????????? with st.container():
??????????????? st.markdown("""
??????????????????????????? """)
??? with st.expander(label="Ethan",expanded=True):
??????? c1 , c2 = st.columns(2)
??????? with c1 :
??????????? with st.container():
??????????????? st.image(r"static/Frame 15597.png",use_column_width=True)
??????? with c2:
??????????? with st.container():
??????????????? st.markdown(deed_dict['Ethan'])
??????????? with st.container():
??????????????? st.markdown("""
??????????????????????????? """)
with st.container():
??? st.image('static/footer.png',use_column_width=True)
#sidebar elements
with st.sidebar:
??? with st.expander("Dashboard Help"):
??????? st.markdown("""
??????? [User Guide]('Dashboard help.pdf')?
??????? [Beinex Website](https://beinex.com/)
??????????????????? """)
??? col1, col2, col3 = st.columns(3)
??? with col2:
??????? st.image('static/santa-claus.png',use_column_width=True)
??? st.title(" :santa: :red[Santa]? Dashboard :christmas_tree:")
??? st.metric(label="Flying Reindeers' Speed", value=f"{random.randint(5000,7000)} km/s", delta=f"{random.randint(100,600)} km/s")
??? st.metric(label="Gifts Delivered", value=f"{random.randint(120000,340000)}")
??? if st.button("Track Santa", type='secondary'):
??????? st.image(random.choice(map_files),use_column_width=True)
??? ph = st.empty()
??? target_date = datetime.datetime(datetime.datetime.now().year, 12, 25)? # Christmas Day
??? with st.expander(" "):
??????? #Counter to Christmas
??????? while datetime.datetime.now() < target_date:
??????????? current_date = datetime.datetime.now() + datetime.timedelta(minutes=720)
??????????? time_diff = target_date - current_date
??????????? days =? str(time_diff.days) if len(str(time_diff.days)) > 1 else "0" + str(time_diff.days)
??????????? hours, remainder = divmod(time_diff.seconds, 3600)
??????????? minutes, seconds = divmod(remainder, 60)
??????????? countdown_str = f"""| {days} | {hours:02d} | {minutes:02d} | {seconds:02d} |"""
??????????? ph.metric("Countdown",countdown_str)
??????????? time.sleep(1)
??????? ph.write("Merry Christmas!")