-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
feat: add dataframe to Loop component, fixes loop input error #6996
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Overview
This pull request adds support for DataFrame inputs and outputs in the LoopComponent, enhancing its data handling flexibility. Key changes include:
- Replacing DataInput with HandleInput and updating the input metadata to accept both Data and DataFrame.
- Modifying _validate_data to convert DataFrame inputs into a list of Data objects.
- Changing done_output to return a DataFrame when iteration is complete.
Reviewed Changes
File | Description |
---|---|
src/backend/base/langflow/components/logic/loop.py | Updates to inputs, validation, and output methods to incorporate DataFrame support |
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
src/backend/base/langflow/components/logic/loop.py:84
- [nitpick] The method name 'done_output' may not clearly indicate that it returns a DataFrame. Consider updating the name or adding documentation to clarify this behavior for improved code clarity.
def done_output(self) -> DataFrame:
def aggregated_output(self) -> list[Data]: | ||
"""Return the aggregated list once all items are processed.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method 'aggregated_output' returns a list of Data objects, while 'done_output' now returns a DataFrame. This discrepancy in return types may lead to inconsistencies when consuming these outputs; consider unifying the output types or clearly documenting the differences in behavior.
def aggregated_output(self) -> list[Data]: | |
"""Return the aggregated list once all items are processed.""" | |
def aggregated_output(self) -> DataFrame: | |
"""Return the aggregated DataFrame once all items are processed.""" |
Copilot is powered by AI, so mistakes are possible. Review output carefully before use.
CodSpeed Performance ReportMerging #6996 will degrade performances by 35.52%Comparing Summary
Benchmarks breakdown
|
Testing, We might need to deplrecate the old one as well as update the template. cc. @italojohnny May I know if you are already working on it if not I could pick it up! |
I haven’t had time to check this PR yet. I’m finishing the tests for #7026 |
Working on Deprecating the old component and making this as a the new component. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors the looping functionality by introducing a new BasicLoopComponent that supports both Data and DataFrame types for inputs and adjusts output behavior accordingly. Key changes include:
- Creating BasicLoopComponent with updated input validation and output methods.
- Updating related methods and tests to use BasicLoopComponent instead of the legacy LoopComponent.
- Adjusting import and type usages in test files and associated modules.
Reviewed Changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
src/backend/base/langflow/components/logic/loop_basic.py | New BasicLoopComponent with updated input handling and output methods. |
src/backend/base/langflow/graph/vertex/base.py | Enhanced get_value_from_output_names with improved documentation and edge handling. |
src/backend/base/langflow/custom/custom_component/component.py | Added get_loop_output_value to support loop outputs. |
src/backend/tests/unit/components/logic/test_loop.py | Updated to test using BasicLoopComponent. |
Other test and module files | Minor updates to imports and dependencies supporting the new component changes. |
return current_index > data_length | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using '>= data_length' instead of '> data_length' so that the loop terminates correctly when the current index equals the length of the data list.
return current_index > data_length | |
return current_index >= data_length |
Copilot is powered by AI, so mistakes are possible. Review output carefully before use.
This pull request introduces several changes to the
LoopComponent
class in thelangflow
backend to support bothData
andDataFrame
types. The modifications include updates to the input handling, validation, and output methods, as well as adjustments to the initial setup templates.Changes to
LoopComponent
class:DataFrame
and changedDataInput
toHandleInput
. (src/backend/base/langflow/components/logic/loop.py
)inputs
attribute to accept bothData
andDataFrame
types and updated the display name and info accordingly. (src/backend/base/langflow/components/logic/loop.py
)_validate_data
method to handleDataFrame
inputs and convert them to a list ofData
objects. (src/backend/base/langflow/components/logic/loop.py
)done_output
method to return aDataFrame
instead of aData
object when the iteration is complete. (src/backend/base/langflow/components/logic/loop.py
)aggregated_output
method to return a list ofData
objects. (src/backend/base/langflow/components/logic/loop.py
)Changes to initial setup templates:
LoopTemplate.json
to reflect the changes in input and output types, including the addition ofDataFrame
as a valid type. (src/backend/base/langflow/initial_setup/starter_projects/LoopTemplate.json
) [1] [2] [3] [4] [5] [6]These changes enhance the flexibility of the
LoopComponent
by allowing it to handle bothData
andDataFrame
inputs, making it more versatile for different data processing scenarios.