Skip to content

Commit

Permalink
Merge branch 'release/0.13.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
dan-blanchard committed Oct 8, 2014
2 parents 39d3b1b + f8a1463 commit f2eda18
Show file tree
Hide file tree
Showing 14 changed files with 147 additions and 92 deletions.
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
language: python
python:
- 2.7
- 3.3
- 3.4

notifications:
email: false

# Install stuff
virtualenv:
system_site_packages: true
before_install:
- travis/install_sge.sh
- export SGE_ROOT=/var/lib/gridengine
Expand Down
11 changes: 6 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ A package to allow you to easily create jobs on the cluster directly from
Python. You can directly map Python functions onto the cluster without needing
to write any wrapper code yourself.

This is the ETS fork of an older project called Python Grid. Unlike the older
version, it is Python 2/3 compatible. Another major difference is that you can
change the configuration via environment variables instead of having to modify
a Python file in your ``site-packages`` directory. We've also removed some cruft
and improved the reliability of some of the features.
This is the ETS fork of an older project called `Python Grid <https://github.com/cwidmer/pythongrid>`__. Unlike the older
version, it is Python 2/3 compatible. Another major difference is that you can
change the configuration via environment variables instead of having to modify
a Python file in your ``site-packages`` directory. We've also removed some
cruft and improved the reliability of some of the features.

