-
Notifications
You must be signed in to change notification settings - Fork 4.5k
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
base: main
Are you sure you want to change the base?
Conversation
…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.
… is not a component
@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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
CodSpeed Performance ReportMerging #5373 will degrade performances by 47.19%Comparing Summary
Benchmarks breakdown
|
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 theread_flows
function to useFlowHeader.model_validate
, addingmodel_validator
toFlowHeader
, and reformatting theFlowBase
andFlow
classes for better readability.Code readability improvements:
src/backend/base/langflow/api/v1/flows.py
: Reformatted imports to a single line for better readability.src/backend/base/langflow/services/database/models/flow/model.py
: Reformatted theFlowBase
andFlow
classes to improve readability by breaking long lines into multiple lines. [1] [2]Functionality improvements:
src/backend/base/langflow/api/v1/flows.py
: Updated theread_flows
function to useFlowHeader.model_validate
for validating flow headers, simplifying the code.src/backend/base/langflow/services/database/models/flow/model.py
: Addedmodel_validator
to theFlowHeader
class to ensuredata
is set toNone
ifis_component
isFalse
.Import enhancements:
src/backend/base/langflow/services/database/models/flow/model.py
: Addedmodel_validator
import frompydantic
to support the new validation inFlowHeader
.