Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add travis test for graph edges #49

Merged
merged 31 commits into from
Jan 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
8b44432
Add test for graph edges
daming-lu Jan 2, 2018
a7899ab
add new line
daming-lu Jan 2, 2018
9881686
Merge branch 'develop' into add_travis_test_for_graph_edges
daming-lu Jan 2, 2018
141b655
add google protobuf
daming-lu Jan 2, 2018
c8afc9f
add onnx to travis
daming-lu Jan 2, 2018
7e82768
install protoc and move installs to tests.sh
daming-lu Jan 2, 2018
8c90bbc
tune protoc
daming-lu Jan 2, 2018
64c7ee6
try to install onnx
daming-lu Jan 2, 2018
612d325
onnx always fails on travis, try script from onnx github
daming-lu Jan 2, 2018
205a142
install protobuf 3.1.0 but not onnx
daming-lu Jan 2, 2018
9407e68
in the right dir
daming-lu Jan 2, 2018
3dc734f
tune path
daming-lu Jan 2, 2018
550bca1
should work
daming-lu Jan 2, 2018
d6a3afb
put onnx_pb2 there and it should work
daming-lu Jan 2, 2018
4466012
what if remove onnx_pb2.py
daming-lu Jan 2, 2018
2cf599f
cp compiled onnx_pb2 to the right place
daming-lu Jan 2, 2018
0dbf8c4
debug
daming-lu Jan 2, 2018
c5326a1
protoc
daming-lu Jan 2, 2018
0b59904
install protoc
daming-lu Jan 2, 2018
38e0847
chown
daming-lu Jan 2, 2018
eab68a7
test
daming-lu Jan 2, 2018
63d22ea
added protc, should work
daming-lu Jan 2, 2018
5d969e1
typo
daming-lu Jan 2, 2018
eeeb9fa
does it exist?
daming-lu Jan 2, 2018
77ddb92
hmmmm
daming-lu Jan 2, 2018
32b0a1b
try dropbox
daming-lu Jan 2, 2018
1531207
test 1
daming-lu Jan 2, 2018
de14167
now it should work
daming-lu Jan 2, 2018
00f208e
done
daming-lu Jan 2, 2018
1e8b284
Merge branch 'develop' into add_travis_test_for_graph_edges
daming-lu Jan 3, 2018
10cba84
make tests more thorough
daming-lu Jan 3, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,7 @@ ENV/
node_modules
/.vscode
package-lock.json

# PyCharm IDE
.idea/

4 changes: 3 additions & 1 deletion server/build.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#!/bin/bash

script=$(readlink -f "$0")
script_path=$(dirname "$script")

pushd $script_path
protoc visualdl/onnx/onnx.proto --python_out .
protoc3/bin/protoc visualdl/onnx/onnx.proto --python_out .
python setup.py bdist_wheel
popd
2 changes: 2 additions & 0 deletions server/visualdl/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ def reorganize_inout(json_obj, key):


def add_edges(json_obj):
# TODO(daming-lu): should try to de-duplicate node's out-edge
# Currently it is counted twice: 1 as out-edge, 1 as in-edge
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

这个会根据前端的需要进行改进,先看看前端是怎么渲染的吧。

json_obj['edges'] = []
label_incrementer = 0

Expand Down
74 changes: 74 additions & 0 deletions server/visualdl/graph_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import unittest
import graph
import json


class GraphTest(unittest.TestCase):
def setUp(self):
self.mock_dir = "./mock"

def test_graph_edges_squeezenet(self):
json_str = graph.load_model(self.mock_dir + '/squeezenet_model.pb')
json_obj = json.loads(json_str)

# 126 edges + 66 nodes (out-edge of each node is counted twice)
self.assertEqual(len(json_obj['edges']), 126 + 66)

# label_0: (in-edge)
# {u'source': u'data_0', u'target': u'node_0', u'label': u'label_0'}
self.assertEqual(json_obj['edges'][0]['source'], 'data_0')
self.assertEqual(json_obj['edges'][0]['target'], 'node_0')
self.assertEqual(json_obj['edges'][0]['label'], 'label_0')

# label_50: (in-edge)
# {u'source': u'fire3/concat_1', u'target': u'node_17', u'label': u'label_50'}
self.assertEqual(json_obj['edges'][50]['source'], 'fire3/concat_1')
self.assertEqual(json_obj['edges'][50]['target'], 'node_17')
self.assertEqual(json_obj['edges'][50]['label'], 'label_50')

