Skip to content

Commit 43c778e

Browse files
report can now be received by client
1 parent 51b6131 commit 43c778e

15 files changed

+65
-9
lines changed
4.66 KB
Binary file not shown.

__pycache__/models.cpython-38.pyc

3.32 KB
Binary file not shown.

__pycache__/utils.cpython-38.pyc

426 Bytes
Binary file not shown.

app.py

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,13 @@ def choose_file_callback(sender, app_data):
8585

8686
def send_model_data():
8787
model_degree = dpg.get_value("model_degree")
88+
client.send(model_degree.encode())
89+
print(f"model degree is {model_degree}")
8890
model_test_percentage = str(dpg.get_value("model_test_percentage"))
8991
print(dpg.get_value("model_degree"))
9092
print(dpg.get_value("model_test_percentage"))
9193
#======client code starts=====
92-
client.send(model_degree.encode())
94+
9395
client.send(model_test_percentage.encode())
9496
#========client code ends=======
9597

@@ -99,6 +101,32 @@ def send_model_data():
99101
dpg.add_text("Data sent to server")
100102
dpg.add_text("Model is getting trained by the model.....")
101103

104+
#==============client code starts===========
105+
#Receive Report from server
106+
file_size = client.recv(1024).decode()
107+
print(file_size)
108+
file_path = 'sentreport.pdf'
109+
file = open(file_path, "wb")
110+
c = 0
111+
# Starting the time capture.
112+
start_time = time.time()
113+
114+
# Running the loop while file is recieved.
115+
while c < int(file_size):
116+
data = client.recv(1024)
117+
if not (data):
118+
break
119+
file.write(data)
120+
c += len(data)
121+
file.close()
122+
123+
# Ending the time capture.
124+
end_time = time.time()
125+
126+
print("[INFO]: Report file received. Total time: ", end_time - start_time)
127+
128+
129+
#===========client code ends========
102130

103131
def get_model_inputs():
104132
pass

dataset.csv

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
x,y
22
32.502345269453031,31.70700584656992
33
53.426804033275019,68.77759598163891
4-
61.530358025636438,62.562382297945803
4+
61.53035802563,62.56238229794
55
47.475639634786098,71.546632233567777
66
59.813207869512318,87.230925133687393
77
55.142188413943821,78.211518270799232
@@ -98,5 +98,4 @@ x,y
9898
49.239765342753763,72.111832469615663
9999
50.039575939875988,85.232007342325673
100100
48.149858891028863,66.224957888054632
101-
25.128484647772304,53.454394214850524
102-
22.23, 21.23
101+
25.128484647772304,53.454394214850524

models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def reg_training_model(df, user_dir, degree = 1, split_ratio = 0.2):
6868
plt.legend(loc='upper left')
6969
plt.title("Polynomial Fitting")
7070
plt.savefig(f"{user_dir}/fitting.png")
71-
plt.show()
71+
# plt.show()
7272

7373

7474
##-------------------------------------------------
@@ -135,6 +135,6 @@ def reg_training_model(df, user_dir, degree = 1, split_ratio = 0.2):
135135
sm.qqplot(residual_test, line='45', ax = ax2)
136136
ax2.set_title("Test")
137137
ax2.set_ylabel("Standard Residual")
138-
plt.savefig(f"{user_dir}/residual_pred.png")
138+
plt.savefig(f"{user_dir}/normalqq.png")
139139
return 0
140140

sentreport.pdf

2.26 MB
Binary file not shown.

server1.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
#receive info about model training from client
6565
degree = conn.recv(100).decode()
6666
print(degree)
67+
print("hello")
6768
training_ratio = conn.recv(100).decode()
6869
print(training_ratio)
6970

@@ -74,7 +75,36 @@
7475
reg_training_model(df, degree = int(degree), split_ratio = int(training_ratio)/100, user_dir = user_dir)
7576

7677
tot, maxi, mini, mean, medi, sd = stats_summary(df)
78+
print("model training done......")
7779
c_report(tot, maxi, mini, mean, medi, sd, training_points, testing_points, degree, split = training_ratio, user_dir = user_dir)
80+
print(str(tot))
81+
print("report generated now")
82+
83+
84+
file_path = f'./server_data/{initial}/report.pdf'
85+
file_size = os.path.getsize(file_path)
86+
print(file_size)
87+
conn.send(str(file_size).encode())
88+
89+
90+
with open(file_path, "rb") as file:
91+
c = 0
92+
# Starting the time capture.
93+
start_time = time.time()
94+
95+
# Running loop while c != file_size.
96+
while c <= file_size:
97+
data = file.read(1024)
98+
if not (data):
99+
break
100+
conn.sendall(data)
101+
c += len(data)
102+
103+
# Ending the time capture.
104+
end_time = time.time()
105+
106+
print("[INFO] Report file Transfer Complete.Total time: ", end_time - start_time)
107+
78108

79109
# Closing the socket.
80110
conn.close()

server_data/jen/actual_pred.png

1.26 KB
Loading

server_data/jen/compare_error.png

-485 Bytes
Loading

0 commit comments

Comments
 (0)