feat: add versioned research templates and alpha variants
This commit is contained in:
@@ -11,7 +11,7 @@ from ..backtests.contracts import Candidate, DraftInput, PreviewInput, Source
|
||||
from ..catalog.contracts import EntryOutput, InputPreparation
|
||||
from ..catalog.service import Catalog
|
||||
from ..models import CatalogEntry
|
||||
from .contracts import PLACEHOLDER
|
||||
from .expressions import analyze, expand
|
||||
|
||||
|
||||
class ResearchBuilder:
|
||||
@@ -94,9 +94,14 @@ class ResearchBuilder:
|
||||
raise HTTPException(422, "绑定字段不属于该输入快照,不能使用被排除或其他数据集字段")
|
||||
if saved["field_types"].get(binding.field_id) != binding.field_type:
|
||||
raise HTTPException(422, "字段类型声明与输入快照不一致,未知类型不能自动构建")
|
||||
expression = PLACEHOLDER.sub(
|
||||
lambda match: item.bindings[match.group(1)].field_id, item.expression_template
|
||||
)
|
||||
expression = expand(
|
||||
item.expression_template,
|
||||
{name: [binding.field_id] for name, binding in item.bindings.items()},
|
||||
limit=1,
|
||||
)["items"][0]["expression"]
|
||||
validation = analyze(expression, saved["field_types"])
|
||||
if validation["syntax"] or validation["types"]:
|
||||
raise HTTPException(422, ";".join(validation["syntax"] + validation["types"]))
|
||||
if len(expression) > 20000:
|
||||
raise HTTPException(422, "绑定后的表达式超过 20000 字符")
|
||||
candidates.append(
|
||||
|
||||
Reference in New Issue
Block a user