Issue with invoking start_human_loop on the API's

0

I am having an issue invoking the start_human_loop method on the Augmented AI API's.

Code:
def startHumanReview():

bucket= '{S3 Bucket name}'  
document = 'xxxx.pdf'  
s3_fname= 's3://%s/%s' % (bucket,document)  
inputContent = {  
		'initialValue': "Withdrawal",  
		'taskObject': s3_fname # the s3 object will be passed to the worker task UI to render  
		}  
client = boto3.client('sagemaker-a2i-runtime')  
response = client.start_human_loop(  
    HumanLoopName='ManualTEST011',  
    FlowDefinitionArn='{FlowARN}',  
    HumanLoopInput={  
    	"InputContent": json.dumps(inputContent)  
    }  
    )  

if name == "main":
startHumanReview()

Error:
Traceback (most recent call last):
File "test.py", line 138, in <module>
startHumanReview()
File "test.py", line 125, in startHumanReview
response = client.start_human_loop(
File "\AppData\Roaming\Python\Python38\site-packages\botocore\client.py", line 316, in _api_call
return self._make_api_call(operation_name, kwargs)
File "\AppData\Roaming\Python\Python38\site-packages\botocore\client.py", line 635, in _make_api_call
raise error_class(parsed_response, operation_name)
botocore.errorfactory.ValidationException: An error occurred (ValidationException) when calling the StartHumanLoop operation: Provided InputContent is not valid. Please use valid InputContent JSON and try your request again.

Any guidance on how to fix this issue?
The format of the inputContent is similar to what's described in the following
https://aws.amazon.com/blogs/machine-learning/object-detection-and-model-retraining-with-amazon-sagemaker-and-amazon-augmented-ai/

질문됨 4년 전316회 조회
2개 답변
1

I was able to get it working. Actually it seems the issue had to do with the Workflow. I created a new custom workflow and no longer getting the error message.

답변함 4년 전
  • Thx! You saved me a lot of time. Got the same error and was tweaking the InputContent JSON and scratching my head for an hour!

  • I am new to textract and a2i. Just trying to understand. In below code..

    inputContent = {
    'initialValue': "Withdrawal",
    'taskObject': s3_fname # the s3 object will be passed to the worker task UI to render
    }

    Why 'initialValue': "Withdrawal". What does it mean?

0

For anyone struggling with this as well, the answer above didn't work for me. I was creating all my resources on the fly so the workflow wasn't the issue.

The issue for me was I was giving a list of dictionaries as the root. ie my string was [{"valid_json": "foobar", ...}, {...}]. While this is parsable by json.loads and was directly coming from a json.dumps call, AWS apparently wants an object as the root. This isn't explicitly mentioned in the docs and took quite a lot of headache to finally come to the realization.

TLDR: Don't use a list at the root, use an object

답변함 2달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