Spaces:
Runtime error
Runtime error
Commit
•
f1a6dea
1
Parent(s):
2390730
increase length cache remains valid
Browse files
app.py
CHANGED
@@ -20,7 +20,7 @@ from toolz import groupby, valmap
|
|
20 |
|
21 |
|
22 |
# @cached_decorator
|
23 |
-
@cached(cache=TTLCache(maxsize=100, ttl=60 *
|
24 |
def get_spaces():
|
25 |
return list(list_spaces(full=True))
|
26 |
|
@@ -60,19 +60,19 @@ def relative_rank(my_dict, target_key, filter_zero=False):
|
|
60 |
}
|
61 |
|
62 |
|
63 |
-
@cached(cache=TTLCache(maxsize=100, ttl=60 *
|
64 |
def relative_rank_for_space(space_id, filter_zero=False):
|
65 |
space_to_like_dict = create_space_to_like_dict()
|
66 |
return relative_rank(space_to_like_dict, space_id, filter_zero=filter_zero)
|
67 |
|
68 |
|
69 |
-
@cached(cache=TTLCache(maxsize=100, ttl=60 *
|
70 |
def relative_rank_for_org(org_id, filter_zero=False):
|
71 |
org_to_like_dict = create_org_to_like_dict()
|
72 |
return relative_rank(org_to_like_dict, org_id, filter_zero=filter_zero)
|
73 |
|
74 |
|
75 |
-
@cached(cache=TTLCache(maxsize=100, ttl=60 *
|
76 |
def rank_space(space_id):
|
77 |
return relative_rank_for_space(space_id)
|
78 |
|
@@ -102,8 +102,8 @@ def get_top_n_orgs_and_users(top_n=100):
|
|
102 |
def plot_top_n_orgs_and_users(top_n=100):
|
103 |
top_n = get_top_n_orgs_and_users(top_n)
|
104 |
return "".join(
|
105 |
-
f"\n
|
106 |
-
for org, likes in top_n
|
107 |
)
|
108 |
|
109 |
|
@@ -117,8 +117,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
|
121 |
-
for space, likes in top_n
|
122 |
)
|
123 |
|
124 |
|
|
|
20 |
|
21 |
|
22 |
# @cached_decorator
|
23 |
+
@cached(cache=TTLCache(maxsize=100, ttl=60 * 30))
|
24 |
def get_spaces():
|
25 |
return list(list_spaces(full=True))
|
26 |
|
|
|
60 |
}
|
61 |
|
62 |
|
63 |
+
@cached(cache=TTLCache(maxsize=100, ttl=60 * 30))
|
64 |
def relative_rank_for_space(space_id, filter_zero=False):
|
65 |
space_to_like_dict = create_space_to_like_dict()
|
66 |
return relative_rank(space_to_like_dict, space_id, filter_zero=filter_zero)
|
67 |
|
68 |
|
69 |
+
@cached(cache=TTLCache(maxsize=100, ttl=60 * 30))
|
70 |
def relative_rank_for_org(org_id, filter_zero=False):
|
71 |
org_to_like_dict = create_org_to_like_dict()
|
72 |
return relative_rank(org_to_like_dict, org_id, filter_zero=filter_zero)
|
73 |
|
74 |
|
75 |
+
@cached(cache=TTLCache(maxsize=100, ttl=60 * 30))
|
76 |
def rank_space(space_id):
|
77 |
return relative_rank_for_space(space_id)
|
78 |
|
|
|
102 |
def plot_top_n_orgs_and_users(top_n=100):
|
103 |
top_n = get_top_n_orgs_and_users(top_n)
|
104 |
return "".join(
|
105 |
+
f"\n{i+1}. [{org}](https://huggingface.co/{org}) with {likes:,} likes"
|
106 |
+
for i, (org, likes) in enumerate(top_n)
|
107 |
)
|
108 |
|
109 |
|
|
|
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 {likes:,} likes"
|
121 |
+
for i, (space, likes) in enumerate(top_n)
|
122 |
)
|
123 |
|
124 |
|