From b1fa34c5eb55513d04b924364520b9f963be0aed Mon Sep 17 00:00:00 2001 From: jgrusewski Date: Fri, 3 Apr 2026 22:59:08 +0200 Subject: [PATCH] feat: --feature-cache-dir CLI arg for training binaries Co-Authored-By: Claude Opus 4.6 (1M context) --- crates/ml/examples/hyperopt_baseline_rl.rs | 8 ++++++++ crates/ml/examples/train_baseline_rl.rs | 11 +++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/crates/ml/examples/hyperopt_baseline_rl.rs b/crates/ml/examples/hyperopt_baseline_rl.rs index fb6315b44..308522e49 100644 --- a/crates/ml/examples/hyperopt_baseline_rl.rs +++ b/crates/ml/examples/hyperopt_baseline_rl.rs @@ -211,6 +211,10 @@ struct Args { /// Contains the best continuous parameter vector from the previous phase. #[arg(long)] hyperopt_params: Option, + + /// Feature cache directory (overrides FOXHUNT_FEATURE_CACHE_DIR and auto-discovery) + #[arg(long)] + feature_cache_dir: Option, } /// Result entry for one model's hyperopt run @@ -263,6 +267,10 @@ fn run_dqn_hyperopt(args: &Args, parallel: usize, gpu_devices: &[ml_core::device args.trades_data_dir.as_ref().map(|p| p.to_string_lossy().into_owned()), ); + if let Some(ref dir) = args.feature_cache_dir { + trainer = trainer.with_feature_cache(PathBuf::from(dir)); + } + // Preload training data once — all trials reuse via Arc (no per-trial disk I/O) if let Err(e) = trainer.preload_data() { warn!("Data preload failed ({}), trials will load from disk individually", e); diff --git a/crates/ml/examples/train_baseline_rl.rs b/crates/ml/examples/train_baseline_rl.rs index b88346790..28dcd3496 100644 --- a/crates/ml/examples/train_baseline_rl.rs +++ b/crates/ml/examples/train_baseline_rl.rs @@ -255,6 +255,10 @@ struct Args { /// Known profiles: dqn-production, dqn-smoketest, dqn-hyperopt. #[arg(long, default_value = "dqn-production")] training_profile: String, + + /// Feature cache directory (overrides FOXHUNT_FEATURE_CACHE_DIR and auto-discovery) + #[arg(long)] + feature_cache_dir: Option, } // --------------------------------------------------------------------------- @@ -538,8 +542,11 @@ fn run_training(args: &Args) -> Result> { info!("Step 1/5: Loading data..."); let data_load_start = std::time::Instant::now(); - // Auto-discover fxcache: env var > sibling feature-cache/ dir - let fxcache_dir = std::env::var("FOXHUNT_FEATURE_CACHE_DIR").ok().map(PathBuf::from) + // Auto-discover fxcache: CLI arg > env var > sibling feature-cache/ dir + let fxcache_dir = args.feature_cache_dir.as_ref() + .map(PathBuf::from) + .filter(|p| p.exists()) + .or_else(|| std::env::var("FOXHUNT_FEATURE_CACHE_DIR").ok().map(PathBuf::from)) .or_else(|| { let symbol_dir = args.data_dir.join(&args.symbol); let mut dir = symbol_dir.as_path();