From 82219d1d35a2294e7d2dd94da2f7fc885aad7b6f Mon Sep 17 00:00:00 2001 From: Filippo Luca Ferretti Date: Mon, 1 Jul 2024 17:52:18 +0200 Subject: [PATCH] Fix headless rendering when executing notebooks with MyST --- docs/conf.py | 10 ++++++---- examples/PD_controller.ipynb | 9 +++++---- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 79667765c..4909deaec 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -100,10 +100,10 @@ # -- Options for sphinx-gallery ---------------------------------------------- sphinx_gallery_conf = { - "examples_dirs": "_collections/examples", - "gallery_dirs": ("_collections/generated_examples/"), + "examples_dirs": "../examples", + "gallery_dirs": "../generated_examples/", "doc_module": "jaxsim", - "backreferences_dir": os.path.join("modules", "generated"), + "abort_on_example_error": True, } # -- Options for myst ------------------------------------------------------- @@ -113,7 +113,9 @@ ] nb_execution_mode = "force" nb_execution_allow_errors = False -nb_render_image_options = {} +nb_render_image_options = { + "scale": "60", +} source_suffix = [".rst", ".md", ".ipynb"] diff --git a/examples/PD_controller.ipynb b/examples/PD_controller.ipynb index 543c816d8..692e9258d 100644 --- a/examples/PD_controller.ipynb +++ b/examples/PD_controller.ipynb @@ -25,7 +25,6 @@ "import sys\n", "\n", "IS_COLAB = \"google.colab\" in sys.modules\n", - "IS_RTD = os.environ.get(\"READTHEDOCS\") is not None\n", "\n", "# Install JAX and Gazebo SDF\n", "if IS_COLAB:\n", @@ -159,6 +158,7 @@ "import os\n", "import subprocess\n", "\n", + "os.environ[\"MUJOCO_GL\"] = \"osmesa\"\n", "\n", "if IS_COLAB:\n", " if subprocess.run(\"nvidia-smi\").returncode:\n", @@ -185,7 +185,8 @@ " \"\"\"\n", " )\n", "\n", - "os.environ[\"MUJOCO_GL\"] = \"egl\" if not IS_RTD else \"osmesa\"\n", + " os.environ[\"MUJOCO_GL\"] = \"egl\"\n", + "\n", "\n", "from jaxsim.mujoco import MujocoModelHelper, MujocoVideoRecorder\n", "from jaxsim.mujoco.loaders import UrdfToMjcf\n", @@ -209,8 +210,8 @@ " model=mj_model_helper.model,\n", " data=mj_model_helper.data,\n", " fps=int(1 / 0.010),\n", - " width=320 * 4,\n", - " height=240 * 4,\n", + " width=320 * 2,\n", + " height=240 * 2,\n", ")" ] },