Skip to content

Commit 6a28633

Browse files
ActiveChooNwarrkan
andauthored
ITEP-31806 Thumbnail preprocessing loaders (#470)
Co-authored-by: Evgeny Romanov <[email protected]>
1 parent 1c609b2 commit 6a28633

File tree

16 files changed

+261
-27
lines changed

16 files changed

+261
-27
lines changed

web_ui/src/core/media/base.interface.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ export enum MEDIA_ANNOTATION_STATUS {
1010
TO_REVISIT = 'to_revisit',
1111
}
1212

13+
export enum MEDIA_PREPROCESSING_STATUS {
14+
SCHEDULED = 'SCHEDULED',
15+
IN_PROGRESS = 'IN_PROGRESS',
16+
FINISHED = 'FINISHED',
17+
FAILED = 'FAILED',
18+
}
19+
1320
export interface AnnotationStatePerTask {
1421
taskId: string;
1522
state: MEDIA_ANNOTATION_STATUS;
@@ -37,4 +44,5 @@ export interface BaseMediaItem {
3744
uploadTime: string;
3845
uploaderId: string;
3946
lastAnnotatorId: string | null;
47+
preprocessingStatus?: MEDIA_PREPROCESSING_STATUS;
4048
}

web_ui/src/core/media/dtos/base.interface.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (C) 2022-2025 Intel Corporation
22
// LIMITED EDGE SOFTWARE DISTRIBUTION LICENSE
33

4-
import { MEDIA_ANNOTATION_STATUS } from '../base.interface';
4+
import { MEDIA_ANNOTATION_STATUS, MEDIA_PREPROCESSING_STATUS } from '../base.interface';
55

66
export interface AnnotationStatePerTaskDTO {
77
task_id: string;
@@ -18,4 +18,7 @@ export interface BaseMediaDTO {
1818
annotation_state_per_task: AnnotationStatePerTaskDTO[];
1919
annotation_scene_id?: string;
2020
last_annotator_id: string | null;
21+
preprocessing: {
22+
status: MEDIA_PREPROCESSING_STATUS;
23+
};
2124
}

web_ui/src/core/media/services/api-media-service/api-media-service.test.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { API_URLS } from '../../../../../packages/core/src/services/urls';
88
import { getMockedDatasetIdentifier } from '../../../../test-utils/mocked-items-factory/mocked-identifiers';
99
import { server } from '../../../annotations/services/test-utils';
1010
import { MEDIA_TYPE } from '../../base-media.interface';
11-
import { MEDIA_ANNOTATION_STATUS } from '../../base.interface';
11+
import { MEDIA_ANNOTATION_STATUS, MEDIA_PREPROCESSING_STATUS } from '../../base.interface';
1212
import { ImageIdentifier } from '../../image.interface';
1313
import { VideoFrameIdentifier } from '../../video.interface';
1414
import { createApiMediaService } from './api-media-service';
@@ -43,6 +43,9 @@ const activeMediaResponse = () => {
4343
'/api/v1/workspaces/61039c80bd1cde3821dcfca6/projects/61039c81bd1cde3821dcfcad/datasets/dummy/media/videos/6103b96e2360313e324963f2/display/thumb',
4444
type: 'video',
4545
upload_time: '2021-07-30T08:33:50.399',
46+
preprocessing: {
47+
status: MEDIA_PREPROCESSING_STATUS.FINISHED,
48+
},
4649
},
4750
{
4851
id: '61039cccbd1cde3821dcfcb2',
@@ -108,6 +111,7 @@ describe('API media service', () => {
108111
width: 600,
109112
},
110113
status: MEDIA_ANNOTATION_STATUS.NONE,
114+
preprocessingStatus: MEDIA_PREPROCESSING_STATUS.FINISHED,
111115
});
112116
});
113117

@@ -173,6 +177,7 @@ describe('API media service', () => {
173177
frames: 5700,
174178
},
175179
status: 'none',
180+
preprocessingStatus: MEDIA_PREPROCESSING_STATUS.FINISHED,
176181
});
177182
});
178183

@@ -241,6 +246,7 @@ describe('API media service', () => {
241246
frames: 5700,
242247
frameStride: 60,
243248
},
249+
preprocessingStatus: MEDIA_PREPROCESSING_STATUS.FINISHED,
244250
},
245251
{
246252
identifier: firstVideoFrameIdentifier,
@@ -263,6 +269,7 @@ describe('API media service', () => {
263269
frames: 5700,
264270
frameStride: 60,
265271
},
272+
preprocessingStatus: MEDIA_PREPROCESSING_STATUS.FINISHED,
266273
},
267274
{
268275
identifier: imageIdentifier,
@@ -281,6 +288,7 @@ describe('API media service', () => {
281288
height: 1599,
282289
width: 899,
283290
},
291+
preprocessingStatus: MEDIA_PREPROCESSING_STATUS.FINISHED,
284292
},
285293
]);
286294
});

