Spaces:
Sleeping
Sleeping
Commit
•
5c0a0b7
1
Parent(s):
58c365c
add cache
Browse files
app.py
CHANGED
@@ -4,13 +4,16 @@ import pandas as pd
|
|
4 |
import gradio as gr
|
5 |
import argilla as rg
|
6 |
import plotly.graph_objects as go
|
7 |
-
import
|
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 |
|
|
|
4 |
import gradio as gr
|
5 |
import argilla as rg
|
6 |
import plotly.graph_objects as go
|
7 |
+
from cachetools import TTLCache, cached
|
8 |
|
9 |
client = rg.Argilla(
|
10 |
api_url=os.getenv("ARGILLA_API_URL"), api_key=os.getenv("ARGILLA_API_KEY")
|
11 |
)
|
12 |
|
13 |
+
cache = TTLCache(maxsize=100, ttl=timedelta(minutes=10), timer=datetime.now)
|
14 |
|
15 |
+
|
16 |
+
@cached(cache)
|
17 |
def fetch_data(dataset_name: str, workspace: str):
|
18 |
return client.datasets(dataset_name, workspace=workspace)
|
19 |
|