From 38533b63538685506efd287a724f61c3c83d188d Mon Sep 17 00:00:00 2001 From: Igor Sapego Date: Thu, 4 Feb 2021 01:33:18 +0300 Subject: [PATCH 1/4] IGNITE-11528: Deprecate SqlQuery API --- pyignite/api/sql.py | 10 +++++----- requirements/install.txt | 1 + 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/pyignite/api/sql.py b/pyignite/api/sql.py index ebb3e30..e5938f9 100644 --- a/pyignite/api/sql.py +++ b/pyignite/api/sql.py @@ -13,11 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -""" -Only key-value queries (scan queries) are implemented. SQL part is still -in progress. -""" - +from deprecated import deprecated from typing import Union from pyignite.constants import * @@ -142,6 +138,8 @@ def scan_cursor_get_page( return result +@deprecated(version='1.2.0', reason="This API is deprecated and will be removed in the following major release. " + "Use sql_fields instead") def sql( conn: 'Connection', cache: Union[str, int], table_name: str, query_str: str, page_size: int, query_args=None, @@ -227,6 +225,8 @@ def sql( return result +@deprecated(version='1.2.0', reason="This API is deprecated and will be removed in the following major release. " + "Use sql_fields instead") def sql_cursor_get_page( conn: 'Connection', cursor: int, query_id: int = None, ) -> APIResult: diff --git a/requirements/install.txt b/requirements/install.txt index 9b87ae8..ed6b329 100644 --- a/requirements/install.txt +++ b/requirements/install.txt @@ -2,3 +2,4 @@ typing==3.6.6; python_version<'3.5' attrs==18.1.0 +deprecated==1.2.11 \ No newline at end of file From fbf416dac5ce544f5a80f9617a68f7765a3d0dca Mon Sep 17 00:00:00 2001 From: Igor Sapego Date: Thu, 4 Feb 2021 00:32:47 -0800 Subject: [PATCH 2/4] IGNITE-11528: Remove dependency --- pyignite/api/sql.py | 3 +-- pyignite/utils.py | 11 +++++++++++ requirements/install.txt | 3 +-- tests/test_auth.py | 40 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 53 insertions(+), 4 deletions(-) create mode 100644 tests/test_auth.py diff --git a/pyignite/api/sql.py b/pyignite/api/sql.py index e5938f9..73cacc6 100644 --- a/pyignite/api/sql.py +++ b/pyignite/api/sql.py @@ -13,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -from deprecated import deprecated from typing import Union from pyignite.constants import * @@ -24,7 +23,7 @@ from pyignite.datatypes.sql import StatementType from pyignite.queries import Query from pyignite.queries.op_codes import * -from pyignite.utils import cache_id +from pyignite.utils import cache_id, deprecated from .result import APIResult diff --git a/pyignite/utils.py b/pyignite/utils.py index ce00d53..ef7b6f6 100644 --- a/pyignite/utils.py +++ b/pyignite/utils.py @@ -15,6 +15,7 @@ import ctypes import decimal +import warnings from functools import wraps from threading import Event, Thread @@ -313,3 +314,13 @@ def process_delimiter(name: str, delimiter: str) -> str: Splits the name by delimiter, capitalize each part, merge. """ return ''.join([capitalize(x) for x in name.split(delimiter)]) + + +def deprecated(version, reason): + def decorator_deprecated(fn): + @wraps(fn) + def wrapper_deprecated(*args, **kwds): + warnings.warn(f'Deprecated since {version}. The reason: {reason}', category=DeprecationWarning) + return fn(*args, **kwds) + return wrapper_deprecated + return decorator_deprecated diff --git a/requirements/install.txt b/requirements/install.txt index ed6b329..9dba648 100644 --- a/requirements/install.txt +++ b/requirements/install.txt @@ -1,5 +1,4 @@ # these pip packages are necessary for the pyignite to run typing==3.6.6; python_version<'3.5' -attrs==18.1.0 -deprecated==1.2.11 \ No newline at end of file +attrs==18.1.0 \ No newline at end of file diff --git a/tests/test_auth.py b/tests/test_auth.py new file mode 100644 index 0000000..29866b3 --- /dev/null +++ b/tests/test_auth.py @@ -0,0 +1,40 @@ +# +# Copyright 2019 GridGain Systems, Inc. and Contributors. +# +# Licensed under the GridGain Community Edition License (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.gridgain.com/products/software/community-edition/gridgain-community-edition-license +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +import pytest + +from tests.util import * + + +def test_auth_success(): + client = Client(partition_aware=True) + with pytest.raises(ReconnectError) as e_info: + client.connect([("127.0.0.1", 10900), ("127.0.0.1", 10901)]) + assert str(e_info.value) == "Can not connect." + + +def test_auth_failure(request): + srv = start_ignite(4) + try: + client = Client() + client.connect([("127.0.0.1", 10804)]) + cache = client.get_or_create_cache(request.node.name) + cache.put(1, 1) + kill_process_tree(srv.pid) + with pytest.raises(ConnectionResetError): + cache.get(1) + finally: + kill_process_tree(srv.pid) + From 291a4e81e3624cd7c2ed7cd2f6a5aaee346824d3 Mon Sep 17 00:00:00 2001 From: Igor Sapego Date: Thu, 4 Feb 2021 00:34:50 -0800 Subject: [PATCH 3/4] IGNITE-11528: NL --- requirements/install.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements/install.txt b/requirements/install.txt index 9dba648..9b87ae8 100644 --- a/requirements/install.txt +++ b/requirements/install.txt @@ -1,4 +1,4 @@ # these pip packages are necessary for the pyignite to run typing==3.6.6; python_version<'3.5' -attrs==18.1.0 \ No newline at end of file +attrs==18.1.0 From ea840f93116bc049c11b812a411ab70d070b8214 Mon Sep 17 00:00:00 2001 From: Igor Sapego Date: Thu, 4 Feb 2021 01:20:57 -0800 Subject: [PATCH 4/4] IGNITE-11528: Remove garbage --- tests/test_auth.py | 40 ---------------------------------------- 1 file changed, 40 deletions(-) delete mode 100644 tests/test_auth.py diff --git a/tests/test_auth.py b/tests/test_auth.py deleted file mode 100644 index 29866b3..0000000 --- a/tests/test_auth.py +++ /dev/null @@ -1,40 +0,0 @@ -# -# Copyright 2019 GridGain Systems, Inc. and Contributors. -# -# Licensed under the GridGain Community Edition License (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.gridgain.com/products/software/community-edition/gridgain-community-edition-license -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -import pytest - -from tests.util import * - - -def test_auth_success(): - client = Client(partition_aware=True) - with pytest.raises(ReconnectError) as e_info: - client.connect([("127.0.0.1", 10900), ("127.0.0.1", 10901)]) - assert str(e_info.value) == "Can not connect." - - -def test_auth_failure(request): - srv = start_ignite(4) - try: - client = Client() - client.connect([("127.0.0.1", 10804)]) - cache = client.get_or_create_cache(request.node.name) - cache.put(1, 1) - kill_process_tree(srv.pid) - with pytest.raises(ConnectionResetError): - cache.get(1) - finally: - kill_process_tree(srv.pid) -