Jython

From ScientificComputing
Jump to: navigation, search

Please note that this application page is referring to the old CentOS software stack which is obsolete and does not work any more with the new Ubuntu setup. You can find an overview on the Ubuntu software stack on this wiki page.

Category

Java, Python

Description

Jython follows closely the Python language and its reference implementation CPython, as created by Guido van Rossum. Jython 2.7 corresponds to CPython 2.7. Jython is an implementation of the Python language for the Java platform. Jython 2.7 implements the same language as CPython 2.7, and nearly all of the Core Python standard library modules. (CPython is the C implementation of the Python language.) Jython 2.7 uses the same regression test suite as CPython, with some minor modifications.

Available versions (Euler, old software stack)

Legacy versions Supported versions New versions
2.7.0

Please note that this page refers to installations from the old software stack. There are two software stacks on Euler. Newer versions of software are found in the new software stack.

Environment modules (Euler, old software stack)

Version Module load command Additional modules loaded automatically
2.7.0 module load gcc/4.8.2 python/2.7.6 java/1.8.0_31 jython/2.7.0 openblas/0.2.13_seq

Please note that this page refers to installations from the old software stack. There are two software stacks on Euler. Newer versions of software are found in the new software stack.

Interactive session

In order to start an interative Jython session, you first need to load the following modules:
[sfux@eu-login-06 ~]$ module load gcc/4.8.2 python/2.7.6 java/1.8.0_31 jython/2.7.0

You can then afterwards start the Jython interpreter with the command jython:

[sfux@eu-login-06 ~]$ jython
Picked up _JAVA_OPTIONS: -XX:ParallelGCThreads=1
*sys-package-mgr*: can't write cache file for '/cluster/apps/jython/2.7.0/x86_64/jython.jar'
*sys-package-mgr*: can't write index file
Jython 2.7.0 (default:9987c746f838, Apr 29 2015, 02:25:11) 
[Java HotSpot(TM) 64-Bit Server VM (Oracle Corporation)] on java1.8.0_31
Type "help", "copyright", "credits" or "license" for more information.
>>> 
Please do not run extensive computations in interactive sessions. All computations need to be submitted through the batch system.

How to submit a job

You can submit a Jython job (using the jython script test.py) with the following command:
sbatch [Slurm options] --wrap="jython test.py"
Here you need to replace [Slurm options] with Slurm parameters for the resource requirements of the job. Please find a documentation about the parameters of sbatch on the wiki page about the batch system.

Example

As an example for running a Jython job, we are printing out the mathematical constants \Pi<math> and <math>e. For this, we are using the following Jython script:
[leonhard@euler06 ~]$ ls
test.py
[leonhard@euler06 ~]$ cat test.py 
import math

print "Pi = %r" % math.pi
print "e = %r" % math.e

First you need to load the required modules for Jython:

[leonhard@euler06 ~]$ module load gcc/4.8.2 python/2.7.6 java/1.8.0_31 jython/2.7.0

then you can submit the job

[leonhard@euler06 ~]$ bsub -n 1 -W 0:05 -R "rusage[mem=128]" "jython test.py"
Generic job.
Job <33655748> is submitted to queue <normal.4h>.
[leonhard@euler06 ~]$ bjobs
JOBID      USER        STAT  QUEUE      FROM_HOST   EXEC_HOST   JOB_NAME   SUBMIT_TIME
33655748   leonhard    PEND  normal.4h  euler06                 *n test.py Dec  6 15:49
[leonhard@euler06 ~]$ bjobs
JOBID      USER        STAT  QUEUE      FROM_HOST   EXEC_HOST   JOB_NAME   SUBMIT_TIME
33655748   leonhard    RUN   normal.4h  euler06     e1359       *n test.py Dec  6 15:49
[leonhard@euler06 ~]$ bjobs
No unfinished job found
[leonhard@euler06 ~]$ grep -A1 "Pi =" lsf.o33655748 
Pi = 3.141592653589793
e = 2.718281828459045
The resource usage summary of the job can also be found in the LSF log file.

License information

Jython license

Links

http://www.jython.org

https://en.wikipedia.org/wiki/Jython
https://wiki.python.org/jython