Skip to content

Commit ba02734

Browse files
authored
Merge pull request #80 from PhilipVinc/threadsafe
Upgrade to ProtoBuf 0.9 and make TensorBoardLogger threadsafe
2 parents b35d851 + 232e4ee commit ba02734

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+9664
-1622
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@
33
events.out.tfevents*
44
docs/build
55
test/test_logs
6+
7+
gen/proto
8+
gen/protojl

Project.toml

Lines changed: 2 additions & 2 deletions
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.12"
4+
version = "0.1.13"
55

66
[deps]
77
CRC32c = "8bf52ea8-c179-5cab-976a-9e18b702a9bc"
@@ -18,7 +18,7 @@ ColorTypes = "0.7, 0.8, 0.9, 0.10"
1818
FileIO = "1"
1919
FixedPointNumbers = "0.6, 0.7, 0.8"
2020
ImageCore = "0.7, 0.8"
21-
ProtoBuf = "0.7, 0.8"
21+
ProtoBuf = "0.10"
2222
Requires = "0.5, 1"
2323
StatsBase = "0.27, 0.28, 0.29, 0.30, 0.31, 0.32, 0.33"
2424
julia = "0.7, 1"

compat/Project.toml

Lines changed: 2 additions & 2 deletions
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.12"
4+
version = "0.1.13"
55

66
[deps]
77
CRC32c = "8bf52ea8-c179-5cab-976a-9e18b702a9bc"
@@ -18,7 +18,7 @@ ColorTypes = "0.7, 0.8, 0.9, 0.10"
1818
FileIO = "1"
1919
FixedPointNumbers = "0.6, 0.7, 0.8"
2020
ImageCore = "0.7, 0.8"
21-
ProtoBuf = "0.7, 0.8"
21+
ProtoBuf = "0.10"
2222
Requires = "0.5, 1"
2323
StatsBase = "0.27, 0.28, 0.29, 0.30, 0.31, 0.32, 0.33"
2424
julia = "0.7, 1"

gen/Project.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[deps]
2+
FilePaths = "8fc22ac5-c921-52a6-82fd-178b2807b824"
3+
FilePathsBase = "48062228-2e41-5def-b9a4-89aafe57970f"
4+
Glob = "c27321d9-0574-5035-807b-f59d2c89b15c"
5+
ProtoBuf = "3349acd9-ac6a-5e09-bcdb-63829b23a429"
6+
7+
[comapt]
8+
ProtoBuf = "0.9.1"

gen/README

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
README.md
2+
3+
Download proto files from tensorboard and tensorflow git master using download_proto_source bash script
4+
5+
Commpile them using compile_proto
6+
7+
then move gen/protojl/tensorboard to src/ and add submodules to protojl/tensorboard.jl

