feat: --feature-cache-dir CLI arg for training binaries

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
jgrusewski
2026-04-03 22:59:08 +02:00
parent cb543dea1d
commit b1fa34c5eb
2 changed files with 17 additions and 2 deletions

View File

@@ -211,6 +211,10 @@ struct Args {
/// Contains the best continuous parameter vector from the previous phase.
#[arg(long)]
hyperopt_params: Option<PathBuf>,
/// Feature cache directory (overrides FOXHUNT_FEATURE_CACHE_DIR and auto-discovery)
#[arg(long)]
feature_cache_dir: Option<String>,
}
/// 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);

View File

@@ -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<String>,
}
// ---------------------------------------------------------------------------
@@ -538,8 +542,11 @@ fn run_training(args: &Args) -> Result<Vec<RlTrainingResult>> {
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();