Resources¶
Resources are the primary mechanism for defining inputs and outputs in Ocelescope plugins.
A resource can represent almost anything — from process models to tabular datasets.
Resources are automatically uploadable and downloadable, making them easy to share across plugin methods and even between different plugins.
Defining a Resource¶
To create a custom resource:
- Define a Python class that inherits from
Resource(provided by theocelescopepackage). - Resource classes can include any number of properties and methods required by your plugin.
- Metadata such as
labelanddescriptioncan be added to improve how the resource appears in the frontend. - Resources can be shared across plugins if they have the same class name and field definitions.
| Example: Defining a Resource | |
|---|---|
Resources Must Be JSON-Serializable
For import and export to work, resources must be serializable and instantiable from their serialized form.
Fields should use standard types such as str, int, float, bool, list, or dict, or any custom subclass that is itself serializable.
To verify that your resource is serializable, try creating an instance from its own serialized output:
Visualization¶
Visualizations in Ocelescope allow resources to render themselves in the frontend using predefined visualization types such as graphs, SVGs, and tables.
To enable visualization for a resource, implement the visualize() method in your Resource subclass. This method should return one of the supported visualization objects described below.
Supported Visualization Types¶
Graph¶
A graph visualization model composed of nodes and directed edges. Commonly used for Petri nets, directly-follows graphs, and other graph-based models. Layout and rendering are powered by Graphviz.
Classes¶
GraphGraphNodeGraphEdgeGraphvizLayoutConfig
GraphNode¶
Defines a visual node in the graph.
| Field | Type | Description |
|---|---|---|
id | str | Unique node ID (UUID string, auto-generated) |
label | str | None | Display label for the node |
shape | Literal["circle", "triangle", "rectangle", "diamond", "hexagon"] | Node shape |
width | float | None | Node width in pixels |
height | float | None | Node height in pixels |
color | str | None | Fill color (hex or named color) |
x | float | None | X-coordinate after layout (auto-set) |
y | float | None | Y-coordinate after layout (auto-set) |
border_color | str | None | Border (stroke) color |
label_pos | Literal["top", "center", "bottom"] | Label position relative to node (default: "bottom") |
rank | Literal["source", "sink"] | int | None | Optional rank constraint for layout (e.g., "source", "sink", or numeric level) |
layout_attrs | dict[str, str | int | float | bool] | None | Additional Graphviz attributes for this node |
GraphEdge¶
Represents a directed connection between two nodes.
| Field | Type | Description |
|---|---|---|
id | str | Unique edge ID (UUID string, auto-generated) |
source | str | Source node ID |
target | str | Target node ID |
color | str | None | Edge color |
label | str | None | Label text displayed along the edge |
start_arrow | EdgeArrow | Arrowhead at the start of the edge (default: None) |
end_arrow | EdgeArrow | Arrowhead at the end of the edge (default: None) |
start_label | str | None | Label near the source end |
end_label | str | None | Label near the target end |
layout_attrs | dict[str, str | int | float | bool] | None | Additional Graphviz attributes for this edge |
annotation | Visualization | None | Optional annotation attached to the edge |
EdgeArrow¶
Supported arrowhead styles:
GraphvizLayoutConfig¶
Specifies Graphviz layout engine and default attributes for rendering.
| Field | Type | Description |
|---|---|---|
engine | GraphVizLayoutingEngine | Graphviz engine (dot, neato, fdp, sfdp, etc.) |
graphAttrs | dict[str, str | int | float | bool] | None | Global graph attributes (e.g., rankdir, splines, size) |
nodeAttrs | dict[str, str | int | float | bool] | None | Default attributes for all nodes (e.g., shape, color, fontsize) |
edgeAttrs | dict[str, str | int | float | bool] | None | Default attributes for all edges (e.g., arrowsize, color, penwidth) |
Graph¶
Main graph visualization container.
| Field | Type | Description |
|---|---|---|
type | Literal["graph"] | Fixed type identifier |
nodes | list[GraphNode] | List of graph nodes |
edges | list[GraphEdge] | List of graph edges |
layout_config | GraphvizLayoutConfig | Graphviz layout configuration |
Example Usage¶
Graphviz automatically determines node coordinates (x, y) and dimensions (width, height) based on the chosen layout engine and attributes.
SVG¶
Use raw SVG markup when a graph-based layout is not appropriate, or when you need full control over visuals.
- Class:
SVGVis - Use case: Custom layouts, charts, icons, or any visualization expressible as SVG.
Example
Table¶
A structured table with typed columns and customizable rows. Ideal for datasets, summaries, or event logs.
- Class:
Table - Column Class:
TableColumn - Supported Column Types:
string,number,boolean,date,datetime
The table supports sorting, hiding, and formatting options for each column.
For advanced use cases, you can contribute your own visualization types to the Ocelescope framework
Dot¶
A raw Graphviz DOT visualization, preserving the full DOT source string. Useful when you want direct control over Graphviz rendering or need to reuse an existing DOT description.
- Class:
DotVis - Layout: Explicitly set by Graphviz via a chosen layout engine (
dot,neato,fdp, etc.)
DotVis¶
| Field | Type | Description |
|---|---|---|
type | Literal["dot"] | Identifies the visualization type as DOT |
dot_str | str | The raw DOT source string (as produced by graphviz.Digraph or Graph) |
layout_engine | GraphVizLayoutingEngine | The Graphviz engine used (dot, neato, fdp, sfdp, circo, etc.) |
Supported Layout Engines¶
| Engine | Description |
|---|---|
dot | Hierarchical layouts, suited for layered graphs and flowcharts |
neato | Spring-model layouts, good for undirected graphs |
fdp | Force-directed placement, similar to neato |
sfdp | Scalable force-directed placement for large graphs |
circo | Circular layouts |
twopi | Radial layouts (nodes placed in concentric circles) |
osage | Clustered layouts |
patchwork | Treemap-style layouts |
nop, nop2 | No-op layout engines (use raw input positions if given) |
Constructing from Graphviz¶
Use .from_graphviz() to convert an existing graphviz.Digraph or graphviz.Graph object into a DotVis.
The resulting DotVis object carries both the DOT source (dot_str) and the layout engine specification, allowing full control over Graphviz rendering.