Skip to main content

scivianna-graph

Build interactive ReactFlow graphs from a plain-Python model. Each node is an embedded Panel/Bokeh figure on a draggable, zoomable canvas - ideal for visualizing the topology of coupled simulations or 1D pipe networks where the plots need to be rotated, plugged on any side and rearranged by hand.

from scivianna_graph import GraphModel, GraphNode, GraphEdge, SciviannaGraph

model = GraphModel()
model.add_node(GraphNode(id="core", position=(0, 0), label="Core", rotation=15))
model.add_node(GraphNode(id="assembly", position=(420, 0), label="Assembly"))
model.add_edge(
    GraphEdge(source="core", target="assembly",
              source_direction="right", target_direction="left")
)

SciviannaGraph(model).make_panel().servable()

Features

  • Plugs on every side - each node exposes handles on all four sides (top/bottom/left/right). An edge declares which side it attaches to on each endpoint, and directions are expressed in the node's own frame, so a pipe flows right-out -> left-in whatever its rotation.
  • Rotatable nodes - rotate any node (border, handles and figure together) by an angle in degrees. An optional fixed pivot (rotation_origin) keeps a point in place while the node rotates - e.g. rotate a pipe about its inlet so pipes fan out radially.
  • Group drag-select - drag an empty area of the canvas to marquee-select several nodes and move them together; drag a single node to reposition it.
  • Embedded figures - each node renders any Panel viewable (typically a Bokeh figure). Give the viewable explicit width/height so the node is sized correctly.
  • Zoom, pan, minimap, controls - standard ReactFlow navigation, all optional.

Install

pip install scivianna-graph

The frontend bundle ships with the package, so no build step or network access is needed at runtime.

Usage

GraphModel is plain Python (no frontend required) and can be built, inspected and serialized on its own:

from scivianna_graph import GraphModel, GraphNode, GraphEdge

model = GraphModel()
model.add_node(GraphNode(id="a", position=(0, 0), label="Inlet",
                         view=bokeh_pane_a))          # optional embedded figure
model.add_node(GraphNode(id="b", position=(300, 0), label="Core",
                         rotation=90,                  # rotate about the centre ...
                         data={"rotation_origin": (0.5, 1.0)}))  # ... or about a pivot
model.add_edge(GraphEdge(source="a", target="b",
                         source_direction="right", target_direction="left"))

graph = SciviannaGraph(model)
graph.make_panel().servable()

Nodes may carry an embedded Panel viewable (e.g. a Bokeh figure wrapped in pn.pane.Bokeh) via GraphNode(view=...).

Display options are passed as SciviannaGraph(...) kwargs: min_zoom, max_zoom, show_controls, show_minimap, enable_multiselect, show_unconnected_ports (default false: only plugs used by an edge are drawn) and rotation_origin (default pivot for every node).

API

Name Purpose
GraphModel Container of nodes and edges; add_node, add_edge, get_node, validate, to_dict.
GraphNode A node: id, position, optional label, view, rotation, data.
GraphEdge A directed edge: source, target, source_direction, target_direction, optional label.
SciviannaGraph Builds the canvas from a GraphModel; set_model, make_panel, and in-place set_node_* / set_edge_* helpers.

Development

The frontend is a standalone React app (src/scivianna_graph/dist/app.jsx) compiled to SciviannaGraphCanvas.bundle.js (+ .bundle.css). To rebuild it after editing the JSX, run from the repository root:

./build.sh            # or: npm run build

build.sh runs npm install (local esbuild) and then panel compile. It needs node, npm, network access for the first run, and pip install panel. Rebuild after every change to app.jsx. Without a bundle, Panel compiles the JSX in the browser and fetches @xyflow/react from esm.sh (needs network). See AGENTS.md for build notes and gotchas.

Metadata

Release files for scivianna-graph 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for scivianna-graph 0.1.2
File Size Uploaded Provenance Actions
scivianna_graph-0.1.2.tar.gz 135.0 kB Without provenance Details for scivianna_graph-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for scivianna-graph 0.1.2
File Interpreter ABI Platform Actions
scivianna_graph-0.1.2-py3-none-any.whl Python 3 none any Details for scivianna_graph-0.1.2-py3-none-any.whl

Total release size: 269.6 kB

Release files / scivianna_graph-0.1.2.tar.gz

Download URL scivianna_graph-0.1.2.tar.gz
Size 135.0 kB
Tags Source
SHA-256 checksum
How to use checksums
4b3c1c3796d2c5d1e8b333a63c145e4695648b03bb9c0c9c74626f7b252f0f02
BLAKE2b-256 checksum
How to use checksums
23fa0060c238b0ed07478f90b0485e444cb6e5036d13d96370eb209f1a75cffa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.12

Release files / scivianna_graph-0.1.2-py3-none-any.whl

Download URL scivianna_graph-0.1.2-py3-none-any.whl
Size 134.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
55cdeb51155cf0f815db0b6383ed100f2831dc4d92a247d1c34b6935669dbb4c
BLAKE2b-256 checksum
How to use checksums
50caf8492150a590b1e673759a6a12e6276e8a3dc3b5be6b19b123700a0fecf1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.12

Security for scivianna-graph 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page