Skip to content

Show read cfg files in DEBUG mode only; change default testing mode to DEBUG #296

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 5 commits into from
Aug 15, 2020
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions manim/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@


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

Expand All @@ -43,7 +43,7 @@ def open_file_if_needed(file_writer):
for file_path in file_paths:
open_media_file(file_path, file_writer_config["show_in_file_browser"])

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

Expand Down
4 changes: 2 additions & 2 deletions manim/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ def _parse_config(config_parser, args):


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

# -v, --verbose
verbose = INFO
# -v, --verbosity
verbosity = INFO

# --progress_bar
progress_bar = True
Expand Down
14 changes: 7 additions & 7 deletions manim/utils/config_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,15 @@ def _parse_file_writer_config(config_parser, args):
fw_config["max_files_cached"] = default.getint("max_files_cached")
if fw_config["max_files_cached"] == -1:
fw_config["max_files_cached"] = float("inf")
# 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 verbosity flag to read in the log level
verbosity = getattr(args, "verbosity")
verbosity = default["verbosity"] if verbosity is None else verbosity
fw_config["verbosity"] = verbosity

# 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]
constants.FFMPEG_VERBOSITY_MAP[verbosity]
if ffmpeg_loglevel is None
else ffmpeg_loglevel
)
Expand Down Expand Up @@ -385,10 +385,10 @@ def _parse_cli(arg_list, input=True):
# Specify the verbosity
parser.add_argument(
"-v",
"--verbose",
"--verbosity",
type=str,
help="Verbosity level. Also changes the ffmpeg log level unless the latter is specified in the config",
choices=constants.VERBOSE_CHOICES,
choices=constants.VERBOSITY_CHOICES,
)

# Specify if the progress bar should be displayed
Expand Down
1 change: 1 addition & 0 deletions tests/test_cli/manim.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
movie_file_extension = .mp4
write_to_movie = True
sound = True
verbosity = DEBUG
# write_all = False
save_last_frame = True
# save_pngs = False
5 changes: 4 additions & 1 deletion tests/test_logging/expected.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
INFO Read configuration files: config.py:
DEBUG Read configuration files: config.py:
DEBUG Animation : Partial movie file written in scene_file_writer.py:
DEBUG Animation : Partial movie file written in scene_file_writer.py:
DEBUG Animation : Partial movie file written in scene_file_writer.py:
INFO scene_file_writer.py:
File ready at

1 change: 1 addition & 0 deletions tests/tests_data/manim.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ write_to_movie = True
# write_all = False
save_last_frame = False
# save_pngs = False
verbosity = DEBUG

[logger]
log_width = 512
Expand Down