modelrunner.storage.backend.text_base module

class TextStorageBase(path, *, mode='read', simplify=True, **kwargs)[source]

Bases: MemoryStorage

base class for storage that stores data in a text file

Note that the data is only written once the storage is closed.

Parameters:
  • path (str or Path) – File path to the file

  • mode (str or AccessMode) – The file mode with which the storage is accessed. Determines allowed operations.

  • simplify (bool) – Flag indicating whether the data is stored in a simplified form

close()[source]

close the file and write the data to the file

Return type:

None

flush()[source]

write (cached) data to storage

Return type:

None

to_text(simplify=None)[source]

serialize the data and return it as a string

Parameters:

simplify (bool) – Flag indicating whether the data is stored in a simplified form. If None, the object-level value is used.

Return type:

str