Using the Grid/Python2.6.4

From BiGGrid Wiki
Jump to navigation Jump to search

Introduction

On the local Grid clusters and the central clusters at SARA, Nikhef and Philips Python 2.6.4 is installed for the lsgrid VO. To find out the which queues are available on which CE's, please issue the command:

lcg-info --vo lsgrid --list-ce --query Tag=VO-lsgrid-python-2.6.4

Available modules

At this moment the following Python modules are installed:

  • Nose
  • Numpy
  • Scipy
  • httplib2
  • pycurl
  • IPython
  • Zope
  • Twisted
  • Foolscap
  • pyOpenSSL
  • Biopython

If you would like to have a module or package added, please send an e-mail to grid.support@sara.nl.

Usage

Users have to be aware that some environment variables need to be set before starting Python. If the user forgets this, he or she will be using the default (or system) version of Python, which is older and has no additional modules installed.

To use Python interactively on a User Inferface of one of the local LSG clusters, you can load the correct environment by typing:

source /data/software/lsgrid/python-2.6.4/set_python_env.sh

To use Python from within a Grid job, please include the following lines in your script:

if [ ! -d $VO_LSGRID_SW_DIR/python-2.6.4 ]; then 
  echo Python not found on this cluster.
  exit 1
fi
source $VO_LSGRID_SW_DIR/python-2.6.4/set_python_env.sh

To make sure your job only lands on clusters which have Python installed, please add the following line to your JDL-script:

Requirements = Member("VO-lsgrid-python-2.6.4", other.GlueHostApplicationSoftwareRunTimeEnvironment);

Example

This is a simple example to test Python on the Grid.

JDL - test_python.jdl

Executable = "test_python.sh";
Stdoutput = "stdout";
StdError = "stderror";
InputSandbox = {"test_python.sh"};
OutputSandbox = {"stdout","stderror"};
Requirements = Member("VO-lsgrid-python-2.6.4", other.GlueHostApplicationSoftwareRunTimeEnvironment);
RetryCount = 0;

shell script - test_python.sh

#!/bin/bash
if [ ! -d $VO_LSGRID_SW_DIR/python-2.6.4 ]; then 
  echo Python not found on this cluster.
  exit 1
fi
source $VO_LSGRID_SW_DIR/python-2.6.4/set_python_env.sh
python -V
python -c 'print "Hello world"'

This should give you the version (Python 2.6.4) in the stderror file and "Hello World" in the stdout file.