Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
eeb4c50
Agustin's suggested Protocol class
CalMacCQ Oct 27, 2025
c5cf1d7
minor fixes
CalMacCQ Oct 27, 2025
8a3d6ba
more methods
CalMacCQ Oct 27, 2025
7b58c05
import Self from typing_extensions
CalMacCQ Oct 27, 2025
33e325b
Merge branch 'main' into cm/composable_pass
CalMacCQ Oct 27, 2025
5e31a3d
fix import
CalMacCQ Oct 27, 2025
c52de85
remove to_dict and from_dict methods as well as supported Ops
CalMacCQ Oct 27, 2025
6d7afc2
remove unused import
CalMacCQ Oct 27, 2025
89fabf0
node -> entrypoint
CalMacCQ Oct 27, 2025
91879cd
Merge branch 'main' into cm/composable_pass
CalMacCQ Oct 27, 2025
4878d5f
rename and update __init__.py
CalMacCQ Oct 27, 2025
7045270
Merge branch 'main' into cm/composable_pass
CalMacCQ Oct 27, 2025
d20aaaa
Merge branch 'main' into cm/composable_pass
CalMacCQ Oct 27, 2025
954730f
make a passes module
CalMacCQ Oct 28, 2025
448b5cf
move passes into hugr root
CalMacCQ Oct 28, 2025
17d1dc8
remove from build
CalMacCQ Oct 28, 2025
b6fa9a5
add __init__.py for passes
CalMacCQ Oct 28, 2025
cc9c151
undo init changes
CalMacCQ Oct 28, 2025
2d10e87
update __all__
CalMacCQ Oct 28, 2025
45bd86a
fix __all__ again
CalMacCQ Oct 28, 2025
6ca653e
minimal methods for ComposablePass
CalMacCQ Nov 12, 2025
9171dba
add ComposedPass dataclass
CalMacCQ Nov 12, 2025
c6fbfc0
fix to comp_pass
CalMacCQ Nov 12, 2025
fcf00c0
docstrings
CalMacCQ Nov 12, 2025
3ae525c
formatting stuff
CalMacCQ Nov 12, 2025
78e7522
Merge branch 'main' into cm/composable_pass
CalMacCQ Nov 12, 2025
af225a3
more ruff check
CalMacCQ Nov 12, 2025
92964a8
provide a default implementation of then() method
CalMacCQ Nov 12, 2025
f139d7c
fix default impl
CalMacCQ Nov 12, 2025
df0ab15
fixup then impl
CalMacCQ Nov 12, 2025
ac63dd5
fixup mypy and ruff
CalMacCQ Nov 12, 2025
9a157b8
yet another fix
CalMacCQ Nov 12, 2025
3db5bdd
more ruff nonsense
CalMacCQ Nov 12, 2025
67d7d38
rm self
CalMacCQ Nov 12, 2025
975ddbb
fixes
CalMacCQ Nov 12, 2025
0165ae7
Update hugr-py/src/hugr/passes/composable_pass.py
CalMacCQ Nov 12, 2025
2def5fc
fmt
CalMacCQ Nov 12, 2025
9673dc2
make name a property
CalMacCQ Nov 12, 2025
01b7126
add a dummy test
CalMacCQ Nov 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions hugr-py/src/hugr/hugr/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""The main HUGR structure."""

from .base import Hugr, NodeData
from .composable_pass import ComposablePass
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Open to better suggestions for this module name. I opted to not use pass.py as pass is a keyword in Python.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
Though maybe I'd move it out of hugr.hugr, and into its own thing?
hugr.passes.ComposablePass?

from .node_port import (
Direction,
InPort,
Expand All @@ -10,11 +11,12 @@
)

__all__ = [
"Hugr",
"NodeData",
"ComposablePass",
"Direction",
"Hugr",
"InPort",
"Wire",
"OutPort",
"Node",
"NodeData",
"OutPort",
"Wire",
]
24 changes: 24 additions & 0 deletions hugr-py/src/hugr/hugr/composable_pass.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"""A Protocol for a composable pass."""

from typing import Protocol

from typing_extensions import Self

from hugr.hugr.base import Hugr
from hugr.hugr.node_port import Node


class ComposablePass(Protocol):
"""A Protocol which represents a composable Hugr transformation."""

def __call__(self, hugr: Hugr) -> None: ...

def then(self, other: Self) -> Self: ...

def with_entrypoint(self, entrypoint: Node) -> Self: ...

@property
def is_global(self) -> bool: ...

@property
def is_recursive(self) -> bool: ...
Loading