Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix timestamp proto util to default to timestamp at call time. #933

Merged
merged 2 commits into from Dec 29, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 5 additions & 3 deletions google/cloud/aiplatform/utils/__init__.py
Expand Up @@ -617,15 +617,17 @@ 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.
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.
Expand Down