aws / aws/amazon-sagemaker-feedback

Sagemaker not importable in Sagemaker, 'Field name "json" shadows a BaseModel attribute'

Open
#149 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
No language data
Stars
10
Forks
3
PR merge metrics
No merged PRs in 30d

Description

### Product Version

- [ ] Amazon SageMaker Studio Classic
- [X] Amazon SageMaker Studio
- [ ] Issue is not related to SageMaker Studio

### Issue Description

A new issue started occurring when using the code editor functionality in SageMaker. The problem occurs when importing sagemaker modules into a notebook. This occurs whether or not I use pip to update sagemaker seemingly.

This is enough to generate the problem for me:

```python
!pip install --upgrade sagemaker
import sagemaker
```

![image](https://github.com/user-attachments/assets/9fd372d3-ba46-455a-8e1d-108a63738bf2)
![{86E0FE52-87A4-470C-8CF3-96E60D9F8537}](https://github.com/user-attachments/assets/6fe2ff4f-46b2-4af1-bf12-87be8b04aef7)

Full output:

╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ in :3 │
│ │
│ 1 get_ipython().system('pip install --upgrade sagemaker') │
│ 2 │
│ ❱ 3 import sagemaker │
│ 4 │
│ │
│ /opt/conda/lib/python3.10/site-packages/sagemaker/__init__.py:18 in │
│ │
│ 15 │
│ 16 import importlib_metadata │
│ 17 │
│ ❱ 18 from sagemaker import estimator, parameter, tuner # noqa: F401 │
│ 19 from sagemaker.amazon.kmeans import KMeans, KMeansModel, KMeansPredictor # noqa: F401 │
│ 20 from sagemaker.amazon.pca import PCA, PCAModel, PCAPredictor # noqa: F401 │
│ 21 from sagemaker.amazon.lda import LDA, LDAModel, LDAPredictor # noqa: F401 │
│ │
│ /opt/conda/lib/python3.10/site-packages/sagemaker/estimator.py:30 in │
│ │
│ 27 from six.moves.urllib.parse import urlparse │
│ 28 │
│ 29 import sagemaker │
│ ❱ 30 from sagemaker import git_utils, image_uris, vpc_utils, s3 │
│ 31 from sagemaker.analytics import TrainingJobAnalytics │
│ 32 from sagemaker.config import ( │
│ 33 │ ESTIMATOR_DEBUG_HOOK_CONFIG_PATH, │
│ │
│ /opt/conda/lib/python3.10/site-packages/sagemaker/image_uris.py:24 in │
│ │
│ 21 from packaging.version import Version │
│ 22 │
│ 23 from sagemaker import utils │
│ ❱ 24 from sagemaker.jumpstart.constants import DEFAULT_JUMPSTART_SAGEMAKER_SESSION │
│ 25 from sagemaker.jumpstart.enums import JumpStartModelType │
│ 26 from sagemaker.jumpstart.utils import is_jumpstart_model_input │
│ 27 from sagemaker.spark import defaults │
│ │
│ /opt/conda/lib/python3.10/site-packages/sagemaker/jumpstart/constants.py:27 in │
│ │
│ 24 │ MIMEType, │
│ 25 │ JumpStartModelType, │
│ 26 ) │
│ ❱ 27 from sagemaker.jumpstart.types import JumpStartLaunchedRegionInfo, JumpStartS3FileType │
│ 28 from sagemaker.base_serializers import ( │
│ 29 │ BaseSerializer, │
│ 30 │ CSVSerializer, │
│ │
│ /opt/conda/lib/python3.10/site-packages/sagemaker/jumpstart/types.py:20 in │
│ │
│ 17 from copy import deepcopy │
│ 18 from enum import Enum │
│ 19 from typing import Any, Dict, List, Optional, Set, Union │
│ ❱ 20 from sagemaker_core.shapes import ModelAccessConfig as CoreModelAccessConfig │
│ 21 from sagemaker.model_card.model_card import ModelCard, ModelPackageModelCard │
│ 22 from sagemaker.utils import ( │
│ 23 │ S3_PREFIX, │
│ │
│ /opt/conda/lib/python3.10/site-packages/sagemaker_core/shapes/__init__.py:1 in │
│ │
│ ❱ 1 from ..main.shapes import * │
│ 2 │
│ │
│ /opt/conda/lib/python3.10/site-packages/sagemaker_core/main/shapes.py:2509 in │
│ │
│ 2506 │ """ │
│ 2507 │
│ 2508 │
│ ❱ 2509 class MonitoringDatasetFormat(Base): │
│ 2510 │ """ │
│ 2511 │ MonitoringDatasetFormat │
│ 2512 │ Represents the dataset format used when running a monitoring job. │
│ │
│ in pydantic.main.ModelMetaclass.__new__:186 │
│ │
│ in pydantic.utils.validate_field_name:167 │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
NameError: Field name "json" shadows a BaseModel attribute; use a different field name with "alias='json'".

### Expected Behavior

Importing should not cause a problem.

### Observed Behavior

_No response_

### Product Category

Code-Editor

### Feedback Category

Reliability and Stability

### Other Details

_No response_

Contributor guide

Open the contributing guide

Research direction

Reproduce the failure in a SageMaker Studio code editor by upgrading the sagemaker package and importing it. Start with the traceback at sagemaker_core/main/shapes.py, especially MonitoringDatasetFormat, and the Pydantic ModelMetaclass error; done means the sagemaker import completes successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, python
Domain
cloud, developer-experience
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.