packg
Collection of utilities used in other python projects.
Features
caching
: Cache objects to disk (using joblib
) or to memoryconstclass.Const
: Base class for defining constants, as alternative to enum.Enum
debugging
: Connect to PyCharm debug serverdtime
: Wrappers and formatters for datetime
and other timing utilitieslog
: Wrapper for loguru
, utilities for stdlib logging
iotools
: Index paths, compress and read files, git utilities, wrappers to load json/yamlmagic
: Wrapper around importlib
maths
: Various small mathematical utilitiesmisc
:
format_exception(e)
outputs the exception as it appears in the stacktrace.suppress_stdout_stderr
context manager to suppress all output of a block of code.
multiproc
: Multiprocessing utilitiespackaging
: Code to handle creation and running of python packagespaths
: Load paths from the global environment or .env files using python-dotenv
stats
: Simple statistics utilitiesstrings
: Base64, quote strings, create random strings, create hashes of objectssystem
: Wrapper for subprocess.Popen
testing
: Import all modules from a package and other utilitiestqdmext
: Wrapper tqdm_max_ncols
that limits the width of a tqdm
progressbar by defaulttypext
: Type definitionsweb
: Download file and resume a partial download, disable web access
Install
Requires python>=3.8
pip install packg
Setup environment paths
python -m packg.cli.show_env
packg show_env
To override the defaults with your own values:
- Set the environment variables in your shell e.g. using .bashrc
- Create a file named
.env
in the root of your project as follows:
ENV_DATA_DIR=data
ENV_RESULT_DIR=results
ENV_ANNO_DIR=annotations
ENV_CODE_DIR=/home/${USER}/code
ENV_CACHE_DIR=/home/${USER}/.cache
Dev install
Clone repository and cd into, then:
pip install -e .
pip install pytest pytest-cov pylint
python -m pytest --cov
pylint packg
pylint tests