# orbit.actions.SaveCheckpointIfPreempted

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/models/blob/v2.20.0/orbit/actions/save_checkpoint_if_preempted.py#L22-L62) |

Action that saves on-demand checkpoints after a preemption.

    orbit.actions.SaveCheckpointIfPreempted(
        cluster_resolver: tf.distribute.cluster_resolver.ClusterResolver,
        checkpoint_manager: tf.train.CheckpointManager,
        checkpoint_number: Optional[tf.Variable] = None,
        keep_running_after_save: Optional[bool] = False
    )

<br />

<br />

<br />

| ## Args ||
|---|---|
| `cluster_resolver` | A [`tf.distribute.cluster_resolver.ClusterResolver`](https://www.tensorflow.org/api_docs/python/tf/distribute/cluster_resolver/ClusterResolver) object. |
| `checkpoint_manager` | A [`tf.train.CheckpointManager`](https://www.tensorflow.org/api_docs/python/tf/train/CheckpointManager) object. |
| `checkpoint_number` | A [`tf.Variable`](https://www.tensorflow.org/api_docs/python/tf/Variable) to indicate the checkpoint_number for checkpoint manager, usually it will be the global step. |
| `keep_running_after_save` | Whether to keep the job running after the preemption on-demand checkpoint. Only set to True when in-process preemption recovery with tf.distribute.experimental.PreemptionWatcher is enabled. |

<br />

## Methods

### `__call__`

[View source](https://github.com/tensorflow/models/blob/v2.20.0/orbit/actions/save_checkpoint_if_preempted.py#L59-L62)

    __call__(
        _
    ) -> None

Call self as a function.