Spaces:
Runtime error
Runtime error
Commit
·
1c8f379
1
Parent(s):
f1a6dea
improve report
Browse files
app.py
CHANGED
@@ -57,6 +57,7 @@ def relative_rank(my_dict, target_key, filter_zero=False):
|
|
57 |
"num_higher": num_higher,
|
58 |
"num_lower": num_lower,
|
59 |
"value": my_dict[target_key],
|
|
|
60 |
}
|
61 |
|
62 |
|
@@ -82,14 +83,30 @@ def rank_space_and_org(space_or_org_id, filter_zero):
|
|
82 |
split = space_or_org_id.split("/")
|
83 |
if len(split) == 2:
|
84 |
space_rank = relative_rank_for_space(space_or_org_id, filter_zero=filter_zero)
|
85 |
-
|
86 |
-
|
87 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
if len(split) == 1:
|
89 |
org_rank = relative_rank_for_org(space_or_org_id, filter_zero=filter_zero)
|
90 |
-
|
91 |
-
|
92 |
-
You have {org_rank['
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
93 |
|
94 |
|
95 |
def get_top_n_orgs_and_users(top_n=100):
|
@@ -117,7 +134,8 @@ def get_top_n_spaces(top_n=100):
|
|
117 |
def plot_top_n_spaces(top_n=100):
|
118 |
top_n = get_top_n_spaces(top_n)
|
119 |
return "".join(
|
120 |
-
f"\n{i+1}. [{space}](https://huggingface.co/spaces/{space}) with
|
|
|
121 |
for i, (space, likes) in enumerate(top_n)
|
122 |
)
|
123 |
|
@@ -144,7 +162,7 @@ with gr.Blocks() as demo:
|
|
144 |
value="yes",
|
145 |
)
|
146 |
run_btn = gr.Button("Show ranking for this Space org org/user!", label="Rank Space")
|
147 |
-
gr.Markdown("###
|
148 |
result = gr.Markdown()
|
149 |
run_btn.click(rank_space_and_org, inputs=[space_id, filter_zero], outputs=result)
|
150 |
gr.Markdown("## Leaderboard of Top 100 Spaces and Orgs/Users by Likes")
|
|
|
57 |
"num_higher": num_higher,
|
58 |
"num_lower": num_lower,
|
59 |
"value": my_dict[target_key],
|
60 |
+
"position": position + 1,
|
61 |
}
|
62 |
|
63 |
|
|
|
83 |
split = space_or_org_id.split("/")
|
84 |
if len(split) == 2:
|
85 |
space_rank = relative_rank_for_space(space_or_org_id, filter_zero=filter_zero)
|
86 |
+
result = "## ⭐️ Space Likes Rankings ⭐️\n"
|
87 |
+
result += f"""Here are the rankings by likes for [`{space_or_org_id}`](https://huggingface.co/spaces/{space_or_org_id}) across all Spaces \n"""
|
88 |
+
result += f"""- You have {space_rank['value']:,} likes for this Space.\n"""
|
89 |
+
result += f"""- Your Space is ranked {space_rank['position']:,} out of {len(create_space_to_like_dict()):,} Spaces.\n"""
|
90 |
+
result += f"""- Space [{space_or_org_id}](https://huggingface.co/spaces/{space_or_org_id}) is ranked {space_rank['rank']:.2f}%\n"""
|
91 |
+
result += f"""- You have {space_rank['num_higher']:,} Spaces above and {space_rank['num_lower']:,} Spaces below in the raking of Space likes\n\n"""
|
92 |
+
result += """### ✨ Remember likes aren't everything!✨\n"""
|
93 |
+
result += """Some Spaces go very viral whilst other Spaces may be very useful for a smaller audience. If you think your Space is useful, please add it to this [thread](https://huggingface.co/spaces/librarian-bots/ranker/discussions/3) of awesome Spaces.
|
94 |
+
We'll look out for awesome Spaces added to this thread to promote more widely!"""
|
95 |
+
return result
|
96 |
+
|
97 |
if len(split) == 1:
|
98 |
org_rank = relative_rank_for_org(space_or_org_id, filter_zero=filter_zero)
|
99 |
+
result = "## ⭐️ Org/User Space Likes Rankings ⭐️\n"
|
100 |
+
result += "Here are the rankings for the org/user across all of their spaces \n"
|
101 |
+
result += f"""- You have {org_rank['value']:,} likes for this org/user.\n"""
|
102 |
+
result += f"""- Your org/user is ranked {org_rank['position']:,} out of {len(create_org_to_like_dict()):,} orgs/users.\n"""
|
103 |
+
result += f"""- You have {org_rank['num_higher']:,} orgs/users above and {org_rank['num_lower']:,} orgs/users below in the raking of Space likes \n\n"""
|
104 |
+
result += f"""- Organization or user [{space_or_org_id}](https://huggingface.co/{space_or_org_id}) is ranked in the top {org_rank['rank']:.2f}% \n\n"""
|
105 |
+
result += f"""You can find all your Spaces sorted by likes [here](https://huggingface.co/{space_or_org_id}?sort_spaces=likes#spaces)\n"""
|
106 |
+
result += """### ✨ Remember likes aren't everything!✨\n"""
|
107 |
+
result += """Some Spaces go very viral whilst other Spaces may be very useful for a smaller audience. If you think your Space is useful, please add it to this [thread](https://huggingface.co/spaces/librarian-bots/ranker/discussions/3) of awesome Spaces.
|
108 |
+
We'll look out for awesome Spaces added to this thread to promote more widely!"""
|
109 |
+
return result
|
110 |
|
111 |
|
112 |
def get_top_n_orgs_and_users(top_n=100):
|
|
|
134 |
def plot_top_n_spaces(top_n=100):
|
135 |
top_n = get_top_n_spaces(top_n)
|
136 |
return "".join(
|
137 |
+
f"\n{i+1}. [{space}](https://huggingface.co/spaces/{space}) with"
|
138 |
+
f" {likes:,} likes"
|
139 |
for i, (space, likes) in enumerate(top_n)
|
140 |
)
|
141 |
|
|
|
162 |
value="yes",
|
163 |
)
|
164 |
run_btn = gr.Button("Show ranking for this Space org org/user!", label="Rank Space")
|
165 |
+
# gr.Markdown("### Results")
|
166 |
result = gr.Markdown()
|
167 |
run_btn.click(rank_space_and_org, inputs=[space_id, filter_zero], outputs=result)
|
168 |
gr.Markdown("## Leaderboard of Top 100 Spaces and Orgs/Users by Likes")
|