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 ¶
Abstract Transformer plugin configuration.
NullTransformer ¶
No-op transformer.
Rather than transforming an object, this transformer just returns the input object as its own identifier.
close() ¶
is_identifier() ¶
transform() ¶
Transform the object into an identifier.
Parameters:
- 
        obj(T) –Object to transform. 
Returns:
- 
            T–Identifier object that can be usd to resolve obj.
NullTransformerConfig ¶
            Bases: TransformerConfig
NullTransformer plugin configuration.
get_transformer() ¶
get_transformer() -> NullTransformer
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.
Attributes:
- 
        file_dir(str) –Object file directory. 
get_transformer() ¶
get_transformer() -> PickleFileTransformer
PickleFileIdentifier ¶
ProxyTransformer ¶
Proxy object transformer.
Transforms objects into proxies which act as the identifier.
Parameters:
- 
        store(Store[Any]) –Store instance to use for proxying objects. 
- 
        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.
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.
Attributes:
- 
        connector(ConnectorConfig) –Name of ProxyStore connector to use. 
- 
        extract_target(bool) –See the usage in ProxyTransformer.
get_transformer() ¶
get_transformer() -> ProxyTransformer
Create a transformer from the configuration.