-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
fix: Solves Issues with Set Function in Component Class and Enhance Input Handling #4258
fix: Solves Issues with Set Function in Component Class and Enhance Input Handling #4258
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.
LGTM
@@ -442,7 +442,8 @@ def _process_connection_or_parameter(self, key, value) -> None: | |||
|
|||
def _process_connection_or_parameters(self, key, value) -> None: | |||
# if value is a list of components, we need to process each component | |||
if isinstance(value, list): | |||
# Note this update make sure it is a list of components and not of any other values | |||
if isinstance(value, list) and all(isinstance(item, Component) for item in value): |
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.
This feels like it's missing a case. We have:
a) IF value
is a list AND they're all Components
, process each item in the list separately.
b) ELSE, process the input as a single value.
What happens if it's a list, but they're not all Components
?
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.
it executes else and assigns the values as per key value pair
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.
I am not sure if we will face that scenario if so we could add a case for it change the case.
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.
@jordanrfrazier you were right in a way. I guess we should add multiple cases. Added a case just now to solve the pytest failure error.
In Pytest: test_starter_projects that tests |
Enhance component input handling and add unit tests for mixed input scenarios.
6bdf5e2
to
33254f7
Compare
…tion_or_parameters - Updated the _process_connection_or_parameters function to handle lists and dictionaries properly. - Ensured that each element in a list is checked for serializability and converted to a string if necessary. - Added logic to convert dictionaries to JSON strings, handling non-serializable contents by converting them to strings. - This change prevents JSON serialization errors when processing component parameters.
updates _process_connection_or_parameters to handles situations where the list is not all component. Also handles any serialisation isseus caused by _process_connection_or_parameters
@jordanrfrazier I have added a case where all the inputs are not components and updated the function accordingly. Even though PR#4269 solves serialization error. Tested with pytest and all cases passes. |
update make sure it is not a list str | int | float | bool | type(None) Serialisation removed
…langflow-ai/langflow into fix-component-set-functionality
This pull request addresses improvements in the
Component
class's input handling and introduces new unit tests to ensure robust functionality. The following changes have been made:Improved Input Processing:
_process_connection_or_parameters
method incomponent.py
to ensure that when a value is a list, it correctly processes only lists ofComponent
instances. This enhancement prevents potential errors when other data types are passed.New Unit Tests:
set
method in theComponent
class:set
method can handle a list containing both a string and a component.set
method can accept a list ofMessageTextInput
instances and that their values are set correctly.Code Changes:
Component Logic:
New Tests:
test_component_set_functionality.py
to cover various input scenarios.Notes:
Component
class by ensuring it can handle diverse input types effectively.