wiki:BossaExampleOne

Version 5 (modified by davea, 16 years ago) (diff)

--

Bossa tutorial

Create a Bossa server

Install the BOINC software on a Linux system (or run the BOINC server virtual machine in a VMWare player on any computer).

Use make_project to create a BOINC project named "test":

> cd boinc/tools
> make_project --web_only test

Edit httpd.conf as directed (you'll need root access to do this). Let's say your server's domain name is "a.b.c".

Visit http://a.b.c/test/create_account.php and create an account for yourself.

Example application

We'll create an application in which volunteers view images consisting of random rectangles, possibly with an ellipse superimposed. Their task is to click on the center of the ellipse, or to indicate that there is no ellipse. Here's an example:

(this has an ellipse slightly below/left of center).

Visit http://a.b.c/test_ops/bossa_ops.php, and create an application named "test", with application file "test.php" (we'll create this later).

A script to generate jobs

We'll need a program to generate jobs. This is done with a PHP script: html/ops/bossa_test.php.

The first part of this script is code for generating an image; the key functions are make_test_case(), which generates a structure saying if and where there's an ellipse, and make_image(), which generates an image given this info.

Next we have

function make_job($app, $batch, $i, $config) {
    // create the image file;
    // store it in the download directory hierarchy
    //
    $jobname = "job_$batch_$i";
    $case = make_test_case();
    $filename = "$jobname.png";
    $path = dir_hier_path(
        $filename, $config->download_dir, $config->uldl_dir_fanout
    );
    $url = dir_hier_url(
        $filename, $config->download_url, $config->uldl_dir_fanout
    );
    imagepng(make_image($case), $path);
    $case->url = $url;

    // make a job record in the Bossa database
    //
    $job = new BossaJob;
    $job->app_id = $app->id;
    $job->batch = $batch;
    $job->time_estimate = 30;
    $job->time_limit = 600;
    $job->name = $jobname;
    $job->info = json_encode($case);

    if (!$job->insert()) {
        echo "BossaJob::insert failed: ", mysql_error(), "\n";
        exit(1);
    }
}

This creates one job. It does the following:

  • Choose a name for the job, and a name for the corresponding image file.
  • Decide where the file will go in the project's download hierarchy.
  • Create the image file.
  • Create a job record in the Bossa database.

Finally we have:

function make_jobs() {
    $c = get_config();
    $config = null;
    $config->download_dir = parse_config($c, "<download_dir>");
    $config->download_url = parse_config($c, "<download_url>");
    $config->uldl_dir_fanout = parse_config($c, "<uldl_dir_fanout>");
    $app = BossaApp::lookup_name("bossa_test");
    if (!$app) {
        echo "Application $appname not found\n";
        exit(1);
    }
    $batch = time();
    for ($i=0; $i<10; $i++) {
        make_job($app, $batch, $i, $config);
    }
}

if ($_GET['make_jobs']) {
    make_jobs();
} else {
    header ("Content-type: image/png");
    imagepng(make_image(make_test_case()));
}

make_jobs() parses the project configuration file, looks up the application in the database, and creates 10 jobs. You can invoke this by visiting http://a.b.c/test_ops/bossa_test.php?make_jobs.

Create jobs

What volunteers see

View results

Attachments (1)

Download all attachments as: .zip