Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
test merge
Browse files
app.py
CHANGED
@@ -80,6 +80,7 @@ async def on_ready():
|
|
80 |
#await remove_huggingfolks() # to initialize
|
81 |
#print(community_global_df_with_id)
|
82 |
remove_huggingfolks.start()
|
|
|
83 |
#await periodic_api_test()
|
84 |
print(f"------------------------------------------------------------------------")
|
85 |
except Exception as e:
|
@@ -608,6 +609,52 @@ async def remove_huggingfolks():
|
|
608 |
print(f"remove_huggingfolks Error: {e}")
|
609 |
|
610 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
611 |
@bot.command(name='xp_help')
|
612 |
async def xp_help(ctx):
|
613 |
try:
|
|
|
80 |
#await remove_huggingfolks() # to initialize
|
81 |
#print(community_global_df_with_id)
|
82 |
remove_huggingfolks.start()
|
83 |
+
update_hub_stats.start()
|
84 |
#await periodic_api_test()
|
85 |
print(f"------------------------------------------------------------------------")
|
86 |
except Exception as e:
|
|
|
609 |
print(f"remove_huggingfolks Error: {e}")
|
610 |
|
611 |
|
612 |
+
|
613 |
+
#---------------------------------------------------------------------------------------------
|
614 |
+
# UPDATE dataframe WITH HFAPI INFO on a timer
|
615 |
+
|
616 |
+
@tasks.loop(minutes=1)
|
617 |
+
async def update_hub_stats():
|
618 |
+
try:
|
619 |
+
global global_df
|
620 |
+
|
621 |
+
updated_df = global_df.copy()
|
622 |
+
for index, user in global_df['hf_user_name'].iteritems():
|
623 |
+
# fill blank values with n/a for now? then replace if they try to verify
|
624 |
+
#column = global_df['hf_user_name']
|
625 |
+
|
626 |
+
#for index, user in column:
|
627 |
+
url = f"https://huggingface.co/api/users/{user}/overview"
|
628 |
+
response = requests.get(url)
|
629 |
+
if response.status_code == 200:
|
630 |
+
data = response.json()
|
631 |
+
likes = data["numLikes"]
|
632 |
+
models = data["numModels"]
|
633 |
+
datasets = data["numDatasets"]
|
634 |
+
spaces = data["numSpaces"]
|
635 |
+
discussions = data["numDiscussions"]
|
636 |
+
papers = data["numPapers"]
|
637 |
+
upvotes = data["numUpvotes"]
|
638 |
+
|
639 |
+
#sheet1.update(f'I{i+1}:O{i+1}',[[likes, models, datasets, spaces, discussions, papers, upvotes]])
|
640 |
+
# update df instead
|
641 |
+
updated_df.loc[index, ['likes', 'models', 'datasets', 'spaces', 'discussions', 'papers', 'upvotes']] = [likes, models, datasets, spaces, discussions, papers, upvotes]
|
642 |
+
|
643 |
+
print(f"updated row {i} for user {user}")
|
644 |
+
else:
|
645 |
+
print(f"Failed to retrieve data for user {user}. Status code: {response.status_code}")
|
646 |
+
|
647 |
+
print global_df
|
648 |
+
|
649 |
+
except Error as e:
|
650 |
+
print(f"Failed to parse data for user {user}.")
|
651 |
+
|
652 |
+
|
653 |
+
|
654 |
+
|
655 |
+
|
656 |
+
#---------------------------------------------------------------------------------------------
|
657 |
+
|
658 |
@bot.command(name='xp_help')
|
659 |
async def xp_help(ctx):
|
660 |
try:
|