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

tests: Enhance component testing and error handling with dynamic retrieval #4526

Merged
merged 23 commits into from
Nov 12, 2024

Conversation

ogabrielluiz
Copy link
Contributor

@ogabrielluiz ogabrielluiz commented Nov 12, 2024

This pull request includes several changes aimed at improving the robustness and functionality of the codebase by adding checks for the existence of attributes before accessing them, and introducing a new PlaceholderGraph class.
The fixes in the PR are needed for the tests to pass. The most important changes are listed below:

Attribute Existence Checks

  • Modified various methods to check for the existence of the graph attribute before accessing its properties, improving error handling and robustness. (src/backend/base/langflow/base/io/chat.py, src/backend/base/langflow/base/tools/flow_tool.py, src/backend/base/langflow/components/deactivated/message.py, src/backend/base/langflow/components/deactivated/store_message.py, src/backend/base/langflow/components/outputs/chat.py) [1] [2] [3] [4] [5]

New PlaceholderGraph Class

  • Introduced a new PlaceholderGraph class to provide default values for graph attributes, preventing potential attribute errors. (src/backend/base/langflow/custom/custom_component/component.py) [1] [2]

JSON Configuration Updates

  • Updated the Agent Flow.json configuration file to include additional information and ensure consistency with the new attribute checks. (src/backend/base/langflow/initial_setup/starter_projects/Agent Flow.json) [1] [2]

@dosubot dosubot bot added the size:XL This PR changes 500-999 lines, ignoring generated files. label Nov 12, 2024
Copy link

codspeed-hq bot commented Nov 12, 2024

CodSpeed Performance Report

Merging #4526 will degrade performances by 15.11%

Comparing general-component-tests (a57f4a8) with main (ab71e2f)

Summary

⚡ 3 improvements
❌ 1 regressions
✅ 11 untouched benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark main general-component-tests Change
test_invalid_run_with_input_type_chat 14 ms 16.4 ms -15.11%
test_successful_run_with_input_type_any 456.4 ms 377.9 ms +20.79%
test_successful_run_with_output_type_any 456.3 ms 347.7 ms +31.23%
test_successful_run_with_output_type_debug 454.6 ms 397.9 ms +14.25%

…andling

- Introduced `VersionComponentMapping` TypedDict for structured version mapping.
- Updated `FILE_NAMES_MAPPING` to use a list of `VersionComponentMapping`.
- Added comprehensive error messages for missing or invalid mappings in `test_all_versions_have_a_file_name_defined`.
- Improved `test_component_versions` with detailed exception handling and error reporting.
- Ensured `component_class` is defined before running tests.
…structure and readability in test_prompt_component.py
Implement comprehensive tests for both ChatInput and TextInputComponent to ensure proper functionality, including message responses and handling of various input scenarios. This enhances reliability and aids in future development.
Implement comprehensive tests for ChatOutput and TextOutputComponent, validating message responses, source properties, and behavior with various input types to ensure reliability and consistency across output components.
…elds

- Added missing `info` fields to various input components to provide better context and descriptions.
- Improved code readability by ensuring consistent formatting and structure across JSON files.
- Updated `message_response` method to handle cases where `graph` attribute might not be present.
- Enhanced `build_vectorize_options` method to set `authentication` and `parameters` to `None` if no values are provided.
- Refined `AgentComponent` to include `info` for `agent_llm` and other fields, improving clarity on their purpose.
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:XL This PR changes 500-999 lines, ignoring generated files. labels Nov 12, 2024
Copy link
Contributor

@anovazzi1 anovazzi1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Nov 12, 2024
Copy link
Collaborator

@phact phact left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love this

@ogabrielluiz ogabrielluiz enabled auto-merge (squash) November 12, 2024 17:59
@ogabrielluiz ogabrielluiz merged commit 0dc6cce into main Nov 12, 2024
29 checks passed
@ogabrielluiz ogabrielluiz deleted the general-component-tests branch November 12, 2024 18:50
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 size:L This PR changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants