From 710b3d22362eccd0bab581a0b29d9ce01baf7a10 Mon Sep 17 00:00:00 2001 From: liyong Date: Tue, 20 Apr 2021 10:51:22 +0800 Subject: [PATCH] fix bug in save --- .../minddata/dataset/engine/consumers/tree_consumer.cc | 3 ++- mindspore/ccsrc/minddata/mindrecord/meta/shard_schema.cc | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/mindspore/ccsrc/minddata/dataset/engine/consumers/tree_consumer.cc b/mindspore/ccsrc/minddata/dataset/engine/consumers/tree_consumer.cc index d13ae192bf..541e5c7875 100644 --- a/mindspore/ccsrc/minddata/dataset/engine/consumers/tree_consumer.cc +++ b/mindspore/ccsrc/minddata/dataset/engine/consumers/tree_consumer.cc @@ -181,7 +181,8 @@ Status SaveToDisk::ValidateParams() { MS_LOG(ERROR) << err; RETURN_STATUS_SYNTAX_ERROR(err); } - if (access(dir.ParentPath().c_str(), R_OK) == -1) { + auto parent_path = dir.ParentPath(); + if (!parent_path.empty() && access(common::SafeCStr(parent_path), R_OK) == -1) { std::string err_msg = "CreateSaver failed, no access to specified dataset path: " + dataset_path_; MS_LOG(ERROR) << err_msg; RETURN_STATUS_SYNTAX_ERROR(err_msg); diff --git a/mindspore/ccsrc/minddata/mindrecord/meta/shard_schema.cc b/mindspore/ccsrc/minddata/mindrecord/meta/shard_schema.cc index b9b26e33d1..b6d37bf836 100644 --- a/mindspore/ccsrc/minddata/mindrecord/meta/shard_schema.cc +++ b/mindspore/ccsrc/minddata/mindrecord/meta/shard_schema.cc @@ -79,20 +79,20 @@ std::vector Schema::PopulateBlobFields(json schema) { bool Schema::ValidateNumberShape(const json &it_value) { if (it_value.find("shape") == it_value.end()) { - MS_LOG(ERROR) << "%s supports shape only." << it_value["type"].dump(); + MS_LOG(ERROR) << it_value["type"].dump() << " supports shape only."; return false; } auto shape = it_value["shape"]; if (!shape.is_array()) { - MS_LOG(ERROR) << "%s shape format is wrong." << it_value["type"].dump(); + MS_LOG(ERROR) << "Shape " << it_value["type"].dump() << ", format is wrong."; return false; } int num_negtive_one = 0; for (const auto &i : shape) { if (i == 0 || i < -1) { - MS_LOG(ERROR) << "Shape %s, number is wrong." << it_value["shape"].dump(); + MS_LOG(ERROR) << "Shape " << it_value["shape"].dump() << ", dimension is wrong."; return false; } if (i == -1) { @@ -101,7 +101,7 @@ bool Schema::ValidateNumberShape(const json &it_value) { } if (num_negtive_one > 1) { - MS_LOG(ERROR) << "Shape %s, have at most 1 variable-length dimension." << it_value["shape"].dump(); + MS_LOG(ERROR) << "Shape " << it_value["shape"].dump() << ", have at most 1 variable-length dimension."; return false; }