refresh data button
Browse files- app.py +33 -14
- data/all_trades_profitability.csv +2 -2
- data/delivers.csv +2 -2
- data/fpmmTrades.csv +2 -2
- data/fpmms.csv +2 -2
- data/requests.csv +2 -2
- data/summary_profitability.csv +2 -2
- data/t_map.pkl +2 -2
- data/tools.csv +2 -2
app.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
import subprocess
|
2 |
import logging
|
|
|
3 |
import gradio as gr
|
4 |
import pandas as pd
|
5 |
from apscheduler.schedulers.background import BackgroundScheduler
|
@@ -30,15 +31,6 @@ from tabs.about import about_olas_predict
|
|
30 |
|
31 |
|
32 |
def refresh_data():
|
33 |
-
# Run the pull_data.py script and wait for it to finish
|
34 |
-
try:
|
35 |
-
result = subprocess.run(["python", "./scripts/pull_data.py"], check=True)
|
36 |
-
logging.info("Script executed successfully: %s", result)
|
37 |
-
except subprocess.CalledProcessError as e:
|
38 |
-
logging.error("Failed to run script: %s", e)
|
39 |
-
return # Stop execution if the script fails
|
40 |
-
|
41 |
-
# Reload dataframes
|
42 |
try:
|
43 |
global tools_df, trades_df, error_df, error_overall_df, winning_rate_df, winning_rate_overall_df, trades_count_df, trades_winning_rate_df
|
44 |
logging.info("Refreshing data...")
|
@@ -55,12 +47,27 @@ def refresh_data():
|
|
55 |
except Exception as e:
|
56 |
logging.error("Failed to refresh data: %s", e)
|
57 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
tools_df = pd.read_csv("./data/tools.csv", low_memory=False)
|
59 |
trades_df = pd.read_csv("./data/all_trades_profitability.csv")
|
60 |
trades_df = prepare_trades(trades_df)
|
61 |
|
|
|
62 |
demo = gr.Blocks()
|
63 |
|
|
|
64 |
INC_TOOLS = [
|
65 |
'prediction-online',
|
66 |
'prediction-offline',
|
@@ -76,7 +83,6 @@ INC_TOOLS = [
|
|
76 |
]
|
77 |
|
78 |
|
79 |
-
# TOOLS DATA
|
80 |
error_df = get_error_data(
|
81 |
tools_df=tools_df,
|
82 |
inc_tools=INC_TOOLS
|
@@ -153,6 +159,21 @@ with demo:
|
|
153 |
with gr.Row():
|
154 |
trade_details_plot
|
155 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
156 |
with gr.TabItem("🚀 Tool Winning Dashboard"):
|
157 |
with gr.Row():
|
158 |
gr.Markdown("# Plot showing overall winning rate")
|
@@ -302,10 +323,8 @@ with demo:
|
|
302 |
|
303 |
# Create the scheduler
|
304 |
scheduler = BackgroundScheduler(timezone=utc)
|
305 |
-
scheduler.add_job(
|
306 |
scheduler.start()
|
307 |
-
|
308 |
-
# scheduler.add_job(refresh_data, CronTrigger(hour='*')) # Runs every hour
|
309 |
-
# scheduler.start()
|
310 |
|
311 |
demo.queue(default_concurrency_limit=40).launch()
|
|
|
1 |
import subprocess
|
2 |
import logging
|
3 |
+
from datetime import datetime
|
4 |
import gradio as gr
|
5 |
import pandas as pd
|
6 |
from apscheduler.schedulers.background import BackgroundScheduler
|
|
|
31 |
|
32 |
|
33 |
def refresh_data():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
try:
|
35 |
global tools_df, trades_df, error_df, error_overall_df, winning_rate_df, winning_rate_overall_df, trades_count_df, trades_winning_rate_df
|
36 |
logging.info("Refreshing data...")
|
|
|
47 |
except Exception as e:
|
48 |
logging.error("Failed to refresh data: %s", e)
|
49 |
|
50 |
+
|
51 |
+
def pull_refresh_data():
|
52 |
+
# Run the pull_data.py script and wait for it to finish
|
53 |
+
try:
|
54 |
+
result = subprocess.run(["python", "./scripts/pull_data.py"], check=True)
|
55 |
+
logging.info("Script executed successfully: %s", result)
|
56 |
+
except subprocess.CalledProcessError as e:
|
57 |
+
logging.error("Failed to run script: %s", e)
|
58 |
+
return # Stop execution if the script fails
|
59 |
+
|
60 |
+
refresh_data()
|
61 |
+
|
62 |
+
|
63 |
tools_df = pd.read_csv("./data/tools.csv", low_memory=False)
|
64 |
trades_df = pd.read_csv("./data/all_trades_profitability.csv")
|
65 |
trades_df = prepare_trades(trades_df)
|
66 |
|
67 |
+
|
68 |
demo = gr.Blocks()
|
69 |
|
70 |
+
|
71 |
INC_TOOLS = [
|
72 |
'prediction-online',
|
73 |
'prediction-offline',
|
|
|
83 |
]
|
84 |
|
85 |
|
|
|
86 |
error_df = get_error_data(
|
87 |
tools_df=tools_df,
|
88 |
inc_tools=INC_TOOLS
|
|
|
159 |
with gr.Row():
|
160 |
trade_details_plot
|
161 |
|
162 |
+
with gr.Row():
|
163 |
+
with gr.Column():
|
164 |
+
refresh_button = gr.Button("Refresh Data")
|
165 |
+
with gr.Column():
|
166 |
+
latest_data_label = gr.Label(
|
167 |
+
value=f"Last Datepoint: {trades_df['creation_timestamp'].max()}"
|
168 |
+
)
|
169 |
+
|
170 |
+
def refresh_callback():
|
171 |
+
refresh_data()
|
172 |
+
latest_data_label.value = f"Last Datepoint: {trades_df['creation_timestamp'].max()}"
|
173 |
+
return latest_data_label.value
|
174 |
+
|
175 |
+
refresh_button.click(refresh_callback, outputs=latest_data_label)
|
176 |
+
|
177 |
with gr.TabItem("🚀 Tool Winning Dashboard"):
|
178 |
with gr.Row():
|
179 |
gr.Markdown("# Plot showing overall winning rate")
|
|
|
323 |
|
324 |
# Create the scheduler
|
325 |
scheduler = BackgroundScheduler(timezone=utc)
|
326 |
+
scheduler.add_job(pull_refresh_data, CronTrigger(hour=0, minute=0)) # Runs daily at 12 AM UTC
|
327 |
scheduler.start()
|
328 |
+
|
|
|
|
|
329 |
|
330 |
demo.queue(default_concurrency_limit=40).launch()
|
data/all_trades_profitability.csv
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:b72fb0e0fef1fd1dca99a5eb13126b892c7e57007c5f82985e84a4017ed603d9
|
3 |
+
size 30934774
|
data/delivers.csv
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:5ab02c18ce54ffd37dfb2602f2da3db92c2a3a302c797618eb045b51084a4098
|
3 |
+
size 1807054756
|
data/fpmmTrades.csv
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:19fd7a791f784004f7f04fd10cec62b7868452925aeaa70157cfa6da0c1afeb7
|
3 |
+
size 68441241
|
data/fpmms.csv
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:054fb82ef35ad64b3d1835d8708a355a36f75b742eccec74301fc828959aad23
|
3 |
+
size 423147
|
data/requests.csv
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:1248612c06090d0d576ea7f438b60990c9043256ce53f6bf3b871b42ed0eab90
|
3 |
+
size 144528918
|
data/summary_profitability.csv
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:2956b3f0d3a21b8c11a770cdb78e0655acab2164f2f680b4fa2addb449fcec62
|
3 |
+
size 54358
|
data/t_map.pkl
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e18c0957b8513a2f91a60ba7f83553752a261bdf150a24cb065cc30d52e0b92f
|
3 |
+
size 6585190
|
data/tools.csv
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:3a56b54aba97829458a543662334b4b66d64f69522f86a1427d31a3a6888f0aa
|
3 |
+
size 1911388629
|