A very minimal module for defining checkpoints or save location in large codebase with the ability to configure how those checkpoints save data externally (similar to how Memento.jl works for logging).

available() -> Vector{String}

Returns a vector of all available (registered) checkpoints.

checkpoint([prefix], name, data)
checkpoint([prefix], name, data::Pair...)
checkpoint([prefix], name, data::Dict)

Defines a data checkpoint with a specified label and values data. By default checkpoints are no-ops and need to be explicitly configured.

checkpoint(session, data)
checkpoint(handler, name, data::Dict)

Alternatively, you can also checkpoint with to a session which stages the data to be commited later by commit!(session). Explicitly calling checkpoint on a handler is generally not advised, but is an option.

config(handler::AbstractHandler, labels::Vector{String})
config(handler::AbstractHandler, prefix::String)
config(labels::Vector{String}, args...; kwargs...)
config(prefix::String, args...; kwargs...)

Configures the specified checkpoints with a AbstractHandler. If the first argument is not an AbstractHandler then all args and kwargs are passed to a JLSOHandler constructor for you.

deprecate([prefix], prev, curr)

Deprecate a checkpoint that has been renamed.

deprecated_checkpoints() -> Dict{String, String}

Returns a Dict mapping deprecated checkpoints to the corresponding new names.

register([prefix], labels)

Registers a checkpoint that may be configured at a later time.

with_checkpoint_tags(f::Function, context_tags::Pair...)
with_checkpoint_tags(f::Function, context_tags::NamedTuple)

Runs the function f, tagging any checkpoints created by f with the context_tags. This is normally used via the do-block form: For example

with_checkpoint_tags(:foo=>1, :bar=>2) do
    q_out = qux()
    checkpoint("foobar"; :output=q_out)

This snippet will result in "foobar" checkpoint having the foo=1 and bar=2 tags, as will any checkpoints created by qux(). The context tags are dynamically scoped and so are retained through function calls.

Nested contexts (nested with_checkpoint_tags calls) are allowed. Duplicate tag names and values are allowed, including the tags provided directly in the checkpoint call. Duplicate tags are repeated, not overwritten.