From ae06ecfe27b3003746f92054f9b458ec26e1b3af Mon Sep 17 00:00:00 2001 From: Etienne Pot Date: Thu, 6 Feb 2025 09:01:09 -0800 Subject: [PATCH] Make colab imports works in open-source PiperOrigin-RevId: 723955684 --- CHANGELOG.md | 2 ++ etils/ecolab/array_as_img.py | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 799106f5..397530a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,8 @@ Changelog follow https://keepachangelog.com/ format. * `epy.StrEnum`: Fix `!=` operator. * `epath`: * Supports `hf://` urls. +* `ecolab`: + * Make mediapy lazy ## [1.11.0] - 2024-11-27 diff --git a/etils/ecolab/array_as_img.py b/etils/ecolab/array_as_img.py index e5c732eb..1b63626c 100644 --- a/etils/ecolab/array_as_img.py +++ b/etils/ecolab/array_as_img.py @@ -29,13 +29,20 @@ from typing import Any, Optional, Tuple from etils import enp - +from etils import epy from etils.epy import _internal with _internal.check_missing_deps(): # pylint: disable=g-import-not-at-top import IPython import IPython.display + # pylint: enable=g-import-not-at-top + + +with epy.lazy_imports( + error_callback='Use `pip install etils[ecolab]` to install missing deps' +): + # pylint: disable=g-import-not-at-top import mediapy as media # pylint: enable=g-import-not-at-top