Skip to content

Commit 846ea77

Browse files
committed
Update agreggate to work
1 parent 9ea0858 commit 846ea77

File tree

1 file changed

+35
-8
lines changed

1 file changed

+35
-8
lines changed

scripts/print_aggregated_errors.py

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ def create_aggregated_error_file():
1616
"""Create aggregated error_stats.json from individual node files"""
1717
aggregated_errors = {}
1818

19-
# Define all possible nodes
19+
# Determine which nodes to check based on environment
20+
# Check if we're in a mainnet or testnet context by looking at existing files
2021
testnet_nodes = [
2122
"Node 01", "Node 04", "Node 05", "Node 06", "Node 07", "Node 08",
2223
"Node 09", "Node 10", "Node 13", "Node 14", "Node 21", "Node 23", "Node 37"
@@ -26,10 +27,23 @@ def create_aggregated_error_file():
2627
"Node 25", "Node 26", "Node 27", "Node 28", "Node 29", "Node 30"
2728
]
2829

29-
all_nodes = testnet_nodes + mainnet_nodes
30+
# Check which type of nodes have error files to determine context
31+
testnet_files_exist = any(os.path.exists(os.path.join(ERROR_DIR, f"errors_{node.replace(' ', '_')}.json")) for node in testnet_nodes)
32+
mainnet_files_exist = any(os.path.exists(os.path.join(ERROR_DIR, f"errors_{node.replace(' ', '_')}.json")) for node in mainnet_nodes)
33+
34+
# Determine which nodes to process
35+
if mainnet_files_exist and not testnet_files_exist:
36+
# Mainnet context
37+
nodes_to_check = mainnet_nodes
38+
elif testnet_files_exist and not mainnet_files_exist:
39+
# Testnet context
40+
nodes_to_check = testnet_nodes
41+
else:
42+
# Mixed context or no files - check all
43+
nodes_to_check = testnet_nodes + mainnet_nodes
3044

3145
# Read each individual node error file
32-
for node_name in all_nodes:
46+
for node_name in nodes_to_check:
3347
node_file = os.path.join(ERROR_DIR, f"errors_{node_name.replace(' ', '_')}.json")
3448
if os.path.exists(node_file):
3549
try:
@@ -94,7 +108,7 @@ def print_all_errors():
94108
# Create aggregated error file from individual files
95109
aggregated_errors = create_aggregated_error_file()
96110

97-
# Define all possible nodes for both testnet and mainnet
111+
# Determine which nodes to show based on context
98112
testnet_nodes = [
99113
"Node 01", "Node 04", "Node 05", "Node 06", "Node 07", "Node 08",
100114
"Node 09", "Node 10", "Node 13", "Node 14", "Node 21", "Node 23", "Node 37"
@@ -104,14 +118,27 @@ def print_all_errors():
104118
"Node 25", "Node 26", "Node 27", "Node 28", "Node 29", "Node 30"
105119
]
106120

107-
all_nodes = testnet_nodes + mainnet_nodes
121+
# Check which type of nodes have error files to determine context
122+
testnet_files_exist = any(os.path.exists(os.path.join(ERROR_DIR, f"errors_{node.replace(' ', '_')}.json")) for node in testnet_nodes)
123+
mainnet_files_exist = any(os.path.exists(os.path.join(ERROR_DIR, f"errors_{node.replace(' ', '_')}.json")) for node in mainnet_nodes)
124+
125+
# Determine which nodes to process
126+
if mainnet_files_exist and not testnet_files_exist:
127+
# Mainnet context
128+
nodes_to_show = mainnet_nodes
129+
elif testnet_files_exist and not mainnet_files_exist:
130+
# Testnet context
131+
nodes_to_show = testnet_nodes
132+
else:
133+
# Mixed context or no files - check all
134+
nodes_to_show = testnet_nodes + mainnet_nodes
108135

109136
# Get nodes that have errors
110137
nodes_with_errors = list(aggregated_errors.keys())
111138

112139
# If no aggregated errors, check individual files
113140
if not nodes_with_errors:
114-
for node_name in all_nodes:
141+
for node_name in nodes_to_show:
115142
node_file = os.path.join(ERROR_DIR, f"errors_{node_name.replace(' ', '_')}.json")
116143
if os.path.exists(node_file):
117144
try:
@@ -124,10 +151,10 @@ def print_all_errors():
124151

125152
# If still no nodes with errors, check all nodes anyway
126153
if not nodes_with_errors:
127-
nodes_with_errors = all_nodes
154+
nodes_with_errors = nodes_to_show
128155

129156
# Process each node
130-
for node_name in nodes_with_errors:
157+
for node_name in nodes_to_show:
131158
errors = get_all_errors_for_node(node_name)
132159

133160
if errors:

0 commit comments

Comments
 (0)