@@ -210,10 +210,12 @@ class Social_URLs(db.Model):
210210
211211 def __repr__ (self ) -> str :
212212 return f"{ self .Social_URL_ID } "
213- #==========================================================================================
213+ # ==========================================================================================
214214
215- #re-training logic
215+ # re-training logic
216216# @app.route("/get_all_users_skills", methods=['GET'])
217+
218+
217219def user_and_skills_for_retraining ():
218220 users = Student .query .all ()
219221 users_and_their_skills = dict ()
@@ -262,18 +264,20 @@ def call_to_retraining_function():
262264 print ('Retraining performed successfully' )
263265
264266
265- #counter logic
266- #==========================================================================================
267+ # counter logic
268+ # ==========================================================================================
267269counter_filename = 'counter.txt'
268270target_count_value = 25
269271
272+
270273def check_file_exists (filename ):
271- if (exists (filename )):
272- pass
273- else :
274- with open (filename , 'w' ) as f :
275- f .write ('0' )
276- f .close ()
274+ if (exists (filename )):
275+ pass
276+ else :
277+ with open (filename , 'w' ) as f :
278+ f .write ('0' )
279+ f .close ()
280+
277281
278282def check_counter (filename ):
279283 check_file_exists (filename )
@@ -285,31 +289,34 @@ def check_counter(filename):
285289 return True
286290 return False
287291
292+
288293def update_counter (filename ):
289- with open (filename , 'r' ) as f :
294+ with open (filename , 'r' ) as f :
290295 count = int (f .read ())
291- with open (filename , 'w' ) as f :
292- f .write (str (count + 1 ))
296+ with open (filename , 'w' ) as f :
297+ f .write (str (count + 1 ))
298+
293299
294300def reset_counter (filename ):
295- with open (filename , 'w' ) as f :
296- f .write ('0' )
301+ with open (filename , 'w' ) as f :
302+ f .write ('0' )
303+
297304
298305def should_call_retrain ():
299- global counter_filename
300- status = check_counter (counter_filename )
301- if (status ):
302- p1 = multiprocessing .Process (target = call_to_retraining_function )
303- p1 .start ()
304- reset_counter (counter_filename )
305- else :
306- update_counter (counter_filename )
307-
308- #==========================================================================================
306+ global counter_filename
307+ status = check_counter (counter_filename )
308+ if (status ):
309+ p1 = multiprocessing .Process (target = call_to_retraining_function )
310+ p1 .start ()
311+ reset_counter (counter_filename )
312+ else :
313+ update_counter (counter_filename )
314+
315+ # ==========================================================================================
309316
310317
311318# Routes
312- #==========================================================================================
319+ # ==========================================================================================
313320
314321# Homepage
315322@app .route ("/" , methods = ['GET' , 'POST' ])
@@ -323,7 +330,6 @@ def hello_world():
323330
324331@app .route ("/signup_and_login" , methods = ["POST" ])
325332def signup_and_login ():
326- # should_call_retrain()
327333 username = str (request .json ["username" ])
328334 new_user = False
329335 student = Student .query .filter_by (
@@ -367,7 +373,6 @@ def protected():
367373@app .route ("/get_recommendations" , methods = ['POST' ])
368374@jwt_required ()
369375def get_recommendations ():
370- # should_call_retrain()
371376 filter_skill_arr = request .json ['filter_skills' ]
372377 filter_skill_arr = [x .strip ().lower () for x in filter_skill_arr ]
373378 # print(filter_skill_arr)
@@ -672,7 +677,7 @@ def get_student_profile():
672677@app .route ("/update_student_profile" , methods = ['POST' ])
673678@jwt_required ()
674679def update_student_profile ():
675- # should_call_retrain()
680+ # should_call_retrain() # For new user sign up and name update for logged in users
676681 if request .method == "POST" :
677682 id = get_jwt_identity ()
678683 student = Student .query .filter_by (Student_ID = id ).first ()
@@ -1057,7 +1062,8 @@ def get_chats_after_last_cached():
10571062# }
10581063# or "DateTime": "Tue, 26 Oct 2021 13:10:38 GMT"
10591064
1060- #==============================================================================
1065+ # ==============================================================================
1066+
10611067
10621068if __name__ == "__main__" :
1063- app .run (debug = True ,threaded = True )
1069+ app .run (debug = True , threaded = True )
0 commit comments