-
Notifications
You must be signed in to change notification settings - Fork 6.1k
[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
Conversation
The documentation is not available anymore as the PR was closed or merged. |
tests/others/test_dependencies.py
Outdated
"Jinja2", | ||
] | ||
|
||
def test_soft_dependencies_no_installed(self): |
There was a problem hiding this comment.
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!"
There was a problem hiding this 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?
@patrickvonplaten thanks! Currently, one test is failing for Edit: Strange. The failing test here didn't fail on my machine locally. |
Looks great! Let's merge it :-) Thanks for iterating |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very cool!
* add test for checking soft dependencies. * address patrick's comments. * dependency tests should not run twice. * debugging. * up.
* add test for checking soft dependencies. * address patrick's comments. * dependency tests should not run twice. * debugging. * up.
Fixes: #2356
Let me know if there's a better way to define the soft dependencies.