bat-6 commited on
Commit
b9ada33
·
1 Parent(s): e2b6cfb
Data_gemini/projects_clean_gemini.csv DELETED
The diff for this file is too large to render. See raw diff
 
models/trained_metadata.pkl DELETED
File without changes
src/services/scheduler.py DELETED
@@ -1,19 +0,0 @@
1
- import time
2
-
3
- from src.services.sync_projects import sync_projects
4
-
5
- while True:
6
-
7
- try:
8
-
9
- print("Checking for new projects...")
10
-
11
- sync_projects()
12
-
13
- print("Done")
14
-
15
- except Exception as e:
16
-
17
- print("Error:", e)
18
-
19
- time.sleep(60)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
src/services/sync_projects.py DELETED
@@ -1,172 +0,0 @@
1
- import json
2
- import pandas as pd
3
-
4
- from Data.database.sql_connector import engine
5
- from src.similarity_model.preprocessing import preprocess_dataset
6
- from src.similarity_model.embedding_engine import (
7
- train_embedding_engine
8
- )
9
-
10
-
11
- def sync_projects():
12
-
13
- projects_query = """
14
- SELECT *
15
- FROM Projects
16
- WHERE Status IN (
17
- 'Completed',
18
- 'UnderReview',
19
- 'In_Progress'
20
- )
21
- """
22
-
23
- projects_df = pd.read_sql(
24
- projects_query,
25
- engine
26
- )
27
-
28
- existing_df = pd.read_sql(
29
- """
30
- SELECT id
31
- FROM PreProcessed_Projects
32
- """,
33
- engine
34
- )
35
-
36
- allowed_ids = set(
37
- projects_df["Id"].tolist()
38
- )
39
-
40
- processed_ids = set(
41
- existing_df["id"].tolist()
42
- )
43
-
44
- # ---------------------------------
45
- # Remove projects no longer allowed
46
- # ---------------------------------
47
-
48
- ids_to_remove = (
49
- processed_ids - allowed_ids
50
- )
51
-
52
- changed = False
53
-
54
- if ids_to_remove:
55
-
56
- ids_str = ",".join(
57
- map(str, ids_to_remove)
58
- )
59
-
60
- with engine.begin() as conn:
61
-
62
- conn.exec_driver_sql(
63
- f"""
64
- DELETE FROM PreProcessed_Projects
65
- WHERE id IN ({ids_str})
66
- """
67
- )
68
-
69
- print(
70
- f"Removed {len(ids_to_remove)} projects"
71
- )
72
-
73
- changed = True
74
-
75
- # ---------------------------------
76
- # Add new projects
77
- # ---------------------------------
78
-
79
- new_projects = projects_df[
80
- ~projects_df["Id"].isin(
81
- processed_ids
82
- )
83
- ].copy()
84
-
85
- if len(new_projects) > 0:
86
-
87
- print(
88
- f"Found {len(new_projects)} new projects"
89
- )
90
-
91
- processed_df = preprocess_dataset(
92
- new_projects
93
- )
94
-
95
- processed_df = processed_df[
96
- [
97
- "id",
98
- "submittedat",
99
- "project_title",
100
- "studentnames",
101
- "year",
102
- "abstract",
103
- "description",
104
- "problemstatement",
105
- "proposedsolution",
106
- "objectives",
107
- "full_content",
108
- "clean_text",
109
- "word_count",
110
- "features"
111
- ]
112
- ]
113
-
114
- processed_df = processed_df.rename(
115
- columns={
116
- "submittedat": "submitted_at",
117
- "studentnames": "student_names",
118
- "problemstatement": "problem_statement",
119
- "proposedsolution": "proposed_solution"
120
- }
121
- )
122
-
123
- processed_df["features"] = (
124
- processed_df["features"]
125
- .apply(json.dumps)
126
- )
127
-
128
- processed_df.to_sql(
129
- "PreProcessed_Projects",
130
- engine,
131
- if_exists="append",
132
- index=False
133
- )
134
-
135
- print(
136
- f"Processed and inserted {len(processed_df)} projects"
137
- )
138
-
139
- changed = True
140
-
141
- else:
142
-
143
- print(
144
- "No new projects found"
145
- )
146
-
147
- # ---------------------------------
148
- # Rebuild FAISS only if changed
149
- # ---------------------------------
150
-
151
- if changed:
152
-
153
- print(
154
- "Updating embeddings..."
155
- )
156
-
157
- train_embedding_engine()
158
-
159
- print(
160
- "Embeddings updated"
161
- )
162
-
163
- else:
164
-
165
- print(
166
- "No changes detected"
167
- )
168
-
169
-
170
- if __name__ == "__main__":
171
-
172
- sync_projects()