@@ -72,14 +72,13 @@ def upload_results_to_s3(bucket_name: str, region: str) -> None:
72
72
hydra_config = HydraConfig .get ()
73
73
74
74
if hydra_config .mode == RunMode .MULTIRUN :
75
- parts = Path (hydra_config .runtime .output_dir ).parent . parts
75
+ source_path = Path (hydra_config .runtime .output_dir ).parent
76
76
77
- date_part , time_part = parts [- 2 :]
77
+ assert len (source_path .parts ) >= 2 , "Source path must have at least 2 parts for date/time extraction"
78
+ date_part , time_part = source_path .parts [- 2 :]
78
79
79
80
s3_target_path = f"s3://{ bucket_name } /results/{ date_part } /{ time_part } "
80
81
81
- source_path = Path (hydra_config .runtime .output_dir ).parent
82
-
83
82
aws_cmd = [
84
83
"aws" ,
85
84
"s3" ,
@@ -91,7 +90,7 @@ def upload_results_to_s3(bucket_name: str, region: str) -> None:
91
90
]
92
91
result = subprocess .run (aws_cmd , capture_output = True , text = True )
93
92
if result .returncode == 0 :
94
- log .info ("Successfully uploaded multirun benchmark results to S3" )
93
+ log .info ("Successfully uploaded benchmark results to S3" )
95
94
else :
96
95
log .error (f"S3 upload failed: { result .stderr .strip ()} " )
97
96
else :
@@ -238,6 +237,17 @@ def run_experiment(cfg: DictConfig) -> None:
238
237
239
238
# Mark success if we get here without exceptions
240
239
metadata ["success" ] = True
240
+
241
+ result_bucket_name = common_config .get ("s3_result_bucket" )
242
+
243
+ # If region is not specified, default to 'us-east-1' as that is the only region we can be relavtively assued that tranium instances are available
244
+ region = common_config .get ("region" , "us-east-1" )
245
+ if result_bucket_name :
246
+ log .info (f"Uploading benchmark results to S3 bucket '{ result_bucket_name } '" )
247
+ upload_results_to_s3 (result_bucket_name , region )
248
+ else :
249
+ log .info ("No results bucket specified (s3_result_bucket), skipping upload" )
250
+
241
251
except Exception :
242
252
log .error ("Benchmark execution failed:" , exc_info = True )
243
253
raise
@@ -250,17 +260,6 @@ def run_experiment(cfg: DictConfig) -> None:
250
260
write_metadata (metadata )
251
261
metadata ["end_time" ] = datetime .now (tz = timezone .utc )
252
262
253
- result_bucket_name = common_config .get ("s3_result_bucket" )
254
-
255
- # If region is not specified, default to 'us-east-1' as that is the only region we can be relavtively assued that tranium instances are available
256
- region = common_config .get ("region" , "us-east-1" )
257
-
258
- if result_bucket_name :
259
- log .info (f"Uploading benchmark results to S3 bucket '{ result_bucket_name } '" )
260
- upload_results_to_s3 (result_bucket_name , region )
261
- else :
262
- log .info ("No results bucket specified (s3_result_bucket), skipping upload" )
263
-
264
263
265
264
if __name__ == "__main__" :
266
265
run_experiment ()
0 commit comments