Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 28, 2023
Merged

Conversation

sayakpaul
Copy link
Member

Fixes: #2356

Let me know if there's a better way to define the soft dependencies.

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Jun 22, 2023

The documentation is not available anymore as the PR was closed or merged.

"Jinja2",
]

def test_soft_dependencies_no_installed(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test wouldn't catch if a user accidentally introduces a new dependency. Let's try to make two tests here:

1.) Simply check that from diffusers import * doesn't throw an error -> this should work and not throw an error. This is an important test still because it means we catch if incorrect "import ..." are added
So let's just test:

import diffusers

here

2.) Next, we import all classes of diffusers and make sure that in case those are dummy classes that they required backend is part of the dependencies. You can do the following here:

import diffusers
from diffusers.dependency_versions_table import deps
import inspect

all_classes =  inspect.getmembers(diffusers, inspect.isclass)

for cls in all_classes:
    # if dummy module check that all backends are in deps
    if "dummy_" in cls.__module__:
        for backend in cls._backends:
            assert backend in deps, f"{backend} is not in the deps table!"

Copy link
Contributor

@patrickvonplaten patrickvonplaten left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The github workflow yaml looks good, we should change the test however. Can you try to add two tests that looks as follows:
https://github.com/huggingface/diffusers/pull/3847/files#r1238267507
maybe?

@sayakpaul
Copy link
Member Author

sayakpaul commented Jun 22, 2023

@patrickvonplaten thanks!

Currently, one test is failing for MidiProcessor, complaining note_seq is not there in there in the dependency table. I can add it, however, wanted to check first.

Edit: Strange. The failing test here didn't fail on my machine locally.

@patrickvonplaten
Copy link
Contributor

Looks great! Let's merge it :-) Thanks for iterating

Copy link
Contributor

@patrickvonplaten patrickvonplaten left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very cool!

@sayakpaul sayakpaul merged commit 49949f3 into main Jun 28, 2023
@sayakpaul sayakpaul deleted the tests/check_deps branch June 28, 2023 16:35
yoonseokjin pushed a commit to yoonseokjin/diffusers that referenced this pull request Dec 25, 2023
* add test for checking soft dependencies.

* address patrick's comments.

* dependency tests should not run twice.

* debugging.

* up.
AmericanPresidentJimmyCarter pushed a commit to AmericanPresidentJimmyCarter/diffusers that referenced this pull request Apr 26, 2024
* add test for checking soft dependencies.

* address patrick's comments.

* dependency tests should not run twice.

* debugging.

* up.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Test] Add tests that no imports have been added that are not a hard dependency
3 participants