-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[minor] Function selflessly #279
Conversation
Coverage summary from CodacySee diff coverage on Codacy
Coverage variation details
Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: Diff coverage details
Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: See your quality gate settings Change summary preferencesYou 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 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 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