
Data Engineering & Infrastructure
In March 2022, Snowflake acquired Streamlit, creators of a Python library for crafting sleek web apps. At Summit 2022, Snowflake introduced Native Apps, enabling users to monetize their creations directly within the Snowflake Marketplace. By June 2023, the Native App Framework launched its public preview on AWS, opening the door for thousands to harness these potent features.
These considerable investments of time and resources are a testament to Snowflake’s strategic goal of enabling users to build, deploy, and use apps without leaving its platform. These Native Apps can be defined as bundling code, data, and Snowflake objects, using a wide array of core Snowflake functionality – including Streamlit, Snowpark, and many others – along the way.
The Aimpoint Digital team has been closely tracking these releases & experimenting with these new features. We are excited to share a series of technical blogs detailing how to utilize these features effectively and the best practices for seamless app deployment.
In this blog post, we will dive into the basics of deploying Streamlit apps within the Snowflake Native Apps Framework.
Before we get into the nitty-gritty details, let’s recap the key concepts and how they fit together.
A Streamlit application refers to an interface built using the Python Streamlit library. This library makes it supremely easy to connect to data and create interactive dashboards, machine learning and predictive analytics models, or data-processing functionality with a slick UI.
A Streamlit app can also be built and run locally on your machine – it is not a purely Snowflake native feature. Snowflake is introducing a separate Streamlit in Snowflake (or SiS) feature that will allow users to quickly build web apps directly into the UI – these are separate from Native Apps and are designed to be used by users within their own Snowflake account.
The standalone Streamlit apps are currently in private preview.
The Snowflake Native App Framework refers to the set of capabilities one can use & rules one must follow when creating a Native App that can be shared with consumer accounts.
Native Apps can include various Snowflake features, including stored procedures, Snowpark, or Streamlit. Once the code & files that comprise an app are ready, they are packaged up into an Application Package from which the Native App is installed.
The Native Apps Framework is built around the concept of Providers and Consumers, similar to data shares:
With this high-level architecture in mind, let us now delve into the detail of creating & deploying a simple Streamlit interface into a Native App using the Native Apps Framework.
To deploy a Streamlit interface in a Snowflake Native App, one must follow the following steps:
In this guide, we will leverage the Snowsight UI functionality as much as possible – but keep in mind that all these deployment & configuration steps can be done directly using a combination of SQL commands and basic scripting.
The Native Apps Framework requires an application to contain a specific set of files. We will be using our Manual Data Entry app as an example and highlighting which bits of code you will have to update to set things up correctly with your application:
-- Setup script for the Manual Data Entry application.
CREATE APPLICATION ROLE manual_data_entry_role;
CREATE OR ALTER VERSIONED SCHEMA code_schema;
GRANT USAGE ON SCHEMA code_schema TO APPLICATION ROLE manual_data_entry_role;
CREATE STREAMLIT code_schema.manual_data_entry_streamlit
FROM '/streamlit'
MAIN_FILE = '/_Data_Entry_App.py';
GRANT USAGE ON STREAMLIT code_schema.manual_data_entry_streamlit TO APPLICATION ROLE manual_data_entry_role;
When building your own setup script, you should pick an APPLICATION ROLE, SCHEMA, and specific Streamlit app name that is relevant to your application.
Make sure also to update the MAIN_FILE path to match the name of your Streamlit Python file.
manifest_version: 1
version:
name: V1
label: Version One
comment: The first version of the application
artifacts:
setup_script: scripts/setup.sql
readme: README.md
We also recommend being aware of the following file:
name: sf_env
channels:
- snowflake
dependencies:
- snowflake-native-apps-permission
As a last point, the Native Apps Framework will expect a specific file structure when these files are added to the application package:
With these files prepared, we are ready to build our Application Package in Snowflake. We will do this in 3 steps:
First, we will create our Application Package:
GRANT CREATE APPLICATION PACKAGE ON ACCOUNT TO ROLE native_app_developer;
CREATE APPLICATION PACKAGE manual_data_entry_app;
USE APPLICATION PACKAGE manual_data_entry_app;
CREATE SCHEMA content_stage;
CREATE OR REPLACE STAGE manual_data_entry_app.content_stage.manual_data_entry_app
FILE_FORMAT = (TYPE = 'csv' FIELD_DELIMITER = '|' SKIP_HEADER = 1);
After completing these steps, you should see the following objects inside of your Snowflake instance:
With the stage ready, we can now add our files to the stage. Start by navigating to the stage you have just created.
Hit the big blue “+ Files” button in the top right corner to add files. We recommend enabling directory tables to view your files – the option will be in the middle of your screen.
In the pop-up window that appears, start adding your files. You can drag and drop the files directly into the box or hit browse to use your file explorer.
Bring in all the files that are meant to live in the same directory together:
You can type the names of the folders in the “Specify path…” text box.
Once all the files have been added, your application package should look like this:
Finally, now that the application package is ready, we can now deploy a new version of our application.
To do this through the UI, navigate to the Apps objects and click on Packages in the top section.
Fill out the required details, and make sure to indicate the path to your application files:
Once you hit publish, you should be greeted with the following screen.
You have now successfully completed creating an application package built using the Snowflake Native Application framework.
Now that your application package has been successfully created, you can:
This guide will show how to create an app in your account. We will dedicate a future blog to best practices around creating listings for the marketplace.
First, to create an Application from an Application Package, make sure you have granted the following privileges to the role you will be using:
GRANT CREATE APPLICATION ON ACCOUNT TO ROLE native_app_developer;
CREATE APPLICATION MANUAL_DATA_ENTRY_APP FROM APPLICATION PACKAGE MANUAL_DATA_ENTRY_APPLICATION USING VERSION V0;
Alternatively, you can specify the location of the stage where the application package is located:
CREATE APPLICATION MANUAL_DATA_ENTRY_APP
FROM APPLICATION PACKAGE MANUAL_DATA_ENTRY_APPLICATION
USING '@manual_data_entry_application.content_stage.manual_data_entry_application_stage';
Once you have done this, your newly installed application will appear under the Apps objects in your Snowflake instance. Congratulations, you have successfully installed your first Native App!
To use your application, click on it and navigate to the tab linked to your Streamlit application.
If you would like to update or modify your application, upload new or updated existing application package files, release an updated version or patch, and re-create the application.
Snowflake’s Native Application features are incredibly powerful tools for allowing customers to get more value out of their data without having to leave the comfort of the platform. Furthermore, it massively simplifies the task of creating & managing SaaS tools for skilled developers hoping to monetize their products without worrying about the infrastructure overhead.
If you want to discuss or deploy native apps, do not hesitate to reach out using the form below.
Whether you need advanced AI solutions, strategic data expertise, or tailored insights, our team is here to help.