-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: make SILO Docker image by default read data from /data
- Loading branch information
1 parent
44327b0
commit e83b910
Showing
9 changed files
with
97 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
dataDirectory: /data/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#ifndef SILO_RUNTIME_CONFIG_H | ||
#define SILO_RUNTIME_CONFIG_H | ||
|
||
#include <filesystem> | ||
#include <optional> | ||
|
||
namespace silo_api { | ||
|
||
struct RuntimeConfig { | ||
std::optional<std::filesystem::path> data_directory; | ||
|
||
static RuntimeConfig readFromFile(const std::filesystem::path& config_path); | ||
}; | ||
|
||
} // namespace silo_api | ||
|
||
#endif // SILO_RUNTIME_CONFIG_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#include "silo_api/runtime_config.h" | ||
|
||
#include <spdlog/spdlog.h> | ||
#include <yaml-cpp/yaml.h> | ||
|
||
namespace YAML { | ||
|
||
template <> | ||
struct convert<silo_api::RuntimeConfig> { | ||
static bool decode(const Node& node, silo_api::RuntimeConfig& config) { | ||
config = silo_api::RuntimeConfig( | ||
node["dataDirectory"] | ||
? std::optional<std::filesystem::path>(node["dataDirectory"].as<std::string>()) | ||
: std::nullopt | ||
); | ||
|
||
return true; | ||
} | ||
}; | ||
|
||
} // namespace YAML | ||
|
||
namespace silo_api { | ||
|
||
RuntimeConfig RuntimeConfig::readFromFile(const std::filesystem::path& config_path) { | ||
SPDLOG_INFO("Reading runtime config from {}", config_path.string()); | ||
return YAML::LoadFile(config_path.string()).as<RuntimeConfig>(); | ||
} | ||
|
||
} // namespace silo_api |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#include "silo_api/runtime_config.h" | ||
|
||
#include <gtest/gtest.h> | ||
|
||
TEST(RuntimeConfig, shouldReadConfig) { | ||
const auto result = | ||
silo_api::RuntimeConfig::readFromFile("./testBaseData/test_runtime_config.yaml"); | ||
|
||
ASSERT_EQ(result.data_directory, std::filesystem::path("test/directory")); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
dataDirectory: test/directory |