DatabaseCampaign: use more flexible get_variants()
This change allows DatabaseCampaign users to take advantage of the improved variant selection methods in the Database class (multiple uses of --variant/--benchmark possible, plus --exclude-variant/--exclude-benchmark switches). Change-Id: Idb1ca04538ff7601b3648cd9ba766aa8690fff6b
This commit is contained in:
@ -1,3 +1,5 @@
|
|||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "DatabaseCampaign.hpp"
|
#include "DatabaseCampaign.hpp"
|
||||||
#include "cpn/CampaignManager.hpp"
|
#include "cpn/CampaignManager.hpp"
|
||||||
#include "util/CommandLine.hpp"
|
#include "util/CommandLine.hpp"
|
||||||
@ -28,12 +30,21 @@ bool DatabaseCampaign::run() {
|
|||||||
line interface */
|
line interface */
|
||||||
if (!cb_commandline_init()) return false;
|
if (!cb_commandline_init()) return false;
|
||||||
|
|
||||||
CommandLine::option_handle VARIANT = cmd.addOption("v", "variant", Arg::Required,
|
CommandLine::option_handle VARIANT =
|
||||||
"-v/--variant \tVariant label (default: \"%\"; use % and _ as wildcard characters)");
|
cmd.addOption("v", "variant", Arg::Required,
|
||||||
CommandLine::option_handle BENCHMARK = cmd.addOption("b", "benchmark", Arg::Required,
|
"-v/--variant \tVariant label (default: \"%\"; use % and _ as wildcard characters; may be used more than once)");
|
||||||
"-b/--benchmark \tBenchmark label (default: \"%\"; use % and _ as wildcard characters)\n");
|
CommandLine::option_handle VARIANT_EXCLUDE =
|
||||||
CommandLine::option_handle PRUNER = cmd.addOption("p", "prune-method", Arg::Required,
|
cmd.addOption("", "variant-exclude", Arg::Required,
|
||||||
"-p/--prune-method \tWhich import method to use (default: basic)");
|
"--variant-exclude \tVariant to exclude (default: UNSET; use % and _ as wildcard characters; may be used more than once)");
|
||||||
|
CommandLine::option_handle BENCHMARK =
|
||||||
|
cmd.addOption("b", "benchmark", Arg::Required,
|
||||||
|
"-b/--benchmark \tBenchmark label (default: \"%\"; use % and _ as wildcard characters; may be used more than once)");
|
||||||
|
CommandLine::option_handle BENCHMARK_EXCLUDE =
|
||||||
|
cmd.addOption("", "benchmark-exclude", Arg::Required,
|
||||||
|
"--benchmark-exclude \tBenchmark to exclude (default: UNSET; use % and _ as wildcard characters; may be used more than once)");
|
||||||
|
CommandLine::option_handle PRUNER =
|
||||||
|
cmd.addOption("p", "prune-method", Arg::Required,
|
||||||
|
"-p/--prune-method \tWhich import method to use (default: basic)");
|
||||||
|
|
||||||
if (!cmd.parse()) {
|
if (!cmd.parse()) {
|
||||||
log_send << "Error parsing arguments." << std::endl;
|
log_send << "Error parsing arguments." << std::endl;
|
||||||
@ -45,25 +56,49 @@ bool DatabaseCampaign::run() {
|
|||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string variant, benchmark, pruner;
|
std::vector<std::string> variants, benchmarks, variants_exclude, benchmarks_exclude;
|
||||||
|
if (cmd[VARIANT]) {
|
||||||
|
for (option::Option *o = cmd[VARIANT]; o; o = o->next()) {
|
||||||
|
variants.push_back(std::string(o->arg));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (cmd[VARIANT].count() > 0)
|
if (cmd[VARIANT_EXCLUDE]) {
|
||||||
variant = std::string(cmd[VARIANT].first()->arg);
|
for (option::Option *o = cmd[VARIANT_EXCLUDE]; o; o = o->next()) {
|
||||||
else
|
variants_exclude.push_back(std::string(o->arg));
|
||||||
variant = "%";
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (cmd[BENCHMARK].count() > 0)
|
// fallback
|
||||||
benchmark = std::string(cmd[BENCHMARK].first()->arg);
|
if (variants.size() == 0) {
|
||||||
else
|
variants.push_back("%");
|
||||||
benchmark = "%";
|
}
|
||||||
|
|
||||||
if (cmd[PRUNER].count() > 0)
|
if (cmd[BENCHMARK]) {
|
||||||
|
for (option::Option *o = cmd[BENCHMARK]; o; o = o->next()) {
|
||||||
|
benchmarks.push_back(std::string(o->arg));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cmd[BENCHMARK_EXCLUDE]) {
|
||||||
|
for (option::Option *o = cmd[BENCHMARK_EXCLUDE]; o; o = o->next()) {
|
||||||
|
benchmarks_exclude.push_back(std::string(o->arg));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// fallback
|
||||||
|
if (benchmarks.size() == 0) {
|
||||||
|
benchmarks.push_back("%");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string pruner;
|
||||||
|
if (cmd[PRUNER]) {
|
||||||
pruner = std::string(cmd[PRUNER].first()->arg);
|
pruner = std::string(cmd[PRUNER].first()->arg);
|
||||||
else
|
} else {
|
||||||
pruner = "basic";
|
pruner = "basic";
|
||||||
|
}
|
||||||
|
|
||||||
db = Database::cmdline_connect();
|
db = Database::cmdline_connect();
|
||||||
log_send << "Variant to use " << variant << "/" << benchmark << std::endl;
|
|
||||||
fspmethod_id = db->get_fspmethod_id(pruner);
|
fspmethod_id = db->get_fspmethod_id(pruner);
|
||||||
log_send << "Pruner to use " << pruner << " (ID: " << fspmethod_id << ")" << std::endl;
|
log_send << "Pruner to use " << pruner << " (ID: " << fspmethod_id << ")" << std::endl;
|
||||||
|
|
||||||
@ -81,9 +116,10 @@ bool DatabaseCampaign::run() {
|
|||||||
|
|
||||||
load_completed_pilots();
|
load_completed_pilots();
|
||||||
|
|
||||||
std::vector<Database::Variant> variants = db->get_variants(variant, benchmark);
|
std::vector<Database::Variant> variantlist =
|
||||||
for (std::vector<Database::Variant>::const_iterator it = variants.begin();
|
db->get_variants(variants, variants_exclude, benchmarks, benchmarks_exclude);
|
||||||
it != variants.end(); ++it) {
|
for (std::vector<Database::Variant>::const_iterator it = variantlist.begin();
|
||||||
|
it != variantlist.end(); ++it) {
|
||||||
if (!run_variant(*it)) {
|
if (!run_variant(*it)) {
|
||||||
log_send << "run_variant failed for " << it->variant << "/" << it->benchmark <<std::endl;
|
log_send << "run_variant failed for " << it->variant << "/" << it->benchmark <<std::endl;
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user