Repository: augerai/a2ml
Issue: wait_for_status does not report error

see:
https://app-staging.auger.ai/admin/prediction_groups/5479

when you call predict, it just show:
Auger Cloud return error...

Changed files:
setup.py, a2ml/api/auger/impl/cloud/rest_api.py, tests/auger/utils.py, a2ml/api/auger/impl/cloud/base.py

diff --git a/a2ml/api/auger/impl/cloud/base.py b/a2ml/api/auger/impl/cloud/base.py
index 77a4f5d..8669eaf 100644
--- a/a2ml/api/auger/impl/cloud/base.py
+++ b/a2ml/api/auger/impl/cloud/base.py
@@ -1,6 +1,9 @@
 import re
+import time
+
 from ..exceptions import AugerException
 
+STATE_POLL_INTERVAL = 10
 
 class AugerBaseApi(object):
     """Auger API base class implements common business object calls."""
@@ -56,11 +59,28 @@ class AugerBaseApi(object):
                 get('data').get(self._get_status_name())
 
     def wait_for_status(self, progress):
-        return self.rest_api.wait_for_object_status(
-            get_status=self.status, progress=progress,
-            object_readable_name=self._get_readable_name(),
-            post_check_status=self._post_check_status,
-            log_status=self._log_status)
+        object_readable_name=self._get_readable_name()
+        status_value = self.status()
+        last_status = ''
+
+        while status_value in progress:
+            if status_value != last_status:
+                last_status = status_value
+                self._log_status(status_value)
+
+            while status_value == last_status:
+                time.sleep(STATE_POLL_INTERVAL)
+                status_value = self.status()
+
+        if status_value == 'processed_with_error':
+            raise AugerException(
+                '%s processed with error' % object_readable_name)
+        elif status_value == 'error' or status_value == "failure":
+            props = self.properties()
+            raise AugerException('Auger Cloud return error: %s. Error details: %s'%(props.get('result', ''), props.get('error_message', '')))
+
+        self._log_status(status_value)
+        return status_value
 
     def delete(self):
         self.rest_api.call(
@@ -97,9 +117,6 @@ class AugerBaseApi(object):
             '%s %s is %s...' % \\
             (self._get_readable_name(), self._get_status_name(), status))
 
-    def _post_check_status(self, status):
-        self._log_status(status)
-
     def _call_create(self, params=None, progress=None,has_return_object=True):
         if self.ctx.provider_info:
             provider = list(self.ctx.provider_info.keys())[0]
diff --git a/a2ml/api/auger/impl/cloud/rest_api.py b/a2ml/api/auger/impl/cloud/rest_api.py
index ba1bb93..be2df86 100644
--- a/a2ml/api/auger/impl/cloud/rest_api.py
+++ b/a2ml/api/auger/impl/cloud/rest_api.py
@@ -1,13 +1,11 @@
 import re
 import sys
-import time
 
 from auger.hub_api_client import HubApiClient
 from ..exceptions import AugerException
 
 
 REQUEST_LIMIT = 100
-STATE_POLL_INTERVAL = 10
 
 class RestApi(object):
     """Warapper around Auger Cloud Rest Api."""
@@ -61,33 +59,3 @@ class RestApi(object):
                     break
             except Exception as e:
                     import traceback; traceback.print_exc()
-
-    def wait_for_object_status(self,
-        get_status, progress, object_readable_name,
-        post_check_status=None, log_status=None):
-
-        def _log_status(obj_status): pass
-        log_status  = log_status if log_status else _log_status
-
-        status = get_status()
-        last_status = ''
-
-        while status in progress:
-            if status != last_status:
-                last_status = status
-                log_status(status)
-
-            while status == last_status:
-                time.sleep(STATE_POLL_INTERVAL)
-                status = get_status()
-
-        if status == 'processed_with_error':
-            raise AugerException(
-                '%s processed with error' % object_readable_name)
-        elif status == 'error' or status == "failure":
-            raise AugerException('Auger Cloud return error...')
-
-        if post_check_status:
-            post_check_status(status)
-
-        return status
diff --git a/setup.py b/setup.py
index 3285fda..dc59258 100644
--- a/setup.py
+++ b/setup.py
@@ -6,7 +6,7 @@ from setuptools import setup
 from setuptools import find_packages
 from setuptools.command.install import install
 
-VERSION = '0.5.0.rc9'
+VERSION = '0.5.0.rc10'
 
 # Get the long description from the README file
 here = os.path.abspath(os.path.dirname(__file__))
diff --git a/tests/auger/utils.py b/tests/auger/utils.py
index 3ead3e1..69ca0cb 100644
--- a/tests/auger/utils.py
+++ b/tests/auger/utils.py
@@ -1,5 +1,5 @@
 from a2ml.api.auger.impl.cloud.rest_api import RestApi
-
+from a2ml.api.auger.impl.cloud.base import AugerBaseApi
 
 ORGANIZATIONS = {
     'meta': {
@@ -96,6 +96,6 @@ def object_status_chain(statuses, monkeypatch):
     current = statuses.pop(0)
     if len(statuses):
         monkeypatch.setattr(
-            RestApi, 'wait_for_object_status', lambda x, *a, **kw: current)
+            AugerBaseApi, 'wait_for_status', lambda x, *a, **kw: current)
     return current