Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(interactive): Remove dummy code #3840

Merged
merged 3 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 1 addition & 21 deletions flex/utils/yaml_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include "flex/utils/yaml_utils.h"
#include <fstream>
#include "nlohmann/json.hpp"

namespace gs {
std::vector<std::string> get_yaml_files(const std::string& plugin_dir) {
Expand Down Expand Up @@ -117,27 +118,6 @@ Result<std::string> get_yaml_string_from_yaml_node(const YAML::Node& node) {
}
}

Result<nlohmann::json> read_json_from_file(const std::string& file_path) {
if (!std::filesystem::exists(file_path)) {
return Result<nlohmann::json>(
Status{StatusCode::IOError, "File not exists: " + file_path});
}
// read string from file_path, and parse into json
std::ifstream file(file_path, std::ios::in);
if (!file.is_open()) {
return Result<nlohmann::json>(
Status{StatusCode::IOError, "Failed to open file: " + file_path});
}
std::string json_str((std::istreambuf_iterator<char>(file)),
std::istreambuf_iterator<char>());
file.close();
try {
return nlohmann::json::parse(json_str);
} catch (const nlohmann::json::parse_error& e) {
return Result<nlohmann::json>(Status{StatusCode::InternalError, e.what()});
}
}

Status write_yaml_node_to_yaml_string(const YAML::Node& node,
YAML::Emitter& emitter) {
if (node.IsNull()) {
Expand Down
3 changes: 0 additions & 3 deletions flex/utils/yaml_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include "flex/utils/result.h"

#include "glog/logging.h"
#include "nlohmann/json.hpp"

namespace gs {

Expand All @@ -33,8 +32,6 @@ Result<std::string> get_json_string_from_yaml(const std::string& file_path);

Result<std::string> get_json_string_from_yaml(const YAML::Node& yaml_node);

Result<nlohmann::json> read_json_from_file(const std::string& file_path);

Status write_yaml_node_to_yaml_string(const YAML::Node& node,
YAML::Emitter& emitter);

Expand Down
Loading