Closed liamhuber closed 2 months ago
Coverage variation | Diff coverage |
---|---|
:white_check_mark: +0.14% (target: -1.00%) | :white_check_mark: 100.00% |
Codacy stopped sending the deprecated coverage status on June 5th, 2024. Learn more
Files with Coverage Reduction | New Missed Lines | % | ||
---|---|---|---|---|
type_hinting.py | 1 | 97.62% | ||
nodes/for_loop.py | 3 | 98.62% | ||
nodes/static_io.py | 3 | 85.71% | ||
<!-- | Total: | 7 | --> |
Totals | |
---|---|
Change from base Build 10693688049: | 0.1% |
Covered Lines: | 2906 |
Relevant Lines: | 3177 |
Thanks a lot Liam, I'll have a look at it over the weekend.
Check out this pull request on
See visual diffs & provide feedback on Jupyter Notebooks.
Powered by ReviewNB
From the updated quickstart:
wf = Workflow("listlike_for_loop")
wf.first_loop = Workflow.create.for_node(
body_node_class=Workflow.create.standard.Add,
iter_on=("other",),
obj=1,
other=[1, 2, 4],
output_as_dataframe=False, # This is what's different
)
wf.second_loop = Workflow.create.for_node(
body_node_class=Workflow.create.standard.Multiply,
iter_on=("other",),
obj=2,
other=wf.first_loop.outputs.add, # This is the nice part it enables!
output_as_dataframe=False,
)
wf()
>>> {
... 'first_loop__other': [1, 2, 4],
... 'second_loop__other': [2, 3, 5],
... 'second_loop__mul': [4, 6, 10]
... }
Where we see the (in this case only) looped output mul
as a channel of list data, and since they aren't connected to anything, the "what input got this output" other
channels for both loops.
In the future I can see making the list-like output default and forcing people to ask for the dataframe.
WIP
Closes #440
@ligerzero-ai, I still need to sand down the rough edges, but I hope this gets 70% of the way to resolving the issues you ran into when making the equation of state stuff.
Before, because the for-loop was returning a dataframe, accessing the underlying dataclass attributes was a pain in the butt and was easiest to accomplish with custom logic
Now, the same thing can be accomplished using built-in tools, in this case a second for-loop for the attribute access:
At the moment we still need the extra step to unpack the dataclass. I can anticipate some feedback that this is still annoying, but at least for the moment I want to move one step at a time here. Basically it's not immediately clear to me whether we should be building up a bunch of infrastructure to help users unpack their dataclasses all over the place, or whether it's a better practice to leave them packages and encourage node packages that use dataclasses to use them throughout the node package (e.g. with multiple dispatch to allow dataclass or explicit input).
In the meantime I'm content that the extra step is at least "standard" stuff and not a custom node definition. I have some ideas for tightening the for-loop syntax though -- e.g. at least
iter_on
(andzip_on
) should be able to take a single string instead of a tuple of length 1...