54 | | Now that PyMW and PyBOINC are setup, it's time to run a real BOINC application with PyMW. |
55 | | |
56 | | {{{ |
57 | | $ cd ~/pymw-0.2/examples |
58 | | $ python monte_pi.py -n 1 -i boinc -p /home/boincadm/projects/sandbox -c /home/boincadm/pyboinc -a 1.00_python26.zip |
59 | | |
60 | | (lots of information will scroll out and then it will eventually wait) |
61 | | }}} |
62 | | |
63 | | The Monte Carlo PI estimation application is waiting for BOINC clients to process it's work units. So go back to your main PC (not the VM) and open up the BOINC client (install it if needed). |
64 | | |
65 | | Once you have the BOINC manager open, click on "advanced view", when debugging it's best if you stay in this view. Next, click "Tools->Attach to project" from the main application menu. Click "Next" and then enter your project URL ("http://192.168.1.190/sandbox" if you are following this exactly) and then click next again. |
66 | | |
67 | | Now that you are attached to the project, it should be listed in the project view. Click on the project and click the "update" button to force it to request work from the server. The PyBOINC interpreter will download and then a handful of tasks should appear. Once these tasks complete you can hit "update" on the project again to force the client to send them back to the server. |
68 | | |
69 | | Back at the BOINC VM, you should now see the results of the computation. |
70 | | |
| 54 | With PyMW and PyBOINC setup, it's time to run a real BOINC application with PyMW. |
| 88 | |
| 89 | The Monte Carlo PI estimation application is waiting for BOINC clients to process it's work units. So go back to your main PC (not the VM) and open up the BOINC client (install it if needed). |
| 90 | |
| 91 | Once you have the BOINC manager open, click on "advanced view", when debugging it's best if you stay in this view. Next, click "Tools->Attach to project" from the main application menu. Click "Next" and then enter your project URL ("http://192.168.1.190/sandbox" if you are following this exactly) and then click next again. |
| 92 | |
| 93 | Now that you are attached to the project, it should be listed in the project view. Click on the project and click the "update" button to force it to request work from the server. The PyBOINC interpreter will download and then a handful of tasks should appear. Once these tasks complete you can hit "update" on the project again to force the client to send them back to the server. |
| 94 | |
| 95 | Back at the BOINC VM, you should now see the results of the computation. |
| 96 | |
| 97 | === Talking to BOINC from Python === |
| 98 | |
| 99 | The PyBOINC interpreter also includes a custom module for interfacing with the BOINC client API under the namespace "boinc". Most common BOINC API functions have been implemented, to see a full list, run the following on the BOINC VM: |
| 100 | |
| 101 | {{{ |
| 102 | $ cd ~/pyboinc/linux |
| 103 | |
| 104 | (you may or may not need the next line) |
| 105 | |
| 106 | $ chmod +x pymw_1.03_i686-pc-linux-gnu |
| 107 | $ echo -e "import boinc\n""print dir(boinc)" > boinc_test.py |
| 108 | $ ./pymw_1.03_i686-pc-linux-gnu boinc_test.py 1.00_python26.zip |
| 109 | }}} |
| 110 | |
| 111 | Accessing the boinc API in your code is as easy as importing the boinc namespace and then using the function you need, for example: |
| 112 | |
| 113 | {{{ |
| 114 | import boinc |
| 115 | print boinc.time_to_checkpoint() |
| 116 | }}} |
| 117 | |
| 118 | There are two things worth noting here, first, all boinc functions have the "boinc_" part of the C name removed, which is redundant when using the "boinc" namespace as a prefix. Secondly, the function boinc.get_app_name() is not actually part of the BOINC API, but is provided by PyBOINC to let you discover the true application name that was launched and not just your script name. |
| 119 | |
| 120 | See the PyMW /examples folder for more examples on using PyMW or go to the [http://pymw.sourceforge.net/ PyMW] web site for official documentation. |