{"id":2760,"library":"sagemaker-mlflow","title":"SageMaker MLflow Plugin","description":"sagemaker-mlflow is an AWS plugin that enables MLflow to use SageMaker as its backend for experiment tracking, allowing users to leverage SageMaker's managed infrastructure for MLflow tracking servers and artifact storage. The current version is 0.2.0, with releases occurring as new features or bug fixes are introduced, typically driven by community contributions and AWS service enhancements.","status":"active","version":"0.2.0","language":"en","source_language":"en","source_url":"https://github.com/aws/sagemaker-mlflow","tags":["aws","sagemaker","mlflow","machine learning","experiment tracking","mle"],"install":[{"cmd":"pip install sagemaker-mlflow","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"symbol":"sagemaker_mlflow","correct":"import sagemaker_mlflow"}],"quickstart":{"code":"import sagemaker_mlflow\nimport mlflow\nimport os\n\n# Ensure MLflow is installed alongside sagemaker-mlflow\n\n# Option 1: Explicitly set the tracking URI\n# This assumes a SageMaker MLflow Tracking Server is already provisioned.\n# You might need to set AWS_REGION environment variable if not in SageMaker Studio.\n# os.environ['AWS_REGION'] = 'us-east-1'\n\ntry:\n    tracking_uri = sagemaker_mlflow.get_sagemaker_tracking_uri()\n    mlflow.set_tracking_uri(tracking_uri)\n    print(f\"MLflow Tracking URI set to: {tracking_uri}\")\n\n    with mlflow.start_run() as run:\n        mlflow.log_param(\"alpha\", 0.5)\n        mlflow.log_metric(\"rmse\", 0.75)\n        print(f\"Logged run with ID: {run.info.run_id}\")\n\nexcept Exception as e:\n    print(f\"Failed to set MLflow Tracking URI or start run: {e}\")\n    print(\"Ensure a SageMaker MLflow Tracking Server is deployed and your IAM role has permissions.\")\n\n# Option 2 (recommended for SageMaker Studio environments):\n# sagemaker_mlflow.enable_global_sagemaker_mlflow_tracking()\n# print(\"Global SageMaker MLflow tracking enabled.\")\n# with mlflow.start_run() as run:\n#    mlflow.log_param(\"beta\", 0.1)\n#    mlflow.log_metric(\"accuracy\", 0.99)\n#    print(f\"Logged another run with ID: {run.info.run_id}\")\n","lang":"python","description":"This example demonstrates how to configure MLflow to use SageMaker for experiment tracking. It first attempts to retrieve the SageMaker MLflow tracking URI and then logs a simple run. It also shows an alternative for SageMaker Studio users to globally enable tracking. Before running, ensure you have an active SageMaker MLflow Tracking Server and appropriate IAM permissions."},"warnings":[{"fix":"Ensure a SageMaker MLflow Tracking Server is deployed in your AWS account and region. Refer to AWS SageMaker documentation for deploying MLflow Tracking Servers.","message":"The sagemaker-mlflow plugin connects to an existing SageMaker MLflow Tracking Server. It does not provision or deploy this server for you. Users must first deploy an MLflow Tracking Server in SageMaker (e.g., via SageMaker Studio applications) before using this plugin.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Review and grant the necessary IAM permissions to your execution role/user. This typically includes `sagemaker:ListMlflowTrackingServers`, `sagemaker:CreateMlflowTrackingServer` (if creating one), and S3 `PutObject`, `GetObject`, `ListBucket` for the artifact bucket.","message":"Proper IAM permissions are crucial. The AWS identity (user or role) executing the MLflow code must have permissions to list and connect to SageMaker MLflow Tracking Servers, as well as necessary S3 permissions for artifact storage. Missing permissions often result in connection errors.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Upgrade to `sagemaker-mlflow` version 0.2.0 or newer to enable cross-account functionality. If unable to upgrade, ensure both the MLflow client and tracking server are in the same AWS account.","message":"Cross-account access to a SageMaker MLflow Tracking Server is only supported from `sagemaker-mlflow` version 0.2.0 onwards. If you are using an older version, the tracking server and your MLflow client must reside in the same AWS account.","severity":"gotcha","affected_versions":"<0.2.0"}],"env_vars":null,"last_verified":"2026-04-10T00:00:00.000Z","next_check":"2026-07-09T00:00:00.000Z"}