# tf.config.run_functions_eagerly

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.7.4/tensorflow/python/eager/def_function.py#L412-L454) |

Enables / disables eager execution of [`tf.function`](https://www.tensorflow.org/versions/r2.7/api_docs/python/tf/function)s.

#### View aliases


**Compat aliases for migration**

See
[Migration guide](https://www.tensorflow.org/guide/migrate) for
more details.

[`tf.compat.v1.config.run_functions_eagerly`](https://www.tensorflow.org/api_docs/python/tf/config/run_functions_eagerly)

<br />

    tf.config.run_functions_eagerly(
        run_eagerly
    )

Calling [`tf.config.run_functions_eagerly(True)`](https://www.tensorflow.org/versions/r2.7/api_docs/python/tf/config/run_functions_eagerly) will make all
invocations of [`tf.function`](https://www.tensorflow.org/versions/r2.7/api_docs/python/tf/function) run eagerly instead of running as a traced graph
function.

This can be useful for debugging.

    def my_func(a):
     print("Python side effect")
     return a + a
    a_fn = tf.function(my_func)

    # A side effect the first time the function is traced
    a_fn(tf.constant(1))
    Python side effect
    <tf.Tensor: shape=(), dtype=int32, numpy=2>

    # No further side effect, as the traced function is called
    a_fn(tf.constant(2))
    <tf.Tensor: shape=(), dtype=int32, numpy=4>

    # Now, switch to eager running
    tf.config.run_functions_eagerly(True)
    # Side effect, as the function is called directly
    a_fn(tf.constant(2))
    Python side effect
    <tf.Tensor: shape=(), dtype=int32, numpy=4>

    # Turn this back off
    tf.config.run_functions_eagerly(False)

> [!NOTE]
> **Note:** This flag has no effect on functions passed into tf.data transformations as arguments. tf.data functions are never executed eagerly and are always executed as a compiled Tensorflow Graph.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `run_eagerly` | Boolean. Whether to run functions eagerly. |

<br />