You are viewing a plain text version of this content. The canonical link for it is here.
Posted to discuss-archive@tvm.apache.org by "tlopex (via GitHub)" <gi...@apache.org> on 2026/06/10 21:27:12 UTC
[PR] [Tests][Hexagon] Lazily import pytest plugin dependencies [tvm]
tlopex opened a new pull request, #19726:
URL: https://github.com/apache/tvm/pull/19726
This pr makes the Hexagon pytest plugin avoid importing Hexagon build/session machinery at module import time.
This keeps pytest collection lightweight and avoids collection-time failures from Hexagon-specific runtime/session imports when running source-tree tests against a TVM wheel or an environment that does not need to execute Hexagon tests.
--
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: discuss-archive-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For additional commands, e-mail: discuss-archive-help@tvm.apache.org
Re: [PR] [Tests][Hexagon] Lazily import pytest plugin dependencies [tvm]
Posted by "tqchen (via GitHub)" <gi...@apache.org>.
tqchen merged PR #19726:
URL: https://github.com/apache/tvm/pull/19726
--
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: discuss-archive-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For additional commands, e-mail: discuss-archive-help@tvm.apache.org
Re: [PR] [Tests][Hexagon] Lazily import pytest plugin dependencies [tvm]
Posted by "gemini-code-assist[bot] (via GitHub)" <gi...@apache.org>.
gemini-code-assist[bot] commented on code in PR #19726:
URL: https://github.com/apache/tvm/pull/19726#discussion_r3391625393
##########
python/tvm/contrib/hexagon/pytest_plugin.py:
##########
@@ -19,24 +19,25 @@
"""Hexagon testing fixtures used to deduce testing argument
values from testing parameters"""
+from __future__ import annotations
+
import os
import random
+import socket
import pytest
import tvm
import tvm.rpc
import tvm.testing
Review Comment:

Since `HexagonLauncherRPC` and `Session` are no longer imported at the module level, using them as type annotations will cause static analysis/linter errors (e.g., `F821 undefined name`) and type-checking failures. Since `from __future__ import annotations` is used, we can import these types under a `TYPE_CHECKING` block to satisfy type checkers and linters without importing them at runtime.
```suggestion
from __future__ import annotations
import os
import random
from typing import TYPE_CHECKING
import pytest
import tvm
import tvm.rpc
import tvm.testing
if TYPE_CHECKING:
from tvm.contrib.hexagon.build import HexagonLauncherRPC
from tvm.contrib.hexagon.session import Session
```
##########
python/tvm/contrib/hexagon/pytest_plugin.py:
##########
@@ -106,13 +107,18 @@ def get_free_port() -> int:
if port > LISTEN_PORT_MAX:
port = LISTEN_PORT_MIN
- while tvm.contrib.hexagon.build._is_port_in_use(port):
+ while _is_port_in_use(port):
port = port + 1 if port < LISTEN_PORT_MAX else LISTEN_PORT_MIN
PREVIOUS_PORT = port
return port
+def _is_port_in_use(port: int) -> bool:
+ with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
+ return sock.connect_ex(("localhost", port)) == 0
Review Comment:

Instead of duplicating the `_is_port_in_use` helper function from `tvm.contrib.hexagon.build`, we can lazily import it inside `get_free_port()`. This avoids code duplication and keeps the module-level imports clean.
```suggestion
from tvm.contrib.hexagon.build import _is_port_in_use
while _is_port_in_use(port):
port = port + 1 if port < LISTEN_PORT_MAX else LISTEN_PORT_MIN
PREVIOUS_PORT = port
return port
```
--
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: discuss-archive-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For additional commands, e-mail: discuss-archive-help@tvm.apache.org