Skip to content

Commit

Permalink
Merge pull request #5286 from BOINC/dpa_submit11
Browse files Browse the repository at this point in the history
web, job submission: show progress bar on batch page
  • Loading branch information
AenBleidd authored Jun 23, 2023
2 parents 6b9928c + 8ff9a1f commit ea8585a
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 8 deletions.
16 changes: 16 additions & 0 deletions html/inc/submit_util.inc
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,22 @@ function get_batch_params($batch, $wus) {
return $batch;
}

// get the number of WUs for which we've sent at least 1 instance
// TODO: do this more efficiently (single query)
//
function wus_nsent($wus) {
$n = 0;
foreach ($wus as $wu) {
$res = BoincResult::enum(
sprintf('workunitid=%d and server_state<>%d',
$wu->id, RESULT_SERVER_STATE_UNSENT
)
);
if (count($res) > 0) $n++;
}
return $n;
}

function get_outfile_names($result) {
$names = [];
$xml = "<a>".$result->xml_doc_out."</a>";
Expand Down
58 changes: 50 additions & 8 deletions html/user/submit.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
// You should have received a copy of the GNU Lesser General Public License
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.

// web interface for managing batches
// (e.g. as part of remote job submission).
// Lets you see the status of batches, get their output files,
// abort them, retire them, etc.

require_once("../inc/submit_db.inc");
require_once("../inc/util.inc");
require_once("../inc/result.inc");
Expand Down Expand Up @@ -162,10 +167,6 @@ function show_aborted($batches, $limit, $user, $app) {
//
function fill_in_app_and_user_names(&$batches) {
foreach ($batches as $batch) {
//if ($batch->state < BATCH_STATE_COMPLETE || $batch->fraction_done < 1) {
// $wus = BoincWorkunit::enum("batch = $batch->id");
// $batch = get_batch_params($batch, $wus);
//}
$app = BoincApp::lookup_id($batch->app_id);
if ($app) {
$batch->app_name = $app->name;
Expand Down Expand Up @@ -355,6 +356,45 @@ function handle_batch_stats($user) {
page_tail();
}

// return HTML for a color-coded batch progress bar
// green: successfully completed jobs
// red: failed
// light green: in progress
// light gray: unsent
//
function progress_bar($batch, $wus, $width) {
$w_success = $width*$batch->fraction_done;
$w_fail = $width*$batch->nerror_jobs/$batch->njobs;
$nsuccess = $batch->njobs * $batch->fraction_done;
$nsent = wus_nsent($wus);
$nprog = $nsent - $nsuccess - $batch->nerror_jobs;
$w_prog = $width*$nprog/$batch->njobs;
$nunsent = $batch->njobs-$nsent;
$w_unsent = $width*$nunsent/$batch->njobs;
$x = '<table height=20><tr>';
if ($w_fail) {
$x .= "<td width=$w_fail bgcolor=red></td>";
}
if ($w_success) {
$x .= "<td width=$w_success bgcolor=green></td>";
}
if ($w_prog) {
$x .= "<td width=$w_prog bgcolor=lightgreen></td>";
}
if ($w_unsent) {
$x .= "<td width=$w_unsent bgcolor=lightgray></td>";
}
$x .= "</tr></table>
<strong>
<font color=red>$batch->nerror_jobs fail</font> &middot;
<font color=green>$nsuccess success</font> &middot;
<font color=lightgreen>$nprog in progress</font> &middot;
<font color=lightgray>$nunsent unsent</font>
</strong>
";
return $x;
}

// show the details of an existing batch
//
function handle_query_batch($user) {
Expand All @@ -369,11 +409,13 @@ function handle_query_batch($user) {
row2("name", $batch->name);
row2("application", $app->name);
row2("state", batch_state_string($batch->state));
row2("# jobs", $batch->njobs);
row2("# error jobs", $batch->nerror_jobs);
//row2("# jobs", $batch->njobs);
//row2("# error jobs", $batch->nerror_jobs);
//row2("logical end time", time_str($batch->logical_end_time));
row2("expiration time", time_str($batch->expire_time));
row2("progress", sprintf("%.0f%%", $batch->fraction_done*100));
if ($batch->expire_time) {
row2("expiration time", time_str($batch->expire_time));
}
row2("progress", progress_bar($batch, $wus, 600));
if ($batch->completion_time) {
row2("completed", local_time_str($batch->completion_time));
}
Expand Down

0 comments on commit ea8585a

Please sign in to comment.