Skip to content

Commit 9307625

Browse files
committed
[TRTLLM-17265][refactor] State why the facade keeps the VisualGen rows as strings and bind the test's culprit list unconditionally
The table comment in tensorrt_llm/serve/openai_protocol/__init__.py said that a TYPE_CHECKING import of the VisualGen models would load their package at run time, which a TYPE_CHECKING block never does. The real reason is the static import-isolation check that lets CI run only the VisualGen tests for VisualGen-only changes: it forbids an import edge from this package to the VisualGen package even under TYPE_CHECKING, so the facade names that module only as a string. In tests/unittest/serve/openai_protocol/test_openai_protocol_facade.py the list of submodules that import the serving extensions was bound only on the failing path and read in the assertion message; it is now bound before the branch, so an unconditional message can never raise UnboundLocalError. Signed-off-by: JunyiXu-nv <219237550+JunyiXu-nv@users.noreply.github.com>
1 parent 04d12a7 commit 9307625

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

‎tensorrt_llm/serve/openai_protocol/__init__.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,10 @@
215215
"to_disaggregated_params": "tensorrt_llm.serve.openai_protocol.disagg",
216216
"to_llm_conversation_params": "tensorrt_llm.serve.openai_protocol.disagg",
217217
"to_llm_disaggregated_params": "tensorrt_llm.serve.openai_protocol.disagg",
218-
# Defined in the VisualGen serving package. Named here only as strings: an import,
219-
# even under TYPE_CHECKING, would load that package into every LLM process.
218+
# Defined in the VisualGen serving package. Named here only as strings: the static
219+
# import-isolation check that lets CI run only the VisualGen tests for VisualGen-only
220+
# changes forbids an import edge from this package to the VisualGen package, even under
221+
# TYPE_CHECKING, so these names are not in the TYPE_CHECKING block above.
220222
"ImageEditRequest": "tensorrt_llm.serve.api.visual_gen.protocol",
221223
"ImageGenerationRequest": "tensorrt_llm.serve.api.visual_gen.protocol",
222224
"ImageGenerationResponse": "tensorrt_llm.serve.api.visual_gen.protocol",

‎tests/unittest/serve/openai_protocol/test_openai_protocol_facade.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,7 @@ def test_chat_models_do_not_load_extensions(package_dir):
429429
}}))
430430
"""
431431
)
432+
culprits: list = []
432433
if out["extensions"]:
433434
importers = sorted(
434435
name

0 commit comments

Comments
 (0)