Commit Graph
68 Commits
Author SHA1 Message Date
Antonio Cordero Balcazar 39d6008f6f * Update version to 3.0.0 because of breaking changes for ComfyUI nodes.
* Refactor PromptPostProcessor class to use the same default values for options
* Add new nodes for the different option groups
2026-03-28 16:34:12 +01:00
Antonio Cordero Balcazar 1b781cb8b8 Allow variables in RHS of if expressions (#28)
# Pull Request

## Description

Allows variables in the RHS of expressions (e.g. `<ppp:if tagsSeen
contains tag>`) for more complex logic

## Type of change

Please delete options that are not relevant.

- [x] New feature (non-breaking change which adds functionality)
- [x] This change requires a documentation update

## How Has This Been Tested?

Added additional tests to the existing test suite.

## Checklist

- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [x] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [x] I have added tests that prove my fix is effective or that my
feature works
- [x] New and existing unit tests pass locally with my changes
- [x] Any dependent changes have been merged and published in downstream
modules
- [x] I have checked my code and corrected any misspellings
2026-03-28 16:24:42 +01:00
Antonio Cordero Balcazar 9cc10cd3f6 Merge branch 'main' into feature/var-vs-var-comparison 2026-03-28 16:09:08 +01:00
Antonio Cordero Balcazar 66422490eb support warn mode when var value cannot be converted to integer (#29)
# Pull Request

## Description

When a variable cannot be converted to integer (because it is undefined, or it is a string that cannot convert) then either warn or fail with proper error message (instead of current behavior which just sort of crashes with no useful information).

`<ppp:if undefinedVar gt 1>` or `{var=hello}<ppp:if var gt 1>` will no longer crash but will warn or stop.


## Type of change

Please delete options that are not relevant.

- [x] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [x] This change requires a documentation update

## How Has This Been Tested?

Additional unit tests added to the test suite.

## Checklist

- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [x] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [x] I have added tests that prove my fix is effective or that my feature works
- [x] New and existing unit tests pass locally with my changes
- [x] Any dependent changes have been merged and published in downstream modules
- [x] I have checked my code and corrected any misspellings
2026-03-28 15:51:29 +01:00
Brandon Wallace 1fdf71c76e fix: add warn_or_stop for undefined variables in __resolve_cond_value
Align RHS variable resolution with LHS behavior in __eval_basiccondition
so undefined system/user variables honor the on_warning setting.
2026-03-19 23:59:41 -05:00
Brandon Wallace f444ce0233 feat(ppp): add variable-vs-variable comparison support in conditions
Allow bare identifiers as the RHS of comparisons in ppp:if conditions
(e.g., `<ppp:if var1 contains var2>`). The grammar now accepts IDENTIFIER
as an alternative to SIMPLEVALUE, and __eval_basiccondition resolves
bare identifier values as variable references before comparison.
2026-03-19 23:41:06 -05:00
Brandon Wallace d7216d5f93 test: add failing tests for PPP variable-vs-variable comparison support
Add 4 TDD tests for the var-vs-var comparison feature (S1-TT2):
- test_cmd_if_var_vs_var_eq
- test_cmd_if_var_vs_var_ne
- test_cmd_if_var_vs_var_contains
- test_cmd_if_var_vs_var_not_contains

All tests fail because the grammar only accepts SIMPLEVALUE on RHS,
not IDENTIFIER. Implementation in S1-T2 will make them pass.
2026-03-19 23:41:06 -05:00
Brandon Wallace cad7a52ed0 fix: handle NaN/undefined variable in integer comparisons
Wrap int(var_value) in __eval_basiccondition() with try/except to
prevent ValueError crash when a variable is undefined, empty, or
contains non-numeric text. In warn mode the comparison evaluates to
false; in stop mode a PPPInterrupt is raised with a descriptive message.
2026-03-19 01:28:24 -05:00
Brandon Wallace 3409909b05 test: add failing tests for NaN/undefined variable integer comparison bug
Add 5 tests covering the ValueError crash in __eval_basiccondition()
when int() is called on empty/non-numeric variable values during
integer comparisons. Tests verify expected behavior for warn mode
(comparison evaluates to false) and stop mode (proper PPPInterrupt).
2026-03-19 01:07:13 -05:00
Antonio Cordero Balcazar fcad5e195c * Fix loading widget values in recent ComfyUI versions. v2.13.2 2026-03-15 22:19:47 +01:00
Antonio Cordero Balcazar 84d31ef072 * 🤦 v2.13.1 2025-12-09 20:12:47 +01:00
Antonio Cordero Balcazar e83c836200 * Wildcard identifiers cannot start with underscore.
* Fix cleaning constructs with only whitespace.
* Logging supports saving to file (used optionally in tests).
* Fix en refresh wildcards.
v2.13.0
2025-12-08 20:04:23 +01:00
Antonio Cordero Balcazar 4bd8a4d71a * implemented proper support for variable echoing inside wildcard names. 2025-12-08 13:11:43 +01:00
Antonio Cordero Balcazar b2e30a6b02 * Commands without content can be ended with "/>" instead of a full "<ppp:/command>". This applies to "stn i", "echo" and "ext" commands.
* Fix and better logging on evaluating final user variables.
* Variables can be used inside a wildcard identifier, as in __wildcard${x:1}__.
2025-12-08 11:53:13 +01:00
Antonio Cordero Balcazar 22c5c77904 * Choice commands: include wildcard choices allowing composability in wildcards.
* Detection of circular references in wildcards.
* Cache for extranetwork mappings.
2025-10-05 16:08:27 +02:00
Antonio Cordero Balcazar db43d409f8 * removed unnecessary processing of variables.
* error control when reading wildcard or mapping files, and second chance for files with incorrect encoding.
* fix processing inside extranetwork tag.
v2.12.1
2025-09-27 13:22:19 +02:00
Antonio Cordero Balcazar 8769c21ee5 * new "optional" parameter for choices/wildcard.
* added "$$" to end of parameters as first choice in a wildcard, to avoid confusion with a choice that could be considered parameters.
* additional fixes in the parser.
v2.12.0
2025-09-06 18:14:00 +02:00
Antonio Cordero Balcazar 54a20117ce * New extranetworks command to group the triggers with the extranetwork.
* Mapping of extranetworks through the new command. This allows you to use a "virtual" extranetwork that is converted to a real one depending on conditions, like the model kind/variant.
* Fixed a parsing bug with the if command.
* Some refactoring and additional checks.
2025-09-01 16:50:46 +02:00
Antonio Cordero Balcazar fe61e54f41 * Selection of prompt parser based on heuristics to improve parsing time on simpler cases.
* Improved timing logging.
* Refactor application support handling.
* Enhanced regex patterns in `ppp.py` for wildcard and choice detection to ensure proper escaping.
* Included icon source files.
2025-08-08 14:05:34 +02:00
Antonio Cordero Balcazar c03339a618 * Better processing of interruptions using an exception.
* New option on_warning to stop on invalid content.
* New option cleanup_extra_separators_include_eol to choose whether to also remove adjacent EOLs when removing extra separators or not. Default is not to do it. In previous versions it was forced.
* Refactoring of the cleanup method.
* Only simplify attention modifiers when the merge attention option is set.
* A1111: avoid logging about HR prompts and avoid saving them in extra metadata when not different.
* A1111: consider options and environment info in the caching of results.
* Some refactorings.
v2.11.0
2025-05-31 12:08:57 +02:00
Antonio Cordero Balcazar bfc47d0d53 * A1111: add prompts to metadata only if they change v2.10.0 2025-05-03 12:07:18 +02:00
Antonio Cordero Balcazar b837f38422 * if_wildcards option defaults now to stop.
* ComfyUI: new wildcards_input.
* removed json import since yaml can read them.
* more models detected in ComfyUI.
* ComfyUI: example workflow.
2025-05-03 12:07:18 +02:00
Antonio Cordero Balcazar 5e3c8cbc44 * ComfyUI: updates to the ComfyUI registry workflow.
* A1111: option to add original prompts to metadata.
* fixed some bogus import error shenanigans.
* warn when a model name detects multiple variants.
2025-04-11 17:50:26 +02:00
Antonio Cordero Balcazar a1958db81f * Improved conditions with bool operations.
* Enhance PromptPostProcessorComfyUINode to return variables.
* New PromptPostProcessorSelectVariableComfyUINode for selecting variables.
* Fixed detection of Flux Schnell in Forge.
* Improved documentation.
v2.9.0
2025-02-09 21:22:30 +01:00
Antonio Cordero Balcazar ce7b76f200 * refactoring
* additional tests
2025-01-25 16:47:43 +01:00
Antonio Cordero Balcazar e059a6d821 * add ifundefined modifier when setting variables.
* ComfyUI: better flux detection.
* Saving of UI settings and prompt/negative prompt to metadata.
2024-12-30 14:20:45 +01:00
Antonio Cordero Balcazar b06bcfa677 * Turned pony detection into detection of any kind of variant models based on filename. Added illustrious. Breaking change: the setting is different and changed pony substrings are not imported.
* Fixed and refactored some UI settings. Slight change in the generation of batched seeds.
* Detection of reforge.
* Small refactoring when getting choices.
2024-12-24 12:26:34 +01:00
Antonio Cordero Balcazar ee7ba94a30 * fix error in i2i detection.
* check for lingering special character sequences.
* small refactorings.
v2.8.1
2024-11-23 14:00:43 +01:00
Antonio Cordero Balcazar 3810320f6e * Simpler versioning
* Cache now takes wildcard definitions into consideration.
* ComfyUI: node is not cached if wildcard processing is active.
* Add a space with prefix and suffix if needed.
* Checks requirements before installing them.
v2.8.0
2024-10-27 16:05:55 +01:00
Antonio Cordero Balcazar c87c24924e * Support anonymous wildcards. 2024-10-19 16:05:21 +02:00
Antonio Cordero Balcazar e9092b877c * Improved wildcard definition support. 2024-10-19 12:45:48 +02:00
Antonio Cordero Balcazar a18e5e659c * Improved processing of wildcards and choices.
* Support for prefix and suffix in wildcard options and object format of the options in json/yaml files.
2024-10-13 12:57:25 +02:00
Antonio Cordero Balcazar 93f0102897 * Fix a bug with the variable echo command.
* Fix a bug obtaining random seed.
* Reading version number from pyproject file.
* A1111: Support for forcing the same seed/variation seed to all images in a batch.
* A1111: Support for unlinking the seed from the image seed and specifying one for the prompt.
* ComfyUI: Warning on use of invalid constructs. Related settings kept but default to False.
2024-10-11 18:13:57 +02:00
Antonio Cordero Balcazar 0b03e1773f * Added pyproject.toml to publish to ComfyUI registry.
* ComfyUI: optional modelname and model, and allowed sending a classname string instead of a model (#12)
v2.7.0
2024-10-05 11:56:26 +02:00
Antonio Cordero Balcazar 830bd4f785 Add Github Action for Publishing to Comfy Registry (#14)
This PR adds a Github Action (publish-node-action) that will publish an
updated version of your custom node to the
[registry](https://comfyregistry.org/) whenever the `pyproject.toml`
file changes.
2024-10-05 11:03:28 +02:00
snomiao b019c5604b chore(publish): Add Github Action for Publishing to Comfy Registry 2024-10-01 16:01:06 +00:00
Antonio Cordero Balcazar 42f7fc65cc * Fixed "dictionary changed size during iteration" error.
* Support for choice labels and their use for filtering wildcard choices.
* New system variable _modelclass and renaming of _sd->_model, _sdname->_modelname and _sdfullname->_modelfullname.
* Support for auraflow models with _is_auraflow.
* Option to "join attention" when sending to negative replaced and generalized as "merge attention".
* Improved processing of extranetwork tags.
v2.6.0
2024-09-29 22:51:39 +02:00
Antonio Cordero Balcazar 956a47adbc * Fix process wildcards setting. v2.5.2 2024-09-05 19:26:54 +02:00
Antonio Cordero Balcazar faa55704cc * Fix problem with seed property in ComfyUI, and allow a value of -1 to get a random one. v2.5.1 2024-09-04 22:22:01 +02:00
Antonio Cordero Balcazar 8a960df0aa * Add support for wildcards.
* Better debug log.
* Set commands support lazy evaluation and content addition.
* Unified in one tree and processing phase.
* Supports Flux.
* Fix evaluation of string variable as truthy.
* Show invalid wildcards.
* Better detection of installed UI.
* Improved cache of results.
* Works as a ComfyUI node.
* Debug setting changed to debug level.
* Fixes in variable use.
* Added timing reporting.
* Detection of more model types.
* Installation script for requirements.
* Extension metadata for A1111.
* Lark grammar in separate file and cached.
* Improved conditions for if command.
* Avoid repeats in the processing of prompts.
* Fix multiple loading of settings.
v2.5.0
2024-08-31 14:02:46 +02:00
Antonio Cordero Balcazar bad0d24fbe * New cleanup options: Remove additional extra separators, Use EOL instead of Space before BREAKs, Use EOL instead of Space before ANDs
* New format for commands
* New commands: "set", "echo" and "if/elif/else"
* Option to Remove extra network tags.
v2.4.0
2024-04-02 00:27:58 +02:00
Antonio Cordero Balcazar e8643680f9 * Support for prompt composition (AND) and cleaning around it.
* Option to cleanup around extra network tags.
* Improved cleanup.
* Some refactoring.
v2.3.0
2024-01-13 12:27:59 +01:00
Antonio Cordero Balcazar 3fc61c8dd1 * Improved documentation.
* New options to choose whether to process in img2img.
* Option to detect and do something with unwanted wildcards.
* Cleanup processing rewritten and separated in multiple options.
v2.2.0
2023-12-10 12:16:55 +01:00
Antonio Cordero Balcazar 77a74a8088 * Renamed the extension to "Prompt Post-Processor".
* Improved logging.
* Fix compatibility with A1111 hiresfix.
v2.1.5
2023-12-02 11:12:00 +01:00
Antonio Cordero Balcazar f59b3e51a5 Fix processing with A1111 hires fix. (#4)
# Pull Request

## Description

Fixes processing A1111 hr prompts.

Fixes #3 

## Type of change

- [x] Bug fix (non-breaking change which fixes an issue)

## How Has This Been Tested?

**Test Configuration**:

- A1111 v1.6
- SD.Next

## Checklist

- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [x] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged and published in downstream
modules
- [x] I have checked my code and corrected any misspellings
v2.1.4
2023-10-14 14:29:26 +02:00
Antonio Cordero Balcazar 496117e004 * Fix processing with A1111 hires fix.
* Remove version from title.
2023-10-14 13:51:09 +02:00
Antonio Cordero Balcazar 5a87292a18 * Fix processing of weights/steps with spaces around. v2.1.3 2023-08-24 18:22:40 +02:00
Antonio Cordero Balcazar a0d22862ca Fix weight calculation. v2.1.2 2023-08-20 23:49:09 +02:00
Antonio Cordero Balcazar 72d3866d65 Fix [Issue] 'Options' object has no attribute 'prompt_attention' #2 v2.1.1 2023-08-18 10:40:50 +02:00
Antonio Cordero Balcazar ac4a8e79f5 * Forgot to commit file. v2.1.0 2023-08-15 18:40:16 +02:00