feat: run fixed research pipelines within durable budgets
This commit is contained in:
@@ -26,6 +26,7 @@ from .db import create_database
|
||||
from .jobs import AUTH_KINDS, Runner, create_job
|
||||
from .models import Account, Admin, BacktestConfig, Job, JobItem, LoginSession
|
||||
from .research.routes import router as research_router
|
||||
from .research.runtime import ResearchRuntime
|
||||
from .schemas import (
|
||||
AccountOutput,
|
||||
AlphaDetail,
|
||||
@@ -89,6 +90,7 @@ def create_app(settings=None, wq_client=None, ai_model_factory=None):
|
||||
engine, sessions = create_database(settings.database_url)
|
||||
runner = Runner(sessions, settings, client=wq_client)
|
||||
ai_runtime = AIRuntime(sessions, settings, runner, ai_model_factory)
|
||||
research_runtime = ResearchRuntime(sessions, ai_runtime, runner)
|
||||
|
||||
@asynccontextmanager
|
||||
async def lifespan(app):
|
||||
@@ -100,7 +102,10 @@ def create_app(settings=None, wq_client=None, ai_model_factory=None):
|
||||
await ai_runtime.start()
|
||||
if settings.enable_runner:
|
||||
await runner.start()
|
||||
await research_runtime.start()
|
||||
yield
|
||||
if settings.enable_runner:
|
||||
await research_runtime.stop()
|
||||
await ai_runtime.stop()
|
||||
if settings.enable_runner:
|
||||
await runner.stop()
|
||||
@@ -117,6 +122,7 @@ def create_app(settings=None, wq_client=None, ai_model_factory=None):
|
||||
app.state.engine, app.state.sessions, app.state.runner = engine, sessions, runner
|
||||
app.state.settings = settings
|
||||
app.state.ai = ai_runtime
|
||||
app.state.research = research_runtime
|
||||
login_failures = defaultdict(list)
|
||||
|
||||
@app.exception_handler(RequestValidationError)
|
||||
|
||||
Reference in New Issue
Block a user