Skip to content

Commit c22fe20

Browse files
authored
added skip for summaries with nothing in deserializtaion iterator
1 parent 3d9c1a5 commit c22fe20

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/Deserialization/deserialization.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,12 @@ function Base.iterate(iter::SummaryDeserializingIterator, state=1)
187187

188188
(tag, summary), i_state = res
189189

190+
# This can happen in certain cases, e.g. if hyperparameters have been recorded.
191+
if summary.value === nothing
192+
# Hence, we just skip it.
193+
return Base.iterate(iter, state + 1)
194+
end
195+
190196
typ = summary_type(summary)
191197
if typ === :histo
192198
val = deserialize_histogram_summary(summary)

test/test_hparams.jl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,19 @@ end
8888
decoded_v = hv.kind.value
8989
@test expected_hparams_config[k] == decoded_v
9090
end
91+
end
92+
93+
@testset "Reading with hparams present (#137)" begin
94+
# https://github.com/JuliaLogging/TensorBoardLogger.jl/issues/137
95+
lg = TBLogger(joinpath(mktempdir(), "logs"))
96+
TensorBoardLogger.write_hparams!(
97+
lg,
98+
Dict("hi" => 1.0),
99+
["x/val"]
100+
)
101+
with_logger(lg) do
102+
@info "x" val=3.0
103+
end
104+
hist = convert(MVHistory, lg)
105+
@test haskey(hist, "x/val")
91106
end

0 commit comments

Comments
 (0)