Skip to content
This repository was archived by the owner on Apr 1, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/classic_client/snippets.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
STORAGE_TYPE = enums.StorageType.SSD
LABEL_KEY = "python-snippet"
LABEL_STAMP = (
datetime.datetime.utcnow()
datetime.datetime.now(datetime.UTC)
.replace(microsecond=0, tzinfo=UTC)
Comment thread
daniel-sanche marked this conversation as resolved.
Outdated
.strftime("%Y-%m-%dt%H-%M-%S")
)
Expand Down
16 changes: 8 additions & 8 deletions docs/classic_client/snippets_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
STORAGE_TYPE = enums.StorageType.SSD
LABEL_KEY = "python-snippet"
LABEL_STAMP = (
datetime.datetime.utcnow()
datetime.datetime.now(datetime.UTC)
.replace(microsecond=0, tzinfo=UTC)
Comment thread
daniel-sanche marked this conversation as resolved.
Outdated
.strftime("%Y-%m-%dt%H-%M-%S")
)
Expand Down Expand Up @@ -179,7 +179,7 @@ def test_bigtable_write_read_drop_truncate():
value = "value_{}".format(i).encode()
row = table.row(row_key)
row.set_cell(
COLUMN_FAMILY_ID, col_name, value, timestamp=datetime.datetime.utcnow()
COLUMN_FAMILY_ID, col_name, value, timestamp=datetime.datetime.now(datetime.UTC)
)
rows.append(row)
response = table.mutate_rows(rows)
Expand Down Expand Up @@ -270,7 +270,7 @@ def test_bigtable_mutations_batcher():
row_key = row_keys[0]
row = table.row(row_key)
row.set_cell(
COLUMN_FAMILY_ID, column_name, "value-0", timestamp=datetime.datetime.utcnow()
COLUMN_FAMILY_ID, column_name, "value-0", timestamp=datetime.datetime.now(datetime.UTC)
)
batcher.mutate(row)
# Add a collections of rows
Expand All @@ -279,7 +279,7 @@ def test_bigtable_mutations_batcher():
row = table.row(row_keys[i])
value = "value_{}".format(i).encode()
row.set_cell(
COLUMN_FAMILY_ID, column_name, value, timestamp=datetime.datetime.utcnow()
COLUMN_FAMILY_ID, column_name, value, timestamp=datetime.datetime.now(datetime.UTC)
)
rows.append(row)
batcher.mutate_rows(rows)
Expand Down Expand Up @@ -759,7 +759,7 @@ def test_bigtable_batcher_mutate_flush_mutate_rows():
row_key = b"row_key_1"
row = table.row(row_key)
row.set_cell(
COLUMN_FAMILY_ID, COL_NAME1, "value-0", timestamp=datetime.datetime.utcnow()
COLUMN_FAMILY_ID, COL_NAME1, "value-0", timestamp=datetime.datetime.now(datetime.UTC)
)

# In batcher, mutate will flush current batch if it
Expand Down Expand Up @@ -967,12 +967,12 @@ def test_bigtable_row_data_cells_cell_value_cell_values():
value = b"value_in_col1"
row = Config.TABLE.row(b"row_key_1")
row.set_cell(
COLUMN_FAMILY_ID, COL_NAME1, value, timestamp=datetime.datetime.utcnow()
COLUMN_FAMILY_ID, COL_NAME1, value, timestamp=datetime.datetime.now(datetime.UTC)
)
row.commit()

row.set_cell(
COLUMN_FAMILY_ID, COL_NAME1, value, timestamp=datetime.datetime.utcnow()
COLUMN_FAMILY_ID, COL_NAME1, value, timestamp=datetime.datetime.now(datetime.UTC)
)
row.commit()

Expand Down Expand Up @@ -1050,7 +1050,7 @@ def test_bigtable_row_setcell_rowkey():

