Skip to main content

Checkpoint

Checkpoint helper using flyte.io.File for all checkpoint blob I/O (load/save, async and sync). Remote paths are a single object.

Attributes

AttributeTypeDescription
remote_destinationstrObject-store prefix where flyte.Checkpoint.save writes.
remote_source`strNone`
pathpathlib.PathLocal directory for reading checkpoint files.

Constructor

Signature

def Checkpoint(
checkpoint_dest: str,
checkpoint_src: str | None = None
) - > null

Parameters

NameTypeDescription
checkpoint_deststrThe remote object-store prefix where the checkpoint will be saved.
checkpoint_src`strNone` = None

Methods


remote_destination()

@classmethod
def remote_destination() - > str

Object-store prefix where flyte.Checkpoint.save writes.

Returns

TypeDescription
strThe remote URI where the checkpoint will be uploaded.

remote_source()

@classmethod
def remote_source() - > Optional[str]

Object-store prefix for the previous attempt's checkpoint, if any.

Returns

TypeDescription
Optional[str]The remote URI of the previous checkpoint, or None if no source exists.

path()

@classmethod
def path() - > pathlib.Path

Local directory for reading checkpoint files.

Returns

TypeDescription
pathlib.PathThe local filesystem path to the temporary directory where checkpoints are managed.

prev_exists()

@classmethod
def prev_exists() - > bool

Checks if a remote source URI is available for restoration.

Returns

TypeDescription
boolTrue if a previous checkpoint source is defined, False otherwise.

load()

@classmethod
def load() - > Optional[pathlib.Path]

Asynchronously downloads and restores the previous checkpoint from the remote source.

Returns

TypeDescription
Optional[pathlib.Path]The local path to the restored checkpoint data, or None if no checkpoint exists.

load_sync()

@classmethod
def load_sync() - > Optional[pathlib.Path]

Synchronously downloads and restores the previous checkpoint from the remote source.

Returns

TypeDescription
Optional[pathlib.Path]The local path to the restored checkpoint data, or None if no checkpoint exists.

save()

@classmethod
def save(
data: pathlib.Path | str | bytes
) - > None

Asynchronously saves the provided data (path, string path, or bytes) as a checkpoint.

Parameters

NameTypeDescription
data`pathlib.Pathstr

Returns

TypeDescription
None

save_sync()

@classmethod
def save_sync(
data: pathlib.Path | str | bytes
) - > None

Synchronously saves the provided data (path, string path, or bytes) as a checkpoint.

Parameters

NameTypeDescription
data`pathlib.Pathstr

Returns

TypeDescription
None