proxystore.factory¶
Factory implementations.
Factories are callable classes that wrap up the functionality needed to resolve a proxy, where resolving is the process of retrieving the object from wherever it is stored such that the proxy can act as the object.
Factory
¶
Bases: Generic[T]
Abstract Factory Class.
A factory is a callable object that when called, returns an object.
The Proxy
constructor takes an instance of
a factory and calls the factory when the proxy does its just-in-time
resolution.
Note
If a custom factory is not-pickleable, __getnewargs_ex__
may need to
be implemented. Writing custom pickling functions is also beneifical
to ensure that a pickled factory does not contain the object itself,
just what is needed to resolve the object to keep the final pickled
factory as small as possible.
__call__
¶
Alias Factory.resolve()
.
SimpleFactory
¶
Bases: Factory[T]
Simple Factory that stores object as class attribute.
Parameters:
-
obj
(T
) –Object to produce when factory is called.
__call__
¶
Alias Factory.resolve()
.
LambdaFactory
¶
Bases: Factory[T]
Factory that takes any callable object.
Parameters:
-
target
(Callable[..., T]
) –Callable object (function, class, lambda) to be invoked when the factory is resolved.
-
args
(Any
, default:()
) –Argument tuple for target invocation.
-
kwargs
(Any
, default:{}
) –Dictionary of keyword arguments for target invocation.
Source code in proxystore/factory.py
__call__
¶
Alias Factory.resolve()
.