Skip to content
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

Return output when calling run #778

Merged
merged 9 commits into from
Aug 2, 2023
Merged

Conversation

liamhuber
Copy link
Member

@liamhuber liamhuber commented Jul 18, 2023

And downstream stuff like update and thus __call__. This was requested by @JNmpi and now makes things really start to feel like regular python.

from pyiron_contrib.workflow import Workflow

@Workflow.wrap_as.single_value_node()
def plus_one(x=0):
    y = x + 1
    return y

wf = Workflow("wf", run_on_updates=True)
# wf.executor = CloudpickleProcessPoolExecutor()
wf.a = plus_one()
wf.b = plus_one(wf.a)

# For workflows we now return the DotDict of the output values
print(wf(a_x=2))
>>> {'b_y': 4}

out = wf(a_x=4)
print(out.b_y)
>>> 6

# And of course it works for Function nodes too, but with just the values
print(wf.a(42))
>>> 43

# The returned value is its own object
# So when we updated the node just there, the workflow output changes
# but `out` stays the same:
print(out.b_y, wf.outputs.to_value_dict())
>>> 6 {'b_y': 44}

# IMO that's desirable, because then you can collect up outputs
# over multiple runs of your workflow and plot them in the notebook
# or whatever

TODO:

  • Update docstrings
  • Update example notebook

And downstream stuff like `update` and thus `__call__`. This was requested by Joerg and now makes things really start to feel like regular python
@github-actions
Copy link
Contributor

Binder 👈 Launch a binder notebook on branch pyiron/pyiron_contrib/return_on_run

@liamhuber liamhuber marked this pull request as draft July 18, 2023 19:43
@liamhuber liamhuber requested a review from samwaseda July 18, 2023 19:44
We may wish to later make Macro's slow, but for Workflows, since the IO is just routing through to the owned nodes, input updates are _anyhow_ most of the time re-running things, so it's a sensible default IMO
@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@liamhuber liamhuber marked this pull request as ready for review July 19, 2023 16:54
@liamhuber liamhuber added the .workflow Pertaining to the workflow submodule label Jul 19, 2023
@liamhuber liamhuber merged commit 98542ce into clean_executor_fails Aug 2, 2023
3 of 4 checks passed
@delete-merged-branch delete-merged-branch bot deleted the return_on_run branch August 2, 2023 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
.workflow Pertaining to the workflow submodule
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant