proxystore.connectors.file¶
File system connector implementation.
FileKey
¶
Bases: NamedTuple
Key to objects in a file system directory.
Attributes:
-
filename(str) –Unique object filename.
FileConnector
¶
FileConnector(
store_dir: str | PathLike[str],
*,
clear: bool = True,
buffering: int = -1,
dir_mode: int = 448,
file_mode: int = 384,
)
Connector to shared file system.
This connector writes objects to unique files within store_dir. Each
object is written to a hidden temporary file in store_dir which is
then renamed, so an object's file only exists once it is completely
written.
Parameters:
-
store_dir(str | PathLike[str]) –Path to directory to store data in. If the connector creates this directory, it is removed when the connector is closed with
clear=True(the default), such as by theownerstore. A directory which already existed is never removed. -
clear(bool, default:True) –Clear all objects on
close()by removingstore_dirif the connector created it. -
buffering(int, default:-1) –Buffering policy used with
open(). -
dir_mode(int, default:448) –Permissions of
store_dirif the connector creates it. The default only gives the current user access. An existingstore_dirkeeps its permissions, and parent directories are created with the default permissions. -
file_mode(int, default:384) –Permissions of the object files. The default only gives the current user access.
Note
dir_mode and file_mode are applied exactly and are not limited
by the umask,
so, e.g., dir_mode=0o770, file_mode=0o660 shares the
objects with the group of store_dir.
Source code in proxystore/connectors/file.py
close
¶
Close the connector and clean up.
Warning
This will delete the store_dir directory by default if the
connector created it. A store_dir which already existed is
left as is, including its objects, and a warning is logged.
Note
A Store only clears its
connector when closed if the store is the
owner. Stores created
implicitly, such as when resolving a proxy, never clear their
connector.
Warning
This method should only be called at the end of the program when the connector will no longer be used, for example once all proxies have been resolved.
Parameters:
-
clear(bool | None, default:None) –Remove the store directory if the connector created it. Overrides the default value of
clearprovided when theFileConnectorwas instantiated.
Returns:
-
bool–If the store directory was removed.
Source code in proxystore/connectors/file.py
config
¶
Get the connector configuration.
The configuration contains all the information needed to reconstruct the connector object.
Source code in proxystore/connectors/file.py
from_config
classmethod
¶
from_config(config: dict[str, Any]) -> FileConnector
Create a new connector instance from a configuration.
Parameters:
Source code in proxystore/connectors/file.py
evict
¶
evict(key: FileKey) -> None
Evict the object associated with the key.
Parameters:
-
key(FileKey) –Key associated with object to evict.
Source code in proxystore/connectors/file.py
exists
¶
get
¶
Get the serialized object associated with the key.
Parameters:
-
key(FileKey) –Key associated with the object to retrieve.
Returns:
-
BytesLike | None–Serialized object or
Noneif the object does not exist.
Source code in proxystore/connectors/file.py
get_batch
¶
Get a batch of serialized objects associated with the keys.
Parameters:
Returns:
-
list[BytesLike | None]–List with same order as
keyswith the serialized objects or -
list[BytesLike | None]–Noneif the corresponding key does not have an associated object.
Source code in proxystore/connectors/file.py
new_key
¶
Create a new key.
Parameters:
-
obj(BytesLike | None, default:None) –Optional object which the key will be associated with. Ignored by this implementation.
Returns:
Source code in proxystore/connectors/file.py
put
¶
put_batch
¶
Put a batch of serialized objects in the store.
Parameters:
Returns:
-
list[FileKey]–List of keys with the same order as
objswhich can be used to -
list[FileKey]–retrieve the objects.
Source code in proxystore/connectors/file.py
set
¶
Set the object associated with a key.
Note
The Connector
provides write-once, read-many semantics. Thus,
set()
should only be called once per key, otherwise unexpected behavior
can occur.
Parameters:
-
key(FileKey) –Key that the object will be associated with.
-
obj(BytesLike) –Object to associate with the key.