Changes between Version 4 and Version 5 of PythonApps


Ignore:
Timestamp:
Aug 12, 2009, 6:09:46 PM (15 years ago)
Author:
jeremy.cowles
Comment:

Updating the Python and PyMW documentation

Legend:

Unmodified
Added
Removed
Modified
  • PythonApps

    v4 v5  
    5252}}}
    5353
    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 
     54With PyMW and PyBOINC setup, it's time to run a real BOINC application with PyMW.
    7155
    7256=== Running PyMW Applications ===
     
    9478}}}
    9579
    96 Now the project is created, but there is no application installed (notice, we never called xadd or update_versions). Luckily, PyMW will do this for us. Now all we have to do is run our application with the boinc interface and point it to our home directory:
     80The project should not be created, but there is no application installed (notice, we never called xadd or update_versions). Luckily, PyMW will do this for us. Now all we have to do is run our application with the boinc interface and point it to our home directory:
    9781
    9882{{{
     83$ cd ~/pymw-0.2/examples
     84$ python monte_pi.py -n 1 -i boinc -p /home/boincadm/projects/sandbox -c /home/boincadm/pyboinc -a 1.00_python26.zip
    9985
     86(lots of information will scroll out and then it will eventually wait)
    10087}}}
     88
     89The 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
     91Once 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
     93Now 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
     95Back at the BOINC VM, you should now see the results of the computation.
     96
     97=== Talking to BOINC from Python ===
     98
     99The 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
     111Accessing 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{{{
     114import boinc
     115print boinc.time_to_checkpoint()
     116}}}
     117
     118There 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
     120See the PyMW /examples folder for more examples on using PyMW or go to the [http://pymw.sourceforge.net/ PyMW] web site for official documentation.
    101121
    102122== Using Py2Exe ==