Skip to content

Decide how to test numba functions #77

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

Closed
eric-czech opened this issue Jul 29, 2020 · 6 comments
Closed

Decide how to test numba functions #77

eric-czech opened this issue Jul 29, 2020 · 6 comments
Labels
documentation Improvements or additions to documentation process + tools

Comments

@eric-czech
Copy link
Collaborator

Testing and getting coverage on jit-compiled functions presents a couple challenges. In https://github.com/pystatgen/sgkit/pull/76, I started by creating separate variables for jit-functions and testing them alongside the original function as part of the same test run. Two reasons for this are that:

  1. There are tests that should only be run using the jit-compiled function since they would be prohibitively slow otherwise
  2. Code coverage is only possible on the original functions

One alternative to this would be to not have separate versions of each function and do this instead:

  • Run all unit tests with coverage and NUMBA_DISABLE_JIT turned on, and read this env variable in the tests to skip some that would otherwise be prohibitively slow
  • Disable coverage, disable NUMBA_DISABLE_JIT (so jit is on), and run a subset of the tests again that actually reference JIT-compiled functions

I think this alternative is better, but I'm not sure what a good way is to limit the scope of tests run with JIT on.

@ravwojdyla
Copy link
Collaborator

Just wanted to mention pytest markers, it doesn't solve the main issue but might be useful here.

@ravwojdyla ravwojdyla added documentation Improvements or additions to documentation process + tools labels Jul 30, 2020
@daletovar
Copy link
Collaborator

Why is code coverage only possible on the original functions? I like your alternative if that's the case. I don't think it's important for #76, but I think in most cases we should have nogil=True when using njit.

@eric-czech
Copy link
Collaborator Author

eric-czech commented Aug 4, 2020

Why is code coverage only possible on the original functions?

Hey @daletovar! I'm not sure except that codecov recognizes that there's code to be covered in an @njit function but then goes on to fail to recognize any tests that force all the code paths within it. Perhaps it decides what should be covered based on the source code and then decides what is covered based on parsed/compiled code. That sounds like a reasonable way for it to work but I really have no idea what it does internally.

@daletovar
Copy link
Collaborator

@eric-czech, thanks for clarifying all of that for me. I'm still +1 on your alternative idea.

@tomwhite
Copy link
Collaborator

I wonder if we can close this given that we are turning off coverage for numba functions (see #380 and linked issue)? I think reviewers just need to be careful to check that all new numba functions have unit tests.

@tomwhite
Copy link
Collaborator

tomwhite commented Jan 4, 2023

Fixed in #964

@tomwhite tomwhite closed this as completed Jan 4, 2023
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 process + tools
Projects
None yet
Development

No branches or pull requests

4 participants