mirror of
https://github.com/huggingface/trl.git
synced 2025-10-21 02:53:59 +08:00
* use transformers' availability functions * require from transformers * rm file * fix no peft * fix import * don't alter _peft_available * fix require_diffusers * style * transformers>=4.40 and add back `is_liger_kernel_available`
40 lines
1.4 KiB
Python
40 lines
1.4 KiB
Python
# Copyright 2023 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 unittest
|
|
|
|
from transformers import is_wandb_available
|
|
|
|
from trl import is_diffusers_available, is_liger_kernel_available
|
|
|
|
|
|
def require_diffusers(test_case):
|
|
"""
|
|
Decorator marking a test that requires diffusers. Skips the test if diffusers is not available.
|
|
"""
|
|
return unittest.skipUnless(is_diffusers_available(), "test requires diffusers")(test_case)
|
|
|
|
|
|
def require_no_wandb(test_case):
|
|
"""
|
|
Decorator marking a test that requires no wandb. Skips the test if wandb is available.
|
|
"""
|
|
return unittest.skipUnless(not is_wandb_available(), "test requires no wandb")(test_case)
|
|
|
|
|
|
def require_liger_kernel(test_case):
|
|
"""
|
|
Decorator marking a test that requires liger_kernel. Skips the test if liger_kernel is not available.
|
|
"""
|
|
return unittest.skipUnless(is_liger_kernel_available(), "test requires liger_kernel")(test_case)
|