Skip to content

Commit 570677c

Browse files
committed
only remove from the collection
1 parent cde02b0 commit 570677c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/diffusers/modular_pipelines/components_manager.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,12 @@ def add(self, name: str, component: Any, collection: Optional[str] = None):
426426
logger.warning(
427427
f"ComponentsManager: removing existing {name} from collection '{collection}': {comp_id}"
428428
)
429-
self.remove(comp_id)
429+
# remove only from this collection
430+
self.collections[collection].remove(comp_id)
431+
comp_colls = [coll for coll, comps in self.collections.items() if comp_id in comps]
432+
if not comp_colls: # only if no other collection contains this component, remove it
433+
logger.info(f"ComponentsManager: removing component '{comp_id}' from ComponentsManager")
434+
self.remove(comp_id)
430435
self.collections[collection].add(component_id)
431436
logger.info(
432437
f"ComponentsManager: added component '{name}' in collection '{collection}': {component_id}"

0 commit comments

Comments
 (0)