From 9fbcd52e162c145ce107b8c921b85a4a717862ff Mon Sep 17 00:00:00 2001 From: Fabian Posch Date: Tue, 16 Jan 2024 18:05:23 -0500 Subject: [PATCH] add dependency check to task fetch (and add debug prints) --- src/actsim_agent/downloader.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/actsim_agent/downloader.cpp b/src/actsim_agent/downloader.cpp index d2709e4..8f5fcca 100644 --- a/src/actsim_agent/downloader.cpp +++ b/src/actsim_agent/downloader.cpp @@ -110,6 +110,7 @@ bool Downloader::fetch_tasks(size_t n) { // 1.) It has not been started yet or the output row doesn't exist // 2.) Passes that are already in progress are preferred // 3.) New passes are started in the order they were added to the database + // 4.) Passes are only started if all their dependencies are fulfilled pqxx::row res = txn->exec1( "SELECT " " ap.design_file AS design, " @@ -128,7 +129,18 @@ bool Downloader::fetch_tasks(size_t n) { "JOIN " " jobs j ON ap.job = j.id " "WHERE " - " so.id IS NULL OR so.part_status = 'not_started' " + " (so.id IS NULL OR so.part_status = 'not_started') " + " AND ap.id IN ( " + " SELECT ap_dep.id " + " FROM actsim_passes ap_dep " + " JOIN passes p ON ap_dep.id = p.id " + " WHERE NOT EXISTS ( " + " SELECT 1 " + " FROM passes dep " + " WHERE dep.id = ANY(p.depends_on) " + " AND dep.pass_status != 'finished' " + " ) " + " ) " "ORDER BY " " ap.pass_status = 'in_progress' DESC, " " j.time_added ASC " @@ -224,6 +236,8 @@ bool Downloader::fetch_tasks(size_t n) { return false; } + DEBUG_PRINT("Fetched task with id " + db::to_string(id) + ", stemming from pass " + db::to_string(source_pass) + ", outputting to artifact " + db::to_string(target_artifact)); + DEBUG_PRINT("Design used is " + db::to_string(design) + ", simulation config " + db::to_string(source_config)); auto task = std::make_unique(id, source_pass, target_artifact, design, source_config); task->add_testcase(testcase);