Skip to content
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

Add: Call _check_types in init of NIRGraph #123

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

benkroehs
Copy link
Contributor

With this change, the _check_types function is called per default during the __init__ of a NIRGraph. By this, wrongly-typed graphs throw an error.
(Also the function _check_types was defined twice, maybe just copied wrong)

Copy link
Collaborator

@Jegp Jegp left a comment

Choose a reason for hiding this comment

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

Thank you for the addition! This looks good in principle, but a lot of the tests are failing, partly, probably, because the metadata field is missing.

It could also be issues with the "enforced" type checking. That's not a bad thing, but we'll have to make sure the tests pass. I'm happy to give a hand here, but I would suggest first resolving the metadata problem and then see where we are.

nir/ir/graph.py Outdated
@@ -31,6 +31,12 @@ class NIRGraph(NIRNode):
output_type: Optional[Dict[str, np.ndarray]] = None
metadata: Dict[str, Any] = field(default_factory=dict)

def __init__(self, nodes, edges, type_check: bool = True):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Aren't you forgetting the metadata field?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah yes, you're right. I added this to the init. Does it looks fine now or should I change other things?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks good, yes. A lot of other tests are failing. Let me investigate...

@Jegp
Copy link
Collaborator

Jegp commented Feb 3, 2025

So, the changes actually exposed a lot of problems in the tests. Which is good, but it had to be fixed. Additionally, we had to correctly add the constructor arguments to __init__, ensure that the __post_init__ function was called correctly, and add the argument to static constructors, like from_list.

I've added a PR to your repo (benkroehs#1). If you merge this into your fork, we can push it upstream.

Fixes the `check_type` check for NIRGraph
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants