Skip to content

Commit

Permalink
added skip for summaries with nothing in deserializtaion iterator
Browse files Browse the repository at this point in the history
  • Loading branch information
torfjelde authored Sep 18, 2023
1 parent 3d9c1a5 commit c22fe20
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Deserialization/deserialization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
15 changes: 15 additions & 0 deletions test/test_hparams.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit c22fe20

Please sign in to comment.