web_ui/src/core/media/services/utils.test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// LIMITED EDGE SOFTWARE DISTRIBUTION LICENSE
33

44
import { DatasetIdentifier } from '../../projects/dataset.interface';
5-
import { MEDIA_ANNOTATION_STATUS } from '../base.interface';
5+
import { MEDIA_ANNOTATION_STATUS, MEDIA_PREPROCESSING_STATUS } from '../base.interface';
66
import { MediaItemDTO } from '../dtos/media.interface';
77
import { getMediaItemFromDTO } from './utils';
88

@@ -44,6 +44,9 @@ describe('getMediaItemFromDTO', () => {
4444
state: MEDIA_ANNOTATION_STATUS.NONE,
4545
frame_index: 0,
4646
last_annotator_id: null,
47+
preprocessing: {
48+
status: MEDIA_PREPROCESSING_STATUS.FINISHED,
49+
},
4750
};
4851

4952
const datasetIdentifier = {
@@ -88,6 +91,7 @@ describe('getMediaItemFromDTO', () => {
8891
),
8992
uploadTime: '2022-04-01T14:46:17.244000+00:00',
9093
uploaderId: '9b89482b-3894-41a1-a67c-7d1fbe8d47ad',
94+
preprocessingStatus: MEDIA_PREPROCESSING_STATUS.FINISHED,
9195
});
9296
});
9397
});

web_ui/src/core/media/services/utils.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { AnnotationStatePerTaskDTO } from '../dtos/base.interface';
1313
import { ActiveMediaItemDTO, MediaItemDTO } from '../dtos/media.interface';
1414
import { FilterVideoFrameMediaDTO, VideoFrameMediaDTO, VideoStatisticsDTO } from '../dtos/video.interface';
1515
import { MediaIdentifier, MediaItem } from '../media.interface';
16+
import { getDefaultPreprocessingStatus } from '../utils/preprocessing.utils';
1617
import { FilterVideoFrame, isVideo, isVideoFrame, VideoStatistics } from '../video.interface';
1718

