diff --git a/Project.toml b/Project.toml index 2bd7038..03f1caf 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "TensorBoardLogger" uuid = "899adc3e-224a-11e9-021f-63837185c80f" authors = ["Filippo Vicentini "] -version = "0.1.22" +version = "0.1.23" [deps] CRC32c = "8bf52ea8-c179-5cab-976a-9e18b702a9bc" diff --git a/src/Deserialization/deserialization.jl b/src/Deserialization/deserialization.jl index 4284fc7..16335b1 100644 --- a/src/Deserialization/deserialization.jl +++ b/src/Deserialization/deserialization.jl @@ -187,6 +187,12 @@ function Base.iterate(iter::SummaryDeserializingIterator, state=1) (tag, summary), i_state = res + # This can happen in certain cases, e.g. if hyperparameters have been recorded. + if summary.value === nothing + # Hence, we just skip it. + return Base.iterate(iter, state + 1) + end + typ = summary_type(summary) if typ === :histo val = deserialize_histogram_summary(summary) diff --git a/test/runtests.jl b/test/runtests.jl index ca969bf..b098713 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -6,6 +6,7 @@ using ImageCore using FileIO using LightGraphs using StatsBase: fit, Histogram +using ValueHistories: MVHistory ENV["DATADEPS_ALWAYS_ACCEPT"] = true ENV["GKSwstype"] = "100" diff --git a/test/test_hparams.jl b/test/test_hparams.jl index 17b959e..587de69 100644 --- a/test/test_hparams.jl +++ b/test/test_hparams.jl @@ -88,4 +88,19 @@ end decoded_v = hv.kind.value @test expected_hparams_config[k] == decoded_v end -end \ No newline at end of file +end + +@testset "Reading with hparams present (#137)" begin + # https://github.com/JuliaLogging/TensorBoardLogger.jl/issues/137 + lg = TBLogger(joinpath(mktempdir(), "logs")) + TensorBoardLogger.write_hparams!( + lg, + Dict("hi" => 1.0), + ["x/val"] + ) + with_logger(lg) do + @info "x" val=3.0 + end + hist = convert(MVHistory, lg) + @test haskey(hist, Symbol("x/val")) +end