-
Notifications
You must be signed in to change notification settings - Fork 1
Replace providers #28
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9889e9e
Update README to use pdm install
robtaylor fc9ea00
Add pin-lock functionality and remove providers
robtaylor e415a26
tests: Update tests for pin-lock functionality
robtaylor 3a84216
Update pyproject.toml and add pdm.lock
robtaylor 9b913ab
docs: update for pin-lock and tweak CI for docs
robtaylor d04d76b
chore: ignore .coverage
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| # .github/workflows/deploy.yml | ||
| name: Deploy | ||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| jobs: | ||
| deploy: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup PDM | ||
| uses: pdm-project/setup-pdm@v4 | ||
| with: | ||
| python-version: 3.12 | ||
| cache: true | ||
|
|
||
| - name: Install dependencies | ||
| run: pdm install | ||
|
|
||
| - name: Build docs | ||
| run: pdm docs | ||
|
|
||
| - uses: JamesIves/github-pages-deploy-action@v4 | ||
| with: | ||
| folder: docs/_build | ||
| branch: gh-pages | ||
| clean-exclude: pr-preview | ||
| force: false |
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 |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| # .github/workflows/preview.yml | ||
| name: Deploy PR previews | ||
| concurrency: preview-${{ github.ref }} | ||
| on: | ||
| pull_request: | ||
| types: | ||
| - opened | ||
| - reopened | ||
| - synchronize | ||
| - closed | ||
| jobs: | ||
| deploy-preview: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup PDM | ||
| uses: pdm-project/setup-pdm@v4 | ||
| with: | ||
| python-version: 3.12 | ||
| cache: true | ||
|
|
||
| - name: Install dependencies | ||
| run: pdm install | ||
|
|
||
| - name: Build docs | ||
| run: pdm docs | ||
| if: github.event.action != 'closed' | ||
|
|
||
| - uses: rossjrw/pr-preview-action@v1 | ||
| with: | ||
| source-dir: docs/_build | ||
| preview-branch: gh-pages | ||
| umbrella-dir: pr-preview | ||
| action: auto | ||
| pages-base-url: chipflow-lib.docs.chipflow-infra.com |
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 |
|---|---|---|
| @@ -1,4 +1,144 @@ | ||
| # SPDX-License-Identifier: BSD-2-Clause | ||
| import importlib.metadata | ||
| import jsonschema | ||
| import os | ||
| import sys | ||
| import tomli | ||
|
|
||
| __version__ = importlib.metadata.version("chipflow_lib") | ||
|
|
||
|
|
||
| class ChipFlowError(Exception): | ||
| pass | ||
|
|
||
|
|
||
| def _get_cls_by_reference(reference, context): | ||
| module_ref, _, class_ref = reference.partition(":") | ||
| try: | ||
| module_obj = importlib.import_module(module_ref) | ||
| except ModuleNotFoundError as e: | ||
| raise ChipFlowError(f"Module `{module_ref}` referenced by {context} is not found") from e | ||
| try: | ||
| return getattr(module_obj, class_ref) | ||
| except AttributeError as e: | ||
| raise ChipFlowError(f"Module `{module_ref}` referenced by {context} does not define " | ||
| f"`{class_ref}`") from e | ||
|
|
||
|
|
||
| def _ensure_chipflow_root(): | ||
| if "CHIPFLOW_ROOT" not in os.environ: | ||
| os.environ["CHIPFLOW_ROOT"] = os.getcwd() | ||
| if os.environ["CHIPFLOW_ROOT"] not in sys.path: | ||
| sys.path.append(os.environ["CHIPFLOW_ROOT"]) | ||
| return os.environ["CHIPFLOW_ROOT"] | ||
|
|
||
|
|
||
| # TODO: convert to pydantic, one truth of source for the schema | ||
| config_schema = { | ||
| "$schema": "https://json-schema.org/draft/2020-12/schema", | ||
| "$id": "https://chipflow.io/meta/chipflow.toml.schema.json", | ||
| "title": "chipflow.toml", | ||
| "type": "object", | ||
| "required": [ | ||
| "chipflow" | ||
| ], | ||
| "properties": { | ||
| "chipflow": { | ||
| "type": "object", | ||
| "required": [ | ||
| "steps", | ||
| "silicon" | ||
| ], | ||
| "additionalProperties": False, | ||
| "properties": { | ||
| "project_name": { | ||
| "type": "string", | ||
| }, | ||
| "top": { | ||
| "type": "object", | ||
| }, | ||
| "steps": { | ||
| "type": "object", | ||
| }, | ||
| "clocks": { | ||
| "type": "object", | ||
| "patternPropertues": { | ||
| ".+": {"type": "string"} | ||
| }, | ||
| }, | ||
| "resets": { | ||
| "type": "object", | ||
| "patternPropertues": { | ||
| ".+": {"type": "string"} | ||
| }, | ||
| }, | ||
| "silicon": { | ||
| "type": "object", | ||
| "required": [ | ||
| "process", | ||
| "package", | ||
| ], | ||
| "additionalProperties": False, | ||
| "properties": { | ||
| "process": { | ||
| "enum": ["sky130", "gf180", "customer1", "gf130bcd", "ihp_sg13g2"] | ||
| }, | ||
| "package": { | ||
| "enum": ["caravel", "cf20", "pga144"] | ||
| }, | ||
| "pads": {"$ref": "#/$defs/pin"}, | ||
| "power": {"$ref": "#/$defs/pin"}, | ||
| "debug": { | ||
| "type": "object", | ||
| "properties": { | ||
| "heartbeat": {"type": "boolean"} | ||
| } | ||
| } | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| "$defs": { | ||
| "pin": { | ||
| "type": "object", | ||
| "additionalProperties": False, | ||
| "minProperties": 1, | ||
| "patternProperties": { | ||
| ".+": { | ||
| "type": "object", | ||
| "required": [ | ||
| "type", | ||
| "loc", | ||
| ], | ||
| "additionalProperties": False, | ||
| "properties": { | ||
| "type": { | ||
| "enum": ["io", "i", "o", "oe", "clock", "reset", "power", "ground"] | ||
| }, | ||
| "loc": { | ||
| "type": "string", | ||
| "pattern": "^[NSWE]?[0-9]+$" | ||
| }, | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
||
| def _parse_config(): | ||
| chipflow_root = _ensure_chipflow_root() | ||
| config_file = f"{chipflow_root}/chipflow.toml" | ||
| return _parse_config_file(config_file) | ||
|
|
||
|
|
||
| def _parse_config_file(config_file): | ||
| with open(config_file, "rb") as f: | ||
| config_dict = tomli.load(f) | ||
|
|
||
| try: | ||
| jsonschema.validate(config_dict, config_schema) | ||
| return config_dict | ||
| except jsonschema.ValidationError as e: | ||
| raise ChipFlowError(f"Syntax error in `chipflow.toml` at `{'.'.join(e.path)}`: {e.message}") | ||
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.
Uh oh!
There was an error while loading. Please reload this page.