fix: Solves Issues with Set Function in Component Class and Enhance Input Handling (#4258)
* Enhance Component Input Handling and Add Unit Tests Enhance component input handling and add unit tests for mixed input scenarios. * [autofix.ci] apply automated fixes * fix: handle JSON serialization for lists and dicts in _process_connection_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. * reverting the changes * [autofix.ci] apply automated fixes * Update component.py 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 * [autofix.ci] apply automated fixes * Update component.py update make sure it is not a list str | int | float | bool | type(None) Serialisation removed --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
5be41ae13e
commit
78e6ee1a8a
3 changed files with 53 additions and 1 deletions
|
|
@ -47,6 +47,8 @@ def build_description(component: Component, output: Output) -> str:
|
|||
|
||||
def _build_output_function(component: Component, output_method: Callable):
|
||||
def output_function(*args, **kwargs):
|
||||
# set the component with the arguments
|
||||
# set functionality was updatedto handle list of components and other values separately
|
||||
component.set(*args, **kwargs)
|
||||
return output_method()
|
||||
|
||||
|
|
|
|||
|
|
@ -442,7 +442,8 @@ class Component(CustomComponent):
|
|||
|
||||
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 not a list str | int | float | bool | type(None)
|
||||
if isinstance(value, list) and not any(isinstance(val, str | int | float | bool | type(None)) for val in value):
|
||||
for val in value:
|
||||
self._process_connection_or_parameter(key, val)
|
||||
else:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue