Skip to content

Commit b618912

Browse files
authored
feat(LAB-3616): remove default processingParameters when not specified (#1903)
1 parent b76bfff commit b618912

2 files changed

Lines changed: 23 additions & 79 deletions

File tree

src/kili/services/asset_import/video.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,20 +37,12 @@ class VideoMixin:
3737
"""Helping functions for importing Video assets."""
3838

3939
@staticmethod
40-
def get_video_processing_parameters(asset: AssetLike, from_frames: bool):
40+
def get_video_processing_parameters(asset: AssetLike):
4141
"""Base method for adding video processing parameters."""
4242
json_metadata = asset.get("json_metadata", {})
43-
processing_parameters = json_metadata.get( # pyright: ignore[reportGeneralTypeIssues]
43+
return json_metadata.get( # pyright: ignore[reportGeneralTypeIssues]
4444
"processingParameters", {}
4545
)
46-
video_parameters = [
47-
("shouldKeepNativeFrameRate", not from_frames),
48-
("framesPlayedPerSecond", 30),
49-
("shouldUseNativeVideo", not from_frames),
50-
]
51-
for key, default_value in video_parameters:
52-
processing_parameters[key] = processing_parameters.get(key, default_value)
53-
return processing_parameters
5446

5547
@staticmethod
5648
def map_frame_urls_to_index(asset: AssetLike):
@@ -70,7 +62,7 @@ class VideoContentBatchImporter(ContentBatchImporter, VideoMixin):
7062
def add_video_processing_parameters(self, asset):
7163
"""Add video processing parameters for a content upload."""
7264
json_metadata = asset.get("json_metadata", {})
73-
processing_parameters = self.get_video_processing_parameters(asset, from_frames=False)
65+
processing_parameters = self.get_video_processing_parameters(asset)
7466
json_metadata = {**json_metadata, "processingParameters": processing_parameters}
7567
return AssetLike(**{**asset, "json_metadata": json_metadata}) # type: ignore
7668

@@ -88,7 +80,7 @@ class FrameBatchImporter(JsonContentBatchImporter, VideoMixin):
8880
def add_video_processing_parameters(self, asset):
8981
"""Add video processing parameters for a frames upload."""
9082
json_metadata = asset.get("json_metadata", {})
91-
processing_parameters = self.get_video_processing_parameters(asset, from_frames=True)
83+
processing_parameters = self.get_video_processing_parameters(asset)
9284
json_metadata = {**json_metadata, "processingParameters": processing_parameters}
9385
return AssetLike(**{**asset, "json_metadata": json_metadata}) # type: ignore
9486

tests/unit/services/asset_import/test_import_video.py

Lines changed: 19 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,22 @@ def test_upload_from_one_local_video_file_to_native(self, *_):
2525
self.kili.kili_api_gateway.get_project.return_value = {"inputType": "VIDEO"}
2626
url = "https://storage.googleapis.com/label-public-staging/asset-test-sample/video/short_video.mp4"
2727
path = self.downloader(url)
28-
assets = [{"content": path, "external_id": "local video file to native"}]
28+
assets = [
29+
{
30+
"content": path,
31+
"external_id": "local video file to native",
32+
"json_metadata": {
33+
"processingParameters": {
34+
"framesPlayedPerSecond": 20,
35+
}
36+
},
37+
}
38+
]
2939
import_assets(self.kili, self.project_id, assets, disable_tqdm=True)
3040
expected_json_metadata = json.dumps(
3141
{
3242
"processingParameters": {
33-
"shouldKeepNativeFrameRate": True,
34-
"framesPlayedPerSecond": 30,
35-
"shouldUseNativeVideo": True,
43+
"framesPlayedPerSecond": 20,
3644
}
3745
}
3846
)
@@ -51,15 +59,7 @@ def test_upload_from_one_hosted_video_file_to_native(self, *_):
5159
{"content": "https://hosted-data", "external_id": "hosted file", "id": "unique_id"}
5260
]
5361
import_assets(self.kili, self.project_id, assets, disable_tqdm=True)
54-
expected_json_metadata = json.dumps(
55-
{
56-
"processingParameters": {
57-
"shouldKeepNativeFrameRate": True,
58-
"framesPlayedPerSecond": 30,
59-
"shouldUseNativeVideo": True,
60-
}
61-
}
62-
)
62+
expected_json_metadata = json.dumps({"processingParameters": {}})
6363
expected_parameters = self.get_expected_async_call(
6464
["https://hosted-data"],
6565
["hosted file"],
@@ -78,15 +78,7 @@ def test_upload_from_one_hosted_video_authorized_while_local_forbidden(self, *_)
7878
{"content": "https://hosted-data", "external_id": "hosted file", "id": "unique_id"}
7979
]
8080
import_assets(self.kili, self.project_id, assets, disable_tqdm=True)
81-
expected_json_metadata = json.dumps(
82-
{
83-
"processingParameters": {
84-
"shouldKeepNativeFrameRate": True,
85-
"framesPlayedPerSecond": 30,
86-
"shouldUseNativeVideo": True,
87-
}
88-
}
89-
)
81+
expected_json_metadata = json.dumps({"processingParameters": {}})
9082
expected_parameters = self.get_expected_async_call(
9183
["https://hosted-data"],
9284
["hosted file"],
@@ -123,8 +115,6 @@ def test_upload_one_local_video_to_frames(self, *_):
123115
{
124116
"processingParameters": {
125117
"shouldUseNativeVideo": False,
126-
"shouldKeepNativeFrameRate": True,
127-
"framesPlayedPerSecond": 30,
128118
}
129119
}
130120
)
@@ -157,8 +147,6 @@ def test_upload_one_hosted_video_to_frames(self, *_):
157147
{
158148
"processingParameters": {
159149
"shouldUseNativeVideo": False,
160-
"shouldKeepNativeFrameRate": True,
161-
"framesPlayedPerSecond": 30,
162150
}
163151
}
164152
)
@@ -187,15 +175,7 @@ def test_upload_one_video_from_local_frames(self, *_):
187175
}
188176
]
189177
import_assets(self.kili, self.project_id, assets, disable_tqdm=True)
190-
expected_json_metadata = json.dumps(
191-
{
192-
"processingParameters": {
193-
"shouldKeepNativeFrameRate": False,
194-
"framesPlayedPerSecond": 30,
195-
"shouldUseNativeVideo": False,
196-
}
197-
}
198-
)
178+
expected_json_metadata = json.dumps({"processingParameters": {}})
199179
expected_parameters = self.get_expected_sync_call(
200180
[""],
201181
["from local frames"],
@@ -219,15 +199,7 @@ def test_upload_one_video_from_hosted_frames(self, *_):
219199
}
220200
]
221201
import_assets(self.kili, self.project_id, assets, disable_tqdm=True)
222-
expected_json_metadata = json.dumps(
223-
{
224-
"processingParameters": {
225-
"shouldKeepNativeFrameRate": False,
226-
"framesPlayedPerSecond": 30,
227-
"shouldUseNativeVideo": False,
228-
}
229-
}
230-
)
202+
expected_json_metadata = json.dumps({"processingParameters": {}})
231203
expected_parameters = self.get_expected_sync_call(
232204
[""],
233205
["from hosted frames"],
@@ -252,15 +224,7 @@ def test_upload_frames_call_from_label_import(self, *_):
252224
}
253225
]
254226
import_assets(self.kili, self.project_id, assets)
255-
expected_json_metadata = json.dumps(
256-
{
257-
"processingParameters": {
258-
"shouldKeepNativeFrameRate": False,
259-
"framesPlayedPerSecond": 30,
260-
"shouldUseNativeVideo": False,
261-
}
262-
}
263-
)
227+
expected_json_metadata = json.dumps({"processingParameters": {}})
264228
expected_parameters = self.get_expected_sync_call(
265229
["https://reading_signed_url_content"],
266230
["from label-import"],
@@ -286,11 +250,7 @@ def test_import_one_video_with_metadata(self, *_):
286250
{
287251
"fromBucket": True,
288252
"score": 10,
289-
"processingParameters": {
290-
"shouldKeepNativeFrameRate": True,
291-
"framesPlayedPerSecond": 30,
292-
"shouldUseNativeVideo": True,
293-
},
253+
"processingParameters": {},
294254
}
295255
)
296256
expected_parameters = self.get_expected_async_call(
@@ -319,15 +279,7 @@ def test_upload_from_one_hosted_video_file_to_video_legacy_project(self, *_):
319279
{"content": "https://hosted-data", "external_id": "hosted file", "id": "unique_id"}
320280
]
321281
import_assets(self.kili, self.project_id, assets, disable_tqdm=True)
322-
expected_json_metadata = json.dumps(
323-
{
324-
"processingParameters": {
325-
"shouldKeepNativeFrameRate": True,
326-
"framesPlayedPerSecond": 30,
327-
"shouldUseNativeVideo": True,
328-
}
329-
}
330-
)
282+
expected_json_metadata = json.dumps({"processingParameters": {}})
331283
expected_parameters = self.get_expected_async_call(
332284
["https://hosted-data"],
333285
["hosted file"],

0 commit comments

Comments
 (0)