Skip to content
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 new node Input type for data in table format #2635

Merged
merged 55 commits into from
Jul 24, 2024
Merged

Conversation

anovazzi1
Copy link
Contributor

@anovazzi1 anovazzi1 commented Jul 11, 2024

Feature: Add New Node Input Type for Table Format Data

Description:

This feature introduces a new input type node specifically designed to handle data in table format. The new node input type allows for seamless integration and manipulation of tabular data within the system, enhancing data processing capabilities.

Key Changes:

  • Added a new input type node for table format data.
  • Implemented necessary parsing and validation for table data.

Copy link
Contributor

Pull Request Validation Report

This comment is automatically generated by Conventional PR

Whitelist Report

Whitelist Active Result
Pull request is a draft and should be ignored
Pull request is made by a whitelisted user and should be ignored
Pull request is submitted by a bot and should be ignored
Pull request is submitted by administrators and should be ignored

Result

Pull request matches with one (or more) enabled whitelist criteria. Pull request validation is skipped.

Last Modified at 11 Jul 24 14:38 UTC

@anovazzi1 anovazzi1 changed the title TableInput feat: add new node Input type for data in table format Jul 16, 2024
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Jul 16, 2024
@anovazzi1 anovazzi1 marked this pull request as ready for review July 16, 2024 18:38
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. javascript Pull requests that update Javascript code labels Jul 16, 2024
@ogabrielluiz ogabrielluiz enabled auto-merge (squash) July 17, 2024 00:39
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Jul 17, 2024
anovazzi1 and others added 14 commits July 18, 2024 10:12
This commit adds the Table component and related functionality to the codebase. The Table component is used to display tabular data and includes features such as pagination, row deletion, row duplication, and adding new rows. The TableOptions component is also added to provide options for resetting the grid and adding new rows. Additionally, the necessary types and interfaces are updated to support the Table component. This feature enhances the user experience by allowing them to interact with tabular data in a more intuitive way.
This commit updates the `Column` model in the table schema to include the `display_name` and `name` fields instead of `header` and `field`. It also adds validation for the `formatter` field to accept either a `FormatterType` enum value or a string. This change improves the clarity and flexibility of the table schema.
This commit adds the `displayEmptyAlert` prop to the `TableComponent` in order to control whether an alert is displayed when the table has no data. By default, the alert will be shown, but it can be disabled by setting `displayEmptyAlert` to `false`. This feature enhances the flexibility of the table component by allowing users to customize the behavior when there are no rows in the table.
…ort for a custom formatter. The formatter can be specified as a prop and allows for rendering the cell value in different formats, such as JSON. This enhancement enhances the flexibility and customization options of the TableAutoCellRender component.
This commit adds the `FormatColumns` function to `utils.ts` file. The function takes an array of `ColumnField` objects and returns an array of `ColDef` objects. It maps each `ColumnField` to a `ColDef` with properties like `headerName`, `field`, `sortable`, and `filter`. If a `ColumnField` has a `formatter` property, it sets the `cellDataType` or `cellRendererParams` accordingly. This function enhances the flexibility and customization options for formatting columns in the table.
This commit enhances the TableNodeComponent by utilizing the FormatColumns function from utils.ts. The FormatColumns function takes an array of ColumnField objects and returns an array of ColDef objects, allowing for flexible and customizable column formatting in the table. By integrating this function, the TableNodeComponent now has improved column handling capabilities.
This commit updates the TableNodeComponent and TableComponent to improve column handling and customization options. The TableNodeComponent now utilizes the FormatColumns function from utils.ts, allowing for flexible and customizable column formatting in the table. The TableComponent now has a new prop, displayEmptyAlert, which controls whether an alert is displayed when the table has no data. These enhancements enhance the flexibility and customization options of the table components.
ogabrielluiz and others added 2 commits July 18, 2024 10:19
…nction

Refactor the error message formatting in the `create_class` function in `validate.py` to improve readability and clarity. Instead of using a list comprehension to extract the error messages, the code now uses a nested list comprehension to split the error messages and extract the relevant information. This change ensures that the error message is properly formatted and provides more informative details about the validation errors.

Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
Co-authored-by: Lucas Oliveira <lucas.edu.oli@hotmail.com>
The TableMixin class in input_mixin.py has been updated to support either a TableSchema object or a list of Columns for the table_schema attribute. This change allows for more flexibility in defining the table schema for input validation.
anovazzi1 and others added 4 commits July 18, 2024 16:38
Refactor the TableNodeComponent to generate backend columns from the value when the columns prop is not provided. This change ensures that the component can handle dynamic column generation based on the value, improving flexibility and usability.

Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
Co-authored-by: Lucas Oliveira <lucas.edu.oli@hotmail.com>
The extractColumnsFromRows function in utils.ts has been refactored to return only ColDef objects instead of a combination of ColDef and ColGroupDef objects. This change simplifies the function's return type and improves consistency in the codebase.

Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
Co-authored-by: Lucas Oliveira <lucas.edu.oli@hotmail.com>
@ogabrielluiz ogabrielluiz marked this pull request as ready for review July 18, 2024 19:58
@dosubot dosubot bot added the python Pull requests that update Python code label Jul 18, 2024
@ogabrielluiz ogabrielluiz requested review from italojohnny and nicoloboschi and removed request for ogabrielluiz and lucaseduoli July 18, 2024 19:58
@ogabrielluiz ogabrielluiz marked this pull request as draft July 18, 2024 19:59
@ogabrielluiz
Copy link
Contributor

