aws / amazon-sagemaker-examples

Example 📓 Jupyter notebooks that demonstrate how to build, train, and deploy machine learning models using 🧠 Amazon SageMaker.
https://sagemaker-examples.readthedocs.io
Apache License 2.0
9.79k stars 6.67k forks source link

Getting "TypeError: can only join an iterable" while running "print(predictor.predict(test_data).decode("utf-8"))" #4593

Open Arpitgit11 opened 3 months ago

Arpitgit11 commented 3 months ago

Link to the .ipynb file https://github.com/aws/amazon-sagemaker-examples/blob/main/advanced_functionality/scikit_bring_your_own/scikit_bring_your_own.ipynb

Describe the bug to me looks like predic() function is expecting a diff input

To reproduce run all previous steps of .ipynb file till line: print(predictor.predict(test_data).decode("utf-8"))

Logs TypeError Traceback (most recent call last) Cell In[89], line 2 1 import pandas as pd ----> 2 print(predictor.predict(test_data).decode("utf-8"))

File ~/anaconda3/envs/python3/lib/python3.10/site-packages/sagemaker/base_predictor.py:196, in Predictor.predict(self, data, initial_args, target_model, target_variant, inference_id, custom_attributes, component_name) 155 """Return the inference from the specified endpoint. 156 157 Args: (...) 193 as is. 194 """ 195 # [TODO]: clean up component_name in _create_request_args --> 196 request_args = self._create_request_args( 197 data=data, 198 initial_args=initial_args, 199 target_model=target_model, 200 target_variant=target_variant, 201 inference_id=inference_id, 202 custom_attributes=custom_attributes, 203 ) 205 inference_component_name = component_name or self._get_component_name() 206 if inference_component_name:

File ~/anaconda3/envs/python3/lib/python3.10/site-packages/sagemaker/base_predictor.py:256, in Predictor._create_request_args(self, data, initial_args, target_model, target_variant, inference_id, custom_attributes) 251 args["ContentType"] = jumpstart_content_type 252 else: 253 args["ContentType"] = ( 254 self.content_type 255 if isinstance(self.content_type, str) --> 256 else ", ".join(self.content_type) 257 ) 259 if "Accept" not in args: 260 if isinstance(data, JumpStartSerializablePayload) and jumpstart_accept:

TypeError: can only join an iterable