From d13e4fc2ceb7bae978b78b58c0e3bf98313f8883 Mon Sep 17 00:00:00 2001 From: Sasha Sobran Date: Tue, 28 Dec 2021 14:11:08 -0500 Subject: [PATCH 1/2] fix: Fix timestamp proto util to default to timestamp at call time. --- google/cloud/aiplatform/utils/__init__.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/google/cloud/aiplatform/utils/__init__.py b/google/cloud/aiplatform/utils/__init__.py index acfde30aea..cefdcba998 100644 --- a/google/cloud/aiplatform/utils/__init__.py +++ b/google/cloud/aiplatform/utils/__init__.py @@ -617,15 +617,18 @@ def _timestamped_copy_to_gcs( def get_timestamp_proto( - time: Optional[datetime.datetime] = datetime.datetime.now(), + time: Optional[datetime.datetime] = None, ) -> timestamp_pb2.Timestamp: """Gets timestamp proto of a given time. + Args: time (datetime.datetime): - Required. A user provided time. Default to datetime.datetime.now() if not given. + Optional. A user provided time. Default to datetime.datetime.now() if not given. Returns: timestamp_pb2.Timestamp - timestamp proto of the given time, not have higher than millisecond precision. """ + if not time: + time = datetime.datetime.now() t = time.timestamp() seconds = int(t) # must not have higher than millisecond precision. From cf60e5fb1aa1dcaf68e0fa6ed4ffa18fc229a055 Mon Sep 17 00:00:00 2001 From: Sasha Sobran Date: Tue, 28 Dec 2021 15:34:47 -0500 Subject: [PATCH 2/2] chore: lint --- google/cloud/aiplatform/utils/__init__.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/google/cloud/aiplatform/utils/__init__.py b/google/cloud/aiplatform/utils/__init__.py index cefdcba998..26b28dcdd7 100644 --- a/google/cloud/aiplatform/utils/__init__.py +++ b/google/cloud/aiplatform/utils/__init__.py @@ -620,12 +620,11 @@ def get_timestamp_proto( time: Optional[datetime.datetime] = None, ) -> timestamp_pb2.Timestamp: """Gets timestamp proto of a given time. - Args: time (datetime.datetime): Optional. A user provided time. Default to datetime.datetime.now() if not given. Returns: - timestamp_pb2.Timestamp - timestamp proto of the given time, not have higher than millisecond precision. + timestamp_pb2.Timestamp: timestamp proto of the given time, not have higher than millisecond precision. """ if not time: time = datetime.datetime.now()