Spaces:
Runtime error
Runtime error
scheduler erased
Browse files
app.py
CHANGED
@@ -12,16 +12,15 @@ import gradio as gr
|
|
12 |
import pandas as pd
|
13 |
|
14 |
# Translation of legends and titels
|
15 |
-
ANNOTATED =
|
16 |
-
NUMBER_ANNOTATED =
|
17 |
-
PENDING =
|
18 |
|
19 |
NUMBER_ANNOTATORS = "Número de anotadores"
|
20 |
-
NAME =
|
21 |
-
NUMBER_ANNOTATIONS =
|
22 |
-
|
23 |
-
CATEGORY = 'Categoría'
|
24 |
|
|
|
25 |
|
26 |
|
27 |
def obtain_source_target_datasets() -> (
|
@@ -175,9 +174,7 @@ def kpi_chart_total_annotators() -> alt.Chart:
|
|
175 |
total_annotators = len(user_ids_annotations)
|
176 |
|
177 |
# Assuming you have a DataFrame with user data, create a sample DataFrame
|
178 |
-
data = pd.DataFrame(
|
179 |
-
{"Category": [NUMBER_ANNOTATORS], "Value": [total_annotators]}
|
180 |
-
)
|
181 |
|
182 |
# Create Altair chart
|
183 |
chart = (
|
@@ -190,14 +187,14 @@ def kpi_chart_total_annotators() -> alt.Chart:
|
|
190 |
return chart
|
191 |
|
192 |
|
193 |
-
def render_hub_user_link(hub_id:str) -> str:
|
194 |
"""
|
195 |
This function returns a link to the user's profile on Hugging Face.
|
196 |
|
197 |
Args:
|
198 |
hub_id: The user's id on Hugging Face.
|
199 |
|
200 |
-
Returns:
|
201 |
A string with the link to the user's profile on Hugging Face.
|
202 |
"""
|
203 |
link = f"https://huggingface.co/{hub_id}"
|
@@ -244,7 +241,7 @@ def fetch_data() -> None:
|
|
244 |
print(f"Data fetched: {datetime.datetime.now()}")
|
245 |
|
246 |
|
247 |
-
def get_top(N
|
248 |
"""
|
249 |
This function returns the top N users with the most annotations.
|
250 |
|
@@ -260,10 +257,6 @@ def get_top(N = 50) -> pd.DataFrame:
|
|
260 |
|
261 |
def main() -> None:
|
262 |
|
263 |
-
# Set the update interval
|
264 |
-
update_interval = 300 # seconds
|
265 |
-
update_interval_charts = 30 # seconds
|
266 |
-
|
267 |
# Connect to the space with rg.init()
|
268 |
rg.init(
|
269 |
api_url=os.getenv("ARGILLA_API_URL"),
|
@@ -272,7 +265,6 @@ def main() -> None:
|
|
272 |
|
273 |
fetch_data()
|
274 |
|
275 |
-
|
276 |
# To avoid the orange border for the Gradio elements that are in constant loading
|
277 |
css = """
|
278 |
.generating {
|
@@ -308,28 +300,13 @@ def main() -> None:
|
|
308 |
with gr.Row():
|
309 |
|
310 |
kpi_submitted_plot = gr.Plot(label="Plot")
|
311 |
-
demo.load(
|
312 |
-
kpi_chart_submitted,
|
313 |
-
inputs=[],
|
314 |
-
outputs=[kpi_submitted_plot],
|
315 |
-
every=update_interval_charts,
|
316 |
-
)
|
317 |
|
318 |
kpi_remaining_plot = gr.Plot(label="Plot")
|
319 |
-
demo.load(
|
320 |
-
kpi_chart_remaining,
|
321 |
-
inputs=[],
|
322 |
-
outputs=[kpi_remaining_plot],
|
323 |
-
every=update_interval_charts,
|
324 |
-
)
|
325 |
|
326 |
donut_total_plot = gr.Plot(label="Plot")
|
327 |
-
demo.load(
|
328 |
-
donut_chart_total,
|
329 |
-
inputs=[],
|
330 |
-
outputs=[donut_total_plot],
|
331 |
-
every=update_interval_charts,
|
332 |
-
)
|
333 |
|
334 |
gr.Markdown(
|
335 |
"""
|
@@ -341,9 +318,7 @@ def main() -> None:
|
|
341 |
with gr.Row():
|
342 |
|
343 |
kpi_hall_plot = gr.Plot(label="Plot")
|
344 |
-
demo.load(
|
345 |
-
kpi_chart_total_annotators, inputs=[], outputs=[kpi_hall_plot], every=update_interval_charts
|
346 |
-
)
|
347 |
|
348 |
top_df_plot = gr.Dataframe(
|
349 |
headers=[NAME, NUMBER_ANNOTATIONS],
|
@@ -354,13 +329,12 @@ def main() -> None:
|
|
354 |
row_count=50,
|
355 |
col_count=(2, "fixed"),
|
356 |
interactive=False,
|
357 |
-
every=update_interval,
|
358 |
)
|
359 |
-
demo.load(get_top, None, [top_df_plot]
|
360 |
|
361 |
# Launch the Gradio interface
|
362 |
demo.launch()
|
363 |
|
364 |
|
365 |
if __name__ == "__main__":
|
366 |
-
main()
|
|
|
12 |
import pandas as pd
|
13 |
|
14 |
# Translation of legends and titels
|
15 |
+
ANNOTATED = "Anotaciones"
|
16 |
+
NUMBER_ANNOTATED = "Anotaciones totales"
|
17 |
+
PENDING = "Pendiente"
|
18 |
|
19 |
NUMBER_ANNOTATORS = "Número de anotadores"
|
20 |
+
NAME = "Nombre de usuario"
|
21 |
+
NUMBER_ANNOTATIONS = "Número de anotaciones"
|
|
|
|
|
22 |
|
23 |
+
CATEGORY = "Categoría"
|
24 |
|
25 |
|
26 |
def obtain_source_target_datasets() -> (
|
|
|
174 |
total_annotators = len(user_ids_annotations)
|
175 |
|
176 |
# Assuming you have a DataFrame with user data, create a sample DataFrame
|
177 |
+
data = pd.DataFrame({"Category": [NUMBER_ANNOTATORS], "Value": [total_annotators]})
|
|
|
|
|
178 |
|
179 |
# Create Altair chart
|
180 |
chart = (
|
|
|
187 |
return chart
|
188 |
|
189 |
|
190 |
+
def render_hub_user_link(hub_id: str) -> str:
|
191 |
"""
|
192 |
This function returns a link to the user's profile on Hugging Face.
|
193 |
|
194 |
Args:
|
195 |
hub_id: The user's id on Hugging Face.
|
196 |
|
197 |
+
Returns:
|
198 |
A string with the link to the user's profile on Hugging Face.
|
199 |
"""
|
200 |
link = f"https://huggingface.co/{hub_id}"
|
|
|
241 |
print(f"Data fetched: {datetime.datetime.now()}")
|
242 |
|
243 |
|
244 |
+
def get_top(N=50) -> pd.DataFrame:
|
245 |
"""
|
246 |
This function returns the top N users with the most annotations.
|
247 |
|
|
|
257 |
|
258 |
def main() -> None:
|
259 |
|
|
|
|
|
|
|
|
|
260 |
# Connect to the space with rg.init()
|
261 |
rg.init(
|
262 |
api_url=os.getenv("ARGILLA_API_URL"),
|
|
|
265 |
|
266 |
fetch_data()
|
267 |
|
|
|
268 |
# To avoid the orange border for the Gradio elements that are in constant loading
|
269 |
css = """
|
270 |
.generating {
|
|
|
300 |
with gr.Row():
|
301 |
|
302 |
kpi_submitted_plot = gr.Plot(label="Plot")
|
303 |
+
demo.load(kpi_chart_submitted, inputs=[], outputs=[kpi_submitted_plot])
|
|
|
|
|
|
|
|
|
|
|
304 |
|
305 |
kpi_remaining_plot = gr.Plot(label="Plot")
|
306 |
+
demo.load(kpi_chart_remaining, inputs=[], outputs=[kpi_remaining_plot])
|
|
|
|
|
|
|
|
|
|
|
307 |
|
308 |
donut_total_plot = gr.Plot(label="Plot")
|
309 |
+
demo.load(donut_chart_total, inputs=[], outputs=[donut_total_plot])
|
|
|
|
|
|
|
|
|
|
|
310 |
|
311 |
gr.Markdown(
|
312 |
"""
|
|
|
318 |
with gr.Row():
|
319 |
|
320 |
kpi_hall_plot = gr.Plot(label="Plot")
|
321 |
+
demo.load(kpi_chart_total_annotators, inputs=[], outputs=[kpi_hall_plot])
|
|
|
|
|
322 |
|
323 |
top_df_plot = gr.Dataframe(
|
324 |
headers=[NAME, NUMBER_ANNOTATIONS],
|
|
|
329 |
row_count=50,
|
330 |
col_count=(2, "fixed"),
|
331 |
interactive=False,
|
|
|
332 |
)
|
333 |
+
demo.load(get_top, None, [top_df_plot])
|
334 |
|
335 |
# Launch the Gradio interface
|
336 |
demo.launch()
|
337 |
|
338 |
|
339 |
if __name__ == "__main__":
|
340 |
+
main()
|