Skip to content

Commit 8cc78a2

Browse files
committed
added log streaming to --wait
1 parent 4d1ec3d commit 8cc78a2

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
@@ -179,6 +179,7 @@ def submit(self, rtlil_path, *, dry_run=False, wait=False):
179179
logger.info(f"Submitted design: {resp_data}")
180180
build_url = f"{chipflow_api_origin}/build/{resp_data['build_id']}"
181181
build_status_url = f"{chipflow_api_origin}/build/{resp_data['build_id']}/status"
182+
log_stream_url = f"{chipflow_api_origin}/build/{resp_data['build_id']}/logs?follow=true"
182183

183184
print(f"Design submitted successfully! Build URL: {build_url}")
184185

@@ -204,9 +205,24 @@ def submit(self, rtlil_path, *, dry_run=False, wait=False):
204205
print("Build failed.")
205206
exit(1)
206207

208+
# Attempt to stream logs
209+
with requests.get(
210+
log_stream_url,
211+
auth=(os.environ["CHIPFLOW_API_KEY_ID"], os.environ["CHIPFLOW_API_KEY_SECRET"]),
212+
stream=True
213+
) as log_resp:
214+
if log_resp.status_code == 200:
215+
for line in log_resp.iter_lines():
216+
if line:
217+
print(line.decode("utf-8")) # Print logs in real-time
218+
elif log_resp.status_code == 404:
219+
logger.error("Log streaming endpoint returned 404: Not Found.")
220+
print("Log streaming failed: Build not found.")
221+
exit(1) # Exit with failure
222+
else:
223+
logger.warning(f"Failed to stream logs: {log_resp.text}")
207224
# Wait before polling again
208225
time.sleep(10)
209-
210226
else:
211227
# Log detailed information about the failed request
212228
logger.error(f"Request failed with status code {resp.status_code}")

0 commit comments

Comments
 (0)