Esempio n. 1
0
def run():		
	print "first"
	if not (0<= num(params["n_levels"]) <= 3) :
		params["n_levels"] = "0"
	
	params["n_levels"] = "0"
	if not(1<= num(params['n_nodes']) <=200):
		params['n_nodes']= "10"

	db.load('plots.db',False)
	angList = distributeJob(num(params['angle_start']), num(params['angle_stop']), num(params['n_angles']))
	names = db.getall()

	#removes the angles and nodes that already have been computed 
	angList = [a for a in angList if "air_a"+str(a)+"_n"+str(params['n_nodes'])+".png" not in names]
				
	#no need to start new computations if it has been done
	if(len(angList) == 0):		
		return render_template('params.html', params=params, airfoil_params=airfoil_params,
	status="This simulation has already been done", results="Click on the wanted plot to display it", images = names)
	 
	#start new workers if needed
	distribute_work(len(angList))

	#creates a group of tasks 
	job = group(computeResults.s(params, airfoil_params, i) for i in angList)
	global task 

	#distributes the job
	task= job.apply_async()
	
	print "Celery is working..."
	
	return redirect('/params')
Esempio n. 2
0
def run():		
	print "first"
	if not (0<= num(params["n_levels"]) <= 3) :
		params["n_levels"] = "1"
	
	params["n_levels"] = "0"
	if not(1<= num(params['n_nodes']) <=200):
		params['n_nodes']= "10"
	
	#if (num(params['angle_stop']) - num(params['angle_start']) >= num(params['n_angles']) ):
	#	params['n_angles'] = str((num(params['angle_stop']) - num(params['angle_start']))/2)

	db.load('plots.db',False)
	angList = distributeJob(num(params['angle_start']), num(params['angle_stop']), num(params['n_angles']))
	names = db.getall()
	#names = os.listdir(os.path.join(app.static_folder))
	angList = [a for a in angList if "air_a"+str(a)+"_n"+str(params['n_nodes'])+".png" not in names]
				
	if(len(angList) == 0):		
		return render_template('params.html', params=params, airfoil_params=airfoil_params,
	status="This simulation has already been done", results="Click on the wanted plot to display it", images = names)
	 
	#start new workers
	#distribute_work(num(params['n_angles']))
	distribute_work(len(angList))

	job = group(computeResults.s(params, airfoil_params, i) for i in angList)
	print job
	global task 
	task= job.apply_async()
	
	print "Celery is working..."
	
	return redirect('/params')