You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Importing sagemaker.mlops / sagemaker.serve raises NoRegionError without a configured region: AIRHub creates boto3 clients at class definition #6542
Describe the bug
Importing sagemaker.mlops (or sagemaker.serve) raises botocore.exceptions.NoRegionError when no AWS region is configured. sagemaker/ai_registry/air_hub.py creates boto3 clients as class attributes, so they run at import time:
The import chain is sagemaker.mlops → sagemaker.serve.model_builder → sagemaker.train.multi_turn_rl_trainer → sagemaker.ai_registry.dataset → sagemaker.ai_registry.air_hub.
Any package that imports sagemaker.mlops.feature_store therefore can't be imported in CI runners, docs builds, or first-run setup tools. When a region is present, these clients are bound to the default credential chain at import, regardless of the session a caller later passes (the same class of problem as #5986).
Expected behavior
Importing the SDK has no AWS side effects. AIRHub should create its clients lazily, on first use and from the caller's session, so imports succeed without a region and the clients honor the session passed in.
Screenshots or logs
File ".../sagemaker/mlops/__init__.py", line 25, in <module>
from sagemaker.serve.model_builder import ModelBuilder
File ".../sagemaker/serve/model_builder.py", line 73, in <module>
from sagemaker.train.multi_turn_rl_trainer import MultiTurnRLTrainer
File ".../sagemaker/train/multi_turn_rl_trainer.py", line 25, in <module>
from sagemaker.ai_registry.dataset import DataSet
File ".../sagemaker/ai_registry/dataset.py", line 29, in <module>
from sagemaker.ai_registry.air_hub import AIRHub
File ".../sagemaker/ai_registry/air_hub.py", line 36, in AIRHub
_sagemaker_client = boto3.client("sagemaker")
...
botocore.exceptions.NoRegionError: You must specify a region.
System information
SageMaker Python SDK version: 3.27.0 (sagemaker-core 2.27.0, sagemaker-train 1.27.0, sagemaker-serve 1.27.0, sagemaker-mlops 1.27.0). Also present in 3.24.0 and on master.
Framework name (eg. PyTorch) or algorithm (eg. KMeans): N/A (import-time failure)
Framework version: N/A
Python version: 3.13 (reproduced on Windows GitHub Actions runners and macOS)
CPU or GPU: CPU
Custom Docker image (Y/N): N
Additional context
We worked around it by importing sagemaker.mlops lazily, inside the functions that use it. sagemaker.core and sagemaker.train.model_trainer import fine without a region; only paths that reach sagemaker.ai_registry fail.
Activity
brifordwylie commentedon Oct 28, 2026
@jam-jee just because I've seen your great work on other issues :) (the same class of problem as #5986)