API
Checkpoints
Checkpoints.Checkpoints
— ModuleCheckpoints
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).
Checkpoints.available
— Methodavailable() -> Vector{String}
Returns a vector of all available (registered) checkpoints.
Checkpoints.checkpoint
— Methodcheckpoint([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.
Checkpoints.config
— Methodconfig(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.
Checkpoints.deprecate
— Functiondeprecate([prefix], prev, curr)
Deprecate a checkpoint that has been renamed.
Checkpoints.deprecated_checkpoints
— Methoddeprecated_checkpoints() -> Dict{String, String}
Returns a Dict mapping deprecated checkpoints to the corresponding new names.
Checkpoints.enabled_checkpoints
— Methodenabled_checkpoints() -> Vector{String}
Returns a vector of all enabled (config
ured) and not deprecate
d checkpoints. Use deprecated_checkpoints
to retrieve a mapping of old / deprecated checkpoints.
Checkpoints.register
— Functionregister([prefix], labels)
Registers a checkpoint that may be configured at a later time.
Checkpoints.with_checkpoint_tags
— Methodwith_checkpoint_tags(f::Function, context_tags::Pair...)
with_checkpoint_tags(f::Function, context_tags::NamedTuple)
Runs the function f
, tagging any checkpoint
s 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)
end
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.