in caller/textractcaller/t_call.py [0:0]
def get_full_json(job_id: str = None,
textract_api: Textract_API = Textract_API.DETECT,
boto3_textract_client=None,
job_done_polling_interval=1) -> dict:
"""returns full json for call, even when response is chunked"""
logger.debug(f"get_full_json: job_id: {job_id}, Textract_API: {textract_api.name}")
job_response = get_job_response(job_id=job_id,
textract_api=textract_api,
boto3_textract_client=boto3_textract_client)
logger.debug(f"job_response for job_id: {job_id}")
job_status = job_response['JobStatus']
while job_status == "IN_PROGRESS":
job_response = get_job_response(job_id=job_id,
textract_api=textract_api,
boto3_textract_client=boto3_textract_client)
job_status = job_response['JobStatus']
time.sleep(job_done_polling_interval)
if job_status == 'SUCCEEDED':
result_value = {}
extra_args = {}
while True:
textract_results = get_job_response(job_id=job_id,
textract_api=textract_api,
extra_args=extra_args,
boto3_textract_client=boto3_textract_client)
if 'Blocks' in result_value:
result_value['Blocks'].extend(textract_results['Blocks'])
else:
result_value = textract_results
if 'NextToken' in textract_results:
logger.debug(f"got next token {textract_results['NextToken']}")
extra_args['NextToken'] = textract_results['NextToken']
else:
break
if 'NextToken' in result_value:
del result_value['NextToken']
return result_value
else:
logger.error(f"{job_response}")
raise Exception(f"job_status not SUCCEEDED. job_status: {job_status}, message: {job_response['StatusMessage']}")