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

--quiet option #448

Merged
merged 3 commits into from
Oct 27, 2022
Merged
Changes from all 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
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