Some checks failed
Self-hosted runner (nightly-past-ci-caller) / Get number (push) Has been cancelled
Self-hosted runner (nightly-past-ci-caller) / TensorFlow 2.11 (push) Has been cancelled
Self-hosted runner (nightly-past-ci-caller) / TensorFlow 2.10 (push) Has been cancelled
Self-hosted runner (nightly-past-ci-caller) / TensorFlow 2.9 (push) Has been cancelled
Self-hosted runner (nightly-past-ci-caller) / TensorFlow 2.8 (push) Has been cancelled
Self-hosted runner (nightly-past-ci-caller) / TensorFlow 2.7 (push) Has been cancelled
Self-hosted runner (nightly-past-ci-caller) / TensorFlow 2.6 (push) Has been cancelled
Self-hosted runner (nightly-past-ci-caller) / TensorFlow 2.5 (push) Has been cancelled
Self-hosted runner (benchmark) / Benchmark (aws-g5-4xlarge-cache) (push) Has been cancelled
Build documentation / build (push) Has been cancelled
Build documentation / build_other_lang (push) Has been cancelled
CodeQL Security Analysis / CodeQL Analysis (push) Has been cancelled
New model PR merged notification / Notify new model (push) Has been cancelled
PR CI / pr-ci (push) Has been cancelled
Slow tests on important models (on Push - A10) / Get all modified files (push) Has been cancelled
Secret Leaks / trufflehog (push) Has been cancelled
Update Transformers metadata / build_and_package (push) Has been cancelled
Slow tests on important models (on Push - A10) / Model CI (push) Has been cancelled
Check Tiny Models / Check tiny models (push) Has been cancelled
Self-hosted runner (Intel Gaudi3 scheduled CI caller) / Model CI (push) Has been cancelled
Self-hosted runner (Intel Gaudi3 scheduled CI caller) / Pipeline CI (push) Has been cancelled
Self-hosted runner (Intel Gaudi3 scheduled CI caller) / Example CI (push) Has been cancelled
Self-hosted runner (Intel Gaudi3 scheduled CI caller) / DeepSpeed CI (push) Has been cancelled
Self-hosted runner (Intel Gaudi3 scheduled CI caller) / Trainer/FSDP CI (push) Has been cancelled
Nvidia CI - Flash Attn / Setup (push) Has been cancelled
Nvidia CI - Flash Attn / Model CI (push) Has been cancelled
Nvidia CI / Setup (push) Has been cancelled
Nvidia CI / Model CI (push) Has been cancelled
Nvidia CI / Torch pipeline CI (push) Has been cancelled
Nvidia CI / Example CI (push) Has been cancelled
Nvidia CI / Trainer/FSDP CI (push) Has been cancelled
Nvidia CI / DeepSpeed CI (push) Has been cancelled
Nvidia CI / Quantization CI (push) Has been cancelled
Nvidia CI / Kernels CI (push) Has been cancelled
Doctests / Setup (push) Has been cancelled
Doctests / Call doctest jobs (push) Has been cancelled
Doctests / Send results to webhook (push) Has been cancelled
Extras Smoke Test / Get supported Python versions (push) Has been cancelled
Extras Smoke Test / Test extras on Python ${{ matrix.python-version }} (push) Has been cancelled
Extras Smoke Test / Check Slack token availability (push) Has been cancelled
Extras Smoke Test / Notify failures to Slack (push) Has been cancelled
Self-hosted runner (AMD scheduled CI caller) / Trigger Scheduled AMD CI (push) Has been cancelled
Stale Bot / Close Stale Issues (push) Has been cancelled
75 lines
3.1 KiB
Python
75 lines
3.1 KiB
Python
# Copyright 2026 The HuggingFace Team. All rights reserved.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
import os
|
|
import sys
|
|
import unittest
|
|
from unittest.mock import patch
|
|
|
|
|
|
git_repo_path = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
|
|
utils_path = os.path.join(git_repo_path, "utils")
|
|
if utils_path not in sys.path:
|
|
sys.path.append(utils_path)
|
|
|
|
import check_modular_conversion # noqa: E402
|
|
|
|
|
|
class ConverterChangedInDiffTest(unittest.TestCase):
|
|
"""Regression guard for PR #45492: changes to the converter alone must force a full check."""
|
|
|
|
def _patch_modified(self, files):
|
|
return patch.object(check_modular_conversion, "_get_modified_files", return_value=files)
|
|
|
|
def test_returns_true_when_modular_model_converter_changed(self):
|
|
with self._patch_modified(
|
|
[
|
|
"utils/modular_model_converter.py",
|
|
"src/transformers/models/llava_onevision/modular_llava_onevision.py",
|
|
]
|
|
):
|
|
self.assertTrue(check_modular_conversion.converter_changed_in_diff())
|
|
|
|
def test_returns_true_when_create_dependency_mapping_changed(self):
|
|
with self._patch_modified(["utils/create_dependency_mapping.py"]):
|
|
self.assertTrue(check_modular_conversion.converter_changed_in_diff())
|
|
|
|
def test_returns_false_for_model_only_diff(self):
|
|
with self._patch_modified(
|
|
[
|
|
"src/transformers/models/llama/modular_llama.py",
|
|
"src/transformers/models/llama/modeling_llama.py",
|
|
]
|
|
):
|
|
self.assertFalse(check_modular_conversion.converter_changed_in_diff())
|
|
|
|
def test_returns_false_for_unrelated_utils_change(self):
|
|
with self._patch_modified(["utils/check_modular_conversion.py", "utils/check_copies.py"]):
|
|
self.assertFalse(check_modular_conversion.converter_changed_in_diff())
|
|
|
|
def test_converter_files_set_includes_expected_entries(self):
|
|
# Keep the allow-list grounded: if either file is renamed/removed, this test fails loudly
|
|
# so the detection logic is updated alongside the rename.
|
|
self.assertIn("utils/modular_model_converter.py", check_modular_conversion.CONVERTER_FILES)
|
|
self.assertIn("utils/create_dependency_mapping.py", check_modular_conversion.CONVERTER_FILES)
|
|
for rel_path in check_modular_conversion.CONVERTER_FILES:
|
|
self.assertTrue(
|
|
os.path.exists(os.path.join(git_repo_path, rel_path)),
|
|
f"{rel_path} listed in CONVERTER_FILES but does not exist on disk",
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|