From d7a091ba4ffb8675a9a6c6773fdfeb06d0ee1d42 Mon Sep 17 00:00:00 2001 From: hj <3148395614@qq.com> Date: Sun, 26 Jan 2025 10:58:11 +0800 Subject: [PATCH 1/2] hj --- .gitignore | 4 ++-- setup.py | 14 +------------- tests/engine/test_trainer.py | 15 +-------------- tools/auto_gen.py | 4 ++-- 4 files changed, 6 insertions(+), 31 deletions(-) diff --git a/.gitignore b/.gitignore index b9f7b62bc..499d72bac 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,11 @@ -# Byte-compiled / optimized / DLL files + __pycache__/ *.py[cod] *$py.class # C extensions *.so -# Distribution / packaging + .Python build/ develop-eggs/ diff --git a/setup.py b/setup.py index 29cf213c0..c0bae295a 100644 --- a/setup.py +++ b/setup.py @@ -1,16 +1,4 @@ -# Copyright 2021 Huawei Technologies Co., Ltd -# -# 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. + """ setup packpage """ diff --git a/tests/engine/test_trainer.py b/tests/engine/test_trainer.py index fcfd158b2..b16c811ba 100644 --- a/tests/engine/test_trainer.py +++ b/tests/engine/test_trainer.py @@ -1,17 +1,4 @@ -# coding=utf-8 -# Copyright 2018 the HuggingFace Inc. team. -# -# 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 dataclasses import gc diff --git a/tools/auto_gen.py b/tools/auto_gen.py index 80ba77a4f..b1187bde9 100644 --- a/tools/auto_gen.py +++ b/tools/auto_gen.py @@ -38,9 +38,9 @@ def generate_global_variables(file_path): new_lines = lines[:] offset = 0 for func_name, line_no in sorted(function_positions.items(), key=lambda x: x[1]): - # Test if the function exists in mindspore.mint + if hasattr(mindspore.mint, func_name): - # Insert global variable if not already present + variable_declaration = f"has_{func_name} = hasattr(mindspore.mint, '{func_name}')" if variable_declaration not in existing_globals: new_lines.insert(line_no + offset, variable_declaration + "\n") From c9eaa03d16a48f3af23690eb94d2312d8567797d Mon Sep 17 00:00:00 2001 From: hj <3148395614@qq.com> Date: Sun, 26 Jan 2025 11:01:08 +0800 Subject: [PATCH 2/2] hj1 --- tests/engine/test_trainer.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/engine/test_trainer.py b/tests/engine/test_trainer.py index b16c811ba..593df9356 100644 --- a/tests/engine/test_trainer.py +++ b/tests/engine/test_trainer.py @@ -36,9 +36,7 @@ from mindnlp.utils import is_mindspore_available, logging from mindnlp.core.serialization import safe_load_file, safe_save_file, load_checkpoint from mindnlp.utils.testing_utils import ( - # ENDPOINT_STAGING, - # TOKEN, - # USER, + CaptureLogger, LoggingLevel, TestCasePlus,