Skip to content

Commit

Permalink
nigiri GTFS-RT debug util (#416)
Browse files Browse the repository at this point in the history
  • Loading branch information
felixguendling authored Dec 3, 2023
1 parent e9b136d commit a3ea1e9
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 4 deletions.
1 change: 1 addition & 0 deletions .github/workflows/unix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ jobs:
BUILDCACHE_LUA_PATH: ${{ github.workspace }}/tools
BUILDCACHE_DIR: ${{ github.workspace }}/.buildcache
BUILDCACHE_MAX_CACHE_SIZE: 1073741824
BUILDCACHE_DEBUG: 1
UBSAN_OPTIONS: halt_on_error=1:abort_on_error=1
ASAN_OPTIONS: alloc_dealloc_mismatch=0
CLICOLOR_FORCE: 1
Expand Down
2 changes: 1 addition & 1 deletion .pkg
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
[nigiri]
[email protected]:motis-project/nigiri.git
branch=master
commit=e8c8f8ed2aa3ff3bf8cd556e7b161ae3ae0b13dc
commit=260eff7fa7751cbf601357f4b8632133a9277733
[osmium]
[email protected]:motis-project/libosmium.git
branch=master
Expand Down
4 changes: 2 additions & 2 deletions .pkg.lock
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
11298868496727142457
15622830898542171340
cista a6218e9cd9da9e1c7a70c1188e2faf9e082b7f1c
zlib fe8e13ffca867612951bc6baf114e5ac8b00f305
boost be5235eb2258d2ec19e32546ab767a62311d9b46
Expand Down Expand Up @@ -29,7 +29,7 @@ abseil-cpp f2b3825f36e37fddd47c5c395096e9b1e99eca12
protobuf 690e03babf0963d3da9615a2dae0891777842719
unordered_dense 4f380fb1d64f1843ca2c993ed39a8342a8747e5d
wyhash 1e012b57fc2227a9e583a57e2eacb3da99816d99
nigiri e8c8f8ed2aa3ff3bf8cd556e7b161ae3ae0b13dc
nigiri 260eff7fa7751cbf601357f4b8632133a9277733
lua 7bb93325b26f84c7e8b51fcbd857361ce7605a1d
luabind 9223568bbcf818ecfb1001d49f567627ee10852a
tbb 2067af88257710d07253761655a802732a32496e
Expand Down
1 change: 1 addition & 0 deletions modules/nigiri/include/motis/nigiri/nigiri.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ struct nigiri : public motis::module::module {
std::vector<std::string> gtfsrt_paths_;
unsigned gtfsrt_update_interval_sec_{60U};
bool gtfsrt_incremental_{false};
bool debug_{false};
};

} // namespace motis::nigiri
11 changes: 10 additions & 1 deletion modules/nigiri/src/nigiri.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "motis/nigiri/nigiri.h"

#include <fstream>

#include "boost/filesystem.hpp"

#include "cista/memory_holder.h"
Expand All @@ -19,6 +21,7 @@
#include "nigiri/rt/create_rt_timetable.h"
#include "nigiri/rt/gtfsrt_update.h"
#include "nigiri/rt/rt_timetable.h"
#include "nigiri/rt/util.h"
#include "nigiri/timetable.h"

#include "motis/core/common/logging.h"
Expand Down Expand Up @@ -137,6 +140,7 @@ nigiri::nigiri() : module("Next Generation Routing", "nigiri") {
"list of GTFS-RT, format: tag|/path/to/file.pb");
param(gtfsrt_incremental_, "gtfsrt_incremental",
"true=incremental updates, false=forget all prev. RT updates");
param(debug_, "debug", "write protobuf JSON files for debugging");
}

nigiri::~nigiri() = default;
Expand Down Expand Up @@ -309,8 +313,13 @@ void nigiri::update_gtfsrt() {
auto const tag = impl_->tags_.get_tag_clean(endpoint.src());
auto stats = n::rt::statistics{};
try {
auto const& body = f->val().body;
if (debug_) {
std::ofstream{fmt::format("{}/{}.json", get_data_directory(), tag)}
<< n::rt::protobuf_to_json(body);
}
stats = n::rt::gtfsrt_update_buf(**impl_->tt_, *rtt, endpoint.src(), tag,
f->val().body);
body);
} catch (std::exception const& e) {
stats.parser_error_ = true;
LOG(logging::error) << "GTFS-RT update error (tag=" << tag << ") "
Expand Down

0 comments on commit a3ea1e9

Please sign in to comment.