Application¶
The application class configures the browser UI, registers actions and algorithms, creates per-browser sessions, and runs the web server.
ImFusionWebApp
¶
ImFusionWebApp(
title="ImFusion WebApp",
sidebar=None,
show_load_button=True,
show_export_button=False,
branding=None,
info=None,
theme=None,
layout=None,
export_formats=None,
sample_datasets=None,
algorithm_selector=None,
)
Bases: OperationRegistrationMixin
FastAPI-based web application for ImFusion WebSDK Python integration.
Initialize the ImFusion WebSDK web application.
on_session_created
¶
Register a callback run once per browser connection.
The place to hook up per-session listeners that no action or workflow
step owns — app.annotation_model.on_annotation_added for an
application that lets the user draw whenever they like. Called on the
ImFusion SDK owner thread with that session's controller, after its seed
data and workflow exist.
set_workflow
¶
Configure the workflow used to create an isolated instance per session.
Accepts either a factory Callable[[app], Workflow] for advanced or
session-conditional workflows, or a plain sequence of steps that is
cloned into a fresh Workflow for each session.
Session controller¶
Callbacks and workflow factories receive one controller per browser connection.
It exposes the portable imfusion.app-style surface and web-specific progress
and selection operations.
WebApplicationController
¶
Browser-session equivalent of the portable imfusion.app subset.
update_progress
¶
Publish progress for this session's active job.
execute_algorithm
¶
Execute an ImFusion algorithm and publish its outputs.
publish_results
¶
Insert, replace, or refresh processing outputs.
download
¶
Push a file to the browser's downloads.
For artifacts the app builds itself — annotation geometry as JSON, a
measurement table as CSV — where ExportStep does not apply because
it only writes datasets in ImFusion's own formats.
Execution policy¶
The HTTP and WebSocket server runs on its own thread. Operations that may touch the ImFusion SDK are queued and executed serially on the thread that created the application and owns ImFusion's OpenGL context.
Each session may have one queued or running operation. Cancelling queued work
prevents it from starting. Cancelling running native work marks it as
cancel-requested; the Python SDK does not expose a general algorithm
interruption API. WebAppKit suppresses automatic publication of returned
outputs when possible, but it cannot roll back in-place SDK mutations or
arbitrary callback side effects. Long callbacks should check
app.cancellation_requested before committing side effects.