From 7abe53e41a63589ee310fb688322c0d198cd0e32 Mon Sep 17 00:00:00 2001 From: Benjamin Fineran Date: Mon, 5 Jun 2023 15:32:35 -0400 Subject: [PATCH] add deprecation warnings for keras and tfv1 support (#1607) --- src/sparseml/keras/__init__.py | 7 +++++++ src/sparseml/tensorflow_v1/__init__.py | 7 +++++++ src/sparseml/utils/helpers.py | 11 +++++++++++ 3 files changed, 25 insertions(+) diff --git a/src/sparseml/keras/__init__.py b/src/sparseml/keras/__init__.py index eb75d6530a3..b8c9e490d7a 100644 --- a/src/sparseml/keras/__init__.py +++ b/src/sparseml/keras/__init__.py @@ -18,6 +18,13 @@ # flake8: noqa +from sparseml.utils import deprecation_warning as _deprecation_warning + + +_deprecation_warning( + "sparseml.keras is deprecated and will be removed in a future version", +) + from sparseml.analytics import sparseml_analytics as _analytics from .base import * diff --git a/src/sparseml/tensorflow_v1/__init__.py b/src/sparseml/tensorflow_v1/__init__.py index 09d6779f2b1..8f2f8d5be02 100644 --- a/src/sparseml/tensorflow_v1/__init__.py +++ b/src/sparseml/tensorflow_v1/__init__.py @@ -18,6 +18,13 @@ # flake8: noqa +from sparseml.utils import deprecation_warning as _deprecation_warning + + +_deprecation_warning( + "sparseml.tensorflow_v1 is deprecated and will be removed in a future version", +) + from sparseml.analytics import sparseml_analytics as _analytics from .base import * diff --git a/src/sparseml/utils/helpers.py b/src/sparseml/utils/helpers.py index 73f8f9d3cfa..e29dadb6b26 100644 --- a/src/sparseml/utils/helpers.py +++ b/src/sparseml/utils/helpers.py @@ -23,6 +23,7 @@ import logging import os import sys +import warnings from collections import OrderedDict from pathlib import Path from typing import Any, Callable, Dict, Iterable, List, Tuple, Union @@ -64,6 +65,7 @@ "tensors_export", "parse_optimization_str", "json_to_jsonl", + "deprecation_warning", ] @@ -820,3 +822,12 @@ def json_to_jsonl(json_file_path: str, overwrite: bool = True): for json_line in json_data: json.dump(json_line, jsonl_file) # append json line jsonl_file.write("\n") # newline + + +def deprecation_warning(message: str): + warnings.simplefilter("always", DeprecationWarning) + warnings.warn( + message, + category=DeprecationWarning, + stacklevel=2, + )