InvokeAI/invokeai/app/services
psychedelicious ce9aeeece3 feat: single app entrypoint with CLI arg parsing
We have two problems with how argparse is being utilized:
- We parse CLI args as the `api_app.py` file is read. This causes a problem pytest, which has an incompatible set of CLI args. Some tests import the FastAPI app, which triggers the config to parse CLI args, which receives the pytest args and fails.
- We've repeatedly had problems when something that uses the config is imported before the CLI args are parsed. When this happens, the root dir may not be set correctly, so we attempt to operate on incorrect paths.

To resolve these issues, we need to lift CLI arg parsing outside of the application code, but still let the application access the CLI args. We can create a external app entrypoint to do this.

- `InvokeAIArgs` is a simple helper class that parses CLI args and stores the result.
- `run_app()` is the new entrypoint. It first parses CLI args, then runs `invoke_api` to start the app.

The `invokeai-web` project script and `invokeai-web.py` dev script now call `run_app()` instead of `invoke_api()`.

The first time `get_config()` is called to get the singleton config object, it retrieves the args from `InvokeAIArgs`, sets the root dir if provided, then merges settings in from `invokeai.yaml`.

CLI arg parsing is now safely insulated from application code, but still accessible. And we don't need to worry about import order having an impact on anything, because by the time the app is running, we have already parsed CLI args. Whew!
2024-03-19 09:24:28 +11:00
..
board_image_records feat(db): add SQLiteMigrator to perform db migrations 2023-12-11 16:14:25 +11:00
board_images feat: refactor services folder/module structure 2023-10-12 12:15:06 -04:00
board_records feat(db): add SQLiteMigrator to perform db migrations 2023-12-11 16:14:25 +11:00
boards feat(api): chore: pydantic & fastapi upgrade 2023-10-17 14:59:25 +11:00
bulk_download feat(bulk_download): update response model, messages 2024-03-01 10:42:33 +11:00
config feat: single app entrypoint with CLI arg parsing 2024-03-19 09:24:28 +11:00
download feat(mm): support generic API tokens via regex/token pairs in config 2024-03-08 13:59:59 +11:00
events feat(events): add submodel_type to model load events 2024-03-14 18:29:55 +05:30
image_files feat(config): fix bad compress_level setting 2024-03-19 09:24:28 +11:00
image_records tidy(nodes): move all field things to fields.py 2024-03-01 10:42:33 +11:00
images tidy(nodes): move all field things to fields.py 2024-03-01 10:42:33 +11:00
invocation_cache fix(nodes): correctly serialize outputs 2024-03-06 08:14:12 -05:00
invocation_stats fix(nodes): fix typing on stats service context manager 2024-03-01 10:42:33 +11:00
item_storage revert(nodes): revert making tensors/conditioning use item storage 2024-03-01 10:42:33 +11:00
model_images docs(mm): update comment about model images 2024-03-08 12:26:35 +11:00
model_install fix(config): use new get_config across the app, use correct settings 2024-03-19 09:24:28 +11:00
model_load feat(events): add submodel_type to model load events 2024-03-14 18:29:55 +05:30
model_manager chore: ruff 2024-03-19 09:24:28 +11:00
model_records add ordering to search_by_attr that is used for model lists 2024-03-08 13:38:38 -06:00
names feat: refactor services folder/module structure 2023-10-12 12:15:06 -04:00
object_serializer feat(nodes): use TemporaryDirectory to handle ephemeral storage in ObjectSerializerDisk 2024-03-01 10:42:33 +11:00
session_processor Log a stack trace for invocation errors. 2024-03-04 23:01:56 +11:00
session_queue fix(config): use new get_config across the app, use correct settings 2024-03-19 09:24:28 +11:00
shared fix(config): use new get_config across the app, use correct settings 2024-03-19 09:24:28 +11:00
urls cleanup 2024-03-06 21:57:41 -05:00
workflow_records add project as category to back-end 2024-01-24 10:59:04 +11:00
__init__.py all files migrated; tweaks needed 2023-03-03 00:02:15 -05:00
invocation_services.py tidy(mm): ModelImages service 2024-03-06 21:57:41 -05:00
invoker.py refactor(nodes): merge processors 2024-03-01 10:42:33 +11:00