Skip to content

vllm.utils.file_utils

File helpers with no dependency on torch or the model executor.

Functions:

  • atomic_writer –

    Context manager that provides an atomic file writing routine.

atomic_writer(filepath, mode='w', encoding=None)

Context manager that provides an atomic file writing routine.

The context manager writes to a temporary file and, if successful, atomically replaces the original file.

Parameters:

  • filepath

    (str or Path) –

    The path to the file to write.

  • mode

    (str, default: 'w' ) –

    The file mode for the temporary file (e.g., 'w', 'wb').

  • encoding

    (str, default: None ) –

    The encoding for text mode.

Yields:

  • Generator[IO] –

    file object: A handle to the temporary file.