Changes between Version 56 and Version 57 of RemoteJobs
- Timestamp:
- Feb 24, 2017, 2:20:30 PM (8 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
RemoteJobs
v56 v57 1 1 [[PageOutline]] 2 2 3 = RPCs for remote job submission = 3 4 This document describes APIs for remotely submitting, 5 monitoring, and controlling jobs on a BOINC server. 6 The APIs supports the submission of '''batches''' of jobs, 7 which may contain a single job or many thousands of jobs. 8 Currently, the API has two restrictions: 4 This document describes APIs for remotely submitting, monitoring, and controlling jobs on a BOINC server. The APIs supports the submission of '''batches''' of jobs, which may contain a single job or many thousands of jobs. Currently, the API has two restrictions: 9 5 10 6 * All jobs in a batch must use the same application. 11 7 * There can be no dependencies between jobs. 12 8 13 At the bottom level, the interface consists of Web RPCs. 14 BOINC provides client-side bindings in PHP, C++, and Python. 15 These bindings differ slightly; they expose different details of the Web RPCs. 16 17 Interfaces for [RemoteInputFiles staging input files] 18 and [RemoteOutputFiles fetching output files] are described separately. 19 20 There are various options for managing input files. 21 If you use [RemoteInputFiles#Job-basedfilemanagement Job-based file management], 22 which maintains batch/file associations, 23 the order of operations is: 9 At the bottom level, the interface consists of Web RPCs. BOINC provides client-side bindings in PHP, C++, and Python. These bindings differ slightly; they expose different details of the Web RPCs. 10 11 Interfaces for [wiki:RemoteInputFiles staging input files] and [wiki:RemoteOutputFiles fetching output files] are described separately. 12 13 There are various options for managing input files. If you use [wiki:RemoteInputFiles#Job-basedfilemanagement Job-based file management], which maintains batch/file associations, the order of operations is: 24 14 25 15 * Create a batch (initially empty); returns the batch ID. … … 27 17 * Submit jobs, passing the batch ID 28 18 29 If you manage input files a different way, 30 then you create the batch and submit jobs in a single API call. 19 If you manage input files a different way, then you create the batch and submit jobs in a single API call. 31 20 32 21 Once you have submitted the batch, you can 22 33 23 * '''Monitor''' the batch with query_batches(), query_batch(), or query_job(). 34 * '''Abort''' the batch (if you see errors, or if enough jobs have been finished) 35 using abort_jobs() or abort_batch(). 36 * [RemoteOutputFiles download output files]. 37 * '''Retire''' the batch using retire_batch(). 38 This tells the server to clean up the files and job records associated with the batch, 39 and to mark the batch as "retired"; 40 retired batches are normally not shown in the web interface. 24 * '''Abort''' the batch (if you see errors, or if enough jobs have been finished) using abort_jobs() or abort_batch(). 25 * [wiki:RemoteOutputFiles download output files]. 26 * '''Retire''' the batch using retire_batch(). This tells the server to clean up the files and job records associated with the batch, and to mark the batch as "retired"; retired batches are normally not shown in the web interface. 41 27 42 28 == PHP interface == 43 44 The following functions are provided in the PHP file 45 [/trac/browser/trunk/boinc/html/inc/submit.inc submit.inc], 46 which is independent of other BOINC PHP code. 47 The file html/user/submit_test.php has code to exercise and test these functions. 29 The following functions are provided in the PHP file [/trac/browser/trunk/boinc/html/inc/submit.inc submit.inc], which is independent of other BOINC PHP code. The file html/user/submit_test.php has code to exercise and test these functions. 48 30 49 31 === boinc_submit_batch() === 50 51 32 Submits a batch. 52 33 53 34 Arguments: a "request object" whose fields include 35 54 36 * '''project''': the project URL 55 37 * '''authenticator''': the user's authenticator 56 38 * '''app_name''': the name of the application for which jobs are being submitted 57 * '''batch_name''': a symbolic name for the batch. 58 Must be unique. 59 If omitted, a name of the form "batch_unixtime" will be used. 60 * '''workunit_template_file''': an optional [JobTemplates input template file name]. 61 * '''result_template_file''': an optional [JobTemplates output template file name]. 39 * '''batch_name''': a symbolic name for the batch. Must be unique. If omitted, a name of the form "batch_unixtime" will be used. 40 * '''workunit_template_file''': an optional [wiki:JobTemplates input template file name]. 41 * '''result_template_file''': an optional [wiki:JobTemplates output template file name]. 62 42 * '''jobs''': an array of job descriptors, each of which contains 63 * '''rsc_fpops_est''': an estimate of the FLOPs used by the job 64 * '''command_line''': command-line arguments to the application 65 * '''wu_template''': optional; the [http://boinc.berkeley.edu/trac/wiki/JobTemplates#Inputtemplates input template] 66 to use for this job, as an XML string. 67 * '''result_template''': optional; 68 the [http://boinc.berkeley.edu/trac/wiki/JobTemplates#Outputtemplates output template] 69 to use for this job, as an XML string. 70 * '''input_files''': an array of input file descriptors, each of which contains 71 * '''mode''': "local", "semilocal", "local_staged", "inline", or "remote" (see below). 72 * '''source''': meaning depends on mode: 73 * local: path on the BOINC server 74 * semilocal: the file's URL 75 * local_staged: physical name 76 * inline: the file's contents 77 * For "remote" mode, instead of "source" you must specify: 78 * '''url''': the file's URL 79 * '''nbytes''': file size 80 * '''md5''': the file's MD5 checksum 43 * '''rsc_fpops_est''': an estimate of the FLOPs used by the job 44 * '''command_line''': command-line arguments to the application 45 * '''wu_template''': optional; the [http://boinc.berkeley.edu/trac/wiki/JobTemplates#Inputtemplates input template] to use for this job, as an XML string. 46 * '''result_template''': optional; the [http://boinc.berkeley.edu/trac/wiki/JobTemplates#Outputtemplates output template] to use for this job, as an XML string. 47 * '''input_files''': an array of input file descriptors, each of which contains 48 * '''mode''': "local", "semilocal", "local_staged", "inline", or "remote" (see below). 49 * '''source''': meaning depends on mode: 50 * local: path on the BOINC server 51 * semilocal: the file's URL 52 * local_staged: physical name 53 * inline: the file's contents 54 * For "remote" mode, instead of "source" you must specify: 55 * '''url''': the file's URL 56 * '''nbytes''': file size 57 * '''md5''': the file's MD5 checksum 81 58 82 59 Result: a 2-element array containing 60 83 61 * The batch ID 84 62 * An error message (null if success) 85 63 86 64 Input files can be supplied in any of the following ways: 87 * '''local''': the file is on the BOINC server and is not [JobStage staged]. 88 It's specified by its full path. 89 * '''local_staged''': the filed has been [JobStage staged] on the BOINC server. 90 It's specified by its physical name. 91 * '''semilocal''': the file is on a data server that's accessible to the BOINC server 92 but not necessarily to the outside world. 93 The file is specified by its URL. 94 It will be downloaded by the BOINC server during job submission, 95 and served to clients from the BOINC server. 96 * '''inline''': the file is included in the job submission request XML message. 97 It will be served to clients from BOINC server. 98 * '''remote''': the file is on a data server other than the BOINC server, 99 and will be served to clients from that data server. 100 It's specified by the URL, the file size, and the file MD5. 65 66 * '''local''': the file is on the BOINC server and is not [wiki:JobStage staged]. It's specified by its full path. 67 * '''local_staged''': the filed has been [wiki:JobStage staged] on the BOINC server. It's specified by its physical name. 68 * '''semilocal''': the file is on a data server that's accessible to the BOINC server but not necessarily to the outside world. The file is specified by its URL. It will be downloaded by the BOINC server during job submission, and served to clients from the BOINC server. 69 * '''inline''': the file is included in the job submission request XML message. It will be served to clients from BOINC server. 70 * '''remote''': the file is on a data server other than the BOINC server, and will be served to clients from that data server. It's specified by the URL, the file size, and the file MD5. 101 71 102 72 The following mode has been proposed but is not implemented yet: 103 * '''sandbox''': the file is in the user's [RemoteInputFiles#Per-userfilesandbox sandbox], 104 73 74 * '''sandbox''': the file is in the user's [wiki:RemoteInputFiles#Per-userfilesandbox sandbox], and is specified by its name in the sandbox. 105 75 106 76 The following example submits a 10-job batch: 77 107 78 {{{ 108 79 $req = new StdClass; … … 132 103 } 133 104 }}} 134 135 Note: this interfaces is inconsistent; it lets you do some things but not others. 136 Let me know if you need additions. 105 Note: this interfaces is inconsistent; it lets you do some things but not others. Let me know if you need additions. 137 106 138 107 === boinc_estimate_batch() === 139 140 108 Returns an estimate of the elapsed time required to complete a batch. 141 109 142 Arguments: same as '''boinc_submit_batch()''' 143 (only relevant fields need to be populated). 110 Arguments: same as '''boinc_submit_batch()''' (only relevant fields need to be populated). 144 111 145 112 Return value: a 2-element array containing 113 146 114 * The elapsed time estimate, in seconds 147 115 * An error message (null if success) 148 116 149 117 === boinc_query_batches() === 150 151 118 Returns a list of this user's batches, both in progress and complete. 152 119 153 120 Argument: a request object with elements 121 154 122 * '''project''' and '''authenticator''': as above. 155 123 * '''get_cpu_time''' (optional): if nonzero, get CPU time of each batch 156 124 157 Result: a 2-element array. 158 The first element is an array of batch descriptor objects, 159 each with the following fields: 125 Result: a 2-element array. The first element is an array of batch descriptor objects, each with the following fields: 126 160 127 * '''id''': batch ID 161 128 * '''state''': values are 162 * 1: in progress163 * 2: completed (all jobs either succeeded or had fatal errors)164 * 3: aborted165 * 4: retired129 * 1: in progress 130 * 2: completed (all jobs either succeeded or had fatal errors) 131 * 3: aborted 132 * 4: retired 166 133 * '''name''': the batch name 167 134 * '''app_name''': the application name … … 172 139 * '''nerror_jobs''': the number of jobs that had fatal errors 173 140 * '''completion_time''': when the batch was completed 174 * '''credit_estimate''': BOINC's initial estimate of the credit that 175 would be granted to complete the batch, including replication 141 * '''credit_estimate''': BOINC's initial estimate of the credit that would be granted to complete the batch, including replication 176 142 * '''credit_canonical''': the actual credit granted to canonical instances 177 143 * '''credit_total''': the actual credit granted to all instances 178 144 179 145 === boinc_query_batch() === 180 181 146 Gets batch details. 182 147 183 148 Argument: a request object with elements 149 184 150 * '''project''' and '''authenticator''': as above 185 151 * '''batch_id''': specifies a batch. 186 * '''get_cpu_time''' (optional): if nonzero, get CPU time of batch 152 * '''get_cpu_time''' (optional): if nonzero, get CPU time of batch. This includes all job instances, and doesn't include GPU time, so it may not be meaningful. 187 153 * '''get_job_details''' (optional): if nonzero, return job details (see below). 188 154 189 Result: a 2-element array. 190 The first element is a batch descriptor object as described above, 191 with one additional field: 155 Result: a 2-element array. The first element is a batch descriptor object as described above, with one additional field: 156 192 157 * '''jobs''': an array of job descriptor objects, each one containing 193 * '''id''': the database ID of the job's workunit record194 * '''canonical_instance_id''': if the job has a canonical result, its database ID158 * '''id''': the database ID of the job's workunit record 159 * '''canonical_instance_id''': if the job has a canonical result, its database ID 195 160 196 161 If '''get_job_details''' was set, the job descriptors also contain: 197 * '''status''': "unsent", "in_progress", "error", or "done". 198 * '''cpu_time''': if done, the CPU time 199 * '''exit_status''': if error, the exit status of one of the error instances. 162 163 * '''status''': "unsent", "in_progress", "error", or "done". 164 * '''cpu_time''': if done, the CPU time 165 * '''exit_status''': if error, the exit status of one of the error instances. 200 166 201 167 The order of job descriptors matches their order in the batch submission. 202 168 203 169 === boinc_query_job() === 204 205 170 Gets job details. 206 171 207 172 Argument: a request object with elements: 173 208 174 * '''project''' and '''authenticator''': as above 209 175 * '''job_id''': specifies a job. 210 176 211 Result: a 2-element array. 212 The first element is a job descriptor object with the following fields: 177 Result: a 2-element array. The first element is a job descriptor object with the following fields: 178 213 179 * '''instances''': an array of job instance descriptors, each containing: 214 * '''name''': the instance's name 215 * '''id''': the ID of the corresponding result record 216 * '''state''': a string describing the instance's state 217 (unsent, in progress, complete, etc.) 218 * '''outfile''': if the instance is over, 219 a list of output file descriptors, each containing 220 * '''size''': file size in bytes 180 * '''name''': the instance's name 181 * '''id''': the ID of the corresponding result record 182 * '''state''': a string describing the instance's state (unsent, in progress, complete, etc.) 183 * '''outfile''': if the instance is over, a list of output file descriptors, each containing 184 * '''size''': file size in bytes 221 185 222 186 === boinc_abort_batch() === 223 224 187 Argument: a request object with elements 188 225 189 * '''project''' and '''authenticator''': as above, 226 190 * '''batch_id''': specifies a batch. … … 229 193 230 194 === boinc_retire_batch() === 231 232 195 Delete server storage (files, DB records) associated with a batch. 233 196 234 197 Argument: a request object with elements 198 235 199 * '''project''' and '''authenticator''': as above, 236 200 * '''batch_id''': specifies a batch. … … 239 203 240 204 == C++ interface == 241 242 A C++ interface to the following functions is available in lib/remote_submit.cpp. 243 Include lib/remote_submit.h. 244 245 All functions return zero on success, 246 else an error code as defined in lib/error_numbers.h 205 A C++ interface to the following functions is available in lib/remote_submit.cpp. Include lib/remote_submit.h. 206 207 All functions return zero on success, else an error code as defined in lib/error_numbers.h 247 208 248 209 === create_batch() === 249 250 210 Create a batch - a set of jobs, initially empty. 211 251 212 {{{ 252 213 int create_batch( … … 260 221 ); 261 222 }}} 262 263 223 project_url:: the project URL 264 224 authenticator:: the authenticator of the submitting user 265 225 batch_name:: a name for the batch. Must be unique over all batches. 266 226 app_name:: the name of an application on the BOINC server 267 expire_time:: if nonzero, the Unix time when the batch should 268 be aborted and removed from the server, whether or not it's completed. 227 expire_time:: if nonzero, the Unix time when the batch should be aborted and removed from the server, whether or not it's completed. 269 228 batch_id:: (out) the batch's database ID 270 229 error_msg:: (out) an error message if the operation failed 271 230 272 231 === estimate_batch() === 273 274 232 Get an estimate of the makespan of a (potential) batch. 275 233 … … 284 242 ); 285 243 }}} 286 jobs 287 est_makespan 244 jobs:: description of jobs; same as for '''submit_jobs()''' (see below). 245 est_makespan:: the estimated makespan (time to completion). 288 246 289 247 === submit_jobs() === 290 291 248 Submit a set of jobs; place them in an existing batch, and make them runnable. 249 292 250 {{{ 293 251 int submit_jobs( … … 323 281 324 282 For each job: 283 325 284 job_name:: must be unique over all jobs 326 285 cmdline_args:: command-line arguments … … 328 287 329 288 For each input file: 289 330 290 physical_name:: BOINC's physical name for the file. The file must already be staged. 331 291 332 333 292 === query_batches() === 334 335 293 Query the status of this user's batches. 336 294 … … 362 320 }; 363 321 }}} 364 365 322 === query_batch() === 366 367 323 Return the detailed status of jobs in a given batch (can specify by either ID or name). 368 324 … … 386 342 387 343 }}} 388 389 344 === abort_jobs() === 390 391 345 Abort a set of jobs. 346 392 347 {{{ 393 348 extern int abort_jobs( … … 399 354 400 355 }}} 401 402 356 === query_completed_job() === 403 404 357 Query a completed job. 358 405 359 {{{ 406 360 extern int query_completed_job( … … 422 376 }; 423 377 }}} 424 425 378 canonical_resultid:: database ID of the "canonical" instance of the job. 426 379 error_mask:: a bitmask of error conditions (see db/boinc_db_types.h) … … 432 385 433 386 === retire_batch() === 434 435 "Retire" a batch. 436 The server is then allowed to delete the batch's input and output files, 437 and its database records. 387 "Retire" a batch. The server is then allowed to delete the batch's input and output files, and its database records. 388 438 389 {{{ 439 390 extern int retire_batch( … … 444 395 ); 445 396 }}} 446 447 397 === set_expire_time() === 448 449 398 Change the expiration time of a batch. 399 450 400 {{{ 451 401 extern int set_expire_time( … … 457 407 ); 458 408 }}} 459 460 409 === ping_server() === 461 462 410 Ping the project's server; return zero if the server is up. 411 463 412 {{{ 464 413 extern int ping_server( … … 467 416 ); 468 417 }}} 469 470 418 === query_batch_set() === 471 472 Return the status of the jobs in a given set of batches. 473 This is used by the Condor interface; it's probably not useful outside of that. 419 Return the status of the jobs in a given set of batches. This is used by the Condor interface; it's probably not useful outside of that. 420 474 421 {{{ 475 422 extern int query_batch_set( … … 492 439 493 440 }}} 494 495 441 == Python binding == 496 497 The file tools/submit_api.py contains a Python binding of some of above RPCs. 498 For examples of its use, see tools/submit_api_test.py. 499 500 To build a description of a batch of jobs, 501 use the BATCH_DESC, JOB_DESC, and FILE_DESC classes: 442 The file tools/submit_api.py contains a Python binding of some of above RPCs. For examples of its use, see tools/submit_api_test.py. 443 444 To build a description of a batch of jobs, use the BATCH_DESC, JOB_DESC, and FILE_DESC classes: 445 502 446 {{{ 503 447 def make_batch(): … … 527 471 }}} 528 472 You can then pass this to either estimate_batch() or submit_batch(): 473 529 474 {{{ 530 475 from submit_api import * … … 536 481 print 'estimated time: ', r.text, ' seconds' 537 482 }}} 538 539 The return value of all the API functions is an !EntityTree representation 540 of the XML returned by the RPC. 541 542 Other requests use a REQUEST object. 543 For example, to query the status of batch 271: 483 The return value of all the API functions is an !EntityTree representation of the XML returned by the RPC. 484 485 Other requests use a REQUEST object. For example, to query the status of batch 271: 486 544 487 {{{ 545 488 req = REQUEST() … … 563 506 564 507 }}} 565 566 508 Possible attributes of FILE_DESC: 509 567 510 * mode 568 511 * url … … 572 515 573 516 Possible attributes of JOB_DESC: 517 574 518 * rsc_fpops 575 519 * command_line … … 579 523 580 524 Possible attributes of BATCH_DESC: 525 581 526 * project (URL of project) 582 527 * authenticator (submitter's account key) … … 586 531 * jobs (list of JOB_DESC) 587 532 588 Available functions are listed below. 589 Each function takes a request object whose attributes include 590 at least project and authenticator. 591 592 abort_batch(req):: 593 req attributes: batch_id 594 abort_jobs(req):: 595 req attributes: jobs (list of job names) 596 create_batch(req):: 597 req attributes: app_name, batch_name, expire_time 598 estimate_batch(req):: 599 req is a BATCH_DESC 600 query_batch(req):: 601 req attributes: batch_id, get_cpu_time 602 query_batches(req):: 603 req attributes_ get_cpu_time 604 query_completed_job(req):: 605 req attributes: job_name 606 query_job(req):: 607 req attributes: job_id 608 get_output_file(req):: 609 req attributes: instance_name, file_num 610 get_output_files(req):: 611 req attributes: batch_id 612 retire_batch(req):: 613 req attributes: batch_id 533 Available functions are listed below. Each function takes a request object whose attributes include at least project and authenticator. 534 535 abort_batch(req):: req attributes: batch_id 536 abort_jobs(req):: req attributes: jobs (list of job names) 537 create_batch(req):: req attributes: app_name, batch_name, expire_time 538 estimate_batch(req):: req is a BATCH_DESC 539 query_batch(req):: req attributes: batch_id, get_cpu_time 540 query_batches(req):: req attributes_ get_cpu_time 541 query_completed_job(req):: req attributes: job_name 542 query_job(req):: req attributes: job_id 543 get_output_file(req):: req attributes: instance_name, file_num 544 get_output_files(req):: req attributes: batch_id 545 retire_batch(req):: req attributes: batch_id 614 546 615 547 == HTTP/XML interface == 616 617 At a lower level, the APIs are accessed by sending a POST request, 618 using HTTP or HTTPS, to PROJECT_URL/submit_rpc_handler.php. 619 The inputs and outputs of each function are XML documents. 620 The format of the request and reply XML documents 621 can be inferred from user/submit_rpc_handler.php. 548 At a lower level, the APIs are accessed by sending a POST request, using HTTP or HTTPS, to PROJECT_URL/submit_rpc_handler.php. The inputs and outputs of each function are XML documents. The format of the request and reply XML documents can be inferred from user/submit_rpc_handler.php. 622 549 623 550 == Example web interface == 624 625 An example of a web interface for job submission and control, 626 based on this API, can be found here: 627 http://boinc.berkeley.edu/trac/browser/trunk/boinc/html/user/submit_example.php 628 629 This example is functional and it shows how to use the API. 630 However, you will have to modify it heavily for your particular 631 applications and web site. 632 633 551 An example of a web interface for job submission and control, based on this API, can be found here: http://boinc.berkeley.edu/trac/browser/trunk/boinc/html/user/submit_example.php 552 553 This example is functional and it shows how to use the API. However, you will have to modify it heavily for your particular applications and web site.