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

Verbose #218

merged 22 commits into from
Aug 10, 2020

Conversation

azarzadavila
Copy link
Contributor

Proposal to solve #107 .

This PR introduces two CLI args :

  • verbose : string which controls the global verbosity
  • ffmpeg : int which controls the log level of ffmpeg

I think they are mainly four sources of output when executing manim :

  • ffmpeg
  • logs from logger
  • status bar handled by tqdm
  • the video viewer used when previewing

I suggest to use the levels of logger as the main parameter, which can be in : DEBUG, INFO, WARNING, ERROR, CRITICAL.
The offered solution is by default to pass the global config of verbose to the logger and then to map this config for the other sources of outputs.
Namely,

  • DEBUG -> ffmpeg set to loglevel 16 (error level) / the status bar is printed / the output of the video viewer is captured
  • INFO -> ffmpeg set to loglevel 16 (error level) / the status bar is printed / the output of the video viewer is not captured
  • WARNING -> ffmpeg set to loglevel 16 (error level) / the status bar is not printed / the output of the video viewer is not captured
  • ERROR -> ffmpeg set to loglevel 16 (error level) / the status bar is not printed / the output of the video viewer is not captured
  • CRITICAL -> ffmpeg set to loglevel 8 (fatal level) / the status bar is not printed / the output of the video viewer is not captured

However as an user may be interested over more control for ffmpeg, one can also pass the arg --ffmpeg to override the mapping.
I also kept the --quiet option equivalent to --verbose CRITICAL.
The three discussed options can be passed on command arguments or on default.cfg but the presence of ffmpeg and quiet in the configuration file is not mandatory.

Copy link
Member

@huguesdevimeux huguesdevimeux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First of all, thank you very much for this contribution.
Just two things :

  • I tested it and passed --ffpmeg 0,--ffpmeg -8,--ffpmeg 16 as flag (since these values are choices on the flag --ffmpeg you added), and it didn't change anything. As I'm not familiar with that at all, it would be nice if you could enlight me on the reasons.

  • Suggestion : Why not adding , in addition to --verbose flag, a flag that would disable progressbar ? Here, progressbar is disabled only when DEBUG or INFO is not enabled, which is cool but it woulc be better if we could have debug logs without progress bar if wanted. I would like to have other's opinion on this point.

@Aathish04 Aathish04 added the enhancement Additions and improvements in general label Jul 25, 2020
@huguesdevimeux
Copy link
Member

huguesdevimeux commented Jul 26, 2020

REMINDER : Please do not merge it until @leotrs approved, as it touches config and I want to be sure that it this done the correct way.

@Aathish04 Aathish04 linked an issue Jul 26, 2020 that may be closed by this pull request
Comment on lines 151 to 158
VERBOSE_CHOICES = ["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"]
VERBOSE_FFMPEG_MAP = {
"DEBUG": "error",
"INFO": "error",
"WARNING": "error",
"ERROR": "error",
"CRITICAL": "fatal",
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion:

VERBOSE_FFMPEG_MAP = {
    "DEBUG": "error",
    "INFO": "error",
    "WARNING": "error",
    "ERROR": "error",
    "CRITICAL": "fatal",
}
VERBOSE_CHOICES = VERBOSE_FFMPEG_MAP.keys()

Comment on lines 39 to 40
# -q, --quiet
quiet = False
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should delete this, yes?

Comment on lines 683 to 688
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
ascii=True if platform.system() == 'Windows' else None,
disable=disable,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: just do time_progression = ProgressDisplay(..., disable=not file_writer_config["progress_bar"], ...).

Comment on lines 125 to 127
quiet = getattr(args, "quiet")
if not quiet and default.getboolean("quiet", None) is not None:
quiet = default.getboolean("quiet")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit confusing to me to have both verbose and quiet flags. Is there any way to keep only one?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes absolutely quiet is just a shortcut for verbose CRITICAL. I thought it could be easier for a user that wants almost no output to remember quiet than verbose CRITICAL. However it does add an additional option so if it is confusing I'll remove it.

@@ -122,6 +121,27 @@ def _parse_file_writer_config(config_parser, args):
[fw_config["save_last_frame"], fw_config["from_animation_number"]]
)

# Read in the log level
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: "parse the verbose and quiet flags to read in the log level".

All other comments indicate which CLI flags they are dealing with, so this one should too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okey, I'll keep it in mind when modifying.

Comment on lines 128 to 130
verbose = getattr(args, "verbose")
verbose = "CRITICAL" if verbose is None and quiet else verbose
verbose = default["verbose"] if verbose is None else verbose
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I can follow this logic easily. Also, it seems that one of the conditionals here is catching the case when args doesn't have a verbose attribute, which presumably happens when the user doesn't pass the verbose flag. This is not how we want to handle things.

