Skip to content

Commit 1d26890

Browse files
committed
rename interfaces
1 parent bbdb0a9 commit 1d26890

21 files changed

+144
-144
lines changed

examples/basic_example_v2/basic_example.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def select_with_parameters(pool: ydb.QuerySessionPool, series_id, season_id, epi
140140
# calls instead to avoid additional hops to YDB cluster and allow more efficient
141141
# execution of queries.
142142
def explicit_transaction_control(pool: ydb.QuerySessionPool, series_id, season_id, episode_id):
143-
def callee(session: ydb.QuerySessionSync):
143+
def callee(session: ydb.QuerySession):
144144
query = """
145145
DECLARE $seriesId AS Int64;
146146
DECLARE $seasonId AS Int64;
@@ -175,7 +175,7 @@ def callee(session: ydb.QuerySessionSync):
175175

176176

177177
def huge_select(pool: ydb.QuerySessionPool):
178-
def callee(session: ydb.QuerySessionSync):
178+
def callee(session: ydb.QuerySession):
179179
query = """SELECT * from episodes;"""
180180

181181
with session.transaction().execute(

examples/basic_example_v2/basic_example_async.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
"""
5959

6060

61-
async def fill_tables_with_data(pool: ydb.aio.QuerySessionPoolAsync):
61+
async def fill_tables_with_data(pool: ydb.aio.QuerySessionPool):
6262
print("\nFilling tables with data...")
6363
await pool.execute_with_retries(
6464
FillDataQuery,
@@ -70,7 +70,7 @@ async def fill_tables_with_data(pool: ydb.aio.QuerySessionPoolAsync):
7070
)
7171

7272

73-
async def select_simple(pool: ydb.aio.QuerySessionPoolAsync):
73+
async def select_simple(pool: ydb.aio.QuerySessionPool):
7474
print("\nCheck series table...")
7575
result_sets = await pool.execute_with_retries(
7676
"""
@@ -96,7 +96,7 @@ async def select_simple(pool: ydb.aio.QuerySessionPoolAsync):
9696
return first_set
9797

9898

99-
async def upsert_simple(pool: ydb.aio.QuerySessionPoolAsync):
99+
async def upsert_simple(pool: ydb.aio.QuerySessionPool):
100100
print("\nPerforming UPSERT into episodes...")
101101

102102
await pool.execute_with_retries(
@@ -106,7 +106,7 @@ async def upsert_simple(pool: ydb.aio.QuerySessionPoolAsync):
106106
)
107107

108108

109-
async def select_with_parameters(pool: ydb.aio.QuerySessionPoolAsync, series_id, season_id, episode_id):
109+
async def select_with_parameters(pool: ydb.aio.QuerySessionPool, series_id, season_id, episode_id):
110110
result_sets = await pool.execute_with_retries(
111111
"""
112112
DECLARE $seriesId AS Int64;
@@ -138,8 +138,8 @@ async def select_with_parameters(pool: ydb.aio.QuerySessionPoolAsync, series_id,
138138
# In most cases it's better to use transaction control settings in session.transaction
139139
# calls instead to avoid additional hops to YDB cluster and allow more efficient
140140
# execution of queries.
141-
async def explicit_transaction_control(pool: ydb.aio.QuerySessionPoolAsync, series_id, season_id, episode_id):
142-
async def callee(session: ydb.aio.QuerySessionAsync):
141+
async def explicit_transaction_control(pool: ydb.aio.QuerySessionPool, series_id, season_id, episode_id):
142+
async def callee(session: ydb.aio.QuerySession):
143143
query = """
144144
DECLARE $seriesId AS Int64;
145145
DECLARE $seasonId AS Int64;
@@ -173,8 +173,8 @@ async def callee(session: ydb.aio.QuerySessionAsync):
173173
return await pool.retry_operation_async(callee)
174174

175175

176-
async def huge_select(pool: ydb.aio.QuerySessionPoolAsync):
177-
async def callee(session: ydb.aio.QuerySessionAsync):
176+
async def huge_select(pool: ydb.aio.QuerySessionPool):
177+
async def callee(session: ydb.aio.QuerySession):
178178
query = """SELECT * from episodes;"""
179179

180180
async with await session.transaction().execute(
@@ -189,12 +189,12 @@ async def callee(session: ydb.aio.QuerySessionAsync):
189189
return await pool.retry_operation_async(callee)
190190

191191

192-
async def drop_tables(pool: ydb.aio.QuerySessionPoolAsync):
192+
async def drop_tables(pool: ydb.aio.QuerySessionPool):
193193
print("\nCleaning up existing tables...")
194194
await pool.execute_with_retries(DropTablesQuery)
195195

196196

197-
async def create_tables(pool: ydb.aio.QuerySessionPoolAsync):
197+
async def create_tables(pool: ydb.aio.QuerySessionPool):
198198
print("\nCreating table series...")
199199
await pool.execute_with_retries(
200200
"""
@@ -246,7 +246,7 @@ async def run(endpoint, database):
246246
) as driver:
247247
await driver.wait(timeout=5, fail_fast=True)
248248

249-
async with ydb.aio.QuerySessionPoolAsync(driver) as pool:
249+
async with ydb.aio.QuerySessionPool(driver) as pool:
250250
await drop_tables(pool)
251251

252252
await create_tables(pool)

examples/query-service/basic_example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def callee(session):
8282

8383
pool.retry_operation_sync(callee)
8484

85-
def callee(session: ydb.QuerySessionSync):
85+
def callee(session: ydb.QuerySession):
8686
query_print = """select $a"""
8787

8888
print("=" * 50)

examples/query-service/basic_example_asyncio.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ async def main():
1515
except TimeoutError:
1616
raise RuntimeError("Connect failed to YDB")
1717

18-
pool = ydb.aio.QuerySessionPoolAsync(driver)
18+
pool = ydb.aio.QuerySessionPool(driver)
1919

2020
print("=" * 50)
2121
print("DELETE TABLE IF EXISTS")
@@ -83,7 +83,7 @@ async def callee(session):
8383

8484
await pool.retry_operation_async(callee)
8585

86-
async def callee(session: ydb.aio.QuerySessionAsync):
86+
async def callee(session: ydb.aio.QuerySession):
8787
query_print = """select $a"""
8888

8989
print("=" * 50)

tests/aio/query/conftest.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import pytest
2-
from ydb.aio.query.session import QuerySessionAsync
3-
from ydb.aio.query.pool import QuerySessionPoolAsync
2+
from ydb.aio.query.session import QuerySession
3+
from ydb.aio.query.pool import QuerySessionPool
44

55

66
@pytest.fixture
77
async def session(driver):
8-
session = QuerySessionAsync(driver)
8+
session = QuerySession(driver)
99

1010
yield session
1111

@@ -30,5 +30,5 @@ async def tx(session):
3030

3131
@pytest.fixture
3232
async def pool(driver):
33-
async with QuerySessionPoolAsync(driver) as pool:
33+
async with QuerySessionPool(driver) as pool:
3434
yield pool

tests/aio/query/test_query_session.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
import pytest
2-
from ydb.aio.query.session import QuerySessionAsync
2+
from ydb.aio.query.session import QuerySession
33

44

5-
def _check_session_state_empty(session: QuerySessionAsync):
5+
def _check_session_state_empty(session: QuerySession):
66
assert session._state.session_id is None
77
assert session._state.node_id is None
88
assert not session._state.attached
99

1010

11-
def _check_session_state_full(session: QuerySessionAsync):
11+
def _check_session_state_full(session: QuerySession):
1212
assert session._state.session_id is not None
1313
assert session._state.node_id is not None
1414
assert session._state.attached
1515

1616

1717
class TestAsyncQuerySession:
1818
@pytest.mark.asyncio
19-
async def test_session_normal_lifecycle(self, session: QuerySessionAsync):
19+
async def test_session_normal_lifecycle(self, session: QuerySession):
2020
_check_session_state_empty(session)
2121

2222
await session.create()
@@ -26,7 +26,7 @@ async def test_session_normal_lifecycle(self, session: QuerySessionAsync):
2626
_check_session_state_empty(session)
2727

2828
@pytest.mark.asyncio
29-
async def test_second_create_do_nothing(self, session: QuerySessionAsync):
29+
async def test_second_create_do_nothing(self, session: QuerySession):
3030
await session.create()
3131
_check_session_state_full(session)
3232

@@ -40,30 +40,30 @@ async def test_second_create_do_nothing(self, session: QuerySessionAsync):
4040
assert session._state.node_id == node_id_before
4141

4242
@pytest.mark.asyncio
43-
async def test_second_delete_do_nothing(self, session: QuerySessionAsync):
43+
async def test_second_delete_do_nothing(self, session: QuerySession):
4444
await session.create()
4545

4646
await session.delete()
4747
await session.delete()
4848

4949
@pytest.mark.asyncio
50-
async def test_delete_before_create_not_possible(self, session: QuerySessionAsync):
50+
async def test_delete_before_create_not_possible(self, session: QuerySession):
5151
with pytest.raises(RuntimeError):
5252
await session.delete()
5353

5454
@pytest.mark.asyncio
55-
async def test_create_after_delete_not_possible(self, session: QuerySessionAsync):
55+
async def test_create_after_delete_not_possible(self, session: QuerySession):
5656
await session.create()
5757
await session.delete()
5858
with pytest.raises(RuntimeError):
5959
await session.create()
6060

61-
def test_transaction_before_create_raises(self, session: QuerySessionAsync):
61+
def test_transaction_before_create_raises(self, session: QuerySession):
6262
with pytest.raises(RuntimeError):
6363
session.transaction()
6464

6565
@pytest.mark.asyncio
66-
async def test_transaction_after_delete_raises(self, session: QuerySessionAsync):
66+
async def test_transaction_after_delete_raises(self, session: QuerySession):
6767
await session.create()
6868

6969
await session.delete()
@@ -72,24 +72,24 @@ async def test_transaction_after_delete_raises(self, session: QuerySessionAsync)
7272
session.transaction()
7373

7474
@pytest.mark.asyncio
75-
async def test_transaction_after_create_not_raises(self, session: QuerySessionAsync):
75+
async def test_transaction_after_create_not_raises(self, session: QuerySession):
7676
await session.create()
7777
session.transaction()
7878

7979
@pytest.mark.asyncio
80-
async def test_execute_before_create_raises(self, session: QuerySessionAsync):
80+
async def test_execute_before_create_raises(self, session: QuerySession):
8181
with pytest.raises(RuntimeError):
8282
await session.execute("select 1;")
8383

8484
@pytest.mark.asyncio
85-
async def test_execute_after_delete_raises(self, session: QuerySessionAsync):
85+
async def test_execute_after_delete_raises(self, session: QuerySession):
8686
await session.create()
8787
await session.delete()
8888
with pytest.raises(RuntimeError):
8989
await session.execute("select 1;")
9090

9191
@pytest.mark.asyncio
92-
async def test_basic_execute(self, session: QuerySessionAsync):
92+
async def test_basic_execute(self, session: QuerySession):
9393
await session.create()
9494
it = await session.execute("select 1;")
9595
result_sets = [result_set async for result_set in it]
@@ -100,7 +100,7 @@ async def test_basic_execute(self, session: QuerySessionAsync):
100100
assert list(result_sets[0].rows[0].values()) == [1]
101101

102102
@pytest.mark.asyncio
103-
async def test_two_results(self, session: QuerySessionAsync):
103+
async def test_two_results(self, session: QuerySession):
104104
await session.create()
105105
res = []
106106

tests/aio/query/test_query_session_pool.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,42 @@
11
import asyncio
22
import pytest
33
import ydb
4-
from ydb.aio.query.pool import QuerySessionPoolAsync
5-
from ydb.aio.query.session import QuerySessionAsync, QuerySessionStateEnum
4+
from ydb.aio.query.pool import QuerySessionPool
5+
from ydb.aio.query.session import QuerySession, QuerySessionStateEnum
66

77

8-
class TestQuerySessionPoolAsync:
8+
class TestQuerySessionPool:
99
@pytest.mark.asyncio
10-
async def test_checkout_provides_created_session(self, pool: QuerySessionPoolAsync):
10+
async def test_checkout_provides_created_session(self, pool: QuerySessionPool):
1111
async with pool.checkout() as session:
1212
assert session._state._state == QuerySessionStateEnum.CREATED
1313

1414
@pytest.mark.asyncio
15-
async def test_oneshot_query_normal(self, pool: QuerySessionPoolAsync):
15+
async def test_oneshot_query_normal(self, pool: QuerySessionPool):
1616
res = await pool.execute_with_retries("select 1;")
1717
assert len(res) == 1
1818

1919
@pytest.mark.asyncio
20-
async def test_oneshot_ddl_query(self, pool: QuerySessionPoolAsync):
20+
async def test_oneshot_ddl_query(self, pool: QuerySessionPool):
2121
await pool.execute_with_retries("drop table if exists Queen;")
2222
await pool.execute_with_retries("create table Queen(key UInt64, PRIMARY KEY (key));")
2323
await pool.execute_with_retries("drop table Queen;")
2424

2525
@pytest.mark.asyncio
26-
async def test_oneshot_query_raises(self, pool: QuerySessionPoolAsync):
26+
async def test_oneshot_query_raises(self, pool: QuerySessionPool):
2727
with pytest.raises(ydb.GenericError):
2828
await pool.execute_with_retries("Is this the real life? Is this just fantasy?")
2929

3030
@pytest.mark.asyncio
31-
async def test_retry_op_uses_created_session(self, pool: QuerySessionPoolAsync):
32-
async def callee(session: QuerySessionAsync):
31+
async def test_retry_op_uses_created_session(self, pool: QuerySessionPool):
32+
async def callee(session: QuerySession):
3333
assert session._state._state == QuerySessionStateEnum.CREATED
3434

3535
await pool.retry_operation_async(callee)
3636

3737
@pytest.mark.asyncio
38-
async def test_retry_op_normal(self, pool: QuerySessionPoolAsync):
39-
async def callee(session: QuerySessionAsync):
38+
async def test_retry_op_normal(self, pool: QuerySessionPool):
39+
async def callee(session: QuerySession):
4040
async with session.transaction() as tx:
4141
iterator = await tx.execute("select 1;", commit_tx=True)
4242
return [result_set async for result_set in iterator]
@@ -45,18 +45,18 @@ async def callee(session: QuerySessionAsync):
4545
assert len(res) == 1
4646

4747
@pytest.mark.asyncio
48-
async def test_retry_op_raises(self, pool: QuerySessionPoolAsync):
48+
async def test_retry_op_raises(self, pool: QuerySessionPool):
4949
class CustomException(Exception):
5050
pass
5151

52-
async def callee(session: QuerySessionAsync):
52+
async def callee(session: QuerySession):
5353
raise CustomException()
5454

5555
with pytest.raises(CustomException):
5656
await pool.retry_operation_async(callee)
5757

5858
@pytest.mark.asyncio
59-
async def test_pool_size_limit_logic(self, pool: QuerySessionPoolAsync):
59+
async def test_pool_size_limit_logic(self, pool: QuerySessionPool):
6060
target_size = 5
6161
pool._size = target_size
6262
ids = set()
@@ -78,7 +78,7 @@ async def test_pool_size_limit_logic(self, pool: QuerySessionPoolAsync):
7878
assert pool._current_size == target_size
7979

8080
@pytest.mark.asyncio
81-
async def test_checkout_do_not_increase_size(self, pool: QuerySessionPoolAsync):
81+
async def test_checkout_do_not_increase_size(self, pool: QuerySessionPool):
8282
session_id = None
8383
for _ in range(10):
8484
async with pool.checkout() as session:
@@ -88,7 +88,7 @@ async def test_checkout_do_not_increase_size(self, pool: QuerySessionPoolAsync):
8888
assert session_id == session._state.session_id
8989

9090
@pytest.mark.asyncio
91-
async def test_pool_recreates_bad_sessions(self, pool: QuerySessionPoolAsync):
91+
async def test_pool_recreates_bad_sessions(self, pool: QuerySessionPool):
9292
async with pool.checkout() as session:
9393
session_id = session._state.session_id
9494
await session.delete()
@@ -98,20 +98,20 @@ async def test_pool_recreates_bad_sessions(self, pool: QuerySessionPoolAsync):
9898
assert pool._current_size == 1
9999

100100
@pytest.mark.asyncio
101-
async def test_acquire_from_closed_pool_raises(self, pool: QuerySessionPoolAsync):
101+
async def test_acquire_from_closed_pool_raises(self, pool: QuerySessionPool):
102102
await pool.stop()
103103
with pytest.raises(RuntimeError):
104104
await pool.acquire()
105105

106106
@pytest.mark.asyncio
107-
async def test_acquire_with_timeout_from_closed_pool_raises(self, pool: QuerySessionPoolAsync):
107+
async def test_acquire_with_timeout_from_closed_pool_raises(self, pool: QuerySessionPool):
108108
await pool.stop()
109109
with pytest.raises(RuntimeError):
110110
await asyncio.wait_for(pool.acquire(), timeout=0.1)
111111

112112
@pytest.mark.asyncio
113113
async def test_no_session_leak(self, driver, docker_project):
114-
pool = ydb.aio.QuerySessionPoolAsync(driver, 1)
114+
pool = ydb.aio.QuerySessionPool(driver, 1)
115115
docker_project.stop()
116116
try:
117117
await asyncio.wait_for(pool.acquire(), timeout=0.1)

0 commit comments

Comments
 (0)