Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Update app.py
Browse files
app.py
CHANGED
@@ -104,6 +104,9 @@ def update_google_sheet():
|
|
104 |
"type": 'TEXT',
|
105 |
},
|
106 |
})
|
|
|
|
|
|
|
107 |
timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
108 |
print(f"Google sheet {name} successfully updated at {timestamp}! \n{global_df}")
|
109 |
print(f"------------------------------------------------------------------------")
|
@@ -111,38 +114,12 @@ def update_google_sheet():
|
|
111 |
print(f"on_message Error: {e}")
|
112 |
|
113 |
|
114 |
-
|
115 |
-
"""save data from HF Space -> google sheets (makes 2 API calls)"""
|
116 |
-
try:
|
117 |
-
"""
|
118 |
-
worksheet2.format(f"E1:E{len(worksheet2_df.index)+1}", {
|
119 |
-
"numberFormat": {
|
120 |
-
"type": 'TEXT',
|
121 |
-
},
|
122 |
-
})
|
123 |
-
worksheet2.format(f"A1:A{len(worksheet2_df.index)+1}", {
|
124 |
-
"numberFormat": {
|
125 |
-
"type": 'TEXT',
|
126 |
-
},
|
127 |
-
})
|
128 |
-
"""
|
129 |
-
name2 = "hf_discord_verified_users_test"
|
130 |
-
# could just do this / format
|
131 |
-
worksheet2['discord_user_id'] = worksheet2['discord_user_id'].astype(str)
|
132 |
-
worksheet2['id_recover_test'] = worksheet2['id_recover_test'].astype(str)
|
133 |
-
print(worksheet2_df.dtypes)
|
134 |
-
set_with_dataframe(worksheet2, worksheet2_df)
|
135 |
-
# very important, otherwise gspread will force format IDs in scientific notation by default (making them unusable)
|
136 |
-
timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
137 |
-
print(f"Google sheet {name2} successfully updated at {timestamp}!")
|
138 |
-
except Exception as e:
|
139 |
-
print(f"on_message Error: {e}")
|
140 |
|
141 |
|
142 |
executor = ThreadPoolExecutor(max_workers=1)
|
143 |
scheduler = BackgroundScheduler(executors={'default': executor})
|
144 |
-
scheduler.add_job(update_google_sheet, trigger='interval', minutes=
|
145 |
-
scheduler.add_job(update_google_sheet2, trigger='interval', minutes=1, max_instances=1)
|
146 |
scheduler.start()
|
147 |
|
148 |
|
|
|
104 |
"type": 'TEXT',
|
105 |
},
|
106 |
})
|
107 |
+
worksheet2['discord_user_id'] = worksheet2['discord_user_id'].astype(str)
|
108 |
+
worksheet2['id_recover_test'] = worksheet2['id_recover_test'].astype(str)
|
109 |
+
set_with_dataframe(worksheet2, worksheet2_df)
|
110 |
timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
111 |
print(f"Google sheet {name} successfully updated at {timestamp}! \n{global_df}")
|
112 |
print(f"------------------------------------------------------------------------")
|
|
|
114 |
print(f"on_message Error: {e}")
|
115 |
|
116 |
|
117 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
118 |
|
119 |
|
120 |
executor = ThreadPoolExecutor(max_workers=1)
|
121 |
scheduler = BackgroundScheduler(executors={'default': executor})
|
122 |
+
scheduler.add_job(update_google_sheet, trigger='interval', minutes=2, max_instances=1)
|
|
|
123 |
scheduler.start()
|
124 |
|
125 |
|