From da9f74491ace321d69d6078a22bc8394194c7eae Mon Sep 17 00:00:00 2001 From: kalyan Date: Fri, 13 Oct 2023 10:54:34 +0530 Subject: [PATCH 1/4] replace is_datetime_or_timedelta_dtype Signed-off-by: kalyan --- opensearch_py_ml/field_mappings.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/opensearch_py_ml/field_mappings.py b/opensearch_py_ml/field_mappings.py index 3dd5e2333..85c217d10 100644 --- a/opensearch_py_ml/field_mappings.py +++ b/opensearch_py_ml/field_mappings.py @@ -43,7 +43,7 @@ from pandas.core.dtypes.common import is_bool_dtype # type: ignore from pandas.core.dtypes.common import ( is_datetime64_any_dtype, - is_datetime_or_timedelta_dtype, + is_timedelta64_dtype, is_float_dtype, is_integer_dtype, is_string_dtype, @@ -91,7 +91,7 @@ def is_numeric(self) -> bool: @property def is_timestamp(self) -> bool: - return is_datetime_or_timedelta_dtype(self.pd_dtype) + return is_datetime64_any_dtype(self.pd_dtype) or is_timedelta64_dtype(self.pd_dtype) @property def is_bool(self) -> bool: @@ -509,7 +509,7 @@ def _pd_dtype_to_os_dtype(pd_dtype) -> Optional[str]: os_dtype = "boolean" elif is_string_dtype(pd_dtype): os_dtype = "keyword" - elif is_datetime_or_timedelta_dtype(pd_dtype): + elif is_datetime64_any_dtype(pd_dtype) or is_timedelta64_dtype(pd_dtype): os_dtype = "date" elif is_datetime64_any_dtype(pd_dtype): os_dtype = "date" @@ -794,7 +794,7 @@ def metric_source_fields( pd_dtypes.append(np.dtype(pd_dtype)) os_field_names.append(os_field_name) os_date_formats.append(os_date_format) - elif include_timestamp and is_datetime_or_timedelta_dtype(pd_dtype): + elif include_timestamp and (is_datetime64_any_dtype(pd_dtype) or is_timedelta64_dtype(pd_dtype)): pd_dtypes.append(np.dtype(pd_dtype)) os_field_names.append(os_field_name) os_date_formats.append(os_date_format) From 00a3dbe93e71c9aa9a03f27fbe6882560a284b88 Mon Sep 17 00:00:00 2001 From: kalyan Date: Fri, 13 Oct 2023 10:57:05 +0530 Subject: [PATCH 2/4] fix formatting Signed-off-by: kalyan --- opensearch_py_ml/field_mappings.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/opensearch_py_ml/field_mappings.py b/opensearch_py_ml/field_mappings.py index 85c217d10..5e7f41d5f 100644 --- a/opensearch_py_ml/field_mappings.py +++ b/opensearch_py_ml/field_mappings.py @@ -91,7 +91,9 @@ def is_numeric(self) -> bool: @property def is_timestamp(self) -> bool: - return is_datetime64_any_dtype(self.pd_dtype) or is_timedelta64_dtype(self.pd_dtype) + return is_datetime64_any_dtype(self.pd_dtype) or is_timedelta64_dtype( + self.pd_dtype + ) @property def is_bool(self) -> bool: @@ -794,7 +796,9 @@ def metric_source_fields( pd_dtypes.append(np.dtype(pd_dtype)) os_field_names.append(os_field_name) os_date_formats.append(os_date_format) - elif include_timestamp and (is_datetime64_any_dtype(pd_dtype) or is_timedelta64_dtype(pd_dtype)): + elif include_timestamp and ( + is_datetime64_any_dtype(pd_dtype) or is_timedelta64_dtype(pd_dtype) + ): pd_dtypes.append(np.dtype(pd_dtype)) os_field_names.append(os_field_name) os_date_formats.append(os_date_format) From 71ab69611630676d06c0fa727bd340fb779e0f7b Mon Sep 17 00:00:00 2001 From: kalyan Date: Fri, 13 Oct 2023 10:58:42 +0530 Subject: [PATCH 3/4] fix import order Signed-off-by: kalyan --- opensearch_py_ml/field_mappings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opensearch_py_ml/field_mappings.py b/opensearch_py_ml/field_mappings.py index 5e7f41d5f..b3c83914a 100644 --- a/opensearch_py_ml/field_mappings.py +++ b/opensearch_py_ml/field_mappings.py @@ -43,10 +43,10 @@ from pandas.core.dtypes.common import is_bool_dtype # type: ignore from pandas.core.dtypes.common import ( is_datetime64_any_dtype, - is_timedelta64_dtype, is_float_dtype, is_integer_dtype, is_string_dtype, + is_timedelta64_dtype, ) from pandas.core.dtypes.inference import is_list_like From a4cfd479edb2eb8233ae8c941e7e522df1f177f2 Mon Sep 17 00:00:00 2001 From: kalyan Date: Tue, 31 Oct 2023 08:03:06 +0530 Subject: [PATCH 4/4] update changelog Signed-off-by: kalyan --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f7523160..66f3864c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Add workflow and scripts for automating model listing updating process by @thanawan-atc in ([#210](https://github.com/opensearch-project/opensearch-py-ml/pull/210)) - Add script to trigger ml-models-release jenkins workflow with generic webhook by @thanawan-atc in ([#211](https://github.com/opensearch-project/opensearch-py-ml/pull/211)) - Add example notebook for tracing and registering a CLIPTextModel to OpenSearch with the Neural Search plugin by @patrickbarnhart in ([#283](https://github.com/opensearch-project/opensearch-py-ml/pull/283)) +- Replaced usage of `is_datetime_or_timedelta_dtype` with `is_timedelta64_dtype` and `is_datetime64_any_dtype`([#316](https://github.com/opensearch-project/opensearch-py-ml/pull/316)) ### Changed - Modify ml-models.JenkinsFile so that it takes model format into account and can be triggered with generic webhook by @thanawan-atc in ([#211](https://github.com/opensearch-project/opensearch-py-ml/pull/211))