addressalign-toparrow-leftarrow-rightbackbellblockcalendarcameraccwcheckchevron-downchevron-leftchevron-rightchevron-small-downchevron-small-leftchevron-small-rightchevron-small-upchevron-upcircle-with-checkcircle-with-crosscircle-with-pluscrossdots-three-verticaleditemptyheartexporteye-with-lineeyefacebookfolderfullheartglobegmailgooglegroupshelp-with-circleimageimagesinstagramFill 1linklocation-pinm-swarmSearchmailmessagesminusmoremuplabelShape 3 + Rectangle 1ShapeoutlookpersonJoin Group on CardStartprice-ribbonShapeShapeShapeShapeImported LayersImported LayersImported Layersshieldstartickettrashtriangle-downtriangle-uptwitteruserwarningyahoo

PiCloud

From: James S.
Sent on: Wednesday, September 28, 2011 11:00 AM
Thanks for hosting Dave.

To follow up on our brief discussion of PiCloud:  What you get is on-demand execution of your pure python code.  Not sure what type of 'markup' this represents on EC2 pricing.  But a managed cloud in ~5 lines of code seems like a decent markDOWN in complexity.


Below is a wrapper module I named picloud.py.  To import elsewhere and run arbitrary functions.

Note the doctests!  Chronicling the evolution of the capability from no args to args to numpy to confirming we want func not just *args.  Culminating in a defacto documentation/tutorial.

(As you have all realized by now: my expertise is only in the TDD unit testing, not the actual coding ;-)

See ya'll next time.

--James
 . . . . . . . . . . . . . . . . . . . . .
   Berkeley Environmental Technology
   www.berkenviro.com
   www.imageseg.com
 . . . . . . . . . . . . . . . . . . . . .

"""
PiCloud architecture wrapper.

by James

Account: [address removed]
Installed: C:\Python26\ArcGIS10.0\python.exe
"""
import cloud 
cloud.setkey(1234, '4f76a1ce6getyourownfortrial')

def run(func, *args):
    """Run a Python function with args on PiCloud.
    
    >>> run(lambda: 1+2)
    3
    >>> def add(first, second):
    ...     return first + second
    >>> run(add, 1, 2)
    3
    >>> import numpy as np
    >>> run(np.sum, np.array([1, 2]))
    3
    >>> run()
    Traceback (most recent call last):
    ...
    TypeError: run() takes at least 1 argument (0 given)
    """
    job_id = cloud.call(func, *args)
    return cloud.result(job_id)

if __name__ == '__main__':
    import doctest
    doctest.testmod()

People in this
Meetup are also in:

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy