Skip to content

Commit 4d51bee

Browse files
committed
fix(launcher): lazy-import nemo_evaluator in loading.py to fix docs env
The top-level `from nemo_evaluator.core.input import ...` in loading.py triggered the full nemo_evaluator import chain (including pydantic) at module import time. In docs environments where nemo_evaluator source is on PYTHONPATH but pydantic is not installed, this caused a ModuleNotFoundError for pydantic that was silently swallowed by the try/except in __init__.py, making extract_framework_yml and parse_framework_to_irs unavailable. Move the import to the only call site (parse_framework_to_irs) so loading.py can be imported without the full nemo_evaluator dep tree. Signed-off-by: Wojciech Prazuch <wprazuch@nvidia.com>
1 parent 33debd3 commit 4d51bee

File tree

2 files changed

+5
-10
lines changed
  • packages/nemo-evaluator-launcher

2 files changed

+5
-10
lines changed

packages/nemo-evaluator-launcher/src/nemo_evaluator_launcher/common/container_metadata/loading.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
from typing import Optional
2626

2727
import yaml
28-
from nemo_evaluator.core.input import get_framework_evaluations
2928

3029
from nemo_evaluator_launcher.common.container_metadata.intermediate_repr import (
3130
HarnessIntermediateRepresentation,
@@ -943,6 +942,8 @@ def parse_framework_to_irs(
943942
temp_file_path = temp_file.name
944943

945944
try:
945+
from nemo_evaluator.core.input import get_framework_evaluations
946+
946947
include_internal = (
947948
importlib.util.find_spec("nemo_evaluator_internal") is not None
948949
or importlib.util.find_spec("nemo_evaluator_launcher_internal")

packages/nemo-evaluator-launcher/tests/unit_tests/test_loading.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,7 @@ def test_create_task_irs(self, mock_extract):
208208
class TestParseFrameworkToIrs:
209209
"""Test parsing framework.yml to IRs."""
210210

211-
@patch(
212-
"nemo_evaluator_launcher.common.container_metadata.loading.get_framework_evaluations"
213-
)
211+
@patch("nemo_evaluator.core.input.get_framework_evaluations")
214212
def test_parse_framework_to_irs_success(self, mock_get_evaluations):
215213
"""Test successful parsing of framework.yml."""
216214
framework_content = """
@@ -237,9 +235,7 @@ def test_parse_framework_to_irs_success(self, mock_get_evaluations):
237235
assert harness_ir.name == "test-harness" # Original name preserved
238236
assert len(task_irs) > 0
239237

240-
@patch(
241-
"nemo_evaluator_launcher.common.container_metadata.loading.get_framework_evaluations"
242-
)
238+
@patch("nemo_evaluator.core.input.get_framework_evaluations")
243239
def test_parse_framework_to_irs_preserves_case(self, mock_get_evaluations):
244240
"""Test that framework name case is preserved."""
245241
framework_content = """
@@ -274,9 +270,7 @@ def test_parse_framework_to_irs_preserves_name(self):
274270
"""
275271
# This should not raise an error - no validation in loading.py
276272
# We'll mock get_framework_evaluations to avoid actual parsing
277-
with patch(
278-
"nemo_evaluator_launcher.common.container_metadata.loading.get_framework_evaluations"
279-
) as mock_get:
273+
with patch("nemo_evaluator.core.input.get_framework_evaluations") as mock_get:
280274
mock_get.return_value = ("test-harness-123", {}, {})
281275
harness_ir, task_irs = parse_framework_to_irs(
282276
framework_content, "test:latest", None

0 commit comments

Comments
 (0)