| | 1 | = PyBOINC: simplified BOINC application development in Python (design doc) = |
| | 2 | |
| | 3 | This is a proposed design for making developing |
| | 4 | BOINC applications as simple as possible. |
| | 5 | PyBOINC provides a master/slave model: |
| | 6 | the master runs on the server, and the slave is distributed. |
| | 7 | |
| | 8 | Here's an example, which sums the squares of integers from 1 to 100. |
| | 9 | The application consists of three files. |
| | 10 | The first, '''app_types.py''', defines the input and output types: |
| | 11 | {{{ |
| | 12 | class Input: |
| | 13 | def __init__(self, arg): |
| | 14 | self.value = arg |
| | 15 | |
| | 16 | class Output: |
| | 17 | def __init__(self, arg): |
| | 18 | self.value = arg; |
| | 19 | }}} |
| | 20 | |
| | 21 | The second file, '''app_master.py''', is the master program: |
| | 22 | {{{ |
| | 23 | import app_types |
| | 24 | |
| | 25 | def make_calls(): |
| | 26 | for i in range(100): |
| | 27 | input = Input(i); |
| | 28 | pyboinc_call('app_slave.py', input) |
| | 29 | |
| | 30 | def handle_result(output): |
| | 31 | sum += output.value |
| | 32 | |
| | 33 | sum = 0 |
| | 34 | |
| | 35 | pyboinc_master(make_calls, handle_result) |
| | 36 | |
| | 37 | print "The answer is %d", sum |
| | 38 | }}} |
| | 39 | |
| | 40 | The third file, '''pyboinc_slave.py''', is the slave function: |
| | 41 | |
| | 42 | {{{ |
| | 43 | import app_types |
| | 44 | |
| | 45 | input = pyboinc_get_input() |
| | 46 | output = Output(input.value*input.value); |
| | 47 | pyboinc_return_output(output); |
| | 48 | }}} |