-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
Conversation
@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 14.82%Comparing Summary
Benchmarks breakdown
|
040096f
to
de3f2c6
Compare
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
.