Skip to content

Accommodate custom components in maybe_raise_or_warn#13458

Open
neo wants to merge 1 commit intohuggingface:mainfrom
neo:assert-custom-component-module
Open

Accommodate custom components in maybe_raise_or_warn#13458
neo wants to merge 1 commit intohuggingface:mainfrom
neo:assert-custom-component-module

Conversation

@neo
Copy link
Copy Markdown

@neo neo commented Apr 13, 2026

What does this PR do?

by using get_class_obj_and_candidates, this now can also check against custom components being passed in and not error out as not found.

side note

I also noticed the second argument library from maybe_raise_or_warn isn't being used, and we might want to remove it if we don't plan to use it later?

Before submitting

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

by using `get_class_obj_and_candidates`
@github-actions github-actions bot added pipelines size/S PR with diff < 50 LOC labels Apr 13, 2026
@sayakpaul
Copy link
Copy Markdown
Member

What is the use case for this?

@neo
Copy link
Copy Markdown
Author

neo commented Apr 13, 2026

What is the use case for this?

so not only instantiated diffusers components can be passed into a pipeline:

pipe2 = DiffusionPipeline.from_pretrained(..., vae=pipe1.vae)

but also for custom components in the same way:

custom_pipe2 = DiffusionPipeline.from_pretrained(..., custom_component=existing_instance)

@sayakpaul
Copy link
Copy Markdown
Member

What error do we get without this change?

):
"""Simple helper method to raise or warn in case incorrect module has been passed"""
if not is_pipeline_module:
library = importlib.import_module(library_name)
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

What error do we get without this change?

It would raise here because it's not real library but custom component/module

and as you can see from def get_class_obj_and_candidates, it's the same logic but with added condition to get_class_from_dynamic_module — I think it should've used this util from the beginning, maybe the util was added after this piece of code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pipelines size/S PR with diff < 50 LOC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants