Unverified Commit 49949f32 authored by Sayak Paul's avatar Sayak Paul Committed by GitHub
Browse files

[Tests] add test for checking soft dependencies. (#3847)

* add test for checking soft dependencies.

* address patrick's comments.

* dependency tests should not run twice.

* debugging.

* up.
parent c7469ebe
name: Run dependency tests
on:
pull_request:
branches:
- main
push:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
check_dependencies:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.7"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .
pip install pytest
- name: Check for soft dependencies
run: |
pytest tests/others/test_dependencies.py
\ No newline at end of file
...@@ -81,7 +81,7 @@ jobs: ...@@ -81,7 +81,7 @@ jobs:
if: ${{ matrix.config.framework == 'pytorch_models' }} if: ${{ matrix.config.framework == 'pytorch_models' }}
run: | run: |
python -m pytest -n 2 --max-worker-restart=0 --dist=loadfile \ python -m pytest -n 2 --max-worker-restart=0 --dist=loadfile \
-s -v -k "not Flax and not Onnx" \ -s -v -k "not Flax and not Onnx and not Dependency" \
--make-reports=tests_${{ matrix.config.report }} \ --make-reports=tests_${{ matrix.config.report }} \
tests/models tests/schedulers tests/others tests/models tests/schedulers tests/others
......
...@@ -94,6 +94,8 @@ _deps = [ ...@@ -94,6 +94,8 @@ _deps = [
"jaxlib>=0.1.65", "jaxlib>=0.1.65",
"Jinja2", "Jinja2",
"k-diffusion>=0.0.12", "k-diffusion>=0.0.12",
"torchsde",
"note_seq",
"librosa", "librosa",
"numpy", "numpy",
"omegaconf", "omegaconf",
...@@ -106,6 +108,7 @@ _deps = [ ...@@ -106,6 +108,7 @@ _deps = [
"safetensors", "safetensors",
"sentencepiece>=0.1.91,!=0.1.92", "sentencepiece>=0.1.91,!=0.1.92",
"scipy", "scipy",
"onnx",
"regex!=2019.12.17", "regex!=2019.12.17",
"requests", "requests",
"tensorboard", "tensorboard",
......
...@@ -18,6 +18,8 @@ deps = { ...@@ -18,6 +18,8 @@ deps = {
"jaxlib": "jaxlib>=0.1.65", "jaxlib": "jaxlib>=0.1.65",
"Jinja2": "Jinja2", "Jinja2": "Jinja2",
"k-diffusion": "k-diffusion>=0.0.12", "k-diffusion": "k-diffusion>=0.0.12",
"torchsde": "torchsde",
"note_seq": "note_seq",
"librosa": "librosa", "librosa": "librosa",
"numpy": "numpy", "numpy": "numpy",
"omegaconf": "omegaconf", "omegaconf": "omegaconf",
...@@ -30,6 +32,7 @@ deps = { ...@@ -30,6 +32,7 @@ deps = {
"safetensors": "safetensors", "safetensors": "safetensors",
"sentencepiece": "sentencepiece>=0.1.91,!=0.1.92", "sentencepiece": "sentencepiece>=0.1.91,!=0.1.92",
"scipy": "scipy", "scipy": "scipy",
"onnx": "onnx",
"regex": "regex!=2019.12.17", "regex": "regex!=2019.12.17",
"requests": "requests", "requests": "requests",
"tensorboard": "tensorboard", "tensorboard": "tensorboard",
......
# 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 inspect
import unittest
class DependencyTester(unittest.TestCase):
def test_diffusers_import(self):
try:
import diffusers # noqa: F401
except ImportError:
assert False
def test_backend_registration(self):
import diffusers
from diffusers.dependency_versions_table import deps
all_classes = inspect.getmembers(diffusers, inspect.isclass)
for cls_name, cls_module in all_classes:
if "dummy_" in cls_module.__module__:
for backend in cls_module._backends:
if backend == "k_diffusion":
backend = "k-diffusion"
assert backend in deps, f"{backend} is not in the deps table!"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment