from myfasthtml.controls.VisNetwork import VisNetwork from myfasthtml.controls.helpers import Ids from myfasthtml.core.instances import SingleInstance, InstancesManager from myfasthtml.core.network_utils import from_parent_child_list class InstancesDebugger(SingleInstance): def __init__(self, session, parent, _id=None): super().__init__(session, Ids.InstancesDebugger, parent) def render(self): instances = self._get_instances() nodes, edges = from_parent_child_list(instances, id_getter=lambda x: x.get_id(), label_getter=lambda x: x.get_prefix(), parent_getter=lambda x: x.get_parent().get_id() if x.get_parent() else None ) vis_network = VisNetwork(self, nodes=nodes, edges=edges) return vis_network def _get_instances(self): return list(InstancesManager.instances.values()) def __ft__(self): return self.render()