|View source on GitHub|
tff.program.ReleaseManager that releases values to a CSV file.
tff.program.CSVFileReleaseManager( file_path: Union[bytes, str, os.PathLike[Union[bytes, str]]], save_mode:
tff.program.CSVSaveMode.APPEND, key_fieldname: str = 'key' )
tff.program.CSVFileReleaseManager is a utility for releasing values
from a federated program to a CSV file and is used to release values from
platform storage to customer storage in a federated program.
Values are released to the file system as a CSV file and are quoted as
strings. When the value is released, if the value is a value reference or a
structure containing value references, each value reference is materialized.
The value is then flattened, converted to a
numpy.ndarray, and then
converted to a nested list of Python scalars, and released as a CSV file.
1 will be written as
tf.ones([2, 2]) will be
'[[1.0, 1.0], [1.0, 1.0]'.
In append mode, when a value is released, this manager will try and append the value to the CSV file instead of overwriting the existing file. While potentially more efficient, append mode is incompatible with compressed files (e.g.
.bz2formats) and encoded directories. This mode is equivalent to write mode when releasing a value with a different structure than the currently released values, so it may not be useful when values with different structures are being released frequently.
In write mode (or in append mode when releasing new structures), when a value is realeased, this manager reads the entire CSV file and overwrites the existing file with the additional values. This can be slower than append mode, but is compatible with compressed files (e.g.
.bz2formats) and encoded directories.
||A path on the file system to save releases values. If this file does not exist it will be created.|
If the file exists but does not
contain a fieldname of
release( value: Any, key ) -> Any
value from a federated program.
This method will atomically update the managed CSV file by removing all
values previously released with a key greater than or equal to
||A materialized value, a value reference, or a structure of materialized values and value references representing the value to release.|
An integer used to reference the released