Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] NameError when importing Transformer #4933

Open
epassaroRKD opened this issue Nov 20, 2024 · 1 comment
Open

[bug] NameError when importing Transformer #4933

epassaroRKD opened this issue Nov 20, 2024 · 1 comment
Labels

Comments

@epassaroRKD
Copy link

epassaroRKD commented Nov 20, 2024

Describe the bug
In latest version, after importing Transformers from sagemaker.transformer I get the error NameError: Field name "json" shadows a BaseModel attribute; use a different field name with "alias='json'".

EDIT: Fixed by updating pydantic.

To reproduce

from sagemarker.transformer import Transformer

Result:

in <module>:3                                                                                    │
│                                                                                                  │
│    1 import json                                                                                 │
│    2                                                                                             │
│ ❱  3 from sagemaker.transformer import Transformer                                               │
│    4                                                                                             │
│    5 from sagemaker.workflow.steps import CacheConfig                                            │
│    6 from sagemaker.workflow.functions import Join                                               │
│                                                                                                  │
│ /usr/local/lib/python3.10/site-packages/sagemaker/__init__.py:18 in <module>                     │
│                                                                                                  │
│   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                  │
│                                                                                                  │
│ /usr/local/lib/python3.10/site-packages/sagemaker/estimator.py:30 in <module>                    │
│                                                                                                  │
│     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,                                                     │
│                                                                                                  │
│ /usr/local/lib/python3.10/site-packages/sagemaker/image_uris.py:24 in <module>                   │
│                                                                                                  │
│    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                                                       │
│                                                                                                  │
│ /usr/local/lib/python3.10/site-packages/sagemaker/jumpstart/constants.py:27 in <module>          │
│                                                                                                  │
│    24 │   MIMEType,                                                                              │
│    25 │   JumpStartModelType,                                                                    │
│    26 )                                                                                          │
│ ❱  27 from sagemaker.jumpstart.types import JumpStartLaunchedRegionInfo, JumpStartS3FileType     │
│    28 from sagemaker.base_serializers import (                                                   │
│    29 │   BaseSerializer,                                                                        │
│    30 │   CSVSerializer,                                                                         │
│                                                                                                  │
│ /usr/local/lib/python3.10/site-packages/sagemaker/jumpstart/types.py:20 in <module>              │
│                                                                                                  │
│     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,                                                                            │
│                                                                                                  │
│ /usr/local/lib/python3.10/site-packages/sagemaker_core/shapes/__init__.py:1 in <module>          │
│                                                                                                  │
│ ❱ 1 from ..main.shapes import *                                                                  │
│   2                                                                                              │
│                                                                                                  │
│ /usr/local/lib/python3.10/site-packages/sagemaker_core/main/shapes.py:2509 in <module>           │
│                                                                                                  │
│    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

Screenshots or logs

System information
A description of your system. Please provide:

  • SageMaker Python SDK version: Latest
  • Framework name (eg. PyTorch) or algorithm (eg. KMeans):
  • Framework version:
  • Python version:
  • CPU or GPU:
  • Custom Docker image (Y/N):

Additional context
Add any other context about the problem here.

@dzornek
Copy link

dzornek commented Nov 23, 2024

I am getting the same error when doing from sagemaker.jumpstart.model import JumpStartModel.

Edit: Resolved for me by upgrading the sagemaker sdk to 2.235.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants