@@ -144,41 +144,58 @@ def main():
144144 # Setup run directory (handles DDP coordination and config saving)
145145 # Determine output base directory from checkpoint for test/tune modes
146146 if args .mode in ["test" , "tune" , "tune-test" ] and args .checkpoint :
147- # Extract base directory from checkpoint path
148- output_base = get_output_base_from_checkpoint (args .checkpoint )
149- output_base .mkdir (parents = True , exist_ok = True )
147+ # Check if test.data.output_path is already set (skip checkpoint-based path extraction)
148+ test_output_path_set = (
149+ hasattr (cfg , "test" )
150+ and hasattr (cfg .test , "data" )
151+ and getattr (cfg .test .data , "output_path" , None )
152+ )
150153
151- # Create mode-specific subdirectories
152- if args .mode in ["tune" , "tune-test" ]:
153- dirpath = str (output_base / "tuning" )
154- results_path = str (output_base / "results" )
155- # Override tune output directories in config
156- if cfg .tune is not None :
157- cfg .tune .output .output_dir = dirpath
158- cfg .tune .output .output_pred = results_path
159- # For tune-test, also set test output directory and cache suffix
160- if args .mode == "tune-test" :
161- print (f"🔍 Setting test config for tune-test mode" )
162- print (f"🔍 cfg.test is None: { cfg .test is None } " )
163- if cfg .test is not None :
164- print (f"🔍 cfg.test.data is None: { cfg .test .data is None } " )
165- if cfg .test .data is not None :
166- cfg .test .data .output_path = results_path
167- cfg .test .data .cache_suffix = cfg .tune .output .cache_suffix
168- print (f"📋 Test output: { cfg .test .data .output_path } " )
169- print (f"📋 Test cache suffix: { cfg .test .data .cache_suffix } " )
154+ if args .mode == "test" and test_output_path_set :
155+ # Use the config value directly, skip checkpoint-based directory creation
156+ dirpath = str (cfg .test .data .output_path )
157+ output_base = None # Not needed when using config path
158+ else :
159+ # Extract base directory from checkpoint path
160+ output_base = get_output_base_from_checkpoint (args .checkpoint )
161+ output_base .mkdir (parents = True , exist_ok = True )
162+
163+ # Create mode-specific subdirectories
164+ if args .mode in ["tune" , "tune-test" ]:
165+ dirpath = str (output_base / "tuning" )
166+ results_path = str (output_base / "results" )
167+ # Override tune output directories in config
168+ if cfg .tune is not None :
169+ cfg .tune .output .output_dir = dirpath
170+ cfg .tune .output .output_pred = results_path
171+ # For tune-test, also set test output directory and cache suffix
172+ if args .mode == "tune-test" :
173+ print (f"🔍 Setting test config for tune-test mode" )
174+ print (f"🔍 cfg.test is None: { cfg .test is None } " )
175+ if cfg .test is not None :
176+ print (f"🔍 cfg.test.data is None: { cfg .test .data is None } " )
177+ if cfg .test .data is not None :
178+ cfg .test .data .output_path = results_path
179+ cfg .test .data .cache_suffix = cfg .tune .output .cache_suffix
180+ print (f"📋 Test output: { cfg .test .data .output_path } " )
181+ print (f"📋 Test cache suffix: { cfg .test .data .cache_suffix } " )
182+ else :
183+ print (f"❌ cfg.test.data is None, cannot set cache_suffix!" )
184+ else :
185+ print (f"❌ cfg.test is None, cannot set cache_suffix!" )
186+ else : # test mode
187+ dirpath = str (output_base / "results" )
188+ # Override test output directory in config only if not already set
189+ if hasattr (cfg , "test" ) and hasattr (cfg .test , "data" ):
190+ if not getattr (cfg .test .data , "output_path" , None ):
191+ cfg .test .data .output_path = dirpath
170192 else :
171- print (f"❌ cfg.test.data is None, cannot set cache_suffix!" )
172- else :
173- print (f"❌ cfg.test is None, cannot set cache_suffix!" )
174- else : # test mode
175- dirpath = str (output_base / "results" )
176- # Override test output directory in config
177- if hasattr (cfg , "test" ) and hasattr (cfg .test , "data" ):
178- cfg .test .data .output_path = dirpath
193+ # Use the config value, but ensure it's a string path
194+ dirpath = str (cfg .test .data .output_path )
179195
180196 run_dir = setup_run_directory (args .mode , cfg , dirpath )
181- print (f"📂 Output base: { output_base } " )
197+ if output_base is not None :
198+ print (f"📂 Output base: { output_base } " )
182199 else :
183200 # Train mode or no checkpoint - use default config paths
184201 dirpath = cfg .monitor .checkpoint .dirpath
0 commit comments