Log In | Get Help   
Home My Page Projects Code Snippets Project Openings BonFIRE VCOC Demonstration Kit
Summary Activity SCM Files Wiki
[bonfiredemokit] Annotation of /ea/submit_rand.py
[bonfiredemokit] / ea / submit_rand.py Repository:
ViewVC logotype

Annotation of /ea/submit_rand.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 9 - (view) (download) (as text)

1 : agomez 9 #
2 :     # BonFIRE Virtual Clusters on Federated Clouds Demonstration Kit
3 :     #
4 :     # Copyright (c) Fundacion Centro Tecnologico de Supercomputacion de Galicia 2012
5 :     #
6 :     # License GPL Version 3
7 :     #
8 :     # The research leading to these results has received funding from
9 :     # the European Community's Seventh Frameqork Programme (FP7/2007-2013)
10 :     # under agreement number 257386
11 :     #
12 :     # This software is provided with ABSOLUTELY NO WARRANTY
13 :     #
14 : agomez 1 '''
15 :     Created on 03/01/2012
16 :    
17 :     @author: R. Valin
18 :     '''
19 :     import matplotlib.pyplot as plt
20 :     import time
21 :     #import os
22 :     import random
23 :     from exp.ea import experiment_type as expt
24 :     from exp.ea import ea_bonfire as ea
25 :    
26 :    
27 :    
28 :     """############################################
29 :     #Generacion aleatoria de experimentos #
30 :     ##############################################"""
31 :     #Lectura de datos del histograma de envio
32 :     #
33 :     dire='/home/cesga/bonfire/workspace/Bonfire/exp/dis'
34 :     print (dire + '/submit_time.csv')
35 :     file1 = open(dire + '/submit_time_norm.csv', 'r')
36 :     #Leemos ficheros estadisticas
37 :     sub_prob = file1.readlines()
38 :     file1.close()
39 :     #Crea una lista con los valores que lee del fichero
40 :     submit_prob = []
41 :     for a in sub_prob:
42 :     submit_prob.append(float(a.split(',')[1]))
43 :     #print(submit_prob)
44 :    
45 :     #Semilla para random si no pones nada en seed coge el tiempo del sistema
46 :     random.seed()
47 :    
48 :     print len(sub_prob)
49 :     #Prueba de que la lectura de datos es correcta
50 :     #b=0
51 :     #for a in submit_prob:
52 :     # b=b+a
53 :     #print ('Prob total', b)
54 :    
55 :    
56 :     #Asignacion del numero de trabajos cada media hora
57 :     jobs = 0
58 :     i = 0
59 :     #Inicializa prob
60 :     prob = 0
61 :     #Trabajos totales que quieres enviar
62 :     total_jobs = 100
63 :     envio = [0 for x in range(len(submit_prob))]
64 :     for a in range(total_jobs):
65 :     #Probabilidad de envio en una hora dada
66 :     prob_envio = random.random()
67 :    
68 :     #Con este algoritmo determinamos la hora (o el bin del histograma)
69 :     while (prob < prob_envio and prob_envio > prob + submit_prob[i + 1]):
70 :     i = i + 1
71 :     #print (i)
72 :     prob = prob + submit_prob[i]
73 :    
74 :     #Vector de trabajos a enviar por hora
75 :     if (i <= len(submit_prob)):
76 :     envio[i] = envio[i] + 1
77 :     else:
78 :     print('Me paso de indice')
79 :     #print prob_envio, prob, prob+submit_prob[i+1]
80 :     #Inicializamos variables para la siguiente iteracion
81 :     i = 0
82 :     prob = submit_prob[0]
83 :    
84 :     #plt.bar(range(1,49), envio, 1)
85 :     #plt.show()
86 :     file2=open('sub.csv', 'w')
87 :     for sub in envio:
88 :     file2.write(str(sub)+'\n')
89 :     file2.close()
90 :    
91 :     """################################################################
92 :     # Envio de experimentos #
93 :     ###################################################################"""
94 :     #Descripcion del trabajo en Json
95 :     #exp={'description': 'Experiment description',
96 :     # 'duration': 120,
97 :     # 'name': 'My Experiment',
98 :     # 'resources': [{'compute': {'name': 'JSON-COMPUTE-TEST',
99 :     # 'description': 'A description of the compute.',
100 :     # 'instanceType': 'small',
101 :     # 'locations': ['fr-inria'],
102 :     # 'resources':[{'storage': '@BonFIRE Debian Squeeze v3'},{'network':'@BonFIRE WAN'}]}}]}
103 :    
104 :    
105 :    
106 :    
107 :     #Indicamos la lista de sites a la que queremos enviar, la duracion de los experimentos
108 :     # y nos devuelve una lista con stings en json con la definicion del experimento
109 :     #locations=['be-ibbt','fr-inria','uk-hplabs','uk-uedin']
110 :    
111 :     #duration = 120
112 :     #locations = ['uk-uedin']
113 :     #exp, info_instance, info_storage, info_location = expt.json_exp(locations, duration)
114 :     #
115 :     #multi = 10
116 :     #
117 :     #for i in exp:
118 :     # print i
119 :     # m=str(i)
120 :     # for j in range(10):
121 :     # save(locations)
122 :     # location=info_location[m]
123 :     # instance=info_instance[m]
124 :     # store=info_storage[m]
125 :     # ea.ea_bf(i,instance,store,location)
126 :     #time.sleep(float(130))
127 :    
128 :    
129 :    

root@forge.cesga.es
ViewVC Help
Powered by ViewVC 1.0.0  

Powered By FusionForge