Skip to content

Commit 37bae6b

Browse files
authored
Merge pull request #138 from torfjelde/torfjelde/hparams-read-fix
Fix for #137
2 parents 3d9c1a5 + 599e147 commit 37bae6b

File tree

4 files changed

+24
-2
lines changed

4 files changed

+24
-2
lines changed

Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "TensorBoardLogger"
22
uuid = "899adc3e-224a-11e9-021f-63837185c80f"
33
authors = ["Filippo Vicentini <filippovicentini@gmail.com>"]
4-
version = "0.1.22"
4+
version = "0.1.23"
55

66
[deps]
77
CRC32c = "8bf52ea8-c179-5cab-976a-9e18b702a9bc"

src/Deserialization/deserialization.jl

+6
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/runtests.jl

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ using ImageCore
66
using FileIO
77
using LightGraphs
88
using StatsBase: fit, Histogram
9+
using ValueHistories: MVHistory
910

1011
ENV["DATADEPS_ALWAYS_ACCEPT"] = true
1112
ENV["GKSwstype"] = "100"

test/test_hparams.jl

+16-1
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
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, Symbol("x/val"))
106+
end

0 commit comments

Comments
 (0)