# label_100: (in-edge)
# {u'source': u'fire6/squeeze1x1_1', u'target': u'node_34', u'label': u'label_100'}
self.assertEqual(json_obj['edges'][100]['source'], 'fire6/squeeze1x1_1')
self.assertEqual(json_obj['edges'][100]['target'], 'node_34')
self.assertEqual(json_obj['edges'][100]['label'], 'label_100')

# label_111: (out-edge)
# {u'source': u'node_37', u'target': u'fire6/expand3x3_1', u'label': u'label_111'}
self.assertEqual(json_obj['edges'][111]['source'], 'node_37')
self.assertEqual(json_obj['edges'][111]['target'], 'fire6/expand3x3_1')
self.assertEqual(json_obj['edges'][111]['label'], 'label_111')

def test_graph_edges_inception_v1(self):
json_str = graph.load_model(self.mock_dir + '/inception_v1_model.pb')
json_obj = json.loads(json_str)

# 286 edges + 143 nodes (out-edge of each node is counted twice)
self.assertEqual(len(json_obj['edges']), 286 + 143)

# label_0: (in-edge)
# {u'source': u'data_0', u'target': u'node_0', u'label': u'label_0'}
self.assertEqual(json_obj['edges'][0]['source'], 'data_0')
self.assertEqual(json_obj['edges'][0]['target'], 'node_0')
self.assertEqual(json_obj['edges'][0]['label'], 'label_0')

# label_50: (in-edge)
# {u'source': u'inception_3a/5x5_reduce_2', u'target': u'node_18', u'label': u'label_50'}
self.assertEqual(json_obj['edges'][50]['source'], 'inception_3a/5x5_reduce_2')
self.assertEqual(json_obj['edges'][50]['target'], 'node_18')
self.assertEqual(json_obj['edges'][50]['label'], 'label_50')

# label_100: (out-edge)
# {u'source': u'node_34', u'target': u'inception_3b/pool_1', u'label': u'label_100'}
self.assertEqual(json_obj['edges'][100]['source'], 'node_34')
self.assertEqual(json_obj['edges'][100]['target'], 'inception_3b/pool_1')
self.assertEqual(json_obj['edges'][100]['label'], 'label_100')

# label_420: (out-edge)
# {u'source': u'node_139', u'target': u'pool5/7x7_s1_2', u'label': u'label_420'}
self.assertEqual(json_obj['edges'][420]['source'], 'node_139')
self.assertEqual(json_obj['edges'][420]['target'], 'pool5/7x7_s1_2')
self.assertEqual(json_obj['edges'][420]['label'], 'label_420')


if __name__ == '__main__':
unittest.main()
12 changes: 12 additions & 0 deletions server/visualdl/graph_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
set -ex

cd mock
bash download_mock_models.sh

cd ..

python graph_test.py

rm ./mock/*.pb

4 changes: 2 additions & 2 deletions server/visualdl/mock/download_mock_models.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

# Download inception_v1 model
curl -LOk http://visualdl.bj.bcebos.com/inception_v1.tar.gz

#curl -LOk https://www.dropbox.com/s/twbfdqgvowzy762/inception_v1.tar.gz?dl=0
tar -xvzf inception_v1.tar.gz
cp inception_v1/model.pb inception_v1_model.pb

Expand All @@ -11,7 +11,7 @@ rm inception_v1.tar.gz

# Download squeezenet model
curl -LOk http://visualdl.bj.bcebos.com/squeezenet.tar.gz

#curl -LOk https://www.dropbox.com/s/fip3jzxsjf2g6zc/squeezenet.tar.gz?dl=0
tar -xvzf squeezenet.tar.gz
cp squeezenet/model.pb squeezenet_model.pb

Expand Down
13 changes: 13 additions & 0 deletions tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,21 @@ frontend_test() {
}

server_test() {
sudo pip install google
sudo pip install protobuf==3.1.0

cd $cur/server
curl -OL https://github.com/google/protobuf/releases/download/v3.1.0/protoc-3.1.0-linux-x86_64.zip
unzip protoc-3.1.0-linux-x86_64.zip -d protoc3
export PATH=$PATH:protoc3/bin
sudo chmod +x protoc3/bin/protoc
sudo chown `whoami` protoc3/bin/protoc

bash build.sh

cd visualdl
bash graph_test.sh

cd $cur/server/visualdl
python lib_test.py
}
Expand Down