Skip to content

Commit 4999830

Browse files
committed
minor update
1 parent 4cedc34 commit 4999830

File tree

2 files changed

+45
-1
lines changed

2 files changed

+45
-1
lines changed

agent/display.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,17 @@ def __init__(self, total_repos: int):
100100
)
101101
self.layout["progress"].split_row(
102102
Layout(name="pbar", ratio=4),
103+
Layout(name="time", ratio=1),
103104
Layout(name="money", ratio=1),
104105
)
105106

106107
self.layout["progress"]["pbar"].update(
107108
Panel(self.overall_progress, title="Overall Progress", border_style="blue")
108109
)
110+
self.time_display = Text("Time Spent So Far: 0s", justify="center")
111+
self.layout["progress"]["time"].update(
112+
Panel(self.time_display, title="$$$$", border_style="blue")
113+
)
109114
self.money_display = Text("Money Spent So Far: $0.00", justify="center")
110115
self.layout["progress"]["money"].update(
111116
Panel(self.money_display, title="$$$$", border_style="blue")
@@ -190,6 +195,24 @@ def update_agent_display(
190195
Panel(text, title=title, border_style="blue")
191196
)
192197

198+
def update_time_display(self, time_in_seconds: int) -> None:
199+
"""Update the time display with the given time."""
200+
days, remainder = divmod(time_in_seconds, 86400)
201+
hours, remainder = divmod(remainder, 3600)
202+
minutes, seconds = divmod(remainder, 60)
203+
if days > 0:
204+
time_str = f"{days}d {hours:02d}h {minutes:02d}m {seconds:02d}s"
205+
elif hours > 0:
206+
time_str = f"{hours:02d}h {minutes:02d}m {seconds:02d}s"
207+
elif minutes > 0:
208+
time_str = f"{minutes:02d}m {seconds:02d}s"
209+
else:
210+
time_str = f"{seconds:02d}s"
211+
self.time_display = Text(f"Time Spent So Far: {time_str}", justify="center")
212+
self.layout["progress"]["time"].update(
213+
Panel(self.time_display, title="Time", border_style="blue")
214+
)
215+
193216
def update_backend_display(self, backend: str) -> None:
194217
"""Update the backend display with the given backend."""
195218
self.backend_display = Text(f"Backend Using: {backend}", justify="center")

agent/run_agent.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ def run_agent_for_repo(
6666
repo_path = os.path.join(repo_base_dir, repo_name)
6767
repo_path = os.path.abspath(repo_path)
6868

69+
# TODO: remove this to make web3.py work
70+
if repo_name == "web3-py":
71+
repo_path = repo_path.replace("web3-py", "web3.py")
72+
6973
src_dir = os.path.join(repo_path, example["src_dir"])
7074

7175
try:
@@ -214,7 +218,11 @@ def run_agent(
214218
]
215219
display.set_not_started_repos(not_started_repos)
216220

217-
display.update_repo_progress_num(display_repo_progress_num)
221+
start_time = time.time()
222+
223+
display.update_repo_progress_num(
224+
min(display_repo_progress_num, max_parallel_repos)
225+
)
218226
display.update_backend_display(backend)
219227
display.update_log_dir_display(log_dir)
220228
display.update_agent_display(
@@ -248,6 +256,7 @@ def run_agent(
248256
)
249257
results.append(result)
250258

259+
last_time_update = 0
251260
while any(not r.ready() for r in results):
252261
try:
253262
while not update_queue.empty():
@@ -268,6 +277,14 @@ def run_agent(
268277
)
269278
except queue.Empty:
270279
pass
280+
281+
# Update time display every second
282+
current_time = time.time()
283+
if current_time - last_time_update >= 1:
284+
elapsed_time = int(current_time - start_time)
285+
display.update_time_display(elapsed_time)
286+
last_time_update = current_time
287+
271288
time.sleep(0.1) # Small delay to prevent busy-waiting
272289

273290
# Final update after all repos are processed
@@ -286,5 +303,9 @@ def run_agent(
286303
repo_name, file_name, money_spent = data
287304
display.update_money_display(repo_name, file_name, money_spent)
288305

306+
# Final time update
307+
elapsed_time = int(time.time() - start_time)
308+
display.update_time_display(elapsed_time)
309+
289310
for result in results:
290311
result.get()

0 commit comments

Comments
 (0)