1212from pipelex .builder .builder_loop import BuilderLoop
1313from pipelex .builder .runner_code import generate_runner_code
1414from pipelex .cli .cli_factory import make_pipelex_for_cli
15+ from pipelex .cli .commands .build .structures_cmd import generate_structures_from_blueprints
1516from pipelex .cli .error_handlers import (
1617 ErrorContext ,
1718 handle_model_availability_error ,
@@ -153,28 +154,17 @@ def build_pipe_cmd(
153154 typer .Option ("--no-extras" , help = "Skip generating inputs.json and runner.py, only generate the PLX file" ),
154155 ] = False ,
155156 graph : Annotated [
156- bool ,
157+ bool | None ,
157158 typer .Option ("--graph/--no-graph" , help = "Generate execution graphs for both build process and built pipeline" ),
158- ] = True ,
159+ ] = None ,
159160 graph_full_data : Annotated [
160161 bool | None ,
161162 typer .Option (
162163 "--graph-full-data/--graph-no-data" ,
163164 help = "Override config: include or exclude full serialized data in graphs (requires --graph)" ,
164165 ),
165166 ] = None ,
166- library_dir : Annotated [
167- list [str ] | None ,
168- typer .Option (
169- "--library-dir" ,
170- "-L" ,
171- help = "Directory to search for pipe definitions (.plx files). Can be specified multiple times." ,
172- ),
173- ] = None ,
174167) -> None :
175- # Import here to avoid circular imports
176- from pipelex .cli .commands .build .structures_cmd import generate_structures_from_blueprints # noqa: PLC0415
177-
178168 make_pipelex_for_cli (context = ErrorContext .VALIDATION_BEFORE_BUILD_PIPE )
179169
180170 typer .secho ("🔥 Starting pipe builder... 🚀\n " , fg = typer .colors .GREEN )
@@ -304,8 +294,10 @@ async def run_pipeline():
304294 save_text_to_path (text = "" , path = init_path )
305295 typer .secho (f"✅ Package init file saved to: { init_path } " , fg = typer .colors .GREEN )
306296
307- # Generate graphs if --graph is enabled
308- if graph and builder_graph_spec :
297+ get_report_delegate ().generate_report ()
298+
299+ # Generate graphs if it was tracked during the build process
300+ if builder_graph_spec :
309301 typer .secho ("\n 📊 Generating graphs..." , fg = typer .colors .CYAN )
310302
311303 # Save builder pipeline graph in graphs/ subfolder
@@ -324,11 +316,13 @@ async def run_pipeline():
324316 try :
325317 built_pipe_execution_config = execution_config .with_graph_config_overrides (mock_inputs = True )
326318
319+ # pass empty library_dirs to avoid loading any libraries set at env var or instance level:
320+ # we don't want any other pipeline to interfere with the pipeline we just built
327321 built_pipe_output = await execute_pipeline (
328322 plx_content = plx_content ,
329323 pipe_run_mode = PipeRunMode .DRY ,
330324 execution_config = built_pipe_execution_config ,
331- library_dirs = library_dir ,
325+ library_dirs = [] ,
332326 )
333327 if built_pipe_output .graph_spec :
334328 pipeline_graph_dir = graphs_dir / "pipeline_graph"
@@ -341,7 +335,7 @@ async def run_pipeline():
341335 )
342336 if pipeline_graph_count > 0 :
343337 typer .secho (
344- f"📊 { pipeline_graph_count } pipeline graph outputs saved to: { pipeline_graph_dir } " ,
338+ f"📊 { pipeline_graph_count } built pipeline graph outputs saved to: { pipeline_graph_dir } " ,
345339 fg = typer .colors .CYAN ,
346340 )
347341 except Exception as graph_exc :
@@ -350,8 +344,6 @@ async def run_pipeline():
350344 end_time = time .time ()
351345 typer .secho (f"\n ✅ Pipeline built in { end_time - start_time :.2f} seconds\n " , fg = typer .colors .WHITE )
352346
353- get_report_delegate ().generate_report ()
354-
355347 # Show how to run the pipe
356348 console = get_console ()
357349 console .print ("\n 📋 [cyan]To run your pipeline:[/cyan]" )
0 commit comments