taps.transformer¶
Transformer
¶
Bases: Protocol[IdentifierT]
Data transformer protocol.
A data transformer is used by the Engine
to
transform task parameters and results into alternative formats that are
more suitable for communication.
An object can be transformed using
transform()
which returns
an identifier. The identifier can then be provided to
resolve()
, the inverse of
transform()
, which returns
the original object.
Data transformer implementations can implement object identifiers in any manner, provided identifiers are serializable. For example, a simple identifier could be a UUID corresponding to a database entry containing the serialized object.
close
¶
Close the transformer.
The transformer is only closed by the client once the application has finished executing (or raised an exception).
transform
¶
Transform the object into an identifier.
Parameters:
-
obj
(T
) –Object to transform.
Returns:
-
IdentifierT
–Identifier object that can be used to resolve
obj
.
TransformerConfig
¶
PickleFileTransformer
¶
Pickle file object transformer.
Transforms objects by pickling the object and writing the pickled object to a file.
Parameters:
Source code in taps/transformer/_file.py
close
¶
is_identifier
¶
transform
¶
transform(obj: T) -> PickleFileIdentifier
Transform the object into an identifier.
Parameters:
-
obj
(T
) –Object to transform.
Returns:
-
PickleFileIdentifier
–Identifier object that can be used to resolve
obj
.
Source code in taps/transformer/_file.py
resolve
¶
resolve(identifier: PickleFileIdentifier) -> Any
Resolve an object from an identifier.
Parameters:
-
identifier
(PickleFileIdentifier
) –Identifier to an object.
Returns:
-
Any
–The resolved object.
Source code in taps/transformer/_file.py
PickleFileTransformerConfig
¶
Bases: TransformerConfig
PickleFileTransformer
plugin configuration.
Parameters:
get_transformer
¶
get_transformer() -> PickleFileTransformer
PickleFileIdentifier
¶
Bases: NamedTuple
Identifier type for the PickleFileTransformer
.
Parameters:
-
cache_dir
(ForwardRef('pathlib.Path')
, default:None
) – -
obj_id
(ForwardRef('uuid.UUID')
, default:None
) –
Attributes:
-
cache_dir
–Object directory.
-
obj_id
–Object ID.
ProxyTransformer
¶
Proxy object transformer.
Transforms objects into proxies which act as the identifier.
Parameters:
-
store
(Store[Any]
) –Store instance to use for proxying objects.
-
async_resolve
(bool
, default:False
) –Begin asynchronously resolving proxies when the transformer resolves a proxy (which is otherwise a no-op unless
extract_target=True
). Not compatible withextract_target=True
. -
extract_target
(bool
, default:False
) –When
True
, resolving an identifier (i.e., a proxy) will return the target object. Otherwise, the proxy is returned since a proxy can act as the target object. Not compatible withasync_resolve=True
.
Source code in taps/transformer/_proxy.py
close
¶
is_identifier
¶
transform
¶
transform(obj: T) -> Proxy[T]
Transform the object into an identifier.
Parameters:
-
obj
(T
) –Object to transform.
Returns:
-
Proxy[T]
–Identifier object that can be used to resolve
obj
.
resolve
¶
Resolve an object from an identifier.
Parameters:
-
identifier
(Proxy[T]
) –Identifier to an object.
Returns:
-
T | Proxy[T]
–The resolved object or a proxy of the resolved object depending on the setting of
extract_target
.
Source code in taps/transformer/_proxy.py
ProxyTransformerConfig
¶
Bases: TransformerConfig
ProxyTransformer
plugin configuration.
Parameters:
-
name
(Literal[str]
, default:'proxystore'
) –Transformer name.
-
connector
(ConnectorConfig
) –Connector configuration.
-
cache_size
(int
, default:16
) –cache size
-
async_resolve
(bool
, default:False
) –Asynchronously resolve proxies. Not compatible with extract_target=True.
-
extract_target
(bool
, default:False
) –Extract the target from the proxy when resolving the identifier. Not compatible with async_resolve=True.
-
populate_target
(bool
, default:True
) –Populate target objects of newly created proxies.
get_transformer
¶
get_transformer() -> ProxyTransformer
Create a transformer from the configuration.