Commit
•
c77eb65
1
Parent(s):
ab39a72
Update app.py
Browse files
app.py
CHANGED
@@ -15,7 +15,6 @@ import uuid
|
|
15 |
from pathlib import Path
|
16 |
import panel as pn
|
17 |
|
18 |
-
|
19 |
pn.extension(design="material")
|
20 |
# Create a queue to communicate between threads
|
21 |
post_queue = queue.Queue()
|
@@ -32,8 +31,8 @@ example = pd.DataFrame(
|
|
32 |
)
|
33 |
df = DataFrame(stream, example=example)
|
34 |
|
35 |
-
# Calculate backlog for
|
36 |
-
|
37 |
|
38 |
# Add environment variable support for configuration
|
39 |
REPO_ID = os.getenv("HF_REPO_ID", "davanstrien/bluesky-counts")
|
@@ -65,14 +64,14 @@ DATA_FILE = f"bluesky_counts_{uuid.uuid4()}.json"
|
|
65 |
# data = []
|
66 |
# with open(local_path, "r") as f:
|
67 |
# data.extend(json.loads(line.strip()) for line in f)
|
68 |
-
# # Keep only last
|
69 |
-
# return data[-
|
70 |
# except Exception as e:
|
71 |
# print(f"Error loading data from Hub: {e}")
|
72 |
# return []
|
73 |
|
74 |
|
75 |
-
#
|
76 |
# DATA_FOLDER.mkdir(exist_ok=True)
|
77 |
# scheduler = CommitScheduler(
|
78 |
# repo_id=REPO_ID,
|
@@ -125,14 +124,14 @@ def emit_counts():
|
|
125 |
time.sleep(1)
|
126 |
|
127 |
|
128 |
-
# Create the plot with
|
129 |
plot = df.hvplot.line(
|
130 |
"timestamp",
|
131 |
"post_count",
|
132 |
-
title="Bluesky Posts per Second",
|
133 |
width=800,
|
134 |
height=400,
|
135 |
-
backlog=
|
136 |
)
|
137 |
|
138 |
|
@@ -162,6 +161,6 @@ if __name__ == "__main__":
|
|
162 |
dashboard,
|
163 |
address="0.0.0.0",
|
164 |
port=7860,
|
165 |
-
allow_websocket_origin=["*"],
|
166 |
show=False,
|
167 |
-
)
|
|
|
15 |
from pathlib import Path
|
16 |
import panel as pn
|
17 |
|
|
|
18 |
pn.extension(design="material")
|
19 |
# Create a queue to communicate between threads
|
20 |
post_queue = queue.Queue()
|
|
|
31 |
)
|
32 |
df = DataFrame(stream, example=example)
|
33 |
|
34 |
+
# Calculate backlog for 24 hours
|
35 |
+
DAY_IN_SECONDS = 24 * 60 * 60 # 24 hours * 60 minutes * 60 seconds
|
36 |
|
37 |
# Add environment variable support for configuration
|
38 |
REPO_ID = os.getenv("HF_REPO_ID", "davanstrien/bluesky-counts")
|
|
|
64 |
# data = []
|
65 |
# with open(local_path, "r") as f:
|
66 |
# data.extend(json.loads(line.strip()) for line in f)
|
67 |
+
# # Keep only last 24 hours of data
|
68 |
+
# return data[-DAY_IN_SECONDS:]
|
69 |
# except Exception as e:
|
70 |
# print(f"Error loading data from Hub: {e}")
|
71 |
# return []
|
72 |
|
73 |
|
74 |
+
# Initialize storage and Hub connection
|
75 |
# DATA_FOLDER.mkdir(exist_ok=True)
|
76 |
# scheduler = CommitScheduler(
|
77 |
# repo_id=REPO_ID,
|
|
|
124 |
time.sleep(1)
|
125 |
|
126 |
|
127 |
+
# Create the plot with 24-hour backlog
|
128 |
plot = df.hvplot.line(
|
129 |
"timestamp",
|
130 |
"post_count",
|
131 |
+
title="Bluesky Posts per Second (Last 24 Hours)",
|
132 |
width=800,
|
133 |
height=400,
|
134 |
+
backlog=DAY_IN_SECONDS, # Keep last 24 hours of points
|
135 |
)
|
136 |
|
137 |
|
|
|
161 |
dashboard,
|
162 |
address="0.0.0.0",
|
163 |
port=7860,
|
164 |
+
allow_websocket_origin=["*"],
|
165 |
show=False,
|
166 |
+
)
|