From 0d544545dc74dcfa04156d41150ae35b36dee9d0 Mon Sep 17 00:00:00 2001 From: Taksh Date: Fri, 23 Oct 2026 09:24:38 +0530 Subject: [PATCH] warn that pipeline.blocks is a copy in-place edits of that copy do not change the pipeline. --- src/diffusers/modular_pipelines/modular_pipeline.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/diffusers/modular_pipelines/modular_pipeline.py b/src/diffusers/modular_pipelines/modular_pipeline.py index 28e485eddbc1..836c20517c34 100644 --- a/src/diffusers/modular_pipelines/modular_pipeline.py +++ b/src/diffusers/modular_pipelines/modular_pipeline.py @@ -2182,6 +2182,14 @@ def blocks(self) -> ModularPipelineBlocks: Returns: - A copy of the pipeline blocks """ + # In-place edits of this copy (for example `pipe.blocks.sub_blocks.insert(...)`) do not + # change the pipeline. Say so once, and point at the supported path. + if not getattr(ModularPipeline.blocks.fget, "_warned_about_copy", False): + logger.warning( + "`pipeline.blocks` is a copy, so in-place edits do not change this pipeline. " + "Edit the blocks, then create a new pipeline with `blocks.init_pipeline()`." + ) + ModularPipeline.blocks.fget._warned_about_copy = True return deepcopy(self._blocks) def register_components(self, **kwargs):