For some examples of how to use it, check out ``map_reduce.py`` (for a simple
example of how you can map a function onto the cluster) and ``manual.py`` (for
Expand All @@ -46,6 +46,7 @@ Requirements
~~~~~~~~~~~~

- `drmaa <https://github.com/drmaa-python/drmaa-python>`__
- `psutil <https://github.com/giampaolo/psutil>`__
- `pyzmq <https://github.com/zeromq/pyzmq>`__
- Python 2.7+

Expand Down
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def __getattr__(cls, name):

# General information about the project.
project = u'GridMap'
copyright = u'2008-2012 Max-Planck-Society, 2012-2013 ETS'
copyright = u'2008-2012 Max-Planck-Society, 2012-2014 ETS'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down Expand Up @@ -276,7 +276,7 @@ def __getattr__(cls, name):
epub_title = u'GridMap'
epub_author = u'Daniel Blanchard, Cheng Soon Ong, Christian Widmer'
epub_publisher = u'Educational Testing Service'
epub_copyright = u'2008-2012 Max-Planck-Society, 2012-2013 Educational Testing Service'
epub_copyright = u'2008-2012 Max-Planck-Society, 2012-2014 Educational Testing Service'

# The language of the text. It defaults to the language option
# or en if the language is not set.
Expand Down
31 changes: 25 additions & 6 deletions examples/manual.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

# Written (W) 2008-2012 Christian Widmer
# Written (W) 2008-2010 Cheng Soon Ong
# Written (W) 2012-2013 Daniel Blanchard, dblanchard@ets.org
# Copyright (C) 2008-2012 Max-Planck-Society, 2012-2013 ETS
# Written (W) 2012-2014 Daniel Blanchard, dblanchard@ets.org
# Copyright (C) 2008-2012 Max-Planck-Society, 2012-2014 ETS

# This file is part of GridMap.

Expand All @@ -28,16 +28,29 @@

from __future__ import print_function, unicode_literals

import time
import logging
from datetime import datetime

from gridmap import Job, process_jobs


def sleep_walk(secs):
'''
Pass the time by adding numbers until the specified number of seconds has
elapsed. Intended as a replacement for ``time.sleep`` that doesn't leave the
CPU idle (which will make the job seem like it's stalled).
'''
start_time = datetime.now()
num = 0
while (datetime.now() - start_time).seconds < secs:
num = num + 1


def compute_factorial(n):
"""
computes factorial of n
"""
time.sleep(10)
sleep_walk(10)
ret = 1
for i in range(n):
ret = ret * (i + 1)
Expand All @@ -62,7 +75,9 @@ def make_jobs():

# create job objects
for arg in inputvec:
job = Job(compute_factorial, arg)
# The default queue used by the Job class is all.q. You must specify
# the `queue` keyword argument if that is not the name of your queue.
job = Job(compute_factorial, arg, queue='all.q')
jobs.append(job)

return jobs
Expand All @@ -73,6 +88,10 @@ def main():
run a set of jobs on cluster
"""

logging.captureWarnings(True)
logging.basicConfig(format=('%(asctime)s - %(name)s - %(levelname)s - ' +
'%(message)s'), level=logging.INFO)

print("=====================================")
print("======== Submit and Wait ========")
print("=====================================")
Expand All @@ -83,7 +102,7 @@ def main():
print("sending function jobs to cluster")
print("")

job_outputs = process_jobs(functionJobs)
job_outputs = process_jobs(functionJobs, max_processes=4)

print("results from each job")
for (i, result) in enumerate(job_outputs):
Expand Down
32 changes: 28 additions & 4 deletions examples/map_reduce.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

# Written (W) 2008-2012 Christian Widmer
# Written (W) 2008-2010 Cheng Soon Ong
# Written (W) 2012-2013 Daniel Blanchard, dblanchard@ets.org
# Copyright (C) 2008-2012 Max-Planck-Society, 2012-2013 ETS
# Written (W) 2012-2014 Daniel Blanchard, dblanchard@ets.org
# Copyright (C) 2008-2012 Max-Planck-Society, 2012-2014 ETS

# This file is part of GridMap.

Expand All @@ -30,13 +30,29 @@

from __future__ import print_function, unicode_literals

import logging
from datetime import datetime

from gridmap import grid_map


def sleep_walk(secs):
'''
Pass the time by adding numbers until the specified number of seconds has
elapsed. Intended as a replacement for ``time.sleep`` that doesn't leave the
CPU idle (which will make the job seem like it's stalled).
'''
start_time = datetime.now()
num = 0
while (datetime.now() - start_time).seconds < secs:
num = num + 1


def computeFactorial(n):
"""
computes factorial of n
"""
sleep_walk(10)
ret = 1
for i in range(n):
ret = ret * (i + 1)
Expand All @@ -48,10 +64,18 @@ def main():
execute map example
"""

args = [1, 2, 4, 8, 16]
logging.captureWarnings(True)
logging.basicConfig(format=('%(asctime)s - %(name)s - %(levelname)s - ' +
'%(message)s'), level=logging.INFO)

args = [3, 5, 10, 20]

intermediate_results = grid_map(computeFactorial, args, quiet=False)
# The default queue used by grid_map is all.q. You must specify
# the `queue` keyword argument if that is not the name of your queue.
intermediate_results = grid_map(computeFactorial, args, quiet=False,
max_processes=4, queue='all.q')

# Just print the items instead of really reducing. We could always sum them.
print("reducing result")
for i, ret in enumerate(intermediate_results):
print("f({0}) = {1}".format(args[i], ret))
Expand Down
4 changes: 2 additions & 2 deletions gridmap/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

# Written (W) 2008-2012 Christian Widmer
# Written (W) 2008-2010 Cheng Soon Ong
# Written (W) 2012-2013 Daniel Blanchard, dblanchard@ets.org
# Copyright (C) 2008-2012 Max-Planck-Society, 2012-2013 ETS
# Written (W) 2012-2014 Daniel Blanchard, dblanchard@ets.org
# Copyright (C) 2008-2012 Max-Planck-Society, 2012-2014 ETS

# This file is part of GridMap.

Expand Down
4 changes: 2 additions & 2 deletions gridmap/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

# Written (W) 2008-2012 Christian Widmer
# Written (W) 2008-2010 Cheng Soon Ong
# Written (W) 2012-2013 Daniel Blanchard, dblanchard@ets.org
# Copyright (C) 2008-2012 Max-Planck-Society, 2012-2013 ETS
# Written (W) 2012-2014 Daniel Blanchard, dblanchard@ets.org
# Copyright (C) 2008-2012 Max-Planck-Society, 2012-2014 ETS

# This file is part of GridMap.

Expand Down
17 changes: 2 additions & 15 deletions gridmap/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

# Written (W) 2008-2012 Christian Widmer
# Written (W) 2008-2010 Cheng Soon Ong
# Written (W) 2012-2013 Daniel Blanchard, dblanchard@ets.org
# Copyright (C) 2008-2012 Max-Planck-Society, 2012-2013 ETS
# Written (W) 2012-2014 Daniel Blanchard, dblanchard@ets.org
# Copyright (C) 2008-2012 Max-Planck-Society, 2012-2014 ETS

# This file is part of GridMap.

Expand Down Expand Up @@ -39,19 +39,6 @@
import re


def clean_path(path):
'''
Replace all weird SAN paths with normal paths. This is really
ETS-specific, but shouldn't harm anyone else.
'''

path = re.sub(r'/\.automount/\w+/SAN/NLP/(\w+)-(dynamic|static)',
r'/home/nlp-\1/\2', path)
path = re.sub(r'/\.automount/[^/]+/SAN/Research/HomeResearch',
'/home/research', path)
return path


def zdumps(obj):
"""
dumps pickleable object into bz2 compressed string
Expand Down
Loading

0 comments on commit f2eda18

Please sign in to comment.