Files
worldquant-alpha-system/backend/app/research/features.py
T

21 lines
694 B
Python
Raw Normal View History

"""Feature plans remain versioned inputs to the shared template research path."""
from fastapi import HTTPException
from .assets import Assets
from .workspace_contracts import AssetWrite
class Features:
def __init__(self, db):
self.assets = Assets(db)
async def to_template(self, asset_id, version):
feature = await self.assets.get(asset_id, version, "feature")
if not feature["content"].get("template"):
raise HTTPException(422, "特征方案尚未定义输出模板")
return await self.assets.save(
AssetWrite(kind="template", content=feature["content"]["template"]),
provenance={"feature": feature},
)