Registry / azure / azureml-train-core

azureml-train-core

JSON →
library1.62.0pypypi✓ verified 85d ago

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.

pip install azureml-train-core
INSTALL
IMPORT
SIG · AZUREML-TRAIN-CORE
A
azureml-train-core
azurepythonv1.62.0
Install
17.0s avg
Import
2856ms
Disk
266MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.62.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 2.945s · 246.7MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 17.0s · import 2.768s · 248MB
266MB installed
● package 266MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Workspace
from azureml.core import Workspace
from azureml_train_core.core import Workspace
`azureml-train-core` is an internal package; user-facing classes are typically imported from `azureml.core`.
ScriptRunConfig
from azureml.core import ScriptRunConfig
from azureml.train.runconfig import ScriptRunConfig
The modern and recommended way to configure training runs, superseding many `Estimator` uses.
Environment
from azureml.core import Environment
Used to define the software environment for training runs.
Estimator
from azureml.core.estimator import Estimator
Legacy class for configuring training; largely superseded by `ScriptRunConfig` and `Environment`.

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.

import os from azureml.core import Workspace, ScriptRunConfig, Environment from azureml.core.conda_dependencies import CondaDependencies # NOTE: Replace with your actual workspace details or ensure environment variables are set subscription_id = os.environ.get("AZURE_SUBSCRIPTION_ID", "your_subscription_id") resource_group = os.environ.get("AZURE_RESOURCE_GROUP", "your_resource_group") workspace_name = os.environ.get("AZURE_WORKSPACE_NAME", "your_workspace_name") try: ws = Workspace.get(name=workspace_name, subscription_id=subscription_id, resource_group=resource_group) print(f"Found workspace {ws.name} at {ws.get_details()['location']}") except Exception: print("Could not connect to workspace. Ensure AZURE_SUBSCRIPTION_ID, AZURE_RESOURCE_GROUP, AZURE_WORKSPACE_NAME env vars are set or replace placeholders.") # For a real run, you'd create a workspace if not found # ws = Workspace.create(name=workspace_name, subscription_id=subscription_id, resource_group=resource_group, location='eastus') # Example: Define an environment env = Environment('my-training-env') c_deps = CondaDependencies() c_deps.add_conda_package('scikit-learn') c_deps.add_pip_package('azureml-sdk') env.python.conda_dependencies = c_deps # Create a dummy training script (e.g., train.py) # with open('train.py', 'w') as f: # f.write(""" # import os # print('Hello from Azure ML training!') # print(f'Running on compute: {os.environ.get("AML_RUN_ID", "unknown")}') # """) # Create a ScriptRunConfig (modern way to submit training) # src = ScriptRunConfig(source_directory='./', # script='train.py', # environment=env, # compute_target='cpu-cluster') # Replace with actual compute target # Submit the run (uncomment for actual execution) # if 'ws' in locals(): # run = ws.submit(src) # run.wait_for_completion(show_output=True) # print(f"Run finished with status: {run.get_status()}") else: print("Workspace not initialized, skipping run submission example.")
Debug
Known issues
deprecatedThe `Estimator` class, while still functional, is largely deprecated for new training scenarios in favor of `ScriptRunConfig` combined with `Environment` objects.
fix
Migrate training job definitions from `Estimator` to `ScriptRunConfig` and explicitly define environments using `Environment` or curated environments.
affects: >=1.0.0
gotcha`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`.
fix
Always refer to the official Azure ML SDK documentation for correct import paths and recommended API usage, focusing on modules under `azureml.core`.
affects: All versions
gotchaEnvironment 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.
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.
affects: All versions
gotchaThe 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.
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.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'azureml.train'
This error occurs when a training script attempts to import a module from `azureml.train` (e.g., `azureml.train.automl` or `azureml.train.hyperdrive`), but the necessary `azureml-train-automl` or a comprehensive `azureml-sdk` package is not installed in the environment where the code is executed. The `azureml-train-core` package alone does not include these sub-modules.
fix
Install the `azureml-train-automl` package, which includes the `azureml.train` sub-modules, or install the full `azureml-sdk` with the `[automl, train]` extras. Ensure `azureml-core` is also updated.

pip install --upgrade azureml-core
pip install --upgrade azureml-train-automl
# Alternatively, for the full SDK:
pip install --upgrade azureml-sdk[automl,train]
Estimator is deprecated. Use the ScriptRunConfig object with your own defined environment or an Azure ML curated environment.
The `Estimator` class and its specialized versions (e.g., `PyTorch` estimator) within `azureml-train-core` are deprecated in favor of the more flexible `ScriptRunConfig` class, which offers better control over environments and execution.
fix
Migrate your code from using `Estimator` to `ScriptRunConfig`. Define your environment separately using `azureml.core.Environment` and then pass it to `ScriptRunConfig`.

from azureml.core import Environment, ScriptRunConfig
from azureml.core.compute import ComputeTarget

# Assuming workspace (ws) and compute_target are already defined

# 1. Define your environment (e.g., from a conda file or by adding pip packages)
env = Environment.from_conda_specification(name='my_env', file_path='myenv.yml')
# Or, to add pip packages directly:
# env = Environment(name='my_env')
# conda_dep = CondaDependencies.create(pip_packages=['scikit-learn', 'pandas'])
# env.python.conda_dependencies = conda_dep

# 2. Create ScriptRunConfig
script_config = ScriptRunConfig(
    source_directory='./',
    script='train.py',
    compute_target=compute_target,
    environment=env,
    arguments=['--data-path', 'data']
)

# 3. Submit the experiment
# experiment.submit(script_config)
AttributeError: module 'azureml' has no attribute 'core'
This error typically indicates that the `azureml-core` package is not correctly installed or is an outdated version. It can also occur if a user's Python script is named `azureml.py`, causing a conflict with the actual `azureml` package.
fix
First, ensure `azureml-core` is installed and up-to-date. If the issue persists, check if any of your Python files are named `azureml.py` or similar, and rename them to avoid namespace collisions.

pip install --upgrade azureml-core

# If a file is named azureml.py, rename it to something like my_azure_script.py
AttributeError: 'RoundTripLoader' object has no attribute 'comment_handling'
This specific error arises due to an incompatibility between certain versions of `azureml-core` and the `ruamel-yaml` package, particularly when `ruamel-yaml` version `0.17.5` or newer is installed.
fix
Uninstall the problematic `ruamel-yaml` version and install a compatible version, typically within the range `0.15.35` to `0.17.4` (inclusive).

pip uninstall ruamel-yaml
pip install "ruamel-yaml>=0.15.35,<0.17.5"
Upgrade
Version history
1.62.0latest on PyPI · released Feb 25, 2026
Audit
Dependencies
azureml-corerequiredPrimary dependency for Azure ML Workspace interaction and run management.
azureml-telemetryrequiredUsed for telemetry data collection within the SDK.
azureml-pipeline-corerequiredProvides core functionalities for pipeline steps and data flow.
Agent activity
24 hits · last 30 days
node
20
OpenAI (training)
1
Resources
azureml-train-core — pip install azureml-train-core · libregistry