NagisaNao commited on
Commit
9d5a4e0
1 Parent(s): 015d38b

WHY IS THERE A PART IN KAGGLE THAT DOESN'T FIT TOGETHER?!

Browse files
Files changed (1) hide show
  1. files_cells/python/ru/widgets_ru.py +16 -24
files_cells/python/ru/widgets_ru.py CHANGED
@@ -499,37 +499,29 @@ save_button = widgets.Button(description='Сохранить').add_class("button
499
  display(save_button)
500
 
501
 
502
- # ============ Load / Save - Settings V3 ============
503
- try:
504
- import toml
505
- except ImportError: # SageMaker - only for you...
506
- get_ipython().system('pip install toml > /dev/null 2>&1')
507
- import toml
508
-
509
- SETTINGS_FILE = f'{root_path}/settings.toml'
510
-
511
- settings_structure = {
512
- "Model": ['Model', 'Model_Num', 'Inpainting_Model'],
513
- "Vae": ['Vae', 'Vae_Num'],
514
- "Additional": ['latest_webui', 'latest_exstensions', 'detailed_download', 'controlnet', 'controlnet_Num', 'commit_hash', 'optional_huggingface_token', 'ngrok_token', 'commandline_arguments'],
515
- "CustomUrl": ['Model_url', 'Vae_url', 'LoRA_url', 'Embedding_url', 'Extensions_url', 'custom_file_urls']
516
- }
517
 
518
  def save_settings():
519
- settings = {}
520
- for section, keys in settings_structure.items():
521
- settings[section] = {key: globals()[f"{key}_widget"].value for key in keys}
522
  with open(SETTINGS_FILE, 'w') as f:
523
- toml.dump(settings, f)
524
 
525
  def load_settings():
526
  if os.path.exists(SETTINGS_FILE):
527
  with open(SETTINGS_FILE, 'r') as f:
528
- loaded_settings = toml.load(f)
529
- for section, keys in settings_structure.items():
530
- for key in keys:
531
- if key in loaded_settings[section]:
532
- globals()[f"{key}_widget"].value = loaded_settings[section][key]
533
 
534
  def save_data(button):
535
  save_settings()
 
499
  display(save_button)
500
 
501
 
502
+ # ============ Load / Save - Settings V2 ============
503
+ SETTINGS_FILE = f'{root_path}/settings.json'
504
+
505
+ settings_keys = [
506
+ 'Model', 'Model_Num', 'Inpainting_Model',
507
+ 'Vae', 'Vae_Num',
508
+ 'latest_webui', 'latest_exstensions', 'detailed_download',
509
+ 'controlnet', 'controlnet_Num', 'commit_hash', 'optional_huggingface_token',
510
+ 'ngrok_token', 'commandline_arguments',
511
+ 'Model_url', 'Vae_url', 'LoRA_url', 'Embedding_url', 'Extensions_url', 'custom_file_urls'
512
+ ]
 
 
 
 
513
 
514
  def save_settings():
515
+ settings = {key: globals()[f"{key}_widget"].value for key in settings_keys}
 
 
516
  with open(SETTINGS_FILE, 'w') as f:
517
+ json.dump(settings, f)
518
 
519
  def load_settings():
520
  if os.path.exists(SETTINGS_FILE):
521
  with open(SETTINGS_FILE, 'r') as f:
522
+ settings = json.load(f)
523
+ for key in settings_keys:
524
+ globals()[f"{key}_widget"].value = settings.get(key)
 
 
525
 
526
  def save_data(button):
527
  save_settings()