Skip to content

Verbose #218

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 22 commits into from
Aug 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
87fd921
Recognize verbose in config
azarzadavila Jul 24, 2020
07512aa
Pass verbose to ffmpeg
azarzadavila Jul 24, 2020
48827d5
Separate verbosity level of project with ffmpeg loglevel
azarzadavila Jul 25, 2020
707395b
!fiuxp remove SILENT in loglevel
azarzadavila Jul 25, 2020
4f39036
Show ouput of open_file_if_needed only on DEBUG
azarzadavila Jul 25, 2020
3635ec7
Quiet equivalent to CRITICAL level
azarzadavila Jul 25, 2020
a75611d
Disable status bar if verbose level not DEBUG/INFO
azarzadavila Jul 25, 2020
b2bdbe9
Remove comment set logger level
azarzadavila Jul 25, 2020
eee9874
Add option progress_bar on/off
azarzadavila Jul 25, 2020
624b6ab
Change ffmpeg loglevel to a string
azarzadavila Jul 25, 2020
4a49e4a
Change ffmpeg option to ffmpeg_loglevel
azarzadavila Jul 25, 2020
794c8e0
VERBOSE_CHOICES through dict keys from FFMPEG_MAP
azarzadavila Jul 29, 2020
1988237
Remove quiet flag
azarzadavila Jul 29, 2020
6f208e4
Remove disable var for progress_bar
azarzadavila Jul 29, 2020
520d1c0
ffmpeg_loglevel only in config file
azarzadavila Jul 29, 2020
ce7cecb
progress_bar flag to boolean
azarzadavila Jul 29, 2020
6209cdf
progress_bar independant on verbose flag
azarzadavila Jul 29, 2020
0104d6e
Comments on verbose/ffmpeg loglevel/progress_bar flags
azarzadavila Jul 29, 2020
67c12fc
Remove metavar to verbose
azarzadavila Aug 3, 2020
7c1c11b
Merge remote-tracking branch 'fork/master' into verbose
azarzadavila Aug 3, 2020
097998a
Black config_utils.py
azarzadavila Aug 3, 2020
9498cfa
Merge remote-tracking branch 'fork/master' into verbose
azarzadavila Aug 4, 2020
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
4 changes: 2 additions & 2 deletions manim/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@


def open_file_if_needed(file_writer):
if file_writer_config["quiet"]:
if file_writer_config["verbose"] != "DEBUG":
curr_stdout = sys.stdout
sys.stdout = open(os.devnull, "w")

Expand Down Expand Up @@ -59,7 +59,7 @@ def open_file_if_needed(file_writer):
sp.call(commands, stdout=FNULL, stderr=sp.STDOUT)
FNULL.close()

if file_writer_config["quiet"]:
if file_writer_config["verbose"] != "DEBUG":
sys.stdout.close()
sys.stdout = curr_stdout

Expand Down
1 change: 1 addition & 0 deletions manim/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ def _parse_config(config_parser, args):


args, config_parser, file_writer_config, successfully_read_files = _run_config()
logger.setLevel(file_writer_config["verbose"])
if _from_command_line():
logger.info(
f"Read configuration files: {[os.path.abspath(cfgfile) for cfgfile in successfully_read_files]}"
Expand Down
8 changes: 8 additions & 0 deletions manim/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,3 +152,11 @@ class MyText(Text):
)
PALETTE = list(COLOR_MAP.values())
locals().update(COLOR_MAP)
VERBOSE_FFMPEG_MAP = {
"DEBUG": "error",
"INFO": "error",
"WARNING": "error",
"ERROR": "error",
"CRITICAL": "fatal",
}
VERBOSE_CHOICES = VERBOSE_FFMPEG_MAP.keys()
17 changes: 12 additions & 5 deletions manim/default.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,11 @@ preview = False
# -f, --show_file_in_finder
show_file_in_finder = False

# -q, --quiet
quiet = False
# -v, --verbose
verbose = INFO

# --progress_bar
progress_bar = True

