From 3039b08eb16777431946ed9ae4a63c5466336bff Mon Sep 17 00:00:00 2001 From: comfyanonymous Date: Wed, 13 Sep 2023 11:38:20 -0400 Subject: [PATCH] Only parse command line args when main.py is called. --- comfy/cli_args.py | 7 +++++-- comfy/options.py | 6 ++++++ main.py | 3 +++ 3 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 comfy/options.py diff --git a/comfy/cli_args.py b/comfy/cli_args.py index fda24543..ffae81c4 100644 --- a/comfy/cli_args.py +++ b/comfy/cli_args.py @@ -1,6 +1,6 @@ import argparse import enum - +import comfy.options class EnumAction(argparse.Action): """ @@ -94,7 +94,10 @@ parser.add_argument("--windows-standalone-build", action="store_true", help="Win parser.add_argument("--disable-metadata", action="store_true", help="Disable saving prompt metadata in files.") -args = parser.parse_args() +if comfy.options.args_parsing: + args = parser.parse_args() +else: + args = parser.parse_args([]) if args.windows_standalone_build: args.auto_launch = True diff --git a/comfy/options.py b/comfy/options.py new file mode 100644 index 00000000..f7f8af41 --- /dev/null +++ b/comfy/options.py @@ -0,0 +1,6 @@ + +args_parsing = False + +def enable_args_parsing(enable=True): + global args_parsing + args_parsing = enable diff --git a/main.py b/main.py index 9f0f8045..7c5eaee0 100644 --- a/main.py +++ b/main.py @@ -1,3 +1,6 @@ +import comfy.options +comfy.options.enable_args_parsing() + import os import importlib.util import folder_paths