From c1940f80fb5cb4d0e063778c28f5bdbf8646dd47 Mon Sep 17 00:00:00 2001 From: Tobias Klockau Date: Mon, 18 Nov 2024 12:47:19 +0100 Subject: [PATCH 1/4] docs: add deprecation warnings to all functions that will be removed in 4.0 --- raillabel/filter/filter.py | 9 +++++++++ raillabel/load_/loader_classes/loader_understand_ai.py | 6 ++++++ raillabel/stats/generate_timespan.py | 5 +++++ raillabel/validate/validate.py | 5 +++++ 4 files changed, 25 insertions(+) diff --git a/raillabel/filter/filter.py b/raillabel/filter/filter.py index afa17bf..e3ee76e 100644 --- a/raillabel/filter/filter.py +++ b/raillabel/filter/filter.py @@ -3,11 +3,17 @@ import pickle import typing as t +from warnings import warn + +from typing_extensions import deprecated from .. import format from . import _filter_classes +@deprecated( + "filter() will not be included in any future releases. Use `scene.filter()` in those versions instead" +) def filter(scene: format.Scene, **kwargs) -> format.Scene: """Return a copy of the scene with the annotations filtered. @@ -83,6 +89,9 @@ def filter(scene: format.Scene, **kwargs) -> format.Scene: TypeError if an unexpected keyword argument has been set. """ + warn( + "filter() will not be included in any future releases. Use `scene.filter()` in those versions instead" + ) filters_by_level = _collect_filter_classes(kwargs) filtered_scene, used_sensors, used_objects = _filter_scene(_copy(scene), filters_by_level) diff --git a/raillabel/load_/loader_classes/loader_understand_ai.py b/raillabel/load_/loader_classes/loader_understand_ai.py index d196360..b15d902 100644 --- a/raillabel/load_/loader_classes/loader_understand_ai.py +++ b/raillabel/load_/loader_classes/loader_understand_ai.py @@ -3,6 +3,9 @@ import typing as t from pathlib import Path +from warnings import warn + +from typing_extensions import deprecated from ..._util._warning import _WarningsLogger from ...format import understand_ai as uai_format @@ -10,6 +13,7 @@ from .loader_raillabel import LoaderRailLabel +@deprecated("This class will be moved to `raillabel_providerkit` in all future releases.") class LoaderUnderstandAi(LoaderABC): """Loader class for the Understand.Ai Trains4 annotation format. @@ -49,6 +53,8 @@ def load(self, data: dict, validate: bool = False) -> uai_format.Scene: The loaded scene with the data. """ + warn("This class will be moved to `raillabel_providerkit` in all future releases.") + if validate: self.validate(data) diff --git a/raillabel/stats/generate_timespan.py b/raillabel/stats/generate_timespan.py index 44853d7..5847c31 100644 --- a/raillabel/stats/generate_timespan.py +++ b/raillabel/stats/generate_timespan.py @@ -3,10 +3,14 @@ import typing as t from decimal import Decimal +from warnings import warn + +from typing_extensions import deprecated from ..format import Scene +@deprecated("This function will be removed in all future releases") def generate_timespan(scene: Scene) -> t.Tuple[t.Optional[Decimal], t.Optional[Decimal]]: """Return start and end timestamp of the scene. @@ -22,6 +26,7 @@ def generate_timespan(scene: Scene) -> t.Tuple[t.Optional[Decimal], t.Optional[D decimal.Decimal or None End timestamp of the scene. Is None if the scene has no frames. """ + warn("This function will be removed in all future releases") start_timestamp = None end_timestamp = None diff --git a/raillabel/validate/validate.py b/raillabel/validate/validate.py index 0beab3e..55c01cf 100644 --- a/raillabel/validate/validate.py +++ b/raillabel/validate/validate.py @@ -5,13 +5,16 @@ import os import typing as t from pathlib import Path +from warnings import warn import fastjsonschema import jsonschema +from typing_extensions import deprecated from .. import exceptions +@deprecated("This function will be moved to `raillabel_providerkit` in all future releases.") def validate(data: dict, schema_path: str = "raillabel") -> t.Tuple[bool, t.List[str]]: """Validate JSON data represented by a dict via a given schema. @@ -38,6 +41,8 @@ def validate(data: dict, schema_path: str = "raillabel") -> t.Tuple[bool, t.List # options must be distinguished. It is therefore assumed, that a complete path contains at # # least one '/' or '\'. + warn("This function will be moved to `raillabel_providerkit` in all future releases.") + if "/" in schema_path or "\\" in schema_path: # if schema_path is a complete path schema_path = Path(schema_path) From c5c84252ebfa522317d0ae065f9722af4a80280a Mon Sep 17 00:00:00 2001 From: Tobias Klockau Date: Mon, 18 Nov 2024 12:49:56 +0100 Subject: [PATCH 2/4] fix: make type_extensions import only for type checking --- raillabel/filter/filter.py | 3 ++- raillabel/stats/generate_timespan.py | 3 ++- raillabel/validate/validate.py | 4 +++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/raillabel/filter/filter.py b/raillabel/filter/filter.py index e3ee76e..283dffa 100644 --- a/raillabel/filter/filter.py +++ b/raillabel/filter/filter.py @@ -5,7 +5,8 @@ import typing as t from warnings import warn -from typing_extensions import deprecated +if t.TYPE_CHECKING: + from typing_extensions import deprecated from .. import format from . import _filter_classes diff --git a/raillabel/stats/generate_timespan.py b/raillabel/stats/generate_timespan.py index 5847c31..af85c3e 100644 --- a/raillabel/stats/generate_timespan.py +++ b/raillabel/stats/generate_timespan.py @@ -5,7 +5,8 @@ from decimal import Decimal from warnings import warn -from typing_extensions import deprecated +if t.TYPE_CHECKING: + from typing_extensions import deprecated from ..format import Scene diff --git a/raillabel/validate/validate.py b/raillabel/validate/validate.py index 55c01cf..97057df 100644 --- a/raillabel/validate/validate.py +++ b/raillabel/validate/validate.py @@ -9,7 +9,9 @@ import fastjsonschema import jsonschema -from typing_extensions import deprecated + +if t.TYPE_CHECKING: + from typing_extensions import deprecated from .. import exceptions From 38474b08c51ce50a65a5514c3452780eb57b5fd7 Mon Sep 17 00:00:00 2001 From: Tobias Klockau Date: Mon, 18 Nov 2024 12:53:05 +0100 Subject: [PATCH 3/4] chore: revert last commit --- raillabel/filter/filter.py | 3 +-- raillabel/stats/generate_timespan.py | 3 +-- raillabel/validate/validate.py | 4 +--- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/raillabel/filter/filter.py b/raillabel/filter/filter.py index 283dffa..e3ee76e 100644 --- a/raillabel/filter/filter.py +++ b/raillabel/filter/filter.py @@ -5,8 +5,7 @@ import typing as t from warnings import warn -if t.TYPE_CHECKING: - from typing_extensions import deprecated +from typing_extensions import deprecated from .. import format from . import _filter_classes diff --git a/raillabel/stats/generate_timespan.py b/raillabel/stats/generate_timespan.py index af85c3e..5847c31 100644 --- a/raillabel/stats/generate_timespan.py +++ b/raillabel/stats/generate_timespan.py @@ -5,8 +5,7 @@ from decimal import Decimal from warnings import warn -if t.TYPE_CHECKING: - from typing_extensions import deprecated +from typing_extensions import deprecated from ..format import Scene diff --git a/raillabel/validate/validate.py b/raillabel/validate/validate.py index 97057df..55c01cf 100644 --- a/raillabel/validate/validate.py +++ b/raillabel/validate/validate.py @@ -9,9 +9,7 @@ import fastjsonschema import jsonschema - -if t.TYPE_CHECKING: - from typing_extensions import deprecated +from typing_extensions import deprecated from .. import exceptions From 4c2478e75e97cee52405601aad0667758bf6b1b6 Mon Sep 17 00:00:00 2001 From: Tobias Klockau Date: Mon, 18 Nov 2024 12:54:25 +0100 Subject: [PATCH 4/4] fix: import typing extensions --- pyproject.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index e4b42b5..e38d9a8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -36,7 +36,8 @@ classifiers = [ ] dependencies = [ "jsonschema>=4.4.0", - "fastjsonschema>=2.16.2" + "fastjsonschema>=2.16.2", + "typing_extensions==4.12.2" ] [project.urls]