diffusers
5f9a5583 - Modular branch specific defaults (#14234)

Commit
6 days ago
Modular branch specific defaults (#14234) * init * Ensure branch-specific input defaults in ConditionalPipelineBlocks When sibling blocks of a ConditionalPipelineBlocks declare different defaults for the same input, combine_inputs now merges the default to None and records the per-block defaults in a new InputParam.defaults_by_block field, instead of silently promoting the non-None default. get_block_state falls back to the block's own declared default when the state value is None, so each branch resolves its own default when it actually runs and a branch using None as a "user didn't pass this" sentinel is no longer polluted by a sibling's default. Docstrings render conflicted defaults as e.g. "defaults to None or 189, depending on the workflow". Fixes #14132 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * Remove stale note about kwargs_type removal — the feature is staying Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * Clarify get_block_state default-resolution comment, drop getattr guards defaults_by_block is a dataclass field so it always exists; the checks are already inside the hasattr(param, "required") InputParam guard. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * Add example comments to combine_inputs and formatters, revert description block restructure Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * Comment the duplicate-input path in combine_inputs with the strength example Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * Rework branch-defaults tests to reuse the image block fixtures strength on img2img (0.3) / inpaint (0.9999), text2img as the None sentinel branch; drop the separate video fixtures. Also add examples to the combine_inputs accumulator comments. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * Simplify branch-defaults tests: drop t2i sentinel and resolved_strength output Assert on state.get("strength") directly (write-back records the branch's resolved value); cover None-vs-non-None merge with a direct combine_inputs test instead. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * Move combine_inputs tests to module level as test_combine_inputs_* block-a/block-b names, whole-list assertions, plus new coverage: first-occurrence-wins, disagreement records every block, direct nested prefixing. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * Tighten merge assertions: unique strength param + full InputParam equality Also group combine_inputs tests under TestConditionalBlocksInputs. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * Assert workflow in runtime tests, fold doc rendering into merge tests workflow is now a declared intermediate output on the fixture blocks so each runtime test shows which branch ran; the merge tests also assert the rendered docstring (nested case covers distinct-value dedupe). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * docs: declare defaults in InputParam, not inside __call__ Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * docs: side-by-side default example in modular.md, test reference in combine_inputs Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * Fix doc-builder formatting; regenerate cosmos3 use_system_prompt docstring The combine_inputs docstring example is now a fenced code block so doc-builder doesn't reflow it. The cosmos3 use_system_prompt docstring change reflects a real behavior fix this PR makes: the transfer/action branches declare default=True while the standard text branch declares default=None as a sentinel that falls back to the default_use_system_prompt config. Previously the merged default True leaked into state before branch selection, so the config fallback never fired for the standard workflow; each branch now resolves its own default and the config is honored again. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * Regenerate cosmos3 auto docstrings Mechanical output of utils/modular_auto_docstring.py for the cosmos files this PR touches; regeneration of the remaining stale pipelines moved to its own PR. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Author
Parents
Loading