From 87fd921db215d8494c77a1a6e80b07e2361949d4 Mon Sep 17 00:00:00 2001 From: azarzadavila <37216245+azarzadavila@users.noreply.github.com> Date: Fri, 24 Jul 2020 19:31:26 +0200 Subject: [PATCH 01/20] Recognize verbose in config --- manim/default.cfg | 3 +++ manim/utils/config_utils.py | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/manim/default.cfg b/manim/default.cfg index 9cf64ede13..4cc02531c4 100644 --- a/manim/default.cfg +++ b/manim/default.cfg @@ -39,6 +39,9 @@ show_file_in_finder = False # -q, --quiet quiet = False +# -v, --verbose +verbose = 32 + # --sound sound = False diff --git a/manim/utils/config_utils.py b/manim/utils/config_utils.py index bad2a13484..1bfe7c2dc8 100644 --- a/manim/utils/config_utils.py +++ b/manim/utils/config_utils.py @@ -122,6 +122,9 @@ def _parse_file_writer_config(config_parser, args): [fw_config["save_last_frame"], fw_config["from_animation_number"]] ) + # Read in the log level + verbose = getattr(args, "verbose") + fw_config["verbose"] = default.getint("verbose") if verbose is None else verbose return fw_config @@ -314,6 +317,13 @@ def _parse_cli(arg_list, input=True): "--config_file", help="Specify the configuration file", ) + parser.add_argument( + "-v", "--verbose", + type=int, + help="Verbosity level", + metavar="loglevel", + choices=[-8, 0, 8, 16, 24, 32, 40, 48, 56] + ) return parser.parse_args(arg_list) From 07512aae8f1b81ed3ad2ca3c8b3a19e5b3806b5b Mon Sep 17 00:00:00 2001 From: azarzadavila <37216245+azarzadavila@users.noreply.github.com> Date: Fri, 24 Jul 2020 19:55:45 +0200 Subject: [PATCH 02/20] Pass verbose to ffmpeg --- manim/scene/scene_file_writer.py | 2 +- manim/utils/config_utils.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/manim/scene/scene_file_writer.py b/manim/scene/scene_file_writer.py index aaea1d2f1f..54f4246f28 100644 --- a/manim/scene/scene_file_writer.py +++ b/manim/scene/scene_file_writer.py @@ -391,7 +391,7 @@ def open_movie_pipe(self): '-r', str(fps), # frames per second '-i', '-', # The imput comes from a pipe '-an', # Tells FFMPEG not to expect any audio - '-loglevel', 'error', + '-loglevel', str(file_writer_config["verbose"]), ] # TODO, the test for a transparent background should not be based on # the file extension. diff --git a/manim/utils/config_utils.py b/manim/utils/config_utils.py index 1bfe7c2dc8..d6bb86a80d 100644 --- a/manim/utils/config_utils.py +++ b/manim/utils/config_utils.py @@ -320,7 +320,7 @@ def _parse_cli(arg_list, input=True): parser.add_argument( "-v", "--verbose", type=int, - help="Verbosity level", + help="Verbosity level. Passed on to ffmpeg, the lower the value the quieter the output", metavar="loglevel", choices=[-8, 0, 8, 16, 24, 32, 40, 48, 56] ) From 48827d5a841177663d060239231cdae55baa366e Mon Sep 17 00:00:00 2001 From: azarzadavila <37216245+azarzadavila@users.noreply.github.com> Date: Sat, 25 Jul 2020 14:24:25 +0200 Subject: [PATCH 03/20] Separate verbosity level of project with ffmpeg loglevel --- manim/config.py | 1 + manim/constants.py | 9 +++++++++ manim/default.cfg | 2 +- manim/scene/scene_file_writer.py | 6 +++--- manim/utils/config_utils.py | 21 ++++++++++++++++++--- 5 files changed, 32 insertions(+), 7 deletions(-) diff --git a/manim/config.py b/manim/config.py index 5ab17cabda..360cb1c06f 100644 --- a/manim/config.py +++ b/manim/config.py @@ -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"]) # Set logger level if _from_command_line(): logger.info(f"Read configuration files: {os.path.abspath(successfully_read_files[-1])}") _init_dirs(file_writer_config) diff --git a/manim/constants.py b/manim/constants.py index e8acf30e61..40ebedd6cd 100644 --- a/manim/constants.py +++ b/manim/constants.py @@ -148,3 +148,12 @@ class MyText(Text): if name.endswith("_C")}) PALETTE = list(COLOR_MAP.values()) locals().update(COLOR_MAP) +VERBOSE_CHOICES = ["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL", "SILENT"] +VERBOSE_FFMPEG_MAP = { + "DEBUG": 16, + "INFO": 16, + "WARNING": 16, + "ERROR": 16, + "CRITICAL": 8, + "SILENT": -8, +} diff --git a/manim/default.cfg b/manim/default.cfg index 4cc02531c4..6a1487adad 100644 --- a/manim/default.cfg +++ b/manim/default.cfg @@ -40,7 +40,7 @@ show_file_in_finder = False quiet = False # -v, --verbose -verbose = 32 +verbose = INFO # --sound sound = False diff --git a/manim/scene/scene_file_writer.py b/manim/scene/scene_file_writer.py index 54f4246f28..6cbf53a525 100644 --- a/manim/scene/scene_file_writer.py +++ b/manim/scene/scene_file_writer.py @@ -391,7 +391,7 @@ def open_movie_pipe(self): '-r', str(fps), # frames per second '-i', '-', # The imput comes from a pipe '-an', # Tells FFMPEG not to expect any audio - '-loglevel', str(file_writer_config["verbose"]), + '-loglevel', str(file_writer_config["ffmpeg"]), ] # TODO, the test for a transparent background should not be based on # the file extension. @@ -472,7 +472,7 @@ def combine_movie_files(self): '-f', 'concat', '-safe', '0', '-i', file_list, - '-loglevel', 'error', + '-loglevel', str(file_writer_config["ffmpeg"]), ] if self.write_to_movie: @@ -514,7 +514,7 @@ def combine_movie_files(self): "-map", "0:v:0", # select audio stream from second file "-map", "1:a:0", - '-loglevel', 'error', + '-loglevel', str(file_writer_config["ffmpeg"]), # "-shortest", temp_file_path, ] diff --git a/manim/utils/config_utils.py b/manim/utils/config_utils.py index d6bb86a80d..cd21b7b1e7 100644 --- a/manim/utils/config_utils.py +++ b/manim/utils/config_utils.py @@ -124,7 +124,15 @@ def _parse_file_writer_config(config_parser, args): # Read in the log level verbose = getattr(args, "verbose") - fw_config["verbose"] = default.getint("verbose") if verbose is None else verbose + verbose = default["verbose"] if verbose is None else verbose + fw_config["verbose"] = verbose + if verbose == "SILENT": + # SILENT is not a predefined value but by placing it higher then all the others, a quieter logger is set + fw_config["verbose"] = 60 + ffmpeg = getattr(args, "ffmpeg") + if ffmpeg is None and default.getint("ffmpeg", None) is not None: + ffmpeg = default.getint("ffmpeg") + fw_config["ffmpeg"] = constants.VERBOSE_FFMPEG_MAP[verbose] if ffmpeg is None else ffmpeg return fw_config @@ -319,10 +327,17 @@ def _parse_cli(arg_list, input=True): parser.add_argument( "-v", "--verbose", + type=str, + help="Verbosity level. Also changes the ffmpeg log level unless the latter is specified", + metavar="loglevel", + choices=constants.VERBOSE_CHOICES, + ) + parser.add_argument( + "-L", "--ffmpeg", type=int, - help="Verbosity level. Passed on to ffmpeg, the lower the value the quieter the output", + help="Log level for ffmpeg", metavar="loglevel", - choices=[-8, 0, 8, 16, 24, 32, 40, 48, 56] + choices=[-8, 0, 8, 16, 24, 32, 40, 48, 56], ) return parser.parse_args(arg_list) From 707395bdea717d815288ebf5809d8b842ec5163e Mon Sep 17 00:00:00 2001 From: azarzadavila <37216245+azarzadavila@users.noreply.github.com> Date: Sat, 25 Jul 2020 14:59:32 +0200 Subject: [PATCH 04/20] !fiuxp remove SILENT in loglevel --- manim/constants.py | 3 +-- manim/utils/config_utils.py | 3 --- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/manim/constants.py b/manim/constants.py index 40ebedd6cd..ce981915dd 100644 --- a/manim/constants.py +++ b/manim/constants.py @@ -148,12 +148,11 @@ class MyText(Text): if name.endswith("_C")}) PALETTE = list(COLOR_MAP.values()) locals().update(COLOR_MAP) -VERBOSE_CHOICES = ["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL", "SILENT"] +VERBOSE_CHOICES = ["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"] VERBOSE_FFMPEG_MAP = { "DEBUG": 16, "INFO": 16, "WARNING": 16, "ERROR": 16, "CRITICAL": 8, - "SILENT": -8, } diff --git a/manim/utils/config_utils.py b/manim/utils/config_utils.py index cd21b7b1e7..7be0b6502f 100644 --- a/manim/utils/config_utils.py +++ b/manim/utils/config_utils.py @@ -126,9 +126,6 @@ def _parse_file_writer_config(config_parser, args): verbose = getattr(args, "verbose") verbose = default["verbose"] if verbose is None else verbose fw_config["verbose"] = verbose - if verbose == "SILENT": - # SILENT is not a predefined value but by placing it higher then all the others, a quieter logger is set - fw_config["verbose"] = 60 ffmpeg = getattr(args, "ffmpeg") if ffmpeg is None and default.getint("ffmpeg", None) is not None: ffmpeg = default.getint("ffmpeg") From 4f390362318100a81837c175d17cc93197bcc6ad Mon Sep 17 00:00:00 2001 From: azarzadavila <37216245+azarzadavila@users.noreply.github.com> Date: Sat, 25 Jul 2020 15:19:13 +0200 Subject: [PATCH 05/20] Show ouput of open_file_if_needed only on DEBUG --- manim/__main__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manim/__main__.py b/manim/__main__.py index fed9b7827a..d452f956e5 100644 --- a/manim/__main__.py +++ b/manim/__main__.py @@ -17,7 +17,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") @@ -56,7 +56,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 From 3635ec7730fb756077de3fb31223cda029842140 Mon Sep 17 00:00:00 2001 From: azarzadavila <37216245+azarzadavila@users.noreply.github.com> Date: Sat, 25 Jul 2020 15:24:07 +0200 Subject: [PATCH 06/20] Quiet equivalent to CRITICAL level --- manim/utils/config_utils.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/manim/utils/config_utils.py b/manim/utils/config_utils.py index 7be0b6502f..ee43a0e62c 100644 --- a/manim/utils/config_utils.py +++ b/manim/utils/config_utils.py @@ -40,7 +40,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", @@ -123,7 +122,11 @@ def _parse_file_writer_config(config_parser, args): ) # Read in the log level + quiet = getattr(args, "quiet") + if not quiet and default.getboolean("quiet", None) is not None: + quiet = default.getboolean("quiet") verbose = getattr(args, "verbose") + verbose = "CRITICAL" if verbose is None and quiet else verbose verbose = default["verbose"] if verbose is None else verbose fw_config["verbose"] = verbose ffmpeg = getattr(args, "ffmpeg") @@ -175,9 +178,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", @@ -322,6 +322,11 @@ def _parse_cli(arg_list, input=True): "--config_file", help="Specify the configuration file", ) + parser.add_argument( + "-q", "--quiet", + action="store_true", + help="Quiet mode. Equivalent to -v CRITICAL. It can be overridden by -v and -L", + ) parser.add_argument( "-v", "--verbose", type=str, From a75611d795dd49f829ece0d64bdac0f15838d540 Mon Sep 17 00:00:00 2001 From: azarzadavila <37216245+azarzadavila@users.noreply.github.com> Date: Sat, 25 Jul 2020 15:38:39 +0200 Subject: [PATCH 07/20] Disable status bar if verbose level not DEBUG/INFO --- manim/scene/scene.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/manim/scene/scene.py b/manim/scene/scene.py index da5e2179dd..a9278cebb8 100644 --- a/manim/scene/scene.py +++ b/manim/scene/scene.py @@ -680,10 +680,12 @@ def get_time_progression(self, run_time, n_iterations=None, override_skip_animat else: step = 1 / self.camera.frame_rate times = np.arange(0, run_time, step) + disable = file_writer_config["verbose"] not in ["DEBUG", "INFO"] time_progression = ProgressDisplay( times, total=n_iterations, leave=file_writer_config['leave_progress_bars'], - ascii=True if platform.system() == 'Windows' else None + ascii=True if platform.system() == 'Windows' else None, + disable=disable, ) return time_progression From b2bdbe9bfe9cdc0195a56f93391ccb072e3fa231 Mon Sep 17 00:00:00 2001 From: azarzadavila <37216245+azarzadavila@users.noreply.github.com> Date: Sat, 25 Jul 2020 17:14:16 +0200 Subject: [PATCH 08/20] Remove comment set logger level --- manim/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manim/config.py b/manim/config.py index 360cb1c06f..1efa6da297 100644 --- a/manim/config.py +++ b/manim/config.py @@ -88,7 +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"]) # Set logger level +logger.setLevel(file_writer_config["verbose"]) if _from_command_line(): logger.info(f"Read configuration files: {os.path.abspath(successfully_read_files[-1])}") _init_dirs(file_writer_config) From eee98747408fc6f3a20d378e14bfaf02a7a3ebf4 Mon Sep 17 00:00:00 2001 From: azarzadavila <37216245+azarzadavila@users.noreply.github.com> Date: Sat, 25 Jul 2020 20:00:36 +0200 Subject: [PATCH 09/20] Add option progress_bar on/off --- manim/scene/scene.py | 2 +- manim/utils/config_utils.py | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/manim/scene/scene.py b/manim/scene/scene.py index a9278cebb8..0e195fc9dc 100644 --- a/manim/scene/scene.py +++ b/manim/scene/scene.py @@ -680,7 +680,7 @@ def get_time_progression(self, run_time, n_iterations=None, override_skip_animat else: step = 1 / self.camera.frame_rate times = np.arange(0, run_time, step) - disable = file_writer_config["verbose"] not in ["DEBUG", "INFO"] + disable = not file_writer_config["progress_bar"] time_progression = ProgressDisplay( times, total=n_iterations, leave=file_writer_config['leave_progress_bars'], diff --git a/manim/utils/config_utils.py b/manim/utils/config_utils.py index ee43a0e62c..4791ac821d 100644 --- a/manim/utils/config_utils.py +++ b/manim/utils/config_utils.py @@ -133,6 +133,16 @@ def _parse_file_writer_config(config_parser, args): if ffmpeg is None and default.getint("ffmpeg", None) is not None: ffmpeg = default.getint("ffmpeg") fw_config["ffmpeg"] = constants.VERBOSE_FFMPEG_MAP[verbose] if ffmpeg is None else ffmpeg + if verbose in ["DEBUG", "INFO"]: + progress_bar_v = True + else: + progress_bar_v = False + progress_bar = getattr(args, "progress_bar") + if progress_bar is None: + progress_bar = default.get("progress_bar", None) + if progress_bar is not None: + progress_bar = True if progress_bar == "on" else False + fw_config["progress_bar"] = progress_bar_v if progress_bar is None else progress_bar return fw_config @@ -341,6 +351,13 @@ def _parse_cli(arg_list, input=True): metavar="loglevel", choices=[-8, 0, 8, 16, 24, 32, 40, 48, 56], ) + parser.add_argument( + "--progress_bar", + type=str, + help="Display the progress bar", + metavar="on/off", + choices=["on", "off"], + ) return parser.parse_args(arg_list) From 624b6ab38a06af19c7a46459baed243367715e98 Mon Sep 17 00:00:00 2001 From: azarzadavila <37216245+azarzadavila@users.noreply.github.com> Date: Sat, 25 Jul 2020 21:02:16 +0200 Subject: [PATCH 10/20] Change ffmpeg loglevel to a string --- manim/constants.py | 10 +++++----- manim/scene/scene_file_writer.py | 6 +++--- manim/utils/config_utils.py | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/manim/constants.py b/manim/constants.py index ce981915dd..d5ad0affca 100644 --- a/manim/constants.py +++ b/manim/constants.py @@ -150,9 +150,9 @@ class MyText(Text): locals().update(COLOR_MAP) VERBOSE_CHOICES = ["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"] VERBOSE_FFMPEG_MAP = { - "DEBUG": 16, - "INFO": 16, - "WARNING": 16, - "ERROR": 16, - "CRITICAL": 8, + "DEBUG": "error", + "INFO": "error", + "WARNING": "error", + "ERROR": "error", + "CRITICAL": "fatal", } diff --git a/manim/scene/scene_file_writer.py b/manim/scene/scene_file_writer.py index 6cbf53a525..6fba3cd9bc 100644 --- a/manim/scene/scene_file_writer.py +++ b/manim/scene/scene_file_writer.py @@ -391,7 +391,7 @@ def open_movie_pipe(self): '-r', str(fps), # frames per second '-i', '-', # The imput comes from a pipe '-an', # Tells FFMPEG not to expect any audio - '-loglevel', str(file_writer_config["ffmpeg"]), + '-loglevel', file_writer_config["ffmpeg"], ] # TODO, the test for a transparent background should not be based on # the file extension. @@ -472,7 +472,7 @@ def combine_movie_files(self): '-f', 'concat', '-safe', '0', '-i', file_list, - '-loglevel', str(file_writer_config["ffmpeg"]), + '-loglevel', file_writer_config["ffmpeg"], ] if self.write_to_movie: @@ -514,7 +514,7 @@ def combine_movie_files(self): "-map", "0:v:0", # select audio stream from second file "-map", "1:a:0", - '-loglevel', str(file_writer_config["ffmpeg"]), + '-loglevel', file_writer_config["ffmpeg"], # "-shortest", temp_file_path, ] diff --git a/manim/utils/config_utils.py b/manim/utils/config_utils.py index 4791ac821d..8d14786e55 100644 --- a/manim/utils/config_utils.py +++ b/manim/utils/config_utils.py @@ -130,8 +130,7 @@ def _parse_file_writer_config(config_parser, args): verbose = default["verbose"] if verbose is None else verbose fw_config["verbose"] = verbose ffmpeg = getattr(args, "ffmpeg") - if ffmpeg is None and default.getint("ffmpeg", None) is not None: - ffmpeg = default.getint("ffmpeg") + ffmpeg = default.get("ffmpeg", None) if ffmpeg is None else ffmpeg fw_config["ffmpeg"] = constants.VERBOSE_FFMPEG_MAP[verbose] if ffmpeg is None else ffmpeg if verbose in ["DEBUG", "INFO"]: progress_bar_v = True @@ -346,10 +345,11 @@ def _parse_cli(arg_list, input=True): ) parser.add_argument( "-L", "--ffmpeg", - type=int, + type=str, help="Log level for ffmpeg", metavar="loglevel", - choices=[-8, 0, 8, 16, 24, 32, 40, 48, 56], + choices=["-8", "0", "8", "16", "24", "32", "40", "48", "56", + "quiet", "panic", "fatal", "error", "warning", "info", "verbose", "debug", "trace"], ) parser.add_argument( "--progress_bar", From 4a49e4adff07c4c34a885902a4569a96b593d980 Mon Sep 17 00:00:00 2001 From: azarzadavila <37216245+azarzadavila@users.noreply.github.com> Date: Sat, 25 Jul 2020 21:06:08 +0200 Subject: [PATCH 11/20] Change ffmpeg option to ffmpeg_loglevel --- manim/scene/scene_file_writer.py | 6 +++--- manim/utils/config_utils.py | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/manim/scene/scene_file_writer.py b/manim/scene/scene_file_writer.py index 6fba3cd9bc..d2ad20d2b1 100644 --- a/manim/scene/scene_file_writer.py +++ b/manim/scene/scene_file_writer.py @@ -391,7 +391,7 @@ def open_movie_pipe(self): '-r', str(fps), # frames per second '-i', '-', # The imput comes from a pipe '-an', # Tells FFMPEG not to expect any audio - '-loglevel', file_writer_config["ffmpeg"], + '-loglevel', file_writer_config["ffmpeg_loglevel"], ] # TODO, the test for a transparent background should not be based on # the file extension. @@ -472,7 +472,7 @@ def combine_movie_files(self): '-f', 'concat', '-safe', '0', '-i', file_list, - '-loglevel', file_writer_config["ffmpeg"], + '-loglevel', file_writer_config["ffmpeg_loglevel"], ] if self.write_to_movie: @@ -514,7 +514,7 @@ def combine_movie_files(self): "-map", "0:v:0", # select audio stream from second file "-map", "1:a:0", - '-loglevel', file_writer_config["ffmpeg"], + '-loglevel', file_writer_config["ffmpeg_loglevel"], # "-shortest", temp_file_path, ] diff --git a/manim/utils/config_utils.py b/manim/utils/config_utils.py index 8d14786e55..f67a9a163e 100644 --- a/manim/utils/config_utils.py +++ b/manim/utils/config_utils.py @@ -129,9 +129,9 @@ def _parse_file_writer_config(config_parser, args): verbose = "CRITICAL" if verbose is None and quiet else verbose verbose = default["verbose"] if verbose is None else verbose fw_config["verbose"] = verbose - ffmpeg = getattr(args, "ffmpeg") - ffmpeg = default.get("ffmpeg", None) if ffmpeg is None else ffmpeg - fw_config["ffmpeg"] = constants.VERBOSE_FFMPEG_MAP[verbose] if ffmpeg is None else ffmpeg + ffmpeg_loglevel = getattr(args, "ffmpeg_loglevel") + ffmpeg_loglevel = default.get("ffmpeg_loglevel", None) if ffmpeg_loglevel is None else ffmpeg_loglevel + fw_config["ffmpeg_loglevel"] = constants.VERBOSE_FFMPEG_MAP[verbose] if ffmpeg_loglevel is None else ffmpeg_loglevel if verbose in ["DEBUG", "INFO"]: progress_bar_v = True else: @@ -344,7 +344,7 @@ def _parse_cli(arg_list, input=True): choices=constants.VERBOSE_CHOICES, ) parser.add_argument( - "-L", "--ffmpeg", + "-L", "--ffmpeg_loglevel", type=str, help="Log level for ffmpeg", metavar="loglevel", From 794c8e060c033d87b3bf29ce2abbbeb466087d92 Mon Sep 17 00:00:00 2001 From: azarzadavila <37216245+azarzadavila@users.noreply.github.com> Date: Wed, 29 Jul 2020 11:59:54 +0200 Subject: [PATCH 12/20] VERBOSE_CHOICES through dict keys from FFMPEG_MAP --- manim/constants.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manim/constants.py b/manim/constants.py index d5ad0affca..82782a7b0f 100644 --- a/manim/constants.py +++ b/manim/constants.py @@ -148,7 +148,6 @@ class MyText(Text): if name.endswith("_C")}) PALETTE = list(COLOR_MAP.values()) locals().update(COLOR_MAP) -VERBOSE_CHOICES = ["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"] VERBOSE_FFMPEG_MAP = { "DEBUG": "error", "INFO": "error", @@ -156,3 +155,4 @@ class MyText(Text): "ERROR": "error", "CRITICAL": "fatal", } +VERBOSE_CHOICES = VERBOSE_FFMPEG_MAP.keys() From 1988237d49b99a7289c817fea934bee641cf066c Mon Sep 17 00:00:00 2001 From: azarzadavila <37216245+azarzadavila@users.noreply.github.com> Date: Wed, 29 Jul 2020 12:12:48 +0200 Subject: [PATCH 13/20] Remove quiet flag --- manim/default.cfg | 3 --- manim/utils/config_utils.py | 9 --------- 2 files changed, 12 deletions(-) diff --git a/manim/default.cfg b/manim/default.cfg index 6a1487adad..6db517e984 100644 --- a/manim/default.cfg +++ b/manim/default.cfg @@ -36,9 +36,6 @@ preview = False # -f, --show_file_in_finder show_file_in_finder = False -# -q, --quiet -quiet = False - # -v, --verbose verbose = INFO diff --git a/manim/utils/config_utils.py b/manim/utils/config_utils.py index f67a9a163e..9f5ea84481 100644 --- a/manim/utils/config_utils.py +++ b/manim/utils/config_utils.py @@ -122,11 +122,7 @@ def _parse_file_writer_config(config_parser, args): ) # Read in the log level - quiet = getattr(args, "quiet") - if not quiet and default.getboolean("quiet", None) is not None: - quiet = default.getboolean("quiet") verbose = getattr(args, "verbose") - verbose = "CRITICAL" if verbose is None and quiet else verbose verbose = default["verbose"] if verbose is None else verbose fw_config["verbose"] = verbose ffmpeg_loglevel = getattr(args, "ffmpeg_loglevel") @@ -331,11 +327,6 @@ def _parse_cli(arg_list, input=True): "--config_file", help="Specify the configuration file", ) - parser.add_argument( - "-q", "--quiet", - action="store_true", - help="Quiet mode. Equivalent to -v CRITICAL. It can be overridden by -v and -L", - ) parser.add_argument( "-v", "--verbose", type=str, From 6f208e43ee089d650771e6e36a94deae337e21e8 Mon Sep 17 00:00:00 2001 From: azarzadavila <37216245+azarzadavila@users.noreply.github.com> Date: Wed, 29 Jul 2020 12:15:45 +0200 Subject: [PATCH 14/20] Remove disable var for progress_bar --- manim/scene/scene.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/manim/scene/scene.py b/manim/scene/scene.py index 0e195fc9dc..8d2d831479 100644 --- a/manim/scene/scene.py +++ b/manim/scene/scene.py @@ -680,12 +680,11 @@ def get_time_progression(self, run_time, n_iterations=None, override_skip_animat else: step = 1 / self.camera.frame_rate times = np.arange(0, run_time, step) - disable = not file_writer_config["progress_bar"] time_progression = ProgressDisplay( times, total=n_iterations, leave=file_writer_config['leave_progress_bars'], ascii=True if platform.system() == 'Windows' else None, - disable=disable, + disable=not file_writer_config["progress_bar"], ) return time_progression From 520d1c0b61f56ea26c010f38cc34991d5e90033a Mon Sep 17 00:00:00 2001 From: azarzadavila <37216245+azarzadavila@users.noreply.github.com> Date: Wed, 29 Jul 2020 12:30:59 +0200 Subject: [PATCH 15/20] ffmpeg_loglevel only in config file --- manim/default.cfg | 4 ++++ manim/utils/config_utils.py | 13 ++----------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/manim/default.cfg b/manim/default.cfg index 6db517e984..b468050783 100644 --- a/manim/default.cfg +++ b/manim/default.cfg @@ -153,3 +153,7 @@ log_level = log_time = cyan dim log_message = log_path = dim + +[ffmpeg] +# Uncomment the following line to manually set the loglevel for ffmpeg. See ffmpeg manpage for accepted values +# loglevel = error \ No newline at end of file diff --git a/manim/utils/config_utils.py b/manim/utils/config_utils.py index 9f5ea84481..2e6f01ccbd 100644 --- a/manim/utils/config_utils.py +++ b/manim/utils/config_utils.py @@ -125,8 +125,7 @@ def _parse_file_writer_config(config_parser, args): verbose = getattr(args, "verbose") verbose = default["verbose"] if verbose is None else verbose fw_config["verbose"] = verbose - ffmpeg_loglevel = getattr(args, "ffmpeg_loglevel") - ffmpeg_loglevel = default.get("ffmpeg_loglevel", None) if ffmpeg_loglevel is None else ffmpeg_loglevel + 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 if verbose in ["DEBUG", "INFO"]: progress_bar_v = True @@ -330,18 +329,10 @@ def _parse_cli(arg_list, input=True): parser.add_argument( "-v", "--verbose", type=str, - help="Verbosity level. Also changes the ffmpeg log level unless the latter is specified", + help="Verbosity level. Also changes the ffmpeg log level unless the latter is specified in the config", metavar="loglevel", choices=constants.VERBOSE_CHOICES, ) - parser.add_argument( - "-L", "--ffmpeg_loglevel", - type=str, - help="Log level for ffmpeg", - metavar="loglevel", - choices=["-8", "0", "8", "16", "24", "32", "40", "48", "56", - "quiet", "panic", "fatal", "error", "warning", "info", "verbose", "debug", "trace"], - ) parser.add_argument( "--progress_bar", type=str, From ce7cecb95b7acd0561709d8b3afe4030a5fefdb7 Mon Sep 17 00:00:00 2001 From: azarzadavila <37216245+azarzadavila@users.noreply.github.com> Date: Wed, 29 Jul 2020 13:00:56 +0200 Subject: [PATCH 16/20] progress_bar flag to boolean --- manim/default.cfg | 3 +++ manim/utils/config_utils.py | 17 +++++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/manim/default.cfg b/manim/default.cfg index b468050783..13e90451ba 100644 --- a/manim/default.cfg +++ b/manim/default.cfg @@ -39,6 +39,9 @@ show_file_in_finder = False # -v, --verbose verbose = INFO +# --progress_bar +progress_bar = True + # --sound sound = False diff --git a/manim/utils/config_utils.py b/manim/utils/config_utils.py index 2e6f01ccbd..ada0a34466 100644 --- a/manim/utils/config_utils.py +++ b/manim/utils/config_utils.py @@ -133,9 +133,7 @@ def _parse_file_writer_config(config_parser, args): progress_bar_v = False progress_bar = getattr(args, "progress_bar") if progress_bar is None: - progress_bar = default.get("progress_bar", None) - if progress_bar is not None: - progress_bar = True if progress_bar == "on" else False + progress_bar = default.getboolean("progress_bar", None) fw_config["progress_bar"] = progress_bar_v if progress_bar is None else progress_bar return fw_config @@ -333,12 +331,19 @@ def _parse_cli(arg_list, input=True): metavar="loglevel", choices=constants.VERBOSE_CHOICES, ) + + 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=str, + type=_str2bool, help="Display the progress bar", - metavar="on/off", - choices=["on", "off"], + metavar="True/False", ) return parser.parse_args(arg_list) From 6209cdf3b78dee6062c251f17332ba36c8d2bdef Mon Sep 17 00:00:00 2001 From: azarzadavila <37216245+azarzadavila@users.noreply.github.com> Date: Wed, 29 Jul 2020 13:05:29 +0200 Subject: [PATCH 17/20] progress_bar independant on verbose flag --- manim/utils/config_utils.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/manim/utils/config_utils.py b/manim/utils/config_utils.py index ada0a34466..d9be9661e8 100644 --- a/manim/utils/config_utils.py +++ b/manim/utils/config_utils.py @@ -127,14 +127,10 @@ def _parse_file_writer_config(config_parser, args): fw_config["verbose"] = verbose 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 - if verbose in ["DEBUG", "INFO"]: - progress_bar_v = True - else: - progress_bar_v = False progress_bar = getattr(args, "progress_bar") if progress_bar is None: - progress_bar = default.getboolean("progress_bar", None) - fw_config["progress_bar"] = progress_bar_v if progress_bar is None else progress_bar + progress_bar = default.getboolean("progress_bar") + fw_config["progress_bar"] = progress_bar return fw_config From 0104d6e67b4d3c1d5e4757862355d277651c72df Mon Sep 17 00:00:00 2001 From: azarzadavila <37216245+azarzadavila@users.noreply.github.com> Date: Wed, 29 Jul 2020 13:08:06 +0200 Subject: [PATCH 18/20] Comments on verbose/ffmpeg loglevel/progress_bar flags --- manim/utils/config_utils.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/manim/utils/config_utils.py b/manim/utils/config_utils.py index d9be9661e8..ac3185c7e6 100644 --- a/manim/utils/config_utils.py +++ b/manim/utils/config_utils.py @@ -121,12 +121,16 @@ def _parse_file_writer_config(config_parser, args): [fw_config["save_last_frame"], fw_config["from_animation_number"]] ) - # Read in the log level + # 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") From 67c12fc70e0df8595b6c4454a88fbd8dc3c296f6 Mon Sep 17 00:00:00 2001 From: azarzadavila <37216245+azarzadavila@users.noreply.github.com> Date: Mon, 3 Aug 2020 19:01:51 +0200 Subject: [PATCH 19/20] Remove metavar to verbose --- manim/utils/config_utils.py | 1 - 1 file changed, 1 deletion(-) diff --git a/manim/utils/config_utils.py b/manim/utils/config_utils.py index ac3185c7e6..00fdc2fa5b 100644 --- a/manim/utils/config_utils.py +++ b/manim/utils/config_utils.py @@ -328,7 +328,6 @@ def _parse_cli(arg_list, input=True): "-v", "--verbose", type=str, help="Verbosity level. Also changes the ffmpeg log level unless the latter is specified in the config", - metavar="loglevel", choices=constants.VERBOSE_CHOICES, ) From 097998a0fbeaa4111a758f4bac3ee6977748e35e Mon Sep 17 00:00:00 2001 From: azarzadavila <37216245+azarzadavila@users.noreply.github.com> Date: Mon, 3 Aug 2020 21:31:24 +0200 Subject: [PATCH 20/20] Black config_utils.py --- manim/utils/config_utils.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/manim/utils/config_utils.py b/manim/utils/config_utils.py index 16304a3e3e..c9db004dae 100644 --- a/manim/utils/config_utils.py +++ b/manim/utils/config_utils.py @@ -140,7 +140,11 @@ def _parse_file_writer_config(config_parser, args): # 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 + 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") @@ -363,7 +367,8 @@ def _parse_cli(arg_list, input=True): # Specify the verbosity parser.add_argument( - "-v", "--verbose", + "-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, @@ -377,6 +382,7 @@ def _str2bool(s): return False else: raise argparse.ArgumentTypeError("True or False expected") + parser.add_argument( "--progress_bar", type=_str2bool,