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

fix: add data field to returned object on flowheader if flow is a component #5373

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

lucaseduoli
Copy link
Collaborator

This pull request includes several changes to improve the code readability and functionality in the langflow backend. The most important changes include reformatting imports, updating the read_flows function to use FlowHeader.model_validate, adding model_validator to FlowHeader, and reformatting the FlowBase and Flow classes for better readability.

Code readability improvements:

Functionality improvements:

Import enhancements:

ogabrielluiz and others added 5 commits December 19, 2024 08:50
…g in flows.py

- Consolidated import statements for better readability.
- Updated the response structure in the  function to utilize  for improved data validation and consistency.
…nd validation

- Updated FlowHeader model to include field descriptions for better clarity and documentation.
- Introduced a model validator to ensure data integrity before processing.
- Streamlined import statements for improved readability.
@lucaseduoli lucaseduoli self-assigned this Dec 19, 2024
@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Dec 19, 2024
@github-actions github-actions bot added the bug Something isn't working label Dec 19, 2024
Comment on lines 229 to 234
@model_validator(mode="before")
@classmethod
def validate_flow_header(cls, data: dict):
def validate_flow_header(cls, data: Flow):
if not data.is_component:
data.data = None
return data
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be a field_validator for data. I don't think this should should work because data is a dict.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I checked and data was returned as a Flow object. I considered it as a dict before and it didnt work

@github-actions github-actions bot added bug Something isn't working and removed bug Something isn't working labels Dec 19, 2024
@dosubot dosubot bot added size:XS This PR changes 0-9 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Dec 19, 2024
@github-actions github-actions bot added bug Something isn't working and removed bug Something isn't working labels Dec 19, 2024
Copy link

codspeed-hq bot commented Dec 19, 2024

CodSpeed Performance Report

Merging #5373 will degrade performances by 47.19%

Comparing fix/saved_components_disappearing (4a1410b) with main (e657e9d)

Summary

⚡ 1 improvements
❌ 1 regressions
✅ 13 untouched benchmarks

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

Benchmarks breakdown

Benchmark main fix/saved_components_disappearing Change
test_setup_llm_caching 1.2 ms 2.2 ms -47.19%
test_successful_run_with_output_type_any 248 ms 171.2 ms +44.87%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working size:XS This PR changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants