Skip to content

Data Import Interface

app.application.interfaces.data_import_interface

View source code

Protocol interface for layer data importers.

See Also

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

IDataImporter

Bases: Protocol

Abstraction boundary for services that load bounding-box data from a file into a session layer.

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

Note

Two concrete implementations exist:

  • DetectionImportService — targets detection layers (A / B).
  • TrackingImportService — targets tracking layers (C / D).

Both share the same wire-format logic from app.application.services.helpers.layer_io so the file produced by one can be read back by the other (cross-layer import is intentionally supported by the dialog).

Consider future improvement: add a validate_file(file_path) -> bool method to the interface so callers can dry-run schema validation before committing to the import.

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

import_layer(s_id: SessionId, layer: VideoDataLayer, file_path: str, mode: ImportMode | str) -> int

Import bounding-box data from file_path into layer for s_id.

PARAMETER DESCRIPTION
s_id

Target session.

TYPE: SessionId

layer

Target layer inside the session's SessionDataStore.

TYPE: VideoDataLayer

file_path

Absolute path to a .json or .csv file produced by IDataExporter.

TYPE: str

mode

Merge strategy — accepts enum or string and is coerced to ImportMode.

TYPE: ImportMode | str

RETURNS DESCRIPTION
int

Number of boxes actually written into the layer.

TYPE: int