Skip to content

Commit 0e4b590

Browse files
- improve batch page
correctly show # of in progress, error, done, unsent jobs fraction done is frac of success jobs - Add 'verbose' checkbox for BUDA job submit. docker_wrapper prints stuff to stderr (can view on result page) - fix bugs in non-BUDA submit pages
1 parent d44bb95 commit 0e4b590

File tree

9 files changed

+157
-94
lines changed

9 files changed

+157
-94
lines changed

html/inc/bootstrap.inc

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -500,8 +500,14 @@ function form_submit($text, $attrs='') {
500500
function form_checkbox($label, $name, $checked=false) {
501501
echo sprintf('
502502
<div class="form-group">
503-
<input type="checkbox" name="%s" %s> &nbsp; <span class="lead">%s</span>
503+
<label align=right class="%s">%s</label>
504+
<div class="%s">
505+
',
506+
FORM_LEFT_CLASS, $label, FORM_RIGHT_CLASS
507+
);
508+
echo sprintf('
509+
<input type="checkbox" name="%s" %s>
504510
</div>
505-
', $name, $checked?"checked":"", $label
511+
', $name, $checked?"checked":""
506512
);
507513
}

html/inc/submit_util.inc

Lines changed: 49 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ function has_submit_access($user, $app_id) {
7878
function has_admin_access($user, $app_id) {
7979
$us = BoincUserSubmit::lookup_userid($user->id);
8080
if (!$us) return false;
81-
if ($us->admin_all) return true;
81+
if ($us->manage_all) return true;
8282
$usa = BoincUserSubmitApp::lookup("user_id=$user->id and app_id=$app_id");
8383
if (!$usa) return false;
8484
return $usa->manage;
@@ -126,11 +126,23 @@ function delete_remote_submit_user($user) {
126126
BoincUserSubmitApp::delete_user($user->id);
127127
}
128128

129-
130-
// given its WUs, compute progress of a batch
131-
// (fraction done, est completion time etc.)
132-
// NOTE: this is inefficient because we need all the WUs.
133-
// it could be done by server components
129+
// given its WUs, compute parameters of a batch:
130+
// credit_canonical: credit granted to canonical instances
131+
// fraction_done: frac of jobs that are done (success or failed)
132+
// state: whether complete (all jobs done)
133+
// completion_time: if newly complete
134+
// nerror_jobs: # of failed jobs
135+
// Update the above in DB.
136+
// Also compute (not in DB):
137+
// njobs_success: # of jobs with canonical instance
138+
// njobs_in_prog: # of jobs not success or fail,
139+
// and at least one result in progress
140+
//
141+
// return the batch object, with these values
142+
//
143+
// NOTE: this involves reading the batch's WUs and results,
144+
// which could be inefficient for huge batches.
145+
// It could instead be done by server components
134146
// (transitioner, validator etc.) as jobs complete or time out
135147
//
136148
// TODO: update est_completion_time
@@ -141,51 +153,61 @@ function get_batch_params($batch, $wus) {
141153
//
142154
return $batch;
143155
}
156+
if (!$wus) {
157+
if ($batch->njobs) {
158+
$batch->update('njobs=0');
159+
$batch->njobs = 0;
160+
}
161+
return $batch;
162+
}
163+
164+
// make list of WU IDs with an in-progress result
165+
$res_in_prog = BoincResult::enum(
166+
sprintf('batch=%d and server_state<>%d',
167+
$batch->id, RESULT_SERVER_STATE_IN_PROGRESS
168+
)
169+
);
170+
$wus_in_prog = [];
171+
foreach ($res_in_prog as $res) {
172+
$wus_in_prog[$res->workunitid] = true;
173+
}
174+
144175
$fp_total = 0;
145176
$fp_done = 0;
146177
$completed = true;
147178
$batch->nerror_jobs = 0;
148179
$batch->credit_canonical = 0;
180+
$njobs_success = 0;
181+
$njobs_in_prog = 0;
149182
foreach ($wus as $wu) {
150183
$fp_total += $wu->rsc_fpops_est;
151184
if ($wu->canonical_resultid) {
152185
$fp_done += $wu->rsc_fpops_est;
186+
$njobs_success++;
153187
$batch->credit_canonical += $wu->canonical_credit;
154188
} else if ($wu->error_mask) {
155189
$batch->nerror_jobs++;
156190
} else {
157191
$completed = false;
192+
if (array_key_exists($wu->id, $wus_in_prog)) {
193+
$njobs_in_prog++;
194+
}
158195
}
159196
}
160-
if ($fp_total) {
161-
$batch->fraction_done = $fp_done / $fp_total;
162-
}
197+
$njobs = count($wus);
198+
$batch->njobs = $njobs;
199+
$batch->fraction_done = ($njobs_success + $batch->nerror_jobs)/$batch->njobs;
163200
if ($completed && $batch->state == BATCH_STATE_IN_PROGRESS) {
164201
$batch->state = BATCH_STATE_COMPLETE;
165202
$batch->completion_time = time();
166203
}
167-
$batch->update("fraction_done = $batch->fraction_done, nerror_jobs = $batch->nerror_jobs, state=$batch->state, completion_time = $batch->completion_time, credit_canonical = $batch->credit_canonical");
204+
$batch->update("fraction_done = $batch->fraction_done, nerror_jobs = $batch->nerror_jobs, state=$batch->state, completion_time = $batch->completion_time, credit_canonical = $batch->credit_canonical, njobs=$njobs");
168205

169-
$batch->credit_estimate = flops_to_credit($fp_total);
206+
$batch->njobs_success = $njobs_success;
207+
$batch->njobs_in_prog = $njobs_in_prog;
170208
return $batch;
171209
}
172210

173-
// get the number of WUs for which we've sent at least 1 instance
174-
// TODO: do this more efficiently (single query)
175-
//
176-
function wus_nsent($wus) {
177-
$n = 0;
178-
foreach ($wus as $wu) {
179-
$res = BoincResult::enum(
180-
sprintf('workunitid=%d and server_state<>%d',
181-
$wu->id, RESULT_SERVER_STATE_UNSENT
182-
)
183-
);
184-
if (count($res) > 0) $n++;
185-
}
186-
return $n;
187-
}
188-
189211
// get the physical names of a result's output files.
190212
//
191213
function get_outfile_phys_names($result) {

html/user/buda_submit.php

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,22 @@ function submit_form($user) {
3535
if (!is_valid_filename($variant)) die('bad arg');
3636

3737
$desc = "<br><small>
38-
A zipped directory with one subdirectory per job,
39-
containing the input file(s) for that job
38+
A zip file with one directory per job.
39+
Each directory contains the input file(s) for that job
4040
and an optional file <code>cmdline</code>
4141
containing command-line arguments.
4242
<a href=https://github.com/BOINC/boinc/wiki/BUDA-job-submission>Details</a></small>.
4343
";
44+
$desc2 = "<br><small>
45+
Write Docker commands and output to stderr (for debugging).
46+
";
4447
page_head("Submit jobs to $app ($variant)");
4548
form_start('buda_submit.php');
4649
form_input_hidden('action', 'submit');
4750
form_input_hidden('app', $app);
4851
form_input_hidden('variant', $variant);
4952
form_select("Batch zip file $desc", 'batch_file', $sbitems_zip);
53+
form_checkbox("Verbose Docker output? $desc2", 'wrapper_verbose');
5054
form_submit('OK');
5155
form_end();
5256
page_tail();
@@ -179,7 +183,7 @@ function stage_input_files($batch_dir, $batch_desc, $batch_id) {
179183
}
180184

181185
function create_jobs(
182-
$variant_desc, $batch_desc, $batch_id, $batch_dir_name
186+
$variant_desc, $batch_desc, $batch_id, $batch_dir_name, $wrapper_verbose
183187
) {
184188
global $buda_app;
185189

@@ -205,8 +209,10 @@ function create_jobs(
205209
$job_cmds .= "$job_cmd\n";
206210
}
207211
$cmd = sprintf(
208-
'cd ../..; bin/create_work --appname %s --batch %d --stdin --command_line "--dockerfile %s --verbose" --wu_template %s --result_template %s',
209-
$buda_app->name, $batch_id, $variant_desc->dockerfile,
212+
'cd ../..; bin/create_work --appname %s --batch %d --stdin --command_line "--dockerfile %s %s" --wu_template %s --result_template %s',
213+
$buda_app->name, $batch_id,
214+
$variant_desc->dockerfile,
215+
$wrapper_verbose?'--verbose':'',
210216
"buda_batches/$batch_dir_name/template_in",
211217
"buda_batches/$batch_dir_name/template_out"
212218
);
@@ -307,6 +313,7 @@ function handle_submit($user) {
307313
if (!is_valid_filename($variant)) die('bad arg');
308314
$batch_file = get_str('batch_file');
309315
if (!is_valid_filename($batch_file)) die('bad arg');
316+
$wrapper_verbose = get_str('wrapper_verbose', true);
310317

311318
$variant_dir = "../../buda_apps/$app/$variant";
312319
$variant_desc = json_decode(
@@ -331,7 +338,8 @@ function handle_submit($user) {
331338
stage_input_files($batch_dir, $batch_desc, $batch->id);
332339

333340
create_jobs(
334-
$variant_desc, $batch_desc, $batch->id, $batch_dir_name
341+
$variant_desc, $batch_desc, $batch->id, $batch_dir_name,
342+
$wrapper_verbose
335343
);
336344

337345
// mark batch as in progress

html/user/get_output.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ function get_output_file($instance_name, $file_num, $auth_str) {
5252
return_error("bad authenticator");
5353
}
5454

55-
$names = get_outfile_names($result);
55+
$names = get_outfile_phys_names($result);
5656
if ($file_num >= count($names)) {
5757
return_error("bad file num: $file_num > ".count($names));
5858
}
@@ -105,7 +105,7 @@ function get_batch_output_files($auth_str) {
105105
foreach ($wus as $wu) {
106106
if (!$wu->canonical_resultid) continue;
107107
$result = BoincResult::lookup_id($wu->canonical_resultid);
108-
$names = get_outfile_names($result);
108+
$names = get_outfile_phys_names($result);
109109
foreach ($names as $name) {
110110
$path = dir_hier_path($name, $upload_dir, $fanout);
111111
if (is_file($path)) {
@@ -143,7 +143,7 @@ function get_wu_output_file($wu_name, $file_num, $auth_str) {
143143
return_error("no canonical result for wu $wu->name");
144144
}
145145
$result = BoincResult::lookup_id($wu->canonical_resultid);
146-
$names = get_outfile_names($result);
146+
$names = get_outfile_phys_names($result);
147147
$path = dir_hier_path($names[$file_num], $upload_dir, $fanout);
148148
if (file_exists($path)) {
149149
do_download($path);
@@ -181,7 +181,7 @@ function get_wu_output_files($wu_id, $auth_str) {
181181
return_error("no canonical result for wu $wu->name");
182182
}
183183
$result = BoincResult::lookup_id($wu->canonical_resultid);
184-
$names = get_outfile_names($result);
184+
$names = get_outfile_phys_names($result);
185185
foreach ($names as $name) {
186186
$path = dir_hier_path($name, $upload_dir, $fanout);
187187
if (is_file($path)) {

html/user/get_output2.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ function check_auth($auth, $batch) {
5252
}
5353

5454
function do_result_aux($result, $batch, $file_num=null) {
55-
$phys_names = get_outfile_names($result);
55+
$phys_names = get_outfile_phys_names($result);
5656
$log_names = get_outfile_log_names($result);
5757
if ($file_num !== null) {
5858
$path = upload_path($phys_names[$file_num]);
@@ -123,7 +123,7 @@ function do_batch($batch_id, $auth) {
123123
$wus = BoincWorkunit::enum("batch=$batch_id and canonical_resultid<>0");
124124
foreach ($wus as $wu) {
125125
$result = BoincResult::lookup_id($wu->canonical_resultid);
126-
$phys_names = get_outfile_names($result);
126+
$phys_names = get_outfile_phys_names($result);
127127
$log_names = get_outfile_log_names($result);
128128
if (count($phys_names) == 1) {
129129
$cmd = sprintf('ln -s %s %s/%s__%s',

html/user/job_file.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ function upload_error_description($errno) {
9999

100100
function query_files($r) {
101101
xml_start_tag("query_files");
102-
list($user, $user_submit) = check_remote_submit_permissions($r, null);
102+
$user = check_remote_submit_permissions($r, null);
103103
$absent_files = array();
104104
$now = time();
105105
$delete_time = (int)$r->delete_time;
@@ -177,7 +177,7 @@ function delete_uploaded_files() {
177177

178178
function upload_files($r) {
179179
xml_start_tag("upload_files");
180-
list($user, $user_submit) = check_remote_submit_permissions($r, null);
180+
$user = check_remote_submit_permissions($r, null);
181181
$fanout = parse_config(get_config(), "<uldl_dir_fanout>");
182182
$delete_time = (int)$r->delete_time;
183183
$batch_id = (int)$r->batch_id;

html/user/sandbox.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ function list_files($user, $notice) {
4444
<h3>Upload files</h3>
4545
<p>
4646
NOTE: if you upload text files from Windows,
47-
they will have CRLF line endings.
48-
If they are shell scripts, they won't work on Linux.
49-
Add shell scripts using Add File.
47+
they will be given CRLF line endings.
48+
Then, if they are shell scripts, they won't work on Linux.
49+
Add shell scripts using 'Add text file' below.
5050
<p>
5151
5252
<form action=sandbox.php method=post ENCTYPE=\"multipart/form-data\">
@@ -55,7 +55,7 @@ function list_files($user, $notice) {
5555
<p> <input class=\"btn btn-success\" type=submit value=Upload>
5656
</form>
5757
<hr>
58-
<h3>Add file</h3>
58+
<h3>Add text file</h3>
5959
";
6060
form_start('sandbox.php', 'post');
6161
form_input_hidden('action', 'add_file');
@@ -180,7 +180,7 @@ function view_file($user) {
180180
}
181181

182182
$user = get_logged_in_user();
183-
if (!submit_permissions($user)) error_page("no job submission access");
183+
if (!has_file_access($user)) error_page("no job submission access");
184184

185185
$action = get_str('action', true);
186186
if (!$action) $action = post_str('action', true);

0 commit comments

Comments
 (0)