Follow these steps to set up and reproduce the maximum recursion depth exceeded error when trying to read s3 objects via an inference script:
-
Create an S3 Bucket:
- Create a bucket, for example, named
bucket11
.
- Create a bucket, for example, named
-
Upload Sample Data:
- Upload the sample JSON object
data.json
to the created bucket.
- Upload the sample JSON object
-
Update the Bucket Name in the Script:
- Modify the
code1/inference.py
script to use the name of the bucket you created. Change the bucket name in theget_json_from_s3
function:... json_object = s3_client.get_object(Bucket="bucket11", Key=key)
- Modify the
-
Start a SageMaker Notebook Instance:
- Launch an
ml.t3.medium
SageMaker notebook instance.
- Launch an
-
Set Up JupyterLab:
- Launch JupyterLab from the SageMaker instance.
- Upload the notebook
test.ipynb
to the JupyterLab directory. - Create a folder named
code1
in the directory and upload all files from thecode1
folder of this repository into it.
-
Clone the Repository (Alternative Setup to 5):
- Alternatively, you can clone the repository directly into JupyterLab:
- Open the Git tab, select
Clone a Repository
from the dropdown, enter the URI:https://github.com/MustaphaU/rerror.git
, and hitClone
.
- Open the Git tab, select
- Alternatively, you can clone the repository directly into JupyterLab:
-
Run the Notebook:
- Execute all the code cells in the
test.ipynb
notebook.
- Execute all the code cells in the
-
Identify the Error:
- The last cell should generate the following error:
This error is due to the
ModelError: An error occurred (ModelError) when calling the InvokeEndpoint operation: Received server error (500) from primary with message "{"error": "cannot unpack non-iterable NoneType object"}".....................................
get_json_from_s3
function returning None because of the recursion error during the setup of the S3 client. See the linked CloudWatch logs for more details on the recursion error.
- The last cell should generate the following error:
-
Review CloudWatch Logs:
- Click the link provided in the error message to view the CloudWatch logs. In the logs, you will find:
maximum recursion depth exceeded while calling a Python object
- Click the link provided in the error message to view the CloudWatch logs. In the logs, you will find: