diff --git a/include/faabric/batch-scheduler/SchedulingDecision.h b/include/faabric/batch-scheduler/SchedulingDecision.h index d28475a10..5a1da6745 100644 --- a/include/faabric/batch-scheduler/SchedulingDecision.h +++ b/include/faabric/batch-scheduler/SchedulingDecision.h @@ -100,6 +100,8 @@ class SchedulingDecision int32_t groupIdx); std::set uniqueHosts(); + + void print(); }; } diff --git a/src/batch-scheduler/SchedulingDecision.cpp b/src/batch-scheduler/SchedulingDecision.cpp index d98e41b1e..4467732e3 100644 --- a/src/batch-scheduler/SchedulingDecision.cpp +++ b/src/batch-scheduler/SchedulingDecision.cpp @@ -1,5 +1,6 @@ #include #include +#include namespace faabric::batch_scheduler { @@ -57,4 +58,22 @@ std::set SchedulingDecision::uniqueHosts() { return std::set(hosts.begin(), hosts.end()); } + +void SchedulingDecision::print() +{ + SPDLOG_DEBUG("-------------- Decision for App: {} ----------------", appId); + SPDLOG_DEBUG("MsgId\tAppId\tGroupId\tGrIdx\tHostIp"); + // Modulo a big number so that we can get the UUIDs to fit within one tab + int formatBase = 1e6; + for (int i = 0; i < hosts.size(); i++) { + SPDLOG_DEBUG("{}\t{}\t{}\t{}\t{}", + messageIds.at(i) % formatBase, + appId % formatBase, + groupId % formatBase, + groupIdxs.at(i), + hosts.at(i)); + } + SPDLOG_DEBUG("------------- End Decision for App {} ---------------", + appId); +} } diff --git a/tests/test/batch-scheduler/test_scheduling_decisions.cpp b/tests/test/batch-scheduler/test_scheduling_decisions.cpp index fe8ddb5c6..e36694812 100644 --- a/tests/test/batch-scheduler/test_scheduling_decisions.cpp +++ b/tests/test/batch-scheduler/test_scheduling_decisions.cpp @@ -88,6 +88,9 @@ TEST_CASE_METHOD(ConfFixture, "Test building scheduling decisions", "[util]") REQUIRE(newDecision == decision); newDecision.groupId = 1338; REQUIRE(newDecision != decision); + + // We can print scheduling decisions + REQUIRE_NOTHROW(decision.print()); } TEST_CASE("Test converting point-to-point mappings to scheduling decisions",