The config system is meant to be used as follows: if the user passes a value through CLI flag, we use that value. If they don't, we use whatever value is in the library-wide config file default.cfg. So the logic should be something like this:

verbose = args.verbose if args.verbose is not None else default["verbose"]

which takes just one line. Does this make sense? Does this yield the same logic as what you wrote before?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does yield the same logic except if verbose is not passed in the CLI flags but if quiet is (or if quiet is in the default.cfg). If the flag quiet flag is removed I'll write it as you put it.

"-v", "--verbose",
type=str,
help="Verbosity level. Also changes the ffmpeg log level unless the latter is specified",
metavar="loglevel",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: what is a metavar? What is the difference from dest?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think metavar is the display name when asking details through --help. On the other hand dest is the name of the attribute that will be generated.
This means that in the help message it will print --verbose loglevel but the attribute will be accessed through args.verbose.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would strongly prefer if the print message and the attribute be called the same.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okey, I removed the metavar attribute to keep the default behavior which is to show in the help message all possible values.

Comment on lines 356 to 359
type=str,
help="Display the progress bar",
metavar="on/off",
choices=["on", "off"],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: change to Boolean.

@leotrs
Copy link
Contributor

leotrs commented Jul 26, 2020

Something I don't like about this PR is that it's adding three new CLI flags. I think some of them can be just config options. For example, I don't think we need a flag to switch between showing or not showing the progress bar. What do you all think?

@huguesdevimeux
Copy link
Member

Something I don't like about this PR is that it's adding three new CLI flags. I think some of them can be just config options. For example, I don't think we need a flag to switch between showing or not showing the progress bar. What do you all think?

I strongly disagree on the flag for the progress bar, it would be a useful flag. Nevertheless, I think that ffmpeg_vebose shouldn't be a flag, maybe.

@azarzadavila
Copy link
Contributor Author

I'll remove then the flag quiet and keep ffmpeg_loglevel only in config file and not in the CLI flags.
Like that the four flags of this PR become only verbose and progress_bar which can also be set in default.cfg.

@azarzadavila
Copy link
Contributor Author

azarzadavila commented Jul 29, 2020

I also removed the fact that changing the verbose flag can change the progress_bar as to make it simpler.
I put the loglevel for ffmpeg into a new section [ffmpeg] in the config file. I am thinking it may be useful if in the future it is decided to give the user even more control to the ffmpeg flags.

@leotrs
Copy link
Contributor

leotrs commented Aug 2, 2020

@azarzadavila sounds good to me! Can you please resolve the conflicts before we can merge this?

@leotrs
Copy link
Contributor

leotrs commented Aug 2, 2020

Also, when this is merged please remember to close #107

"-v", "--verbose",
type=str,
help="Verbosity level. Also changes the ffmpeg log level unless the latter is specified",
metavar="loglevel",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would strongly prefer if the print message and the attribute be called the same.

@azarzadavila
Copy link
Contributor Author

I also see there is now a new attribute log_level in the config [logger] in default.cfg from a commit a few hours earlier.
I am guessing it would have the same function as the attribute verbose but I did not change it not knowing for sure it had the same purpose.

@leotrs
Copy link
Contributor

leotrs commented Aug 4, 2020

@Aathish04 and @naveen521kk can you please comment on how this relates to #180? Thanks.

@naveen521kk
Copy link
Member

No, those things in default.cfg for colour and not related to verbose output. @azarzadavila

@Aathish04
Copy link
Member

I also see there is now a new attribute log_level in the config [logger] in default.cfg from a commit a few hours earlier.
@Aathish04 and @naveen521kk can you please comment on how this relates to #180? Thanks.

log_level was introduced in commit d5162f5 , and not by #180. I have tried changing its values multiple times, and cannot find out what it actually modifies.

I think @naveen521kk is in a better position to answer what changing log_level actually modifies, since it was introduced with his PR and he has more experience with rich than me.

@leotrs
Copy link
Contributor

leotrs commented Aug 4, 2020

No, those things in default.cfg for colour and not related to verbose output. @azarzadavila

Sounds good! Now the problem will be that we will now have two flags log_level and verbose, which sound redundant, and it's not obvious which one does what.

@azarzadavila
Copy link
Contributor Author

I agree the names are confusing between those two flags. I see log_level is currently (in the branch master) not used anywhere and is only present in the config files. If log_level is related to the color of the output than it could perhaps be indicated in its name and thus reducing the ambiguity between the two flags ?

@leotrs
Copy link
Contributor

leotrs commented Aug 5, 2020

@naveen521kk could you tell us exactly what log_level does? I see it exists as a possible config option in the config files, but there is no CLI flag for it.

@leotrs leotrs merged commit 74c158c into ManimCommunity:master Aug 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Additions and improvements in general
Projects
None yet
Development

Successfully merging this pull request may close these issues.

--quiet not optimal
5 participants