From c22fe2036e69dd14d4a8a2bd79e45ddbb39709e9 Mon Sep 17 00:00:00 2001 From: Tor Erlend Fjelde Date: Mon, 18 Sep 2023 21:21:03 +0100 Subject: [PATCH 1/4] added skip for summaries with nothing in deserializtaion iterator --- src/Deserialization/deserialization.jl | 6 ++++++ test/test_hparams.jl | 15 +++++++++++++++ 2 files changed, 21 insertions(+) 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/test_hparams.jl b/test/test_hparams.jl index 17b959e..46ec760 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 + +@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, "x/val") end \ No newline at end of file From e5088ae2c711104e509ee1dac5dd5c8f13754671 Mon Sep 17 00:00:00 2001 From: Tor Erlend Fjelde Date: Mon, 18 Sep 2023 21:21:45 +0100 Subject: [PATCH 2/4] bump patch version --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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" From fca3ac549c426ab59a957475902deca3f09c6341 Mon Sep 17 00:00:00 2001 From: Tor Erlend Fjelde Date: Wed, 4 Oct 2023 11:41:40 +0100 Subject: [PATCH 3/4] loaded ValueHistories --- test/runtests.jl | 1 + 1 file changed, 1 insertion(+) 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" From 599e147f2a1231f9ff8aec36ded5103f45f31c8c Mon Sep 17 00:00:00 2001 From: Tor Erlend Fjelde Date: Wed, 4 Oct 2023 13:45:57 +0100 Subject: [PATCH 4/4] fixed incorrect usage of haskey for MvHistory in tests --- test/test_hparams.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test_hparams.jl b/test/test_hparams.jl index 46ec760..587de69 100644 --- a/test/test_hparams.jl +++ b/test/test_hparams.jl @@ -102,5 +102,5 @@ end @info "x" val=3.0 end hist = convert(MVHistory, lg) - @test haskey(hist, "x/val") -end \ No newline at end of file + @test haskey(hist, Symbol("x/val")) +end