wiki:RemoteJobs

Version 12 (modified by davea, 13 years ago) (diff)

--

APIs for remote job submission

This document describes APIs for remotely submitting jobs to a BOINC server. The APIs support the submission of large batches of jobs, such as parameter sweeps. The APIs can be used, for example, to create web interfaces for job submission, such as might be found in a science portal web site:

No image "submit.png" attached to RemoteJobs

BOINC provides a PHP library that implements the API. The underlying web services are implemented as HTTP/XML RPCs, and it is easy to create bindings in other languages.

This system is coupled with new multi-user project features. In particuler, users can submit jobs only if they have been given access (via a web interface) by project administrators, and admins can restrict the apps for which each user is allowed to submit jobs.

PHP interface

boinc_estimate_batch()

This function returns an estimate of the elapsed time required to complete a given batch.

Arguments: a "request object" whose fields include

  • project: the project URL
  • authenticator: the user's authenticator
  • app_name: the name of the application for which jobs are being submitted
  • jobs: an array of job descriptors (see example)

Return value: a 2-element array containing

  • The estimate, in seconds
  • An error message (null if success)

Example usage:

$req->project = "http://foo.bar.edu/test/";
$req->authenticator = "xxx";
$req->app_name = "uppercase";
$req->jobs = array();

$f->source = "http://foo.bar.edu/index.php";
$f->name = "in";
$job->input_files = array($f);

for ($i=10; $i<20; $i++) {
	$job->rsc_fpops_est = $i*1e9;
	$job->command_line = "--t $i";
	$req->jobs[] = $job;
}

list($e, $errmsg) = boinc_estimate_batch($req);
if ($errmsg) {
	echo "Error: $errmsg\n";
} else {
	echo "The batch will take about $e seconds to complete\n";
}

boinc_submit_batch()

Similar to boinc_estimate_batch(), but submits the batch.

Result: a 2-element array containing

  • The batch ID
  • An error message (null if success)

boinc_query_batches()

Returns a list of this user's batches, both in progress and complete.

Argument: a request object with elements

  • project and authenticator: as above.

Result: a 2-element array. The first element is an array of objects describing batches, with the following fields:

  • batch_id: batch ID
  • fraction_done: a number 0..1 giving the fraction of the batch that has been completed
  • create_time: when the batch was submitted
  • est_completion_time: an updated estimate of completion time
  • njobs: the number of jobs in the batch

boinc_query_batch()

Gets batch details.

Argument: a request object with elements

  • project and authenticator: as above
  • batch_id: specifies a batch.

Result: a 2-element array. The first element is an array of objects describing jobs within the batch, with the following fields:

  • job_id: the job ID
  • canonical_instance_id: if the job has been completed and validated, the ID of a valid instance
  • n_outfiles: the number of output files

boinc_query_job()

Gets job details.

Argument: a request object with elements:

  • project and authenticator: as above
  • job_id: specifies a job.

Result: a 2-element array. The first element is an object with the following fields:

  • instances: an array of job instance descriptors

Each job instances descriptor is an object with the following fields:

  • instance_name: the instance's name
  • instance_id: the ID of the corresponding result record

boinc_abort_batch()

Argument: a request object with elements

  • project and authenticator: as above,
  • batch_id: specifies a batch.

Result: an error message, null if successful

boinc_get_output_file()

Get a URL for a particular output file.

Argument: a request object with elements

  • project and authenticator: as above,
  • instance_name: specifies a job instance,
  • file_num: the ordinal number of one of the output files.

Result: a 2-element array; the first element is a URL from which the output file can be downloaded.

boinc_get_output_files()

Argument: a request object with elements

  • project and authenticator: as above,
  • batch_id: specifies a batch.

Result: a 2-element array; the first element is a URL from which a zipped archive of all output files from the batch can be downloaded (only the outputs of "canonical" instances are included).

boinc_cleanup_batch()

Delete server storage (files, DB records) associated with a batch.

Argument: a request object with elements

  • project and authenticator: as above,
  • batch_id: specifies a batch.

Result: an error message, null if successful

HTTPS/XML interface

The APIs are accessed by sending a POST request, using HTTPS, to PROJECT_URL/submit.php

The inputs and outputs of each function are XML documents. If an operation fails, the output is of the form

<error>
   <message>X</message>
</error>

where X is an error message.

All operations include the authenticator of the user making the request. This user must be marked as a "job submitter" in the BOINC database.

Describing a batch

A job is described by

<job>
   [<command_line>C</command_line>]
   [<input_file>URL or path</input_file>]
   ... other input files
</job>

Each input file is specified either by a URL accessible to the server, or by a path on the server.

A batch of jobs is described by:

<batch>
   <app>appname</app>
   [<input_template>x</input_template>]
   [<output_template>x</output_template>]
   <job>...</job>
   ... more jobs
</batch>

The names of the input and output template files may be specified; otherwise the defaults appname_in and appname_out are used.

Batch runtime estimation

This function estimates the completion time of a batch. Input:

<batch_estimate>
   <authenticator>X</authenticator>
   <batch> ... </batch>
   [<priority>N</priority>]
</batch_estimate>

Priority, if specified, is relative to other batches submitted by this user.

Output:

<estimate>
   <seconds>X</seconds>
</estimate>

Submitting a batch

Input:

<batch_submit>
   <authenticator>X</authenticator>
   <batch> ... </batch>
   [<priority>N</priority>]
</batch_submit>

Output:

<batch_id>N</batch_id>

Querying batches

Querying a batch

Input:

<query_batch>
   <authenticator>X</authenticator>
   <batch_id>N</batch_id>
</query_batch>

Output:

<batch_status>
   <fraction_done>X</fraction_done>
   <jobs_completed>N</jobs_completed>
   <remaining_time>X</remaining_time>
</batch_status>

Aborting a batch

Implementation notes

New tables

batch
  id
  create_time
  logical_start_time
  logical_end_time
  estimated_completion_time
  njobs

user_submit
  user_id
  quota
  logical_start_time
  bool all_apps

user_app
  user_id
  app_id