cell_val = b"cell-val"
row.set_cell(
COLUMN_FAMILY_ID, COL_NAME1, cell_val, timestamp=datetime.datetime.utcnow()
COLUMN_FAMILY_ID, COL_NAME1, cell_val, timestamp=datetime.datetime.now(datetime.UTC)
)
# [END bigtable_api_row_set_cell]

Expand Down
2 changes: 1 addition & 1 deletion samples/hello/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def main(project_id, instance_id, table_id):
row_key = f"greeting{i}".encode()
row = table.direct_row(row_key)
row.set_cell(
column_family_id, column, value, timestamp=datetime.datetime.utcnow(),
column_family_id, column, value, timestamp=datetime.datetime.now(datetime.UTC),
)
rows.append(row)
table.mutate_rows(rows)
Expand Down
2 changes: 1 addition & 1 deletion samples/snippets/writes/write_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def write_batch(project_id, instance_id, table_id):
table = instance.table(table_id)

with MutationsBatcher(table=table) as batcher:
timestamp = datetime.datetime.utcnow()
timestamp = datetime.datetime.now(datetime.UTC)
column_family_id = "stats_summary"

rows = [
Expand Down
2 changes: 1 addition & 1 deletion samples/snippets/writes/write_conditionally.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def write_conditional(project_id, instance_id, table_id):
instance = client.instance(instance_id)
table = instance.table(table_id)

timestamp = datetime.datetime.utcnow()
timestamp = datetime.datetime.now(datetime.UTC)
column_family_id = "stats_summary"

row_key = "phone#4c410523#20190501"
Expand Down
2 changes: 1 addition & 1 deletion samples/snippets/writes/write_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def write_simple(project_id, instance_id, table_id):
instance = client.instance(instance_id)
table = instance.table(table_id)

timestamp = datetime.datetime.utcnow()
timestamp = datetime.datetime.now(datetime.UTC)
column_family_id = "stats_summary"

row_key = "phone#4c410523#20190501"
Expand Down
2 changes: 1 addition & 1 deletion tests/system/v2_client/_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def _retry_on_unavailable(exc):

def label_stamp():
return (
datetime.datetime.utcnow()
datetime.datetime.now(datetime.UTC)
.replace(microsecond=0, tzinfo=UTC)
Comment thread
daniel-sanche marked this conversation as resolved.
Outdated
.strftime("%Y-%m-%dt%H-%M-%S")
)
2 changes: 1 addition & 1 deletion tests/system/v2_client/test_data_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ def _write_to_row(row1, row2, row3, row4):
from google.cloud._helpers import UTC
from google.cloud.bigtable.row_data import Cell

timestamp1 = datetime.datetime.utcnow().replace(tzinfo=UTC)
timestamp1 = datetime.datetime.now(datetime.UTC)
timestamp1_micros = _microseconds_from_datetime(timestamp1)
# Truncate to millisecond granularity.
timestamp1_micros -= timestamp1_micros % 1000
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/v2_client/test_backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@


def _make_timestamp():
return datetime.datetime.utcnow().replace(tzinfo=UTC)
return datetime.datetime.now(datetime.UTC)


def _make_table_admin_client():
Expand Down
16 changes: 8 additions & 8 deletions tests/unit/v2_client/test_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ def test_cluster_create():
from google.cloud.bigtable_admin_v2.types import instance as instance_v2_pb2
from google.cloud.bigtable.enums import StorageType

NOW = datetime.datetime.utcnow()
NOW = datetime.datetime.now(datetime.UTC)
NOW_PB = _datetime_to_pb_timestamp(NOW)
credentials = _make_credentials()
client = _make_client(project=PROJECT, credentials=credentials, admin=True)
Expand Down Expand Up @@ -475,7 +475,7 @@ def test_cluster_create_w_cmek():
from google.cloud.bigtable_admin_v2.types import instance as instance_v2_pb2
from google.cloud.bigtable.enums import StorageType

NOW = datetime.datetime.utcnow()
NOW = datetime.datetime.now(datetime.UTC)
NOW_PB = _datetime_to_pb_timestamp(NOW)
credentials = _make_credentials()
client = _make_client(project=PROJECT, credentials=credentials, admin=True)
Expand Down Expand Up @@ -535,7 +535,7 @@ def test_cluster_create_w_autoscaling():
from google.cloud.bigtable_admin_v2.types import instance as instance_v2_pb2
from google.cloud.bigtable.enums import StorageType

NOW = datetime.datetime.utcnow()
NOW = datetime.datetime.now(datetime.UTC)
NOW_PB = _datetime_to_pb_timestamp(NOW)
credentials = _make_credentials()
client = _make_client(project=PROJECT, credentials=credentials, admin=True)
Expand Down Expand Up @@ -602,7 +602,7 @@ def test_cluster_update():
)
from google.cloud.bigtable.enums import StorageType

