Spaces:
Runtime error
Runtime error
Commit ·
1fcd9e2
1
Parent(s): 68a4e98
bug fixes
Browse files- persistStorage.py +7 -7
persistStorage.py
CHANGED
|
@@ -19,7 +19,7 @@ fs = HfFileSystem(token=HUGGING_FACE_TOKEN)
|
|
| 19 |
def append_dict_to_csv(file_path, row_data):
|
| 20 |
fieldnames = row_data.keys()
|
| 21 |
|
| 22 |
-
with fs.open(file_path, 'a+'
|
| 23 |
csv_writer = csv.DictWriter(csv_file, fieldnames=fieldnames)
|
| 24 |
|
| 25 |
# Check if the file is empty, and if so, write the header
|
|
@@ -28,9 +28,9 @@ def append_dict_to_csv(file_path, row_data):
|
|
| 28 |
csv_writer.writerow(row_data)
|
| 29 |
|
| 30 |
def saveLog(message, level='info') -> None:
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
|
|
|
| 19 |
def append_dict_to_csv(file_path, row_data):
|
| 20 |
fieldnames = row_data.keys()
|
| 21 |
|
| 22 |
+
with fs.open(file_path, 'a+') as csv_file:
|
| 23 |
csv_writer = csv.DictWriter(csv_file, fieldnames=fieldnames)
|
| 24 |
|
| 25 |
# Check if the file is empty, and if so, write the header
|
|
|
|
| 28 |
csv_writer.writerow(row_data)
|
| 29 |
|
| 30 |
def saveLog(message, level='info') -> None:
|
| 31 |
+
current_time = datetime.now(TIMEZONE_OBJ)
|
| 32 |
+
message = str(message)
|
| 33 |
+
log_path = 'spaces/Express-Analytics/QueryHelper/'
|
| 34 |
+
log_file_path = os.path.join(log_path, f"{current_time.strftime('%Y-%m')}.csv")
|
| 35 |
+
data_dict = {"time":str(currrent_time), "level": level, "message": message}
|
| 36 |
+
append_dict_to_csv(log_file_path, data_dict)
|