Multi user support #820
-
|
Hi, i'm working with trame and pyVista for visualize vtu files. Everythink is working fine with a single user. I'd like to implement a mechanism that allow different users to work on diffent vtu files in a separete state. At the moment on my main.py (entry point) i istanciate a viewer class. How can i achieve a multi user setup? Followin main.py: import argparse
import sys
from loguru import logger
import os
from ui.viewer import TrameViewer
def main():
args = parse_arguments()
setup_logging(args.debug)
# Initialize viewer app
viewer = TrameViewer()
print("=" * 60)
print("VTK Viewer started!")
print(f"Trame UI: http://{args.host}:{args.port}")
print("=" * 60)
try:
# Start Trame (blocks main thread)
viewer.start(port=args.port)
except KeyboardInterrupt:
logger.info("🛑 Shutting down application...")
except Exception as e:
logger.error(f"❌ Trame server error: {e}")
# Other utilities functions
if __name__ == "__main__":
main()Following the init function of viewer.py class # PyVista
import pyvista as pv
from pyvista.trame.ui import plotter_ui
from pyvista import examples
# Trame Imports
from trame.app import get_server
from trame.app.file_upload import ClientFile
from trame.ui.vuetify3 import SinglePageWithDrawerLayout
from trame.widgets import vuetify3, trame # This import provide the access to trame's widget for vtk and vuetify
from trame.ui.vuetify3 import SinglePageWithDrawerLayout
# Core Imports
from config.enums import ColorMap, RenderMode
from config.settings import config
pv.OFF_SCREEN = True
class TrameViewer:
"""Interfaccia grafica Trame + PyVista per visualizzare file VTU con controllo avanzato."""
def __init__(self):
# --- SERVER TRAME ---
self.server = get_server(client_type="vue3")
self.state = self.server.state
self.ctrl = self.server.controller
# --- CONFIGS ---
self.config = config
# --- PLOTTER & PIPELINE ---
self.plotter = pv.Plotter(off_screen=True, notebook=False, window_size=(800, 600))
self.mesh = examples.load_random_hills()
self.plotter.add_mesh(self.mesh)
# --- FILE-UPLOAD ---
self.state.file_exchange = None
self.upload_vtu_file()
# --- Initialize state for mesh card UI ---
self.state.setdefault("active_ui", None)
self.state.setdefault("mesh_color_selection", 0)
self.state.setdefault("mesh_representation", RenderMode.SURFACE)
self.state.setdefault("color_map", ColorMap.COOL_WARM)
self.state.setdefault("mesh_opacity", config.default_opacity)
self.state.setdefault("show_edges", True)
## --- Initialize state for contour card UI ---
self.state.setdefault("num_contours", 10)
self.state.setdefault("contours_opacity", 1)
self.state.mesh_options = []
# --- Create UI ---
self.create_ui()
# --- Setup Callbacks ---
self.setupCallbacks()
# Other code that manage callbacks and define UI
# ----------------------------------------------------------
# SERVER START
# ----------------------------------------------------------
def start(self, port=3015):
"""Start trame (block main process)"""
self.server.start(port=port)Thanks :) |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 7 replies
-
|
Interesting question, I'have not found a solution for the same use case. |
Beta Was this translation helpful? Give feedback.
-
|
The multi user setup can be achieved with the docker bundling. See those examples for reference. If you want to configure each session differently based on some URL parameter, you need to rely on the CLI and template some of your parameters with the ones you will get from the URL inside the apps.yml like we do with host and port. HTH |
Beta Was this translation helpful? Give feedback.
-
|
Thanks for the prompt reply. I updated my docker file, now using: FROM kitware/trame:uv-glvnd
ENV TRAME_PYTHON=3.13
RUN apt-get update \
&& apt-get install -y \
libxrender1 \
&& rm -rf /var/lib/apt/lists/*
COPY --chown=trame-user:trame-user . /deploy
RUN /opt/trame/entrypoint.sh buildAnd added setup folder with Now i can build the docker image correctly but when i run Thanks |
Beta Was this translation helpful? Give feedback.
-
|
The error inside is the following: |
Beta Was this translation helpful? Give feedback.
-
|
Thank you so much for your fast support! |
Beta Was this translation helpful? Give feedback.
--data ${data}is not expected on the trame side though.