- CAS@home stuff

svn path=/trunk/boinc/; revision=25548
This commit is contained in:
Wenjing Wu 2012-04-12 07:30:45 +00:00
parent d35758bedb
commit 6c02937500
3 changed files with 42 additions and 68 deletions

View File

@ -3259,3 +3259,10 @@ David 9 Apr 2012
boinc_api.h
html/user/
tree_threader.php
David 12 Apr 2012
- CAS@home stuff
tools/
tt_boinc.cpp
html/user/
tree_threader.cpp

View File

@ -19,7 +19,7 @@ error_reporting(E_ALL);
ini_set('display_errors', true);
ini_set('display_startup_errors', true);
$app_name = "uppercase";
$app_name = "treeThreader";
function error($s) {
echo "<error>\n<message>$s</message>\n</error>\n";
@ -27,6 +27,8 @@ function error($s) {
}
function handle_submit($r, $user, $app) {
global $app_name;
// read the list of template filenames
//
$files = file("../../tree_threader_template_files");
@ -34,16 +36,37 @@ function handle_submit($r, $user, $app) {
$njobs = sizeof($files);
$now = time();
$batch_id = BoincBatch::insert(
"(user_id, create_time, njobs, name, app_id, state) values ($user->id, $now, $njobs, 'test batch', $app->id, ".BATCH_STATE_IN_PROGRESS.")"
"(user_id, create_time, njobs, name, app_id, state) values ($user->id, $now, $njobs, 'tree_threader batch', $app->id, ".BATCH_STATE_IN_PROGRESS.")"
);
if (!$batch_id) die("couldn't create batch\n");
// write the sequence to a file
//
$seq_fname = "three_threader_seq_$batch_id";
$config = simplexml_load_string(file_get_contents("../../config.xml"));
$fanout = (int)$config->config->uldl_dir_fanout;
$download_dir = trim((string)$config->config->download_dir);
$seq_path = dir_hier_path($seq_fname, $download_dir, $fanout);
$ret = file_put_contents($seq_path, (string)$r->sequence);
if ($ret === false) {
error("couldn't write sequence file");
}
echo "write sequence file to $seq_path\n";
$i = 0;
foreach ($files as $file) {
$cmd = "cd ../..; ./bin/create_work --appname tree_thread --batch $batch_id $file";
$file = trim($file);
$wu_name = "ICT_".$batch_id."_$i";
$cmd = "cd ../..; ./bin/create_work --appname $app_name --batch $batch_id --wu_name $wu_name --wu_template templates/ICT_in --result_template templates/ICT_out $file ss3.kmeans.8 $seq_fname";
$ret = system($cmd);
if ($ret === false) {
error("can't create job");
}
} else {
echo "created job: $ret\n";
}
}
echo "<batchid>$batchid</batchid>\n";
echo "<batch_id>$batch_id</batch_id>\n";
}
// Enumerate all the successfully completed WUs for this batch.
@ -52,7 +75,7 @@ function handle_submit($r, $user, $app) {
// and return the resulting URL
//
function handle_get_output($r, $batch) {
$wus = BoincWorkUnit::enum("batchid=$batch->id");
$wus = BoincWorkUnit::enum("batch=$batch->id");
$outdir = "/tmp/tree_threader_".$batch->id;
foreach ($wus as $wu) {
if (!$wu->canonical_resultid) continue;
@ -126,7 +149,7 @@ database.connect()
projectxml.default_project().commit_all()
]]></sequence>
<auth>157f96a018b0b2f2b466e2ce3c7f54db</auth>
<auth>06e5740fb78352852cd8aeef6cdd2893</auth>
</tt_request>
EOF;
$r = simplexml_load_string($x);
@ -156,7 +179,7 @@ if (!$user_submit->submit_all) {
switch ((string)$r->action) {
case 'submit': handle_submit($r, $user, $app); break;
case 'get_output':
$batch_id = (int)$r->batchid;
$batch_id = (int)$r->batch_id;
$batch = BoincBatch::lookup_id($batch_id);
if (!$batch) error("no such batch");
if ($batch->user_id != $user->id) error("not owner of batch");

View File

@ -12,13 +12,8 @@ function usage() {
Usage:
tt_boinc submit sequence_file authenticator
submit batch, print batch ID
tt_boinc abort batchid auth
abort batch, delete files
tt_boinc status batchid auth
show fraction done
tt_boinc get_output batchid auth
tt_boinc get_output batch_id auth
show URL of output file
tt_boinc retire batchid auth
");
}
@ -51,70 +46,22 @@ $seq
<auth>$auth</auth>
</tt_request>
";
echo $req_xml; exit;
list($reply, $errmsg) = do_http_op($req_xml);
if ($errmsg) die("Error: $errmsg\n");
$id = (int)$reply->id;
echo "batch ID: $id\n";
}
function handle_abort() {
global $argc, $argv;
if ($argc != 4) usage();
$batchid = $argv[3];
$auth = $argv[4];
$req_xml = "
<tt_request>
<action>abort</action>
<batchid>$batchid</batchid>
<auth>$auth</auth>
</tt_request>
";
list($reply, $errmsg) = do_http_op($req_xml);
if ($errmsg) die("Error: $errmsg\n");
echo "success\n";
}
function handle_status() {
global $argc, $argv;
if ($argc != 4) usage();
$batchid = $argv[3];
$auth = $argv[4];
$req_xml = "
<tt_request>
<action>status</action>
<batchid>$batchid</batchid>
<auth>$auth</auth>
</tt_request>
";
list($reply, $errmsg) = do_http_op($req_xml);
if ($errmsg) die("Error: $errmsg\n");
}
function handle_get_output() {
global $argc, $argv;
if ($argc != 4) usage();
$batchid = $argv[3];
$batch_id = $argv[3];
$auth = $argv[4];
$req_xml = "
<tt_request>
<action>get_output</action>
<batchid>$batchid</batchid>
<auth>$auth</auth>
</tt_request>
";
list($reply, $errmsg) = do_http_op($req_xml);
if ($errmsg) die("Error: $errmsg\n");
}
function handle_retire() {
global $argc, $argv;
if ($argc != 4) usage();
$batchid = $argv[3];
$auth = $argv[4];
$req_xml = "
<tt_request>
<action>retire</action>
<batchid>$batchid</batchid>
<batch_id>$batch_id</batch_id>
<auth>$auth</auth>
</tt_request>
";
@ -125,10 +72,7 @@ function handle_retire() {
if ($argc < 2) usage();
switch ($argv[1]) {
case "submit": handle_submit(); break;
case "abort": handle_abort(); break;
case "status": handle_status(); break;
case "get_output": handle_get_output(); break;
case "retire": handle_retire(); break;
default: usage();
}