TraceWriter

class osi_utilities.tracefile.writers.base.TraceWriter[source]

Bases: ABC

Abstract base class for writing OSI trace files.

Supports context manager protocol.

Usage:

with SingleTraceWriter() as writer:
    writer.open(Path("output.osi"))
    writer.write_message(ground_truth_msg)
abstractmethod open(path, **kwargs)[source]

Open a trace file for writing.

Parameters:
  • path (Path) – Path to the output file.

  • **kwargs (object) – Format-specific options (e.g. metadata, compression, chunk_size).

Returns:

True if the file was opened successfully, False otherwise.

Return type:

bool

abstractmethod write_message(message, topic='')[source]

Write a protobuf message to the trace file.

Parameters:
  • message (Message) – The protobuf message to write.

  • topic (str) – Channel topic name (used by MCAP writer, ignored by single-channel writers).

Returns:

True if the message was written successfully, False otherwise.

Return type:

bool

abstractmethod close()[source]

Close the trace file and finalize writing.

Return type:

None