Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions mlc/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def setup_logging(log_path = os.getcwd(),log_file = 'mlc-log.txt'):

if not logger.hasHandlers():
logFormatter = ColoredFormatter('[%(asctime)s %(filename)s:%(lineno)d %(levelname)s] - %(message)s')
# by default logging level is set to INFO is being set
logger.setLevel(logging.INFO)


Expand Down
21 changes: 17 additions & 4 deletions mlc/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from . import utils

from .action import Action, logger, default_parent
from .action import Action, default_parent
from .repo_action import RepoAction
from .script_action import ScriptAction
from .cache_action import CacheAction
Expand All @@ -15,7 +15,7 @@

from .item import Item
from .action_factory import get_action
from .logger import logger
from .logger import logger, logging


class Automation:
Expand Down Expand Up @@ -167,9 +167,22 @@ def main():

# Parse arguments
args = parser.parse_args()

#logger.info(f"Args = {args}")

# set log level for MLCFlow if -v/--verbose or -s/--silent is specified
log_levels = {
'-v': logging.DEBUG,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we map all the single character args to the full ones in the main function so that everywhere else we can ignore the single character ones?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. I have made the changes in commit 7af3e68

'--verbose': logging.DEBUG,
'-s': logging.WARNING,
'--silent': logging.WARNING
}
# Set log level based on the first matching flag
for flag, level in log_levels.items():
if flag in args.extra:
logger.setLevel(level)
args.extra.remove(flag)

res = utils.convert_args_to_dictionary(args.extra)
if res['return'] > 0:
return res
Expand Down Expand Up @@ -215,7 +228,7 @@ def main():
if help_text != "":
print(help_text)
sys.exit(0)

if hasattr(args, 'repo') and args.repo:
run_args['repo'] = args.repo

Expand Down
Loading