proxystore.store.multi
MultiStore Implementation.
Policy
dataclass
¶
Policy that allows validating a set of constraints.
is_valid ¶
is_valid(
*,
size: int | None = None,
subset_tags: Iterable[str] | None = None,
superset_tags: Iterable[str] | None = None
) -> bool
Check if set of contstraints is valid for this policy.
Note
All arguments are optional keyword arguments that default to
None
. If left as the default, that constraint will not be
checked against the policy.
Parameters:
-
size
(
int | None
) –Object size.
-
subset_tags
(
Iterable[str] | None
) –Set of tags that must be a subset of the Policy's
subset_tags
to be valid. -
superset_tags
(
Iterable[str] | None
) –Set of tags that must be a superset of the Policy's
superset_tags
to be valid.
Returns:
-
bool
–If the provided constraints are valid for the policy.
Source code in proxystore/store/multi.py
as_dict ¶
Convert the Policy to a JSON compatible dict.
Usage
policy = Policy(...) policy_dict = policy.as_dict() Policy(**policy_dict) == policy True
Source code in proxystore/store/multi.py
MultiStoreKey ¶
MultiStore ¶
MultiStore(
name: str,
*,
stores: dict[str, Policy]
| dict[Store[Any], Policy]
| Sequence[_StorePolicyArgs],
cache_size: int = 0,
stats: bool = False
) -> None
Bases: Store[MultiStoreKey]
Policy based manager for a collection of Store
.
Note
This store does not implement
get_bytes()
or
set_bytes()
because
MultiStore.get()
and MultiStore.set()
forward operations to the
corresponding store.
Warning
MultiStore.close()
will call
Store.close()
on all the stores managed by the instance and unregister them.
Parameters:
-
name
(
str
) –Name of this store instance.
-
stores
(
dict[str, Policy] | dict[Store[Any], Policy] | Sequence[_StorePolicyArgs]
) –Mapping of stores (either
Store
instances or string names of registered stores) to the correspondingPolicy
. IfStore
instances are passed, the instances will be registered. -
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/multi.py
proxy ¶
proxy(
obj: T,
serializer: SerializerT | None = None,
deserializer: DeserializerT | None = None,
subset_tags: Iterable[str] = (),
superset_tags: Iterable[str] = (),
**kwargs: Any
) -> Proxy[T]
Create a proxy that will resolve to an object in the store.
Warning
If the factory requires reinstantiating the store to correctly
resolve the object, the factory should reinstantiate the store
with the same arguments used to instantiate the store that
created the proxy/factory. I.e. the
proxy()
method
should pass any arguments given to
Store
along to the factory so the factory can correctly recreate the
store if the factory is resolved in a different Python process.
Parameters:
-
obj
(
T
) –Object to place in store and return proxy for.
-
serializer
(
SerializerT | None
) –optional callable which serializes the object. If
None
, the default serializer (serialize()
) will be used. -
deserializer
(
DeserializerT | None
) –Optional callable used by the factory to deserialize the byte string. If
None
, the default deserializer (deserialize()
) will be used. -
subset_tags
(
Iterable[str]
) –Iterable of tags that must be a subset of a store policy's
subset_tags
to match that store. -
superset_tags
(
Iterable[str]
) –Iterable of tags that must be a superset of a store policy's
superset_tags
to match that store. -
kwargs
(
Any
) –Additional arguments to pass to the factory.
Returns:
-
Proxy[T]
–A proxy of the object.
Source code in proxystore/store/multi.py
proxy_batch ¶
proxy_batch(
objs: Sequence[T],
serializer: SerializerT | None = None,
deserializer: DeserializerT | None = None,
subset_tags: Iterable[str] = (),
superset_tags: Iterable[str] = (),
**kwargs: Any
) -> list[Proxy[T]]
Create proxies for batch of objects in the store.
See Store.proxy()
for more
details.
Parameters:
-
objs
(
Sequence[object]
) –Objects to place in store and return proxies for.
-
serializer
(
SerializerT | None
) –Optional callable which serializes the object. If
None
, the default serializer (serialize()
) will be used. -
deserializer
(
DeserializerT | None
) –Optional callable used by the factory to deserialize the byte string. If
None
, the default deserializer (deserialize()
) will be used. -
subset_tags
(
Iterable[str]
) –Iterable of tags that must be a subset of a store policy's
subset_tags
to match that store. -
superset_tags
(
Iterable[str]
) –Iterable of tags that must be a superset of a store policy's
superset_tags
to match that store. -
kwargs
(
Any
) –Additional arguments to pass to the Factory.
Returns:
Source code in proxystore/store/multi.py
locked_proxy ¶
locked_proxy(
obj: T,
serializer: SerializerT | None = None,
deserializer: DeserializerT | None = None,
subset_tags: Iterable[str] = (),
superset_tags: Iterable[str] = (),
**kwargs: Any
) -> ProxyLocker[T]
Create a proxy locker that will prevent resolution.
Parameters:
-
obj
(
T
) –Object to place in store and create proxy of.
-
serializer
(
SerializerT | None
) –Optional callable which serializes the object. If
None
, the default serializer (serialize()
) will be used. -
deserializer
(
DeserializerT | None
) –Optional callable used by the factory to deserialize the byte string. If
None
, the default deserializer (deserialize()
) will be used. -
subset_tags
(
Iterable[str]
) –Iterable of tags that must be a subset of a store policy's
subset_tags
to match that store. -
superset_tags
(
Iterable[str]
) –Iterable of tags that must be a superset of a store policy's
superset_tags
to match that store. -
kwargs
(
Any
) –Additional arguments to pass to the Factory.
Returns:
-
ProxyLocker[T]
–A proxy wrapped in a
ProxyLocker
.
Source code in proxystore/store/multi.py
set ¶
set(
obj: Any,
*,
serializer: SerializerT | None = None,
subset_tags: Iterable[str] = (),
superset_tags: Iterable[str] = ()
) -> MultiStoreKey
Set key-object pair in store.
Parameters:
-
obj
(
Any
) –Object to be placed in the store.
-
serializer
(
SerializerT | None
) –Optional callable which serializes the object. If
None
, the default serializer (serialize()
) will be used. -
subset_tags
(
Iterable[str]
) –Iterable of tags that must be a subset of a store policy's
subset_tags
to match that store. -
superset_tags
(
Iterable[str]
) –Iterable of tags that must be a superset of a store policy's
superset_tags
to match that store.
Returns:
-
MultiStoreKey
–A key that can be used to retrieve the object.
Raises:
-
TypeError
–If the output of
serializer
is not bytes.
Source code in proxystore/store/multi.py
set_batch ¶
set_batch(
objs: Sequence[Any],
*,
serializer: SerializerT | None = None,
subset_tags: Iterable[str] = (),
superset_tags: Iterable[str] = ()
) -> list[MultiStoreKey]
Set objects in store.
Parameters:
-
objs
(
Sequence[Any]
) –An iterable of objects to be placed in the store.
-
serializer
(
SerializerT | None
) –Optional callable which serializes the object. If
None
, the default serializer (serialize()
) will be used. -
subset_tags
(
Iterable[str]
) –Iterable of tags that must be a subset of a store policy's
subset_tags
to match that store. -
superset_tags
(
Iterable[str]
) –Iterable of tags that must be a superset of a store policy's
superset_tags
to match that store.
Returns:
-
list[MultiStoreKey]
–List of keys that can be used to retrieve the objects.
Raises:
-
TypeError
–If the output of
serializer
is not bytes.