Skip to content

Commit

Permalink
feat: Allow module_name to be specified with the base logger.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 612860933
  • Loading branch information
yeesian authored and copybara-github committed Mar 5, 2024
1 parent 0b33bdd commit c01df66
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions google/cloud/aiplatform/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ def log_create_complete(
cls: Type["VertexAiResourceNoun"],
resource: proto.Message,
variable_name: str,
*,
module_name: str = "aiplatform",
):
"""Logs create event is complete.
Expand All @@ -102,17 +104,23 @@ def log_create_complete(
Vertex AI Resource Noun class that is being created.
resource (proto.Message):
Vertex AI Resource proto.Message
variable_name (str): Name of variable to use for code snippet
variable_name (str):
Name of variable to use for code snippet.
module_name (str):
The module namespace under which the Vertex AI Resource Noun
is available. Defaults to `aiplatform`.
"""
self.info(f"{cls.__name__} created. Resource name: {resource.name}")
self.info(f"To use this {cls.__name__} in another session:")
self.info(f"{variable_name} = aiplatform.{cls.__name__}('{resource.name}')")
self.info(f"{variable_name} = {module_name}.{cls.__name__}('{resource.name}')")

def log_create_complete_with_getter(
self,
cls: Type["VertexAiResourceNoun"],
resource: proto.Message,
variable_name: str,
*,
module_name: str = "aiplatform",
):
"""Logs create event is complete.
Expand All @@ -123,11 +131,16 @@ def log_create_complete_with_getter(
Vertex AI Resource Noun class that is being created.
resource (proto.Message):
Vertex AI Resource proto.Message
variable_name (str): Name of variable to use for code snippet
variable_name (str):
Name of variable to use for code snippet.
module_name (str):
The module namespace under which the Vertex AI Resource Noun
is available. Defaults to `aiplatform`.
"""
self.info(f"{cls.__name__} created. Resource name: {resource.name}")
self.info(f"To use this {cls.__name__} in another session:")
self.info(f"{variable_name} = aiplatform.{cls.__name__}.get('{resource.name}')")
usage_message = f"{module_name}.{cls.__name__}.get('{resource.name}')"
self.info(f"{variable_name} = {usage_message}")

def log_delete_with_lro(
self,
Expand Down

0 comments on commit c01df66

Please sign in to comment.