A tff.program.FilteringReleaseManager is a utility for filtering values
before releasing the values and is used to release values from platform
storage to customer storage in a federated program.
Values are filtered using a filter_fn and released to the release_manager.
The filter_fn is a Callable that has a single parameter path and returns
a bool, and is used to filter values before they are released. A path is a
tuple of indices and/or keys which uniquely identifies the position of the
corresponding item in the value; path matches the expectations of the
tree library.
The filter_fn is applied to the items in the structure but not the structure
itself. If all the items in a structure are filtered out, then the structure
will be filtered out as well.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-09-20 UTC."],[],[],null,["# tff.program.FilteringReleaseManager\n\n\u003cbr /\u003e\n\n|-------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/federated/blob/v0.87.0 Version 2.0, January 2004 Licensed under the Apache License, Version 2.0 (the) |\n\nA [`tff.program.ReleaseManager`](../../tff/program/ReleaseManager) that filters values before releasing them.\n\nInherits From: [`ReleaseManager`](../../tff/program/ReleaseManager) \n\n tff.program.FilteringReleaseManager(\n release_manager: ReleaseManager[ReleasableStructure, Key],\n filter_fn: Callable[[tuple[Union[str, int], ...]], bool]\n )\n\nA [`tff.program.FilteringReleaseManager`](../../tff/program/FilteringReleaseManager) is a utility for filtering values\nbefore releasing the values and is used to release values from platform\nstorage to customer storage in a federated program.\n\nValues are filtered using a `filter_fn` and released to the `release_manager`.\n\nThe `filter_fn` is a `Callable` that has a single parameter `path` and returns\na `bool`, and is used to filter values before they are released. A `path` is a\ntuple of indices and/or keys which uniquely identifies the position of the\ncorresponding item in the `value`; `path` matches the expectations of the\n`tree` library.\n\nThe `filter_fn` is applied to the items in the structure but not the structure\nitself. If all the items in a structure are filtered out, then the structure\nwill be filtered out as well.\n\n#### For example:\n\n filtering_manager = tff.program.FilteringReleaseManager(\n release_manager=...,\n filter_fn=...,\n )\n\n value = {\n 'loss': 1.0,\n 'accuracy': 0.5,\n }\n await filtering_manager.release(value, ...)\n\nIf `filter_fn` is:\n\n- `lambda _: True` then the entire structure is released.\n- `lambda _: False` then nothing is released.\n- `lambda path: path == ('loss',)` then `{'loss': 1.0}` is released.\n\n| **Note:** The path `()` corresponds to the root of the structure; because the `filter_fn` is applied to the items in the structure but not the structure itself, this path can be used to filter individual values from structures of values.\n| **Important:** Most [`tff.program.ReleasableStructure`](../../tff/program#ReleasableStructure) can be filtered, including individual values, structures, and structures nested in `NamedTuple`s. However, the fields of a `NamedTuple` cannot be filtered.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|-------------------|--------------------------------------------------------------------------------------------------------------------------------|\n| `release_manager` | A [`tff.program.ReleaseManager`](../../tff/program/ReleaseManager) used to release values to. |\n| `filter_fn` | A `Callable` used to filter values before they are released, this function has a single parameter `path` and returns a `bool`. |\n\n\u003cbr /\u003e\n\nMethods\n-------\n\n### `release`\n\n[View source](https://github.com/tensorflow/federated/blob/v0.87.0\nVersion 2.0, January 2004\nLicensed under the Apache License, Version 2.0 (the) \n\n release(\n value, key\n ) -\u003e Optional[Union[ReleasableStructure, type(_FILTERED_SUBTREE)]]\n\nReleases `value` from a federated program.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ||\n|---------|------------------------------------------------------------------------------------------|\n| `value` | A [`tff.program.ReleasableStructure`](../../tff/program#ReleasableStructure) to release. |\n| `key` | A value used to reference the released `value`. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ||\n|----------------------|------------------------------------|\n| `NotFilterableError` | If the `value` cannot be filtered. |\n\n\u003cbr /\u003e"]]