mirror of
https://github.com/easydiffusion/easydiffusion.git
synced 2024-11-22 00:03:20 +01:00
Use yaml instead of json for the config file
This commit is contained in:
parent
fa205f483a
commit
932ee11c91
@ -15,6 +15,7 @@ mkdir dist\win\stable-diffusion-ui\scripts
|
|||||||
|
|
||||||
copy scripts\on_env_start.bat dist\win\stable-diffusion-ui\scripts\
|
copy scripts\on_env_start.bat dist\win\stable-diffusion-ui\scripts\
|
||||||
copy scripts\bootstrap.bat dist\win\stable-diffusion-ui\scripts\
|
copy scripts\bootstrap.bat dist\win\stable-diffusion-ui\scripts\
|
||||||
|
copy scripts\config.yaml.sample dist\win\stable-diffusion-ui\scripts\config.yaml
|
||||||
copy "scripts\Start Stable Diffusion UI.cmd" dist\win\stable-diffusion-ui\
|
copy "scripts\Start Stable Diffusion UI.cmd" dist\win\stable-diffusion-ui\
|
||||||
copy LICENSE dist\win\stable-diffusion-ui\
|
copy LICENSE dist\win\stable-diffusion-ui\
|
||||||
copy "CreativeML Open RAIL-M License" dist\win\stable-diffusion-ui\
|
copy "CreativeML Open RAIL-M License" dist\win\stable-diffusion-ui\
|
||||||
|
1
build.sh
1
build.sh
@ -29,6 +29,7 @@ mkdir -p dist/linux-mac/stable-diffusion-ui/scripts
|
|||||||
cp scripts/on_env_start.sh dist/linux-mac/stable-diffusion-ui/scripts/
|
cp scripts/on_env_start.sh dist/linux-mac/stable-diffusion-ui/scripts/
|
||||||
cp scripts/bootstrap.sh dist/linux-mac/stable-diffusion-ui/scripts/
|
cp scripts/bootstrap.sh dist/linux-mac/stable-diffusion-ui/scripts/
|
||||||
cp scripts/functions.sh dist/linux-mac/stable-diffusion-ui/scripts/
|
cp scripts/functions.sh dist/linux-mac/stable-diffusion-ui/scripts/
|
||||||
|
cp scripts/config.yaml.sample dist/linux-mac/stable-diffusion-ui/scripts/config.yaml
|
||||||
cp scripts/start.sh dist/linux-mac/stable-diffusion-ui/
|
cp scripts/start.sh dist/linux-mac/stable-diffusion-ui/
|
||||||
cp LICENSE dist/linux-mac/stable-diffusion-ui/
|
cp LICENSE dist/linux-mac/stable-diffusion-ui/
|
||||||
cp "CreativeML Open RAIL-M License" dist/linux-mac/stable-diffusion-ui/
|
cp "CreativeML Open RAIL-M License" dist/linux-mac/stable-diffusion-ui/
|
||||||
|
24
scripts/config.yaml.sample
Normal file
24
scripts/config.yaml.sample
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
# Change listen_port if port 9000 is already in use on your system
|
||||||
|
# Set listen_to_network to true to make Easy Diffusion accessibble on your local network
|
||||||
|
net:
|
||||||
|
listen_port: 9000
|
||||||
|
listen_to_network: false
|
||||||
|
|
||||||
|
# Multi GPU setup
|
||||||
|
render_devices: auto
|
||||||
|
|
||||||
|
# Set open_browser_on_start to false to disable opening a new browser tab on each restart
|
||||||
|
ui:
|
||||||
|
open_browser_on_start: true
|
||||||
|
|
||||||
|
# set update_branch to main to use the stable version, or to beta to use the experimental
|
||||||
|
# beta version.
|
||||||
|
update_branch: main
|
||||||
|
|
||||||
|
# Set force_save_path to enforce an auto save path. Clients will not be able to change or
|
||||||
|
# disable auto save when this option is set. Please adapt the path in the examples to your
|
||||||
|
# needs.
|
||||||
|
# Windows:
|
||||||
|
# force_save_path: C:\\Easy Diffusion Images\\
|
||||||
|
# Linux:
|
||||||
|
# force_save_path: /data/easy-diffusion-images/
|
@ -135,6 +135,23 @@ if "%ERRORLEVEL%" EQU "0" (
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@rem install ruamel.yaml
|
||||||
|
call python ..\scripts\check_modules.py ruamel.yaml
|
||||||
|
if "%ERRORLEVEL%" EQU "0" (
|
||||||
|
echo "ruamel.yaml has already been installed."
|
||||||
|
) else (
|
||||||
|
echo "Installing ruamel.yaml.."
|
||||||
|
|
||||||
|
set PYTHONNOUSERSITE=1
|
||||||
|
set PYTHONPATH=%INSTALL_ENV_DIR%\lib\site-packages
|
||||||
|
|
||||||
|
call python -m pip install ruamel.yaml==0.17.21 || (
|
||||||
|
echo "Error installing ruamel.yaml. Sorry about that, please try to:" & echo " 1. Run this installer again." & echo " 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/wiki/Troubleshooting" & echo " 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB" & echo " 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues" & echo "Thanks!"
|
||||||
|
pause
|
||||||
|
exit /b
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
set PATH=C:\Windows\System32;%PATH%
|
set PATH=C:\Windows\System32;%PATH%
|
||||||
|
|
||||||
call python ..\scripts\check_modules.py uvicorn fastapi
|
call python ..\scripts\check_modules.py uvicorn fastapi
|
||||||
|
@ -5,6 +5,9 @@ import json
|
|||||||
import traceback
|
import traceback
|
||||||
import logging
|
import logging
|
||||||
import shlex
|
import shlex
|
||||||
|
from ruamel.yaml import YAML
|
||||||
|
yaml = YAML()
|
||||||
|
|
||||||
from rich.logging import RichHandler
|
from rich.logging import RichHandler
|
||||||
|
|
||||||
from sdkit.utils import log as sdkit_log # hack, so we can overwrite the log config
|
from sdkit.utils import log as sdkit_log # hack, so we can overwrite the log config
|
||||||
@ -54,33 +57,50 @@ def init():
|
|||||||
update_render_threads()
|
update_render_threads()
|
||||||
|
|
||||||
def getConfig(default_val=APP_CONFIG_DEFAULTS):
|
def getConfig(default_val=APP_CONFIG_DEFAULTS):
|
||||||
try:
|
config_yaml_path = os.path.join(CONFIG_DIR, 'config.yaml')
|
||||||
config_json_path = os.path.join(CONFIG_DIR, 'config.json')
|
if os.path.isfile(config_yaml_path):
|
||||||
if not os.path.exists(config_json_path):
|
try:
|
||||||
config = default_val
|
log.info('Loading config.yaml')
|
||||||
else:
|
with open(config_yaml_path, 'r', encoding='utf-8') as f:
|
||||||
with open(config_json_path, 'r', encoding='utf-8') as f:
|
config = yaml.load(f)
|
||||||
config = json.load(f)
|
if 'net' not in config:
|
||||||
if 'net' not in config:
|
config['net'] = {}
|
||||||
config['net'] = {}
|
if os.getenv('SD_UI_BIND_PORT') is not None:
|
||||||
if os.getenv('SD_UI_BIND_PORT') is not None:
|
config['net']['listen_port'] = int(os.getenv('SD_UI_BIND_PORT'))
|
||||||
config['net']['listen_port'] = int(os.getenv('SD_UI_BIND_PORT'))
|
else:
|
||||||
else:
|
config['net']['listen_port'] = 9000
|
||||||
config['net']['listen_port'] = 9000
|
if os.getenv('SD_UI_BIND_IP') is not None:
|
||||||
if os.getenv('SD_UI_BIND_IP') is not None:
|
config['net']['listen_to_network'] = (os.getenv('SD_UI_BIND_IP') == '0.0.0.0')
|
||||||
config['net']['listen_to_network'] = (os.getenv('SD_UI_BIND_IP') == '0.0.0.0')
|
else:
|
||||||
else:
|
config['net']['listen_to_network'] = True
|
||||||
config['net']['listen_to_network'] = True
|
return config
|
||||||
return config
|
except Exception as e:
|
||||||
except Exception as e:
|
log.warn(traceback.format_exc())
|
||||||
log.warn(traceback.format_exc())
|
return default_val
|
||||||
return default_val
|
else:
|
||||||
|
try:
|
||||||
|
config_json_path = os.path.join(CONFIG_DIR, 'config.json')
|
||||||
|
if not os.path.exists(config_json_path):
|
||||||
|
return default_val
|
||||||
|
else:
|
||||||
|
log.info('Converting old json config file to yaml')
|
||||||
|
with open(config_json_path, 'r', encoding='utf-8') as f:
|
||||||
|
config = json.load(f)
|
||||||
|
# Save config in new format
|
||||||
|
setConfig(config)
|
||||||
|
os.rename(config_json_path, config_json_path + '.bak')
|
||||||
|
log.info('Saved old config.json as config.json.bak')
|
||||||
|
return getConfig(default_val)
|
||||||
|
except Exception as e:
|
||||||
|
log.warn(traceback.format_exc())
|
||||||
|
return default_val
|
||||||
|
|
||||||
def setConfig(config):
|
def setConfig(config):
|
||||||
try: # config.json
|
try: # config.yaml
|
||||||
config_json_path = os.path.join(CONFIG_DIR, 'config.json')
|
config_yaml_path = os.path.join(CONFIG_DIR, 'config.yaml')
|
||||||
with open(config_json_path, 'w', encoding='utf-8') as f:
|
yaml.indent(mapping=2, sequence=4, offset=2)
|
||||||
json.dump(config, f)
|
with open(config_yaml_path, 'w', encoding='utf-8') as f:
|
||||||
|
yaml.dump(config, f)
|
||||||
except:
|
except:
|
||||||
log.error(traceback.format_exc())
|
log.error(traceback.format_exc())
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user