Skip to content

Commit 3970cc5

Browse files
committed
Minor changes
1 parent 2d4c252 commit 3970cc5

File tree

2 files changed

+11
-193
lines changed

2 files changed

+11
-193
lines changed

mlflow/tests/RunClient.test.ts

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,12 @@ describe('RunClient', () => {
128128

129129
// POST - Restore a deleted run
130130
describe('restoreRun', () => {
131+
let run: Run;
132+
beforeEach(async () => {
133+
run = (await runClient.createRun(experimentId)) as Run;
134+
});
135+
131136
test('- Should restore a deleted run with run_id', async () => {
132-
const run = (await runClient.createRun(experimentId)) as Run;
133137
await runClient.deleteRun(run.info.run_id);
134138

135139
// check if the run is marked as deleted
@@ -147,8 +151,6 @@ describe('RunClient', () => {
147151
});
148152

149153
test('- Should not throw error when trying to restore a non-deleted run', async () => {
150-
const run = (await runClient.createRun(experimentId)) as Run;
151-
152154
// Attempt to restore a non-deleted run
153155
await expect(
154156
runClient.restoreRun(run.info.run_id)
@@ -403,17 +405,19 @@ describe('RunClient', () => {
403405

404406
// POST - Log a batch of metrics, params, and tags for a run
405407
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+
});
408413

414+
test('- Should not throw error with just run_id', async () => {
409415
await expect(
410416
runClient.logBatch(run.info.run_id)
411417
).resolves.toBeUndefined();
412418
});
413419

414420
test('- Should log batch with optional metrics', async () => {
415-
const run = (await runClient.createRun(experimentId)) as Run;
416-
417421
const metrics: Metrics[] = [
418422
{ key: 'accuracy', value: 0.83, timestamp: 1694000700000 },
419423
{ key: 'loss', value: 0.18, timestamp: 1694000700000 },
@@ -448,8 +452,6 @@ describe('RunClient', () => {
448452
});
449453

450454
test('- Should log batch with optional params', async () => {
451-
const run = (await runClient.createRun(experimentId)) as Run;
452-
453455
const params: Params[] = [
454456
{ key: 'learning_rate', value: '0.0001' },
455457
{ key: 'batch_size', value: '256' },
@@ -464,8 +466,6 @@ describe('RunClient', () => {
464466
});
465467

466468
test('- Should log batch with optional tags', async () => {
467-
const run = (await runClient.createRun(experimentId)) as Run;
468-
469469
const tags: Tags[] = [
470470
{ key: 'model_type', value: 'GradientBoosting' },
471471
{ key: 'data_version', value: 'v1.7' },
@@ -480,8 +480,6 @@ describe('RunClient', () => {
480480
});
481481

482482
test('- Should be able to log up to 1000 metrics', async () => {
483-
const run = (await runClient.createRun(experimentId)) as Run;
484-
485483
const metrics = Array.from({ length: 1000 }, (_, index) => ({
486484
key: `metric${index}`,
487485
value: index,
@@ -495,8 +493,6 @@ describe('RunClient', () => {
495493
});
496494

497495
test('- Should throw error when exceeding 1000 metrics', async () => {
498-
const run = (await runClient.createRun(experimentId)) as Run;
499-
500496
const metrics = Array.from({ length: 1001 }, (_, index) => ({
501497
key: `metric${index}`,
502498
value: index,
@@ -510,8 +506,6 @@ describe('RunClient', () => {
510506
});
511507

512508
test('- Should be able to log up to 100 params', async () => {
513-
const run = (await runClient.createRun(experimentId)) as Run;
514-
515509
const params = Array.from({ length: 100 }, (_, index) => ({
516510
key: `param${index}`,
517511
value: `value${index}`,
@@ -523,8 +517,6 @@ describe('RunClient', () => {
523517
});
524518

525519
test('- Should throw error when exceeding 100 params', async () => {
526-
const run = (await runClient.createRun(experimentId)) as Run;
527-
528520
const params = Array.from({ length: 101 }, (_, index) => ({
529521
key: `param${index}`,
530522
value: `value${index}`,
@@ -536,8 +528,6 @@ describe('RunClient', () => {
536528
});
537529

538530
test('- Should be able to log up to 100 tags', async () => {
539-
const run = (await runClient.createRun(experimentId)) as Run;
540-
541531
const tags = Array.from({ length: 100 }, (_, index) => ({
542532
key: `tag${index}`,
543533
value: `value${index}`,
@@ -549,8 +539,6 @@ describe('RunClient', () => {
549539
});
550540

551541
test('- Should throw error when exceeding 100 tags', async () => {
552-
const run = (await runClient.createRun(experimentId)) as Run;
553-
554542
const tags = Array.from({ length: 101 }, (_, index) => ({
555543
key: `tag${index}`,
556544
value: `value${index}`,

mlflow/tests/RunManagerTestFile.ts

Lines changed: 0 additions & 170 deletions
This file was deleted.

0 commit comments

Comments
 (0)