Skip to main content
Archived

This project has been archived by its maintainers, and is no longer receiving any updates.

GitHub tag (latest by date) PyPI - Module Version PyPI - License PyPI - Downloads

A library used in project Thoth. It’s aim is to provide core utilities for logger setup, manipulation with datetimes and similar handy helpers. Namely, you can find:

  • operations used for cluster object management (e.g. obtaining logs of pods)

  • operations used for scheduling workload using Argo Workflows

  • Thoth’s configuration abstraction used for serialization/deserialization of Thoth’s config file across all the components

  • application logging setup

  • manipulation with date and time

Installation

This project is released on PyPI, so the latest release can be installed via pip or Pipenv as shown below:

pipenv install thoth-common

This library will automatically discover installed packages and enable Sentry integrations if you use Flask, SQLAlchemy or AIOHTTP. An exception is for Flask applications, that need to explicitly install sentry-sdk[flask] due to integrations dependencies.

Logging setup

To setup a logger in any of Thoth’s component (component that are namespaced with thoth), you can simply set an environment variable. The name of environment variable is constructed from module name. Let’s say you want to debug thoth.adviser.pipeline module, in that case you can set environment variable THOTH_LOG_ADVISER_PIPELINE=DEBUG which will cause loggers thoth.adviser.pipeline to be set to DEBUG mode. See log-levels documentation for more info. If a module has underscore in its name, replace it with double underscore in the environment variable name.

To setup a logger that is not introduced by a Thoth’s component, you can set THOTH_ADJUST_LOGGING environment variable. The format of this environment variable THOTH_ADJUST_LOGGING is a comma separated list where each entry is made out of a logger name and a corresponding log-level (”DEBUG”, “INFO”, “WARNING”, “ERROR” as for standard Python’s logging). These two are delimited by a colon, an example:

THOTH_ADJUST_LOGGING="flask:WARNING,alembic.migrations:ERROR"

Structured logging

The library will automatically detect when it is running inside an OpenShift cluster (based on STI_SCRIPTS_PATH environment variable that is inserted into the container if build the container was built in an OpenShift cluster), In such case, the library will setup structured logging suitable for automated logs aggregation (e.g. automated logs aggregation using the ELK stack). This behavior can be suppressed by setting environment variable THOTH_LOGGING_NO_JSON=1.

Ignoring reports from a logger

In some cases it’s expected to turn off reporting of some logger to Sentry. You can provide THOTH_SENTRY_IGNORE_LOGGER environment variable which holds a comma separated list of loggers that should be ignored when reporting errors to Sentry:

THOTH_SENTRY_IGNORE_LOGGER="thoth.adviser.resolver,thoth.adviser.run"

This is helpful if you want to report errors to users but not to Thoth application itself.

If you want some certain classes of error not to be reported to Sentry, you can can provide THOTH_SENTRY_IGNORE_EXCEPTION environment variable which holds a comma-separated list of exception classes to be ignored when reporting to Sentry:

THOTH_SENTRY_IGNORE_EXCEPTION="connexion.decorators.validation,builtins.ValueError"

Remember all builtin exception classes need to be specified as in the same manner as ValueError is specified above.

Release files for thoth-common 0.36.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for thoth-common 0.36.6
File Size Uploaded
thoth-common-0.36.6.tar.gz 124.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for thoth-common 0.36.6
File Interpreter ABI Platform
thoth_common-0.36.6-py3-none-any.whl Python 3 none any Details

Total release size: 176.4 kB

Release files / thoth-common-0.36.6.tar.gz

Download URL thoth-common-0.36.6.tar.gz
Size 124.3 kB
Tags Source
SHA-256 checksum
How to use checksums
8591433a16046722e475dff35b63b711f6578566057191357b55b44ad4ed3c57
BLAKE2b-256 checksum
How to use checksums
aeef90b54b7210b22190596b54b55ad22322460b0c0dbbf8733e44c18b30d8ae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.8

Release files / thoth_common-0.36.6-py3-none-any.whl

Download URL thoth_common-0.36.6-py3-none-any.whl
Size 52.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ff512cacdc3a537464d7818c32fde97049b7084a21c318c4b220a715f7d02dc3
BLAKE2b-256 checksum
How to use checksums
ebc73ba5304293c47eaec9c971fb0bd52567cf7b551094571f63716869699074
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.8

Release history Release notifications | RSS feed

This release

0.36.6 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page