Skip to content

Commit 063480d

Browse files
committed
Add mlflow tracking arn telemetry
1 parent 305bdf8 commit 063480d

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/sagemaker/serve/utils/telemetry_logger.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
from sagemaker import Session, exceptions
2121
from sagemaker.serve.mode.function_pointers import Mode
22-
from sagemaker.serve.model_format.mlflow.constants import MLFLOW_MODEL_PATH
22+
from sagemaker.serve.model_format.mlflow.constants import MLFLOW_MODEL_PATH, MLFLOW_TRACKING_ARN
2323
from sagemaker.serve.utils.exceptions import ModelBuilderException
2424
from sagemaker.serve.utils.lineage_constants import (
2525
MLFLOW_LOCAL_PATH,
@@ -144,6 +144,9 @@ def wrapper(self, *args, **kwargs):
144144
mlflow_model_path = self.model_metadata[MLFLOW_MODEL_PATH]
145145
mlflow_model_path_type = _get_mlflow_model_path_type(mlflow_model_path)
146146
extra += f"&x-mlflowModelPathType={MLFLOW_MODEL_PATH_CODE[mlflow_model_path_type]}"
147+
mlflow_model_tracking_server_arn = self.model_metadata.get(MLFLOW_TRACKING_ARN)
148+
if mlflow_model_tracking_server_arn is not None:
149+
extra += f"&x-mlflowTrackingServerArn={mlflow_model_tracking_server_arn}"
147150

148151
if getattr(self, "model_hub", False):
149152
extra += f"&x-modelHub={MODEL_HUB_TO_CODE[str(self.model_hub)]}"

tests/unit/sagemaker/serve/utils/test_telemetry_logger.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import unittest
1515
from unittest.mock import Mock, patch, MagicMock
1616
from sagemaker.serve import Mode, ModelServer
17-
from sagemaker.serve.model_format.mlflow.constants import MLFLOW_MODEL_PATH
17+
from sagemaker.serve.model_format.mlflow.constants import MLFLOW_MODEL_PATH, MLFLOW_TRACKING_ARN
1818
from sagemaker.serve.utils.telemetry_logger import (
1919
_send_telemetry,
2020
_capture_telemetry,
@@ -40,7 +40,10 @@
4040
MOCK_HUGGINGFACE_ID = "meta-llama/Llama-2-7b-hf"
4141
MOCK_EXCEPTION = LocalModelOutOfMemoryException("mock raise ex")
4242
MOCK_ENDPOINT_ARN = "arn:aws:sagemaker:us-west-2:123456789012:endpoint/test"
43-
MOCK_MODEL_METADATA_FOR_MLFLOW = {MLFLOW_MODEL_PATH: "s3://some_path"}
43+
MOCK_MODEL_METADATA_FOR_MLFLOW = {
44+
MLFLOW_MODEL_PATH: "s3://some_path",
45+
MLFLOW_TRACKING_ARN: "arn:aws:sagemaker:us-west-2:000000000000:mlflow-tracking-server/test",
46+
}
4447

4548

4649
class ModelBuilderMock:
@@ -274,6 +277,7 @@ def test_capture_telemetry_decorator_mlflow_success(self, mock_send_telemetry):
274277
f"&x-defaultImageUsage={ImageUriOption.DEFAULT_IMAGE.value}"
275278
f"&x-endpointArn={MOCK_ENDPOINT_ARN}"
276279
f"&x-mlflowModelPathType=2"
280+
f"&x-mlflowTrackingServerArn={MOCK_MODEL_METADATA_FOR_MLFLOW[MLFLOW_TRACKING_ARN]}"
277281
f"&x-latency={latency}"
278282
)
279283

0 commit comments

Comments
 (0)