Enforce an autosave directory#736
Enforce an autosave directory#736cmdr2 merged 2 commits intoeasydiffusion:betaeasydiffusion/easydiffusion:betafrom
Conversation
ui/easydiffusion/app.py
Outdated
| UI_PLUGINS_SOURCES = ((CORE_UI_PLUGINS_DIR, 'core'), (USER_UI_PLUGINS_DIR, 'user')) | ||
|
|
||
| OUTPUT_DIRNAME = "Stable Diffusion UI" # in the user's home folder | ||
| PRESERVE_CONFIG_VARS = ['FORCE_SAVE_PATH', 'FORCE_FULL_PRECISION'] |
There was a problem hiding this comment.
Thanks for the bugfix to preserve FORCE_FULL_PRECISION!
However I'd like to get rid of writing to config.bat/sh soon, and would prefer FORCE_SAVE_PATH to be in config.json. Rethinking my own decision, maybe FORCE_FULL_PRECISION should also be in config.json.
Both of these are server configs. We only chose to not expose to them to users in the UI (to avoid shooting themselves in the foot). But they are still server configs, hence make sense to be in config.json.
config.bat/sh still make sense to be around, as a convenient way for users to set environment variables. But I'd like to get rid of us writing to them, or relying on them. Thanks!
There was a problem hiding this comment.
I fully agree that the duplication of config.bat and config.json is not very nice.
My idea behind this PR was: config.bat for server side (read: admin) settings, config.json for everything accessible via the UI, since JSON files aren't very user friendly to be edited, especially since we don't pretty print the JSON string. It's easier to say "Add this line to that file" than to explain the syntax of a JSON file.
FORCE_SAVE_PATH is an admin setting, so it can't be accessible through the UI.
While writing this down, I got an idea: Could add a small command line tool to manipulate the config.json file:
E A S Y D I F F U S I O N
==========================
1. Reset default model
2. Configure auto save path
3. Configure Full Precision
0. Quit
Please choose from the above options: _
There was a problem hiding this comment.
We only use variables from config.bat after we've set up and activated our python env. So it should be possible to have a small script get_config.py:
import sys
import json
# Load the JSON file
with open(sys.argv[1], 'r') as f:
data = json.load(f)
# Iterate through the keys and get the corresponding value
value = data
for key in sys.argv[2:]:
value = value[key]
print(value)And to use it to extract variables from the JSON file for those cases where we really need them in the shell scripts:
for /f "delims=" %i in ('python scripts\get_config.py scripts\config.json net listen_port') do set PORT=%i(Todo: default value handling if there's no such key in the config.json file or the file doesn't exist)
There was a problem hiding this comment.
How about we just get rid of config.json and use yaml instead? :) That's an easy format for hand-editing, and a common format for server config in other software.
I can write a simple script to migrate existing config.json files to the yaml one (during startup).
I'd really like to avoid any further use of bat/sh files, except for letting people set environment variables in a convenient way.
|
Thanks, this looks good! Only comment - please use config.json (instead of config.bat/sh) to store the autosave dir path. |
Add a config.bat/sh setting
FORCE_SAVE_PATHthat can be used by server admins to restrict auto save to a specific directory. Also useful for users who use different end devices and want to centrally configure the auto save option.If
FORCE_SAVE_PATHis set, the auto save options in the UI are disabled.Fixes #597
Fixes https://discord.com/channels/1014774730907209781/1052691036981428255