Skip to content

Commit 792ee57

Browse files
authored
Merge pull request #464 from ydb-platform/docstrings_experimental_warning
Add docstrings about experimental API
2 parents 2042a16 + 96372fb commit 792ee57

File tree

4 files changed

+53
-18
lines changed

4 files changed

+53
-18
lines changed

ydb/query/base.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ def __init__(self, driver: SupportedDriverType, settings: Optional[QueryClientSe
103103

104104
@abc.abstractmethod
105105
def create(self) -> "IQuerySession":
106-
"""
106+
"""WARNING: This API is experimental and could be changed.
107+
107108
Creates a Session of Query Service on server side and attaches it.
108109
109110
:return: Session object.
@@ -112,7 +113,8 @@ def create(self) -> "IQuerySession":
112113

113114
@abc.abstractmethod
114115
def delete(self) -> None:
115-
"""
116+
"""WARNING: This API is experimental and could be changed.
117+
116118
Deletes a Session of Query Service on server side and releases resources.
117119
118120
:return: None
@@ -121,7 +123,8 @@ def delete(self) -> None:
121123

122124
@abc.abstractmethod
123125
def transaction(self, tx_mode: Optional[BaseQueryTxMode] = None) -> "IQueryTxContext":
124-
"""
126+
"""WARNING: This API is experimental and could be changed.
127+
125128
Creates a transaction context manager with specified transaction mode.
126129
127130
:param tx_mode: Transaction mode, which is a one from the following choises:
@@ -143,7 +146,8 @@ def execute(
143146
parameters: Optional[dict] = None,
144147
concurrent_result_sets: Optional[bool] = False,
145148
) -> Iterator:
146-
"""
149+
"""WARNING: This API is experimental and could be changed.
150+
147151
Sends a query to Query Service
148152
:param query: (YQL or SQL text) to be executed.
149153
:param syntax: Syntax of the query, which is a one from the following choises:
@@ -235,7 +239,8 @@ def tx_id(self) -> Optional[str]:
235239

236240
@abc.abstractmethod
237241
def begin(self, settings: Optional[QueryClientSettings] = None) -> None:
238-
"""
242+
"""WARNING: This API is experimental and could be changed.
243+
239244
Explicitly begins a transaction
240245
241246
:param settings: A request settings
@@ -246,7 +251,8 @@ def begin(self, settings: Optional[QueryClientSettings] = None) -> None:
246251

247252
@abc.abstractmethod
248253
def commit(self, settings: Optional[QueryClientSettings] = None) -> None:
249-
"""
254+
"""WARNING: This API is experimental and could be changed.
255+
250256
Calls commit on a transaction if it is open. If transaction execution
251257
failed then this method raises PreconditionFailed.
252258
@@ -258,7 +264,8 @@ def commit(self, settings: Optional[QueryClientSettings] = None) -> None:
258264

259265
@abc.abstractmethod
260266
def rollback(self, settings: Optional[QueryClientSettings] = None) -> None:
261-
"""
267+
"""WARNING: This API is experimental and could be changed.
268+
262269
Calls rollback on a transaction if it is open. If transaction execution
263270
failed then this method raises PreconditionFailed.
264271
@@ -278,7 +285,8 @@ def execute(
278285
parameters: Optional[dict] = None,
279286
concurrent_result_sets: Optional[bool] = False,
280287
) -> Iterator:
281-
"""
288+
"""WARNING: This API is experimental and could be changed.
289+
282290
Sends a query to Query Service
283291
:param query: (YQL or SQL text) to be executed.
284292
:param commit_tx: A special flag that allows transaction commit.

ydb/query/pool.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,15 @@ def __init__(self, driver: base.SupportedDriverType):
3030
self._driver = driver
3131

3232
def checkout(self) -> "SimpleQuerySessionCheckout":
33-
"""Return a Session context manager, that opens session on enter and closes session on exit."""
33+
"""WARNING: This API is experimental and could be changed.
34+
Return a Session context manager, that opens session on enter and closes session on exit.
35+
"""
3436

3537
return SimpleQuerySessionCheckout(self)
3638

3739
def retry_operation_sync(self, callee: Callable, retry_settings: Optional[RetrySettings] = None, *args, **kwargs):
38-
"""Special interface to execute a bunch of commands with session in a safe, retriable way.
40+
"""WARNING: This API is experimental and could be changed.
41+
Special interface to execute a bunch of commands with session in a safe, retriable way.
3942
4043
:param callee: A function, that works with session.
4144
:param retry_settings: RetrySettings object.
@@ -54,7 +57,8 @@ def wrapped_callee():
5457
def execute_with_retries(
5558
self, query: str, retry_settings: Optional[RetrySettings] = None, *args, **kwargs
5659
) -> List[convert.ResultSet]:
57-
"""Special interface to execute a one-shot queries in a safe, retriable way.
60+
"""WARNING: This API is experimental and could be changed.
61+
Special interface to execute a one-shot queries in a safe, retriable way.
5862
Note: this method loads all data from stream before return, do not use this
5963
method with huge read queries.
6064

ydb/query/session.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,8 @@ def _check_session_status_loop(self, status_stream: _utilities.SyncResponseItera
227227
pass
228228

229229
def delete(self) -> None:
230-
"""
230+
"""WARNING: This API is experimental and could be changed.
231+
231232
Deletes a Session of Query Service on server side and releases resources.
232233
233234
:return: None
@@ -240,7 +241,8 @@ def delete(self) -> None:
240241
self._stream.cancel()
241242

242243
def create(self) -> "QuerySessionSync":
243-
"""
244+
"""WARNING: This API is experimental and could be changed.
245+
244246
Creates a Session of Query Service on server side and attaches it.
245247
246248
:return: QuerySessionSync object.
@@ -255,7 +257,8 @@ def create(self) -> "QuerySessionSync":
255257
return self
256258

257259
def transaction(self, tx_mode: Optional[base.BaseQueryTxMode] = None) -> base.IQueryTxContext:
258-
"""
260+
"""WARNING: This API is experimental and could be changed.
261+
259262
Creates a transaction context manager with specified transaction mode.
260263
:param tx_mode: Transaction mode, which is a one from the following choises:
261264
1) QuerySerializableReadWrite() which is default mode;
@@ -285,7 +288,8 @@ def execute(
285288
parameters: dict = None,
286289
concurrent_result_sets: bool = False,
287290
) -> base.SyncResponseContextIterator:
288-
"""
291+
"""WARNING: This API is experimental and could be changed.
292+
289293
Sends a query to Query Service
290294
:param query: (YQL or SQL text) to be executed.
291295
:param syntax: Syntax of the query, which is a one from the following choises:

ydb/query/transaction.py

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,8 @@ def _move_to_commited(self) -> None:
314314
self._tx_state._change_state(QueryTxStateEnum.COMMITTED)
315315

316316
def begin(self, settings: Optional[base.QueryClientSettings] = None) -> None:
317-
"""
317+
"""WARNING: This API is experimental and could be changed.
318+
318319
Explicitly begins a transaction
319320
320321
:param settings: A request settings
@@ -326,7 +327,8 @@ def begin(self, settings: Optional[base.QueryClientSettings] = None) -> None:
326327
self._begin_call(settings)
327328

328329
def commit(self, settings: Optional[base.QueryClientSettings] = None) -> None:
329-
"""
330+
"""WARNING: This API is experimental and could be changed.
331+
330332
Calls commit on a transaction if it is open otherwise is no-op. If transaction execution
331333
failed then this method raises PreconditionFailed.
332334
@@ -369,7 +371,24 @@ def execute(
369371
parameters: Optional[dict] = None,
370372
concurrent_result_sets: Optional[bool] = False,
371373
) -> base.SyncResponseContextIterator:
372-
374+
"""WARNING: This API is experimental and could be changed.
375+
376+
Sends a query to Query Service
377+
:param query: (YQL or SQL text) to be executed.
378+
:param commit_tx: A special flag that allows transaction commit.
379+
:param syntax: Syntax of the query, which is a one from the following choises:
380+
1) QuerySyntax.YQL_V1, which is default;
381+
2) QuerySyntax.PG.
382+
:param exec_mode: Exec mode of the query, which is a one from the following choises:
383+
1) QueryExecMode.EXECUTE, which is default;
384+
2) QueryExecMode.EXPLAIN;
385+
3) QueryExecMode.VALIDATE;
386+
4) QueryExecMode.PARSE.
387+
:param parameters: dict with parameters and YDB types;
388+
:param concurrent_result_sets: A flag to allow YDB mix parts of different result sets. Default is False;
389+
390+
:return: Iterator with result sets
391+
"""
373392
self._ensure_prev_stream_finished()
374393
self._tx_state._check_tx_ready_to_use()
375394

0 commit comments

Comments
 (0)