@@ -149,8 +149,12 @@ class Context(BaseContext):
149149 physical_schema: The schema used to store physical materialized tables.
150150 snapshot_ttl: Duration before unpromoted snapshots are removed.
151151 path: The directory containing SQLMesh files.
152+ backfill_concurrent_tasks: The number of concurrent tasks used for model backfilling during
153+ plan application. Default: 1.
152154 ddl_concurrent_task: The number of concurrent tasks used for DDL
153155 operations (table / view creation, deletion, etc). Default: 1.
156+ evaluation_concurrent_tasks: The number of concurrent tasks used for model evaluation when
157+ running with the built-in scheduler. Default: 1.
154158 config: A Config object or the name of a Config object in config.py.
155159 test_config: A Config object or name of a Config object in config.py to use for testing only
156160 load: Whether or not to automatically load all models and macros (default True).
@@ -166,7 +170,9 @@ def __init__(
166170 physical_schema : str = "" ,
167171 snapshot_ttl : str = "" ,
168172 path : str = "" ,
173+ backfill_concurrent_tasks : t .Optional [int ] = None ,
169174 ddl_concurrent_tasks : t .Optional [int ] = None ,
175+ evaluation_concurrent_tasks : t .Optional [int ] = None ,
170176 config : t .Optional [t .Union [Config , str ]] = None ,
171177 test_config : t .Optional [t .Union [Config , str ]] = None ,
172178 load : bool = True ,
@@ -200,20 +206,33 @@ def __init__(
200206 self .macros = UniqueKeyDict ("macros" )
201207 self .dag : DAG [str ] = DAG ()
202208
209+ self .backfill_concurrent_tasks = (
210+ backfill_concurrent_tasks or self .config .backfill_concurrent_tasks
211+ )
203212 self .ddl_concurrent_tasks = (
204213 ddl_concurrent_tasks or self .config .ddl_concurrent_tasks
205214 )
215+ self .evaluation_concurrent_tasks = (
216+ evaluation_concurrent_tasks or self .config .evaluation_concurrent_tasks
217+ )
218+ self .is_multithreaded = (
219+ max (
220+ self .backfill_concurrent_tasks ,
221+ self .ddl_concurrent_tasks ,
222+ self .evaluation_concurrent_tasks ,
223+ )
224+ > 1
225+ )
206226
207227 self ._engine_adapter = engine_adapter or EngineAdapter (
208228 self .config .engine_connection_factory ,
209229 self .config .engine_dialect ,
210- multithreaded = self .ddl_concurrent_tasks > 1 ,
230+ multithreaded = self .is_multithreaded ,
211231 )
212232 self .test_engine_adapter = (
213233 EngineAdapter (
214234 self .test_config .engine_connection_factory ,
215235 self .test_config .engine_dialect ,
216- multithreaded = self .test_config .ddl_concurrent_tasks > 1 ,
217236 )
218237 if self .test_config
219238 else None
@@ -270,6 +289,7 @@ def scheduler(self) -> Scheduler:
270289 self .snapshots ,
271290 self .snapshot_evaluator ,
272291 self .state_sync ,
292+ max_workers = self .evaluation_concurrent_tasks ,
273293 console = self .console ,
274294 )
275295
0 commit comments