Skip to content

Commit

Permalink
Allow skipping the taxonomy version check.
Browse files Browse the repository at this point in the history
  • Loading branch information
bredelings committed Oct 3, 2023
1 parent bf0108e commit 56ad959
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion otc/ws/tolws.h
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ std::string phylesystem_conflict_ws_method(const SummaryTree_t & summary,
const std::string& tree1s,
const std::string& tree2s);

bool read_trees(const std::filesystem::path & dirname, TreesToServe & tts);
bool read_trees(const std::filesystem::path & dirname, TreesToServe & tts, const std::string& tax_version_check);

void from_json(const nlohmann::json &j, SourceTreeId & sti);
void to_json(nlohmann::json &j, const SourceTreeId & sti);
Expand Down
18 changes: 12 additions & 6 deletions ws/tolwsbooting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,8 @@ int run_server(const po::variables_map & args) {
tts.set_taxonomy(taxonomy);

// Now load trees
if (!read_trees(topdir, tts)) {
auto tax_version_check = args.at("tax-version-check").as<string>();
if (!read_trees(topdir, tts, tax_version_check)) {
return 2;
}
time_t post_trees_time;
Expand Down Expand Up @@ -997,6 +998,7 @@ po::variables_map parse_cmd_line(int argc, char* argv[]) {
("pidfile,p",value<string>(),"filepath for PID")
("num-threads,n",value<int>(),"number of threads")
("ignore-broken-syn","If passed in, the presence of a synonym mapping to a non-existent ID will just be ignored.")
("tax-version-check",value<string>()->default_value("exact"),"Should we load synth trees built with an older taxonomy: 'exact' or 'no-check'.")
;

options_description visible;
Expand All @@ -1021,13 +1023,14 @@ bool read_tree_and_annotations(const fs::path & configpath,
const fs::path & annotationspath,
const fs::path & brokentaxapath,
const fs::path & contestingtrees_path,
TreesToServe & tts);
TreesToServe & tts,
const string& tax_version_check);

// Globals. TODO: lock if we read twice
fp_set checked_dirs;
fp_set known_tree_dirs;

bool read_trees(const fs::path & dirname, TreesToServe & tts) {
bool read_trees(const fs::path & dirname, TreesToServe & tts, const string& tax_version_check) {
auto [is_dir, subdir_set] = get_subdirs(dirname);
if (not is_dir) {
return false;
Expand Down Expand Up @@ -1057,7 +1060,7 @@ bool read_trees(const fs::path & dirname, TreesToServe & tts) {

try
{
if (read_tree_and_annotations(configpath, treepath, annotationspath, brokentaxapath, contestingtrees_path, tts))
if (read_tree_and_annotations(configpath, treepath, annotationspath, brokentaxapath, contestingtrees_path, tts, tax_version_check))
known_tree_dirs.insert(p);
}
catch (const std::exception & x)
Expand Down Expand Up @@ -1191,7 +1194,8 @@ bool read_tree_and_annotations(const fs::path & config_path,
const fs::path & annotations_path,
const fs::path & brokentaxa_path,
const fs::path & contestingtrees_path,
TreesToServe & tts)
TreesToServe & tts,
const string& tax_version_check)
{
auto locked_taxonomy = tts.get_readable_taxonomy();
const auto & taxonomy = locked_taxonomy.first;
Expand All @@ -1215,7 +1219,9 @@ bool read_tree_and_annotations(const fs::path & config_path,
// So, MTH is relaxing the checking of the OTT verstion string to allow version + "modified" as a prefix to count as a match
auto taxv = taxonomy.get_version();
auto ttaxvm = tree_tax_version + "modified";
if (!lcase_match_prefix(taxv, ttaxvm)) {

// FIXME! We should really have an "or-newer" option, but that requires parsing and comparing versions.
if (!lcase_match_prefix(taxv, ttaxvm) and tax_version_check == "exact") {
LOG(WARNING) << "Read \"" << annotations_path << "\" as JSON.\n";
throw OTCError()<<"Tree with <synth_id='"<<synth_id<<"',taxonomy_version='"<<tree_tax_version<<"'> does not match taxonomy version '"<<taxonomy.get_version()<<"' (= or modified)";
}
Expand Down

0 comments on commit 56ad959

Please sign in to comment.