Skip to content

Commit

Permalink
feat: log databaseConfig and preprocessingConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasKellerer committed Jul 18, 2023
1 parent b3eb867 commit d2dc58c
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 1 deletion.
18 changes: 18 additions & 0 deletions include/silo/config/database_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#include <string>
#include <vector>

#include <fmt/core.h>

namespace silo::config {

enum class ValueType { STRING, PANGOLINEAGE, DATE, INT, FLOAT };
Expand Down Expand Up @@ -36,4 +38,20 @@ struct DatabaseConfig {
};
} // namespace silo::config

template <>
struct [[maybe_unused]] fmt::formatter<silo::config::DatabaseConfig> : fmt::formatter<std::string> {
[[maybe_unused]] static auto format(
const silo::config::DatabaseConfig& database_config,
format_context& ctx
) -> decltype(ctx.out());
};

template <>
struct [[maybe_unused]] fmt::formatter<silo::config::DatabaseSchema> : fmt::formatter<std::string> {
[[maybe_unused]] static auto format(
const silo::config::DatabaseSchema& database_schema,
format_context& ctx
) -> decltype(ctx.out());
};

#endif // SILO_INCLUDE_SILO_CONFIG_DATABASECONFIG_H_
27 changes: 26 additions & 1 deletion src/silo/config/database_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,29 @@ std::optional<DatabaseMetadata> DatabaseConfig::getMetadata(const std::string& n
return *element;
}

} // namespace silo::config
} // namespace silo::config

[[maybe_unused]] auto fmt::formatter<silo::config::DatabaseConfig>::format(
const silo::config::DatabaseConfig& database_config,
fmt::format_context& ctx
) -> decltype(ctx.out()) {
return format_to(
ctx.out(),
"DatabaseConfig[default_nucleotide_sequence: {}, schema: {}",
database_config.default_nucleotide_sequence,
database_config.schema
);
}

[[maybe_unused]] auto fmt::formatter<silo::config::DatabaseSchema>::format(
const silo::config::DatabaseSchema& database_schema,
fmt::format_context& ctx
) -> decltype(ctx.out()) {
return format_to(
ctx.out(),
"DatabaseSchema[instance_name: {}, primary_key: {}, partition_by: {}]",
database_schema.instance_name,
database_schema.primary_key,
database_schema.partition_by
);
}
2 changes: 2 additions & 0 deletions src/silo/database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,8 @@ void Database::preprocessing(
const config::DatabaseConfig& database_config_
) {
database_config = database_config_;
SPDLOG_DEBUG("preprocessing - using database config: {}", database_config);
SPDLOG_DEBUG("preprocessing - using preprocessing config: {}", preprocessing_config);

SPDLOG_INFO("preprocessing - validate metadata file against config");
preprocessing::MetadataValidator().validateMedataFile(
Expand Down
2 changes: 2 additions & 0 deletions src/silo/preprocessing/metadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
#include <ostream>
#include <string>

#include <spdlog/spdlog.h>
#include <boost/algorithm/string/join.hpp>

#include "silo/preprocessing/preprocessing_exception.h"

namespace silo::preprocessing {

csv::CSVReader buildReader(const std::filesystem::path& metadata_path) {
SPDLOG_INFO("Reading metadata file: {}", metadata_path.string());
try {
csv::CSVFormat format;
format.delimiter('\t');
Expand Down

0 comments on commit d2dc58c

Please sign in to comment.