Spaces:
Sleeping
Sleeping
Commit
•
6f2b708
1
Parent(s):
73b17e1
revert
Browse files
app.py
CHANGED
@@ -1,26 +1,21 @@
|
|
1 |
import os
|
2 |
-
|
3 |
-
|
4 |
-
import argilla as rg
|
5 |
-
import gradio as gr
|
6 |
import pandas as pd
|
7 |
-
import
|
|
|
8 |
import plotly.graph_objects as go
|
9 |
-
|
10 |
|
11 |
client = rg.Argilla(
|
12 |
api_url=os.getenv("ARGILLA_API_URL"), api_key=os.getenv("ARGILLA_API_KEY")
|
13 |
)
|
14 |
-
cache = TTLCache(maxsize=100, ttl=timedelta(minutes=10), timer=datetime.now)
|
15 |
|
16 |
|
17 |
def fetch_data(dataset_name: str, workspace: str):
|
18 |
return client.datasets(dataset_name, workspace=workspace)
|
19 |
|
20 |
|
21 |
-
|
22 |
-
def get_progress(dataset_name: str, workspace: str) -> dict:
|
23 |
-
dataset = fetch_data(dataset_name, workspace)
|
24 |
records = list(dataset.records)
|
25 |
total_records = len(records)
|
26 |
annotated_records = len(
|
@@ -34,9 +29,7 @@ def get_progress(dataset_name: str, workspace: str) -> dict:
|
|
34 |
}
|
35 |
|
36 |
|
37 |
-
|
38 |
-
def get_leaderboard(dataset_name: str, workspace: str) -> dict:
|
39 |
-
dataset = fetch_data(dataset_name, workspace)
|
40 |
user_annotations = {}
|
41 |
for record in dataset.records:
|
42 |
for response in record.responses:
|
@@ -156,10 +149,9 @@ def create_treemap(user_annotations, total_records):
|
|
156 |
|
157 |
|
158 |
def update_dashboard():
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
user_annotations = get_leaderboard(dataset_name, workspace)
|
163 |
|
164 |
gauge_chart = create_gauge_chart(progress)
|
165 |
treemap = create_treemap(user_annotations, progress["total"])
|
@@ -175,10 +167,7 @@ def update_dashboard():
|
|
175 |
|
176 |
|
177 |
with gr.Blocks() as demo:
|
178 |
-
gr.Markdown("# Argilla Dataset
|
179 |
-
gr.Markdown(
|
180 |
-
"This dashboard shows the progress of the dataset annotation and the contributions of the annotators for a dataset on [Argilla](https://davanstrien-my-argilla.hf.space/dataset/1100a091-7f3f-4a6e-ad51-4e859abab58f/annotation-mode?page=2&status=pending)."
|
181 |
-
)
|
182 |
|
183 |
with gr.Row():
|
184 |
gauge_output = gr.Plot(label="Overall Progress")
|
|
|
1 |
import os
|
2 |
+
import datetime
|
|
|
|
|
|
|
3 |
import pandas as pd
|
4 |
+
import gradio as gr
|
5 |
+
import argilla as rg
|
6 |
import plotly.graph_objects as go
|
7 |
+
import plotly.colors as colors
|
8 |
|
9 |
client = rg.Argilla(
|
10 |
api_url=os.getenv("ARGILLA_API_URL"), api_key=os.getenv("ARGILLA_API_KEY")
|
11 |
)
|
|
|
12 |
|
13 |
|
14 |
def fetch_data(dataset_name: str, workspace: str):
|
15 |
return client.datasets(dataset_name, workspace=workspace)
|
16 |
|
17 |
|
18 |
+
def get_progress(dataset) -> dict:
|
|
|
|
|
19 |
records = list(dataset.records)
|
20 |
total_records = len(records)
|
21 |
annotated_records = len(
|
|
|
29 |
}
|
30 |
|
31 |
|
32 |
+
def get_leaderboard(dataset) -> dict:
|
|
|
|
|
33 |
user_annotations = {}
|
34 |
for record in dataset.records:
|
35 |
for response in record.responses:
|
|
|
149 |
|
150 |
|
151 |
def update_dashboard():
|
152 |
+
dataset = fetch_data(os.getenv("DATASET_NAME"), os.getenv("WORKSPACE"))
|
153 |
+
progress = get_progress(dataset)
|
154 |
+
user_annotations = get_leaderboard(dataset)
|
|
|
155 |
|
156 |
gauge_chart = create_gauge_chart(progress)
|
157 |
treemap = create_treemap(user_annotations, progress["total"])
|
|
|
167 |
|
168 |
|
169 |
with gr.Blocks() as demo:
|
170 |
+
gr.Markdown("# Argilla Dataset Dashboard")
|
|
|
|
|
|
|
171 |
|
172 |
with gr.Row():
|
173 |
gauge_output = gr.Plot(label="Overall Progress")
|