You are here

How to use PROOF from the Python shell



Enable the ROOT Python bindings

First all make sure the the ROOT Python bindings have been built: under $ROOTSYS/lib there should be modules ROOT.py and libPyROOT.so (under windows the related modules appear under$ROOTSYS/bin). If the modules are absent you should re-configure ROOT with the option '--enable-python' and re-build. Do not forget to make the new modules visible to Python: for that, you should add $ROOTSYS/lib to $PYTHONPATH or $PYTHONDIR .

Starting a PROOF session within Python

In Python shell first import TProof from ROOT

>>> from ROOT import TProof

then just open a session, remembering that double quotes must be replaced by single quotes and '::' by a simple '.' :

>>> p = TProof.Open('lxfsrd0706.cern.ch')
Starting master: opening connection ...
Starting master: OK
Opening connections to workers: OK (8 workers)
Setting up worker servers: OK (8 workers)
PROOF set to parallel mode (8 workers)
>>>

At this point the session is open; in using the 'p' object remember to replace '->' by '.', e.g.

>>> p.Print()
Connected to:             lxfsrd0706.cern.ch (valid)
Port number:              1093
User:                     ganis
ROOT version|rev:         5.21/05|r26159
Architecture-Compiler:    linuxx8664gcc-gcc412
Proofd protocol version:  17
Client protocol version:  19
Remote protocol version:  17
Log level:                0
Session unique tag:       lxfsrd0706-1226574772-21889
Default data pool:        root://lxfsrd0506.cern.ch//proofpool
*** Master server 0 (parallel mode, 8 workers):
Master host name:           lxfsrd0706.cern.ch
Port number:                1093
User/Group:                 ganis/group03
ROOT version|rev|tag:       5.21/01|r24746|v5-21-01-alice_dbg
Architecture-Compiler:      linuxx8664gcc-gcc346
Protocol version:           17
Image name:                 lxfsrd0706.cern.ch:/pool/proofbox/ganis
Working directory:          /pool/proofbox/ganis/session-lxfsrd0706-1226576324-24040/master-0-lxfsrd0706-1226576324-24040
Config directory:
Config file:                proof.conf
Log level:                  0
Number of workers:          8
Number of active workers:   8
Number of unique workers:   2
Number of inactive workers: 0
Number of bad workers:      0
Total MBs processed:        0.00
Total real time used (s):   0.011
Total CPU time used (s):    0.000
>>>

You can test processing using the ProofSimple example in $ROOTSYS/tutorials/proof

>>> p.Process('$ROOTSYS/tutorials/proof/ProofSimple.C+',100000)
Mst-0: grand total: sent 101 objects, size: 94354 bytes
0L
>>>>

which should produce a canvas with 100 1-D histograms with random gaussian distributions

ProofSimple.png