NOW = datetime.datetime.utcnow()
NOW = datetime.datetime.now(datetime.UTC)
NOW_PB = _datetime_to_pb_timestamp(NOW)

credentials = _make_credentials()
Expand Down Expand Up @@ -669,7 +669,7 @@ def test_cluster_update_w_autoscaling():
)
from google.cloud.bigtable.enums import StorageType

NOW = datetime.datetime.utcnow()
NOW = datetime.datetime.now(datetime.UTC)
NOW_PB = _datetime_to_pb_timestamp(NOW)

credentials = _make_credentials()
Expand Down Expand Up @@ -728,7 +728,7 @@ def test_cluster_update_w_partial_autoscaling_config():
)
from google.cloud.bigtable.enums import StorageType

NOW = datetime.datetime.utcnow()
NOW = datetime.datetime.now(datetime.UTC)
NOW_PB = _datetime_to_pb_timestamp(NOW)

credentials = _make_credentials()
Expand Down Expand Up @@ -812,7 +812,7 @@ def test_cluster_update_w_both_manual_and_autoscaling():
)
from google.cloud.bigtable.enums import StorageType

NOW = datetime.datetime.utcnow()
NOW = datetime.datetime.now(datetime.UTC)
NOW_PB = _datetime_to_pb_timestamp(NOW)

credentials = _make_credentials()
Expand Down Expand Up @@ -873,7 +873,7 @@ def test_cluster_disable_autoscaling():
from google.cloud.bigtable.instance import Instance
from google.cloud.bigtable.enums import StorageType

NOW = datetime.datetime.utcnow()
NOW = datetime.datetime.now(datetime.UTC)
NOW_PB = _datetime_to_pb_timestamp(NOW)
credentials = _make_credentials()
client = _make_client(project=PROJECT, credentials=credentials, admin=True)
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/v2_client/test_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ def _instance_api_response_for_create():
)
from google.cloud.bigtable_admin_v2.types import instance

NOW = datetime.datetime.utcnow()
NOW = datetime.datetime.now(datetime.UTC)
NOW_PB = _datetime_to_pb_timestamp(NOW)
metadata = messages_v2_pb2.CreateInstanceMetadata(request_time=NOW_PB)
type_url = "type.googleapis.com/{}".format(
Expand Down Expand Up @@ -503,7 +503,7 @@ def _instance_api_response_for_update():
)
from google.cloud.bigtable_admin_v2.types import instance

NOW = datetime.datetime.utcnow()
NOW = datetime.datetime.now(datetime.UTC)
NOW_PB = _datetime_to_pb_timestamp(NOW)
metadata = messages_v2_pb2.UpdateInstanceMetadata(request_time=NOW_PB)
type_url = "type.googleapis.com/{}".format(
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/v2_client/test_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -1384,7 +1384,7 @@ def test_table_backup_factory_non_defaults():

instance = Instance(INSTANCE_ID, None)
table = _make_table(TABLE_ID, instance)
timestamp = datetime.datetime.utcnow().replace(tzinfo=UTC)
timestamp = datetime.datetime.now(datetime.UTC)
backup = table.backup(
BACKUP_ID,
cluster_id=CLUSTER_ID,
Expand Down
Loading