Collection of eclectic utils for python.
APACHE-2.0 License
Bot releases are visible (Hide)
Published by github-actions[bot] about 2 months ago
eapp
:
eapp.make_flags_parser()
epath
:
epy
:
epy.is_test
to check whether we're running in a test environment.epy.typing.Json
.epy.ExitStack
which allows setting the contextmanagers during init.epy.binary_adhoc
exm
:
exm.url_to_python_only_logs()
and exm.curr_job_name()
to addexm.current_experiment
crashPublished by github-actions[bot] 4 months ago
epath
:
Published by github-actions[bot] 5 months ago
epath
:
is_relative_to
for Python>=3.12.Published by github-actions[bot] 5 months ago
epy
:
epy.lazy_api_imports
to lazy-import __init__.py
symbols.epy.cached_property
epy.lazy_imports
: Error callback accept a str
to auto-re-raiseepy.lazy_imports()
with epy.binary_adhoc()
.ecolab
:
reload_workspace=True
to adhoc to auto-reload from workspaceecolab.get_permalink()
ecolab.inspect
not finding static files when the kernel containepath
:
importlib.resources.files
return MultiplexedPath
gs://
URI for 3.12.walk
3.12 error (topdown
-> top_down
rename)Published by github-actions[bot] 7 months ago
epy
:
epy.pretty_repr
: Add support for namedtupleecolab
:
ecolab.disp(obj)
;h
for syntax highlighting with auto-displayPublished by github-actions[bot] 8 months ago
epath
:
mode
to epath.Path.stat
output. Does not work for Windows nortf.io.gfile
is used..walk
to epath.Path
. Similar usage than pathlib.Path.walk
epy
:
epy.reverse_fstring
: Reverse fstring parsingreload=
for epy.binary_adhoc()
, fixed behavior forecolab.adhoc
epy.pprint
: Pretty print an object (including dataclass).epy.pretty_repr_top_level
epy.wraps_cls
equivalent of functools.wraps
but for classes.epy.lazy_imports(error_callback=)
has now signature(Exception) -> None
(instead of (str) -> None
)epy.pretty_repr
missing trailing ,
for tuple with singleecolab
:
ecolab.auto_display
: Better representation when line isadhoc
that delete sub-module when invalidate=False
adhoc
with reload_mode=UPDATE_INPLACE
now supports enums, so olda is FOO
adhoc
with reload_mode=UPDATE_INPLACE
is now much faster.cell_autoreload=True
the default reload_mode
isUPDATE_INPLACE
.exm
:
exm.set_citc_source()
to specify which workspace to use whenetree
:
is_leaf
kwarg to .map
and .parallel_map
enp
:
ArraySpec
support for flax.linen.summary
.Published by github-actions[bot] 10 months ago
ecolab
:
ecolab.inspect
ecolab.auto_display
:
;s
, ;a
, ;i
,;p
,...)ecolab.highlight_html
to escape HTML string.epy
:
epy.lazy_imports()
support adhoc imports (will re-create the originalecolab.adhoc
context when resolved)epy.binary_adhoc()
to add adhoc imports when using Pythonepy.lazy_imports()
supports error and success callbackserror_callback
/success_callback
).epy.pretty_repr
support attr
dataclass-like objects.exm
:
with xm.create_experiment()
Published by github-actions[bot] 12 months ago
ecolab
:
epath
:
Published by github-actions[bot] about 1 year ago
epath
:
glob
issue when used with ffspec.Published by github-actions[bot] about 1 year ago
ecolab
:
;
(assignments, returnepath
:
missing_ok=False
kwargs to path.rmtree
.fsspec_backend
relying on fsspec to handle GCS/S3 without needinggcsfs
and s3fs
become requiredtf_backend
for backward compatibility.path.glob
raise an error if insufficient permission.enp
:
ArraySpec.from_array
:
orbax
metadata supportepy
:
epy.pretty_repr
for pretty print an object (including dataclass).epy.diff_str
for pretty diff print of 2 objects.epy.is_namedtuple
etree
:
etree.map
for namedtuple
(Python backend)Published by github-actions[bot] about 1 year ago
lazy_imports
: More lazy importsepath
: Remove circular depsPublished by github-actions[bot] about 1 year ago
epy
:
@epy.lazy_imports
to lazyly import modules.@epy.frozen
when class has custom __getattr__
ecolab
:
ecolab.collapse()
widget=True
argument to (widget always enabled).
expanded: bool
kwargs to control whether the widget iskeep_proto
kwargs from clear_cached_modules
andimport_proto
kwargs from adhoc
(proto always supported)expanded
argument to ecolab.json()
and change default behaviorenp
:
etree.spec_like()
) hashable.enp.lazy.is_tf
returns True
for tf.TensorSpec
array_types.dtypes
and array_types.typing
(should useenp.dtypes
and enp.typing
instead).epath
:
owner
and group
to epath.Path.stat
output. Does not work fortf.io.gfile
is used.etree
:
etree.map
for collections.defaultdict
internal
:
unwrap_on_reload
to save/restore original function after aPublished by github-actions[bot] over 1 year ago
ecolab
:
widget=True
argument to ecolab.collapse()
for betterecolab.highlight_html(code)
to add syntax highlighting to celledc
:
contextvars
option: Fields annotated as edc.ContextVars[T]
arecontextvars.ContextVars
._: dataclasses.KW_ONLY
__repr__
now also pretty-print nested dataclasses, list, dict,...enp
:
ArraySpec
support grain.ArraySpec
(allow supportetree.spec_like(ds.element_spec)
on grain datasets)epy
:
epy.Lines.make_block
for custom pretty print classes, list,...Published by github-actions[bot] over 1 year ago
enp
:
etree.spec_like
support f32
,... annotations (when fully defined).etree
:
optree
backend.ecolab
:
ecolab.auto_inspect()
to allow inspecting all colab outputs.ecolab.inspect
issues (e.g. when used on metaclasses,...).ecolab.inspect
support for Jupyter notebook (non-Colab).Published by github-actions[bot] over 1 year ago
enp
:
torch==2.0
compatibility.pip install
(missing epath-no-tf
)Published by github-actions[bot] over 1 year ago
enp
:
torch
support!enp.lazy.LazyArray
to lazily checkisinstance(array, enp.lazy.LazyArray)
without triggering TF
,jax
,... importsskip=['jnp', ...]
kwarg to enp.testing.parametrize_xnp
toenp.compat
function to fix compatibility issues between Jax, TF,x.astype()
missing from torch
, but working injax
, tf
, np
).enp.linalg
to enp.compat
.enp.lazy.
methods for conversions from/to dtypeecolab
:
ecolab.inspect
for interactively inspect any Python objects.ecolab.json
for interactive expandable JSON display.ecolab.auto_plot_array
torch
ecolab.auto_plot_array(height=None)
mediapy
default options with show_images_kwargs
show_videos_kwargs
ecolab.interruptible
for graceful interruption of loops.lazy_imports
: unlock auto-complete,"xxx" is not definedPylancereportUndefinedVariable
).etree
:
from etils import etree
now expose the Python backend (etree.map
,...). Other backend are still available as previouslyetree.jax.map
,...)epy
:
epy.splitby
to split an iterator in 2, based on a predicate.small, big = epy.splitby([20, 1, 30, 1, 2], lambda x: x > 10)
)Published by github-actions[bot] almost 2 years ago
etree
:
etree.stack
to stack/batch multiple trees of arrays together.etils.etree.py
backend (pure Python implementation to avoidetree.map
(as convenience to access the correspondingmap_structure
).enp
:
enp.batch_dot
: Always dot product on the last axis withnp.dot
is inconsistent 1-D vs 2-D).enp.angle_between
to compute angle between 2 n-dimensionsenp.project_onto_vector
, enp.project_onto_plane
supportsTF
accidentally imported when using enp.linalg
functions.ecolab
:
ecolab.patch_graphviz
to fix Colab display with graphviz
.ecolab.set_verbose
to activate stderr logging on Colab.ecolab.clear_cached_modules
accept single str
ecolab.clear_cached_modules
has a invalidate=False
to notedc
:
edc.repr
, for functional use or directly assign class__repr__ = edc.repr
)eapp
:
eapp.better_logging()
do not raise is_borg
AttributeError
epath
:
local_path.copy('gs://')
uses the correct backend.Published by github-actions[bot] almost 2 years ago
eapp
(Added):
.make_flags_parser
to define CLI flags through dataclasses..better_logging
to display logs by default, tqdmepy
:
@epy.frozen
class decorator to make class immutableedc
:
@edc.dataclass
can be annotated with x: edc.AutoCast[T]
(for auto-normalization).ecolab
:
ecolab.clear_cached_modules
to reload modules (useful foretils.lazy_imports
supports multi-import (e.g. usingconcurrent
also trigger concurrent.futures
import).Published by github-actions[bot] about 2 years ago
epath
:
path.stat()
path.mkdir
.ecolab
:
from etils.lazy_imports import *
alias of from etils.ecolab.lazy_imports import *
.builtins
module for example.edc
:
.replace
only added once (not in subclasses).