Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
VisualDL
提交
ad4dc58a
V
VisualDL
项目概览
PaddlePaddle
/
VisualDL
大约 1 年 前同步成功
通知
88
Star
4655
Fork
642
代码
文件
提交
分支
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看板
提交
ad4dc58a
编写于
12月 10, 2017
作者:
Y
Yan Chunwei
提交者:
GitHub
12月 10, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #46 from ChunweiYan/feature/support_web_server_storage_read
上级
29259816
cfec13be
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
80 addition
and
12 deletion
+80
-12
visualdl/backend/logic/pybind.cc
visualdl/backend/logic/pybind.cc
+1
-1
visualdl/backend/logic/sdk.cc
visualdl/backend/logic/sdk.cc
+0
-2
visualdl/backend/logic/sdk.h
visualdl/backend/logic/sdk.h
+61
-6
visualdl/backend/storage/CMakeLists.txt
visualdl/backend/storage/CMakeLists.txt
+1
-1
visualdl/backend/utils/concurrency.h
visualdl/backend/utils/concurrency.h
+17
-2
未找到文件。
visualdl/backend/logic/pybind.cc
浏览文件 @
ad4dc58a
...
...
@@ -62,7 +62,7 @@ PYBIND11_PLUGIN(core) {
&
vs
::
start_write_service
,
"global information-maintainer object."
);
m
.
def
(
"im"
,
&
vs
::
im
);
m
.
def
(
"stop_threads"
,
&
vs
::
StopT
hreads
);
m
.
def
(
"stop_threads"
,
&
vs
::
stop_t
hreads
);
// interfaces for components
#define ADD_SCALAR_TYPED_INTERFACE(T, name__) \
...
...
visualdl/backend/logic/sdk.cc
浏览文件 @
ad4dc58a
...
...
@@ -60,8 +60,6 @@ std::string TabletHelper::human_readable_buffer() const {
return
buffer
;
}
void
ImHelper
::
PersistToDisk
()
const
{
IM
::
Global
().
PersistToDisk
();
}
// implementations for components
namespace
components
{
...
...
visualdl/backend/logic/sdk.h
浏览文件 @
ad4dc58a
...
...
@@ -96,14 +96,69 @@ class ImHelper {
public:
ImHelper
()
{}
/*
* mode:
* 0: read
* 1: write
* 2: none
*/
StorageHelper
storage
()
{
return
StorageHelper
(
IM
::
Global
().
storage
().
mutable_data
());
}
TabletHelper
tablet
(
const
std
::
string
&
tag
)
{
return
TabletHelper
(
IM
::
Global
().
storage
().
tablet
(
tag
));
}
TabletHelper
AddTablet
(
const
std
::
string
&
tag
,
int
num_samples
)
{
return
TabletHelper
(
IM
::
Global
().
AddTablet
(
tag
,
num_samples
));
}
void
ClearTablets
()
{
IM
::
Global
().
storage
().
mutable_data
()
->
clear_tablets
();
}
void
PersistToDisk
()
const
{
IM
::
Global
().
PersistToDisk
();
}
};
namespace
components
{
/*
* Read and write support for Scalar component.
*/
template
<
typename
T
>
class
ScalarHelper
{
public:
ScalarHelper
(
storage
::
Tablet
*
tablet
)
:
data_
(
tablet
)
{}
void
SetCaptions
(
const
std
::
vector
<
std
::
string
>
&
captions
);
void
AddRecord
(
int
id
,
const
std
::
vector
<
T
>
&
values
);
std
::
vector
<
std
::
vector
<
T
>>
GetRecords
()
const
;
std
::
vector
<
int
>
GetIds
()
const
;
std
::
vector
<
int
>
GetTimestamps
()
const
;
std
::
vector
<
std
::
string
>
GetCaptions
()
const
;
size_t
GetSize
()
const
{
return
data_
->
records_size
();
}
private:
storage
::
Tablet
*
data_
;
};
}
// namespace components
static
ImHelper
&
im
()
{
static
ImHelper
im
;
return
im
;
}
static
void
start_read_service
(
const
std
::
string
&
dir
)
{
IM
::
Global
().
SetPersistDest
(
dir
);
IM
::
Global
().
MaintainRead
();
}
static
void
start_write_service
(
const
std
::
string
&
dir
)
{
IM
::
Global
().
SetPersistDest
(
dir
);
IM
::
Global
().
MaintainWrite
();
}
static
void
stop_threads
()
{
cc
::
PeriodExector
::
Global
().
Quit
();
}
}
// namespace visualdl
#endif // VISUALDL_BACKEND_LOGIC_SDK_H
visualdl/backend/storage/CMakeLists.txt
浏览文件 @
ad4dc58a
...
...
@@ -4,5 +4,5 @@ add_library(storage_proto ${PROTO_SRCS})
add_dependencies
(
storage_proto protobuf
)
## add storage as target
add_library
(
storage storage.cc
${
PROTO_SRCS
}
${
PROTO_HDRS
}
)
add_library
(
storage storage.cc
storage.h
${
PROTO_SRCS
}
${
PROTO_HDRS
}
)
add_dependencies
(
storage storage_proto
)
visualdl/backend/utils/concurrency.h
浏览文件 @
ad4dc58a
...
...
@@ -30,12 +30,27 @@ struct PeriodExector {
void
Start
()
{
quit
=
false
;
}
void
operator
()(
task_t
&&
task
,
int
msec
)
{
const
int
interval
=
500
;
auto
task_wrapper
=
[
=
]
{
while
(
!
quit
)
{
if
(
!
task
())
break
;
std
::
this_thread
::
sleep_for
(
std
::
chrono
::
milliseconds
(
msec
));
// if the program is terminated, quit while as soon as possible.
// this is just trick, but should works.
if
(
msec
>
1000
)
{
int
i
;
for
(
i
=
0
;
i
<
msec
/
interval
;
i
++
)
{
if
(
quit
)
break
;
std
::
this_thread
::
sleep_for
(
std
::
chrono
::
milliseconds
(
interval
));
}
std
::
this_thread
::
sleep_for
(
std
::
chrono
::
milliseconds
(
msec
-
i
*
interval
));
if
(
quit
)
break
;
}
else
{
std
::
this_thread
::
sleep_for
(
std
::
chrono
::
milliseconds
(
msec
));
}
}
LOG
(
INFO
)
<<
"quit job"
;
LOG
(
INFO
)
<<
"quit
concurrent
job"
;
};
threads_
.
emplace_back
(
std
::
thread
(
std
::
move
(
task_wrapper
)));
msec_
=
msec
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录