Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
正统之独孤求败
mindspore
提交
286db9b5
M
mindspore
项目概览
正统之独孤求败
/
mindspore
与 Fork 源项目一致
Fork自
MindSpore / mindspore
通知
1
Star
0
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
286db9b5
编写于
4月 07, 2020
作者:
高东海
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix runtest.sh for python ut
上级
04a46e36
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
20 addition
and
69 deletion
+20
-69
mindspore/dataset/engine/datasets.py
mindspore/dataset/engine/datasets.py
+6
-14
mindspore/dataset/engine/validators.py
mindspore/dataset/engine/validators.py
+0
-49
tests/ut/python/ops/test_ops_check.py
tests/ut/python/ops/test_ops_check.py
+2
-2
tests/ut/python/runtest.sh
tests/ut/python/runtest.sh
+12
-4
未找到文件。
mindspore/dataset/engine/datasets.py
浏览文件 @
286db9b5
...
@@ -38,7 +38,7 @@ from .iterators import DictIterator, TupleIterator
...
@@ -38,7 +38,7 @@ from .iterators import DictIterator, TupleIterator
from
.validators
import
check
,
check_batch
,
check_shuffle
,
check_map
,
check_repeat
,
check_zip
,
check_rename
,
\
from
.validators
import
check
,
check_batch
,
check_shuffle
,
check_map
,
check_repeat
,
check_zip
,
check_rename
,
\
check_project
,
check_imagefolderdatasetv2
,
check_mnist_cifar_dataset
,
check_manifestdataset
,
\
check_project
,
check_imagefolderdatasetv2
,
check_mnist_cifar_dataset
,
check_manifestdataset
,
\
check_tfrecorddataset
,
check_vocdataset
,
check_celebadataset
,
check_minddataset
,
check_generatordataset
,
\
check_tfrecorddataset
,
check_vocdataset
,
check_celebadataset
,
check_minddataset
,
check_generatordataset
,
\
check_zip_dataset
,
check_add_column
,
check_columns
check_zip_dataset
from
..core.datatypes
import
mstype_to_detype
,
mstypelist_to_detypelist
from
..core.datatypes
import
mstype_to_detype
,
mstypelist_to_detypelist
try
:
try
:
...
@@ -2334,20 +2334,13 @@ class Schema:
...
@@ -2334,20 +2334,13 @@ class Schema:
self
.
dataset_type
=
''
self
.
dataset_type
=
''
self
.
num_rows
=
0
self
.
num_rows
=
0
else
:
else
:
if
not
os
.
path
.
isfile
(
schema_file
)
or
not
os
.
access
(
schema_file
,
os
.
R_OK
):
raise
ValueError
(
"The file %s does not exist or permission denied!"
%
schema_file
)
try
:
try
:
with
open
(
schema_file
,
'r'
)
as
load_f
:
with
open
(
schema_file
,
'r'
)
as
load_f
:
json_obj
=
json
.
load
(
load_f
)
json_obj
=
json
.
load
(
load_f
)
except
json
.
decoder
.
JSONDecodeError
:
raise
RuntimeError
(
"Schema file failed to load."
)
except
UnicodeDecodeError
:
raise
RuntimeError
(
"Schema file failed to decode."
)
except
Exception
:
raise
RuntimeError
(
"Schema file failed to open."
)
self
.
from_json
(
json_obj
)
self
.
from_json
(
json_obj
)
except
json
.
decoder
.
JSONDecodeError
:
raise
RuntimeError
(
"Schema file failed to load"
)
@
check_add_column
def
add_column
(
self
,
name
,
de_type
,
shape
=
None
):
def
add_column
(
self
,
name
,
de_type
,
shape
=
None
):
"""
"""
Add new column to the schema.
Add new column to the schema.
...
@@ -2366,8 +2359,10 @@ class Schema:
...
@@ -2366,8 +2359,10 @@ class Schema:
if
isinstance
(
de_type
,
typing
.
Type
):
if
isinstance
(
de_type
,
typing
.
Type
):
de_type
=
mstype_to_detype
(
de_type
)
de_type
=
mstype_to_detype
(
de_type
)
new_column
[
"type"
]
=
str
(
de_type
)
new_column
[
"type"
]
=
str
(
de_type
)
el
se
:
el
if
isinstance
(
de_type
,
str
)
:
new_column
[
"type"
]
=
str
(
DataType
(
de_type
))
new_column
[
"type"
]
=
str
(
DataType
(
de_type
))
else
:
raise
ValueError
(
"Unknown column type"
)
if
shape
is
not
None
:
if
shape
is
not
None
:
new_column
[
"shape"
]
=
shape
new_column
[
"shape"
]
=
shape
...
@@ -2404,7 +2399,6 @@ class Schema:
...
@@ -2404,7 +2399,6 @@ class Schema:
RuntimeError: If column's name field is missing.
RuntimeError: If column's name field is missing.
RuntimeError: If column's type field is missing.
RuntimeError: If column's type field is missing.
"""
"""
check_columns
(
columns
,
columns
)
self
.
columns
=
[]
self
.
columns
=
[]
for
col
in
columns
:
for
col
in
columns
:
name
=
None
name
=
None
...
@@ -2449,8 +2443,6 @@ class Schema:
...
@@ -2449,8 +2443,6 @@ class Schema:
RuntimeError: if dataset type is missing in the object.
RuntimeError: if dataset type is missing in the object.
RuntimeError: if columns are missing in the object.
RuntimeError: if columns are missing in the object.
"""
"""
if
not
isinstance
(
json_obj
,
dict
)
or
json_obj
is
None
:
raise
ValueError
(
"Expected non-empty dict."
)
for
k
,
v
in
json_obj
.
items
():
for
k
,
v
in
json_obj
.
items
():
if
k
==
"datasetType"
:
if
k
==
"datasetType"
:
self
.
dataset_type
=
v
self
.
dataset_type
=
v
...
...
mindspore/dataset/engine/validators.py
浏览文件 @
286db9b5
...
@@ -19,15 +19,10 @@ import inspect as ins
...
@@ -19,15 +19,10 @@ import inspect as ins
import
os
import
os
from
functools
import
wraps
from
functools
import
wraps
from
multiprocessing
import
cpu_count
from
multiprocessing
import
cpu_count
from
mindspore._c_expression
import
typing
from
.
import
samplers
from
.
import
samplers
from
.
import
datasets
from
.
import
datasets
INT32_MAX
=
2147483647
INT32_MAX
=
2147483647
valid_detype
=
[
"bool"
,
"int8"
,
"int16"
,
"int32"
,
"int64"
,
"uint8"
,
"uint16"
,
"uint32"
,
"uint64"
,
"float16"
,
"float32"
,
"float64"
]
def
check
(
method
):
def
check
(
method
):
...
@@ -193,12 +188,6 @@ def check(method):
...
@@ -193,12 +188,6 @@ def check(method):
return
wrapper
return
wrapper
def
check_valid_detype
(
type_
):
if
type_
not
in
valid_detype
:
raise
ValueError
(
"Unknown column type"
)
return
True
def
check_filename
(
path
):
def
check_filename
(
path
):
"""
"""
check the filename in the path
check the filename in the path
...
@@ -754,41 +743,3 @@ def check_project(method):
...
@@ -754,41 +743,3 @@ def check_project(method):
return
method
(
*
args
,
**
kwargs
)
return
method
(
*
args
,
**
kwargs
)
return
new_method
return
new_method
def
check_shape
(
shape
,
name
):
if
isinstance
(
shape
,
list
):
for
element
in
shape
:
if
not
isinstance
(
element
,
int
):
raise
TypeError
(
"Each element in {0} should be of type int. Got {1}."
.
format
(
name
,
type
(
element
)))
else
:
raise
TypeError
(
"Expected int list."
)
def
check_add_column
(
method
):
"""check the input arguments of add_column."""
@
wraps
(
method
)
def
new_method
(
*
args
,
**
kwargs
):
param_dict
=
make_param_dict
(
method
,
args
,
kwargs
)
# check name; required argument
name
=
param_dict
.
get
(
"name"
)
if
not
isinstance
(
name
,
str
)
or
not
name
:
raise
TypeError
(
"Expected non-empty string."
)
# check type; required argument
de_type
=
param_dict
.
get
(
"de_type"
)
if
not
isinstance
(
de_type
,
str
)
or
not
de_type
:
raise
TypeError
(
"Expected non-empty string."
)
if
not
isinstance
(
de_type
,
typing
.
Type
)
and
not
check_valid_detype
(
de_type
):
raise
ValueError
(
"Unknown column type."
)
# check shape
shape
=
param_dict
.
get
(
"shape"
)
if
shape
is
not
None
:
check_shape
(
shape
,
"shape"
)
return
method
(
*
args
,
**
kwargs
)
return
new_method
tests/ut/python/ops/test_ops_check.py
浏览文件 @
286db9b5
...
@@ -62,7 +62,7 @@ def test_net_without_construct():
...
@@ -62,7 +62,7 @@ def test_net_without_construct():
try
:
try
:
_executor
.
compile
(
net
,
inp
)
_executor
.
compile
(
net
,
inp
)
except
RuntimeError
as
err
:
except
RuntimeError
as
err
:
if
str
(
err
).
find
(
"
u
nsupported syntax 'Raise' at "
)
>=
0
:
if
str
(
err
).
find
(
"
U
nsupported syntax 'Raise' at "
)
>=
0
:
print
(
str
(
err
))
print
(
str
(
err
))
else
:
else
:
raise
err
raise
err
...
@@ -86,7 +86,7 @@ def test_net_with_raise():
...
@@ -86,7 +86,7 @@ def test_net_with_raise():
try
:
try
:
_executor
.
compile
(
net
,
inp
)
_executor
.
compile
(
net
,
inp
)
except
RuntimeError
as
err
:
except
RuntimeError
as
err
:
if
str
(
err
).
find
(
"
u
nsupported syntax 'Raise' at "
)
>=
0
:
if
str
(
err
).
find
(
"
U
nsupported syntax 'Raise' at "
)
>=
0
:
print
(
str
(
err
))
print
(
str
(
err
))
else
:
else
:
raise
err
raise
err
...
...
tests/ut/python/runtest.sh
浏览文件 @
286db9b5
...
@@ -40,12 +40,8 @@ fi
...
@@ -40,12 +40,8 @@ fi
if
[
$#
-gt
0
]
;
then
if
[
$#
-gt
0
]
;
then
pytest
-s
--ignore
=
$1
/pynative_mode
--ignore
=
$1
/parallel
--ignore
=
$1
/train
$IGNORE_EXEC
$1
pytest
-s
--ignore
=
$1
/pynative_mode
--ignore
=
$1
/parallel
--ignore
=
$1
/train
$IGNORE_EXEC
$1
pytest
-n
4
--dist
=
loadfile
-v
$1
/parallel
pytest
-n
4
--dist
=
loadfile
-v
$1
/train
else
else
pytest
--ignore
=
$CURRPATH
/pynative_mode
--ignore
=
$CURRPATH
/parallel
--ignore
=
$CURRPATH
/train
$IGNORE_EXEC
$CURRPATH
pytest
--ignore
=
$CURRPATH
/pynative_mode
--ignore
=
$CURRPATH
/parallel
--ignore
=
$CURRPATH
/train
$IGNORE_EXEC
$CURRPATH
pytest
-n
4
--dist
=
loadfile
-v
$CURRPATH
/parallel
pytest
-n
4
--dist
=
loadfile
-v
$CURRPATH
/train
fi
fi
RET
=
$?
RET
=
$?
...
@@ -57,6 +53,18 @@ if [ ${RET} -ne 0 ]; then
...
@@ -57,6 +53,18 @@ if [ ${RET} -ne 0 ]; then
exit
${
RET
}
exit
${
RET
}
fi
fi
if
[
$#
-gt
0
]
;
then
pytest
-n
4
--dist
=
loadfile
-v
$1
/parallel
$1
/train
else
pytest
-n
4
--dist
=
loadfile
-v
$CURRPATH
/parallel
$CURRPATH
/train
fi
RET
=
$?
if
[
${
RET
}
-ne
0
]
;
then
exit
${
RET
}
fi
if
[
$#
-gt
0
]
;
then
if
[
$#
-gt
0
]
;
then
pytest
-s
$1
/pynative_mode
pytest
-s
$1
/pynative_mode
else
else
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录