Skip to content

Commit d8dab78

Browse files
authored
Added explicit production quality flag. (#529)
* Added explicit production quality flag. * Updated documentation to mention production quality flag.
1 parent e1adf6a commit d8dab78

File tree

6 files changed

+25
-10
lines changed

6 files changed

+25
-10
lines changed

docs/source/changelog.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Command line
3232
#. You can save the logs to a file by using :code:`--log_to_file`
3333
#. Read :code:`tex_template` from config file if not specified by :code:`--tex_template`.
3434
#. Add experimental javascript rendering with :code:`--use_js_renderer`
35-
#. Add :code:`-q/--quality [k|h|m|l]` flag and removed :code:`-m/-l` flags.
35+
#. Add :code:`-q/--quality [k|p|h|m|l]` flag and removed :code:`-m/-l` flags.
3636
#. Removed :code:`--sound` flag
3737

3838

docs/source/tutorials/configuration.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ The output looks as follows.
4747
:options: -ELLIPSIS, +NORMALIZE_WHITESPACE
4848

4949
usage: manim [-h] [-o OUTPUT_FILE] [-p] [-f] [--leave_progress_bars] [-a] [-w] [-s] [-g] [-i] [--disable_caching] [--flush_cache] [--log_to_file] [-c BACKGROUND_COLOR]
50-
[--background_opacity BACKGROUND_OPACITY] [--media_dir MEDIA_DIR] [--log_dir LOG_DIR] [--tex_template TEX_TEMPLATE] [--dry_run] [-t] [-q {k,h,m,l}] [--low_quality] [--medium_quality]
51-
[--high_quality] [--fourk_quality] [-r RESOLUTION] [-n FROM_ANIMATION_NUMBER] [--use_js_renderer] [--js_renderer_path JS_RENDERER_PATH] [--config_file CONFIG_FILE] [--custom_folders]
50+
[--background_opacity BACKGROUND_OPACITY] [--media_dir MEDIA_DIR] [--log_dir LOG_DIR] [--tex_template TEX_TEMPLATE] [--dry_run] [-t] [-q {k,p,h,m,l}] [--low_quality] [--medium_quality]
51+
[--high_quality] [--production_quality] [--fourk_quality] [-r RESOLUTION] [-n FROM_ANIMATION_NUMBER] [--use_js_renderer] [--js_renderer_path JS_RENDERER_PATH] [--config_file CONFIG_FILE] [--custom_folders]
5252
[-v {DEBUG,INFO,WARNING,ERROR,CRITICAL}] [--progress_bar True/False]
5353
{cfg} ... file [scene_names [scene_names ...]]
5454

@@ -88,11 +88,12 @@ optional arguments:
8888
Specify a custom TeX template file
8989
--dry_run Do a dry run (render scenes but generate no output files)
9090
-t, --transparent Render a scene with an alpha channel
91-
-q {k,h,m,l}, --quality {k,h,m,l}
91+
-q {k,p,h,m,l}, --quality {k,p,h,m,l}
9292
Render at specific quality, short form of the --*_quality flags
9393
--low_quality Render at low quality
9494
--medium_quality Render at medium quality
9595
--high_quality Render at high quality
96+
--production_quality Render at default production quality
9697
--fourk_quality Render at 4K quality
9798
-r RESOLUTION, --resolution RESOLUTION
9899
Resolution, passed as "height,width". Overrides any quality flags, if present

manim/config/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def _parse_config(config_parser, args):
8686
# and are stored in 'camera_config'. Note the highest resolution
8787
# passed as argument will be used.
8888
quality = _determine_quality(args)
89-
section = config_parser[quality if quality != "production" else "CLI"]
89+
section = config_parser[quality if quality != constants.DEFAULT_QUALITY else "CLI"]
9090

9191
# Loop over low quality for the keys, could be any quality really
9292
config = {opt: section.getint(opt) for opt in config_parser["low_quality"]}

manim/config/config_utils.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,7 @@ def _parse_cli(arg_list, input=True):
343343
"-q",
344344
"--quality",
345345
choices=constants.QUALITIES.values(),
346+
default=constants.DEFAULT_QUALITY_SHORT,
346347
help="Render at specific quality, short form of the --*_quality flags",
347348
)
348349
parser.add_argument(
@@ -360,6 +361,11 @@ def _parse_cli(arg_list, input=True):
360361
action="store_true",
361362
help="Render at high quality",
362363
)
364+
parser.add_argument(
365+
"--production_quality",
366+
action="store_true",
367+
help="Render at default production quality",
368+
)
363369
parser.add_argument(
364370
"--fourk_quality",
365371
action="store_true",
@@ -650,7 +656,10 @@ def _determine_quality(args):
650656
}
651657

652658
for quality in constants.QUALITIES.keys():
653-
if getattr(args, quality) or (
659+
if quality == constants.DEFAULT_QUALITY:
660+
# Skip so we prioritize anything that overwrites the default quality.
661+
pass
662+
elif getattr(args, quality) or (
654663
hasattr(args, "quality") and args.quality == constants.QUALITIES[quality]
655664
):
656665
return quality
@@ -662,4 +671,4 @@ def _determine_quality(args):
662671
)
663672
return old_qualities[quality]
664673

665-
return "production"
674+
return constants.DEFAULT_QUALITY

manim/constants.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,11 @@ class MyText(Text):
130130
# Video qualities
131131
QUALITIES = {
132132
"fourk_quality": "k",
133+
"production_quality": "p",
133134
"high_quality": "h",
134135
"medium_quality": "m",
135136
"low_quality": "l",
136137
}
138+
139+
DEFAULT_QUALITY = "production_quality"
140+
DEFAULT_QUALITY_SHORT = QUALITIES[DEFAULT_QUALITY]

tests/test_cli_flags.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33

44

55
def test_quality_flags():
6-
# Assert that quality is None when not specifying it
6+
# Assert that quality is the default when not specifying it
77
parsed = _parse_cli([], False)
88

9-
assert not parsed.quality
9+
assert parsed.quality == constants.DEFAULT_QUALITY_SHORT
10+
assert _determine_quality(parsed) == constants.DEFAULT_QUALITY
1011

1112
for quality in constants.QUALITIES.keys():
1213
# Assert that quality is properly set when using -q*
@@ -41,4 +42,4 @@ def test_quality_flags():
4142
parsed = _parse_cli([], False)
4243

4344
assert not getattr(parsed, quality)
44-
assert "production" == _determine_quality(parsed)
45+
assert _determine_quality(parsed) == constants.DEFAULT_QUALITY

0 commit comments

Comments
 (0)