mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
feat(config): add flag to indicate if args were parsed
This flag acts as a proxy for the `get_config()` function to determine if the full application is running. If it was, the config will set the root, do HF login, etc. If not (e.g. it's called by an external script), all that stuff will be skipped.
This commit is contained in:
parent
6af6673a4f
commit
ee3096f616
@ -436,6 +436,11 @@ def get_config() -> InvokeAIAppConfig:
|
||||
|
||||
args = InvokeAIArgs.args
|
||||
|
||||
# This flag serves as a proxy for whether the config was retrieved in the context of the full application or not.
|
||||
# If it is False, we should just return a default config and not set the root, log in to HF, etc.
|
||||
if not InvokeAIArgs.did_parse:
|
||||
return config
|
||||
|
||||
# CLI args trump environment variables
|
||||
if root := getattr(args, "root", None):
|
||||
config.set_root(Path(root))
|
||||
|
@ -34,9 +34,11 @@ class InvokeAIArgs:
|
||||
"""
|
||||
|
||||
args: Optional[Namespace] = None
|
||||
did_parse: bool = False
|
||||
|
||||
@staticmethod
|
||||
def parse_args() -> Optional[Namespace]:
|
||||
"""Parse CLI args and store the result."""
|
||||
InvokeAIArgs.args = _parser.parse_args()
|
||||
InvokeAIArgs.did_parse = True
|
||||
return InvokeAIArgs.args
|
||||
|
Loading…
x
Reference in New Issue
Block a user