tf.compat.forward_compatibility_horizon

View source on GitHub

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:

Yields:

Nothing.