fix bug in save

This commit is contained in:
liyong 2021-04-20 10:51:22 +08:00
parent ba5b751418
commit 710b3d2236
2 changed files with 6 additions and 5 deletions

View File

@ -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);

View File

@ -79,20 +79,20 @@ std::vector<std::string> 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;
}