arshy commited on
Commit
af81022
·
1 Parent(s): cf60c9b

not automated

Browse files
Files changed (2) hide show
  1. app.py +10 -146
  2. tabs/__pycache__/error.cpython-310.pyc +0 -0
app.py CHANGED
@@ -28,116 +28,22 @@ from tabs.error import (
28
  plot_week_error_data
29
  )
30
  from tabs.about import about_olas_predict
 
31
 
 
 
 
 
 
 
 
 
32
 
33
- def update_trades_plots():
34
- global tools_df, trades_df, error_df, error_overall_df, winning_rate_df, winning_rate_overall_df, trades_count_df, trades_winning_rate_df
35
-
36
- refresh_data()
37
-
38
- updated_trades_by_week_plot = plot_trades_by_week(
39
- trades_df=trades_count_df
40
- )
41
-
42
- updated_winning_trades_by_week_plot = plot_winning_trades_by_week(
43
- trades_df=trades_winning_rate_df
44
- )
45
-
46
- updated_trade_details_plot = plot_trade_details(
47
- trade_detail="mech calls",
48
- trades_df=trades_df
49
- )
50
-
51
- return (
52
- updated_trades_by_week_plot,
53
- updated_winning_trades_by_week_plot,
54
- updated_trade_details_plot
55
- )
56
-
57
-
58
- def update_tool_winnings_plots():
59
- global tools_df, trades_df, error_df, error_overall_df, winning_rate_df, winning_rate_overall_df, trades_count_df, trades_winning_rate_df
60
-
61
- refresh_data()
62
-
63
- updated_winning_plot = plot_tool_winnings_overall(
64
- wins_df=winning_rate_overall_df,
65
- winning_selector="win_perc"
66
- )
67
-
68
- updated_tool_winnings_by_tool_plot = plot_tool_winnings_by_tool(
69
- wins_df=winning_rate_df,
70
- tool=INC_TOOLS[0]
71
- )
72
-
73
- return (
74
- updated_winning_plot,
75
- updated_tool_winnings_by_tool_plot
76
- )
77
-
78
- def update_error_plots():
79
- global tools_df, trades_df, error_df, error_overall_df, winning_rate_df, winning_rate_overall_df, trades_count_df, trades_winning_rate_df
80
-
81
- refresh_data()
82
-
83
- updated_error_overall_plot = plot_error_data(
84
- error_all_df=error_overall_df
85
- )
86
-
87
- updated_tool_error_plot = plot_tool_error_data(
88
- error_df=error_df,
89
- tool=INC_TOOLS[0]
90
- )
91
-
92
- updated_week_error_plot = plot_week_error_data(
93
- error_df=error_df,
94
- week=choices[-1]
95
- )
96
-
97
- return (
98
- updated_error_overall_plot,
99
- updated_tool_error_plot,
100
- updated_week_error_plot
101
- )
102
-
103
- def refresh_data():
104
- try:
105
- global tools_df, trades_df, error_df, error_overall_df, winning_rate_df, winning_rate_overall_df, trades_count_df, trades_winning_rate_df
106
-
107
- logging.info("Refreshing data...")
108
-
109
- tools_df = pd.read_parquet("./data/tools.parquet")
110
- trades_df = pd.read_parquet("./data/all_trades_profitability.parquet")
111
- trades_df = prepare_trades(trades_df)
112
- error_df = get_error_data(tools_df=tools_df, inc_tools=INC_TOOLS)
113
- error_overall_df = get_error_data_overall(error_df=error_df)
114
- winning_rate_df = get_tool_winning_rate(tools_df=tools_df, inc_tools=INC_TOOLS)
115
- winning_rate_overall_df = get_overall_winning_rate(wins_df=winning_rate_df)
116
- trades_count_df = get_overall_trades(trades_df=trades_df)
117
- trades_winning_rate_df = get_overall_winning_trades(trades_df=trades_df)
118
-
119
- logging.info("Data refreshed.")
120
- except Exception as e:
121
- logging.error("Failed to refresh data: %s", e)
122
-
123
-
124
- def pull_refresh_data():
125
- # Run the pull_data.py script and wait for it to finish
126
- try:
127
- result = subprocess.run(["python", "./scripts/pull_data.py"], check=True)
128
- logging.info("Script executed successfully: %s", result)
129
- refresh_data()
130
- except subprocess.CalledProcessError as e:
131
- logging.error("Failed to run script: %s", e)
132
- return # Stop execution if the script fails
133
-
134
- refresh_data()
135
-
136
-
137
  tools_df = pd.read_parquet("./data/tools.parquet")
