Skip to content

Commit ced40b6

Browse files
Andrew Pullinfacebook-github-bot
authored andcommitted
Fix test_nss.py import error when ng_model_gym is not installed (pytorch#17184)
Summary: Fixes test collection failure in CI when `ng_model_gym` is not installed. The `test_nss.py` file imports `ng_model_gym` at module level, which requires `pydantic`. In CI environments where these dependencies are not installed, pytest fails during test collection with `ModuleNotFoundError: No module named 'pydantic'`. This fix adds `pytest.importorskip("ng_model_gym")` before the import, which gracefully skips the entire test module when the dependency is unavailable instead of failing test collection. --- > Generated by [Confucius Code Assist (CCA)](https://www.internalfb.com/wiki/Confucius/Analect/Shared_Analects/Confucius_Code_Assist_(CCA)/) [Confucius Session](https://www.internalfb.com/confucius?host=44014.od.fbinfra.net&port=8086&tab=Chat&session_id=3841a0f6-014b-11f1-919a-6b37349122a8&entry_name=Code+Assist), [Trace](https://www.internalfb.com/confucius?session_id=3841a0f6-014b-11f1-919a-6b37349122a8&tab=Trace) Differential Revision: D92206283
1 parent c0cef6c commit ced40b6

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

backends/arm/test/models/test_nss.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
import pytest
99
import torch
10-
1110
from executorch.backends.arm.test import common
1211
from executorch.backends.arm.test.tester.test_pipeline import (
1312
EthosU55PipelineINT,
@@ -16,9 +15,11 @@
1615
TosaPipelineINT,
1716
VgfPipeline,
1817
)
19-
2018
from huggingface_hub import hf_hub_download
2119

20+
# Skip entire module if ng_model_gym is not installed (requires pydantic)
21+
pytest.importorskip("ng_model_gym")
22+
2223
from ng_model_gym.usecases.nss.model.model_blocks import ( # type: ignore[import-not-found,import-untyped]
2324
AutoEncoderV1,
2425
)

0 commit comments

Comments
 (0)