Closed honix closed 5 years ago
Oh, shit. This never been that easy.
According to 1f3ca76:
So we get separation. Now let's create a library of nodes! :)
A question: can you clear up why you use exec() here (and elsewhere in the code) instead of importing the module? Seems to me not very pythonic, and possibly quite the security risk, and I don't see why it is done that way.
Pretty pythonic i think, it uses dynamic nature of the lang. Module import may be unsecure too, as i belive it is just a form of exec. Which is parse code and evaluate it in current environment.
How do you see importing using modules? Maybe it can be better for nodes library than exec?
OK, maybe I have misunderstood what exec should do, sorry. An advantage, in any case, is that you can tweak the scope with the optional arguments of exec().
This closes #9 also.
@honix: What is the exact idea now? Should nodes only be used as shown be the nodes/identity.py
example here? Or is this just one additional way of using it? I wonder as module imports from external python script have to be possible. The also have to work using import
. What about putting the call = identity
into the pyno node? That would allow to use one .py file for all nodes and come close to #14? (is this a scope issue?) Is the idea to always use the same code for those externals in the pyno node?
(sorry for may be aking naiive questions - I try to clarify the concept)
@drtrigon there is little trouble with import
when i use G
and S
variables in some nodes, and they are not defined, so import
throws exception.
But importing from external modules is possible right now! You just need to call
-bind function from module. And you can hold this functions in one file. As @bilderbuchi mentioned:
Really i dont have any exact opinion. It is good that here many ways to do. But we need to choose one 'official' way of importing. I like import
example, need to solve scope issue. :)
I will reopen this issue to find best way of making node-files. I found this scheme can handle local and (if needed) global scopes. One thing i don't like is pyno code on the right: too many lines. We can introduce new binding node = w.Window
as reference of class, or something smarter. :)
If we do, this can end up with something like this in pyno. But i find this little long and complicated for users. So i prefer to take call
cleanup
fast binding alongside with node
pro-user binding. Guys?
I'll have to think on this. But yes, simple/short is good, which is why I elsewhere suggested looking into decorators, this way you can hide complexity from users.
Another crazy idea is to link node
symbol to node itself, so user can node.call = kill_all_aliens(42)
or even node.color = (0, 0, 255)
. Hackableeee!
By this we reduce 'service' symbols to just node
.
The class approach reminds me to https://www.vistrails.org/usersguide/dev/html/packages.html
You want to be able to have multiple functions in one node and all the code in a python file. I can think of 2 ways:
call =
bindingsGenerally I think the call
binding should may be not be part of the .py file but off the pyno patch onl
The node symbol could most probably be similar to the self
we need for loop support.
OK, I have to admit I don't understand why there is GUI/windows code up there in the user-defined node code. I think you strictly have to separate three things, and then the structure will hopefully be clearer to implement (note I have not read the current code for these things):
somenode = Node(call=numpy.cos)
somenode = Node(call=pyno.nodes.timeSinus)
somenode = Node(call=string_from_editor_window)
somenode.update_call(updated_content_from_editor)
(By the way, the name .call
is kinda dangerous, as it's easy to confuse it with the Python __call__
method. Something like compute
or process
would proably be clearer.
mygraph[42].update_call(new_content)
to interact with the node.I just fonud out that PyQtGraph also has something similiar called "flowchart": http://www.pyqtgraph.org/documentation/flowchart/index.html
Read conversation here #17