Example component:

# from langflow.field_typing import Data
from langflow.custom import Component
from langflow.io import TableInput, Output
from langflow.schema import Data


class CustomComponent(Component):
    display_name = "Custom Component"
    description = "Use as a template to create your own component."
    documentation: str = "http://docs.langflow.org/components/custom"
    icon = "custom_components"
    name = "CustomComponent"

    inputs = [
        TableInput(name="input_value", display_name="Input Value", value=[{"bacon":"a"}], table_schema=[{"name": "bacon","display_name": "Bacon"}]),
    ]

    outputs = [
        Output(display_name="Output", name="output", method="build_output"),
    ]

    def build_output(self) -> Data:
        data = Data(value=self.input_value)
        self.status = data
        return data

Refactor the TableNodeComponent to generate backend columns from the value when the columns prop is not provided. This change ensures that the component can handle dynamic column generation based on the value, improving flexibility and usability.
@anovazzi1 anovazzi1 marked this pull request as ready for review July 22, 2024 13:17
@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Jul 22, 2024
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jul 24, 2024
@ogabrielluiz ogabrielluiz merged commit 007c38a into main Jul 24, 2024
15 checks passed
@ogabrielluiz ogabrielluiz deleted the TableInput branch July 24, 2024 13:21
@severfire
Copy link

Great feature, but while testing it, I noticed It would be great to have user interface for it on frontend.

nicoloboschi pushed a commit to datastax/ragstack-ai-langflow that referenced this pull request Jul 30, 2024
)

* feat: add Table component and related functionality

This commit adds the Table component and related functionality to the codebase. The Table component is used to display tabular data and includes features such as pagination, row deletion, row duplication, and adding new rows. The TableOptions component is also added to provide options for resetting the grid and adding new rows. Additionally, the necessary types and interfaces are updated to support the Table component. This feature enhances the user experience by allowing them to interact with tabular data in a more intuitive way.

* feat: add Edit Data trigger to TableNodeComponent

* [autofix.ci] apply automated fixes

* feat: add TableSchema class for defining table structure

* feat: add TableMixin class for table-related functionality

* feat: add TableInput class for table-related functionality

* feat: add TableInput to io module

* feat: update Column model in table schema

This commit updates the `Column` model in the table schema to include the `display_name` and `name` fields instead of `header` and `field`. It also adds validation for the `formatter` field to accept either a `FormatterType` enum value or a string. This change improves the clarity and flexibility of the table schema.

* feat: add displayEmptyAlert prop to TableComponent

This commit adds the `displayEmptyAlert` prop to the `TableComponent` in order to control whether an alert is displayed when the table has no data. By default, the alert will be shown, but it can be disabled by setting `displayEmptyAlert` to `false`. This feature enhances the flexibility of the table component by allowing users to customize the behavior when there are no rows in the table.

* This commit improves the TableAutoCellRender component by adding support for a custom formatter. The formatter can be specified as a prop and allows for rendering the cell value in different formats, such as JSON. This enhancement enhances the flexibility and customization options of the TableAutoCellRender component.

* feat: add FormatColumns function to utils.ts

This commit adds the `FormatColumns` function to `utils.ts` file. The function takes an array of `ColumnField` objects and returns an array of `ColDef` objects. It maps each `ColumnField` to a `ColDef` with properties like `headerName`, `field`, `sortable`, and `filter`. If a `ColumnField` has a `formatter` property, it sets the `cellDataType` or `cellRendererParams` accordingly. This function enhances the flexibility and customization options for formatting columns in the table.

* feat: enhance TableNodeComponent with FormatColumns function

This commit enhances the TableNodeComponent by utilizing the FormatColumns function from utils.ts. The FormatColumns function takes an array of ColumnField objects and returns an array of ColDef objects, allowing for flexible and customizable column formatting in the table. By integrating this function, the TableNodeComponent now has improved column handling capabilities.

* chore: Update TableNodeComponent and TableComponent

This commit updates the TableNodeComponent and TableComponent to improve column handling and customization options. The TableNodeComponent now utilizes the FormatColumns function from utils.ts, allowing for flexible and customizable column formatting in the table. The TableComponent now has a new prop, displayEmptyAlert, which controls whether an alert is displayed when the table has no data. These enhancements enhance the flexibility and customization options of the table components.

* [autofix.ci] apply automated fixes

* feat: Update TableNodeComponent and TableComponent