138
  trades_df = pd.read_parquet("./data/all_trades_profitability.parquet")
139
  trades_df = prepare_trades(trades_df)
140
 
 
141
 
142
  demo = gr.Blocks()
143
 
@@ -233,19 +139,6 @@ with demo:
233
  with gr.Row():
234
  trade_details_plot
235
 
236
- with gr.Row():
237
- with gr.Column():
238
- refresh_button = gr.Button("Refresh Data")
239
-
240
- refresh_button.click(
241
- update_trades_plots,
242
- outputs=[
243
- trades_by_week_plot,
244
- winning_trades_by_week_plot,
245
- trade_details_plot,
246
- ]
247
- )
248
-
249
  with gr.TabItem("🚀 Tool Winning Dashboard"):
250
  with gr.Row():
251
  gr.Markdown("# Plot showing overall winning rate")
@@ -312,17 +205,6 @@ with demo:
312
  sel_tool
313
  with gr.Row():
314
  tool_winnings_by_tool_plot
315
- with gr.Row():
316
- refresh_button = gr.Button("Refresh Data")
317
-
318
- refresh_button.click(
319
- update_tool_winnings_plots,
320
- outputs=[
321
- winning_plot,
322
- tool_winnings_by_tool_plot
323
- ]
324
- )
325
-
326
 
327
  with gr.TabItem("🏥 Tool Error Dashboard"):
328
  with gr.Row():
@@ -400,26 +282,8 @@ with demo:
400
  with gr.Row():
401
  week_error_plot
402
 
403
- with gr.Row():
404
- refresh_button = gr.Button("Refresh Data")
405
-
406
- refresh_button.click(
407
- update_error_plots,
408
- outputs=[
409
- error_overall_plot,
410
- tool_error_plot,
411
- week_error_plot
412
- ]
413
- )
414
-
415
  with gr.TabItem("ℹ️ About"):
416
  with gr.Accordion("About Olas Predict"):
417
  gr.Markdown(about_olas_predict)
418
 
419
- # Create the scheduler
420
- scheduler = BackgroundScheduler(timezone=utc)
421
- scheduler.add_job(pull_refresh_data, CronTrigger(hour=0, minute=0)) # Runs daily at 12 AM UTC
422
- scheduler.start()
423
-
424
-
425
  demo.queue(default_concurrency_limit=40).launch()
 
28
  plot_week_error_data
29
  )
30
  from tabs.about import about_olas_predict
31
+ import psutil
32
 
33
+ def log_ram_usage():
34
+ process = psutil.Process()
35
+ mem_info = process.memory_info()
36
+ # Convert memory usage to GB
37
+ rss_gb = mem_info.rss / (1024 ** 3)
38
+ vms_gb = mem_info.vms / (1024 ** 3)
39
+ logging.info(f"RAM Usage: RSS={rss_gb:.2f} GB, VMS={vms_gb:.2f} GB")
40
+ print(f"RAM Usage: RSS={rss_gb:.2f} GB, VMS={vms_gb:.2f} GB")
41
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  tools_df = pd.read_parquet("./data/tools.parquet")
43
  trades_df = pd.read_parquet("./data/all_trades_profitability.parquet")
44
  trades_df = prepare_trades(trades_df)
45
 
46
+ log_ram_usage()
47
 
48
  demo = gr.Blocks()
49
 
 
139
  with gr.Row():
140
  trade_details_plot
141
 
 
 
 
 
 
 
 
 
 
 
 
 
 
142
  with gr.TabItem("🚀 Tool Winning Dashboard"):
143
  with gr.Row():
144
  gr.Markdown("# Plot showing overall winning rate")
 
205
  sel_tool
206
  with gr.Row():
207
  tool_winnings_by_tool_plot
 
 
 
 
 
 
 
 
 
 
 
208
 
209
  with gr.TabItem("🏥 Tool Error Dashboard"):
210
  with gr.Row():
 
282
  with gr.Row():
283
  week_error_plot
284
 
 
 
 
 
 
 
 
 
 
 
 
 
285
  with gr.TabItem("ℹ️ About"):
286
  with gr.Accordion("About Olas Predict"):
287
  gr.Markdown(about_olas_predict)
288
 
 
 
 
 
 
 
289
  demo.queue(default_concurrency_limit=40).launch()
tabs/__pycache__/error.cpython-310.pyc CHANGED
Binary files a/tabs/__pycache__/error.cpython-310.pyc and b/tabs/__pycache__/error.cpython-310.pyc differ