Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
VisualDL
提交
ca13bf98
V
VisualDL
项目概览
PaddlePaddle
/
VisualDL
大约 1 年 前同步成功
通知
87
Star
4655
Fork
641
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
10
列表
看板
标记
里程碑
合并请求
2
Wiki
5
Wiki
分析
仓库
DevOps
项目成员
Pages
V
VisualDL
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
10
Issue
10
列表
看板
标记
里程碑
合并请求
2
合并请求
2
Pages
分析
分析
仓库分析
DevOps
Wiki
5
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ca13bf98
编写于
1月 09, 2018
作者:
Y
Yan Chunwei
提交者:
GitHub
1月 09, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feature/glog to exception (#73)
上级
04e3f0fc
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
187 addition
and
32 deletion
+187
-32
.travis.yml
.travis.yml
+10
-0
CMakeLists.txt
CMakeLists.txt
+9
-3
tests.sh
tests.sh
+19
-10
visualdl/utils/log.h
visualdl/utils/log.h
+0
-19
visualdl/utils/logging.h
visualdl/utils/logging.h
+126
-0
visualdl/utils/test_logging.cc
visualdl/utils/test_logging.cc
+23
-0
未找到文件。
.travis.yml
浏览文件 @
ca13bf98
...
...
@@ -6,8 +6,13 @@ cache:
-
npm
sudo
:
required
dist
:
trusty
os
:
-
linux
# much bug with osx environment
# TODO(ChunweiYan) support osx in the future
#- osx
addons
:
apt
:
packages
:
...
...
@@ -23,6 +28,11 @@ addons:
-
npm
-
nodejs
before_install
:
-
if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; fi
-
if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew upgrade python; fi
-
if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install brew-pip; fi
script
:
/bin/bash ./tests.sh all
...
...
CMakeLists.txt
浏览文件 @
ca13bf98
...
...
@@ -17,6 +17,7 @@ set(THIRD_PARTY_PATH "${CMAKE_BINARY_DIR}/third_party" CACHE STRING
################################ Configurations #######################################
option
(
WITH_TESTING
"Compile VisualDL with unit testing"
ON
)
option
(
ON_RELEASE
"RELEASE mode"
ON
)
include
(
external/zlib
)
# download, build, install zlib
...
...
@@ -28,6 +29,12 @@ include(external/pybind11) # download pybind11
include
(
external/protobuf
)
# download, build, install protobuf
include
(
external/python
)
# find python and set path
if
(
NOT ON_RELEASE
)
message
(
STATUS
"build on debug mode"
)
add_compile_options
(
-DVISUALDL_WITH_GLOG
)
endif
(
NOT ON_RELEASE
)
include_directories
(
${
PROJECT_SOURCE_DIR
}
)
include_directories
(
${
CMAKE_CURRENT_BINARY_DIR
}
)
...
...
@@ -35,6 +42,7 @@ add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/visualdl/storage)
add_subdirectory
(
${
CMAKE_CURRENT_SOURCE_DIR
}
/visualdl/logic
)
add_subdirectory
(
${
CMAKE_CURRENT_SOURCE_DIR
}
/visualdl/python
)
if
(
NOT ON_RELEASE
)
add_executable
(
vl_test
${
PROJECT_SOURCE_DIR
}
/visualdl/test.cc
${
PROJECT_SOURCE_DIR
}
/visualdl/logic/sdk_test.cc
...
...
@@ -46,8 +54,6 @@ add_executable(vl_test
${
PROJECT_SOURCE_DIR
}
/visualdl/utils/filesystem.h
)
target_link_libraries
(
vl_test sdk storage entry tablet im gtest glog protobuf gflags pthread eigen3
)
enable_testing
()
add_custom_target
(
test_init COMMAND $CMAKE_BINARY_DIR
)
add_test
(
NAME vstest COMMAND ./vl_test
)
endif
(
NOT ON_RELEASE
)
tests.sh
浏览文件 @
ca13bf98
...
...
@@ -7,6 +7,22 @@ readonly core_path=$TOP_DIR/build/visualdl/logic
readonly
python_path
=
$TOP_DIR
/visualdl/python
readonly
max_file_size
=
1000000
# 1MB
sudo
=
"sudo"
if
[[
"
$TRAVIS_OS_NAME
"
==
"osx"
]]
;
then
sudo
=
""
;
fi
if
[[
"
$TRAVIS_OS_NAME
"
==
"osx"
]]
;
then
curl
-O
http://python-distribute.org/distribute_setup.py
python distribute_setup.py
curl
-O
https://raw.github.com/pypa/pip/master/contrib/get-pip.py
python get-pip.py
fi
$sudo
pip
install
numpy
$sudo
pip
install
Flask
$sudo
pip
install
Pillow
$sudo
pip
install
protobuf
export
PYTHONPATH
=
"
${
core_path
}
:
${
python_path
}
"
# install the visualdl wheel first
...
...
@@ -22,21 +38,14 @@ package() {
export
PATH
=
"
$PATH
:
$(
pwd
)
/protoc3/bin"
chmod
+x protoc3/bin/
*
sudo
pip
install
numpy
sudo
pip
install
Flask
sudo
pip
install
Pillow
sudo
pip
install
protobuf
#sudo apt-get install protobuf-compiler
cd
$TOP_DIR
python setup.py bdist_wheel
sudo
pip
install
dist/visualdl-0.0.1-py2-none-any.whl
$
sudo
pip
install
dist/visualdl-0.0.1-py2-none-any.whl
}
backend_test
()
{
cd
$TOP_DIR
sudo
pip
install
numpy
sudo
pip
install
Pillow
mkdir
-p
build
cd
build
cmake ..
...
...
@@ -52,8 +61,8 @@ frontend_test() {
}
server_test
()
{
sudo
pip
install
google
sudo
pip
install
protobuf
==
3.1.0
$
sudo
pip
install
google
$
sudo
pip
install
protobuf
==
3.1.0
cd
$TOP_DIR
/visualdl/server
bash graph_test.sh
...
...
visualdl/utils/log.h
已删除
100644 → 0
浏览文件 @
04e3f0fc
#ifndef VISUALDL_UTILS_LOG_H
#define VISUALDL_UTILS_LOG_H
#include <stdexcept>
namespace
visualdl
{
namespace
log
{
class
NotImplementedException
:
public
std
::
logic_error
{
public:
NotImplementedException
()
:
std
::
logic_error
{
"Function not implemented"
}
{}
};
}
// namespace log
}
// namespace visualdl
#endif
visualdl/utils/logging.h
0 → 100644
浏览文件 @
ca13bf98
#ifndef VISUALDL_UTILS_LOGGING_H
#define VISUALDL_UTILS_LOGGING_H
#include <csignal>
#include <iostream>
#include <sstream>
#include <stdexcept>
#include <string>
#if defined(VISUALDL_WITH_GLOG)
#include <glog/logging.h>
#endif
namespace
visualdl
{
namespace
logging
{
#if !defined(VISUALDL_WITH_GLOG)
// basic log stream for INFO, ERROR, WARNING
struct
LogStream
{
LogStream
(
const
char
*
file
,
int
line
)
:
os_
(
std
::
cerr
)
{
os_
<<
"["
<<
file
<<
":"
<<
line
<<
"] "
;
}
~
LogStream
()
{
os_
<<
"
\n
"
;
}
std
::
ostream
&
stream
()
{
return
os_
;
}
void
operator
=
(
const
LogStream
&
)
=
delete
;
LogStream
(
const
LogStream
&
)
=
delete
;
private:
std
::
ostream
&
os_
;
};
#endif
#if !defined(VISUALDL_WITH_GLOG)
#if defined(VISUALDL_FATAL_ABORT)
// log stream for FATAL
struct
LogStreamFatal
:
public
LogStream
{
LogStreamFatal
(
const
char
*
file
,
int
line
)
:
LogStream
(
file
,
line
)
{}
~
LogStreamFatal
()
{
abort
();
}
LogStreamFatal
(
const
LogStreamFatal
&
)
=
delete
;
void
operator
=
(
const
LogStreamFatal
&
)
=
delete
;
};
#else
struct
Error
:
public
std
::
runtime_error
{
explicit
Error
(
const
std
::
string
&
s
)
:
std
::
runtime_error
(
s
)
{}
};
// With exception.
struct
LogStreamFatal
{
LogStreamFatal
(
const
char
*
file
,
int
line
)
{
ss
<<
"["
<<
file
<<
":"
<<
line
<<
"] "
;
throw
Error
(
ss
.
str
());
}
std
::
stringstream
&
stream
()
{
return
ss
;
}
~
LogStreamFatal
()
{
if
(
!
has_throw_
)
{
std
::
cerr
<<
"throw exception"
<<
std
::
endl
;
throw
Error
(
ss
.
str
());
}
}
private:
bool
has_throw_
{
false
};
mutable
std
::
stringstream
ss
;
};
#endif // VISUALDL_FATAL_ABORT
#endif // VISUALDL_WITH_GLOG
#ifndef VISUALDL_WITH_GLOG
#define LOG(severity) LOG_##severity
#define LOG_INFO visualdl::logging::LogStream(__FILE__, __LINE__).stream()
#define LOG_WARNING LOG_INFO
#define LOG_ERROR LOG_INFO
#define LOG_FATAL visualdl::logging::LogStreamFatal(__FILE__, __LINE__).stream()
// basic version without support for debug level.
#define VLOG(x) LOG_INFO
#define CHECK(cond) \
if (!(cond)) \
visualdl::logging::LogStreamFatal(__FILE__, __LINE__).stream() \
<< "Check failed: " << #cond << " "
#define CHECK_EQ(v0, v1) CHECK_BINARY(v0, v1, ==)
#define CHECK_GE(v0, v1) CHECK_BINARY(v0, v1, >=)
#define CHECK_GT(v0, v1) CHECK_BINARY(v0, v1, >)
#define CHECK_LE(v0, v1) CHECK_BINARY(v0, v1, <=)
#define CHECK_LT(v0, v1) CHECK_BINARY(v0, v1, <)
#define CHECK_BINARY(v0, v1, op) \
if (!(v0 op v1)) LOG_FATAL << " Check failed: " << v0 << #op << v1 << " "
#endif // ifndef VISUALDL_WITH_GLOG
}
// namespace logging
}
// namespace visualdl
namespace
visualdl
{
namespace
log
{
class
NotImplementedException
:
public
std
::
logic_error
{
public:
NotImplementedException
()
:
std
::
logic_error
{
"Function not implemented"
}
{}
};
static
void
SignalHandler
(
int
sig
)
{
LOG
(
INFO
)
<<
"get signal "
<<
sig
;
exit
(
sig
);
}
struct
__once_caller__
{
__once_caller__
()
{
std
::
signal
(
SIGINT
,
SignalHandler
);
}
};
}
// namespace log
}
// namespace visualdl
#endif
visualdl/utils/test_logging.cc
0 → 100644
浏览文件 @
ca13bf98
#ifdef VISUALDL_WITH_GLOG
#undef VISUALDL_WITH_GLOG
#endif
#include "visualdl/utils/logging.h"
#include <gtest/gtest.h>
TEST
(
Log
,
LOG
)
{
LOG
(
INFO
)
<<
"hello world"
;
}
TEST
(
Log
,
CHECK
)
{
CHECK_EQ
(
1
,
1
)
<<
"yes this works"
;
}
TEST
(
Log
,
CHECK_FAIL
)
{
try
{
CHECK_LE
(
3
,
2
)
<<
"this is wrong"
;
// throw std::runtime_error("some error");
}
catch
(
const
visualdl
::
logging
::
Error
&
e
)
{
LOG
(
INFO
)
<<
e
.
what
();
auto
msg
=
std
::
string
(
e
.
what
());
auto
it
=
msg
.
find
(
"test_logging.cc:14"
);
ASSERT_GT
(
it
,
0
);
}
catch
(...)
{
LOG
(
INFO
)
<<
"catch something"
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录