Skip to main content

Streamlit wrapper for Cognite Reveal to view 3D content from Cognite Data Fsion

Project description

Cognite 3D Reveal Streamlit

This is a Streamlit library that can be used to show 3D models inside a Streamlit app. It works especially good when used inside Streamlit in Fusion, but can also be used in standalone Streamlit apps.

How to install

You simply install it by running pip install cognite-streamlit-reveal

How to use

Here is an example app

import streamlit as st
import os
from cognite.streamlit import reveal
from cognite.client import CogniteClient

st.subheader("Cognite Reveal Streamlit example")
client = CogniteClient()
model_id = 123
revision_id = 234

selected_node_id = reveal(client, model_id, revision_id)
st.markdown("Selected node id: %d!" % int(selected_node_id))

Local development

It's recommended to add a clean environment. You need pip and node.

Clone repo git clone https://github.com/cognitedata/streamlit-cognite-reveal.git

Install Python packages pip install streamlit pip install cognite-sdk

Install NPM packages and start server

cd reveal/frontend
yarn
HTTPS=true yarn start

Then open https://localhost:3001/ to accept bad certificate.

Open repo folder in another terminal. Install this package as development package pip install -e .

Extract a token from Fusion, and start with

COGNITE_TOKEN="TOKEN" streamlit run examples/demo.py

Local development in fusion stlite

Make sure you have set (reveal/init.py:8)[reveal/init.py:8] to _RELEASE = True.

Step 1) Build front end component with cd reveal/frontend && yarn && yarn build Step 2) Build streamlit component with python -m build (hint: pip install build) Step 3) Start local server python server.py

Open Fusion, create a Streamlit app and add the following the installed package http://localhost:8000/dist/streamlit_cognite_reveal-0.0.6-py3-none-any.whl

It will then load successfully inside Stlite.

Building a release version

In order to build a packaged release version, follow steps:

Set the 'RELEASE' environment variable to indicate to build system that you are building a release version: export RELEASE=1

steps to actually build the package

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

streamlit_cognite_reveal-0.0.7.tar.gz (6.0 MB view details)

Uploaded Source

Built Distribution

streamlit_cognite_reveal-0.0.7-py3-none-any.whl (6.1 MB view details)

Uploaded Python 3

File details

Details for the file streamlit_cognite_reveal-0.0.7.tar.gz.

File metadata

File hashes

Hashes for streamlit_cognite_reveal-0.0.7.tar.gz
Algorithm Hash digest
SHA256 a26b17a2fbf6832e9b3053499fabdaca29d85bf83d44c14182475761121d00c6
MD5 5f19d22c6c6baf0d6d462cfbb7706947
BLAKE2b-256 35cc98930deff8291f62928502e206713879b6e4a9338c8be58cc1134cecc294

See more details on using hashes here.

File details

Details for the file streamlit_cognite_reveal-0.0.7-py3-none-any.whl.

File metadata

File hashes

Hashes for streamlit_cognite_reveal-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 ed11e856435402545ecebfa7d18b6c30cd6eac93d14cc3ae2f62c8a0191c4769
MD5 fdb702ae8f7011c7dc2c0e95ee290cf5
BLAKE2b-256 71978b1b9152f8566661383aa62ed589904bfe10217922a1813cc6d55d34188d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page