Skip to content

proxystore.store.file

FileStore Implementation.

FileStoreKey

Bases: NamedTuple

Key to objects in a FileStore.

filename class-attribute

filename: str

Unique object filename.

FileStore

FileStore(
    name: str,
    *,
    store_dir: str,
    cache_size: int = 16,
    stats: bool = False
) -> None

Bases: Store[FileStoreKey]

File backend class.

Parameters:

  • name (str) –

    name of the store instance.

  • store_dir (str) –

    Path to directory to store data in. Note this directory will be deleted upon closing the store.

  • cache_size (int) –

    Size of LRU cache (in # of objects). If 0, the cache is disabled. The cache is local to the Python process.

  • stats (bool) –

    Collect stats on store operations.

Source code in proxystore/store/file.py
def __init__(
    self,
    name: str,
    *,
    store_dir: str,
    cache_size: int = 16,
    stats: bool = False,
) -> None:
    self.store_dir = os.path.abspath(store_dir)

    if not os.path.exists(self.store_dir):
        os.makedirs(self.store_dir, exist_ok=True)

    super().__init__(
        name,
        cache_size=cache_size,
        stats=stats,
        kwargs={'store_dir': self.store_dir},
    )

close

close() -> None

Cleanup all files associated with the file system store.

Warning

Will delete the store_dir directory.

Warning

This method should only be called at the end of the program when the store will no longer be used, for example once all proxies have been resolved.

Source code in proxystore/store/file.py
def close(self) -> None:
    """Cleanup all files associated with the file system store.

    Warning:
        Will delete the `store_dir` directory.

    Warning:
        This method should only be called at the end of the program
        when the store will no longer be used, for example once all
        proxies have been resolved.
    """
    shutil.rmtree(self.store_dir)