Skip to content

Commit

Permalink
checkpointing: add generic placeholders
Browse files Browse the repository at this point in the history
Let’s not fail fatally when checkpointing methods are not implemented.
Print a warning instead.
  • Loading branch information
lukas-weber committed Jan 30, 2024
1 parent 50c2ffa commit ef36c0f
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/abstract_mc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ function write_checkpoint(
return nothing
end

function write_checkpoint(
obj,
dump_file::HDF5.Group
)
@warn "checkpointing $(typeof(obj)) not supported. Implement Carlo.write_checkpoint."

return nothing
end

"""
Carlo.read_checkpoint!(mc::YourMC, in::HDF5.Group)
Expand All @@ -85,6 +93,14 @@ function read_checkpoint!(
return nothing
end

function read_checkpoint(
::Type{T},
dump_file::HDF5.Group
) where T
@warn "checkpointing $(T) not supported. Implement Carlo.read_checkpoint. Attempting to construct $(T)() as a stand-in..."
return T()
end

"""
Carlo.register_evaluables(mc::Type{YourMC}, eval::Evaluator, params::AbstractDict)
Expand Down

0 comments on commit ef36c0f

Please sign in to comment.