etils - Eclectic Python Utilities
etils (eclectic utils) is an open-source collection of Python utilities designed for machine learning and scientific computing workflows. Each top-level submodule is self-contained and independent, prefixed by 'e' (e.g., `epath`, `epy`) to avoid name collisions. This modular design allows users to import only the necessary components, minimizing dependencies. The library is actively maintained, with frequent updates.
Warnings
- gotcha Etils is designed with independent submodules; importing `etils` directly does not expose all functionalities. Users must explicitly `from etils import <submodule>` (e.g., `from etils import epath`) to access specific utilities.
- breaking Many features are behind optional dependencies (extras). Installing only `pip install etils` will lead to `ModuleNotFoundError` if you attempt to use functionality from submodules like `epath` or `ejax` without installing `pip install etils[epath]` or similar.
- gotcha The return value format of `epath.Path.stat()` might not strictly match `pathlib.Path.stat()`. This can cause subtle incompatibilities or `AttributeError` if code expects specific attributes only present in `pathlib`'s `stat` result.
- deprecated Previous versions may have included or exposed certain utilities (e.g., `epy.cached_property`) that have since been removed or relocated, leading to `AttributeError` on upgrade.
- gotcha There's an open issue (#756) regarding `eapp.better_logging()` potentially causing double logging output. This can lead to redundant or confusing log messages in applications using `eapp`.
Install
-
pip install etils -
pip install etils[array_types,epath,epy,etree]
Imports
- epath
from etils import epath
- epy
from etils import epy
- etree
from etils import etree
- enp
from etils import enp
- ecolab
from etils import ecolab
- edc
from etils import edc
- eapp
from etils import eapp
- array_types
from etils import array_types
Quickstart
from etils import epath
# epath provides a pathlib-like API with cloud storage support (gs://, s3://)
# For local paths, it behaves like pathlib.Path
local_path = epath.Path("/tmp/etils_example.txt")
local_path.write_text("Hello from etils epath!")
print(f"File created at: {local_path}")
print(f"Content: {local_path.read_text()}")
# Clean up (optional)
local_path.unlink()