From 0f5d68597723ab4f1718bdae5518ec36956eb223 Mon Sep 17 00:00:00 2001 From: Michael Haas Date: Tue, 22 Sep 2020 13:54:30 +0200 Subject: [PATCH 1/3] Improve logging in case polling succeeds --- sap/aibus/dar/client/data_manager_client.py | 3 +++ sap/aibus/dar/client/model_manager_client.py | 14 ++++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/sap/aibus/dar/client/data_manager_client.py b/sap/aibus/dar/client/data_manager_client.py index 32b7b9f..f7ebdb8 100644 --- a/sap/aibus/dar/client/data_manager_client.py +++ b/sap/aibus/dar/client/data_manager_client.py @@ -278,6 +278,9 @@ def polling_function() -> dict: ) self.log.error(msg) raise DatasetValidationFailed(msg) + self.log.info( + "Dataset '%s' has status '%s'.", response["id"], response["status"] + ) return response def upload_data_and_validate( diff --git a/sap/aibus/dar/client/model_manager_client.py b/sap/aibus/dar/client/model_manager_client.py index e7303af..f190b98 100644 --- a/sap/aibus/dar/client/model_manager_client.py +++ b/sap/aibus/dar/client/model_manager_client.py @@ -226,10 +226,12 @@ def polling_function(): self.log.exception(timeout_msg) raise TrainingJobTimeOut(timeout_msg) + msg = "Job '{}' has status: '{}'".format(job_id, result["status"]) if self.is_job_failed(result): - fail_msg = "Job '{}' has status: '{}'".format(job_id, result["status"]) - self.log.error(fail_msg) - raise TrainingJobFailed(fail_msg) + self.log.error(msg) + raise TrainingJobFailed(msg) + + self.log.info(msg) return result @@ -444,13 +446,13 @@ def polling_function(): self.log.exception(msg) raise DeploymentTimeOut(msg) from exc + msg = "Deployment '{}' has status: {}".format(deployment_id, response["status"]) if self.is_deployment_failed(response): - msg = "Deployment '{}' has status: {}".format( - deployment_id, response["status"] - ) self.log.error(msg) raise DeploymentFailed(msg) + self.log.info(msg) + return response def deploy_and_wait(self, model_name: str) -> dict: From 2e848856b8901a6034e39eb8fd8051e0b42f4d40 Mon Sep 17 00:00:00 2001 From: Michael Haas Date: Tue, 22 Sep 2020 13:55:41 +0200 Subject: [PATCH 2/3] Make OnlineCredentialsSource logging less verbose Fixes #80 --- sap/aibus/dar/client/util/credentials.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sap/aibus/dar/client/util/credentials.py b/sap/aibus/dar/client/util/credentials.py index 3382f45..8d9ca3d 100644 --- a/sap/aibus/dar/client/util/credentials.py +++ b/sap/aibus/dar/client/util/credentials.py @@ -153,11 +153,11 @@ def token(self) -> str: def _fetch_token_from_auth_server(self) -> dict: url = self.url + "/oauth/token?grant_type=client_credentials" - self.log.info('Retrieving token from URL: "%s"', url) + self.log.debug('Retrieving token from URL: "%s"', url) response = self.session.get(url, auth=(self.clientid, self.clientsecret)) response.raise_for_status() payload = response.json() - self.log.info( + self.log.debug( 'Got token for clientid "%s" with HTTP status "%s" and scope "%s"', self.clientid, response.status_code, From 217d341eda748eea0ac2ea9cd254e8105dc5d01d Mon Sep 17 00:00:00 2001 From: Michael Haas Date: Tue, 22 Sep 2020 13:58:18 +0200 Subject: [PATCH 3/3] Update changelog --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index abe6134..f0db77f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 [#72]: https://github.com/SAP/data-attribute-recommendation-python-sdk/pull/72 +### Changed + +* Improve logging: quieten OnlineCredentialsSource, make polling explicit [#81] + +[#81] : https://github.com/SAP/data-attribute-recommendation-python-sdk/pull/81 ## [0.7.0]