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 test case to check if all ops are being verified #169

Closed
wants to merge 5 commits into from

Conversation

Mgluhovskoi
Copy link
Collaborator

Added one test case that checks if all ops have their data types verified. I also added a list where functions can be excluded if needed.

@Mgluhovskoi Mgluhovskoi added documentation Improvements or additions to documentation enhancement New feature or request tripy Pull request for the tripy project labels Aug 30, 2024
@Mgluhovskoi Mgluhovskoi self-assigned this Aug 30, 2024
@Mgluhovskoi
Copy link
Collaborator Author

I was able to implement a test case that checks if most of the operations are being verified or not, but I am not sure how to get a list of all ____s. I tried to use inspect.getmembers, but they don't show up here. Any recommendations?

@@ -181,3 +181,21 @@ def test_neg_dtype_constraints(test_data):
api_call_locals, namespace = _run_dtype_constraints_subtest(test_data)
if isinstance(api_call_locals[RETURN_VALUE], tp.Tensor):
assert api_call_locals[RETURN_VALUE].dtype == namespace[return_dtype]


operations = [obj.__qualname__ for _, obj in inspect.getmembers(tp) if inspect.isfunction(obj)]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you use tests.helper.get_all_tripy_interfaces here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It seems like tests.helper.get_all_tripy_interfaces doesn't work anymore

Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you elaborate? We use it for our docstring testing, so it should still be working.

Copy link
Collaborator Author

@Mgluhovskoi Mgluhovskoi Aug 30, 2024

Choose a reason for hiding this comment

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

I keep getting the following error when calling it:

test_dtype_constraints.py:29: in <module>
    print(get_all_tripy_interfaces())
../../tripy/common/datatype.py:48: in __repr__
    return cls.name
E   AttributeError: type object 'BaseDtype' has no attribute 'name

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh this is an issue do to me trying to print the result.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'll fix that in #170

@@ -181,3 +181,63 @@ def test_neg_dtype_constraints(test_data):
api_call_locals, namespace = _run_dtype_constraints_subtest(test_data)
if isinstance(api_call_locals[RETURN_VALUE], tp.Tensor):
assert api_call_locals[RETURN_VALUE].dtype == namespace[return_dtype]


def get_all_possible_verif_ops():
Copy link
Collaborator

Choose a reason for hiding this comment

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

Another approach could be to check all public APIs, and then for classes, check their methods. We can then filter those on whether any of the type annotations include tp.Tensor.

… this commit has lots of issue and it may be easier to just to add tensor checking from scratch
for block in tests.helper.consolidate_code_blocks(obj.__doc__)
if isinstance(block, tests.helper.DocstringCodeBlock)
]
if blocks is None:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Will this ever happen? Even if nothing is found, blocks will be an empty list, which is not None.

@pranavm-nvidia
Copy link
Collaborator

Adding this in #274

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request tripy Pull request for the tripy project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants