Skip to content

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

on_session_created(callback)

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

set_workflow(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.

run

run(host='localhost', port=8000, **kwargs)

Start the server.

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

WebApplicationController(host, session)

Browser-session equivalent of the portable imfusion.app subset.

update_progress

update_progress(progress, message=None)

Publish progress for this session's active job.

open

open(path)

Load data on the SDK thread and add it to this session.

execute_algorithm

execute_algorithm(algorithm_id, data=None, properties=None)

Execute an ImFusion algorithm and publish its outputs.

publish_results

publish_results(
    result, operation_name, inputs=None, replace=None
)

Insert, replace, or refresh processing outputs.

download

download(
    filename, content, media_type="application/octet-stream"
)

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.

close_all

close_all()

Clear all session data and browser views.

select_data

select_data(data)

Set the browser-visible selection for this session.

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.