add dependency check to task fetch (and add debug prints)

This commit is contained in:
Fabian Posch 2024-01-16 18:05:23 -05:00
parent e9436919ad
commit 9fbcd52e16

View file

@ -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<DBSimConfigArtifact>(id, source_pass, target_artifact, design, source_config);
task->add_testcase(testcase);