Closed liamhuber closed 2 months ago
Coverage variation | Diff coverage |
---|---|
:white_check_mark: +0.03% (target: -1.00%) | :white_check_mark: 100.00% |
You may notice some variations in coverage metrics with the latest Coverage engine update. For more details, visit the documentation
Sorry I had a heated discussion yesterday elsewhere and could not join the pyiron meeting. I was never very comfortable with self
(I guess same for you) so I'm ok with getting rid of it. But this only removes self
right? I thought the intention of self
was to pass information from outside, like:
from pyiron_workflow import Workflow
@Workflow.wrap.as_function_node()
def Selfish(self, some_executable):
some_executable.cores = self.server.cores
some_executable.run()
return some_executable.output
Or do we now want to do everything via function arguments?
Ah, I had only been thinking in terms of adding state to the node rather than pulling data from existing state. At any rate, I agree we can probably manage to do it via the function input. E.g.
from pyiron_workflow import Workflow
@Workflow.wrap.as_function_node()
def Selfless(some_executable, cores):
some_executable.cores = cores
some_executable.run()
return some_executable.output
n = Selfless()
n(some_executable=exe, cores=n.server.cores)
This is not identical functionality, but let's run with it and add back in self
only in the dire case that it's unavoidably necessary for a particular application.
EDIT: python highlighting
Currently, we jump through some hoops to let users pass
self
as a special argument forFunction
nodes. This didn't show up in the node input, and under the hood the node instance got passed in for that argument. You could do things like this:Now we don't, and
self
is treated just like any otherFunction
node argument, which means it bumps right into the protection we have in place to stop people from using terms already in theFunction.__init__
signature (this protection allows input to be set as**kwargs
)I like for a bunch of reasons:
self
argument didn't play well with executors, so there were special exceptions to fail early and non-universal behaviourI.e. if you want state, use a state-ful
Macro
node and hold the state as IO of one of its children.Non-goals:
input
to be accessed. I want this, and it should be easy, but it pertains to all protected signature items and is out of scope here.EDIT: python syntax highlighting on the examples