{"id":3796,"library":"sagemaker-train","title":"SageMaker Training (Deprecated)","description":"This library, `sagemaker-train`, is deprecated and no longer maintained. It previously provided functionalities for defining and running training jobs on Amazon SageMaker. Users are strongly advised to migrate to the main `sagemaker` Python SDK (also known as `sagemaker-python-sdk`) for all SageMaker interactions, including training, which offers comprehensive and actively developed features. The last stable version of `sagemaker-train` is 1.7.1.","status":"deprecated","version":"1.7.1","language":"python","source_language":"en","source_url":"https://github.com/aws/sagemaker-python-sdk","tags":["aws","sagemaker","ml","training","deprecated","sdk","python"],"install":[{"cmd":"pip install sagemaker-train","lang":"bash","label":"Install deprecated library (NOT RECOMMENDED)"},{"cmd":"pip install sagemaker","lang":"bash","label":"Install recommended replacement (SageMaker Python SDK)"}],"dependencies":[],"imports":[{"wrong":"from sagemaker.estimator import Estimator","symbol":"Estimator","correct":"from sagemaker.estimator import Estimator"}],"quickstart":{"code":"import sagemaker\nfrom sagemaker.pytorch import PyTorch\nimport os\n\n# --- THIS IS A REPLACEMENT EXAMPLE FOR THE DEPRECATED `sagemaker-train` LIBRARY ---\n# It demonstrates how to train a model using the recommended `sagemaker` SDK.\n\n# 1. Configure SageMaker session and IAM role\nsagemaker_session = sagemaker.Session()\n# IMPORTANT: Replace with your actual AWS IAM role ARN for SageMaker execution.\n# This role grants SageMaker permissions to access resources like S3 and ECR.\n# Example: \"arn:aws:iam::123456789012:role/SageMakerExecutionRole\"\nrole = os.environ.get('SAGEMAKER_ROLE_ARN', 'arn:aws:iam::123456789012:role/SageMakerExecutionRole')\nif '123456789012' in role:\n    print(\"WARNING: Placeholder IAM role ARN detected. Please replace 'SAGEMAKER_ROLE_ARN' \"\n          \"with your actual SageMaker execution role ARN to run this code on AWS.\")\n\n# 2. Create a dummy local training script for demonstration purposes.\n# In a real scenario, this would be your actual training script (e.g., train.py).\nscript_path = 'my_training_script.py'\nwith open(script_path, 'w') as f:\n    f.write(\"\"\"\nimport argparse, os, logging\nif __name__ == '__main__':\n    parser = argparse.ArgumentParser()\n    parser.add_argument('--epochs', type=int, default=1)\n    args = parser.parse_args()\n    logging.basicConfig(level=logging.INFO)\n    logging.info(f\"Starting dummy training for {args.epochs} epochs.\")\n    # SageMaker automatically sets SM_MODEL_DIR for model artifacts\n    model_output_path = os.environ.get('SM_MODEL_DIR')\n    if model_output_path:\n        with open(os.path.join(model_output_path, 'model.txt'), 'w') as mf:\n            mf.write('dummy_model_content')\n    logging.info(\"Dummy training finished.\")\n\"\"\")\n\n# 3. Define the Estimator for your training job.\n# This example uses a PyTorch Estimator. Other framework estimators (TensorFlow, SKLearn, etc.)\n# are also available in the sagemaker SDK.\npytorch_estimator = PyTorch(\n    entry_point=script_path,\n    role=role,\n    instance_count=1,\n    instance_type='ml.m5.large', # Choose an appropriate SageMaker instance type\n    framework_version='1.13.1',  # Specify your desired PyTorch version\n    py_version='py39',          # Specify your desired Python version\n    hyperparameters={'epochs': 2},\n    sagemaker_session=sagemaker_session\n)\n\nprint(f\"Estimator configured for script: {script_path}\")\nprint(\"To start a training job on SageMaker, uncomment the line below:\")\n# pytorch_estimator.fit() \n\n# Optional: Clean up the dummy script\n# os.remove(script_path)\n","lang":"python","description":"This quickstart demonstrates how to initiate a training job using the recommended `sagemaker` Python SDK. It creates a simple training script and configures a PyTorch Estimator to run it on SageMaker. Ensure you replace the placeholder IAM role ARN with your actual SageMaker execution role and adjust instance types/framework versions as needed."},"warnings":[{"fix":"Migrate all existing code to use the `sagemaker` (sagemaker-python-sdk) library. Update import statements (e.g., `from sagemaker_train.estimator import Estimator` to `from sagemaker.estimator import Estimator`) and consult the SageMaker Python SDK documentation for up-to-date API usage.","message":"The `sagemaker-train` library is officially deprecated and is no longer being maintained or updated. Its functionalities have been absorbed into the main `sagemaker` Python SDK.","severity":"breaking","affected_versions":"All versions (since the deprecation announcement)"},{"fix":"Immediately replace `sagemaker-train` with the actively maintained `sagemaker` SDK to ensure security, stability, and access to the latest features. Review your `requirements.txt` or `pyproject.toml` to remove the deprecated dependency.","message":"Using deprecated and unmaintained libraries like `sagemaker-train` can lead to security vulnerabilities, compatibility issues with newer Python versions or AWS services, and lack of support for new SageMaker features.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"search_vec":"'1.7.1':69 'activ':57 'advis':31 'also':40 'amazon':26 'aw':70 'comprehens':55 'defin':20 'deprec':3,10,74 'develop':58 'featur':59 'function':18 'includ':51 'interact':50 'job':24 'known':41 'last':61 'librari':5 'longer':13 'main':36 'maintain':14 'migrat':33 'ml':72 'offer':54 'previous':16 'provid':17 'python':38,45,76 'run':22 'sagemak':1,7,27,37,44,49,66,71 'sagemaker-python-sdk':43 'sagemaker-train':6,65 'sdk':39,46,75 'stabl':62 'strong':30 'train':2,8,23,52,67,73 'user':28 'version':63","created_at":"2026-04-11T17:45:04.486425+00:00","updated_at":"2026-04-11T17:45:04.486425+00:00","problems":{"verify_error":"Traceback (most recent call last):\n  File \"<string>\", line 1, in <module>\nModuleNotFoundError: No module named 'sagemaker.estimator'"},"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"1.21.0","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/aws/sagemaker-python-sdk","docs":null,"changelog":null,"pypi":"https://pypi.org/project/sagemaker-train/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["aws","ai-ml"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-07-03","last_verified":"2026-08-29","next_check":"2026-07-10","install_tag":null}}