Skip to content

Writer

timenet.writer source

Serialization of a :class:~timenet.dataset.TimeFDataset to the TimeF on-disk format.

ProgressStage source

Bases: StrEnum

The writer's incremental stages. The writer emits only stages that carry information.

COMMIT class-attribute instance-attribute source

COMMIT = 'commit'

SHARD_FINALIZED class-attribute instance-attribute source

SHARD_FINALIZED = 'shard_finalized'

TIME_SERIES class-attribute instance-attribute source

TIME_SERIES = 'time_series'

TimeFWriter source

Context manager that serializes a dataset into the TimeF format and commits it atomically.

payload_sources property source

payload_sources: Mapping[SourceKey, PayloadSource]

The releases that store the payloads this release reuses, pinned to their files.

:meth:write fills it, and the manifest records it as payload_sources.

abort source

abort() -> None

Delete the staging directory. Safe to call more than once.

close source

close() -> None

Write the manifest and atomically publish the staging directory.

An existing version directory is renamed aside to a sibling <version>.old-<uuid> first. The staging directory then takes its place, and the old directory is deleted. If that rename fails, the old directory moves back. A hard kill between the two renames leaves the old release in <version>.old-<uuid>, which no sweep deletes, so it can be renamed back. The manifest pins the payload source files that :meth:write checked. Before the rename, the written files are compared with the pins of each release in pinned_by.

Raises:

Type Description
RuntimeError

If :meth:write has not run successfully.

TimeFFormatError

If a release in pinned_by pins a file that this release did not write as pinned. Nothing is published.

OSError

If publishing fails and the old release cannot be moved back either. The error names the <version>.old-<uuid> directory that holds it.

write source

write() -> None

Serialize every artifact except the manifest into the staging directory.

WriteProgressEvent dataclass source

A single progress event passed to the writer's progress_cb.

completed instance-attribute source

completed: int

Number of items finished in this stage so far.

message class-attribute instance-attribute source

message: str | None = None

Optional human-readable detail for the event.

stage instance-attribute source

The writer stage this event reports.

total instance-attribute source

total: int | None

Total number of items to process, or None if unknown.