@@ -128,8 +128,12 @@ describe('RunClient', () => {
128
128
129
129
// POST - Restore a deleted run
130
130
describe ( 'restoreRun' , ( ) => {
131
+ let run : Run ;
132
+ beforeEach ( async ( ) => {
133
+ run = ( await runClient . createRun ( experimentId ) ) as Run ;
134
+ } ) ;
135
+
131
136
test ( '- Should restore a deleted run with run_id' , async ( ) => {
132
- const run = ( await runClient . createRun ( experimentId ) ) as Run ;
133
137
await runClient . deleteRun ( run . info . run_id ) ;
134
138
135
139
// check if the run is marked as deleted
@@ -147,8 +151,6 @@ describe('RunClient', () => {
147
151
} ) ;
148
152
149
153
test ( '- Should not throw error when trying to restore a non-deleted run' , async ( ) => {
150
- const run = ( await runClient . createRun ( experimentId ) ) as Run ;
151
-
152
154
// Attempt to restore a non-deleted run
153
155
await expect (
154
156
runClient . restoreRun ( run . info . run_id )
@@ -403,17 +405,19 @@ describe('RunClient', () => {
403
405
404
406
// POST - Log a batch of metrics, params, and tags for a run
405
407
describe ( 'logBatch' , ( ) => {
406
- test ( '- Should not throw error with just run_id' , async ( ) => {
407
- const run = ( await runClient . createRun ( experimentId ) ) as Run ;
408
+ let run : Run ;
409
+
410
+ beforeEach ( async ( ) => {
411
+ run = ( await runClient . createRun ( experimentId ) ) as Run ;
412
+ } ) ;
408
413
414
+ test ( '- Should not throw error with just run_id' , async ( ) => {
409
415
await expect (
410
416
runClient . logBatch ( run . info . run_id )
411
417
) . resolves . toBeUndefined ( ) ;
412
418
} ) ;
413
419
414
420
test ( '- Should log batch with optional metrics' , async ( ) => {
415
- const run = ( await runClient . createRun ( experimentId ) ) as Run ;
416
-
417
421
const metrics : Metrics [ ] = [
418
422
{ key : 'accuracy' , value : 0.83 , timestamp : 1694000700000 } ,
419
423
{ key : 'loss' , value : 0.18 , timestamp : 1694000700000 } ,
@@ -448,8 +452,6 @@ describe('RunClient', () => {
448
452
} ) ;
449
453
450
454
test ( '- Should log batch with optional params' , async ( ) => {
451
- const run = ( await runClient . createRun ( experimentId ) ) as Run ;
452
-
453
455
const params : Params [ ] = [
454
456
{ key : 'learning_rate' , value : '0.0001' } ,
455
457
{ key : 'batch_size' , value : '256' } ,
@@ -464,8 +466,6 @@ describe('RunClient', () => {
464
466
} ) ;
465
467
466
468
test ( '- Should log batch with optional tags' , async ( ) => {
467
- const run = ( await runClient . createRun ( experimentId ) ) as Run ;
468
-
469
469
const tags : Tags [ ] = [
470
470
{ key : 'model_type' , value : 'GradientBoosting' } ,
471
471
{ key : 'data_version' , value : 'v1.7' } ,
@@ -480,8 +480,6 @@ describe('RunClient', () => {
480
480
} ) ;
481
481
482
482
test ( '- Should be able to log up to 1000 metrics' , async ( ) => {
483
- const run = ( await runClient . createRun ( experimentId ) ) as Run ;
484
-
485
483
const metrics = Array . from ( { length : 1000 } , ( _ , index ) => ( {
486
484
key : `metric${ index } ` ,
487
485
value : index ,
@@ -495,8 +493,6 @@ describe('RunClient', () => {
495
493
} ) ;
496
494
497
495
test ( '- Should throw error when exceeding 1000 metrics' , async ( ) => {
498
- const run = ( await runClient . createRun ( experimentId ) ) as Run ;
499
-
500
496
const metrics = Array . from ( { length : 1001 } , ( _ , index ) => ( {
501
497
key : `metric${ index } ` ,
502
498
value : index ,
@@ -510,8 +506,6 @@ describe('RunClient', () => {
510
506
} ) ;
511
507
512
508
test ( '- Should be able to log up to 100 params' , async ( ) => {
513
- const run = ( await runClient . createRun ( experimentId ) ) as Run ;
514
-
515
509
const params = Array . from ( { length : 100 } , ( _ , index ) => ( {
516
510
key : `param${ index } ` ,
517
511
value : `value${ index } ` ,
@@ -523,8 +517,6 @@ describe('RunClient', () => {
523
517
} ) ;
524
518
525
519
test ( '- Should throw error when exceeding 100 params' , async ( ) => {
526
- const run = ( await runClient . createRun ( experimentId ) ) as Run ;
527
-
528
520
const params = Array . from ( { length : 101 } , ( _ , index ) => ( {
529
521
key : `param${ index } ` ,
530
522
value : `value${ index } ` ,
@@ -536,8 +528,6 @@ describe('RunClient', () => {
536
528
} ) ;
537
529
538
530
test ( '- Should be able to log up to 100 tags' , async ( ) => {
539
- const run = ( await runClient . createRun ( experimentId ) ) as Run ;
540
-
541
531
const tags = Array . from ( { length : 100 } , ( _ , index ) => ( {
542
532
key : `tag${ index } ` ,
543
533
value : `value${ index } ` ,
@@ -549,8 +539,6 @@ describe('RunClient', () => {
549
539
} ) ;
550
540
551
541
test ( '- Should throw error when exceeding 100 tags' , async ( ) => {
552
- const run = ( await runClient . createRun ( experimentId ) ) as Run ;
553
-
554
542
const tags = Array . from ( { length : 101 } , ( _ , index ) => ( {
555
543
key : `tag${ index } ` ,
556
544
value : `value${ index } ` ,
0 commit comments