diff --git a/README.md b/README.md index 53c6d9677..aaa5185e1 100644 --- a/README.md +++ b/README.md @@ -181,7 +181,7 @@ On macOS, install exactly Python 3.11 using `brew`, which you can download from 5. Then, run the following command to install `comfyui` into your current environment. This will correctly select the version of pytorch that matches the GPU on your machine (NVIDIA or CPU on Windows, NVIDIA AMD or CPU on Linux): ```shell - pip install -e .[test] + pip install -e .[dev] ``` 6. To run the web server: ```shell diff --git a/comfy/cli_args.py b/comfy/cli_args.py index 5560f0511..ca4ffcd3a 100644 --- a/comfy/cli_args.py +++ b/comfy/cli_args.py @@ -1,4 +1,4 @@ -import argparse +import configargparse as argparse import enum from . import options @@ -31,13 +31,14 @@ class EnumAction(argparse.Action): setattr(namespace, self.dest, value) -parser = argparse.ArgumentParser() +parser = argparse.ArgumentParser(default_config_files=['config.yaml', 'config.json'], auto_env_var_prefix='COMFYUI_') -parser.add_argument("--listen", type=str, default="127.0.0.1", metavar="IP", nargs="?", const="0.0.0.0", help="Specify the IP address to listen on (default: 127.0.0.1). If --listen is provided without an argument, it defaults to 0.0.0.0. (listens on all)") +parser.add_argument('-c', '--config', required=False, default=None, is_config_file=True, help='Specify additional configuration files.') +parser.add_argument('-w', "--cwd", type=str, default=None, help="Specify the working directory. If not set, this is the current working directory. models/, input/, output/ and other directories will be located here by default.") +parser.add_argument('-H', "--listen", type=str, default="127.0.0.1", metavar="IP", nargs="?", const="0.0.0.0", help="Specify the IP address to listen on (default: 127.0.0.1). If --listen is provided without an argument, it defaults to 0.0.0.0. (listens on all)") parser.add_argument("--port", type=int, default=8188, help="Set the listen port.") parser.add_argument("--enable-cors-header", type=str, default=None, metavar="ORIGIN", nargs="?", const="*", help="Enable CORS (Cross-Origin Resource Sharing) with optional origin or allow all with default '*'.") parser.add_argument("--max-upload-size", type=float, default=100, help="Set the maximum upload size in MB.") - parser.add_argument("--extra-model-paths-config", type=str, default=None, metavar="PATH", nargs='+', action='append', help="Load one or more extra_model_paths.yaml files.") parser.add_argument("--output-directory", type=str, default=None, help="Set the ComfyUI output directory.") parser.add_argument("--temp-directory", type=str, default=None, help="Set the ComfyUI temp directory (default is in the ComfyUI directory).") diff --git a/comfy/cmd/folder_paths.py b/comfy/cmd/folder_paths.py index e854b5d08..b53b4f5c2 100644 --- a/comfy/cmd/folder_paths.py +++ b/comfy/cmd/folder_paths.py @@ -2,12 +2,21 @@ import os import sys import time +from ..cli_args import args + supported_pt_extensions = set(['.ckpt', '.pt', '.bin', '.pth', '.safetensors']) folder_names_and_paths = {} if 'main.py' in sys.argv: base_path = os.path.realpath(os.path.join(os.path.dirname(os.path.realpath(__file__)), "../..")) +elif args.cwd: + if not os.path.exists(args.cwd): + try: + os.makedirs(args.cwd) + except: + print("Failed to create custom working directory") + base_path = args.cwd else: base_path = os.getcwd() models_dir = os.path.join(base_path, "models") @@ -21,24 +30,18 @@ folder_names_and_paths["style_models"] = ([os.path.join(models_dir, "style_model folder_names_and_paths["embeddings"] = ([os.path.join(models_dir, "embeddings")], supported_pt_extensions) folder_names_and_paths["diffusers"] = ([os.path.join(models_dir, "diffusers")], ["folder"]) folder_names_and_paths["vae_approx"] = ([os.path.join(models_dir, "vae_approx")], supported_pt_extensions) - folder_names_and_paths["controlnet"] = ([os.path.join(models_dir, "controlnet"), os.path.join(models_dir, "t2i_adapter")], supported_pt_extensions) folder_names_and_paths["gligen"] = ([os.path.join(models_dir, "gligen")], supported_pt_extensions) - folder_names_and_paths["upscale_models"] = ([os.path.join(models_dir, "upscale_models")], supported_pt_extensions) - folder_names_and_paths["custom_nodes"] = ([os.path.join(base_path, "custom_nodes")], []) - folder_names_and_paths["hypernetworks"] = ([os.path.join(models_dir, "hypernetworks")], supported_pt_extensions) - folder_names_and_paths["photomaker"] = ([os.path.join(models_dir, "photomaker")], supported_pt_extensions) - folder_names_and_paths["classifiers"] = ([os.path.join(models_dir, "classifiers")], {""}) output_directory = os.path.join(base_path, "output") temp_directory = os.path.join(base_path, "temp") input_directory = os.path.join(base_path, "input") -user_directory = os.path.join(os.path.dirname(os.path.realpath(__file__)), "user") +user_directory = os.path.join(base_path, "user") filename_list_cache = {} @@ -250,7 +253,7 @@ def get_save_image_path(filename_prefix, output_dir, image_width=0, image_height err = "**** ERROR: Saving image outside the output folder is not allowed." + \ "\n full_output_folder: " + os.path.abspath(full_output_folder) + \ "\n output_dir: " + output_dir + \ - "\n commonpath: " + os.path.commonpath((output_dir, os.path.abspath(full_output_folder))) + "\n commonpath: " + os.path.commonpath((output_dir, os.path.abspath(full_output_folder))) print(err) raise Exception(err) diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 000000000..51e6ffc1d --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,3 @@ +pytest +websocket-client==1.6.1 +PyInstaller \ No newline at end of file diff --git a/requirements-tests.txt b/requirements-tests.txt deleted file mode 100644 index dce71e32c..000000000 --- a/requirements-tests.txt +++ /dev/null @@ -1,2 +0,0 @@ -pytest -websocket-client==1.6.1 \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index df6d90d44..a1d9d7a6b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -28,4 +28,5 @@ scipy tqdm protobuf==3.20.3 psutil -mypy>=1.6.0 \ No newline at end of file +mypy>=1.6.0 +ConfigArgParse \ No newline at end of file diff --git a/setup.py b/setup.py index 95843ba21..0b47be320 100644 --- a/setup.py +++ b/setup.py @@ -151,7 +151,7 @@ def dependencies() -> List[str]: package_data = ['sd1_tokenizer/*', '**/*.json', '**/*.yaml'] if not is_editable: package_data.append('comfy/web/**/*') -test_dependencies = open(os.path.join(os.path.dirname(__file__), "requirements-tests.txt")).readlines() +dev_dependencies = open(os.path.join(os.path.dirname(__file__), "requirements-dev.txt")).readlines() setup( name=package_name, description="", @@ -173,8 +173,8 @@ setup( package_data={ 'comfy': package_data }, - tests_require=test_dependencies, + tests_require=dev_dependencies, extras_require={ - 'test': test_dependencies + 'dev': dev_dependencies }, ) diff --git a/tests/README.md b/tests/README.md index 6a71005ee..ca3abad88 100644 --- a/tests/README.md +++ b/tests/README.md @@ -4,7 +4,7 @@ Additional requirements for running tests: ``` -pip install .[test] +pip install .[dev] ``` Run inference tests: ```