gen/compile_proto.jl

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
## Note: this file is supposed to be run from the TensorBoardLogger/gen folder as
2+
## $ cd .../TensorBoardLogger/gen
3+
## $ julia --project=. compile_proto.jl
4+
5+
# The proto folder is generated by the following script
6+
# and then manually cleaning the output from useless stuff
7+
#
8+
# mkdir -p tmp/proto && cd tmp
9+
# git clone --recurse-submodules git@github.com:tensorflow/tensorboard.git
10+
# git clone --recurse-submodules git@github.com:tensorflow/tensorflow.git
11+
# rsync -zarvm --include="*/" --include="*.proto" --exclude="*" tensorboard proto
12+
# rsync -zarvm --include="*/" --include="*.proto" --exclude="*" tensorflow proto
13+
14+
using ProtoBuf
15+
using Glob
16+
using FilePaths; using FilePathsBase: /
17+
18+
pbpath =dirname(dirname(PosixPath(pathof(ProtoBuf))))/p"gen"
19+
20+
## Setup input and output paths
21+
cur_path = cwd()
22+
TBL_root = dirname(cur_path)
23+
24+
src_dir = cur_path/"proto"
25+
out_dir = cur_path/"protojl"
26+
27+
## Clean the output directory
28+
rm(out_dir, force=true, recursive=true)
29+
30+
## First module
31+
function process_module(cur_module::AbstractString; base_module::AbstractString=cur_module, input_path=cur_module)
32+
# Include search paths
33+
includes = [src_dir, src_dir/base_module]
34+
35+
# Output folder
36+
module_out_dir = out_dir/cur_module
37+
38+
# Input files
39+
infiles = glob("*.proto", src_dir/input_path)
40+
41+
mkpath(module_out_dir)
42+
includes_str=["--proto_path=$path" for path=includes]
43+
run(ProtoBuf.protoc(`$includes_str --julia_out=$module_out_dir $infiles`))
44+
45+
nothing
46+
end
47+
48+
#process_module("tensorflow", input_path="tensorflow/core/protobuf")
49+
50+
process_module("tensorboard", input_path="tensorboard/compat/proto")
51+
52+
#plugins = ["audio", "custom_scalar", "hparams", "histogram", "image", "scalar", "text"]
53+
plugins = ["custom_scalar", "hparams", "text"]
54+
for plugin in plugins
55+
process_module("tensorboard/plugins/$plugin", base_module="tensorboard")
56+
end
57+
58+
59+
## this fails but would be better
60+
#cur_module = "tensorboard"
61+
#base_module = cur_module
62+
#
63+
## Include search paths
64+
#includes = [src_dir, src_dir/base_module]
65+
#
66+
## Output folder
67+
#module_out_dir = out_dir/("$cur_module"*"2")
68+
#
69+
## Input files
70+
#infiles = glob("*.proto", src_dir/cur_module/"compat/proto")
71+
#
72+
#for plugin in plugins
73+
# plugin_proto_files = glob("*.proto", src_dir/cur_module/"plugins/$plugin")
74+
# append!(infiles, plugin_proto_files)
75+
#end
76+
#
77+
#mkpath(module_out_dir)
78+
#includes_str=["--proto_path=$path" for path=includes]
79+
#run(ProtoBuf.protoc(`$includes_str --julia_out=$module_out_dir $infiles`))
80+
81+
82+
# Finally move the output directory to the src folder
83+
mv(out_dir, TBL_root/"src"/"protojl")

gen/download_proto_source

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/bash
2+
set -o xtrace
3+
4+
# The proto folder is generated by the following script
5+
# and then manually cleaning the output from useless stuff
6+
7+
echo "Cleaning up tmp and output directory"
8+
rm -rf tmp
9+
rm -rf proto
10+
11+
echo "Creating tmp directory"
12+
mkdir -p tmp/proto
13+
14+
echo "Entering tmp..."
15+
cd tmp
16+
17+
echo "Cloning all submodules of git@github.com:tensorflow/tensorboard.git"
18+
git clone --recurse-submodules git@github.com:tensorflow/tensorboard.git
19+
20+
echo "Cloning all submodules of git@github.com:tensorflow/tensorflow.git"
21+
git clone --recurse-submodules git@github.com:tensorflow/tensorflow.git
22+
23+
echo "Copy from tmp/tensorboard to tmp/proto only proto files, keeping folder structure"
24+
rsync -zarvm --include="*/" --include="*.proto" --exclude="*" tensorboard/ proto
25+
26+
echo "Copy from tmp/tensorflow to tmp/proto only proto files, keeping folder structure"
27+
rsync -zarvm --include="*/" --include="*.proto" --exclude="*" tensorflow/ proto
28+
29+
# Tensorboard has a file named struct.proto which conflicts with google's stdlib struct.proto,
30+
# so we rename it to struct_tb.proto to avoid the conflict
31+
mv proto/tensorboard/compat/proto/struct.proto proto/tensorboard/compat/proto/struct_tb.proto
32+
33+
# find and replace usages "compat/proto/struct.proto" with "compat/proto/struct.proto"
34+
if [[ $(uname) == "Darwin" ]]; then
35+
echo "Workaround for sed on macos."
36+
LC_ALL=C
37+
fi
38+
grep -rl "compat/proto/struct.proto" . | xargs sed -i '' -e 's+compat/proto/struct\.proto+compat/proto/struct_tb\.proto+g'
39+
40+
cd ..
41+
mv tmp/proto proto
42+
rm -rf tmp

proto/attr_value.proto

Lines changed: 0 additions & 62 deletions
This file was deleted.

proto/event.proto

Lines changed: 0 additions & 76 deletions
This file was deleted.

0 commit comments

Comments
 (0)