simple-2.py 2.17 KB
Newer Older
1
2
3
4
5
6
7
8
import requests, json, time 

url = "http://localhost:8766"
#train model request 

url_file = '/home/jean-didier/Projects/morphemic/performance-model/ml_code/example/dataset.csv'
url_file_3 = '/home/jean-didier/Projects/morphemic/performance-model/ml_code/example/all.csv'

Jean-Didier Totow's avatar
Jean-Didier Totow committed
9
10
url_file_4 = '/var/performance_model/datasets/all.csv'

11
12
#features = ['time','served_request','request_rate','response_time','performance','cpu_usage','memory']
#features_3 = ['number','served_request','request_rate','number_instances','response_time','performance','cpu_usage','cpu_alloc','memory','memory_alloc']
Jean-Didier Totow's avatar
Jean-Didier Totow committed
13
14
#features_2 = ['cpu_usage','memory','level','response_time','latency']
features_4 = ["EstimatedRemainingTimeContext","SimulationLeftNumber","SimulationElapsedTime","NotFinishedOnTime","MinimumCoresContext","NotFinished","WillFinishTooSoonContext","NotFinishedOnTimeContext","MinimumCores","ETPercentile","RemainingSimulationTimeMetric","TotalCores"]
15
16
17


#post_data = {'url_file': url_file, 'application': 'application-1','target':'performance','features': features}
Jean-Didier Totow's avatar
Jean-Didier Totow committed
18
#post_data_2 = {'url_file': "", 'application': 'demo','target':'response_time','features': features_2, "variant": "vm"}
19
#post_data_3 = {'url_file': url_file_3, 'application': 'application-3','target':'performance','features': features_3}
Jean-Didier Totow's avatar
Jean-Didier Totow committed
20
post_data_4 = {'url_file': url_file_4, 'application': 'genome','target':'EstimatedRemainingTimeContext','features': features_4,'variant':'vm'}
21
22
23
24
25
#print("Get model")
#response = requests.post(url+"/api/v1/model", data='{"application":"application-2"}', headers={'Content-Type':'application/json'})
#print(response.text)


Jean-Didier Totow's avatar
Jean-Didier Totow committed
26
27
28
response = requests.post(url+"/api/v1/model/train", data=json.dumps(post_data_4),headers={'Content-Type':'application/json'}).text 
print("Training phase")
print(response)
29
30
31
32
33

#time.sleep(5)
#prediction request 

#features = {'cpu_alloc': 1 ,'memory_alloc': 64,'number_instances':4, "memory": 51086677.3333}
Jean-Didier Totow's avatar
Jean-Didier Totow committed
34
35
36
37
#features = {'cpu_usage': 31, "memory": 4500.23, 'latency': 2.1, 'level': 1}
#post_data = {'application': 'fcr','target':'response_time','features':features}
#response = requests.post(url+"/api/v1/model/predict", data=json.dumps(post_data),headers={'Content-Type':'application/json'}).text 
#print(response)