Skip to content

Commit

Permalink
Merge pull request #138 from torfjelde/torfjelde/hparams-read-fix
Browse files Browse the repository at this point in the history
Fix for #137
  • Loading branch information
oxinabox authored Oct 4, 2023
2 parents 3d9c1a5 + 599e147 commit 37bae6b
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "TensorBoardLogger"
uuid = "899adc3e-224a-11e9-021f-63837185c80f"
authors = ["Filippo Vicentini <filippovicentini@gmail.com>"]
version = "0.1.22"
version = "0.1.23"

[deps]
CRC32c = "8bf52ea8-c179-5cab-976a-9e18b702a9bc"
Expand Down
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
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
17 changes: 16 additions & 1 deletion 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
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

2 comments on commit 37bae6b

@oxinabox
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/92749

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.1.23 -m "<description of version>" 37bae6bcf5a79917f63c1af0bc81cfc62af050ec
git push origin v0.1.23

Please sign in to comment.