mirror of
https://github.com/clearml/clearml-agent
synced 2025-02-07 05:19:17 +00:00
Print conda install output if running in debug mode, turn on debugging if --debug flag is used
This commit is contained in:
parent
21f6a73f66
commit
f6be64a4b5
@ -20,6 +20,8 @@ from .interface import get_parser
|
||||
def run_command(parser, args, command_name):
|
||||
|
||||
debug = args.debug
|
||||
session.Session.set_debug_mode(debug)
|
||||
|
||||
if command_name and command_name.lower() in ('config', 'init'):
|
||||
command_class = commands.Config
|
||||
elif len(command_name.split('.')) < 2:
|
||||
|
@ -420,10 +420,14 @@ class CondaAPI(PackageManager):
|
||||
try:
|
||||
print('Executing Conda: {}'.format(command.serialize()))
|
||||
result = command.get_output(stdin=DEVNULL, **kwargs)
|
||||
if self.session.debug_mode:
|
||||
print(result)
|
||||
except Exception as e:
|
||||
result = e.output if hasattr(e, 'output') else ''
|
||||
if self.session.debug_mode:
|
||||
print(result)
|
||||
if raw:
|
||||
raise
|
||||
result = e.output if hasattr(e, 'output') else ''
|
||||
if raw:
|
||||
return result
|
||||
|
||||
|
@ -63,6 +63,7 @@ def tree(*args):
|
||||
|
||||
class Session(_Session):
|
||||
version = __version__
|
||||
force_debug = False
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
# make sure we set the environment variable so the parent session opens the correct file
|
||||
@ -83,6 +84,11 @@ class Session(_Session):
|
||||
self.config = load()
|
||||
else:
|
||||
super(Session, self).__init__(*args, **kwargs)
|
||||
|
||||
# set force debug mode, if it's on:
|
||||
if Session.force_debug:
|
||||
self.config["agent"]["debug"] = True
|
||||
|
||||
self.log = self.get_logger(__name__)
|
||||
self.trace = kwargs.get('trace', False)
|
||||
self._config_file = kwargs.get('config_file') or \
|
||||
@ -154,9 +160,16 @@ class Session(_Session):
|
||||
logger.propagate = True
|
||||
return TrainsAgentLogger(logger)
|
||||
|
||||
@staticmethod
|
||||
def set_debug_mode(enable):
|
||||
if enable:
|
||||
import logging
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
Session.force_debug = enable
|
||||
|
||||
@property
|
||||
def debug_mode(self):
|
||||
return self.config.get("agent.debug", False)
|
||||
return Session.force_debug or self.config.get("agent.debug", False)
|
||||
|
||||
@property
|
||||
def config_file(self):
|
||||
|
Loading…
Reference in New Issue
Block a user