1819
export const mediaIdentifierToDTO = (mediaIdentifier: MediaIdentifier): ImageIdDTO | VideoIdDTO | VideoFrameIdDTO => {
@@ -68,7 +69,10 @@ export const getMediaItemFromDTO = (
6869
upload_time,
6970
uploader_id,
7071
last_annotator_id,
72+
preprocessing,
7173
} = item;
74+
75+
const preprocessing_status = preprocessing?.status;
7276
const { size, height, width } = media_information;
7377

7478
const baseMediaItem = {
@@ -84,6 +88,7 @@ export const getMediaItemFromDTO = (
8488
uploaderId: uploader_id,
8589
annotationStatePerTask: getAnnotationStatePerTaskFromDTO(annotation_state_per_task),
8690
lastAnnotatorId: last_annotator_id,
91+
preprocessingStatus: getDefaultPreprocessingStatus(preprocessing_status),
8792
};
8893

8994
switch (item.type) {
@@ -213,6 +218,7 @@ export const getActiveMediaItems = (
213218
uploadTime: videoMediaItem.uploadTime,
214219
uploaderId: videoMediaItem.uploaderId,
215220
lastAnnotatorId: videoMediaItem.lastAnnotatorId,
221+
preprocessingStatus: videoMediaItem.preprocessingStatus,
216222
};
217223
});
218224

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Copyright (C) 2022-2025 Intel Corporation
2+
// LIMITED EDGE SOFTWARE DISTRIBUTION LICENSE
3+
4+
import { MEDIA_PREPROCESSING_STATUS } from '../base.interface';
5+
import { getDefaultPreprocessingStatus, isMediaPreprocessing } from './preprocessing.utils';
6+
7+
describe('preprocessing.utils', () => {
8+
describe('Status Check Functions', () => {
9+
describe('isMediaPreprocessing', () => {
10+
it.each([
11+
[MEDIA_PREPROCESSING_STATUS.SCHEDULED, true],
12+
[MEDIA_PREPROCESSING_STATUS.IN_PROGRESS, true],
13+
[MEDIA_PREPROCESSING_STATUS.FINISHED, false],
14+
[MEDIA_PREPROCESSING_STATUS.FAILED, false],
15+
[undefined, false],
16+
])('should return %s when status is %s', (status, expected) => {
17+
expect(isMediaPreprocessing(status)).toBe(expected);
18+
});
19+
});
20+
});
21+
22+
describe('Utility Functions', () => {
23+
describe('getDefaultPreprocessingStatus', () => {
24+
it('should return FINISHED for undefined status', () => {
25+
expect(getDefaultPreprocessingStatus(undefined)).toBe(MEDIA_PREPROCESSING_STATUS.FINISHED);
26+
});
27+
28+
it.each([
29+
MEDIA_PREPROCESSING_STATUS.SCHEDULED,
30+
MEDIA_PREPROCESSING_STATUS.IN_PROGRESS,
31+
MEDIA_PREPROCESSING_STATUS.FAILED,
32+
MEDIA_PREPROCESSING_STATUS.FINISHED,
33+
])('should return the provided status when defined: %s', (status) => {
34+
expect(getDefaultPreprocessingStatus(status)).toBe(status);
35+
});
36+
});
37+
});
38+
});
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright (C) 2022-2025 Intel Corporation
2+
// LIMITED EDGE SOFTWARE DISTRIBUTION LICENSE
3+
4+
import { MEDIA_PREPROCESSING_STATUS } from '../base.interface';
5+
6+
export const isMediaPreprocessing = (status?: MEDIA_PREPROCESSING_STATUS): boolean => {
7+
return status === MEDIA_PREPROCESSING_STATUS.SCHEDULED || status === MEDIA_PREPROCESSING_STATUS.IN_PROGRESS;
8+
};
9+
10+
export const getDefaultPreprocessingStatus = (status?: MEDIA_PREPROCESSING_STATUS): MEDIA_PREPROCESSING_STATUS => {
11+
return status ?? MEDIA_PREPROCESSING_STATUS.FINISHED;
12+
};

web_ui/src/core/tests/services/utils.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { v4 as uuidv4 } from 'uuid';
77
import { MEDIA_TYPE } from '../../media/base-media.interface';
88
import { Image } from '../../media/image.interface';
99
import { getAnnotationStatePerTaskFromDTO } from '../../media/services/utils';
10+
import { getDefaultPreprocessingStatus } from '../../media/utils/preprocessing.utils';
1011
import { ModelsGroups, ModelVersion } from '../../models/models.interface';
1112
import {
1213
BASELINE_MODEL,
@@ -123,7 +124,16 @@ export const getTestEntity = (test: TestDTO, modelsGroups: ModelsGroups[]): Test
123124
};
124125

125126
export const getTestMediaItemEntity = (mediaItem: TestMediaItemDTO): TestMediaItem => {
126-
const { name, annotation_state_per_task, thumbnail, upload_time, uploader_id, id, last_annotator_id } = mediaItem;
127+
const {
128+
name,
129+
annotation_state_per_task,
130+
thumbnail,
131+
upload_time,
132+
uploader_id,
133+
id,
134+
last_annotator_id,
135+
preprocessing,
136+
} = mediaItem;
127137

128138
const baseMediaItem = {
129139
name,
@@ -132,6 +142,7 @@ export const getTestMediaItemEntity = (mediaItem: TestMediaItemDTO): TestMediaIt
132142
uploaderId: uploader_id,
133143
annotationStatePerTask: getAnnotationStatePerTaskFromDTO(annotation_state_per_task),
134144
lastAnnotatorId: last_annotator_id,
145+
preprocessingStatus: getDefaultPreprocessingStatus(preprocessing?.status),
135146
};
136147

137148
switch (mediaItem.type) {

web_ui/src/pages/annotator/components/video-player/propagate-annotations/propagate-annotations.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ describe('Propagate annotations', () => {
125125
};
126126
});
127127

128-
const videoFrame = getMockedVideoFrameMediaItem({});
128+
const { preprocessingStatus, ...videoFrame } = getMockedVideoFrameMediaItem({});
129129

130130
const src = API_URLS.MEDIA_ITEM_SRC(mockDatasetIdentifier, { ...videoFrame.identifier, frameNumber: 60 });
131131

web_ui/src/pages/annotator/components/video-player/video-player.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ describe('Video player', () => {
8888
jest.clearAllTimers();
8989
});
9090

91-
const videoFrame = getMockedVideoFrameMediaItem({});
91+
const { preprocessingStatus, ...videoFrame } = getMockedVideoFrameMediaItem({});
9292

9393
it('Shows video player controls', async () => {
9494
await renderVideoPlayer(videoFrame);

0 commit comments

Comments
 (0)