11from __future__ import annotations
22
3- import asyncio
4- import functools
53import typing as t
64
75from fastapi import APIRouter , Body , Depends , HTTPException , Request , Response , status
1210from sqlmesh .utils .errors import PlanError
1311from web .server import models
1412from web .server .settings import get_loaded_context
15- from web .server .utils import run_in_executor
1613
1714router = APIRouter ()
1815
@@ -39,23 +36,20 @@ async def run_plan(
3936
4037 context .refresh ()
4138
42- plan_func = functools .partial (
43- context .plan ,
44- environment = environment ,
45- no_prompts = True ,
46- start = plan_dates .start if plan_dates else None ,
47- end = plan_dates .end if plan_dates else None ,
48- create_from = plan_options .create_from ,
49- skip_tests = plan_options .skip_tests ,
50- restate_models = plan_options .restate_models ,
51- no_gaps = plan_options .no_gaps ,
52- skip_backfill = plan_options .skip_backfill ,
53- forward_only = plan_options .forward_only ,
54- no_auto_categorization = plan_options .no_auto_categorization ,
55- )
56- request .app .state .task = asyncio .create_task (run_in_executor (plan_func ))
5739 try :
58- plan = await request .app .state .task
40+ plan = context .plan (
41+ environment = environment ,
42+ no_prompts = True ,
43+ start = plan_dates .start if plan_dates else None ,
44+ end = plan_dates .end if plan_dates else None ,
45+ create_from = plan_options .create_from ,
46+ skip_tests = plan_options .skip_tests ,
47+ restate_models = plan_options .restate_models ,
48+ no_gaps = plan_options .no_gaps ,
49+ skip_backfill = plan_options .skip_backfill ,
50+ forward_only = plan_options .forward_only ,
51+ no_auto_categorization = plan_options .no_auto_categorization ,
52+ )
5953 except PlanError as e :
6054 raise HTTPException (
6155 status_code = HTTP_422_UNPROCESSABLE_ENTITY ,
0 commit comments