This commit updates the TableNodeComponent and TableComponent to improve column handling and customization options. It utilizes the FormatColumns function from utils.ts for flexible and customizable column formatting in the table. The TableComponent now has a new prop, displayEmptyAlert, to control the display of an alert when the table has no data. These enhancements enhance the flexibility and customization options of the table components.

* feat: initialize table field values as DataFrame

* feat: Enhance TableNodeComponent with duplicateRow function

This commit enhances the TableNodeComponent by adding the duplicateRow function. This function allows users to duplicate selected rows in the table. When called, it clones the selected nodes and adds the duplicated rows to the table. This feature enhances the flexibility and customization options of the TableNodeComponent.

* [autofix.ci] apply automated fixes

* feat: Remove "text" from basic_types in FormatColumns function

This commit removes the "text" value from the basic_types set in the FormatColumns function in utils.ts. The basic_types set is used to determine the column type for formatting in the table. By removing "text", we ensure that only "date" and "number" types are considered as basic types. This change improves the accuracy and consistency of column formatting in the table.

* fix: alingment bug on AgGrid cell

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes

* Styled the Open Table button on TableNodeComponent

* Fixed type of ref on tableComponent

* Creaed a TableModal component, that receives the props that are passed to the Table, as well as a title, and creates a modal

* Used the TableModal on the TableNodeComponent

* Fixed looks of TableModal

* Added description set on tableModal

* Add description field to TableNodeComponent

* Fixed text of description if info is not provided

* Added TableComponent in tableNodeCellRenderer

* Added styling based on editNode

* Added Auto Size to table modal

* refactor: update TableOptions component styling and behavior

- Update TableOptions component to dynamically apply text color based on selection
- Remove unnecessary console.log statement
- Improve hover behavior for the Trash2 icon

* chore: Remove unnecessary imports and initialize empty columns array in TableNodeComponent

* feat: Add default values for sortable and filterable in Column model

The code changes in `table.py` modify the `Column` model in the `langflow.schema` module. The `sortable` and `filterable` attributes of the `Column` model now have default values of `True`. This change ensures that new instances of the `Column` model will have these attributes set to `True` by default.

Based on the recent user commits and repository commits, the commit message follows the established convention of using a prefix to indicate the type of change (`feat` for a new feature) and provides a clear and concise description of the changes made.

* feat(utils.ts): add check for empty columns array in FormatColumns function to prevent errors

* feat: Add validation for TableInput value in inputs.py

The code changes in `inputs.py` add a validation function for the `value` attribute of the `TableInput` class. The function checks if the value is a list of dictionaries and raises a `ValueError` if it is not. This ensures that the `TableInput` instances have a valid value that is a list of dictionaries.

Based on the recent user commits and repository commits, the commit message follows the established convention of using a prefix to indicate the type of change (`feat` for a new feature) and provides a clear and concise description of the changes made.

* [autofix.ci] apply automated fixes

* feat: extend editable field to json field

* [autofix.ci] apply automated fixes

* feat: Add validation for TableInput value in inputs.py

* feat(validate.py): add exception handling to catch and re-raise ValidationError with a more informative error message

* chore: Refactor error message in build_custom_component_template function

* fix(validate.py): improve error message formatting in create_class function

Refactor the error message formatting in the `create_class` function in `validate.py` to improve readability and clarity. Instead of using a list comprehension to extract the error messages, the code now uses a nested list comprehension to split the error messages and extract the relevant information. This change ensures that the error message is properly formatted and provides more informative details about the validation errors.

Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
Co-authored-by: Lucas Oliveira <lucas.edu.oli@hotmail.com>

* feat: Update TableMixin to support TableSchema or list of Columns

The TableMixin class in input_mixin.py has been updated to support either a TableSchema object or a list of Columns for the table_schema attribute. This change allows for more flexibility in defining the table schema for input validation.

* feat: Update TableNodeComponent to generate backend columns from value

Refactor the TableNodeComponent to generate backend columns from the value when the columns prop is not provided. This change ensures that the component can handle dynamic column generation based on the value, improving flexibility and usability.

Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
Co-authored-by: Lucas Oliveira <lucas.edu.oli@hotmail.com>

* Refactor extractColumnsFromRows function to return only ColDef objects

The extractColumnsFromRows function in utils.ts has been refactored to return only ColDef objects instead of a combination of ColDef and ColGroupDef objects. This change simplifies the function's return type and improves consistency in the codebase.

Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
Co-authored-by: Lucas Oliveira <lucas.edu.oli@hotmail.com>

* [autofix.ci] apply automated fixes

* refactor: Generate backend columns from value in TableNodeComponent

Refactor the TableNodeComponent to generate backend columns from the value when the columns prop is not provided. This change ensures that the component can handle dynamic column generation based on the value, improving flexibility and usability.

* feat: Update TableNodeComponent to handle number and date properly

* fix bug that delete all rows on modal close

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
Co-authored-by: Lucas Oliveira <lucas.edu.oli@hotmail.com>
(cherry picked from commit 007c38a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request javascript Pull requests that update Javascript code lgtm This PR has been approved by a maintainer python Pull requests that update Python code size:XL This PR changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants