Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/diffusers/modular_pipelines/components_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,9 @@ def add(self, name: str, component: Any, collection: str | None = None):
if comp == component:
comp_name = self._id_to_name(comp_id)
if comp_name == name:
logger.warning(f"ComponentsManager: component '{name}' already exists as '{comp_id}'")
# The same object registered again under its name: a second pipeline sharing it, or a collection
# it joins below. Nothing is duplicated, so this is not worth a warning.
logger.debug(f"ComponentsManager: component '{name}' is already registered as '{comp_id}'")
component_id = comp_id
is_new_component = False
break
Expand Down Expand Up @@ -454,7 +456,7 @@ def add(self, name: str, component: Any, collection: str | None = None):
logger.info(
f"ComponentsManager: added component '{name}' in collection '{collection}': {component_id}"
)
else:
elif is_new_component:
logger.info(f"ComponentsManager: added component '{name}' as '{component_id}'")

if self._auto_offload_enabled and is_new_component:
Expand Down
9 changes: 9 additions & 0 deletions tests/modular_pipelines/test_components_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,15 @@ def test_add_same_component_twice_reuses_id(self):
assert first_id == second_id
assert len(cm.components) == 1

def test_add_same_component_to_second_collection(self):
cm = ComponentsManager()
model = self.get_dummy_model()
first_id = cm.add("unet", model, collection="first")
second_id = cm.add("unet", model, collection="second")
assert first_id == second_id
assert len(cm.components) == 1
assert cm.collections["first"] == cm.collections["second"] == {first_id}

def test_remove(self):
cm = ComponentsManager()
component_id = cm.add("unet", self.get_dummy_model())
Expand Down
Loading