An interface for saving and loading program state in a federated program.
A tff.program.ProgramStateManager is used to implement fault tolerance in a
federated program. The structure or type of the program state that is saved is
unknown at construction time and can change as the program runs.
Methods
get_versions
View source
get_versions()
Returns a list of saved versions or None.
| Returns |
A list of saved versions or None if there is no saved program state.
|
load
View source
load(
version, structure
)
Returns the saved program state for the given version.
| Args |
version
|
A integer representing the version of a saved program state.
|
structure
|
The structure of the saved program state for the given
version used to support serialization and deserailization of
user-defined classes in the structure.
|
| Raises |
ProgramStateNotFoundError
|
If there is no program state for the given
version.
|
load_latest
View source
load_latest(
structure
)
Returns the latest saved program state and version or (None, 0).
| Args |
structure
|
The structure of the saved program state for the given
version used to support serialization and deserailization of
user-defined classes in the structure.
|
| Returns |
A tuple of the latest saved (program state, version) or (None, 0) if
there is no latest saved program state.
|
save
View source
save(
program_state, version
)
Saves program_state for the given version.
| Raises |
ProgramStateExistsError
|
If there is already program state for the given
version.
|