-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsend_data.py
34 lines (28 loc) · 1003 Bytes
/
send_data.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import json
import uuid
from time import sleep
from datetime import datetime
import requests
from pyarrow import csv
table = csv.read_csv(".\evidently_service\datasets\sample_test_data.csv")
data = table.to_pylist()
class DateTimeEncoder(json.JSONEncoder):
def default(self, o):
if isinstance(o, datetime):
return o.isoformat()
return json.JSONEncoder.default(self, o)
with open("target.csv", 'w') as f_target:
for row in data:
# print(max(0,int(row['Pass/Fail'])))
row['id'] = str(uuid.uuid4())
duration = row['Pass/Fail']
data = json.dumps(row, cls=DateTimeEncoder)
# duration = str(duration)
f_target.write(f"{row['id']},{duration}\n")
resp = requests.post(
"http://127.0.0.1:9696/predict",
headers={"Content-Type": "application/json"},
data=json.dumps(row, cls=DateTimeEncoder),
).json()
print(f"prediction: {resp['Pass/Fail']}")
sleep(0.5)