-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(feat) Add Variable Support in Wildcard Paths #110
Conversation
Adds support for the issue described in [#614 of sd-dynamic-prompts](adieyal/sd-dynamic-prompts#614). The patch adds support for allowing variable refences within wildcard paths (e.g. `__cars/${car}/types__`). During the parsing phase, the variables will be retained in the path. During sampling, before resolving the wildcard, the variable is first resolved and replaced in the wildcard. The update should allow support for variable replacement, including providing default values using the normal `:default` syntax. Some examples: * `${gender=male}${section=upper} __clothes/${gender}/${section}__` * `__clothes/${gender:female}/${section:lower}__` * `__clothes/${gender:female}/${section:*}__` The test cases were updated to test a variety of scenarios.
Added a test case to test the cars scenario from a YAML file discussed in sd-dynamic-prompts #164. Added the example wildcard file, and a test case a utilitizes it.
Codecov ReportAttention:
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #110 +/- ##
==========================================
- Coverage 97.47% 97.43% -0.05%
==========================================
Files 77 77
Lines 3249 3352 +103
==========================================
+ Hits 3167 3266 +99
- Misses 82 86 +4 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, looks very neat!
Our linters are complaining about a bunch of things (I just landed #111 to make Ruff speak GitHub Actions annotations, to make them easier to see, so if you rebase to the current main
, you should see them here in GitHub too). You can install pre-commit
from pip
and run pre-commit run --all-files
to apply all relevant auto-fixes.
Beyond that, there's a couple of comments within the PR that I think would be neat to address now.
…riables_within_wilcards
@akx Thank you for the in-depth feedback. I'll be honest, this is my first time trying work with Python, so I'm unfamiliar with many of the idioms. I've mostly done Java, JavaScript, and TypeScript development, so I appreciate the Python guidance. I hope this last update resolved all of your concerns. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple more smaller comments this time around.
Great stuff for someone who hasn't touched Python much! 💪
@mwootendev Tests seem to be now failing 😩 |
This should be resolved in the latest push. In the case where the variable was |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you! 🎉
Adds support for the issue described in #614 of
sd-dynamic-prompts.
The patch adds support for allowing variable refences within wildcard
paths (e.g.
__cars/${car}/types__
). During the parsing phase, thevariables will be retained in the path. During sampling, before
resolving the wildcard, the variable is first resolved and replaced in
the wildcard.
The update should allow support for variable replacement, including
providing default values using the normal
:default
syntax.Some examples:
${gender=male}${section=upper} __clothes/${gender}/${section}__
__clothes/${gender:female}/${section:lower}__
__clothes/${gender:female}/${section:*}__
The test cases were updated to test a variety of scenarios.