@@ -51,14 +51,16 @@ def sample_sqlmesh_project():
5151
5252@dataclass
5353class SQLMeshTestContext :
54+ """A test context for running SQLMesh"""
55+
5456 db_path : str
5557 context_config : SQLMeshContextConfig
5658
5759 def create_controller (self , enable_debug_console : bool = False ):
5860 console = None
5961 if enable_debug_console :
6062 console = get_console ()
61- return DagsterSQLMeshController .setup (
63+ return DagsterSQLMeshController .setup_with_config (
6264 self .context_config , debug_console = console
6365 )
6466
@@ -96,17 +98,33 @@ def append_to_test_source(self, df: polars.DataFrame):
9698 """
9799 )
98100
99- def run (
101+ def plan_and_run (
100102 self ,
101103 * ,
102104 environment : str ,
103- apply : bool = False ,
104105 execution_time : t .Optional [TimeLike ] = None ,
105106 enable_debug_console : bool = False ,
106107 start : t .Optional [TimeLike ] = None ,
107108 end : t .Optional [TimeLike ] = None ,
108109 restate_models : t .Optional [t .List [str ]] = None ,
109110 ):
111+ """Runs plan and run on SQLMesh with the given configuration and record all of the generated events.
112+
113+ Args:
114+ environment (str): The environment to run SQLMesh in.
115+ execution_time (TimeLike, optional): The execution timestamp for the run. Defaults to None.
116+ enable_debug_console (bool, optional): Flag to enable debug console. Defaults to False.
117+ start (TimeLike, optional): Start time for the run interval. Defaults to None.
118+ end (TimeLike, optional): End time for the run interval. Defaults to None.
119+ restate_models (List[str], optional): List of models to restate. Defaults to None.
120+
121+ Returns:
122+ None: The function records events to a debug console but doesn't return anything.
123+
124+ Note:
125+ TimeLike can be any time-like object that SQLMesh accepts (datetime, str, etc.).
126+ The function creates a controller and recorder to capture all SQLMesh events during execution.
127+ """
110128 controller = self .create_controller (enable_debug_console = enable_debug_console )
111129 recorder = ConsoleRecorder ()
112130 # controller.add_event_handler(ConsoleRecorder())
@@ -126,7 +144,7 @@ def run(
126144 plan_options ["end" ] = end
127145 run_options ["end" ] = end
128146
129- for _context , event in controller .plan_and_run (
147+ for event in controller .plan_and_run (
130148 environment ,
131149 plan_options = plan_options ,
132150 run_options = run_options ,
0 commit comments