Skip to content
This repository has been archived by the owner on Sep 13, 2023. It is now read-only.

Commit

Permalink
--quiet option (#448)
Browse files Browse the repository at this point in the history
* Add quiet mode option

* add help

Co-authored-by: Alexander Guschin <[email protected]>
  • Loading branch information
mike0sv and aguschin authored Oct 27, 2022
1 parent de9c700 commit 601be82
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions mlem/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,13 @@
cli_echo,
color,
echo,
no_echo,
stderr_echo,
)

PATH_METAVAR = "path"
COMMITISH_METAVAR = "commitish"

PATH_METAVAR = "path"
COMMITISH_METAVAR = "commitish"


class MlemFormatter(HelpFormatter):
def write_heading(self, heading: str) -> None:
Expand Down Expand Up @@ -339,6 +337,7 @@ def mlem_callback(
False, "--verbose", "-v", help="Print debug messages"
),
traceback: bool = Option(False, "--traceback", "--tb", hidden=True),
quiet: bool = Option(False, "--quiet", "-q", help="Suppress output"),
):
"""\b
MLEM is a tool to help you version and deploy your Machine Learning models:
Expand All @@ -355,7 +354,7 @@ def mlem_callback(
logger = logging.getLogger("mlem")
logger.handlers[0].setLevel(logging.DEBUG)
logger.setLevel(logging.DEBUG)
ctx.obj = {"traceback": traceback or LOCAL_CONFIG.DEBUG}
ctx.obj = {"traceback": traceback or LOCAL_CONFIG.DEBUG, "quiet": quiet}


def get_cmd_name(ctx: Context, no_aliases=False, sep=" "):
Expand Down Expand Up @@ -431,7 +430,7 @@ def inner(*iargs, **ikwargs):
and (o not in ikwargs or ikwargs[o] is None)
}
)
with cli_echo():
with (cli_echo() if not ctx.obj["quiet"] else no_echo()):
res = f(*iargs, **ikwargs) or {}
res = {f"cmd_{cmd_name}_{k}": v for k, v in res.items()}
except (ClickException, Exit, Abort) as e:
Expand Down

0 comments on commit 601be82

Please sign in to comment.