VisJsRenderer - Erroneous parent path detection while rendering child in HTML
Description
When trying to access the child in the class, the HTML rendering fails. The error arises when attempting to find the path to the parent, but the parent isn't recognized as a child of the mentioned child.
Code to reproduce
from cosapp.systems import System
class Foo(System):
def setup(self):
self.add_inward('a')
class Sys(System):
def setup(self):
self.add_child(Foo('foo'))
sys = Sys('sys')
sys.foo
Extract of the traceback
File ~\miniconda3\envs\cosapp\Lib\site-packages\cosapp\tools\views\visjs.py:45, in VisJsRenderer.get_system_title(self, system)
43 name = head.name
44 else:
---> 45 name = head.get_path_to_child(system)
46 return f"{name} - {system.__class__.__name__}"
File ~\miniconda3\envs\cosapp\Lib\site-packages\cosapp\core\module.py:305, in Module.get_path_to_child(self, other)
303 child = child.parent
304 if child is None:
--> 305 raise ValueError(
306 f"{other.name!r} is not a child of {self.name!r}."
307 )
308 return ".".join(reversed(path))
ValueError: 'sys' is not a child of 'foo'.