!18665 delete GetEnvConfigFile func as it no longer used

Merge pull request !18665 from ms_yan/del_GetEnvConfigFile
This commit is contained in:
i-robot 2021-06-22 01:45:59 +00:00 committed by Gitee
commit 8e742a5bf7
2 changed files with 0 additions and 26 deletions

View File

@ -20,7 +20,6 @@
#include <iomanip>
#include <optional>
#include <fstream>
#include "utils/ms_context.h"
#include "utils/system/env.h"
#include "utils/system/file_system.h"
#include "utils/log_adapter.h"
@ -146,30 +145,6 @@ std::optional<std::string> Common::GetConfigFile(const std::string &env) {
return dump_config_file;
}
std::optional<std::string> Common::GetEnvConfigFile() {
auto context = MsContext::GetInstance();
MS_EXCEPTION_IF_NULL(context);
std::string env_config_path = context->get_param<std::string>(MS_CTX_ENV_CONFIG_PATH);
if (env_config_path.empty()) {
MS_LOG(INFO) << "The env_config_path is not set in context.";
return {};
}
MS_LOG(INFO) << "Get env_config_path: " << env_config_path;
std::string config_file(env_config_path);
std::shared_ptr<system::FileSystem> fs = system::Env::GetFileSystem();
MS_EXCEPTION_IF_NULL(fs);
if (!fs->FileExist(config_file)) {
MS_LOG(ERROR) << config_file << " not exist.";
return {};
}
auto point_pos = config_file.find_last_of('.');
if (point_pos == std::string::npos) {
MS_LOG(EXCEPTION) << "Invalid json file name:" << config_file;
}
return config_file;
}
bool Common::IsStrLengthValid(const std::string &str, size_t length_limit, const std::string &error_message) {
auto len_str = str.length();
if (len_str > length_limit) {

View File

@ -31,7 +31,6 @@ class Common {
~Common() = default;
static std::optional<std::string> GetRealPath(const std::string &input_path);
static std::optional<std::string> GetConfigFile(const std::string &env);
static std::optional<std::string> GetEnvConfigFile();
static bool IsStrLengthValid(const std::string &str, size_t length_limit, const std::string &error_message = "");
static bool IsPathValid(const std::string &path, size_t length_limit, const std::string &error_message = "");
static bool IsFilenameValid(const std::string &filename, size_t length_limit, const std::string &error_message = "");