def client(): client = Client() return client
if not model_id: raise ValueError('A modelId is needed for prediction, input modelId directly or MODEL_ID to env') response = las_client.create_prediction( document_id=document_id, model_id=model_id, max_pages=event.get('maxPages', 1), auto_rotate=event.get('autoRotate', False), ) return response if __name__ == '__main__': las_client = Client() transition_id = os.environ['TRANSITION_ID'] execution_id = os.environ['EXECUTION_ID'] logging.info(f'Execute {execution_id} of transition {transition_id}') try: execution = las_client.get_transition_execution(transition_id, execution_id=execution_id) event = execution['input'] logging.info(f'event: {event}') output = handler(las_client, event, environ=os.environ) las_client.update_transition_execution( transition_id=transition_id, execution_id=execution_id, status='succeeded', output=output, )
'documentId': response['documentId'], } if model_id: content['modelId'] = model_id response = client.execute_workflow(workflow_id, content) logging.info(f'{json.dumps(response, indent=2)}') if __name__ == '__main__': parser = ArgumentParser() parser.add_argument('document') parser.add_argument('--workflow-id') parser.add_argument('--model-id') parser.add_argument('--content-type', default='application/pdf') parser.add_argument('--profile') args = parser.parse_args() if args.profile: credentials = Credentials(*read_from_file(section=args.profile)) client = Client(credentials) else: client = Client() main(client=client, workflow_id=args.workflow_id, document_path=args.document, content_type=args.content_type, model_id=args.model_id)