Skip to content

Commit e4f687b

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

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

chipflow_lib/steps/silicon.py

Lines changed: 17 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

@@ -229,9 +230,24 @@ def submit(self, rtlil_path, *, dry_run=False, wait=False):
229230
print("Build failed.")
230231
exit(1)
231232

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

0 commit comments

Comments
 (0)