-
Notifications
You must be signed in to change notification settings - Fork 1
Use new build system #44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
+47
−42
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
206f487
Enable a a bidir port to have either one output enable, or one for ea…
robtaylor a2a4b41
changed endpoint
mooperd 4fedb61
Remove check for CHIPFLOW_API_KEY_ID and load dotenv before check for…
robtaylor 0c4c701
Rename CHIPFLOW_API_KEY_SECRET to CHIPFLOW_API_KEY
robtaylor File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,7 +12,7 @@ | |
| import time | ||
|
|
||
| import dotenv | ||
|
|
||
| from pprint import pformat | ||
| from amaranth import * | ||
|
|
||
| from .. import ChipFlowError | ||
|
|
@@ -65,15 +65,15 @@ def build_cli_parser(self, parser): | |
|
|
||
| def run_cli(self, args): | ||
| if args.action == "submit" and not args.dry_run: | ||
| dotenv.load_dotenv() | ||
| if self.project_name is None: | ||
| raise ChipFlowError( | ||
| "Key `chipflow.project_id` is not defined in chipflow.toml; " | ||
| "see https://chipflow.io/beta for details on how to join the beta") | ||
| if ("CHIPFLOW_API_KEY_ID" not in os.environ or | ||
| "CHIPFLOW_API_KEY_SECRET" not in os.environ): | ||
| "Key `chipflow.project_name` is not defined in chipflow.toml") | ||
| if "CHIPFLOW_API_KEY" not in os.environ: | ||
| raise ChipFlowError( | ||
| "Environment variables `CHIPFLOW_API_KEY_ID` and `CHIPFLOW_API_KEY_SECRET` " | ||
| "must be set in order to submit a design") | ||
| "Environment variable `CHIPFLOW_API_KEY` " | ||
| "must be set in order to submit a design. " | ||
| "You can set this in a `.env` file in your project root.") | ||
|
|
||
| rtlil_path = self.prepare() # always prepare before submission | ||
| if args.action == "submit": | ||
|
|
@@ -89,7 +89,6 @@ def prepare(self): | |
| def submit(self, rtlil_path, *, dry_run=False): | ||
| """Submit the design to the ChipFlow cloud builder. | ||
| """ | ||
| dotenv.load_dotenv() | ||
| git_head = subprocess.check_output( | ||
| ["git", "-C", os.environ["CHIPFLOW_ROOT"], | ||
| "rev-parse", "HEAD"], | ||
|
|
@@ -124,13 +123,13 @@ def submit(self, rtlil_path, *, dry_run=False): | |
| pads = {} | ||
| for iface, port in self.platform._ports.items(): | ||
| width = len(port.pins) | ||
| print(f"iface={iface}, port={port}, dir={port.direction}, width={width}") | ||
| logger.debug(f"iface={iface}, port={port}, dir={port.direction}, width={width}") | ||
| if width > 1: | ||
| for i in range(width): | ||
| padname = f"{iface}{i}" | ||
| print(f"padname={padname}, port={port}, loc={port.pins[i:i+1]}, " | ||
| logger.debug(f"padname={padname}, port={port}, loc={port.pins[i]}, " | ||
| f"dir={port.direction}, width={width}") | ||
| pads[padname] = {'loc': port.pins[i:i+1], 'dir': port.direction} | ||
| pads[padname] = {'loc': port.pins[i], 'dir': port.direction.value} | ||
|
|
||
| config = { | ||
| "dependency_versions": dep_versions, | ||
|
|
@@ -149,32 +148,14 @@ def submit(self, rtlil_path, *, dry_run=False): | |
| logger.info(f"Submitting {submission_name} for project {self.project_name}") | ||
|
|
||
| resp = requests.post( | ||
| os.environ.get("CHIPFLOW_API_ENDPOINT", "https://app.chipflow-infra.com/api/builds"), | ||
| auth=(os.environ["CHIPFLOW_API_KEY_ID"], os.environ["CHIPFLOW_API_KEY_SECRET"]), | ||
| os.environ.get("CHIPFLOW_API_ENDPOINT", "https://build.chipflow.org/api/builds"), | ||
| auth=os.environ["CHIPFLOW_API_KEY"], | ||
| data=data, | ||
| files={ | ||
| "rtlil": open(rtlil_path, "rb"), | ||
| "config": json.dumps(config), | ||
| }) | ||
| resp_data = resp.json() | ||
| if resp.status_code == 403: | ||
| raise ChipFlowError( | ||
| "Authentication failed; please verify the values of the the CHIPFLOW_API_KEY_ID " | ||
| "and CHIPFLOW_API_KEY_SECRET environment variables, if the issue persists, " | ||
| "contact support to resolve it") | ||
| elif resp.status_code >= 400: | ||
| raise ChipFlowError( | ||
| f"Submission failed ({resp_data['statusCode']} {resp_data['error']}: " | ||
| f"{resp_data['message']}); please contact support and provide this error message") | ||
| elif resp.status_code >= 300: | ||
| assert False, "3xx responses should not be returned" | ||
| elif resp.status_code >= 200: | ||
| if not resp_data["ok"]: | ||
| raise ChipFlowError( | ||
| f"Submission failed ({resp_data['msg']}); please contact support and provide " | ||
| f"this error message") | ||
| else: | ||
| print(f"{resp_data['msg']} (#{resp_data['id']}: {resp_data['name']}); " | ||
| f"{resp_data['url']}") | ||
| else: | ||
| ChipFlowError(f"Unexpected response from API: {resp}") | ||
|
Comment on lines
-160
to
-180
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Error handling is still needed. Auth failure, or other issues on cloud side - I just got a 404 for example. no idea why! |
||
| print(resp_data) | ||
| if resp.status_code != 200: | ||
| raise ChipFlowError(f"Failed to submit: {resp_data}") | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
auth takes a tuple: ('user', 'pass')