Metadata-Version: 2.1
Name: streamlit-pyvista
Version: 0.0.9
Summary: A Streamlit component that allow support for new PyVista viewer backend: Trame.
Home-page: https://gitlab.com/groups/dcsm
License: GPL-3.0-or-later
Author: Maxime Rochat
Author-email: rochat.max@gmail.com
Requires-Python: >=3.9.12,<4.0.0
Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Dist: APScheduler (>=3.10.4,<4.0.0)
Requires-Dist: Flask (>=3.0.3,<4.0.0)
Requires-Dist: aiohttp (>=3.9.3,<4.0.0)
Requires-Dist: flask-sock (>=0.7.0,<0.8.0)
Requires-Dist: protobuf (<=4.25.3)
Requires-Dist: pytest (>=7.2.1)
Requires-Dist: pyvista (>=0.43.3,<0.44.0)
Requires-Dist: requests (>=2.31.0,<3.0.0)
Requires-Dist: streamlit (>=1.17.0,<2.0.0)
Requires-Dist: trame (>=3.5.2,<4.0.0)
Requires-Dist: trame-client (>=2.16.1,<3.0.0)
Requires-Dist: trame-plotly (>=3.0.2,<4.0.0)
Requires-Dist: trame-server (>=2.17.2,<3.0.0)
Requires-Dist: trame-vtk (>=2.8.5,<3.0.0)
Requires-Dist: trame-vuetify (>=2.4.2,<3.0.0)
Requires-Dist: validators (>=0.28.0,<0.29.0)
Requires-Dist: websocket-client (>=1.8.0,<2.0.0)
Project-URL: Repository, https://gitlab.com/dcsm/streamlit-pyvista
Description-Content-Type: text/markdown

# Streamlit PyVista
[![PyPI version](https://badge.fury.io/py/streamlit-pyvista.svg)](https://badge.fury.io/py/streamlit-pyvista)
[![Read the Docs](https://readthedocs.org/projects/streamlit_pyvista/badge/?version=latest)](http://streamlit-pyvista.readthedocs.io/)

A Streamlit component that allow support for new pyvista viewer backend : Trame. 

# Installation instructions
````sh
pip install streamlit-pyvista
````
# Usage Instructions

````python
import streamlit as st
from streamlit_pyvista.mesh_viewer_component import MeshViewerComponent


def main():
    st.title("Simple Streamlit App With Pyvista Viewer")

    mesh_viewer = MeshViewerComponent(
        "https://gitlab.com/dcsm/streamlit-pyvista/-/raw/main/examples/assets/plate_hole.vtu")
    mesh_viewer2 = MeshViewerComponent("assets/plate_hole.vtu")

    mesh_viewer.show()
    mesh_viewer2.show()


if __name__ == "__main__":
    main()
````
Note that instead of a file path or a url it's also possible to pass an array of link or path to display a sequence
of files.

This viewer leverage the capabilities of the new pyvista backend `Trame`, beyond  the nice design revamp, 
it also supports remote rendering.

# Package documentation
You can find the automatic documentation generated with sphinx [here](https://streamlit-pyvista.readthedocs.io/)

# Workflow overview

This package has 3 different components: 
- The Streamlit component
- The Trame viewers
- A "Server manager"

## Streamlit component
This pyvista new backend requires now to have its own server for each instance of a pyvista plotter. This means that the
streamlit component can be as simple as an iframe and displayed in the app and can use a simple api to communicate with 
the trame server and the server manger

## Trame viewers
The Trame viewers are the servers that are embeded in the streamlit app, it has exposed api endpoints that allow the 
component to communicate with the server for action such as loading a mesh in the viewer.

## Server manager
As said earlier, the trame viewers can only display one plotter at a time which means that if we want to display 
multiple plotters we need multiple servers. The job of the Server manager is to control how many trame viewers exists, 
if they need to killed or if they can be reused for other viewers

## Workflow
These 3 components interact the following manner:
1) A `MeshViewerComponent` is created and notify a `ServerManager` that it needs a viewer.
2) The `ServerManager` look if he have idling trame viewer anf if not, it start a new server.
3) The `ServerManager` specify the endpoints of the server that can be used to the `MeshViewerComponent`
4) The `MeshViewerComponent` directly communicate with the api of the trame viewer via the endpoints 
specified by the `ServerManager` 


