cconvey opened a new issue, #11752:
URL: https://github.com/apache/tvm/issues/11752

   ### Expected behavior
   
   TVM unit-test scripts can be directly invoked in a simple manner.  E.g.:
   
   `python3 
"${TVM_HOME}/tests/python/contrib/test_hexagon/test_2d_physical_buffers.py"`
   
   ### Actual behavior
   
   Some scripts fail when invoked in this manner.  For example:
   ```
   $ python3.8 tests/python/contrib/test_hexagon/test_2d_physical_buffers.py 
   Traceback (most recent call last):
     File "tests/python/contrib/test_hexagon/test_2d_physical_buffers.py", line 
33, in <module>
       from .infrastructure import allocate_hexagon_array
   ImportError: attempted relative import with no known parent package
   ```
   
   At least for this particular script, there are two ways to successfully run 
it:
   - What TVM CI does:
       ``` bash
       python3 -m pytest 
"${TVM_HOME}/tests/python/contrib/test_hexagon/test_2d_physical_buffers.py"
      ```
   
   - Alternatively:
      ``` bash
      PYTHONPATH="${TVM_HOME}/tests/python:${PYTHONPATH}" python3 -m 
contrib.test_hexagon.test_2d_physical_buffers
      ```
   
   I think this arises when a test script has _both_ of these features:
   - It uses relative-import statements, typically to import other Python code 
from the same directory.  E.g., `from . import benchmark_utils`
   - It adheres to the (new?) TVM convention in which unit-test scripts end 
with the following code:
      ``` python
      if __name__ == "__main__":
       tvm.testing.main()
      ```
      rather than the more common:
      ``` python
      if __name__ == "__main__":
       sys.exit(pytest.main(sys.argv))
      ```
   
   ### Environment
   
   Ubuntu 18.04, Python 3.8, TVM commit 
d0650bad66d0ff89a01347537021bc442a98c223 .
   
   ### Steps to reproduce
   
   See above.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to