Skip to main content

Useful utilities for python and datascience

Reason this release was yanked:

Uninstallable package

Project description

Antho Utils

Description

This package is a collection of useful helpers that I regularly use in my projects. It uses a single lightweight dependency: PyYAML. I made a public package because I think it might be helpful to others as well. The following presents a short description of each module.

Color

A zero dependencies api to add color to the terminal. It supports 256 colors and 24-bit colors (True color). It is also possible to theme the colors, so you can use consistent colors in your project. It includes a traceback formatting tool that automatically add colors to the traceback, in order to make it easier and quicker to read. (I use this function in all of my projects)

ConfigFile

A simple api to load and parse configuration files. It supports YAML files. You can verify the configuration format with a template with a single parameter. This can be helpful when you have a long task, such as training a neural network, and you access some keys in the config later. You do not want your long task to crash after few hours or even days because you have the wrong type on a missing key in your config.

It also supports different Profiles, so the same configuration file can be used on different machines or for different , but analogous, tasks. For example, if I want a to run my script locally for quicker developpement, but I train on a HPC server, I do not want to make two configurations files that are almost identical, I can simply create two profiles in the same configuration file with different paths or values, and use the appropriate profile depending on the machine.

Logger

A simple wrapper of the python logging api. It adds colored formatters out of the box, and is easy to configure. It also reduce the number of lines of code needed to log.

from pyutils import logger

logger.debug("My debug message")
logger.info("My info message")
logger.warning("My warning message")
logger.error("My error message")
logger.critical("My critical message")

Progress

This module has a similar function - and usage synthax - to tqdm. However, I believe it is more customizable than tqdm, and more suitable for deep learning progress bar. It also implements out of the box three different types of progress bars: a tqdm-like, a deep-learning one (keras-like) and a pip-like progress bar. It is also possible, and easy to create your own progress bar. Let's look at an example:

# tqdm-like
for i in progress(range(100)):
    time.sleep(0.1)
# keras-like, it will report the loss value in the progress bar in real-time
for bar, batch in progress(dataloader, type="dl").ref():
    time.sleep(0.1)
    bar.repport(loss=...)
# pip-like
for i in progress(range(100), type="pip"):
    time.sleep(0.1)

Installation

It is as easy to install as:

pip install antho-utils

Usage

For a basic usage, you can import everything from the package:

from pyutils import *

or, you can also import the desired tools/modules:

from pyutils.color import Colors, ResetColor, TraceBackColor, ConfigFile, Logger, LoggerType, progress, prange

For a more detailed usage, or to see how you can configure/customize each tool, see the documentation of each module.

Documentation

You can go take a look at the docs folder to see the documentation of each module.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

antho_utils-0.2.0.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

antho_utils-0.2.0-py3-none-any.whl (2.9 kB view details)

Uploaded Python 3

File details

Details for the file antho_utils-0.2.0.tar.gz.

File metadata

  • Download URL: antho_utils-0.2.0.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.22

File hashes

Hashes for antho_utils-0.2.0.tar.gz
Algorithm Hash digest
SHA256 609cd3ed50cf7ce7826cf76e5971101c633d09841942b490a87ef94fbd15384c
MD5 087384707e9c1c48a3412705caf62553
BLAKE2b-256 9f33e2c7367e0d3fd02cfa30674d34e82b2bb0a98fd8294b50f21797368fb83a

See more details on using hashes here.

File details

Details for the file antho_utils-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for antho_utils-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e7419c2a4ad0f99d674d0617f1698f9a426652db141c18afd72558bf3b3f6d83
MD5 1b1633ccad33d7f122660fe09827e1b0
BLAKE2b-256 234755c6f2fdd704f4981e988f0dfc2e9fd6a5a5bbb8ebe453a21c752b857d70

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page