mirror of
https://github.com/clearml/clearml-agent
synced 2025-05-10 14:51:01 +00:00
Fix --debug to set all specified loggers to DEBUG
Add set_urllib_log_level, in debug set urllib log level to DEBUG
This commit is contained in:
parent
b13cc1e8e7
commit
2c8d7d3d9a
@ -40,6 +40,7 @@ class Session(TokenManager):
|
|||||||
_session_requests = 0
|
_session_requests = 0
|
||||||
_session_initial_timeout = (3.0, 10.)
|
_session_initial_timeout = (3.0, 10.)
|
||||||
_session_timeout = (10.0, 30.)
|
_session_timeout = (10.0, 30.)
|
||||||
|
_session_initial_connect_retry = 4
|
||||||
_write_session_data_size = 15000
|
_write_session_data_size = 15000
|
||||||
_write_session_timeout = (30.0, 30.)
|
_write_session_timeout = (30.0, 30.)
|
||||||
|
|
||||||
@ -96,7 +97,7 @@ class Session(TokenManager):
|
|||||||
else:
|
else:
|
||||||
self.config = load()
|
self.config = load()
|
||||||
if initialize_logging:
|
if initialize_logging:
|
||||||
self.config.initialize_logging()
|
self.config.initialize_logging(debug=kwargs.get('debug', False))
|
||||||
|
|
||||||
token_expiration_threshold_sec = self.config.get(
|
token_expiration_threshold_sec = self.config.get(
|
||||||
"auth.token_expiration_threshold_sec", 60
|
"auth.token_expiration_threshold_sec", 60
|
||||||
@ -145,7 +146,7 @@ class Session(TokenManager):
|
|||||||
|
|
||||||
# limit the reconnect retries, so we get an error if we are starting the session
|
# limit the reconnect retries, so we get an error if we are starting the session
|
||||||
http_no_retries_config = dict(**http_retries_config)
|
http_no_retries_config = dict(**http_retries_config)
|
||||||
http_no_retries_config['connect'] = 3
|
http_no_retries_config['connect'] = self._session_initial_connect_retry
|
||||||
self.__http_session = get_http_session_with_retry(**http_no_retries_config)
|
self.__http_session = get_http_session_with_retry(**http_no_retries_config)
|
||||||
# try to connect with the server
|
# try to connect with the server
|
||||||
self.refresh_token()
|
self.refresh_token()
|
||||||
|
@ -190,7 +190,7 @@ class Config(object):
|
|||||||
def reload(self):
|
def reload(self):
|
||||||
self.replace(self._reload())
|
self.replace(self._reload())
|
||||||
|
|
||||||
def initialize_logging(self):
|
def initialize_logging(self, debug=False):
|
||||||
logging_config = self._config.get("logging", None)
|
logging_config = self._config.get("logging", None)
|
||||||
if not logging_config:
|
if not logging_config:
|
||||||
return False
|
return False
|
||||||
@ -217,6 +217,8 @@ class Config(object):
|
|||||||
)
|
)
|
||||||
for logger in loggers:
|
for logger in loggers:
|
||||||
handlers = logger.get("handlers", None)
|
handlers = logger.get("handlers", None)
|
||||||
|
if debug:
|
||||||
|
logger['level'] = 'DEBUG'
|
||||||
if not handlers:
|
if not handlers:
|
||||||
continue
|
continue
|
||||||
logger["handlers"] = [h for h in handlers if h not in deleted]
|
logger["handlers"] = [h for h in handlers if h not in deleted]
|
||||||
|
@ -73,9 +73,11 @@ class Session(_Session):
|
|||||||
os.environ[LOCAL_CONFIG_FILE_OVERRIDE_VAR] = config_file
|
os.environ[LOCAL_CONFIG_FILE_OVERRIDE_VAR] = config_file
|
||||||
if not Path(config_file).is_file():
|
if not Path(config_file).is_file():
|
||||||
raise ValueError("Could not open configuration file: {}".format(config_file))
|
raise ValueError("Could not open configuration file: {}".format(config_file))
|
||||||
|
|
||||||
cpu_only = kwargs.get('cpu_only')
|
cpu_only = kwargs.get('cpu_only')
|
||||||
if cpu_only:
|
if cpu_only:
|
||||||
os.environ['CUDA_VISIBLE_DEVICES'] = os.environ['NVIDIA_VISIBLE_DEVICES'] = 'none'
|
os.environ['CUDA_VISIBLE_DEVICES'] = os.environ['NVIDIA_VISIBLE_DEVICES'] = 'none'
|
||||||
|
|
||||||
if kwargs.get('gpus') and not os.environ.get('KUBERNETES_SERVICE_HOST') \
|
if kwargs.get('gpus') and not os.environ.get('KUBERNETES_SERVICE_HOST') \
|
||||||
and not os.environ.get('KUBERNETES_PORT'):
|
and not os.environ.get('KUBERNETES_PORT'):
|
||||||
# CUDA_VISIBLE_DEVICES does not support 'all'
|
# CUDA_VISIBLE_DEVICES does not support 'all'
|
||||||
@ -84,6 +86,7 @@ class Session(_Session):
|
|||||||
os.environ['NVIDIA_VISIBLE_DEVICES'] = kwargs.get('gpus')
|
os.environ['NVIDIA_VISIBLE_DEVICES'] = kwargs.get('gpus')
|
||||||
else:
|
else:
|
||||||
os.environ['CUDA_VISIBLE_DEVICES'] = os.environ['NVIDIA_VISIBLE_DEVICES'] = kwargs.get('gpus')
|
os.environ['CUDA_VISIBLE_DEVICES'] = os.environ['NVIDIA_VISIBLE_DEVICES'] = kwargs.get('gpus')
|
||||||
|
|
||||||
if kwargs.get('only_load_config'):
|
if kwargs.get('only_load_config'):
|
||||||
from trains_agent.backend_api.config import load
|
from trains_agent.backend_api.config import load
|
||||||
self.config = load()
|
self.config = load()
|
||||||
|
Loading…
Reference in New Issue
Block a user