From 8cc78a2cba40d5e046563808842664e0e99f98d8 Mon Sep 17 00:00:00 2001 From: Andrew Holway Date: Mon, 7 Apr 2025 07:19:04 +0100 Subject: [PATCH 01/23] added log streaming to --wait --- chipflow_lib/steps/silicon.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/chipflow_lib/steps/silicon.py b/chipflow_lib/steps/silicon.py index 22d9cec9..5b2cb483 100644 --- a/chipflow_lib/steps/silicon.py +++ b/chipflow_lib/steps/silicon.py @@ -179,6 +179,7 @@ def submit(self, rtlil_path, *, dry_run=False, wait=False): logger.info(f"Submitted design: {resp_data}") build_url = f"{chipflow_api_origin}/build/{resp_data['build_id']}" build_status_url = f"{chipflow_api_origin}/build/{resp_data['build_id']}/status" + log_stream_url = f"{chipflow_api_origin}/build/{resp_data['build_id']}/logs?follow=true" print(f"Design submitted successfully! Build URL: {build_url}") @@ -204,9 +205,24 @@ def submit(self, rtlil_path, *, dry_run=False, wait=False): print("Build failed.") exit(1) + # Attempt to stream logs + with requests.get( + log_stream_url, + auth=(os.environ["CHIPFLOW_API_KEY_ID"], os.environ["CHIPFLOW_API_KEY_SECRET"]), + stream=True + ) as log_resp: + if log_resp.status_code == 200: + for line in log_resp.iter_lines(): + if line: + print(line.decode("utf-8")) # Print logs in real-time + elif log_resp.status_code == 404: + logger.error("Log streaming endpoint returned 404: Not Found.") + print("Log streaming failed: Build not found.") + exit(1) # Exit with failure + else: + logger.warning(f"Failed to stream logs: {log_resp.text}") # Wait before polling again time.sleep(10) - else: # Log detailed information about the failed request logger.error(f"Request failed with status code {resp.status_code}") From caa484fbee3e30cd5d09eeb585d5152ca4d905c7 Mon Sep 17 00:00:00 2001 From: Andrew Holway Date: Mon, 7 Apr 2025 19:14:54 +0100 Subject: [PATCH 02/23] error handling --- chipflow_lib/steps/silicon.py | 37 +++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/chipflow_lib/steps/silicon.py b/chipflow_lib/steps/silicon.py index 5b2cb483..a95dee4f 100644 --- a/chipflow_lib/steps/silicon.py +++ b/chipflow_lib/steps/silicon.py @@ -6,6 +6,7 @@ import logging import os import requests +import requests.exceptions import subprocess import time @@ -206,21 +207,27 @@ def submit(self, rtlil_path, *, dry_run=False, wait=False): exit(1) # Attempt to stream logs - with requests.get( - log_stream_url, - auth=(os.environ["CHIPFLOW_API_KEY_ID"], os.environ["CHIPFLOW_API_KEY_SECRET"]), - stream=True - ) as log_resp: - if log_resp.status_code == 200: - for line in log_resp.iter_lines(): - if line: - print(line.decode("utf-8")) # Print logs in real-time - elif log_resp.status_code == 404: - logger.error("Log streaming endpoint returned 404: Not Found.") - print("Log streaming failed: Build not found.") - exit(1) # Exit with failure - else: - logger.warning(f"Failed to stream logs: {log_resp.text}") + try: + with requests.get( + log_stream_url, + auth=(os.environ["CHIPFLOW_API_KEY_ID"], os.environ["CHIPFLOW_API_KEY_SECRET"]), + stream=True + ) as log_resp: + if log_resp.status_code == 200: + for line in log_resp.iter_lines(): + if line: + print(line.decode("utf-8")) # Print logs in real-time + elif log_resp.status_code == 404: + logger.error("Log streaming endpoint returned 404: Not Found.") + print("Log streaming failed: Build not found.") + exit(1) # Exit with failure + else: + logger.warning(f"Failed to stream logs: {log_resp.text}") + except requests.exceptions.ChunkedEncodingError as e: + logger.error("Log streaming failed due to a premature response termination.") + logger.error(f"Error details: {e}") + print("Log streaming interrupted. Please check the build status manually.") + exit(1) # Exit with failure # Wait before polling again time.sleep(10) else: From eb4e3a80e8e4b592a5c9499c6c87ea8bf942ef7d Mon Sep 17 00:00:00 2001 From: Andrew Holway Date: Mon, 7 Apr 2025 19:17:53 +0100 Subject: [PATCH 03/23] error handling --- chipflow_lib/steps/silicon.py | 1 - 1 file changed, 1 deletion(-) diff --git a/chipflow_lib/steps/silicon.py b/chipflow_lib/steps/silicon.py index a95dee4f..a00c9e1d 100644 --- a/chipflow_lib/steps/silicon.py +++ b/chipflow_lib/steps/silicon.py @@ -227,7 +227,6 @@ def submit(self, rtlil_path, *, dry_run=False, wait=False): logger.error("Log streaming failed due to a premature response termination.") logger.error(f"Error details: {e}") print("Log streaming interrupted. Please check the build status manually.") - exit(1) # Exit with failure # Wait before polling again time.sleep(10) else: From 5cb1b3d56af2c92d20d2798661f484e479f218c1 Mon Sep 17 00:00:00 2001 From: Andrew Holway Date: Sat, 12 Apr 2025 09:17:54 +0100 Subject: [PATCH 04/23] error handling --- chipflow_lib/steps/silicon.py | 39 ++++++++++++++--------------------- 1 file changed, 16 insertions(+), 23 deletions(-) diff --git a/chipflow_lib/steps/silicon.py b/chipflow_lib/steps/silicon.py index a00c9e1d..bcb67ebc 100644 --- a/chipflow_lib/steps/silicon.py +++ b/chipflow_lib/steps/silicon.py @@ -6,7 +6,6 @@ import logging import os import requests -import requests.exceptions import subprocess import time @@ -206,29 +205,23 @@ def submit(self, rtlil_path, *, dry_run=False, wait=False): print("Build failed.") exit(1) - # Attempt to stream logs - try: - with requests.get( - log_stream_url, - auth=(os.environ["CHIPFLOW_API_KEY_ID"], os.environ["CHIPFLOW_API_KEY_SECRET"]), - stream=True - ) as log_resp: - if log_resp.status_code == 200: - for line in log_resp.iter_lines(): - if line: - print(line.decode("utf-8")) # Print logs in real-time - elif log_resp.status_code == 404: - logger.error("Log streaming endpoint returned 404: Not Found.") - print("Log streaming failed: Build not found.") - exit(1) # Exit with failure - else: - logger.warning(f"Failed to stream logs: {log_resp.text}") - except requests.exceptions.ChunkedEncodingError as e: - logger.error("Log streaming failed due to a premature response termination.") - logger.error(f"Error details: {e}") - print("Log streaming interrupted. Please check the build status manually.") # Wait before polling again - time.sleep(10) + # time.sleep(10) + # Attempt to stream logs rather than time.sleep + with requests.get( + log_stream_url, + auth=(os.environ["CHIPFLOW_API_KEY_ID"], os.environ["CHIPFLOW_API_KEY_SECRET"]), + stream=True + ) as log_resp: + if log_resp.status_code == 200: + for line in log_resp.iter_lines(): + if line: + print(line.decode("utf-8")) # Print logs in real-time + sys.stdout.flush() + else: + logger.warning(f"Failed to stream logs: {log_resp.text}") + time.sleep(10) # Wait before polling again + else: # Log detailed information about the failed request logger.error(f"Request failed with status code {resp.status_code}") From ea4483a6690758dc511645378459fe125f6b423e Mon Sep 17 00:00:00 2001 From: Andrew Holway Date: Sat, 12 Apr 2025 14:55:47 +0100 Subject: [PATCH 05/23] added sys --- chipflow_lib/steps/silicon.py | 1 + 1 file changed, 1 insertion(+) diff --git a/chipflow_lib/steps/silicon.py b/chipflow_lib/steps/silicon.py index bcb67ebc..5879a942 100644 --- a/chipflow_lib/steps/silicon.py +++ b/chipflow_lib/steps/silicon.py @@ -8,6 +8,7 @@ import requests import subprocess import time +import sys import dotenv from amaranth import * From 65e2bc565401f7d1958b49b47d41a328dca7de15 Mon Sep 17 00:00:00 2001 From: Andrew Holway Date: Sat, 12 Apr 2025 14:57:00 +0100 Subject: [PATCH 06/23] removed whitespace --- chipflow_lib/steps/silicon.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chipflow_lib/steps/silicon.py b/chipflow_lib/steps/silicon.py index 5879a942..0453fd6c 100644 --- a/chipflow_lib/steps/silicon.py +++ b/chipflow_lib/steps/silicon.py @@ -219,7 +219,7 @@ def submit(self, rtlil_path, *, dry_run=False, wait=False): if line: print(line.decode("utf-8")) # Print logs in real-time sys.stdout.flush() - else: + else: logger.warning(f"Failed to stream logs: {log_resp.text}") time.sleep(10) # Wait before polling again From de52daba8b74770b9b7dc7f0cb43ec8af42f7454 Mon Sep 17 00:00:00 2001 From: Andrew Holway Date: Sat, 12 Apr 2025 15:03:57 +0100 Subject: [PATCH 07/23] catch log streaming errors and carry on --- chipflow_lib/steps/silicon.py | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/chipflow_lib/steps/silicon.py b/chipflow_lib/steps/silicon.py index 0453fd6c..c5060d15 100644 --- a/chipflow_lib/steps/silicon.py +++ b/chipflow_lib/steps/silicon.py @@ -209,19 +209,23 @@ def submit(self, rtlil_path, *, dry_run=False, wait=False): # Wait before polling again # time.sleep(10) # Attempt to stream logs rather than time.sleep - with requests.get( - log_stream_url, - auth=(os.environ["CHIPFLOW_API_KEY_ID"], os.environ["CHIPFLOW_API_KEY_SECRET"]), - stream=True - ) as log_resp: - if log_resp.status_code == 200: - for line in log_resp.iter_lines(): - if line: - print(line.decode("utf-8")) # Print logs in real-time - sys.stdout.flush() - else: - logger.warning(f"Failed to stream logs: {log_resp.text}") - time.sleep(10) # Wait before polling again + try: + with requests.get( + log_stream_url, + auth=(os.environ["CHIPFLOW_API_KEY_ID"], os.environ["CHIPFLOW_API_KEY_SECRET"]), + stream=True + ) as log_resp: + if log_resp.status_code == 200: + for line in log_resp.iter_lines(): + if line: + print(line.decode("utf-8")) # Print logs in real-time + sys.stdout.flush() + else: + logger.warning(f"Failed to stream logs: {log_resp.text}") + time.sleep(10) # Wait before polling again + except requests.RequestException as e: + logger.error(f"Error while streaming logs: {e}") + pass else: # Log detailed information about the failed request From e12d0197291d2c452df4a016f76fded719f48f1e Mon Sep 17 00:00:00 2001 From: Andrew Holway Date: Sat, 12 Apr 2025 15:38:18 +0100 Subject: [PATCH 08/23] Log streaming may have been interrupted. Some logs may be missing. --- chipflow_lib/steps/silicon.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/chipflow_lib/steps/silicon.py b/chipflow_lib/steps/silicon.py index c5060d15..e2e1115b 100644 --- a/chipflow_lib/steps/silicon.py +++ b/chipflow_lib/steps/silicon.py @@ -185,8 +185,11 @@ def submit(self, rtlil_path, *, dry_run=False, wait=False): print(f"Design submitted successfully! Build URL: {build_url}") # Poll the status API until the build is completed or failed + counter = 0 if wait: while True: + counter += 1 + logger.info(f"Polling build status... (attempt {counter})") status_resp = requests.get( build_status_url, auth=(os.environ["CHIPFLOW_API_KEY_ID"], os.environ["CHIPFLOW_API_KEY_SECRET"]) @@ -210,6 +213,8 @@ def submit(self, rtlil_path, *, dry_run=False, wait=False): # time.sleep(10) # Attempt to stream logs rather than time.sleep try: + if counter > 1: + logger.warning("Log streaming may have been interrupted. Some logs may be missing.") with requests.get( log_stream_url, auth=(os.environ["CHIPFLOW_API_KEY_ID"], os.environ["CHIPFLOW_API_KEY_SECRET"]), From dcab7747d48a6f32231a3447870f73a3fc9ca559 Mon Sep 17 00:00:00 2001 From: Andrew Holway Date: Sat, 12 Apr 2025 16:19:16 +0100 Subject: [PATCH 09/23] added Build URL to interuption warning --- chipflow_lib/steps/silicon.py | 1 + 1 file changed, 1 insertion(+) diff --git a/chipflow_lib/steps/silicon.py b/chipflow_lib/steps/silicon.py index e2e1115b..285e4bde 100644 --- a/chipflow_lib/steps/silicon.py +++ b/chipflow_lib/steps/silicon.py @@ -215,6 +215,7 @@ def submit(self, rtlil_path, *, dry_run=False, wait=False): try: if counter > 1: logger.warning("Log streaming may have been interrupted. Some logs may be missing.") + logger.warning(f"Check {build_url}") with requests.get( log_stream_url, auth=(os.environ["CHIPFLOW_API_KEY_ID"], os.environ["CHIPFLOW_API_KEY_SECRET"]), From 5dc531973db8eb00ef02a4731b1bac7c2dce299e Mon Sep 17 00:00:00 2001 From: Andrew Holway Date: Sat, 12 Apr 2025 17:32:08 +0100 Subject: [PATCH 10/23] empty From 253dc2e0f559c89bf24c688418e24c81ec0b6a67 Mon Sep 17 00:00:00 2001 From: Andrew Holway Date: Sat, 12 Apr 2025 18:11:36 +0100 Subject: [PATCH 11/23] empty From a4dcddcd5c2e6e964b4f344913e10add822e1833 Mon Sep 17 00:00:00 2001 From: Andrew Holway Date: Sat, 12 Apr 2025 18:31:59 +0100 Subject: [PATCH 12/23] empty From a0db462c546c09ecce0784a667b75b0439206a6c Mon Sep 17 00:00:00 2001 From: Andrew Holway Date: Sat, 12 Apr 2025 18:32:03 +0100 Subject: [PATCH 13/23] empty From 2cfab3788f1a3273e51963d004a260784c6cc7d0 Mon Sep 17 00:00:00 2001 From: Andrew Holway Date: Sat, 12 Apr 2025 18:32:06 +0100 Subject: [PATCH 14/23] empty From 4f920d4cd881e6dfc1f8d669c105df03bcc458eb Mon Sep 17 00:00:00 2001 From: Andrew Holway Date: Sat, 12 Apr 2025 18:32:10 +0100 Subject: [PATCH 15/23] empty From d01102934298a215b03a31105ba8472dd09e675e Mon Sep 17 00:00:00 2001 From: Andrew Holway Date: Sat, 12 Apr 2025 18:32:15 +0100 Subject: [PATCH 16/23] empty From 83cb9822159e8d61ea5485b22b00cceff6769e09 Mon Sep 17 00:00:00 2001 From: Andrew Holway Date: Sat, 12 Apr 2025 18:34:29 +0100 Subject: [PATCH 17/23] empty From 5db5c08fb18be0f60e34e3964a6733acb1348426 Mon Sep 17 00:00:00 2001 From: Andrew Holway Date: Sat, 12 Apr 2025 18:34:32 +0100 Subject: [PATCH 18/23] empty From 5b1916d6e81228ca3c910c33b8f5f663eaf57fa1 Mon Sep 17 00:00:00 2001 From: Andrew Holway Date: Sat, 12 Apr 2025 18:34:35 +0100 Subject: [PATCH 19/23] empty From c71ce75d030b72c3c70c14ec012db54fc3803933 Mon Sep 17 00:00:00 2001 From: Andrew Holway Date: Sat, 12 Apr 2025 18:34:38 +0100 Subject: [PATCH 20/23] empty From d9553910872bceaf4e3774bded05e0389528a763 Mon Sep 17 00:00:00 2001 From: Andrew Holway Date: Sat, 12 Apr 2025 18:38:29 +0100 Subject: [PATCH 21/23] empty From 1f191f86c3d818f24439f8bdb21d21a63d00fe6d Mon Sep 17 00:00:00 2001 From: Andrew Holway Date: Sat, 12 Apr 2025 18:38:32 +0100 Subject: [PATCH 22/23] empty From e5541174bf4d9492c07ab05418fc6bc9612f7f34 Mon Sep 17 00:00:00 2001 From: Andrew Holway Date: Sat, 12 Apr 2025 18:38:35 +0100 Subject: [PATCH 23/23] empty