Skip to content

Commit

Permalink
Add pyright github workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
math-fehr committed Nov 13, 2023
1 parent bfb8e11 commit 6bbed0c
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 8 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/ci-pyright.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: CI - Pyright

on:
# Trigger the workflow on push or pull request,
# but only for the master branch
push:
branches:
- main
pull_request:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10"]

env:
PYRIGHT_VERSION: 1.0

steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Upgrade pip
run: |
pip install --upgrade pip
- name: Install the package
run: |
pip install .[dev]
- name: Pyright
uses: jakebailey/pyright-action@v1
with:
version: "1.1.309"
14 changes: 7 additions & 7 deletions xdsl_pdl/fuzzing/generate_pdl_matches.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,11 @@ class PDLSynthContext:
def possible_values_of_type(self, type: Attribute) -> list[SSAValue]:
values: list[SSAValue] = []
for value in self.values.values():
if value.typ == type:
if value.type == type:
values.append(value)
for op in self.ops.values():
for result in op.results:
if result.typ == type:
if result.type == type:
values.append(result)
return values

Expand Down Expand Up @@ -158,7 +158,7 @@ def pdl_to_operations(
possible_values = pdl_context.possible_values_of_type(operand_type)
region_args = region.blocks[0].args
possible_values.extend(
[arg for arg in region_args if arg.typ == operand_type]
[arg for arg in region_args if arg.type == operand_type]
)
choice = randrange(0, len(possible_values) + 1)
if choice == len(possible_values):
Expand Down Expand Up @@ -195,11 +195,11 @@ def pdl_to_operations(
operands = [pdl_context.values[operand] for operand in op.operand_values]
result_types = [pdl_context.types[types] for types in op.type_values]
if op.opName is None:
op_def = ctx.get_op("unknown", allow_unregistered=True)
op_def = ctx.get_op("unknown")
else:
op_def = ctx.get_optional_op(op.opName.data)
if op_def is None:
op_def = ctx.get_op(op.opName.data, allow_unregistered=True)
op_def = ctx.get_op(op.opName.data)
new_op = op_def.create(
operands=operands, attributes=attributes, result_types=result_types
)
Expand All @@ -221,13 +221,13 @@ def create_dag_in_region(region: Region, dag: SingleEntryDAGStructure, ctx: MLCo
blocks.append(block)

region.blocks[0].add_op(
ctx.get_op("test.entry", allow_unregistered=True).create(successors=[blocks[0]])
ctx.get_op("test.entry").create(successors=[blocks[0]])
)

for i, adjency_set in enumerate(dag.get_adjency_list()):
block = blocks[i]
successors = [blocks[j] for j in adjency_set]
branch_op = ctx.get_op("test.branch", allow_unregistered=True)
branch_op = ctx.get_op("test.branch")
block.add_op(branch_op.create(successors=successors))


Expand Down
4 changes: 4 additions & 0 deletions xdsl_pdl/tools/generate_pdl_matches.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ def fuzz_pdl_matches(module: ModuleOp, ctx: MLContext, mlir_executable_path: str


class PDLMatchFuzzMain(xDSLOptMain):
def __init__(self):
super().__init__()
self.ctx.allow_unregistered = True

def register_all_arguments(self, arg_parser: argparse.ArgumentParser):
super().register_all_arguments(arg_parser)
arg_parser.add_argument("--mlir-executable", type=str, required=True)
Expand Down
2 changes: 1 addition & 1 deletion xdsl_pdl/tools/generate_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def fuzz_pdl_matches(
class GenerateTableMain(xDSLOptMain):
def register_all_dialects(self):
super().register_all_dialects()
self.ctx.register_dialect(PDLTest)
self.ctx.load_dialect(PDLTest)

def register_all_arguments(self, arg_parser: argparse.ArgumentParser):
super().register_all_arguments(arg_parser)
Expand Down

0 comments on commit 6bbed0c

Please sign in to comment.