|
| 1 | +# Copyright 2023 The HuggingFace Team. All rights reserved. |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +import inspect |
| 16 | +import unittest |
| 17 | + |
| 18 | + |
| 19 | +class DependencyTester(unittest.TestCase): |
| 20 | + def test_diffusers_import(self): |
| 21 | + try: |
| 22 | + import diffusers # noqa: F401 |
| 23 | + except ImportError: |
| 24 | + assert False |
| 25 | + |
| 26 | + def test_backend_registration(self): |
| 27 | + import diffusers |
| 28 | + from diffusers.dependency_versions_table import deps |
| 29 | + |
| 30 | + all_classes = inspect.getmembers(diffusers, inspect.isclass) |
| 31 | + |
| 32 | + for cls_name, cls_module in all_classes: |
| 33 | + if "dummy_" in cls_module.__module__: |
| 34 | + for backend in cls_module._backends: |
| 35 | + if backend == "k_diffusion": |
| 36 | + backend = "k-diffusion" |
| 37 | + assert backend in deps, f"{backend} is not in the deps table!" |
0 commit comments