ai2_kit.core.checkpoint module#

class ai2_kit.core.checkpoint.CheckpointCmd[source]#

Bases: object

checkpoint command line interface

load(file)[source]#
ls(verbose=False)[source]#

list all the checkpoint entries in the checkpoint file

rm(glob_pattern: str, yes=False, exclude: Optional[str] = None)[source]#

remove checkpoint entries with the given pattern

class ai2_kit.core.checkpoint.FnInfo(fn_name, args, kwargs, call_site)[source]#

Bases: NamedTuple

args: tuple#

Alias for field number 1

call_site: str#

Alias for field number 3

fn_name: str#

Alias for field number 0

kwargs: dict#

Alias for field number 2

ai2_kit.core.checkpoint.apply_checkpoint(key_fn: Union[str, Callable[[FnInfo], str]], disable=False)[source]#

apply checkpoint for function.

Note: This checkpoint implementation doesn’t support multiprocess. To support multiple process we need to have a dedicated background process to read/write checkpoint, which will require message queue (e.g. nanomsg or nng) to implement it.

Example:

>>> set_checkpoint_file('/tmp/test.ckpt')
>>> task_fn = lambda a, b: a + b
>>> checkpoint('task_1+2')(task_fn)(1, 2)
ai2_kit.core.checkpoint.del_checkpoint(key: str)[source]#
ai2_kit.core.checkpoint.set_checkpoint_file(path: str)[source]#