make rich optional for setup_logging
MODIFY
pangeo_forge_recipes/recipes/__init__.py
pangeo_forge_recipes/recipes/__init__.py
@@ -13,13 +13,19 @@ def setup_logging(level: str = "INFO"):
"""
import logging
+ try:
from rich.logging import RichHandler
+ handler = RichHandler()
+ handler.setFormatter(logging.Formatter("%(message)s"))
+ except ImportError:
+ import sys
+
+ handler = logging.StreamHandler(stream=sys.stdout)
+ handler.setFormatter(logging.Formatter("%(name)s - %(levelname)s - %(message)s"))
+
logger = logging.getLogger("pangeo_forge_recipes")
if logger.hasHandlers():
logger.handlers.clear()
logger.setLevel(getattr(logging, level))
- handler = RichHandler()
- formatter = logging.Formatter("%(message)s")
- handler.setFormatter(formatter)
logger.addHandler(handler)

MODIFY
setup.cfg
setup.cfg
@@ -39,7 +39,6 @@ install_requires =
numcodecs >= 0.9.0
fsspec[http] >= 2021.6.0
fsspec-reference-maker >= 0.0.4
- rich >= 10.16.1
mypy_extensions
[options.extras_require]

make rich optional for setup_logging