Changes between Version 2 and Version 3 of PythonApps


Ignore:
Timestamp:
Aug 12, 2009, 5:45:24 PM (15 years ago)
Author:
jeremy.cowles
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • PythonApps

    v2 v3  
    11= Python applications =
    22
     3Python applications can be run two different ways: by using the [http://pymw.sourceforge.net/ PyMW framework] (cross platform) or by using [http://www.py2exe.org/ py2exe] (Windows only). Both methods are discussed here.
     4
     5== Using PyMW ==
     6The [http://pymw.sourceforge.net/ PyMW framework] is a master-worker computing framework for Python. Using PyMW in conjunction with a special interpreter (PyBOINC) allows you to send Python scripts as work units and does not require the client to have Python installed. PyMW can also be used without the portable Python interpreter, however, the client is responsible for installing the correct version of Python (2.4 or greater) and adding the interpreter to their system PATH environment variable.
     7
     8In addition to BOINC, PyMW also provides non-BOINC interfaces for Condor, MPI, and simple multi-core processing which can be selected using a command line switch. The multi-core interface is particularly useful for debugging BOINC applications before submitting them to your project.
     9
     10The following is a brief explanation of how to setup PyMW using the [VmServer BOINC virtual server].
     11
     12=== Installing and Testing PyMW ===
     13First, setup the [VmServer BOINC virtual server] following the instructions in the [QuickStart Quick Start] guide. Also, if you are following this exactly, it's highly recommended that you ssh into your VM instead of using a VM viewer so that you can copy and paste commands.
     14
     15First, login to your VM as "boincadm" (with password "boincadmpw" if you haven't changed it). To get up and running with PyMW, first download the PyMW package and unzip it into your home folder on the BOINC VM and install it into your local Python "site-packages" directory. This can be done with the following commmands, assuming you have internet access:
     16
     17{{{
     18$ cd ~
     19$ wget http://downloads.sourceforge.net/project/pymw/pymw/PyMW%200.2/pymw-0.2.tar.gz
     20$ tar -xzf pymw-0.2.tar.gz
     21$ rm pymw-0.2.tar.gz
     22$ cd pymw-0.2
     23$ su -c "python setup.py install"
     24
     25(the password for root is rootpw, unless you changed it)
     26}}}
     27
     28''Note that the URL for PyMW was current as of the time of this writing (v0.2), but you should check for and use the newest available release.''
     29
     30At this point, PyMW is installed and so it's a good idea to test the installation. While still in the PyMW directory that you extracted above, try the following example distributed with PyMW:
     31
     32{{{
     33$ cd examples
     34$ python monte_pi.py
     35
     36(some output should appear)
     37
     38$ cd ../../
     39}}}
     40
     41After a moment, you should see some vague estimate of PI printed out to the screen. This means that PyMW is installed and working properly. By default, the example that was run above uses the "generic" interface and does not interact with the BOINC server.
     42
     43Next, you should install PyBOINC to allow your PyMW apps to run without Python being installed on the BOINC client's machines. The following downloads the zip file, extracts it and moves it into a convenient location:
     44
     45{{{
     46$ wget http://bitbucket.org/jeremycowles/pyboinc/downloads/pyboinc-0.01.zip
     47$ unzip pyboinc-0.01.zip
     48$ rm pyboinc-0.01.zip
     49$ mv pyboinc-0.01/bin-python26 pyboinc
     50$ rm -r pyboinc-0.01
     51$ rm pyboinc-0.01.zip
     52}}}
     53
     54Now 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
     63Now 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
     65Once 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
     67Now 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
     69Back at the BOINC VM, you should now see the results of the computation.
     70
     71
     72=== Running PyMW Applications ===
     73
     74'''''Note:''' the following assumes that you have a folder in your home directory called "pyboinc" containing the Python 2.6 binaries and that you have installed PyMW as described in the previous section.''
     75
     76First, you must setup a project for testing, I will call mine "sandbox" and it will be run on the local address I have given my VM, 192.168.1.190, but you should use whatever address or domain name that is setup on your VM:
     77
     78{{{
     79$ cd ~/boinc/tools
     80$ ./make_project --url_base http://192.168.1.190 sandbox
     81
     82(answer yes to all questions/warnings)
     83}}}
     84
     85This may take a while to generate the server keys. After it's completed, you should go into your project directory and add it to your cron jobs and to the Apache server:
     86
     87{{{
     88$ cd ~/projects/sandbox
     89$ su -c 'cat sandbox.httpd.conf >> /etc/apache2/httpd.conf'
     90  (you'll be prompted for the root password, which is "rootpw")
     91
     92$ su -c 'apache2ctl -k restart'
     93$ crontab sandbox.cronjob
     94}}}
     95
     96Now 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:
     97
     98{{{
     99
     100}}}
     101
     102== Using Py2Exe ==
    3103[http://www.py2exe.org/ py2exe] allows you to make a
    4104standalone executable that envelops both the Python executable, and