Closed HeftyCoder closed 11 months ago
Please correct me if I'm missing something but I think your api.py
compromises the whole point of separating nodes dependencies and UI dependencies in the first place, which is that Ryven has a headless mode in which it runs without any Qt dependencies (only ryvencore).
Clarifying the previous comment: Ryven can run in environments where Qt is not even installed (because it can't without desktop environment). That's why ryven.main
is separate from ryven.gui
. [^1] ryven.main.Ryven.run()
runs with the editor, ryven.main.RyvenConsole.run()
runs without.
[^1]: config.py
imports something from gui
but it doesn't cause Qt
import
I took the liberty to fix the imports and remove api
. If I messed up your local branch I can rollback re-commit later. Looks good to me now, anything else from your side?
I think your api.py compromises the whole point of separating nodes dependencies and UI dependencies in the first place
I was (and probably still am) confused about how python importing works. I thought that by calling from ryven.api import in_gui_mode
only that function would be imported, ignoring the rest. Didn't account that in_gui_mode
was also imported in gui_env
. I thought one could bundle everything that way. My bad.
I made minor changes to the consume_last_exported_package
function. Other than that, I'm good!
Importing a module just means running it. A module-level expression such as def foo
makes the foo
symbol available. A module-level expression such as import ryven.gui_env
runs ryven.gui_env
at the point where the import is stated. A from
import is actually no different, from ryven.api import in_gui_mode
will first run ryven.api
and then make in_gui_mode
available locally. That's why it matters how imports are placed.
This PR introduces a new way to assign Node GUIs to Nodes. Specifically:
node_gui
which accepts a Node as a parameter. Assigning a gui to a node happens in thegui.py
file and not thenodes.py
, allowing for IDE hinting and deprecating the need for theimport_guis
andexport_guis
functions.on_gui_load
function which can be applied to any function in the importednodes.py
file. This function will then be called after package loading inimport_nodes_package
.Adds aBad idea, read the conversation for details.api.py
file in the ryven folder. Might not be needed, but thought it was a good idea.The
built_in
package and thepkg_test
package (which haslinalg
andstd
subpackages) have been changed to use this new utility. The olderlinalg
andstd
packages haven't been altered and are working with the "deprecated" functions.CC: these ideas were first discussed in #171 as a result of investigating sub-packages