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

Allow extension to be installed in any directory #56

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 7 additions & 15 deletions nodes/sampler.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from __future__ import annotations

import logging
import os
from abc import ABC, abstractproperty
from collections.abc import Iterable
from pathlib import Path

from dynamicprompts.sampling_context import SamplingContext
from dynamicprompts.wildcards import WildcardManager
Expand Down Expand Up @@ -37,24 +37,16 @@ def __init__(self, *args, **kwargs):
self._wildcard_manager = WildcardManager(path=wildcards_folder)
self._current_prompt = None

def _find_wildcards_folder(self) -> Path | None:
def _find_wildcards_folder(self):
"""
Find the wildcards folder.
First look in the comfy_dynamicprompts folder, then in the custom_nodes folder, then in the Comfui base folder.
"""
from folder_paths import base_path, folder_names_and_paths
install_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
wildcard_path = os.path.join(install_dir, "wildcards")

wildcard_path = Path(base_path) / "wildcards"

if wildcard_path.exists():
return wildcard_path

extension_path = (
Path(folder_names_and_paths["custom_nodes"][0][0])
/ "comfyui-dynamicprompts"
)
wildcard_path = extension_path / "wildcards"
wildcard_path.mkdir(parents=True, exist_ok=True)
if not os.path.exists(wildcard_path):
wildcard_path = os.path.join(wildcard_path)
os.mkdir(wildcard_path)

return wildcard_path

Expand Down