sverchok icon indicating copy to clipboard operation
sverchok copied to clipboard

Mock Nodes

Open Durman opened this issue 2 years ago • 0 comments

Problem statement

Mock node is a twin of a class of a normal node. Mock nodes include only basic information about their twins link idname, label, icon, dependencies. Mock node classes should be automatically generated in separate file by reading files of normal classes. During initialization of the add-on only mock nodes are registered. During adding new nodes, reading files, importing jsons correspondent mock nodes should be automatically unregistered and normal nodes should be imported and registered.

Advantages:

  • Faster startup of add-on what should resolve this #4752 Speedup also can be achieved by importing dependent libraries on demand
  • Dependent libraries can be imported directly without. import numba instead of from sverchok.dependencies import numba. It will require less work to add new dependencies to Sverchok. If dependency is optional it will require try catch construction around import.
  • Such approach does not require any changes in add node menu code.

Disadvantages:

  • More complicated code of adding new node operators, opening files and importing jsons = new bugs
  • It won't be possible to import nodes with dependencies. It means that when a file is opened with dependent nodes it want be possible to reregister normal nodes and mock nodes will be displayed. Probably it's not a big problem since we had similar approach with dummy nodes recently. Such nodes just won't show node buttons.
  • Successful add-on initialization won't guarantee that all nodes can be imported. Can be solved by adding unit test.
  • First startup will be slower anyway to generate file with mock nodes.

Durman avatar Dec 22 '22 08:12 Durman