Skip to content

Conversation

@behackl
Copy link
Member

@behackl behackl commented Jul 18, 2023

This adds a new command line interface subcommand which can be used to check whether a local installation of Manim has been configured correctly, and all required (and optional) dependencies are available. To try it, run it via manim checkhealth or python -m manim checkhealth.

Description of new feature

The new subcommand manim checkhealth programmatically checks whether all of the required system dependencies (ffmpeg) as well as the optional dependencies (like latex and dvisvgm) are available:

(manim-py3.10) behackl@draven manim % manim checkhealth
Manim Community v0.17.2

Checking whether your installation of Manim Community is healthy...
- Checking whether manim is on your PATH ... PASSED
- Checking whether the executable belongs to manim ... PASSED
- Checking whether ffmpeg is available ... PASSED
- Checking whether ffmpeg is working ... PASSED
- Checking whether latex is available ... PASSED
- Checking whether dvisvgm is available ... PASSED

No problems detected, your installation seems healthy!

If all defined health checks pass, the CLI also offers to render and preview a simple test scene, namely

class CheckHealthDemo(Scene):
      def construct(self):
          banner = ManimBanner()
          self.play(banner.create())
          self.wait()
          self.play(banner.expand())
          self.wait()
          self.play(FadeOut(banner, shift=UP))

In case health checks fail, some (hopefully) useful instructions for fixing the problem are displayed:

(manim-py3.10) behackl@draven manim % manim checkhealth
Manim Community v0.17.2

Checking whether your installation of Manim Community is healthy...
- Checking whether manim is on your PATH ... FAILED
- Checking whether the executable belongs to manim ... SKIPPED
- Checking whether ffmpeg is available ... FAILED
- Checking whether ffmpeg is working ... SKIPPED
- Checking whether latex is available ... PASSED
- Checking whether dvisvgm is available ... PASSED

There are problems with your installation, here are some recommendations to fix them:
The command <manim> is currently not on your system's PATH.

You can work around this by calling the manim module directly via <python -m manim> instead of just <manim>.

To fix the PATH issue properly: Usually, the Python package installer pip issues a warning during the installation which contains more information. Consider reinstalling manim via <pip uninstall manim> followed by <pip install manim> to see the warning again, then consult the internet on how to modify your system's PATH variable.
Continue with next recommendation? [y/N]: y
...

Theoretically, some of these problems could also be resolved interactively, from within the CLI. More details below.

Implementation detail

Health checks have been implemented in a somewhat generic way, namely in form of a function returning a bool that is decorated with a new @healthcheck decorator. The decorator takes several arguments:

  • a description, which is printed in the output of the subcommand,
  • a recommendation, which is a help text displayed if the health check fails,
  • a list allowing to describe dependencies between checks,
  • and an optional function which can contain some code that helps the user (interactively) to fix an identified problem (for example, in case the ffmpeg executable is not found on the system's PATH, an interactive dialog could help to set the corresponding config.ffmpeg_executable option in the user-wide config file.)

@behackl behackl added the new feature Enhancement specifically adding a new feature (feature request should be used for issues instead) label Jul 18, 2023
@behackl behackl marked this pull request as ready for review July 29, 2023 02:47
@behackl behackl added the highlight For contributions that should be highlighted explicitly in the next changelog label Aug 5, 2023
@behackl behackl merged commit efd6474 into ManimCommunity:main Aug 5, 2023
@behackl behackl deleted the cli-checkhealth branch August 5, 2023 09:03
@MrDiver
Copy link
Collaborator

MrDiver commented Aug 6, 2023

WE SHOULD IMPLEMENT A BASIC LATEX TEST RENDERING TEST

am i too late to the party? Oh damn.

nothing happened

@behackl behackl added this to the v0.18.0 milestone Aug 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

highlight For contributions that should be highlighted explicitly in the next changelog new feature Enhancement specifically adding a new feature (feature request should be used for issues instead)

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants