{"id":6537,"library":"azureml-train-core","title":"Azure ML Train Core","description":"The `azureml-train-core` package provides core functionalities for training models within the Azure Machine Learning Python SDK. It underpins concepts like estimators and run configurations for submitting training jobs to Azure ML workspaces. It is currently at version 1.62.0 and is part of the actively maintained Azure ML SDK, which typically sees monthly or bi-monthly releases.","status":"active","version":"1.62.0","language":"en","source_language":"en","source_url":"https://github.com/Azure/azureml-sdk-for-python","tags":["azure","machine-learning","ml","training","sdk"],"install":[{"cmd":"pip install azureml-train-core","lang":"bash","label":"Install core training components"}],"dependencies":[{"reason":"Primary dependency for Azure ML Workspace interaction and run management.","package":"azureml-core"},{"reason":"Used for telemetry data collection within the SDK.","package":"azureml-telemetry"},{"reason":"Provides core functionalities for pipeline steps and data flow.","package":"azureml-pipeline-core"}],"imports":[{"note":"`azureml-train-core` is an internal package; user-facing classes are typically imported from `azureml.core`.","wrong":"from azureml_train_core.core import Workspace","symbol":"Workspace","correct":"from azureml.core import Workspace"},{"note":"The modern and recommended way to configure training runs, superseding many `Estimator` uses.","wrong":"from azureml.train.runconfig import ScriptRunConfig","symbol":"ScriptRunConfig","correct":"from azureml.core import ScriptRunConfig"},{"note":"Used to define the software environment for training runs.","symbol":"Environment","correct":"from azureml.core import Environment"},{"note":"Legacy class for configuring training; largely superseded by `ScriptRunConfig` and `Environment`.","symbol":"Estimator","correct":"from azureml.core.estimator import Estimator"}],"quickstart":{"code":"import os\nfrom azureml.core import Workspace, ScriptRunConfig, Environment\nfrom azureml.core.conda_dependencies import CondaDependencies\n\n# NOTE: Replace with your actual workspace details or ensure environment variables are set\nsubscription_id = os.environ.get(\"AZURE_SUBSCRIPTION_ID\", \"your_subscription_id\")\nresource_group = os.environ.get(\"AZURE_RESOURCE_GROUP\", \"your_resource_group\")\nworkspace_name = os.environ.get(\"AZURE_WORKSPACE_NAME\", \"your_workspace_name\")\n\ntry:\n    ws = Workspace.get(name=workspace_name, subscription_id=subscription_id, resource_group=resource_group)\n    print(f\"Found workspace {ws.name} at {ws.get_details()['location']}\")\nexcept Exception:\n    print(\"Could not connect to workspace. Ensure AZURE_SUBSCRIPTION_ID, AZURE_RESOURCE_GROUP, AZURE_WORKSPACE_NAME env vars are set or replace placeholders.\")\n    # For a real run, you'd create a workspace if not found\n    # ws = Workspace.create(name=workspace_name, subscription_id=subscription_id, resource_group=resource_group, location='eastus')\n\n# Example: Define an environment\nenv = Environment('my-training-env')\nc_deps = CondaDependencies()\nc_deps.add_conda_package('scikit-learn')\nc_deps.add_pip_package('azureml-sdk')\nenv.python.conda_dependencies = c_deps\n\n# Create a dummy training script (e.g., train.py)\n# with open('train.py', 'w') as f:\n#     f.write(\"\"\"\n# import os\n# print('Hello from Azure ML training!')\n# print(f'Running on compute: {os.environ.get(\"AML_RUN_ID\", \"unknown\")}')\n#     \"\"\")\n\n# Create a ScriptRunConfig (modern way to submit training)\n# src = ScriptRunConfig(source_directory='./',\n#                       script='train.py',\n#                       environment=env,\n#                       compute_target='cpu-cluster') # Replace with actual compute target\n\n# Submit the run (uncomment for actual execution)\n# if 'ws' in locals():\n#     run = ws.submit(src)\n#     run.wait_for_completion(show_output=True)\n#     print(f\"Run finished with status: {run.get_status()}\")\nelse:\n    print(\"Workspace not initialized, skipping run submission example.\")","lang":"python","description":"This quickstart demonstrates how to initialize an Azure ML Workspace and define an `Environment` using `azureml.core`, which relies on `azureml-train-core`'s underlying capabilities. It highlights the use of `ScriptRunConfig` for submitting training jobs, which has largely replaced the legacy `Estimator` for many scenarios. Authentication details are expected via environment variables or direct replacement."},"warnings":[{"fix":"Migrate training job definitions from `Estimator` to `ScriptRunConfig` and explicitly define environments using `Environment` or curated environments.","message":"The `Estimator` class, while still functional, is largely deprecated for new training scenarios in favor of `ScriptRunConfig` combined with `Environment` objects.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Always refer to the official Azure ML SDK documentation for correct import paths and recommended API usage, focusing on modules under `azureml.core`.","message":"`azureml-train-core` is primarily an internal component of the Azure ML SDK. End-users typically interact with its capabilities through higher-level abstractions imported from `azureml.core` (e.g., `Workspace`, `ScriptRunConfig`, `Environment`), rather than direct imports from `azureml.train.core`.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Explicitly define `Environment` objects with specific Conda or Docker configurations. Use `conda_dependencies.add_pip_package()` and `conda_dependencies.add_conda_package()` to ensure all required libraries are specified. Test environments locally if possible before submitting to a remote compute target.","message":"Environment management (Conda, Docker) is a common source of errors. Mismatches between local and remote environments, or incorrect `CondaDependencies` specifications, can lead to failed runs or unexpected behavior.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always check the `requires_python` specification on PyPI (`>=3.8, <4` for 1.62.0) and use a compatible Python version for your development and deployment environments.","message":"The Azure ML SDK components, including `azureml-train-core`, often have strict Python version requirements. Using an unsupported Python version can lead to installation failures or runtime errors.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-15T00:00:00.000Z","next_check":"2026-07-14T00:00:00.000Z","problems":[]}