-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
refactor: simplified config system #5920
Conversation
I've run the proposed test, but the resulting config file doesn't seem to have some of my previous settings (like compress level, etc) This is all that's in the resulting config
|
Please paste your original config. The compress level is supposed to be reset and not be there. The new default is the best setting. For users who have the old default of 6 baked into their config, the new default of 1 represents up to 30% improvement every time we save an image. |
Re: failing tests - looks like the default YAML file isn't being created. This didn't come up locally for me because I already had a YAML file. I'll figure that out tomorrow & test with the installer. |
|
@hipsterusername Your resultant config file is almost exactly what it should be. Those values are all default values, they should not be in a config file that is meant to override defaults. The things that are not correct are the cache sizes. Turns out you are using "legacy" config settings: max_cache_size: 12.0 # This has been called "ram" for a while now
max_vram_cache_size: .25 # This has been called "vram" for a while now So what's needed to make your new yaml 100% correct is to add handling for these two settings into the simple migration logic. I'll fix that. |
bf04279
to
0482b38
Compare
Works as intended on my end. A couple of small issues that I saw were some of the paths stayed in the new config even though they were the same as the defaults -- but the reason that might have happened is coz I was using absolute paths for those rather than relative. For example Rest of it seems good. |
Is there anything holding this back? |
@blessedcoolant I'll be reviewing it again today, thinking through edge cases and testing interactions with the installer/configurator. Aiming to have this in RC3. |
0482b38
to
490e152
Compare
I added two notable changes: feat: single app entrypoint with CLI arg parsing We have two problems with how argparse is being utilized:
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.
The The first time 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! fix(install): resolve config-related issues with configurator
|
I've spruced up the config docs a bit. Also fixed a problem where user-defined |
Hold onto `conf_path` temporarily while migrating `invokeai.yaml` so that it gets migrated correctly as the model installer starts up. Stashed as `legacy_models_yaml_path` in the config, excluded from serialization.
Add testing for the settings that had to be explicitly migrated.
When running the configurator, the `legacy_models_conf_path` was stripped when saving the config file. Then the migration logic didn't fire correctly, and the custom models.yaml paths weren't migrated into the db. - Rework the logic to migrate this path by adding it to the config object as a normal field that is not excluded from serialization. - Rearrange the models.yaml migration logic to remove the legacy path after migrating, then write the config file. This way, the legacy path doesn't stick around. - Move the schema version into the config object. - Back up the config file before attempting migration. - Add tests to cover this edge case
- fix places where `get_config()` is being called at import time rather than at run time. - add regression test for import time get_config() calling.
…re they are needed
Fixes converting ckpt main models
e0beb44
to
87f769b
Compare
Now that the Inkokeai.yaml will initially only contain the settings that are not default. Will there be a method to output a full config including all the default settings. This could be used to help diagnose support issues. Obviously this should include a way to censor sensitive information like website download tokens. |
@skunkworxdark The docs here have all settings: https://invoke-ai.github.io/InvokeAI/features/CONFIGURATION/#all-settings Maybe we could have the config file be written with settings commented out? I'm wary of putting all the settings there:
|
I see all the settings there but not what the default will be if it is omitted from the yaml. I can find what they are by looking at the code but most users will not be able to do this. Commented defaults sounds like a nice compromise. But would they change if a default is updated. Maybe a way of viewing a list of what the current settings are via the frontend including defaults that are not in the yaml file. As I said before would need sensitive info like tokens censored. Then you could keep the yaml clean and mark in the frontend list which are defaults and which are defaults but omitted etc.. could even add the descriptions that you linked in the docs. I'm not suggesting adding a way of editing the config just viewing them with defaults, but that might be nice in the long term. |
@skunkworxdark Ya I understand. An example config file will be written to # This is an example file with default and example settings. Use the values here as a baseline.
# Internal metadata - do not edit:
schema_version: 4.0.0
# Put user settings here - see https://invoke-ai.github.io/InvokeAI/features/CONFIGURATION/:
host: 127.0.0.1
port: 9090
allow_origins: []
allow_credentials: true
allow_methods:
- '*'
allow_headers:
- '*'
log_tokenization: false
patchmatch: true
autoimport_dir: autoimport
models_dir: models
convert_cache_dir: models/.cache
legacy_conf_dir: configs
db_dir: databases
outputs_dir: outputs
custom_nodes_dir: nodes
log_handlers:
- console
log_format: color
log_level: info
log_sql: false
use_memory_db: false
dev_reload: false
profile_graphs: false
profiles_dir: profiles
ram: 7.5
vram: 0.25
convert_cache: 20.0
lazy_offload: true
log_memory_usage: false
device: auto
precision: auto
sequential_guidance: false
attention_type: auto
attention_slice_size: auto
force_tiled_decode: false
pil_compress_level: 1
max_queue_size: 10000
node_cache_size: 512
hashing_algorithm: blake3
remote_api_tokens:
- url_regex: cool-models.com
token: my_secret_token
- url_regex: nifty-models.com
token: some_other_token I'll also be getting the JSON schema for the config put onto the schema store. This will enable editors to get autocomplete and error highlighting in |
I have tried using the env variables to configure some folders for dev however I have come across an issue. When I use the below launch.json to start invoke for dev. It writes out these env settings to the invokeai.yaml file overwriting the existing settings. I wasn't expecting that. As this is pointing to my normal invoke install this would mean that I would have to change the settings back to normal before I could run the normal installation. Additionally I don't see the "configurations": [
{
// Run the InvokeAI backend & serve the pre-built UI
"name": "InvokeAI Server New",
"type": "debugpy",
"request": "launch",
"program": "scripts/invokeai-web.py",
"console": "integratedTerminal",
"justMyCode": true,
"args": ["--root", "d:\\ai\\invokeai"],
"env": {
// Access the app from anywhere on your local network
"INVOKEAI_HOST": "0.0.0.0",
// DB Folder
"INVOKEAI_DB_DIR": "d:\\git\\invoke-devdb",
//Nodes Folder
"INVOKEAI_CUSTOM_NODES_DIR": "d:\\git\\backup\\nodes-test",
//MemoryDB
//"INVOKEAI_USE_MEMORY_DB": "true"
},
}, |
@skunkworxdark That PR also includes the ability to use an arbitrary config file. So you can pass Re: env vars being written, I expect this to occur if you have them specified along with an uninitialized root directory. Not sure how to get around this, bc env vars are handled by the settings library and I don't see a way to defer merging them without disabling it completely. |
The What do you mean by Also, I am seeing the yaml file getting updated even if nothing has been changed inside the file every time I run my dev server. I don't think either of these things is game-breaking but they are not how I would have expected them to work. I would have thought that the env vars would be overrides to the config not updates to it. Also, I wouldn't have expected the config to be updated unless some config was changed within the app. |
@skunkworxdark By I'll figure out how to prevent env vars from being written to file, I agree that this is incorrect behaviour. |
What type of PR is this? (check all applicable)
Have you discussed this change with the InvokeAI team?
Have you updated all relevant documentation?
Description
I ran into some issues with interactions between argparse, omegaconf and pydantic validation + existing issues:
png_compress_level
topil_compress_level
- this will get everybody using the better default value of 1.InvokeAIAppConfig.get_config
.It was all very intertwined and I couldn't figure out an easy fix, so I refactored the whole thing and simplified it substantially.
See the commit messages for details on the changes, especially 6b066f3 which has the meat and potatoes. Most changes are just small changes to use the revised config system.
The API did change slightly from that commit, to support testing and the configurator.
QA Instructions, Screenshots, Recordings
invokeai.yaml
should change to the new flat format, and the old one backed up toinvokeai.yaml.bak
. Your YAML should now only contain settings that are different from defaults. Everything should work exactly the same as it did before - like custom paths for models, host, port..bak
file. Run the configurator - it should migrate the YAML as it starts and back it up, same as before. Change a couple settings and apply changes, the YAML should change accordingly.It's hard to fully test this change because the config is used all over the place, but I was pretty darn careful when updating all the places the config is used.
Merge Plan
This PR can be merged when approved
Added/updated tests?
have not been included
Closes #5964