🐛 fix(flow.py): make flow field optional to allow creation of flows without a flow
🧪 test(test_database.py): add test case for creating flows without a flow
The flow field is now optional to allow creation of flows without a flow. This is useful when creating a flow that will be populated later. A test case was added to ensure that flows can be created without a flow.
This commit is contained in:
parent
1d33933d64
commit
2feeeb9ecd
2 changed files with 9 additions and 1 deletions
|
|
@ -12,11 +12,13 @@ from langflow.database.models.flow_style import FlowStyle, FlowStyleRead
|
|||
|
||||
class FlowBase(SQLModelSerializable):
|
||||
name: str = Field(index=True)
|
||||
flow: Dict = Field(default_factory=dict, sa_column=Column(JSON))
|
||||
flow: Optional[Dict] = Field(default_factory=dict, sa_column=Column(JSON))
|
||||
|
||||
@validator("flow")
|
||||
def validate_json(v):
|
||||
# dict_keys(['description', 'name', 'id', 'data'])
|
||||
if not v:
|
||||
return v
|
||||
if not isinstance(v, dict):
|
||||
raise ValueError("Flow must be a valid JSON")
|
||||
if "description" not in v.keys():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue