1.16.16

flytekit.core.checkpointer

Directory

Classes

Class Description
Checkpoint Base class for Checkpoint system.
SyncCheckpoint This class is NOT THREAD-SAFE!.

flytekit.core.checkpointer.Checkpoint

Base class for Checkpoint system. Checkpoint system allows reading and writing custom checkpoints from user scripts

Methods

Method Description
prev_exists()
read() This should only be used if there is a singular checkpoint file written.
restore() Given a path, if a previous checkpoint exists, will be downloaded to this path.
save() Usage: If you have a io.
write() This will overwrite the checkpoint.

prev_exists()

def prev_exists()

read()

def read()

This should only be used if there is a singular checkpoint file written. If more than one checkpoint file is found, this will raise a ValueError

restore()

def restore(
    path: typing.Union[pathlib.Path, str],
) -> typing.Optional[pathlib.Path]

Given a path, if a previous checkpoint exists, will be downloaded to this path. If download is successful the downloaded path is returned

Download will not be performed, if the checkpoint was previously restored. The method will return the previously downloaded path.

Parameter Type Description
path typing.Union[pathlib.Path, str]

save()

def save(
    cp: typing.Union[pathlib.Path, str, _io.BufferedReader],
)

Usage: If you have a io.BufferedReader then the following should work

with input_file.open(mode="rb") as b:
    checkpointer.save(b)
Parameter Type Description
cp typing.Union[pathlib.Path, str, _io.BufferedReader] Checkpoint file (path, str path or a io.BufferedReader)

write()

def write(
    b: bytes,
)

This will overwrite the checkpoint. It can be retrieved using read or restore

Parameter Type Description
b bytes

flytekit.core.checkpointer.SyncCheckpoint

This class is NOT THREAD-SAFE! Sync Checkpoint, will synchronously checkpoint a user given file or folder. It will also synchronously download / restore previous checkpoints, when restore is invoked.

TODO: Implement an async checkpoint system

Parameters

class SyncCheckpoint(
    checkpoint_dest: str,
    checkpoint_src: typing.Optional[str],
)

checkpoint_src: If a previous checkpoint should exist, this path should be set to the folder that contains the checkpoint information checkpoint_dest: Location where the new checkpoint should be copied to

Parameter Type Description
checkpoint_dest str
checkpoint_src typing.Optional[str]

Methods

Method Description
prev_exists()
read() This should only be used if there is a singular checkpoint file written.
restore() Given a path, if a previous checkpoint exists, will be downloaded to this path.
save() Usage: If you have a io.
write() This will overwrite the checkpoint.

prev_exists()

def prev_exists()

read()

def read()

This should only be used if there is a singular checkpoint file written. If more than one checkpoint file is found, this will raise a ValueError

restore()

def restore(
    path: typing.Union[pathlib.Path, str, NoneType],
) -> typing.Optional[pathlib.Path]

Given a path, if a previous checkpoint exists, will be downloaded to this path. If download is successful the downloaded path is returned

Download will not be performed, if the checkpoint was previously restored. The method will return the previously downloaded path.

Parameter Type Description
path typing.Union[pathlib.Path, str, NoneType]

save()

def save(
    cp: typing.Union[pathlib.Path, str, _io.BufferedReader],
)

Usage: If you have a io.BufferedReader then the following should work

with input_file.open(mode="rb") as b:
    checkpointer.save(b)
Parameter Type Description
cp typing.Union[pathlib.Path, str, _io.BufferedReader] Checkpoint file (path, str path or a io.BufferedReader)

write()

def write(
    b: bytes,
)

This will overwrite the checkpoint. It can be retrieved using read or restore

Parameter Type Description
b bytes