@@ -10,17 +10,21 @@ import { getS3Client, getS3FilePath } from './utils/dataDumpUtils.js';
1010 * @param filePath file path to the metrics collection results, uses config.js by default
1111 */
1212export async function uploadMetricCollectionDataToS3 ( filePath = config . defaultMetricCollectionResultsFilePath ) {
13+ console . log ( 'Loading metrics collection data from' , filePath ) ;
14+ const metricsCollectionData = JSON . parse ( fs . readFileSync ( filePath , 'utf8' ) ) ;
15+ if ( metricsCollectionData === undefined || metricsCollectionData . length === 0 ) {
16+ throw new Error ( 'Loaded metrics collection data is empty' ) ;
17+ }
18+
1319 try {
1420 console . log ( 'Creating S3 Client...' ) ;
1521 const client = getS3Client ( ) ;
1622 const formattedDate = new Date ( ) . toISOString ( ) . split ( 'T' ) [ 0 ] ;
1723
18- console . log ( 'Loading metrics collection data from' , filePath ) ;
19- const metricsCollectionData = JSON . parse ( fs . readFileSync ( filePath , 'utf8' ) ) ;
20- const table = tableFromJSON ( metricsCollectionData ) ;
21-
2224 console . log ( 'Getting S3 file path...' ) ;
2325 const s3fileProps = getS3FilePath ( ) ;
26+
27+ const table = tableFromJSON ( metricsCollectionData ) ;
2428 const command = new PutObjectCommand ( {
2529 Bucket : s3fileProps . bucketName ,
2630 Key : path . join ( s3fileProps . key , formattedDate , 'metric-collection-results.parquet' ) ,
@@ -30,6 +34,7 @@ export async function uploadMetricCollectionDataToS3(filePath = config.defaultMe
3034 console . log ( 'Dumping data to S3...' ) ;
3135 const response = await client . send ( command ) ;
3236 console . log ( response ) ;
37+ return response ;
3338 } catch ( caught ) {
3439 if ( caught instanceof S3ServiceException && caught . name === 'EntityTooLarge' ) {
3540 console . error (
0 commit comments