<commit_before>var sprintf=require("sprintf-js").sprintf;
var _ = require("underscore-node");
var bus = require("hermes-bus");

function reportTasks(tasks) {
	console.log('\033[2J'); // clear console (ANSI terminal/VT100)
	console.log("Tasks:");
	console.log("           Test Name              |    Status    |   Worker Id    | Completed? |Retry| Report");
	console.log(tasks.map(function(task) {
		var taskCopy = {
			name:		task.name.substr(-30),
			status:		task.status,
			completed:	task.completed ? "Completed" : "",
			workerId:	task.workerId,
			numRecoveryRunsLeft: 3-(task.numRecoveryRunsLeft || 3),
			report:		JSON.stringify(_.pick(task.report, "fail", "error", "total")),
		};
		taskCopy.name = task.name.substr(-30);
		return sprintf("   %(name)30s | %(status)12s | %(workerId)14s | %(completed)10s | %(numRecoveryRunsLeft)3s | %(report)s", taskCopy);
	}).join("\n"));
	console.log("");
}

bus.on("tasksUpdated", reportTasks);

bus.on("scheduleTasks", function(tasks) {
	reportTasks(tasks);
});<commit_msg>tasks-status-stdout.js: Now properly reports the number of retries<commit_after>var sprintf=require("sprintf-js").sprintf;
var _ = require("underscore-node");
var bus = require("hermes-bus");

function orElse(a, b) {
	return a != undefined ? a : b;
}

function reportTasks(tasks) {
	console.log('\033[2J'); // clear console (ANSI terminal/VT100)
	console.log("Tasks:");
	console.log("           Test Name              |    Status    |   Worker Id    | Completed? |Retry| Report");
	console.log(tasks.map(function(task) {
		var taskCopy = {
			name:		task.name.substr(-30),
			status:		task.status,
			completed:	task.completed ? "Completed" : "",
			workerId:	task.workerId,
			numRecoveryRunsLeft: 3-orElse(task.numRecoveryRunsLeft, 3),
			report:		JSON.stringify(_.pick(task.report, "fail", "error", "total")),
		};
		taskCopy.name = task.name.substr(-30);
		return sprintf("   %(name)30s | %(status)12s | %(workerId)14s | %(completed)10s | %(numRecoveryRunsLeft)3s | %(report)s", taskCopy);
	}).join("\n"));
	console.log("");
}

bus.on("tasksUpdated", reportTasks);

bus.on("scheduleTasks", function(tasks) {
	reportTasks(tasks);
});
{'fraction_non_alphanumeric': 0.1859925788497217, 'fraction_numerical': 0.02040816326530612, 'mean_word_length': 4.2227602905569, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2730842', 'n_tokens_mistral': 817, 'n_tokens_neox': 760, 'n_words': 139}