diff --git a/clearml_agent/backend_api/session/session.py b/clearml_agent/backend_api/session/session.py index 27fc877..dbf8cf4 100644 --- a/clearml_agent/backend_api/session/session.py +++ b/clearml_agent/backend_api/session/session.py @@ -111,7 +111,8 @@ class Session(TokenManager): self._logger = logger self.__access_key = api_key or ENV_ACCESS_KEY.get( - default=(self.config.get("api.credentials.access_key", None) or self.default_key) + default=(self.config.get("api.credentials.access_key", None) or self.default_key), + value_cb=lambda key, value: logger.info("Using environment access key {}={}".format(key, value)) ) if not self.access_key: raise ValueError( @@ -119,7 +120,8 @@ class Session(TokenManager): ) self.__secret_key = secret_key or ENV_SECRET_KEY.get( - default=(self.config.get("api.credentials.secret_key", None) or self.default_secret) + default=(self.config.get("api.credentials.secret_key", None) or self.default_secret), + value_cb=lambda key, value: logger.info("Using environment secret key {}=********".format(key)) ) if not self.secret_key: raise ValueError( diff --git a/clearml_agent/backend_config/entry.py b/clearml_agent/backend_config/entry.py index 1107563..489d326 100644 --- a/clearml_agent/backend_config/entry.py +++ b/clearml_agent/backend_config/entry.py @@ -64,8 +64,8 @@ class Entry(object): converter = self.default_conversions().get(self.type, self.type) return converter(value) - def get_pair(self, default=NotSet, converter=None): - # type: (Any, Converter) -> Optional[Tuple[Text, Any]] + def get_pair(self, default=NotSet, converter=None, value_cb=None): + # type: (Any, Converter, Callable[[str, Any], None]) -> Optional[Tuple[Text, Any]] for key in self.keys: value = self._get(key) if value is NotSet: @@ -75,13 +75,20 @@ class Entry(object): except Exception as ex: self.error("invalid value {key}={value}: {ex}".format(**locals())) break + # noinspection PyBroadException + try: + if value_cb: + value_cb(key, value) + except Exception: + pass return key, value + result = self.default if default is NotSet else default return self.key, result - def get(self, default=NotSet, converter=None): - # type: (Any, Converter) -> Optional[Any] - return self.get_pair(default=default, converter=converter)[1] + def get(self, default=NotSet, converter=None, value_cb=None): + # type: (Any, Converter, Callable[[str, Any], None]) -> Optional[Any] + return self.get_pair(default=default, converter=converter, value_cb=value_cb)[1] def set(self, value): # type: (Any, Any) -> (Text, Any)