Skip to content

Commit

Permalink
fix: fmt::format inconsistencies leading to errors in v10
Browse files Browse the repository at this point in the history
  • Loading branch information
Taepper committed Jun 14, 2024
1 parent d927f23 commit b5f7a71
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 37 deletions.
23 changes: 15 additions & 8 deletions include/silo/config/database_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <string_view>
#include <vector>

#include <fmt/core.h>
#include <fmt/format.h>

namespace silo::config {

Expand Down Expand Up @@ -52,32 +52,39 @@ class DatabaseConfigReader {
} // namespace silo::config

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

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

template <>
struct [[maybe_unused]] fmt::formatter<silo::config::DatabaseMetadata>
: fmt::formatter<std::string> {
class [[maybe_unused]] fmt::formatter<silo::config::DatabaseMetadata> {
public:
constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); }
[[maybe_unused]] static auto format(
const silo::config::DatabaseMetadata& database_metadata,
format_context& ctx
) -> decltype(ctx.out());
};

template <>
struct [[maybe_unused]] fmt::formatter<silo::config::ValueType> : fmt::formatter<std::string> {
class [[maybe_unused]] fmt::formatter<silo::config::ValueType> {
public:
constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); }
[[maybe_unused]] static auto format(
const silo::config::ValueType& value_type,
format_context& ctx
Expand Down
2 changes: 1 addition & 1 deletion include/silo/config/preprocessing_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <string_view>
#include <unordered_map>

#include <fmt/core.h>
#include <fmt/format.h>

#include "silo/config/util/abstract_config_source.h"

Expand Down
4 changes: 3 additions & 1 deletion include/silo/database_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ struct DatabaseInfo {
} // namespace silo

template <>
struct [[maybe_unused]] fmt::formatter<silo::DatabaseInfo> : fmt::formatter<std::string> {
class [[maybe_unused]] fmt::formatter<silo::DatabaseInfo> {
public:
constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); }
[[maybe_unused]] static auto format(silo::DatabaseInfo database_info, format_context& ctx)
-> decltype(ctx.out()) {
return fmt::format_to(
Expand Down
2 changes: 1 addition & 1 deletion include/silo/storage/position.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <utility>
#include <vector>

#include <fmt/core.h>
#include <fmt/format.h>
#include <roaring/roaring.hh>

#include "silo/common/aa_symbols.h"
Expand Down
21 changes: 16 additions & 5 deletions include/silo/storage/sequence_store.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
#include <utility>
#include <vector>

#include <fmt/core.h>
#include <fmt/format.h>
#include <roaring/roaring.hh>

#include "silo/common/aa_symbols.h"
#include "silo/common/format_number.h"
#include "silo/common/nucleotide_symbols.h"
#include "silo/common/symbol_map.h"
#include "silo/storage/insertion_index.h"
Expand Down Expand Up @@ -108,9 +109,19 @@ class SequenceStore {
} // namespace silo

template <>
struct [[maybe_unused]] fmt::formatter<silo::SequenceStoreInfo> : fmt::formatter<std::string> {
class [[maybe_unused]] fmt::formatter<silo::SequenceStoreInfo> {
public:
constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); }
[[maybe_unused]] static auto format(
silo::SequenceStoreInfo sequence_store_info,
const silo::SequenceStoreInfo& sequence_store_info,
format_context& ctx
) -> decltype(ctx.out());
};
) -> decltype(ctx.out()) {
return fmt::format_to(
ctx.out(),
"SequenceStoreInfo[sequence count: {}, size: {}, N bitmaps size: {}]",
sequence_store_info.sequence_count,
sequence_store_info.size,
silo::formatNumber(sequence_store_info.n_bitmaps_size)
);
}
};
7 changes: 3 additions & 4 deletions src/silo/config/database_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include <string_view>

#include <fmt/format.h>
#include <spdlog/spdlog.h>
#include <yaml-cpp/yaml.h>

#include "silo/config/util/config_exception.h"
Expand Down Expand Up @@ -69,7 +68,7 @@ struct convert<silo::config::DatabaseConfig> {
config.default_nucleotide_sequence = "main";
}

SPDLOG_TRACE("Resulting database config: {}", config);
// SPDLOG_TRACE(fmt::format("Resulting database config: {}", config));

return true;
}
Expand Down Expand Up @@ -193,13 +192,13 @@ std::optional<DatabaseMetadata> DatabaseConfig::getMetadata(const std::string& n

void DatabaseConfig::writeConfig(const std::filesystem::path& config_path) const {
const YAML::Node node = YAML::convert<DatabaseConfig>::encode(*this);
SPDLOG_DEBUG("Writing database config to {}", config_path.string());
// SPDLOG_DEBUG("Writing database config to {}", config_path.string());
std::ofstream out_file(config_path);
out_file << YAML::Dump(node);
}

DatabaseConfig DatabaseConfigReader::readConfig(const std::filesystem::path& config_path) const {
SPDLOG_INFO("Reading database config from {}", config_path.string());
// SPDLOG_INFO("Reading database config from {}", config_path.string());
try {
return YAML::LoadFile(config_path.string()).as<DatabaseConfig>();
} catch (const YAML::Exception& e) {
Expand Down
2 changes: 1 addition & 1 deletion src/silo/database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include <utility>
#include <vector>

#include <fmt/core.h>
#include <fmt/format.h>
#include <oneapi/tbb/blocked_range.h>
#include <oneapi/tbb/parallel_for.h>
#include <oneapi/tbb/parallel_for_each.h>
Expand Down
1 change: 0 additions & 1 deletion src/silo/query_engine/actions/fasta_aligned.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include <optional>
#include <utility>

#include <fmt/core.h>
#include <fmt/format.h>
#include <oneapi/tbb/blocked_range.h>
#include <oneapi/tbb/parallel_for.h>
Expand Down
1 change: 0 additions & 1 deletion src/silo/query_engine/filter_expressions/bool_equals.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include "silo/query_engine/filter_expressions/bool_equals.h"
#include <fmt/core.h>

#include <utility>

Expand Down
14 changes: 0 additions & 14 deletions src/silo/storage/sequence_store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include <roaring/roaring.hh>

#include "silo/common/aa_symbols.h"
#include "silo/common/format_number.h"
#include "silo/common/nucleotide_symbols.h"
#include "silo/common/string_utils.h"
#include "silo/common/symbol_map.h"
Expand Down Expand Up @@ -129,19 +128,6 @@ void silo::SequenceStorePartition<SymbolType>::finalize() {
);
}

[[maybe_unused]] auto fmt::formatter<silo::SequenceStoreInfo>::format(
silo::SequenceStoreInfo sequence_store_info,
fmt::format_context& ctx
) -> decltype(ctx.out()) {
return fmt::format_to(
ctx.out(),
"SequenceStoreInfo[sequence count: {}, size: {}, N bitmaps size: {}]",
sequence_store_info.sequence_count,
sequence_store_info.size,
silo::formatNumber(sequence_store_info.n_bitmaps_size)
);
}

template <typename SymbolType>
silo::SequenceStoreInfo silo::SequenceStorePartition<SymbolType>::getInfo() const {
size_t n_bitmaps_size = 0;
Expand Down

0 comments on commit b5f7a71

Please sign in to comment.