diff --git a/Project.toml b/Project.toml index 8571da6..fb3f1b9 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "Checkpoints" uuid = "b4a3413d-e481-5afc-88ff-bdfbd6a50dce" authors = "Invenia Technical Computing Corporation" -version = "0.3.6" +version = "0.3.7" [deps] AWSS3 = "1c724243-ef5b-51ab-93f4-b0a88ac62a95" diff --git a/src/Checkpoints.jl b/src/Checkpoints.jl index d921072..a26507e 100644 --- a/src/Checkpoints.jl +++ b/src/Checkpoints.jl @@ -32,6 +32,7 @@ include("deprecated.jl") """ with_checkpoint_tags(f::Function, context_tags::Pair...) + with_checkpoint_tags(f::Function, context_tags::NamedTuple) Runs the function `f`, tagging any [`checkpoint`](@ref)s created by `f` with the `context_tags`. This is normally used via the do-block form: @@ -53,6 +54,7 @@ Duplicate tags are repeated, not overwritten. function with_checkpoint_tags(f::Function, context_tags::Pair...) with_context(f, CONTEXT_TAGS => (CONTEXT_TAGS[]..., context_tags...)) end +with_checkpoint_tags(f::Function, context_tags::NamedTuple) = with_checkpoint_tags(f, pairs(context_tags)...) """ available() -> Vector{String} diff --git a/test/runtests.jl b/test/runtests.jl index 0463d1f..4023831 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -62,6 +62,14 @@ Distributed.addprocs(5) @test isfile(joinpath(path, "tag=a", "date=2017-01-01", "TestPkg", "bar.jlso")) end + @testset "NamedTuple tags" begin + tags = (tag1="some", tag2="thing") + with_checkpoint_tags(tags) do + TestPkg.bar(a) + end + @test isfile(joinpath(path, "tag1=some", "tag2=thing", "date=2017-01-01", "TestPkg", "bar.jlso")) + end + @testset "nested tags" begin @testset "different tags" begin with_checkpoint_tags(:first => "first") do