diff --git a/eland/__init__.py b/eland/__init__.py index f1a2b30..71e227b 100644 --- a/eland/__init__.py +++ b/eland/__init__.py @@ -15,6 +15,8 @@ # specific language governing permissions and limitations # under the License. +import warnings + from ._version import ( # noqa: F401 __author__, __author_email__, @@ -25,13 +27,16 @@ from ._version import ( # noqa: F401 __url__, __version__, ) -from .common import SortOrder +from .common import ElandDeprecationWarning, SortOrder from .dataframe import DataFrame from .etl import csv_to_eland, eland_to_pandas, pandas_to_eland from .index import Index from .ndframe import NDFrame from .series import Series +# Display Eland deprecation warnings by default +warnings.simplefilter("default", category=ElandDeprecationWarning) + __all__ = [ "DataFrame", "Series", diff --git a/eland/common.py b/eland/common.py index 219ec8b..667313c 100644 --- a/eland/common.py +++ b/eland/common.py @@ -52,6 +52,10 @@ PANDAS_VERSION: Tuple[int, ...] = tuple( _ELAND_MAJOR_VERSION = int(_eland_version.split(".")[0]) +class ElandDeprecationWarning(DeprecationWarning): + """Warning for deprecation functionality in Eland""" + + with warnings.catch_warnings(): warnings.simplefilter("ignore") EMPTY_SERIES_DTYPE = pd.Series().dtype diff --git a/eland/ml/exporters/es_gb_models.py b/eland/ml/exporters/es_gb_models.py index 5802b05..4f1e197 100644 --- a/eland/ml/exporters/es_gb_models.py +++ b/eland/ml/exporters/es_gb_models.py @@ -15,6 +15,7 @@ # specific language governing permissions and limitations # under the License. +import warnings from abc import ABC from typing import Any, List, Literal, Mapping, Optional, Set, Tuple, Union @@ -36,7 +37,7 @@ from sklearn.ensemble._gb_losses import ( from sklearn.tree import DecisionTreeClassifier, DecisionTreeRegressor from sklearn.utils.validation import check_array -from eland.common import ensure_es_client +from eland.common import ElandDeprecationWarning, ensure_es_client from eland.ml.common import TYPE_CLASSIFICATION, TYPE_REGRESSION from ._sklearn_deserializers import Tree @@ -62,6 +63,10 @@ class ESGradientBoostingModel(ABC): model_id : str The unique identifier of the trained inference model in Elasticsearch. + Deprecation Warning: + ------ + Exporting data frame analytics models as ESGradientBoostingModel subclasses is deprecated and will be removed in version 9.0.0. + Raises ------ RuntimeError @@ -70,6 +75,11 @@ class ESGradientBoostingModel(ABC): The model is expected to be trained in Elastic Stack. Models initially imported from xgboost, lgbm, or sklearn are not supported. """ + warnings.warn( + "Exporting data frame analytics models as ESGradientBoostingModel subclasses is deprecated and will be removed in version 9.0.0.", + ElandDeprecationWarning, + stacklevel=2, + ) self.es_client: Elasticsearch = ensure_es_client(es_client) self.model_id = model_id