From 227403cf13c5c847cc9302ec99a572dc70213bb0 Mon Sep 17 00:00:00 2001 From: U18034332 Date: Wed, 16 Aug 2023 09:34:10 +0200 Subject: [PATCH 01/19] Reformated recommendations end point --- AI/Koja-AI.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/AI/Koja-AI.py b/AI/Koja-AI.py index e1304909..69511aef 100644 --- a/AI/Koja-AI.py +++ b/AI/Koja-AI.py @@ -8,6 +8,7 @@ app = Flask(__name__) + def load_data_and_models(): f = open('test.json') data = json.load(f) @@ -58,8 +59,10 @@ def load_data_and_models(): return user_model_index, weekday_model_index, time_frame_model_index + user_model_index, weekday_model_index, time_frame_model_index = load_data_and_models() + @app.route('/recommendations', methods=['POST']) def recommend_categories(): if request.is_json: From 55f61c8c3ea17df32e8f3281aad0f984713e8c18 Mon Sep 17 00:00:00 2001 From: U18034332 Date: Wed, 16 Aug 2023 09:40:58 +0200 Subject: [PATCH 02/19] Created get training data endpoint --- AI/Koja-AI.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/AI/Koja-AI.py b/AI/Koja-AI.py index 69511aef..b275d44b 100644 --- a/AI/Koja-AI.py +++ b/AI/Koja-AI.py @@ -1,3 +1,4 @@ +import requests from flask import Flask, request, jsonify import numpy as np import pandas as pd @@ -89,6 +90,15 @@ def recommend_categories(): else: return "Request was not JSON", 400 +@app.route('/training-data'): +def get_training_data: + api_url = "koja api endpoint" + headers = {'Authorization': 'Bearer YOUR_ACCESS_TOKEN'} + response = requests.get(api_url,headers=headers) + + if response.status_code == 200: + + if __name__ == "__main__": port = int(os.getenv("PORT", 6000)) From 02aeb6ec00080715114932c123249ed686f666a5 Mon Sep 17 00:00:00 2001 From: U18034332 Date: Wed, 16 Aug 2023 09:41:35 +0200 Subject: [PATCH 03/19] Further worked on get training data endpoint --- AI/Koja-AI.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/AI/Koja-AI.py b/AI/Koja-AI.py index b275d44b..0bf5a289 100644 --- a/AI/Koja-AI.py +++ b/AI/Koja-AI.py @@ -97,8 +97,7 @@ def get_training_data: response = requests.get(api_url,headers=headers) if response.status_code == 200: - - + data = response.json() if __name__ == "__main__": port = int(os.getenv("PORT", 6000)) From 1acd864036b89edfc4aac3e7781b1c32487f1b25 Mon Sep 17 00:00:00 2001 From: U18034332 Date: Wed, 16 Aug 2023 09:43:30 +0200 Subject: [PATCH 04/19] Added returns to get training data endpoint --- AI/Koja-AI.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/AI/Koja-AI.py b/AI/Koja-AI.py index 0bf5a289..d30219e9 100644 --- a/AI/Koja-AI.py +++ b/AI/Koja-AI.py @@ -98,6 +98,9 @@ def get_training_data: if response.status_code == 200: data = response.json() + return jsonify(data) + else: + return jsonify({'error': 'Failed to fetch data'}), 500 if __name__ == "__main__": port = int(os.getenv("PORT", 6000)) From 379c8bbf6024c8e3e4de1f59ee8fa1ee6ed5506f Mon Sep 17 00:00:00 2001 From: U18034332 Date: Wed, 16 Aug 2023 09:44:39 +0200 Subject: [PATCH 05/19] Reformated and removed bugs --- AI/Koja-AI.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/AI/Koja-AI.py b/AI/Koja-AI.py index d30219e9..c1c32c6d 100644 --- a/AI/Koja-AI.py +++ b/AI/Koja-AI.py @@ -90,11 +90,12 @@ def recommend_categories(): else: return "Request was not JSON", 400 -@app.route('/training-data'): -def get_training_data: + +@app.route('/training-data') +def get_training_data(): api_url = "koja api endpoint" headers = {'Authorization': 'Bearer YOUR_ACCESS_TOKEN'} - response = requests.get(api_url,headers=headers) + response = requests.get(api_url, headers=headers) if response.status_code == 200: data = response.json() @@ -102,6 +103,7 @@ def get_training_data: else: return jsonify({'error': 'Failed to fetch data'}), 500 + if __name__ == "__main__": port = int(os.getenv("PORT", 6000)) app.run(host='0.0.0.0', port=port, debug=True) From b6fff6e92e06f22689961168536eb6a21cbb2807 Mon Sep 17 00:00:00 2001 From: U18034332 Date: Wed, 16 Aug 2023 10:06:48 +0200 Subject: [PATCH 06/19] Reformated and removed bugs --- AI/category_model/fingerprint.pb | 2 +- .../variables/variables.data-00000-of-00001 | Bin 2770 -> 2770 bytes AI/category_model/variables/variables.index | Bin 307 -> 307 bytes AI/main.py | 5 ++++- AI/time_frame_model/fingerprint.pb | 2 +- .../variables/variables.data-00000-of-00001 | Bin 8210 -> 8210 bytes AI/time_frame_model/variables/variables.index | Bin 307 -> 307 bytes AI/user_model/fingerprint.pb | 2 +- .../variables/variables.data-00000-of-00001 | Bin 2512 -> 2512 bytes AI/user_model/variables/variables.index | Bin 307 -> 307 bytes AI/weekday_model/fingerprint.pb | 2 +- .../variables/variables.data-00000-of-00001 | Bin 2578 -> 2578 bytes AI/weekday_model/variables/variables.index | Bin 307 -> 307 bytes 13 files changed, 8 insertions(+), 5 deletions(-) diff --git a/AI/category_model/fingerprint.pb b/AI/category_model/fingerprint.pb index 27796c04..5a776e33 100644 --- a/AI/category_model/fingerprint.pb +++ b/AI/category_model/fingerprint.pb @@ -1 +1 @@ -ޫޏϤݻ ݻ (2 \ No newline at end of file +ޫޏϤݻ ݻ (ߓ2 \ No newline at end of file diff --git a/AI/category_model/variables/variables.data-00000-of-00001 b/AI/category_model/variables/variables.data-00000-of-00001 index f069da34f8c5cc0994b2dd3a8bac8e5d3be3198a..679fbc6657eb2ff7c9c6947c63705ce286cf1b76 100644 GIT binary patch delta 788 zcmWO3{ZGts902g{PR^<8>U7_GNY4^=cRjJ{`hMPp*-BDm8Pb~8VWw$>P)8oOlA0g1 zHtRvTQl3Im-_QFF#iEDxBu8^BTSMis)YgOkgx6lZvR;|t-M73-o20gg(6WtG9971h z(|Qm~n=2`4utX$WtZO;BzJbkfu3&Q7-f6^14avZW6$%9ABaCUHz^t+~$aGyz%+ci(dL`O+vlLGgc`VH(c zR*tw$f)#-wknbYIMQK@7ead)*P99A1ls>CTYYss-)p zP!vY@Q&GAK^ywjBBMODgQ2>W96|6J!u`+lqJ}wFZoCwGKi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%d{s$MP9Ly#uDwf4vtkj IJH2%M4+%qaxc~qF diff --git a/AI/category_model/variables/variables.index b/AI/category_model/variables/variables.index index 176986982b8cd54d25adfa22a66ddd5fdcb2a4a0..f9035adf75e0e092c03888ac7ddb945ed11bb0ad 100644 GIT binary patch delta 27 fcmdnYw3%tbMZsC-U;i@z0V9ZDeeOPa;-f$SgnS7t delta 27 fcmdnYw3%tbMM1Bwo~sN%zz8BTg(nnFd=v-(c;X0D diff --git a/AI/main.py b/AI/main.py index 49570a62..d55be6f3 100644 --- a/AI/main.py +++ b/AI/main.py @@ -1,4 +1,5 @@ import json +from abc import ABC from typing import Dict, Text import requests import pandas as pd @@ -129,8 +130,9 @@ candidates=all_candidates )) + # # Create a TFRS model -class CategoryRecommender(tfrs.models.Model): +class CategoryRecommender(tfrs.models.Model, ABC): def __init__(self, user_model, category_model, weekday_model, time_frame_model, task): super().__init__() self.user_model = user_model @@ -154,6 +156,7 @@ def compute_loss(self, features, training=False): # Combine these losses return user_loss + category_loss + weekday_loss + time_frame_loss + model = CategoryRecommender(user_model, category_model, weekday_model, time_frame_model, task) # # Configure and train the model diff --git a/AI/time_frame_model/fingerprint.pb b/AI/time_frame_model/fingerprint.pb index a3b86171..b411986d 100644 --- a/AI/time_frame_model/fingerprint.pb +++ b/AI/time_frame_model/fingerprint.pb @@ -1 +1 @@ -ڈ㬁ϽIJۋ ׿쩉(זӨO2 \ No newline at end of file +ڈ㬁ϽIJۋ ׿쩉(Ђۅ2 \ No newline at end of file diff --git a/AI/time_frame_model/variables/variables.data-00000-of-00001 b/AI/time_frame_model/variables/variables.data-00000-of-00001 index f9ba06c733a81b878bb2c19699d22d4c7accb1c2..4b4d4b83eca1ebb453a0e92f3cfcce5dda1ee347 100644 GIT binary patch delta 6281 zcmWNVhhNPL7{*Ich=znR3SH4qWK_TRBr-!nxI#&?$-E6YEh?2L8X9O1Nu<*GJ*SOm zXo}L*-X#+0_8+{TcYUAd@mc4yj$75?6ecy#o0%?IilRB^(KV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-=vnrM(DvK0P4%T)iqe+`Zdb|Gob*;=Qq) zrM=EVkv+DSpS{X=(!Ha9mBKyc{1iUls1rWQ6E(gHZL+)8 z5+gokOdme*$$z1h4ejyZ7x1(@6kO@5)r<%)ZaY- zXyiMfjpDpQ>4ZGGU);R#!aThrVKlv~K delta 27 fcmdnYw3%tbMZpzrUPl;!fDuG=&E?CP_$UwncJ2s2 diff --git a/AI/weekday_model/fingerprint.pb b/AI/weekday_model/fingerprint.pb index 95f36159..206a67b2 100644 --- a/AI/weekday_model/fingerprint.pb +++ b/AI/weekday_model/fingerprint.pb @@ -1 +1 @@ -ꓱ\▭ (ò=2 \ No newline at end of file +ꓱ\▭ (‐ЯD2 \ No newline at end of file diff --git a/AI/weekday_model/variables/variables.data-00000-of-00001 b/AI/weekday_model/variables/variables.data-00000-of-00001 index 7d5f3469cc21be5a0de063692f5cd06e5a8aff5d..69dbc832cd0f88abef25bcf4346ad715d26e2484 100644 GIT binary patch delta 594 zcmV-Y0+*T@4c}-q;v{CzK!BN5)7NY;$;y&m3&h@6*jTG1qH8vy-YawJ*Tg_J$nomJ{2uB zzVlrlK4|n8KKhEXJ<6K-J;IhSKB%VwzG58Nywo%SKICm?z5jSCK0&4uzJoRvKIXom zy|tm4y=NwW{k`wF5b+hqV7&#Fj=dftpgj{32fd}z={=eu)4eTIIlQ^XN4wRj zroB{1VLc7`KfOJzmA#Fn0Y3E{@jXQ$=Ddk~G`tdaf4$SktUV;Y@;#W3#yvzBqCHt% zf4%6Jwmoc6>%At%6g+MYmpz-TqrB3pW4+|3FFoOZaCf>5#DqPz=iEJ!*9|_2oESc3 zjKRG@4D>yfteJDO0 z83aCPS*ATF0yI8-0J=S=Cj31T-WR^oAdS8IiK#t`>;%5{v&20%N-Ms{eUv@yTyVYC z*e$+D-UlhZg(0^+0955T!*MLV&`+B?z0MRplVAV57U2aH)CcmMzZ delta 594 zcmV-Y0PVBGAz*)18qHQu9tJr0EgK1t#>KHY)~J$J?a zJ!(?bJ^!OLyQJ*C*Ly%~VkJTI^*zG9)uy~g3Ky~JfAKH(`ZJ{NEizGy5C zzBZOBzOL%2z1CKoz2;N)z4P?oJ^2KC-aF zy_`V@zWu0wn>`pC13m;;KRp#Mn!VHJ+&z{fj6H+_K|Q^CN}-J-x?uH@t;H;JwNDjJ-TaEj%tZs6FIyWxd@P zl|4f}d_4J<#!<`F&}WGOzcM&LbzF(L!2%>VBc^% g1HK16q9WToXCe(f05VQHW_U2l^l#)c^nh diff --git a/AI/weekday_model/variables/variables.index b/AI/weekday_model/variables/variables.index index e924aa29fb5e8fd2cad495f2142143140308fdb4..d6e6bdd7cd04015f82dc60902d5231d490790f8f 100644 GIT binary patch delta 27 fcmdnYw3%tbMZxY`2UP|jU<471TvzH%d=v-(ZX*ZH delta 27 fcmdnYw3%tbMZwk8Pp2{f0V9a0xV Date: Wed, 16 Aug 2023 10:09:59 +0200 Subject: [PATCH 07/19] Reformated and removed bugs --- AI/Koja-AI.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AI/Koja-AI.py b/AI/Koja-AI.py index c1c32c6d..66313e88 100644 --- a/AI/Koja-AI.py +++ b/AI/Koja-AI.py @@ -70,14 +70,14 @@ def recommend_categories(): data = request.get_json() user_id = data['userID'] - maxOutput = 7 + max_output = 7 _, titles = user_model_index(np.array([user_id])) recommendations = [] for category_id in titles[0][:10]: # Convert TensorFlow EagerTensor to numpy array category_id_np = category_id.numpy().decode("utf-8") - _, weekdays = weekday_model_index(np.array([category_id_np]), k=maxOutput) + _, weekdays = weekday_model_index(np.array([category_id_np]), k=max_output) _, time_frames = time_frame_model_index(np.array([category_id_np])) recommendations.append({ From 34a687586c9e8bd6a3fb8d2bc83f6ab09f9e9a08 Mon Sep 17 00:00:00 2001 From: U18034332 Date: Mon, 21 Aug 2023 13:04:05 +0200 Subject: [PATCH 08/19] Added load model --- AI/Koja-AI.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/AI/Koja-AI.py b/AI/Koja-AI.py index 66313e88..6a7b23c4 100644 --- a/AI/Koja-AI.py +++ b/AI/Koja-AI.py @@ -63,6 +63,11 @@ def load_data_and_models(): user_model_index, weekday_model_index, time_frame_model_index = load_data_and_models() +def load_model(): + user_model = tf.keras.models.load_model("user_model") + category_model = tf.keras.models.load_model("category_model") + weekday_model = tf.keras.models.load_model("weekday_model") + time_frame_model = tf.keras.models.load_model("time_frame_model") @app.route('/recommendations', methods=['POST']) def recommend_categories(): From 9cd3e01e5ab87459b7fe7805b3cc7b656bc44800 Mon Sep 17 00:00:00 2001 From: U18034332 Date: Mon, 21 Aug 2023 13:32:51 +0200 Subject: [PATCH 09/19] Added load model --- AI/Koja-AI.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/AI/Koja-AI.py b/AI/Koja-AI.py index 6a7b23c4..092be5ec 100644 --- a/AI/Koja-AI.py +++ b/AI/Koja-AI.py @@ -63,12 +63,6 @@ def load_data_and_models(): user_model_index, weekday_model_index, time_frame_model_index = load_data_and_models() -def load_model(): - user_model = tf.keras.models.load_model("user_model") - category_model = tf.keras.models.load_model("category_model") - weekday_model = tf.keras.models.load_model("weekday_model") - time_frame_model = tf.keras.models.load_model("time_frame_model") - @app.route('/recommendations', methods=['POST']) def recommend_categories(): if request.is_json: From b9ebf0e6ef18192ab69c44f33ddc43e1542386cf Mon Sep 17 00:00:00 2001 From: U18034332 Date: Mon, 21 Aug 2023 13:41:50 +0200 Subject: [PATCH 10/19] Clean training data --- AI/Koja-AI.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/AI/Koja-AI.py b/AI/Koja-AI.py index 092be5ec..f1e86f68 100644 --- a/AI/Koja-AI.py +++ b/AI/Koja-AI.py @@ -63,6 +63,32 @@ def load_data_and_models(): user_model_index, weekday_model_index, time_frame_model_index = load_data_and_models() +def clean_training_data(training_data): + data = json.load(training_data) + all_events = [] + + for block in data: + expanded_events = [] + for event in block['training'] + block['testing']: + for time_frame in event['timeFrame']: + new_event = event.copy() + new_event['startTime'] = time_frame['first'].strip() + new_event['endTime'] = time_frame['second'].strip() + new_event['category'] = event['category'].strip() + new_event['weekday'] = event['weekday'].strip() + new_event['userID'] = event['userID'].strip() + new_event['timeFrame'] = f"{new_event['startTime']}-{new_event['endTime']}" + expanded_events.append(new_event) + + all_events += expanded_events + + return all_events + + + +def retrain_for_new_users(training_data): + + @app.route('/recommendations', methods=['POST']) def recommend_categories(): if request.is_json: From a6b36ec31c7f8414bcc45d1353f75517ef30709c Mon Sep 17 00:00:00 2001 From: U18034332 Date: Mon, 21 Aug 2023 13:44:03 +0200 Subject: [PATCH 11/19] Load training data for retrain on new users --- AI/Koja-AI.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/AI/Koja-AI.py b/AI/Koja-AI.py index f1e86f68..1ac1f50d 100644 --- a/AI/Koja-AI.py +++ b/AI/Koja-AI.py @@ -63,6 +63,7 @@ def load_data_and_models(): user_model_index, weekday_model_index, time_frame_model_index = load_data_and_models() + def clean_training_data(training_data): data = json.load(training_data) all_events = [] @@ -85,8 +86,8 @@ def clean_training_data(training_data): return all_events - def retrain_for_new_users(training_data): + events_data = clean_training_data(training_data) @app.route('/recommendations', methods=['POST']) From c884fe66c201cdbc17a74912de3fd0bc6888ad68 Mon Sep 17 00:00:00 2001 From: U18034332 Date: Mon, 21 Aug 2023 13:58:20 +0200 Subject: [PATCH 12/19] Auto retrain every 24 hours --- AI/main.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/AI/main.py b/AI/main.py index d55be6f3..84e6bdab 100644 --- a/AI/main.py +++ b/AI/main.py @@ -2,6 +2,8 @@ from abc import ABC from typing import Dict, Text import requests +import time +import schedule import pandas as pd import tensorflow as tf import tensorflow_recommenders as tfrs @@ -199,3 +201,9 @@ def compute_loss(self, features, training=False): category_model.save("category_model") weekday_model.save("weekday_model") time_frame_model.save("time_frame_model") + +schedule.every(24).hours.do(retrain_for_new_users(training_data)) + +while True: + schedule.run_pending() + time.sleep(1) From b028a338e13916671dd68391706163fb177f205d Mon Sep 17 00:00:00 2001 From: U18034332 Date: Mon, 21 Aug 2023 14:15:29 +0200 Subject: [PATCH 13/19] Auto retrain every fix --- AI/main.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/AI/main.py b/AI/main.py index 84e6bdab..0c4ad886 100644 --- a/AI/main.py +++ b/AI/main.py @@ -1,3 +1,4 @@ +import datetime import json from abc import ABC from typing import Dict, Text @@ -202,7 +203,11 @@ def compute_loss(self, features, training=False): weekday_model.save("weekday_model") time_frame_model.save("time_frame_model") -schedule.every(24).hours.do(retrain_for_new_users(training_data)) +now = datetime.datetime.now() +next_retrain_time = now.replace(hour=23, minute=59, second=0, microsecond=0) +if now > next_retrain_time: + next_retrain_time += datetime.timedelta(days=1) + while True: schedule.run_pending() From 5e5a91f9cfd2335f59df078cad6e4e1cdb61e5a5 Mon Sep 17 00:00:00 2001 From: U18034332 Date: Mon, 21 Aug 2023 14:16:54 +0200 Subject: [PATCH 14/19] Auto retrain scheduler added --- AI/main.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/AI/main.py b/AI/main.py index 0c4ad886..9c4129e6 100644 --- a/AI/main.py +++ b/AI/main.py @@ -208,6 +208,9 @@ def compute_loss(self, features, training=False): if now > next_retrain_time: next_retrain_time += datetime.timedelta(days=1) +schedule.every().day.at(next_retrain_time.strftime("%H:%M")).do(retrain_for_new_users(training_data)) + + while True: schedule.run_pending() From ee2802eea302c485596b8b734e262f493c36f47c Mon Sep 17 00:00:00 2001 From: U18034332 Date: Mon, 21 Aug 2023 14:17:45 +0200 Subject: [PATCH 15/19] Added auto schedule runner --- AI/main.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/AI/main.py b/AI/main.py index 9c4129e6..f1147a00 100644 --- a/AI/main.py +++ b/AI/main.py @@ -210,6 +210,9 @@ def compute_loss(self, features, training=False): schedule.every().day.at(next_retrain_time.strftime("%H:%M")).do(retrain_for_new_users(training_data)) +while True: + schedule.run_pending() + time.sleep(1) while True: From e2eff9ef6d853617202d0bc8f6f500aace4b82c1 Mon Sep 17 00:00:00 2001 From: U18034332 Date: Mon, 21 Aug 2023 14:20:29 +0200 Subject: [PATCH 16/19] Bug fixes on auto retrain --- AI/Koja-AI.py | 17 +++++++++++++++++ AI/main.py | 2 -- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/AI/Koja-AI.py b/AI/Koja-AI.py index 1ac1f50d..7590ee29 100644 --- a/AI/Koja-AI.py +++ b/AI/Koja-AI.py @@ -90,6 +90,23 @@ def retrain_for_new_users(training_data): events_data = clean_training_data(training_data) +now = datetime.datetime.now() +next_retrain_time = now.replace(hour=23, minute=59, second=0, microsecond=0) +if now > next_retrain_time: + next_retrain_time += datetime.timedelta(days=1) + +schedule.every().day.at(next_retrain_time.strftime("%H:%M")).do(retrain_for_new_users(training_data)) + +while True: + schedule.run_pending() + time.sleep(1) + + +while True: + schedule.run_pending() + time.sleep(1) + + @app.route('/recommendations', methods=['POST']) def recommend_categories(): if request.is_json: diff --git a/AI/main.py b/AI/main.py index f1147a00..239bbd85 100644 --- a/AI/main.py +++ b/AI/main.py @@ -3,8 +3,6 @@ from abc import ABC from typing import Dict, Text import requests -import time -import schedule import pandas as pd import tensorflow as tf import tensorflow_recommenders as tfrs From 922fa3f72ccec28513b3f1ea7a35a5cc8bb06df6 Mon Sep 17 00:00:00 2001 From: U18034332 Date: Mon, 21 Aug 2023 14:22:13 +0200 Subject: [PATCH 17/19] Bug fixes on auto retrain v2 --- AI/Koja-AI.py | 5 +++++ AI/main.py | 16 ---------------- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/AI/Koja-AI.py b/AI/Koja-AI.py index 7590ee29..02f2a4d2 100644 --- a/AI/Koja-AI.py +++ b/AI/Koja-AI.py @@ -1,10 +1,15 @@ import requests +import schedule as schedule from flask import Flask, request, jsonify import numpy as np import pandas as pd import tensorflow as tf import tensorflow_recommenders as tfrs import json +import time +import schedule +import datetime + import os app = Flask(__name__) diff --git a/AI/main.py b/AI/main.py index 239bbd85..b96edfea 100644 --- a/AI/main.py +++ b/AI/main.py @@ -1,4 +1,3 @@ -import datetime import json from abc import ABC from typing import Dict, Text @@ -201,18 +200,3 @@ def compute_loss(self, features, training=False): weekday_model.save("weekday_model") time_frame_model.save("time_frame_model") -now = datetime.datetime.now() -next_retrain_time = now.replace(hour=23, minute=59, second=0, microsecond=0) -if now > next_retrain_time: - next_retrain_time += datetime.timedelta(days=1) - -schedule.every().day.at(next_retrain_time.strftime("%H:%M")).do(retrain_for_new_users(training_data)) - -while True: - schedule.run_pending() - time.sleep(1) - - -while True: - schedule.run_pending() - time.sleep(1) From 41f26bfa50da37f3ec6bccc93befb22f731dc95a Mon Sep 17 00:00:00 2001 From: U18034332 Date: Mon, 21 Aug 2023 14:25:38 +0200 Subject: [PATCH 18/19] Removed duplicate code --- AI/Koja-AI.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/AI/Koja-AI.py b/AI/Koja-AI.py index 02f2a4d2..cb1c7fef 100644 --- a/AI/Koja-AI.py +++ b/AI/Koja-AI.py @@ -107,11 +107,6 @@ def retrain_for_new_users(training_data): time.sleep(1) -while True: - schedule.run_pending() - time.sleep(1) - - @app.route('/recommendations', methods=['POST']) def recommend_categories(): if request.is_json: From 160d93f38525c3d1b4898f6d457bb24e01fb0609 Mon Sep 17 00:00:00 2001 From: U18034332 Date: Mon, 21 Aug 2023 14:37:55 +0200 Subject: [PATCH 19/19] Bug fixes on auto retrain v2 --- AI/Koja-AI.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/AI/Koja-AI.py b/AI/Koja-AI.py index cb1c7fef..f13480d0 100644 --- a/AI/Koja-AI.py +++ b/AI/Koja-AI.py @@ -95,16 +95,17 @@ def retrain_for_new_users(training_data): events_data = clean_training_data(training_data) -now = datetime.datetime.now() -next_retrain_time = now.replace(hour=23, minute=59, second=0, microsecond=0) -if now > next_retrain_time: - next_retrain_time += datetime.timedelta(days=1) +def auto_scheduler(training_data): + now = datetime.datetime.now() + next_retrain_time = now.replace(hour=23, minute=59, second=0, microsecond=0) + if now > next_retrain_time: + next_retrain_time += datetime.timedelta(days=1) -schedule.every().day.at(next_retrain_time.strftime("%H:%M")).do(retrain_for_new_users(training_data)) + schedule.every().day.at(next_retrain_time.strftime("%H:%M")).do(retrain_for_new_users(training_data)) -while True: - schedule.run_pending() - time.sleep(1) + while True: + schedule.run_pending() + time.sleep(1) @app.route('/recommendations', methods=['POST']) @@ -148,5 +149,6 @@ def get_training_data(): if __name__ == "__main__": + auto_scheduler(get_training_data()) port = int(os.getenv("PORT", 6000)) app.run(host='0.0.0.0', port=port, debug=True)