Commit
·
66de1e0
1
Parent(s):
32781dc
cache
Browse files
app.py
CHANGED
|
@@ -11,7 +11,6 @@ from cachetools import TTLCache, cached
|
|
| 11 |
client = rg.Argilla(
|
| 12 |
api_url=os.getenv("ARGILLA_API_URL"), api_key=os.getenv("ARGILLA_API_KEY")
|
| 13 |
)
|
| 14 |
-
|
| 15 |
cache = TTLCache(maxsize=100, ttl=timedelta(minutes=10), timer=datetime.now)
|
| 16 |
|
| 17 |
|
|
@@ -20,7 +19,8 @@ def fetch_data(dataset_name: str, workspace: str):
|
|
| 20 |
|
| 21 |
|
| 22 |
@cached(cache)
|
| 23 |
-
def get_progress(
|
|
|
|
| 24 |
records = list(dataset.records)
|
| 25 |
total_records = len(records)
|
| 26 |
annotated_records = len(
|
|
@@ -35,7 +35,8 @@ def get_progress(dataset) -> dict:
|
|
| 35 |
|
| 36 |
|
| 37 |
@cached(cache)
|
| 38 |
-
def get_leaderboard(
|
|
|
|
| 39 |
user_annotations = {}
|
| 40 |
for record in dataset.records:
|
| 41 |
for response in record.responses:
|
|
@@ -155,9 +156,10 @@ def create_treemap(user_annotations, total_records):
|
|
| 155 |
|
| 156 |
|
| 157 |
def update_dashboard():
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
|
|
|
| 161 |
|
| 162 |
gauge_chart = create_gauge_chart(progress)
|
| 163 |
treemap = create_treemap(user_annotations, progress["total"])
|
|
|
|
| 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 |
|
|
|
|
| 19 |
|
| 20 |
|
| 21 |
@cached(cache)
|
| 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(
|
|
|
|
| 35 |
|
| 36 |
|
| 37 |
@cached(cache)
|
| 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 |
|
| 157 |
|
| 158 |
def update_dashboard():
|
| 159 |
+
dataset_name = os.getenv("DATASET_NAME")
|
| 160 |
+
workspace = os.getenv("WORKSPACE")
|
| 161 |
+
progress = get_progress(dataset_name, workspace)
|
| 162 |
+
user_annotations = get_leaderboard(dataset_name, workspace)
|
| 163 |
|
| 164 |
gauge_chart = create_gauge_chart(progress)
|
| 165 |
treemap = create_treemap(user_annotations, progress["total"])
|