diff --git a/CHANGELOG.md b/CHANGELOG.md index e5c191e15..d9e5a4c5d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Vector-search vector-loading bug fixed - Bugs related to new queuing paradigm - Remove --user from make install_devkit as it supposed to run on a virtualenv. +- component info support list ## [0.3.0](https://github.com/superduper-io/superduper/compare/0.3.0...0.2.0]) (2024-Jun-21) diff --git a/superduper/misc/special_dicts.py b/superduper/misc/special_dicts.py index 59b781846..3508a3f36 100644 --- a/superduper/misc/special_dicts.py +++ b/superduper/misc/special_dicts.py @@ -408,16 +408,34 @@ def _display_component(obj, verbosity=1): console = Console() + MAX_STR_LENGTH = 50 + + def _handle_list(lst): + handled_list = [] + for item in lst: + if isinstance(item, Leaf): + if len(str(item)) > MAX_STR_LENGTH: + handled_list.append(str(item)[:MAX_STR_LENGTH] + "...") + else: + handled_list.append(str(item)) + elif isinstance(item, (list, tuple)): + handled_list.append(_handle_list(item)) + else: + handled_list.append(str(item)) + return handled_list + def _component_info(obj): base_component = [] for key, value in obj.__dict__.items(): if value is None: continue if isinstance(value, Leaf): - if len(str(value)) > 50: - value = str(value)[:50] + "..." + if len(str(value)) > MAX_STR_LENGTH: + value = str(value)[:MAX_STR_LENGTH] + "..." else: value = str(value) + elif isinstance(value, (tuple, list)): + value = _handle_list(value) base_component.append(f"[magenta]{key}[/magenta]: [blue]{value}[/blue]") base_component = "\n".join(base_component)