<commit_before>import threading
import time
import GPy
import numpy as np
from matplotlib import pyplot as plt
from cloudUnit import cloudUnit
from poap.tcpserve import ThreadedTCPServer
from poap.strategy import FixedSampleStrategy
from poap.strategy import InputStrategy

# Evaluate points in initial sweep
numevals = 20
X = np.linspace(-3, 3, num=numevals)

# Start Up TCP Server
strategy = FixedSampleStrategy(X)
server = ThreadedTCPServer(sockname=('0.0.0.0', 3000), strategy=strategy)

# Get Server Socket
name = server.sockname 
print "Starting Server on socket ", name

# Start CloudUnit Worker
unit = cloudUnit('xenon-marker-147522')
unit.startWorker()
print "Worker Successfully Started"

# Start Server
cthread = threading.Thread(target=server.run)
cthread.start()
cthread.join()
Xnew = np.zeros([len(server.controller.fevals), 1])
Ynew = np.zeros([len(server.controller.fevals), 1])
for k in range(len(server.controller.fevals)):
	Ynew[k] = server.controller.fevals[k].value
	Xnew[k] = server.controller.fevals[k].params
kernel = GPy.kern.RBF(input_dim=1, variance=1., lengthscale=1.)
plt.ion()
plt.show()
for i in range(2,len(Xnew)):
	m = GPy.models.GPRegression(Xnew[0:i],Ynew[0:i],kernel)
	fig = m.plot()
	plt.pause(.5)
result = server.controller.best_point()
unit.cleanupWorkers()
print("Final: {0:.3e} @ {1}".format(result.value, result.params))
<commit_msg>Working GPserverdemo<commit_after>import threading
import time
import GPy
import numpy as np
from matplotlib import pyplot as plt
from cloudUnit import cloudUnit
from poap.tcpserve import ThreadedTCPServer
from poap.strategy import FixedSampleStrategy
from poap.strategy import InputStrategy

# Evaluate points in initial sweep
numevals = 20
X = 2*np.random.random(numevals)-1

# Start Up TCP Server
strategy = FixedSampleStrategy(X)
server = ThreadedTCPServer(sockname=('0.0.0.0', 3000), strategy=strategy)

# Get Server Socket
name = server.sockname 
print "Starting Server on socket ", name

# Start CloudUnit Worker
unit = cloudUnit('xenon-marker-147522')
unit.startWorker()
print "Worker Successfully Started..."

# Start Server
cthread = threading.Thread(target=server.run)
cthread.start()
time.sleep(35)
plt.ion()
plt.show()
while(len(server.controller.fevals) < numevals):
	try:
		time.sleep(1.5)
		Xnew = np.zeros([len(server.controller.fevals), 1])
		Ynew = np.zeros([len(server.controller.fevals), 1])
		for k in range(len(server.controller.fevals)):
			Ynew[k] = server.controller.fevals[k].value
			Xnew[k] = server.controller.fevals[k].params
		idx = np.isnan(Ynew)
		idx = np.nonzero(idx)
		Xnew = np.delete(Xnew, idx)
		Ynew = np.delete(Ynew, idx)
		Ynew = np.reshape(Ynew, [len(Ynew), 1])
		Xnew = np.reshape(Xnew, [len(Xnew), 1])
		print Xnew
		print Ynew
		kernel = GPy.kern.RBF(input_dim=1, variance=1., lengthscale=1.)
		m = GPy.models.GPRegression(Xnew,Ynew,kernel)
		fig = m.plot()
		plt.pause(.5)
#		m.optimize_restarts(3)
	except:
		print('Waiting...')
cthread.join()
result = server.controller.best_point()
unit.cleanupWorkers()
print("Final: {0:.3e} @ {1}".format(result.value, result.params))

{'fraction_non_alphanumeric': 0.13565891472868216, 'fraction_numerical': 0.020671834625323, 'mean_word_length': 5.385567010309279, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1509935', 'n_tokens_mistral': 1185, 'n_tokens_neox': 1118, 'n_words': 257}