Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
magicwindyyd
mindspore
提交
4870abc8
M
mindspore
项目概览
magicwindyyd
/
mindspore
与 Fork 源项目一致
Fork自
MindSpore / mindspore
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
mindspore
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
4870abc8
编写于
8月 21, 2020
作者:
H
heleiwang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
1. fix generator_dataset hangs
2. fix test_graphdata_distributed.py failing randomly
上级
9a3baf4f
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
24 addition
and
13 deletion
+24
-13
mindspore/dataset/engine/datasets.py
mindspore/dataset/engine/datasets.py
+15
-6
mindspore/dataset/engine/validators.py
mindspore/dataset/engine/validators.py
+3
-3
tests/ut/python/dataset/test_graphdata_distributed.py
tests/ut/python/dataset/test_graphdata_distributed.py
+6
-4
未找到文件。
mindspore/dataset/engine/datasets.py
浏览文件 @
4870abc8
...
@@ -3217,12 +3217,14 @@ def _generator_worker_loop(dataset, idx_queue, result_queue, eoe, eof):
...
@@ -3217,12 +3217,14 @@ def _generator_worker_loop(dataset, idx_queue, result_queue, eoe, eof):
while
True
:
while
True
:
# Fetch index, block
# Fetch index, block
try
:
try
:
idx
=
idx_queue
.
get
(
timeout
=
10
)
# Index is generated very fast, so the timeout is very short
idx
=
idx_queue
.
get
(
timeout
=
0.01
)
except
KeyboardInterrupt
:
except
KeyboardInterrupt
:
raise
Exception
(
"Generator worker receives KeyboardInterrupt"
)
raise
Exception
(
"Generator worker receives KeyboardInterrupt"
)
except
queue
.
Empty
:
except
queue
.
Empty
:
if
eof
.
is_set
()
or
eoe
.
is_set
():
if
eof
.
is_set
()
or
eoe
.
is_set
():
raise
Exception
(
"Generator worker receives queue.Empty"
)
return
# If eoe or eof is not set, continue to get data from idx_queue
continue
continue
if
idx
is
None
:
if
idx
is
None
:
# When the queue is out of scope from master process, a None item can be fetched from the queue.
# When the queue is out of scope from master process, a None item can be fetched from the queue.
...
@@ -3234,10 +3236,17 @@ def _generator_worker_loop(dataset, idx_queue, result_queue, eoe, eof):
...
@@ -3234,10 +3236,17 @@ def _generator_worker_loop(dataset, idx_queue, result_queue, eoe, eof):
# Fetch data, any exception from __getitem__ will terminate worker and timeout master process
# Fetch data, any exception from __getitem__ will terminate worker and timeout master process
result
=
dataset
[
idx
]
result
=
dataset
[
idx
]
# Send data, block
# Send data, block
try
:
while
True
:
result_queue
.
put
(
result
)
try
:
except
KeyboardInterrupt
:
result_queue
.
put
(
result
,
timeout
=
5
)
raise
Exception
(
"Generator worker receives KeyboardInterrupt"
)
except
KeyboardInterrupt
:
raise
Exception
(
"Generator worker receives KeyboardInterrupt"
)
except
queue
.
Full
:
if
eof
.
is_set
():
return
# If eof is not set, continue to put data to result_queue
continue
break
del
result
,
idx
del
result
,
idx
if
eoe
.
is_set
()
and
idx_queue
.
empty
():
if
eoe
.
is_set
()
and
idx_queue
.
empty
():
return
return
...
...
mindspore/dataset/engine/validators.py
浏览文件 @
4870abc8
...
@@ -929,10 +929,10 @@ def check_split(method):
...
@@ -929,10 +929,10 @@ def check_split(method):
def
check_hostname
(
hostname
):
def
check_hostname
(
hostname
):
if
len
(
hostname
)
>
255
:
if
not
hostname
or
len
(
hostname
)
>
255
:
return
False
return
False
if
hostname
[
-
1
]
==
"."
:
if
hostname
[
-
1
]
==
"."
:
hostname
=
hostname
[:
-
1
]
# strip exactly one dot from the right, if present
hostname
=
hostname
[:
-
1
]
# strip exactly one dot from the right, if present
allowed
=
re
.
compile
(
"(?!-)[A-Z
\\
d-]{1,63}(?<!-)$"
,
re
.
IGNORECASE
)
allowed
=
re
.
compile
(
"(?!-)[A-Z
\\
d-]{1,63}(?<!-)$"
,
re
.
IGNORECASE
)
return
all
(
allowed
.
match
(
x
)
for
x
in
hostname
.
split
(
"."
))
return
all
(
allowed
.
match
(
x
)
for
x
in
hostname
.
split
(
"."
))
...
@@ -952,7 +952,7 @@ def check_gnn_graphdata(method):
...
@@ -952,7 +952,7 @@ def check_gnn_graphdata(method):
raise
ValueError
(
"The hostname is illegal"
)
raise
ValueError
(
"The hostname is illegal"
)
type_check
(
working_mode
,
(
str
,),
"working_mode"
)
type_check
(
working_mode
,
(
str
,),
"working_mode"
)
if
working_mode
not
in
{
'local'
,
'client'
,
'server'
}:
if
working_mode
not
in
{
'local'
,
'client'
,
'server'
}:
raise
ValueError
(
"Invalid working mode"
)
raise
ValueError
(
"Invalid working mode
, please enter 'local', 'client' or 'server'
"
)
type_check
(
port
,
(
int
,),
"port"
)
type_check
(
port
,
(
int
,),
"port"
)
check_value
(
port
,
(
1024
,
65535
),
"port"
)
check_value
(
port
,
(
1024
,
65535
),
"port"
)
type_check
(
num_client
,
(
int
,),
"num_client"
)
type_check
(
num_client
,
(
int
,),
"num_client"
)
...
...
tests/ut/python/dataset/test_graphdata_distributed.py
浏览文件 @
4870abc8
...
@@ -23,12 +23,12 @@ from mindspore import log as logger
...
@@ -23,12 +23,12 @@ from mindspore import log as logger
DATASET_FILE
=
"../data/mindrecord/testGraphData/testdata"
DATASET_FILE
=
"../data/mindrecord/testGraphData/testdata"
def
graphdata_startserver
():
def
graphdata_startserver
(
server_port
):
"""
"""
start graphdata server
start graphdata server
"""
"""
logger
.
info
(
'test start server.
\n
'
)
logger
.
info
(
'test start server.
\n
'
)
ds
.
GraphData
(
DATASET_FILE
,
1
,
'server'
)
ds
.
GraphData
(
DATASET_FILE
,
1
,
'server'
,
port
=
server_port
)
class
RandomBatchedSampler
(
ds
.
Sampler
):
class
RandomBatchedSampler
(
ds
.
Sampler
):
...
@@ -83,11 +83,13 @@ def test_graphdata_distributed():
...
@@ -83,11 +83,13 @@ def test_graphdata_distributed():
"""
"""
logger
.
info
(
'test distributed.
\n
'
)
logger
.
info
(
'test distributed.
\n
'
)
p1
=
Process
(
target
=
graphdata_startserver
)
server_port
=
random
.
randint
(
10000
,
60000
)
p1
=
Process
(
target
=
graphdata_startserver
,
args
=
(
server_port
,))
p1
.
start
()
p1
.
start
()
time
.
sleep
(
2
)
time
.
sleep
(
2
)
g
=
ds
.
GraphData
(
DATASET_FILE
,
1
,
'client'
)
g
=
ds
.
GraphData
(
DATASET_FILE
,
1
,
'client'
,
port
=
server_port
)
nodes
=
g
.
get_all_nodes
(
1
)
nodes
=
g
.
get_all_nodes
(
1
)
assert
nodes
.
tolist
()
==
[
101
,
102
,
103
,
104
,
105
,
106
,
107
,
108
,
109
,
110
]
assert
nodes
.
tolist
()
==
[
101
,
102
,
103
,
104
,
105
,
106
,
107
,
108
,
109
,
110
]
row_tensor
=
g
.
get_node_feature
(
nodes
.
tolist
(),
[
1
,
2
,
3
])
row_tensor
=
g
.
get_node_feature
(
nodes
.
tolist
(),
[
1
,
2
,
3
])
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录