Skip to main content

A component to render STEP files in Streamlit.

Project description

Cognite STP renderer

This is a Streamlit library that can be used to show CAD 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 streamlit-cognite-stp-renderer

How to use

Here is an example app

import streamlit as st
from stp_renderer import StpRendererParams, stp_renderer
from cognite.client import CogniteClient

client = CogniteClient()

state = stp_renderer(
    client=client,
    file_id=1234,
    params=StpRendererParams(height=400),
    key='stp_renderer'
)
st.header("STP Renderer:")
st.json(state)

Local development

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

Clone repo git clone git@github.com:cognitedata/streamlit-cognite-stp-renderer.git

Install Python packages pip install streamlit pip install cognite-sdk

Install NPM packages and start server

cd stp_renderer/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 stp_renderer/init.py:8 to _RELEASE = True.

Step 1) Build front end component with cd stp_renderer/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_stp_renderer-0.0.1-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.

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_stp_renderer-0.0.1.tar.gz (16.7 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

streamlit_cognite_stp_renderer-0.0.1-py3-none-any.whl (16.8 MB view details)

Uploaded Python 3

File details

Details for the file streamlit_cognite_stp_renderer-0.0.1.tar.gz.

File metadata

File hashes

Hashes for streamlit_cognite_stp_renderer-0.0.1.tar.gz
Algorithm Hash digest
SHA256 8ae34940cc89cb252ad833d8f154eb653081dabe1afbb1059933665f11a435d9
MD5 1da77ed86df60eb79adfcc2603c12e53
BLAKE2b-256 1db1117244351f6b774ac336eec9f7dfa6fdc0c7a1356db07991d42a17b7ab12

See more details on using hashes here.

File details

Details for the file streamlit_cognite_stp_renderer-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for streamlit_cognite_stp_renderer-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0178b723d6358a936b02cb51fd96a17292b5fccad57c5dce0defb18c36589cb4
MD5 5508dafbcfc4a9f92ed8018da81026b4
BLAKE2b-256 7e505b7123aa853de1f72aa32c202548187978f4b6e4a2e79b8c257e11a5dfa9

See more details on using hashes here.

Supported by

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