Skip to content
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: Allow support for custom wildcard directory in sd-dynamic-prompts #229

Merged
merged 1 commit into from
Sep 2, 2023

Conversation

azmodii
Copy link
Contributor

@azmodii azmodii commented Sep 2, 2023

This PR introduces the following changes:

  • Allow support for custom wildcard directory in sd-dynamic-prompts

@azmodii
Copy link
Contributor Author

azmodii commented Sep 2, 2023

Note: I did not test stable-diffusion-webui-wildcards but it appears to use similar syntax:

        wildcards_dir = shared.cmd_opts.wildcards_dir or os.path.join(repo_dir, "wildcards")

I assume the following change would work, but am unable to test (as I don't personally use that extension).

    try:
        from modules.shared import opts, cmd_opts
    except ImportError:  # likely not in an a1111 context
        opts, cmd_opts = None

    wildcard_dir = getattr(opts, "wildcard_dir", None)
    wui_wildcards_dir = getattr(cmd_opts, "wildcards_dir", None)

   ...

    if wui_wildcards_dir is not None:
        wui_wildcards_dir = Path(wui_wildcards_dir)
        if wui_wildcards_dir.exists():
            found.append(wui_wildcards_dir)

@DominikDoom
Copy link
Owner

DominikDoom commented Sep 2, 2023

The normal webui argument won't need the getattr syntax since both cmd args and normal options settable through the UI have a default value, making it even simpler. Scratch that, since it's only available with the extension active it's still needed. But nonetheless very simple like you suggested. I'll add it alongside.

For whatever reason sd-dynamic-prompts doesn't expose the path setting in the UI, so that's why they need to use the function themselves (for providing a default value instead of throwing an error).

@DominikDoom DominikDoom merged commit d4cca00 into DominikDoom:main Sep 2, 2023
DominikDoom added a commit that referenced this pull request Sep 2, 2023
Refactor PR #229 a bit to share code with this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants