diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 772fdd7..c159045 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,3 +1,4 @@ +- 2.11.6 Disabling the extension if the correct version of dynamicprompts is not installed - 2.11.5 Added kwargs to FrozenPromptGenerator to fix one of the unexpected keyword argument 'seeds' errors - 2.11.4 Fixed type error in install.py for older versions of python - 2.11.3 Added check to ensure that the correct version of dynamicprompts is installed. If not it outputs instructions for manual installation. diff --git a/install.py b/install.py index 9049898..fe3d277 100644 --- a/install.py +++ b/install.py @@ -62,21 +62,34 @@ def check_versions() -> None: launch.run_pip(f"install {requirement}", f"{requirement}") -def check_correct_dynamicprompts_installed(): +def get_update_command() -> str: + requirements = get_requirements() + dynamicprompts_requirement = [ + r for r in requirements if r.startswith("dynamicprompts") + ][0] + return f"{sys.executable} -m pip install '{dynamicprompts_requirement}'" + + +def check_correct_dynamicprompts_installed() -> bool: try: import dynamicprompts dynamicprompts_requirement_version = get_dynamic_prompts_version() if dynamicprompts_requirement_version: - if dynamicprompts.__version__ != dynamicprompts_requirement_version: + if dynamicprompts.__version__ == dynamicprompts_requirement_version: + return True + else: + update_command = get_update_command() print( f"""*** WARNING: Something went wrong when updating to the latest dynamicprompts version. Please install it manually by running the following command: - {sys.executable} -m pip install dynamicprompts=={dynamicprompts_requirement_version} + {update_command} """, ) except Exception as e: logger.exception(e) + return False + if __name__ == "__main__": check_versions() diff --git a/sd_dynamic_prompts/__init__.py b/sd_dynamic_prompts/__init__.py index 0d4f030..517f12e 100644 --- a/sd_dynamic_prompts/__init__.py +++ b/sd_dynamic_prompts/__init__.py @@ -1 +1 @@ -__version__ = "2.11.5" +__version__ = "2.11.6" diff --git a/sd_dynamic_prompts/dynamic_prompting.py b/sd_dynamic_prompts/dynamic_prompting.py index d99ac6e..a105bf2 100644 --- a/sd_dynamic_prompts/dynamic_prompting.py +++ b/sd_dynamic_prompts/dynamic_prompting.py @@ -16,7 +16,7 @@ from modules import devices from modules.processing import fix_seed from modules.shared import opts -from install import check_correct_dynamicprompts_installed +from install import check_correct_dynamicprompts_installed, get_update_command from sd_dynamic_prompts import __version__, callbacks from sd_dynamic_prompts.element_ids import make_element_id from sd_dynamic_prompts.generator_builder import GeneratorBuilder @@ -108,6 +108,9 @@ class Script(scripts.Script): return scripts.AlwaysVisible def ui(self, is_img2img): + correct_lib_version = check_correct_dynamicprompts_installed() + update_command = get_update_command() + html_path = base_dir / "helptext.html" html = html_path.open().read() html = Template(html).substitute( @@ -123,11 +126,17 @@ class Script(scripts.Script): with gr.Accordion("Dynamic Prompts", open=False): is_enabled = gr.Checkbox( label="Dynamic Prompts enabled", - value=True, + value=correct_lib_version, + interactive=correct_lib_version, elem_id=make_element_id("dynamic-prompts-enabled"), ) - with gr.Group(): + if not correct_lib_version: + gr.HTML( + f"""Dynamic Prompts is not installed correctly. Please reinstall the dynamic prompts library by running the following command: {update_command}""", + ) + + with gr.Group(visible=correct_lib_version): is_combinatorial = gr.Checkbox( label="Combinatorial generation", value=False, diff --git a/style.css b/style.css index 3dbbad2..9fc93f7 100644 --- a/style.css +++ b/style.css @@ -47,10 +47,19 @@ color: #50a080; } +.sddp-warning { + color: red !important; +} + +.sddp-info { + color: rgb(121, 240, 10) !important; +} + .tree-leaf { position: relative; } .tree-leaf .tree-child-leaves { display: block; margin-left: 15px; } .tree-leaf .hidden { display: none; } .tree-leaf .tree-expando { background: #ddd; border-radius: 3px; cursor: pointer; float: left; height: 10px; line-height: 10px; position: relative; text-align: center; top: 5px; width: 10px; } + .tree-leaf .hidden { visibility: hidden; } .tree-leaf .tree-expando:hover { background: #aaa; } .tree-leaf .tree-leaf-text { cursor: pointer; float: left; margin-left: 5px; }