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

refactor: add getters and setters for inputs and outputs #3119

Merged
merged 61 commits into from
Aug 1, 2024

Conversation

ogabrielluiz
Copy link
Contributor

The Component and Vertex classes have been refactored to include new methods for easier access to input and output values.

In the Component class, the get_input and get_output methods have been added. These methods allow for the retrieval of input and output values by name, improving the usability and readability of the codebase. Additionally, the set_output_value method has been added to facilitate the modification of output values.

In the Vertex class, corresponding get_input and get_output methods have been added. These methods retrieve the input and output values from the associated Component instance.

These changes enhance the flexibility and maintainability of the codebase by providing a more intuitive way to access and modify input and output values.

ogabrielluiz and others added 24 commits July 31, 2024 13:32
…erscore

Refactored the `Component` class in `component.py` to handle inputs and outputs. Added a new method `map_outputs` to map a list of outputs to the component. Also updated the `__init__` method to properly initialize the inputs, outputs, and other attributes. This change improves the flexibility and extensibility of the `Component` class.

Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
Refactored the `instantiate_class` function in `loading.py` to update the initialization parameters for the `CustomComponent` class. Changed the parameter names from `user_id`, `parameters`, `vertex`, and `tracing_service` to `_user_id`, `_parameters`, `_vertex`, and `_tracing_service` respectively. This change ensures consistency and improves code readability.

Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
Updated the `BaseComponent` class in `base_component.py` to accept a `UUID` type for the `_user_id` attribute. This change improves the type safety and ensures consistency with the usage of `_user_id` throughout the codebase.
The `nanoid` import in `component.py` has been updated to include a type annotation `# type: ignore`. This change ensures that the type checker ignores any errors related to the `nanoid` import.
…o functions to ensure compatibility with function signatures
…turn type to improve type checking and validation in custom components
…for consistency and clarity

perf(utils.py): optimize code by reusing cc_instance instead of calling get_component_instance multiple times
…p_name' for clarity and consistency in codebase
The `schema.py` file in the `src/backend/base/langflow/graph/edge` directory has been updated to include the `TargetHandle` and `SourceHandle` models. These models define the structure and attributes of the target and source handles used in the edge data. This change improves the clarity and consistency of the codebase.
The `BaseInputMixin` class in `input_mixin.py` has been updated to handle invalid field types gracefully. Instead of raising an exception, it now returns `FieldTypes.OTHER` for any invalid field type. This change improves the robustness and reliability of the codebase.
The `file_types` field in the `FileMixin` class of `input_mixin.py` has been updated to use the `alias` parameter instead of `serialization_alias`. This change ensures consistency and improves the clarity of the codebase.
…sses to use SerializableFieldTypes enum for better type safety and clarity
…ulating by name

The `model_config` attribute in the `BaseInputMixin` class of `input_mixin.py` has been updated to include the `populate_by_name=True` parameter. This change allows the model configuration to be populated by name, improving the flexibility and usability of the codebase.
…cept Any type

The _extract_return_type method in CustomComponent has been updated to accept the Any type as the return_type parameter. This change improves the flexibility and compatibility of the method, allowing it to handle a wider range of return types.
…access to input and output values

The `Component` class in `component.py` has been updated to include the `get_input` and `get_output` methods. These methods allow for easier retrieval of input and output values by name, improving the usability and readability of the codebase.
…ion of output values

The `Component` class in `component.py` has been updated to include the `set_output_value` method. This method allows for easier modification of output values by name, improving the usability and flexibility of the codebase.
@ogabrielluiz ogabrielluiz requested a review from italojohnny July 31, 2024 17:33
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. enhancement New feature or request labels Jul 31, 2024
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 does not satisfy any enabled whitelist criteria. Pull request will be validated.

Validation Report

Validation Active Result
All commits in this pull request has valid messages
Pull request does not introduce too many changes
Pull request has a valid title
Pull request has mentioned issues
Pull request has valid branch name
Pull request should have a non-empty body

Result

Pull request satisfies all enabled pull request rules.

Last Modified at 31 Jul 24 17:43 UTC

@github-actions github-actions bot added refactor Maintenance tasks and housekeeping and removed enhancement New feature or request labels Jul 31, 2024
Improve the validation for the value type in the IntInput class. The updated code ensures that the value is of a valid type (int or float) and converts float values to integers. This change enhances the accuracy and reliability of the input validation process.
Improve the validation for the value type in the FloatInput class. The updated code ensures that the value is of a valid type (int or float) and converts integer values to floats. This change enhances the accuracy and reliability of the input validation process.
…or input classes

Add comprehensive unit tests for the input classes in the test_inputs.py file. This change ensures that the input classes are thoroughly tested and functioning correctly. The unit tests cover various scenarios and edge cases to validate the behavior of the input classes. This improvement enhances the reliability and stability of the codebase.
…est_inputs.py

Cleaned up unnecessary test cases for invalid input types
Base automatically changed from refactor/updateinputtypes to main August 1, 2024 18:29
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Aug 1, 2024
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Aug 1, 2024
@github-actions github-actions bot added refactor Maintenance tasks and housekeeping and removed refactor Maintenance tasks and housekeeping labels Aug 1, 2024
@ogabrielluiz ogabrielluiz enabled auto-merge (squash) August 1, 2024 18:30
@ogabrielluiz ogabrielluiz merged commit 377f179 into main Aug 1, 2024
49 checks passed
@ogabrielluiz ogabrielluiz deleted the feat/addgetters branch August 1, 2024 19:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm This PR has been approved by a maintainer refactor Maintenance tasks and housekeeping size:M This PR changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants