1919import datetime
2020import json
2121import os
22- import time
2322import uuid
2423from dataclasses import asdict , dataclass , field
2524from enum import Enum
2625from typing import Any , Callable , Optional
2726
28- import psutil # You might need to install this: pip install psutil
27+ import psutil
2928import torch
3029from peft import PeftConfig
3130
3231
3332# Constants
3433FILE_NAME_BENCHMARK_PARAMS = "benchmark_params.json"
34+ FILE_NAME_DEFAULT_CONFIG = "default_config.json"
3535
3636# Main paths for storing results
3737RESULT_PATH = os .path .join (os .path .dirname (__file__ ), "results" )
@@ -73,7 +73,7 @@ def __post_init__(self):
7373 """Initialize structured data format."""
7474 # Default run_info
7575 self .run_info = {
76- "timestamp" : datetime .datetime .now ().isoformat (),
76+ "timestamp" : datetime .datetime .now (tz = datetime . timezone . utc ).isoformat (),
7777 "duration" : 0.0 ,
7878 "status" : self .status .value ,
7979 "hardware" : {
@@ -347,7 +347,7 @@ def get_variant_configs(self) -> list["BenchmarkConfig"]:
347347
348348def generate_experiment_id () -> str :
349349 """Generate a unique experiment ID."""
350- return datetime .datetime .now ().strftime ("%Y%m%d_%H%M%S" ) + "_" + uuid . uuid4 (). hex [: 8 ]
350+ return datetime .datetime .now (tz = datetime . timezone . utc ).strftime ("%Y%m%d_%H%M%S" )
351351
352352
353353def validate_experiment_path (path : str ) -> tuple [str , "BenchmarkConfig" , Any ]:
@@ -360,11 +360,16 @@ def validate_experiment_path(path: str) -> tuple[str, "BenchmarkConfig", Any]:
360360
361361 # Check for benchmark params file
362362 benchmark_params_path = os .path .join (path , FILE_NAME_BENCHMARK_PARAMS )
363- if not os .path .exists (benchmark_params_path ):
364- raise FileNotFoundError (f"Benchmark params not found: { benchmark_params_path } " )
365-
366- # Load benchmark config
367- benchmark_config = BenchmarkConfig .from_json (benchmark_params_path )
363+ default_config_path = os .path .join (os .path .dirname (__file__ ), FILE_NAME_DEFAULT_CONFIG )
364+
365+ # Use benchmark_params.json if exists, otherwise use default config
366+ if os .path .exists (benchmark_params_path ):
367+ benchmark_config = BenchmarkConfig .from_json (benchmark_params_path )
368+ elif os .path .exists (default_config_path ):
369+ print (f"No benchmark_params.json found in { path } , using default configuration" )
370+ benchmark_config = BenchmarkConfig .from_json (default_config_path )
371+ else :
372+ raise FileNotFoundError (f"Neither benchmark_params.json nor default_config.json found" )
368373
369374 # Try to load PEFT config
370375 try :
0 commit comments