[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to disable importing #492

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Allow to disable importing
  • Loading branch information
jbruechert committed Apr 23, 2024
commit 7367d32e18dec5364f77d52bd7bd678444272610
5 changes: 4 additions & 1 deletion base/bootstrap/include/motis/bootstrap/import_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ struct import_settings : conf::configuration {
param(data_directory_, "data_dir", "directory for preprocessing output");
param(require_successful_, "require_successful",
"exit if import is not successful for all modules");
param(disabled_, "disabled",
"Always use the existing files in data/ without checking");
}

import_settings(import_settings const&) = delete;
Expand All @@ -28,6 +30,7 @@ struct import_settings : conf::configuration {
std::vector<std::string> import_paths_;
std::string data_directory_{"data"};
bool require_successful_{true};
bool disabled_{false};
};

} // namespace motis::bootstrap
} // namespace motis::bootstrap
40 changes: 22 additions & 18 deletions base/bootstrap/src/motis_instance.cc
Original file line number Diff line number Diff line change
Expand Up @@ -86,31 +86,35 @@ void motis_instance::import(module_settings const& module_opt,
}
}

// Dummy message to trigger initial progress updates.
dispatcher.publish(make_success_msg("/import"));
dispatcher.run();

// Paths as actual trigger for import processing.
dispatcher.publish(make_file_event(import_opt.import_paths_));
dispatcher.run();
if (!import_opt.disabled_) {
// Dummy message to trigger initial progress updates.
dispatcher.publish(make_success_msg("/import"));
dispatcher.run();

// Paths as actual trigger for import processing.
dispatcher.publish(make_file_event(import_opt.import_paths_));
dispatcher.run();
}

registry_.reset();

utl::verify(
dataset_opt.no_schedule_ || includes(to_res_id(global_res_id::SCHEDULE)),
"schedule not loaded");

if (import_opt.require_successful_) {
auto const unsuccessful_imports =
utl::all(modules_) //
| utl::remove_if([&](auto&& m) {
return !module_opt.is_module_active(m->module_name()) ||
m->import_successful();
}) //
| utl::transform([&](auto&& m) { return m->module_name(); }) //
| utl::vec();
utl::verify(unsuccessful_imports.empty(),
"some imports were not successful: {}", unsuccessful_imports);
if (!import_opt.disabled_) {
if (import_opt.require_successful_) {
auto const unsuccessful_imports =
utl::all(modules_) //
| utl::remove_if([&](auto&& m) {
return !module_opt.is_module_active(m->module_name()) ||
m->import_successful();
}) //
| utl::transform([&](auto&& m) { return m->module_name(); }) //
| utl::vec();
utl::verify(unsuccessful_imports.empty(),
"some imports were not successful: {}", unsuccessful_imports);
}
}
}

Expand Down
Loading