forked from mindspore-Ecosystem/mindspore
fix minddata directory path problem
This commit is contained in:
parent
ff0103f5ff
commit
e0148f7181
|
@ -260,6 +260,10 @@ Status Tensor::CreateFromByteList(const dataengine::BytesList &bytes_list, const
|
|||
#endif
|
||||
|
||||
Status Tensor::CreateFromFile(const std::string &path, std::shared_ptr<Tensor> *out) {
|
||||
Path file(path);
|
||||
if (file.IsDirectory()) {
|
||||
RETURN_STATUS_UNEXPECTED("Invalid file found: " + path + ", should be file, but got directory.");
|
||||
}
|
||||
std::ifstream fs;
|
||||
fs.open(path, std::ios::binary | std::ios::in);
|
||||
CHECK_FAIL_RETURN_UNEXPECTED(!fs.fail(), "Fail to open file: " + path);
|
||||
|
|
|
@ -759,6 +759,15 @@ def test_imagefolder_exception():
|
|||
except RuntimeError as e:
|
||||
assert "map operation: [PyFunc] failed. The corresponding data files" in str(e)
|
||||
|
||||
data_dir_invalid = "../data/dataset/testPK"
|
||||
try:
|
||||
data = ds.ImageFolderDataset(data_dir_invalid)
|
||||
for _ in data.__iter__():
|
||||
pass
|
||||
assert False
|
||||
except RuntimeError as e:
|
||||
assert "should be file, but got directory" in str(e)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
test_imagefolder_basic()
|
||||
|
|
Loading…
Reference in New Issue