Skip to content

Commit 1193530

Browse files
chore: use more verbose paths in hello snippets (#1045)
1 parent 7ea3c23 commit 1193530

17 files changed

+42
-22
lines changed

samples/beam/requirements-test.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
pytest==8.3.2
1+
pytest

samples/hello/async_main.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@
3131
# [START bigtable_async_hw_imports]
3232
from google.cloud import bigtable
3333
from google.cloud.bigtable.data import row_filters
34-
from google.cloud.bigtable.data import RowMutationEntry
35-
from google.cloud.bigtable.data import SetCell
36-
from google.cloud.bigtable.data import ReadRowsQuery
3734
# [END bigtable_async_hw_imports]
3835

36+
# use to ignore warnings
37+
row_filters
38+
3939

4040
async def main(project_id, instance_id, table_id):
4141
# [START bigtable_async_hw_connect]
@@ -85,8 +85,8 @@ async def main(project_id, instance_id, table_id):
8585
#
8686
# https://cloud.google.com/bigtable/docs/schema-design
8787
row_key = "greeting{}".format(i).encode()
88-
row_mutation = RowMutationEntry(
89-
row_key, SetCell(column_family_id, column, value)
88+
row_mutation = bigtable.data.RowMutationEntry(
89+
row_key, bigtable.data.SetCell(column_family_id, column, value)
9090
)
9191
mutations.append(row_mutation)
9292
await table.bulk_mutate_rows(mutations)
@@ -95,7 +95,7 @@ async def main(project_id, instance_id, table_id):
9595
# [START bigtable_async_hw_create_filter]
9696
# Create a filter to only retrieve the most recent version of the cell
9797
# for each column across entire row.
98-
row_filter = row_filters.CellsColumnLimitFilter(1)
98+
row_filter = bigtable.data.row_filters.CellsColumnLimitFilter(1)
9999
# [END bigtable_async_hw_create_filter]
100100

101101
# [START bigtable_async_hw_get_with_filter]
@@ -112,7 +112,7 @@ async def main(project_id, instance_id, table_id):
112112
# [START bigtable_async_hw_scan_with_filter]
113113
# [START bigtable_async_hw_scan_all]
114114
print("Scanning for all greetings:")
115-
query = ReadRowsQuery(row_filter=row_filter)
115+
query = bigtable.data.ReadRowsQuery(row_filter=row_filter)
116116
async for row in await table.read_rows_stream(query):
117117
cell = row.cells[0]
118118
print(cell.value.decode("utf-8"))

samples/hello/main.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@
3636

3737
# [END bigtable_hw_imports]
3838

39+
# use to avoid warnings
40+
row_filters
41+
column_family
42+
3943

4044
def main(project_id, instance_id, table_id):
4145
# [START bigtable_hw_connect]
@@ -52,7 +56,7 @@ def main(project_id, instance_id, table_id):
5256
print("Creating column family cf1 with Max Version GC rule...")
5357
# Create a column family with GC policy : most recent N versions
5458
# Define the GC policy to retain only the most recent 2 versions
55-
max_versions_rule = column_family.MaxVersionsGCRule(2)
59+
max_versions_rule = bigtable.column_family.MaxVersionsGCRule(2)
5660
column_family_id = "cf1"
5761
column_families = {column_family_id: max_versions_rule}
5862
if not table.exists():
@@ -93,7 +97,7 @@ def main(project_id, instance_id, table_id):
9397
# [START bigtable_hw_create_filter]
9498
# Create a filter to only retrieve the most recent version of the cell
9599
# for each column across entire row.
96-
row_filter = row_filters.CellsColumnLimitFilter(1)
100+
row_filter = bigtable.row_filters.CellsColumnLimitFilter(1)
97101
# [END bigtable_hw_create_filter]
98102

99103
# [START bigtable_hw_get_with_filter]

samples/hello/requirements-test.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
pytest==8.3.2
1+
pytest
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
pytest==8.3.2
1+
pytest
+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
pytest==8.3.2
1+
pytest
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
pytest==8.3.2
1+
pytest
22
mock==5.1.0
33
google-cloud-testutils
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
pytest==8.3.2
1+
pytest
22
pytest-asyncio
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
pytest==8.3.2
1+
pytest
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
pytest==8.3.2
1+
pytest
22
pytest-asyncio

samples/snippets/deletes/deletes_async_test.py

+8
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@
3030
TABLE_ID = f"mobile-time-series-deletes-async-{str(uuid.uuid4())[:16]}"
3131

3232

33+
@pytest.fixture(scope="module")
34+
def event_loop():
35+
import asyncio
36+
loop = asyncio.get_event_loop_policy().new_event_loop()
37+
yield loop
38+
loop.close()
39+
40+
3341
@pytest_asyncio.fixture(scope="module", autouse=True)
3442
async def table_id() -> AsyncGenerator[str, None]:
3543
with create_table_cm(PROJECT, BIGTABLE_INSTANCE, TABLE_ID, {"stats_summary": None, "cell_plan": None}, verbose=False):
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
pytest==8.3.2
1+
pytest
22
pytest-asyncio

samples/snippets/filters/filter_snippets_async_test.py

+8
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@
3434
TABLE_ID = f"mobile-time-series-filters-async-{str(uuid.uuid4())[:16]}"
3535

3636

37+
@pytest.fixture(scope="module")
38+
def event_loop():
39+
import asyncio
40+
loop = asyncio.get_event_loop_policy().new_event_loop()
41+
yield loop
42+
loop.close()
43+
44+
3745
@pytest_asyncio.fixture(scope="module", autouse=True)
3846
async def table_id() -> AsyncGenerator[str, None]:
3947
with create_table_cm(PROJECT, BIGTABLE_INSTANCE, TABLE_ID, {"stats_summary": None, "cell_plan": None}):
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
pytest==8.3.2
1+
pytest
22
pytest-asyncio
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
pytest==8.3.2
1+
pytest
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
backoff==2.2.1
2-
pytest==8.3.2
2+
pytest
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
pytest==8.3.2
1+
pytest
22
google-cloud-testutils==1.4.0

0 commit comments

Comments
 (0)