# --sound
sound = False
Expand Down Expand Up @@ -155,9 +158,13 @@ logging_level_info = blue
logging_level_warning = red
logging_level_error = red bold
logging_level_critical = red bold reverse
log_level =
log_level =
log_time = cyan dim
log_message =
log_message =
log_path = dim
log_width = -1
log_height = -1
log_height = -1

[ffmpeg]
# Uncomment the following line to manually set the loglevel for ffmpeg. See ffmpeg manpage for accepted values
# loglevel = error
1 change: 1 addition & 0 deletions manim/scene/scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,7 @@ def get_time_progression(
total=n_iterations,
leave=file_writer_config["leave_progress_bars"],
ascii=True if platform.system() == "Windows" else None,
disable=not file_writer_config["progress_bar"],
)
return time_progression

Expand Down
6 changes: 3 additions & 3 deletions manim/scene/scene_file_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ def open_movie_pipe(self):
"-", # The imput comes from a pipe
"-an", # Tells FFMPEG not to expect any audio
"-loglevel",
"error",
file_writer_config["ffmpeg_loglevel"],
]
# TODO, the test for a transparent background should not be based on
# the file extension.
Expand Down Expand Up @@ -474,7 +474,7 @@ def combine_movie_files(self):
"-i",
file_list,
"-loglevel",
"error",
file_writer_config["ffmpeg_loglevel"],
]

if self.write_to_movie:
Expand Down Expand Up @@ -518,7 +518,7 @@ def combine_movie_files(self):
"-map",
"1:a:0",
"-loglevel",
"error",
file_writer_config["ffmpeg_loglevel"],
# "-shortest",
temp_file_path,
]
Expand Down
47 changes: 43 additions & 4 deletions manim/utils/config_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ def _parse_file_writer_config(config_parser, args):
for boolean_opt in [
"preview",
"show_file_in_finder",
"quiet",
"sound",
"leave_progress_bars",
"write_to_movie",
Expand Down Expand Up @@ -135,6 +134,24 @@ def _parse_file_writer_config(config_parser, args):
[fw_config["save_last_frame"], fw_config["from_animation_number"]]
)

# Parse the verbose flag to read in the log level
verbose = getattr(args, "verbose")
verbose = default["verbose"] if verbose is None else verbose
fw_config["verbose"] = verbose

# Parse the ffmpeg log level in the config
ffmpeg_loglevel = config_parser["ffmpeg"].get("loglevel", None)
fw_config["ffmpeg_loglevel"] = (
constants.VERBOSE_FFMPEG_MAP[verbose]
if ffmpeg_loglevel is None
else ffmpeg_loglevel
)

# Parse the progress_bar flag
progress_bar = getattr(args, "progress_bar")
if progress_bar is None:
progress_bar = default.getboolean("progress_bar")
fw_config["progress_bar"] = progress_bar
return fw_config


Expand Down Expand Up @@ -205,9 +222,6 @@ def _parse_cli(arg_list, input=True):
const=True,
help="Show the output file in finder",
)
parser.add_argument(
"-q", "--quiet", action="store_const", const=True, help="Quiet mode",
)
parser.add_argument(
"--sound",
action="store_const",
Expand Down Expand Up @@ -363,6 +377,31 @@ def _parse_cli(arg_list, input=True):
parser.add_argument(
"--config_file", help="Specify the configuration file",
)

# Specify the verbosity
parser.add_argument(
"-v",
"--verbose",
type=str,
help="Verbosity level. Also changes the ffmpeg log level unless the latter is specified in the config",
choices=constants.VERBOSE_CHOICES,
)

# Specify if the progress bar should be displayed
def _str2bool(s):
if s == "True":
return True
elif s == "False":
return False
else:
raise argparse.ArgumentTypeError("True or False expected")

parser.add_argument(
"--progress_bar",
type=_str2bool,
help="Display the progress bar",
metavar="True/False",
)
parsed = parser.parse_args(arg_list)
if hasattr(parsed, "subcommands"):
setattr(
Expand Down