diff --git a/crates/desktop/artcraft/src/lib.rs b/crates/desktop/artcraft/src/lib.rs index 5017b8769e..e708785e0e 100644 --- a/crates/desktop/artcraft/src/lib.rs +++ b/crates/desktop/artcraft/src/lib.rs @@ -11,16 +11,16 @@ use crate::commands::platform_info_command::platform_info_command; use crate::commands::sora::open_sora_login_command::open_sora_login_command; use crate::commands::sora::sora_image_generation_command::sora_image_generation_command; use crate::commands::sora::sora_image_remix_command::sora_image_remix_command; -use crate::state::app_config::AppConfig; +use crate::state::data_dir::app_data_root::AppDataRoot; use crate::state::main_window_size::MainWindowSize; use crate::state::sora::sora_credential_manager::SoraCredentialManager; -use crate::utils::webview_unsafe::webview_unsafe_for_app; use crate::state::sora::sora_task_queue::SoraTaskQueue; use crate::state::storyteller::storyteller_credential_manager::StorytellerCredentialManager; use crate::threads::discord_presence_thread::discord_presence_thread; use crate::threads::main_window_thread::main_window_thread::main_window_thread; use crate::threads::sora_session_login_thread::sora_session_login_thread; use crate::threads::sora_task_polling_thread::sora_task_polling_thread; +use crate::utils::webview_unsafe::webview_unsafe_for_app; use tauri_plugin_http; use tauri_plugin_log::Target; @@ -30,13 +30,9 @@ use tauri_plugin_log::TargetKind; pub fn run() { // NB: Tauri wants to install the logger itself, so we can't rely on the logger crate // until the tauri runtime begins. - println!("Loading model config..."); - - let config = AppConfig::init() - .expect("config should load"); - - let app_data_root = config.app_data_root.clone(); - let app_data_root_2 = config.app_data_root.clone(); + println!("Loading config..."); + let app_data_root = AppDataRoot::create_default().expect("data directory should be created"); + let app_data_root_2 = app_data_root.clone(); println!("Attempting to read existing artcraft credentials..."); let storyteller_creds_manager = StorytellerCredentialManager::initialize_from_disk_infallible(&app_data_root); @@ -112,7 +108,6 @@ pub fn run() { Ok(()) }) .manage(app_data_root) - .manage(config) .manage(sora_creds_manager) .manage(sora_task_queue) .invoke_handler(tauri::generate_handler![ diff --git a/crates/desktop/artcraft/src/state/app_config.rs b/crates/desktop/artcraft/src/state/app_config.rs deleted file mode 100644 index a090a53d82..0000000000 --- a/crates/desktop/artcraft/src/state/app_config.rs +++ /dev/null @@ -1,58 +0,0 @@ -use crate::state::data_dir::app_data_root::AppDataRoot; -use crate::state::os_platform::OsPlatform; -use crate::state::yaml_config::YamlConfig; - -const DEFAULT_SD_IMAGE_WIDTH: usize = 1024; -const DEFAULT_SD_IMAGE_HEIGHT: usize = 1024; - - -/// A central place to configure app-wide details. -pub struct AppConfig { - pub image_height: usize, - pub image_width: usize, - pub scheduler_steps: usize, - pub scheduler_samples: usize, - - pub seed: Option, - - pub cfg_scale: Option, - - /// Root location for application data. - pub app_data_root: AppDataRoot, -} - -impl AppConfig { - - pub fn init() -> anyhow::Result { - let yaml_configs = YamlConfig::load_from_config_file_recursive(); - - println!("Configs: {:?}", yaml_configs); - - let os_platform = OsPlatform::get(); - - let default_data_root = match os_platform { - OsPlatform::Linux => yaml_configs.linux_default_data_path.as_deref(), - OsPlatform::MacOs => yaml_configs.mac_default_data_path.as_deref(), - OsPlatform::Windows => yaml_configs.windows_default_data_path.as_deref(), - }; - - println!("Possible user-defined data root: {:?}", default_data_root); - - let app_data_root = match default_data_root { - None => AppDataRoot::create_default()?, - Some(path) => AppDataRoot::create_existing(path)?, - }; - - println!("App data root: {:?}", app_data_root.path()); - - Ok(Self { - image_height: yaml_configs.image_height.unwrap_or(DEFAULT_SD_IMAGE_HEIGHT), - image_width: yaml_configs.image_width.unwrap_or(DEFAULT_SD_IMAGE_WIDTH), - scheduler_steps: yaml_configs.scheduler_steps.unwrap_or(4), - scheduler_samples: yaml_configs.scheduler_samples.unwrap_or(15), - seed: yaml_configs.seed, - cfg_scale: yaml_configs.cfg_scale, - app_data_root, - }) - } -} diff --git a/crates/desktop/artcraft/src/state/data_dir/app_data_root.rs b/crates/desktop/artcraft/src/state/data_dir/app_data_root.rs index 1cc66c5bfd..c9e675681c 100644 --- a/crates/desktop/artcraft/src/state/data_dir/app_data_root.rs +++ b/crates/desktop/artcraft/src/state/data_dir/app_data_root.rs @@ -100,7 +100,7 @@ impl AppDataRoot { pub fn settings_dir(&self) -> &AppSettingsDir { &self.settings_dir } - + pub fn weights_dir(&self) -> &AppWeightsDir { &self.weights_dir } diff --git a/crates/desktop/artcraft/src/state/mod.rs b/crates/desktop/artcraft/src/state/mod.rs index 4f79cf311e..c2375bf22b 100644 --- a/crates/desktop/artcraft/src/state/mod.rs +++ b/crates/desktop/artcraft/src/state/mod.rs @@ -1,9 +1,7 @@ -pub mod app_config; pub mod app_startup_time; pub mod data_dir; pub mod expanduser; pub mod main_window_size; pub mod os_platform; pub mod sora; -pub mod storyteller; -pub mod yaml_config; \ No newline at end of file +pub mod storyteller; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/state/yaml_config.rs b/crates/desktop/artcraft/src/state/yaml_config.rs deleted file mode 100644 index 6a63db99ea..0000000000 --- a/crates/desktop/artcraft/src/state/yaml_config.rs +++ /dev/null @@ -1,52 +0,0 @@ -use filesys::recursively_find_file_by_name::recursively_find_file_by_name; -use std::fs::File; -use std::io::BufReader; -use std::path::Path; - -const CONFIG_FILENAME : &str = "app_config.yaml"; - -/// Configuration read or derived from a YAML config file at startup -/// This is not meant to contain any runtime config values. -/// This may not be exhaustive. -#[derive(serde::Deserialize, serde::Serialize, Clone, Debug, Default)] -pub struct YamlConfig { - pub image_height: Option, - pub image_width: Option, - pub scheduler_steps: Option, - pub scheduler_samples: Option, - pub seed: Option, - pub cfg_scale: Option, - - /// Override the default location to store data on Linux - pub linux_default_data_path: Option, - - /// Override the default location to store data on Windows - pub windows_default_data_path: Option, - - /// Override the default location to store data on Mac - pub mac_default_data_path: Option, -} - -impl YamlConfig { - pub fn read_from_file>(path: P) -> anyhow::Result { - let file = File::open(path)?; - let reader = BufReader::new(file); - let config = serde_yaml::from_reader(reader)?; - Ok(config) - } - - pub fn load_from_config_file_recursive() -> YamlConfig { - let maybe_path = recursively_find_file_by_name(CONFIG_FILENAME, "../../../", 5) - .ok() - .flatten(); - if let Some(path) = maybe_path { - let path = path.canonicalize().unwrap_or(path); - println!("Attempting to load configs from: {:?}", &path); - if let Ok(config) = YamlConfig::read_from_file(path) { - return config; - } - } - println!("Couldn't load config file. Using default configs."); - YamlConfig::default() - } -}