Skip to content

Commit 882bb1e

Browse files
authored
Remove deprecated MediaManager (#1262)
<!-- Contributing guide: https://github.com/openvinotoolkit/datumaro/blob/develop/CONTRIBUTING.md --> ### Summary - Ticket no. 131646 - `MediaManager` looks deprecated because there is no usage (`.get()`) in the codebase but only remains `.push()` and `.clear()`. - However, this makes [weakref-related errors in OTX 2.0 integration tests](https://github.com/openvinotoolkit/training_extensions/actions/runs/7665862410/job/20892722202?pr=2841). Therefore, it seems good to remove. ### How to test No need for the test ### Checklist <!-- Put an 'x' in all the boxes that apply --> - [x] I have added unit tests to cover my changes.​ - [x] I have added integration tests to cover my changes.​ - [x] I have added the description of my changes into [CHANGELOG](https://github.com/openvinotoolkit/datumaro/blob/develop/CHANGELOG.md).​ - [x] I have updated the [documentation](https://github.com/openvinotoolkit/datumaro/tree/develop/docs) accordingly ### License - [x] I submit _my code changes_ under the same [MIT License](https://github.com/openvinotoolkit/datumaro/blob/develop/LICENSE) that covers the project. Feel free to contact the maintainers if that's a concern. - [x] I have updated the license header for each file (see an example below). ```python # Copyright (C) 2023 Intel Corporation # # SPDX-License-Identifier: MIT ``` --------- Signed-off-by: Kim, Vinnam <vinnam.kim@intel.com>
1 parent f2b930f commit 882bb1e

File tree

7 files changed

+2
-104
lines changed

7 files changed

+2
-104
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6565
(<https://github.com/openvinotoolkit/datumaro/pull/1251>)
6666
- Add default value for target in prune cli
6767
(<https://github.com/openvinotoolkit/datumaro/pull/1253>)
68+
- Remove deprecated MediaManager
69+
(<https://github.com/openvinotoolkit/datumaro/pull/1262>)
6870

6971
## Jan. 2024 Release 1.5.2
7072
### Enhancements

src/datumaro/__init__.py

-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757
from .components.importer import FailingImportErrorPolicy, Importer, ImportErrorPolicy
5858
from .components.launcher import Launcher
5959
from .components.media import Image, MediaElement, Video, VideoFrame
60-
from .components.media_manager import MediaManager
6160
from .components.progress_reporting import (
6261
NullProgressReporter,
6362
ProgressReporter,

src/datumaro/components/media.py

-5
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import os
1010
import os.path as osp
1111
import shutil
12-
import weakref
1312
from copy import deepcopy
1413
from enum import IntEnum
1514
from typing import (
@@ -603,10 +602,6 @@ def __init__(
603602
self._frame_count = None
604603
self._length = None
605604

606-
from .media_manager import MediaManager
607-
608-
MediaManager.get_instance().push(weakref.ref(self), self)
609-
610605
def close(self):
611606
self._iterator = None
612607

src/datumaro/components/media_manager.py

-81
This file was deleted.

src/datumaro/components/project.py

-11
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@
7272
VcsError,
7373
)
7474
from datumaro.components.launcher import Launcher
75-
from datumaro.components.media_manager import MediaManager
7675
from datumaro.util import find, parse_json_file, parse_str_enum_value
7776
from datumaro.util.log_utils import catch_logs, logging_disabled
7877
from datumaro.util.os_util import (
@@ -1812,8 +1811,6 @@ def init(cls, path) -> Project:
18121811
return project
18131812

18141813
def close(self):
1815-
MediaManager.get_instance().clear()
1816-
18171814
if self._dvc:
18181815
self._dvc.close()
18191816
self._dvc = None
@@ -2012,8 +2009,6 @@ def remove_cache_obj(self, ref: Union[Revision, ObjectId]):
20122009
if self.readonly:
20132010
raise ReadonlyProjectError()
20142011

2015-
MediaManager.get_instance().clear()
2016-
20172012
obj_type, obj_hash = self._parse_ref(ref)
20182013

20192014
if self._is_cached(obj_hash):
@@ -2364,8 +2359,6 @@ def remove_source(self, name: str, *, force: bool = False, keep_data: bool = Tru
23642359
if name not in self.working_tree.sources and not force:
23652360
raise UnknownSourceError(name)
23662361

2367-
MediaManager.get_instance().clear()
2368-
23692362
self.working_tree.sources.remove(name)
23702363

23712364
data_dir = self.source_data_dir(name)
@@ -2502,8 +2495,6 @@ def checkout(
25022495

25032496
rev = rev or "HEAD"
25042497

2505-
MediaManager.get_instance().clear()
2506-
25072498
if sources:
25082499
rev_tree = self.get_rev(rev)
25092500

@@ -2714,8 +2705,6 @@ def remove_model(self, name: str):
27142705
if name not in self.models:
27152706
raise KeyError("Unknown model '%s'" % name)
27162707

2717-
MediaManager.get_instance().clear()
2718-
27192708
self._config.models.remove(name)
27202709

27212710
data_dir = self.model_data_dir(name)

tests/integration/cli/test_utils.py

-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import numpy as np
77
import pytest
88

9-
from datumaro.components.media_manager import MediaManager
109
from datumaro.util.scope import on_exit_do, scope_add, scoped
1110

1211
from ...requirements import Requirements, mark_requirement
@@ -22,7 +21,6 @@ class VideoSplittingTest:
2221
@patch("datumaro.components.media.VideoFrame.data", new_callable=PropertyMock)
2322
def test_can_split_video(self, mock_video_frame_data):
2423
mock_video_frame_data.return_value = np.full((32, 32, 3), fill_value=0, dtype=np.uint8)
25-
on_exit_do(MediaManager.get_instance().clear)
2624

2725
test_dir = scope_add(TestDir())
2826
video_path = osp.join(test_dir, "video.avi")

tests/unit/test_video.py

-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
from datumaro.components.dataset import Dataset
1414
from datumaro.components.dataset_base import DatasetItem
1515
from datumaro.components.media import Image, Video, VideoFrame
16-
from datumaro.components.media_manager import MediaManager
1716
from datumaro.components.project import Project
1817
from datumaro.util.scope import Scope, on_exit_do, scope_add, scoped
1918

@@ -122,8 +121,6 @@ class VideoExtractorTest:
122121
@mark_requirement(Requirements.DATUM_GENERAL_REQ)
123122
@scoped
124123
def test_can_read_frames(self, fxt_sample_video):
125-
on_exit_do(MediaManager.get_instance().clear)
126-
127124
expected = Dataset.from_iterable(
128125
[
129126
DatasetItem(
@@ -145,7 +142,6 @@ def test_can_read_frames(self, fxt_sample_video):
145142
@scoped
146143
def test_can_split_and_load(self, fxt_sample_video):
147144
test_dir = scope_add(TestDir())
148-
on_exit_do(MediaManager.get_instance().clear)
149145

150146
expected = Dataset.from_iterable(
151147
[

0 commit comments

Comments
 (0)