From 04ef686d7c6e86a04bf0a568f5b5ef78b698f84e Mon Sep 17 00:00:00 2001 From: Andrew Pullin Date: Thu, 5 Feb 2026 08:21:18 -0800 Subject: [PATCH] Fix test_nss.py import error when ng_model_gym is not installed (#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) Reviewed By: mergennachin Differential Revision: D92206283 --- backends/arm/test/models/test_nss.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/backends/arm/test/models/test_nss.py b/backends/arm/test/models/test_nss.py index e5e381cfe66..3dbfaf7f874 100644 --- a/backends/arm/test/models/test_nss.py +++ b/backends/arm/test/models/test_nss.py @@ -7,7 +7,6 @@ import pytest import torch - from executorch.backends.arm.test import common from executorch.backends.arm.test.tester.test_pipeline import ( EthosU55PipelineINT, @@ -16,9 +15,11 @@ TosaPipelineINT, VgfPipeline, ) - from huggingface_hub import hf_hub_download +# Skip entire module if ng_model_gym is not installed (requires pydantic) +pytest.importorskip("ng_model_gym") + from ng_model_gym.usecases.nss.model.model_blocks import ( # type: ignore[import-not-found,import-untyped] AutoEncoderV1, )