From b6c02ea2060423ee32f5fceef979cb98bbfff9ff Mon Sep 17 00:00:00 2001 From: Oleg Ovcharuk Date: Thu, 19 Sep 2024 14:22:06 +0300 Subject: [PATCH 1/2] Remove experimental warn from query service --- ydb/aio/query/pool.py | 21 +++++---------------- ydb/aio/query/session.py | 12 +++--------- ydb/aio/query/transaction.py | 16 ++++------------ ydb/query/__init__.py | 1 - ydb/query/pool.py | 21 +++++---------------- ydb/query/session.py | 16 ++++------------ ydb/query/transaction.py | 16 ++++------------ 7 files changed, 25 insertions(+), 78 deletions(-) diff --git a/ydb/aio/query/pool.py b/ydb/aio/query/pool.py index e8d53438..086e326a 100644 --- a/ydb/aio/query/pool.py +++ b/ydb/aio/query/pool.py @@ -28,7 +28,6 @@ def __init__(self, driver: common_utils.SupportedDriverType, size: int = 100): :param size: Size of session pool """ - logger.warning("QuerySessionPool is an experimental API, which could be changed.") self._driver = driver self._size = size self._should_stop = asyncio.Event() @@ -44,9 +43,7 @@ async def _create_new_session(self): return session async def acquire(self) -> QuerySession: - """WARNING: This API is experimental and could be changed. - - Acquire a session from Session Pool. + """Acquire a session from Session Pool. :return A QuerySession object. """ @@ -86,18 +83,14 @@ async def acquire(self) -> QuerySession: return session async def release(self, session: QuerySession) -> None: - """WARNING: This API is experimental and could be changed. - - Release a session back to Session Pool. + """Release a session back to Session Pool. """ self._queue.put_nowait(session) logger.debug("Session returned to queue: %s", session._state.session_id) def checkout(self) -> "SimpleQuerySessionCheckoutAsync": - """WARNING: This API is experimental and could be changed. - - Return a Session context manager, that acquires session on enter and releases session on exit. + """Return a Session context manager, that acquires session on enter and releases session on exit. """ return SimpleQuerySessionCheckoutAsync(self) @@ -105,9 +98,7 @@ def checkout(self) -> "SimpleQuerySessionCheckoutAsync": async def retry_operation_async( self, callee: Callable, retry_settings: Optional[RetrySettings] = None, *args, **kwargs ): - """WARNING: This API is experimental and could be changed. - - Special interface to execute a bunch of commands with session in a safe, retriable way. + """Special interface to execute a bunch of commands with session in a safe, retriable way. :param callee: A function, that works with session. :param retry_settings: RetrySettings object. @@ -131,9 +122,7 @@ async def execute_with_retries( *args, **kwargs, ) -> List[convert.ResultSet]: - """WARNING: This API is experimental and could be changed. - - Special interface to execute a one-shot queries in a safe, retriable way. + """Special interface to execute a one-shot queries in a safe, retriable way. Note: this method loads all data from stream before return, do not use this method with huge read queries. diff --git a/ydb/aio/query/session.py b/ydb/aio/query/session.py index 4c1c1a10..779eb3f0 100644 --- a/ydb/aio/query/session.py +++ b/ydb/aio/query/session.py @@ -64,9 +64,7 @@ async def _check_session_status_loop(self) -> None: self._state._change_state(QuerySessionStateEnum.CLOSED) async def delete(self, settings: Optional[BaseRequestSettings] = None) -> None: - """WARNING: This API is experimental and could be changed. - - Deletes a Session of Query Service on server side and releases resources. + """Deletes a Session of Query Service on server side and releases resources. :return: None """ @@ -78,9 +76,7 @@ async def delete(self, settings: Optional[BaseRequestSettings] = None) -> None: self._stream.cancel() async def create(self, settings: Optional[BaseRequestSettings] = None) -> "QuerySession": - """WARNING: This API is experimental and could be changed. - - Creates a Session of Query Service on server side and attaches it. + """Creates a Session of Query Service on server side and attaches it. :return: QuerySession object. """ @@ -113,9 +109,7 @@ async def execute( concurrent_result_sets: bool = False, settings: Optional[BaseRequestSettings] = None, ) -> AsyncResponseContextIterator: - """WARNING: This API is experimental and could be changed. - - Sends a query to Query Service + """Sends a query to Query Service :param query: (YQL or SQL text) to be executed. :param syntax: Syntax of the query, which is a one from the following choises: diff --git a/ydb/aio/query/transaction.py b/ydb/aio/query/transaction.py index b115a4b4..5b63a32b 100644 --- a/ydb/aio/query/transaction.py +++ b/ydb/aio/query/transaction.py @@ -48,9 +48,7 @@ async def _ensure_prev_stream_finished(self) -> None: self._prev_stream = None async def begin(self, settings: Optional[BaseRequestSettings] = None) -> "QueryTxContext": - """WARNING: This API is experimental and could be changed. - - Explicitly begins a transaction + """Explicitly begins a transaction :param settings: An additional request settings BaseRequestSettings; @@ -60,9 +58,7 @@ async def begin(self, settings: Optional[BaseRequestSettings] = None) -> "QueryT return self async def commit(self, settings: Optional[BaseRequestSettings] = None) -> None: - """WARNING: This API is experimental and could be changed. - - Calls commit on a transaction if it is open otherwise is no-op. If transaction execution + """Calls commit on a transaction if it is open otherwise is no-op. If transaction execution failed then this method raises PreconditionFailed. :param settings: An additional request settings BaseRequestSettings; @@ -81,9 +77,7 @@ async def commit(self, settings: Optional[BaseRequestSettings] = None) -> None: await self._commit_call(settings) async def rollback(self, settings: Optional[BaseRequestSettings] = None) -> None: - """WARNING: This API is experimental and could be changed. - - Calls rollback on a transaction if it is open otherwise is no-op. If transaction execution + """Calls rollback on a transaction if it is open otherwise is no-op. If transaction execution failed then this method raises PreconditionFailed. :param settings: An additional request settings BaseRequestSettings; @@ -111,9 +105,7 @@ async def execute( concurrent_result_sets: Optional[bool] = False, settings: Optional[BaseRequestSettings] = None, ) -> AsyncResponseContextIterator: - """WARNING: This API is experimental and could be changed. - - Sends a query to Query Service + """Sends a query to Query Service :param query: (YQL or SQL text) to be executed. :param parameters: dict with parameters and YDB types; diff --git a/ydb/query/__init__.py b/ydb/query/__init__.py index 0f818789..59dd7992 100644 --- a/ydb/query/__init__.py +++ b/ydb/query/__init__.py @@ -35,7 +35,6 @@ class QueryClientSync: def __init__(self, driver: common_utils.SupportedDriverType, query_client_settings: QueryClientSettings = None): - logger.warning("QueryClientSync is an experimental API, which could be changed.") self._driver = driver self._settings = query_client_settings diff --git a/ydb/query/pool.py b/ydb/query/pool.py index 839d8688..fa220bb5 100644 --- a/ydb/query/pool.py +++ b/ydb/query/pool.py @@ -33,7 +33,6 @@ def __init__(self, driver: common_utils.SupportedDriverType, size: int = 100): :param size: Max size of Session Pool. """ - logger.warning("QuerySessionPool is an experimental API, which could be changed.") self._driver = driver self._queue = queue.Queue() self._current_size = 0 @@ -48,9 +47,7 @@ def _create_new_session(self, timeout: Optional[float]): return session def acquire(self, timeout: Optional[float] = None) -> QuerySession: - """WARNING: This API is experimental and could be changed. - - Acquire a session from Session Pool. + """Acquire a session from Session Pool. :param timeout: A timeout to wait in seconds. @@ -102,18 +99,14 @@ def acquire(self, timeout: Optional[float] = None) -> QuerySession: self._lock.release() def release(self, session: QuerySession) -> None: - """WARNING: This API is experimental and could be changed. - - Release a session back to Session Pool. + """Release a session back to Session Pool. """ self._queue.put_nowait(session) logger.debug("Session returned to queue: %s", session._state.session_id) def checkout(self, timeout: Optional[float] = None) -> "SimpleQuerySessionCheckout": - """WARNING: This API is experimental and could be changed. - - Return a Session context manager, that acquires session on enter and releases session on exit. + """Return a Session context manager, that acquires session on enter and releases session on exit. :param timeout: A timeout to wait in seconds. """ @@ -121,9 +114,7 @@ def checkout(self, timeout: Optional[float] = None) -> "SimpleQuerySessionChecko return SimpleQuerySessionCheckout(self, timeout) def retry_operation_sync(self, callee: Callable, retry_settings: Optional[RetrySettings] = None, *args, **kwargs): - """WARNING: This API is experimental and could be changed. - - Special interface to execute a bunch of commands with session in a safe, retriable way. + """Special interface to execute a bunch of commands with session in a safe, retriable way. :param callee: A function, that works with session. :param retry_settings: RetrySettings object. @@ -147,9 +138,7 @@ def execute_with_retries( *args, **kwargs, ) -> List[convert.ResultSet]: - """WARNING: This API is experimental and could be changed. - - Special interface to execute a one-shot queries in a safe, retriable way. + """Special interface to execute a one-shot queries in a safe, retriable way. Note: this method loads all data from stream before return, do not use this method with huge read queries. diff --git a/ydb/query/session.py b/ydb/query/session.py index 5b4db26c..e13540d3 100644 --- a/ydb/query/session.py +++ b/ydb/query/session.py @@ -235,9 +235,7 @@ def _check_session_status_loop(self, status_stream: _utilities.SyncResponseItera self._state._change_state(QuerySessionStateEnum.CLOSED) def delete(self, settings: Optional[BaseRequestSettings] = None) -> None: - """WARNING: This API is experimental and could be changed. - - Deletes a Session of Query Service on server side and releases resources. + """Deletes a Session of Query Service on server side and releases resources. :return: None """ @@ -249,9 +247,7 @@ def delete(self, settings: Optional[BaseRequestSettings] = None) -> None: self._stream.cancel() def create(self, settings: Optional[BaseRequestSettings] = None) -> "QuerySession": - """WARNING: This API is experimental and could be changed. - - Creates a Session of Query Service on server side and attaches it. + """Creates a Session of Query Service on server side and attaches it. :return: QuerySession object. """ @@ -266,9 +262,7 @@ def create(self, settings: Optional[BaseRequestSettings] = None) -> "QuerySessio return self def transaction(self, tx_mode: Optional[base.BaseQueryTxMode] = None) -> QueryTxContext: - """WARNING: This API is experimental and could be changed. - - Creates a transaction context manager with specified transaction mode. + """Creates a transaction context manager with specified transaction mode. :param tx_mode: Transaction mode, which is a one from the following choises: 1) QuerySerializableReadWrite() which is default mode; @@ -299,9 +293,7 @@ def execute( concurrent_result_sets: bool = False, settings: Optional[BaseRequestSettings] = None, ) -> base.SyncResponseContextIterator: - """WARNING: This API is experimental and could be changed. - - Sends a query to Query Service + """Sends a query to Query Service :param query: (YQL or SQL text) to be executed. :param syntax: Syntax of the query, which is a one from the following choises: diff --git a/ydb/query/transaction.py b/ydb/query/transaction.py index 21ba0279..d9c0dfcb 100644 --- a/ydb/query/transaction.py +++ b/ydb/query/transaction.py @@ -327,9 +327,7 @@ def _ensure_prev_stream_finished(self) -> None: self._prev_stream = None def begin(self, settings: Optional[BaseRequestSettings] = None) -> "QueryTxContext": - """WARNING: This API is experimental and could be changed. - - Explicitly begins a transaction + """Explicitly begins a transaction :param settings: An additional request settings BaseRequestSettings; @@ -340,9 +338,7 @@ def begin(self, settings: Optional[BaseRequestSettings] = None) -> "QueryTxConte return self def commit(self, settings: Optional[BaseRequestSettings] = None) -> None: - """WARNING: This API is experimental and could be changed. - - Calls commit on a transaction if it is open otherwise is no-op. If transaction execution + """Calls commit on a transaction if it is open otherwise is no-op. If transaction execution failed then this method raises PreconditionFailed. :param settings: An additional request settings BaseRequestSettings; @@ -361,9 +357,7 @@ def commit(self, settings: Optional[BaseRequestSettings] = None) -> None: self._commit_call(settings) def rollback(self, settings: Optional[BaseRequestSettings] = None) -> None: - """WARNING: This API is experimental and could be changed. - - Calls rollback on a transaction if it is open otherwise is no-op. If transaction execution + """Calls rollback on a transaction if it is open otherwise is no-op. If transaction execution failed then this method raises PreconditionFailed. :param settings: An additional request settings BaseRequestSettings; @@ -391,9 +385,7 @@ def execute( concurrent_result_sets: Optional[bool] = False, settings: Optional[BaseRequestSettings] = None, ) -> base.SyncResponseContextIterator: - """WARNING: This API is experimental and could be changed. - - Sends a query to Query Service + """Sends a query to Query Service :param query: (YQL or SQL text) to be executed. :param parameters: dict with parameters and YDB types; From e1c83d5066f3ec18ba5e20b46d36b410770b5cc2 Mon Sep 17 00:00:00 2001 From: Oleg Ovcharuk Date: Thu, 19 Sep 2024 14:25:25 +0300 Subject: [PATCH 2/2] style fixes --- ydb/aio/query/pool.py | 6 ++---- ydb/query/pool.py | 3 +-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/ydb/aio/query/pool.py b/ydb/aio/query/pool.py index 086e326a..6d116600 100644 --- a/ydb/aio/query/pool.py +++ b/ydb/aio/query/pool.py @@ -83,15 +83,13 @@ async def acquire(self) -> QuerySession: return session async def release(self, session: QuerySession) -> None: - """Release a session back to Session Pool. - """ + """Release a session back to Session Pool.""" self._queue.put_nowait(session) logger.debug("Session returned to queue: %s", session._state.session_id) def checkout(self) -> "SimpleQuerySessionCheckoutAsync": - """Return a Session context manager, that acquires session on enter and releases session on exit. - """ + """Return a Session context manager, that acquires session on enter and releases session on exit.""" return SimpleQuerySessionCheckoutAsync(self) diff --git a/ydb/query/pool.py b/ydb/query/pool.py index fa220bb5..4c51a971 100644 --- a/ydb/query/pool.py +++ b/ydb/query/pool.py @@ -99,8 +99,7 @@ def acquire(self, timeout: Optional[float] = None) -> QuerySession: self._lock.release() def release(self, session: QuerySession) -> None: - """Release a session back to Session Pool. - """ + """Release a session back to Session Pool.""" self._queue.put_nowait(session) logger.debug("Session returned to queue: %s", session._state.session_id)