fix(setup): preserve advanced attribute and generalize starter project JSON (#8529)
* update the template * update to fix format issues
This commit is contained in:
parent
b8f72d929d
commit
ca23dc4c53
3 changed files with 193 additions and 232 deletions
|
|
@ -41,5 +41,5 @@ FIELD_FORMAT_ATTRIBUTES = [
|
|||
"advanced",
|
||||
"copy_field",
|
||||
]
|
||||
|
||||
SKIPPED_FIELD_ATTRIBUTES = ["advanced"]
|
||||
ORJSON_OPTIONS = orjson.OPT_INDENT_2 | orjson.OPT_SORT_KEYS | orjson.OPT_OMIT_MICROSECONDS
|
||||
|
|
|
|||
|
|
@ -26,7 +26,12 @@ from sqlalchemy.orm import selectinload
|
|||
from sqlmodel import col, select
|
||||
from sqlmodel.ext.asyncio.session import AsyncSession
|
||||
|
||||
from langflow.base.constants import FIELD_FORMAT_ATTRIBUTES, NODE_FORMAT_ATTRIBUTES, ORJSON_OPTIONS
|
||||
from langflow.base.constants import (
|
||||
FIELD_FORMAT_ATTRIBUTES,
|
||||
NODE_FORMAT_ATTRIBUTES,
|
||||
ORJSON_OPTIONS,
|
||||
SKIPPED_FIELD_ATTRIBUTES,
|
||||
)
|
||||
from langflow.initial_setup.constants import STARTER_FOLDER_DESCRIPTION, STARTER_FOLDER_NAME
|
||||
from langflow.services.auth.utils import create_super_user
|
||||
from langflow.services.database.models.flow.model import Flow, FlowCreate
|
||||
|
|
@ -130,7 +135,16 @@ def update_projects_components_with_latest_component_versions(project_data, all_
|
|||
continue
|
||||
# The idea here is to update some attributes of the field
|
||||
to_check_attributes = FIELD_FORMAT_ATTRIBUTES
|
||||
# Skip specific field attributes that should respect the starter project template values.
|
||||
# Currently we skip 'advanced' so that a field marked as advanced in the component code
|
||||
# will NOT overwrite the value specified in the starter project template. This preserves
|
||||
# the intended UX configuration of the starter projects.
|
||||
# SKIPPED_FIELD_ATTRIBUTES = {"advanced"}
|
||||
# Iterate through the attributes we want to potentially update
|
||||
for attr in to_check_attributes:
|
||||
# Respect the template value by not updating if the attribute is in the skipped set
|
||||
if attr in SKIPPED_FIELD_ATTRIBUTES:
|
||||
continue
|
||||
if (
|
||||
attr in field_dict
|
||||
and attr in node_data["template"].get(field_name)
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue