langflow icon indicating copy to clipboard operation
langflow copied to clipboard

feat(component): enhance merge data with standard operations

Open raphaelchristi opened this issue 1 year ago • 0 comments

Description

This PR refactors the Merge Data component, introducing improved functionality and clarity to the merging process.


Changes

  • Standardized Merge Operations:

    • concatenate: Combines text values with newlines.
    • append: Adds data as new rows.
    • merge: Combines values into lists.
    • join: Adds columns with suffixes.
  • Output Improvements:

    • Change output type to DataFrame for enhanced data handling and manipulation.
  • Documentation:

    • Add detailed documentation for each operation, improving clarity and usability.
  • Error Handling:

    • Enhanced with detailed logging for better debugging and traceability.
  • Refactored Merge Logic:

    • Separate merge logic into dedicated methods for cleaner, modular code.
  • UI Enhancements:

    • Add informative tooltips to aid users in selecting the correct merge operation.

Code Comparison

Before

def merge_data(self) -> list[Data]:
    # Single method handling all merging
    all_keys: set[str] = set()
    for data_input in data_inputs:
        all_keys.update(data_input.data.keys())

After

def merge_data(self) -> DataFrame:
    # Clear operation selection with enum
    operation = MergeOperation(self.operation)
    # Process using dedicated methods
    df = self._process_operation(operation)
    return DataFrame(df)

Benefits

  • Enhanced readability and maintainability.
  • Improved user experience with clear guidance.
  • Robust error handling ensures fewer runtime issues.
  • Modular methods facilitate easier future extensions.

raphaelchristi avatar Dec 06 '24 18:12 raphaelchristi