Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Enforce an autosave directory#736

Merged
cmdr2 merged 2 commits intoeasydiffusion:betaeasydiffusion/easydiffusion:betafrom
JeLuF:enfdirJeLuF/stable-diffusion-ui:enfdirCopy head branch name to clipboard
Feb 10, 2023
Merged

Enforce an autosave directory#736
cmdr2 merged 2 commits intoeasydiffusion:betaeasydiffusion/easydiffusion:betafrom
JeLuF:enfdirJeLuF/stable-diffusion-ui:enfdirCopy head branch name to clipboard

Conversation

@JeLuF
Copy link
Contributor

@JeLuF JeLuF commented Dec 30, 2022

Add a config.bat/sh setting FORCE_SAVE_PATH that 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_PATH is set, the auto save options in the UI are disabled.

Fixes #597
Fixes https://discord.com/channels/1014774730907209781/1052691036981428255

@JeLuF JeLuF changed the title Enforce a autosave directory Enforce an autosave directory Dec 30, 2022
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']
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:  _

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@cmdr2
Copy link
Collaborator

cmdr2 commented Jan 9, 2023

Thanks, this looks good! Only comment - please use config.json (instead of config.bat/sh) to store the autosave dir path.

@cmdr2 cmdr2 merged commit 4df442f into easydiffusion:beta Feb 10, 2023
@JeLuF JeLuF deleted the enfdir branch September 1, 2023 21:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.