Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
test - moving worksheet definition outside function
Browse files
app.py
CHANGED
@@ -42,7 +42,7 @@ file_path = 'service_account.json'
|
|
42 |
with open(file_path, 'w') as json_file:
|
43 |
json.dump(service_account, json_file)
|
44 |
gspread_bot = gspread.service_account(filename='service_account.json')
|
45 |
-
|
46 |
worksheet2 = gspread_bot.open("hf_discord_verified_users_test").sheet1
|
47 |
""""""
|
48 |
bot_ids = [1136614989411655780, 1166392942387265536, 1158038249835610123, 1130774761031610388, 1155489509518098565, 1155169841276260546, 1152238037355474964, 1154395078735953930]
|
@@ -74,13 +74,15 @@ async def on_ready():
|
|
74 |
|
75 |
async def update_google_sheet():
|
76 |
"""save data from HF Space -> google sheets (makes 1 API call)"""
|
|
|
77 |
try:
|
78 |
print("Updating...")
|
79 |
name = "levelbot"
|
80 |
await asyncio.sleep(1.1)
|
81 |
-
worksheet = gspread_bot.open(name).sheet1
|
82 |
await asyncio.sleep(1.1)
|
83 |
global_df['discord_user_id'] = global_df['discord_user_id'].astype(str)
|
|
|
84 |
set_with_dataframe(worksheet, global_df)
|
85 |
await asyncio.sleep(1.1)
|
86 |
# very important, otherwise gspread will force format IDs in scientific notation by default (making them unusable)
|
|
|
42 |
with open(file_path, 'w') as json_file:
|
43 |
json.dump(service_account, json_file)
|
44 |
gspread_bot = gspread.service_account(filename='service_account.json')
|
45 |
+
worksheet = gspread_bot.open("levelbot").sheet1
|
46 |
worksheet2 = gspread_bot.open("hf_discord_verified_users_test").sheet1
|
47 |
""""""
|
48 |
bot_ids = [1136614989411655780, 1166392942387265536, 1158038249835610123, 1130774761031610388, 1155489509518098565, 1155169841276260546, 1152238037355474964, 1154395078735953930]
|
|
|
74 |
|
75 |
async def update_google_sheet():
|
76 |
"""save data from HF Space -> google sheets (makes 1 API call)"""
|
77 |
+
# run this in separate thread?
|
78 |
try:
|
79 |
print("Updating...")
|
80 |
name = "levelbot"
|
81 |
await asyncio.sleep(1.1)
|
82 |
+
#worksheet = gspread_bot.open(name).sheet1
|
83 |
await asyncio.sleep(1.1)
|
84 |
global_df['discord_user_id'] = global_df['discord_user_id'].astype(str)
|
85 |
+
# could just do this / format
|
86 |
set_with_dataframe(worksheet, global_df)
|
87 |
await asyncio.sleep(1.1)
|
88 |
# very important, otherwise gspread will force format IDs in scientific notation by default (making them unusable)
|