aws / aws/sagemaker-python-sdk

Import in Python 3.11 Lambda creates: No module named 'rpds.rpds'

Cerrado
#5,205 0 comentarios 1 reacción 0 asignados Ver en GitHub
component: pysdk-team type: bug
Lenguaje dominante
Python
Estrellas
2.3k
Forks
1.3k
Merge medio
1 d 22 h
PR fusionados (30 d)
35

Descripción

**Describe the bug**
I am importing `sagemaker` in a Python 3.11 Lambda and it produces the error `No module named 'rpds.rpds'`. The module `rpds` does appear to be available.

**To reproduce**
I am using a Lambda Layer with the requirements of:
```
sagemaker==2.246.0
```
I have narrowed down my Lambda code to just

```python
import json
import boto3
import logging
import os
import uuid
import time
from datetime import datetime
from botocore.exceptions import ClientError

help('modules')

# SageMaker imports
from sagemaker import get_execution_role, Session
# from sagemaker.workflow.pipeline import Pipeline
# from sagemaker.workflow.steps import ProcessingStep
# from sagemaker.workflow.parameters import ParameterString, ParameterInteger
# from sagemaker.processing import ProcessingInput, ProcessingOutput
# from sagemaker.wrangler.processing import DataWranglerProcessor

DEFAULT_INPUT_DATA_S3_URI = os.environ.get('DEFAULT_INPUT_DATA_S3_URI', '')
DEFAULT_OUTPUT_S3_URI = os.environ.get('DEFAULT_OUTPUT_S3_URI', '')
SAGEMAKER_ROLE_ARN = os.environ.get('SAGEMAKER_ROLE_ARN', '')

if not DEFAULT_INPUT_DATA_S3_URI:
raise ValueError("DEFAULT_INPUT_DATA_S3_URI is not set")
if not DEFAULT_OUTPUT_S3_URI:
raise ValueError("DEFAULT_OUTPUT_S3_URI is not set")

# Configure logging
logger = logging.getLogger()
logger.setLevel(logging.INFO)

def lambda_handler(event, context):
"""
Lambda function to create a SageMaker pipeline using Data Wrangler Processor
Following patterns from AWS samples: sm-data-wrangler-mlops-workflows

Expected event structure:
{
"input_data_s3_uri": "s3://bucket/path/to/dataset",
"data_wrangler_flow_s3_uri": "s3://bucket/path/to/workflow.flow",
"output_s3_uri": "s3://bucket/path/to/output/",
"pipeline_name": "data-processing-pipeline",
"role_arn": "arn:aws:iam::account:role/SageMakerRole" (optional),
"instance_type": "ml.m5.4xlarge" (optional),
"instance_count": 1 (optional),
"flow_output_name": "node_id.default" (optional),
"flow_output_content_type": "CSV" (optional)
}
"""
logger.info(f"Event: {json.dumps(event)}")
```

**Expected behavior**
Be able to import `sagemaker` without error.

**Screenshots or logs**
These are the reported available modules from the `help('modules')` call.

```

_multiprocess crypt pathlib textwrap
_multiprocessing csv pathos this
_opcode ctypes pdb threading
_operator curses pickle time
_osx_support dataclasses pickletools timeit
_pickle datetime pip tkinter
_posixshmem dateutil pipes token
_posixsubprocess dbm pkg_resources tokenize
_py_abc decimal pkgutil tomllib
_pydecimal difflib platform tqdm
_pyio dill platformdirs trace
_queue dis plistlib traceback
_random distutils poplib tracemalloc
_sha1 docker posix tty
_sha256 doctest posixpath turtle
_sha3 email pox turtledemo
_sha512 encodings pp types
_signal ensurepip ppft typing
_sitebuiltins enum pprint typing_extensions
_socket errno profile typing_inspection
_sqlite3 fastapi pstats tzdata
_sre faulthandler psutil unicodedata
_ssl fcntl pty unittest
_stat filecmp pwd urllib
_statistics fileinput py_compile urllib3
_string fnmatch pyclbr uu
_strptime fractions pydantic uuid
_struct ftplib pydantic_core uvicorn
_symtable functools pydevd_plugins venv
_sysconfigdata__linux_x86_64-linux-gnu gc pydoc warnings
_testbuffer genericpath pydoc_data wave
_testcapi getopt pyexpat weakref
_testclinic getpass pygments webbrowser
_testimportmultiple gettext pytz wsgiref
_testinternalcapi glob queue xdrlib
_testmultiphase graphene quopri xml
_thread graphlib random xmlrpc
_threading_local graphql re xxlimited
_tokenize graphql_relay readline xxlimited_35
_tracemalloc grp referencing xxsubtype
_typing gzip reprlib yaml
_warnings h11 requests zipapp
_weakref hashlib resource zipfile
_weakrefset heapq rich zipimport
_xxsubinterpreters hmac rlcompleter zipp
_xxtestfuzz html rpds zlib
_yaml http runpy zoneinfo
_zoneinfo idlelib runtime_client
abc idna s3transfer
aifc imaplib sagemaker
```
**System information**
A description of your system. Please provide:
- **SageMaker Python SDK version**: sagemaker==2.246.0
- **Framework name (eg. PyTorch) or algorithm (eg. KMeans)**: N/A
- **Framework version**: N/A
- **Python version**: 3.11
- **CPU or GPU**: x86
- **Custom Docker image (Y/N)**: N

**Additional context**
I was able to create a local virtual environment with Python 3.11 and the same version of the Sagemaker module without receiving this error. I'm not sure what to try next.

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

Start by reproducing the import in a Python 3.11 AWS Lambda layer containing sagemaker==2.246.0, then compare it with the reported local virtual environment. Inspect the available rpds and sagemaker modules shown by help('modules'). Done means importing sagemaker succeeds in the Lambda environment without the No module named 'rpds.rpds' error.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
aws, python
Área
cloud, machine-learning
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
25/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.