Skip to content

Commit ea3a2ed

Browse files
committed
update more?
1 parent 570677c commit ea3a2ed

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

src/diffusers/modular_pipelines/components_manager.py

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -426,12 +426,9 @@ 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-
# 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)
429+
# remove existing component from this collection (if it is not in any other collection, will be removed from ComponentsManager)
430+
self.remove_from_collection(comp_id, collection)
431+
435432
self.collections[collection].add(component_id)
436433
logger.info(
437434
f"ComponentsManager: added component '{name}' in collection '{collection}': {component_id}"
@@ -444,6 +441,24 @@ def add(self, name: str, component: Any, collection: Optional[str] = None):
444441

445442
return component_id
446443

444+
def remove_from_collection(self, component_id: str, collection: str):
445+
"""
446+
Remove a component from a collection.
447+
"""
448+
if collection not in self.collections:
449+
logger.warning(f"Collection '{collection}' not found in ComponentsManager")
450+
return
451+
if component_id not in self.collections[collection]:
452+
logger.warning(f"Component '{component_id}' not found in collection '{collection}'")
453+
return
454+
# remove from the collection
455+
self.collections[collection].remove(component_id)
456+
# check if this component is in any other collection
457+
comp_colls = [coll for coll, comps in self.collections.items() if component_id in comps]
458+
if not comp_colls: # only if no other collection contains this component, remove it
459+
logger.warning(f"ComponentsManager: removing component '{component_id}' from ComponentsManager")
460+
self.remove(component_id)
461+
447462
def remove(self, component_id: str = None):
448463
"""
449464
Remove a component from the ComponentsManager.

src/diffusers/modular_pipelines/modular_pipeline_utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,8 @@ def load_id(self) -> str:
185185
Unique identifier for this spec's pretrained load, composed of repo|subfolder|variant|revision (no empty
186186
segments).
187187
"""
188+
if self.default_creation_method == "from_config":
189+
return "null"
188190
parts = [getattr(self, k) for k in self.loading_fields()]
189191
parts = ["null" if p is None else p for p in parts]
190192
return "|".join(p for p in parts if p)

0 commit comments

Comments
 (0)