Skip to content

Commit 086c9b0

Browse files
committed
added log streaming to --wait
1 parent 7f2df52 commit 086c9b0

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

chipflow_lib/steps/silicon.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ def submit(self, rtlil_path, *, dry_run=False, wait=False):
204204
logger.info(f"Submitted design: {resp_data}")
205205
build_url = f"{chipflow_api_origin}/build/{resp_data['build_id']}"
206206
build_status_url = f"{chipflow_api_origin}/build/{resp_data['build_id']}/status"
207+
log_stream_url = f"{chipflow_api_origin}/build/{resp_data['build_id']}/logs?follow=true"
207208

208209
print(f"Design submitted successfully! Build URL: {build_url}")
209210

@@ -230,8 +231,25 @@ def submit(self, rtlil_path, *, dry_run=False, wait=False):
230231
exit(1)
231232

232233
# Wait before polling again
234+
235+
# Attempt to stream logs rather than time.sleep
236+
with requests.get(
237+
log_stream_url,
238+
auth=(os.environ["CHIPFLOW_API_KEY_ID"], os.environ["CHIPFLOW_API_KEY_SECRET"]),
239+
stream=True
240+
) as log_resp:
241+
if log_resp.status_code == 200:
242+
for line in log_resp.iter_lines():
243+
if line:
244+
print(line.decode("utf-8")) # Print logs in real-time
245+
elif log_resp.status_code == 404:
246+
logger.error("Log streaming endpoint returned 404: Not Found.")
247+
print("Log streaming failed: Build not found.")
248+
exit(1) # Exit with failure
249+
else:
250+
logger.warning(f"Failed to stream logs: {log_resp.text}")
251+
# Wait before polling again
233252
time.sleep(10)
234-
235253
else:
236254
# Log detailed information about the failed request
237255
logger.error(f"Request failed with status code {resp.status_code}")

0 commit comments

Comments
 (0)