Skip to content

Commit 863c7df

Browse files
committed
components manager: use shorter ID, display id instead of name
1 parent e0083b2 commit 863c7df

File tree

1 file changed

+9
-26
lines changed

1 file changed

+9
-26
lines changed

src/diffusers/modular_pipelines/components_manager.py

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
import copy
1616
import time
17-
import uuid
1817
from collections import OrderedDict
1918
from itertools import combinations
2019
from typing import Any, Dict, List, Optional, Union
@@ -280,7 +279,7 @@ def _id_to_name(component_id: str):
280279
return "_".join(component_id.split("_")[:-1])
281280

282281
def add(self, name, component, collection: Optional[str] = None):
283-
component_id = f"{name}_{uuid.uuid4()}"
282+
component_id = f"{name}_{id(component)}"
284283

285284
# check for duplicated components
286285
for comp_id, comp in self.components.items():
@@ -674,16 +673,6 @@ def __repr__(self):
674673
if not self.components:
675674
return "Components:\n" + "=" * 50 + "\nNo components registered.\n" + "=" * 50
676675

677-
# Helper to get simple name without UUID
678-
def get_simple_name(name):
679-
# Extract the base name by splitting on underscore and taking first part
680-
# This assumes names are in format "name_uuid"
681-
parts = name.split("_")
682-
# If we have at least 2 parts and the last part looks like a UUID, remove it
683-
if len(parts) > 1 and len(parts[-1]) >= 8 and "-" in parts[-1]:
684-
return "_".join(parts[:-1])
685-
return name
686-
687676
# Extract load_id if available
688677
def get_load_id(component):
689678
if hasattr(component, "_diffusers_load_id"):
@@ -699,9 +688,6 @@ def format_device(component, info):
699688
exec_device = str(info["execution_device"] or "N/A")
700689
return f"{device}({exec_device})"
701690

702-
# Get all simple names to calculate width
703-
simple_names = [get_simple_name(id) for id in self.components.keys()]
704-
705691
# Get max length of load_ids for models
706692
load_ids = [
707693
get_load_id(component)
@@ -725,7 +711,7 @@ def format_device(component, info):
725711
max_collection_len = max(10, max(len(str(c)) for c in all_collections)) if all_collections else 10
726712

727713
col_widths = {
728-
"name": max(15, max(len(name) for name in simple_names)),
714+
"id": max(15, max(len(name) for name in self.components.keys())),
729715
"class": max(25, max(len(component.__class__.__name__) for component in self.components.values())),
730716
"device": 20,
731717
"dtype": 15,
@@ -748,30 +734,29 @@ def format_device(component, info):
748734
if models:
749735
output += "Models:\n" + dash_line
750736
# Column headers
751-
output += f"{'Name':<{col_widths['name']}} | {'Class':<{col_widths['class']}} | "
737+
output += f"{'Name_ID':<{col_widths['id']}} | {'Class':<{col_widths['class']}} | "
752738
output += f"{'Device: act(exec)':<{col_widths['device']}} | {'Dtype':<{col_widths['dtype']}} | "
753739
output += f"{'Size (GB)':<{col_widths['size']}} | {'Load ID':<{col_widths['load_id']}} | Collection\n"
754740
output += dash_line
755741

756742
# Model entries
757743
for name, component in models.items():
758744
info = self.get_model_info(name)
759-
simple_name = get_simple_name(name)
760745
device_str = format_device(component, info)
761746
dtype = str(component.dtype) if hasattr(component, "dtype") else "N/A"
762747
load_id = get_load_id(component)
763748

764749
# Print first collection on the main line
765750
first_collection = component_collections[name][0] if component_collections[name] else "N/A"
766751

767-
output += f"{simple_name:<{col_widths['name']}} | {info['class_name']:<{col_widths['class']}} | "
752+
output += f"{name:<{col_widths['id']}} | {info['class_name']:<{col_widths['class']}} | "
768753
output += f"{device_str:<{col_widths['device']}} | {dtype:<{col_widths['dtype']}} | "
769754
output += f"{info['size_gb']:<{col_widths['size']}.2f} | {load_id:<{col_widths['load_id']}} | {first_collection}\n"
770755

771756
# Print additional collections on separate lines if they exist
772757
for i in range(1, len(component_collections[name])):
773758
collection = component_collections[name][i]
774-
output += f"{'':<{col_widths['name']}} | {'':<{col_widths['class']}} | "
759+
output += f"{'':<{col_widths['id']}} | {'':<{col_widths['class']}} | "
775760
output += f"{'':<{col_widths['device']}} | {'':<{col_widths['dtype']}} | "
776761
output += f"{'':<{col_widths['size']}} | {'':<{col_widths['load_id']}} | {collection}\n"
777762

@@ -783,23 +768,22 @@ def format_device(component, info):
783768
output += "\n"
784769
output += "Other Components:\n" + dash_line
785770
# Column headers for other components
786-
output += f"{'Name':<{col_widths['name']}} | {'Class':<{col_widths['class']}} | Collection\n"
771+
output += f"{'ID':<{col_widths['id']}} | {'Class':<{col_widths['class']}} | Collection\n"
787772
output += dash_line
788773

789774
# Other component entries
790775
for name, component in others.items():
791776
info = self.get_model_info(name)
792-
simple_name = get_simple_name(name)
793777

794778
# Print first collection on the main line
795779
first_collection = component_collections[name][0] if component_collections[name] else "N/A"
796780

797-
output += f"{simple_name:<{col_widths['name']}} | {component.__class__.__name__:<{col_widths['class']}} | {first_collection}\n"
781+
output += f"{name:<{col_widths['id']}} | {component.__class__.__name__:<{col_widths['class']}} | {first_collection}\n"
798782

799783
# Print additional collections on separate lines if they exist
800784
for i in range(1, len(component_collections[name])):
801785
collection = component_collections[name][i]
802-
output += f"{'':<{col_widths['name']}} | {'':<{col_widths['class']}} | {collection}\n"
786+
output += f"{'':<{col_widths['id']}} | {'':<{col_widths['class']}} | {collection}\n"
803787

804788
output += dash_line
805789

@@ -808,8 +792,7 @@ def format_device(component, info):
808792
for name in self.components:
809793
info = self.get_model_info(name)
810794
if info is not None and (info.get("adapters") is not None or info.get("ip_adapter")):
811-
simple_name = get_simple_name(name)
812-
output += f"\n{simple_name}:\n"
795+
output += f"\n{name}:\n"
813796
if info.get("adapters") is not None:
814797
output += f" Adapters: {info['adapters']}\n"
815798
if info.get("ip_adapter"):

0 commit comments

Comments
 (0)