tf.compat.forward_compatibility_horizon
Stay organized with collections
Save and categorize content based on your preferences.
Context manager for testing forward compatibility of generated graphs.
@tf_contextlib.contextmanager
tf.compat.forward_compatibility_horizon(
year, month, day
)
See Version
compatibility.
To ensure forward compatibility of generated graphs (see forward_compatible
)
with older binaries, new features can be gated with:
if compat.forward_compatible(year=2018, month=08, date=01):
generate_graph_with_new_features()
else:
generate_graph_so_older_binaries_can_consume_it()
However, when adding new features, one may want to unittest it before
the forward compatibility window expires. This context manager enables
such tests. For example:
from tensorflow.python.compat import compat
def testMyNewFeature(self):
with compat.forward_compatibility_horizon(2018, 08, 02):
# Test that generate_graph_with_new_features() has an effect
Args |
year
|
A year (e.g., 2018). Must be an int .
|
month
|
A month (1 <= month <= 12) in year. Must be an int .
|
day
|
A day (1 <= day <= 31, or 30, or 29, or 28) in month. Must be an
int .
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates. Some content is licensed under the numpy license.
Last updated 2023-10-06 UTC.
[null,null,["Last updated 2023-10-06 UTC."],[],[],null,["# tf.compat.forward_compatibility_horizon\n\n\u003cbr /\u003e\n\n|-----------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.13.1/tensorflow/python/compat/compat.py#L125-L168) |\n\nContext manager for testing forward compatibility of generated graphs.\n\n#### View aliases\n\n\n**Compat aliases for migration**\n\nSee\n[Migration guide](https://www.tensorflow.org/guide/migrate) for\nmore details.\n\n[`tf.compat.v1.compat.forward_compatibility_horizon`](https://www.tensorflow.org/api_docs/python/tf/compat/forward_compatibility_horizon)\n\n\u003cbr /\u003e\n\n @tf_contextlib.contextmanager\n tf.compat.forward_compatibility_horizon(\n year, month, day\n )\n\nSee [Version\ncompatibility](https://www.tensorflow.org/guide/versions#backward_and_partial_forward_compatibility).\n\nTo ensure forward compatibility of generated graphs (see `forward_compatible`)\nwith older binaries, new features can be gated with: \n\n if compat.forward_compatible(year=2018, month=08, date=01):\n generate_graph_with_new_features()\n else:\n generate_graph_so_older_binaries_can_consume_it()\n\nHowever, when adding new features, one may want to unittest it before\nthe forward compatibility window expires. This context manager enables\nsuch tests. For example: \n\n from tensorflow.python.compat import compat\n\n def testMyNewFeature(self):\n with compat.forward_compatibility_horizon(2018, 08, 02):\n # Test that generate_graph_with_new_features() has an effect\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|---------|---------------------------------------------------------------------------|\n| `year` | A year (e.g., 2018). Must be an `int`. |\n| `month` | A month (1 \\\u003c= month \\\u003c= 12) in year. Must be an `int`. |\n| `day` | A day (1 \\\u003c= day \\\u003c= 31, or 30, or 29, or 28) in month. Must be an `int`. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Yields ------ ||\n|---|---|\n| Nothing. ||\n\n\u003cbr /\u003e"]]