diff options
Diffstat (limited to 'src/config.rs')
| -rw-r--r-- | src/config.rs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/config.rs b/src/config.rs index 10f5755..16286b5 100644 --- a/src/config.rs +++ b/src/config.rs @@ -60,6 +60,14 @@ pub struct Config { pub dev_token_client_secret: String, pub dev_token_username: String, pub dev_token_password: String, + /// The gemma-wrapper executable to invoke for POST /compute/gemma. + /// Same GEMMA_WRAPPER_CMD config key GeneNetwork3 uses. Defaults to + /// "gemma-wrapper", resolved via PATH. + pub gemma_wrapper_cmd: String, + /// Directory gemma-wrapper uses to cache K matrices and association + /// results between calls (its own --cache-dir switch). Defaults to + /// a "gn4-gemma" directory under the system temp dir. + pub gemma_cache_dir: String, } impl Config { @@ -102,6 +110,14 @@ impl Config { values.insert("GN3_TIMEOUT_SECS".to_string(), "30".to_string()); values.insert("XAPIAN_DB_PATH".to_string(), String::new()); values.insert("SEARCH_ENGINE".to_string(), "forward".to_string()); + values.insert("GEMMA_WRAPPER_CMD".to_string(), "gemma-wrapper".to_string()); + values.insert( + "GEMMA_CACHE_DIR".to_string(), + std::env::temp_dir() + .join("gn4-gemma") + .to_string_lossy() + .into_owned(), + ); // Layers 2 and 3: config files, in increasing priority. for env_key in ["GN4_CONF", "GN4_SECRETS"] { @@ -127,6 +143,8 @@ impl Config { "GN3_TIMEOUT_SECS", "XAPIAN_DB_PATH", "SEARCH_ENGINE", + "GEMMA_WRAPPER_CMD", + "GEMMA_CACHE_DIR", ] { if let Ok(value) = std::env::var(key) { values.insert(key.to_string(), value); @@ -153,6 +171,8 @@ impl Config { dev_token_client_secret: values["GN_AUTH_DEV_CLIENT_SECRET"].clone(), dev_token_username: values["GN_AUTH_DEV_USERNAME"].clone(), dev_token_password: values["GN_AUTH_DEV_PASSWORD"].clone(), + gemma_wrapper_cmd: values["GEMMA_WRAPPER_CMD"].clone(), + gemma_cache_dir: values["GEMMA_CACHE_DIR"].clone(), } } } @@ -223,6 +243,8 @@ mod tests { "GN3_TIMEOUT_SECS", "XAPIAN_DB_PATH", "SEARCH_ENGINE", + "GEMMA_WRAPPER_CMD", + "GEMMA_CACHE_DIR", ] { if std::env::var(key).is_ok() { eprintln!("skipping: {key} is set in the environment"); @@ -232,6 +254,8 @@ mod tests { let config = Config::load(); assert!(config.sql_uri.contains("db_webqtl")); assert_eq!(config.port, 3000); + assert_eq!(config.gemma_wrapper_cmd, "gemma-wrapper"); + assert!(config.gemma_cache_dir.ends_with("gn4-gemma")); assert_eq!(config.auth_server_url, "http://127.0.0.1:8081/"); assert_eq!(config.bind, "0.0.0.0"); assert!(config.test_token_enabled, "on by default"); |
