Streamlit in Cognite Data Fusion
Streamlit is integrated with Cognite Data Fusion (CDF) and you can use it to create data visualization tools, dashboards, or prototypes and make these available in the Industrial tools workspace. Access to data is governed by the user running the app, and users can only see data they already have access to.
Use Python code and the Cognite SDK to create your app and let CDF handle authentication, infrastructure, and data storage. In CDF, you'll also find tools for debugging and testing, and you can install public dependencies directly.
The features described in this section are currently in beta testing and are subject to change.
Before you start
To develop Streamlit apps in CDF, we recommend that you get familiar with Python programming, the Streamlit library, and the Cognite Python SDK. Also, make sure that you have the necessary access capabilities.
Create an app
-
Navigate to Data management > Build solutions > Streamlit apps.
-
Select Create app and start from scratch, import a Streamlit application file, or use one of the CDF app templates.
-
Provide a title and description for your application.
-
Optionally, provide a data set to restrict access to your application.
-
Start developing the application.
Learn more in the CDF developer documentation and the Streamlit documentation.
Manage files
Split your project into multiple files and pages in the code editor. Import files and pages with the Python import
statement.
To add additional files:
-
Select + Add file from the side panel.
-
Select the file type. Library files are imported through Python code. Page files display as separate pages in the side panel when you run the application.
The file name determines the page order. To control the page order, you can prefix the names with a number. You can also use emojis to add icons, and use underscores to insert a whitespace in the name.
Install third-party packages
From the Settings menu, you can install third-party packages from PyPi and specify versions using pip requirement specifiers. See also limitations to packages.
Manage access
Streamlit applications are stored using the Cognite Files API. To access the applications you need access to the underlying files.
We recommend that you create dedicated data sets and use them to scope the access to the Streamlit applications, typically with files:read
access for end users. App maintainers also need files:write
access to the data sets.
See also capabilities for Streamlit apps.
Publish applications
Published applications are available under Custom apps in the Industrial tools workspace.
Technical limitations
In CDF, Streamlit has these limitations:
-
CDF only supports packages written in pure Python. The error Can't find a pure Python 3 wheel for ‘<package>’ indicates that a package relies on native libraries incompatible with Pyodide. For more details and workarounds, refer to the Pyodide documentation.
-
The browser environment limits network access due to cross-origin resource sharing (CORS) policies. This can affect access to external data sources and services.
dicaCORS workarounds:
- Data ingestion via Cognite Function: You can ingest data into CDF using a Cognite Function, allowing access within Streamlit once the data is available in CDF.
- Triggering HTTP actions with Cognite Functions: If you need to perform an action via an HTTP request, you can trigger it using a Cognite Function directly from Streamlit. Note that some processing delay may occur as the function executes.
-
Hardware resources can limit browser-based environments. This includes access to graphics processing units (GPUs) and constraints on available memory and processing power.
-
Multithreading isn't supported. Other functions, for example
sleep()
, may not perform as expected under Pyodide.
See also https://github.com/whitphx/stlite?tab=readme-ov-file#limitations .