Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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: 2 additions & 0 deletions sagemaker-serve/src/sagemaker/serve/bedrock_model_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,9 @@ def _is_nova_model_for_telemetry(self) -> bool:
func_name="BedrockModelBuilder.deploy",
telemetry_params=[
("model_package", TelemetryParamType.ATTR_EXISTS),
("_is_nova_model_for_telemetry", TelemetryParamType.ATTR_CALL),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how does this work? What if bedrock model builder doesn't call _is_nova_model_for_telemetry() and calls _is_nova_model instead?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so every time BedrockModelBuilder.deploy() is called, the decorator runs _is_nova_model_for_telemetry before the actual deploy() body executes. The actual method called inside deploy doesn't matter

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for explaining.

("imported_model_kms_key_id", TelemetryParamType.KWARG_EXISTS),
("reuse_resources", TelemetryParamType.KWARG_EXISTS),
],
)
def deploy(
Expand Down
4 changes: 4 additions & 0 deletions sagemaker-serve/src/sagemaker/serve/model_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -3948,9 +3948,11 @@ def _reset_build_state(self):
func_name="model_builder.build",
telemetry_params=[
("mode", TelemetryParamType.ATTR_VALUE),
("_is_nova_model_for_telemetry", TelemetryParamType.ATTR_CALL),
("network", TelemetryParamType.ATTR_EXISTS),
("source_code", TelemetryParamType.ATTR_EXISTS),
("inference_spec", TelemetryParamType.ATTR_EXISTS),
("reuse_resources", TelemetryParamType.KWARG_EXISTS),
],
)
@runnable_by_pipeline
Expand Down Expand Up @@ -5326,9 +5328,11 @@ def _deploy_recommendation(
("mode", TelemetryParamType.ATTR_VALUE),
("instance_type", TelemetryParamType.ATTR_VALUE),
("_is_model_customization", TelemetryParamType.ATTR_CALL),
("_is_nova_model_for_telemetry", TelemetryParamType.ATTR_CALL),
("network", TelemetryParamType.ATTR_EXISTS),
("compute", TelemetryParamType.ATTR_EXISTS),
("update_endpoint", TelemetryParamType.KWARG_EXISTS),
("reuse_resources", TelemetryParamType.KWARG_EXISTS),
],
)
def deploy(
Expand Down
16 changes: 16 additions & 0 deletions sagemaker-train/src/sagemaker/train/base_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
from sagemaker.train.common_utils.notifications import enable_notifications, delete_notification_rule, list_notification_rules
from sagemaker.train.common_utils.validator import validate_hyperpod_compute
from sagemaker.train.common_utils.cloudwatch_metrics import fetch_and_plot_metrics, _get_smhp_log_group
from sagemaker.core.telemetry.telemetry_logging import _telemetry_emitter, TelemetryParamType
from sagemaker.core.telemetry.constants import Feature
from sagemaker.train.defaults import TrainDefaults
from sagemaker.train.model_trainer import ModelTrainer
from sagemaker.train.utils import _get_unique_name
Expand Down Expand Up @@ -365,6 +367,13 @@ def _apply_recipe_to_hyperparameters(

return final_hyperparameters

@_telemetry_emitter(
feature=Feature.MODEL_CUSTOMIZATION,
func_name="BaseTrainer.show_metrics",
telemetry_params=[
("compute", TelemetryParamType.ATTR_TYPE),
],
)
def show_metrics(
self,
metrics: Optional[List[str]] = None,
Expand Down Expand Up @@ -627,6 +636,13 @@ def list_notification_rules(
event_bus_arn=event_bus_arn,
)

@_telemetry_emitter(
feature=Feature.MODEL_CUSTOMIZATION,
func_name="BaseTrainer.stream_logs",
telemetry_params=[
("compute", TelemetryParamType.ATTR_TYPE),
],
)
def stream_logs(self, poll: int = 5, start_time: Optional[Any] = None, tail_lines: Optional[int] = None) -> None:
"""Stream CloudWatch logs in real-time (like ``kubectl logs -f``).

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
("kms_key_id", TelemetryParamType.ATTR_EXISTS),
("mlflow_resource_arn", TelemetryParamType.ATTR_EXISTS),
("stopping_condition", TelemetryParamType.ATTR_EXISTS),
("notification_rule_arn", TelemetryParamType.ATTR_EXISTS),
("validation_dataset", TelemetryParamType.KWARG_EXISTS),
("wait", TelemetryParamType.KWARG_EXISTS),
("dry_run", TelemetryParamType.KWARG_EXISTS),
]

# Common params for all evaluators
Expand All @@ -20,4 +22,5 @@
("networking", TelemetryParamType.ATTR_EXISTS),
("kms_key_id", TelemetryParamType.ATTR_EXISTS),
("mlflow_resource_arn", TelemetryParamType.ATTR_EXISTS),
("dry_run", TelemetryParamType.KWARG_EXISTS),
]
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
_is_nova_model,
)
from sagemaker.train.common_utils.cloudwatch_metrics import _get_smhp_log_group
from sagemaker.core.telemetry.telemetry_logging import _telemetry_emitter, TelemetryParamType
from sagemaker.core.telemetry.constants import Feature
from sagemaker.train.common_utils.log_streamer import (
LogStreamer,
_format_timestamp,
Expand Down Expand Up @@ -1096,6 +1098,13 @@ def evaluate(self, dry_run: bool = False) -> Any:
"""
raise NotImplementedError("Subclasses must implement evaluate method")

@_telemetry_emitter(
feature=Feature.MODEL_CUSTOMIZATION,
func_name="BaseEvaluator.stream_logs",
telemetry_params=[
("compute", TelemetryParamType.ATTR_TYPE),
],
)
def stream_logs(self, poll: int = 5, start_time=None) -> None:
"""Stream CloudWatch logs for the latest evaluation execution.

Expand Down