Skip to content

Commit cb853d6

Browse files
committed
style: format code with ruff
1 parent 3507659 commit cb853d6

File tree

3 files changed

+210
-176
lines changed

3 files changed

+210
-176
lines changed

run_gaia_with_monitor.py

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,111 +12,119 @@
1212

1313
def main(*args, config_file_name: str = "", output_dir: str = "", web_port: int = 8080):
1414
"""Run benchmark with integrated web monitoring"""
15-
15+
1616
# Validate required arguments
1717
if not output_dir:
1818
print("Error: output_dir is required")
19-
print("Usage: uv run main.py run-gaia-with-monitor --output_dir=path --config_file_name=name")
19+
print(
20+
"Usage: uv run main.py run-gaia-with-monitor --output_dir=path --config_file_name=name"
21+
)
2022
return 1
21-
23+
2224
# Create output directory if it doesn't exist
2325
os.makedirs(output_dir, exist_ok=True)
24-
26+
2527
print("=" * 50)
2628
print("Benchmark Runner with Monitor")
2729
print("=" * 50)
2830
print(f"Output directory: {output_dir}")
2931
print(f"Config name: {config_file_name}")
3032
print(f"Web port: {web_port}")
3133
print("=" * 50)
32-
34+
3335
# Global variables for process management
3436
benchmark_process: Optional[subprocess.Popen] = None
3537
monitor_process: Optional[subprocess.Popen] = None
36-
38+
3739
def cleanup_processes():
3840
"""Clean up running processes"""
3941
print("\nShutting down processes...")
40-
42+
4143
if benchmark_process and benchmark_process.poll() is None:
4244
print(f"Stopping benchmark (PID: {benchmark_process.pid})...")
4345
benchmark_process.terminate()
4446
try:
4547
benchmark_process.wait(timeout=5)
4648
except subprocess.TimeoutExpired:
4749
benchmark_process.kill()
48-
50+
4951
if monitor_process and monitor_process.poll() is None:
5052
print(f"Stopping monitor (PID: {monitor_process.pid})...")
5153
monitor_process.terminate()
5254
try:
5355
monitor_process.wait(timeout=5)
5456
except subprocess.TimeoutExpired:
5557
monitor_process.kill()
56-
58+
5759
print("Cleanup complete.")
58-
60+
5961
def signal_handler(signum, frame):
6062
"""Handle Ctrl+C gracefully"""
6163
cleanup_processes()
6264
sys.exit(0)
63-
65+
6466
# Set up signal handlers
6567
signal.signal(signal.SIGINT, signal_handler)
6668
signal.signal(signal.SIGTERM, signal_handler)
67-
69+
6870
try:
6971
# Start benchmark
7072
print("Starting benchmark...")
7173
benchmark_cmd = [
72-
"uv", "run", "main.py", "common-benchmark",
74+
"uv",
75+
"run",
76+
"main.py",
77+
"common-benchmark",
7378
f"--config_file_name={config_file_name}",
74-
f"output_dir={output_dir}"
79+
f"output_dir={output_dir}",
7580
]
7681
benchmark_process = subprocess.Popen(benchmark_cmd)
7782
print(f"Benchmark started with PID: {benchmark_process.pid}")
78-
83+
7984
# Wait a moment for benchmark to initialize
8085
time.sleep(3)
81-
86+
8287
# Start monitor
8388
print("Starting web monitor...")
8489
monitor_cmd = [
85-
"uv", "run", "utils/progress_check/gaia_web_monitor.py",
90+
"uv",
91+
"run",
92+
"utils/progress_check/gaia_web_monitor.py",
8693
output_dir,
87-
f"--web-port={web_port}"
94+
f"--web-port={web_port}",
8895
]
8996
monitor_process = subprocess.Popen(monitor_cmd)
9097
print(f"Monitor started with PID: {monitor_process.pid}")
9198
print(f"Web dashboard available at: http://localhost:{web_port}")
92-
99+
93100
print("\n" + "=" * 50)
94101
print("Both processes are running!")
95102
print("Press Ctrl+C to stop both processes")
96103
print("Monitor will continue running even if benchmark finishes")
97104
print("=" * 50)
98-
105+
99106
# Monitor the processes
100107
while True:
101108
time.sleep(5)
102-
109+
103110
# Check if benchmark process is still running
104111
if benchmark_process and benchmark_process.poll() is not None:
105112
print("Benchmark process ended")
106113
benchmark_process = None
107-
114+
108115
# Check if monitor process is still running
109116
if monitor_process and monitor_process.poll() is not None:
110117
print("Monitor process died unexpectedly. Restarting...")
111118
monitor_process = subprocess.Popen(monitor_cmd)
112119
print(f"Monitor restarted with PID: {monitor_process.pid}")
113-
120+
114121
except KeyboardInterrupt:
115122
cleanup_processes()
116-
123+
117124
return 0
118125

119126

120127
if __name__ == "__main__":
121128
import fire
129+
122130
fire.Fire(main)

0 commit comments

Comments
 (0)