예제 #1
0
    def create_executor(cls, allowCached=True):
        if not allowCached:
            return pyfora.connect('http://localhost:30000')

        if cls.executor is None:
            cls.executor = pyfora.connect('http://localhost:30000')
            cls.executor.stayOpenOnExit = True
        return cls.executor
예제 #2
0
    def create_executor(cls, allowCached=True):
        if not allowCached:
            return pyfora.connect('http://localhost:30000')

        if cls.executor is None:
            cls.executor = pyfora.connect('http://localhost:30000')
            cls.executor.stayOpenOnExit = True
        return cls.executor
예제 #3
0
 def setUpClass(cls):
     cls.config = Setup.config()
     cls.executor = None
     cls.simulation = ClusterSimulation.Simulator.createGlobalSimulator()
     cls.simulation.startService()
     cls.simulation.getDesirePublisher().desireNumberOfWorkers(1)
     cls.ufora = pyfora.connect('http://localhost:30000')
예제 #4
0
 def setUpClass(cls):
     cls.config = Setup.config()
     cls.executor = None
     cls.simulation = ClusterSimulation.Simulator.createGlobalSimulator()
     cls.simulation.startService()
     cls.simulation.getDesirePublisher().desireNumberOfWorkers(1)
     cls.ufora = pyfora.connect('http://localhost:30000')
import pyfora
import pandas as pd
from pyfora.pandas_util import read_csv_from_string
from pyfora.algorithms import linearRegression

print "Connecting..."
executor = pyfora.connect('http://localhost:30000')
print "Importing data..."
#raw_data = executor.importS3Dataset('ufora-test-data',
 #                                 'iid-normal-floats-20GB-20-columns.csv').result()

print "Parsing and regressing..."

#df = pd.read_csv('cara.csv', sep=';')
#print df 
#df = pd.read_cdfsv('caracteristicas_images.csv', sep=' ')

     
#X = df[list(df.columns)[1:]]
#mat = X.as_matrix()
##X.pop(0);
#print mat
#y = df['A58']
data_frame = pd.read_csv('cara.csv',sep=';')#
with executor.remotely:
    #data_frame = pd.read_csv('cara.csv',sep=';')#read_csv_from_string(raw_data)
    predictors = data_frame.iloc[:, :-1]
    responses = data_frame.iloc[:, -1:]

    regression_result = linearRegression(predictors, responses)
    coefficients = regression_result[:-1]
예제 #6
0
 def impure_method(self, host_and_port):
     return pyfora.connect(host_and_port)
예제 #7
0
 def impure_method(self, host_and_port):
     return pyfora.connect(host_and_port)
예제 #8
0
import pyfora
print 'hello'
#import boto.ec2
#conn = boto.ec2.connect_to_region('us-west-1')
ufora = pyfora.connect("http://localhost:30000")
print 'hi'
print 'helloo'


def isPrime(p):
    x = 2
    while x*x <= p:
        if p%x == 0:
            return 0
        x = x + 1
    return 1

print 'hi'
with ufora.remotely.downloadAll():
	result = sum(isPrime(x) for x in xrange(10))

print result
예제 #9
0
import pyfora

ufora = pyfora.connect('http://localhost:30000')



X = [[12,7,3],
    [4 ,5,6],
    [7 ,8,9]]

Y = [[5,8,1,2],
    [6,7,3,0],
    [4,5,9,1]]
# result is 3x4


def multi(X,Y):
	r2 = []
	for i in range(len(X)):
		r = []
		for j in range(len(Y[0])):
			s = 0
			for k in range(len(Y)):
				s = s + X[i][k] * Y[k][j]
			r = r + [s]
		r2 = r2 + [r]
	#r2[0][0]=999
	return r2        

def test(A,B):
	C=A+B