Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -41,10 +41,12 @@ class PaperManager:
|
|
41 |
Returns a dictionary with counts for each type.
|
42 |
"""
|
43 |
try:
|
|
|
44 |
response = requests.get(REPOS_API_URL_TEMPLATE.format(arxiv_id=arxiv_id))
|
45 |
response.raise_for_status()
|
46 |
data = response.json()
|
47 |
-
|
|
|
48 |
counts = {'models': 0, 'datasets': 0, 'spaces': 0}
|
49 |
for repo in data:
|
50 |
repo_type = repo.get('type', '').lower()
|
@@ -54,6 +56,7 @@ class PaperManager:
|
|
54 |
counts['datasets'] += 1
|
55 |
elif repo_type == 'space':
|
56 |
counts['spaces'] += 1
|
|
|
57 |
return counts
|
58 |
except requests.RequestException as e:
|
59 |
print(f"Error fetching repos for arxiv_id {arxiv_id}: {e}")
|
@@ -82,6 +85,7 @@ class PaperManager:
|
|
82 |
future_to_paper = {}
|
83 |
for paper in self.raw_papers:
|
84 |
arxiv_id = paper.get('paper', {}).get('arxiv_id', '')
|
|
|
85 |
if arxiv_id:
|
86 |
future = executor.submit(self.fetch_repos_counts, arxiv_id)
|
87 |
future_to_paper[future] = paper
|
@@ -94,6 +98,7 @@ class PaperManager:
|
|
94 |
for future in as_completed(future_to_paper):
|
95 |
paper = future_to_paper[future]
|
96 |
counts = future.result()
|
|
|
97 |
paper['models'] = counts['models']
|
98 |
paper['datasets'] = counts['datasets']
|
99 |
paper['spaces'] = counts['spaces']
|
@@ -147,12 +152,13 @@ class PaperManager:
|
|
147 |
key=lambda x: self.calculate_score(x),
|
148 |
reverse=True
|
149 |
)
|
|
|
150 |
|
151 |
def set_sort_method(self, method):
|
152 |
valid_methods = ["hot", "new", "most_models", "most_datasets", "most_spaces"]
|
153 |
if method not in valid_methods:
|
154 |
method = "hot"
|
155 |
-
print(f"Setting sort method to: {method}")
|
156 |
self.sort_method = method
|
157 |
self.sort_papers()
|
158 |
self.current_page = 1
|
@@ -178,6 +184,8 @@ class PaperManager:
|
|
178 |
datasets = paper.get('datasets', 0)
|
179 |
spaces = paper.get('spaces', 0)
|
180 |
|
|
|
|
|
181 |
return f"""
|
182 |
<tr class="athing">
|
183 |
<td align="right" valign="top" class="title"><span class="rank">{rank}.</span></td>
|
@@ -237,7 +245,7 @@ def refresh_papers():
|
|
237 |
|
238 |
def change_sort_method(method):
|
239 |
method_lower = method.lower().replace(" ", "_")
|
240 |
-
print(f"Changing sort method to: {method_lower}")
|
241 |
if paper_manager.set_sort_method(method_lower):
|
242 |
print("Sort method set successfully.")
|
243 |
return paper_manager.render_papers()
|
@@ -430,4 +438,4 @@ with demo:
|
|
430 |
outputs=[paper_list]
|
431 |
)
|
432 |
|
433 |
-
demo.launch()
|
|
|
41 |
Returns a dictionary with counts for each type.
|
42 |
"""
|
43 |
try:
|
44 |
+
print(f"Fetching repos for arxiv_id: {arxiv_id}") # Debug
|
45 |
response = requests.get(REPOS_API_URL_TEMPLATE.format(arxiv_id=arxiv_id))
|
46 |
response.raise_for_status()
|
47 |
data = response.json()
|
48 |
+
print(f"Repos data for arxiv_id {arxiv_id}: {data}") # Debug
|
49 |
+
|
50 |
counts = {'models': 0, 'datasets': 0, 'spaces': 0}
|
51 |
for repo in data:
|
52 |
repo_type = repo.get('type', '').lower()
|
|
|
56 |
counts['datasets'] += 1
|
57 |
elif repo_type == 'space':
|
58 |
counts['spaces'] += 1
|
59 |
+
print(f"Counts for arxiv_id {arxiv_id}: {counts}") # Debug
|
60 |
return counts
|
61 |
except requests.RequestException as e:
|
62 |
print(f"Error fetching repos for arxiv_id {arxiv_id}: {e}")
|
|
|
85 |
future_to_paper = {}
|
86 |
for paper in self.raw_papers:
|
87 |
arxiv_id = paper.get('paper', {}).get('arxiv_id', '')
|
88 |
+
print(f"Processing paper ID: {paper.get('paper', {}).get('id', '')}, arxiv_id: {arxiv_id}") # Debug
|
89 |
if arxiv_id:
|
90 |
future = executor.submit(self.fetch_repos_counts, arxiv_id)
|
91 |
future_to_paper[future] = paper
|
|
|
98 |
for future in as_completed(future_to_paper):
|
99 |
paper = future_to_paper[future]
|
100 |
counts = future.result()
|
101 |
+
print(f"Paper ID: {paper.get('paper', {}).get('id', '')}, Counts: {counts}") # Debug
|
102 |
paper['models'] = counts['models']
|
103 |
paper['datasets'] = counts['datasets']
|
104 |
paper['spaces'] = counts['spaces']
|
|
|
152 |
key=lambda x: self.calculate_score(x),
|
153 |
reverse=True
|
154 |
)
|
155 |
+
print(f"Papers sorted by {self.sort_method}") # Debug
|
156 |
|
157 |
def set_sort_method(self, method):
|
158 |
valid_methods = ["hot", "new", "most_models", "most_datasets", "most_spaces"]
|
159 |
if method not in valid_methods:
|
160 |
method = "hot"
|
161 |
+
print(f"Setting sort method to: {method}") # Debug
|
162 |
self.sort_method = method
|
163 |
self.sort_papers()
|
164 |
self.current_page = 1
|
|
|
184 |
datasets = paper.get('datasets', 0)
|
185 |
spaces = paper.get('spaces', 0)
|
186 |
|
187 |
+
print(f"Formatting paper {rank}: Models={models}, Datasets={datasets}, Spaces={spaces}") # Debug
|
188 |
+
|
189 |
return f"""
|
190 |
<tr class="athing">
|
191 |
<td align="right" valign="top" class="title"><span class="rank">{rank}.</span></td>
|
|
|
245 |
|
246 |
def change_sort_method(method):
|
247 |
method_lower = method.lower().replace(" ", "_")
|
248 |
+
print(f"Changing sort method to: {method_lower}") # Debug
|
249 |
if paper_manager.set_sort_method(method_lower):
|
250 |
print("Sort method set successfully.")
|
251 |
return paper_manager.render_papers()
|
|
|
438 |
outputs=[paper_list]
|
439 |
)
|
440 |
|
441 |
+
demo.launch()
|