Skip to content

Data Export Interface

app.application.interfaces.data_export_interface

View source code

Protocol interface for layer data exporters.

See Also

Layer: Application. Context: Defines protocol boundaries consumed by application orchestration.

IDataExporter

Bases: Protocol

Abstraction boundary for services that serialise a session layer to a file.

Any object that exposes export_layer() with a matching signature satisfies this interface — no explicit inheritance required (structural subtyping via Protocol).

Note

Two concrete implementations exist:

  • DetectionExportService — reads from detection layers (A / B).
  • TrackingExportService — reads from tracking layers (C / D).

The file format (JSON or CSV) is determined by the extension of file_path and handled entirely by the concrete service; callers do not need to be aware of the format.

Consider future improvement: add a supported_formats() -> list[str] method to the interface so the dialog can dynamically build its format combo box from what the service advertises, rather than hard-coding ["json", "csv"] on the UI side.

Layer: Application. Context: Coordinates use-case behavior through domain services and application contracts.

export_layer(s_id: SessionId, layer: VideoDataLayer, file_path: str) -> int

Export bounding-box data from layer for session s_id to file_path.

PARAMETER DESCRIPTION
s_id

Source session.

TYPE: SessionId

layer

Source layer inside the session's SessionDataStore.

TYPE: VideoDataLayer

file_path

Absolute destination path. The file extension (.json or .csv) determines the serialisation format.

TYPE: str

RETURNS DESCRIPTION
int

Number of boxes written to the file.

TYPE: int

RAISES DESCRIPTION
ValueError

If the file extension is not recognised.