forked from extern/easydiffusion
Don't use YAML as a singleton, seems to be stateful; Use ruamel in get_config for consistency
This commit is contained in:
parent
ec353ba90d
commit
26042b1e26
@ -17,10 +17,11 @@ args = parser.parse_args()
|
||||
|
||||
|
||||
if os.path.isfile(config_yaml):
|
||||
import yaml
|
||||
from ruamel.yaml import YAML
|
||||
yaml = YAML(typ='safe')
|
||||
with open(config_yaml, 'r') as configfile:
|
||||
try:
|
||||
config = yaml.safe_load(configfile)
|
||||
config = yaml.load(configfile)
|
||||
except Exception as e:
|
||||
print(e, file=sys.stderr)
|
||||
config = {}
|
||||
|
@ -18,8 +18,6 @@ from rich.console import Console
|
||||
from rich.panel import Panel
|
||||
from sdkit.utils import log as sdkit_log # hack, so we can overwrite the log config
|
||||
|
||||
yaml = YAML()
|
||||
|
||||
# Remove all handlers associated with the root logger object.
|
||||
for handler in logging.root.handlers[:]:
|
||||
logging.root.removeHandler(handler)
|
||||
@ -107,6 +105,7 @@ def getConfig(default_val=APP_CONFIG_DEFAULTS):
|
||||
config_yaml_path = os.path.join(CONFIG_DIR, "config.yaml")
|
||||
if os.path.isfile(config_yaml_path):
|
||||
try:
|
||||
yaml = YAML()
|
||||
with open(config_yaml_path, "r", encoding="utf-8") as f:
|
||||
config = yaml.load(f)
|
||||
if "net" not in config:
|
||||
@ -145,6 +144,7 @@ def getConfig(default_val=APP_CONFIG_DEFAULTS):
|
||||
def setConfig(config):
|
||||
try: # config.yaml
|
||||
config_yaml_path = os.path.join(CONFIG_DIR, "config.yaml")
|
||||
yaml = YAML()
|
||||
yaml.indent(mapping=2, sequence=4, offset=2)
|
||||
with open(config_yaml_path, "w", encoding="utf-8") as f:
|
||||
yaml.dump(config, f)
|
||||
|
Loading…
Reference in New Issue
Block a user