Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Update app.py
Browse files
app.py
CHANGED
@@ -20,7 +20,7 @@ import requests
|
|
20 |
from apscheduler.executors.pool import ThreadPoolExecutor
|
21 |
from apscheduler.schedulers.background import BackgroundScheduler
|
22 |
from discord import Color, Embed
|
23 |
-
from discord.ext import commands
|
24 |
from gradio_client import Client
|
25 |
from gspread_dataframe import get_as_dataframe, set_with_dataframe
|
26 |
from gspread_formatting.dataframe import format_with_dataframe
|
@@ -74,6 +74,10 @@ async def on_ready():
|
|
74 |
#data.to_csv(csv_file, index=False)
|
75 |
|
76 |
await remove_huggingfolks()
|
|
|
|
|
|
|
|
|
77 |
print(f"------------------------------------------------------------------------")
|
78 |
except Exception as e:
|
79 |
print(f"on_message Error: {e}")
|
@@ -340,6 +344,8 @@ async def remove_huggingfolks():
|
|
340 |
community_global_df['discord_exp'] = pd.to_numeric(community_global_df['discord_exp'])
|
341 |
top_30_exp = community_global_df.nlargest(30, 'discord_exp')
|
342 |
top_30_exp.drop(top_30_exp.columns[0], axis=1, inplace=True)
|
|
|
|
|
343 |
top_30_exp['D'] = ['π₯','π₯','π₯','','','','','','','','','','','','','','','','','','','','','','','','','','','']
|
344 |
top_30_rows = top_30_exp.values.tolist()
|
345 |
|
@@ -355,7 +361,8 @@ async def remove_huggingfolks():
|
|
355 |
print(f"remove_huggingfolks Error: {e}")
|
356 |
|
357 |
|
358 |
-
|
|
|
359 |
try:
|
360 |
# split into clear sections, discord bot only and gspread only
|
361 |
if ctx.author.id == 811235357663297546:
|
@@ -457,6 +464,8 @@ csv_url = URL.replace('/edit#gid=', '/export?format=csv&gid=')
|
|
457 |
|
458 |
def get_data():
|
459 |
try:
|
|
|
|
|
460 |
data = pd.read_csv(csv_url)
|
461 |
first_3_columns = data.iloc[:, 1:4]
|
462 |
sorted = first_3_columns.sort_values(by='discord_exp', ascending=False)
|
@@ -490,7 +499,7 @@ with demo:
|
|
490 |
#gr.Markdown("# π Experience Leaderboard")
|
491 |
with gr.Row():
|
492 |
with gr.Column():
|
493 |
-
gr.DataFrame(
|
494 |
|
495 |
with gr.Column():
|
496 |
gr.BarPlot(
|
|
|
20 |
from apscheduler.executors.pool import ThreadPoolExecutor
|
21 |
from apscheduler.schedulers.background import BackgroundScheduler
|
22 |
from discord import Color, Embed
|
23 |
+
from discord.ext import commands, tasks
|
24 |
from gradio_client import Client
|
25 |
from gspread_dataframe import get_as_dataframe, set_with_dataframe
|
26 |
from gspread_formatting.dataframe import format_with_dataframe
|
|
|
74 |
#data.to_csv(csv_file, index=False)
|
75 |
|
76 |
await remove_huggingfolks()
|
77 |
+
|
78 |
+
@tasks.loop(seconds=5.0, count=5)
|
79 |
+
async def slow_count():
|
80 |
+
print(slow_count.current_loop)
|
81 |
print(f"------------------------------------------------------------------------")
|
82 |
except Exception as e:
|
83 |
print(f"on_message Error: {e}")
|
|
|
344 |
community_global_df['discord_exp'] = pd.to_numeric(community_global_df['discord_exp'])
|
345 |
top_30_exp = community_global_df.nlargest(30, 'discord_exp')
|
346 |
top_30_exp.drop(top_30_exp.columns[0], axis=1, inplace=True)
|
347 |
+
community_global_df = top_30_exp.copy() # for gradio
|
348 |
+
|
349 |
top_30_exp['D'] = ['π₯','π₯','π₯','','','','','','','','','','','','','','','','','','','','','','','','','','','']
|
350 |
top_30_rows = top_30_exp.values.tolist()
|
351 |
|
|
|
361 |
print(f"remove_huggingfolks Error: {e}")
|
362 |
|
363 |
|
364 |
+
@tasks.loop(minutes=1)
|
365 |
+
async def update_leaderboard():
|
366 |
try:
|
367 |
# split into clear sections, discord bot only and gspread only
|
368 |
if ctx.author.id == 811235357663297546:
|
|
|
464 |
|
465 |
def get_data():
|
466 |
try:
|
467 |
+
|
468 |
+
data = pd.read_csv(csv_url)
|
469 |
data = pd.read_csv(csv_url)
|
470 |
first_3_columns = data.iloc[:, 1:4]
|
471 |
sorted = first_3_columns.sort_values(by='discord_exp', ascending=False)
|
|
|
499 |
#gr.Markdown("# π Experience Leaderboard")
|
500 |
with gr.Row():
|
501 |
with gr.Column():
|
502 |
+
gr.DataFrame(community_global_df, every=5, height=500, interactive=False, col_count=(3, "fixed"), column_widths=["100px","100px","100px"])
|
503 |
|
504 |
with gr.Column():
|
505 |
gr.BarPlot(
|