phenotypic.sdk_.atomic_write_with_writer#

phenotypic.sdk_.atomic_write_with_writer(path: str | Path, writer: Callable[[str], None], *, pre_replace: Callable[[], None] | None = None) None[source]#

Atomically write path using a callback that receives a temp path.

Parameters:
  • path (str | Path) – Final destination path.

  • writer (Callable[[str], None]) – Callable that writes complete output to a temporary path string.

  • pre_replace (Callable[[], None] | None) – Optional callback invoked after the temporary file is synced, immediately before it replaces path. An exception aborts publication and removes the temporary file.

Raises:

OSError – Propagated from the writer or rename after temp cleanup.

Return type:

None