From 8489928769f239667ee746ebfb43cee79c0c91e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B5=AE=E6=A2=A6?= <46097299+frozenleaves@users.noreply.github.com> Date: Mon, 13 Jul 2026 17:30:36 +0800 Subject: [PATCH] [fix]update license check, update transformers (#10632) --- pyproject.toml | 2 +- src/llamafactory/extras/misc.py | 4 +--- tests/check_license.py | 12 ++++++++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 4105361c9..2c40602dc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,7 +40,7 @@ dependencies = [ "torch>=2.4.0", "torchvision>=0.19.0", "torchaudio>=2.4.0", - "transformers>=4.55.0,<=5.7.0,!=4.57.0,!=5.6.0", + "transformers>=4.55.0,<=5.8.0,!=4.57.0,!=5.6.0", "datasets>=2.16.0,<=4.0.0", "accelerate>=1.3.0,<=1.11.0", "peft>=0.18.0,<=0.18.1", diff --git a/src/llamafactory/extras/misc.py b/src/llamafactory/extras/misc.py index 77137afaf..f95ab9f49 100644 --- a/src/llamafactory/extras/misc.py +++ b/src/llamafactory/extras/misc.py @@ -94,9 +94,7 @@ def check_version(requirement: str, mandatory: bool = False) -> None: def check_dependencies() -> None: r"""Check the version of the required packages.""" - check_version("transformers>=4.55.0,<=5.7.0") - check_version("transformers!=4.57.0") - check_version("transformers!=5.6.0") + check_version("transformers>=4.55.0,<=5.8.0,!=4.57.0,!=5.6.0") check_version("datasets>=2.16.0,<=4.0.0") check_version("accelerate>=1.3.0,<=1.15.0") check_version("peft>=0.18.0,<=0.20.0") diff --git a/tests/check_license.py b/tests/check_license.py index 1512347d9..3680c939a 100644 --- a/tests/check_license.py +++ b/tests/check_license.py @@ -16,7 +16,8 @@ import sys from pathlib import Path -KEYWORDS = ("Copyright", "2025", "LlamaFactory") +KEYWORDS = ("Copyright", "LlamaFactory") +VALID_YEARS = tuple(str(year) for year in range(2023, 2027)) def main(): @@ -30,8 +31,15 @@ def main(): if not file_content[0]: continue + first_line = file_content[0] print(f"Check license: {path}") - assert all(keyword in file_content[0] for keyword in KEYWORDS), f"File {path} does not contain license." + has_keywords = all(keyword in first_line for keyword in KEYWORDS) + has_valid_year = any(year in first_line for year in VALID_YEARS) + + assert has_keywords and has_valid_year, ( + f"File {path} does not contain a valid license. " + f"Expected 'Copyright', 'LlamaFactory' and a year between 2023-2026 in the first line." + ) if __name__ == "__main__":