Spaces:
Sleeping
Sleeping
Commit
·
bf56562
1
Parent(s):
cee942f
Change to make the last 5 logs visible
Browse files
app.py
CHANGED
@@ -26,6 +26,24 @@ vector_db = VectorStore()
|
|
26 |
topic_modeller = TopicModeller()
|
27 |
|
28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
def log_submission(filename: str, num_chunks: int, start_time: float, status: str, session_id: str = "anonymous") -> None:
|
30 |
"""
|
31 |
Basic logging utility to keep track of app usage.
|
@@ -117,11 +135,13 @@ def process_file(file: Any) -> Tuple[List[Tuple[str, int]], Any, Any]:
|
|
117 |
|
118 |
# Log success
|
119 |
log_submission(file.name, len(chunks), start, status = "success")
|
|
|
120 |
|
121 |
return annotated, fig, overview_table, umap_fig
|
122 |
|
123 |
except Exception as e:
|
124 |
log_submission(file.name, 0, start, status = f"error: {str(e)}")
|
|
|
125 |
|
126 |
raise e
|
127 |
|
|
|
26 |
topic_modeller = TopicModeller()
|
27 |
|
28 |
|
29 |
+
def print_recent_logs(n: int = 5):
|
30 |
+
"""
|
31 |
+
Print the last N log lines to the container logs for developer monitoring.
|
32 |
+
"""
|
33 |
+
log_file = "semanticdala_log.csv"
|
34 |
+
|
35 |
+
if os.path.exists(log_file):
|
36 |
+
print(f"\n[SEMANTICDALA USAGE LOG - Last {n} Entries]")
|
37 |
+
|
38 |
+
with open(log_file, "r") as f:
|
39 |
+
lines = f.readlines()
|
40 |
+
|
41 |
+
for line in lines[-n:]:
|
42 |
+
print(line.strip())
|
43 |
+
|
44 |
+
print("[END LOG SNAPSHOT]\n")
|
45 |
+
|
46 |
+
|
47 |
def log_submission(filename: str, num_chunks: int, start_time: float, status: str, session_id: str = "anonymous") -> None:
|
48 |
"""
|
49 |
Basic logging utility to keep track of app usage.
|
|
|
135 |
|
136 |
# Log success
|
137 |
log_submission(file.name, len(chunks), start, status = "success")
|
138 |
+
print_recent_logs()
|
139 |
|
140 |
return annotated, fig, overview_table, umap_fig
|
141 |
|
142 |
except Exception as e:
|
143 |
log_submission(file.name, 0, start, status = f"error: {str(e)}")
|
144 |
+
print_recent_logs()
|
145 |
|
146 |
raise e
|
147 |
|